@pipelex/sdk 0.65.0 → 0.66.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.
@@ -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"}
@@ -433,13 +433,15 @@ export type MethodPublishOutcome = "published" | "unchanged" | "refused";
433
433
  * - `thumbnail_invalid`: the method is public, and no file directly under the draft's
434
434
  * `thumbnails/` is a valid thumbnail (a PNG, JPEG or WebP of at least 800×400 pixels);
435
435
  * - `storage_reference`: the method is public, and a `.mthds` file of the draft names a
436
- * `pipelex-storage://` file, which other organizations cannot read.
436
+ * `pipelex-storage://` file, which other organizations cannot read;
437
+ * - `showcase_missing`: the method is public, and the draft's tree holds no showcase for other
438
+ * organizations to look at. Reserved: the platform states it and does not raise it yet.
437
439
  *
438
- * `thumbnail_missing`, `thumbnail_invalid` and `storage_reference` refuse only a public method's
439
- * publish, so that the card of a template never loses its picture and every organization can run
440
- * what it reads.
440
+ * `thumbnail_missing`, `thumbnail_invalid`, `storage_reference` and `showcase_missing` refuse only
441
+ * a public method's publish, so that the card of a template never loses its picture, every
442
+ * organization can run what it reads, and a template never appears with nothing to show.
441
443
  */
442
- export type MethodPublishRefusalReason = "invalid" | "not_runnable" | "thumbnail_missing" | "thumbnail_invalid" | "storage_reference";
444
+ export type MethodPublishRefusalReason = "invalid" | "not_runnable" | "thumbnail_missing" | "thumbnail_invalid" | "storage_reference" | "showcase_missing";
443
445
  /** A publish that wrote a new version. */
444
446
  export interface MethodPublished {
445
447
  outcome: "published";
@@ -654,6 +656,17 @@ export interface MethodCopied {
654
656
  examples_copied: number;
655
657
  /** How many distinct stored files were copied into the destination for the copy's inputs. */
656
658
  stored_files_copied: number;
659
+ /**
660
+ * How many showcases of the tree taken the copy holds, each copied with its files. Reserved: the
661
+ * platform answers `0` until copies carry showcases, and a platform that predates it leaves it
662
+ * out, which means none.
663
+ */
664
+ showcases_copied?: number;
665
+ /**
666
+ * How many layouts of the tree taken the copy holds. Reserved: the platform answers `0` until
667
+ * copies carry layouts, and a platform that predates it leaves it out, which means none.
668
+ */
669
+ layouts_copied?: number;
657
670
  }
658
671
  /**
659
672
  * A copy refused before anything was written: a bundle of the draft names stored files the copy
@@ -729,6 +742,13 @@ export interface MethodExample {
729
742
  * changed. It may name a run deleted since, which then reads as not found.
730
743
  */
731
744
  latest_run_id: string | null;
745
+ /**
746
+ * The showcase frozen from the example's latest run, the output a person may look at without
747
+ * running the method; `null` when none was, and cleared when the inputs change. Reserved: the
748
+ * platform answers `null` until copies born from a showcase fill it, and a platform that predates
749
+ * it leaves it out, which means none.
750
+ */
751
+ showcase_id?: string | null;
732
752
  /** The canonical id of the member who saved the example; it confers nothing. */
733
753
  created_by_user_id: string;
734
754
  /** ISO-8601 UTC instant of the example's creation. */
package/dist/version.d.ts CHANGED
@@ -3,4 +3,4 @@
3
3
  * `User-Agent` without importing the public barrel. Kept in sync with
4
4
  * `package.json` — enforced by `tests/index.test.ts`.
5
5
  */
6
- export declare const SDK_VERSION = "0.65.0";
6
+ export declare const SDK_VERSION = "0.66.0";
package/dist/version.js CHANGED
@@ -3,5 +3,5 @@
3
3
  * `User-Agent` without importing the public barrel. Kept in sync with
4
4
  * `package.json` — enforced by `tests/index.test.ts`.
5
5
  */
6
- export const SDK_VERSION = "0.65.0";
6
+ export const SDK_VERSION = "0.66.0";
7
7
  //# sourceMappingURL=version.js.map
@@ -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).
@@ -162,7 +163,8 @@ The hosted catalog/account routes the webapp drives. All ride the same `{base}/v
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 layouts:** `storeMethodLayout` and `listMethodLayouts`, on `/v1/methods/{id}/versions/{n}/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
+ - **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
 
