@transloadit/zod 5.0.0 → 5.0.1
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/v3/index.d.ts +1 -0
- package/dist/v3/index.d.ts.map +1 -1
- package/dist/v3/index.js +1 -0
- package/dist/v3/storageResults.d.ts +29 -0
- package/dist/v3/storageResults.d.ts.map +1 -0
- package/dist/v3/storageResults.js +52 -0
- package/dist/v4/index.d.ts +1 -0
- package/dist/v4/index.d.ts.map +1 -1
- package/dist/v4/index.js +1 -0
- package/dist/v4/storageResults.d.ts +23 -0
- package/dist/v4/storageResults.d.ts.map +1 -0
- package/dist/v4/storageResults.js +53 -0
- package/package.json +3 -3
package/dist/v3/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from './robots/_index.ts';
|
|
|
13
13
|
export * from './skillFrontmatter.ts';
|
|
14
14
|
export * from './stackVersions.ts';
|
|
15
15
|
export * from './storageAsset.ts';
|
|
16
|
+
export * from './storageResults.ts';
|
|
16
17
|
export * from './template.ts';
|
|
17
18
|
export * from './templateCredential.ts';
|
|
18
19
|
export * from './utility.ts';
|
package/dist/v3/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v3/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,yBAAyB,CAAA;AACvC,cAAc,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v3/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,yBAAyB,CAAA;AACvC,cAAc,cAAc,CAAA"}
|
package/dist/v3/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./robots/_index.js";
|
|
|
13
13
|
export * from "./skillFrontmatter.js";
|
|
14
14
|
export * from "./stackVersions.js";
|
|
15
15
|
export * from "./storageAsset.js";
|
|
16
|
+
export * from "./storageResults.js";
|
|
16
17
|
export * from "./template.js";
|
|
17
18
|
export * from "./templateCredential.js";
|
|
18
19
|
export * from "./utility.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { StoredAsset } from './storageAsset.ts';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
|
+
/** Server-owned Assembly identity and expected Workspace, never untrusted notification fields. */
|
|
4
|
+
export declare const storedAssemblyResultsOptionsSchema: z.ZodObject<{
|
|
5
|
+
assemblyId: z.ZodString;
|
|
6
|
+
workspace: z.ZodString;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
workspace: string;
|
|
9
|
+
assemblyId: string;
|
|
10
|
+
}, {
|
|
11
|
+
workspace: string;
|
|
12
|
+
assemblyId: string;
|
|
13
|
+
}>;
|
|
14
|
+
export type GetStoredAssemblyResultsOptions = z.infer<typeof storedAssemblyResultsOptionsSchema>;
|
|
15
|
+
/** Canonical retained receipt and producing result provenance, for idempotent registration. */
|
|
16
|
+
export interface StoredAssemblyResult {
|
|
17
|
+
assembly_id: string;
|
|
18
|
+
step: string;
|
|
19
|
+
result_id: string;
|
|
20
|
+
original_id?: string | (string | null)[];
|
|
21
|
+
asset: StoredAsset;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Pure extraction from a fetched/verified Assembly bound to an authorized app upload. Validates
|
|
25
|
+
* every retained result atomically; temporary outputs are ignored, partial receipts are rejected.
|
|
26
|
+
* This does not authenticate notifications or check application permissions.
|
|
27
|
+
*/
|
|
28
|
+
export declare function extractStoredAssemblyResults(input: unknown, options: GetStoredAssemblyResultsOptions): StoredAssemblyResult[];
|
|
29
|
+
//# sourceMappingURL=storageResults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storageResults.d.ts","sourceRoot":"","sources":["../../src/v3/storageResults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAO1B,kGAAkG;AAClG,eAAO,MAAM,kCAAkC;;;;;;;;;EAG7C,CAAA;AAEF,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAEhG,+FAA+F;AAC/F,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;IACxC,KAAK,EAAE,WAAW,CAAA;CACnB;AAaD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,+BAA+B,GACvC,oBAAoB,EAAE,CA6BxB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from 'zod/v3';
|
|
2
|
+
import { storedAssetSchema } from "./storageAsset.js";
|
|
3
|
+
// SDK-owned extraction is outside alphalib-sync's explicit node-sdk syncIncludes. Co-location
|
|
4
|
+
// reuses canonical schemas and their Types/Zod generation without adding a runtime package.
|
|
5
|
+
/** Server-owned Assembly identity and expected Workspace, never untrusted notification fields. */
|
|
6
|
+
export const storedAssemblyResultsOptionsSchema = z.object({
|
|
7
|
+
assemblyId: z.string().regex(/^[A-Za-z0-9_-]+$/),
|
|
8
|
+
workspace: z.string().min(1),
|
|
9
|
+
});
|
|
10
|
+
const resultSchema = storedAssetSchema.extend({
|
|
11
|
+
id: z.string().min(1),
|
|
12
|
+
original_id: z.union([z.string(), z.array(z.string().nullable())]).optional(),
|
|
13
|
+
});
|
|
14
|
+
const assemblySchema = z.object({
|
|
15
|
+
assembly_id: z.string(),
|
|
16
|
+
ok: z.string().nullable().optional(),
|
|
17
|
+
error: z.string().optional(),
|
|
18
|
+
results: z.record(z.array(z.record(z.unknown()))).optional(),
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Pure extraction from a fetched/verified Assembly bound to an authorized app upload. Validates
|
|
22
|
+
* every retained result atomically; temporary outputs are ignored, partial receipts are rejected.
|
|
23
|
+
* This does not authenticate notifications or check application permissions.
|
|
24
|
+
*/
|
|
25
|
+
export function extractStoredAssemblyResults(input, options) {
|
|
26
|
+
const { assemblyId, workspace } = storedAssemblyResultsOptionsSchema.parse(options);
|
|
27
|
+
const assembly = assemblySchema.parse(input);
|
|
28
|
+
if (assembly.assembly_id !== assemblyId)
|
|
29
|
+
throw new Error('The response did not match the requested Assembly');
|
|
30
|
+
if (assembly.error !== undefined || assembly.ok !== 'ASSEMBLY_COMPLETED')
|
|
31
|
+
throw new Error(`The Storage Assembly is not complete (${assembly.error ?? assembly.ok})`);
|
|
32
|
+
if (assembly.results === undefined)
|
|
33
|
+
throw new Error('The completed Assembly did not contain results');
|
|
34
|
+
const results = [];
|
|
35
|
+
for (const [step, files] of Object.entries(assembly.results)) {
|
|
36
|
+
for (const file of files) {
|
|
37
|
+
if (file.asset_id === undefined &&
|
|
38
|
+
file.version_id === undefined &&
|
|
39
|
+
file.workspace === undefined)
|
|
40
|
+
continue;
|
|
41
|
+
const parsed = resultSchema.safeParse(file);
|
|
42
|
+
if (!parsed.success || parsed.data.workspace !== workspace) {
|
|
43
|
+
throw new Error('The Assembly returned an invalid or cross-Workspace Storage result', {
|
|
44
|
+
cause: { assemblyId, step },
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const { id, original_id, ...asset } = parsed.data;
|
|
48
|
+
results.push({ assembly_id: assemblyId, step, result_id: id, original_id, asset });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return results;
|
|
52
|
+
}
|
package/dist/v4/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from './robots/_index.ts';
|
|
|
13
13
|
export * from './skillFrontmatter.ts';
|
|
14
14
|
export * from './stackVersions.ts';
|
|
15
15
|
export * from './storageAsset.ts';
|
|
16
|
+
export * from './storageResults.ts';
|
|
16
17
|
export * from './template.ts';
|
|
17
18
|
export * from './templateCredential.ts';
|
|
18
19
|
export * from './utility.ts';
|
package/dist/v4/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v4/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,yBAAyB,CAAA;AACvC,cAAc,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v4/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,yBAAyB,CAAA;AACvC,cAAc,cAAc,CAAA"}
|
package/dist/v4/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./robots/_index.js";
|
|
|
13
13
|
export * from "./skillFrontmatter.js";
|
|
14
14
|
export * from "./stackVersions.js";
|
|
15
15
|
export * from "./storageAsset.js";
|
|
16
|
+
export * from "./storageResults.js";
|
|
16
17
|
export * from "./template.js";
|
|
17
18
|
export * from "./templateCredential.js";
|
|
18
19
|
export * from "./utility.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { StoredAsset } from './storageAsset.ts';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
/** Server-owned Assembly identity and expected Workspace, never untrusted notification fields. */
|
|
4
|
+
export declare const storedAssemblyResultsOptionsSchema: z.ZodObject<{
|
|
5
|
+
assemblyId: z.ZodString;
|
|
6
|
+
workspace: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type GetStoredAssemblyResultsOptions = z.infer<typeof storedAssemblyResultsOptionsSchema>;
|
|
9
|
+
/** Canonical retained receipt and producing result provenance, for idempotent registration. */
|
|
10
|
+
export interface StoredAssemblyResult {
|
|
11
|
+
assembly_id: string;
|
|
12
|
+
step: string;
|
|
13
|
+
result_id: string;
|
|
14
|
+
original_id?: string | (string | null)[];
|
|
15
|
+
asset: StoredAsset;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Pure extraction from a fetched/verified Assembly bound to an authorized app upload. Validates
|
|
19
|
+
* every retained result atomically; temporary outputs are ignored, partial receipts are rejected.
|
|
20
|
+
* This does not authenticate notifications or check application permissions.
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractStoredAssemblyResults(input: unknown, options: GetStoredAssemblyResultsOptions): StoredAssemblyResult[];
|
|
23
|
+
//# sourceMappingURL=storageResults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storageResults.d.ts","sourceRoot":"","sources":["../../src/v4/storageResults.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAO1B,kGAAkG;AAClG,eAAO,MAAM,kCAAkC;;;iBAG7C,CAAA;AAEF,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAEhG,+FAA+F;AAC/F,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;IACxC,KAAK,EAAE,WAAW,CAAA;CACnB;AAaD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,+BAA+B,GACvC,oBAAoB,EAAE,CA6BxB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { optionalWithV3Semantics } from "./lib/sdkZodOptional.js";
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
import { storedAssetSchema } from "./storageAsset.js";
|
|
4
|
+
// SDK-owned extraction is outside alphalib-sync's explicit node-sdk syncIncludes. Co-location
|
|
5
|
+
// reuses canonical schemas and their Types/Zod generation without adding a runtime package.
|
|
6
|
+
/** Server-owned Assembly identity and expected Workspace, never untrusted notification fields. */
|
|
7
|
+
export const storedAssemblyResultsOptionsSchema = z.object({
|
|
8
|
+
assemblyId: z.string().regex(/^[A-Za-z0-9_-]+$/),
|
|
9
|
+
workspace: z.string().min(1),
|
|
10
|
+
});
|
|
11
|
+
const resultSchema = storedAssetSchema.extend({
|
|
12
|
+
id: z.string().min(1),
|
|
13
|
+
original_id: optionalWithV3Semantics(z.union([z.string(), z.array(z.string().nullable())])),
|
|
14
|
+
});
|
|
15
|
+
const assemblySchema = z.object({
|
|
16
|
+
assembly_id: z.string(),
|
|
17
|
+
ok: optionalWithV3Semantics(z.string().nullable()),
|
|
18
|
+
error: optionalWithV3Semantics(z.string()),
|
|
19
|
+
results: optionalWithV3Semantics(z.record(z.string(), z.array(z.record(z.string(), z.unknown())))),
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Pure extraction from a fetched/verified Assembly bound to an authorized app upload. Validates
|
|
23
|
+
* every retained result atomically; temporary outputs are ignored, partial receipts are rejected.
|
|
24
|
+
* This does not authenticate notifications or check application permissions.
|
|
25
|
+
*/
|
|
26
|
+
export function extractStoredAssemblyResults(input, options) {
|
|
27
|
+
const { assemblyId, workspace } = storedAssemblyResultsOptionsSchema.parse(options);
|
|
28
|
+
const assembly = assemblySchema.parse(input);
|
|
29
|
+
if (assembly.assembly_id !== assemblyId)
|
|
30
|
+
throw new Error('The response did not match the requested Assembly');
|
|
31
|
+
if (assembly.error !== undefined || assembly.ok !== 'ASSEMBLY_COMPLETED')
|
|
32
|
+
throw new Error(`The Storage Assembly is not complete (${assembly.error ?? assembly.ok})`);
|
|
33
|
+
if (assembly.results === undefined)
|
|
34
|
+
throw new Error('The completed Assembly did not contain results');
|
|
35
|
+
const results = [];
|
|
36
|
+
for (const [step, files] of Object.entries(assembly.results)) {
|
|
37
|
+
for (const file of files) {
|
|
38
|
+
if (file.asset_id === undefined &&
|
|
39
|
+
file.version_id === undefined &&
|
|
40
|
+
file.workspace === undefined)
|
|
41
|
+
continue;
|
|
42
|
+
const parsed = resultSchema.safeParse(file);
|
|
43
|
+
if (!parsed.success || parsed.data.workspace !== workspace) {
|
|
44
|
+
throw new Error('The Assembly returned an invalid or cross-Workspace Storage result', {
|
|
45
|
+
cause: { assemblyId, step },
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const { id, original_id, ...asset } = parsed.data;
|
|
49
|
+
results.push({ assembly_id: assemblyId, step, result_id: id, original_id, asset });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return results;
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transloadit/zod",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Transloadit Zod schemas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"sync": "yarn sync:v3 && yarn sync:v4",
|
|
42
42
|
"lint:ts": "yarn sync && ../../node_modules/.bin/tsc --build tsconfig.build.json",
|
|
43
43
|
"test:types": "yarn sync && ../../node_modules/.bin/tsc --noEmit --project tsconfig.test.json",
|
|
44
|
-
"test:unit": "yarn sync && node test/scripts-config.test.ts && node test/patch-ai-chat-schema.test.ts && node test/exports-sync.test.ts && node test/runtime-parity.test.ts",
|
|
44
|
+
"test:unit": "yarn sync && node test/scripts-config.test.ts && node test/patch-ai-chat-schema.test.ts && node test/exports-sync.test.ts && node test/runtime-parity.test.ts && node test/storage-results.test.ts",
|
|
45
45
|
"build": "yarn sync && ../../node_modules/.bin/tsc --build tsconfig.build.json",
|
|
46
46
|
"prepack": "yarn build",
|
|
47
47
|
"check": "yarn sync && ../../node_modules/.bin/tsc --build tsconfig.build.json && ../../node_modules/.bin/tsc --noEmit --project tsconfig.test.json && yarn test:unit"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"zod": "^4.4.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@transloadit/types": "^5.0.
|
|
53
|
+
"@transloadit/types": "^5.0.1",
|
|
54
54
|
"@types/node": "^25.8.0"
|
|
55
55
|
}
|
|
56
56
|
}
|