@pipelex/sdk 0.3.1 → 0.4.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/dist/models.d.ts CHANGED
@@ -136,19 +136,95 @@ export interface ValidationErrorItem {
136
136
  missing_concept_code?: string;
137
137
  declared_concepts?: string[];
138
138
  }
139
+ /** Which analysis produced a `Diagnostic` — mirror of `pipelex-tools`' closed kind set. */
140
+ export type DiagnosticKind = "syntax" | "semantic" | "schema";
141
+ /** Source span of a `Diagnostic` — byte offsets plus 1-based line/column coordinates. */
142
+ export interface DiagnosticRange {
143
+ start_offset: number;
144
+ end_offset: number;
145
+ start_line: number;
146
+ start_col: number;
147
+ end_line: number;
148
+ end_col: number;
149
+ }
150
+ /**
151
+ * One structured lint/format diagnostic — mirror of pipelex's `Diagnostic`.
152
+ * `severity` stays an open string (the server does not close the vocabulary);
153
+ * `location` and `range` are `null` when the analysis cannot attribute a span.
154
+ */
155
+ export interface Diagnostic {
156
+ kind: DiagnosticKind;
157
+ severity: string;
158
+ message: string;
159
+ location: string | null;
160
+ range: DiagnosticRange | null;
161
+ }
162
+ /** `POST /v1/lint` 200 body — the diagnostics of one linted `.mthds` file. */
163
+ export interface LintResponse {
164
+ diagnostics: Diagnostic[];
165
+ }
166
+ /**
167
+ * `POST /v1/format` 200 body — the canonically formatted content, whether it
168
+ * differs from the submitted one, and any diagnostics found on the way. A syntax
169
+ * error yields `changed: false` with the content echoed back unchanged.
170
+ */
171
+ export interface FormatResponse {
172
+ formatted: string;
173
+ changed: boolean;
174
+ diagnostics: Diagnostic[];
175
+ }
139
176
  export type ConceptRepresentationFormat = "json" | "python" | "schema";
