Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "33.0"
version: "33.4"

- name: Generate Protobuf Files
run: npm run protoc-gen
Expand Down
631 changes: 313 additions & 318 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@crossplane-org/function-sdk-typescript",
"version": "0.3.1",
"version": "0.4.0",
"description": "A Crossplane Function SDK for Typescript",
"keywords": [
"crossplane",
Expand Down Expand Up @@ -58,7 +58,7 @@
"prettier": "^3.7.4",
"ts-node": "^10.9.2",
"typescript": "^5.9.3",
"typescript-eslint": "^8.52.0",
"typescript-eslint": "^8.56.1",
"vitest": "^4.0.16"
}
}
4 changes: 2 additions & 2 deletions src/proto/google/protobuf/duration.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 32 additions & 8 deletions src/proto/google/protobuf/struct.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 54 additions & 6 deletions src/proto/run_function.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 9 additions & 23 deletions src/resource/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ export function newDesiredComposed(): DesiredComposed {
* @param struct - The protobuf Struct to convert
* @returns A plain JavaScript object representing the Kubernetes resource
*/
export function asObject(
struct: Record<string, unknown> | undefined,
): Record<string, unknown> {
export function asObject(struct: Record<string, unknown> | undefined): Record<string, unknown> {
if (!struct) {
return {};
}
Expand All @@ -75,9 +73,7 @@ export function asObject(
* @param obj - The plain JavaScript object to convert
* @returns A protobuf Struct representation
*/
export function asStruct(
obj: Record<string, unknown>,
): Record<string, unknown> {
export function asStruct(obj: Record<string, unknown>): Record<string, unknown> {
// In our TypeScript implementation, this is essentially a pass-through
// The actual conversion happens in the protobuf serialization layer
return obj;
Expand All @@ -96,16 +92,14 @@ export function asStruct(
* @returns A Struct representation
* @throws Error if conversion fails
*/
export function mustStructObject(
obj: Record<string, unknown>,
): Record<string, unknown> {
export function mustStructObject(obj: Record<string, unknown>): Record<string, unknown> {
try {
return asStruct(obj);
} catch (error) {
throw new Error(
`Failed to convert object to struct: ${
error instanceof Error ? error.message : String(error)
}`,
}`
);
}
}
Expand All @@ -129,9 +123,7 @@ export function mustStructJSON(json: string): Record<string, unknown> {
return asStruct(obj);
} catch (error) {
throw new Error(
`Failed to parse JSON to struct: ${
error instanceof Error ? error.message : String(error)
}`,
`Failed to parse JSON to struct: ${error instanceof Error ? error.message : String(error)}`
);
}
}
Expand All @@ -148,7 +140,7 @@ export function mustStructJSON(json: string): Record<string, unknown> {
export function fromObject(
obj: Record<string, unknown>,
connectionDetails?: ConnectionDetails,
ready?: Ready,
ready?: Ready
): Resource {
return Resource.fromJSON({
resource: obj,
Expand All @@ -164,9 +156,7 @@ export function fromObject(
* @param resource - The Resource to extract from
* @returns The plain JavaScript object, or undefined if not present
*/
export function toObject(
resource: Resource,
): Record<string, unknown> | undefined {
export function toObject(resource: Resource): Record<string, unknown> | undefined {
return resource.resource;
}

Expand Down Expand Up @@ -198,11 +188,7 @@ export function toObject(
export function fromModel<T extends Record<string, unknown>>(
obj: { toJSON: () => T },
connectionDetails?: ConnectionDetails,
ready?: Ready,
ready?: Ready
): Resource {
return fromObject(
obj.toJSON() as Record<string, unknown>,
connectionDetails,
ready,
);
return fromObject(obj.toJSON() as Record<string, unknown>, connectionDetails, ready);
}