@instruments/materialgraph 0.25.0 → 0.27.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.
Files changed (158) hide show
  1. package/association-types.d.ts +38 -27
  2. package/associations-client.d.ts +4 -4
  3. package/associations-client.js +3 -10
  4. package/attribution-types.d.ts +4 -4
  5. package/brand-types.d.ts +14 -6
  6. package/brands-client.d.ts +7 -38
  7. package/brands-client.js +10 -40
  8. package/by-colour-types.d.ts +58 -31
  9. package/by-spec-types.d.ts +6 -73
  10. package/by-spec-types.js +7 -5
  11. package/catalog-discovery-types.d.ts +11 -26
  12. package/catalogue-client.d.ts +16 -35
  13. package/catalogue-client.js +32 -67
  14. package/catalogue-types.d.ts +44 -4
  15. package/categories-client.d.ts +63 -0
  16. package/categories-client.js +48 -0
  17. package/category-types.d.ts +114 -0
  18. package/citation-types.d.ts +4 -4
  19. package/client-config.d.ts +4 -6
  20. package/client-config.js +2 -4
  21. package/client-source-material-comments.d.ts +4 -4
  22. package/client-source-material-comments.js +4 -38
  23. package/client-vocabulary.d.ts +7 -9
  24. package/client-vocabulary.js +22 -30
  25. package/client.d.ts +110 -244
  26. package/client.js +217 -387
  27. package/codes-client.d.ts +2 -2
  28. package/codes-client.js +8 -8
  29. package/codes-types.d.ts +55 -34
  30. package/colour-aggregate-types.d.ts +24 -24
  31. package/colours-client.d.ts +6 -11
  32. package/colours-client.js +11 -19
  33. package/coordinate-client.d.ts +2 -2
  34. package/coordinate-client.js +1 -13
  35. package/corpus-scope-types.d.ts +3 -3
  36. package/corpus-scope-types.js +1 -25
  37. package/demand-batch-types.d.ts +18 -18
  38. package/demand-types.d.ts +24 -24
  39. package/errors.d.ts +13 -13
  40. package/errors.js +54 -52
  41. package/http-transport.d.ts +13 -21
  42. package/http-transport.js +31 -28
  43. package/identify-types.d.ts +54 -44
  44. package/identify-types.js +5 -3
  45. package/index.d.ts +11 -27
  46. package/index.js +4 -6
  47. package/list-variant-facets-types.d.ts +60 -0
  48. package/list-variants-types.d.ts +142 -0
  49. package/list-variants-types.js +12 -0
  50. package/match-stream-types.d.ts +45 -32
  51. package/match-stream-types.js +2 -0
  52. package/match-stream.d.ts +2 -2
  53. package/match-stream.js +67 -49
  54. package/match-types.d.ts +32 -8
  55. package/material-asset-types.d.ts +89 -69
  56. package/material-block-types.d.ts +8 -6
  57. package/material-composition-client.d.ts +21 -0
  58. package/material-composition-client.js +13 -0
  59. package/material-composition-types.d.ts +403 -0
  60. package/material-query-plan-types.d.ts +61 -145
  61. package/material-resources-client.d.ts +12 -10
  62. package/material-resources-client.js +27 -22
  63. package/material-types.d.ts +16 -24
  64. package/ndjson.js +16 -8
  65. package/operations.d.ts +6 -6
  66. package/operations.js +29 -156
  67. package/package.json +5 -1
  68. package/palette-search-types.d.ts +87 -52
  69. package/query-understanding-types.d.ts +65 -40
  70. package/resolve-client.d.ts +8 -12
  71. package/resolve-client.js +9 -13
  72. package/resolve-colour-types.d.ts +8 -8
  73. package/resolve-types.d.ts +10 -10
  74. package/response-schemas.d.ts +20 -0
  75. package/response-schemas.generated.d.ts +5 -0
  76. package/response-schemas.generated.js +160 -0
  77. package/response-schemas.js +113 -0
  78. package/run-types.d.ts +64 -145
  79. package/runs.d.ts +9 -58
  80. package/runs.js +60 -149
  81. package/samplize-catalogue-types.d.ts +18 -18
  82. package/samplize-colorvec.d.ts +20 -20
  83. package/samplize-colorvec.js +66 -42
  84. package/schema-resource-types.d.ts +52 -39
  85. package/schema-resource-types.js +5 -5
  86. package/search-card-types.d.ts +26 -4
  87. package/search-index-plan-types.d.ts +70 -0
  88. package/search-refinement-types.d.ts +10 -40
  89. package/search-refinement-types.js +1 -0
  90. package/search-request-types.d.ts +121 -204
  91. package/search-response-receipt-types.d.ts +13 -253
  92. package/search-response-types.d.ts +2 -2
  93. package/search-result-validation.d.ts +3 -19
  94. package/search-result-validation.js +42 -183
  95. package/source-material-validation.d.ts +3 -3
  96. package/source-material-validation.js +35 -39
  97. package/spec-facet-types.d.ts +11 -16
  98. package/spec-types.d.ts +23 -16
  99. package/spec-types.js +8 -7
  100. package/specifications.d.ts +14 -72
  101. package/specifications.js +39 -89
  102. package/sse.d.ts +2 -2
  103. package/sse.js +32 -16
  104. package/substitute-types.d.ts +22 -22
  105. package/suggest-types.d.ts +11 -17
  106. package/suggest-types.js +3 -3
  107. package/taxonomy-coverage-types.d.ts +8 -8
  108. package/types.d.ts +202 -405
  109. package/validation.d.ts +26 -26
  110. package/validation.js +97 -92
  111. package/webmcp.d.ts +3 -3
  112. package/webmcp.generated.js +10 -93
  113. package/brand-most-sampled-types.d.ts +0 -33
  114. package/browse-types.d.ts +0 -236
  115. package/client-browse.d.ts +0 -78
  116. package/client-browse.js +0 -72
  117. package/client-exploration.d.ts +0 -9
  118. package/client-exploration.js +0 -7
  119. package/compare-types.d.ts +0 -89
  120. package/composition-client.d.ts +0 -33
  121. package/composition-client.js +0 -27
  122. package/composition-types.d.ts +0 -455
  123. package/composition-types.js +0 -10
  124. package/correction-types.d.ts +0 -88
  125. package/exploration-types.d.ts +0 -118
  126. package/exploration-types.js +0 -1
  127. package/fan-deck-types.d.ts +0 -42
  128. package/fan-deck-types.js +0 -9
  129. package/match-rejection-types.d.ts +0 -43
  130. package/match-rejection-types.js +0 -7
  131. package/palette-completion-types.d.ts +0 -115
  132. package/palette-completion-types.js +0 -1
  133. package/project-types.d.ts +0 -79
  134. package/project-types.js +0 -9
  135. package/projects.d.ts +0 -13
  136. package/projects.js +0 -46
  137. package/render-assets-types.d.ts +0 -65
  138. package/render-assets-types.js +0 -1
  139. package/run-events.d.ts +0 -106
  140. package/run-events.js +0 -32
  141. package/schedule-reference-types.d.ts +0 -46
  142. package/schedule-reference-types.js +0 -1
  143. package/schedule-references-client.d.ts +0 -14
  144. package/schedule-references-client.js +0 -26
  145. package/schedule-types.d.ts +0 -261
  146. package/schedule-types.js +0 -1
  147. package/search-collapse-types.d.ts +0 -69
  148. package/search-collapse-types.js +0 -1
  149. package/search-mood-types.d.ts +0 -6
  150. package/search-mood-types.js +0 -1
  151. package/search-window-types.d.ts +0 -25
  152. package/search-window-types.js +0 -1
  153. package/slot-pool-types.d.ts +0 -372
  154. package/slot-pool-types.js +0 -1
  155. /package/{brand-most-sampled-types.js → category-types.js} +0 -0
  156. /package/{browse-types.js → list-variant-facets-types.js} +0 -0
  157. /package/{compare-types.js → material-composition-types.js} +0 -0
  158. /package/{correction-types.js → search-index-plan-types.js} +0 -0