140
- export interface BuildInputsRequest {
141
- mthds_contents: string[];
142
- pipe_code: string;
177
+ /** Encoding of a `/v1/build/inputs` template. Decides which field carries it back. */
178
+ export type InputsTemplateFormat = "json" | "toml";
179
+ /**
180
+ * One MTHDS file in a build closure. `source` is an optional provenance label (a
181
+ * filename, a URI) that the server threads onto every diagnostic it raises from
182
+ * this file, so an invalid verdict can point at the file that caused it.
183
+ *
184
+ * NOT the same type as `MthdsFile` (the one `validateFiles()` takes), which the
185
+ * client adapts into `/v1/validate`'s parallel `mthds_contents` + `mthds_sources`
186
+ * arrays: that route spells the label `uri`, this envelope spells it `source`. The
187
+ * two collapse into one only if `/v1/validate` ever migrates onto `files[]` — a
188
+ * protocol-level change owned by the MTHDS standard, not ours to make here.
189
+ */
190
+ export interface MthdsFileItem {
191
+ content: string;
192
+ source?: string;
143
193
  }
144
- export interface BuildOutputRequest {
145
- mthds_contents: string[];
146
- pipe_code: string;
194
+ /**
195
+ * The closure + pipe selector every `/v1/build/*` route shares.
196
+ *
197
+ * Supply the closure EITHER as inline `files` OR as a `method_ref` into the method
198
+ * registry — never both. `method_ref` is reserved: the registry does not exist yet,
199
+ * so the server answers `501` for it today.
200
+ */
201
+ export interface BuildRequestBase {
202
+ files?: MthdsFileItem[];
203
+ method_ref?: string;
204
+ /**
205
+ * The pipe to project, as a QUALIFIED `domain.pipe_code` ref. Omit it to default
206
+ * to the closure's declared `main_pipe` — which fails (422) when the closure
207
+ * declares none, or declares several across its domains.
208
+ */
209
+ pipe_ref?: string;
210
+ }
211
+ export interface BuildInputsRequest extends BuildRequestBase {
212
+ /** `json` (default) puts the parsed template in `inputs`; `toml` puts raw text in `inputs_toml`. */
213
+ format?: InputsTemplateFormat;
214
+ /** Emit the ceremonial `{concept, content}` envelope per input. Defaults to the light shape. */
215
+ explicit?: boolean;
216
+ }
217
+ export interface BuildOutputRequest extends BuildRequestBase {
218
+ /** `schema` (default) and `json` put a parsed object in `output`; `python` puts source in `output_python`. */
147
219
  format?: ConceptRepresentationFormat;
148
220
  }
149
- export interface BuildRunnerRequest {
150
- mthds_contents: string[];
151
- pipe_code: string;
221
+ export interface BuildRunnerRequest extends BuildRequestBase {
222
+ /**
223
+ * Accept unresolved pipe signatures as pending rather than invalid. Alone among
224
+ * the build routes this one still runs the dry-run sweep, and the flag only ever
225
+ * parameterized that sweep.
226
+ */
227
+ allow_signatures?: boolean;
152
228
  }
153
229
  export interface ConceptRequest {
154
230
  spec: Record<string, unknown>;
@@ -157,12 +233,92 @@ export interface PipeSpecRequest {
157
233
  pipe_type: string;
158
234
  spec: Record<string, unknown>;
159
235
  }
160
- export interface BuildRunnerResponse {
161
- python_code: string;
162
- pipe_code: string;
163
- success: boolean;
236
+ /**
237
+ * The `is_valid: false` arm shared by every `/v1/build/*` route.
238
+ *
239
+ * The build routes follow `/validate`'s discipline: an unresolvable closure is the
240
+ * *successful product* of the call (the request was well-formed, the library was
241
+ * not), so it rides a **200** discriminated on `is_valid` — never a 4xx. Only a
242
+ * no-verdict condition (an unknown `pipe_ref`, `method_ref`, auth, a server fault)
243
+ * throws `ApiResponseError`. Branch on `is_valid`, never on the transport.
244
+ */
245
+ export interface CrateInvalidReport {
246
+ is_valid: false;
247
+ validation_errors: ValidationErrorItem[];
164
248
  message: string;
165
249
  }
250
+ /** Fields the valid arm of every `/v1/build/*` route carries. */
251
+ interface BuildValidReportBase {
252
+ is_valid: true;
253
+ /** The qualified pipe that was projected — the RESOLVED selector, always `domain.pipe_code`. */
254
+ pipe_ref: string;
255
+ /** The `pipe_ref` as submitted. Absent when it was omitted and defaulted to `main_pipe`. */
256
+ requested_pipe_ref?: string;
257
+ message: string;
258
+ }
259
+ /**
260
+ * The `/v1/build/inputs` valid arm. The template rides ONE of two fields, chosen by
261
+ * `format`: `inputs` (a parsed object) for `json`, `inputs_toml` (raw text) for
262
+ * `toml`. TOML cannot be carried as a parsed object without losing what makes it
263
+ * worth asking for — its concept comments and key order — so the two are separate
264
+ * fields and the unused one is absent from the body entirely.
265
+ *
266
+ * That "absent entirely" is why this is a union rather than one interface with two
267
+ * optional fields: `format` is a real discriminant, so narrowing on it hands you the
268
+ * field it selected as REQUIRED, with the other one statically unreachable.
269
+ */
270
+ interface BuildInputsJsonReport extends BuildValidReportBase {
271
+ format: "json";
272
+ explicit: boolean;
273
+ inputs: Record<string, unknown>;
274
+ inputs_toml?: never;
275
+ }
276
+ interface BuildInputsTomlReport extends BuildValidReportBase {
277
+ format: "toml";
278
+ explicit: boolean;
279
+ inputs?: never;
280
+ inputs_toml: string;
281
+ }
282
+ export type BuildInputsValidReport = BuildInputsJsonReport | BuildInputsTomlReport;
283
+ export type BuildInputsResponse = BuildInputsValidReport | CrateInvalidReport;
284
+ /**
285
+ * The `/v1/build/output` valid arm. Same two-field split as the inputs template, for
286
+ * the same reason: `schema` and `json` are objects, `python` is source text — and so
287
+ * it is a discriminated union for the same reason too.
288
+ */
289
+ interface BuildOutputObjectReport extends BuildValidReportBase {
290
+ format: "schema" | "json";
291
+ output: Record<string, unknown>;
292
+ output_python?: never;
293
+ }
294
+ interface BuildOutputPythonReport extends BuildValidReportBase {
295
+ format: "python";
296
+ output?: never;
297
+ output_python: string;
298
+ }
299
+ export type BuildOutputValidReport = BuildOutputObjectReport | BuildOutputPythonReport;
300
+ export type BuildOutputResponse = BuildOutputValidReport | CrateInvalidReport;
301
+ /** One stamped generated file in the structures projection. */
302
+ export interface GeneratedArtifact {
303
+ path: string;
304
+ content: string;
305
+ }
306
+ /**
307
+ * The typed-structures projection the runner script imports from. Write `artifacts`
308
+ * and `lock` (as `lock_filename`) under `directory`, relative to the runner script,
309
+ * and the returned `python_code` runs against them.
310
+ */
311
+ export interface RunnerStructures {
312
+ directory: string;
313
+ artifacts: GeneratedArtifact[];
314
+ lock: string;
315
+ lock_filename: string;
316
+ }
317
+ export interface BuildRunnerValidReport extends BuildValidReportBase {
318
+ python_code: string;
319
+ structures: RunnerStructures;
320
+ }
321
+ export type BuildRunnerResponse = BuildRunnerValidReport | CrateInvalidReport;
166
322
  export interface ConceptResponse {
167
323
  success: boolean;
168
324
  concept_code: string;
@@ -174,3 +330,4 @@ export interface PipeSpecResponse {
174
330
  pipe_type: string;
175
331
  toml: string;
176
332
  }
333
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipelex/sdk",
3
- "version": "0.3.1",
3
+ "version": "0.4.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": {
@@ -19,8 +19,10 @@
19
19
  },
20
20
  "scripts": {
21
21
  "build": "tsc",
22
+ "build:hook": "node scripts/build-hook.mjs",
22
23
  "test": "vitest run",
23
24
  "test:coverage": "vitest run --coverage",
25
+ "test:e2e": "vitest run --config vitest.e2e.config.ts",
24
26
  "typecheck": "tsc --noEmit",
25
27
  "typecheck:test": "tsc -p tsconfig.test.json --noEmit",
26
28
  "lint": "eslint src/ tests/",
@@ -41,9 +43,11 @@
41
43
  },
42
44
  "devDependencies": {
43
45
  "@eslint/js": "^9.39.4",
46
+ "@pipelex/tools-wasm": "^0.1.0",
44
47
  "@types/node": "^22.12.0",
45
48
  "@vitest/coverage-v8": "^4.1.9",
46
49
  "dependency-cruiser": "^17.4.3",
50
+ "esbuild": "^0.25.12",
47
51
  "eslint": "^9.39.4",
48
52
  "globals": "^16.5.0",
49
53
  "prettier": "^3.8.4",
@@ -52,6 +56,6 @@
52
56
  "vitest": "^4.0.18"
53
57
  },
54
58
  "dependencies": {
55
- "mthds": "^0.18.0"
59
+ "mthds": "^0.19.0"
56
60
  }
57
61
  }