@pipelex/mthds-ui 0.31.0 → 0.33.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.
@@ -1,4 +1,4 @@
1
- import { C as ConceptInfo, P as PipeBlueprintUnion, a as PresenceMarker, b as GraphSpec, V as ValidationIssue } from '../types-KYRgLdlh.js';
1
+ import { C as ConceptInfo, P as PipeBlueprintUnion, a as PresenceMarker, b as GraphSpec, V as ValidationIssue } from '../types-MvxsDLCo.js';
2
2
  export { P as ParsedPipeRef, m as makePipeRef, p as parsePipeRef } from '../pipeRefs-BQJO5nh5.js';
3
3
 
4
4
  type DiagnosticSeverity = "error" | "warning";
@@ -7,7 +7,7 @@ import {
7
7
  KNOWN_PIPE_TYPES,
8
8
  isBindingStepSpec,
9
9
  isPluralMultiplicity
10
- } from "../chunk-QRO3TYZE.js";
10
+ } from "../chunk-TMZ2JR2J.js";
11
11
  import {
12
12
  __spreadProps,
13
13
  __spreadValues
@@ -275,6 +275,7 @@ function stringArrayOrNull(value) {
275
275
  return value.filter((item) => typeof item === "string");
276
276
  }
277
277
  var PLAIN_NAME_RE = /^[a-z][a-z0-9_]*$/;
278
+ var PRIVATE_BINDING_NAME_PREFIX = "_bound_";
278
279
  function bindingStepFor(dottedPath) {
279
280
  const plainName = dottedPath.slice(dottedPath.lastIndexOf(".") + 1);
280
281
  return `{ from = "${dottedPath}", result = "${plainName}" }`;
@@ -283,13 +284,61 @@ function dottedInputNameRemedy(dottedName) {
283
284
  const root = dottedName.slice(0, dottedName.indexOf("."));
284
285
  return `an input names one whole value, so its name cannot reach into a field with a dot; declare "${root}" with its whole concept and read the field through it, or have the calling sequence bind the field to a plain name with a binding step (${bindingStepFor(dottedName)}) and declare that name`;
285
286
  }
286
- function invalidInputNameReason(name) {
287
+ function isDottedFieldPath(name) {
287
288
  const segments = name.split(".");
288
- if (segments.length > 1 && segments.every((segment) => PLAIN_NAME_RE.test(segment))) {
289
+ return segments.length > 1 && segments.every((segment) => PLAIN_NAME_RE.test(segment));
290
+ }
291
+ function invalidInputNameReason(name) {
292
+ if (isDottedFieldPath(name)) {
289
293
  return `is not a plain input name: ${dottedInputNameRemedy(name)}`;
290
294
  }
291
295
  return "is not a plain input name, which is a lowercase letter followed by lowercase letters, digits and underscores";
292
296
  }
297
+ function reportInvalidStoredName(name, storedUnder, pipeCode, path, ctx) {
298
+ if (name === null || PLAIN_NAME_RE.test(name)) return;
299
+ let why;
300
+ if (name.startsWith(PRIVATE_BINDING_NAME_PREFIX)) {
301
+ why = `and the prefix "${PRIVATE_BINDING_NAME_PREFIX}" is reserved for the runtime's own names`;
302
+ } else if (name.includes(".")) {
303
+ why = "and an input names one whole value, so its name cannot reach into a field with a dot";
304
+ } else {
305
+ why = "and an input name is a lowercase letter followed by lowercase letters, digits and underscores";
306
+ }
307
+ ctx.diagnostics.push({
308
+ severity: "warning",
309
+ code: "invalid-input-name",
310
+ message: `pipe "${pipeCode}": ${storedUnder} "${name}", which is not a plain input name: a pipe reads the value through an input, ${why} \u2014 drawn as written`,
311
+ path
312
+ });
313
+ }
314
+ function reportInvalidBatchListName(name, branchPipeCode, pipeCode, ctx) {
315
+ if (name === null || PLAIN_NAME_RE.test(name)) return;
316
+ let why;
317
+ if (isDottedFieldPath(name)) {
318
+ const plainName = name.slice(name.lastIndexOf(".") + 1);
319
+ const branch = branchPipeCode === null ? "the branch pipe" : `"${branchPipeCode}"`;
320
+ why = `: a PipeBatch maps over a list it declares as an input of its own, so declare the list as "${plainName}" and have the calling sequence bind the field to it with a binding step (${bindingStepFor(name)}), or have the calling sequence run ${branch} in a step that batches over the field itself`;
321
+ } else {
322
+ why = ", which is a lowercase letter followed by lowercase letters, digits and underscores";
323
+ }
324
+ ctx.diagnostics.push({
325
+ severity: "warning",
326
+ code: "invalid-input-name",
327
+ message: `pipe "${pipeCode}": input_list_name "${name}" is not a plain input name${why} \u2014 drawn as written`,
328
+ path: `pipe.${pipeCode}.input_list_name`
329
+ });
330
+ }
331
+ function reportReservedBatchOver(batchOver, pipeRef, pipeCode, path, ctx) {
332
+ if (batchOver === null || batchOver.includes(".") || !batchOver.startsWith(PRIVATE_BINDING_NAME_PREFIX)) {
333
+ return;
334
+ }
335
+ ctx.diagnostics.push({
336
+ severity: "warning",
337
+ code: "invalid-input-name",
338
+ message: `pipe "${pipeCode}": sub-pipe "${pipeRef}" batches over "${batchOver}", which takes the prefix "${PRIVATE_BINDING_NAME_PREFIX}" the runtime reserves for the list a dotted batch_over binds, a name only the runtime writes or reads \u2014 drawn as written`,
339
+ path
340
+ });
341
+ }
293
342
  function tomlKey(key) {
294
343
  return /^[A-Za-z0-9_-]+$/.test(key) ? key : JSON.stringify(key);
295
344
  }
@@ -359,6 +408,24 @@ function normalizeOutput(raw, pipeCode, ctx) {
359
408
  });
360
409
  return { concept: nativeConceptInfo("Anything"), multiplicity: null, presence: "plain" };
361
410
  }
411
+ function reportSubPipeNames(raw, pipeCode, path, ctx) {
412
+ const pipeRef = raw.pipe;
413
+ reportInvalidStoredName(
414
+ strOrNull(raw.result),
415
+ `sub-pipe "${pipeRef}" stores its result under`,
416
+ pipeCode,
417
+ `${path}.result`,
418
+ ctx
419
+ );
420
+ reportInvalidStoredName(
421
+ strOrNull(raw.batch_as),
422
+ `sub-pipe "${pipeRef}" hands each item to its pipe under`,
423
+ pipeCode,
424
+ `${path}.batch_as`,
425
+ ctx
426
+ );
427
+ reportReservedBatchOver(strOrNull(raw.batch_over), pipeRef, pipeCode, `${path}.batch_over`, ctx);
428
+ }
362
429
  function normalizeSubPipe(raw, pipeCode, path, ctx) {
363
430
  var _a;
364
431
  if (strOrNull(raw.pipe) === null) {
@@ -370,6 +437,8 @@ function normalizeSubPipe(raw, pipeCode, path, ctx) {
370
437
  });
371
438
  return null;
372
439
  }
440
+ const pipeRef = raw.pipe;
441
+ const result = strOrNull(raw.result);
373
442
  const batchOver = strOrNull(raw.batch_over);
374
443
  const batchAs = strOrNull(raw.batch_as);
375
444
  let batchParams = null;
@@ -379,22 +448,21 @@ function normalizeSubPipe(raw, pipeCode, path, ctx) {
379
448
  ctx.diagnostics.push({
380
449
  severity: "warning",
381
450
  code: "incomplete-batch-spec",
382
- message: `pipe "${pipeCode}": sub-pipe "${raw.pipe}" sets only one of batch_over/batch_as \u2014 batching ignored`,
451
+ message: `pipe "${pipeCode}": sub-pipe "${pipeRef}" sets only one of batch_over/batch_as \u2014 batching ignored`,
383
452
  path
384
453
  });
385
454
  }
386
455
  let outputMultiplicity = (_a = intOrNull(raw.nb_output)) != null ? _a : raw.multiple_output === true ? true : null;
387
456
  if (batchParams !== null && outputMultiplicity === null) outputMultiplicity = true;
388
457
  return {
389
- pipe_code: raw.pipe,
390
- output_name: strOrNull(raw.result),
458
+ pipe_code: pipeRef,
459
+ output_name: result,
391
460
  output_multiplicity: outputMultiplicity,
392
461
  batch_params: batchParams
393
462
  };
394
463
  }
395
464
  var BINDING_PATH_RE = /^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*$/;
396
465
  var BINDING_STEP_KEYS = /* @__PURE__ */ new Set(["from", "result"]);
397
- var PRIVATE_BINDING_NAME_PREFIX = "_bound_";
398
466
  function normalizeBindingStep(raw, pipeCode, path, ctx) {
399
467
  const skip = (why) => {
400
468
  ctx.diagnostics.push({
@@ -486,6 +554,7 @@ function normalizeSequenceSteps(raw, pipeCode, inputNames, ctx) {
486
554
  }
487
555
  const step = normalizeSubPipe(entry, pipeCode, path, ctx);
488
556
  if (step === null) return;
557
+ reportSubPipeNames(entry, pipeCode, path, ctx);
489
558
  const listName = (_a = step.batch_params) == null ? void 0 : _a.input_list_stuff_name;
490
559
  if (step.batch_params != null && listName !== void 0 && listName.includes(".")) {
491
560
  if (!BINDING_PATH_RE.test(listName)) {
@@ -551,6 +620,7 @@ function normalizeBranchList(raw, pipeCode, ctx) {
551
620
  });
552
621
  return;
553
622
  }
623
+ reportSubPipeNames(entry, pipeCode, path, ctx);
554
624
  branches.push(branch);
555
625
  });
556
626
  return branches;
@@ -641,7 +711,7 @@ function resolvePipeTypeTag(code, raw, ctx) {
641
711
  return null;
642
712
  }
643
713
  function normalizePipe(code, raw, ctx) {
644
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
714
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
645
715
  const typeValue = resolvePipeTypeTag(code, raw, ctx);
646
716
  if (typeValue === null) return null;
647
717
  const type = typeValue;
@@ -707,13 +777,23 @@ function normalizePipe(code, raw, ctx) {
707
777
  path: `pipe.${code}.branch_pipe_code`
708
778
  });
709
779
  }
780
+ const inputListName = strOrNull(raw.input_list_name);
781
+ const inputItemName = strOrNull(raw.input_item_name);
782
+ reportInvalidBatchListName(inputListName, branchPipeCode, code, ctx);
783
+ reportInvalidStoredName(
784
+ inputItemName,
785
+ "the batch hands each item to its branch pipe under",
786
+ code,
787
+ `pipe.${code}.input_item_name`,
788
+ ctx
789
+ );
710
790
  return __spreadProps(__spreadValues({}, base), {
711
791
  type,
712
792
  pipe_category: "PipeController",
713
793
  branch_pipe_code: branchPipeCode != null ? branchPipeCode : "",
714
794
  batch_params: {
715
- input_list_stuff_name: (_e = strOrNull(raw.input_list_name)) != null ? _e : "",
716
- input_item_stuff_name: (_f = strOrNull(raw.input_item_name)) != null ? _f : ""
795
+ input_list_stuff_name: inputListName != null ? inputListName : "",
796
+ input_item_stuff_name: inputItemName != null ? inputItemName : ""
717
797
  }
718
798
  });
719
799
  }
@@ -746,7 +826,7 @@ function normalizePipe(code, raw, ctx) {
746
826
  type,
747
827
  pipe_category: "PipeOperator",
748
828
  llm_choice: llmChoice,
749
- text_input_name: (_g = inputNames[0]) != null ? _g : "text",
829
+ text_input_name: (_e = inputNames[0]) != null ? _e : "text",
750
830
  output_multiplicity: null
751
831
  });