package/validation.d.ts CHANGED
@@ -14,26 +14,26 @@
14
14
  * owned by the calling module — so one payload's failures all read alike without
15
15
  * this file knowing what a Match frame or a Run event is.
16
16
  */
17
- import { MaterialGraphError } from "./errors.js";
17
+ import type { MaterialGraphError } from "./errors.js";
18
18
  import type { JsonValue } from "./types.js";
19
19
  /**
20
20
  * Builds the one error a validation run raises. The calling module supplies it,
21
21
  * so the message names that payload and quotes its source.
22
22
  */
23
23
  export type ValidationFailure = (reason: string) => MaterialGraphError;
24
- export declare function isRecord(value: unknown): value is Record<string, unknown>;
24
+ export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
25
25
  /** A `z.object({…})`. */
26
- export declare function requireRecord(value: unknown, what: string, fail: ValidationFailure): Record<string, unknown>;
26
+ export declare const requireRecord: (value: unknown, what: string, fail: ValidationFailure) => Record<string, unknown>;
27
27
  /** A `z.string()`. */
28
- export declare function requireString(value: unknown, what: string, fail: ValidationFailure): string;
28
+ export declare const requireString: (value: unknown, what: string, fail: ValidationFailure) => string;
29
29
  /** A `z.string().min(1)`. */
