@deepraxis/sdk 0.1.1-dev.f0ef747 → 0.1.1-dev.f23829c
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 +412 -1
- package/README.md +3 -3
- package/dist/automation.d.ts +61 -0
- package/dist/core/client.d.ts +7 -1
- package/dist/core/client.js +3 -0
- package/dist/core/transport.d.ts +9 -0
- package/dist/core/transport.js +13 -2
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.js +1 -1
- package/dist/generated/sdk.gen.d.ts +987 -62
- package/dist/generated/sdk.gen.js +3074 -523
- package/dist/generated/types.gen.d.ts +50386 -35608
- package/dist/helpers/application-build.d.ts +10 -0
- package/dist/helpers/application-build.js +98 -0
- package/dist/helpers/application-publish.d.ts +8 -0
- package/dist/helpers/application-publish.js +26 -9
- package/dist/helpers/browser-decisions.d.ts +2 -0
- package/dist/helpers/browser-decisions.js +14 -1
- package/dist/helpers/file-upload.d.ts +2 -2
- package/dist/helpers/sandbox-templates.d.ts +121 -0
- package/dist/helpers/sandbox-templates.js +60 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/operations.generated.d.ts +6068 -2195
- package/dist/operations.generated.js +8228 -3410
- package/dist/resources.generated.d.ts +536 -40
- package/dist/resources.generated.js +252 -1
- package/package.json +2 -2
package/dist/core/client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SandboxTemplateBuildInput, type SandboxTemplateBuildResult } from "../helpers/sandbox-templates.js";
|
|
1
2
|
import { type UploadFileOptions, type UploadedFile } from '../helpers/file-upload.js';
|
|
2
3
|
import { resourceFactories } from '../resources.generated.js';
|
|
3
4
|
import { type PraxisOptions } from './transport.js';
|
|
@@ -7,7 +8,12 @@ import { type CountInput, type CountResult } from '../helpers/database-count.js'
|
|
|
7
8
|
type Resources = {
|
|
8
9
|
readonly [K in keyof typeof resourceFactories]: ReturnType<(typeof resourceFactories)[K]>;
|
|
9
10
|
};
|
|
10
|
-
export interface Praxis extends Omit<Resources, 'application' | 'browser' | 'database' | 'file'> {
|
|
11
|
+
export interface Praxis extends Omit<Resources, 'application' | 'browser' | 'database' | 'file' | 'sandbox'> {
|
|
12
|
+
readonly sandbox: Omit<Resources['sandbox'], 'templates'> & {
|
|
13
|
+
templates: Resources['sandbox']['templates'] & {
|
|
14
|
+
build(input: SandboxTemplateBuildInput): Promise<SandboxTemplateBuildResult>;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
11
17
|
readonly browser: Resources['browser'] & {
|
|
12
18
|
connect(options?: BrowserConnectOptions): Promise<PraxisBrowser>;
|
|
13
19
|
};
|
package/dist/core/client.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildSandboxTemplate } from "../helpers/sandbox-templates.js";
|
|
1
2
|
import { uploadFile } from "../helpers/file-upload.js";
|
|
2
3
|
import { resourceFactories } from "../resources.generated.js";
|
|
3
4
|
import { Transport } from "./transport.js";
|
|
@@ -10,6 +11,8 @@ export class Praxis {
|
|
|
10
11
|
for (const [name, create] of Object.entries(resourceFactories)) {
|
|
11
12
|
const resource = create(transport);
|
|
12
13
|
// Assemble before sealing the resource property; never replace a readonly SDK resource.
|
|
14
|
+
if (name === 'sandbox')
|
|
15
|
+
Object.assign(resource.templates, { build: (input) => buildSandboxTemplate(this, input) });
|
|
13
16
|
if (name === 'file')
|
|
14
17
|
Object.assign(resource, { uploadFile: (file, options) => uploadFile(this, file, options) });
|
|
15
18
|
if (name === 'database')
|
package/dist/core/transport.d.ts
CHANGED
|
@@ -25,6 +25,15 @@ type InternalOptions = RequestOptions & {
|
|
|
25
25
|
query?: unknown;
|
|
26
26
|
lastEventId?: string;
|
|
27
27
|
};
|
|
28
|
+
/** Margin over a server-side execution deadline: the response still has to travel back after it. */
|
|
29
|
+
export declare const SERVER_DEADLINE_MARGIN_MS = 30000;
|
|
30
|
+
/**
|
|
31
|
+
* A request body that carries its own execution deadline (`timeoutMs`, as in sandbox commands.run) is
|
|
32
|
+
* waited for at least that long plus a margin, so the client never gives up before the server answers.
|
|
33
|
+
*/
|
|
34
|
+
export declare function serverDeadlineMs(options: {
|
|
35
|
+
body?: unknown;
|
|
36
|
+
}): number;
|
|
28
37
|
export declare class Transport {
|
|
29
38
|
private readonly config;
|
|
30
39
|
constructor(options: PraxisOptions);
|
package/dist/core/transport.js
CHANGED
|
@@ -32,10 +32,21 @@ function assertKnownOptions(options) {
|
|
|
32
32
|
detail: `Unrecognised option ${stray.length > 1 ? 'keys' : 'key'} ${names}. Request parameters are not flat: put each under \`query\` (GET/DELETE: filters, pagination), \`path\` (URL segments) or \`body\` (POST/PATCH/PUT payload), e.g. call({ query: { ${stray[0]} } }) or call({ body: { ${stray[0]} } }). Common top-level keys: path, query, body, headers, signal, timeoutMs, maxRetries.`,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
+
/** Margin over a server-side execution deadline: the response still has to travel back after it. */
|
|
36
|
+
export const SERVER_DEADLINE_MARGIN_MS = 30_000;
|
|
37
|
+
/**
|
|
38
|
+
* A request body that carries its own execution deadline (`timeoutMs`, as in sandbox commands.run) is
|
|
39
|
+
* waited for at least that long plus a margin, so the client never gives up before the server answers.
|
|
40
|
+
*/
|
|
41
|
+
export function serverDeadlineMs(options) {
|
|
42
|
+
const body = options.body;
|
|
43
|
+
const deadline = body && typeof body === 'object' ? body.timeoutMs : undefined;
|
|
44
|
+
return typeof deadline === 'number' && Number.isFinite(deadline) && deadline > 0 ? deadline + SERVER_DEADLINE_MARGIN_MS : 0;
|
|
45
|
+
}
|
|
35
46
|
export class Transport {
|
|
36
47
|
config;
|
|
37
48
|
constructor(options) {
|
|
38
|
-
this.config = { timeoutMs:
|
|
49
|
+
this.config = { timeoutMs: 600_000, maxRetries: 2, fetch: globalThis.fetch, ...options };
|
|
39
50
|
this.validate(this.config.timeoutMs, this.config.maxRetries);
|
|
40
51
|
}
|
|
41
52
|
validate(timeout, retries) {
|
|
@@ -46,7 +57,7 @@ export class Transport {
|
|
|
46
57
|
}
|
|
47
58
|
scope(options, streaming) {
|
|
48
59
|
assertKnownOptions(options);
|
|
49
|
-
const timeoutMs = options.timeoutMs ?? this.config.timeoutMs;
|
|
60
|
+
const timeoutMs = options.timeoutMs ?? Math.max(this.config.timeoutMs, serverDeadlineMs(options));
|
|
50
61
|
const maxRetries = options.maxRetries ?? this.config.maxRetries;
|
|
51
62
|
this.validate(timeoutMs, maxRetries);
|
|
52
63
|
const controller = new AbortController();
|