├── .fernignore ├── .github └── workflows │ ├── ci.yml │ └── npm-publish-cloud.yml ├── .gitignore ├── .npmignore ├── .prettierrc.yml ├── LICENSE ├── README.md ├── examples ├── documents │ ├── babbages_calculating_engine.txt │ └── index.ts ├── graph │ ├── conversations.ts │ ├── entity_type_example.ts │ ├── group_graph_example.ts │ └── user_graph_example.ts ├── langgraph │ ├── .env.example │ ├── .gitignore │ ├── README.md │ ├── agent.ts │ ├── package-lock.json │ ├── package.json │ └── zep-memory.ts ├── memory │ ├── chat_shoe_store_history.ts │ ├── memory_example.ts │ └── structured_data_extraction_example.ts └── users │ └── users.ts ├── jest.config.mjs ├── package.json ├── reference.md ├── scripts └── rename-to-esm-files.js ├── src ├── Client.ts ├── api │ ├── errors │ │ ├── BadRequestError.ts │ │ ├── ConflictError.ts │ │ ├── InternalServerError.ts │ │ ├── NotFoundError.ts │ │ ├── UnauthorizedError.ts │ │ └── index.ts │ ├── index.ts │ ├── resources │ │ ├── document │ │ │ ├── client │ │ │ │ ├── Client.ts │ │ │ │ ├── index.ts │ │ │ │ └── requests │ │ │ │ │ ├── CreateDocumentCollectionRequest.ts │ │ │ │ │ ├── DocumentSearchPayload.ts │ │ │ │ │ ├── GetDocumentListRequest.ts │ │ │ │ │ ├── UpdateDocumentCollectionRequest.ts │ │ │ │ │ ├── UpdateDocumentRequest.ts │ │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── graph │ │ │ ├── client │ │ │ │ ├── Client.ts │ │ │ │ ├── index.ts │ │ │ │ └── requests │ │ │ │ │ ├── AddDataBatchRequest.ts │ │ │ │ │ ├── AddDataRequest.ts │ │ │ │ │ ├── AddTripleRequest.ts │ │ │ │ │ ├── EntityTypeRequest.ts │ │ │ │ │ ├── GraphSearchQuery.ts │ │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ └── resources │ │ │ │ ├── edge │ │ │ │ ├── client │ │ │ │ │ ├── Client.ts │ │ │ │ │ └── index.ts │ │ │ │ └── index.ts │ │ │ │ ├── episode │ │ │ │ ├── client │ │ │ │ │ ├── Client.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── requests │ │ │ │ │ │ ├── EpisodeGetByGroupIdRequest.ts │ │ │ │ │ │ ├── EpisodeGetByUserIdRequest.ts │ │ │ │ │ │ └── index.ts │ │ │ │ └── index.ts │ │ │ │ ├── index.ts │ │ │ │ └── node │ │ │ │ ├── client │ │ │ │ ├── Client.ts │ │ │ │ └── index.ts │ │ │ │ └── index.ts │ │ ├── group │ │ │ ├── client │ │ │ │ ├── Client.ts │ │ │ │ ├── index.ts │ │ │ │ └── requests │ │ │ │ │ ├── CreateGroupRequest.ts │ │ │ │ │ ├── GetGroupsOrderedRequest.ts │ │ │ │ │ ├── UpdateGroupRequest.ts │ │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── memory │ │ │ ├── client │ │ │ │ ├── Client.ts │ │ │ │ ├── index.ts │ │ │ │ └── requests │ │ │ │ │ ├── AddFactsRequest.ts │ │ │ │ │ ├── AddMemoryRequest.ts │ │ │ │ │ ├── CreateSessionRequest.ts │ │ │ │ │ ├── EndSessionRequest.ts │ │ │ │ │ ├── EndSessionsRequest.ts │ │ │ │ │ ├── ExtractDataRequest.ts │ │ │ │ │ ├── MemoryGetRequest.ts │ │ │ │ │ ├── MemoryGetSessionFactsRequest.ts │ │ │ │ │ ├── MemoryGetSessionMessagesRequest.ts │ │ │ │ │ ├── MemoryListSessionsRequest.ts │ │ │ │ │ ├── MemorySearchPayload.ts │ │ │ │ │ ├── MemorySynthesizeQuestionRequest.ts │ │ │ │ │ ├── ModelsMessageMetadataUpdate.ts │ │ │ │ │ ├── SessionSearchQuery.ts │ │ │ │ │ ├── UpdateSessionRequest.ts │ │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ └── user │ │ │ ├── client │ │ │ ├── Client.ts │ │ │ ├── index.ts │ │ │ └── requests │ │ │ │ ├── CreateUserRequest.ts │ │ │ │ ├── UpdateUserRequest.ts │ │ │ │ ├── UserListOrderedRequest.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ └── types │ │ ├── AddMemoryResponse.ts │ │ ├── AddTripleResponse.ts │ │ ├── ApiError.ts │ │ ├── ApidataDocument.ts │ │ ├── ApidataDocumentCollection.ts │ │ ├── ApidataDocumentSearchResponse.ts │ │ ├── ApidataDocumentWithScore.ts │ │ ├── ClassifySessionRequest.ts │ │ ├── CreateDocumentRequest.ts │ │ ├── EdgeType.ts │ │ ├── EndSessionResponse.ts │ │ ├── EndSessionsResponse.ts │ │ ├── EntityEdge.ts │ │ ├── EntityEdgeSourceTarget.ts │ │ ├── EntityNode.ts │ │ ├── EntityProperty.ts │ │ ├── EntityPropertyType.ts │ │ ├── EntityType.ts │ │ ├── EntityTypeResponse.ts │ │ ├── Episode.ts │ │ ├── EpisodeData.ts │ │ ├── EpisodeMentions.ts │ │ ├── EpisodeResponse.ts │ │ ├── Fact.ts │ │ ├── FactRatingExamples.ts │ │ ├── FactRatingInstruction.ts │ │ ├── FactResponse.ts │ │ ├── FactsResponse.ts │ │ ├── GraphDataType.ts │ │ ├── GraphEdgesRequest.ts │ │ ├── GraphNodesRequest.ts │ │ ├── GraphSearchResults.ts │ │ ├── GraphSearchScope.ts │ │ ├── Group.ts │ │ ├── GroupListResponse.ts │ │ ├── Memory.ts │ │ ├── MemorySearchResult.ts │ │ ├── Message.ts │ │ ├── MessageListResponse.ts │ │ ├── NewFact.ts │ │ ├── Question.ts │ │ ├── Reranker.ts │ │ ├── RoleType.ts │ │ ├── SearchFilters.ts │ │ ├── SearchScope.ts │ │ ├── SearchType.ts │ │ ├── Session.ts │ │ ├── SessionClassification.ts │ │ ├── SessionListResponse.ts │ │ ├── SessionSearchResponse.ts │ │ ├── SessionSearchResult.ts │ │ ├── SuccessResponse.ts │ │ ├── Summary.ts │ │ ├── SummaryListResponse.ts │ │ ├── UpdateDocumentListRequest.ts │ │ ├── User.ts │ │ ├── UserListResponse.ts │ │ ├── UserNodeResponse.ts │ │ └── index.ts ├── core │ ├── fetcher │ │ ├── APIResponse.ts │ │ ├── Fetcher.ts │ │ ├── Supplier.ts │ │ ├── createRequestUrl.ts │ │ ├── getFetchFn.ts │ │ ├── getHeader.ts │ │ ├── getRequestBody.ts │ │ ├── getResponseBody.ts │ │ ├── index.ts │ │ ├── makeRequest.ts │ │ ├── requestWithRetries.ts │ │ ├── signals.ts │ │ └── stream-wrappers │ │ │ ├── Node18UniversalStreamWrapper.ts │ │ │ ├── NodePre18StreamWrapper.ts │ │ │ ├── UndiciStreamWrapper.ts │ │ │ └── chooseStreamWrapper.ts │ ├── index.ts │ ├── runtime │ │ ├── index.ts │ │ └── runtime.ts │ └── schemas │ │ ├── Schema.ts │ │ ├── builders │ │ ├── bigint │ │ │ ├── bigint.ts │ │ │ └── index.ts │ │ ├── date │ │ │ ├── date.ts │ │ │ └── index.ts │ │ ├── enum │ │ │ ├── enum.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── lazy │ │ │ ├── index.ts │ │ │ ├── lazy.ts │ │ │ └── lazyObject.ts │ │ ├── list │ │ │ ├── index.ts │ │ │ └── list.ts │ │ ├── literals │ │ │ ├── booleanLiteral.ts │ │ │ ├── index.ts │ │ │ └── stringLiteral.ts │ │ ├── object-like │ │ │ ├── getObjectLikeUtils.ts │ │ │ ├── index.ts │ │ │ └── types.ts │ │ ├── object │ │ │ ├── index.ts │ │ │ ├── object.ts │ │ │ ├── objectWithoutOptionalProperties.ts │ │ │ ├── property.ts │ │ │ └── types.ts │ │ ├── primitives │ │ │ ├── any.ts │ │ │ ├── boolean.ts │ │ │ ├── index.ts │ │ │ ├── number.ts │ │ │ ├── string.ts │ │ │ └── unknown.ts │ │ ├── record │ │ │ ├── index.ts │ │ │ ├── record.ts │ │ │ └── types.ts │ │ ├── schema-utils │ │ │ ├── JsonError.ts │ │ │ ├── ParseError.ts │ │ │ ├── getSchemaUtils.ts │ │ │ ├── index.ts │ │ │ └── stringifyValidationErrors.ts │ │ ├── set │ │ │ ├── index.ts │ │ │ └── set.ts │ │ ├── undiscriminated-union │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ └── undiscriminatedUnion.ts │ │ └── union │ │ │ ├── discriminant.ts │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ └── union.ts │ │ ├── index.ts │ │ └── utils │ │ ├── MaybePromise.ts │ │ ├── addQuestionMarksToNullableProperties.ts │ │ ├── createIdentitySchemaCreator.ts │ │ ├── entries.ts │ │ ├── filterObject.ts │ │ ├── getErrorMessageForIncorrectType.ts │ │ ├── isPlainObject.ts │ │ ├── keys.ts │ │ ├── maybeSkipValidation.ts │ │ └── partition.ts ├── environments.ts ├── errors │ ├── ZepError.ts │ ├── ZepTimeoutError.ts │ └── index.ts ├── extractor │ ├── base.ts │ ├── date.ts │ ├── index.ts │ ├── number.ts │ ├── regex.ts │ └── text.ts ├── index.ts ├── serialization │ ├── index.ts │ ├── resources │ │ ├── document │ │ │ ├── client │ │ │ │ ├── addDocuments.ts │ │ │ │ ├── batchDeleteDocuments.ts │ │ │ │ ├── batchGetDocuments.ts │ │ │ │ ├── batchUpdateDocuments.ts │ │ │ │ ├── index.ts │ │ │ │ ├── listCollections.ts │ │ │ │ └── requests │ │ │ │ │ ├── CreateDocumentCollectionRequest.ts │ │ │ │ │ ├── DocumentSearchPayload.ts │ │ │ │ │ ├── GetDocumentListRequest.ts │ │ │ │ │ ├── UpdateDocumentCollectionRequest.ts │ │ │ │ │ ├── UpdateDocumentRequest.ts │ │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── graph │ │ │ ├── client │ │ │ │ ├── addBatch.ts │ │ │ │ ├── index.ts │ │ │ │ └── requests │ │ │ │ │ ├── AddDataBatchRequest.ts │ │ │ │ │ ├── AddDataRequest.ts │ │ │ │ │ ├── AddTripleRequest.ts │ │ │ │ │ ├── EntityTypeRequest.ts │ │ │ │ │ ├── GraphSearchQuery.ts │ │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ └── resources │ │ │ │ ├── edge │ │ │ │ ├── client │ │ │ │ │ ├── getByGroupId.ts │ │ │ │ │ ├── getByUserId.ts │ │ │ │ │ └── index.ts │ │ │ │ └── index.ts │ │ │ │ ├── index.ts │ │ │ │ └── node │ │ │ │ ├── client │ │ │ │ ├── getByGroupId.ts │ │ │ │ ├── getByUserId.ts │ │ │ │ ├── getEdges.ts │ │ │ │ └── index.ts │ │ │ │ └── index.ts │ │ ├── group │ │ │ ├── client │ │ │ │ ├── index.ts │ │ │ │ └── requests │ │ │ │ │ ├── CreateGroupRequest.ts │ │ │ │ │ ├── UpdateGroupRequest.ts │ │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── memory │ │ │ ├── client │ │ │ │ ├── extractData.ts │ │ │ │ ├── index.ts │ │ │ │ ├── requests │ │ │ │ │ ├── AddFactsRequest.ts │ │ │ │ │ ├── AddMemoryRequest.ts │ │ │ │ │ ├── CreateSessionRequest.ts │ │ │ │ │ ├── EndSessionRequest.ts │ │ │ │ │ ├── EndSessionsRequest.ts │ │ │ │ │ ├── ExtractDataRequest.ts │ │ │ │ │ ├── MemorySearchPayload.ts │ │ │ │ │ ├── ModelsMessageMetadataUpdate.ts │ │ │ │ │ ├── SessionSearchQuery.ts │ │ │ │ │ ├── UpdateSessionRequest.ts │ │ │ │ │ └── index.ts │ │ │ │ └── search.ts │ │ │ └── index.ts │ │ └── user │ │ │ ├── client │ │ │ ├── getSessions.ts │ │ │ ├── index.ts │ │ │ └── requests │ │ │ │ ├── CreateUserRequest.ts │ │ │ │ ├── UpdateUserRequest.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ └── types │ │ ├── AddMemoryResponse.ts │ │ ├── AddTripleResponse.ts │ │ ├── ApiError.ts │ │ ├── ApidataDocument.ts │ │ ├── ApidataDocumentCollection.ts │ │ ├── ApidataDocumentSearchResponse.ts │ │ ├── ApidataDocumentWithScore.ts │ │ ├── ClassifySessionRequest.ts │ │ ├── CreateDocumentRequest.ts │ │ ├── EdgeType.ts │ │ ├── EndSessionResponse.ts │ │ ├── EndSessionsResponse.ts │ │ ├── EntityEdge.ts │ │ ├── EntityEdgeSourceTarget.ts │ │ ├── EntityNode.ts │ │ ├── EntityProperty.ts │ │ ├── EntityPropertyType.ts │ │ ├── EntityType.ts │ │ ├── EntityTypeResponse.ts │ │ ├── Episode.ts │ │ ├── EpisodeData.ts │ │ ├── EpisodeMentions.ts │ │ ├── EpisodeResponse.ts │ │ ├── Fact.ts │ │ ├── FactRatingExamples.ts │ │ ├── FactRatingInstruction.ts │ │ ├── FactResponse.ts │ │ ├── FactsResponse.ts │ │ ├── GraphDataType.ts │ │ ├── GraphEdgesRequest.ts │ │ ├── GraphNodesRequest.ts │ │ ├── GraphSearchResults.ts │ │ ├── GraphSearchScope.ts │ │ ├── Group.ts │ │ ├── GroupListResponse.ts │ │ ├── Memory.ts │ │ ├── MemorySearchResult.ts │ │ ├── Message.ts │ │ ├── MessageListResponse.ts │ │ ├── NewFact.ts │ │ ├── Question.ts │ │ ├── Reranker.ts │ │ ├── RoleType.ts │ │ ├── SearchFilters.ts │ │ ├── SearchScope.ts │ │ ├── SearchType.ts │ │ ├── Session.ts │ │ ├── SessionClassification.ts │ │ ├── SessionListResponse.ts │ │ ├── SessionSearchResponse.ts │ │ ├── SessionSearchResult.ts │ │ ├── SuccessResponse.ts │ │ ├── Summary.ts │ │ ├── SummaryListResponse.ts │ │ ├── UpdateDocumentListRequest.ts │ │ ├── User.ts │ │ ├── UserListResponse.ts │ │ ├── UserNodeResponse.ts │ │ └── index.ts ├── version.ts └── wrapper │ ├── graph.ts │ ├── index.ts │ ├── memory.ts │ └── ontology.ts ├── tests ├── custom.test.ts ├── sde.test.ts └── unit │ ├── fetcher │ ├── Fetcher.test.ts │ ├── createRequestUrl.test.ts │ ├── getFetchFn.test.ts │ ├── getRequestBody.test.ts │ ├── getResponseBody.test.ts │ ├── makeRequest.test.ts │ ├── requestWithRetries.test.ts │ ├── signals.test.ts │ ├── stream-wrappers │ │ ├── Node18UniversalStreamWrapper.test.ts │ │ ├── NodePre18StreamWrapper.test.ts │ │ ├── UndiciStreamWrapper.test.ts │ │ ├── chooseStreamWrapper.test.ts │ │ └── webpack.test.ts │ └── test-file.txt │ └── zurg │ ├── bigint │ └── bigint.test.ts │ ├── date │ └── date.test.ts │ ├── enum │ └── enum.test.ts │ ├── lazy │ ├── lazy.test.ts │ ├── lazyObject.test.ts │ └── recursive │ │ ├── a.ts │ │ └── b.ts │ ├── list │ └── list.test.ts │ ├── literals │ └── stringLiteral.test.ts │ ├── object-like │ └── withParsedProperties.test.ts │ ├── object │ ├── extend.test.ts │ ├── object.test.ts │ ├── objectWithoutOptionalProperties.test.ts │ └── passthrough.test.ts │ ├── primitives │ ├── any.test.ts │ ├── boolean.test.ts │ ├── number.test.ts │ ├── string.test.ts │ └── unknown.test.ts │ ├── record │ └── record.test.ts │ ├── schema-utils │ └── getSchemaUtils.test.ts │ ├── schema.test.ts │ ├── set │ └── set.test.ts │ ├── skipValidation.test.ts │ ├── undiscriminated-union │ └── undiscriminatedUnion.test.ts │ ├── union │ └── union.test.ts │ └── utils │ ├── itSchema.ts │ └── itValidate.ts ├── tsconfig.json └── yarn.lock /.fernignore: -------------------------------------------------------------------------------- 1 | # Specify files that shouldn't be modified by Fern 2 | examples 3 | src/wrapper 4 | src/extractor 5 | src/index.ts 6 | src/langchain 7 | package.json 8 | yarn.lock 9 | .github 10 | README.md 11 | tests/sde.test.ts 12 | .gitignore 13 | LICENSE -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: [push] 4 | 5 | jobs: 6 | compile: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - name: Checkout repo 11 | uses: actions/checkout@v3 12 | 13 | - name: Set up node 14 | uses: actions/setup-node@v3 15 | 16 | - name: Install dependencies 17 | run: yarn 18 | - name: Test 19 | run: yarn test 20 | - name: Build 21 | run: yarn build 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | /dist 4 | .idea/ -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | src 3 | tests 4 | .gitignore 5 | .github 6 | .fernignore 7 | .prettierrc.yml 8 | tsconfig.json 9 | yarn.lock -------------------------------------------------------------------------------- /.prettierrc.yml: -------------------------------------------------------------------------------- 1 | tabWidth: 4 2 | printWidth: 120 3 | -------------------------------------------------------------------------------- /examples/graph/entity_type_example.ts: -------------------------------------------------------------------------------- 1 | import { ZepClient } from "../../src"; 2 | import { EntityData, entityFields, EntityType, EdgeType } from "../../src/wrapper/ontology"; 3 | 4 | const API_KEY = process.env.ZEP_API_KEY; 5 | 6 | async function main() { 7 | const client = new ZepClient({ 8 | apiKey: API_KEY, 9 | }); 10 | 11 | const travelDestinationSchema: EntityType = { 12 | description: "A travel destination entity", 13 | fields: { 14 | destination_name: entityFields.text("The name of travel destination"), 15 | }, 16 | }; 17 | 18 | type TravelDestination = EntityData; 19 | 20 | const isTravelingTo: EdgeType = { 21 | description: "An edge representing a traveler going to a destination.", 22 | fields: { 23 | travel_date: entityFields.text("The date of the travel"), 24 | purpose: entityFields.text("The purpose of the travel"), 25 | }, 26 | sourceTargets: [ 27 | { 28 | source: "User", 29 | target: "TravelDestination", 30 | } 31 | ] 32 | } 33 | 34 | await client.graph.setEntityTypes({ 35 | TravelDestination: travelDestinationSchema, 36 | }, { 37 | IS_TRAVELING_TO: isTravelingTo, 38 | }); 39 | 40 | const customTypes = await client.graph.listEntityTypes(); 41 | console.log(JSON.stringify(customTypes, null, 2)); 42 | } 43 | 44 | main().catch(console.error); 45 | -------------------------------------------------------------------------------- /examples/langgraph/.env.example: -------------------------------------------------------------------------------- 1 | # OpenAI API key for the language model 2 | OPENAI_API_KEY=your_openai_api_key_here 3 | 4 | # Tavily API key for web search functionality 5 | TAVILY_API_KEY=your_tavily_api_key_here 6 | # Zep API key for memory persistence 7 | ZEP_API_KEY=your_zep_api_key_here 8 | -------------------------------------------------------------------------------- /examples/langgraph/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /examples/langgraph/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "agent", 3 | "version": "1.0.0", 4 | "description": "A simple agent built with LangGraph.js", 5 | "type": "module", 6 | "scripts": { 7 | "start": "tsx agent.ts" 8 | }, 9 | "dependencies": { 10 | "@getzep/zep-cloud": "^2.5.0", 11 | "@langchain/core": "^0.3.40", 12 | "@langchain/langgraph": "^0.2.51", 13 | "@langchain/openai": "^0.4.4", 14 | "commander": "^12.0.0", 15 | "dotenv": "^16.4.1", 16 | "tsx": "^4.7.0", 17 | "typescript": "^5.3.3", 18 | "uuid": "^9.0.1" 19 | } 20 | } -------------------------------------------------------------------------------- /examples/memory/structured_data_extraction_example.ts: -------------------------------------------------------------------------------- 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; 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(); 35 | -------------------------------------------------------------------------------- /jest.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('jest').Config} */ 2 | export default { 3 | preset: "ts-jest", 4 | testEnvironment: "node", 5 | moduleNameMapper: { 6 | "(.+)\.js$": "$1", 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /src/api/errors/BadRequestError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as errors from "../../errors/index"; 6 | import * as Zep from "../index"; 7 | 8 | export class BadRequestError extends errors.ZepError { 9 | constructor(body: Zep.ApiError) { 10 | super({ 11 | message: "BadRequestError", 12 | statusCode: 400, 13 | body: body, 14 | }); 15 | Object.setPrototypeOf(this, BadRequestError.prototype); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/api/errors/ConflictError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as errors from "../../errors/index"; 6 | import * as Zep from "../index"; 7 | 8 | export class ConflictError extends errors.ZepError { 9 | constructor(body: Zep.ApiError) { 10 | super({ 11 | message: "ConflictError", 12 | statusCode: 409, 13 | body: body, 14 | }); 15 | Object.setPrototypeOf(this, ConflictError.prototype); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/api/errors/InternalServerError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as errors from "../../errors/index"; 6 | import * as Zep from "../index"; 7 | 8 | export class InternalServerError extends errors.ZepError { 9 | constructor(body: Zep.ApiError) { 10 | super({ 11 | message: "InternalServerError", 12 | statusCode: 500, 13 | body: body, 14 | }); 15 | Object.setPrototypeOf(this, InternalServerError.prototype); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/api/errors/NotFoundError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as errors from "../../errors/index"; 6 | import * as Zep from "../index"; 7 | 8 | export class NotFoundError extends errors.ZepError { 9 | constructor(body: Zep.ApiError) { 10 | super({ 11 | message: "NotFoundError", 12 | statusCode: 404, 13 | body: body, 14 | }); 15 | Object.setPrototypeOf(this, NotFoundError.prototype); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/api/errors/UnauthorizedError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as errors from "../../errors/index"; 6 | import * as Zep from "../index"; 7 | 8 | export class UnauthorizedError extends errors.ZepError { 9 | constructor(body: Zep.ApiError) { 10 | super({ 11 | message: "UnauthorizedError", 12 | statusCode: 401, 13 | body: body, 14 | }); 15 | Object.setPrototypeOf(this, UnauthorizedError.prototype); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/api/errors/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./UnauthorizedError"; 2 | export * from "./InternalServerError"; 3 | export * from "./BadRequestError"; 4 | export * from "./NotFoundError"; 5 | export * from "./ConflictError"; 6 | -------------------------------------------------------------------------------- /src/api/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./errors"; 3 | export * from "./resources"; 4 | -------------------------------------------------------------------------------- /src/api/resources/document/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/api/resources/document/client/requests/CreateDocumentCollectionRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * {} 8 | */ 9 | export interface CreateDocumentCollectionRequest { 10 | description?: string; 11 | metadata?: Record; 12 | } 13 | -------------------------------------------------------------------------------- /src/api/resources/document/client/requests/DocumentSearchPayload.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * {} 10 | */ 11 | export interface DocumentSearchPayload { 12 | /** 13 | * Limit the number of returned documents 14 | */ 15 | limit?: number; 16 | /** Document metadata to filter on. */ 17 | metadata?: Record; 18 | minScore?: number; 19 | /** The lambda parameter for the MMR Reranking Algorithm. */ 20 | mmrLambda?: number; 21 | /** The type of search to perform. Defaults to "similarity". Must be one of "similarity" or "mmr". */ 22 | searchType?: Zep.SearchType; 23 | /** The search text. */ 24 | text?: string; 25 | } 26 | -------------------------------------------------------------------------------- /src/api/resources/document/client/requests/GetDocumentListRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * {} 8 | */ 9 | export interface GetDocumentListRequest { 10 | documentIds?: string[]; 11 | uuids?: string[]; 12 | } 13 | -------------------------------------------------------------------------------- /src/api/resources/document/client/requests/UpdateDocumentCollectionRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * {} 8 | */ 9 | export interface UpdateDocumentCollectionRequest { 10 | description?: string; 11 | metadata?: Record; 12 | } 13 | -------------------------------------------------------------------------------- /src/api/resources/document/client/requests/UpdateDocumentRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * {} 8 | */ 9 | export interface UpdateDocumentRequest { 10 | documentId?: string; 11 | metadata?: Record; 12 | } 13 | -------------------------------------------------------------------------------- /src/api/resources/document/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { type CreateDocumentCollectionRequest } from "./CreateDocumentCollectionRequest"; 2 | export { type UpdateDocumentCollectionRequest } from "./UpdateDocumentCollectionRequest"; 3 | export { type GetDocumentListRequest } from "./GetDocumentListRequest"; 4 | export { type UpdateDocumentRequest } from "./UpdateDocumentRequest"; 5 | export { type DocumentSearchPayload } from "./DocumentSearchPayload"; 6 | -------------------------------------------------------------------------------- /src/api/resources/document/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /src/api/resources/graph/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/api/resources/graph/client/requests/AddDataBatchRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * { 10 | * episodes: [{ 11 | * data: "data", 12 | * type: "text" 13 | * }] 14 | * } 15 | */ 16 | export interface AddDataBatchRequest { 17 | episodes: Zep.EpisodeData[]; 18 | groupId?: string; 19 | userId?: string; 20 | } 21 | -------------------------------------------------------------------------------- /src/api/resources/graph/client/requests/AddDataRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * { 10 | * data: "data", 11 | * type: "text" 12 | * } 13 | */ 14 | export interface AddDataRequest { 15 | createdAt?: string; 16 | data: string; 17 | groupId?: string; 18 | sourceDescription?: string; 19 | type: Zep.GraphDataType; 20 | userId?: string; 21 | } 22 | -------------------------------------------------------------------------------- /src/api/resources/graph/client/requests/AddTripleRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * { 8 | * fact: "fact", 9 | * factName: "fact_name", 10 | * targetNodeName: "target_node_name" 11 | * } 12 | */ 13 | export interface AddTripleRequest { 14 | /** The timestamp of the message */ 15 | createdAt?: string; 16 | /** The time (if any) at which the edge expires */ 17 | expiredAt?: string; 18 | /** The fact relating the two nodes that this edge represents */ 19 | fact: string; 20 | /** The name of the edge to add. Should be all caps using snake case (eg RELATES_TO) */ 21 | factName: string; 22 | /** The uuid of the edge to add */ 23 | factUuid?: string; 24 | groupId?: string; 25 | /** The time (if any) at which the fact stops being true */ 26 | invalidAt?: string; 27 | /** The name of the source node to add */ 28 | sourceNodeName?: string; 29 | /** The summary of the source node to add */ 30 | sourceNodeSummary?: string; 31 | /** The source node uuid */ 32 | sourceNodeUuid?: string; 33 | /** The name of the target node to add */ 34 | targetNodeName: string; 35 | /** The summary of the target node to add */ 36 | targetNodeSummary?: string; 37 | /** The target node uuid */ 38 | targetNodeUuid?: string; 39 | userId?: string; 40 | /** The time at which the fact becomes true */ 41 | validAt?: string; 42 | } 43 | -------------------------------------------------------------------------------- /src/api/resources/graph/client/requests/EntityTypeRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * {} 10 | */ 11 | export interface EntityTypeRequest { 12 | edgeTypes?: Zep.EdgeType[]; 13 | entityTypes?: Zep.EntityType[]; 14 | } 15 | -------------------------------------------------------------------------------- /src/api/resources/graph/client/requests/GraphSearchQuery.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * { 10 | * query: "query" 11 | * } 12 | */ 13 | export interface GraphSearchQuery { 14 | /** Node to rerank around for node distance reranking */ 15 | centerNodeUuid?: string; 16 | /** one of user_id or group_id must be provided */ 17 | groupId?: string; 18 | /** The maximum number of facts to retrieve. Defaults to 10. Limited to 50. */ 19 | limit?: number; 20 | /** The minimum rating by which to filter relevant facts */ 21 | minFactRating?: number; 22 | /** Deprecated */ 23 | minScore?: number; 24 | /** weighting for maximal marginal relevance */ 25 | mmrLambda?: number; 26 | /** The string to search for (required) */ 27 | query: string; 28 | /** Defaults to RRF */ 29 | reranker?: Zep.Reranker; 30 | /** Defaults to Edges. Communities will be added in the future. */ 31 | scope?: Zep.GraphSearchScope; 32 | /** Search filters to apply to the search */ 33 | searchFilters?: Zep.SearchFilters; 34 | /** one of user_id or group_id must be provided */ 35 | userId?: string; 36 | } 37 | -------------------------------------------------------------------------------- /src/api/resources/graph/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { type EntityTypeRequest } from "./EntityTypeRequest"; 2 | export { type AddDataRequest } from "./AddDataRequest"; 3 | export { type AddDataBatchRequest } from "./AddDataBatchRequest"; 4 | export { type AddTripleRequest } from "./AddTripleRequest"; 5 | export { type GraphSearchQuery } from "./GraphSearchQuery"; 6 | -------------------------------------------------------------------------------- /src/api/resources/graph/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | export * from "./resources"; 3 | -------------------------------------------------------------------------------- /src/api/resources/graph/resources/edge/client/index.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /src/api/resources/graph/resources/edge/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /src/api/resources/graph/resources/episode/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/api/resources/graph/resources/episode/client/requests/EpisodeGetByGroupIdRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * {} 8 | */ 9 | export interface EpisodeGetByGroupIdRequest { 10 | /** 11 | * The number of most recent episodes to retrieve. 12 | */ 13 | lastn?: number; 14 | } 15 | -------------------------------------------------------------------------------- /src/api/resources/graph/resources/episode/client/requests/EpisodeGetByUserIdRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * {} 8 | */ 9 | export interface EpisodeGetByUserIdRequest { 10 | /** 11 | * The number of most recent episodes entries to retrieve. 12 | */ 13 | lastn?: number; 14 | } 15 | -------------------------------------------------------------------------------- /src/api/resources/graph/resources/episode/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { type EpisodeGetByGroupIdRequest } from "./EpisodeGetByGroupIdRequest"; 2 | export { type EpisodeGetByUserIdRequest } from "./EpisodeGetByUserIdRequest"; 3 | -------------------------------------------------------------------------------- /src/api/resources/graph/resources/episode/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /src/api/resources/graph/resources/index.ts: -------------------------------------------------------------------------------- 1 | export * as edge from "./edge"; 2 | export * as episode from "./episode"; 3 | export * as node from "./node"; 4 | export * from "./episode/client/requests"; 5 | -------------------------------------------------------------------------------- /src/api/resources/graph/resources/node/client/index.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /src/api/resources/graph/resources/node/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /src/api/resources/group/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/api/resources/group/client/requests/CreateGroupRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * { 10 | * groupId: "group_id" 11 | * } 12 | */ 13 | export interface CreateGroupRequest { 14 | description?: string; 15 | factRatingInstruction?: Zep.FactRatingInstruction; 16 | groupId: string; 17 | name?: string; 18 | } 19 | -------------------------------------------------------------------------------- /src/api/resources/group/client/requests/GetGroupsOrderedRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * {} 8 | */ 9 | export interface GetGroupsOrderedRequest { 10 | /** 11 | * Page number for pagination, starting from 1. 12 | */ 13 | pageNumber?: number; 14 | /** 15 | * Number of groups to retrieve per page. 16 | */ 17 | pageSize?: number; 18 | } 19 | -------------------------------------------------------------------------------- /src/api/resources/group/client/requests/UpdateGroupRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * {} 10 | */ 11 | export interface UpdateGroupRequest { 12 | description?: string; 13 | factRatingInstruction?: Zep.FactRatingInstruction; 14 | name?: string; 15 | } 16 | -------------------------------------------------------------------------------- /src/api/resources/group/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { type CreateGroupRequest } from "./CreateGroupRequest"; 2 | export { type GetGroupsOrderedRequest } from "./GetGroupsOrderedRequest"; 3 | export { type UpdateGroupRequest } from "./UpdateGroupRequest"; 4 | -------------------------------------------------------------------------------- /src/api/resources/group/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /src/api/resources/index.ts: -------------------------------------------------------------------------------- 1 | export * as document from "./document"; 2 | export * as graph from "./graph"; 3 | export * as memory from "./memory"; 4 | export * as group from "./group"; 5 | export * as user from "./user"; 6 | export * from "./document/client/requests"; 7 | export * from "./graph/client/requests"; 8 | export * from "./memory/client/requests"; 9 | export * from "./group/client/requests"; 10 | export * from "./user/client/requests"; 11 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/AddFactsRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * { 10 | * facts: [{ 11 | * fact: "fact" 12 | * }] 13 | * } 14 | */ 15 | export interface AddFactsRequest { 16 | facts: Zep.NewFact[]; 17 | } 18 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/AddMemoryRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * { 10 | * messages: [{ 11 | * content: "content", 12 | * roleType: "norole" 13 | * }] 14 | * } 15 | */ 16 | export interface AddMemoryRequest { 17 | /** Deprecated */ 18 | factInstruction?: string; 19 | /** 20 | * Optional list of role types to ignore when adding messages to graph memory. 21 | * The message itself will still be added retained and used as context for messages 22 | * that are added to a user's graph. 23 | */ 24 | ignoreRoles?: Zep.RoleType[]; 25 | /** A list of message objects, where each message contains a role and content. */ 26 | messages: Zep.Message[]; 27 | /** Optionally return memory context relevant to the most recent messages. */ 28 | returnContext?: boolean; 29 | /** Deprecated */ 30 | summaryInstruction?: string; 31 | } 32 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/CreateSessionRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * { 10 | * sessionId: "session_id", 11 | * userId: "user_id" 12 | * } 13 | */ 14 | export interface CreateSessionRequest { 15 | /** Deprecated */ 16 | factRatingInstruction?: Zep.FactRatingInstruction; 17 | /** Deprecated */ 18 | metadata?: Record; 19 | /** The unique identifier of the session. */ 20 | sessionId: string; 21 | /** The unique identifier of the user associated with the session */ 22 | userId: string; 23 | } 24 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/EndSessionRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * {} 10 | */ 11 | export interface EndSessionRequest { 12 | classify?: Zep.ClassifySessionRequest; 13 | instruction?: string; 14 | } 15 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/EndSessionsRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * { 8 | * sessionIds: ["session_ids"] 9 | * } 10 | */ 11 | export interface EndSessionsRequest { 12 | instruction?: string; 13 | sessionIds: string[]; 14 | } 15 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/ExtractDataRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * { 8 | * lastN: 1, 9 | * modelSchema: "model_schema" 10 | * } 11 | */ 12 | export interface ExtractDataRequest { 13 | /** Your current date and time in ISO 8601 format including timezone. This is used for determining relative dates. */ 14 | currentDateTime?: string; 15 | /** The number of messages in the chat history from which to extract data */ 16 | lastN: number; 17 | /** The schema describing the data to be extracted. See Zep's SDKs for more details. */ 18 | modelSchema: string; 19 | /** 20 | * Validate that the extracted data is present in the dialog and correct per the field description. 21 | * Mitigates hallucination, but is slower and may result in false negatives. 22 | */ 23 | validate?: boolean; 24 | } 25 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/MemoryGetRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * {} 8 | */ 9 | export interface MemoryGetRequest { 10 | /** 11 | * The number of most recent memory entries to retrieve. 12 | */ 13 | lastn?: number; 14 | /** 15 | * The minimum rating by which to filter relevant facts. 16 | */ 17 | minRating?: number; 18 | } 19 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/MemoryGetSessionFactsRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * {} 8 | */ 9 | export interface MemoryGetSessionFactsRequest { 10 | /** 11 | * Minimum rating by which to filter facts 12 | */ 13 | minRating?: number; 14 | } 15 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/MemoryGetSessionMessagesRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * {} 8 | */ 9 | export interface MemoryGetSessionMessagesRequest { 10 | /** 11 | * Limit the number of results returned 12 | */ 13 | limit?: number; 14 | /** 15 | * Cursor for pagination 16 | */ 17 | cursor?: number; 18 | } 19 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/MemoryListSessionsRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * {} 8 | */ 9 | export interface MemoryListSessionsRequest { 10 | /** 11 | * Page number for pagination, starting from 1 12 | */ 13 | pageNumber?: number; 14 | /** 15 | * Number of sessions to retrieve per page. 16 | */ 17 | pageSize?: number; 18 | /** 19 | * Field to order the results by: created_at, updated_at, user_id, session_id. 20 | */ 21 | orderBy?: string; 22 | /** 23 | * Order direction: true for ascending, false for descending. 24 | */ 25 | asc?: boolean; 26 | } 27 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/MemorySearchPayload.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * {} 10 | */ 11 | export interface MemorySearchPayload { 12 | /** 13 | * The maximum number of search results to return. Defaults to None (no limit). 14 | */ 15 | limit?: number; 16 | /** Metadata Filter */ 17 | metadata?: Record; 18 | minFactRating?: number; 19 | minScore?: number; 20 | mmrLambda?: number; 21 | searchScope?: Zep.SearchScope; 22 | searchType?: Zep.SearchType; 23 | text?: string; 24 | } 25 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/MemorySynthesizeQuestionRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * {} 8 | */ 9 | export interface MemorySynthesizeQuestionRequest { 10 | /** 11 | * The number of messages to use for question synthesis. 12 | */ 13 | lastNMessages?: number; 14 | } 15 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/ModelsMessageMetadataUpdate.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * { 8 | * metadata: { 9 | * "key": "value" 10 | * } 11 | * } 12 | */ 13 | export interface ModelsMessageMetadataUpdate { 14 | /** Deprecated */ 15 | metadata: Record; 16 | } 17 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/SessionSearchQuery.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * { 10 | * text: "text" 11 | * } 12 | */ 13 | export interface SessionSearchQuery { 14 | /** 15 | * The maximum number of search results to return. Defaults to None (no limit). 16 | */ 17 | limit?: number; 18 | /** The minimum fact rating to filter on. */ 19 | minFactRating?: number; 20 | /** The minimum score for search results. */ 21 | minScore?: number; 22 | /** The lambda parameter for the MMR Reranking Algorithm. */ 23 | mmrLambda?: number; 24 | /** Record filter on the metadata. */ 25 | recordFilter?: Record; 26 | /** Search scope. */ 27 | searchScope?: Zep.SearchScope; 28 | /** Search type. */ 29 | searchType?: Zep.SearchType; 30 | /** the session ids to search */ 31 | sessionIds?: string[]; 32 | /** The search text. */ 33 | text: string; 34 | /** User ID used to determine which sessions to search. */ 35 | userId?: string; 36 | } 37 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/UpdateSessionRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * { 10 | * metadata: { 11 | * "key": "value" 12 | * } 13 | * } 14 | */ 15 | export interface UpdateSessionRequest { 16 | /** 17 | * Optional instruction to use for fact rating. 18 | * Fact rating instructions can not be unset. 19 | */ 20 | factRatingInstruction?: Zep.FactRatingInstruction; 21 | /** Deprecated */ 22 | metadata: Record; 23 | } 24 | -------------------------------------------------------------------------------- /src/api/resources/memory/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { type CreateSessionRequest } from "./CreateSessionRequest"; 2 | export { type MemoryListSessionsRequest } from "./MemoryListSessionsRequest"; 3 | export { type EndSessionsRequest } from "./EndSessionsRequest"; 4 | export { type SessionSearchQuery } from "./SessionSearchQuery"; 5 | export { type UpdateSessionRequest } from "./UpdateSessionRequest"; 6 | export { type EndSessionRequest } from "./EndSessionRequest"; 7 | export { type ExtractDataRequest } from "./ExtractDataRequest"; 8 | export { type MemoryGetSessionFactsRequest } from "./MemoryGetSessionFactsRequest"; 9 | export { type AddFactsRequest } from "./AddFactsRequest"; 10 | export { type MemoryGetRequest } from "./MemoryGetRequest"; 11 | export { type AddMemoryRequest } from "./AddMemoryRequest"; 12 | export { type MemoryGetSessionMessagesRequest } from "./MemoryGetSessionMessagesRequest"; 13 | export { type ModelsMessageMetadataUpdate } from "./ModelsMessageMetadataUpdate"; 14 | export { type MemorySearchPayload } from "./MemorySearchPayload"; 15 | export { type MemorySynthesizeQuestionRequest } from "./MemorySynthesizeQuestionRequest"; 16 | -------------------------------------------------------------------------------- /src/api/resources/memory/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /src/api/resources/user/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/api/resources/user/client/requests/CreateUserRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * { 10 | * userId: "user_id" 11 | * } 12 | */ 13 | export interface CreateUserRequest { 14 | /** The email address of the user. */ 15 | email?: string; 16 | /** Optional instruction to use for fact rating. */ 17 | factRatingInstruction?: Zep.FactRatingInstruction; 18 | /** The first name of the user. */ 19 | firstName?: string; 20 | /** The last name of the user. */ 21 | lastName?: string; 22 | /** The metadata associated with the user. */ 23 | metadata?: Record; 24 | /** The unique identifier of the user. */ 25 | userId: string; 26 | } 27 | -------------------------------------------------------------------------------- /src/api/resources/user/client/requests/UpdateUserRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../../../../index"; 6 | 7 | /** 8 | * @example 9 | * {} 10 | */ 11 | export interface UpdateUserRequest { 12 | /** The email address of the user. */ 13 | email?: string; 14 | /** Optional instruction to use for fact rating. */ 15 | factRatingInstruction?: Zep.FactRatingInstruction; 16 | /** The first name of the user. */ 17 | firstName?: string; 18 | /** The last name of the user. */ 19 | lastName?: string; 20 | /** The metadata to update */ 21 | metadata?: Record; 22 | } 23 | -------------------------------------------------------------------------------- /src/api/resources/user/client/requests/UserListOrderedRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * @example 7 | * {} 8 | */ 9 | export interface UserListOrderedRequest { 10 | /** 11 | * Page number for pagination, starting from 1 12 | */ 13 | pageNumber?: number; 14 | /** 15 | * Number of users to retrieve per page 16 | */ 17 | pageSize?: number; 18 | } 19 | -------------------------------------------------------------------------------- /src/api/resources/user/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { type CreateUserRequest } from "./CreateUserRequest"; 2 | export { type UserListOrderedRequest } from "./UserListOrderedRequest"; 3 | export { type UpdateUserRequest } from "./UpdateUserRequest"; 4 | -------------------------------------------------------------------------------- /src/api/resources/user/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /src/api/types/AddMemoryResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface AddMemoryResponse { 6 | context?: string; 7 | } 8 | -------------------------------------------------------------------------------- /src/api/types/AddTripleResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface AddTripleResponse { 8 | edge?: Zep.EntityEdge; 9 | sourceNode?: Zep.EntityNode; 10 | targetNode?: Zep.EntityNode; 11 | } 12 | -------------------------------------------------------------------------------- /src/api/types/ApiError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface ApiError { 6 | message?: string; 7 | } 8 | -------------------------------------------------------------------------------- /src/api/types/ApidataDocument.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface ApidataDocument { 6 | content?: string; 7 | createdAt?: string; 8 | documentId?: string; 9 | embedding?: number[]; 10 | isEmbedded?: boolean; 11 | metadata?: Record; 12 | updatedAt?: string; 13 | uuid?: string; 14 | } 15 | -------------------------------------------------------------------------------- /src/api/types/ApidataDocumentCollection.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface ApidataDocumentCollection { 6 | createdAt?: string; 7 | description?: string; 8 | documentCount?: number; 9 | documentEmbeddedCount?: number; 10 | embeddingDimensions?: number; 11 | embeddingModelName?: string; 12 | isAutoEmbedded?: boolean; 13 | isIndexed?: boolean; 14 | isNormalized?: boolean; 15 | metadata?: Record; 16 | name?: string; 17 | updatedAt?: string; 18 | uuid?: string; 19 | } 20 | -------------------------------------------------------------------------------- /src/api/types/ApidataDocumentSearchResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface ApidataDocumentSearchResponse { 8 | currentPage?: number; 9 | queryVector?: number[]; 10 | resultCount?: number; 11 | results?: Zep.ApidataDocumentWithScore[]; 12 | totalPages?: number; 13 | } 14 | -------------------------------------------------------------------------------- /src/api/types/ApidataDocumentWithScore.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface ApidataDocumentWithScore { 6 | content?: string; 7 | createdAt?: string; 8 | documentId?: string; 9 | embedding?: number[]; 10 | isEmbedded?: boolean; 11 | metadata?: Record; 12 | score?: number; 13 | updatedAt?: string; 14 | uuid?: string; 15 | } 16 | -------------------------------------------------------------------------------- /src/api/types/ClassifySessionRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface ClassifySessionRequest { 6 | /** The classes to use for classification. */ 7 | classes: string[]; 8 | /** Custom instruction to use for classification. */ 9 | instruction?: string; 10 | /** The number of session messages to consider for classification. Defaults to 4. */ 11 | lastN?: number; 12 | /** The name of the classifier. */ 13 | name: string; 14 | /** Deprecated */ 15 | persist?: boolean; 16 | } 17 | -------------------------------------------------------------------------------- /src/api/types/CreateDocumentRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface CreateDocumentRequest { 6 | content: string; 7 | documentId?: string; 8 | metadata?: Record; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/types/EdgeType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface EdgeType { 8 | description: string; 9 | name: string; 10 | properties?: Zep.EntityProperty[]; 11 | sourceTargets?: Zep.EntityEdgeSourceTarget[]; 12 | } 13 | -------------------------------------------------------------------------------- /src/api/types/EndSessionResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface EndSessionResponse { 8 | classification?: Zep.SessionClassification; 9 | session?: Zep.Session; 10 | } 11 | -------------------------------------------------------------------------------- /src/api/types/EndSessionsResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface EndSessionsResponse { 8 | sessions?: Zep.Session[]; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/types/EntityEdge.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface EntityEdge { 6 | /** Additional attributes of the edge. Dependent on edge types */ 7 | attributes?: Record; 8 | /** Creation time of the edge */ 9 | createdAt: string; 10 | /** List of episode ids that reference these entity edges */ 11 | episodes?: string[]; 12 | /** Datetime of when the node was invalidated */ 13 | expiredAt?: string; 14 | /** Fact representing the edge and nodes that it connects */ 15 | fact: string; 16 | /** Datetime of when the fact stopped being true */ 17 | invalidAt?: string; 18 | /** Name of the edge, relation name */ 19 | name: string; 20 | /** UUID of the source node */ 21 | sourceNodeUuid: string; 22 | /** UUID of the target node */ 23 | targetNodeUuid: string; 24 | /** UUID of the edge */ 25 | uuid: string; 26 | /** Datetime of when the fact became true */ 27 | validAt?: string; 28 | } 29 | -------------------------------------------------------------------------------- /src/api/types/EntityEdgeSourceTarget.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface EntityEdgeSourceTarget { 6 | /** Source represents the originating node identifier in the edge type relationship. (optional) */ 7 | source?: string; 8 | /** Target represents the target node identifier in the edge type relationship. (optional) */ 9 | target?: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/api/types/EntityNode.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface EntityNode { 6 | /** Additional attributes of the node. Dependent on node labels */ 7 | attributes?: Record; 8 | /** Creation time of the node */ 9 | createdAt: string; 10 | /** Labels associated with the node */ 11 | labels?: string[]; 12 | /** Name of the node */ 13 | name: string; 14 | /** Regional summary of surrounding edges */ 15 | summary: string; 16 | /** UUID of the node */ 17 | uuid: string; 18 | } 19 | -------------------------------------------------------------------------------- /src/api/types/EntityProperty.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface EntityProperty { 8 | description: string; 9 | name: string; 10 | type: Zep.EntityPropertyType; 11 | } 12 | -------------------------------------------------------------------------------- /src/api/types/EntityPropertyType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export type EntityPropertyType = "Text" | "Int" | "Float" | "Boolean"; 6 | export const EntityPropertyType = { 7 | Text: "Text", 8 | Int: "Int", 9 | Float: "Float", 10 | Boolean: "Boolean", 11 | } as const; 12 | -------------------------------------------------------------------------------- /src/api/types/EntityType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface EntityType { 8 | description: string; 9 | name: string; 10 | properties?: Zep.EntityProperty[]; 11 | } 12 | -------------------------------------------------------------------------------- /src/api/types/EntityTypeResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface EntityTypeResponse { 8 | edgeTypes?: Zep.EdgeType[]; 9 | entityTypes?: Zep.EntityType[]; 10 | } 11 | -------------------------------------------------------------------------------- /src/api/types/Episode.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface Episode { 8 | content: string; 9 | createdAt: string; 10 | processed?: boolean; 11 | /** Optional role, will only be present if the episode was created using memory.add API */ 12 | role?: string; 13 | /** Optional role_type, will only be present if the episode was created using memory.add API */ 14 | roleType?: Zep.RoleType; 15 | /** Optional session ID. Will be present only if the episode corresponds to the messages added using memory.add API */ 16 | sessionId?: string; 17 | source?: Zep.GraphDataType; 18 | sourceDescription?: string; 19 | uuid: string; 20 | } 21 | -------------------------------------------------------------------------------- /src/api/types/EpisodeData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface EpisodeData { 8 | createdAt?: string; 9 | data: string; 10 | sourceDescription?: string; 11 | type: Zep.GraphDataType; 12 | } 13 | -------------------------------------------------------------------------------- /src/api/types/EpisodeMentions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface EpisodeMentions { 8 | edges?: Zep.EntityEdge[]; 9 | nodes?: Zep.EntityNode[]; 10 | } 11 | -------------------------------------------------------------------------------- /src/api/types/EpisodeResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface EpisodeResponse { 8 | episodes?: Zep.Episode[]; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/types/Fact.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface Fact { 6 | content: string; 7 | createdAt: string; 8 | expiredAt?: string; 9 | /** Deprecated */ 10 | fact: string; 11 | invalidAt?: string; 12 | name?: string; 13 | rating?: number; 14 | sourceNodeName?: string; 15 | targetNodeName?: string; 16 | uuid: string; 17 | validAt?: string; 18 | } 19 | -------------------------------------------------------------------------------- /src/api/types/FactRatingExamples.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface FactRatingExamples { 6 | high?: string; 7 | low?: string; 8 | medium?: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/types/FactRatingInstruction.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface FactRatingInstruction { 8 | /** 9 | * Examples is a list of examples that demonstrate how facts might be rated based on your instruction. You should provide 10 | * an example of a highly rated example, a low rated example, and a medium (or in between example). For example, if you are rating 11 | * based on relevance to a trip planning application, your examples might be: 12 | * High: "Joe's dream vacation is Bali" 13 | * Medium: "Joe has a fear of flying", 14 | * Low: "Joe's favorite food is Japanese", 15 | */ 16 | examples?: Zep.FactRatingExamples; 17 | /** 18 | * A string describing how to rate facts as they apply to your application. A trip planning application may 19 | * use something like "relevancy to planning a trip, the user's preferences when traveling, 20 | * or the user's travel history." 21 | */ 22 | instruction?: string; 23 | } 24 | -------------------------------------------------------------------------------- /src/api/types/FactResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface FactResponse { 8 | fact?: Zep.Fact; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/types/FactsResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface FactsResponse { 8 | facts?: Zep.Fact[]; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/types/GraphDataType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export type GraphDataType = "text" | "json" | "message"; 6 | export const GraphDataType = { 7 | Text: "text", 8 | Json: "json", 9 | Message: "message", 10 | } as const; 11 | -------------------------------------------------------------------------------- /src/api/types/GraphEdgesRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface GraphEdgesRequest { 6 | /** Maximum number of items to return */ 7 | limit?: number; 8 | /** UUID based cursor, used for pagination. Should be the UUID of the last item in the previous page */ 9 | uuidCursor?: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/api/types/GraphNodesRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface GraphNodesRequest { 6 | /** Maximum number of items to return */ 7 | limit?: number; 8 | /** UUID based cursor, used for pagination. Should be the UUID of the last item in the previous page */ 9 | uuidCursor?: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/api/types/GraphSearchResults.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface GraphSearchResults { 8 | edges?: Zep.EntityEdge[]; 9 | episodes?: Zep.Episode[]; 10 | nodes?: Zep.EntityNode[]; 11 | } 12 | -------------------------------------------------------------------------------- /src/api/types/GraphSearchScope.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export type GraphSearchScope = "edges" | "nodes" | "episodes"; 6 | export const GraphSearchScope = { 7 | Edges: "edges", 8 | Nodes: "nodes", 9 | Episodes: "episodes", 10 | } as const; 11 | -------------------------------------------------------------------------------- /src/api/types/Group.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface Group { 8 | createdAt?: string; 9 | description?: string; 10 | /** Deprecated */ 11 | externalId?: string; 12 | factRatingInstruction?: Zep.FactRatingInstruction; 13 | groupId?: string; 14 | id?: number; 15 | name?: string; 16 | projectUuid?: string; 17 | uuid?: string; 18 | } 19 | -------------------------------------------------------------------------------- /src/api/types/GroupListResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface GroupListResponse { 8 | groups?: Zep.Group[]; 9 | rowCount?: number; 10 | totalCount?: number; 11 | } 12 | -------------------------------------------------------------------------------- /src/api/types/Memory.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface Memory { 8 | /** Memory context containing relevant facts and entities for the session. Can be put into the prompt directly. */ 9 | context?: string; 10 | /** Deprecated: Use relevant_facts instead. */ 11 | facts?: string[]; 12 | /** A list of message objects, where each message contains a role and content. Only last_n messages will be returned */ 13 | messages?: Zep.Message[]; 14 | /** Deprecated */ 15 | metadata?: Record; 16 | /** Most relevant facts to the recent messages in the session. */ 17 | relevantFacts?: Zep.Fact[]; 18 | /** Deprecated: Use context string instead. */ 19 | summary?: Zep.Summary; 20 | } 21 | -------------------------------------------------------------------------------- /src/api/types/MemorySearchResult.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface MemorySearchResult { 8 | message?: Zep.Message; 9 | metadata?: Record; 10 | score?: number; 11 | summary?: Zep.Summary; 12 | } 13 | -------------------------------------------------------------------------------- /src/api/types/Message.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface Message { 8 | /** The content of the message. */ 9 | content: string; 10 | /** The timestamp of when the message was created. */ 11 | createdAt?: string; 12 | /** The metadata associated with the message. */ 13 | metadata?: Record; 14 | /** Whether the message has been processed. */ 15 | processed?: boolean; 16 | /** Customizable role of the sender of the message (e.g., "john", "sales_agent"). */ 17 | role?: string; 18 | /** The type of the role (e.g., "user", "system"). */ 19 | roleType: Zep.RoleType; 20 | /** Deprecated */ 21 | tokenCount?: number; 22 | /** Deprecated */ 23 | updatedAt?: string; 24 | /** The unique identifier of the message. */ 25 | uuid?: string; 26 | } 27 | -------------------------------------------------------------------------------- /src/api/types/MessageListResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface MessageListResponse { 8 | /** A list of message objects. */ 9 | messages?: Zep.Message[]; 10 | /** The number of messages returned. */ 11 | rowCount?: number; 12 | /** The total number of messages. */ 13 | totalCount?: number; 14 | } 15 | -------------------------------------------------------------------------------- /src/api/types/NewFact.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface NewFact { 6 | fact: string; 7 | } 8 | -------------------------------------------------------------------------------- /src/api/types/Question.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface Question { 6 | question?: string; 7 | } 8 | -------------------------------------------------------------------------------- /src/api/types/Reranker.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export type Reranker = "rrf" | "mmr" | "node_distance" | "episode_mentions" | "cross_encoder"; 6 | export const Reranker = { 7 | Rrf: "rrf", 8 | Mmr: "mmr", 9 | NodeDistance: "node_distance", 10 | EpisodeMentions: "episode_mentions", 11 | CrossEncoder: "cross_encoder", 12 | } as const; 13 | -------------------------------------------------------------------------------- /src/api/types/RoleType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export type RoleType = "norole" | "system" | "assistant" | "user" | "function" | "tool"; 6 | export const RoleType = { 7 | NoRole: "norole", 8 | SystemRole: "system", 9 | AssistantRole: "assistant", 10 | UserRole: "user", 11 | FunctionRole: "function", 12 | ToolRole: "tool", 13 | } as const; 14 | -------------------------------------------------------------------------------- /src/api/types/SearchFilters.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface SearchFilters { 6 | /** List of edge types to filter on */ 7 | edgeTypes?: string[]; 8 | /** List of node labels to filter on */ 9 | nodeLabels?: string[]; 10 | } 11 | -------------------------------------------------------------------------------- /src/api/types/SearchScope.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export type SearchScope = "messages" | "summary" | "facts"; 6 | export const SearchScope = { 7 | Messages: "messages", 8 | Summary: "summary", 9 | Facts: "facts", 10 | } as const; 11 | -------------------------------------------------------------------------------- /src/api/types/SearchType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export type SearchType = "similarity" | "mmr"; 6 | export const SearchType = { 7 | Similarity: "similarity", 8 | Mmr: "mmr", 9 | } as const; 10 | -------------------------------------------------------------------------------- /src/api/types/Session.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface Session { 8 | classifications?: Record; 9 | createdAt?: string; 10 | deletedAt?: string; 11 | endedAt?: string; 12 | /** Deprecated */ 13 | factRatingInstruction?: Zep.FactRatingInstruction; 14 | /** Deprecated */ 15 | facts?: string[]; 16 | id?: number; 17 | /** Deprecated */ 18 | metadata?: Record; 19 | projectUuid?: string; 20 | sessionId?: string; 21 | /** Deprecated */ 22 | updatedAt?: string; 23 | userId?: string; 24 | uuid?: string; 25 | } 26 | -------------------------------------------------------------------------------- /src/api/types/SessionClassification.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface SessionClassification { 6 | class?: string; 7 | label?: string; 8 | } 9 | -------------------------------------------------------------------------------- /src/api/types/SessionListResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface SessionListResponse { 8 | responseCount?: number; 9 | sessions?: Zep.Session[]; 10 | totalCount?: number; 11 | } 12 | -------------------------------------------------------------------------------- /src/api/types/SessionSearchResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface SessionSearchResponse { 8 | results?: Zep.SessionSearchResult[]; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/types/SessionSearchResult.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface SessionSearchResult { 8 | fact?: Zep.Fact; 9 | message?: Zep.Message; 10 | score?: number; 11 | sessionId?: string; 12 | summary?: Zep.Summary; 13 | } 14 | -------------------------------------------------------------------------------- /src/api/types/SuccessResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface SuccessResponse { 6 | message?: string; 7 | } 8 | -------------------------------------------------------------------------------- /src/api/types/Summary.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface Summary { 6 | /** The content of the summary. */ 7 | content?: string; 8 | /** The timestamp of when the summary was created. */ 9 | createdAt?: string; 10 | metadata?: Record; 11 | relatedMessageUuids?: string[]; 12 | /** The number of tokens in the summary. */ 13 | tokenCount?: number; 14 | /** The unique identifier of the summary. */ 15 | uuid?: string; 16 | } 17 | -------------------------------------------------------------------------------- /src/api/types/SummaryListResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface SummaryListResponse { 8 | rowCount?: number; 9 | summaries?: Zep.Summary[]; 10 | totalCount?: number; 11 | } 12 | -------------------------------------------------------------------------------- /src/api/types/UpdateDocumentListRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface UpdateDocumentListRequest { 6 | documentId?: string; 7 | metadata?: Record; 8 | uuid: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/types/User.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface User { 8 | createdAt?: string; 9 | deletedAt?: string; 10 | email?: string; 11 | factRatingInstruction?: Zep.FactRatingInstruction; 12 | firstName?: string; 13 | id?: number; 14 | lastName?: string; 15 | /** Deprecated */ 16 | metadata?: Record; 17 | projectUuid?: string; 18 | /** Deprecated */ 19 | sessionCount?: number; 20 | /** Deprecated */ 21 | updatedAt?: string; 22 | userId?: string; 23 | uuid?: string; 24 | } 25 | -------------------------------------------------------------------------------- /src/api/types/UserListResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface UserListResponse { 8 | rowCount?: number; 9 | totalCount?: number; 10 | users?: Zep.User[]; 11 | } 12 | -------------------------------------------------------------------------------- /src/api/types/UserNodeResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as Zep from "../index"; 6 | 7 | export interface UserNodeResponse { 8 | node?: Zep.EntityNode; 9 | } 10 | -------------------------------------------------------------------------------- /src/core/fetcher/APIResponse.ts: -------------------------------------------------------------------------------- 1 | export type APIResponse = SuccessfulResponse | FailedResponse; 2 | 3 | export interface SuccessfulResponse { 4 | ok: true; 5 | body: T; 6 | headers?: Record; 7 | } 8 | 9 | export interface FailedResponse { 10 | ok: false; 11 | error: T; 12 | } 13 | -------------------------------------------------------------------------------- /src/core/fetcher/Supplier.ts: -------------------------------------------------------------------------------- 1 | export type Supplier = T | Promise | (() => T | Promise); 2 | 3 | export const Supplier = { 4 | get: async (supplier: Supplier): Promise => { 5 | if (typeof supplier === "function") { 6 | return (supplier as () => T)(); 7 | } else { 8 | return supplier; 9 | } 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /src/core/fetcher/createRequestUrl.ts: -------------------------------------------------------------------------------- 1 | import qs from "qs"; 2 | 3 | export function createRequestUrl( 4 | baseUrl: string, 5 | queryParameters?: Record, 6 | ): string { 7 | return Object.keys(queryParameters ?? {}).length > 0 8 | ? `${baseUrl}?${qs.stringify(queryParameters, { arrayFormat: "repeat" })}` 9 | : baseUrl; 10 | } 11 | -------------------------------------------------------------------------------- /src/core/fetcher/getFetchFn.ts: -------------------------------------------------------------------------------- 1 | import { RUNTIME } from "../runtime"; 2 | 3 | /** 4 | * Returns a fetch function based on the runtime 5 | */ 6 | export async function getFetchFn(): Promise { 7 | // In Node.js 18+ environments, use native fetch 8 | if (RUNTIME.type === "node" && RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) { 9 | return fetch; 10 | } 11 | 12 | // In Node.js 18 or lower environments, the SDK always uses`node-fetch`. 13 | if (RUNTIME.type === "node") { 14 | return (await import("node-fetch")).default as any; 15 | } 16 | 17 | // Otherwise the SDK uses global fetch if available, 18 | // and falls back to node-fetch. 19 | if (typeof fetch == "function") { 20 | return fetch; 21 | } 22 | 23 | // Defaults to node `node-fetch` if global fetch isn't available 24 | return (await import("node-fetch")).default as any; 25 | } 26 | -------------------------------------------------------------------------------- /src/core/fetcher/getHeader.ts: -------------------------------------------------------------------------------- 1 | export function getHeader(headers: Record, header: string): string | undefined { 2 | for (const [headerKey, headerValue] of Object.entries(headers)) { 3 | if (headerKey.toLowerCase() === header.toLowerCase()) { 4 | return headerValue; 5 | } 6 | } 7 | return undefined; 8 | } 9 | -------------------------------------------------------------------------------- /src/core/fetcher/getRequestBody.ts: -------------------------------------------------------------------------------- 1 | export declare namespace GetRequestBody { 2 | interface Args { 3 | body: unknown; 4 | type: "json" | "file" | "bytes" | "other"; 5 | } 6 | } 7 | 8 | export async function getRequestBody({ body, type }: GetRequestBody.Args): Promise { 9 | if (type.includes("json")) { 10 | return JSON.stringify(body); 11 | } else { 12 | return body as BodyInit; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/core/fetcher/getResponseBody.ts: -------------------------------------------------------------------------------- 1 | import { chooseStreamWrapper } from "./stream-wrappers/chooseStreamWrapper"; 2 | 3 | export async function getResponseBody(response: Response, responseType?: string): Promise { 4 | if (response.body != null && responseType === "blob") { 5 | return await response.blob(); 6 | } else if (response.body != null && responseType === "arrayBuffer") { 7 | return await response.arrayBuffer(); 8 | } else if (response.body != null && responseType === "sse") { 9 | return response.body; 10 | } else if (response.body != null && responseType === "streaming") { 11 | return chooseStreamWrapper(response.body); 12 | } else if (response.body != null && responseType === "text") { 13 | return await response.text(); 14 | } else { 15 | const text = await response.text(); 16 | if (text.length > 0) { 17 | try { 18 | let responseBody = JSON.parse(text); 19 | return responseBody; 20 | } catch (err) { 21 | return { 22 | ok: false, 23 | error: { 24 | reason: "non-json", 25 | statusCode: response.status, 26 | rawBody: text, 27 | }, 28 | }; 29 | } 30 | } else { 31 | return undefined; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/core/fetcher/index.ts: -------------------------------------------------------------------------------- 1 | export type { APIResponse } from "./APIResponse"; 2 | export { fetcher } from "./Fetcher"; 3 | export type { Fetcher, FetchFunction } from "./Fetcher"; 4 | export { getHeader } from "./getHeader"; 5 | export { Supplier } from "./Supplier"; 6 | -------------------------------------------------------------------------------- /src/core/fetcher/makeRequest.ts: -------------------------------------------------------------------------------- 1 | import { anySignal, getTimeoutSignal } from "./signals"; 2 | 3 | export const makeRequest = async ( 4 | fetchFn: (url: string, init: RequestInit) => Promise, 5 | url: string, 6 | method: string, 7 | headers: Record, 8 | requestBody: BodyInit | undefined, 9 | timeoutMs?: number, 10 | abortSignal?: AbortSignal, 11 | withCredentials?: boolean, 12 | duplex?: "half", 13 | ): Promise => { 14 | const signals: AbortSignal[] = []; 15 | 16 | // Add timeout signal 17 | let timeoutAbortId: NodeJS.Timeout | undefined = undefined; 18 | if (timeoutMs != null) { 19 | const { signal, abortId } = getTimeoutSignal(timeoutMs); 20 | timeoutAbortId = abortId; 21 | signals.push(signal); 22 | } 23 | 24 | // Add arbitrary signal 25 | if (abortSignal != null) { 26 | signals.push(abortSignal); 27 | } 28 | let newSignals = anySignal(signals); 29 | const response = await fetchFn(url, { 30 | method: method, 31 | headers, 32 | body: requestBody, 33 | signal: newSignals, 34 | credentials: withCredentials ? "include" : undefined, 35 | // @ts-ignore 36 | duplex, 37 | }); 38 | 39 | if (timeoutAbortId != null) { 40 | clearTimeout(timeoutAbortId); 41 | } 42 | 43 | return response; 44 | }; 45 | -------------------------------------------------------------------------------- /src/core/fetcher/requestWithRetries.ts: -------------------------------------------------------------------------------- 1 | const INITIAL_RETRY_DELAY = 1000; // in milliseconds 2 | const MAX_RETRY_DELAY = 60000; // in milliseconds 3 | const DEFAULT_MAX_RETRIES = 2; 4 | const JITTER_FACTOR = 0.2; // 20% random jitter 5 | 6 | function addJitter(delay: number): number { 7 | // Generate a random value between -JITTER_FACTOR and +JITTER_FACTOR 8 | const jitterMultiplier = 1 + (Math.random() * 2 - 1) * JITTER_FACTOR; 9 | return delay * jitterMultiplier; 10 | } 11 | 12 | export async function requestWithRetries( 13 | requestFn: () => Promise, 14 | maxRetries: number = DEFAULT_MAX_RETRIES, 15 | ): Promise { 16 | let response: Response = await requestFn(); 17 | 18 | for (let i = 0; i < maxRetries; ++i) { 19 | if ([408, 409, 429].includes(response.status) || response.status >= 500) { 20 | // Calculate base delay using exponential backoff (in milliseconds) 21 | const baseDelay = Math.min(INITIAL_RETRY_DELAY * Math.pow(2, i), MAX_RETRY_DELAY); 22 | 23 | // Add jitter to the delay 24 | const delayWithJitter = addJitter(baseDelay); 25 | 26 | await new Promise((resolve) => setTimeout(resolve, delayWithJitter)); 27 | response = await requestFn(); 28 | } else { 29 | break; 30 | } 31 | } 32 | return response!; 33 | } 34 | -------------------------------------------------------------------------------- /src/core/fetcher/signals.ts: -------------------------------------------------------------------------------- 1 | const TIMEOUT = "timeout"; 2 | 3 | export function getTimeoutSignal(timeoutMs: number): { signal: AbortSignal; abortId: NodeJS.Timeout } { 4 | const controller = new AbortController(); 5 | const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs); 6 | return { signal: controller.signal, abortId }; 7 | } 8 | 9 | /** 10 | * Returns an abort signal that is getting aborted when 11 | * at least one of the specified abort signals is aborted. 12 | * 13 | * Requires at least node.js 18. 14 | */ 15 | export function anySignal(...args: AbortSignal[] | [AbortSignal[]]): AbortSignal { 16 | // Allowing signals to be passed either as array 17 | // of signals or as multiple arguments. 18 | const signals = (args.length === 1 && Array.isArray(args[0]) ? args[0] : args) as AbortSignal[]; 19 | 20 | const controller = new AbortController(); 21 | 22 | for (const signal of signals) { 23 | if (signal.aborted) { 24 | // Exiting early if one of the signals 25 | // is already aborted. 26 | controller.abort((signal as any)?.reason); 27 | break; 28 | } 29 | 30 | // Listening for signals and removing the listeners 31 | // when at least one symbol is aborted. 32 | signal.addEventListener("abort", () => controller.abort((signal as any)?.reason), { 33 | signal: controller.signal, 34 | }); 35 | } 36 | 37 | return controller.signal; 38 | } 39 | -------------------------------------------------------------------------------- /src/core/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./fetcher"; 2 | export * from "./runtime"; 3 | export * as serialization from "./schemas"; 4 | -------------------------------------------------------------------------------- /src/core/runtime/index.ts: -------------------------------------------------------------------------------- 1 | export { RUNTIME } from "./runtime"; 2 | -------------------------------------------------------------------------------- /src/core/schemas/builders/bigint/index.ts: -------------------------------------------------------------------------------- 1 | export { bigint } from "./bigint"; 2 | -------------------------------------------------------------------------------- /src/core/schemas/builders/date/index.ts: -------------------------------------------------------------------------------- 1 | export { date } from "./date"; 2 | -------------------------------------------------------------------------------- /src/core/schemas/builders/enum/index.ts: -------------------------------------------------------------------------------- 1 | export { enum_ } from "./enum"; 2 | -------------------------------------------------------------------------------- /src/core/schemas/builders/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./bigint"; 2 | export * from "./date"; 3 | export * from "./enum"; 4 | export * from "./lazy"; 5 | export * from "./list"; 6 | export * from "./literals"; 7 | export * from "./object"; 8 | export * from "./object-like"; 9 | export * from "./primitives"; 10 | export * from "./record"; 11 | export * from "./schema-utils"; 12 | export * from "./set"; 13 | export * from "./undiscriminated-union"; 14 | export * from "./union"; 15 | -------------------------------------------------------------------------------- /src/core/schemas/builders/lazy/index.ts: -------------------------------------------------------------------------------- 1 | export { lazy } from "./lazy"; 2 | export type { SchemaGetter } from "./lazy"; 3 | export { lazyObject } from "./lazyObject"; 4 | -------------------------------------------------------------------------------- /src/core/schemas/builders/lazy/lazy.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema, Schema } from "../../Schema"; 2 | import { getSchemaUtils } from "../schema-utils"; 3 | 4 | export type SchemaGetter> = () => SchemaType; 5 | 6 | export function lazy(getter: SchemaGetter>): Schema { 7 | const baseSchema = constructLazyBaseSchema(getter); 8 | return { 9 | ...baseSchema, 10 | ...getSchemaUtils(baseSchema), 11 | }; 12 | } 13 | 14 | export function constructLazyBaseSchema( 15 | getter: SchemaGetter>, 16 | ): BaseSchema { 17 | return { 18 | parse: (raw, opts) => getMemoizedSchema(getter).parse(raw, opts), 19 | json: (parsed, opts) => getMemoizedSchema(getter).json(parsed, opts), 20 | getType: () => getMemoizedSchema(getter).getType(), 21 | }; 22 | } 23 | 24 | type MemoizedGetter> = SchemaGetter & { __zurg_memoized?: SchemaType }; 25 | 26 | export function getMemoizedSchema>(getter: SchemaGetter): SchemaType { 27 | const castedGetter = getter as MemoizedGetter; 28 | if (castedGetter.__zurg_memoized == null) { 29 | castedGetter.__zurg_memoized = getter(); 30 | } 31 | return castedGetter.__zurg_memoized; 32 | } 33 | -------------------------------------------------------------------------------- /src/core/schemas/builders/lazy/lazyObject.ts: -------------------------------------------------------------------------------- 1 | import { getObjectUtils } from "../object"; 2 | import { getObjectLikeUtils } from "../object-like"; 3 | import { BaseObjectSchema, ObjectSchema } from "../object/types"; 4 | import { getSchemaUtils } from "../schema-utils"; 5 | import { SchemaGetter, constructLazyBaseSchema, getMemoizedSchema } from "./lazy"; 6 | 7 | export function lazyObject(getter: SchemaGetter>): ObjectSchema { 8 | const baseSchema: BaseObjectSchema = { 9 | ...constructLazyBaseSchema(getter), 10 | _getRawProperties: () => getMemoizedSchema(getter)._getRawProperties(), 11 | _getParsedProperties: () => getMemoizedSchema(getter)._getParsedProperties(), 12 | }; 13 | 14 | return { 15 | ...baseSchema, 16 | ...getSchemaUtils(baseSchema), 17 | ...getObjectLikeUtils(baseSchema), 18 | ...getObjectUtils(baseSchema), 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /src/core/schemas/builders/list/index.ts: -------------------------------------------------------------------------------- 1 | export { list } from "./list"; 2 | -------------------------------------------------------------------------------- /src/core/schemas/builders/literals/booleanLiteral.ts: -------------------------------------------------------------------------------- 1 | import { Schema, SchemaType } from "../../Schema"; 2 | import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; 3 | import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; 4 | 5 | export function booleanLiteral(literal: V): Schema { 6 | const schemaCreator = createIdentitySchemaCreator( 7 | SchemaType.BOOLEAN_LITERAL, 8 | (value, { breadcrumbsPrefix = [] } = {}) => { 9 | if (value === literal) { 10 | return { 11 | ok: true, 12 | value: literal, 13 | }; 14 | } else { 15 | return { 16 | ok: false, 17 | errors: [ 18 | { 19 | path: breadcrumbsPrefix, 20 | message: getErrorMessageForIncorrectType(value, `${literal.toString()}`), 21 | }, 22 | ], 23 | }; 24 | } 25 | }, 26 | ); 27 | 28 | return schemaCreator(); 29 | } 30 | -------------------------------------------------------------------------------- /src/core/schemas/builders/literals/index.ts: -------------------------------------------------------------------------------- 1 | export { stringLiteral } from "./stringLiteral"; 2 | export { booleanLiteral } from "./booleanLiteral"; 3 | -------------------------------------------------------------------------------- /src/core/schemas/builders/literals/stringLiteral.ts: -------------------------------------------------------------------------------- 1 | import { Schema, SchemaType } from "../../Schema"; 2 | import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; 3 | import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; 4 | 5 | export function stringLiteral(literal: V): Schema { 6 | const schemaCreator = createIdentitySchemaCreator( 7 | SchemaType.STRING_LITERAL, 8 | (value, { breadcrumbsPrefix = [] } = {}) => { 9 | if (value === literal) { 10 | return { 11 | ok: true, 12 | value: literal, 13 | }; 14 | } else { 15 | return { 16 | ok: false, 17 | errors: [ 18 | { 19 | path: breadcrumbsPrefix, 20 | message: getErrorMessageForIncorrectType(value, `"${literal}"`), 21 | }, 22 | ], 23 | }; 24 | } 25 | }, 26 | ); 27 | 28 | return schemaCreator(); 29 | } 30 | -------------------------------------------------------------------------------- /src/core/schemas/builders/object-like/index.ts: -------------------------------------------------------------------------------- 1 | export { getObjectLikeUtils, withParsedProperties } from "./getObjectLikeUtils"; 2 | export type { ObjectLikeSchema, ObjectLikeUtils } from "./types"; 3 | -------------------------------------------------------------------------------- /src/core/schemas/builders/object-like/types.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema, Schema } from "../../Schema"; 2 | 3 | export type ObjectLikeSchema = Schema & 4 | BaseSchema & 5 | ObjectLikeUtils; 6 | 7 | export interface ObjectLikeUtils { 8 | withParsedProperties: >(properties: { 9 | [K in keyof T]: T[K] | ((parsed: Parsed) => T[K]); 10 | }) => ObjectLikeSchema; 11 | } 12 | -------------------------------------------------------------------------------- /src/core/schemas/builders/object/index.ts: -------------------------------------------------------------------------------- 1 | export { getObjectUtils, object } from "./object"; 2 | export { objectWithoutOptionalProperties } from "./objectWithoutOptionalProperties"; 3 | export type { 4 | inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas, 5 | inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas, 6 | } from "./objectWithoutOptionalProperties"; 7 | export { isProperty, property } from "./property"; 8 | export type { Property } from "./property"; 9 | export type { 10 | BaseObjectSchema, 11 | inferObjectSchemaFromPropertySchemas, 12 | inferParsedObject, 13 | inferParsedObjectFromPropertySchemas, 14 | inferParsedPropertySchema, 15 | inferRawKey, 16 | inferRawObject, 17 | inferRawObjectFromPropertySchemas, 18 | inferRawPropertySchema, 19 | ObjectSchema, 20 | ObjectUtils, 21 | PropertySchemas, 22 | } from "./types"; 23 | -------------------------------------------------------------------------------- /src/core/schemas/builders/object/objectWithoutOptionalProperties.ts: -------------------------------------------------------------------------------- 1 | import { object } from "./object"; 2 | import { ObjectSchema, PropertySchemas, inferParsedPropertySchema, inferRawObjectFromPropertySchemas } from "./types"; 3 | 4 | export function objectWithoutOptionalProperties>( 5 | schemas: T, 6 | ): inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas { 7 | return object(schemas) as unknown as inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas; 8 | } 9 | 10 | export type inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas> = 11 | ObjectSchema< 12 | inferRawObjectFromPropertySchemas, 13 | inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas 14 | >; 15 | 16 | export type inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas> = { 17 | [K in keyof T]: inferParsedPropertySchema; 18 | }; 19 | -------------------------------------------------------------------------------- /src/core/schemas/builders/object/property.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from "../../Schema"; 2 | 3 | export function property( 4 | rawKey: RawKey, 5 | valueSchema: Schema, 6 | ): Property { 7 | return { 8 | rawKey, 9 | valueSchema, 10 | isProperty: true, 11 | }; 12 | } 13 | 14 | export interface Property { 15 | rawKey: RawKey; 16 | valueSchema: Schema; 17 | isProperty: true; 18 | } 19 | 20 | export function isProperty>(maybeProperty: unknown): maybeProperty is O { 21 | // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition 22 | return (maybeProperty as O).isProperty; 23 | } 24 | -------------------------------------------------------------------------------- /src/core/schemas/builders/primitives/any.ts: -------------------------------------------------------------------------------- 1 | import { SchemaType } from "../../Schema"; 2 | import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; 3 | 4 | export const any = createIdentitySchemaCreator(SchemaType.ANY, (value) => ({ ok: true, value })); 5 | -------------------------------------------------------------------------------- /src/core/schemas/builders/primitives/boolean.ts: -------------------------------------------------------------------------------- 1 | import { SchemaType } from "../../Schema"; 2 | import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; 3 | import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; 4 | 5 | export const boolean = createIdentitySchemaCreator( 6 | SchemaType.BOOLEAN, 7 | (value, { breadcrumbsPrefix = [] } = {}) => { 8 | if (typeof value === "boolean") { 9 | return { 10 | ok: true, 11 | value, 12 | }; 13 | } else { 14 | return { 15 | ok: false, 16 | errors: [ 17 | { 18 | path: breadcrumbsPrefix, 19 | message: getErrorMessageForIncorrectType(value, "boolean"), 20 | }, 21 | ], 22 | }; 23 | } 24 | }, 25 | ); 26 | -------------------------------------------------------------------------------- /src/core/schemas/builders/primitives/index.ts: -------------------------------------------------------------------------------- 1 | export { any } from "./any"; 2 | export { boolean } from "./boolean"; 3 | export { number } from "./number"; 4 | export { string } from "./string"; 5 | export { unknown } from "./unknown"; 6 | -------------------------------------------------------------------------------- /src/core/schemas/builders/primitives/number.ts: -------------------------------------------------------------------------------- 1 | import { SchemaType } from "../../Schema"; 2 | import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; 3 | import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; 4 | 5 | export const number = createIdentitySchemaCreator( 6 | SchemaType.NUMBER, 7 | (value, { breadcrumbsPrefix = [] } = {}) => { 8 | if (typeof value === "number") { 9 | return { 10 | ok: true, 11 | value, 12 | }; 13 | } else { 14 | return { 15 | ok: false, 16 | errors: [ 17 | { 18 | path: breadcrumbsPrefix, 19 | message: getErrorMessageForIncorrectType(value, "number"), 20 | }, 21 | ], 22 | }; 23 | } 24 | }, 25 | ); 26 | -------------------------------------------------------------------------------- /src/core/schemas/builders/primitives/string.ts: -------------------------------------------------------------------------------- 1 | import { SchemaType } from "../../Schema"; 2 | import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; 3 | import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; 4 | 5 | export const string = createIdentitySchemaCreator( 6 | SchemaType.STRING, 7 | (value, { breadcrumbsPrefix = [] } = {}) => { 8 | if (typeof value === "string") { 9 | return { 10 | ok: true, 11 | value, 12 | }; 13 | } else { 14 | return { 15 | ok: false, 16 | errors: [ 17 | { 18 | path: breadcrumbsPrefix, 19 | message: getErrorMessageForIncorrectType(value, "string"), 20 | }, 21 | ], 22 | }; 23 | } 24 | }, 25 | ); 26 | -------------------------------------------------------------------------------- /src/core/schemas/builders/primitives/unknown.ts: -------------------------------------------------------------------------------- 1 | import { SchemaType } from "../../Schema"; 2 | import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; 3 | 4 | export const unknown = createIdentitySchemaCreator(SchemaType.UNKNOWN, (value) => ({ ok: true, value })); 5 | -------------------------------------------------------------------------------- /src/core/schemas/builders/record/index.ts: -------------------------------------------------------------------------------- 1 | export { record } from "./record"; 2 | export type { BaseRecordSchema, RecordSchema } from "./types"; 3 | -------------------------------------------------------------------------------- /src/core/schemas/builders/record/types.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema } from "../../Schema"; 2 | import { SchemaUtils } from "../schema-utils"; 3 | 4 | export type RecordSchema< 5 | RawKey extends string | number, 6 | RawValue, 7 | ParsedKey extends string | number, 8 | ParsedValue, 9 | > = BaseRecordSchema & 10 | SchemaUtils, Record>; 11 | 12 | export type BaseRecordSchema< 13 | RawKey extends string | number, 14 | RawValue, 15 | ParsedKey extends string | number, 16 | ParsedValue, 17 | > = BaseSchema, Record>; 18 | -------------------------------------------------------------------------------- /src/core/schemas/builders/schema-utils/JsonError.ts: -------------------------------------------------------------------------------- 1 | import { ValidationError } from "../../Schema"; 2 | import { stringifyValidationError } from "./stringifyValidationErrors"; 3 | 4 | export class JsonError extends Error { 5 | constructor(public readonly errors: ValidationError[]) { 6 | super(errors.map(stringifyValidationError).join("; ")); 7 | Object.setPrototypeOf(this, JsonError.prototype); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/core/schemas/builders/schema-utils/ParseError.ts: -------------------------------------------------------------------------------- 1 | import { ValidationError } from "../../Schema"; 2 | import { stringifyValidationError } from "./stringifyValidationErrors"; 3 | 4 | export class ParseError extends Error { 5 | constructor(public readonly errors: ValidationError[]) { 6 | super(errors.map(stringifyValidationError).join("; ")); 7 | Object.setPrototypeOf(this, ParseError.prototype); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/core/schemas/builders/schema-utils/index.ts: -------------------------------------------------------------------------------- 1 | export { getSchemaUtils, optional, transform } from "./getSchemaUtils"; 2 | export type { SchemaUtils } from "./getSchemaUtils"; 3 | export { JsonError } from "./JsonError"; 4 | export { ParseError } from "./ParseError"; 5 | -------------------------------------------------------------------------------- /src/core/schemas/builders/schema-utils/stringifyValidationErrors.ts: -------------------------------------------------------------------------------- 1 | import { ValidationError } from "../../Schema"; 2 | 3 | export function stringifyValidationError(error: ValidationError): string { 4 | if (error.path.length === 0) { 5 | return error.message; 6 | } 7 | return `${error.path.join(" -> ")}: ${error.message}`; 8 | } 9 | -------------------------------------------------------------------------------- /src/core/schemas/builders/set/index.ts: -------------------------------------------------------------------------------- 1 | export { set } from "./set"; 2 | -------------------------------------------------------------------------------- /src/core/schemas/builders/undiscriminated-union/index.ts: -------------------------------------------------------------------------------- 1 | export type { 2 | inferParsedUnidiscriminatedUnionSchema, 3 | inferRawUnidiscriminatedUnionSchema, 4 | UndiscriminatedUnionSchema, 5 | } from "./types"; 6 | export { undiscriminatedUnion } from "./undiscriminatedUnion"; 7 | -------------------------------------------------------------------------------- /src/core/schemas/builders/undiscriminated-union/types.ts: -------------------------------------------------------------------------------- 1 | import { Schema, inferParsed, inferRaw } from "../../Schema"; 2 | 3 | export type UndiscriminatedUnionSchema = Schema< 4 | inferRawUnidiscriminatedUnionSchema, 5 | inferParsedUnidiscriminatedUnionSchema 6 | >; 7 | 8 | export type inferRawUnidiscriminatedUnionSchema = inferRaw; 9 | 10 | export type inferParsedUnidiscriminatedUnionSchema = inferParsed; 11 | -------------------------------------------------------------------------------- /src/core/schemas/builders/union/discriminant.ts: -------------------------------------------------------------------------------- 1 | export function discriminant( 2 | parsedDiscriminant: ParsedDiscriminant, 3 | rawDiscriminant: RawDiscriminant, 4 | ): Discriminant { 5 | return { 6 | parsedDiscriminant, 7 | rawDiscriminant, 8 | }; 9 | } 10 | 11 | export interface Discriminant { 12 | parsedDiscriminant: ParsedDiscriminant; 13 | rawDiscriminant: RawDiscriminant; 14 | } 15 | -------------------------------------------------------------------------------- /src/core/schemas/builders/union/index.ts: -------------------------------------------------------------------------------- 1 | export { discriminant } from "./discriminant"; 2 | export type { Discriminant } from "./discriminant"; 3 | export type { 4 | inferParsedDiscriminant, 5 | inferParsedUnion, 6 | inferRawDiscriminant, 7 | inferRawUnion, 8 | UnionSubtypes, 9 | } from "./types"; 10 | export { union } from "./union"; 11 | -------------------------------------------------------------------------------- /src/core/schemas/builders/union/types.ts: -------------------------------------------------------------------------------- 1 | import { ObjectSchema, inferParsedObject, inferRawObject } from "../object"; 2 | import { Discriminant } from "./discriminant"; 3 | 4 | export type UnionSubtypes = { 5 | [K in DiscriminantValues]: ObjectSchema; 6 | }; 7 | 8 | export type inferRawUnion, U extends UnionSubtypes> = { 9 | [K in keyof U]: Record, K> & inferRawObject; 10 | }[keyof U]; 11 | 12 | export type inferParsedUnion, U extends UnionSubtypes> = { 13 | [K in keyof U]: Record, K> & inferParsedObject; 14 | }[keyof U]; 15 | 16 | export type inferRawDiscriminant> = D extends string 17 | ? D 18 | : D extends Discriminant 19 | ? Raw 20 | : never; 21 | 22 | export type inferParsedDiscriminant> = D extends string 23 | ? D 24 | : D extends Discriminant 25 | ? Parsed 26 | : never; 27 | -------------------------------------------------------------------------------- /src/core/schemas/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./builders"; 2 | export type { inferParsed, inferRaw, Schema, SchemaOptions } from "./Schema"; 3 | -------------------------------------------------------------------------------- /src/core/schemas/utils/MaybePromise.ts: -------------------------------------------------------------------------------- 1 | export type MaybePromise = T | Promise; 2 | -------------------------------------------------------------------------------- /src/core/schemas/utils/addQuestionMarksToNullableProperties.ts: -------------------------------------------------------------------------------- 1 | export type addQuestionMarksToNullableProperties = { 2 | [K in OptionalKeys]?: T[K]; 3 | } & Pick>; 4 | 5 | export type OptionalKeys = { 6 | [K in keyof T]-?: undefined extends T[K] 7 | ? K 8 | : null extends T[K] 9 | ? K 10 | : 1 extends (any extends T[K] ? 0 : 1) 11 | ? never 12 | : K; 13 | }[keyof T]; 14 | 15 | export type RequiredKeys = Exclude>; 16 | -------------------------------------------------------------------------------- /src/core/schemas/utils/createIdentitySchemaCreator.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema, MaybeValid, Schema, SchemaOptions, SchemaType } from "../Schema"; 2 | import { getSchemaUtils } from "../builders/schema-utils"; 3 | import { maybeSkipValidation } from "./maybeSkipValidation"; 4 | 5 | export function createIdentitySchemaCreator( 6 | schemaType: SchemaType, 7 | validate: (value: unknown, opts?: SchemaOptions) => MaybeValid, 8 | ): () => Schema { 9 | return () => { 10 | const baseSchema: BaseSchema = { 11 | parse: validate, 12 | json: validate, 13 | getType: () => schemaType, 14 | }; 15 | 16 | return { 17 | ...maybeSkipValidation(baseSchema), 18 | ...getSchemaUtils(baseSchema), 19 | }; 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /src/core/schemas/utils/entries.ts: -------------------------------------------------------------------------------- 1 | export function entries(object: T): [keyof T, T[keyof T]][] { 2 | return Object.entries(object) as [keyof T, T[keyof T]][]; 3 | } 4 | -------------------------------------------------------------------------------- /src/core/schemas/utils/filterObject.ts: -------------------------------------------------------------------------------- 1 | export function filterObject(obj: T, keysToInclude: K[]): Pick { 2 | const keysToIncludeSet = new Set(keysToInclude); 3 | return Object.entries(obj).reduce( 4 | (acc, [key, value]) => { 5 | if (keysToIncludeSet.has(key as K)) { 6 | acc[key as K] = value as T[K]; 7 | } 8 | return acc; 9 | // eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter 10 | }, 11 | {} as Pick, 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /src/core/schemas/utils/getErrorMessageForIncorrectType.ts: -------------------------------------------------------------------------------- 1 | export function getErrorMessageForIncorrectType(value: unknown, expectedType: string): string { 2 | return `Expected ${expectedType}. Received ${getTypeAsString(value)}.`; 3 | } 4 | 5 | function getTypeAsString(value: unknown): string { 6 | if (Array.isArray(value)) { 7 | return "list"; 8 | } 9 | if (value === null) { 10 | return "null"; 11 | } 12 | if (value instanceof BigInt) { 13 | return "BigInt"; 14 | } 15 | switch (typeof value) { 16 | case "string": 17 | return `"${value}"`; 18 | case "bigint": 19 | case "number": 20 | case "boolean": 21 | case "undefined": 22 | return `${value}`; 23 | } 24 | return typeof value; 25 | } 26 | -------------------------------------------------------------------------------- /src/core/schemas/utils/isPlainObject.ts: -------------------------------------------------------------------------------- 1 | // borrowed from https://github.com/lodash/lodash/blob/master/isPlainObject.js 2 | export function isPlainObject(value: unknown): value is Record { 3 | if (typeof value !== "object" || value === null) { 4 | return false; 5 | } 6 | 7 | if (Object.getPrototypeOf(value) === null) { 8 | return true; 9 | } 10 | 11 | let proto = value; 12 | while (Object.getPrototypeOf(proto) !== null) { 13 | proto = Object.getPrototypeOf(proto); 14 | } 15 | 16 | return Object.getPrototypeOf(value) === proto; 17 | } 18 | -------------------------------------------------------------------------------- /src/core/schemas/utils/keys.ts: -------------------------------------------------------------------------------- 1 | export function keys(object: T): (keyof T)[] { 2 | return Object.keys(object) as (keyof T)[]; 3 | } 4 | -------------------------------------------------------------------------------- /src/core/schemas/utils/maybeSkipValidation.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema, MaybeValid, SchemaOptions } from "../Schema"; 2 | 3 | export function maybeSkipValidation, Raw, Parsed>(schema: S): S { 4 | return { 5 | ...schema, 6 | json: transformAndMaybeSkipValidation(schema.json), 7 | parse: transformAndMaybeSkipValidation(schema.parse), 8 | }; 9 | } 10 | 11 | function transformAndMaybeSkipValidation( 12 | transform: (value: unknown, opts?: SchemaOptions) => MaybeValid, 13 | ): (value: unknown, opts?: SchemaOptions) => MaybeValid { 14 | return (value, opts): MaybeValid => { 15 | const transformed = transform(value, opts); 16 | const { skipValidation = false } = opts ?? {}; 17 | if (!transformed.ok && skipValidation) { 18 | // eslint-disable-next-line no-console 19 | console.warn( 20 | [ 21 | "Failed to validate.", 22 | ...transformed.errors.map( 23 | (error) => 24 | " - " + 25 | (error.path.length > 0 ? `${error.path.join(".")}: ${error.message}` : error.message), 26 | ), 27 | ].join("\n"), 28 | ); 29 | 30 | return { 31 | ok: true, 32 | value: value as T, 33 | }; 34 | } else { 35 | return transformed; 36 | } 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /src/core/schemas/utils/partition.ts: -------------------------------------------------------------------------------- 1 | export function partition(items: readonly T[], predicate: (item: T) => boolean): [T[], T[]] { 2 | const trueItems: T[] = [], 3 | falseItems: T[] = []; 4 | for (const item of items) { 5 | if (predicate(item)) { 6 | trueItems.push(item); 7 | } else { 8 | falseItems.push(item); 9 | } 10 | } 11 | return [trueItems, falseItems]; 12 | } 13 | -------------------------------------------------------------------------------- /src/environments.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export const ZepEnvironment = { 6 | Default: "https://api.getzep.com/api/v2", 7 | } as const; 8 | 9 | export type ZepEnvironment = typeof ZepEnvironment.Default; 10 | -------------------------------------------------------------------------------- /src/errors/ZepError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export class ZepError extends Error { 6 | readonly statusCode?: number; 7 | readonly body?: unknown; 8 | 9 | constructor({ message, statusCode, body }: { message?: string; statusCode?: number; body?: unknown }) { 10 | super(buildMessage({ message, statusCode, body })); 11 | Object.setPrototypeOf(this, ZepError.prototype); 12 | if (statusCode != null) { 13 | this.statusCode = statusCode; 14 | } 15 | 16 | if (body !== undefined) { 17 | this.body = body; 18 | } 19 | } 20 | } 21 | 22 | function buildMessage({ 23 | message, 24 | statusCode, 25 | body, 26 | }: { 27 | message: string | undefined; 28 | statusCode: number | undefined; 29 | body: unknown | undefined; 30 | }): string { 31 | let lines: string[] = []; 32 | if (message != null) { 33 | lines.push(message); 34 | } 35 | 36 | if (statusCode != null) { 37 | lines.push(`Status code: ${statusCode.toString()}`); 38 | } 39 | 40 | if (body != null) { 41 | lines.push(`Body: ${JSON.stringify(body, undefined, 2)}`); 42 | } 43 | 44 | return lines.join("\n"); 45 | } 46 | -------------------------------------------------------------------------------- /src/errors/ZepTimeoutError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export class ZepTimeoutError extends Error { 6 | constructor(message: string) { 7 | super(message); 8 | Object.setPrototypeOf(this, ZepTimeoutError.prototype); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/errors/index.ts: -------------------------------------------------------------------------------- 1 | export { ZepError } from "./ZepError"; 2 | export { ZepTimeoutError } from "./ZepTimeoutError"; 3 | -------------------------------------------------------------------------------- /src/extractor/base.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | 3 | export enum ZepDataType { 4 | ZepText = "ZepText", 5 | ZepZipCode = "ZepZipCode", 6 | ZepDate = "ZepDate", 7 | ZepDateTime = "ZepDateTime", 8 | ZepEmail = "ZepEmail", 9 | ZepPhoneNumber = "ZepPhoneNumber", 10 | ZepFloat = "ZepFloat", 11 | ZepNumber = "ZepNumber", 12 | ZepRegex = "ZepRegex", 13 | } 14 | 15 | export const BaseSchema = z.object({ 16 | zep_type: z.nativeEnum(ZepDataType), 17 | description: z.string(), 18 | }); 19 | -------------------------------------------------------------------------------- /src/extractor/date.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | import { BaseSchema, ZepDataType } from "./base"; 3 | import { HasOptionalValue } from "./index"; 4 | 5 | const stringToDateTransformer = z.union([z.string(), z.date()]).transform((value, ctx) => { 6 | if (typeof value === "string") { 7 | return new Date(value); 8 | } 9 | return value; 10 | }); 11 | 12 | export const ZepDateSchema = BaseSchema.extend({ 13 | zep_type: z.union([z.literal(ZepDataType.ZepDate), z.literal(ZepDataType.ZepDateTime)]), 14 | value: stringToDateTransformer.optional(), 15 | }); 16 | 17 | export interface ZepDateField extends HasOptionalValue { 18 | zep_type: ZepDataType.ZepDate | ZepDataType.ZepDateTime; 19 | description: string; 20 | } 21 | 22 | export const zepDateField = (description: string): ZepDateField => { 23 | return ZepDateSchema.parse({ 24 | zep_type: ZepDataType.ZepDate, 25 | description, 26 | }); 27 | }; 28 | 29 | export const zepDateTimeField = (description: string): ZepDateField => { 30 | return ZepDateSchema.parse({ 31 | zep_type: ZepDataType.ZepDateTime, 32 | description, 33 | }); 34 | }; 35 | -------------------------------------------------------------------------------- /src/extractor/number.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | import { BaseSchema, ZepDataType } from "./base"; 3 | import { HasOptionalValue } from "./index"; 4 | 5 | const stringToNumberTransformer = z.union([z.string(), z.number()]).transform((value, ctx) => { 6 | if (typeof value === "string") { 7 | const parsed = parseFloat(value); 8 | if (isNaN(parsed)) { 9 | ctx.addIssue({ 10 | code: z.ZodIssueCode.custom, 11 | message: "Not a number", 12 | }); 13 | } 14 | return parsed; 15 | } 16 | return value; 17 | }); 18 | 19 | export const ZepNumberSchema = BaseSchema.extend({ 20 | zep_type: z.union([z.literal(ZepDataType.ZepNumber), z.literal(ZepDataType.ZepFloat)]), 21 | value: stringToNumberTransformer.optional(), 22 | default: stringToNumberTransformer.optional(), 23 | }); 24 | 25 | export interface ZepNumberField extends HasOptionalValue { 26 | zep_type: ZepDataType.ZepNumber | ZepDataType.ZepFloat; 27 | description: string; 28 | } 29 | 30 | export const zepNumberField = (description: string): ZepNumberField => { 31 | return ZepNumberSchema.parse({ 32 | zep_type: ZepDataType.ZepNumber, 33 | description, 34 | }); 35 | }; 36 | 37 | export const zepFloatField = (description: string): ZepNumberField => { 38 | return ZepNumberSchema.parse({ 39 | zep_type: ZepDataType.ZepFloat, 40 | description, 41 | }); 42 | }; 43 | -------------------------------------------------------------------------------- /src/extractor/regex.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | import { BaseSchema, ZepDataType } from "./base"; 3 | import { HasOptionalValue } from "./index"; 4 | 5 | export const ZepRegexSchema = BaseSchema.extend({ 6 | zep_type: z.literal(ZepDataType.ZepRegex), 7 | value: z.string().optional(), 8 | pattern: z.string().refine( 9 | (p) => { 10 | try { 11 | new RegExp(p); 12 | return true; // Pattern is valid 13 | } catch { 14 | return false; // Pattern is invalid 15 | } 16 | }, 17 | { 18 | message: "Invalid regex pattern", // Custom error message 19 | } 20 | ), 21 | default: z.string().optional(), 22 | }); 23 | 24 | export interface ZepRegexField extends HasOptionalValue { 25 | zep_type: ZepDataType.ZepRegex; 26 | description: string; 27 | pattern: string; 28 | } 29 | 30 | export const zepRegexField = (description: string, pattern: RegExp): ZepRegexField => { 31 | return ZepRegexSchema.parse({ 32 | zep_type: ZepDataType.ZepRegex, 33 | pattern: pattern.source, 34 | description, 35 | }); 36 | }; 37 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * as Zep from "./api"; 2 | export { ZepClient } from "./wrapper"; 3 | export { ZepEnvironment } from "./environments"; 4 | export { ZepError, ZepTimeoutError } from "./errors"; 5 | export { zepFields } from "./extractor"; 6 | -------------------------------------------------------------------------------- /src/serialization/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./resources"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/document/client/addDocuments.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../index"; 6 | import * as Zep from "../../../../api/index"; 7 | import * as core from "../../../../core"; 8 | import { CreateDocumentRequest } from "../../../types/CreateDocumentRequest"; 9 | 10 | export const Request: core.serialization.Schema< 11 | serializers.document.addDocuments.Request.Raw, 12 | Zep.CreateDocumentRequest[] 13 | > = core.serialization.list(CreateDocumentRequest); 14 | 15 | export declare namespace Request { 16 | export type Raw = CreateDocumentRequest.Raw[]; 17 | } 18 | 19 | export const Response: core.serialization.Schema = 20 | core.serialization.list(core.serialization.list(core.serialization.string())); 21 | 22 | export declare namespace Response { 23 | export type Raw = string[][]; 24 | } 25 | -------------------------------------------------------------------------------- /src/serialization/resources/document/client/batchDeleteDocuments.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../index"; 6 | import * as core from "../../../../core"; 7 | 8 | export const Request: core.serialization.Schema = 9 | core.serialization.list(core.serialization.string()); 10 | 11 | export declare namespace Request { 12 | export type Raw = string[]; 13 | } 14 | -------------------------------------------------------------------------------- /src/serialization/resources/document/client/batchGetDocuments.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../index"; 6 | import * as Zep from "../../../../api/index"; 7 | import * as core from "../../../../core"; 8 | import { ApidataDocument } from "../../../types/ApidataDocument"; 9 | 10 | export const Response: core.serialization.Schema< 11 | serializers.document.batchGetDocuments.Response.Raw, 12 | Zep.ApidataDocument[][] 13 | > = core.serialization.list(core.serialization.list(ApidataDocument)); 14 | 15 | export declare namespace Response { 16 | export type Raw = ApidataDocument.Raw[][]; 17 | } 18 | -------------------------------------------------------------------------------- /src/serialization/resources/document/client/batchUpdateDocuments.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../index"; 6 | import * as Zep from "../../../../api/index"; 7 | import * as core from "../../../../core"; 8 | import { UpdateDocumentListRequest } from "../../../types/UpdateDocumentListRequest"; 9 | 10 | export const Request: core.serialization.Schema< 11 | serializers.document.batchUpdateDocuments.Request.Raw, 12 | Zep.UpdateDocumentListRequest[] 13 | > = core.serialization.list(UpdateDocumentListRequest); 14 | 15 | export declare namespace Request { 16 | export type Raw = UpdateDocumentListRequest.Raw[]; 17 | } 18 | -------------------------------------------------------------------------------- /src/serialization/resources/document/client/index.ts: -------------------------------------------------------------------------------- 1 | export * as listCollections from "./listCollections"; 2 | export * as addDocuments from "./addDocuments"; 3 | export * as batchDeleteDocuments from "./batchDeleteDocuments"; 4 | export * as batchGetDocuments from "./batchGetDocuments"; 5 | export * as batchUpdateDocuments from "./batchUpdateDocuments"; 6 | export * from "./requests"; 7 | -------------------------------------------------------------------------------- /src/serialization/resources/document/client/listCollections.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../index"; 6 | import * as Zep from "../../../../api/index"; 7 | import * as core from "../../../../core"; 8 | import { ApidataDocumentCollection } from "../../../types/ApidataDocumentCollection"; 9 | 10 | export const Response: core.serialization.Schema< 11 | serializers.document.listCollections.Response.Raw, 12 | Zep.ApidataDocumentCollection[][] 13 | > = core.serialization.list(core.serialization.list(ApidataDocumentCollection)); 14 | 15 | export declare namespace Response { 16 | export type Raw = ApidataDocumentCollection.Raw[][]; 17 | } 18 | -------------------------------------------------------------------------------- /src/serialization/resources/document/client/requests/CreateDocumentCollectionRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | 9 | export const CreateDocumentCollectionRequest: core.serialization.Schema< 10 | serializers.CreateDocumentCollectionRequest.Raw, 11 | Zep.CreateDocumentCollectionRequest 12 | > = core.serialization.object({ 13 | description: core.serialization.string().optional(), 14 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 15 | }); 16 | 17 | export declare namespace CreateDocumentCollectionRequest { 18 | export interface Raw { 19 | description?: string | null; 20 | metadata?: Record | null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/serialization/resources/document/client/requests/DocumentSearchPayload.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | import { SearchType } from "../../../../types/SearchType"; 9 | 10 | export const DocumentSearchPayload: core.serialization.Schema< 11 | serializers.DocumentSearchPayload.Raw, 12 | Omit 13 | > = core.serialization.object({ 14 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 15 | minScore: core.serialization.property("min_score", core.serialization.number().optional()), 16 | mmrLambda: core.serialization.property("mmr_lambda", core.serialization.number().optional()), 17 | searchType: core.serialization.property("search_type", SearchType.optional()), 18 | text: core.serialization.string().optional(), 19 | }); 20 | 21 | export declare namespace DocumentSearchPayload { 22 | export interface Raw { 23 | metadata?: Record | null; 24 | min_score?: number | null; 25 | mmr_lambda?: number | null; 26 | search_type?: SearchType.Raw | null; 27 | text?: string | null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/serialization/resources/document/client/requests/GetDocumentListRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | 9 | export const GetDocumentListRequest: core.serialization.Schema< 10 | serializers.GetDocumentListRequest.Raw, 11 | Zep.GetDocumentListRequest 12 | > = core.serialization.object({ 13 | documentIds: core.serialization.property( 14 | "document_ids", 15 | core.serialization.list(core.serialization.string()).optional(), 16 | ), 17 | uuids: core.serialization.list(core.serialization.string()).optional(), 18 | }); 19 | 20 | export declare namespace GetDocumentListRequest { 21 | export interface Raw { 22 | document_ids?: string[] | null; 23 | uuids?: string[] | null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/serialization/resources/document/client/requests/UpdateDocumentCollectionRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | 9 | export const UpdateDocumentCollectionRequest: core.serialization.Schema< 10 | serializers.UpdateDocumentCollectionRequest.Raw, 11 | Zep.UpdateDocumentCollectionRequest 12 | > = core.serialization.object({ 13 | description: core.serialization.string().optional(), 14 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 15 | }); 16 | 17 | export declare namespace UpdateDocumentCollectionRequest { 18 | export interface Raw { 19 | description?: string | null; 20 | metadata?: Record | null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/serialization/resources/document/client/requests/UpdateDocumentRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | 9 | export const UpdateDocumentRequest: core.serialization.Schema< 10 | serializers.UpdateDocumentRequest.Raw, 11 | Zep.UpdateDocumentRequest 12 | > = core.serialization.object({ 13 | documentId: core.serialization.property("document_id", core.serialization.string().optional()), 14 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 15 | }); 16 | 17 | export declare namespace UpdateDocumentRequest { 18 | export interface Raw { 19 | document_id?: string | null; 20 | metadata?: Record | null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/serialization/resources/document/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { CreateDocumentCollectionRequest } from "./CreateDocumentCollectionRequest"; 2 | export { UpdateDocumentCollectionRequest } from "./UpdateDocumentCollectionRequest"; 3 | export { GetDocumentListRequest } from "./GetDocumentListRequest"; 4 | export { UpdateDocumentRequest } from "./UpdateDocumentRequest"; 5 | export { DocumentSearchPayload } from "./DocumentSearchPayload"; 6 | -------------------------------------------------------------------------------- /src/serialization/resources/document/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/client/addBatch.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../index"; 6 | import * as Zep from "../../../../api/index"; 7 | import * as core from "../../../../core"; 8 | import { Episode } from "../../../types/Episode"; 9 | 10 | export const Response: core.serialization.Schema = 11 | core.serialization.list(Episode); 12 | 13 | export declare namespace Response { 14 | export type Raw = Episode.Raw[]; 15 | } 16 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/client/index.ts: -------------------------------------------------------------------------------- 1 | export * as addBatch from "./addBatch"; 2 | export * from "./requests"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/client/requests/AddDataBatchRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | import { EpisodeData } from "../../../../types/EpisodeData"; 9 | 10 | export const AddDataBatchRequest: core.serialization.Schema< 11 | serializers.AddDataBatchRequest.Raw, 12 | Zep.AddDataBatchRequest 13 | > = core.serialization.object({ 14 | episodes: core.serialization.list(EpisodeData), 15 | groupId: core.serialization.property("group_id", core.serialization.string().optional()), 16 | userId: core.serialization.property("user_id", core.serialization.string().optional()), 17 | }); 18 | 19 | export declare namespace AddDataBatchRequest { 20 | export interface Raw { 21 | episodes: EpisodeData.Raw[]; 22 | group_id?: string | null; 23 | user_id?: string | null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/client/requests/AddDataRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | import { GraphDataType } from "../../../../types/GraphDataType"; 9 | 10 | export const AddDataRequest: core.serialization.Schema = 11 | core.serialization.object({ 12 | createdAt: core.serialization.property("created_at", core.serialization.string().optional()), 13 | data: core.serialization.string(), 14 | groupId: core.serialization.property("group_id", core.serialization.string().optional()), 15 | sourceDescription: core.serialization.property("source_description", core.serialization.string().optional()), 16 | type: GraphDataType, 17 | userId: core.serialization.property("user_id", core.serialization.string().optional()), 18 | }); 19 | 20 | export declare namespace AddDataRequest { 21 | export interface Raw { 22 | created_at?: string | null; 23 | data: string; 24 | group_id?: string | null; 25 | source_description?: string | null; 26 | type: GraphDataType.Raw; 27 | user_id?: string | null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/client/requests/EntityTypeRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | import { EdgeType } from "../../../../types/EdgeType"; 9 | import { EntityType } from "../../../../types/EntityType"; 10 | 11 | export const EntityTypeRequest: core.serialization.Schema = 12 | core.serialization.object({ 13 | edgeTypes: core.serialization.property("edge_types", core.serialization.list(EdgeType).optional()), 14 | entityTypes: core.serialization.property("entity_types", core.serialization.list(EntityType).optional()), 15 | }); 16 | 17 | export declare namespace EntityTypeRequest { 18 | export interface Raw { 19 | edge_types?: EdgeType.Raw[] | null; 20 | entity_types?: EntityType.Raw[] | null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { EntityTypeRequest } from "./EntityTypeRequest"; 2 | export { AddDataRequest } from "./AddDataRequest"; 3 | export { AddDataBatchRequest } from "./AddDataBatchRequest"; 4 | export { AddTripleRequest } from "./AddTripleRequest"; 5 | export { GraphSearchQuery } from "./GraphSearchQuery"; 6 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | export * from "./resources"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/resources/edge/client/getByGroupId.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../../index"; 6 | import * as Zep from "../../../../../../api/index"; 7 | import * as core from "../../../../../../core"; 8 | import { EntityEdge } from "../../../../../types/EntityEdge"; 9 | 10 | export const Response: core.serialization.Schema = 11 | core.serialization.list(EntityEdge); 12 | 13 | export declare namespace Response { 14 | export type Raw = EntityEdge.Raw[]; 15 | } 16 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/resources/edge/client/getByUserId.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../../index"; 6 | import * as Zep from "../../../../../../api/index"; 7 | import * as core from "../../../../../../core"; 8 | import { EntityEdge } from "../../../../../types/EntityEdge"; 9 | 10 | export const Response: core.serialization.Schema = 11 | core.serialization.list(EntityEdge); 12 | 13 | export declare namespace Response { 14 | export type Raw = EntityEdge.Raw[]; 15 | } 16 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/resources/edge/client/index.ts: -------------------------------------------------------------------------------- 1 | export * as getByGroupId from "./getByGroupId"; 2 | export * as getByUserId from "./getByUserId"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/resources/edge/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/resources/index.ts: -------------------------------------------------------------------------------- 1 | export * as edge from "./edge"; 2 | export * as node from "./node"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/resources/node/client/getByGroupId.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../../index"; 6 | import * as Zep from "../../../../../../api/index"; 7 | import * as core from "../../../../../../core"; 8 | import { EntityNode } from "../../../../../types/EntityNode"; 9 | 10 | export const Response: core.serialization.Schema = 11 | core.serialization.list(EntityNode); 12 | 13 | export declare namespace Response { 14 | export type Raw = EntityNode.Raw[]; 15 | } 16 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/resources/node/client/getByUserId.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../../index"; 6 | import * as Zep from "../../../../../../api/index"; 7 | import * as core from "../../../../../../core"; 8 | import { EntityNode } from "../../../../../types/EntityNode"; 9 | 10 | export const Response: core.serialization.Schema = 11 | core.serialization.list(EntityNode); 12 | 13 | export declare namespace Response { 14 | export type Raw = EntityNode.Raw[]; 15 | } 16 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/resources/node/client/getEdges.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../../index"; 6 | import * as Zep from "../../../../../../api/index"; 7 | import * as core from "../../../../../../core"; 8 | import { EntityEdge } from "../../../../../types/EntityEdge"; 9 | 10 | export const Response: core.serialization.Schema = 11 | core.serialization.list(EntityEdge); 12 | 13 | export declare namespace Response { 14 | export type Raw = EntityEdge.Raw[]; 15 | } 16 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/resources/node/client/index.ts: -------------------------------------------------------------------------------- 1 | export * as getByGroupId from "./getByGroupId"; 2 | export * as getByUserId from "./getByUserId"; 3 | export * as getEdges from "./getEdges"; 4 | -------------------------------------------------------------------------------- /src/serialization/resources/graph/resources/node/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/group/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/group/client/requests/CreateGroupRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | import { FactRatingInstruction } from "../../../../types/FactRatingInstruction"; 9 | 10 | export const CreateGroupRequest: core.serialization.Schema = 11 | core.serialization.object({ 12 | description: core.serialization.string().optional(), 13 | factRatingInstruction: core.serialization.property("fact_rating_instruction", FactRatingInstruction.optional()), 14 | groupId: core.serialization.property("group_id", core.serialization.string()), 15 | name: core.serialization.string().optional(), 16 | }); 17 | 18 | export declare namespace CreateGroupRequest { 19 | export interface Raw { 20 | description?: string | null; 21 | fact_rating_instruction?: FactRatingInstruction.Raw | null; 22 | group_id: string; 23 | name?: string | null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/serialization/resources/group/client/requests/UpdateGroupRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | import { FactRatingInstruction } from "../../../../types/FactRatingInstruction"; 9 | 10 | export const UpdateGroupRequest: core.serialization.Schema = 11 | core.serialization.object({ 12 | description: core.serialization.string().optional(), 13 | factRatingInstruction: core.serialization.property("fact_rating_instruction", FactRatingInstruction.optional()), 14 | name: core.serialization.string().optional(), 15 | }); 16 | 17 | export declare namespace UpdateGroupRequest { 18 | export interface Raw { 19 | description?: string | null; 20 | fact_rating_instruction?: FactRatingInstruction.Raw | null; 21 | name?: string | null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/serialization/resources/group/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { CreateGroupRequest } from "./CreateGroupRequest"; 2 | export { UpdateGroupRequest } from "./UpdateGroupRequest"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/group/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/index.ts: -------------------------------------------------------------------------------- 1 | export * as document from "./document"; 2 | export * as graph from "./graph"; 3 | export * as memory from "./memory"; 4 | export * as user from "./user"; 5 | export * from "./document/client/requests"; 6 | export * from "./graph/client/requests"; 7 | export * from "./memory/client/requests"; 8 | export * as group from "./group"; 9 | export * from "./group/client/requests"; 10 | export * from "./user/client/requests"; 11 | -------------------------------------------------------------------------------- /src/serialization/resources/memory/client/extractData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../index"; 6 | import * as core from "../../../../core"; 7 | 8 | export const Response: core.serialization.Schema< 9 | serializers.memory.extractData.Response.Raw, 10 | Record 11 | > = core.serialization.record(core.serialization.string(), core.serialization.string()); 12 | 13 | export declare namespace Response { 14 | export type Raw = Record; 15 | } 16 | -------------------------------------------------------------------------------- /src/serialization/resources/memory/client/index.ts: -------------------------------------------------------------------------------- 1 | export * as extractData from "./extractData"; 2 | export * as search from "./search"; 3 | export * from "./requests"; 4 | -------------------------------------------------------------------------------- /src/serialization/resources/memory/client/requests/AddFactsRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | import { NewFact } from "../../../../types/NewFact"; 9 | 10 | export const AddFactsRequest: core.serialization.Schema = 11 | core.serialization.object({ 12 | facts: core.serialization.list(NewFact), 13 | }); 14 | 15 | export declare namespace AddFactsRequest { 16 | export interface Raw { 17 | facts: NewFact.Raw[]; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/serialization/resources/memory/client/requests/AddMemoryRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | import { RoleType } from "../../../../types/RoleType"; 9 | import { Message } from "../../../../types/Message"; 10 | 11 | export const AddMemoryRequest: core.serialization.Schema = 12 | core.serialization.object({ 13 | factInstruction: core.serialization.property("fact_instruction", core.serialization.string().optional()), 14 | ignoreRoles: core.serialization.property("ignore_roles", core.serialization.list(RoleType).optional()), 15 | messages: core.serialization.list(Message), 16 | returnContext: core.serialization.property("return_context", core.serialization.boolean().optional()), 17 | summaryInstruction: core.serialization.property("summary_instruction", core.serialization.string().optional()), 18 | }); 19 | 20 | export declare namespace AddMemoryRequest { 21 | export interface Raw { 22 | fact_instruction?: string | null; 23 | ignore_roles?: RoleType.Raw[] | null; 24 | messages: Message.Raw[]; 25 | return_context?: boolean | null; 26 | summary_instruction?: string | null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/serialization/resources/memory/client/requests/CreateSessionRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | import { FactRatingInstruction } from "../../../../types/FactRatingInstruction"; 9 | 10 | export const CreateSessionRequest: core.serialization.Schema< 11 | serializers.CreateSessionRequest.Raw, 12 | Zep.CreateSessionRequest 13 | > = core.serialization.object({ 14 | factRatingInstruction: core.serialization.property("fact_rating_instruction", FactRatingInstruction.optional()), 15 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 16 | sessionId: core.serialization.property("session_id", core.serialization.string()), 17 | userId: core.serialization.property("user_id", core.serialization.string()), 18 | }); 19 | 20 | export declare namespace CreateSessionRequest { 21 | export interface Raw { 22 | fact_rating_instruction?: FactRatingInstruction.Raw | null; 23 | metadata?: Record | null; 24 | session_id: string; 25 | user_id: string; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/serialization/resources/memory/client/requests/EndSessionRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | import { ClassifySessionRequest } from "../../../../types/ClassifySessionRequest"; 9 | 10 | export const EndSessionRequest: core.serialization.Schema = 11 | core.serialization.object({ 12 | classify: ClassifySessionRequest.optional(), 13 | instruction: core.serialization.string().optional(), 14 | }); 15 | 16 | export declare namespace EndSessionRequest { 17 | export interface Raw { 18 | classify?: ClassifySessionRequest.Raw | null; 19 | instruction?: string | null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/serialization/resources/memory/client/requests/EndSessionsRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | 9 | export const EndSessionsRequest: core.serialization.Schema = 10 | core.serialization.object({ 11 | instruction: core.serialization.string().optional(), 12 | sessionIds: core.serialization.property("session_ids", core.serialization.list(core.serialization.string())), 13 | }); 14 | 15 | export declare namespace EndSessionsRequest { 16 | export interface Raw { 17 | instruction?: string | null; 18 | session_ids: string[]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/serialization/resources/memory/client/requests/ExtractDataRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | 9 | export const ExtractDataRequest: core.serialization.Schema = 10 | core.serialization.object({ 11 | currentDateTime: core.serialization.property("current_date_time", core.serialization.string().optional()), 12 | lastN: core.serialization.property("last_n", core.serialization.number()), 13 | modelSchema: core.serialization.property("model_schema", core.serialization.string()), 14 | validate: core.serialization.boolean().optional(), 15 | }); 16 | 17 | export declare namespace ExtractDataRequest { 18 | export interface Raw { 19 | current_date_time?: string | null; 20 | last_n: number; 21 | model_schema: string; 22 | validate?: boolean | null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/serialization/resources/memory/client/requests/ModelsMessageMetadataUpdate.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | 9 | export const ModelsMessageMetadataUpdate: core.serialization.Schema< 10 | serializers.ModelsMessageMetadataUpdate.Raw, 11 | Zep.ModelsMessageMetadataUpdate 12 | > = core.serialization.object({ 13 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()), 14 | }); 15 | 16 | export declare namespace ModelsMessageMetadataUpdate { 17 | export interface Raw { 18 | metadata: Record; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/serialization/resources/memory/client/requests/UpdateSessionRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | import { FactRatingInstruction } from "../../../../types/FactRatingInstruction"; 9 | 10 | export const UpdateSessionRequest: core.serialization.Schema< 11 | serializers.UpdateSessionRequest.Raw, 12 | Zep.UpdateSessionRequest 13 | > = core.serialization.object({ 14 | factRatingInstruction: core.serialization.property("fact_rating_instruction", FactRatingInstruction.optional()), 15 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()), 16 | }); 17 | 18 | export declare namespace UpdateSessionRequest { 19 | export interface Raw { 20 | fact_rating_instruction?: FactRatingInstruction.Raw | null; 21 | metadata: Record; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/serialization/resources/memory/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { CreateSessionRequest } from "./CreateSessionRequest"; 2 | export { EndSessionsRequest } from "./EndSessionsRequest"; 3 | export { SessionSearchQuery } from "./SessionSearchQuery"; 4 | export { UpdateSessionRequest } from "./UpdateSessionRequest"; 5 | export { EndSessionRequest } from "./EndSessionRequest"; 6 | export { ExtractDataRequest } from "./ExtractDataRequest"; 7 | export { AddFactsRequest } from "./AddFactsRequest"; 8 | export { AddMemoryRequest } from "./AddMemoryRequest"; 9 | export { ModelsMessageMetadataUpdate } from "./ModelsMessageMetadataUpdate"; 10 | export { MemorySearchPayload } from "./MemorySearchPayload"; 11 | -------------------------------------------------------------------------------- /src/serialization/resources/memory/client/search.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../index"; 6 | import * as Zep from "../../../../api/index"; 7 | import * as core from "../../../../core"; 8 | import { MemorySearchResult } from "../../../types/MemorySearchResult"; 9 | 10 | export const Response: core.serialization.Schema = 11 | core.serialization.list(MemorySearchResult); 12 | 13 | export declare namespace Response { 14 | export type Raw = MemorySearchResult.Raw[]; 15 | } 16 | -------------------------------------------------------------------------------- /src/serialization/resources/memory/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/user/client/getSessions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../index"; 6 | import * as Zep from "../../../../api/index"; 7 | import * as core from "../../../../core"; 8 | import { Session } from "../../../types/Session"; 9 | 10 | export const Response: core.serialization.Schema = 11 | core.serialization.list(Session); 12 | 13 | export declare namespace Response { 14 | export type Raw = Session.Raw[]; 15 | } 16 | -------------------------------------------------------------------------------- /src/serialization/resources/user/client/index.ts: -------------------------------------------------------------------------------- 1 | export * as getSessions from "./getSessions"; 2 | export * from "./requests"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/user/client/requests/CreateUserRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | import { FactRatingInstruction } from "../../../../types/FactRatingInstruction"; 9 | 10 | export const CreateUserRequest: core.serialization.Schema = 11 | core.serialization.object({ 12 | email: core.serialization.string().optional(), 13 | factRatingInstruction: core.serialization.property("fact_rating_instruction", FactRatingInstruction.optional()), 14 | firstName: core.serialization.property("first_name", core.serialization.string().optional()), 15 | lastName: core.serialization.property("last_name", core.serialization.string().optional()), 16 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 17 | userId: core.serialization.property("user_id", core.serialization.string()), 18 | }); 19 | 20 | export declare namespace CreateUserRequest { 21 | export interface Raw { 22 | email?: string | null; 23 | fact_rating_instruction?: FactRatingInstruction.Raw | null; 24 | first_name?: string | null; 25 | last_name?: string | null; 26 | metadata?: Record | null; 27 | user_id: string; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/serialization/resources/user/client/requests/UpdateUserRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../index"; 6 | import * as Zep from "../../../../../api/index"; 7 | import * as core from "../../../../../core"; 8 | import { FactRatingInstruction } from "../../../../types/FactRatingInstruction"; 9 | 10 | export const UpdateUserRequest: core.serialization.Schema = 11 | core.serialization.object({ 12 | email: core.serialization.string().optional(), 13 | factRatingInstruction: core.serialization.property("fact_rating_instruction", FactRatingInstruction.optional()), 14 | firstName: core.serialization.property("first_name", core.serialization.string().optional()), 15 | lastName: core.serialization.property("last_name", core.serialization.string().optional()), 16 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 17 | }); 18 | 19 | export declare namespace UpdateUserRequest { 20 | export interface Raw { 21 | email?: string | null; 22 | fact_rating_instruction?: FactRatingInstruction.Raw | null; 23 | first_name?: string | null; 24 | last_name?: string | null; 25 | metadata?: Record | null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/serialization/resources/user/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { CreateUserRequest } from "./CreateUserRequest"; 2 | export { UpdateUserRequest } from "./UpdateUserRequest"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/user/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /src/serialization/types/AddMemoryResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const AddMemoryResponse: core.serialization.ObjectSchema< 10 | serializers.AddMemoryResponse.Raw, 11 | Zep.AddMemoryResponse 12 | > = core.serialization.object({ 13 | context: core.serialization.string().optional(), 14 | }); 15 | 16 | export declare namespace AddMemoryResponse { 17 | export interface Raw { 18 | context?: string | null; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/serialization/types/AddTripleResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { EntityEdge } from "./EntityEdge"; 9 | import { EntityNode } from "./EntityNode"; 10 | 11 | export const AddTripleResponse: core.serialization.ObjectSchema< 12 | serializers.AddTripleResponse.Raw, 13 | Zep.AddTripleResponse 14 | > = core.serialization.object({ 15 | edge: EntityEdge.optional(), 16 | sourceNode: core.serialization.property("source_node", EntityNode.optional()), 17 | targetNode: core.serialization.property("target_node", EntityNode.optional()), 18 | }); 19 | 20 | export declare namespace AddTripleResponse { 21 | export interface Raw { 22 | edge?: EntityEdge.Raw | null; 23 | source_node?: EntityNode.Raw | null; 24 | target_node?: EntityNode.Raw | null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/serialization/types/ApiError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const ApiError: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | message: core.serialization.string().optional(), 12 | }); 13 | 14 | export declare namespace ApiError { 15 | export interface Raw { 16 | message?: string | null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/serialization/types/ApidataDocumentSearchResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { ApidataDocumentWithScore } from "./ApidataDocumentWithScore"; 9 | 10 | export const ApidataDocumentSearchResponse: core.serialization.ObjectSchema< 11 | serializers.ApidataDocumentSearchResponse.Raw, 12 | Zep.ApidataDocumentSearchResponse 13 | > = core.serialization.object({ 14 | currentPage: core.serialization.property("current_page", core.serialization.number().optional()), 15 | queryVector: core.serialization.property( 16 | "query_vector", 17 | core.serialization.list(core.serialization.number()).optional(), 18 | ), 19 | resultCount: core.serialization.property("result_count", core.serialization.number().optional()), 20 | results: core.serialization.list(ApidataDocumentWithScore).optional(), 21 | totalPages: core.serialization.property("total_pages", core.serialization.number().optional()), 22 | }); 23 | 24 | export declare namespace ApidataDocumentSearchResponse { 25 | export interface Raw { 26 | current_page?: number | null; 27 | query_vector?: number[] | null; 28 | result_count?: number | null; 29 | results?: ApidataDocumentWithScore.Raw[] | null; 30 | total_pages?: number | null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/serialization/types/ClassifySessionRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const ClassifySessionRequest: core.serialization.ObjectSchema< 10 | serializers.ClassifySessionRequest.Raw, 11 | Zep.ClassifySessionRequest 12 | > = core.serialization.object({ 13 | classes: core.serialization.list(core.serialization.string()), 14 | instruction: core.serialization.string().optional(), 15 | lastN: core.serialization.property("last_n", core.serialization.number().optional()), 16 | name: core.serialization.string(), 17 | persist: core.serialization.boolean().optional(), 18 | }); 19 | 20 | export declare namespace ClassifySessionRequest { 21 | export interface Raw { 22 | classes: string[]; 23 | instruction?: string | null; 24 | last_n?: number | null; 25 | name: string; 26 | persist?: boolean | null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/serialization/types/CreateDocumentRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const CreateDocumentRequest: core.serialization.ObjectSchema< 10 | serializers.CreateDocumentRequest.Raw, 11 | Zep.CreateDocumentRequest 12 | > = core.serialization.object({ 13 | content: core.serialization.string(), 14 | documentId: core.serialization.property("document_id", core.serialization.string().optional()), 15 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 16 | }); 17 | 18 | export declare namespace CreateDocumentRequest { 19 | export interface Raw { 20 | content: string; 21 | document_id?: string | null; 22 | metadata?: Record | null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/serialization/types/EdgeType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { EntityProperty } from "./EntityProperty"; 9 | import { EntityEdgeSourceTarget } from "./EntityEdgeSourceTarget"; 10 | 11 | export const EdgeType: core.serialization.ObjectSchema = 12 | core.serialization.object({ 13 | description: core.serialization.string(), 14 | name: core.serialization.string(), 15 | properties: core.serialization.list(EntityProperty).optional(), 16 | sourceTargets: core.serialization.property( 17 | "source_targets", 18 | core.serialization.list(EntityEdgeSourceTarget).optional(), 19 | ), 20 | }); 21 | 22 | export declare namespace EdgeType { 23 | export interface Raw { 24 | description: string; 25 | name: string; 26 | properties?: EntityProperty.Raw[] | null; 27 | source_targets?: EntityEdgeSourceTarget.Raw[] | null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/serialization/types/EndSessionResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { SessionClassification } from "./SessionClassification"; 9 | import { Session } from "./Session"; 10 | 11 | export const EndSessionResponse: core.serialization.ObjectSchema< 12 | serializers.EndSessionResponse.Raw, 13 | Zep.EndSessionResponse 14 | > = core.serialization.object({ 15 | classification: SessionClassification.optional(), 16 | session: Session.optional(), 17 | }); 18 | 19 | export declare namespace EndSessionResponse { 20 | export interface Raw { 21 | classification?: SessionClassification.Raw | null; 22 | session?: Session.Raw | null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/serialization/types/EndSessionsResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { Session } from "./Session"; 9 | 10 | export const EndSessionsResponse: core.serialization.ObjectSchema< 11 | serializers.EndSessionsResponse.Raw, 12 | Zep.EndSessionsResponse 13 | > = core.serialization.object({ 14 | sessions: core.serialization.list(Session).optional(), 15 | }); 16 | 17 | export declare namespace EndSessionsResponse { 18 | export interface Raw { 19 | sessions?: Session.Raw[] | null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/serialization/types/EntityEdgeSourceTarget.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const EntityEdgeSourceTarget: core.serialization.ObjectSchema< 10 | serializers.EntityEdgeSourceTarget.Raw, 11 | Zep.EntityEdgeSourceTarget 12 | > = core.serialization.object({ 13 | source: core.serialization.string().optional(), 14 | target: core.serialization.string().optional(), 15 | }); 16 | 17 | export declare namespace EntityEdgeSourceTarget { 18 | export interface Raw { 19 | source?: string | null; 20 | target?: string | null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/serialization/types/EntityNode.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const EntityNode: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | attributes: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 12 | createdAt: core.serialization.property("created_at", core.serialization.string()), 13 | labels: core.serialization.list(core.serialization.string()).optional(), 14 | name: core.serialization.string(), 15 | summary: core.serialization.string(), 16 | uuid: core.serialization.string(), 17 | }); 18 | 19 | export declare namespace EntityNode { 20 | export interface Raw { 21 | attributes?: Record | null; 22 | created_at: string; 23 | labels?: string[] | null; 24 | name: string; 25 | summary: string; 26 | uuid: string; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/serialization/types/EntityProperty.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { EntityPropertyType } from "./EntityPropertyType"; 9 | 10 | export const EntityProperty: core.serialization.ObjectSchema = 11 | core.serialization.object({ 12 | description: core.serialization.string(), 13 | name: core.serialization.string(), 14 | type: EntityPropertyType, 15 | }); 16 | 17 | export declare namespace EntityProperty { 18 | export interface Raw { 19 | description: string; 20 | name: string; 21 | type: EntityPropertyType.Raw; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/serialization/types/EntityPropertyType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const EntityPropertyType: core.serialization.Schema = 10 | core.serialization.enum_(["Text", "Int", "Float", "Boolean"]); 11 | 12 | export declare namespace EntityPropertyType { 13 | export type Raw = "Text" | "Int" | "Float" | "Boolean"; 14 | } 15 | -------------------------------------------------------------------------------- /src/serialization/types/EntityType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { EntityProperty } from "./EntityProperty"; 9 | 10 | export const EntityType: core.serialization.ObjectSchema = 11 | core.serialization.object({ 12 | description: core.serialization.string(), 13 | name: core.serialization.string(), 14 | properties: core.serialization.list(EntityProperty).optional(), 15 | }); 16 | 17 | export declare namespace EntityType { 18 | export interface Raw { 19 | description: string; 20 | name: string; 21 | properties?: EntityProperty.Raw[] | null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/serialization/types/EntityTypeResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { EdgeType } from "./EdgeType"; 9 | import { EntityType } from "./EntityType"; 10 | 11 | export const EntityTypeResponse: core.serialization.ObjectSchema< 12 | serializers.EntityTypeResponse.Raw, 13 | Zep.EntityTypeResponse 14 | > = core.serialization.object({ 15 | edgeTypes: core.serialization.property("edge_types", core.serialization.list(EdgeType).optional()), 16 | entityTypes: core.serialization.property("entity_types", core.serialization.list(EntityType).optional()), 17 | }); 18 | 19 | export declare namespace EntityTypeResponse { 20 | export interface Raw { 21 | edge_types?: EdgeType.Raw[] | null; 22 | entity_types?: EntityType.Raw[] | null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/serialization/types/EpisodeData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { GraphDataType } from "./GraphDataType"; 9 | 10 | export const EpisodeData: core.serialization.ObjectSchema = 11 | core.serialization.object({ 12 | createdAt: core.serialization.property("created_at", core.serialization.string().optional()), 13 | data: core.serialization.string(), 14 | sourceDescription: core.serialization.property("source_description", core.serialization.string().optional()), 15 | type: GraphDataType, 16 | }); 17 | 18 | export declare namespace EpisodeData { 19 | export interface Raw { 20 | created_at?: string | null; 21 | data: string; 22 | source_description?: string | null; 23 | type: GraphDataType.Raw; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/serialization/types/EpisodeMentions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { EntityEdge } from "./EntityEdge"; 9 | import { EntityNode } from "./EntityNode"; 10 | 11 | export const EpisodeMentions: core.serialization.ObjectSchema = 12 | core.serialization.object({ 13 | edges: core.serialization.list(EntityEdge).optional(), 14 | nodes: core.serialization.list(EntityNode).optional(), 15 | }); 16 | 17 | export declare namespace EpisodeMentions { 18 | export interface Raw { 19 | edges?: EntityEdge.Raw[] | null; 20 | nodes?: EntityNode.Raw[] | null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/serialization/types/EpisodeResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { Episode } from "./Episode"; 9 | 10 | export const EpisodeResponse: core.serialization.ObjectSchema = 11 | core.serialization.object({ 12 | episodes: core.serialization.list(Episode).optional(), 13 | }); 14 | 15 | export declare namespace EpisodeResponse { 16 | export interface Raw { 17 | episodes?: Episode.Raw[] | null; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/serialization/types/FactRatingExamples.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const FactRatingExamples: core.serialization.ObjectSchema< 10 | serializers.FactRatingExamples.Raw, 11 | Zep.FactRatingExamples 12 | > = core.serialization.object({ 13 | high: core.serialization.string().optional(), 14 | low: core.serialization.string().optional(), 15 | medium: core.serialization.string().optional(), 16 | }); 17 | 18 | export declare namespace FactRatingExamples { 19 | export interface Raw { 20 | high?: string | null; 21 | low?: string | null; 22 | medium?: string | null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/serialization/types/FactRatingInstruction.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { FactRatingExamples } from "./FactRatingExamples"; 9 | 10 | export const FactRatingInstruction: core.serialization.ObjectSchema< 11 | serializers.FactRatingInstruction.Raw, 12 | Zep.FactRatingInstruction 13 | > = core.serialization.object({ 14 | examples: FactRatingExamples.optional(), 15 | instruction: core.serialization.string().optional(), 16 | }); 17 | 18 | export declare namespace FactRatingInstruction { 19 | export interface Raw { 20 | examples?: FactRatingExamples.Raw | null; 21 | instruction?: string | null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/serialization/types/FactResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { Fact } from "./Fact"; 9 | 10 | export const FactResponse: core.serialization.ObjectSchema = 11 | core.serialization.object({ 12 | fact: Fact.optional(), 13 | }); 14 | 15 | export declare namespace FactResponse { 16 | export interface Raw { 17 | fact?: Fact.Raw | null; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/serialization/types/FactsResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { Fact } from "./Fact"; 9 | 10 | export const FactsResponse: core.serialization.ObjectSchema = 11 | core.serialization.object({ 12 | facts: core.serialization.list(Fact).optional(), 13 | }); 14 | 15 | export declare namespace FactsResponse { 16 | export interface Raw { 17 | facts?: Fact.Raw[] | null; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/serialization/types/GraphDataType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const GraphDataType: core.serialization.Schema = 10 | core.serialization.enum_(["text", "json", "message"]); 11 | 12 | export declare namespace GraphDataType { 13 | export type Raw = "text" | "json" | "message"; 14 | } 15 | -------------------------------------------------------------------------------- /src/serialization/types/GraphEdgesRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const GraphEdgesRequest: core.serialization.ObjectSchema< 10 | serializers.GraphEdgesRequest.Raw, 11 | Zep.GraphEdgesRequest 12 | > = core.serialization.object({ 13 | limit: core.serialization.number().optional(), 14 | uuidCursor: core.serialization.property("uuid_cursor", core.serialization.string().optional()), 15 | }); 16 | 17 | export declare namespace GraphEdgesRequest { 18 | export interface Raw { 19 | limit?: number | null; 20 | uuid_cursor?: string | null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/serialization/types/GraphNodesRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const GraphNodesRequest: core.serialization.ObjectSchema< 10 | serializers.GraphNodesRequest.Raw, 11 | Zep.GraphNodesRequest 12 | > = core.serialization.object({ 13 | limit: core.serialization.number().optional(), 14 | uuidCursor: core.serialization.property("uuid_cursor", core.serialization.string().optional()), 15 | }); 16 | 17 | export declare namespace GraphNodesRequest { 18 | export interface Raw { 19 | limit?: number | null; 20 | uuid_cursor?: string | null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/serialization/types/GraphSearchResults.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { EntityEdge } from "./EntityEdge"; 9 | import { Episode } from "./Episode"; 10 | import { EntityNode } from "./EntityNode"; 11 | 12 | export const GraphSearchResults: core.serialization.ObjectSchema< 13 | serializers.GraphSearchResults.Raw, 14 | Zep.GraphSearchResults 15 | > = core.serialization.object({ 16 | edges: core.serialization.list(EntityEdge).optional(), 17 | episodes: core.serialization.list(Episode).optional(), 18 | nodes: core.serialization.list(EntityNode).optional(), 19 | }); 20 | 21 | export declare namespace GraphSearchResults { 22 | export interface Raw { 23 | edges?: EntityEdge.Raw[] | null; 24 | episodes?: Episode.Raw[] | null; 25 | nodes?: EntityNode.Raw[] | null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/serialization/types/GraphSearchScope.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const GraphSearchScope: core.serialization.Schema = 10 | core.serialization.enum_(["edges", "nodes", "episodes"]); 11 | 12 | export declare namespace GraphSearchScope { 13 | export type Raw = "edges" | "nodes" | "episodes"; 14 | } 15 | -------------------------------------------------------------------------------- /src/serialization/types/GroupListResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { Group } from "./Group"; 9 | 10 | export const GroupListResponse: core.serialization.ObjectSchema< 11 | serializers.GroupListResponse.Raw, 12 | Zep.GroupListResponse 13 | > = core.serialization.object({ 14 | groups: core.serialization.list(Group).optional(), 15 | rowCount: core.serialization.property("row_count", core.serialization.number().optional()), 16 | totalCount: core.serialization.property("total_count", core.serialization.number().optional()), 17 | }); 18 | 19 | export declare namespace GroupListResponse { 20 | export interface Raw { 21 | groups?: Group.Raw[] | null; 22 | row_count?: number | null; 23 | total_count?: number | null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/serialization/types/Memory.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { Message } from "./Message"; 9 | import { Fact } from "./Fact"; 10 | import { Summary } from "./Summary"; 11 | 12 | export const Memory: core.serialization.ObjectSchema = core.serialization.object({ 13 | context: core.serialization.string().optional(), 14 | facts: core.serialization.list(core.serialization.string()).optional(), 15 | messages: core.serialization.list(Message).optional(), 16 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 17 | relevantFacts: core.serialization.property("relevant_facts", core.serialization.list(Fact).optional()), 18 | summary: Summary.optional(), 19 | }); 20 | 21 | export declare namespace Memory { 22 | export interface Raw { 23 | context?: string | null; 24 | facts?: string[] | null; 25 | messages?: Message.Raw[] | null; 26 | metadata?: Record | null; 27 | relevant_facts?: Fact.Raw[] | null; 28 | summary?: Summary.Raw | null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/serialization/types/MemorySearchResult.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { Message } from "./Message"; 9 | import { Summary } from "./Summary"; 10 | 11 | export const MemorySearchResult: core.serialization.ObjectSchema< 12 | serializers.MemorySearchResult.Raw, 13 | Zep.MemorySearchResult 14 | > = core.serialization.object({ 15 | message: Message.optional(), 16 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 17 | score: core.serialization.number().optional(), 18 | summary: Summary.optional(), 19 | }); 20 | 21 | export declare namespace MemorySearchResult { 22 | export interface Raw { 23 | message?: Message.Raw | null; 24 | metadata?: Record | null; 25 | score?: number | null; 26 | summary?: Summary.Raw | null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/serialization/types/MessageListResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { Message } from "./Message"; 9 | 10 | export const MessageListResponse: core.serialization.ObjectSchema< 11 | serializers.MessageListResponse.Raw, 12 | Zep.MessageListResponse 13 | > = core.serialization.object({ 14 | messages: core.serialization.list(Message).optional(), 15 | rowCount: core.serialization.property("row_count", core.serialization.number().optional()), 16 | totalCount: core.serialization.property("total_count", core.serialization.number().optional()), 17 | }); 18 | 19 | export declare namespace MessageListResponse { 20 | export interface Raw { 21 | messages?: Message.Raw[] | null; 22 | row_count?: number | null; 23 | total_count?: number | null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/serialization/types/NewFact.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const NewFact: core.serialization.ObjectSchema = core.serialization.object( 10 | { 11 | fact: core.serialization.string(), 12 | }, 13 | ); 14 | 15 | export declare namespace NewFact { 16 | export interface Raw { 17 | fact: string; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/serialization/types/Question.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const Question: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | question: core.serialization.string().optional(), 12 | }); 13 | 14 | export declare namespace Question { 15 | export interface Raw { 16 | question?: string | null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/serialization/types/Reranker.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const Reranker: core.serialization.Schema = core.serialization.enum_([ 10 | "rrf", 11 | "mmr", 12 | "node_distance", 13 | "episode_mentions", 14 | "cross_encoder", 15 | ]); 16 | 17 | export declare namespace Reranker { 18 | export type Raw = "rrf" | "mmr" | "node_distance" | "episode_mentions" | "cross_encoder"; 19 | } 20 | -------------------------------------------------------------------------------- /src/serialization/types/RoleType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const RoleType: core.serialization.Schema = core.serialization.enum_([ 10 | "norole", 11 | "system", 12 | "assistant", 13 | "user", 14 | "function", 15 | "tool", 16 | ]); 17 | 18 | export declare namespace RoleType { 19 | export type Raw = "norole" | "system" | "assistant" | "user" | "function" | "tool"; 20 | } 21 | -------------------------------------------------------------------------------- /src/serialization/types/SearchFilters.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const SearchFilters: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | edgeTypes: core.serialization.property( 12 | "edge_types", 13 | core.serialization.list(core.serialization.string()).optional(), 14 | ), 15 | nodeLabels: core.serialization.property( 16 | "node_labels", 17 | core.serialization.list(core.serialization.string()).optional(), 18 | ), 19 | }); 20 | 21 | export declare namespace SearchFilters { 22 | export interface Raw { 23 | edge_types?: string[] | null; 24 | node_labels?: string[] | null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/serialization/types/SearchScope.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const SearchScope: core.serialization.Schema = 10 | core.serialization.enum_(["messages", "summary", "facts"]); 11 | 12 | export declare namespace SearchScope { 13 | export type Raw = "messages" | "summary" | "facts"; 14 | } 15 | -------------------------------------------------------------------------------- /src/serialization/types/SearchType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const SearchType: core.serialization.Schema = 10 | core.serialization.enum_(["similarity", "mmr"]); 11 | 12 | export declare namespace SearchType { 13 | export type Raw = "similarity" | "mmr"; 14 | } 15 | -------------------------------------------------------------------------------- /src/serialization/types/SessionClassification.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const SessionClassification: core.serialization.ObjectSchema< 10 | serializers.SessionClassification.Raw, 11 | Zep.SessionClassification 12 | > = core.serialization.object({ 13 | class: core.serialization.string().optional(), 14 | label: core.serialization.string().optional(), 15 | }); 16 | 17 | export declare namespace SessionClassification { 18 | export interface Raw { 19 | class?: string | null; 20 | label?: string | null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/serialization/types/SessionListResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { Session } from "./Session"; 9 | 10 | export const SessionListResponse: core.serialization.ObjectSchema< 11 | serializers.SessionListResponse.Raw, 12 | Zep.SessionListResponse 13 | > = core.serialization.object({ 14 | responseCount: core.serialization.property("response_count", core.serialization.number().optional()), 15 | sessions: core.serialization.list(Session).optional(), 16 | totalCount: core.serialization.property("total_count", core.serialization.number().optional()), 17 | }); 18 | 19 | export declare namespace SessionListResponse { 20 | export interface Raw { 21 | response_count?: number | null; 22 | sessions?: Session.Raw[] | null; 23 | total_count?: number | null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/serialization/types/SessionSearchResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { SessionSearchResult } from "./SessionSearchResult"; 9 | 10 | export const SessionSearchResponse: core.serialization.ObjectSchema< 11 | serializers.SessionSearchResponse.Raw, 12 | Zep.SessionSearchResponse 13 | > = core.serialization.object({ 14 | results: core.serialization.list(SessionSearchResult).optional(), 15 | }); 16 | 17 | export declare namespace SessionSearchResponse { 18 | export interface Raw { 19 | results?: SessionSearchResult.Raw[] | null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/serialization/types/SessionSearchResult.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { Fact } from "./Fact"; 9 | import { Message } from "./Message"; 10 | import { Summary } from "./Summary"; 11 | 12 | export const SessionSearchResult: core.serialization.ObjectSchema< 13 | serializers.SessionSearchResult.Raw, 14 | Zep.SessionSearchResult 15 | > = core.serialization.object({ 16 | fact: Fact.optional(), 17 | message: Message.optional(), 18 | score: core.serialization.number().optional(), 19 | sessionId: core.serialization.property("session_id", core.serialization.string().optional()), 20 | summary: Summary.optional(), 21 | }); 22 | 23 | export declare namespace SessionSearchResult { 24 | export interface Raw { 25 | fact?: Fact.Raw | null; 26 | message?: Message.Raw | null; 27 | score?: number | null; 28 | session_id?: string | null; 29 | summary?: Summary.Raw | null; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/serialization/types/SuccessResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const SuccessResponse: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | message: core.serialization.string().optional(), 12 | }); 13 | 14 | export declare namespace SuccessResponse { 15 | export interface Raw { 16 | message?: string | null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/serialization/types/Summary.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const Summary: core.serialization.ObjectSchema = core.serialization.object( 10 | { 11 | content: core.serialization.string().optional(), 12 | createdAt: core.serialization.property("created_at", core.serialization.string().optional()), 13 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 14 | relatedMessageUuids: core.serialization.property( 15 | "related_message_uuids", 16 | core.serialization.list(core.serialization.string()).optional(), 17 | ), 18 | tokenCount: core.serialization.property("token_count", core.serialization.number().optional()), 19 | uuid: core.serialization.string().optional(), 20 | }, 21 | ); 22 | 23 | export declare namespace Summary { 24 | export interface Raw { 25 | content?: string | null; 26 | created_at?: string | null; 27 | metadata?: Record | null; 28 | related_message_uuids?: string[] | null; 29 | token_count?: number | null; 30 | uuid?: string | null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/serialization/types/SummaryListResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { Summary } from "./Summary"; 9 | 10 | export const SummaryListResponse: core.serialization.ObjectSchema< 11 | serializers.SummaryListResponse.Raw, 12 | Zep.SummaryListResponse 13 | > = core.serialization.object({ 14 | rowCount: core.serialization.property("row_count", core.serialization.number().optional()), 15 | summaries: core.serialization.list(Summary).optional(), 16 | totalCount: core.serialization.property("total_count", core.serialization.number().optional()), 17 | }); 18 | 19 | export declare namespace SummaryListResponse { 20 | export interface Raw { 21 | row_count?: number | null; 22 | summaries?: Summary.Raw[] | null; 23 | total_count?: number | null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/serialization/types/UpdateDocumentListRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | 9 | export const UpdateDocumentListRequest: core.serialization.ObjectSchema< 10 | serializers.UpdateDocumentListRequest.Raw, 11 | Zep.UpdateDocumentListRequest 12 | > = core.serialization.object({ 13 | documentId: core.serialization.property("document_id", core.serialization.string().optional()), 14 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 15 | uuid: core.serialization.string(), 16 | }); 17 | 18 | export declare namespace UpdateDocumentListRequest { 19 | export interface Raw { 20 | document_id?: string | null; 21 | metadata?: Record | null; 22 | uuid: string; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/serialization/types/UserListResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { User } from "./User"; 9 | 10 | export const UserListResponse: core.serialization.ObjectSchema = 11 | core.serialization.object({ 12 | rowCount: core.serialization.property("row_count", core.serialization.number().optional()), 13 | totalCount: core.serialization.property("total_count", core.serialization.number().optional()), 14 | users: core.serialization.list(User).optional(), 15 | }); 16 | 17 | export declare namespace UserListResponse { 18 | export interface Raw { 19 | row_count?: number | null; 20 | total_count?: number | null; 21 | users?: User.Raw[] | null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/serialization/types/UserNodeResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../index"; 6 | import * as Zep from "../../api/index"; 7 | import * as core from "../../core"; 8 | import { EntityNode } from "./EntityNode"; 9 | 10 | export const UserNodeResponse: core.serialization.ObjectSchema = 11 | core.serialization.object({ 12 | node: EntityNode.optional(), 13 | }); 14 | 15 | export declare namespace UserNodeResponse { 16 | export interface Raw { 17 | node?: EntityNode.Raw | null; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/version.ts: -------------------------------------------------------------------------------- 1 | export const SDK_VERSION = "2.14.0"; 2 | -------------------------------------------------------------------------------- /src/wrapper/index.ts: -------------------------------------------------------------------------------- 1 | import { ZepClient as BaseClient } from "../Client"; 2 | import { Memory } from "./memory"; 3 | import { Graph } from "./graph"; 4 | 5 | export class ZepClient extends BaseClient { 6 | public get memory(): Memory { 7 | return new Memory(this._options); 8 | } 9 | 10 | public get graph(): Graph { 11 | return new Graph(this._options); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/custom.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a custom test file, if you wish to add more tests 3 | * to your SDK. 4 | * Be sure to mark this file in `.fernignore`. 5 | * 6 | * If you include example requests/responses in your fern definition, 7 | * you will have tests automatically generated for you. 8 | */ 9 | describe("test", () => { 10 | it("default", () => { 11 | expect(true).toBe(true); 12 | }); 13 | }); 14 | -------------------------------------------------------------------------------- /tests/unit/fetcher/getFetchFn.test.ts: -------------------------------------------------------------------------------- 1 | import { RUNTIME } from "../../../src/core/runtime"; 2 | import { getFetchFn } from "../../../src/core/fetcher/getFetchFn"; 3 | 4 | describe("Test for getFetchFn", () => { 5 | it("should get node-fetch function", async () => { 6 | if (RUNTIME.type == "node") { 7 | if (RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) { 8 | expect(await getFetchFn()).toBe(fetch); 9 | } else { 10 | expect(await getFetchFn()).toEqual((await import("node-fetch")).default as any); 11 | } 12 | } 13 | }); 14 | 15 | it("should get fetch function", async () => { 16 | if (RUNTIME.type == "browser") { 17 | const fetchFn = await getFetchFn(); 18 | expect(typeof fetchFn).toBe("function"); 19 | expect(fetchFn.name).toBe("fetch"); 20 | } 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /tests/unit/fetcher/test-file.txt: -------------------------------------------------------------------------------- 1 | This is a test file! 2 | -------------------------------------------------------------------------------- /tests/unit/zurg/bigint/bigint.test.ts: -------------------------------------------------------------------------------- 1 | import { bigint } from "../../../../src/core/schemas/builders/bigint"; 2 | import { itSchema } from "../utils/itSchema"; 3 | import { itValidateJson, itValidateParse } from "../utils/itValidate"; 4 | 5 | describe("bigint", () => { 6 | itSchema("converts between raw string and parsed bigint", bigint(), { 7 | raw: "123456789012345678901234567890123456789012345678901234567890", 8 | parsed: BigInt("123456789012345678901234567890123456789012345678901234567890"), 9 | }); 10 | 11 | itValidateParse("non-string", bigint(), 42, [ 12 | { 13 | message: "Expected string. Received 42.", 14 | path: [], 15 | }, 16 | ]); 17 | 18 | itValidateJson("non-bigint", bigint(), "hello", [ 19 | { 20 | message: 'Expected bigint. Received "hello".', 21 | path: [], 22 | }, 23 | ]); 24 | }); 25 | -------------------------------------------------------------------------------- /tests/unit/zurg/date/date.test.ts: -------------------------------------------------------------------------------- 1 | import { date } from "../../../../src/core/schemas/builders/date"; 2 | import { itSchema } from "../utils/itSchema"; 3 | import { itValidateJson, itValidateParse } from "../utils/itValidate"; 4 | 5 | describe("date", () => { 6 | itSchema("converts between raw ISO string and parsed Date", date(), { 7 | raw: "2022-09-29T05:41:21.939Z", 8 | parsed: new Date("2022-09-29T05:41:21.939Z"), 9 | }); 10 | 11 | itValidateParse("non-string", date(), 42, [ 12 | { 13 | message: "Expected string. Received 42.", 14 | path: [], 15 | }, 16 | ]); 17 | 18 | itValidateParse("non-ISO", date(), "hello world", [ 19 | { 20 | message: 'Expected ISO 8601 date string. Received "hello world".', 21 | path: [], 22 | }, 23 | ]); 24 | 25 | itValidateJson("non-Date", date(), "hello", [ 26 | { 27 | message: 'Expected Date object. Received "hello".', 28 | path: [], 29 | }, 30 | ]); 31 | }); 32 | -------------------------------------------------------------------------------- /tests/unit/zurg/enum/enum.test.ts: -------------------------------------------------------------------------------- 1 | import { enum_ } from "../../../../src/core/schemas/builders/enum"; 2 | import { itSchemaIdentity } from "../utils/itSchema"; 3 | import { itValidate } from "../utils/itValidate"; 4 | 5 | describe("enum", () => { 6 | itSchemaIdentity(enum_(["A", "B", "C"]), "A"); 7 | 8 | itSchemaIdentity(enum_(["A", "B", "C"]), "D" as any, { 9 | opts: { allowUnrecognizedEnumValues: true }, 10 | }); 11 | 12 | itValidate("invalid enum", enum_(["A", "B", "C"]), "D", [ 13 | { 14 | message: 'Expected enum. Received "D".', 15 | path: [], 16 | }, 17 | ]); 18 | 19 | itValidate( 20 | "non-string", 21 | enum_(["A", "B", "C"]), 22 | [], 23 | [ 24 | { 25 | message: "Expected string. Received list.", 26 | path: [], 27 | }, 28 | ], 29 | ); 30 | }); 31 | -------------------------------------------------------------------------------- /tests/unit/zurg/lazy/lazyObject.test.ts: -------------------------------------------------------------------------------- 1 | import { lazyObject, number, object, string } from "../../../../src/core/schemas/builders"; 2 | import { itSchemaIdentity } from "../utils/itSchema"; 3 | 4 | describe("lazy", () => { 5 | itSchemaIdentity( 6 | lazyObject(() => object({ foo: string() })), 7 | { foo: "hello" }, 8 | ); 9 | 10 | itSchemaIdentity( 11 | lazyObject(() => object({ foo: string() })).extend(object({ bar: number() })), 12 | { 13 | foo: "hello", 14 | bar: 42, 15 | }, 16 | { title: "returned schema has object utils" }, 17 | ); 18 | }); 19 | -------------------------------------------------------------------------------- /tests/unit/zurg/lazy/recursive/a.ts: -------------------------------------------------------------------------------- 1 | import { object } from "../../../../../src/core/schemas/builders/object"; 2 | import { schemaB } from "./b"; 3 | 4 | // @ts-expect-error 5 | export const schemaA = object({ 6 | b: schemaB, 7 | }); 8 | -------------------------------------------------------------------------------- /tests/unit/zurg/lazy/recursive/b.ts: -------------------------------------------------------------------------------- 1 | import { object } from "../../../../../src/core/schemas/builders/object"; 2 | import { optional } from "../../../../../src/core/schemas/builders/schema-utils"; 3 | import { schemaA } from "./a"; 4 | 5 | // @ts-expect-error 6 | export const schemaB = object({ 7 | a: optional(schemaA), 8 | }); 9 | -------------------------------------------------------------------------------- /tests/unit/zurg/list/list.test.ts: -------------------------------------------------------------------------------- 1 | import { list, object, property, string } from "../../../../src/core/schemas/builders"; 2 | import { itSchema, itSchemaIdentity } from "../utils/itSchema"; 3 | import { itValidate } from "../utils/itValidate"; 4 | 5 | describe("list", () => { 6 | itSchemaIdentity(list(string()), ["hello", "world"], { 7 | title: "functions as identity when item type is primitive", 8 | }); 9 | 10 | itSchema( 11 | "converts objects correctly", 12 | list( 13 | object({ 14 | helloWorld: property("hello_world", string()), 15 | }), 16 | ), 17 | { 18 | raw: [{ hello_world: "123" }], 19 | parsed: [{ helloWorld: "123" }], 20 | }, 21 | ); 22 | 23 | itValidate("not a list", list(string()), 42, [ 24 | { 25 | path: [], 26 | message: "Expected list. Received 42.", 27 | }, 28 | ]); 29 | 30 | itValidate( 31 | "invalid item type", 32 | list(string()), 33 | [42], 34 | [ 35 | { 36 | path: ["[0]"], 37 | message: "Expected string. Received 42.", 38 | }, 39 | ], 40 | ); 41 | }); 42 | -------------------------------------------------------------------------------- /tests/unit/zurg/literals/stringLiteral.test.ts: -------------------------------------------------------------------------------- 1 | import { stringLiteral } from "../../../../src/core/schemas/builders"; 2 | import { itSchemaIdentity } from "../utils/itSchema"; 3 | import { itValidate } from "../utils/itValidate"; 4 | 5 | describe("stringLiteral", () => { 6 | itSchemaIdentity(stringLiteral("A"), "A"); 7 | 8 | itValidate("incorrect string", stringLiteral("A"), "B", [ 9 | { 10 | path: [], 11 | message: 'Expected "A". Received "B".', 12 | }, 13 | ]); 14 | 15 | itValidate("non-string", stringLiteral("A"), 42, [ 16 | { 17 | path: [], 18 | message: 'Expected "A". Received 42.', 19 | }, 20 | ]); 21 | }); 22 | -------------------------------------------------------------------------------- /tests/unit/zurg/object/objectWithoutOptionalProperties.test.ts: -------------------------------------------------------------------------------- 1 | import { objectWithoutOptionalProperties, string, stringLiteral } from "../../../../src/core/schemas/builders"; 2 | import { itSchema } from "../utils/itSchema"; 3 | 4 | describe("objectWithoutOptionalProperties", () => { 5 | itSchema( 6 | "all properties are required", 7 | objectWithoutOptionalProperties({ 8 | foo: string(), 9 | bar: stringLiteral("bar").optional(), 10 | }), 11 | { 12 | raw: { 13 | foo: "hello", 14 | }, 15 | // @ts-expect-error 16 | parsed: { 17 | foo: "hello", 18 | }, 19 | }, 20 | ); 21 | }); 22 | -------------------------------------------------------------------------------- /tests/unit/zurg/primitives/any.test.ts: -------------------------------------------------------------------------------- 1 | import { any } from "../../../../src/core/schemas/builders"; 2 | import { itSchemaIdentity } from "../utils/itSchema"; 3 | 4 | describe("any", () => { 5 | itSchemaIdentity(any(), true); 6 | }); 7 | -------------------------------------------------------------------------------- /tests/unit/zurg/primitives/boolean.test.ts: -------------------------------------------------------------------------------- 1 | import { boolean } from "../../../../src/core/schemas/builders"; 2 | import { itSchemaIdentity } from "../utils/itSchema"; 3 | import { itValidate } from "../utils/itValidate"; 4 | 5 | describe("boolean", () => { 6 | itSchemaIdentity(boolean(), true); 7 | 8 | itValidate("non-boolean", boolean(), {}, [ 9 | { 10 | path: [], 11 | message: "Expected boolean. Received object.", 12 | }, 13 | ]); 14 | }); 15 | -------------------------------------------------------------------------------- /tests/unit/zurg/primitives/number.test.ts: -------------------------------------------------------------------------------- 1 | import { number } from "../../../../src/core/schemas/builders"; 2 | import { itSchemaIdentity } from "../utils/itSchema"; 3 | import { itValidate } from "../utils/itValidate"; 4 | 5 | describe("number", () => { 6 | itSchemaIdentity(number(), 42); 7 | 8 | itValidate("non-number", number(), "hello", [ 9 | { 10 | path: [], 11 | message: 'Expected number. Received "hello".', 12 | }, 13 | ]); 14 | }); 15 | -------------------------------------------------------------------------------- /tests/unit/zurg/primitives/string.test.ts: -------------------------------------------------------------------------------- 1 | import { string } from "../../../../src/core/schemas/builders"; 2 | import { itSchemaIdentity } from "../utils/itSchema"; 3 | import { itValidate } from "../utils/itValidate"; 4 | 5 | describe("string", () => { 6 | itSchemaIdentity(string(), "hello"); 7 | 8 | itValidate("non-string", string(), 42, [ 9 | { 10 | path: [], 11 | message: "Expected string. Received 42.", 12 | }, 13 | ]); 14 | }); 15 | -------------------------------------------------------------------------------- /tests/unit/zurg/primitives/unknown.test.ts: -------------------------------------------------------------------------------- 1 | import { unknown } from "../../../../src/core/schemas/builders"; 2 | import { itSchemaIdentity } from "../utils/itSchema"; 3 | 4 | describe("unknown", () => { 5 | itSchemaIdentity(unknown(), true); 6 | }); 7 | -------------------------------------------------------------------------------- /tests/unit/zurg/record/record.test.ts: -------------------------------------------------------------------------------- 1 | import { number, record, string } from "../../../../src/core/schemas/builders"; 2 | import { itSchemaIdentity } from "../utils/itSchema"; 3 | import { itValidate } from "../utils/itValidate"; 4 | 5 | describe("record", () => { 6 | itSchemaIdentity(record(string(), string()), { hello: "world" }); 7 | itSchemaIdentity(record(number(), string()), { 42: "world" }); 8 | 9 | itValidate( 10 | "non-record", 11 | record(number(), string()), 12 | [], 13 | [ 14 | { 15 | path: [], 16 | message: "Expected object. Received list.", 17 | }, 18 | ], 19 | ); 20 | 21 | itValidate("invalid key type", record(number(), string()), { hello: "world" }, [ 22 | { 23 | path: ["hello (key)"], 24 | message: 'Expected number. Received "hello".', 25 | }, 26 | ]); 27 | 28 | itValidate("invalid value type", record(string(), number()), { hello: "world" }, [ 29 | { 30 | path: ["hello"], 31 | message: 'Expected number. Received "world".', 32 | }, 33 | ]); 34 | }); 35 | -------------------------------------------------------------------------------- /tests/unit/zurg/set/set.test.ts: -------------------------------------------------------------------------------- 1 | import { set, string } from "../../../../src/core/schemas/builders"; 2 | import { itSchema } from "../utils/itSchema"; 3 | import { itValidateJson, itValidateParse } from "../utils/itValidate"; 4 | 5 | describe("set", () => { 6 | itSchema("converts between raw list and parsed Set", set(string()), { 7 | raw: ["A", "B"], 8 | parsed: new Set(["A", "B"]), 9 | }); 10 | 11 | itValidateParse("not a list", set(string()), 42, [ 12 | { 13 | path: [], 14 | message: "Expected list. Received 42.", 15 | }, 16 | ]); 17 | 18 | itValidateJson( 19 | "not a Set", 20 | set(string()), 21 | [], 22 | [ 23 | { 24 | path: [], 25 | message: "Expected Set. Received list.", 26 | }, 27 | ], 28 | ); 29 | 30 | itValidateParse( 31 | "invalid item type", 32 | set(string()), 33 | [42], 34 | [ 35 | { 36 | path: ["[0]"], 37 | message: "Expected string. Received 42.", 38 | }, 39 | ], 40 | ); 41 | 42 | itValidateJson("invalid item type", set(string()), new Set([42]), [ 43 | { 44 | path: ["[0]"], 45 | message: "Expected string. Received 42.", 46 | }, 47 | ]); 48 | }); 49 | -------------------------------------------------------------------------------- /tests/unit/zurg/skipValidation.test.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-console */ 2 | import { boolean, number, object, property, string, undiscriminatedUnion } from "../../../src/core/schemas/builders"; 3 | 4 | describe("skipValidation", () => { 5 | it("allows data that doesn't conform to the schema", async () => { 6 | const warningLogs: string[] = []; 7 | const originalConsoleWarn = console.warn; 8 | console.warn = (...args) => warningLogs.push(args.join(" ")); 9 | 10 | const schema = object({ 11 | camelCase: property("snake_case", string()), 12 | numberProperty: number(), 13 | requiredProperty: boolean(), 14 | anyPrimitive: undiscriminatedUnion([string(), number(), boolean()]), 15 | }); 16 | 17 | const parsed = await schema.parse( 18 | { 19 | snake_case: "hello", 20 | numberProperty: "oops", 21 | anyPrimitive: true, 22 | }, 23 | { 24 | skipValidation: true, 25 | }, 26 | ); 27 | 28 | expect(parsed).toEqual({ 29 | ok: true, 30 | value: { 31 | camelCase: "hello", 32 | numberProperty: "oops", 33 | anyPrimitive: true, 34 | }, 35 | }); 36 | 37 | expect(warningLogs).toEqual([ 38 | `Failed to validate. 39 | - numberProperty: Expected number. Received "oops".`, 40 | ]); 41 | 42 | console.warn = originalConsoleWarn; 43 | }); 44 | }); 45 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "extendedDiagnostics": true, 4 | "strict": true, 5 | "target": "ES6", 6 | "moduleResolution": "node", 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "declaration": true, 10 | "outDir": "dist", 11 | "rootDir": "src", 12 | "baseUrl": "src", 13 | "module": "CommonJS" 14 | }, 15 | "include": ["src"], 16 | "exclude": [] 17 | } 18 | --------------------------------------------------------------------------------