30
- export declare function requireNonEmptyString(value: unknown, what: string, fail: ValidationFailure): string;
30
+ export declare const requireNonEmptyString: (value: unknown, what: string, fail: ValidationFailure) => string;
31
31
  /** A `z.string().optional()`: absent is fine, present-but-wrong is not. */
32
- export declare function requireOptionalString(value: unknown, what: string, fail: ValidationFailure): void;
32
+ export declare const requireOptionalString: (value: unknown, what: string, fail: ValidationFailure) => void;
33
33
  /** A `z.string().nullable()`. */
34
- export declare function requireNullableString(value: unknown, what: string, fail: ValidationFailure): string | null;
34
+ export declare const requireNullableString: (value: unknown, what: string, fail: ValidationFailure) => string | null;
35
35
  /** A `z.string().min(1).nullable()`. */
36
- export declare function requireNullableNonEmptyString(value: unknown, what: string, fail: ValidationFailure): string | null;
36
+ export declare const requireNullableNonEmptyString: (value: unknown, what: string, fail: ValidationFailure) => string | null;
37
37
  /**
38
38
  * A `z.string().trim().min(1).max(max)`.
39
39
  *
@@ -43,29 +43,29 @@ export declare function requireNullableNonEmptyString(value: unknown, what: stri
43
43
  * whitespace-only value the schema rejects, and reject a padded value the schema
44
44
  * accepts. Returns the trimmed string, which is what the schema returns.
45
45
  */
46
- export declare function requireTrimmedBoundedString(value: unknown, what: string, max: number, fail: ValidationFailure): string;
46
+ export declare const requireTrimmedBoundedString: (value: unknown, what: string, max: number, fail: ValidationFailure) => string;
47
47
  /** A `z.string().trim().min(1).max(max).nullable()`. */
48
- export declare function requireNullableTrimmedBoundedString(value: unknown, what: string, max: number, fail: ValidationFailure): string | null;
48
+ export declare const requireNullableTrimmedBoundedString: (value: unknown, what: string, max: number, fail: ValidationFailure) => string | null;
49
49
  /** A `z.boolean()`. */
50
- export declare function requireBoolean(value: unknown, what: string, fail: ValidationFailure): boolean;
50
+ export declare const requireBoolean: (value: unknown, what: string, fail: ValidationFailure) => boolean;
51
51
  /** A `z.boolean().optional()`. */
52
- export declare function requireOptionalBoolean(value: unknown, what: string, fail: ValidationFailure): void;
52
+ export declare const requireOptionalBoolean: (value: unknown, what: string, fail: ValidationFailure) => void;
53
53
  /**
54
54
  * A `z.number()`. Zod 4 rejects `NaN` AND `±Infinity` for it, and `1e999` parses
55
55
  * out of JSON as `Infinity`, so finiteness is a reachable check.
56
56
  */