@@ -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.
@@ -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
 
@@ -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.
@@ -0,0 +1,100 @@
1
+ # A method's showcases
2
+
3
+ A **showcase** is a completed run of a method, frozen: its inputs, its main output, the forms and contracts that describe them, and a private copy of every stored file they name. It exists so that people can see what a method really produces without spending credit. It differs from what sits beside it: an **example** is the builder's private test bench, whose output is whatever its latest run left, and a **layout's written sample** is invented, while a showcase is real output that stays exactly as it was frozen.
4
+
5
+ The client reaches the hosted API's `POST` and `GET /v1/methods/{method_id}/showcases`, `GET` and `DELETE /v1/methods/{method_id}/showcases/{showcase_id}`, and `GET /v1/methods/{method_id}/versions/{version}/showcases[/{showcase_id}]`. The types are in `src/method-showcases.ts`, exported from the package's root. The platform's own account of the contract is `platform/docs/method-showcases.md` in `pipelex-server`. This page is the twin of `pipelex-sdk`'s `docs/method-showcases.md`.
6
+
7
+ ```ts
8
+ import { PipelexApiClient } from "@pipelex/sdk";
9
+
10
+ const client = new PipelexApiClient();
11
+
12
+ // A builder freezes a completed run of the draft, then publishes.
13
+ const verdict = await client.freezeMethodShowcase("mt_abc123", {
14
+ run_id: "run_1",
15
+ name: "March receipt",
16
+ });
17
+ switch (verdict.outcome) {
18
+ case "frozen":
19
+ case "unchanged":
20
+ console.log(verdict.showcase.showcase_id);
21
+ break;
22
+ case "refused":
23
+ console.log(verdict.reason, verdict.message);
24
+ break;
25
+ }
26
+
27
+ // Any reader of a published version, another organization's on a public method included.
28
+ const { items } = await client.listMethodVersionShowcases("mt_abc123", 3);
29
+ const detail = await client.getMethodVersionShowcase("mt_abc123", 3, items[0]!.showcase_id);
30
+ console.log(detail.document.main_stuff, detail.files.map((file) => file.file_name));
31
+ ```
32
+
33
+ ## Freezing a run
34
+
35
+ | Method | Route | Answer |
36
+ |---|---|---|
37
+ | `freezeMethodShowcase(methodId, { run_id, name }, options?)` | `POST /v1/methods/{id}/showcases` | A `MethodShowcaseFreezeResult`, a `200` discriminated on `outcome` |
38
+
39
+ `run_id` is a run's `pipeline_run_id`. The body is closed, and the client sends these members and nothing else. Freezing precedes publishing: a builder freezes a run of the draft, so a showcase can exist before the version that shows it, and another organization reads one only through a published version holding its tree.
40
+
41
+ A run that cannot be frozen is a verdict about the run, not a failure of the request, so branch on `outcome`, never on the status:
42
+
43
+ | `outcome` | Members | When |
44
+ |---|---|---|
45
+ | `frozen` | `showcase`, a new summary | The run was frozen. |
46
+ | `unchanged` | `showcase`, the one that stands | This run is already a showcase, whatever has happened to its tree since. Nothing is written, and the name in the request is ignored. |
47
+ | `refused` | `reason`, `message` | The run cannot be frozen, and nothing was written. |
48
+
49
+ | `reason` | When |
50
+ |---|---|
51
+ | `run_not_usable` | The run is not this method's in this organization, did not complete, kept no results (a blocking `execute` stores none), stored no output or forms, does not say which pipe it ran, or kept no record of inputs its pipe declares. |
52
+ | `tree_not_current` | The run's tree is neither the draft's nor the latest published version's, or the run records none. |
53
+ | `file_not_readable` | The document names a file that is gone or outside the organization, or holds a signed link the freeze could not rewrite. |
54
+ | `too_large` | A stored artifact of the run, the document, the number of files or their total size is past what one showcase holds. |
55
+ | `too_many` | The tree already holds as many showcases as one tree keeps. |
56
+
57
+ `reason` is read open, typed `MethodShowcaseRefusalReason | (string & {})`: a reason a later platform adds arrives as its raw string, still a verdict, so show its `message` when you do not handle it. An `outcome` that is none of these, a `showcase` that does not read as a summary, and a refusal whose `reason` or `message` is not a string are each an answer the SDK cannot read, thrown as an `ApiResponseError` coded `client.response_unreadable`.
58
+
59
+ **Who may freeze.** The write changes the method, so it takes an `admin` or a `member` of the method's organization; a `runner` is refused with `403` `auth.forbidden`. Other refusals are thrown as `ApiResponseError`: `404` `pipelex.catalog.not_found` for a method the organization does not hold, `409` `pipelex.catalog.being_deleted` during its erasure, `422` `request.invalid` for a body that does not validate, and `503` `runtime.unavailable`, with `retry` `yes`, past the freeze's deadline.
60
+
61
+ A `run_id` or a `name` that is not a non-empty string is a `RequestArgumentError` before any request. `options.idempotencyKey` is sent as the `Idempotency-Key` header. A freeze sent again without a key is safe in itself, since freezing a run already frozen answers `unchanged`.
62
+
63
+ ## Withdrawing a showcase
64
+
65
+ | Method | Route | Answer |
66
+ |---|---|---|
67
+ | `withdrawMethodShowcase(methodId, showcaseId, options?)` | `DELETE /v1/methods/{id}/showcases/{showcase_id}` | Nothing, on a `204` |
68
+
69
+ The row goes first, which closes every read at once, and then its stored document and files. It runs no check, even on a public method's last showcase, because taking down something published by mistake must never be refused; the method then stays public, and its next publish needs a showcase. What another organization already copied stays theirs.
70
+
71
+ A second withdrawal is a `404` `pipelex.catalog.not_found` with `params.resource` `example`, so a withdrawal whose answer was lost reads as a failure when sent again without a key. Send it under the same `options.idempotencyKey` and it is answered as the first was. A `runner` is refused with `403` `auth.forbidden`.
72
+
73
+ ## Reading showcases
74
+
75
+ | Method | Route | Who | Answer |
76
+ |---|---|---|---|
77
+ | `listMethodVersionShowcases(methodId, version, options?)` | `GET /v1/methods/{id}/versions/{n}/showcases` | Every reader of the version | The showcases of the tree it holds, oldest first |
78
+ | `getMethodVersionShowcase(methodId, version, showcaseId, options?)` | `GET …/versions/{n}/showcases/{showcase_id}` | The same | One showcase in full |
79
+ | `listMethodShowcases(methodId, options?)` | `GET /v1/methods/{id}/showcases` | The holding organization's members alone | Every showcase across every tree, each naming its digest, oldest first |
80
+ | `getMethodShowcase(methodId, showcaseId, options?)` | `GET /v1/methods/{id}/showcases/{showcase_id}` | The same | One showcase in full |
81
+
82
+ **Another organization never reads a showcase of a tree no published version holds**: a version's read looks the showcase up under the digest that version names, and the holder's routes answer another organization a `404`, public method or not.
83
+
84
+ **A summary** (`MethodShowcaseSummary`) is `showcase_id`, `name`, `pipe_ref`, `tree_digest` and `frozen_at`. A list's `items` are read entry by entry, so an entry that does not read as a summary is left out, and an answer whose `items` is not an array is one the SDK cannot read.
85
+
86
+ **A detail** (`MethodShowcaseDetail`) adds `document` and `files`. `document` holds `inputs`, `main_stuff`, `input_form`, `output_form` and `pipe_io_contracts`, relayed as they were stored, and is read with `parseExactJson`, so an integer past `Number.MAX_SAFE_INTEGER` is a `bigint`. `files` lists `address`, `file_name`, `media_type`, `size_bytes` and `url` for every stored file the document names. A detail is held whole, unlike a list: one that breaks its shape, a `document` member left out or a `files` entry included, is an answer the SDK cannot read, thrown with its signed links redacted.
87
+
88
+ **A document never holds a signed link.** After a freeze, an image that was a stored link is an `src="pipelex-storage://…"` address, and a renderer replaces each address with the `url` of the matching entry of `files`. `url` is a short-lived presigned `GET` of the file's bytes: a bearer credential, which belongs on a server and never in a browser.
89
+
90
+ The refusals are thrown as `ApiResponseError`: `404` `pipelex.catalog.not_found` for an unknown method or another organization's internal one (`params.resource` `method`), a version never published (`params.resource` `version`), and a showcase the route does not hold (`params.resource` `example`, since the values of that parameter are the published registry's); `409` `pipelex.catalog.being_deleted` during the erasure of the caller's own method. A `version` that is not a positive integer and a showcase id that is empty, `.` or `..`, or holds a lone surrogate are refused with `RequestArgumentError` before any request. `options.signal` cancels a read.
91
+
92
+ ## Fields reserved for later
93
+
94
+ The platform answers these, and nothing fills them yet, so that the SDKs are released once:
95
+
96
+ - `showcase_id` on an example (`MethodExample.showcase_id`), `null` for now, and cleared with `latest_run_id` when the inputs change. A platform that predates it leaves it out, which means none.
97
+ - `showcase_missing` on a publish's refusal (`MethodPublishRefused.reason`), which the platform states and does not raise yet.
98
+ - `showcases_copied` and `layouts_copied` on a copy's verdict (`MethodCopied`), which stay `0`. A platform that predates them leaves them out, which means none.
99
+
100
+ `GET /v1/version` lists `method_showcases` in its `extensions` when the platform serves these routes. The SDK types no field for it: read it off `version()`, as the [layouts' discovery](./method-layouts.md) does.
@@ -106,5 +106,6 @@ A public method's publish is held to more than any draft's, so that a template's
106
106
  | `storage_reference` | A `.mthds` file of the draft names a `pipelex-storage://` file, which other organizations cannot read. |
107
107
  | `thumbnail_missing` | The draft's tree holds no file directly under `thumbnails/`, or none was read within the publish's time; a retry may read them in time. |
108
108
  | `thumbnail_invalid` | No file directly under `thumbnails/` is a valid thumbnail. |
109
+ | `showcase_missing` | The draft's tree holds no showcase for other organizations to look at. Reserved: the platform states it and does not raise it yet ([method-showcases.md](./method-showcases.md#fields-reserved-for-later)). |
109
110
 
110
111
  Each is a verdict, a `200` with a `message` for a person and the runner's valid `validation`, never a thrown error. `MethodPublishRefused.reason` is read open, typed `MethodPublishRefusalReason | (string & {})`: a reason a later platform adds arrives as its raw string, still a verdict, so a client shows its `message` when it does not handle the reason. An internal method's publish never meets the reasons of this table. A method made public while its publish ran is a `503` with nothing written, safe to retry.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipelex/sdk",
3
- "version": "0.65.0",
3
+ "version": "0.66.0",
4
4
  "description": "TypeScript SDK for the Pipelex hosted API — execute methods, manage runs, and call the product surface.",
5
5
  "license": "MIT",
6
6
  "repository": {