vellum-ai 0.0.45 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Client.d.ts +23 -26
- package/Client.js +288 -242
- package/api/resources/deployments/client/Client.d.ts +8 -4
- package/api/resources/deployments/client/Client.js +52 -34
- package/api/resources/documentIndexes/client/Client.d.ts +9 -5
- package/api/resources/documentIndexes/client/Client.js +97 -69
- package/api/resources/documents/client/Client.d.ts +14 -10
- package/api/resources/documents/client/Client.js +222 -176
- package/api/resources/index.d.ts +0 -1
- package/api/resources/index.js +0 -1
- package/api/resources/modelVersions/client/Client.d.ts +8 -8
- package/api/resources/modelVersions/client/Client.js +51 -75
- package/api/resources/modelVersions/client/index.d.ts +1 -1
- package/api/resources/modelVersions/client/index.js +0 -15
- package/api/resources/registeredPrompts/client/Client.d.ts +11 -7
- package/api/resources/registeredPrompts/client/Client.js +72 -53
- package/api/resources/registeredPrompts/client/requests/RegisterPromptRequestRequest.d.ts +4 -1
- package/api/resources/sandboxes/client/Client.d.ts +9 -5
- package/api/resources/sandboxes/client/Client.js +92 -65
- package/api/resources/testSuites/client/Client.d.ts +9 -5
- package/api/resources/testSuites/client/Client.js +90 -63
- package/api/types/EnrichedNormalizedCompletion.d.ts +3 -1
- package/api/types/ModelVersionRead.d.ts +3 -0
- package/api/types/ProviderEnum.d.ts +7 -1
- package/api/types/ProviderEnum.js +3 -0
- package/api/types/RegisterPromptPromptInfoRequest.d.ts +0 -1
- package/api/types/RegisterPromptResponse.d.ts +2 -0
- package/api/types/index.d.ts +0 -2
- package/api/types/index.js +0 -2
- package/core/fetcher/Fetcher.d.ts +5 -3
- package/core/fetcher/Fetcher.js +104 -62
- package/core/fetcher/Supplier.js +11 -2
- package/core/fetcher/index.d.ts +3 -2
- package/core/form-data-utils/getFormDataContentLength.d.ts +1 -1
- package/core/form-data-utils/getFormDataContentLength.js +20 -9
- package/core/index.d.ts +1 -2
- package/core/index.js +4 -5
- package/core/schemas/Schema.d.ts +19 -0
- package/core/schemas/Schema.js +1 -0
- package/core/schemas/builders/date/date.js +22 -14
- package/core/schemas/builders/enum/enum.js +17 -7
- package/core/schemas/builders/lazy/index.d.ts +2 -1
- package/core/schemas/builders/lazy/lazy.js +21 -13
- package/core/schemas/builders/lazy/lazyObject.js +11 -11
- package/core/schemas/builders/list/list.js +53 -38
- package/core/schemas/builders/literals/booleanLiteral.d.ts +2 -0
- package/core/schemas/builders/literals/booleanLiteral.js +29 -0
- package/core/schemas/builders/literals/index.d.ts +1 -0
- package/core/schemas/builders/literals/index.js +3 -1
- package/core/schemas/builders/literals/stringLiteral.js +4 -3
- package/core/schemas/builders/object/index.d.ts +5 -2
- package/core/schemas/builders/object/index.js +3 -1
- package/core/schemas/builders/object/object.js +150 -129
- package/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +6 -0
- package/core/schemas/builders/object/objectWithoutOptionalProperties.js +8 -0
- package/core/schemas/builders/object-like/getObjectLikeUtils.js +19 -18
- package/core/schemas/builders/object-like/index.d.ts +1 -1
- package/core/schemas/builders/primitives/boolean.js +4 -3
- package/core/schemas/builders/primitives/number.js +4 -3
- package/core/schemas/builders/primitives/string.js +4 -3
- package/core/schemas/builders/record/index.d.ts +1 -1
- package/core/schemas/builders/record/record.js +82 -67
- package/core/schemas/builders/schema-utils/JsonError.js +0 -1
- package/core/schemas/builders/schema-utils/ParseError.js +0 -1
- package/core/schemas/builders/schema-utils/getSchemaUtils.js +23 -20
- package/core/schemas/builders/schema-utils/index.d.ts +2 -1
- package/core/schemas/builders/set/set.js +21 -12
- package/core/schemas/builders/undiscriminated-union/index.d.ts +1 -1
- package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +38 -24
- package/core/schemas/builders/union/index.d.ts +3 -2
- package/core/schemas/builders/union/union.js +95 -74
- package/core/schemas/index.d.ts +1 -1
- package/core/schemas/utils/createIdentitySchemaCreator.js +2 -4
- package/core/schemas/utils/getErrorMessageForIncorrectType.d.ts +1 -0
- package/core/schemas/utils/getErrorMessageForIncorrectType.js +24 -0
- package/core/schemas/utils/isPlainObject.d.ts +0 -1
- package/core/schemas/utils/isPlainObject.js +1 -2
- package/core/schemas/utils/maybeSkipValidation.d.ts +2 -0
- package/core/schemas/utils/maybeSkipValidation.js +37 -0
- package/core/streaming-fetcher/Stream.d.ts +14 -0
- package/core/streaming-fetcher/Stream.js +75 -0
- package/core/streaming-fetcher/StreamingFetcher.d.ts +10 -8
- package/core/streaming-fetcher/StreamingFetcher.js +38 -44
- package/core/streaming-fetcher/getHeader.d.ts +2 -0
- package/core/streaming-fetcher/getHeader.js +12 -0
- package/core/streaming-fetcher/index.d.ts +4 -1
- package/core/streaming-fetcher/index.js +5 -1
- package/dist/Client.d.ts +23 -26
- package/dist/Client.js +288 -242
- package/dist/api/resources/deployments/client/Client.d.ts +8 -4
- package/dist/api/resources/deployments/client/Client.js +52 -34
- package/dist/api/resources/documentIndexes/client/Client.d.ts +9 -5
- package/dist/api/resources/documentIndexes/client/Client.js +97 -69
- package/dist/api/resources/documents/client/Client.d.ts +14 -10
- package/dist/api/resources/documents/client/Client.js +222 -176
- package/dist/api/resources/index.d.ts +0 -1
- package/dist/api/resources/index.js +0 -1
- package/dist/api/resources/modelVersions/client/Client.d.ts +8 -8
- package/dist/api/resources/modelVersions/client/Client.js +51 -75
- package/dist/api/resources/modelVersions/client/index.d.ts +1 -1
- package/dist/api/resources/modelVersions/client/index.js +0 -15
- package/dist/api/resources/registeredPrompts/client/Client.d.ts +11 -7
- package/dist/api/resources/registeredPrompts/client/Client.js +72 -53
- package/dist/api/resources/registeredPrompts/client/requests/RegisterPromptRequestRequest.d.ts +4 -1
- package/dist/api/resources/sandboxes/client/Client.d.ts +9 -5
- package/dist/api/resources/sandboxes/client/Client.js +92 -65
- package/dist/api/resources/testSuites/client/Client.d.ts +9 -5
- package/dist/api/resources/testSuites/client/Client.js +90 -63
- package/dist/api/types/EnrichedNormalizedCompletion.d.ts +3 -1
- package/dist/api/types/ModelVersionRead.d.ts +3 -0
- package/dist/api/types/ProviderEnum.d.ts +7 -1
- package/dist/api/types/ProviderEnum.js +3 -0
- package/dist/api/types/RegisterPromptPromptInfoRequest.d.ts +0 -1
- package/dist/api/types/RegisterPromptResponse.d.ts +2 -0
- package/dist/api/types/index.d.ts +0 -2
- package/dist/api/types/index.js +0 -2
- package/dist/core/fetcher/Fetcher.d.ts +5 -3
- package/dist/core/fetcher/Fetcher.js +104 -62
- package/dist/core/fetcher/Supplier.js +11 -2
- package/dist/core/fetcher/index.d.ts +3 -2
- package/dist/core/form-data-utils/getFormDataContentLength.d.ts +1 -1
- package/dist/core/form-data-utils/getFormDataContentLength.js +20 -9
- package/dist/core/index.d.ts +1 -2
- package/dist/core/index.js +4 -5
- package/dist/core/schemas/Schema.d.ts +19 -0
- package/dist/core/schemas/Schema.js +1 -0
- package/dist/core/schemas/builders/date/date.js +22 -14
- package/dist/core/schemas/builders/enum/enum.js +17 -7
- package/dist/core/schemas/builders/lazy/index.d.ts +2 -1
- package/dist/core/schemas/builders/lazy/lazy.js +21 -13
- package/dist/core/schemas/builders/lazy/lazyObject.js +11 -11
- package/dist/core/schemas/builders/list/list.js +53 -38
- package/dist/core/schemas/builders/literals/booleanLiteral.d.ts +2 -0
- package/dist/core/schemas/builders/literals/booleanLiteral.js +29 -0
- package/dist/core/schemas/builders/literals/index.d.ts +1 -0
- package/dist/core/schemas/builders/literals/index.js +3 -1
- package/dist/core/schemas/builders/literals/stringLiteral.js +4 -3
- package/dist/core/schemas/builders/object/index.d.ts +5 -2
- package/dist/core/schemas/builders/object/index.js +3 -1
- package/dist/core/schemas/builders/object/object.js +150 -129
- package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +6 -0
- package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js +8 -0
- package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +19 -18
- package/dist/core/schemas/builders/object-like/index.d.ts +1 -1
- package/dist/core/schemas/builders/primitives/boolean.js +4 -3
- package/dist/core/schemas/builders/primitives/number.js +4 -3
- package/dist/core/schemas/builders/primitives/string.js +4 -3
- package/dist/core/schemas/builders/record/index.d.ts +1 -1
- package/dist/core/schemas/builders/record/record.js +82 -67
- package/dist/core/schemas/builders/schema-utils/JsonError.js +0 -1
- package/dist/core/schemas/builders/schema-utils/ParseError.js +0 -1
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +23 -20
- package/dist/core/schemas/builders/schema-utils/index.d.ts +2 -1
- package/dist/core/schemas/builders/set/set.js +21 -12
- package/dist/core/schemas/builders/undiscriminated-union/index.d.ts +1 -1
- package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +38 -24
- package/dist/core/schemas/builders/union/index.d.ts +3 -2
- package/dist/core/schemas/builders/union/union.js +95 -74
- package/dist/core/schemas/index.d.ts +1 -1
- package/dist/core/schemas/utils/createIdentitySchemaCreator.js +2 -4
- package/dist/core/schemas/utils/getErrorMessageForIncorrectType.d.ts +1 -0
- package/dist/core/schemas/utils/getErrorMessageForIncorrectType.js +24 -0
- package/dist/core/schemas/utils/isPlainObject.d.ts +0 -1
- package/dist/core/schemas/utils/isPlainObject.js +1 -2
- package/dist/core/schemas/utils/maybeSkipValidation.d.ts +2 -0
- package/dist/core/schemas/utils/maybeSkipValidation.js +37 -0
- package/dist/core/streaming-fetcher/Stream.d.ts +14 -0
- package/dist/core/streaming-fetcher/Stream.js +75 -0
- package/dist/core/streaming-fetcher/StreamingFetcher.d.ts +10 -8
- package/dist/core/streaming-fetcher/StreamingFetcher.js +38 -44
- package/dist/core/streaming-fetcher/getHeader.d.ts +2 -0
- package/dist/core/streaming-fetcher/getHeader.js +12 -0
- package/dist/core/streaming-fetcher/index.d.ts +4 -1
- package/dist/core/streaming-fetcher/index.js +5 -1
- package/dist/errors/VellumError.js +14 -3
- package/dist/serialization/client/requests/ExecuteWorkflowStreamRequest.js +11 -2
- package/dist/serialization/client/requests/GenerateBodyRequest.js +11 -2
- package/dist/serialization/client/requests/GenerateStreamBodyRequest.js +11 -2
- package/dist/serialization/client/requests/SearchRequestBodyRequest.js +10 -1
- package/dist/serialization/client/requests/SubmitCompletionActualsRequest.js +10 -1
- package/dist/serialization/client/requests/SubmitWorkflowExecutionActualsRequest.js +10 -1
- package/dist/serialization/resources/documentIndexes/client/requests/DocumentIndexCreateRequest.js +11 -2
- package/dist/serialization/resources/documents/client/requests/PatchedDocumentUpdateRequest.js +10 -1
- package/dist/serialization/resources/index.d.ts +0 -2
- package/dist/serialization/resources/index.js +1 -3
- package/dist/serialization/resources/registeredPrompts/client/requests/RegisterPromptRequestRequest.d.ts +1 -1
- package/dist/serialization/resources/registeredPrompts/client/requests/RegisterPromptRequestRequest.js +12 -3
- package/dist/serialization/resources/sandboxes/client/requests/UpsertSandboxScenarioRequestRequest.js +11 -2
- package/dist/serialization/resources/testSuites/client/requests/TestSuiteTestCaseRequest.js +10 -1
- package/dist/serialization/types/ApiNodeResult.js +10 -1
- package/dist/serialization/types/ChatMessage.js +10 -1
- package/dist/serialization/types/ChatMessageRequest.js +10 -1
- package/dist/serialization/types/ConditionalNodeResult.js +10 -1
- package/dist/serialization/types/DeploymentRead.js +12 -3
- package/dist/serialization/types/DocumentDocumentToDocumentIndex.js +10 -1
- package/dist/serialization/types/DocumentIndexRead.js +11 -2
- package/dist/serialization/types/DocumentRead.js +12 -3
- package/dist/serialization/types/EnrichedNormalizedCompletion.d.ts +3 -1
- package/dist/serialization/types/EnrichedNormalizedCompletion.js +15 -4
- package/dist/serialization/types/GenerateOptionsRequest.js +10 -1
- package/dist/serialization/types/GenerateRequest.js +10 -1
- package/dist/serialization/types/GenerateResponse.js +10 -1
- package/dist/serialization/types/GenerateResult.js +11 -2
- package/dist/serialization/types/GenerateResultData.js +10 -1
- package/dist/serialization/types/GenerateStreamResponse.js +10 -1
- package/dist/serialization/types/GenerateStreamResult.js +11 -2
- package/dist/serialization/types/GenerateStreamResultData.js +10 -1
- package/dist/serialization/types/MetadataFilterConfigRequest.js +12 -3
- package/dist/serialization/types/MetadataFilterRuleRequest.js +12 -3
- package/dist/serialization/types/ModelVersionBuildConfig.js +10 -1
- package/dist/serialization/types/ModelVersionExecConfig.js +12 -3
- package/dist/serialization/types/ModelVersionRead.js +13 -4
- package/dist/serialization/types/NodeInputCompiledChatHistoryValue.js +10 -1
- package/dist/serialization/types/NodeInputCompiledErrorValue.js +10 -1
- package/dist/serialization/types/NodeInputCompiledSearchResultsValue.js +10 -1
- package/dist/serialization/types/NodeInputVariableCompiledValue.js +15 -6
- package/dist/serialization/types/NormalizedLogProbs.js +10 -1
- package/dist/serialization/types/PaginatedSlimDocumentList.js +10 -1
- package/dist/serialization/types/PromptNodeResult.js +10 -1
- package/dist/serialization/types/PromptTemplateBlock.js +11 -2
- package/dist/serialization/types/PromptTemplateBlockData.js +10 -1
- package/dist/serialization/types/PromptTemplateBlockDataRequest.js +10 -1
- package/dist/serialization/types/PromptTemplateBlockProperties.js +12 -3
- package/dist/serialization/types/PromptTemplateBlockPropertiesRequest.js +12 -3
- package/dist/serialization/types/PromptTemplateBlockRequest.js +11 -2
- package/dist/serialization/types/ProviderEnum.d.ts +1 -1
- package/dist/serialization/types/ProviderEnum.js +3 -0
- package/dist/serialization/types/RegisterPromptPromptInfoRequest.d.ts +0 -1
- package/dist/serialization/types/RegisterPromptPromptInfoRequest.js +11 -3
- package/dist/serialization/types/RegisterPromptResponse.d.ts +1 -0
- package/dist/serialization/types/RegisterPromptResponse.js +15 -5
- package/dist/serialization/types/RegisteredPromptInputVariableRequest.js +10 -1
- package/dist/serialization/types/SandboxMetricInputParams.js +10 -1
- package/dist/serialization/types/SandboxMetricInputParamsRequest.js +10 -1
- package/dist/serialization/types/SandboxScenario.js +11 -2
- package/dist/serialization/types/ScenarioInput.js +11 -2
- package/dist/serialization/types/ScenarioInputRequest.js +11 -2
- package/dist/serialization/types/SearchFiltersRequest.js +10 -1
- package/dist/serialization/types/SearchNodeResult.js +10 -1
- package/dist/serialization/types/SearchNodeResultData.js +10 -1
- package/dist/serialization/types/SearchRequestOptionsRequest.js +12 -3
- package/dist/serialization/types/SearchResponse.js +10 -1
- package/dist/serialization/types/SearchResult.js +10 -1
- package/dist/serialization/types/SlimDocument.js +13 -4
- package/dist/serialization/types/SubmitWorkflowExecutionActualRequest.js +12 -3
- package/dist/serialization/types/TemplatingNodeChatHistoryResult.js +10 -1
- package/dist/serialization/types/TemplatingNodeErrorResult.js +10 -1
- package/dist/serialization/types/TemplatingNodeResult.js +10 -1
- package/dist/serialization/types/TemplatingNodeResultData.js +10 -1
- package/dist/serialization/types/TemplatingNodeResultOutput.js +15 -6
- package/dist/serialization/types/TemplatingNodeSearchResultsResult.js +10 -1
- package/dist/serialization/types/TerminalNodeChatHistoryResult.js +10 -1
- package/dist/serialization/types/TerminalNodeErrorResult.js +10 -1
- package/dist/serialization/types/TerminalNodeResult.js +10 -1
- package/dist/serialization/types/TerminalNodeResultData.js +10 -1
- package/dist/serialization/types/TerminalNodeResultOutput.js +15 -6
- package/dist/serialization/types/TerminalNodeSearchResultsResult.js +10 -1
- package/dist/serialization/types/TestSuiteTestCase.js +10 -1
- package/dist/serialization/types/VellumError.js +10 -1
- package/dist/serialization/types/VellumVariable.js +10 -1
- package/dist/serialization/types/WorkflowEventError.js +10 -1
- package/dist/serialization/types/WorkflowExecutionActualChatHistoryRequest.js +10 -1
- package/dist/serialization/types/WorkflowExecutionNodeResultEvent.js +10 -1
- package/dist/serialization/types/WorkflowExecutionWorkflowResultEvent.js +10 -1
- package/dist/serialization/types/WorkflowNodeResultData.js +15 -6
- package/dist/serialization/types/WorkflowNodeResultEvent.js +13 -4
- package/dist/serialization/types/WorkflowRequestChatHistoryInputRequest.js +10 -1
- package/dist/serialization/types/WorkflowRequestInputRequest.js +12 -3
- package/dist/serialization/types/WorkflowResultEvent.js +12 -3
- package/dist/serialization/types/WorkflowResultEventOutputData.js +15 -6
- package/dist/serialization/types/WorkflowResultEventOutputDataChatHistory.js +11 -2
- package/dist/serialization/types/WorkflowResultEventOutputDataError.js +11 -2
- package/dist/serialization/types/WorkflowResultEventOutputDataJson.js +10 -1
- package/dist/serialization/types/WorkflowResultEventOutputDataNumber.js +10 -1
- package/dist/serialization/types/WorkflowResultEventOutputDataSearchResults.js +11 -2
- package/dist/serialization/types/WorkflowResultEventOutputDataString.js +10 -1
- package/dist/serialization/types/WorkflowStreamEvent.js +11 -2
- package/dist/serialization/types/index.d.ts +0 -2
- package/dist/serialization/types/index.js +0 -2
- package/errors/VellumError.js +14 -3
- package/package.json +4 -3
- package/serialization/client/requests/ExecuteWorkflowStreamRequest.js +11 -2
- package/serialization/client/requests/GenerateBodyRequest.js +11 -2
- package/serialization/client/requests/GenerateStreamBodyRequest.js +11 -2
- package/serialization/client/requests/SearchRequestBodyRequest.js +10 -1
- package/serialization/client/requests/SubmitCompletionActualsRequest.js +10 -1
- package/serialization/client/requests/SubmitWorkflowExecutionActualsRequest.js +10 -1
- package/serialization/resources/documentIndexes/client/requests/DocumentIndexCreateRequest.js +11 -2
- package/serialization/resources/documents/client/requests/PatchedDocumentUpdateRequest.js +10 -1
- package/serialization/resources/index.d.ts +0 -2
- package/serialization/resources/index.js +1 -3
- package/serialization/resources/registeredPrompts/client/requests/RegisterPromptRequestRequest.d.ts +1 -1
- package/serialization/resources/registeredPrompts/client/requests/RegisterPromptRequestRequest.js +12 -3
- package/serialization/resources/sandboxes/client/requests/UpsertSandboxScenarioRequestRequest.js +11 -2
- package/serialization/resources/testSuites/client/requests/TestSuiteTestCaseRequest.js +10 -1
- package/serialization/types/ApiNodeResult.js +10 -1
- package/serialization/types/ChatMessage.js +10 -1
- package/serialization/types/ChatMessageRequest.js +10 -1
- package/serialization/types/ConditionalNodeResult.js +10 -1
- package/serialization/types/DeploymentRead.js +12 -3
- package/serialization/types/DocumentDocumentToDocumentIndex.js +10 -1
- package/serialization/types/DocumentIndexRead.js +11 -2
- package/serialization/types/DocumentRead.js +12 -3
- package/serialization/types/EnrichedNormalizedCompletion.d.ts +3 -1
- package/serialization/types/EnrichedNormalizedCompletion.js +15 -4
- package/serialization/types/GenerateOptionsRequest.js +10 -1
- package/serialization/types/GenerateRequest.js +10 -1
- package/serialization/types/GenerateResponse.js +10 -1
- package/serialization/types/GenerateResult.js +11 -2
- package/serialization/types/GenerateResultData.js +10 -1
- package/serialization/types/GenerateStreamResponse.js +10 -1
- package/serialization/types/GenerateStreamResult.js +11 -2
- package/serialization/types/GenerateStreamResultData.js +10 -1
- package/serialization/types/MetadataFilterConfigRequest.js +12 -3
- package/serialization/types/MetadataFilterRuleRequest.js +12 -3
- package/serialization/types/ModelVersionBuildConfig.js +10 -1
- package/serialization/types/ModelVersionExecConfig.js +12 -3
- package/serialization/types/ModelVersionRead.js +13 -4
- package/serialization/types/NodeInputCompiledChatHistoryValue.js +10 -1
- package/serialization/types/NodeInputCompiledErrorValue.js +10 -1
- package/serialization/types/NodeInputCompiledSearchResultsValue.js +10 -1
- package/serialization/types/NodeInputVariableCompiledValue.js +15 -6
- package/serialization/types/NormalizedLogProbs.js +10 -1
- package/serialization/types/PaginatedSlimDocumentList.js +10 -1
- package/serialization/types/PromptNodeResult.js +10 -1
- package/serialization/types/PromptTemplateBlock.js +11 -2
- package/serialization/types/PromptTemplateBlockData.js +10 -1
- package/serialization/types/PromptTemplateBlockDataRequest.js +10 -1
- package/serialization/types/PromptTemplateBlockProperties.js +12 -3
- package/serialization/types/PromptTemplateBlockPropertiesRequest.js +12 -3
- package/serialization/types/PromptTemplateBlockRequest.js +11 -2
- package/serialization/types/ProviderEnum.d.ts +1 -1
- package/serialization/types/ProviderEnum.js +3 -0
- package/serialization/types/RegisterPromptPromptInfoRequest.d.ts +0 -1
- package/serialization/types/RegisterPromptPromptInfoRequest.js +11 -3
- package/serialization/types/RegisterPromptResponse.d.ts +1 -0
- package/serialization/types/RegisterPromptResponse.js +15 -5
- package/serialization/types/RegisteredPromptInputVariableRequest.js +10 -1
- package/serialization/types/SandboxMetricInputParams.js +10 -1
- package/serialization/types/SandboxMetricInputParamsRequest.js +10 -1
- package/serialization/types/SandboxScenario.js +11 -2
- package/serialization/types/ScenarioInput.js +11 -2
- package/serialization/types/ScenarioInputRequest.js +11 -2
- package/serialization/types/SearchFiltersRequest.js +10 -1
- package/serialization/types/SearchNodeResult.js +10 -1
- package/serialization/types/SearchNodeResultData.js +10 -1
- package/serialization/types/SearchRequestOptionsRequest.js +12 -3
- package/serialization/types/SearchResponse.js +10 -1
- package/serialization/types/SearchResult.js +10 -1
- package/serialization/types/SlimDocument.js +13 -4
- package/serialization/types/SubmitWorkflowExecutionActualRequest.js +12 -3
- package/serialization/types/TemplatingNodeChatHistoryResult.js +10 -1
- package/serialization/types/TemplatingNodeErrorResult.js +10 -1
- package/serialization/types/TemplatingNodeResult.js +10 -1
- package/serialization/types/TemplatingNodeResultData.js +10 -1
- package/serialization/types/TemplatingNodeResultOutput.js +15 -6
- package/serialization/types/TemplatingNodeSearchResultsResult.js +10 -1
- package/serialization/types/TerminalNodeChatHistoryResult.js +10 -1
- package/serialization/types/TerminalNodeErrorResult.js +10 -1
- package/serialization/types/TerminalNodeResult.js +10 -1
- package/serialization/types/TerminalNodeResultData.js +10 -1
- package/serialization/types/TerminalNodeResultOutput.js +15 -6
- package/serialization/types/TerminalNodeSearchResultsResult.js +10 -1
- package/serialization/types/TestSuiteTestCase.js +10 -1
- package/serialization/types/VellumError.js +10 -1
- package/serialization/types/VellumVariable.js +10 -1
- package/serialization/types/WorkflowEventError.js +10 -1
- package/serialization/types/WorkflowExecutionActualChatHistoryRequest.js +10 -1
- package/serialization/types/WorkflowExecutionNodeResultEvent.js +10 -1
- package/serialization/types/WorkflowExecutionWorkflowResultEvent.js +10 -1
- package/serialization/types/WorkflowNodeResultData.js +15 -6
- package/serialization/types/WorkflowNodeResultEvent.js +13 -4
- package/serialization/types/WorkflowRequestChatHistoryInputRequest.js +10 -1
- package/serialization/types/WorkflowRequestInputRequest.js +12 -3
- package/serialization/types/WorkflowResultEvent.js +12 -3
- package/serialization/types/WorkflowResultEventOutputData.js +15 -6
- package/serialization/types/WorkflowResultEventOutputDataChatHistory.js +11 -2
- package/serialization/types/WorkflowResultEventOutputDataError.js +11 -2
- package/serialization/types/WorkflowResultEventOutputDataJson.js +10 -1
- package/serialization/types/WorkflowResultEventOutputDataNumber.js +10 -1
- package/serialization/types/WorkflowResultEventOutputDataSearchResults.js +11 -2
- package/serialization/types/WorkflowResultEventOutputDataString.js +10 -1
- package/serialization/types/WorkflowStreamEvent.js +11 -2
- package/serialization/types/index.d.ts +0 -2
- package/serialization/types/index.js +0 -2
- package/api/resources/modelVersions/client/requests/ModelVersionCompilePromptRequestRequest.d.ts +0 -7
- package/api/resources/modelVersions/client/requests/ModelVersionCompilePromptRequestRequest.js +0 -5
- package/api/resources/modelVersions/client/requests/index.d.ts +0 -1
- package/api/resources/modelVersions/client/requests/index.js +0 -2
- package/api/types/ModelVersionCompilePromptResponse.d.ts +0 -8
- package/api/types/ModelVersionCompilePromptResponse.js +0 -5
- package/api/types/ModelVersionCompiledPrompt.d.ts +0 -9
- package/api/types/ModelVersionCompiledPrompt.js +0 -5
- package/core/callback-queue/CallbackQueue.d.ts +0 -6
- package/core/callback-queue/CallbackQueue.js +0 -20
- package/core/callback-queue/index.d.ts +0 -1
- package/core/callback-queue/index.js +0 -5
- package/dist/api/resources/modelVersions/client/requests/ModelVersionCompilePromptRequestRequest.d.ts +0 -7
- package/dist/api/resources/modelVersions/client/requests/ModelVersionCompilePromptRequestRequest.js +0 -5
- package/dist/api/resources/modelVersions/client/requests/index.d.ts +0 -1
- package/dist/api/resources/modelVersions/client/requests/index.js +0 -2
- package/dist/api/types/ModelVersionCompilePromptResponse.d.ts +0 -8
- package/dist/api/types/ModelVersionCompilePromptResponse.js +0 -5
- package/dist/api/types/ModelVersionCompiledPrompt.d.ts +0 -9
- package/dist/api/types/ModelVersionCompiledPrompt.js +0 -5
- package/dist/core/callback-queue/CallbackQueue.d.ts +0 -6
- package/dist/core/callback-queue/CallbackQueue.js +0 -20
- package/dist/core/callback-queue/index.d.ts +0 -1
- package/dist/core/callback-queue/index.js +0 -5
- package/dist/serialization/resources/modelVersions/client/index.d.ts +0 -1
- package/dist/serialization/resources/modelVersions/client/index.js +0 -17
- package/dist/serialization/resources/modelVersions/client/requests/ModelVersionCompilePromptRequestRequest.d.ts +0 -12
- package/dist/serialization/resources/modelVersions/client/requests/ModelVersionCompilePromptRequestRequest.js +0 -33
- package/dist/serialization/resources/modelVersions/client/requests/index.d.ts +0 -1
- package/dist/serialization/resources/modelVersions/client/requests/index.js +0 -5
- package/dist/serialization/resources/modelVersions/index.d.ts +0 -1
- package/dist/serialization/resources/modelVersions/index.js +0 -17
- package/dist/serialization/types/ModelVersionCompilePromptResponse.d.ts +0 -12
- package/dist/serialization/types/ModelVersionCompilePromptResponse.js +0 -33
- package/dist/serialization/types/ModelVersionCompiledPrompt.d.ts +0 -13
- package/dist/serialization/types/ModelVersionCompiledPrompt.js +0 -34
- package/serialization/resources/modelVersions/client/index.d.ts +0 -1
- package/serialization/resources/modelVersions/client/index.js +0 -17
- package/serialization/resources/modelVersions/client/requests/ModelVersionCompilePromptRequestRequest.d.ts +0 -12
- package/serialization/resources/modelVersions/client/requests/ModelVersionCompilePromptRequestRequest.js +0 -33
- package/serialization/resources/modelVersions/client/requests/index.d.ts +0 -1
- package/serialization/resources/modelVersions/client/requests/index.js +0 -5
- package/serialization/resources/modelVersions/index.d.ts +0 -1
- package/serialization/resources/modelVersions/index.js +0 -17
- package/serialization/types/ModelVersionCompilePromptResponse.d.ts +0 -12
- package/serialization/types/ModelVersionCompilePromptResponse.js +0 -33
- package/serialization/types/ModelVersionCompiledPrompt.d.ts +0 -13
- package/serialization/types/ModelVersionCompiledPrompt.js +0 -34
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.getObjectUtils = exports.object = void 0;
|
|
4
13
|
const Schema_1 = require("../../Schema");
|
|
5
14
|
const entries_1 = require("../../utils/entries");
|
|
6
15
|
const filterObject_1 = require("../../utils/filterObject");
|
|
16
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
7
17
|
const isPlainObject_1 = require("../../utils/isPlainObject");
|
|
8
18
|
const keys_1 = require("../../utils/keys");
|
|
19
|
+
const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
|
|
9
20
|
const partition_1 = require("../../utils/partition");
|
|
10
21
|
const object_like_1 = require("../object-like");
|
|
11
22
|
const schema_utils_1 = require("../schema-utils");
|
|
@@ -14,7 +25,7 @@ function object(schemas) {
|
|
|
14
25
|
const baseSchema = {
|
|
15
26
|
_getRawProperties: () => Promise.resolve(Object.entries(schemas).map(([parsedKey, propertySchema]) => (0, property_1.isProperty)(propertySchema) ? propertySchema.rawKey : parsedKey)),
|
|
16
27
|
_getParsedProperties: () => Promise.resolve((0, keys_1.keys)(schemas)),
|
|
17
|
-
parse:
|
|
28
|
+
parse: (raw, opts) => __awaiter(this, void 0, void 0, function* () {
|
|
18
29
|
const rawKeyToProperty = {};
|
|
19
30
|
const requiredKeys = [];
|
|
20
31
|
for (const [parsedKey, schemaOrObjectProperty] of (0, entries_1.entries)(schemas)) {
|
|
@@ -28,7 +39,7 @@ function object(schemas) {
|
|
|
28
39
|
valueSchema,
|
|
29
40
|
};
|
|
30
41
|
rawKeyToProperty[rawKey] = property;
|
|
31
|
-
if (
|
|
42
|
+
if (yield isSchemaRequired(valueSchema)) {
|
|
32
43
|
requiredKeys.push(rawKey);
|
|
33
44
|
}
|
|
34
45
|
}
|
|
@@ -42,19 +53,24 @@ function object(schemas) {
|
|
|
42
53
|
}
|
|
43
54
|
return {
|
|
44
55
|
transformedKey: property.parsedKey,
|
|
45
|
-
transform: (propertyValue) =>
|
|
56
|
+
transform: (propertyValue) => {
|
|
57
|
+
var _a;
|
|
58
|
+
return property.valueSchema.parse(propertyValue, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), rawKey] }));
|
|
59
|
+
},
|
|
46
60
|
};
|
|
47
61
|
},
|
|
48
|
-
unrecognizedObjectKeys: opts
|
|
62
|
+
unrecognizedObjectKeys: opts === null || opts === void 0 ? void 0 : opts.unrecognizedObjectKeys,
|
|
63
|
+
skipValidation: opts === null || opts === void 0 ? void 0 : opts.skipValidation,
|
|
64
|
+
breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
|
|
49
65
|
});
|
|
50
|
-
},
|
|
51
|
-
json:
|
|
66
|
+
}),
|
|
67
|
+
json: (parsed, opts) => __awaiter(this, void 0, void 0, function* () {
|
|
52
68
|
const requiredKeys = [];
|
|
53
69
|
for (const [parsedKey, schemaOrObjectProperty] of (0, entries_1.entries)(schemas)) {
|
|
54
70
|
const valueSchema = (0, property_1.isProperty)(schemaOrObjectProperty)
|
|
55
71
|
? schemaOrObjectProperty.valueSchema
|
|
56
72
|
: schemaOrObjectProperty;
|
|
57
|
-
if (
|
|
73
|
+
if (yield isSchemaRequired(valueSchema)) {
|
|
58
74
|
requiredKeys.push(parsedKey);
|
|
59
75
|
}
|
|
60
76
|
}
|
|
@@ -70,168 +86,173 @@ function object(schemas) {
|
|
|
70
86
|
if ((0, property_1.isProperty)(property)) {
|
|
71
87
|
return {
|
|
72
88
|
transformedKey: property.rawKey,
|
|
73
|
-
transform: (propertyValue) =>
|
|
89
|
+
transform: (propertyValue) => {
|
|
90
|
+
var _a;
|
|
91
|
+
return property.valueSchema.json(propertyValue, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), parsedKey] }));
|
|
92
|
+
},
|
|
74
93
|
};
|
|
75
94
|
}
|
|
76
95
|
else {
|
|
77
96
|
return {
|
|
78
97
|
transformedKey: parsedKey,
|
|
79
|
-
transform: (propertyValue) =>
|
|
98
|
+
transform: (propertyValue) => {
|
|
99
|
+
var _a;
|
|
100
|
+
return property.json(propertyValue, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), parsedKey] }));
|
|
101
|
+
},
|
|
80
102
|
};
|
|
81
103
|
}
|
|
82
104
|
},
|
|
83
|
-
unrecognizedObjectKeys: opts
|
|
105
|
+
unrecognizedObjectKeys: opts === null || opts === void 0 ? void 0 : opts.unrecognizedObjectKeys,
|
|
106
|
+
skipValidation: opts === null || opts === void 0 ? void 0 : opts.skipValidation,
|
|
107
|
+
breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
|
|
84
108
|
});
|
|
85
|
-
},
|
|
109
|
+
}),
|
|
86
110
|
getType: () => Schema_1.SchemaType.OBJECT,
|
|
87
111
|
};
|
|
88
|
-
return {
|
|
89
|
-
...baseSchema,
|
|
90
|
-
...(0, schema_utils_1.getSchemaUtils)(baseSchema),
|
|
91
|
-
...(0, object_like_1.getObjectLikeUtils)(baseSchema),
|
|
92
|
-
...getObjectUtils(baseSchema),
|
|
93
|
-
};
|
|
112
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), getObjectUtils(baseSchema));
|
|
94
113
|
}
|
|
95
114
|
exports.object = object;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
function validateAndTransformObject({ value, requiredKeys, getProperty, unrecognizedObjectKeys = "fail", skipValidation = false, breadcrumbsPrefix = [], }) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
if (!(0, isPlainObject_1.isPlainObject)(value)) {
|
|
118
|
+
return {
|
|
119
|
+
ok: false,
|
|
120
|
+
errors: [
|
|
121
|
+
{
|
|
122
|
+
path: breadcrumbsPrefix,
|
|
123
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "object"),
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const missingRequiredKeys = new Set(requiredKeys);
|
|
129
|
+
const errors = [];
|
|
130
|
+
const transformed = {};
|
|
131
|
+
for (const [preTransformedKey, preTransformedItemValue] of Object.entries(value)) {
|
|
132
|
+
const property = getProperty(preTransformedKey);
|
|
133
|
+
if (property != null) {
|
|
134
|
+
missingRequiredKeys.delete(preTransformedKey);
|
|
135
|
+
const value = yield property.transform(preTransformedItemValue);
|
|
136
|
+
if (value.ok) {
|
|
137
|
+
transformed[property.transformedKey] = value.value;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
transformed[preTransformedKey] = preTransformedItemValue;
|
|
141
|
+
errors.push(...value.errors);
|
|
142
|
+
}
|
|
118
143
|
}
|
|
119
144
|
else {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
145
|
+
switch (unrecognizedObjectKeys) {
|
|
146
|
+
case "fail":
|
|
147
|
+
errors.push({
|
|
148
|
+
path: [...breadcrumbsPrefix, preTransformedKey],
|
|
149
|
+
message: `Unexpected key "${preTransformedKey}"`,
|
|
150
|
+
});
|
|
151
|
+
break;
|
|
152
|
+
case "strip":
|
|
153
|
+
break;
|
|
154
|
+
case "passthrough":
|
|
155
|
+
transformed[preTransformedKey] = preTransformedItemValue;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
124
158
|
}
|
|
125
159
|
}
|
|
160
|
+
errors.push(...requiredKeys
|
|
161
|
+
.filter((key) => missingRequiredKeys.has(key))
|
|
162
|
+
.map((key) => ({
|
|
163
|
+
path: breadcrumbsPrefix,
|
|
164
|
+
message: `Missing required key "${key}"`,
|
|
165
|
+
})));
|
|
166
|
+
if (errors.length === 0 || skipValidation) {
|
|
167
|
+
return {
|
|
168
|
+
ok: true,
|
|
169
|
+
value: transformed,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
126
172
|
else {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
message: `Unrecognized key "${preTransformedKey}"`,
|
|
132
|
-
});
|
|
133
|
-
break;
|
|
134
|
-
case "strip":
|
|
135
|
-
break;
|
|
136
|
-
case "passthrough":
|
|
137
|
-
transformed[preTransformedKey] = preTransformedItemValue;
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
173
|
+
return {
|
|
174
|
+
ok: false,
|
|
175
|
+
errors,
|
|
176
|
+
};
|
|
140
177
|
}
|
|
141
|
-
}
|
|
142
|
-
errors.push(...requiredKeys
|
|
143
|
-
.filter((key) => missingRequiredKeys.has(key))
|
|
144
|
-
.map((key) => ({
|
|
145
|
-
path: [],
|
|
146
|
-
message: `Missing required key "${key}"`,
|
|
147
|
-
})));
|
|
148
|
-
if (errors.length === 0) {
|
|
149
|
-
return {
|
|
150
|
-
ok: true,
|
|
151
|
-
value: transformed,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
return {
|
|
156
|
-
ok: false,
|
|
157
|
-
errors,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
178
|
+
});
|
|
160
179
|
}
|
|
161
180
|
function getObjectUtils(schema) {
|
|
162
181
|
return {
|
|
163
182
|
extend: (extension) => {
|
|
164
183
|
const baseSchema = {
|
|
165
|
-
_getParsedProperties:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
184
|
+
_getParsedProperties: () => __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
return [
|
|
186
|
+
...(yield schema._getParsedProperties()),
|
|
187
|
+
...(yield extension._getParsedProperties()),
|
|
188
|
+
];
|
|
189
|
+
}),
|
|
190
|
+
_getRawProperties: () => __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
return [
|
|
192
|
+
...(yield schema._getRawProperties()),
|
|
193
|
+
...(yield extension._getRawProperties()),
|
|
194
|
+
];
|
|
195
|
+
}),
|
|
196
|
+
parse: (raw, opts) => __awaiter(this, void 0, void 0, function* () {
|
|
174
197
|
return validateAndTransformExtendedObject({
|
|
175
|
-
extensionKeys:
|
|
198
|
+
extensionKeys: yield extension._getRawProperties(),
|
|
176
199
|
value: raw,
|
|
177
200
|
transformBase: (rawBase) => schema.parse(rawBase, opts),
|
|
178
201
|
transformExtension: (rawExtension) => extension.parse(rawExtension, opts),
|
|
179
202
|
});
|
|
180
|
-
},
|
|
181
|
-
json:
|
|
203
|
+
}),
|
|
204
|
+
json: (parsed, opts) => __awaiter(this, void 0, void 0, function* () {
|
|
182
205
|
return validateAndTransformExtendedObject({
|
|
183
|
-
extensionKeys:
|
|
206
|
+
extensionKeys: yield extension._getParsedProperties(),
|
|
184
207
|
value: parsed,
|
|
185
208
|
transformBase: (parsedBase) => schema.json(parsedBase, opts),
|
|
186
209
|
transformExtension: (parsedExtension) => extension.json(parsedExtension, opts),
|
|
187
210
|
});
|
|
188
|
-
},
|
|
211
|
+
}),
|
|
189
212
|
getType: () => Schema_1.SchemaType.OBJECT,
|
|
190
213
|
};
|
|
191
|
-
return {
|
|
192
|
-
...baseSchema,
|
|
193
|
-
...(0, schema_utils_1.getSchemaUtils)(baseSchema),
|
|
194
|
-
...(0, object_like_1.getObjectLikeUtils)(baseSchema),
|
|
195
|
-
...getObjectUtils(baseSchema),
|
|
196
|
-
};
|
|
214
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), getObjectUtils(baseSchema));
|
|
197
215
|
},
|
|
198
216
|
};
|
|
199
217
|
}
|
|
200
218
|
exports.getObjectUtils = getObjectUtils;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
219
|
+
function validateAndTransformExtendedObject({ extensionKeys, value, transformBase, transformExtension, }) {
|
|
220
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
const extensionPropertiesSet = new Set(extensionKeys);
|
|
222
|
+
const [extensionProperties, baseProperties] = (0, partition_1.partition)((0, keys_1.keys)(value), (key) => extensionPropertiesSet.has(key));
|
|
223
|
+
const transformedBase = yield transformBase((0, filterObject_1.filterObject)(value, baseProperties));
|
|
224
|
+
const transformedExtension = yield transformExtension((0, filterObject_1.filterObject)(value, extensionProperties));
|
|
225
|
+
if (transformedBase.ok && transformedExtension.ok) {
|
|
226
|
+
return {
|
|
227
|
+
ok: true,
|
|
228
|
+
value: Object.assign(Object.assign({}, transformedBase.value), transformedExtension.value),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
return {
|
|
233
|
+
ok: false,
|
|
234
|
+
errors: [
|
|
235
|
+
...(transformedBase.ok ? [] : transformedBase.errors),
|
|
236
|
+
...(transformedExtension.ok ? [] : transformedExtension.errors),
|
|
237
|
+
],
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
});
|
|
224
241
|
}
|
|
225
|
-
|
|
226
|
-
return
|
|
242
|
+
function isSchemaRequired(schema) {
|
|
243
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
244
|
+
return !(yield isSchemaOptional(schema));
|
|
245
|
+
});
|
|
227
246
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
247
|
+
function isSchemaOptional(schema) {
|
|
248
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
249
|
+
switch (yield schema.getType()) {
|
|
250
|
+
case Schema_1.SchemaType.ANY:
|
|
251
|
+
case Schema_1.SchemaType.UNKNOWN:
|
|
252
|
+
case Schema_1.SchemaType.OPTIONAL:
|
|
253
|
+
return true;
|
|
254
|
+
default:
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
237
258
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { inferParsedPropertySchema, inferRawObjectFromPropertySchemas, ObjectSchema, PropertySchemas } from "./types";
|
|
2
|
+
export declare function objectWithoutOptionalProperties<ParsedKeys extends string, T extends PropertySchemas<ParsedKeys>>(schemas: T): inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas<T>;
|
|
3
|
+
export declare type inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas<T extends PropertySchemas<keyof T>> = ObjectSchema<inferRawObjectFromPropertySchemas<T>, inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas<T>>;
|
|
4
|
+
export declare type inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas<T extends PropertySchemas<keyof T>> = {
|
|
5
|
+
[K in keyof T]: inferParsedPropertySchema<T[K]>;
|
|
6
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objectWithoutOptionalProperties = void 0;
|
|
4
|
+
const object_1 = require("./object");
|
|
5
|
+
function objectWithoutOptionalProperties(schemas) {
|
|
6
|
+
return (0, object_1.object)(schemas);
|
|
7
|
+
}
|
|
8
|
+
exports.objectWithoutOptionalProperties = objectWithoutOptionalProperties;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.withParsedProperties = exports.getObjectLikeUtils = void 0;
|
|
4
13
|
const filterObject_1 = require("../../utils/filterObject");
|
|
14
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
5
15
|
const isPlainObject_1 = require("../../utils/isPlainObject");
|
|
6
16
|
const schema_utils_1 = require("../schema-utils");
|
|
7
17
|
function getObjectLikeUtils(schema) {
|
|
@@ -15,33 +25,28 @@ exports.getObjectLikeUtils = getObjectLikeUtils;
|
|
|
15
25
|
*/
|
|
16
26
|
function withParsedProperties(objectLike, properties) {
|
|
17
27
|
const objectSchema = {
|
|
18
|
-
parse:
|
|
19
|
-
const parsedObject =
|
|
28
|
+
parse: (raw, opts) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const parsedObject = yield objectLike.parse(raw, opts);
|
|
20
30
|
if (!parsedObject.ok) {
|
|
21
31
|
return parsedObject;
|
|
22
32
|
}
|
|
23
33
|
const additionalProperties = Object.entries(properties).reduce((processed, [key, value]) => {
|
|
24
|
-
return {
|
|
25
|
-
...processed,
|
|
26
|
-
[key]: typeof value === "function" ? value(parsedObject.value) : value,
|
|
27
|
-
};
|
|
34
|
+
return Object.assign(Object.assign({}, processed), { [key]: typeof value === "function" ? value(parsedObject.value) : value });
|
|
28
35
|
}, {});
|
|
29
36
|
return {
|
|
30
37
|
ok: true,
|
|
31
|
-
value: {
|
|
32
|
-
...parsedObject.value,
|
|
33
|
-
...additionalProperties,
|
|
34
|
-
},
|
|
38
|
+
value: Object.assign(Object.assign({}, parsedObject.value), additionalProperties),
|
|
35
39
|
};
|
|
36
|
-
},
|
|
40
|
+
}),
|
|
37
41
|
json: (parsed, opts) => {
|
|
42
|
+
var _a;
|
|
38
43
|
if (!(0, isPlainObject_1.isPlainObject)(parsed)) {
|
|
39
44
|
return {
|
|
40
45
|
ok: false,
|
|
41
46
|
errors: [
|
|
42
47
|
{
|
|
43
|
-
path: [],
|
|
44
|
-
message:
|
|
48
|
+
path: (_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : [],
|
|
49
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(parsed, "object"),
|
|
45
50
|
},
|
|
46
51
|
],
|
|
47
52
|
};
|
|
@@ -53,10 +58,6 @@ function withParsedProperties(objectLike, properties) {
|
|
|
53
58
|
},
|
|
54
59
|
getType: () => objectLike.getType(),
|
|
55
60
|
};
|
|
56
|
-
return {
|
|
57
|
-
...objectSchema,
|
|
58
|
-
...(0, schema_utils_1.getSchemaUtils)(objectSchema),
|
|
59
|
-
...getObjectLikeUtils(objectSchema),
|
|
60
|
-
};
|
|
61
|
+
return Object.assign(Object.assign(Object.assign({}, objectSchema), (0, schema_utils_1.getSchemaUtils)(objectSchema)), getObjectLikeUtils(objectSchema));
|
|
61
62
|
}
|
|
62
63
|
exports.withParsedProperties = withParsedProperties;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { getObjectLikeUtils, withParsedProperties } from "./getObjectLikeUtils";
|
|
2
|
-
export {
|
|
2
|
+
export type { ObjectLikeSchema, ObjectLikeUtils } from "./types";
|
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.boolean = void 0;
|
|
4
4
|
const Schema_1 = require("../../Schema");
|
|
5
5
|
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
-
|
|
6
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
7
|
+
exports.boolean = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.BOOLEAN, (value, { breadcrumbsPrefix = [] } = {}) => {
|
|
7
8
|
if (typeof value === "boolean") {
|
|
8
9
|
return {
|
|
9
10
|
ok: true,
|
|
@@ -15,8 +16,8 @@ exports.boolean = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)
|
|
|
15
16
|
ok: false,
|
|
16
17
|
errors: [
|
|
17
18
|
{
|
|
18
|
-
path:
|
|
19
|
-
message:
|
|
19
|
+
path: breadcrumbsPrefix,
|
|
20
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "boolean"),
|
|
20
21
|
},
|
|
21
22
|
],
|
|
22
23
|
};
|
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.number = void 0;
|
|
4
4
|
const Schema_1 = require("../../Schema");
|
|
5
5
|
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
-
|
|
6
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
7
|
+
exports.number = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.NUMBER, (value, { breadcrumbsPrefix = [] } = {}) => {
|
|
7
8
|
if (typeof value === "number") {
|
|
8
9
|
return {
|
|
9
10
|
ok: true,
|
|
@@ -15,8 +16,8 @@ exports.number = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(
|
|
|
15
16
|
ok: false,
|
|
16
17
|
errors: [
|
|
17
18
|
{
|
|
18
|
-
path:
|
|
19
|
-
message:
|
|
19
|
+
path: breadcrumbsPrefix,
|
|
20
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "number"),
|
|
20
21
|
},
|
|
21
22
|
],
|
|
22
23
|
};
|
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.string = void 0;
|
|
4
4
|
const Schema_1 = require("../../Schema");
|
|
5
5
|
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
-
|
|
6
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
7
|
+
exports.string = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.STRING, (value, { breadcrumbsPrefix = [] } = {}) => {
|
|
7
8
|
if (typeof value === "string") {
|
|
8
9
|
return {
|
|
9
10
|
ok: true,
|
|
@@ -15,8 +16,8 @@ exports.string = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(
|
|
|
15
16
|
ok: false,
|
|
16
17
|
errors: [
|
|
17
18
|
{
|
|
18
|
-
path:
|
|
19
|
-
message:
|
|
19
|
+
path: breadcrumbsPrefix,
|
|
20
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "string"),
|
|
20
21
|
},
|
|
21
22
|
],
|
|
22
23
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { record } from "./record";
|
|
2
|
-
export {
|
|
2
|
+
export type { BaseRecordSchema, RecordSchema } from "./types";
|