57
- export declare function requireNumber(value: unknown, what: string, fail: ValidationFailure): number;
57
+ export declare const requireNumber: (value: unknown, what: string, fail: ValidationFailure) => number;
58
58
  /** A `z.number().optional()`. */
59
- export declare function requireOptionalNumber(value: unknown, what: string, fail: ValidationFailure): void;
59
+ export declare const requireOptionalNumber: (value: unknown, what: string, fail: ValidationFailure) => void;
60
60
  /** A `z.number().nullable()`. */
61
- export declare function requireNullableNumber(value: unknown, what: string, fail: ValidationFailure): number | null;
61
+ export declare const requireNullableNumber: (value: unknown, what: string, fail: ValidationFailure) => number | null;
62
62
  /**
63
63
  * A `z.number().min(min).max(max)`. `NaN` and both infinities fail the
64
64
  * comparisons, exactly as the bounded Zod schema rejects them.
65
65
  */
66
- export declare function requireBoundedNumber(value: unknown, what: string, fail: ValidationFailure, min: number, max: number): number;
66
+ export declare const requireBoundedNumber: (value: unknown, what: string, fail: ValidationFailure, min: number, max: number) => number;
67
67
  /** A `z.number().min(min).max(max).nullable()`. */
68
- export declare function requireNullableBoundedNumber(value: unknown, what: string, fail: ValidationFailure, min: number, max: number): number | null;
68
+ export declare const requireNullableBoundedNumber: (value: unknown, what: string, fail: ValidationFailure, min: number, max: number) => number | null;
69
69
  /**
70
70
  * A bare `z.number().int()` — integer, finite, and within the SAFE range, with
71
71
  * NO lower bound.
@@ -80,22 +80,22 @@ export declare function requireNullableBoundedNumber(value: unknown, what: strin
80
80
  * which the schema rejects — so `requireIntegerAtLeast` is not this helper with
81
81
  * the bound dropped, and the safe-range test is why.
82
82
  */
83
- export declare function requireSafeInteger(value: unknown, what: string, fail: ValidationFailure): number;
83
+ export declare const requireSafeInteger: (value: unknown, what: string, fail: ValidationFailure) => number;
84
84
  /** A `z.number().int().min(min)` — the integer constraint AND the lower bound. */
85
- export declare function requireIntegerAtLeast(value: unknown, what: string, fail: ValidationFailure, min: number): number;
85
+ export declare const requireIntegerAtLeast: (value: unknown, what: string, fail: ValidationFailure, min: number) => number;
86
86
  /** A `z.enum([…])` — CLOSED, exactly like the canonical member list. */
87
- export declare function requireEnum(value: unknown, allowed: readonly string[], what: string, fail: ValidationFailure): string;
87
+ export declare const requireEnum: (value: unknown, allowed: readonly string[], what: string, fail: ValidationFailure) => string;
88
88
  /** A `z.enum([…]).nullable()`. */
89
- export declare function requireNullableEnum(value: unknown, allowed: readonly string[], what: string, fail: ValidationFailure): string | null;
89
+ export declare const requireNullableEnum: (value: unknown, allowed: readonly string[], what: string, fail: ValidationFailure) => string | null;
90
90
  /** A `z.array(…)`. */
91
- export declare function requireArray(value: unknown, what: string, fail: ValidationFailure): unknown[];
91
+ export declare const requireArray: (value: unknown, what: string, fail: ValidationFailure) => unknown[];
92
92
  /**
93
93
  * A `z.array(…).default([])`: an OMITTED array is valid and materialises as
94
94
  * `[]`; a present non-array is not.
95
95
  */
96
- export declare function requireDefaultedArray(value: unknown, what: string, fail: ValidationFailure): unknown[];
96
+ export declare const requireDefaultedArray: (value: unknown, what: string, fail: ValidationFailure) => unknown[];
97
97
  /** A `z.array(z.string()).min(1)` — non-empty, and every element a string. */
