@workglow/util 0.2.20 → 0.2.22
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/browser.js +5 -2
- package/dist/browser.js.map +3 -3
- package/dist/bun.js +5 -2
- package/dist/bun.js.map +3 -3
- package/dist/json-schema/SchemaUtils.d.ts.map +1 -1
- package/dist/json-schema/SchemaValidation.d.ts +6 -0
- package/dist/json-schema/SchemaValidation.d.ts.map +1 -1
- package/dist/media/cpuImage.d.ts +15 -16
- package/dist/media/cpuImage.d.ts.map +1 -1
- package/dist/media/encode.d.ts +3 -5
- package/dist/media/encode.d.ts.map +1 -1
- package/dist/media/gpuImage.d.ts +21 -30
- package/dist/media/gpuImage.d.ts.map +1 -1
- package/dist/media/imageCacheCodec.d.ts +19 -7
- package/dist/media/imageCacheCodec.d.ts.map +1 -1
- package/dist/media/imageRasterCodecRegistry.d.ts +3 -3
- package/dist/media/imageRasterCodecRegistry.d.ts.map +1 -1
- package/dist/media/imageTypes.d.ts +0 -16
- package/dist/media/imageTypes.d.ts.map +1 -1
- package/dist/media/imageValue.d.ts +44 -0
- package/dist/media/imageValue.d.ts.map +1 -0
- package/dist/media/imageValue.test.d.ts +7 -0
- package/dist/media/imageValue.test.d.ts.map +1 -0
- package/dist/media/imageValueSchema.d.ts +15 -0
- package/dist/media/imageValueSchema.d.ts.map +1 -0
- package/dist/media/previewBudget.d.ts +10 -13
- package/dist/media/previewBudget.d.ts.map +1 -1
- package/dist/media/rawPixelBuffer.d.ts +20 -0
- package/dist/media/rawPixelBuffer.d.ts.map +1 -0
- package/dist/media/{sharpImage.node.d.ts → sharpImage.server.d.ts} +42 -14
- package/dist/media/sharpImage.server.d.ts.map +1 -0
- package/dist/media/webGpuImage.browser.d.ts +11 -14
- package/dist/media/webGpuImage.browser.d.ts.map +1 -1
- package/dist/media-browser.d.ts +9 -3
- package/dist/media-browser.d.ts.map +1 -1
- package/dist/media-browser.js +429 -342
- package/dist/media-browser.js.map +14 -14
- package/dist/media-node.d.ts +8 -6
- package/dist/media-node.d.ts.map +1 -1
- package/dist/media-node.js +479 -254
- package/dist/media-node.js.map +14 -14
- package/dist/node.js +5 -2
- package/dist/node.js.map +3 -3
- package/dist/schema-entry.js +166 -165
- package/dist/schema-entry.js.map +5 -5
- package/dist/worker/WorkerManager.d.ts.map +1 -1
- package/dist/worker-browser.js +5 -2
- package/dist/worker-browser.js.map +3 -3
- package/dist/worker-bun.js +5 -2
- package/dist/worker-bun.js.map +3 -3
- package/dist/worker-node.js +5 -2
- package/dist/worker-node.js.map +3 -3
- package/package.json +1 -1
- package/dist/media/gpuImageSchema.d.ts +0 -8
- package/dist/media/gpuImageSchema.d.ts.map +0 -1
- package/dist/media/sharpImage.bun.d.ts +0 -7
- package/dist/media/sharpImage.bun.d.ts.map +0 -1
- package/dist/media/sharpImage.node.d.ts.map +0 -1
package/dist/schema-entry.js
CHANGED
|
@@ -6,10 +6,171 @@ var FromSchemaDefaultOptions = {
|
|
|
6
6
|
references: false,
|
|
7
7
|
deserialize: false
|
|
8
8
|
};
|
|
9
|
+
// src/json-schema/SchemaValidation.ts
|
|
10
|
+
import { compileSchema } from "@sroussey/json-schema-library";
|
|
11
|
+
var VALID_RESULT = Object.freeze({
|
|
12
|
+
valid: true,
|
|
13
|
+
errors: Object.freeze([])
|
|
14
|
+
});
|
|
15
|
+
var FORMAT_PATTERN = /^[a-zA-Z][a-zA-Z0-9_-]*(?::[a-zA-Z0-9][a-zA-Z0-9_-]*)*$/;
|
|
16
|
+
var VALID_JSON_SCHEMA_TYPES = new Set([
|
|
17
|
+
"string",
|
|
18
|
+
"number",
|
|
19
|
+
"integer",
|
|
20
|
+
"boolean",
|
|
21
|
+
"object",
|
|
22
|
+
"array",
|
|
23
|
+
"null"
|
|
24
|
+
]);
|
|
25
|
+
function validateDataPortSchema(schema) {
|
|
26
|
+
if (typeof schema === "boolean") {
|
|
27
|
+
return VALID_RESULT;
|
|
28
|
+
}
|
|
29
|
+
const errors = [];
|
|
30
|
+
if (typeof schema !== "object" || schema === null) {
|
|
31
|
+
return { valid: false, errors: [{ path: "", message: "Schema must be a boolean or object" }] };
|
|
32
|
+
}
|
|
33
|
+
if (schema.type !== "object") {
|
|
34
|
+
errors.push({
|
|
35
|
+
path: "/type",
|
|
36
|
+
message: `DataPortSchema must have type "object", got "${String(schema.type)}"`
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (!schema.properties || typeof schema.properties !== "object" || Array.isArray(schema.properties)) {
|
|
40
|
+
errors.push({
|
|
41
|
+
path: "/properties",
|
|
42
|
+
message: "DataPortSchema must have a properties object"
|
|
43
|
+
});
|
|
44
|
+
} else {
|
|
45
|
+
for (const [key, value] of Object.entries(schema.properties)) {
|
|
46
|
+
if (typeof value === "boolean") {
|
|
47
|
+
errors.push({
|
|
48
|
+
path: `/properties/${key}`,
|
|
49
|
+
message: `Property "${key}" must not be a boolean schema`
|
|
50
|
+
});
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
collectJsonSchemaErrors(value, `/properties/${key}`, errors);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return errors.length === 0 ? VALID_RESULT : { valid: false, errors };
|
|
57
|
+
}
|
|
58
|
+
function collectJsonSchemaErrors(schema, path, errors) {
|
|
59
|
+
if (typeof schema === "boolean") {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (schema === null || schema === undefined) {
|
|
63
|
+
errors.push({ path, message: `Expected schema object, got ${typeof schema}` });
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (typeof schema !== "object") {
|
|
67
|
+
errors.push({ path, message: `Expected schema object, got ${typeof schema}` });
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (schema.type !== undefined) {
|
|
71
|
+
if (typeof schema.type === "string") {
|
|
72
|
+
if (!VALID_JSON_SCHEMA_TYPES.has(schema.type)) {
|
|
73
|
+
errors.push({
|
|
74
|
+
path: `${path}/type`,
|
|
75
|
+
message: `Unknown JSON Schema type "${schema.type}"`
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
} else if (Array.isArray(schema.type)) {
|
|
79
|
+
for (const t of schema.type) {
|
|
80
|
+
if (!VALID_JSON_SCHEMA_TYPES.has(t)) {
|
|
81
|
+
errors.push({
|
|
82
|
+
path: `${path}/type`,
|
|
83
|
+
message: `Unknown JSON Schema type "${String(t)}" in type array`
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (schema.properties && typeof schema.properties === "object") {
|
|
90
|
+
for (const [key, value] of Object.entries(schema.properties)) {
|
|
91
|
+
if (typeof value === "boolean") {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
collectJsonSchemaErrors(value, `${path}/properties/${key}`, errors);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (schema.items && typeof schema.items === "object" && !Array.isArray(schema.items)) {
|
|
98
|
+
collectJsonSchemaErrors(schema.items, `${path}/items`, errors);
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(schema.items)) {
|
|
101
|
+
for (let i = 0;i < schema.items.length; i++) {
|
|
102
|
+
collectJsonSchemaErrors(schema.items[i], `${path}/items/${i}`, errors);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
for (const keyword of ["oneOf", "anyOf", "allOf"]) {
|
|
106
|
+
const arr = schema[keyword];
|
|
107
|
+
if (Array.isArray(arr)) {
|
|
108
|
+
for (let i = 0;i < arr.length; i++) {
|
|
109
|
+
collectJsonSchemaErrors(arr[i], `${path}/${keyword}/${i}`, errors);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function validateFormatAnnotations(schema) {
|
|
115
|
+
if (typeof schema === "boolean") {
|
|
116
|
+
return VALID_RESULT;
|
|
117
|
+
}
|
|
118
|
+
if (typeof schema !== "object" || schema === null || Array.isArray(schema)) {
|
|
119
|
+
return {
|
|
120
|
+
valid: false,
|
|
121
|
+
errors: [{ path: "", message: "Schema must be a JSON Schema object or boolean" }]
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const errors = [];
|
|
125
|
+
collectFormatErrors(schema, "", errors);
|
|
126
|
+
return errors.length === 0 ? VALID_RESULT : { valid: false, errors };
|
|
127
|
+
}
|
|
128
|
+
function collectFormatErrors(schema, path, errors) {
|
|
129
|
+
if (typeof schema !== "object" || schema === null) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const format = schema.format;
|
|
133
|
+
if (typeof format === "string" && !FORMAT_PATTERN.test(format)) {
|
|
134
|
+
errors.push({
|
|
135
|
+
path: `${path}/format`,
|
|
136
|
+
message: `Invalid format annotation "${format}" — must match pattern ${FORMAT_PATTERN.source}`
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (schema.properties && typeof schema.properties === "object") {
|
|
140
|
+
for (const [key, value] of Object.entries(schema.properties)) {
|
|
141
|
+
collectFormatErrors(value, `${path}/properties/${key}`, errors);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (schema.items && typeof schema.items === "object" && !Array.isArray(schema.items)) {
|
|
145
|
+
collectFormatErrors(schema.items, `${path}/items`, errors);
|
|
146
|
+
}
|
|
147
|
+
if (Array.isArray(schema.items)) {
|
|
148
|
+
for (let i = 0;i < schema.items.length; i++) {
|
|
149
|
+
collectFormatErrors(schema.items[i], `${path}/items/${i}`, errors);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
for (const keyword of ["oneOf", "anyOf", "allOf"]) {
|
|
153
|
+
const arr = schema[keyword];
|
|
154
|
+
if (Array.isArray(arr)) {
|
|
155
|
+
for (let i = 0;i < arr.length; i++) {
|
|
156
|
+
collectFormatErrors(arr[i], `${path}/${keyword}/${i}`, errors);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function validateSchema(schema) {
|
|
162
|
+
if (typeof schema === "boolean") {
|
|
163
|
+
return VALID_RESULT;
|
|
164
|
+
}
|
|
165
|
+
const structureResult = validateDataPortSchema(schema);
|
|
166
|
+
const formatResult = validateFormatAnnotations(schema);
|
|
167
|
+
const allErrors = [...structureResult.errors, ...formatResult.errors];
|
|
168
|
+
return allErrors.length === 0 ? VALID_RESULT : { valid: false, errors: allErrors };
|
|
169
|
+
}
|
|
170
|
+
|
|
9
171
|
// src/json-schema/SchemaUtils.ts
|
|
10
172
|
function areFormatStringsCompatible(sourceFormat, targetFormat) {
|
|
11
|
-
|
|
12
|
-
if (!formatPattern.test(sourceFormat) || !formatPattern.test(targetFormat)) {
|
|
173
|
+
if (!FORMAT_PATTERN.test(sourceFormat) || !FORMAT_PATTERN.test(targetFormat)) {
|
|
13
174
|
return "incompatible";
|
|
14
175
|
}
|
|
15
176
|
const [sourceName, sourceNarrow] = sourceFormat.split(":");
|
|
@@ -353,167 +514,6 @@ function areSemanticallyCompatible(sourceSchema, targetSchema) {
|
|
|
353
514
|
function areObjectSchemasSemanticallyCompatible(sourceSchema, targetSchema) {
|
|
354
515
|
return areSemanticallyCompatible(sourceSchema, targetSchema);
|
|
355
516
|
}
|
|
356
|
-
// src/json-schema/SchemaValidation.ts
|
|
357
|
-
import { compileSchema } from "@sroussey/json-schema-library";
|
|
358
|
-
var VALID_RESULT = Object.freeze({
|
|
359
|
-
valid: true,
|
|
360
|
-
errors: Object.freeze([])
|
|
361
|
-
});
|
|
362
|
-
var FORMAT_PATTERN = /^[a-zA-Z][a-zA-Z0-9_-]*(?::[a-zA-Z][a-zA-Z0-9_-]*)?$/;
|
|
363
|
-
var VALID_JSON_SCHEMA_TYPES = new Set([
|
|
364
|
-
"string",
|
|
365
|
-
"number",
|
|
366
|
-
"integer",
|
|
367
|
-
"boolean",
|
|
368
|
-
"object",
|
|
369
|
-
"array",
|
|
370
|
-
"null"
|
|
371
|
-
]);
|
|
372
|
-
function validateDataPortSchema(schema) {
|
|
373
|
-
if (typeof schema === "boolean") {
|
|
374
|
-
return VALID_RESULT;
|
|
375
|
-
}
|
|
376
|
-
const errors = [];
|
|
377
|
-
if (typeof schema !== "object" || schema === null) {
|
|
378
|
-
return { valid: false, errors: [{ path: "", message: "Schema must be a boolean or object" }] };
|
|
379
|
-
}
|
|
380
|
-
if (schema.type !== "object") {
|
|
381
|
-
errors.push({
|
|
382
|
-
path: "/type",
|
|
383
|
-
message: `DataPortSchema must have type "object", got "${String(schema.type)}"`
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
if (!schema.properties || typeof schema.properties !== "object" || Array.isArray(schema.properties)) {
|
|
387
|
-
errors.push({
|
|
388
|
-
path: "/properties",
|
|
389
|
-
message: "DataPortSchema must have a properties object"
|
|
390
|
-
});
|
|
391
|
-
} else {
|
|
392
|
-
for (const [key, value] of Object.entries(schema.properties)) {
|
|
393
|
-
if (typeof value === "boolean") {
|
|
394
|
-
errors.push({
|
|
395
|
-
path: `/properties/${key}`,
|
|
396
|
-
message: `Property "${key}" must not be a boolean schema`
|
|
397
|
-
});
|
|
398
|
-
continue;
|
|
399
|
-
}
|
|
400
|
-
collectJsonSchemaErrors(value, `/properties/${key}`, errors);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
return errors.length === 0 ? VALID_RESULT : { valid: false, errors };
|
|
404
|
-
}
|
|
405
|
-
function collectJsonSchemaErrors(schema, path, errors) {
|
|
406
|
-
if (typeof schema === "boolean") {
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
if (schema === null || schema === undefined) {
|
|
410
|
-
errors.push({ path, message: `Expected schema object, got ${typeof schema}` });
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
if (typeof schema !== "object") {
|
|
414
|
-
errors.push({ path, message: `Expected schema object, got ${typeof schema}` });
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
if (schema.type !== undefined) {
|
|
418
|
-
if (typeof schema.type === "string") {
|
|
419
|
-
if (!VALID_JSON_SCHEMA_TYPES.has(schema.type)) {
|
|
420
|
-
errors.push({
|
|
421
|
-
path: `${path}/type`,
|
|
422
|
-
message: `Unknown JSON Schema type "${schema.type}"`
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
} else if (Array.isArray(schema.type)) {
|
|
426
|
-
for (const t of schema.type) {
|
|
427
|
-
if (!VALID_JSON_SCHEMA_TYPES.has(t)) {
|
|
428
|
-
errors.push({
|
|
429
|
-
path: `${path}/type`,
|
|
430
|
-
message: `Unknown JSON Schema type "${String(t)}" in type array`
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
if (schema.properties && typeof schema.properties === "object") {
|
|
437
|
-
for (const [key, value] of Object.entries(schema.properties)) {
|
|
438
|
-
if (typeof value === "boolean") {
|
|
439
|
-
continue;
|
|
440
|
-
}
|
|
441
|
-
collectJsonSchemaErrors(value, `${path}/properties/${key}`, errors);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
if (schema.items && typeof schema.items === "object" && !Array.isArray(schema.items)) {
|
|
445
|
-
collectJsonSchemaErrors(schema.items, `${path}/items`, errors);
|
|
446
|
-
}
|
|
447
|
-
if (Array.isArray(schema.items)) {
|
|
448
|
-
for (let i = 0;i < schema.items.length; i++) {
|
|
449
|
-
collectJsonSchemaErrors(schema.items[i], `${path}/items/${i}`, errors);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
for (const keyword of ["oneOf", "anyOf", "allOf"]) {
|
|
453
|
-
const arr = schema[keyword];
|
|
454
|
-
if (Array.isArray(arr)) {
|
|
455
|
-
for (let i = 0;i < arr.length; i++) {
|
|
456
|
-
collectJsonSchemaErrors(arr[i], `${path}/${keyword}/${i}`, errors);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
function validateFormatAnnotations(schema) {
|
|
462
|
-
if (typeof schema === "boolean") {
|
|
463
|
-
return VALID_RESULT;
|
|
464
|
-
}
|
|
465
|
-
if (typeof schema !== "object" || schema === null || Array.isArray(schema)) {
|
|
466
|
-
return {
|
|
467
|
-
valid: false,
|
|
468
|
-
errors: [{ path: "", message: "Schema must be a JSON Schema object or boolean" }]
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
const errors = [];
|
|
472
|
-
collectFormatErrors(schema, "", errors);
|
|
473
|
-
return errors.length === 0 ? VALID_RESULT : { valid: false, errors };
|
|
474
|
-
}
|
|
475
|
-
function collectFormatErrors(schema, path, errors) {
|
|
476
|
-
if (typeof schema !== "object" || schema === null) {
|
|
477
|
-
return;
|
|
478
|
-
}
|
|
479
|
-
const format = schema.format;
|
|
480
|
-
if (typeof format === "string" && !FORMAT_PATTERN.test(format)) {
|
|
481
|
-
errors.push({
|
|
482
|
-
path: `${path}/format`,
|
|
483
|
-
message: `Invalid format annotation "${format}" — must match pattern ${FORMAT_PATTERN.source}`
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
if (schema.properties && typeof schema.properties === "object") {
|
|
487
|
-
for (const [key, value] of Object.entries(schema.properties)) {
|
|
488
|
-
collectFormatErrors(value, `${path}/properties/${key}`, errors);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
if (schema.items && typeof schema.items === "object" && !Array.isArray(schema.items)) {
|
|
492
|
-
collectFormatErrors(schema.items, `${path}/items`, errors);
|
|
493
|
-
}
|
|
494
|
-
if (Array.isArray(schema.items)) {
|
|
495
|
-
for (let i = 0;i < schema.items.length; i++) {
|
|
496
|
-
collectFormatErrors(schema.items[i], `${path}/items/${i}`, errors);
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
for (const keyword of ["oneOf", "anyOf", "allOf"]) {
|
|
500
|
-
const arr = schema[keyword];
|
|
501
|
-
if (Array.isArray(arr)) {
|
|
502
|
-
for (let i = 0;i < arr.length; i++) {
|
|
503
|
-
collectFormatErrors(arr[i], `${path}/${keyword}/${i}`, errors);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
function validateSchema(schema) {
|
|
509
|
-
if (typeof schema === "boolean") {
|
|
510
|
-
return VALID_RESULT;
|
|
511
|
-
}
|
|
512
|
-
const structureResult = validateDataPortSchema(schema);
|
|
513
|
-
const formatResult = validateFormatAnnotations(schema);
|
|
514
|
-
const allErrors = [...structureResult.errors, ...formatResult.errors];
|
|
515
|
-
return allErrors.length === 0 ? VALID_RESULT : { valid: false, errors: allErrors };
|
|
516
|
-
}
|
|
517
517
|
// src/json-schema/parsePartialJson.ts
|
|
518
518
|
function parsePartialJson(text) {
|
|
519
519
|
const trimmed = text.trim();
|
|
@@ -925,7 +925,8 @@ export {
|
|
|
925
925
|
TypedArraySchema,
|
|
926
926
|
TensorType,
|
|
927
927
|
TensorSchema,
|
|
928
|
-
FromSchemaDefaultOptions
|
|
928
|
+
FromSchemaDefaultOptions,
|
|
929
|
+
FORMAT_PATTERN
|
|
929
930
|
};
|
|
930
931
|
|
|
931
|
-
//# debugId=
|
|
932
|
+
//# debugId=A6ECA6928852238264756E2164756E21
|