752
832
  }
@@ -765,8 +845,8 @@ function normalizePipe(code, raw, ctx) {
765
845
  page_views_dpi: intOrNull(raw.page_views_dpi),
766
846
  render_js: boolOrNull(raw.render_js),
767
847
  include_raw_html: boolOrNull(raw.include_raw_html),
768
- image_stuff_name: (_h = imageInput == null ? void 0 : imageInput[0]) != null ? _h : null,
769
- document_stuff_name: (_i = documentInput == null ? void 0 : documentInput[0]) != null ? _i : null
848
+ image_stuff_name: (_f = imageInput == null ? void 0 : imageInput[0]) != null ? _f : null,
849
+ document_stuff_name: (_g = documentInput == null ? void 0 : documentInput[0]) != null ? _g : null
770
850
  });
771
851
  }
772
852
  case "PipeSearch":
@@ -774,7 +854,7 @@ function normalizePipe(code, raw, ctx) {
774
854
  type,
775
855
  pipe_category: "PipeOperator",
776
856
  search_choice: modelToString(raw.model),
777
- prompt_blueprint: makeTemplate((_j = strOrNull(raw.prompt)) != null ? _j : "", "basic"),
857
+ prompt_blueprint: makeTemplate((_h = strOrNull(raw.prompt)) != null ? _h : "", "basic"),
778
858
  include_images_override: boolOrNull(raw.include_images),
779
859
  max_results_override: intOrNull(raw.max_results),
780
860
  from_date: strOrNull(raw.from_date),
@@ -786,7 +866,7 @@ function normalizePipe(code, raw, ctx) {
786
866
  case "PipeImgGen": {
787
867
  const prompt = strOrNull(raw.prompt);
788
868
  const negativePrompt = strOrNull(raw.negative_prompt);
789
- const seed = (_k = intOrNull(raw.seed)) != null ? _k : raw.seed === "auto" ? "auto" : null;
869
+ const seed = (_i = intOrNull(raw.seed)) != null ? _i : raw.seed === "auto" ? "auto" : null;
790
870
  return __spreadProps(__spreadValues({}, base), {
791
871
  type,
792
872
  pipe_category: "PipeOperator",
@@ -815,7 +895,7 @@ function normalizePipe(code, raw, ctx) {
815
895
  } else if (isPlainObject(rawTemplate)) {
816
896
  template = strOrNull(rawTemplate.template);
817
897
  templatingStyle = strOrNull(rawTemplate.templating_style);
818
- category = (_l = strOrNull(rawTemplate.category)) != null ? _l : category;
898
+ category = (_j = strOrNull(rawTemplate.category)) != null ? _j : category;
819
899
  extraContext = isPlainObject(rawTemplate.extra_context) ? rawTemplate.extra_context : null;
820
900
  }
821
901
  return __spreadProps(__spreadValues({}, base), {
@@ -842,7 +922,7 @@ function normalizePipe(code, raw, ctx) {
842
922
  return __spreadProps(__spreadValues({}, base), {
843
923
  type,
844
924
  pipe_category: "PipeOperator",
845
- doc_gen_format: (_m = strOrNull(raw.format)) != null ? _m : "",
925
+ doc_gen_format: (_k = strOrNull(raw.format)) != null ? _k : "",
846
926
  doc_gen_choice: isPlainObject(raw.model) ? raw.model : strOrNull(raw.model),
847
927
  template: strOrNull(raw.template),
848
928
  template_file: strOrNull(raw.template_file),