98
- export declare function requireNonEmptyStringArray(value: unknown, what: string, fail: ValidationFailure): string[];
98
+ export declare const requireNonEmptyStringArray: (value: unknown, what: string, fail: ValidationFailure) => string[];
99
99
  /**
100
100
  * A `z.json()` — a JSON value, recursively: `string | number | boolean | null`,
101
101
  * an array of them, or an object of them, at ANY depth.
@@ -110,7 +110,7 @@ export declare function requireNonEmptyStringArray(value: unknown, what: string,
110
110
  * back than written). The mirror has to reject what the schema rejects or the
111
111
  * parity test is lying. Do not delete this as dead code.
112
112
  */
113
- export declare function requireJsonValue(value: unknown, what: string, fail: ValidationFailure): JsonValue;
113
+ export declare const requireJsonValue: (value: unknown, what: string, fail: ValidationFailure) => JsonValue;
114
114
  /**
115
115
  * A `z.record(z.string(), z.json())` — a PLAIN JSON object of JSON values.
116
116
  *
@@ -128,4 +128,4 @@ export declare function requireJsonValue(value: unknown, what: string, fail: Val
128
128
  * genuinely does accept any record, and tightening a shared helper under them
129
129
  * would be a change none of them asked for.
130
130
  */
131
- export declare function requireJsonRecord(value: unknown, what: string, fail: ValidationFailure): Record<string, JsonValue>;
131
+ export declare const requireJsonRecord: (value: unknown, what: string, fail: ValidationFailure) => Record<string, JsonValue>;
package/validation.js CHANGED
@@ -1,60 +1,47 @@
1
- /**
2
- * The SDK's shared wire-validation primitives — the vocabulary every hand-rolled
3
- * mirror of a canonical Zod schema is built from.
4
- *
5
- * The SDK publishes with ZERO runtime dependencies, so it cannot call
6
- * `schema.parse()` on anything. Where a wire payload must be proven rather than
7
- * trusted, it is checked with these helpers and the result is pinned against the
8
- * real schema in `contract-parity.test.ts`. Each helper mirrors one Zod
9
- * construct, named for it, so a reviewer can read the mirror against the schema
10
- * line by line.
11
- *
12
- * Every helper takes the same three shapes: the value, a `what` path used in the
13
- * diagnostic (`results[3].verdict.cells[0].state`), and a {@link ValidationFailure}
14
- * owned by the calling module — so one payload's failures all read alike without
15
- * this file knowing what a Match frame or a Run event is.
16
- */
17
- import { MaterialGraphError } from "./errors.js";
18
- export function isRecord(value) {
19
- return typeof value === "object" && value !== null && !Array.isArray(value);
20
- }
1
+ export const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
21
2
  /** A `z.object({…})`. */
22
- export function requireRecord(value, what, fail) {
23
- if (!isRecord(value))
3
+ export const requireRecord = (value, what, fail) => {
4
+ if (!isRecord(value)) {
24
5
  throw fail(`${what} is not a JSON object`);
6
+ }
25
7
  return value;
26
- }
8
+ };
27
9
  /** A `z.string()`. */
28
- export function requireString(value, what, fail) {
29
- if (typeof value !== "string")
10
+ export const requireString = (value, what, fail) => {
11
+ if (typeof value !== "string") {
30
12
  throw fail(`${what} is not a string`);
13
+ }
31
14
  return value;
32
- }
15
+ };
33
16
  /** A `z.string().min(1)`. */
34
- export function requireNonEmptyString(value, what, fail) {
17
+ export const requireNonEmptyString = (value, what, fail) => {
35
18
  const text = requireString(value, what, fail);
36
- if (text.length === 0)
19
+ if (text.length === 0) {
37
20
  throw fail(`${what} is an empty string`);
21
+ }
38
22
  return text;
39
- }
23
+ };
40
24
  /** A `z.string().optional()`: absent is fine, present-but-wrong is not. */
