vellum-ai 0.6.8 → 0.6.11
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/Client.d.ts +9 -6
- package/Client.js +40 -37
- package/api/client/requests/ExecutePromptRequest.d.ts +7 -5
- package/api/client/requests/ExecutePromptStreamRequest.d.ts +7 -5
- package/api/resources/deployments/client/Client.d.ts +8 -5
- package/api/resources/deployments/client/Client.js +22 -17
- package/api/resources/documentIndexes/client/Client.d.ts +21 -7
- package/api/resources/documentIndexes/client/Client.js +77 -26
- package/api/resources/documents/client/Client.d.ts +11 -7
- package/api/resources/documents/client/Client.js +25 -22
- package/api/resources/folderEntities/client/Client.d.ts +4 -1
- package/api/resources/folderEntities/client/Client.js +4 -3
- package/api/resources/sandboxes/client/Client.d.ts +7 -4
- package/api/resources/sandboxes/client/Client.js +14 -13
- package/api/resources/testSuiteRuns/client/Client.d.ts +6 -3
- package/api/resources/testSuiteRuns/client/Client.js +13 -10
- package/api/resources/testSuites/client/Client.d.ts +6 -3
- package/api/resources/testSuites/client/Client.js +16 -14
- package/api/resources/workflowDeployments/client/Client.d.ts +7 -4
- package/api/resources/workflowDeployments/client/Client.js +17 -13
- package/api/resources/workflowSandboxes/client/Client.d.ts +4 -1
- package/api/resources/workflowSandboxes/client/Client.js +5 -6
- package/api/types/IterationStateEnum.d.ts +12 -0
- package/api/types/IterationStateEnum.js +10 -0
- package/api/types/MapNodeResultData.d.ts +2 -0
- package/api/types/PromptNodeResultData.d.ts +1 -0
- package/api/types/TestSuiteRunMetricNumberOutput.d.ts +1 -1
- package/api/types/TestSuiteRunMetricStringOutput.d.ts +1 -1
- package/api/types/TestSuiteTestCaseRejectedBulkResult.d.ts +1 -1
- package/api/types/index.d.ts +1 -0
- package/api/types/index.js +1 -0
- package/core/fetcher/Fetcher.d.ts +2 -0
- package/core/fetcher/Fetcher.js +19 -185
- package/core/fetcher/createRequestUrl.d.ts +1 -0
- package/core/fetcher/createRequestUrl.js +13 -0
- package/core/fetcher/getFetchFn.d.ts +4 -0
- package/core/fetcher/getFetchFn.js +55 -0
- package/core/fetcher/getRequestBody.d.ts +7 -0
- package/core/fetcher/getRequestBody.js +23 -0
- package/core/fetcher/getResponseBody.d.ts +1 -0
- package/core/fetcher/getResponseBody.js +48 -0
- package/core/fetcher/makeRequest.d.ts +1 -0
- package/core/fetcher/makeRequest.js +40 -0
- package/core/fetcher/requestWithRetries.d.ts +1 -0
- package/core/fetcher/requestWithRetries.js +32 -0
- package/core/fetcher/signals.d.ts +12 -0
- package/core/fetcher/signals.js +37 -0
- package/core/form-data-utils/FormDataWrapper.d.ts +10 -21
- package/core/form-data-utils/FormDataWrapper.js +82 -49
- package/core/runtime/runtime.d.ts +1 -0
- package/core/runtime/runtime.js +1 -0
- package/core/schemas/Schema.d.ts +7 -4
- package/core/schemas/builders/lazy/lazy.d.ts +2 -2
- package/core/schemas/builders/lazy/lazy.js +8 -19
- package/core/schemas/builders/lazy/lazyObject.js +1 -10
- package/core/schemas/builders/list/list.js +31 -44
- package/core/schemas/builders/object/object.js +90 -111
- package/core/schemas/builders/object/types.d.ts +2 -2
- package/core/schemas/builders/object-like/getObjectLikeUtils.js +3 -12
- package/core/schemas/builders/record/record.js +49 -60
- package/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +2 -2
- package/core/schemas/builders/schema-utils/getSchemaUtils.js +18 -21
- package/core/schemas/builders/set/set.js +6 -15
- package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +21 -32
- package/core/schemas/builders/union/union.js +51 -62
- package/core/schemas/utils/maybeSkipValidation.js +3 -12
- package/dist/Client.d.ts +9 -6
- package/dist/Client.js +40 -37
- package/dist/api/client/requests/ExecutePromptRequest.d.ts +7 -5
- package/dist/api/client/requests/ExecutePromptStreamRequest.d.ts +7 -5
- package/dist/api/resources/deployments/client/Client.d.ts +8 -5
- package/dist/api/resources/deployments/client/Client.js +22 -17
- package/dist/api/resources/documentIndexes/client/Client.d.ts +21 -7
- package/dist/api/resources/documentIndexes/client/Client.js +77 -26
- package/dist/api/resources/documents/client/Client.d.ts +11 -7
- package/dist/api/resources/documents/client/Client.js +25 -22
- package/dist/api/resources/folderEntities/client/Client.d.ts +4 -1
- package/dist/api/resources/folderEntities/client/Client.js +4 -3
- package/dist/api/resources/sandboxes/client/Client.d.ts +7 -4
- package/dist/api/resources/sandboxes/client/Client.js +14 -13
- package/dist/api/resources/testSuiteRuns/client/Client.d.ts +6 -3
- package/dist/api/resources/testSuiteRuns/client/Client.js +13 -10
- package/dist/api/resources/testSuites/client/Client.d.ts +6 -3
- package/dist/api/resources/testSuites/client/Client.js +16 -14
- package/dist/api/resources/workflowDeployments/client/Client.d.ts +7 -4
- package/dist/api/resources/workflowDeployments/client/Client.js +17 -13
- package/dist/api/resources/workflowSandboxes/client/Client.d.ts +4 -1
- package/dist/api/resources/workflowSandboxes/client/Client.js +5 -6
- package/dist/api/types/IterationStateEnum.d.ts +12 -0
- package/dist/api/types/IterationStateEnum.js +10 -0
- package/dist/api/types/MapNodeResultData.d.ts +2 -0
- package/dist/api/types/PromptNodeResultData.d.ts +1 -0
- package/dist/api/types/TestSuiteRunMetricNumberOutput.d.ts +1 -1
- package/dist/api/types/TestSuiteRunMetricStringOutput.d.ts +1 -1
- package/dist/api/types/TestSuiteTestCaseRejectedBulkResult.d.ts +1 -1
- package/dist/api/types/index.d.ts +1 -0
- package/dist/api/types/index.js +1 -0
- package/dist/core/fetcher/Fetcher.d.ts +2 -0
- package/dist/core/fetcher/Fetcher.js +19 -185
- package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
- package/dist/core/fetcher/createRequestUrl.js +13 -0
- package/dist/core/fetcher/getFetchFn.d.ts +4 -0
- package/dist/core/fetcher/getFetchFn.js +55 -0
- package/dist/core/fetcher/getRequestBody.d.ts +7 -0
- package/dist/core/fetcher/getRequestBody.js +23 -0
- package/dist/core/fetcher/getResponseBody.d.ts +1 -0
- package/dist/core/fetcher/getResponseBody.js +48 -0
- package/dist/core/fetcher/makeRequest.d.ts +1 -0
- package/dist/core/fetcher/makeRequest.js +40 -0
- package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/core/fetcher/requestWithRetries.js +32 -0
- package/dist/core/fetcher/signals.d.ts +12 -0
- package/dist/core/fetcher/signals.js +37 -0
- package/dist/core/form-data-utils/FormDataWrapper.d.ts +10 -21
- package/dist/core/form-data-utils/FormDataWrapper.js +82 -49
- package/dist/core/runtime/runtime.d.ts +1 -0
- package/dist/core/runtime/runtime.js +1 -0
- package/dist/core/schemas/Schema.d.ts +7 -4
- package/dist/core/schemas/builders/lazy/lazy.d.ts +2 -2
- package/dist/core/schemas/builders/lazy/lazy.js +8 -19
- package/dist/core/schemas/builders/lazy/lazyObject.js +1 -10
- package/dist/core/schemas/builders/list/list.js +31 -44
- package/dist/core/schemas/builders/object/object.js +90 -111
- package/dist/core/schemas/builders/object/types.d.ts +2 -2
- package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +3 -12
- package/dist/core/schemas/builders/record/record.js +49 -60
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +2 -2
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +18 -21
- package/dist/core/schemas/builders/set/set.js +6 -15
- package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +21 -32
- package/dist/core/schemas/builders/union/union.js +51 -62
- package/dist/core/schemas/utils/maybeSkipValidation.js +3 -12
- package/dist/serialization/types/IterationStateEnum.d.ts +10 -0
- package/dist/serialization/types/IterationStateEnum.js +31 -0
- package/dist/serialization/types/MapNodeResultData.d.ts +2 -0
- package/dist/serialization/types/MapNodeResultData.js +2 -0
- package/dist/serialization/types/MetadataFilterConfigRequest.js +2 -10
- package/dist/serialization/types/MetadataFilterRuleRequest.js +2 -10
- package/dist/serialization/types/PromptNodeResultData.d.ts +1 -0
- package/dist/serialization/types/PromptNodeResultData.js +1 -0
- package/dist/serialization/types/TestSuiteRunMetricNumberOutput.d.ts +1 -1
- package/dist/serialization/types/TestSuiteRunMetricNumberOutput.js +1 -1
- package/dist/serialization/types/TestSuiteRunMetricStringOutput.d.ts +1 -1
- package/dist/serialization/types/TestSuiteRunMetricStringOutput.js +1 -1
- package/dist/serialization/types/TestSuiteTestCaseRejectedBulkResult.d.ts +1 -1
- package/dist/serialization/types/TestSuiteTestCaseRejectedBulkResult.js +1 -1
- package/dist/serialization/types/index.d.ts +1 -0
- package/dist/serialization/types/index.js +1 -0
- package/package.json +6 -1
- package/reference.md +2418 -0
- package/serialization/types/IterationStateEnum.d.ts +10 -0
- package/serialization/types/IterationStateEnum.js +31 -0
- package/serialization/types/MapNodeResultData.d.ts +2 -0
- package/serialization/types/MapNodeResultData.js +2 -0
- package/serialization/types/MetadataFilterConfigRequest.js +2 -10
- package/serialization/types/MetadataFilterRuleRequest.js +2 -10
- package/serialization/types/PromptNodeResultData.d.ts +1 -0
- package/serialization/types/PromptNodeResultData.js +1 -0
- package/serialization/types/TestSuiteRunMetricNumberOutput.d.ts +1 -1
- package/serialization/types/TestSuiteRunMetricNumberOutput.js +1 -1
- package/serialization/types/TestSuiteRunMetricStringOutput.d.ts +1 -1
- package/serialization/types/TestSuiteRunMetricStringOutput.js +1 -1
- package/serialization/types/TestSuiteTestCaseRejectedBulkResult.d.ts +1 -1
- package/serialization/types/TestSuiteTestCaseRejectedBulkResult.js +1 -1
- package/serialization/types/index.d.ts +1 -0
- package/serialization/types/index.js +1 -0
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export declare type MaybePromise<T> = Promise<T> | T;
|
|
2
|
+
declare type FormDataRequest<Body> = {
|
|
3
|
+
body: Body;
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
};
|
|
6
|
+
export interface CrossPlatformFormData {
|
|
5
7
|
setup(): Promise<void>;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
getBody(): Promise<any>;
|
|
10
|
-
/**
|
|
11
|
-
* @returns headers that need to be added to the multipart form data request
|
|
12
|
-
*/
|
|
13
|
-
getHeaders(): Promise<Record<string, string>>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* FormDataWrapper is a utility to make form data
|
|
17
|
-
* requests across both Browser and Node.js runtimes.
|
|
18
|
-
*/
|
|
19
|
-
export declare class FormDataWrapper {
|
|
20
|
-
private fd;
|
|
21
|
-
append(name: string, value: any): Promise<void>;
|
|
22
|
-
getRequest(): FormDataRequestBody;
|
|
8
|
+
append(key: string, value: unknown): void;
|
|
9
|
+
appendFile(key: string, value: unknown, fileName?: string): Promise<void>;
|
|
10
|
+
getRequest(): MaybePromise<FormDataRequest<unknown>>;
|
|
23
11
|
}
|
|
12
|
+
export declare function newFormData(): Promise<CrossPlatformFormData>;
|
|
24
13
|
export {};
|
|
@@ -32,75 +32,108 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.
|
|
36
|
-
const stream_1 = require("stream");
|
|
35
|
+
exports.newFormData = void 0;
|
|
37
36
|
const runtime_1 = require("../runtime");
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
function newFormData() {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
let formdata;
|
|
40
|
+
if (runtime_1.RUNTIME.type === "node" && runtime_1.RUNTIME.parsedVersion != null && runtime_1.RUNTIME.parsedVersion > 18) {
|
|
41
|
+
formdata = new Node19FormData();
|
|
42
|
+
}
|
|
43
|
+
else if (runtime_1.RUNTIME.type === "node") {
|
|
44
|
+
formdata = new Node16FormData();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
formdata = new WebFormData();
|
|
48
|
+
}
|
|
49
|
+
yield formdata.setup();
|
|
50
|
+
return formdata;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
exports.newFormData = newFormData;
|
|
54
|
+
/**
|
|
55
|
+
* Form Data Implementation for Node.js 18+
|
|
56
|
+
*/
|
|
57
|
+
class Node19FormData {
|
|
42
58
|
setup() {
|
|
43
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
|
|
45
|
-
this.encoder = new (yield Promise.resolve().then(() => __importStar(require("form-data-encoder")))).FormDataEncoder(this.fd);
|
|
46
|
-
}
|
|
60
|
+
this.fd = new (yield Promise.resolve().then(() => __importStar(require("formdata-node")))).FormData();
|
|
47
61
|
});
|
|
48
62
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
append(key, value) {
|
|
64
|
+
var _a;
|
|
65
|
+
(_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value);
|
|
66
|
+
}
|
|
67
|
+
appendFile(key, value, fileName) {
|
|
68
|
+
var _a;
|
|
53
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
(_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, new (yield Promise.resolve().then(() => __importStar(require("buffer")))).Blob([value]), fileName);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
getRequest() {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const encoder = new (yield Promise.resolve().then(() => __importStar(require("form-data-encoder")))).FormDataEncoder(this.fd);
|
|
76
|
+
return {
|
|
77
|
+
body: (yield Promise.resolve().then(() => __importStar(require("stream")))).Readable.from(encoder),
|
|
78
|
+
headers: encoder.headers,
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Form Data Implementation for Node.js 16-18
|
|
85
|
+
*/
|
|
86
|
+
class Node16FormData {
|
|
87
|
+
setup() {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
this.fd = new (yield Promise.resolve().then(() => __importStar(require("form-data")))).default();
|
|
63
90
|
});
|
|
64
91
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
92
|
+
append(key, value) {
|
|
93
|
+
var _a;
|
|
94
|
+
(_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value);
|
|
95
|
+
}
|
|
96
|
+
appendFile(key, value, fileName) {
|
|
97
|
+
var _a, _b;
|
|
69
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
if (
|
|
71
|
-
|
|
99
|
+
if (fileName == null) {
|
|
100
|
+
(_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value);
|
|
72
101
|
}
|
|
73
102
|
else {
|
|
74
|
-
|
|
75
|
-
yield this.setup();
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
"Content-Length": this.encoder.length,
|
|
79
|
-
};
|
|
103
|
+
(_b = this.fd) === null || _b === void 0 ? void 0 : _b.append(key, value, { filename: fileName });
|
|
80
104
|
}
|
|
81
105
|
});
|
|
82
106
|
}
|
|
107
|
+
getRequest() {
|
|
108
|
+
return {
|
|
109
|
+
body: this.fd,
|
|
110
|
+
headers: this.fd ? this.fd.getHeaders() : {},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
83
113
|
}
|
|
84
114
|
/**
|
|
85
|
-
*
|
|
86
|
-
* requests across both Browser and Node.js runtimes.
|
|
115
|
+
* Form Data Implementation for Web
|
|
87
116
|
*/
|
|
88
|
-
class
|
|
89
|
-
|
|
117
|
+
class WebFormData {
|
|
118
|
+
setup() {
|
|
90
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
120
|
+
this.fd = new FormData();
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
append(key, value) {
|
|
124
|
+
var _a;
|
|
125
|
+
(_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value);
|
|
126
|
+
}
|
|
127
|
+
appendFile(key, value, fileName) {
|
|
128
|
+
var _a;
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
(_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, new Blob([value]), fileName);
|
|
100
131
|
});
|
|
101
132
|
}
|
|
102
133
|
getRequest() {
|
|
103
|
-
return
|
|
134
|
+
return {
|
|
135
|
+
body: this.fd,
|
|
136
|
+
headers: {},
|
|
137
|
+
};
|
|
104
138
|
}
|
|
105
139
|
}
|
|
106
|
-
exports.FormDataWrapper = FormDataWrapper;
|
package/core/runtime/runtime.js
CHANGED
package/core/schemas/Schema.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { SchemaUtils } from "./builders";
|
|
2
|
-
import { MaybePromise } from "./utils/MaybePromise";
|
|
3
2
|
export declare type Schema<Raw = unknown, Parsed = unknown> = BaseSchema<Raw, Parsed> & SchemaUtils<Raw, Parsed>;
|
|
4
3
|
export declare type inferRaw<S extends Schema> = S extends Schema<infer Raw, any> ? Raw : never;
|
|
5
4
|
export declare type inferParsed<S extends Schema> = S extends Schema<any, infer Parsed> ? Parsed : never;
|
|
6
5
|
export interface BaseSchema<Raw, Parsed> {
|
|
7
|
-
parse: (raw: unknown, opts?: SchemaOptions) =>
|
|
8
|
-
json: (parsed: unknown, opts?: SchemaOptions) =>
|
|
9
|
-
getType: () => SchemaType |
|
|
6
|
+
parse: (raw: unknown, opts?: SchemaOptions) => MaybeValid<Parsed>;
|
|
7
|
+
json: (parsed: unknown, opts?: SchemaOptions) => MaybeValid<Raw>;
|
|
8
|
+
getType: () => SchemaType | SchemaType;
|
|
10
9
|
}
|
|
11
10
|
export declare const SchemaType: {
|
|
12
11
|
readonly DATE: "date";
|
|
@@ -78,4 +77,8 @@ export interface SchemaOptions {
|
|
|
78
77
|
* helpful for zurg's internal debug logging.
|
|
79
78
|
*/
|
|
80
79
|
breadcrumbsPrefix?: string[];
|
|
80
|
+
/**
|
|
81
|
+
* whether to send 'null' for optional properties explicitly set to 'undefined'.
|
|
82
|
+
*/
|
|
83
|
+
omitUndefined?: boolean;
|
|
81
84
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseSchema, Schema } from "../../Schema";
|
|
2
|
-
export declare type SchemaGetter<SchemaType extends Schema<any, any>> = () => SchemaType
|
|
2
|
+
export declare type SchemaGetter<SchemaType extends Schema<any, any>> = () => SchemaType;
|
|
3
3
|
export declare function lazy<Raw, Parsed>(getter: SchemaGetter<Schema<Raw, Parsed>>): Schema<Raw, Parsed>;
|
|
4
4
|
export declare function constructLazyBaseSchema<Raw, Parsed>(getter: SchemaGetter<Schema<Raw, Parsed>>): BaseSchema<Raw, Parsed>;
|
|
5
|
-
export declare function getMemoizedSchema<SchemaType extends Schema<any, any>>(getter: SchemaGetter<SchemaType>):
|
|
5
|
+
export declare function getMemoizedSchema<SchemaType extends Schema<any, any>>(getter: SchemaGetter<SchemaType>): SchemaType;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getMemoizedSchema = exports.constructLazyBaseSchema = exports.lazy = void 0;
|
|
13
4
|
const schema_utils_1 = require("../schema-utils");
|
|
@@ -18,19 +9,17 @@ function lazy(getter) {
|
|
|
18
9
|
exports.lazy = lazy;
|
|
19
10
|
function constructLazyBaseSchema(getter) {
|
|
20
11
|
return {
|
|
21
|
-
parse: (raw, opts) =>
|
|
22
|
-
json: (parsed, opts) =>
|
|
23
|
-
getType: () =>
|
|
12
|
+
parse: (raw, opts) => getMemoizedSchema(getter).parse(raw, opts),
|
|
13
|
+
json: (parsed, opts) => getMemoizedSchema(getter).json(parsed, opts),
|
|
14
|
+
getType: () => getMemoizedSchema(getter).getType(),
|
|
24
15
|
};
|
|
25
16
|
}
|
|
26
17
|
exports.constructLazyBaseSchema = constructLazyBaseSchema;
|
|
27
18
|
function getMemoizedSchema(getter) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return castedGetter.__zurg_memoized;
|
|
34
|
-
});
|
|
19
|
+
const castedGetter = getter;
|
|
20
|
+
if (castedGetter.__zurg_memoized == null) {
|
|
21
|
+
castedGetter.__zurg_memoized = getter();
|
|
22
|
+
}
|
|
23
|
+
return castedGetter.__zurg_memoized;
|
|
35
24
|
}
|
|
36
25
|
exports.getMemoizedSchema = getMemoizedSchema;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.lazyObject = void 0;
|
|
13
4
|
const object_1 = require("../object");
|
|
@@ -15,7 +6,7 @@ const object_like_1 = require("../object-like");
|
|
|
15
6
|
const schema_utils_1 = require("../schema-utils");
|
|
16
7
|
const lazy_1 = require("./lazy");
|
|
17
8
|
function lazyObject(getter) {
|
|
18
|
-
const baseSchema = Object.assign(Object.assign({}, (0, lazy_1.constructLazyBaseSchema)(getter)), { _getRawProperties: () =>
|
|
9
|
+
const baseSchema = Object.assign(Object.assign({}, (0, lazy_1.constructLazyBaseSchema)(getter)), { _getRawProperties: () => (0, lazy_1.getMemoizedSchema)(getter)._getRawProperties(), _getParsedProperties: () => (0, lazy_1.getMemoizedSchema)(getter)._getParsedProperties() });
|
|
19
10
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), (0, object_1.getObjectUtils)(baseSchema));
|
|
20
11
|
}
|
|
21
12
|
exports.lazyObject = lazyObject;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.list = void 0;
|
|
13
4
|
const Schema_1 = require("../../Schema");
|
|
@@ -16,11 +7,9 @@ const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
|
|
|
16
7
|
const schema_utils_1 = require("../schema-utils");
|
|
17
8
|
function list(schema) {
|
|
18
9
|
const baseSchema = {
|
|
19
|
-
parse: (raw, opts) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return schema.parse(item, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `[${index}]`] }));
|
|
23
|
-
});
|
|
10
|
+
parse: (raw, opts) => validateAndTransformArray(raw, (item, index) => {
|
|
11
|
+
var _a;
|
|
12
|
+
return schema.parse(item, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `[${index}]`] }));
|
|
24
13
|
}),
|
|
25
14
|
json: (parsed, opts) => validateAndTransformArray(parsed, (item, index) => {
|
|
26
15
|
var _a;
|
|
@@ -32,37 +21,35 @@ function list(schema) {
|
|
|
32
21
|
}
|
|
33
22
|
exports.list = list;
|
|
34
23
|
function validateAndTransformArray(value, transformItem) {
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
if (!Array.isArray(value)) {
|
|
25
|
+
return {
|
|
26
|
+
ok: false,
|
|
27
|
+
errors: [
|
|
28
|
+
{
|
|
29
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "list"),
|
|
30
|
+
path: [],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const maybeValidItems = value.map((item, index) => transformItem(item, index));
|
|
36
|
+
return maybeValidItems.reduce((acc, item) => {
|
|
37
|
+
if (acc.ok && item.ok) {
|
|
37
38
|
return {
|
|
38
|
-
ok:
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "list"),
|
|
42
|
-
path: [],
|
|
43
|
-
},
|
|
44
|
-
],
|
|
39
|
+
ok: true,
|
|
40
|
+
value: [...acc.value, item.value],
|
|
45
41
|
};
|
|
46
42
|
}
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (!item.ok) {
|
|
60
|
-
errors.push(...item.errors);
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
ok: false,
|
|
64
|
-
errors,
|
|
65
|
-
};
|
|
66
|
-
}, { ok: true, value: [] });
|
|
67
|
-
});
|
|
43
|
+
const errors = [];
|
|
44
|
+
if (!acc.ok) {
|
|
45
|
+
errors.push(...acc.errors);
|
|
46
|
+
}
|
|
47
|
+
if (!item.ok) {
|
|
48
|
+
errors.push(...item.errors);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
ok: false,
|
|
52
|
+
errors,
|
|
53
|
+
};
|
|
54
|
+
}, { ok: true, value: [] });
|
|
68
55
|
}
|