@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.
Files changed (92) hide show
  1. package/association-types.d.ts +11 -11
  2. package/associations-client.d.ts +7 -7
  3. package/associations-client.js +5 -5
  4. package/brand-types.d.ts +37 -41
  5. package/brand-types.js +3 -5
  6. package/brands-client.d.ts +22 -9
  7. package/brands-client.js +20 -6
  8. package/by-spec-types.d.ts +1 -1
  9. package/catalog-discovery-types.d.ts +3 -3
  10. package/catalogue-client.d.ts +2 -50
  11. package/catalogue-client.js +2 -10
  12. package/catalogue-types.d.ts +1 -1
  13. package/categories-client.d.ts +3 -5
  14. package/categories-client.js +1 -1
  15. package/category-types.d.ts +17 -30
  16. package/citation-types.d.ts +2 -2
  17. package/client-vocabulary.d.ts +2 -2
  18. package/client-vocabulary.js +4 -1
  19. package/client.d.ts +62 -105
  20. package/client.js +68 -106
  21. package/color-profiles-types.d.ts +70 -0
  22. package/colors-client.d.ts +76 -0
  23. package/colors-client.js +52 -0
  24. package/find-sampled-together-types.d.ts +70 -0
  25. package/{find-companions-types.js → find-sampled-together-types.js} +4 -4
  26. package/{find-variants-by-colour-types.d.ts → find-variants-by-color-types.d.ts} +70 -64
  27. package/find-variants-by-vector-types.d.ts +4 -1
  28. package/get-variant-types.d.ts +14 -2
  29. package/http-transport.d.ts +1 -1
  30. package/http-transport.js +1 -2
  31. package/identifiers.d.ts +2 -2
  32. package/identifiers.js +1 -1
  33. package/index.d.ts +5 -14
  34. package/index.js +1 -3
  35. package/list-variant-facets-types.d.ts +4 -4
  36. package/list-variants-types.d.ts +71 -21
  37. package/material-asset-types.d.ts +3 -3
  38. package/material-block-types.d.ts +9 -9
  39. package/material-types.d.ts +10 -8
  40. package/operations.d.ts +2 -2
  41. package/operations.js +19 -25
  42. package/package.json +2 -2
  43. package/{resolve-colour-types.d.ts → resolve-color-types.d.ts} +18 -18
  44. package/response-schemas.generated.d.ts +2 -2
  45. package/response-schemas.generated.js +41 -71
  46. package/response-schemas.js +1 -1
  47. package/samplize-catalogue-types.d.ts +4 -4
  48. package/samplize-colorvec.js +6 -6
  49. package/{corpus-scope-types.d.ts → search-catalogue-subset-types.d.ts} +3 -3
  50. package/search-variants-types.d.ts +33 -2
  51. package/types.d.ts +32 -284
  52. package/webmcp.generated.js +4 -9
  53. package/attribution-types.d.ts +0 -51
  54. package/attribution-types.js +0 -13
  55. package/by-colour-types.d.ts +0 -320
  56. package/colour-region-types.d.ts +0 -18
  57. package/colours-client.d.ts +0 -70
  58. package/colours-client.js +0 -38
  59. package/find-companions-types.d.ts +0 -70
  60. package/material-query-plan-types.d.ts +0 -70
  61. package/material-query-plan-types.js +0 -1
  62. package/ndjson.d.ts +0 -46
  63. package/ndjson.js +0 -111
  64. package/palette-search-types.d.ts +0 -171
  65. package/palette-search-types.js +0 -1
  66. package/query-understanding-types.d.ts +0 -254
  67. package/query-understanding-types.js +0 -1
  68. package/resolve-colour-types.js +0 -1
  69. package/search-card-types.d.ts +0 -86
  70. package/search-card-types.js +0 -1
  71. package/search-index-plan-types.d.ts +0 -74
  72. package/search-index-plan-types.js +0 -1
  73. package/search-refinement-types.d.ts +0 -103
  74. package/search-refinement-types.js +0 -2
  75. package/search-request-types.d.ts +0 -170
  76. package/search-request-types.js +0 -1
  77. package/search-response-receipt-types.d.ts +0 -24
  78. package/search-response-receipt-types.js +0 -1
  79. package/search-response-types.d.ts +0 -11
  80. package/search-response-types.js +0 -1
  81. package/search-result-validation.d.ts +0 -9
  82. package/search-result-validation.js +0 -83
  83. package/spec-types.d.ts +0 -109
  84. package/spec-types.js +0 -54
  85. package/specifications.d.ts +0 -34
  86. package/specifications.js +0 -56
  87. package/validation.d.ts +0 -43
  88. package/validation.js +0 -117
  89. /package/{by-colour-types.js → color-profiles-types.js} +0 -0
  90. /package/{colour-region-types.js → find-variants-by-color-types.js} +0 -0
  91. /package/{corpus-scope-types.js → resolve-color-types.js} +0 -0
  92. /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