41
- export function requireOptionalString(value, what, fail) {
42
- if (value === undefined)
25
+ export const requireOptionalString = (value, what, fail) => {
26
+ if (value === undefined) {
43
27
  return;
28
+ }
44
29
  requireString(value, what, fail);
45
- }
30
+ };
46
31
  /** A `z.string().nullable()`. */
47
- export function requireNullableString(value, what, fail) {
48
- if (value === null)
32
+ export const requireNullableString = (value, what, fail) => {
33
+ if (value === null) {
49
34
  return null;
35
+ }
50
36
  return requireString(value, what, fail);
51
- }
37
+ };
52
38
  /** A `z.string().min(1).nullable()`. */
53
- export function requireNullableNonEmptyString(value, what, fail) {
54
- if (value === null)
39
+ export const requireNullableNonEmptyString = (value, what, fail) => {
40
+ if (value === null) {
55
41
  return null;
42
+ }
56
43
  return requireNonEmptyString(value, what, fail);
57
- }
44
+ };
58
45
  /**
59
46
  * A `z.string().trim().min(1).max(max)`.
60
47
  *
@@ -64,70 +51,78 @@ export function requireNullableNonEmptyString(value, what, fail) {
64
51
  * whitespace-only value the schema rejects, and reject a padded value the schema
65
52
  * accepts. Returns the trimmed string, which is what the schema returns.
66
53
  */
67
- export function requireTrimmedBoundedString(value, what, max, fail) {
54
+ export const requireTrimmedBoundedString = (value, what, max, fail) => {
68
55
  const text = requireString(value, what, fail).trim();
69
- if (text.length === 0)
56
+ if (text.length === 0) {
70
57
  throw fail(`${what} is empty once trimmed`);
71
- if (text.length > max)
58
+ }
59
+ if (text.length > max) {
72
60
  throw fail(`${what} is longer than ${max} characters (${text.length})`);
61
+ }
73
62
  return text;
74
- }
63
+ };
75
64
  /** A `z.string().trim().min(1).max(max).nullable()`. */
76
- export function requireNullableTrimmedBoundedString(value, what, max, fail) {
77
- if (value === null)
65
+ export const requireNullableTrimmedBoundedString = (value, what, max, fail) => {
66
+ if (value === null) {
78
67
  return null;
68
+ }
79
69
  return requireTrimmedBoundedString(value, what, max, fail);
80
- }
70
+ };
81
71
  /** A `z.boolean()`. */
82
- export function requireBoolean(value, what, fail) {
83
- if (typeof value !== "boolean")
72
+ export const requireBoolean = (value, what, fail) => {
73
+ if (typeof value !== "boolean") {
84
74
  throw fail(`${what} is not a boolean`);
75
+ }
85
76
  return value;
86
- }
77
+ };
87
78
  /** A `z.boolean().optional()`. */
88
- export function requireOptionalBoolean(value, what, fail) {
89
- if (value === undefined)
79
+ export const requireOptionalBoolean = (value, what, fail) => {
80
+ if (value === undefined) {
90
81
  return;
82
+ }
91
83
  requireBoolean(value, what, fail);
92
- }
84
+ };
93
85
  /**
94
86
  * A `z.number()`. Zod 4 rejects `NaN` AND `±Infinity` for it, and `1e999` parses
95
87
  * out of JSON as `Infinity`, so finiteness is a reachable check.
96
88
  */
97
- export function requireNumber(value, what, fail) {
89
+ export const requireNumber = (value, what, fail) => {
98
90
  if (typeof value !== "number" || !Number.isFinite(value)) {
99
91
  throw fail(`${what} is not a finite number`);
100
92
  }
101
93
  return value;
102
- }
94
+ };
103
95
  /** A `z.number().optional()`. */
104
- export function requireOptionalNumber(value, what, fail) {
105
- if (value === undefined)
96
+ export const requireOptionalNumber = (value, what, fail) => {
97
+ if (value === undefined) {
106
98
  return;
99
+ }
107
100
  requireNumber(value, what, fail);
108
- }
101
+ };
109
102
  /** A `z.number().nullable()`. */
