@instruments/materialgraph 0.33.0 → 0.36.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/association-types.d.ts +11 -11
- package/associations-client.d.ts +7 -7
- package/associations-client.js +5 -5
- package/brand-types.d.ts +37 -41
- package/brand-types.js +3 -5
- package/brands-client.d.ts +22 -9
- package/brands-client.js +20 -6
- package/by-spec-types.d.ts +1 -1
- package/catalog-discovery-types.d.ts +3 -3
- package/catalogue-client.d.ts +2 -50
- package/catalogue-client.js +2 -10
- package/catalogue-types.d.ts +1 -1
- package/categories-client.d.ts +3 -5
- package/categories-client.js +1 -1
- package/category-types.d.ts +17 -30
- package/citation-types.d.ts +2 -2
- package/client-vocabulary.d.ts +2 -2
- package/client-vocabulary.js +4 -1
- package/client.d.ts +62 -105
- package/client.js +68 -106
- package/color-profiles-types.d.ts +70 -0
- package/colors-client.d.ts +76 -0
- package/colors-client.js +52 -0
- package/find-sampled-together-types.d.ts +70 -0
- package/{find-companions-types.js → find-sampled-together-types.js} +4 -4
- package/{find-variants-by-colour-types.d.ts → find-variants-by-color-types.d.ts} +70 -64
- package/find-variants-by-vector-types.d.ts +4 -1
- package/get-variant-types.d.ts +14 -2
- package/http-transport.d.ts +1 -1
- package/http-transport.js +1 -2
- package/identifiers.d.ts +2 -2
- package/identifiers.js +1 -1
- package/index.d.ts +5 -14
- package/index.js +1 -3
- package/list-variant-facets-types.d.ts +4 -4
- package/list-variants-types.d.ts +71 -21
- package/material-asset-types.d.ts +3 -3
- package/material-block-types.d.ts +9 -9
- package/material-types.d.ts +10 -8
- package/operations.d.ts +2 -2
- package/operations.js +19 -25
- package/package.json +2 -2
- package/{resolve-colour-types.d.ts → resolve-color-types.d.ts} +18 -18
- package/response-schemas.generated.d.ts +2 -2
- package/response-schemas.generated.js +41 -71
- package/response-schemas.js +1 -1
- package/samplize-catalogue-types.d.ts +4 -4
- package/samplize-colorvec.js +6 -6
- package/{corpus-scope-types.d.ts → search-catalogue-subset-types.d.ts} +3 -3
- package/search-variants-types.d.ts +33 -2
- package/types.d.ts +32 -284
- package/webmcp.generated.js +4 -9
- package/attribution-types.d.ts +0 -51
- package/attribution-types.js +0 -13
- package/by-colour-types.d.ts +0 -320
- package/colour-region-types.d.ts +0 -18
- package/colours-client.d.ts +0 -70
- package/colours-client.js +0 -38
- package/find-companions-types.d.ts +0 -70
- package/material-query-plan-types.d.ts +0 -70
- package/material-query-plan-types.js +0 -1
- package/ndjson.d.ts +0 -46
- package/ndjson.js +0 -111
- package/palette-search-types.d.ts +0 -171
- package/palette-search-types.js +0 -1
- package/query-understanding-types.d.ts +0 -254
- package/query-understanding-types.js +0 -1
- package/resolve-colour-types.js +0 -1
- package/search-card-types.d.ts +0 -86
- package/search-card-types.js +0 -1
- package/search-index-plan-types.d.ts +0 -74
- package/search-index-plan-types.js +0 -1
- package/search-refinement-types.d.ts +0 -103
- package/search-refinement-types.js +0 -2
- package/search-request-types.d.ts +0 -170
- package/search-request-types.js +0 -1
- package/search-response-receipt-types.d.ts +0 -24
- package/search-response-receipt-types.js +0 -1
- package/search-response-types.d.ts +0 -11
- package/search-response-types.js +0 -1
- package/search-result-validation.d.ts +0 -9
- package/search-result-validation.js +0 -83
- package/spec-types.d.ts +0 -109
- package/spec-types.js +0 -54
- package/specifications.d.ts +0 -34
- package/specifications.js +0 -56
- package/validation.d.ts +0 -43
- package/validation.js +0 -117
- /package/{by-colour-types.js → color-profiles-types.js} +0 -0
- /package/{colour-region-types.js → find-variants-by-color-types.js} +0 -0
- /package/{corpus-scope-types.js → resolve-color-types.js} +0 -0
- /package/{find-variants-by-colour-types.js → search-catalogue-subset-types.js} +0 -0
package/validation.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2
|
-
/** A `z.object({…})`. */
|
|
3
|
-
export const requireRecord = (value, what, fail) => {
|
|
4
|
-
if (!isRecord(value)) {
|
|
5
|
-
throw fail(`${what} is not a JSON object`);
|
|
6
|
-
}
|
|
7
|
-
return value;
|
|
8
|
-
};
|
|
9
|
-
/** A `z.string()`. */
|
|
10
|
-
export const requireString = (value, what, fail) => {
|
|
11
|
-
if (typeof value !== "string") {
|
|
12
|
-
throw fail(`${what} is not a string`);
|
|
13
|
-
}
|
|
14
|
-
return value;
|
|
15
|
-
};
|
|
16
|
-
/** A `z.string().optional()`: absent is fine, present-but-wrong is not. */
|
|
17
|
-
export const requireOptionalString = (value, what, fail) => {
|
|
18
|
-
if (value === undefined) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
requireString(value, what, fail);
|
|
22
|
-
};
|
|
23
|
-
/** A `z.string().nullable()`. */
|
|
24
|
-
export const requireNullableString = (value, what, fail) => {
|
|
25
|
-
if (value === null) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
return requireString(value, what, fail);
|
|
29
|
-
};
|
|
30
|
-
/** A `z.boolean()`. */
|
|
31
|
-
export const requireBoolean = (value, what, fail) => {
|
|
32
|
-
if (typeof value !== "boolean") {
|
|
33
|
-
throw fail(`${what} is not a boolean`);
|
|
34
|
-
}
|
|
35
|
-
return value;
|
|
36
|
-
};
|
|
37
|
-
/** A `z.boolean().optional()`. */
|
|
38
|
-
export const requireOptionalBoolean = (value, what, fail) => {
|
|
39
|
-
if (value === undefined) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
requireBoolean(value, what, fail);
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* A `z.number()`. Zod 4 rejects `NaN` AND `±Infinity` for it, and `1e999` parses
|
|
46
|
-
* out of JSON as `Infinity`, so finiteness is a reachable check.
|
|
47
|
-
*/
|
|
48
|
-
export const requireNumber = (value, what, fail) => {
|
|
49
|
-
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
50
|
-
throw fail(`${what} is not a finite number`);
|
|
51
|
-
}
|
|
52
|
-
return value;
|
|
53
|
-
};
|
|
54
|
-
/** A `z.enum([…])` — CLOSED, exactly like the canonical member list. */
|
|
55
|
-
export const requireEnum = (value, allowed, what, fail) => {
|
|
56
|
-
const text = requireString(value, what, fail);
|
|
57
|
-
if (!allowed.includes(text)) {
|
|
58
|
-
throw fail(`${what} is not one of ${allowed.join(" | ")} (${text})`);
|
|
59
|
-
}
|
|
60
|
-
return text;
|
|
61
|
-
};
|
|
62
|
-
/** A `z.array(…)`. */
|
|
63
|
-
export const requireArray = (value, what, fail) => {
|
|
64
|
-
if (!Array.isArray(value)) {
|
|
65
|
-
throw fail(`${what} is not an array`);
|
|
66
|
-
}
|
|
67
|
-
return value;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* A `z.json()` — a JSON value, recursively: `string | number | boolean | null`,
|
|
71
|
-
* an array of them, or an object of them, at ANY depth.
|
|
72
|
-
*
|
|
73
|
-
* WHY THIS EXISTS, given it can never fire over the wire. Every SDK response
|
|
74
|
-
* has already been through `JSON.parse`, so a `Date`, `bigint`, `undefined`, or
|
|
75
|
-
* function CANNOT be present by construction — this check is unreachable in
|
|
76
|
-
* practice. It is here for PARITY: the canonical `sourceImageAnalysisResultSchema`
|
|
77
|
-
* uses `z.json()` precisely because those four break differently on the way to
|
|
78
|
-
* `jsonb` (a `bigint` throws in `JSON.stringify`, an `undefined` is silently
|
|
79
|
-
* dropped, and a `Date` round-trips as an ISO *string* — a different type read
|
|
80
|
-
* back than written). The mirror has to reject what the schema rejects or the
|
|
81
|
-
* parity test is lying. Do not delete this as dead code.
|
|
82
|
-
*/
|
|
83
|
-
const requireJsonValue = (value, what, fail) => {
|
|
84
|
-
if (value === null) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
if (typeof value === "string" || typeof value === "boolean") {
|
|
88
|
-
return value;
|
|
89
|
-
}
|
|
90
|
-
if (typeof value === "number") {
|
|
91
|
-
// `z.json()`'s number leaf rejects NaN and ±Infinity, and `1e999` parses out
|
|
92
|
-
// of JSON as `Infinity` — so finiteness IS reachable, unlike the rest.
|
|
93
|
-
if (!Number.isFinite(value)) {
|
|
94
|
-
throw fail(`${what} is not a finite number`);
|
|
95
|
-
}
|
|
96
|
-
return value;
|
|
97
|
-
}
|
|
98
|
-
if (Array.isArray(value)) {
|
|
99
|
-
return value.map((item, index) => requireJsonValue(item, `${what}[${index}]`, fail));
|
|
100
|
-
}
|
|
101
|
-
if (isRecord(value)) {
|
|
102
|
-
// A PLAIN object only. `isRecord` alone is not enough: it answers true for a
|
|
103
|
-
// `Date`, a `Map`, and any class instance, none of which have own enumerable
|
|
104
|
-
// entries — so recursing over them would silently accept them as `{}` while
|
|
105
|
-
// `z.json()` rejects them outright. A `Date` reaching `jsonb` is exactly the
|
|
106
|
-
// failure this check exists to stop.
|
|
107
|
-
const prototype = Object.getPrototypeOf(value);
|
|
108
|
-
if (prototype !== Object.prototype && prototype !== null) {
|
|
109
|
-
throw fail(`${what} is not a JSON value`);
|
|
110
|
-
}
|
|
111
|
-
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
112
|
-
key,
|
|
113
|
-
requireJsonValue(item, `${what}.${key}`, fail),
|
|
114
|
-
]));
|
|
115
|
-
}
|
|
116
|
-
throw fail(`${what} is not a JSON value`);
|
|
117
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|