@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,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.
|
package/docs/public-methods.md
CHANGED
|
@@ -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.
|