110
- export function requireNullableNumber(value, what, fail) {
111
- if (value === null)
103
+ export const requireNullableNumber = (value, what, fail) => {
104
+ if (value === null) {
112
105
  return null;
106
+ }
113
107
  return requireNumber(value, what, fail);
114
- }
108
+ };
115
109
  /**
116
110
  * A `z.number().min(min).max(max)`. `NaN` and both infinities fail the
117
111
  * comparisons, exactly as the bounded Zod schema rejects them.
118
112
  */
119
- export function requireBoundedNumber(value, what, fail, min, max) {
113
+ export const requireBoundedNumber = (value, what, fail, min, max) => {
120
114
  if (typeof value !== "number" || !(value >= min && value <= max)) {
121
115
  throw fail(`${what} is not a number within [${min}, ${max}]`);
122
116
  }
123
117
  return value;
124
- }
118
+ };
125
119
  /** A `z.number().min(min).max(max).nullable()`. */
126
- export function requireNullableBoundedNumber(value, what, fail, min, max) {
127
- if (value === null)
120
+ export const requireNullableBoundedNumber = (value, what, fail, min, max) => {
121
+ if (value === null) {
128
122
  return null;
123
+ }
129
124
  return requireBoundedNumber(value, what, fail, min, max);
130
- }
125
+ };
131
126
  /**
132
127
  * A bare `z.number().int()` — integer, finite, and within the SAFE range, with
133
128
  * NO lower bound.
@@ -142,56 +137,63 @@ export function requireNullableBoundedNumber(value, what, fail, min, max) {
142
137
  * which the schema rejects — so `requireIntegerAtLeast` is not this helper with
143
138
  * the bound dropped, and the safe-range test is why.
144
139
  */
145
- export function requireSafeInteger(value, what, fail) {
146
- if (!Number.isSafeInteger(value))
140
+ export const requireSafeInteger = (value, what, fail) => {
141
+ if (!Number.isSafeInteger(value)) {
147
142
  throw fail(`${what} is not a safe integer`);
143
+ }
148
144
  return requireNumber(value, what, fail);
149
- }
145
+ };
150
146
  /** A `z.number().int().min(min)` — the integer constraint AND the lower bound. */
151
- export function requireIntegerAtLeast(value, what, fail, min) {
147
+ export const requireIntegerAtLeast = (value, what, fail, min) => {
152
148
  const numeric = requireNumber(value, what, fail);
153
- if (!Number.isInteger(numeric))
149
+ if (!Number.isInteger(numeric)) {
154
150
  throw fail(`${what} is not an integer`);
155
- if (numeric < min)
151
+ }
152
+ if (numeric < min) {
156
153
  throw fail(`${what} is below the minimum of ${min}`);
154
+ }
157
155
  return numeric;
158
- }
156
+ };
159
157
  /** A `z.enum([…])` — CLOSED, exactly like the canonical member list. */
160
- export function requireEnum(value, allowed, what, fail) {
158
+ export const requireEnum = (value, allowed, what, fail) => {
161
159
  const text = requireString(value, what, fail);
162
160
  if (!allowed.includes(text)) {
163
161
  throw fail(`${what} is not one of ${allowed.join(" | ")} (${text})`);
164
162
  }
165
163
  return text;
166
- }
164
+ };
167
165
  /** A `z.enum([…]).nullable()`. */
168
- export function requireNullableEnum(value, allowed, what, fail) {
169
- if (value === null)
166
+ export const requireNullableEnum = (value, allowed, what, fail) => {
167
+ if (value === null) {
170
168
  return null;
169
+ }
171
170
  return requireEnum(value, allowed, what, fail);
172
- }
171
+ };
173
172
  /** A `z.array(…)`. */
174
- export function requireArray(value, what, fail) {
175
- if (!Array.isArray(value))
173
+ export const requireArray = (value, what, fail) => {
174
+ if (!Array.isArray(value)) {
176
175
  throw fail(`${what} is not an array`);
176
+ }
177
177
  return value;
178
- }
178
+ };
179
179
  /**
180
180
  * A `z.array(…).default([])`: an OMITTED array is valid and materialises as
181
181
  * `[]`; a present non-array is not.
182
182
  */
