@getzep/zep-cloud 1.0.4 → 1.0.6
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/api/index.d.ts +1 -1
- package/api/index.js +1 -1
- package/api/resources/document/client/Client.js +13 -13
- package/api/resources/index.d.ts +1 -2
- package/api/resources/index.js +2 -3
- package/api/resources/memory/client/Client.d.ts +18 -0
- package/api/resources/memory/client/Client.js +104 -17
- package/api/resources/memory/client/requests/ExtractDataRequest.d.ts +23 -0
- package/api/resources/memory/client/requests/ExtractDataRequest.js +5 -0
- package/api/resources/memory/client/requests/MemoryGetRequest.d.ts +1 -1
- package/api/resources/memory/client/requests/index.d.ts +1 -0
- package/api/resources/memory/index.d.ts +0 -1
- package/api/resources/memory/index.js +0 -1
- package/api/resources/user/client/Client.js +6 -6
- package/api/types/Fact.d.ts +8 -0
- package/api/types/Fact.js +5 -0
- package/api/{resources/memory/types/MemoryGetRequestMemoryType.d.ts → types/MemoryType.d.ts} +2 -2
- package/api/{resources/memory/types/MemoryGetRequestMemoryType.js → types/MemoryType.js} +2 -2
- package/api/types/SearchScope.d.ts +2 -1
- package/api/types/SearchScope.js +1 -0
- package/api/types/Session.d.ts +1 -0
- package/api/types/SessionSearchResult.d.ts +1 -0
- package/api/types/index.d.ts +2 -0
- package/api/types/index.js +2 -0
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/resources/document/client/Client.js +13 -13
- package/dist/api/resources/index.d.ts +1 -2
- package/dist/api/resources/index.js +2 -3
- package/dist/api/resources/memory/client/Client.d.ts +18 -0
- package/dist/api/resources/memory/client/Client.js +104 -17
- package/dist/api/resources/memory/client/requests/ExtractDataRequest.d.ts +23 -0
- package/dist/api/resources/memory/client/requests/ExtractDataRequest.js +5 -0
- package/dist/api/resources/memory/client/requests/MemoryGetRequest.d.ts +1 -1
- package/dist/api/resources/memory/client/requests/index.d.ts +1 -0
- package/dist/api/resources/memory/index.d.ts +0 -1
- package/dist/api/resources/memory/index.js +0 -1
- package/dist/api/resources/user/client/Client.js +6 -6
- package/dist/api/types/Fact.d.ts +8 -0
- package/dist/api/types/Fact.js +5 -0
- package/dist/api/{resources/memory/types/MemoryGetRequestMemoryType.d.ts → types/MemoryType.d.ts} +2 -2
- package/dist/api/{resources/memory/types/MemoryGetRequestMemoryType.js → types/MemoryType.js} +2 -2
- package/dist/api/types/SearchScope.d.ts +2 -1
- package/dist/api/types/SearchScope.js +1 -0
- package/dist/api/types/Session.d.ts +1 -0
- package/dist/api/types/SessionSearchResult.d.ts +1 -0
- package/dist/api/types/index.d.ts +2 -0
- package/dist/api/types/index.js +2 -0
- package/dist/extractor/base.d.ts +22 -0
- package/dist/extractor/base.js +20 -0
- package/dist/extractor/date.d.ts +24 -0
- package/dist/extractor/date.js +29 -0
- package/dist/extractor/index.d.ts +281 -0
- package/dist/extractor/index.js +31 -0
- package/dist/extractor/number.d.ts +27 -0
- package/dist/extractor/number.js +37 -0
- package/dist/extractor/regex.d.ts +30 -0
- package/dist/extractor/regex.js +29 -0
- package/dist/extractor/text.d.ts +29 -0
- package/dist/extractor/text.js +43 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/langchain/message_history.d.ts +2 -2
- package/dist/serialization/index.d.ts +1 -1
- package/dist/serialization/index.js +1 -1
- package/dist/serialization/resources/index.d.ts +1 -2
- package/dist/serialization/resources/index.js +2 -3
- package/dist/serialization/resources/memory/client/extractData.d.ts +9 -0
- package/{serialization/resources/memory/types/MemoryGetRequestMemoryType.js → dist/serialization/resources/memory/client/extractData.js} +2 -2
- package/dist/serialization/resources/memory/client/index.d.ts +1 -0
- package/dist/serialization/resources/memory/client/index.js +2 -1
- package/dist/serialization/resources/memory/client/requests/ExtractDataRequest.d.ts +15 -0
- package/dist/serialization/resources/memory/client/requests/ExtractDataRequest.js +36 -0
- package/dist/serialization/resources/memory/client/requests/index.d.ts +1 -0
- package/dist/serialization/resources/memory/client/requests/index.js +3 -1
- package/dist/serialization/resources/memory/index.d.ts +0 -1
- package/dist/serialization/resources/memory/index.js +0 -1
- package/dist/serialization/types/Fact.d.ts +14 -0
- package/dist/serialization/types/Fact.js +35 -0
- package/dist/serialization/types/MemoryType.d.ts +10 -0
- package/dist/serialization/types/MemoryType.js +31 -0
- package/dist/serialization/types/SearchScope.d.ts +1 -1
- package/dist/serialization/types/SearchScope.js +1 -1
- package/dist/serialization/types/Session.d.ts +1 -0
- package/dist/serialization/types/Session.js +1 -0
- package/dist/serialization/types/SessionSearchResult.d.ts +2 -0
- package/dist/serialization/types/SessionSearchResult.js +2 -0
- package/dist/serialization/types/index.d.ts +2 -0
- package/dist/serialization/types/index.js +2 -0
- package/dist/wrapper/index.d.ts +2 -0
- package/dist/wrapper/index.js +4 -0
- package/dist/wrapper/memory.d.ts +35 -0
- package/dist/wrapper/memory.js +59 -0
- package/examples/memory/memory_example.ts +27 -8
- package/examples/memory/structured_data_extraction_example.ts +34 -0
- package/extractor/base.d.ts +22 -0
- package/extractor/base.js +20 -0
- package/extractor/date.d.ts +24 -0
- package/extractor/date.js +29 -0
- package/extractor/index.d.ts +281 -0
- package/extractor/index.js +31 -0
- package/extractor/number.d.ts +27 -0
- package/extractor/number.js +37 -0
- package/extractor/regex.d.ts +30 -0
- package/extractor/regex.js +29 -0
- package/extractor/text.d.ts +29 -0
- package/extractor/text.js +43 -0
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/langchain/message_history.d.ts +2 -2
- package/package.json +11 -5
- package/serialization/index.d.ts +1 -1
- package/serialization/index.js +1 -1
- package/serialization/resources/index.d.ts +1 -2
- package/serialization/resources/index.js +2 -3
- package/serialization/resources/memory/client/extractData.d.ts +9 -0
- package/{dist/serialization/resources/memory/types/MemoryGetRequestMemoryType.js → serialization/resources/memory/client/extractData.js} +2 -2
- package/serialization/resources/memory/client/index.d.ts +1 -0
- package/serialization/resources/memory/client/index.js +2 -1
- package/serialization/resources/memory/client/requests/ExtractDataRequest.d.ts +15 -0
- package/serialization/resources/memory/client/requests/ExtractDataRequest.js +36 -0
- package/serialization/resources/memory/client/requests/index.d.ts +1 -0
- package/serialization/resources/memory/client/requests/index.js +3 -1
- package/serialization/resources/memory/index.d.ts +0 -1
- package/serialization/resources/memory/index.js +0 -1
- package/serialization/types/Fact.d.ts +14 -0
- package/serialization/types/Fact.js +35 -0
- package/serialization/types/MemoryType.d.ts +10 -0
- package/serialization/types/MemoryType.js +31 -0
- package/serialization/types/SearchScope.d.ts +1 -1
- package/serialization/types/SearchScope.js +1 -1
- package/serialization/types/Session.d.ts +1 -0
- package/serialization/types/Session.js +1 -0
- package/serialization/types/SessionSearchResult.d.ts +2 -0
- package/serialization/types/SessionSearchResult.js +2 -0
- package/serialization/types/index.d.ts +2 -0
- package/serialization/types/index.js +2 -0
- package/wrapper/index.d.ts +2 -0
- package/wrapper/index.js +4 -0
- package/wrapper/memory.d.ts +35 -0
- package/wrapper/memory.js +59 -0
- package/api/resources/memory/types/index.d.ts +0 -1
- package/api/resources/memory/types/index.js +0 -17
- package/dist/api/resources/memory/types/index.d.ts +0 -1
- package/dist/api/resources/memory/types/index.js +0 -17
- package/dist/serialization/resources/memory/types/MemoryGetRequestMemoryType.d.ts +0 -10
- package/dist/serialization/resources/memory/types/index.d.ts +0 -1
- package/dist/serialization/resources/memory/types/index.js +0 -17
- package/serialization/resources/memory/types/MemoryGetRequestMemoryType.d.ts +0 -10
- package/serialization/resources/memory/types/index.d.ts +0 -1
- package/serialization/resources/memory/types/index.js +0 -17
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Memory = void 0;
|
|
13
|
+
const Client_1 = require("../api/resources/memory/client/Client");
|
|
14
|
+
const extractor_1 = require("../extractor");
|
|
15
|
+
class Memory extends Client_1.Memory {
|
|
16
|
+
/**
|
|
17
|
+
* Extracts data based on a given schema and session details, transforms it according to the defined Zod schemas, and returns the transformed results.
|
|
18
|
+
*
|
|
19
|
+
* This method parses the provided schema against defined Zod validation rules, sends a request to extract data, and then transforms
|
|
20
|
+
* the extracted data according to the schema's specified ZepDataType.
|
|
21
|
+
*
|
|
22
|
+
* @template T - A record type where each key corresponds to a field name and its value is an object specifying `zep_type` and `description`.
|
|
23
|
+
* @param {string} sessionId - The session identifier for which data needs to be extracted.
|
|
24
|
+
* @param {T} schema - An object mapping each field to its corresponding ZepDataType and description. Each field should use one of the predefined methods from `zepFields` to ensure it conforms to the expected data type and structure.
|
|
25
|
+
* @param {Omit<ExtractDataRequest, "modelSchema">} params - Additional parameters for the extraction request excluding the model schema.
|
|
26
|
+
* @param {BaseMemory.RequestOptions} [requestOptions] - Optional additional request options.
|
|
27
|
+
* @returns {Promise<Record<string, any>>} A promise that resolves to an object where each key corresponds to the original schema's keys and their parsed values from the extraction.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const result = await client.memory.extract(
|
|
31
|
+
* session_id,
|
|
32
|
+
* {
|
|
33
|
+
* shoeSize: zepFields.number("The Customer's shoe size"),
|
|
34
|
+
* budget: zepFields.number("The Customer's budget for shoe purchase"),
|
|
35
|
+
* favoriteBrand: zepFields.text("The Customer's favorite shoe brand. Just one brand, please!"),
|
|
36
|
+
* conversationDate: zepFields.date("The date of the conversation. Use current date if not present"),
|
|
37
|
+
* conversationDateTime: zepFields.dateTime("The date time of the conversation."),
|
|
38
|
+
* formattedPrice: zepFields.regex("The formatted price of the shoe", /\$\d+\.\d{2}/),
|
|
39
|
+
* },
|
|
40
|
+
* { lastN: 20, validate: false, currentDateTime: new Date().toISOString() }
|
|
41
|
+
* );
|
|
42
|
+
*/
|
|
43
|
+
extract(sessionId, schema, params, requestOptions) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const validatedData = extractor_1.DataExtractorFields.parse(schema);
|
|
46
|
+
const result = yield this.extractData(sessionId, Object.assign(Object.assign({}, params), { modelSchema: JSON.stringify({ properties: validatedData }) }), requestOptions);
|
|
47
|
+
const transformedResult = {};
|
|
48
|
+
for (const key in schema) {
|
|
49
|
+
const schemaItem = extractor_1.schemas[schema[key].zep_type];
|
|
50
|
+
if (!schemaItem) {
|
|
51
|
+
throw new Error(`Unsupported zep_type: ${schema[key].zep_type}`);
|
|
52
|
+
}
|
|
53
|
+
transformedResult[key] = schemaItem.parse(Object.assign(Object.assign({}, schema[key]), { value: result[key] })).value;
|
|
54
|
+
}
|
|
55
|
+
return transformedResult;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.Memory = Memory;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from "uuid";
|
|
2
2
|
import { CreateUserRequest, Message, NotFoundError } from "../../src/api";
|
|
3
|
-
import { ZepClient } from "../../src";
|
|
3
|
+
import { ZepClient, zepFields } from "../../src";
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
import { history } from "./chat_shoe_store_history";
|
|
@@ -171,8 +171,9 @@ async function main() {
|
|
|
171
171
|
const searchText = "Name some books that are about dystopian futures.";
|
|
172
172
|
console.debug("Searching memory...", searchText);
|
|
173
173
|
|
|
174
|
-
const searchResults = await client.memory.
|
|
175
|
-
|
|
174
|
+
const { results: searchResults } = await client.memory.searchSessions({
|
|
175
|
+
sessionIds: [sessionID],
|
|
176
|
+
recordFilter: {
|
|
176
177
|
where: {
|
|
177
178
|
and: [
|
|
178
179
|
{
|
|
@@ -188,7 +189,7 @@ async function main() {
|
|
|
188
189
|
searchScope: "messages",
|
|
189
190
|
});
|
|
190
191
|
|
|
191
|
-
searchResults
|
|
192
|
+
searchResults?.forEach((searchResult) => {
|
|
192
193
|
console.debug("Search Result: ", JSON.stringify(searchResult.message));
|
|
193
194
|
console.debug("Search Result Score: ", JSON.stringify(searchResult.score));
|
|
194
195
|
});
|
|
@@ -205,7 +206,8 @@ async function main() {
|
|
|
205
206
|
const searchText = "Name some books that are about dystopian futures.";
|
|
206
207
|
console.debug("Searching memory with MMR...", searchText);
|
|
207
208
|
|
|
208
|
-
const searchResults = await client.memory.
|
|
209
|
+
const { results: searchResults } = await client.memory.searchSessions({
|
|
210
|
+
sessionIds: [sessionID],
|
|
209
211
|
text: searchText,
|
|
210
212
|
searchType: "mmr",
|
|
211
213
|
mmrLambda: 0.6,
|
|
@@ -213,7 +215,7 @@ async function main() {
|
|
|
213
215
|
searchScope: "messages",
|
|
214
216
|
});
|
|
215
217
|
|
|
216
|
-
searchResults
|
|
218
|
+
searchResults?.forEach((searchResult) => {
|
|
217
219
|
console.debug("Search Result: ", JSON.stringify(searchResult.message));
|
|
218
220
|
console.debug("Search Result Score: ", JSON.stringify(searchResult.score));
|
|
219
221
|
});
|
|
@@ -230,7 +232,8 @@ async function main() {
|
|
|
230
232
|
const searchText = "Name some books that are about dystopian futures.";
|
|
231
233
|
console.debug("Searching summaries with MMR...", searchText);
|
|
232
234
|
|
|
233
|
-
const searchResults = await client.memory.
|
|
235
|
+
const { results: searchResults } = await client.memory.searchSessions({
|
|
236
|
+
sessionIds: [sessionID],
|
|
234
237
|
text: searchText,
|
|
235
238
|
searchScope: "summary",
|
|
236
239
|
searchType: "mmr",
|
|
@@ -238,7 +241,7 @@ async function main() {
|
|
|
238
241
|
limit: 3,
|
|
239
242
|
});
|
|
240
243
|
|
|
241
|
-
searchResults
|
|
244
|
+
searchResults?.forEach((searchResult) => {
|
|
242
245
|
console.debug("Search Result: ", JSON.stringify(searchResult.summary));
|
|
243
246
|
console.debug("Search Result Score: ", JSON.stringify(searchResult.score));
|
|
244
247
|
});
|
|
@@ -250,6 +253,22 @@ async function main() {
|
|
|
250
253
|
}
|
|
251
254
|
}
|
|
252
255
|
|
|
256
|
+
try {
|
|
257
|
+
const result = await client.memory.extract(
|
|
258
|
+
sessionID,
|
|
259
|
+
{
|
|
260
|
+
shoeSize: zepFields.number("The Customer's shoe size"),
|
|
261
|
+
budget: zepFields.number("The Customer's budget for shoe purchase"),
|
|
262
|
+
favoriteBrand: zepFields.text("The Customer's favorite shoe brand. Just one brand, please!"),
|
|
263
|
+
formattedPrice: zepFields.regex("The formatted price of the shoe", /\$\d+\.\d{2}/),
|
|
264
|
+
},
|
|
265
|
+
{ lastN: 20, validate: false, currentDateTime: new Date().toISOString() }
|
|
266
|
+
);
|
|
267
|
+
console.log("Data Extraction Result", result);
|
|
268
|
+
} catch (error) {
|
|
269
|
+
console.debug("Got error:", error);
|
|
270
|
+
}
|
|
271
|
+
|
|
253
272
|
// End session - this will trigger summarization and other background tasks on the completed session
|
|
254
273
|
try {
|
|
255
274
|
await client.memory.endSession(sessionID);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ZepClient, zepFields } from "../../src";
|
|
2
|
+
import { type ExtractedData } from "../../src/extractor";
|
|
3
|
+
|
|
4
|
+
async function main() {
|
|
5
|
+
const projectApiKey = process.env.ZEP_API_KEY;
|
|
6
|
+
const sessionId = process.env.ZEP_SESSION_ID;
|
|
7
|
+
if (!sessionId) {
|
|
8
|
+
console.error("Please provide a session ID using the ZEP_SESSION_ID environment variable");
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const client = new ZepClient({
|
|
13
|
+
apiKey: projectApiKey,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const customerSchema = {
|
|
17
|
+
shoeSize: zepFields.number("The Customer's shoe size"),
|
|
18
|
+
budget: zepFields.number("The Customer's budget for shoe purchase"),
|
|
19
|
+
favoriteBrand: zepFields.text("The Customer's favorite shoe brand. Just one brand, please!"),
|
|
20
|
+
formattedPrice: zepFields.regex("The formatted price of the shoe", /\$\d+\.\d{2}/),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type Customer = ExtractedData<typeof customerSchema>;
|
|
24
|
+
|
|
25
|
+
const result: Customer = await client.memory.extract(sessionId, customerSchema, {
|
|
26
|
+
lastN: 20,
|
|
27
|
+
validate: false,
|
|
28
|
+
currentDateTime: new Date().toISOString(),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
console.log("Data Extraction Result", result);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
main();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare enum ZepDataType {
|
|
3
|
+
ZepText = "ZepText",
|
|
4
|
+
ZepZipCode = "ZepZipCode",
|
|
5
|
+
ZepDate = "ZepDate",
|
|
6
|
+
ZepDateTime = "ZepDateTime",
|
|
7
|
+
ZepEmail = "ZepEmail",
|
|
8
|
+
ZepPhoneNumber = "ZepPhoneNumber",
|
|
9
|
+
ZepFloat = "ZepFloat",
|
|
10
|
+
ZepNumber = "ZepNumber",
|
|
11
|
+
ZepRegex = "ZepRegex"
|
|
12
|
+
}
|
|
13
|
+
export declare const BaseSchema: z.ZodObject<{
|
|
14
|
+
zep_type: z.ZodNativeEnum<typeof ZepDataType>;
|
|
15
|
+
description: z.ZodString;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
description: string;
|
|
18
|
+
zep_type: ZepDataType;
|
|
19
|
+
}, {
|
|
20
|
+
description: string;
|
|
21
|
+
zep_type: ZepDataType;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseSchema = exports.ZepDataType = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
var ZepDataType;
|
|
6
|
+
(function (ZepDataType) {
|
|
7
|
+
ZepDataType["ZepText"] = "ZepText";
|
|
8
|
+
ZepDataType["ZepZipCode"] = "ZepZipCode";
|
|
9
|
+
ZepDataType["ZepDate"] = "ZepDate";
|
|
10
|
+
ZepDataType["ZepDateTime"] = "ZepDateTime";
|
|
11
|
+
ZepDataType["ZepEmail"] = "ZepEmail";
|
|
12
|
+
ZepDataType["ZepPhoneNumber"] = "ZepPhoneNumber";
|
|
13
|
+
ZepDataType["ZepFloat"] = "ZepFloat";
|
|
14
|
+
ZepDataType["ZepNumber"] = "ZepNumber";
|
|
15
|
+
ZepDataType["ZepRegex"] = "ZepRegex";
|
|
16
|
+
})(ZepDataType = exports.ZepDataType || (exports.ZepDataType = {}));
|
|
17
|
+
exports.BaseSchema = zod_1.z.object({
|
|
18
|
+
zep_type: zod_1.z.nativeEnum(ZepDataType),
|
|
19
|
+
description: zod_1.z.string(),
|
|
20
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ZepDataType } from "./base";
|
|
3
|
+
import { HasOptionalValue } from "./index";
|
|
4
|
+
export declare const ZepDateSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
5
|
+
zep_type: z.ZodNativeEnum<typeof ZepDataType>;
|
|
6
|
+
description: z.ZodString;
|
|
7
|
+
}, {
|
|
8
|
+
zep_type: z.ZodUnion<[z.ZodLiteral<ZepDataType.ZepDate>, z.ZodLiteral<ZepDataType.ZepDateTime>]>;
|
|
9
|
+
value: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodDate]>, Date, string | Date>>;
|
|
10
|
+
}>, "strip", z.ZodTypeAny, {
|
|
11
|
+
description: string;
|
|
12
|
+
zep_type: ZepDataType.ZepDate | ZepDataType.ZepDateTime;
|
|
13
|
+
value?: Date | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
description: string;
|
|
16
|
+
zep_type: ZepDataType.ZepDate | ZepDataType.ZepDateTime;
|
|
17
|
+
value?: string | Date | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export interface ZepDateField extends HasOptionalValue<Date> {
|
|
20
|
+
zep_type: ZepDataType.ZepDate | ZepDataType.ZepDateTime;
|
|
21
|
+
description: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const zepDateField: (description: string) => ZepDateField;
|
|
24
|
+
export declare const zepDateTimeField: (description: string) => ZepDateField;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zepDateTimeField = exports.zepDateField = exports.ZepDateSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
const stringToDateTransformer = zod_1.z.union([zod_1.z.string(), zod_1.z.date()]).transform((value, ctx) => {
|
|
7
|
+
if (typeof value === "string") {
|
|
8
|
+
return new Date(value);
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
});
|
|
12
|
+
exports.ZepDateSchema = base_1.BaseSchema.extend({
|
|
13
|
+
zep_type: zod_1.z.union([zod_1.z.literal(base_1.ZepDataType.ZepDate), zod_1.z.literal(base_1.ZepDataType.ZepDateTime)]),
|
|
14
|
+
value: stringToDateTransformer.optional(),
|
|
15
|
+
});
|
|
16
|
+
const zepDateField = (description) => {
|
|
17
|
+
return exports.ZepDateSchema.parse({
|
|
18
|
+
zep_type: base_1.ZepDataType.ZepDate,
|
|
19
|
+
description,
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
exports.zepDateField = zepDateField;
|
|
23
|
+
const zepDateTimeField = (description) => {
|
|
24
|
+
return exports.ZepDateSchema.parse({
|
|
25
|
+
zep_type: base_1.ZepDataType.ZepDateTime,
|
|
26
|
+
description,
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
exports.zepDateTimeField = zepDateTimeField;
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ZepDateField } from "./date";
|
|
3
|
+
import { ZepNumberField } from "./number";
|
|
4
|
+
import { ZepTextField } from "./text";
|
|
5
|
+
import { ZepRegexField } from "./regex";
|
|
6
|
+
export declare const DataExtractorFields: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
|
|
7
|
+
zep_type: z.ZodNativeEnum<typeof import("./base").ZepDataType>;
|
|
8
|
+
description: z.ZodString;
|
|
9
|
+
}, {
|
|
10
|
+
zep_type: z.ZodUnion<[z.ZodLiteral<import("./base").ZepDataType.ZepNumber>, z.ZodLiteral<import("./base").ZepDataType.ZepFloat>]>;
|
|
11
|
+
value: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
12
|
+
default: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
13
|
+
}>, "strip", z.ZodTypeAny, {
|
|
14
|
+
description: string;
|
|
15
|
+
zep_type: import("./base").ZepDataType.ZepFloat | import("./base").ZepDataType.ZepNumber;
|
|
16
|
+
value?: number | undefined;
|
|
17
|
+
default?: number | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
description: string;
|
|
20
|
+
zep_type: import("./base").ZepDataType.ZepFloat | import("./base").ZepDataType.ZepNumber;
|
|
21
|
+
value?: string | number | undefined;
|
|
22
|
+
default?: string | number | undefined;
|
|
23
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
24
|
+
zep_type: z.ZodNativeEnum<typeof import("./base").ZepDataType>;
|
|
25
|
+
description: z.ZodString;
|
|
26
|
+
}, {
|
|
27
|
+
zep_type: z.ZodUnion<[z.ZodLiteral<import("./base").ZepDataType.ZepText>, z.ZodLiteral<import("./base").ZepDataType.ZepZipCode>, z.ZodLiteral<import("./base").ZepDataType.ZepEmail>, z.ZodLiteral<import("./base").ZepDataType.ZepPhoneNumber>]>;
|
|
28
|
+
value: z.ZodOptional<z.ZodString>;
|
|
29
|
+
default: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}>, "strip", z.ZodTypeAny, {
|
|
31
|
+
description: string;
|
|
32
|
+
zep_type: import("./base").ZepDataType.ZepText | import("./base").ZepDataType.ZepZipCode | import("./base").ZepDataType.ZepEmail | import("./base").ZepDataType.ZepPhoneNumber;
|
|
33
|
+
value?: string | undefined;
|
|
34
|
+
default?: string | undefined;
|
|
35
|
+
}, {
|
|
36
|
+
description: string;
|
|
37
|
+
zep_type: import("./base").ZepDataType.ZepText | import("./base").ZepDataType.ZepZipCode | import("./base").ZepDataType.ZepEmail | import("./base").ZepDataType.ZepPhoneNumber;
|
|
38
|
+
value?: string | undefined;
|
|
39
|
+
default?: string | undefined;
|
|
40
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
41
|
+
zep_type: z.ZodNativeEnum<typeof import("./base").ZepDataType>;
|
|
42
|
+
description: z.ZodString;
|
|
43
|
+
}, {
|
|
44
|
+
zep_type: z.ZodUnion<[z.ZodLiteral<import("./base").ZepDataType.ZepDate>, z.ZodLiteral<import("./base").ZepDataType.ZepDateTime>]>;
|
|
45
|
+
value: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodDate]>, Date, string | Date>>;
|
|
46
|
+
}>, "strip", z.ZodTypeAny, {
|
|
47
|
+
description: string;
|
|
48
|
+
zep_type: import("./base").ZepDataType.ZepDate | import("./base").ZepDataType.ZepDateTime;
|
|
49
|
+
value?: Date | undefined;
|
|
50
|
+
}, {
|
|
51
|
+
description: string;
|
|
52
|
+
zep_type: import("./base").ZepDataType.ZepDate | import("./base").ZepDataType.ZepDateTime;
|
|
53
|
+
value?: string | Date | undefined;
|
|
54
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
55
|
+
zep_type: z.ZodNativeEnum<typeof import("./base").ZepDataType>;
|
|
56
|
+
description: z.ZodString;
|
|
57
|
+
}, {
|
|
58
|
+
zep_type: z.ZodLiteral<import("./base").ZepDataType.ZepRegex>;
|
|
59
|
+
value: z.ZodOptional<z.ZodString>;
|
|
60
|
+
pattern: z.ZodEffects<z.ZodString, string, string>;
|
|
61
|
+
default: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}>, "strip", z.ZodTypeAny, {
|
|
63
|
+
description: string;
|
|
64
|
+
zep_type: import("./base").ZepDataType.ZepRegex;
|
|
65
|
+
pattern: string;
|
|
66
|
+
value?: string | undefined;
|
|
67
|
+
default?: string | undefined;
|
|
68
|
+
}, {
|
|
69
|
+
description: string;
|
|
70
|
+
zep_type: import("./base").ZepDataType.ZepRegex;
|
|
71
|
+
pattern: string;
|
|
72
|
+
value?: string | undefined;
|
|
73
|
+
default?: string | undefined;
|
|
74
|
+
}>]>>;
|
|
75
|
+
export declare type SupportedZepField = ZepNumberField | ZepDateField | ZepRegexField | ZepTextField;
|
|
76
|
+
export interface HasOptionalValue<V = any> {
|
|
77
|
+
value?: V;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Extracts the data types from the fields defined in the schema T. Each field in T
|
|
81
|
+
* is expected to conform to the HasOptionalValue interface, which optionally includes
|
|
82
|
+
* a 'value' of type V. This type definition maps each field in T to its corresponding
|
|
83
|
+
* 'value' type, but since 'value' is optional, the resulting type for each field also
|
|
84
|
+
* includes 'undefined'.
|
|
85
|
+
*
|
|
86
|
+
* @template T - The schema object from which to extract data types. Each property of T
|
|
87
|
+
* should implement the HasOptionalValue interface.
|
|
88
|
+
*
|
|
89
|
+
* @returns An object type with the same keys as T, but where the type of each key is
|
|
90
|
+
* either the type of 'value' in the corresponding field of T or 'undefined'
|
|
91
|
+
* if 'value' is optional.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```
|
|
95
|
+
* interface PersonSchema {
|
|
96
|
+
* name: HasOptionalValue<string>; // ZepTextField
|
|
97
|
+
* age: HasOptionalValue<number>; // ZepNumberField
|
|
98
|
+
* }
|
|
99
|
+
*
|
|
100
|
+
* type PersonData = ExtractedData<PersonSchema>;
|
|
101
|
+
* // PersonData would be equivalent to:
|
|
102
|
+
* // { name: string | undefined; age: number | undefined; }
|
|
103
|
+
* ```
|
|
104
|
+
* This example demonstrates how `ExtractedData` would transform a hypothetical `PersonSchema`
|
|
105
|
+
* into `PersonData`, clarifying how the types are derived and what to expect in the output.
|
|
106
|
+
*/
|
|
107
|
+
export declare type ExtractedData<T> = {
|
|
108
|
+
[P in keyof T]: T[P] extends HasOptionalValue<infer V> ? V | undefined : never;
|
|
109
|
+
};
|
|
110
|
+
export declare const schemas: {
|
|
111
|
+
ZepNumber: z.ZodObject<z.objectUtil.extendShape<{
|
|
112
|
+
zep_type: z.ZodNativeEnum<typeof import("./base").ZepDataType>;
|
|
113
|
+
description: z.ZodString;
|
|
114
|
+
}, {
|
|
115
|
+
zep_type: z.ZodUnion<[z.ZodLiteral<import("./base").ZepDataType.ZepNumber>, z.ZodLiteral<import("./base").ZepDataType.ZepFloat>]>;
|
|
116
|
+
value: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
117
|
+
default: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
118
|
+
}>, "strip", z.ZodTypeAny, {
|
|
119
|
+
description: string;
|
|
120
|
+
zep_type: import("./base").ZepDataType.ZepFloat | import("./base").ZepDataType.ZepNumber;
|
|
121
|
+
value?: number | undefined;
|
|
122
|
+
default?: number | undefined;
|
|
123
|
+
}, {
|
|
124
|
+
description: string;
|
|
125
|
+
zep_type: import("./base").ZepDataType.ZepFloat | import("./base").ZepDataType.ZepNumber;
|
|
126
|
+
value?: string | number | undefined;
|
|
127
|
+
default?: string | number | undefined;
|
|
128
|
+
}>;
|
|
129
|
+
ZepText: z.ZodObject<z.objectUtil.extendShape<{
|
|
130
|
+
zep_type: z.ZodNativeEnum<typeof import("./base").ZepDataType>;
|
|
131
|
+
description: z.ZodString;
|
|
132
|
+
}, {
|
|
133
|
+
zep_type: z.ZodUnion<[z.ZodLiteral<import("./base").ZepDataType.ZepText>, z.ZodLiteral<import("./base").ZepDataType.ZepZipCode>, z.ZodLiteral<import("./base").ZepDataType.ZepEmail>, z.ZodLiteral<import("./base").ZepDataType.ZepPhoneNumber>]>;
|
|
134
|
+
value: z.ZodOptional<z.ZodString>;
|
|
135
|
+
default: z.ZodOptional<z.ZodString>;
|
|
136
|
+
}>, "strip", z.ZodTypeAny, {
|
|
137
|
+
description: string;
|
|
138
|
+
zep_type: import("./base").ZepDataType.ZepText | import("./base").ZepDataType.ZepZipCode | import("./base").ZepDataType.ZepEmail | import("./base").ZepDataType.ZepPhoneNumber;
|
|
139
|
+
value?: string | undefined;
|
|
140
|
+
default?: string | undefined;
|
|
141
|
+
}, {
|
|
142
|
+
description: string;
|
|
143
|
+
zep_type: import("./base").ZepDataType.ZepText | import("./base").ZepDataType.ZepZipCode | import("./base").ZepDataType.ZepEmail | import("./base").ZepDataType.ZepPhoneNumber;
|
|
144
|
+
value?: string | undefined;
|
|
145
|
+
default?: string | undefined;
|
|
146
|
+
}>;
|
|
147
|
+
ZepZipCode: z.ZodObject<z.objectUtil.extendShape<{
|
|
148
|
+
zep_type: z.ZodNativeEnum<typeof import("./base").ZepDataType>;
|
|
149
|
+
description: z.ZodString;
|
|
150
|
+
}, {
|
|
151
|
+
zep_type: z.ZodUnion<[z.ZodLiteral<import("./base").ZepDataType.ZepText>, z.ZodLiteral<import("./base").ZepDataType.ZepZipCode>, z.ZodLiteral<import("./base").ZepDataType.ZepEmail>, z.ZodLiteral<import("./base").ZepDataType.ZepPhoneNumber>]>;
|
|
152
|
+
value: z.ZodOptional<z.ZodString>;
|
|
153
|
+
default: z.ZodOptional<z.ZodString>;
|
|
154
|
+
}>, "strip", z.ZodTypeAny, {
|
|
155
|
+
description: string;
|
|
156
|
+
zep_type: import("./base").ZepDataType.ZepText | import("./base").ZepDataType.ZepZipCode | import("./base").ZepDataType.ZepEmail | import("./base").ZepDataType.ZepPhoneNumber;
|
|
157
|
+
value?: string | undefined;
|
|
158
|
+
default?: string | undefined;
|
|
159
|
+
}, {
|
|
160
|
+
description: string;
|
|
161
|
+
zep_type: import("./base").ZepDataType.ZepText | import("./base").ZepDataType.ZepZipCode | import("./base").ZepDataType.ZepEmail | import("./base").ZepDataType.ZepPhoneNumber;
|
|
162
|
+
value?: string | undefined;
|
|
163
|
+
default?: string | undefined;
|
|
164
|
+
}>;
|
|
165
|
+
ZepDate: z.ZodObject<z.objectUtil.extendShape<{
|
|
166
|
+
zep_type: z.ZodNativeEnum<typeof import("./base").ZepDataType>;
|
|
167
|
+
description: z.ZodString;
|
|
168
|
+
}, {
|
|
169
|
+
zep_type: z.ZodUnion<[z.ZodLiteral<import("./base").ZepDataType.ZepDate>, z.ZodLiteral<import("./base").ZepDataType.ZepDateTime>]>;
|
|
170
|
+
value: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodDate]>, Date, string | Date>>;
|
|
171
|
+
}>, "strip", z.ZodTypeAny, {
|
|
172
|
+
description: string;
|
|
173
|
+
zep_type: import("./base").ZepDataType.ZepDate | import("./base").ZepDataType.ZepDateTime;
|
|
174
|
+
value?: Date | undefined;
|
|
175
|
+
}, {
|
|
176
|
+
description: string;
|
|
177
|
+
zep_type: import("./base").ZepDataType.ZepDate | import("./base").ZepDataType.ZepDateTime;
|
|
178
|
+
value?: string | Date | undefined;
|
|
179
|
+
}>;
|
|
180
|
+
ZepDateTime: z.ZodObject<z.objectUtil.extendShape<{
|
|
181
|
+
zep_type: z.ZodNativeEnum<typeof import("./base").ZepDataType>;
|
|
182
|
+
description: z.ZodString;
|
|
183
|
+
}, {
|
|
184
|
+
zep_type: z.ZodUnion<[z.ZodLiteral<import("./base").ZepDataType.ZepDate>, z.ZodLiteral<import("./base").ZepDataType.ZepDateTime>]>;
|
|
185
|
+
value: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodDate]>, Date, string | Date>>;
|
|
186
|
+
}>, "strip", z.ZodTypeAny, {
|
|
187
|
+
description: string;
|
|
188
|
+
zep_type: import("./base").ZepDataType.ZepDate | import("./base").ZepDataType.ZepDateTime;
|
|
189
|
+
value?: Date | undefined;
|
|
190
|
+
}, {
|
|
191
|
+
description: string;
|
|
192
|
+
zep_type: import("./base").ZepDataType.ZepDate | import("./base").ZepDataType.ZepDateTime;
|
|
193
|
+
value?: string | Date | undefined;
|
|
194
|
+
}>;
|
|
195
|
+
ZepEmail: z.ZodObject<z.objectUtil.extendShape<{
|
|
196
|
+
zep_type: z.ZodNativeEnum<typeof import("./base").ZepDataType>;
|
|
197
|
+
description: z.ZodString;
|
|
198
|
+
}, {
|
|
199
|
+
zep_type: z.ZodUnion<[z.ZodLiteral<import("./base").ZepDataType.ZepText>, z.ZodLiteral<import("./base").ZepDataType.ZepZipCode>, z.ZodLiteral<import("./base").ZepDataType.ZepEmail>, z.ZodLiteral<import("./base").ZepDataType.ZepPhoneNumber>]>;
|
|
200
|
+
value: z.ZodOptional<z.ZodString>;
|
|
201
|
+
default: z.ZodOptional<z.ZodString>;
|
|
202
|
+
}>, "strip", z.ZodTypeAny, {
|
|
203
|
+
description: string;
|
|
204
|
+
zep_type: import("./base").ZepDataType.ZepText | import("./base").ZepDataType.ZepZipCode | import("./base").ZepDataType.ZepEmail | import("./base").ZepDataType.ZepPhoneNumber;
|
|
205
|
+
value?: string | undefined;
|
|
206
|
+
default?: string | undefined;
|
|
207
|
+
}, {
|
|
208
|
+
description: string;
|
|
209
|
+
zep_type: import("./base").ZepDataType.ZepText | import("./base").ZepDataType.ZepZipCode | import("./base").ZepDataType.ZepEmail | import("./base").ZepDataType.ZepPhoneNumber;
|
|
210
|
+
value?: string | undefined;
|
|
211
|
+
default?: string | undefined;
|
|
212
|
+
}>;
|
|
213
|
+
ZepPhoneNumber: z.ZodObject<z.objectUtil.extendShape<{
|
|
214
|
+
zep_type: z.ZodNativeEnum<typeof import("./base").ZepDataType>;
|
|
215
|
+
description: z.ZodString;
|
|
216
|
+
}, {
|
|
217
|
+
zep_type: z.ZodUnion<[z.ZodLiteral<import("./base").ZepDataType.ZepText>, z.ZodLiteral<import("./base").ZepDataType.ZepZipCode>, z.ZodLiteral<import("./base").ZepDataType.ZepEmail>, z.ZodLiteral<import("./base").ZepDataType.ZepPhoneNumber>]>;
|
|
218
|
+
value: z.ZodOptional<z.ZodString>;
|
|
219
|
+
default: z.ZodOptional<z.ZodString>;
|
|
220
|
+
}>, "strip", z.ZodTypeAny, {
|
|
221
|
+
description: string;
|
|
222
|
+
zep_type: import("./base").ZepDataType.ZepText | import("./base").ZepDataType.ZepZipCode | import("./base").ZepDataType.ZepEmail | import("./base").ZepDataType.ZepPhoneNumber;
|
|
223
|
+
value?: string | undefined;
|
|
224
|
+
default?: string | undefined;
|
|
225
|
+
}, {
|
|
226
|
+
description: string;
|
|
227
|
+
zep_type: import("./base").ZepDataType.ZepText | import("./base").ZepDataType.ZepZipCode | import("./base").ZepDataType.ZepEmail | import("./base").ZepDataType.ZepPhoneNumber;
|
|
228
|
+
value?: string | undefined;
|
|
229
|
+
default?: string | undefined;
|
|
230
|
+
}>;
|
|
231
|
+
ZepFloat: z.ZodObject<z.objectUtil.extendShape<{
|
|
232
|
+
zep_type: z.ZodNativeEnum<typeof import("./base").ZepDataType>;
|
|
233
|
+
description: z.ZodString;
|
|
234
|
+
}, {
|
|
235
|
+
zep_type: z.ZodUnion<[z.ZodLiteral<import("./base").ZepDataType.ZepNumber>, z.ZodLiteral<import("./base").ZepDataType.ZepFloat>]>;
|
|
236
|
+
value: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
237
|
+
default: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
238
|
+
}>, "strip", z.ZodTypeAny, {
|
|
239
|
+
description: string;
|
|
240
|
+
zep_type: import("./base").ZepDataType.ZepFloat | import("./base").ZepDataType.ZepNumber;
|
|
241
|
+
value?: number | undefined;
|
|
242
|
+
default?: number | undefined;
|
|
243
|
+
}, {
|
|
244
|
+
description: string;
|
|
245
|
+
zep_type: import("./base").ZepDataType.ZepFloat | import("./base").ZepDataType.ZepNumber;
|
|
246
|
+
value?: string | number | undefined;
|
|
247
|
+
default?: string | number | undefined;
|
|
248
|
+
}>;
|
|
249
|
+
ZepRegex: z.ZodObject<z.objectUtil.extendShape<{
|
|
250
|
+
zep_type: z.ZodNativeEnum<typeof import("./base").ZepDataType>;
|
|
251
|
+
description: z.ZodString;
|
|
252
|
+
}, {
|
|
253
|
+
zep_type: z.ZodLiteral<import("./base").ZepDataType.ZepRegex>;
|
|
254
|
+
value: z.ZodOptional<z.ZodString>;
|
|
255
|
+
pattern: z.ZodEffects<z.ZodString, string, string>;
|
|
256
|
+
default: z.ZodOptional<z.ZodString>;
|
|
257
|
+
}>, "strip", z.ZodTypeAny, {
|
|
258
|
+
description: string;
|
|
259
|
+
zep_type: import("./base").ZepDataType.ZepRegex;
|
|
260
|
+
pattern: string;
|
|
261
|
+
value?: string | undefined;
|
|
262
|
+
default?: string | undefined;
|
|
263
|
+
}, {
|
|
264
|
+
description: string;
|
|
265
|
+
zep_type: import("./base").ZepDataType.ZepRegex;
|
|
266
|
+
pattern: string;
|
|
267
|
+
value?: string | undefined;
|
|
268
|
+
default?: string | undefined;
|
|
269
|
+
}>;
|
|
270
|
+
};
|
|
271
|
+
export declare const zepFields: {
|
|
272
|
+
number: (description: string) => ZepNumberField;
|
|
273
|
+
text: (description: string) => ZepTextField;
|
|
274
|
+
zipCode: (description: string) => ZepTextField;
|
|
275
|
+
date: (description: string) => ZepDateField;
|
|
276
|
+
dateTime: (description: string) => ZepDateField;
|
|
277
|
+
email: (description: string) => ZepTextField;
|
|
278
|
+
phoneNumber: (description: string) => ZepTextField;
|
|
279
|
+
float: (description: string) => ZepNumberField;
|
|
280
|
+
regex: (description: string, pattern: RegExp) => ZepRegexField;
|
|
281
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zepFields = exports.schemas = exports.DataExtractorFields = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const date_1 = require("./date");
|
|
6
|
+
const number_1 = require("./number");
|
|
7
|
+
const text_1 = require("./text");
|
|
8
|
+
const regex_1 = require("./regex");
|
|
9
|
+
exports.DataExtractorFields = zod_1.z.record(zod_1.z.union([number_1.ZepNumberSchema, text_1.ZepTextSchema, date_1.ZepDateSchema, regex_1.ZepRegexSchema]));
|
|
10
|
+
exports.schemas = {
|
|
11
|
+
ZepNumber: number_1.ZepNumberSchema,
|
|
12
|
+
ZepText: text_1.ZepTextSchema,
|
|
13
|
+
ZepZipCode: text_1.ZepTextSchema,
|
|
14
|
+
ZepDate: date_1.ZepDateSchema,
|
|
15
|
+
ZepDateTime: date_1.ZepDateSchema,
|
|
16
|
+
ZepEmail: text_1.ZepTextSchema,
|
|
17
|
+
ZepPhoneNumber: text_1.ZepTextSchema,
|
|
18
|
+
ZepFloat: number_1.ZepNumberSchema,
|
|
19
|
+
ZepRegex: regex_1.ZepRegexSchema,
|
|
20
|
+
};
|
|
21
|
+
exports.zepFields = {
|
|
22
|
+
number: number_1.zepNumberField,
|
|
23
|
+
text: text_1.zepTextField,
|
|
24
|
+
zipCode: text_1.zepZipcodeField,
|
|
25
|
+
date: date_1.zepDateField,
|
|
26
|
+
dateTime: date_1.zepDateTimeField,
|
|
27
|
+
email: text_1.zepEmailField,
|
|
28
|
+
phoneNumber: text_1.zepPhoneNumberField,
|
|
29
|
+
float: number_1.zepFloatField,
|
|
30
|
+
regex: regex_1.zepRegexField,
|
|
31
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ZepDataType } from "./base";
|
|
3
|
+
import { HasOptionalValue } from "./index";
|
|
4
|
+
export declare const ZepNumberSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
5
|
+
zep_type: z.ZodNativeEnum<typeof ZepDataType>;
|
|
6
|
+
description: z.ZodString;
|
|
7
|
+
}, {
|
|
8
|
+
zep_type: z.ZodUnion<[z.ZodLiteral<ZepDataType.ZepNumber>, z.ZodLiteral<ZepDataType.ZepFloat>]>;
|
|
9
|
+
value: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
10
|
+
default: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
11
|
+
}>, "strip", z.ZodTypeAny, {
|
|
12
|
+
description: string;
|
|
13
|
+
zep_type: ZepDataType.ZepFloat | ZepDataType.ZepNumber;
|
|
14
|
+
value?: number | undefined;
|
|
15
|
+
default?: number | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
description: string;
|
|
18
|
+
zep_type: ZepDataType.ZepFloat | ZepDataType.ZepNumber;
|
|
19
|
+
value?: string | number | undefined;
|
|
20
|
+
default?: string | number | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
export interface ZepNumberField extends HasOptionalValue<number> {
|
|
23
|
+
zep_type: ZepDataType.ZepNumber | ZepDataType.ZepFloat;
|
|
24
|
+
description: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const zepNumberField: (description: string) => ZepNumberField;
|
|
27
|
+
export declare const zepFloatField: (description: string) => ZepNumberField;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zepFloatField = exports.zepNumberField = exports.ZepNumberSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
const stringToNumberTransformer = zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform((value, ctx) => {
|
|
7
|
+
if (typeof value === "string") {
|
|
8
|
+
const parsed = parseFloat(value);
|
|
9
|
+
if (isNaN(parsed)) {
|
|
10
|
+
ctx.addIssue({
|
|
11
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
12
|
+
message: "Not a number",
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return parsed;
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
18
|
+
});
|
|
19
|
+
exports.ZepNumberSchema = base_1.BaseSchema.extend({
|
|
20
|
+
zep_type: zod_1.z.union([zod_1.z.literal(base_1.ZepDataType.ZepNumber), zod_1.z.literal(base_1.ZepDataType.ZepFloat)]),
|
|
21
|
+
value: stringToNumberTransformer.optional(),
|
|
22
|
+
default: stringToNumberTransformer.optional(),
|
|
23
|
+
});
|
|
24
|
+
const zepNumberField = (description) => {
|
|
25
|
+
return exports.ZepNumberSchema.parse({
|
|
26
|
+
zep_type: base_1.ZepDataType.ZepNumber,
|
|
27
|
+
description,
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
exports.zepNumberField = zepNumberField;
|
|
31
|
+
const zepFloatField = (description) => {
|
|
32
|
+
return exports.ZepNumberSchema.parse({
|
|
33
|
+
zep_type: base_1.ZepDataType.ZepFloat,
|
|
34
|
+
description,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
exports.zepFloatField = zepFloatField;
|