@pipelex/sdk 0.65.0 → 0.67.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 +10 -0
- package/dist/cli/script.d.ts +1 -1
- package/dist/client.d.ts +157 -3
- package/dist/client.js +229 -6
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js.map +1 -1
- package/dist/method-showcases.d.ts +169 -0
- package/dist/method-showcases.js +139 -0
- package/dist/method-showcases.js.map +1 -0
- package/dist/product-models.d.ts +31 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/architecture.md +4 -2
- package/docs/errors.md +1 -1
- package/docs/method-copy.md +1 -1
- package/docs/method-examples.md +1 -0
- package/docs/method-layouts.md +9 -1
- package/docs/method-showcases.md +100 -0
- package/docs/public-methods.md +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A method's showcases: a completed run of a method, frozen, so that people can see what the method
|
|
3
|
+
* really produces without spending credit. A builder freezes a run (`freezeMethodShowcase`,
|
|
4
|
+
* `POST /v1/methods/{id}/showcases`) and withdraws it (`withdrawMethodShowcase`); every reader of a
|
|
5
|
+
* published version reads the showcases of the tree that version holds
|
|
6
|
+
* (`listMethodVersionShowcases`, `getMethodVersionShowcase`), and the method's own organization
|
|
7
|
+
* reads every showcase across every tree (`listMethodShowcases`, `getMethodShowcase`).
|
|
8
|
+
*
|
|
9
|
+
* A showcase holds real output, unlike a layout's written sample, which is invented, and unlike an
|
|
10
|
+
* example, which is the builder's private test bench whose output is whatever its latest run left.
|
|
11
|
+
* It is keyed by the digest of the method tree of its run, so a run's own content stands behind
|
|
12
|
+
* what is shown. The frozen document names its stored files by `pipelex-storage://` address and
|
|
13
|
+
* holds no signed link; the one place a link appears is a detail read's `files`, signed for that
|
|
14
|
+
* one read over that showcase's own files.
|
|
15
|
+
*
|
|
16
|
+
* The readers here hold a list entry by entry, as `method-layouts.ts` does, so one showcase the SDK
|
|
17
|
+
* cannot read never costs a page the others, and hold a detail and a freeze verdict whole, since
|
|
18
|
+
* the caller acts on what they name.
|
|
19
|
+
*/
|
|
20
|
+
import type { InputForm, OutputForm, PipeIOContracts } from "mthds/protocol";
|
|
21
|
+
/**
|
|
22
|
+
* One showcase of a list: what names it and what it was frozen from. The same for every reader,
|
|
23
|
+
* whoever holds the method.
|
|
24
|
+
*/
|
|
25
|
+
export interface MethodShowcaseSummary {
|
|
26
|
+
/** The showcase's id, `sc_` and a time-ordered uuid, so a list reads oldest first. */
|
|
27
|
+
showcase_id: string;
|
|
28
|
+
/** The showcase's name, for a person reading a list. */
|
|
29
|
+
name: string;
|
|
30
|
+
/** The namespaced pipe the run ran, `domain_path.pipe_code`. */
|
|
31
|
+
pipe_ref: string;
|
|
32
|
+
/**
|
|
33
|
+
* The digest of the method tree of the run the showcase was frozen from: `sha256:` and 64
|
|
34
|
+
* lowercase hexadecimal characters, as a published version's `tree_digest` states it.
|
|
35
|
+
*/
|
|
36
|
+
tree_digest: string;
|
|
37
|
+
/** The moment of the freeze, ISO 8601 in UTC. */
|
|
38
|
+
frozen_at: string;
|
|
39
|
+
}
|
|
40
|
+
/** One stored file of a showcase on a detail read, with a link signed for that read. */
|
|
41
|
+
export interface MethodShowcaseFile {
|
|
42
|
+
/** The file's `pipelex-storage://` address, as the document names it. */
|
|
43
|
+
address: string;
|
|
44
|
+
/** The file's name inside the showcase, which is its content's hash and its extension. */
|
|
45
|
+
file_name: string;
|
|
46
|
+
/** The file's media type, one `type/subtype`. */
|
|
47
|
+
media_type: string;
|
|
48
|
+
/** The file's size in bytes. */
|
|
49
|
+
size_bytes: number;
|
|
50
|
+
/**
|
|
51
|
+
* A short-lived presigned `GET` of the file's bytes. It is a bearer credential: it needs no API
|
|
52
|
+
* key, and anyone holding it can read the file until it expires, so it is never logged and
|
|
53
|
+
* belongs on a server rather than in a browser.
|
|
54
|
+
*/
|
|
55
|
+
url: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* What a showcase shows, frozen from its run and relayed as it was stored, its addresses rewritten
|
|
59
|
+
* to the showcase's own files. A renderer of an HTML output replaces each address with the `url` of
|
|
60
|
+
* the matching entry of `MethodShowcaseDetail.files`.
|
|
61
|
+
*/
|
|
62
|
+
export interface MethodShowcaseDocument {
|
|
63
|
+
/** The inputs the run was started with, an integer past the safe range read as a `bigint`. */
|
|
64
|
+
inputs: Record<string, unknown>;
|
|
65
|
+
/** The run's main output. */
|
|
66
|
+
main_stuff: unknown;
|
|
67
|
+
/** The input-form descriptors of the library the run executed against, keyed by `pipe_ref`. */
|
|
68
|
+
input_form: InputForm | null;
|
|
69
|
+
/** The output-form descriptors of that library, keyed by `pipe_ref`. */
|
|
70
|
+
output_form: OutputForm | null;
|
|
71
|
+
/** The per-pipe input and output contracts of that library, keyed by `pipe_ref`. */
|
|
72
|
+
pipe_io_contracts: PipeIOContracts | null;
|
|
73
|
+
}
|
|
74
|
+
/** One showcase in full: its summary, the frozen document and its files, each with a link. */
|
|
75
|
+
export interface MethodShowcaseDetail extends MethodShowcaseSummary {
|
|
76
|
+
/** The frozen inputs and output, and what describes them. */
|
|
77
|
+
document: MethodShowcaseDocument;
|
|
78
|
+
/** Every stored file the document names, each with a link signed for this read. */
|
|
79
|
+
files: MethodShowcaseFile[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A list of showcases, oldest first, empty when none is frozen — what `listMethodShowcases` and
|
|
83
|
+
* `listMethodVersionShowcases` answer.
|
|
84
|
+
*/
|
|
85
|
+
export interface MethodShowcaseList {
|
|
86
|
+
items: MethodShowcaseSummary[];
|
|
87
|
+
}
|
|
88
|
+
/** The freeze — `freezeMethodShowcase`. Its wire body is closed: these members and nothing else. */
|
|
89
|
+
export interface MethodShowcaseInput {
|
|
90
|
+
/** The `pipeline_run_id` of the completed run of this method to freeze. */
|
|
91
|
+
run_id: string;
|
|
92
|
+
/** The showcase's name, 1 to 200 characters and not blank. */
|
|
93
|
+
name: string;
|
|
94
|
+
}
|
|
95
|
+
/** What a freeze did — the discriminant of `MethodShowcaseFreezeResult`. */
|
|
96
|
+
export type MethodShowcaseFreezeOutcome = "frozen" | "unchanged" | "refused";
|
|
97
|
+
/**
|
|
98
|
+
* Why a freeze was refused:
|
|
99
|
+
*
|
|
100
|
+
* - `run_not_usable`: the run is not this method's in this organization, did not complete, kept no
|
|
101
|
+
* results (a blocking execute stores none), stored no output or forms, does not say which pipe
|
|
102
|
+
* it ran, or kept no record of inputs its pipe declares;
|
|
103
|
+
* - `tree_not_current`: the run's tree is neither the draft's nor the latest published version's,
|
|
104
|
+
* or the run records none;
|
|
105
|
+
* - `file_not_readable`: the document names a file that is gone or outside the organization, or
|
|
106
|
+
* holds a signed link the freeze could not rewrite;
|
|
107
|
+
* - `too_large`: a stored artifact of the run, the document, the number of files or their total
|
|
108
|
+
* size is past what one showcase holds;
|
|
109
|
+
* - `too_many`: the tree already holds as many showcases as one tree keeps.
|
|
110
|
+
*/
|
|
111
|
+
export type MethodShowcaseRefusalReason = "run_not_usable" | "tree_not_current" | "file_not_readable" | "too_large" | "too_many";
|
|
112
|
+
/** The run was frozen: `showcase` names the new showcase. */
|
|
113
|
+
export interface MethodShowcaseFrozen {
|
|
114
|
+
outcome: "frozen";
|
|
115
|
+
showcase: MethodShowcaseSummary;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* This run is already a showcase, whatever has happened to its tree since: `showcase` names the one
|
|
119
|
+
* that stands, nothing was written and the name in the request was ignored.
|
|
120
|
+
*/
|
|
121
|
+
export interface MethodShowcaseUnchanged {
|
|
122
|
+
outcome: "unchanged";
|
|
123
|
+
showcase: MethodShowcaseSummary;
|
|
124
|
+
}
|
|
125
|
+
/** The run cannot be frozen, and nothing was written. */
|
|
126
|
+
export interface MethodShowcaseRefused {
|
|
127
|
+
outcome: "refused";
|
|
128
|
+
/**
|
|
129
|
+
* Why: a `MethodShowcaseRefusalReason`, or the raw string of one this SDK does not know, which a
|
|
130
|
+
* later platform may add. A refusal is a verdict whatever its reason, so show its `message` when
|
|
131
|
+
* the reason is one you do not handle.
|
|
132
|
+
*/
|
|
133
|
+
reason: MethodShowcaseRefusalReason | (string & {});
|
|
134
|
+
/** What was refused and what to do, for a person. */
|
|
135
|
+
message: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The answer of `freezeMethodShowcase`, a `200` discriminated on `outcome`, because a run that
|
|
139
|
+
* cannot be frozen is a verdict about the run and not a failure of the request. Branch on
|
|
140
|
+
* `outcome`, never on the status.
|
|
141
|
+
*/
|
|
142
|
+
export type MethodShowcaseFreezeResult = MethodShowcaseFrozen | MethodShowcaseUnchanged | MethodShowcaseRefused;
|
|
143
|
+
/**
|
|
144
|
+
* What keeps `value` from reading as a showcase summary, as the end of a sentence naming it ("a
|
|
145
|
+
* showcase whose `name` is not a string"), or `null` when it reads as one.
|
|
146
|
+
*/
|
|
147
|
+
export declare function methodShowcaseSummaryFault(value: unknown): string | null;
|
|
148
|
+
/**
|
|
149
|
+
* A list of showcases read entry by entry, `listMethodShowcases`'s or
|
|
150
|
+
* `listMethodVersionShowcases`'s `items`: each entry that reads as a summary
|
|
151
|
+
* (`methodShowcaseSummaryFault`), in the answer's order, oldest first as the platform sends them,
|
|
152
|
+
* and anything else left out. A value that is not an array reads as no showcase.
|
|
153
|
+
*/
|
|
154
|
+
export declare function readMethodShowcaseSummaries(value: unknown): MethodShowcaseSummary[];
|
|
155
|
+
/**
|
|
156
|
+
* What keeps `value` from reading as a showcase detail, as the end of a sentence naming it, or
|
|
157
|
+
* `null` when it reads as one: a summary whose `document` is an object holding an object `inputs`
|
|
158
|
+
* and stating each of its other members, `null` included, and whose `files` is an array of complete
|
|
159
|
+
* entries. Unlike a list of showcases, whose entries
|
|
160
|
+
* stand apart, a detail is held whole: a renderer resolves each address the document names through
|
|
161
|
+
* `files`, so a file it cannot read would leave a result drawn with a hole in it.
|
|
162
|
+
*/
|
|
163
|
+
export declare function methodShowcaseDetailFault(value: unknown): string | null;
|
|
164
|
+
/**
|
|
165
|
+
* What keeps `answer` from reading as a freeze's verdict, as the words naming it, or `null` when it
|
|
166
|
+
* reads as one: an `outcome` of `frozen` or `unchanged` with a `showcase` that reads as a summary,
|
|
167
|
+
* or `refused` with a string `reason` and `message`.
|
|
168
|
+
*/
|
|
169
|
+
export declare function methodShowcaseFreezeFault(answer: Record<string, unknown>): string | null;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A method's showcases: a completed run of a method, frozen, so that people can see what the method
|
|
3
|
+
* really produces without spending credit. A builder freezes a run (`freezeMethodShowcase`,
|
|
4
|
+
* `POST /v1/methods/{id}/showcases`) and withdraws it (`withdrawMethodShowcase`); every reader of a
|
|
5
|
+
* published version reads the showcases of the tree that version holds
|
|
6
|
+
* (`listMethodVersionShowcases`, `getMethodVersionShowcase`), and the method's own organization
|
|
7
|
+
* reads every showcase across every tree (`listMethodShowcases`, `getMethodShowcase`).
|
|
8
|
+
*
|
|
9
|
+
* A showcase holds real output, unlike a layout's written sample, which is invented, and unlike an
|
|
10
|
+
* example, which is the builder's private test bench whose output is whatever its latest run left.
|
|
11
|
+
* It is keyed by the digest of the method tree of its run, so a run's own content stands behind
|
|
12
|
+
* what is shown. The frozen document names its stored files by `pipelex-storage://` address and
|
|
13
|
+
* holds no signed link; the one place a link appears is a detail read's `files`, signed for that
|
|
14
|
+
* one read over that showcase's own files.
|
|
15
|
+
*
|
|
16
|
+
* The readers here hold a list entry by entry, as `method-layouts.ts` does, so one showcase the SDK
|
|
17
|
+
* cannot read never costs a page the others, and hold a detail and a freeze verdict whole, since
|
|
18
|
+
* the caller acts on what they name.
|
|
19
|
+
*/
|
|
20
|
+
import { isPlainObject } from "./records.js";
|
|
21
|
+
/** The members of a showcase summary, in the order a fault names the first one missing. */
|
|
22
|
+
const SHOWCASE_SUMMARY_STRING_MEMBERS = [
|
|
23
|
+
"showcase_id",
|
|
24
|
+
"name",
|
|
25
|
+
"pipe_ref",
|
|
26
|
+
"tree_digest",
|
|
27
|
+
"frozen_at",
|
|
28
|
+
];
|
|
29
|
+
/** The members of a showcase's document that must be stated, `null` being a statement. */
|
|
30
|
+
const SHOWCASE_DOCUMENT_STATED_MEMBERS = [
|
|
31
|
+
"main_stuff",
|
|
32
|
+
"input_form",
|
|
33
|
+
"output_form",
|
|
34
|
+
"pipe_io_contracts",
|
|
35
|
+
];
|
|
36
|
+
/** The members of a showcase's file read as strings. */
|
|
37
|
+
const SHOWCASE_FILE_STRING_MEMBERS = ["address", "file_name", "media_type", "url"];
|
|
38
|
+
/**
|
|
39
|
+
* What keeps `value` from reading as a showcase summary, as the end of a sentence naming it ("a
|
|
40
|
+
* showcase whose `name` is not a string"), or `null` when it reads as one.
|
|
41
|
+
*/
|
|
42
|
+
export function methodShowcaseSummaryFault(value) {
|
|
43
|
+
if (!isPlainObject(value))
|
|
44
|
+
return "that is not an object";
|
|
45
|
+
for (const member of SHOWCASE_SUMMARY_STRING_MEMBERS) {
|
|
46
|
+
if (typeof value[member] !== "string")
|
|
47
|
+
return `whose \`${member}\` is not a string`;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A list of showcases read entry by entry, `listMethodShowcases`'s or
|
|
53
|
+
* `listMethodVersionShowcases`'s `items`: each entry that reads as a summary
|
|
54
|
+
* (`methodShowcaseSummaryFault`), in the answer's order, oldest first as the platform sends them,
|
|
55
|
+
* and anything else left out. A value that is not an array reads as no showcase.
|
|
56
|
+
*/
|
|
57
|
+
export function readMethodShowcaseSummaries(value) {
|
|
58
|
+
if (!Array.isArray(value))
|
|
59
|
+
return [];
|
|
60
|
+
const summaries = [];
|
|
61
|
+
for (const entry of value) {
|
|
62
|
+
if (methodShowcaseSummaryFault(entry) === null) {
|
|
63
|
+
summaries.push(entry);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return summaries;
|
|
67
|
+
}
|
|
68
|
+
/** What keeps `file` from reading as one file of a detail, or `null` when it reads as one. */
|
|
69
|
+
function showcaseFileFault(file) {
|
|
70
|
+
if (!isPlainObject(file))
|
|
71
|
+
return "that is not an object";
|
|
72
|
+
for (const member of SHOWCASE_FILE_STRING_MEMBERS) {
|
|
73
|
+
if (typeof file[member] !== "string")
|
|
74
|
+
return `whose \`${member}\` is not a string`;
|
|
75
|
+
}
|
|
76
|
+
const size = file.size_bytes;
|
|
77
|
+
if (typeof size !== "number" || !Number.isSafeInteger(size) || size < 0) {
|
|
78
|
+
return "whose `size_bytes` is not a non-negative integer";
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* What keeps `value` from reading as a showcase detail, as the end of a sentence naming it, or
|
|
84
|
+
* `null` when it reads as one: a summary whose `document` is an object holding an object `inputs`
|
|
85
|
+
* and stating each of its other members, `null` included, and whose `files` is an array of complete
|
|
86
|
+
* entries. Unlike a list of showcases, whose entries
|
|
87
|
+
* stand apart, a detail is held whole: a renderer resolves each address the document names through
|
|
88
|
+
* `files`, so a file it cannot read would leave a result drawn with a hole in it.
|
|
89
|
+
*/
|
|
90
|
+
export function methodShowcaseDetailFault(value) {
|
|
91
|
+
const summaryFault = methodShowcaseSummaryFault(value);
|
|
92
|
+
if (summaryFault !== null)
|
|
93
|
+
return summaryFault;
|
|
94
|
+
const detail = value;
|
|
95
|
+
const frozen = detail.document;
|
|
96
|
+
const files = detail.files;
|
|
97
|
+
if (!isPlainObject(frozen))
|
|
98
|
+
return "whose `document` is not an object";
|
|
99
|
+
if (!isPlainObject(frozen.inputs))
|
|
100
|
+
return "whose `document.inputs` is not an object";
|
|
101
|
+
for (const member of SHOWCASE_DOCUMENT_STATED_MEMBERS) {
|
|
102
|
+
if (frozen[member] === undefined)
|
|
103
|
+
return `whose \`document.${member}\` is left out`;
|
|
104
|
+
}
|
|
105
|
+
if (!Array.isArray(files))
|
|
106
|
+
return "whose `files` is not an array";
|
|
107
|
+
for (let index = 0; index < files.length; index += 1) {
|
|
108
|
+
const fault = showcaseFileFault(files[index]);
|
|
109
|
+
if (fault !== null)
|
|
110
|
+
return `whose \`files\` holds an entry ${fault}, at [${index}]`;
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* What keeps `answer` from reading as a freeze's verdict, as the words naming it, or `null` when it
|
|
116
|
+
* reads as one: an `outcome` of `frozen` or `unchanged` with a `showcase` that reads as a summary,
|
|
117
|
+
* or `refused` with a string `reason` and `message`.
|
|
118
|
+
*/
|
|
119
|
+
export function methodShowcaseFreezeFault(answer) {
|
|
120
|
+
switch (answer.outcome) {
|
|
121
|
+
case "frozen":
|
|
122
|
+
case "unchanged": {
|
|
123
|
+
const fault = methodShowcaseSummaryFault(answer.showcase);
|
|
124
|
+
if (fault === null)
|
|
125
|
+
return null;
|
|
126
|
+
return `a \`${answer.outcome}\` freeze result whose \`showcase\` is one ${fault}`;
|
|
127
|
+
}
|
|
128
|
+
case "refused":
|
|
129
|
+
for (const member of ["reason", "message"]) {
|
|
130
|
+
if (typeof answer[member] !== "string") {
|
|
131
|
+
return `a \`refused\` freeze result whose \`${member}\` is not a string`;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
default:
|
|
136
|
+
return "a freeze result whose `outcome` is not `frozen`, `unchanged` or `refused`";
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=method-showcases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"method-showcases.js","sourceRoot":"","sources":["../src/method-showcases.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA0I7C,2FAA2F;AAC3F,MAAM,+BAA+B,GAAG;IACtC,aAAa;IACb,MAAM;IACN,UAAU;IACV,aAAa;IACb,WAAW;CACH,CAAC;AAEX,0FAA0F;AAC1F,MAAM,gCAAgC,GAAG;IACvC,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,mBAAmB;CACX,CAAC;AAEX,wDAAwD;AACxD,MAAM,4BAA4B,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,CAAU,CAAC;AAE5F;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAc;IACvD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;QAAE,OAAO,uBAAuB,CAAC;IAC1D,KAAK,MAAM,MAAM,IAAI,+BAA+B,EAAE,CAAC;QACrD,IAAI,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,QAAQ;YAAE,OAAO,WAAW,MAAM,oBAAoB,CAAC;IACtF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,KAAc;IACxD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,SAAS,GAA4B,EAAE,CAAC;IAC9C,KAAK,MAAM,KAAK,IAAI,KAAkB,EAAE,CAAC;QACvC,IAAI,0BAA0B,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;YAC/C,SAAS,CAAC,IAAI,CAAC,KAA8B,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,8FAA8F;AAC9F,SAAS,iBAAiB,CAAC,IAAa;IACtC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;QAAE,OAAO,uBAAuB,CAAC;IACzD,KAAK,MAAM,MAAM,IAAI,4BAA4B,EAAE,CAAC;QAClD,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,QAAQ;YAAE,OAAO,WAAW,MAAM,oBAAoB,CAAC;IACrF,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACxE,OAAO,kDAAkD,CAAC;IAC5D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAc;IACtD,MAAM,YAAY,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAC;IACvD,IAAI,YAAY,KAAK,IAAI;QAAE,OAAO,YAAY,CAAC;IAC/C,MAAM,MAAM,GAAG,KAAgC,CAAC;IAChD,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC3B,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;QAAE,OAAO,mCAAmC,CAAC;IACvE,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC;QAAE,OAAO,0CAA0C,CAAC;IACrF,KAAK,MAAM,MAAM,IAAI,gCAAgC,EAAE,CAAC;QACtD,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,SAAS;YAAE,OAAO,oBAAoB,MAAM,gBAAgB,CAAC;IACtF,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,+BAA+B,CAAC;IAClE,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACrD,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9C,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,kCAAkC,KAAK,SAAS,KAAK,GAAG,CAAC;IACtF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAA+B;IACvE,QAAQ,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,KAAK,QAAQ,CAAC;QACd,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,MAAM,KAAK,GAAG,0BAA0B,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1D,IAAI,KAAK,KAAK,IAAI;gBAAE,OAAO,IAAI,CAAC;YAChC,OAAO,OAAO,MAAM,CAAC,OAAO,8CAA8C,KAAK,EAAE,CAAC;QACpF,CAAC;QACD,KAAK,SAAS;YACZ,KAAK,MAAM,MAAM,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAU,EAAE,CAAC;gBACpD,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,QAAQ,EAAE,CAAC;oBACvC,OAAO,uCAAuC,MAAM,oBAAoB,CAAC;gBAC3E,CAAC;YACH,CAAC;YACD,OAAO,IAAI,CAAC;QACd;YACE,OAAO,2EAA2E,CAAC;IACvF,CAAC;AACH,CAAC"}
|
package/dist/product-models.d.ts
CHANGED
|
@@ -411,6 +411,12 @@ export interface MethodDraftInput extends MethodTreeInput {
|
|
|
411
411
|
export interface MethodRenameInput {
|
|
412
412
|
/** The method's new name, non-empty. */
|
|
413
413
|
name: string;
|
|
414
|
+
/**
|
|
415
|
+
* The name this rename expects to replace. Given, the rename lands only while the method still
|
|
416
|
+
* holds it, and is otherwise a `409` `pipelex.catalog.update_conflict` naming `expected_name`
|
|
417
|
+
* with nothing written. Omitted, the rename is unconditional.
|
|
418
|
+
*/
|
|
419
|
+
expected_name?: string;
|
|
414
420
|
}
|
|
415
421
|
/** The publish — `publishMethod`, `POST /v1/methods/{id}/publish`. */
|
|
416
422
|
export interface MethodPublishInput {
|
|
@@ -433,13 +439,15 @@ export type MethodPublishOutcome = "published" | "unchanged" | "refused";
|
|
|
433
439
|
* - `thumbnail_invalid`: the method is public, and no file directly under the draft's
|
|
434
440
|
* `thumbnails/` is a valid thumbnail (a PNG, JPEG or WebP of at least 800×400 pixels);
|
|
435
441
|
* - `storage_reference`: the method is public, and a `.mthds` file of the draft names a
|
|
436
|
-
* `pipelex-storage://` file, which other organizations cannot read
|
|
442
|
+
* `pipelex-storage://` file, which other organizations cannot read;
|
|
443
|
+
* - `showcase_missing`: the method is public, and the draft's tree holds no showcase for other
|
|
444
|
+
* organizations to look at. Reserved: the platform states it and does not raise it yet.
|
|
437
445
|
*
|
|
438
|
-
* `thumbnail_missing`, `thumbnail_invalid` and `
|
|
439
|
-
* publish, so that the card of a template never loses its picture
|
|
440
|
-
* what it reads.
|
|
446
|
+
* `thumbnail_missing`, `thumbnail_invalid`, `storage_reference` and `showcase_missing` refuse only
|
|
447
|
+
* a public method's publish, so that the card of a template never loses its picture, every
|
|
448
|
+
* organization can run what it reads, and a template never appears with nothing to show.
|
|
441
449
|
*/
|
|
442
|
-
export type MethodPublishRefusalReason = "invalid" | "not_runnable" | "thumbnail_missing" | "thumbnail_invalid" | "storage_reference";
|
|
450
|
+
export type MethodPublishRefusalReason = "invalid" | "not_runnable" | "thumbnail_missing" | "thumbnail_invalid" | "storage_reference" | "showcase_missing";
|
|
443
451
|
/** A publish that wrote a new version. */
|
|
444
452
|
export interface MethodPublished {
|
|
445
453
|
outcome: "published";
|
|
@@ -654,6 +662,17 @@ export interface MethodCopied {
|
|
|
654
662
|
examples_copied: number;
|
|
655
663
|
/** How many distinct stored files were copied into the destination for the copy's inputs. */
|
|
656
664
|
stored_files_copied: number;
|
|
665
|
+
/**
|
|
666
|
+
* How many showcases of the tree taken the copy holds, each copied with its files. Reserved: the
|
|
667
|
+
* platform answers `0` until copies carry showcases, and a platform that predates it leaves it
|
|
668
|
+
* out, which means none.
|
|
669
|
+
*/
|
|
670
|
+
showcases_copied?: number;
|
|
671
|
+
/**
|
|
672
|
+
* How many layouts of the tree taken the copy holds. Reserved: the platform answers `0` until
|
|
673
|
+
* copies carry layouts, and a platform that predates it leaves it out, which means none.
|
|
674
|
+
*/
|
|
675
|
+
layouts_copied?: number;
|
|
657
676
|
}
|
|
658
677
|
/**
|
|
659
678
|
* A copy refused before anything was written: a bundle of the draft names stored files the copy
|
|
@@ -729,6 +748,13 @@ export interface MethodExample {
|
|
|
729
748
|
* changed. It may name a run deleted since, which then reads as not found.
|
|
730
749
|
*/
|
|
731
750
|
latest_run_id: string | null;
|
|
751
|
+
/**
|
|
752
|
+
* The showcase frozen from the example's latest run, the output a person may look at without
|
|
753
|
+
* running the method; `null` when none was, and cleared when the inputs change. Reserved: the
|
|
754
|
+
* platform answers `null` until copies born from a showcase fill it, and a platform that predates
|
|
755
|
+
* it leaves it out, which means none.
|
|
756
|
+
*/
|
|
757
|
+
showcase_id?: string | null;
|
|
732
758
|
/** The canonical id of the member who saved the example; it confers nothing. */
|
|
733
759
|
created_by_user_id: string;
|
|
734
760
|
/** ISO-8601 UTC instant of the example's creation. */
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/docs/architecture.md
CHANGED
|
@@ -118,6 +118,7 @@ Flat `src/` (mirrors `mthds-js`'s `runners/api` flatness — the SDK has one cli
|
|
|
118
118
|
- `models.ts` — Dict-serialized concretes (`DictStuff` / `DictWorkingMemory` / `DictPipeOutput` / `DictRunResultExecute`), the `/v1/validate` surface (`PipelexValidationResult`, whose two arms are declared whole rather than as narrowings of the standard's `ValidationResult`, listing their faults and warnings as the standard's `ProblemItem`, with its `SuggestedFix` and `FixOp`, see [errors.md](./errors.md#a-verdicts-problem-items)), the tools surface (`Diagnostic` / `LintResponse` / `FormatResponse`), and the crate-route request/response models — the shared `CrateRequestBase` / `CrateInvalidReport` vocabulary plus the `/v1/resolve`, `/v1/codegen` and `/v1/pipe-io` shapes built on it, `GeneratedArtifact` among them.
|
|
119
119
|
- `product-models.ts` — the snake_case wire shapes for the hosted-product management routes (profile, methods catalog, organizations, billing, API keys, onboarding, storage, an organization's files, runs list/detail/update). Each interface models only the fields the product actually consumes — no speculative mirrors.
|
|
120
120
|
- `method-layouts.ts` — a method's stored layouts: `MethodLayoutInput` and `LayoutProvenanceInput`, the write `storeMethodLayout` sends, `MethodLayout` and `LayoutProvenance`, what the platform stores, answers and carries on a validate's `layouts`, `MethodLayoutList`, what `listMethodLayouts` answers, and the reader they all go through, `readMethodLayout` (with `methodLayoutFault`, which names the member an unreadable layout breaks, and `readMethodLayouts`, which reads a list of layouts entry by entry). It imports the plain-object guard of `records.ts` and nothing else. The Python twin is `pipelex_sdk/method_layout_models.py`. See [method-layouts.md](./method-layouts.md).
|
|
121
|
+
- `method-showcases.ts` — a method's showcases: `MethodShowcaseInput`, the freeze `freezeMethodShowcase` sends, `MethodShowcaseSummary`, `MethodShowcaseDetail`, its document and its files, what the holder's and a version's reads answer, `MethodShowcaseFreezeResult`, the freeze's verdict, and the readers they go through: `readMethodShowcaseSummaries`, which reads a list of showcases entry by entry, and `methodShowcaseDetailFault` and `methodShowcaseFreezeFault`, which hold a detail and a verdict whole. It imports the plain-object guard of `records.ts` and the standard's form types. The Python twin is `pipelex_sdk/method_showcase_models.py`. See [method-showcases.md](./method-showcases.md).
|
|
121
122
|
- `answer-reading.ts` — `readHostedAnswer`, the reading of an answer that is not the route's result as its problem: a problem document as received, and an answer whose body is none, the hosted edge's, a gateway's or a proxy's, by its status, `client.outcome_unknown` for a start or an execute that may have created a run; and `outcomeUnknownProblem`. `ApiResponseError` reads every answer through it. The Python twin is `pipelex_sdk/answer_reading.py`. See [errors.md](./errors.md#an-answer-that-is-no-problem-document).
|
|
122
123
|
- `transport-reading.ts` — `requestMayHaveLeft`, the **pure** reading of whether a request that got no answer may have left this machine, every failure counting unless it proves nothing was sent (a failure of the connection's set-up). `ApiUnreachableError` applies it on a start or an execute, which the client marks with `mayStartRun`, to read the failure as `client.unreachable` or `client.outcome_unknown`. The Python twin is `pipelex_sdk/transport_reading.py`. See [errors.md](./errors.md#a-run-that-may-have-started--outcome_unknown).
|
|
123
124
|
- `problem-items.ts` — `readProblemItems`, the reading of a verdict's `errors` and `warnings` as the standard's problem items, member by member, so one malformed member never costs the caller its fault. The Python twin is `pipelex_sdk/problem_items.py`. See [errors.md](./errors.md#a-verdicts-problem-items).
|
|
@@ -158,11 +159,12 @@ Flat `src/` (mirrors `mthds-js`'s `runners/api` flatness — the SDK has one cli
|
|
|
158
159
|
The hosted catalog/account routes the webapp drives. All ride the same `{base}/v1/*` + `Authorization: Bearer` + org-from-JWT contract as the protocol routes, go through the shared `requestProduct<T>` helper (30s management timeout, empty-body tolerant), and map a non-2xx RFC 9457 `problem+json` to a typed `ApiResponseError`. Every route parses a 2xx body through one private helper, so an answer that is not JSON (a gateway's HTML page, an empty body where one was due) is an `ApiResponseError` carrying its status and raw text, `client.response_unreadable`, rather than a bare `SyntaxError`. A product route whose answer the SDK or its caller reads before anything else (`listMethods`, `listRuns`, `getRunDetail`, `upload`, `requestUploadGrant`, `resolveStorageUrls`, and the methods routes answering one stored method) goes through `requestProductObject` or a helper built on the same read instead, which also refuses an empty body and JSON that is not an object; the two paged routes then refuse, the same way, through one page reader, a page whose `items` is not an array or whose `next_cursor` is neither a string nor `null`, `upload` an answer with no non-empty string `uri`, and `getMethod` and `getMethodVersion` a `files` member that is not a listing of files, each with its string `path`, `sha256`, `url` and `expires_at` and a non-negative integer `size`. Every refusal the platform renders is a problem document under a registered code, a core one (`request.invalid`, `auth.forbidden`, …) or a Pipelex one (`pipelex.catalog.not_found`, `pipelex.billing.plan_limit`, …), and consumers branch on its `code`, as the hosted-envelope spec (`conformance/specs/pipelex-hosted-envelope.md`, in the `conformance` repository) says, never on the HTTP status. An answer whose body is no problem document comes from the hosted edge and reads by its status. See [errors.md](./errors.md).
|
|
159
160
|
|
|
160
161
|
- **User profile:** `getMe` (`GET /v1/me`).
|
|
161
|
-
- **Methods catalog:** `listMethods`, `getMethod`, `createMethod`, `writeDraft`, `renameMethod`, `publishMethod`, `listMethodVersions`, `getMethodVersion`, `deleteMethod`. **A saved method has a draft and immutable published versions.** Its draft is a method tree with its `input_data`, which `writeDraft` (`PUT /v1/methods/{id}/draft`) replaces whole, without validating it; `updated_at` is the draft's token, which moves on every draft write and nothing else, and `draft_digest` the draft's tree digest (`sha256:` and 64 hex digits), `null` for an empty draft. A save takes the tree as `files`, sent as given, or as `directory`, `tree` or `contents`, sent inline or by hash after uploading the blobs the organization lacks, and a read lists the tree's files, each with a short-lived link to its bytes, which `writeMethodTree` writes to disk ([method-trees.md](./method-trees.md)). A draft write may carry `expected_updated_at`, the token the caller last saw, and is then a compare-and-swap: a draft that moved since is a `409` `pipelex.catalog.update_conflict` and nothing is written. `renameMethod` (`PATCH /v1/methods/{id}`) changes the name alone and moves no token. `publishMethod` (`POST /v1/methods/{id}/publish`) takes the required `expected_draft_updated_at` and answers a `MethodPublishResult` discriminated on `outcome` — `published` with the new version, `unchanged` with the existing latest version when the draft's digest equals it, `refused` with a `reason` (`invalid` or `not_runnable`, and for a public method `storage_reference`, `thumbnail_missing` or `thumbnail_invalid`, read open so a later reason arrives as its raw string), a `message` and the runner's `validation` verdict, its problem items read member by member as `validate` reads them — every arm carrying the `method`; the SDK reads the nested method as `getMethod` does, and an answer whose `outcome` is none of these, or a refusal whose `validation` is not a verdict object, is an answer it cannot read. A publish that produced no verdict is thrown rather than answered: only a draft that differs from the latest version reaches the runner, and a runner that cannot be reached, answers unusably or does not finish within the platform's deadline is a `502` or `503` with nothing written, so a retry is safe, and a retry of a publish that landed while its answer was lost answers `unchanged` with the version it wrote. A method is stored as one item that keeps room for the summary a publish adds, so a draft that saves can always be published: a creation or a draft write is a `413` `request.too_large` when it would grow the method past that room, below the store's item limit, and a rename is the same `413` for a name so long it would leave the method too large to publish. A version is numbered from 1, never reused, and holds the draft's tree as it stood, its `tree_digest` (`null` for a version stored before methods were trees), its `crate_fingerprint` (`null` when the runner could not resolve the bundle in memory), the runner's version, and when and by whom it was published; `listMethodVersions` pages the summaries newest first (`MethodVersionPage`, `{items, nextCursor}`, a `limit` from 1 to 100, 20 by default, and a `422` outside that range), and `getMethodVersion` reads one with its `files` listed as a method's are, or answers a `500` `runtime.unexpected` for a version stored before methods were trees and never rewritten as one. A method read carries `latest_version` and `latest_published`, both `null` until the first publish, so the publish state is derived: never published, draft unchanged (`draft_digest` not `null` and equal to `latest_published.tree_digest`), or draft ahead. The method routes take a bare id and address the method itself, never one of its versions; the platform does not parse a suffix there, so `mt_x@3` would answer a `404` that reads as a method that does not exist, and each route refuses a suffixed id with `RequestArgumentError` before anything is sent, naming `parseMethodSelector` and `getMethodVersion`. The whole-method `updateMethod` is gone, replaced by the draft write and the rename. **`deleteMethod` is asynchronous and its return type says so:** `DELETE /v1/methods/{id}` answers `202` with a `MethodDeletionAccepted` (`method_id`, `deletion_state`, `deletion_job_id`) the moment the platform has claimed the method and terminated its in-flight workflows — the rest of the cascade (runs, events, S3 objects) is enqueued. A resolved promise means "accepted", never "gone"; completion is the row disappearing from `listMethods`, not any field of that body. The claim is a conditional write, so a double-clicked delete is a `409` `pipelex.catalog.being_deleted` rather than a second cascade over the same runs, and an unknown or foreign-org id is a `404`. The erasure deletes the method's versions with the rest. (This doc previously stated the SDK had no `delete` because the platform had no such route — the route has always existed; the claim was simply false.) `listMethods` returns **one page**, not the whole catalog — a `MethodPage` (`{items, nextCursor}`) served from a narrow index projection, so its cost is the page size rather than the size of the catalog. It used to return every method with its full `.mthds` bundle attached, which hit DynamoDB's 1 MB page cap at a couple hundred methods and came back truncated with no error and no flag, so methods silently vanished from the UI. Rows are therefore `MethodSummary`, **not** `MethodDetail`: no `files`, no `updated_at`, because neither is in the projection and putting the source back is what restored the truncation. Reach for `getMethod(id)` when you need a method's files. `query.q` is applied server-side across the whole catalog, not over the page — filtering one page client-side would be searching 50 rows of 10,000 and calling it a search. `query.published` filters the same way, sent as `published=true` (the methods with a published version) or `published=false` (those never published), and combines with `q`. Each row carries the method's publish state, so a list tells its methods apart without reading each one: `latest_version` and `latest_published` (a `MethodVersionSummary`), both `null` when the method was never published, and `draft_digest`, `null` for an empty draft; all three are optional, absent from a platform that does not serve them. Never published is `latest_version === null`, the draft unchanged is a `draft_digest` that is not `null` and equals `latest_published.tree_digest`, and the draft ahead is two digests that differ. Both filters run after the index read, so **a filtered page can come back empty and still carry a `nextCursor`**: an empty page is not the end of the list, and only a `null` cursor is. `iterateMethods` is the async iterator that follows the cursor for callers who genuinely want everything (`for await (const m of client.iterateMethods())`); it keeps going **past empty pages**, since `{items: [], nextCursor: "…"}` means "nothing matched in the slice I just read, keep going". A server that keeps minting fresh cursors forever stops it at a page ceiling far past any real catalog with a `PagingNotTerminatingError` carrying `pageLimit`, never a silently truncated stream; `iterateRuns` shares the same loop. It gives up only when the server stops advancing its cursor, and **throws** rather than returning a partial answer; like `iterateRuns` it is deliberately not a `listAllMethods(): Promise<MethodSummary[]>`, because an all-at-once helper needs a page cap and a cap means silently returning a truncated list. `MethodSummary.deletion_state` rides the list rows: a method mid-erasure stays listed so the UI can render it as "Deleting…", while `getMethod` refuses it with a 409. Full read responses (`MethodDetail`, from `getMethod`) carry `org_id`, `created_by_user_id`, a server-derived `description` (recomputed on every draft write from the manifest's `description`, else the primary bundle's top-level `description`, else its main pipe's), `categories` and `visibility`, the draft token and digest, the latest version's summary and the draft's `files` on top of the write contract's `name` / `input_data`; the writes and the rename answer `MethodData`, the same method without `files`. Another organization's public method reads as a `PublicMethodDetail`, its latest published version and nothing of its draft, so `getMethod` is typed `MethodDetail | PublicMethodDetail`, told apart by `updated_at`; an answer without it that carries a member only the owner's read has is an answer the SDK cannot read, and so is a public read without its `latest_version` and `latest_published` ([public-methods.md](./public-methods.md)).
|
|
162
|
+
- **Methods catalog:** `listMethods`, `getMethod`, `createMethod`, `writeDraft`, `renameMethod`, `publishMethod`, `listMethodVersions`, `getMethodVersion`, `deleteMethod`. **A saved method has a draft and immutable published versions.** Its draft is a method tree with its `input_data`, which `writeDraft` (`PUT /v1/methods/{id}/draft`) replaces whole, without validating it; `updated_at` is the draft's token, which moves on every draft write and nothing else, and `draft_digest` the draft's tree digest (`sha256:` and 64 hex digits), `null` for an empty draft. A save takes the tree as `files`, sent as given, or as `directory`, `tree` or `contents`, sent inline or by hash after uploading the blobs the organization lacks, and a read lists the tree's files, each with a short-lived link to its bytes, which `writeMethodTree` writes to disk ([method-trees.md](./method-trees.md)). A draft write may carry `expected_updated_at`, the token the caller last saw, and is then a compare-and-swap: a draft that moved since is a `409` `pipelex.catalog.update_conflict` and nothing is written. `renameMethod` (`PATCH /v1/methods/{id}`) changes the name alone and moves no token; with `expected_name` it lands only while the method still holds that name, and is otherwise the same `409` `pipelex.catalog.update_conflict`, naming `expected_name`, with nothing written. `publishMethod` (`POST /v1/methods/{id}/publish`) takes the required `expected_draft_updated_at` and answers a `MethodPublishResult` discriminated on `outcome` — `published` with the new version, `unchanged` with the existing latest version when the draft's digest equals it, `refused` with a `reason` (`invalid` or `not_runnable`, and for a public method `storage_reference`, `thumbnail_missing` or `thumbnail_invalid`, read open so a later reason arrives as its raw string), a `message` and the runner's `validation` verdict, its problem items read member by member as `validate` reads them — every arm carrying the `method`; the SDK reads the nested method as `getMethod` does, and an answer whose `outcome` is none of these, or a refusal whose `validation` is not a verdict object, is an answer it cannot read. A publish that produced no verdict is thrown rather than answered: only a draft that differs from the latest version reaches the runner, and a runner that cannot be reached, answers unusably or does not finish within the platform's deadline is a `502` or `503` with nothing written, so a retry is safe, and a retry of a publish that landed while its answer was lost answers `unchanged` with the version it wrote. A method is stored as one item that keeps room for the summary a publish adds, so a draft that saves can always be published: a creation or a draft write is a `413` `request.too_large` when it would grow the method past that room, below the store's item limit, and a rename is the same `413` for a name so long it would leave the method too large to publish. A version is numbered from 1, never reused, and holds the draft's tree as it stood, its `tree_digest` (`null` for a version stored before methods were trees), its `crate_fingerprint` (`null` when the runner could not resolve the bundle in memory), the runner's version, and when and by whom it was published; `listMethodVersions` pages the summaries newest first (`MethodVersionPage`, `{items, nextCursor}`, a `limit` from 1 to 100, 20 by default, and a `422` outside that range), and `getMethodVersion` reads one with its `files` listed as a method's are, or answers a `500` `runtime.unexpected` for a version stored before methods were trees and never rewritten as one. A method read carries `latest_version` and `latest_published`, both `null` until the first publish, so the publish state is derived: never published, draft unchanged (`draft_digest` not `null` and equal to `latest_published.tree_digest`), or draft ahead. The method routes take a bare id and address the method itself, never one of its versions; the platform does not parse a suffix there, so `mt_x@3` would answer a `404` that reads as a method that does not exist, and each route refuses a suffixed id with `RequestArgumentError` before anything is sent, naming `parseMethodSelector` and `getMethodVersion`. The whole-method `updateMethod` is gone, replaced by the draft write and the rename. **`deleteMethod` is asynchronous and its return type says so:** `DELETE /v1/methods/{id}` answers `202` with a `MethodDeletionAccepted` (`method_id`, `deletion_state`, `deletion_job_id`) the moment the platform has claimed the method and terminated its in-flight workflows — the rest of the cascade (runs, events, S3 objects) is enqueued. A resolved promise means "accepted", never "gone"; completion is the row disappearing from `listMethods`, not any field of that body. The claim is a conditional write, so a double-clicked delete is a `409` `pipelex.catalog.being_deleted` rather than a second cascade over the same runs, and an unknown or foreign-org id is a `404`. The erasure deletes the method's versions with the rest. (This doc previously stated the SDK had no `delete` because the platform had no such route — the route has always existed; the claim was simply false.) `listMethods` returns **one page**, not the whole catalog — a `MethodPage` (`{items, nextCursor}`) served from a narrow index projection, so its cost is the page size rather than the size of the catalog. It used to return every method with its full `.mthds` bundle attached, which hit DynamoDB's 1 MB page cap at a couple hundred methods and came back truncated with no error and no flag, so methods silently vanished from the UI. Rows are therefore `MethodSummary`, **not** `MethodDetail`: no `files`, no `updated_at`, because neither is in the projection and putting the source back is what restored the truncation. Reach for `getMethod(id)` when you need a method's files. `query.q` is applied server-side across the whole catalog, not over the page — filtering one page client-side would be searching 50 rows of 10,000 and calling it a search. `query.published` filters the same way, sent as `published=true` (the methods with a published version) or `published=false` (those never published), and combines with `q`. Each row carries the method's publish state, so a list tells its methods apart without reading each one: `latest_version` and `latest_published` (a `MethodVersionSummary`), both `null` when the method was never published, and `draft_digest`, `null` for an empty draft; all three are optional, absent from a platform that does not serve them. Never published is `latest_version === null`, the draft unchanged is a `draft_digest` that is not `null` and equals `latest_published.tree_digest`, and the draft ahead is two digests that differ. Both filters run after the index read, so **a filtered page can come back empty and still carry a `nextCursor`**: an empty page is not the end of the list, and only a `null` cursor is. `iterateMethods` is the async iterator that follows the cursor for callers who genuinely want everything (`for await (const m of client.iterateMethods())`); it keeps going **past empty pages**, since `{items: [], nextCursor: "…"}` means "nothing matched in the slice I just read, keep going". A server that keeps minting fresh cursors forever stops it at a page ceiling far past any real catalog with a `PagingNotTerminatingError` carrying `pageLimit`, never a silently truncated stream; `iterateRuns` shares the same loop. It gives up only when the server stops advancing its cursor, and **throws** rather than returning a partial answer; like `iterateRuns` it is deliberately not a `listAllMethods(): Promise<MethodSummary[]>`, because an all-at-once helper needs a page cap and a cap means silently returning a truncated list. `MethodSummary.deletion_state` rides the list rows: a method mid-erasure stays listed so the UI can render it as "Deleting…", while `getMethod` refuses it with a 409. Full read responses (`MethodDetail`, from `getMethod`) carry `org_id`, `created_by_user_id`, a server-derived `description` (recomputed on every draft write from the manifest's `description`, else the primary bundle's top-level `description`, else its main pipe's), `categories` and `visibility`, the draft token and digest, the latest version's summary and the draft's `files` on top of the write contract's `name` / `input_data`; the writes and the rename answer `MethodData`, the same method without `files`. Another organization's public method reads as a `PublicMethodDetail`, its latest published version and nothing of its draft, so `getMethod` is typed `MethodDetail | PublicMethodDetail`, told apart by `updated_at`; an answer without it that carries a member only the owner's read has is an answer the SDK cannot read, and so is a public read without its `latest_version` and `latest_published` ([public-methods.md](./public-methods.md)).
|
|
162
163
|
- **Method examples:** `createMethodExample`, `listMethodExamples`, `iterateMethodExamples`, `getMethodExample`, `updateMethodExample`, `recordMethodExampleLatestRun`, `saveAssistantMethodExample`, `deleteMethodExample`, on `/v1/methods/{id}/examples`. An example is a named set of inputs saved on a method, shared across the organization, with an `input_revision` that rises each time its inputs change and the `latest_run_id` of those inputs, which an inputs edit clears. `recordMethodExampleLatestRun` records a run against the revision whose inputs it used and answers a `MethodExampleLatestRunResult` discriminated on `outcome`, `recorded` or `stale`, each arm carrying the `example`: a run that outlasted an edit is a verdict, never thrown, and an answer off the union is one the SDK cannot read; `saveAssistantMethodExample` is the build assistant's save, which writes into the example it names only while that example is still the assistant's (`kept_by_assistant`) at the revision it read, and otherwise creates one, answering a `MethodExampleAssistantSaveResult` discriminated on `outcome`, `kept` or `created`; one helper, `readVerdict`, reads these verdicts and `publishMethod`'s, the example checked once, by the reader every example goes through. Every answer carrying an example is read with `parseExactJson` and every request body written with `stringifyExactJson`, so an integer past `Number.MAX_SAFE_INTEGER` in the inputs reads as a `bigint` and goes back digit for digit, to an edit or as a run's inputs; `3.0` still reads as `3`, and inputs holding one sent back unchanged are an edit for the platform, which compares inputs as canonical JSON. Every example the client hands back, the page rows and the verdict's `example` included, is checked by `readMethodExample` against the fields the Python SDK's model requires, with the strict types it holds them to, an example breaking one being an answer the SDK cannot read. The list is paged oldest first by an opaque cursor, and a page may be short while `nextCursor` is set; `iterateMethodExamples` follows it through the loop `iterateMethods` and `iterateRuns` share, and refuses a method id at the call rather than at the first pull. Every method takes a bare catalog id, and the client refuses an example id that is empty, `.` or `..` or holds a lone surrogate, a create without its name or inputs or whose `run_id` is given but empty, an edit naming neither `name` nor `inputs`, and a latest-run write without a run id or a positive integer revision before sending. See [method-examples.md](./method-examples.md).
|
|
163
164
|
- **Template catalog:** `listMethodTemplates`, `iterateMethodTemplates`, on `GET /v1/method-templates`, and `listMethodCategories`, on `GET /v1/method-categories`. The public methods of the deployment's templates organization, in the order the platform serves for the `ordering` asked for, filtered by `category`, with the page's `categories` and each card's thumbnails behind short-lived links. `listMethodTemplates` reads the page with its own reader rather than `requestPage`, since its `ordering` and `categories` sit beside `items` and `nextCursor`, and redacts the links of an answer it cannot read; `iterateMethodTemplates` follows the cursor with the same ordering and category. `listMethodCategories` reads the catalog's whole list of categories, which an admin of the platform keeps, in its order. Both check each category with one reader, `methodCategoriesFault`: a string `slug` and `label`, and `labels`, an object of strings by language tag ([public-methods.md](./public-methods.md)).
|
|
164
165
|
- **Method copies:** `copyMethod`, on `/v1/methods/{id}/copy`. `copyMethod` makes a new, unpublished method in an organization the caller may change methods in, the method's own for a duplicate, holding the original's draft tree, its form inputs and its examples, the stored files they name copied into the destination, and answers a `MethodCopyResult` discriminated on `outcome`: `copied` with the copy as `method` and what was copied, or `refused` with the `references` of a bundle naming storage the destination cannot read or, in a duplicate, a file under the original's run files, which erasing the original would remove. The two arms carry different members, so the verdict is read by the copy itself rather than by `readVerdict`, which reads verdicts whose arms share one: an `outcome` off the union, a `copied` answer whose `method` is not an object and a `refused` one whose `references` is not an array are each an answer the SDK cannot read. Its body is closed, `destination_org_id` with `name` and `expected_draft_updated_at` when given, and its last argument takes an `idempotencyKey`, sent as the `Idempotency-Key` header through the same `requestRaw` option and the same `idempotencyKeyOf` check a start uses. Every method read carries `copied_from`, the original a copy names, `null` on a method created afresh. `MethodErrorCode` names the copy's own codes, `pipelex.org.not_found` and `pipelex.catalog.copy_too_large`, whose `limit` member is typed `MethodCopyLimit`. It takes a bare catalog id. See [method-copy.md](./method-copy.md).
|
|
165
|
-
- **Method
|
|
166
|
+
- **Method showcases:** `freezeMethodShowcase` and `listMethodShowcases`, on `/v1/methods/{id}/showcases`, `getMethodShowcase` and `withdrawMethodShowcase`, on `/v1/methods/{id}/showcases/{showcase_id}`, and `listMethodVersionShowcases` and `getMethodVersionShowcase`, on `/v1/methods/{id}/versions/{n}/showcases[/{showcase_id}]`. A showcase is a completed run frozen with a private copy of its files; the freeze answers a verdict discriminated on `outcome`, read open on `reason`, the lists are read entry by entry as a layout list is, and a detail is read whole with `parseExactJson` and any error's signed links redacted. The freeze's and the withdrawal's `idempotencyKey` goes through the same `idempotencyKeyOf` check. See [method-showcases.md](./method-showcases.md).
|
|
167
|
+
- **Method layouts:** `storeMethodLayout` and `listMethodLayouts`, on `/v1/methods/{id}/versions/{n}/layouts`, `listMethodDraftLayouts`, on `/v1/methods/{id}/draft/layouts`, `setMethodLayoutsOff`, on `/v1/methods/{id}/layouts-off`, and the `layouts` view of `validate`. A layout is a data file a producer designed for one pipe of a published version, which the platform stores keyed by the content it was designed for, `tree_digest`, `pipe_ref`, `catalog` and `prompt_hash`, a write of the same identity replacing it, and carries on every validate by `method_id` that names `layouts` and resolves the same tree. The write takes a bare catalog id and a positive integer version, refuses a layout or a provenance that is not an object before sending, and sends the closed body alone, its members listed once in `method-layouts.ts` (`LAYOUT_INPUT_MEMBERS`, `PROVENANCE_INPUT_MEMBERS`) and held to the input interfaces by `satisfies`, `sample_json` and each optional provenance member that is `null` or omitted left out; its last argument takes an `idempotencyKey` (`MethodLayoutWriteOptions`), sent as the `Idempotency-Key` header through the same `idempotencyKeyOf` check a start and a copy use, since a write sent again without one runs again, restamping the layout and applying the bound again; the platform's refusals (`422` `request.invalid` naming the member, `tree_digest` among them for a tree that is not the version's, `403` `auth.forbidden` for a runner, `404` `pipelex.catalog.not_found` naming the method or the version, `409` `pipelex.catalog.being_deleted`) are `ApiResponseError`s. One reader in `method-layouts.ts`, `readMethodLayout`, holds the write's answer and each entry of a report's `layouts` to the same rule, the six identity and payload members strings and the provenance an object with a string `producer` and `model`, its `seed` and `style` read as `null` and its `repair_rounds` as `0` when they do not fit; an answer breaking it is one the SDK cannot read, and an entry breaking it is left out of the report, a list left with none removed, so `layouts` is absent or holds at least one layout. `listMethodLayouts` reads the same list with no dry run, its `items` read entry by entry by that rule, and `setMethodLayoutsOff` writes the whole list of switched-off catalogs, an array or a `RequestArgumentError` before sending, its idempotency key sent as the write's is. See [method-layouts.md](./method-layouts.md).
|
|
166
168
|
- **Organizations:** `listMemberships`, `createOrganization`, `renameOrganization` (`PATCH`). Each membership carries the caller's `role_in_org`, an `OrgRole` (`admin`, `member` or `runner`) read open: a role a later platform adds arrives as its raw string, so a `switch` over it says what an unknown role does. The role is for display; what it may do is the platform's to decide, and a call refused to the caller's role is an `ApiResponseError`. The org "switch" is a WorkOS-session op (`/api/active-org`), not a `/v1` route — out of SDK scope.
|
|
167
169
|
- **Organization branding:** `getBranding` (`GET /v1/branding`, any role, web session or API key) and `updateOrganizationBranding` (`PATCH /v1/organizations/{org_id}/branding`, a write by the `admin` or the `member` role, never a `runner`) answer the same `OrganizationBranding`: the organization's name, its light and dark colour sets (`BrandingColors`), its square and wide logos (`LogoDescriptor`), its app `style` and `typeface`, and its read-only `white_label` entitlement, the last three read as `null`, `null` and `false` from a platform that predates them. The write's `OrganizationBrandingUpdate` sets a key given a value, clears a key given `null` and keeps a key left out; a refused field is named by its `location.field`, a colour by its dotted key, a logo by its slot in `ApiResponseError.errors` with a `LogoRefusalCode` when the platform measured it. See [organization-branding.md](./organization-branding.md).
|
|
168
170
|
- **Caller webhooks:** `listRunWebhookDeliveries`, `getRunWebhookDelivery` and `replayRunWebhookDelivery`, on `/v1/runs/{id}/webhook-deliveries`, `/v1/runs/{id}/webhook-deliveries/{delivery_id}` and its `/replay`, read a run's delivery log and send a settled delivery again, any member by web session or API key, the replay taking an `idempotencyKey` under which the platform stores its answer; `getWebhookSecret`, on `GET /v1/organizations/{org_id}/webhook-secret`, and `rotateWebhookSecret`, on `POST /v1/organizations/{org_id}/webhook-secret/rotate`, read and rotate the organization's signing secret, an admin's routes from a web session only, the rotation taking an `idempotencyKey` the platform never replays. See [webhooks.md](./webhooks.md).
|
package/docs/errors.md
CHANGED
|
@@ -96,7 +96,7 @@ What the hosted API answers a start sent under a key:
|
|
|
96
96
|
|
|
97
97
|
**A copy takes a key too.** `copyMethod` sends an `idempotencyKey` the same way, held to the same rule, and the hosted API keeps it for the same 24 hours, scoped to the caller and the method's organization. A copy binds no run, so its answers under a key differ from a start's: [method-copy.md](./method-copy.md#retrying-a-copy--idempotencykey) gives them.
|
|
98
98
|
|
|
99
|
-
**And a layout write.** `storeMethodLayout` sends an `idempotencyKey` the same way, held to the same rule. A write sent again without one runs again, restamping the layout and applying the bound of layouts a content keeps again, so a write whose answer was lost is sent again under the key it was first sent with, which answers it as the first write was answered: [method-layouts.md](./method-layouts.md#storing-a-layout) gives the answers. `setMethodLayoutsOff` takes a key by the same rule, since a write of the whole list sent again undoes a switch that landed in between.
|
|
99
|
+
**And a layout write.** `storeMethodLayout` sends an `idempotencyKey` the same way, held to the same rule. A write sent again without one runs again, restamping the layout and applying the bound of layouts a content keeps again, so a write whose answer was lost is sent again under the key it was first sent with, which answers it as the first write was answered: [method-layouts.md](./method-layouts.md#storing-a-layout) gives the answers. `setMethodLayoutsOff` takes a key by the same rule, since a write of the whole list sent again undoes a switch that landed in between. `freezeMethodShowcase` and `withdrawMethodShowcase` take one as well, by the same rule, which matters most to a withdrawal, since one sent again without a key answers a `404` ([method-showcases.md](./method-showcases.md#withdrawing-a-showcase)).
|
|
100
100
|
|
|
101
101
|
**So do a secret rotation and a delivery replay.** `rotateWebhookSecret` and `replayRunWebhookDelivery` send an `idempotencyKey` the same way, held to the same rule. A rotation's answer carries a secret, so the platform never replays it, while a replay's stored answer is given again: [webhooks.md](./webhooks.md) gives both.
|
|
102
102
|
|
package/docs/method-copy.md
CHANGED
|
@@ -59,7 +59,7 @@ The answer is a `200` discriminated on `outcome`, as `publishMethod`'s is, becau
|
|
|
59
59
|
|
|
60
60
|
| `outcome` | Members | When |
|
|
61
61
|
|---|---|---|
|
|
62
|
-
| `copied` | `method`, the copy, a `MethodData` with its `copied_from`; `examples_copied`; `stored_files_copied` | The copy exists in the destination. |
|
|
62
|
+
| `copied` | `method`, the copy, a `MethodData` with its `copied_from`; `examples_copied`; `stored_files_copied`; `showcases_copied` and `layouts_copied`, reserved and `0` for now, absent from a platform that predates them, which means none ([method-showcases.md](./method-showcases.md#fields-reserved-for-later)) | The copy exists in the destination. |
|
|
63
63
|
| `refused` | `reason`, `bundle_names_other_storage`; `message`, a sentence for a person; `references`, every `{ path, uri }` the destination cannot read and, in a duplicate, every one under the original's run files, ordered by path and then by reference | A `.mthds` file of the draft names a stored file outside the destination, which every run there would refuse, or, in a duplicate, a file under the original method's own run files, which erasing the original would remove. Nothing was written. |
|
|
64
64
|
|
|
65
65
|
**A duplicate is held to one more rule.** Every reference to the original's organization is one the destination can read, the original's storage being the destination's, but a reference under the original method's own run files, `pipelex-storage://<org_id>/<method_id>/…`, names a file one of the original's runs stored, and erasing the original sweeps those away: every run of the duplicate would then fail to fetch it. So such a reference is refused too, with the same verdict and the same reason, beside any the destination cannot read. It is the rule the copy's inputs follow: an input naming such a file is re-homed, while a bundle naming one is refused, since the platform rewrites a copy's inputs but never its bundles. Every other reference of the organization, an upload under its `assets/` or another method's run file, passes in a duplicate as it does for the original. A copy into another organization needs no such rule, since it already refuses every reference to the original's organization. The `message` says why for each kind of reference.
|
package/docs/method-examples.md
CHANGED
|
@@ -12,6 +12,7 @@ An **example** is a named set of inputs saved on a stored method, so the method
|
|
|
12
12
|
| `inputs` | A JSON object: the inputs as a run of the method takes them. The platform answers them exactly as they were saved; the client reads an integer past `Number.MAX_SAFE_INTEGER` as a `bigint` holding its exact digits and every other number as a double, so `3.0` reads as `3` ([below](#numbers-in-an-examples-inputs)). |
|
|
13
13
|
| `input_revision` | Starts at 1 and rises by one each time the inputs change. |
|
|
14
14
|
| `latest_run_id` | The latest run of the current inputs, or `null`. It may name a run deleted since, whose read then answers `404`. |
|
|
15
|
+
| `showcase_id` | The showcase frozen from the example's latest run, or `null`. Reserved: the platform answers `null` for now, and clears it with `latest_run_id` when the inputs change. A platform that predates it leaves it out, which means none ([method-showcases.md](./method-showcases.md#fields-reserved-for-later)). |
|
|
15
16
|
| `created_by_user_id`, `created_at`, `updated_at` | Who saved it, when, and when it last changed. |
|
|
16
17
|
| `kept_by_assistant` | Whether the build assistant keeps this example's inputs current with its test inputs: `true` on an example the assistant's save created, `false` on every other, and `false` from the first inputs change a person makes. A rename leaves it as it is ([below](#the-build-assistants-example)). |
|
|
17
18
|
|
package/docs/method-layouts.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A **layout** is a data file a producer designed for one pipe of a method: a tree of elements written in the vocabulary of a catalog of components, every value bound to a path in the host's form state, carrying no field descriptions and no data of its own. A host renders it over the input-form descriptor the same method's validate projects, and renders the plain form instead whenever it cannot. The hosted platform stores layouts beside a method's published versions and hands them back, on a direct read by the version or on a validate of the method by id, so a method laid out once opens with its layout for everyone who opens it. It never produces a layout, never parses one and never judges one against a catalog or a descriptor: that is the producer's work before the write and the host's before it renders.
|
|
4
4
|
|
|
5
|
-
The client reaches the write on the hosted API's `POST /v1/methods/{method_id}/versions/{version}/layouts`, the direct read on `GET` of the same route, the read through `POST /v1/validate` under the `layouts` view, and the off switch on `PUT /v1/methods/{method_id}/layouts-off`. The types are in `src/method-layouts.ts`, exported from the package's root: `MethodLayoutInput` and `LayoutProvenanceInput` for the write, `MethodLayout` and `LayoutProvenance` for what is stored, and `MethodLayoutList` for the direct read. The storage and the `layouts` token are a Pipelex hosted feature; the shapes are stated brand-neutrally, snake_case with no `pipelex_` prefix, as the input-form descriptor they are rendered over is. The conformance spec `pipelex-hosted-method-layouts.md`, in the workspace's `conformance` repository, states the contract.
|
|
5
|
+
The client reaches the write on the hosted API's `POST /v1/methods/{method_id}/versions/{version}/layouts`, the direct read on `GET` of the same route, the read of the draft's layouts on `GET /v1/methods/{method_id}/draft/layouts`, the read through `POST /v1/validate` under the `layouts` view, and the off switch on `PUT /v1/methods/{method_id}/layouts-off`. The types are in `src/method-layouts.ts`, exported from the package's root: `MethodLayoutInput` and `LayoutProvenanceInput` for the write, `MethodLayout` and `LayoutProvenance` for what is stored, and `MethodLayoutList` for the direct read. The storage and the `layouts` token are a Pipelex hosted feature; the shapes are stated brand-neutrally, snake_case with no `pipelex_` prefix, as the input-form descriptor they are rendered over is. The conformance spec `pipelex-hosted-method-layouts.md`, in the workspace's `conformance` repository, states the contract.
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
import { PipelexApiClient } from "@pipelex/sdk";
|
|
@@ -123,6 +123,14 @@ const { items } = await client.listMethodLayouts("mt_abc123", 3, {
|
|
|
123
123
|
});
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
+
## Reading the draft's layouts
|
|
127
|
+
|
|
128
|
+
| Method | Route | Returns |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| `listMethodDraftLayouts(methodId, options?)` | `GET /v1/methods/{id}/draft/layouts` | A `MethodLayoutList` of the layouts stored for the draft's content, newest first, `items` empty for an empty draft or a draft none was designed for. |
|
|
131
|
+
|
|
132
|
+
A layout is keyed by its content, so a draft holding a published tree finds that tree's layouts here, and a builder sees the designs of what it is editing. It reads for the organization that holds the method alone, since a draft is its holder's. It takes a bare catalog id, and `options.signal` cancels the read. The platform answers `404` `pipelex.catalog.not_found` for a method the organization does not hold, another organization's public one included, and `409` `pipelex.catalog.being_deleted` during its erasure.
|
|
133
|
+
|
|
126
134
|
## Switching a page's design off
|
|
127
135
|
|
|
128
136
|
A builder can turn a page's design off and on, per catalog, without losing it. The state is `layouts_off`, the catalog slugs whose layouts no host draws, read on `MethodData`, `MethodDetail` and `PublicMethodDetail` and absent from a platform that predates it, which means none.
|