183
- export function requireDefaultedArray(value, what, fail) {
184
- if (value === undefined)
183
+ export const requireDefaultedArray = (value, what, fail) => {
184
+ if (value === undefined) {
185
185
  return [];
186
+ }
186
187
  return requireArray(value, what, fail);
187
- }
188
+ };
188
189
  /** A `z.array(z.string()).min(1)` — non-empty, and every element a string. */
189
- export function requireNonEmptyStringArray(value, what, fail) {
190
+ export const requireNonEmptyStringArray = (value, what, fail) => {
190
191
  const items = requireArray(value, what, fail);
191
- if (items.length === 0)
192
+ if (items.length === 0) {
192
193
  throw fail(`${what} is empty`);
194
+ }
193
195
  return items.map((item, index) => requireString(item, `${what}[${index}]`, fail));
194
- }
196
+ };
195
197
  /**
196
198
  * A `z.json()` — a JSON value, recursively: `string | number | boolean | null`,
197
199
  * an array of them, or an object of them, at ANY depth.
@@ -206,16 +208,19 @@ export function requireNonEmptyStringArray(value, what, fail) {
206
208
  * back than written). The mirror has to reject what the schema rejects or the
207
209
  * parity test is lying. Do not delete this as dead code.
208
210
  */
209
- export function requireJsonValue(value, what, fail) {
210
- if (value === null)
211
+ export const requireJsonValue = (value, what, fail) => {
212
+ if (value === null) {
211
213
  return null;
212
- if (typeof value === "string" || typeof value === "boolean")
214
+ }
215
+ if (typeof value === "string" || typeof value === "boolean") {
213
216
  return value;
217
+ }
214
218
  if (typeof value === "number") {
215
219
  // `z.json()`'s number leaf rejects NaN and ±Infinity, and `1e999` parses out
216
220
  // of JSON as `Infinity` — so finiteness IS reachable, unlike the rest.
217
- if (!Number.isFinite(value))
221
+ if (!Number.isFinite(value)) {
218
222
  throw fail(`${what} is not a finite number`);
223
+ }
219
224
  return value;
220
225
  }
221
226
  if (Array.isArray(value)) {
@@ -237,7 +242,7 @@ export function requireJsonValue(value, what, fail) {
237
242
  ]));
238
243
  }
239
244
  throw fail(`${what} is not a JSON value`);
240
- }
245
+ };
241
246
  /**
242
247
  * A `z.record(z.string(), z.json())` — a PLAIN JSON object of JSON values.
243
248
  *
@@ -255,10 +260,10 @@ export function requireJsonValue(value, what, fail) {
255
260
  * genuinely does accept any record, and tightening a shared helper under them
256
261
  * would be a change none of them asked for.
257
262
  */
258
- export function requireJsonRecord(value, what, fail) {
263
+ export const requireJsonRecord = (value, what, fail) => {
259
264
  const json = requireJsonValue(value, what, fail);
260
265
  if (json === null || typeof json !== "object" || Array.isArray(json)) {
261
266
  throw fail(`${what} is not a JSON object`);
262
267
  }
263
268
  return json;
264
- }
269
+ };
package/webmcp.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /** Canonical operation contracts. Consumers validate both boundaries and supply their own transport. */
2
- export interface WebMcpToolContract {
3
- readonly name: "identify" | "search" | "compare" | "create_correction";
2
+ export type WebMcpToolContract = {
3
+ readonly name: "search";
4
4
  readonly operationId: string;
5
5
  readonly path: string;
6
6
  readonly method: "POST";
@@ -13,5 +13,5 @@ export interface WebMcpToolContract {
13
13
  };
14
14
  readonly requiresVisibleConfirmation: boolean;
15
15
  readonly requiredHeaders: readonly string[];
16
- }
16
+ };
17
17
  export { WEBMCP_TOOLS } from "./webmcp.generated.js";