@renderinc/sdk 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -22
- package/dist/experimental/experimental.d.ts +6 -2
- package/dist/experimental/experimental.d.ts.map +1 -1
- package/dist/experimental/experimental.js +9 -3
- package/dist/experimental/index.d.ts +2 -2
- package/dist/experimental/index.d.ts.map +1 -1
- package/dist/experimental/index.js +6 -5
- package/dist/experimental/object/api.d.ts +12 -0
- package/dist/experimental/object/api.d.ts.map +1 -0
- package/dist/experimental/object/api.js +61 -0
- package/dist/experimental/object/client.d.ts +23 -0
- package/dist/experimental/object/client.d.ts.map +1 -0
- package/dist/experimental/object/client.js +168 -0
- package/dist/experimental/object/index.d.ts +5 -0
- package/dist/experimental/object/index.d.ts.map +1 -0
- package/dist/experimental/object/index.js +8 -0
- package/dist/experimental/object/types.d.ts +66 -0
- package/dist/experimental/object/types.d.ts.map +1 -0
- package/dist/generated/schema.d.ts +289 -22
- package/dist/generated/schema.d.ts.map +1 -1
- package/dist/workflows/uds.d.ts.map +1 -1
- package/dist/workflows/uds.js +27 -51
- package/package.json +12 -8
- package/CHANGELOG.md +0 -26
- package/biome.json +0 -84
- package/dist/workflows/client/errors.d.ts +0 -25
- package/dist/workflows/client/errors.d.ts.map +0 -1
- package/dist/workflows/client/errors.js +0 -56
- package/dist/workflows/client/schema.d.ts +0 -9322
- package/dist/workflows/client/schema.d.ts.map +0 -1
- package/dist/workflows/client/workflows.d.ts +0 -15
- package/dist/workflows/client/workflows.d.ts.map +0 -1
- package/dist/workflows/client/workflows.js +0 -63
- package/examples/client/main.ts +0 -42
- package/examples/client/package-lock.json +0 -601
- package/examples/client/package.json +0 -16
- package/examples/client/tsconfig.json +0 -17
- package/examples/task/main.ts +0 -90
- package/examples/task/package-lock.json +0 -585
- package/examples/task/package.json +0 -16
- package/examples/task/tsconfig.json +0 -17
- package/src/errors.ts +0 -73
- package/src/experimental/blob/api.ts +0 -91
- package/src/experimental/blob/client.ts +0 -317
- package/src/experimental/blob/index.ts +0 -22
- package/src/experimental/blob/types.ts +0 -131
- package/src/experimental/experimental.ts +0 -33
- package/src/experimental/index.ts +0 -24
- package/src/generated/schema.ts +0 -12729
- package/src/index.ts +0 -7
- package/src/render.ts +0 -35
- package/src/utils/create-api-client.ts +0 -13
- package/src/utils/get-base-url.ts +0 -16
- package/src/version.ts +0 -37
- package/src/workflows/client/client.ts +0 -142
- package/src/workflows/client/create-client.ts +0 -17
- package/src/workflows/client/index.ts +0 -3
- package/src/workflows/client/sse.ts +0 -95
- package/src/workflows/client/types.ts +0 -56
- package/src/workflows/executor.ts +0 -124
- package/src/workflows/index.ts +0 -7
- package/src/workflows/registry.test.ts +0 -76
- package/src/workflows/registry.ts +0 -88
- package/src/workflows/runner.ts +0 -38
- package/src/workflows/schema.ts +0 -348
- package/src/workflows/task.ts +0 -117
- package/src/workflows/types.ts +0 -89
- package/src/workflows/uds.ts +0 -179
- package/test-types.ts +0 -14
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -23
- package/vite.config.ts +0 -7
- /package/dist/{workflows/client/schema.js → experimental/object/types.js} +0 -0
package/src/workflows/uds.ts
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { createConnection } from "node:net";
|
|
2
|
-
import { getUserAgent } from "../version.js";
|
|
3
|
-
|
|
4
|
-
const CONTENT_LENGTH_REGEX = /Content-Length:\s*(\d+)/i;
|
|
5
|
-
|
|
6
|
-
import type {
|
|
7
|
-
CallbackRequest,
|
|
8
|
-
GetInputResponse,
|
|
9
|
-
GetSubtaskResultRequest,
|
|
10
|
-
GetSubtaskResultResponse,
|
|
11
|
-
RegisterTasksRequest,
|
|
12
|
-
RunSubtaskRequest,
|
|
13
|
-
RunSubtaskResponse,
|
|
14
|
-
TaskMetadata,
|
|
15
|
-
} from "./types.js";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Unix Domain Socket client for communicating with the workflow system
|
|
19
|
-
*/
|
|
20
|
-
export class UDSClient {
|
|
21
|
-
constructor(private readonly socketPath: string) {}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Get task input and name
|
|
25
|
-
*/
|
|
26
|
-
async getInput(): Promise<GetInputResponse> {
|
|
27
|
-
return this.request<GetInputResponse>("/input", "GET");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
private buildCallbackBody(results?: any, error?: string): CallbackRequest {
|
|
31
|
-
if (results !== undefined) {
|
|
32
|
-
const resultsArray = [results];
|
|
33
|
-
const output = Buffer.from(JSON.stringify(resultsArray)).toString("base64");
|
|
34
|
-
return {
|
|
35
|
-
complete: {
|
|
36
|
-
output,
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (error === undefined) {
|
|
42
|
-
throw new Error("Either results or error must be provided");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
error: {
|
|
47
|
-
details: error,
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Send task result or error
|
|
54
|
-
*/
|
|
55
|
-
async sendCallback(results?: any, error?: string): Promise<void> {
|
|
56
|
-
await this.request<void>("/callback", "POST", this.buildCallbackBody(results, error));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Run a subtask
|
|
61
|
-
*/
|
|
62
|
-
async runSubtask(taskName: string, input: any[]): Promise<string> {
|
|
63
|
-
const inputBase64 = Buffer.from(JSON.stringify(input)).toString("base64");
|
|
64
|
-
const body: RunSubtaskRequest = {
|
|
65
|
-
task_name: taskName,
|
|
66
|
-
input: inputBase64,
|
|
67
|
-
};
|
|
68
|
-
const response = await this.request<RunSubtaskResponse>("/run-subtask", "POST", body);
|
|
69
|
-
return response.task_run_id;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Get subtask result
|
|
74
|
-
*/
|
|
75
|
-
async getSubtaskResult(subtaskId: string): Promise<GetSubtaskResultResponse> {
|
|
76
|
-
const body: GetSubtaskResultRequest = {
|
|
77
|
-
task_run_id: subtaskId,
|
|
78
|
-
};
|
|
79
|
-
return this.request<GetSubtaskResultResponse>("/get-subtask-result", "POST", body);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Register tasks with the workflow system
|
|
84
|
-
*/
|
|
85
|
-
async registerTasks(tasks: TaskMetadata[]): Promise<void> {
|
|
86
|
-
const body: RegisterTasksRequest = {
|
|
87
|
-
tasks: tasks.map((task) => ({
|
|
88
|
-
name: task.name,
|
|
89
|
-
options: task.options,
|
|
90
|
-
})),
|
|
91
|
-
};
|
|
92
|
-
await this.request<void>("/register-tasks", "POST", body);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Make a request to the Unix socket
|
|
97
|
-
*/
|
|
98
|
-
private async request<T>(path: string, method: string, body?: any): Promise<T> {
|
|
99
|
-
return new Promise((resolve, reject) => {
|
|
100
|
-
const client = createConnection({ path: this.socketPath }, () => {
|
|
101
|
-
const bodyStr = body ? JSON.stringify(body) : "";
|
|
102
|
-
const userAgent = getUserAgent();
|
|
103
|
-
const request = `${method} ${path} HTTP/1.1\r\nHost: unix\r\nContent-Length: ${bodyStr.length}\r\nContent-Type: application/json\r\nUser-Agent: ${userAgent}\r\n\r\n${bodyStr}`;
|
|
104
|
-
client.write(request);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
let data = "";
|
|
108
|
-
let contentLength: number | null = null;
|
|
109
|
-
let headersParsed = false;
|
|
110
|
-
let bodyStartIndex = -1;
|
|
111
|
-
|
|
112
|
-
client.on("data", (chunk) => {
|
|
113
|
-
data += chunk.toString();
|
|
114
|
-
|
|
115
|
-
// Check if we have received the full response
|
|
116
|
-
if (!headersParsed) {
|
|
117
|
-
const headerEndIndex = data.indexOf("\r\n\r\n");
|
|
118
|
-
if (headerEndIndex !== -1) {
|
|
119
|
-
headersParsed = true;
|
|
120
|
-
bodyStartIndex = headerEndIndex + 4;
|
|
121
|
-
|
|
122
|
-
// Parse Content-Length header
|
|
123
|
-
const headers = data.substring(0, headerEndIndex);
|
|
124
|
-
const contentLengthMatch = headers.match(CONTENT_LENGTH_REGEX);
|
|
125
|
-
if (contentLengthMatch) {
|
|
126
|
-
contentLength = Number.parseInt(contentLengthMatch[1], 10);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Check if we have received the complete body
|
|
132
|
-
if (headersParsed && contentLength !== null) {
|
|
133
|
-
const bodyReceived = data.length - bodyStartIndex;
|
|
134
|
-
if (bodyReceived >= contentLength) {
|
|
135
|
-
// We have the complete response, close the connection
|
|
136
|
-
client.end();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
client.on("end", () => {
|
|
142
|
-
try {
|
|
143
|
-
// Parse HTTP response
|
|
144
|
-
const lines = data.split("\r\n");
|
|
145
|
-
const statusLine = lines[0];
|
|
146
|
-
const statusCode = Number.parseInt(statusLine.split(" ")[1], 10);
|
|
147
|
-
|
|
148
|
-
if (statusCode >= 400) {
|
|
149
|
-
reject(new Error(`HTTP ${statusCode}: ${data}`));
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Find empty line (separates headers from body)
|
|
154
|
-
const emptyLineIndex = lines.indexOf("");
|
|
155
|
-
if (emptyLineIndex === -1) {
|
|
156
|
-
resolve(undefined as T);
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const bodyLines = lines.slice(emptyLineIndex + 1);
|
|
161
|
-
const responseBody = bodyLines.join("\r\n").trim();
|
|
162
|
-
|
|
163
|
-
if (!responseBody) {
|
|
164
|
-
resolve(undefined as T);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
resolve(JSON.parse(responseBody));
|
|
169
|
-
} catch (error) {
|
|
170
|
-
reject(error);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
client.on("error", (error) => {
|
|
175
|
-
reject(error);
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
}
|
package/test-types.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Render } from "./src";
|
|
2
|
-
|
|
3
|
-
export async function test() {
|
|
4
|
-
const render = new Render({
|
|
5
|
-
baseUrl: "https://api.localhost.render.com:8443",
|
|
6
|
-
token: "test",
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
const taskRun = await render.workflows.runTask("workflow-sdk/greet", ["Ruben"]);
|
|
10
|
-
|
|
11
|
-
// This should show the type
|
|
12
|
-
const taskRunType = typeof taskRun;
|
|
13
|
-
console.log(taskRunType);
|
|
14
|
-
}
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"lib": ["ES2020"],
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"outDir": "./dist",
|
|
9
|
-
"rootDir": "./src",
|
|
10
|
-
"removeComments": true,
|
|
11
|
-
"strict": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"forceConsistentCasingInFileNames": true,
|
|
15
|
-
"moduleResolution": "NodeNext",
|
|
16
|
-
"resolveJsonModule": true,
|
|
17
|
-
"experimentalDecorators": true,
|
|
18
|
-
"emitDecoratorMetadata": true,
|
|
19
|
-
"types": ["vitest/globals"]
|
|
20
|
-
},
|
|
21
|
-
"include": ["src/**/*"],
|
|
22
|
-
"exclude": ["node_modules", "dist"]
|
|
23
|
-
}
|
package/vite.config.ts
DELETED
|
File without changes
|