@deepraxis/sdk 0.1.1-dev.ea219e1 → 0.1.1-dev.ea3ec5c
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/METHODS.md +1562 -198
- package/README.md +4 -4
- package/dist/automation.d.ts +54 -0
- package/dist/core/binary-operations.d.ts +3 -0
- package/dist/core/binary-operations.js +14 -0
- package/dist/core/client.d.ts +7 -1
- package/dist/core/client.js +3 -0
- package/dist/core/credentials.d.ts +22 -3
- package/dist/core/credentials.js +44 -5
- package/dist/core/errors.d.ts +6 -0
- package/dist/core/errors.js +8 -0
- package/dist/core/transport.d.ts +10 -1
- package/dist/core/transport.js +20 -5
- package/dist/generated/binary-operations.gen.d.ts +3 -0
- package/dist/generated/binary-operations.gen.js +14 -0
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.js +1 -1
- package/dist/generated/sdk.gen.d.ts +3087 -338
- package/dist/generated/sdk.gen.js +9993 -2071
- package/dist/generated/types.gen.d.ts +95082 -47430
- package/dist/helpers/application-publish.js +16 -2
- package/dist/helpers/browser-actions.d.ts +102 -0
- package/dist/helpers/browser-actions.js +146 -0
- package/dist/helpers/browser-connect-error.d.ts +28 -0
- package/dist/helpers/browser-connect-error.js +74 -0
- package/dist/helpers/browser-connect.d.ts +33 -2
- package/dist/helpers/browser-connect.js +238 -25
- package/dist/helpers/browser-decisions.d.ts +44 -0
- package/dist/helpers/browser-decisions.js +53 -0
- package/dist/helpers/browser-documentation.d.ts +1 -1
- package/dist/helpers/browser-documentation.js +20 -11
- package/dist/helpers/sandbox-templates.d.ts +121 -0
- package/dist/helpers/sandbox-templates.js +60 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/operations.generated.d.ts +36 -13529
- package/dist/operations.generated.js +20985 -5137
- package/dist/resources.generated.d.ts +2962 -223
- package/dist/resources.generated.js +843 -13
- package/package.json +2 -2
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { sleep } from "../core/retry.js";
|
|
2
|
+
export class SandboxTemplateBuildError extends Error {
|
|
3
|
+
templateID;
|
|
4
|
+
buildID;
|
|
5
|
+
reason;
|
|
6
|
+
logEntries;
|
|
7
|
+
name = 'SandboxTemplateBuildError';
|
|
8
|
+
constructor(templateID, buildID, reason, logEntries) {
|
|
9
|
+
super(`Template build failed: ${reason?.message ?? 'Unknown build error'}${logEntries.length ? `\n${logEntries.map(log => log.message).join('\n')}` : ''}`);
|
|
10
|
+
this.templateID = templateID;
|
|
11
|
+
this.buildID = buildID;
|
|
12
|
+
this.reason = reason;
|
|
13
|
+
this.logEntries = logEntries;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** Build an organization-local template and wait until it is ready, streaming logs in order.
|
|
17
|
+
* Uses create, source submission and status polling. COPY is unavailable; use RUN curl or git clone.
|
|
18
|
+
* fromTemplate accepts official catalog names only. Abort stops the client; it does not cancel the build.
|
|
19
|
+
* Terminal errors include the provider reason and the final twenty bounded log entries.
|
|
20
|
+
*/
|
|
21
|
+
export async function buildSandboxTemplate(client, input) {
|
|
22
|
+
const signal = input.signal ?? new AbortController().signal;
|
|
23
|
+
signal.throwIfAborted();
|
|
24
|
+
const interval = input.pollIntervalMs ?? 1000;
|
|
25
|
+
if (!Number.isSafeInteger(interval) || interval < 0)
|
|
26
|
+
throw new RangeError('pollIntervalMs must be a nonnegative integer');
|
|
27
|
+
if ([input.dockerfile, input.fromTemplate, input.fromImage].filter(value => value !== undefined).length !== 1
|
|
28
|
+
|| (input.dockerfile !== undefined && input.steps !== undefined))
|
|
29
|
+
throw new TypeError('Supply dockerfile, fromTemplate or fromImage; dockerfile cannot include steps');
|
|
30
|
+
const created = await client.sandbox.templates.create({ body: {
|
|
31
|
+
name: input.name, cpuCount: input.cpuCount, memoryMB: input.memoryMB, diskGb: input.diskGb, tags: input.tags,
|
|
32
|
+
}, signal });
|
|
33
|
+
const path = { templateID: created.templateID, buildID: created.buildID };
|
|
34
|
+
await client.sandbox.templates.builds.update({ path, body: input.dockerfile !== undefined ? { dockerfile: input.dockerfile }
|
|
35
|
+
: { fromTemplate: input.fromTemplate, fromImage: input.fromImage, steps: input.steps }, signal });
|
|
36
|
+
let logsOffset = 0;
|
|
37
|
+
const tail = [];
|
|
38
|
+
let terminal;
|
|
39
|
+
while (true) {
|
|
40
|
+
signal.throwIfAborted();
|
|
41
|
+
const result = await client.sandbox.templates.builds.status.list({ path, query: { logsOffset }, signal });
|
|
42
|
+
for (const entry of result.logEntries) {
|
|
43
|
+
signal.throwIfAborted();
|
|
44
|
+
await input.onLog?.(entry);
|
|
45
|
+
// Bound retained diagnostics even when one provider log message is enormous.
|
|
46
|
+
tail.push({ ...entry, message: entry.message.slice(-4096) });
|
|
47
|
+
if (tail.length > 20)
|
|
48
|
+
tail.shift();
|
|
49
|
+
}
|
|
50
|
+
logsOffset += result.logEntries.length;
|
|
51
|
+
if (!terminal && (result.status === 'ready' || result.status === 'error'))
|
|
52
|
+
terminal = result;
|
|
53
|
+
if (terminal && result.logEntries.length === 0) {
|
|
54
|
+
if (terminal.status === 'error')
|
|
55
|
+
throw new SandboxTemplateBuildError(path.templateID, path.buildID, terminal.reason, tail);
|
|
56
|
+
return { ...terminal, status: 'ready', logEntries: [] };
|
|
57
|
+
}
|
|
58
|
+
await sleep(interval, signal);
|
|
59
|
+
}
|
|
60
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,3 +15,5 @@ export { uploadFile } from './helpers/file-upload.js';
|
|
|
15
15
|
export type { UploadFileOptions, UploadedFile } from './helpers/file-upload.js';
|
|
16
16
|
export { connectBrowser } from './helpers/browser-connect.js';
|
|
17
17
|
export type { PraxisBrowser, BrowserTab, BrowserConnectOptions } from './helpers/browser-connect.js';
|
|
18
|
+
export { buildSandboxTemplate, SandboxTemplateBuildError } from './helpers/sandbox-templates.js';
|
|
19
|
+
export type { SandboxTemplateBuildInput, SandboxTemplateBuildResult, TemplateBuildLog, TemplateBuildReason } from './helpers/sandbox-templates.js';
|
package/dist/index.js
CHANGED
|
@@ -7,3 +7,4 @@ export { publishInputFromBuild } from "./helpers/application-build.js";
|
|
|
7
7
|
export { count } from "./helpers/database-count.js";
|
|
8
8
|
export { uploadFile } from "./helpers/file-upload.js";
|
|
9
9
|
export { connectBrowser } from "./helpers/browser-connect.js";
|
|
10
|
+
export { buildSandboxTemplate, SandboxTemplateBuildError } from "./helpers/sandbox-templates.js";
|