@fern-api/venus-api-sdk 0.10.0 → 0.10.1-1-ged0356b
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 +14 -6
- package/Client.js +8 -9
- package/api/resources/commons/types/OrganizationId.d.ts +1 -1
- package/api/resources/commons/types/UserId.d.ts +1 -1
- package/api/resources/organization/client/Client.d.ts +116 -13
- package/api/resources/organization/client/Client.js +513 -236
- package/api/resources/organization/client/addUser.d.ts +1 -1
- package/api/resources/organization/client/addUser.js +27 -4
- package/api/resources/organization/client/create.d.ts +1 -1
- package/api/resources/organization/client/create.js +27 -4
- package/api/resources/organization/client/get.d.ts +1 -1
- package/api/resources/organization/client/get.js +26 -3
- package/api/resources/organization/client/getMyOrganizationFromScopedToken.d.ts +1 -1
- package/api/resources/organization/client/getMyOrganizationFromScopedToken.js +26 -3
- package/api/resources/organization/client/getOrgIdsFromToken.d.ts +1 -1
- package/api/resources/organization/client/getOrgIdsFromToken.js +25 -2
- package/api/resources/organization/client/inviteUser.d.ts +1 -1
- package/api/resources/organization/client/inviteUser.js +27 -4
- package/api/resources/organization/client/isMember.d.ts +1 -1
- package/api/resources/organization/client/isMember.js +25 -2
- package/api/resources/organization/client/removeUser.d.ts +1 -1
- package/api/resources/organization/client/removeUser.js +27 -4
- package/api/resources/organization/client/requests/AddUserToOrgRequest.d.ts +8 -1
- package/api/resources/organization/client/requests/CreateOrganizationRequest.d.ts +15 -1
- package/api/resources/organization/client/requests/GetMyOrganizationFromScopedToken.d.ts +6 -0
- package/api/resources/organization/client/requests/GetOrganizationRequest.d.ts +6 -0
- package/api/resources/organization/client/requests/InviteUserToOrgRequest.d.ts +8 -1
- package/api/resources/organization/client/requests/RemoveUserFromOrgRequest.d.ts +8 -1
- package/api/resources/organization/client/requests/UpdateOrganizationRequest.d.ts +31 -0
- package/api/resources/organization/client/requests/index.d.ts +7 -7
- package/api/resources/organization/client/update.d.ts +1 -1
- package/api/resources/organization/client/update.js +26 -3
- package/api/resources/organization/types/Organization.d.ts +1 -1
- package/api/resources/registry/client/Client.d.ts +48 -7
- package/api/resources/registry/client/Client.js +198 -87
- package/api/resources/registry/client/generateRegistryTokens.d.ts +1 -1
- package/api/resources/registry/client/generateRegistryTokens.js +27 -4
- package/api/resources/registry/client/hasRegistryPermission.d.ts +1 -1
- package/api/resources/registry/client/hasRegistryPermission.js +27 -4
- package/api/resources/registry/client/requests/CheckRegistryPermissionRequest.d.ts +11 -1
- package/api/resources/registry/client/requests/GenerateRegistryTokensRequest.d.ts +7 -1
- package/api/resources/registry/client/requests/RevokeTokenRequest.d.ts +8 -1
- package/api/resources/registry/client/requests/index.d.ts +3 -3
- package/api/resources/registry/client/revokeToken.d.ts +1 -1
- package/api/resources/registry/client/revokeToken.js +27 -4
- package/api/resources/registry/types/RegistryToken.d.ts +5 -28
- package/api/resources/registry/types/RegistryToken.js +0 -51
- package/api/resources/registry/types/RegistryTokens.d.ts +1 -1
- package/api/resources/user/client/Client.d.ts +30 -6
- package/api/resources/user/client/Client.js +107 -43
- package/api/resources/user/client/getMyOrganizations.d.ts +1 -1
- package/api/resources/user/client/getMyOrganizations.js +25 -2
- package/api/resources/user/client/getMyself.d.ts +1 -1
- package/api/resources/user/client/getMyself.js +25 -2
- package/api/resources/user/client/requests/GetUserOrganizationsRequest.d.ts +6 -0
- package/api/resources/user/client/requests/index.d.ts +1 -1
- package/api/resources/user/types/OrganizationsPage.d.ts +1 -1
- package/api/resources/user/types/User.d.ts +1 -1
- package/core/fetcher/APIResponse.d.ts +1 -0
- package/core/fetcher/Fetcher.d.ts +9 -2
- package/core/fetcher/Fetcher.js +78 -64
- package/core/fetcher/Supplier.js +11 -2
- package/core/fetcher/createRequestUrl.d.ts +1 -0
- package/core/fetcher/createRequestUrl.js +13 -0
- package/core/fetcher/getFetchFn.d.ts +4 -0
- package/core/fetcher/getFetchFn.js +59 -0
- package/core/fetcher/getHeader.d.ts +1 -0
- package/core/fetcher/getHeader.js +12 -0
- package/core/fetcher/getRequestBody.d.ts +7 -0
- package/core/fetcher/getRequestBody.js +23 -0
- package/core/fetcher/getResponseBody.d.ts +1 -0
- package/core/fetcher/getResponseBody.js +52 -0
- package/core/fetcher/index.d.ts +4 -2
- package/core/fetcher/index.js +3 -1
- package/core/fetcher/makeRequest.d.ts +1 -0
- package/core/fetcher/makeRequest.js +42 -0
- package/core/fetcher/requestWithRetries.d.ts +1 -0
- package/core/fetcher/requestWithRetries.js +32 -0
- package/core/fetcher/signals.d.ts +12 -0
- package/core/fetcher/signals.js +37 -0
- package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
- package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +22 -0
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +124 -0
- package/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
- package/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +50 -0
- package/core/index.d.ts +3 -2
- package/core/index.js +6 -5
- package/core/runtime/index.d.ts +1 -0
- package/core/runtime/index.js +5 -0
- package/core/runtime/runtime.d.ts +9 -0
- package/core/runtime/runtime.js +93 -0
- package/core/schemas/Schema.d.ts +44 -5
- package/core/schemas/Schema.js +3 -0
- package/core/schemas/builders/bigint/bigint.d.ts +2 -0
- package/core/schemas/builders/bigint/bigint.js +50 -0
- package/core/schemas/builders/bigint/index.d.ts +1 -0
- package/core/schemas/builders/bigint/index.js +5 -0
- package/core/schemas/builders/date/date.js +22 -14
- package/core/schemas/builders/enum/enum.js +17 -7
- package/core/schemas/builders/index.d.ts +2 -0
- package/core/schemas/builders/index.js +2 -0
- package/core/schemas/builders/lazy/index.d.ts +2 -1
- package/core/schemas/builders/lazy/lazy.d.ts +2 -2
- package/core/schemas/builders/lazy/lazy.js +6 -9
- package/core/schemas/builders/lazy/lazyObject.js +2 -11
- package/core/schemas/builders/list/list.js +16 -14
- 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 +65 -63
- package/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +6 -0
- package/core/schemas/builders/object/objectWithoutOptionalProperties.js +8 -0
- package/core/schemas/builders/object/types.d.ts +2 -2
- package/core/schemas/builders/object-like/getObjectLikeUtils.js +9 -17
- 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 +36 -32
- package/core/schemas/builders/record/types.d.ts +2 -3
- 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.d.ts +2 -2
- package/core/schemas/builders/schema-utils/getSchemaUtils.js +16 -16
- package/core/schemas/builders/schema-utils/index.d.ts +2 -1
- package/core/schemas/builders/set/set.js +10 -10
- package/core/schemas/builders/undiscriminated-union/index.d.ts +2 -0
- package/core/schemas/builders/undiscriminated-union/index.js +5 -0
- package/core/schemas/builders/undiscriminated-union/types.d.ts +4 -0
- package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts +3 -0
- package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +40 -0
- package/core/schemas/builders/union/index.d.ts +3 -2
- package/core/schemas/builders/union/union.js +61 -31
- 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 +28 -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 +28 -0
- package/dist/Client.d.ts +31 -0
- package/dist/Client.js +27 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +17 -0
- package/dist/api/resources/commons/index.d.ts +1 -0
- package/dist/api/resources/commons/index.js +17 -0
- package/dist/api/resources/commons/types/OrganizationId.d.ts +8 -0
- package/dist/api/resources/commons/types/OrganizationId.js +10 -0
- package/dist/api/resources/commons/types/UserId.d.ts +8 -0
- package/dist/api/resources/commons/types/UserId.js +10 -0
- package/dist/api/resources/commons/types/index.d.ts +2 -0
- package/dist/api/resources/commons/types/index.js +18 -0
- package/dist/api/resources/index.d.ts +11 -0
- package/dist/api/resources/index.js +40 -0
- package/dist/api/resources/organization/client/Client.d.ts +130 -0
- package/dist/api/resources/organization/client/Client.js +582 -0
- package/dist/api/resources/organization/client/addUser.d.ts +32 -0
- package/dist/api/resources/organization/client/addUser.js +67 -0
- package/dist/api/resources/organization/client/create.d.ts +32 -0
- package/dist/api/resources/organization/client/create.js +67 -0
- package/dist/api/resources/organization/client/get.d.ts +27 -0
- package/dist/api/resources/organization/client/get.js +57 -0
- package/dist/api/resources/organization/client/getMyOrganizationFromScopedToken.d.ts +27 -0
- package/dist/api/resources/organization/client/getMyOrganizationFromScopedToken.js +57 -0
- package/dist/api/resources/organization/client/getOrgIdsFromToken.d.ts +22 -0
- package/dist/api/resources/organization/client/getOrgIdsFromToken.js +47 -0
- package/dist/api/resources/organization/client/index.d.ts +10 -0
- package/dist/api/resources/organization/client/index.js +39 -0
- package/dist/api/resources/organization/client/inviteUser.d.ts +32 -0
- package/dist/api/resources/organization/client/inviteUser.js +67 -0
- package/dist/api/resources/organization/client/isMember.d.ts +22 -0
- package/dist/api/resources/organization/client/isMember.js +47 -0
- package/dist/api/resources/organization/client/removeUser.d.ts +32 -0
- package/dist/api/resources/organization/client/removeUser.js +67 -0
- package/dist/api/resources/organization/client/requests/AddUserToOrgRequest.d.ts +15 -0
- package/dist/api/resources/organization/client/requests/AddUserToOrgRequest.js +5 -0
- package/dist/api/resources/organization/client/requests/CreateOrganizationRequest.d.ts +23 -0
- package/dist/api/resources/organization/client/requests/CreateOrganizationRequest.js +5 -0
- package/dist/api/resources/organization/client/requests/GetMyOrganizationFromScopedToken.d.ts +12 -0
- package/dist/api/resources/organization/client/requests/GetMyOrganizationFromScopedToken.js +5 -0
- package/dist/api/resources/organization/client/requests/GetOrganizationRequest.d.ts +12 -0
- package/dist/api/resources/organization/client/requests/GetOrganizationRequest.js +5 -0
- package/dist/api/resources/organization/client/requests/InviteUserToOrgRequest.d.ts +15 -0
- package/dist/api/resources/organization/client/requests/InviteUserToOrgRequest.js +5 -0
- package/dist/api/resources/organization/client/requests/RemoveUserFromOrgRequest.d.ts +15 -0
- package/dist/api/resources/organization/client/requests/RemoveUserFromOrgRequest.js +5 -0
- package/dist/api/resources/organization/client/requests/UpdateOrganizationRequest.d.ts +49 -0
- package/dist/api/resources/organization/client/requests/UpdateOrganizationRequest.js +5 -0
- package/dist/api/resources/organization/client/requests/index.d.ts +7 -0
- package/dist/api/resources/organization/client/requests/index.js +2 -0
- package/dist/api/resources/organization/client/update.d.ts +27 -0
- package/dist/api/resources/organization/client/update.js +57 -0
- package/dist/api/resources/organization/index.d.ts +2 -0
- package/dist/api/resources/organization/index.js +18 -0
- package/dist/api/resources/organization/types/LightweightUser.d.ts +9 -0
- package/dist/api/resources/organization/types/LightweightUser.js +5 -0
- package/dist/api/resources/organization/types/Organization.d.ts +35 -0
- package/dist/api/resources/organization/types/Organization.js +5 -0
- package/dist/api/resources/organization/types/index.d.ts +2 -0
- package/dist/api/resources/organization/types/index.js +18 -0
- package/dist/api/resources/registry/client/Client.d.ts +59 -0
- package/dist/api/resources/registry/client/Client.js +246 -0
- package/dist/api/resources/registry/client/generateRegistryTokens.d.ts +32 -0
- package/dist/api/resources/registry/client/generateRegistryTokens.js +67 -0
- package/dist/api/resources/registry/client/hasRegistryPermission.d.ts +32 -0
- package/dist/api/resources/registry/client/hasRegistryPermission.js +67 -0
- package/dist/api/resources/registry/client/index.d.ts +4 -0
- package/dist/api/resources/registry/client/index.js +33 -0
- package/dist/api/resources/registry/client/requests/CheckRegistryPermissionRequest.d.ts +18 -0
- package/dist/api/resources/registry/client/requests/CheckRegistryPermissionRequest.js +5 -0
- package/dist/api/resources/registry/client/requests/GenerateRegistryTokensRequest.d.ts +13 -0
- package/dist/api/resources/registry/client/requests/GenerateRegistryTokensRequest.js +5 -0
- package/dist/api/resources/registry/client/requests/RevokeTokenRequest.d.ts +15 -0
- package/dist/api/resources/registry/client/requests/RevokeTokenRequest.js +5 -0
- package/dist/api/resources/registry/client/requests/index.d.ts +3 -0
- package/dist/api/resources/registry/client/requests/index.js +2 -0
- package/dist/api/resources/registry/client/revokeToken.d.ts +32 -0
- package/dist/api/resources/registry/client/revokeToken.js +67 -0
- package/dist/api/resources/registry/index.d.ts +2 -0
- package/dist/api/resources/registry/index.js +18 -0
- package/dist/api/resources/registry/types/MavenRegistryToken.d.ts +7 -0
- package/dist/api/resources/registry/types/MavenRegistryToken.js +5 -0
- package/dist/api/resources/registry/types/NpmRegistryToken.d.ts +6 -0
- package/dist/api/resources/registry/types/NpmRegistryToken.js +5 -0
- package/dist/api/resources/registry/types/PypiRegistryToken.d.ts +7 -0
- package/dist/api/resources/registry/types/PypiRegistryToken.js +5 -0
- package/dist/api/resources/registry/types/RegistryToken.d.ts +16 -0
- package/dist/api/resources/registry/types/RegistryToken.js +5 -0
- package/dist/api/resources/registry/types/RegistryTokens.d.ts +9 -0
- package/dist/api/resources/registry/types/RegistryTokens.js +5 -0
- package/dist/api/resources/registry/types/index.d.ts +5 -0
- package/dist/api/resources/registry/types/index.js +21 -0
- package/dist/api/resources/user/client/Client.d.ts +41 -0
- package/dist/api/resources/user/client/Client.js +151 -0
- package/dist/api/resources/user/client/getMyOrganizations.d.ts +22 -0
- package/dist/api/resources/user/client/getMyOrganizations.js +47 -0
- package/dist/api/resources/user/client/getMyself.d.ts +22 -0
- package/dist/api/resources/user/client/getMyself.js +47 -0
- package/dist/api/resources/user/client/index.d.ts +3 -0
- package/dist/api/resources/user/client/index.js +32 -0
- package/dist/api/resources/user/client/requests/GetUserOrganizationsRequest.d.ts +12 -0
- package/dist/api/resources/user/client/requests/GetUserOrganizationsRequest.js +5 -0
- package/dist/api/resources/user/client/requests/index.d.ts +1 -0
- package/dist/api/resources/user/client/requests/index.js +2 -0
- package/dist/api/resources/user/index.d.ts +2 -0
- package/dist/api/resources/user/index.js +18 -0
- package/dist/api/resources/user/types/OrganizationsPage.d.ts +8 -0
- package/dist/api/resources/user/types/OrganizationsPage.js +5 -0
- package/dist/api/resources/user/types/User.d.ts +10 -0
- package/dist/api/resources/user/types/User.js +5 -0
- package/dist/api/resources/user/types/index.d.ts +2 -0
- package/dist/api/resources/user/types/index.js +18 -0
- package/dist/core/auth/BasicAuth.d.ts +8 -0
- package/dist/core/auth/BasicAuth.js +26 -0
- package/dist/core/auth/BearerToken.d.ts +5 -0
- package/dist/core/auth/BearerToken.js +15 -0
- package/dist/core/auth/index.d.ts +2 -0
- package/dist/core/auth/index.js +7 -0
- package/dist/core/fetcher/APIResponse.d.ts +10 -0
- package/dist/core/fetcher/APIResponse.js +2 -0
- package/dist/core/fetcher/Fetcher.d.ts +39 -0
- package/dist/core/fetcher/Fetcher.js +99 -0
- package/dist/core/fetcher/Supplier.d.ts +4 -0
- package/dist/core/fetcher/Supplier.js +22 -0
- package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
- package/dist/core/fetcher/createRequestUrl.js +13 -0
- package/dist/core/fetcher/getFetchFn.d.ts +4 -0
- package/dist/core/fetcher/getFetchFn.js +59 -0
- package/dist/core/fetcher/getHeader.d.ts +1 -0
- package/dist/core/fetcher/getHeader.js +12 -0
- package/dist/core/fetcher/getRequestBody.d.ts +7 -0
- package/dist/core/fetcher/getRequestBody.js +23 -0
- package/dist/core/fetcher/getResponseBody.d.ts +1 -0
- package/dist/core/fetcher/getResponseBody.js +52 -0
- package/dist/core/fetcher/index.d.ts +5 -0
- package/dist/core/fetcher/index.js +9 -0
- package/dist/core/fetcher/makeRequest.d.ts +1 -0
- package/dist/core/fetcher/makeRequest.js +42 -0
- package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/core/fetcher/requestWithRetries.js +32 -0
- package/dist/core/fetcher/signals.d.ts +12 -0
- package/dist/core/fetcher/signals.js +37 -0
- package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
- package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +22 -0
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +124 -0
- package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
- package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +50 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +33 -0
- package/dist/core/runtime/index.d.ts +1 -0
- package/dist/core/runtime/index.js +5 -0
- package/dist/core/runtime/runtime.d.ts +9 -0
- package/dist/core/runtime/runtime.js +93 -0
- package/dist/core/schemas/Schema.d.ts +85 -0
- package/dist/core/schemas/Schema.js +22 -0
- package/dist/core/schemas/builders/bigint/bigint.d.ts +2 -0
- package/dist/core/schemas/builders/bigint/bigint.js +50 -0
- package/dist/core/schemas/builders/bigint/index.d.ts +1 -0
- package/dist/core/schemas/builders/bigint/index.js +5 -0
- package/dist/core/schemas/builders/date/date.d.ts +2 -0
- package/dist/core/schemas/builders/date/date.js +63 -0
- package/dist/core/schemas/builders/date/index.d.ts +1 -0
- package/dist/core/schemas/builders/date/index.js +5 -0
- package/dist/core/schemas/builders/enum/enum.d.ts +2 -0
- package/dist/core/schemas/builders/enum/enum.js +39 -0
- package/dist/core/schemas/builders/enum/index.d.ts +1 -0
- package/dist/core/schemas/builders/enum/index.js +5 -0
- package/dist/core/schemas/builders/index.d.ts +14 -0
- package/dist/core/schemas/builders/index.js +30 -0
- package/dist/core/schemas/builders/lazy/index.d.ts +3 -0
- package/dist/core/schemas/builders/lazy/index.js +7 -0
- package/dist/core/schemas/builders/lazy/lazy.d.ts +5 -0
- package/dist/core/schemas/builders/lazy/lazy.js +25 -0
- package/dist/core/schemas/builders/lazy/lazyObject.d.ts +3 -0
- package/dist/core/schemas/builders/lazy/lazyObject.js +12 -0
- package/dist/core/schemas/builders/list/index.d.ts +1 -0
- package/dist/core/schemas/builders/list/index.js +5 -0
- package/dist/core/schemas/builders/list/list.d.ts +2 -0
- package/dist/core/schemas/builders/list/list.js +55 -0
- 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 +2 -0
- package/dist/core/schemas/builders/literals/index.js +7 -0
- package/dist/core/schemas/builders/literals/stringLiteral.d.ts +2 -0
- package/dist/core/schemas/builders/literals/stringLiteral.js +29 -0
- package/dist/core/schemas/builders/object/index.d.ts +6 -0
- package/dist/core/schemas/builders/object/index.js +11 -0
- package/dist/core/schemas/builders/object/object.d.ts +3 -0
- package/dist/core/schemas/builders/object/object.js +233 -0
- 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/property.d.ts +8 -0
- package/dist/core/schemas/builders/object/property.js +16 -0
- package/dist/core/schemas/builders/object/types.d.ts +26 -0
- package/dist/core/schemas/builders/object/types.js +2 -0
- package/dist/core/schemas/builders/object-like/getObjectLikeUtils.d.ts +9 -0
- package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +54 -0
- package/dist/core/schemas/builders/object-like/index.d.ts +2 -0
- package/dist/core/schemas/builders/object-like/index.js +6 -0
- package/dist/core/schemas/builders/object-like/types.d.ts +7 -0
- package/dist/core/schemas/builders/object-like/types.js +2 -0
- package/dist/core/schemas/builders/primitives/any.d.ts +1 -0
- package/dist/core/schemas/builders/primitives/any.js +6 -0
- package/dist/core/schemas/builders/primitives/boolean.d.ts +1 -0
- package/dist/core/schemas/builders/primitives/boolean.js +25 -0
- package/dist/core/schemas/builders/primitives/index.d.ts +5 -0
- package/dist/core/schemas/builders/primitives/index.js +13 -0
- package/dist/core/schemas/builders/primitives/number.d.ts +1 -0
- package/dist/core/schemas/builders/primitives/number.js +25 -0
- package/dist/core/schemas/builders/primitives/string.d.ts +1 -0
- package/dist/core/schemas/builders/primitives/string.js +25 -0
- package/dist/core/schemas/builders/primitives/unknown.d.ts +1 -0
- package/dist/core/schemas/builders/primitives/unknown.js +6 -0
- package/dist/core/schemas/builders/record/index.d.ts +2 -0
- package/dist/core/schemas/builders/record/index.js +5 -0
- package/dist/core/schemas/builders/record/record.d.ts +3 -0
- package/dist/core/schemas/builders/record/record.js +95 -0
- package/dist/core/schemas/builders/record/types.d.ts +4 -0
- package/dist/core/schemas/builders/record/types.js +2 -0
- package/dist/core/schemas/builders/schema-utils/JsonError.d.ts +5 -0
- package/dist/core/schemas/builders/schema-utils/JsonError.js +12 -0
- package/dist/core/schemas/builders/schema-utils/ParseError.d.ts +5 -0
- package/dist/core/schemas/builders/schema-utils/ParseError.js +12 -0
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +17 -0
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +82 -0
- package/dist/core/schemas/builders/schema-utils/index.d.ts +4 -0
- package/dist/core/schemas/builders/schema-utils/index.js +11 -0
- package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts +2 -0
- package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js +10 -0
- package/dist/core/schemas/builders/set/index.d.ts +1 -0
- package/dist/core/schemas/builders/set/index.js +5 -0
- package/dist/core/schemas/builders/set/set.d.ts +2 -0
- package/dist/core/schemas/builders/set/set.js +44 -0
- package/dist/core/schemas/builders/undiscriminated-union/index.d.ts +2 -0
- package/dist/core/schemas/builders/undiscriminated-union/index.js +5 -0
- package/dist/core/schemas/builders/undiscriminated-union/types.d.ts +4 -0
- package/dist/core/schemas/builders/undiscriminated-union/types.js +2 -0
- package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts +3 -0
- package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +40 -0
- package/dist/core/schemas/builders/union/discriminant.d.ts +5 -0
- package/dist/core/schemas/builders/union/discriminant.js +10 -0
- package/dist/core/schemas/builders/union/index.d.ts +4 -0
- package/dist/core/schemas/builders/union/index.js +7 -0
- package/dist/core/schemas/builders/union/types.d.ts +13 -0
- package/dist/core/schemas/builders/union/types.js +2 -0
- package/dist/core/schemas/builders/union/union.d.ts +4 -0
- package/dist/core/schemas/builders/union/union.js +130 -0
- package/dist/core/schemas/index.d.ts +2 -0
- package/dist/core/schemas/index.js +17 -0
- package/dist/core/schemas/utils/MaybePromise.d.ts +1 -0
- package/dist/core/schemas/utils/MaybePromise.js +2 -0
- package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +7 -0
- package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.js +2 -0
- package/dist/core/schemas/utils/createIdentitySchemaCreator.d.ts +2 -0
- package/dist/core/schemas/utils/createIdentitySchemaCreator.js +16 -0
- package/dist/core/schemas/utils/entries.d.ts +1 -0
- package/dist/core/schemas/utils/entries.js +7 -0
- package/dist/core/schemas/utils/filterObject.d.ts +1 -0
- package/dist/core/schemas/utils/filterObject.js +14 -0
- package/dist/core/schemas/utils/getErrorMessageForIncorrectType.d.ts +1 -0
- package/dist/core/schemas/utils/getErrorMessageForIncorrectType.js +28 -0
- package/dist/core/schemas/utils/isPlainObject.d.ts +1 -0
- package/dist/core/schemas/utils/isPlainObject.js +18 -0
- package/dist/core/schemas/utils/keys.d.ts +1 -0
- package/dist/core/schemas/utils/keys.js +7 -0
- package/dist/core/schemas/utils/maybeSkipValidation.d.ts +2 -0
- package/dist/core/schemas/utils/maybeSkipValidation.js +28 -0
- package/dist/core/schemas/utils/partition.d.ts +1 -0
- package/dist/core/schemas/utils/partition.js +16 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +29 -0
- package/dist/serialization/index.d.ts +1 -0
- package/dist/serialization/index.js +17 -0
- package/dist/serialization/resources/commons/index.d.ts +1 -0
- package/dist/serialization/resources/commons/index.js +17 -0
- package/dist/serialization/resources/commons/types/OrganizationId.d.ts +10 -0
- package/dist/serialization/resources/commons/types/OrganizationId.js +35 -0
- package/dist/serialization/resources/commons/types/UserId.d.ts +10 -0
- package/dist/serialization/resources/commons/types/UserId.js +37 -0
- package/dist/serialization/resources/commons/types/index.d.ts +2 -0
- package/dist/serialization/resources/commons/types/index.js +18 -0
- package/dist/serialization/resources/index.d.ts +10 -0
- package/dist/serialization/resources/index.js +39 -0
- package/dist/serialization/resources/organization/client/addUser.d.ts +16 -0
- package/dist/serialization/resources/organization/client/addUser.js +61 -0
- package/dist/serialization/resources/organization/client/create.d.ts +16 -0
- package/dist/serialization/resources/organization/client/create.js +61 -0
- package/dist/serialization/resources/organization/client/get.d.ts +13 -0
- package/dist/serialization/resources/organization/client/get.js +58 -0
- package/dist/serialization/resources/organization/client/getMyOrganizationFromScopedToken.d.ts +13 -0
- package/dist/serialization/resources/organization/client/getMyOrganizationFromScopedToken.js +58 -0
- package/dist/serialization/resources/organization/client/getOrgIdsFromToken.d.ts +11 -0
- package/dist/serialization/resources/organization/client/getOrgIdsFromToken.js +32 -0
- package/dist/serialization/resources/organization/client/index.d.ts +10 -0
- package/dist/serialization/resources/organization/client/index.js +39 -0
- package/dist/serialization/resources/organization/client/inviteUser.d.ts +16 -0
- package/dist/serialization/resources/organization/client/inviteUser.js +61 -0
- package/dist/serialization/resources/organization/client/isMember.d.ts +9 -0
- package/dist/serialization/resources/organization/client/isMember.js +31 -0
- package/dist/serialization/resources/organization/client/removeUser.d.ts +16 -0
- package/dist/serialization/resources/organization/client/removeUser.js +61 -0
- package/dist/serialization/resources/organization/client/requests/AddUserToOrgRequest.d.ts +15 -0
- package/dist/serialization/resources/organization/client/requests/AddUserToOrgRequest.js +36 -0
- package/dist/serialization/resources/organization/client/requests/CreateOrganizationRequest.d.ts +15 -0
- package/dist/serialization/resources/organization/client/requests/CreateOrganizationRequest.js +36 -0
- package/dist/serialization/resources/organization/client/requests/InviteUserToOrgRequest.d.ts +14 -0
- package/dist/serialization/resources/organization/client/requests/InviteUserToOrgRequest.js +35 -0
- package/dist/serialization/resources/organization/client/requests/RemoveUserFromOrgRequest.d.ts +14 -0
- package/dist/serialization/resources/organization/client/requests/RemoveUserFromOrgRequest.js +35 -0
- package/dist/serialization/resources/organization/client/requests/UpdateOrganizationRequest.d.ts +24 -0
- package/dist/serialization/resources/organization/client/requests/UpdateOrganizationRequest.js +45 -0
- package/dist/serialization/resources/organization/client/requests/index.d.ts +5 -0
- package/dist/serialization/resources/organization/client/requests/index.js +13 -0
- package/dist/serialization/resources/organization/client/update.d.ts +13 -0
- package/dist/serialization/resources/organization/client/update.js +58 -0
- package/dist/serialization/resources/organization/index.d.ts +2 -0
- package/dist/serialization/resources/organization/index.js +18 -0
- package/dist/serialization/resources/organization/types/LightweightUser.d.ts +15 -0
- package/dist/serialization/resources/organization/types/LightweightUser.js +36 -0
- package/dist/serialization/resources/organization/types/Organization.d.ts +30 -0
- package/dist/serialization/resources/organization/types/Organization.js +51 -0
- package/dist/serialization/resources/organization/types/index.d.ts +2 -0
- package/dist/serialization/resources/organization/types/index.js +18 -0
- package/dist/serialization/resources/registry/client/generateRegistryTokens.d.ts +16 -0
- package/dist/serialization/resources/registry/client/generateRegistryTokens.js +61 -0
- package/dist/serialization/resources/registry/client/hasRegistryPermission.d.ts +20 -0
- package/dist/serialization/resources/registry/client/hasRegistryPermission.js +62 -0
- package/dist/serialization/resources/registry/client/index.d.ts +4 -0
- package/dist/serialization/resources/registry/client/index.js +33 -0
- package/dist/serialization/resources/registry/client/requests/CheckRegistryPermissionRequest.d.ts +15 -0
- package/dist/serialization/resources/registry/client/requests/CheckRegistryPermissionRequest.js +36 -0
- package/dist/serialization/resources/registry/client/requests/GenerateRegistryTokensRequest.d.ts +13 -0
- package/dist/serialization/resources/registry/client/requests/GenerateRegistryTokensRequest.js +34 -0
- package/dist/serialization/resources/registry/client/requests/RevokeTokenRequest.d.ts +14 -0
- package/dist/serialization/resources/registry/client/requests/RevokeTokenRequest.js +35 -0
- package/dist/serialization/resources/registry/client/requests/index.d.ts +3 -0
- package/dist/serialization/resources/registry/client/requests/index.js +9 -0
- package/dist/serialization/resources/registry/client/revokeToken.d.ts +16 -0
- package/dist/serialization/resources/registry/client/revokeToken.js +61 -0
- package/dist/serialization/resources/registry/index.d.ts +2 -0
- package/dist/serialization/resources/registry/index.js +18 -0
- package/dist/serialization/resources/registry/types/MavenRegistryToken.d.ts +13 -0
- package/dist/serialization/resources/registry/types/MavenRegistryToken.js +34 -0
- package/dist/serialization/resources/registry/types/NpmRegistryToken.d.ts +12 -0
- package/dist/serialization/resources/registry/types/NpmRegistryToken.js +33 -0
- package/dist/serialization/resources/registry/types/PypiRegistryToken.d.ts +13 -0
- package/dist/serialization/resources/registry/types/PypiRegistryToken.js +34 -0
- package/dist/serialization/resources/registry/types/RegistryToken.d.ts +22 -0
- package/dist/serialization/resources/registry/types/RegistryToken.js +43 -0
- package/dist/serialization/resources/registry/types/RegistryTokens.d.ts +17 -0
- package/dist/serialization/resources/registry/types/RegistryTokens.js +38 -0
- package/dist/serialization/resources/registry/types/index.d.ts +5 -0
- package/dist/serialization/resources/registry/types/index.js +21 -0
- package/dist/serialization/resources/user/index.d.ts +1 -0
- package/dist/serialization/resources/user/index.js +17 -0
- package/dist/serialization/resources/user/types/OrganizationsPage.d.ts +14 -0
- package/dist/serialization/resources/user/types/OrganizationsPage.js +35 -0
- package/dist/serialization/resources/user/types/User.d.ts +16 -0
- package/dist/serialization/resources/user/types/User.js +37 -0
- package/dist/serialization/resources/user/types/index.d.ts +2 -0
- package/dist/serialization/resources/user/types/index.js +18 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +4 -0
- package/jest.config.js +5 -0
- package/package.json +28 -18
- package/serialization/resources/commons/types/OrganizationId.d.ts +2 -2
- package/serialization/resources/commons/types/OrganizationId.js +2 -2
- package/serialization/resources/commons/types/UserId.d.ts +2 -2
- package/serialization/resources/commons/types/UserId.js +2 -2
- package/serialization/resources/organization/client/addUser.d.ts +2 -2
- package/serialization/resources/organization/client/addUser.js +18 -4
- package/serialization/resources/organization/client/create.d.ts +2 -2
- package/serialization/resources/organization/client/create.js +18 -4
- package/serialization/resources/organization/client/get.d.ts +2 -2
- package/serialization/resources/organization/client/get.js +17 -3
- package/serialization/resources/organization/client/getMyOrganizationFromScopedToken.d.ts +2 -2
- package/serialization/resources/organization/client/getMyOrganizationFromScopedToken.js +17 -3
- package/serialization/resources/organization/client/getOrgIdsFromToken.d.ts +4 -3
- package/serialization/resources/organization/client/getOrgIdsFromToken.js +2 -1
- package/serialization/resources/organization/client/inviteUser.d.ts +2 -2
- package/serialization/resources/organization/client/inviteUser.js +18 -4
- package/serialization/resources/organization/client/isMember.d.ts +1 -1
- package/serialization/resources/organization/client/removeUser.d.ts +2 -2
- package/serialization/resources/organization/client/removeUser.js +18 -4
- package/serialization/resources/organization/client/requests/AddUserToOrgRequest.d.ts +6 -4
- package/serialization/resources/organization/client/requests/AddUserToOrgRequest.js +4 -2
- package/serialization/resources/organization/client/requests/CreateOrganizationRequest.d.ts +4 -3
- package/serialization/resources/organization/client/requests/CreateOrganizationRequest.js +2 -1
- package/serialization/resources/organization/client/requests/InviteUserToOrgRequest.d.ts +4 -3
- package/serialization/resources/organization/client/requests/InviteUserToOrgRequest.js +2 -1
- package/serialization/resources/organization/client/requests/RemoveUserFromOrgRequest.d.ts +4 -3
- package/serialization/resources/organization/client/requests/RemoveUserFromOrgRequest.js +2 -1
- package/serialization/resources/organization/client/requests/UpdateOrganizationRequest.d.ts +2 -2
- package/serialization/resources/organization/client/update.d.ts +2 -2
- package/serialization/resources/organization/client/update.js +17 -3
- package/serialization/resources/organization/types/LightweightUser.d.ts +2 -2
- package/serialization/resources/organization/types/Organization.d.ts +6 -4
- package/serialization/resources/organization/types/Organization.js +4 -2
- package/serialization/resources/registry/client/generateRegistryTokens.d.ts +2 -2
- package/serialization/resources/registry/client/generateRegistryTokens.js +18 -4
- package/serialization/resources/registry/client/hasRegistryPermission.d.ts +2 -2
- package/serialization/resources/registry/client/hasRegistryPermission.js +18 -4
- package/serialization/resources/registry/client/requests/CheckRegistryPermissionRequest.d.ts +6 -4
- package/serialization/resources/registry/client/requests/CheckRegistryPermissionRequest.js +4 -2
- package/serialization/resources/registry/client/requests/GenerateRegistryTokensRequest.d.ts +4 -3
- package/serialization/resources/registry/client/requests/GenerateRegistryTokensRequest.js +2 -1
- package/serialization/resources/registry/client/requests/RevokeTokenRequest.d.ts +4 -3
- package/serialization/resources/registry/client/requests/RevokeTokenRequest.js +2 -1
- package/serialization/resources/registry/client/revokeToken.d.ts +2 -2
- package/serialization/resources/registry/client/revokeToken.js +18 -4
- package/serialization/resources/registry/types/MavenRegistryToken.d.ts +2 -2
- package/serialization/resources/registry/types/NpmRegistryToken.d.ts +2 -2
- package/serialization/resources/registry/types/PypiRegistryToken.d.ts +2 -2
- package/serialization/resources/registry/types/RegistryToken.d.ts +8 -5
- package/serialization/resources/registry/types/RegistryToken.js +8 -17
- package/serialization/resources/registry/types/RegistryTokens.d.ts +8 -5
- package/serialization/resources/registry/types/RegistryTokens.js +6 -3
- package/serialization/resources/user/types/OrganizationsPage.d.ts +4 -3
- package/serialization/resources/user/types/OrganizationsPage.js +2 -1
- package/serialization/resources/user/types/User.d.ts +4 -3
- package/serialization/resources/user/types/User.js +2 -1
- package/version.d.ts +1 -0
- package/version.js +4 -0
- package/core/schemas/utils/OptionalRecord.d.ts +0 -1
- /package/core/schemas/{utils/OptionalRecord.js → builders/undiscriminated-union/types.js} +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.booleanLiteral = void 0;
|
|
4
|
+
const Schema_1 = require("../../Schema");
|
|
5
|
+
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
7
|
+
function booleanLiteral(literal) {
|
|
8
|
+
const schemaCreator = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.BOOLEAN_LITERAL, (value, { breadcrumbsPrefix = [] } = {}) => {
|
|
9
|
+
if (value === literal) {
|
|
10
|
+
return {
|
|
11
|
+
ok: true,
|
|
12
|
+
value: literal,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return {
|
|
17
|
+
ok: false,
|
|
18
|
+
errors: [
|
|
19
|
+
{
|
|
20
|
+
path: breadcrumbsPrefix,
|
|
21
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, `${literal.toString()}`),
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return schemaCreator();
|
|
28
|
+
}
|
|
29
|
+
exports.booleanLiteral = booleanLiteral;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringLiteral = void 0;
|
|
3
|
+
exports.booleanLiteral = exports.stringLiteral = void 0;
|
|
4
4
|
var stringLiteral_1 = require("./stringLiteral");
|
|
5
5
|
Object.defineProperty(exports, "stringLiteral", { enumerable: true, get: function () { return stringLiteral_1.stringLiteral; } });
|
|
6
|
+
var booleanLiteral_1 = require("./booleanLiteral");
|
|
7
|
+
Object.defineProperty(exports, "booleanLiteral", { enumerable: true, get: function () { return booleanLiteral_1.booleanLiteral; } });
|
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.stringLiteral = void 0;
|
|
4
4
|
const Schema_1 = require("../../Schema");
|
|
5
5
|
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
6
7
|
function stringLiteral(literal) {
|
|
7
|
-
const schemaCreator = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.STRING_LITERAL, (value) => {
|
|
8
|
+
const schemaCreator = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.STRING_LITERAL, (value, { breadcrumbsPrefix = [] } = {}) => {
|
|
8
9
|
if (value === literal) {
|
|
9
10
|
return {
|
|
10
11
|
ok: true,
|
|
@@ -16,8 +17,8 @@ function stringLiteral(literal) {
|
|
|
16
17
|
ok: false,
|
|
17
18
|
errors: [
|
|
18
19
|
{
|
|
19
|
-
path:
|
|
20
|
-
message:
|
|
20
|
+
path: breadcrumbsPrefix,
|
|
21
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, `"${literal}"`),
|
|
21
22
|
},
|
|
22
23
|
],
|
|
23
24
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { getObjectUtils, object } from "./object";
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
2
|
+
export { objectWithoutOptionalProperties } from "./objectWithoutOptionalProperties";
|
|
3
|
+
export type { inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas, inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas, } from "./objectWithoutOptionalProperties";
|
|
4
|
+
export { isProperty, property } from "./property";
|
|
5
|
+
export type { Property } from "./property";
|
|
6
|
+
export type { BaseObjectSchema, inferObjectSchemaFromPropertySchemas, inferParsedObject, inferParsedObjectFromPropertySchemas, inferParsedPropertySchema, inferRawKey, inferRawObject, inferRawObjectFromPropertySchemas, inferRawPropertySchema, ObjectSchema, ObjectUtils, PropertySchemas, } from "./types";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.property = exports.isProperty = exports.object = exports.getObjectUtils = void 0;
|
|
3
|
+
exports.property = exports.isProperty = exports.objectWithoutOptionalProperties = exports.object = exports.getObjectUtils = void 0;
|
|
4
4
|
var object_1 = require("./object");
|
|
5
5
|
Object.defineProperty(exports, "getObjectUtils", { enumerable: true, get: function () { return object_1.getObjectUtils; } });
|
|
6
6
|
Object.defineProperty(exports, "object", { enumerable: true, get: function () { return object_1.object; } });
|
|
7
|
+
var objectWithoutOptionalProperties_1 = require("./objectWithoutOptionalProperties");
|
|
8
|
+
Object.defineProperty(exports, "objectWithoutOptionalProperties", { enumerable: true, get: function () { return objectWithoutOptionalProperties_1.objectWithoutOptionalProperties; } });
|
|
7
9
|
var property_1 = require("./property");
|
|
8
10
|
Object.defineProperty(exports, "isProperty", { enumerable: true, get: function () { return property_1.isProperty; } });
|
|
9
11
|
Object.defineProperty(exports, "property", { enumerable: true, get: function () { return property_1.property; } });
|
|
@@ -4,17 +4,19 @@ exports.getObjectUtils = exports.object = void 0;
|
|
|
4
4
|
const Schema_1 = require("../../Schema");
|
|
5
5
|
const entries_1 = require("../../utils/entries");
|
|
6
6
|
const filterObject_1 = require("../../utils/filterObject");
|
|
7
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
7
8
|
const isPlainObject_1 = require("../../utils/isPlainObject");
|
|
8
9
|
const keys_1 = require("../../utils/keys");
|
|
10
|
+
const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
|
|
9
11
|
const partition_1 = require("../../utils/partition");
|
|
10
12
|
const object_like_1 = require("../object-like");
|
|
11
13
|
const schema_utils_1 = require("../schema-utils");
|
|
12
14
|
const property_1 = require("./property");
|
|
13
15
|
function object(schemas) {
|
|
14
16
|
const baseSchema = {
|
|
15
|
-
_getRawProperties: () =>
|
|
16
|
-
_getParsedProperties: () =>
|
|
17
|
-
parse:
|
|
17
|
+
_getRawProperties: () => Object.entries(schemas).map(([parsedKey, propertySchema]) => (0, property_1.isProperty)(propertySchema) ? propertySchema.rawKey : parsedKey),
|
|
18
|
+
_getParsedProperties: () => (0, keys_1.keys)(schemas),
|
|
19
|
+
parse: (raw, opts) => {
|
|
18
20
|
const rawKeyToProperty = {};
|
|
19
21
|
const requiredKeys = [];
|
|
20
22
|
for (const [parsedKey, schemaOrObjectProperty] of (0, entries_1.entries)(schemas)) {
|
|
@@ -28,7 +30,7 @@ function object(schemas) {
|
|
|
28
30
|
valueSchema,
|
|
29
31
|
};
|
|
30
32
|
rawKeyToProperty[rawKey] = property;
|
|
31
|
-
if (
|
|
33
|
+
if (isSchemaRequired(valueSchema)) {
|
|
32
34
|
requiredKeys.push(rawKey);
|
|
33
35
|
}
|
|
34
36
|
}
|
|
@@ -42,19 +44,25 @@ function object(schemas) {
|
|
|
42
44
|
}
|
|
43
45
|
return {
|
|
44
46
|
transformedKey: property.parsedKey,
|
|
45
|
-
transform: (propertyValue) =>
|
|
47
|
+
transform: (propertyValue) => {
|
|
48
|
+
var _a;
|
|
49
|
+
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] }));
|
|
50
|
+
},
|
|
46
51
|
};
|
|
47
52
|
},
|
|
48
|
-
|
|
53
|
+
unrecognizedObjectKeys: opts === null || opts === void 0 ? void 0 : opts.unrecognizedObjectKeys,
|
|
54
|
+
skipValidation: opts === null || opts === void 0 ? void 0 : opts.skipValidation,
|
|
55
|
+
breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
|
|
56
|
+
omitUndefined: opts === null || opts === void 0 ? void 0 : opts.omitUndefined,
|
|
49
57
|
});
|
|
50
58
|
},
|
|
51
|
-
json:
|
|
59
|
+
json: (parsed, opts) => {
|
|
52
60
|
const requiredKeys = [];
|
|
53
61
|
for (const [parsedKey, schemaOrObjectProperty] of (0, entries_1.entries)(schemas)) {
|
|
54
62
|
const valueSchema = (0, property_1.isProperty)(schemaOrObjectProperty)
|
|
55
63
|
? schemaOrObjectProperty.valueSchema
|
|
56
64
|
: schemaOrObjectProperty;
|
|
57
|
-
if (
|
|
65
|
+
if (isSchemaRequired(valueSchema)) {
|
|
58
66
|
requiredKeys.push(parsedKey);
|
|
59
67
|
}
|
|
60
68
|
}
|
|
@@ -70,37 +78,41 @@ function object(schemas) {
|
|
|
70
78
|
if ((0, property_1.isProperty)(property)) {
|
|
71
79
|
return {
|
|
72
80
|
transformedKey: property.rawKey,
|
|
73
|
-
transform: (propertyValue) =>
|
|
81
|
+
transform: (propertyValue) => {
|
|
82
|
+
var _a;
|
|
83
|
+
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] }));
|
|
84
|
+
},
|
|
74
85
|
};
|
|
75
86
|
}
|
|
76
87
|
else {
|
|
77
88
|
return {
|
|
78
89
|
transformedKey: parsedKey,
|
|
79
|
-
transform: (propertyValue) =>
|
|
90
|
+
transform: (propertyValue) => {
|
|
91
|
+
var _a;
|
|
92
|
+
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] }));
|
|
93
|
+
},
|
|
80
94
|
};
|
|
81
95
|
}
|
|
82
96
|
},
|
|
83
|
-
|
|
97
|
+
unrecognizedObjectKeys: opts === null || opts === void 0 ? void 0 : opts.unrecognizedObjectKeys,
|
|
98
|
+
skipValidation: opts === null || opts === void 0 ? void 0 : opts.skipValidation,
|
|
99
|
+
breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
|
|
100
|
+
omitUndefined: opts === null || opts === void 0 ? void 0 : opts.omitUndefined,
|
|
84
101
|
});
|
|
85
102
|
},
|
|
86
103
|
getType: () => Schema_1.SchemaType.OBJECT,
|
|
87
104
|
};
|
|
88
|
-
return {
|
|
89
|
-
...baseSchema,
|
|
90
|
-
...(0, schema_utils_1.getSchemaUtils)(baseSchema),
|
|
91
|
-
...(0, object_like_1.getObjectLikeUtils)(baseSchema),
|
|
92
|
-
...getObjectUtils(baseSchema),
|
|
93
|
-
};
|
|
105
|
+
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
106
|
}
|
|
95
107
|
exports.object = object;
|
|
96
|
-
|
|
108
|
+
function validateAndTransformObject({ value, requiredKeys, getProperty, unrecognizedObjectKeys = "fail", skipValidation = false, breadcrumbsPrefix = [], }) {
|
|
97
109
|
if (!(0, isPlainObject_1.isPlainObject)(value)) {
|
|
98
110
|
return {
|
|
99
111
|
ok: false,
|
|
100
112
|
errors: [
|
|
101
113
|
{
|
|
102
|
-
path:
|
|
103
|
-
message:
|
|
114
|
+
path: breadcrumbsPrefix,
|
|
115
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "object"),
|
|
104
116
|
},
|
|
105
117
|
],
|
|
106
118
|
};
|
|
@@ -112,34 +124,38 @@ async function validateAndTransformObject({ value, requiredKeys, getProperty, al
|
|
|
112
124
|
const property = getProperty(preTransformedKey);
|
|
113
125
|
if (property != null) {
|
|
114
126
|
missingRequiredKeys.delete(preTransformedKey);
|
|
115
|
-
const value =
|
|
127
|
+
const value = property.transform(preTransformedItemValue);
|
|
116
128
|
if (value.ok) {
|
|
117
129
|
transformed[property.transformedKey] = value.value;
|
|
118
130
|
}
|
|
119
131
|
else {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
message: error.message,
|
|
123
|
-
})));
|
|
132
|
+
transformed[preTransformedKey] = preTransformedItemValue;
|
|
133
|
+
errors.push(...value.errors);
|
|
124
134
|
}
|
|
125
135
|
}
|
|
126
|
-
else if (allowUnknownKeys) {
|
|
127
|
-
transformed[preTransformedKey] = preTransformedItemValue;
|
|
128
|
-
}
|
|
129
136
|
else {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
switch (unrecognizedObjectKeys) {
|
|
138
|
+
case "fail":
|
|
139
|
+
errors.push({
|
|
140
|
+
path: [...breadcrumbsPrefix, preTransformedKey],
|
|
141
|
+
message: `Unexpected key "${preTransformedKey}"`,
|
|
142
|
+
});
|
|
143
|
+
break;
|
|
144
|
+
case "strip":
|
|
145
|
+
break;
|
|
146
|
+
case "passthrough":
|
|
147
|
+
transformed[preTransformedKey] = preTransformedItemValue;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
134
150
|
}
|
|
135
151
|
}
|
|
136
152
|
errors.push(...requiredKeys
|
|
137
153
|
.filter((key) => missingRequiredKeys.has(key))
|
|
138
154
|
.map((key) => ({
|
|
139
|
-
path:
|
|
155
|
+
path: breadcrumbsPrefix,
|
|
140
156
|
message: `Missing required key "${key}"`,
|
|
141
157
|
})));
|
|
142
|
-
if (errors.length === 0) {
|
|
158
|
+
if (errors.length === 0 || skipValidation) {
|
|
143
159
|
return {
|
|
144
160
|
ok: true,
|
|
145
161
|
value: transformed,
|
|
@@ -156,25 +172,19 @@ function getObjectUtils(schema) {
|
|
|
156
172
|
return {
|
|
157
173
|
extend: (extension) => {
|
|
158
174
|
const baseSchema = {
|
|
159
|
-
_getParsedProperties:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
],
|
|
163
|
-
_getRawProperties: async () => [
|
|
164
|
-
...(await schema._getRawProperties()),
|
|
165
|
-
...(await extension._getRawProperties()),
|
|
166
|
-
],
|
|
167
|
-
parse: async (raw, opts) => {
|
|
175
|
+
_getParsedProperties: () => [...schema._getParsedProperties(), ...extension._getParsedProperties()],
|
|
176
|
+
_getRawProperties: () => [...schema._getRawProperties(), ...extension._getRawProperties()],
|
|
177
|
+
parse: (raw, opts) => {
|
|
168
178
|
return validateAndTransformExtendedObject({
|
|
169
|
-
extensionKeys:
|
|
179
|
+
extensionKeys: extension._getRawProperties(),
|
|
170
180
|
value: raw,
|
|
171
181
|
transformBase: (rawBase) => schema.parse(rawBase, opts),
|
|
172
182
|
transformExtension: (rawExtension) => extension.parse(rawExtension, opts),
|
|
173
183
|
});
|
|
174
184
|
},
|
|
175
|
-
json:
|
|
185
|
+
json: (parsed, opts) => {
|
|
176
186
|
return validateAndTransformExtendedObject({
|
|
177
|
-
extensionKeys:
|
|
187
|
+
extensionKeys: extension._getParsedProperties(),
|
|
178
188
|
value: parsed,
|
|
179
189
|
transformBase: (parsedBase) => schema.json(parsedBase, opts),
|
|
180
190
|
transformExtension: (parsedExtension) => extension.json(parsedExtension, opts),
|
|
@@ -182,28 +192,20 @@ function getObjectUtils(schema) {
|
|
|
182
192
|
},
|
|
183
193
|
getType: () => Schema_1.SchemaType.OBJECT,
|
|
184
194
|
};
|
|
185
|
-
return {
|
|
186
|
-
...baseSchema,
|
|
187
|
-
...(0, schema_utils_1.getSchemaUtils)(baseSchema),
|
|
188
|
-
...(0, object_like_1.getObjectLikeUtils)(baseSchema),
|
|
189
|
-
...getObjectUtils(baseSchema),
|
|
190
|
-
};
|
|
195
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), getObjectUtils(baseSchema));
|
|
191
196
|
},
|
|
192
197
|
};
|
|
193
198
|
}
|
|
194
199
|
exports.getObjectUtils = getObjectUtils;
|
|
195
|
-
|
|
200
|
+
function validateAndTransformExtendedObject({ extensionKeys, value, transformBase, transformExtension, }) {
|
|
196
201
|
const extensionPropertiesSet = new Set(extensionKeys);
|
|
197
202
|
const [extensionProperties, baseProperties] = (0, partition_1.partition)((0, keys_1.keys)(value), (key) => extensionPropertiesSet.has(key));
|
|
198
|
-
const transformedBase =
|
|
199
|
-
const transformedExtension =
|
|
203
|
+
const transformedBase = transformBase((0, filterObject_1.filterObject)(value, baseProperties));
|
|
204
|
+
const transformedExtension = transformExtension((0, filterObject_1.filterObject)(value, extensionProperties));
|
|
200
205
|
if (transformedBase.ok && transformedExtension.ok) {
|
|
201
206
|
return {
|
|
202
207
|
ok: true,
|
|
203
|
-
value: {
|
|
204
|
-
...transformedBase.value,
|
|
205
|
-
...transformedExtension.value,
|
|
206
|
-
},
|
|
208
|
+
value: Object.assign(Object.assign({}, transformedBase.value), transformedExtension.value),
|
|
207
209
|
};
|
|
208
210
|
}
|
|
209
211
|
else {
|
|
@@ -216,11 +218,11 @@ async function validateAndTransformExtendedObject({ extensionKeys, value, transf
|
|
|
216
218
|
};
|
|
217
219
|
}
|
|
218
220
|
}
|
|
219
|
-
|
|
220
|
-
return !
|
|
221
|
+
function isSchemaRequired(schema) {
|
|
222
|
+
return !isSchemaOptional(schema);
|
|
221
223
|
}
|
|
222
|
-
|
|
223
|
-
switch (
|
|
224
|
+
function isSchemaOptional(schema) {
|
|
225
|
+
switch (schema.getType()) {
|
|
224
226
|
case Schema_1.SchemaType.ANY:
|
|
225
227
|
case Schema_1.SchemaType.UNKNOWN:
|
|
226
228
|
case Schema_1.SchemaType.OPTIONAL:
|
|
@@ -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;
|
|
@@ -5,8 +5,8 @@ import { SchemaUtils } from "../schema-utils";
|
|
|
5
5
|
import { Property } from "./property";
|
|
6
6
|
export declare type ObjectSchema<Raw, Parsed> = BaseObjectSchema<Raw, Parsed> & ObjectLikeUtils<Raw, Parsed> & ObjectUtils<Raw, Parsed> & SchemaUtils<Raw, Parsed>;
|
|
7
7
|
export interface BaseObjectSchema<Raw, Parsed> extends BaseSchema<Raw, Parsed> {
|
|
8
|
-
_getRawProperties: () =>
|
|
9
|
-
_getParsedProperties: () =>
|
|
8
|
+
_getRawProperties: () => (keyof Raw)[];
|
|
9
|
+
_getParsedProperties: () => (keyof Parsed)[];
|
|
10
10
|
}
|
|
11
11
|
export interface ObjectUtils<Raw, Parsed> {
|
|
12
12
|
extend: <RawExtension, ParsedExtension>(schemas: ObjectSchema<RawExtension, ParsedExtension>) => ObjectSchema<Raw & RawExtension, Parsed & ParsedExtension>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withParsedProperties = exports.getObjectLikeUtils = void 0;
|
|
4
4
|
const filterObject_1 = require("../../utils/filterObject");
|
|
5
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
5
6
|
const isPlainObject_1 = require("../../utils/isPlainObject");
|
|
6
7
|
const schema_utils_1 = require("../schema-utils");
|
|
7
8
|
function getObjectLikeUtils(schema) {
|
|
@@ -15,33 +16,28 @@ exports.getObjectLikeUtils = getObjectLikeUtils;
|
|
|
15
16
|
*/
|
|
16
17
|
function withParsedProperties(objectLike, properties) {
|
|
17
18
|
const objectSchema = {
|
|
18
|
-
parse:
|
|
19
|
-
const parsedObject =
|
|
19
|
+
parse: (raw, opts) => {
|
|
20
|
+
const parsedObject = objectLike.parse(raw, opts);
|
|
20
21
|
if (!parsedObject.ok) {
|
|
21
22
|
return parsedObject;
|
|
22
23
|
}
|
|
23
24
|
const additionalProperties = Object.entries(properties).reduce((processed, [key, value]) => {
|
|
24
|
-
return {
|
|
25
|
-
...processed,
|
|
26
|
-
[key]: typeof value === "function" ? value(parsedObject.value) : value,
|
|
27
|
-
};
|
|
25
|
+
return Object.assign(Object.assign({}, processed), { [key]: typeof value === "function" ? value(parsedObject.value) : value });
|
|
28
26
|
}, {});
|
|
29
27
|
return {
|
|
30
28
|
ok: true,
|
|
31
|
-
value: {
|
|
32
|
-
...parsedObject.value,
|
|
33
|
-
...additionalProperties,
|
|
34
|
-
},
|
|
29
|
+
value: Object.assign(Object.assign({}, parsedObject.value), additionalProperties),
|
|
35
30
|
};
|
|
36
31
|
},
|
|
37
32
|
json: (parsed, opts) => {
|
|
33
|
+
var _a;
|
|
38
34
|
if (!(0, isPlainObject_1.isPlainObject)(parsed)) {
|
|
39
35
|
return {
|
|
40
36
|
ok: false,
|
|
41
37
|
errors: [
|
|
42
38
|
{
|
|
43
|
-
path: [],
|
|
44
|
-
message:
|
|
39
|
+
path: (_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : [],
|
|
40
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(parsed, "object"),
|
|
45
41
|
},
|
|
46
42
|
],
|
|
47
43
|
};
|
|
@@ -53,10 +49,6 @@ function withParsedProperties(objectLike, properties) {
|
|
|
53
49
|
},
|
|
54
50
|
getType: () => objectLike.getType(),
|
|
55
51
|
};
|
|
56
|
-
return {
|
|
57
|
-
...objectSchema,
|
|
58
|
-
...(0, schema_utils_1.getSchemaUtils)(objectSchema),
|
|
59
|
-
...getObjectLikeUtils(objectSchema),
|
|
60
|
-
};
|
|
52
|
+
return Object.assign(Object.assign(Object.assign({}, objectSchema), (0, schema_utils_1.getSchemaUtils)(objectSchema)), getObjectLikeUtils(objectSchema));
|
|
61
53
|
}
|
|
62
54
|
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";
|
|
@@ -3,52 +3,65 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.record = void 0;
|
|
4
4
|
const Schema_1 = require("../../Schema");
|
|
5
5
|
const entries_1 = require("../../utils/entries");
|
|
6
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
6
7
|
const isPlainObject_1 = require("../../utils/isPlainObject");
|
|
8
|
+
const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
|
|
7
9
|
const schema_utils_1 = require("../schema-utils");
|
|
8
10
|
function record(keySchema, valueSchema) {
|
|
9
11
|
const baseSchema = {
|
|
10
|
-
parse:
|
|
12
|
+
parse: (raw, opts) => {
|
|
11
13
|
return validateAndTransformRecord({
|
|
12
14
|
value: raw,
|
|
13
|
-
isKeyNumeric:
|
|
14
|
-
transformKey: (key) =>
|
|
15
|
-
|
|
15
|
+
isKeyNumeric: keySchema.getType() === Schema_1.SchemaType.NUMBER,
|
|
16
|
+
transformKey: (key) => {
|
|
17
|
+
var _a;
|
|
18
|
+
return keySchema.parse(key, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `${key} (key)`] }));
|
|
19
|
+
},
|
|
20
|
+
transformValue: (value, key) => {
|
|
21
|
+
var _a;
|
|
22
|
+
return valueSchema.parse(value, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `${key}`] }));
|
|
23
|
+
},
|
|
24
|
+
breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
|
|
16
25
|
});
|
|
17
26
|
},
|
|
18
|
-
json:
|
|
27
|
+
json: (parsed, opts) => {
|
|
19
28
|
return validateAndTransformRecord({
|
|
20
29
|
value: parsed,
|
|
21
|
-
isKeyNumeric:
|
|
22
|
-
transformKey: (key) =>
|
|
23
|
-
|
|
30
|
+
isKeyNumeric: keySchema.getType() === Schema_1.SchemaType.NUMBER,
|
|
31
|
+
transformKey: (key) => {
|
|
32
|
+
var _a;
|
|
33
|
+
return keySchema.json(key, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `${key} (key)`] }));
|
|
34
|
+
},
|
|
35
|
+
transformValue: (value, key) => {
|
|
36
|
+
var _a;
|
|
37
|
+
return valueSchema.json(value, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `${key}`] }));
|
|
38
|
+
},
|
|
39
|
+
breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
|
|
24
40
|
});
|
|
25
41
|
},
|
|
26
42
|
getType: () => Schema_1.SchemaType.RECORD,
|
|
27
43
|
};
|
|
28
|
-
return {
|
|
29
|
-
...baseSchema,
|
|
30
|
-
...(0, schema_utils_1.getSchemaUtils)(baseSchema),
|
|
31
|
-
};
|
|
44
|
+
return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
|
|
32
45
|
}
|
|
33
46
|
exports.record = record;
|
|
34
|
-
|
|
47
|
+
function validateAndTransformRecord({ value, isKeyNumeric, transformKey, transformValue, breadcrumbsPrefix = [], }) {
|
|
35
48
|
if (!(0, isPlainObject_1.isPlainObject)(value)) {
|
|
36
49
|
return {
|
|
37
50
|
ok: false,
|
|
38
51
|
errors: [
|
|
39
52
|
{
|
|
40
|
-
path:
|
|
41
|
-
message:
|
|
53
|
+
path: breadcrumbsPrefix,
|
|
54
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "object"),
|
|
42
55
|
},
|
|
43
56
|
],
|
|
44
57
|
};
|
|
45
58
|
}
|
|
46
|
-
return (0, entries_1.entries)(value).reduce(
|
|
59
|
+
return (0, entries_1.entries)(value).reduce((accPromise, [stringKey, value]) => {
|
|
47
60
|
// skip nullish keys
|
|
48
61
|
if (value == null) {
|
|
49
62
|
return accPromise;
|
|
50
63
|
}
|
|
51
|
-
const acc =
|
|
64
|
+
const acc = accPromise;
|
|
52
65
|
let key = stringKey;
|
|
53
66
|
if (isKeyNumeric) {
|
|
54
67
|
const numberKey = stringKey.length > 0 ? Number(stringKey) : NaN;
|
|
@@ -56,15 +69,12 @@ async function validateAndTransformRecord({ value, isKeyNumeric, transformKey, t
|
|
|
56
69
|
key = numberKey;
|
|
57
70
|
}
|
|
58
71
|
}
|
|
59
|
-
const transformedKey =
|
|
60
|
-
const transformedValue =
|
|
72
|
+
const transformedKey = transformKey(key);
|
|
73
|
+
const transformedValue = transformValue(value, key);
|
|
61
74
|
if (acc.ok && transformedKey.ok && transformedValue.ok) {
|
|
62
75
|
return {
|
|
63
76
|
ok: true,
|
|
64
|
-
value: {
|
|
65
|
-
...acc.value,
|
|
66
|
-
[transformedKey.value]: transformedValue.value,
|
|
67
|
-
},
|
|
77
|
+
value: Object.assign(Object.assign({}, acc.value), { [transformedKey.value]: transformedValue.value }),
|
|
68
78
|
};
|
|
69
79
|
}
|
|
70
80
|
const errors = [];
|
|
@@ -72,20 +82,14 @@ async function validateAndTransformRecord({ value, isKeyNumeric, transformKey, t
|
|
|
72
82
|
errors.push(...acc.errors);
|
|
73
83
|
}
|
|
74
84
|
if (!transformedKey.ok) {
|
|
75
|
-
errors.push(...transformedKey.errors
|
|
76
|
-
path: [`${key} (key)`, ...error.path],
|
|
77
|
-
message: error.message,
|
|
78
|
-
})));
|
|
85
|
+
errors.push(...transformedKey.errors);
|
|
79
86
|
}
|
|
80
87
|
if (!transformedValue.ok) {
|
|
81
|
-
errors.push(...transformedValue.errors
|
|
82
|
-
path: [stringKey, ...error.path],
|
|
83
|
-
message: error.message,
|
|
84
|
-
})));
|
|
88
|
+
errors.push(...transformedValue.errors);
|
|
85
89
|
}
|
|
86
90
|
return {
|
|
87
91
|
ok: false,
|
|
88
92
|
errors,
|
|
89
93
|
};
|
|
90
|
-
},
|
|
94
|
+
}, { ok: true, value: {} });
|
|
91
95
|
}
|