@deepraxis/sdk 0.1.1-dev.ea4a5dd → 0.1.1-dev.eaacee7
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 +383 -1
- package/README.md +2 -2
- package/dist/automation.d.ts +54 -0
- package/dist/core/client.d.ts +7 -1
- package/dist/core/client.js +3 -0
- package/dist/core/errors.d.ts +6 -0
- package/dist/core/errors.js +8 -0
- package/dist/core/transport.d.ts +9 -0
- package/dist/core/transport.js +12 -1
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.js +1 -1
- package/dist/generated/sdk.gen.d.ts +866 -54
- package/dist/generated/sdk.gen.js +2890 -697
- package/dist/generated/types.gen.d.ts +45174 -32725
- 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 +4766 -1246
- package/dist/operations.generated.js +8388 -3992
- package/dist/resources.generated.d.ts +381 -9
- package/dist/resources.generated.js +227 -1
- package/package.json +2 -2
package/dist/core/errors.js
CHANGED
|
@@ -16,6 +16,9 @@ export function problemFrom(status, headers, body, statusText) {
|
|
|
16
16
|
param: typeof param === 'string' ? param : param === null || nested.param === null ? null : undefined,
|
|
17
17
|
errors: Array.isArray(value.errors) ? value.errors : [],
|
|
18
18
|
requestId: headers.get('x-request-id') ?? string(value.requestId) ?? string(value.request_id),
|
|
19
|
+
// Both spellings reach here: the own face writes snake_case, an in-process problem keeps docUrl.
|
|
20
|
+
docUrl: string(nested.doc_url) ?? string(value.doc_url) ?? string(nested.docUrl) ?? string(value.docUrl),
|
|
21
|
+
describe: string(nested.describe) ?? string(value.describe),
|
|
19
22
|
raw: body,
|
|
20
23
|
};
|
|
21
24
|
}
|
|
@@ -28,6 +31,9 @@ export class PraxisError extends Error {
|
|
|
28
31
|
errors;
|
|
29
32
|
requestId;
|
|
30
33
|
param;
|
|
34
|
+
/** ticket-681 — the documented page and the exact section an agent should read to fix the call. */
|
|
35
|
+
docUrl;
|
|
36
|
+
describe;
|
|
31
37
|
raw;
|
|
32
38
|
constructor(problem = {}, options) {
|
|
33
39
|
super(problem.message ?? problem.detail ?? problem.title ?? `Praxis request failed${problem.status ? ` (${problem.status})` : ''}`, options);
|
|
@@ -40,6 +46,8 @@ export class PraxisError extends Error {
|
|
|
40
46
|
this.errors = problem.errors ?? [];
|
|
41
47
|
this.requestId = problem.requestId;
|
|
42
48
|
this.param = problem.param;
|
|
49
|
+
this.docUrl = problem.docUrl;
|
|
50
|
+
this.describe = problem.describe;
|
|
43
51
|
this.raw = problem.raw;
|
|
44
52
|
}
|
|
45
53
|
static fromResponse(response, body) {
|
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,6 +32,17 @@ 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) {
|
|
@@ -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();
|