rcs-js 0.0.1 → 1.0.2
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 +93 -0
- package/Client.js +384 -0
- package/README.md +137 -0
- package/api/client/index.d.ts +1 -0
- package/api/client/index.js +17 -0
- package/api/client/requests/CheckRcsCapabilityRequest.d.ts +21 -0
- package/api/client/requests/CheckRcsCapabilityRequest.js +5 -0
- package/api/client/requests/UpdateSettingsRequest.d.ts +13 -0
- package/api/client/requests/UpdateSettingsRequest.js +5 -0
- package/api/client/requests/index.d.ts +2 -0
- package/api/client/requests/index.js +2 -0
- package/api/errors/BadRequestError.d.ts +8 -0
- package/api/errors/BadRequestError.js +41 -0
- package/api/errors/InternalServerError.d.ts +8 -0
- package/api/errors/InternalServerError.js +41 -0
- package/api/errors/UnauthorizedError.d.ts +8 -0
- package/api/errors/UnauthorizedError.js +41 -0
- package/api/errors/index.d.ts +3 -0
- package/api/errors/index.js +19 -0
- package/api/index.d.ts +3 -0
- package/api/index.js +19 -0
- package/api/types/Action.d.ts +5 -0
- package/api/types/Action.js +5 -0
- package/api/types/BadRequestErrorBody.d.ts +6 -0
- package/api/types/BadRequestErrorBody.js +5 -0
- package/api/types/BasicRcs.d.ts +13 -0
- package/api/types/BasicRcs.js +5 -0
- package/api/types/BasicRcsMessage.d.ts +10 -0
- package/api/types/BasicRcsMessage.js +5 -0
- package/api/types/Call.d.ts +9 -0
- package/api/types/Call.js +5 -0
- package/api/types/Card.d.ts +16 -0
- package/api/types/Card.js +5 -0
- package/api/types/CardRcs.d.ts +12 -0
- package/api/types/CardRcs.js +5 -0
- package/api/types/CardRcsMessage.d.ts +13 -0
- package/api/types/CardRcsMessage.js +5 -0
- package/api/types/CardStyle.d.ts +16 -0
- package/api/types/CardStyle.js +5 -0
- package/api/types/CardStyleImageAlignment.d.ts +11 -0
- package/api/types/CardStyleImageAlignment.js +10 -0
- package/api/types/CardStyleMediaHeight.d.ts +12 -0
- package/api/types/CardStyleMediaHeight.js +11 -0
- package/api/types/CardStyleOrientation.d.ts +11 -0
- package/api/types/CardStyleOrientation.js +10 -0
- package/api/types/CardStyleWidth.d.ts +11 -0
- package/api/types/CardStyleWidth.js +10 -0
- package/api/types/CarouselRcs.d.ts +12 -0
- package/api/types/CarouselRcs.js +5 -0
- package/api/types/CarouselRcsMessage.d.ts +13 -0
- package/api/types/CarouselRcsMessage.js +5 -0
- package/api/types/CheckRcsCapabilityResponse.d.ts +7 -0
- package/api/types/CheckRcsCapabilityResponse.js +5 -0
- package/api/types/Event.d.ts +15 -0
- package/api/types/Event.js +5 -0
- package/api/types/GetAccountNumberResponse.d.ts +7 -0
- package/api/types/GetAccountNumberResponse.js +5 -0
- package/api/types/InternalServerErrorBody.d.ts +6 -0
- package/api/types/InternalServerErrorBody.js +5 -0
- package/api/types/LatLng.d.ts +12 -0
- package/api/types/LatLng.js +5 -0
- package/api/types/MediaRcs.d.ts +12 -0
- package/api/types/MediaRcs.js +5 -0
- package/api/types/MediaRcsMessage.d.ts +14 -0
- package/api/types/MediaRcsMessage.js +5 -0
- package/api/types/MediaType.d.ts +14 -0
- package/api/types/MediaType.js +13 -0
- package/api/types/PhoneNumber.d.ts +7 -0
- package/api/types/PhoneNumber.js +5 -0
- package/api/types/Postback.d.ts +11 -0
- package/api/types/Postback.js +5 -0
- package/api/types/SendRequest.d.ts +5 -0
- package/api/types/SendRequest.js +5 -0
- package/api/types/SendResponse.d.ts +7 -0
- package/api/types/SendResponse.js +5 -0
- package/api/types/ShareLocation.d.ts +7 -0
- package/api/types/ShareLocation.js +5 -0
- package/api/types/Sms.d.ts +12 -0
- package/api/types/Sms.js +5 -0
- package/api/types/SmsMessage.d.ts +12 -0
- package/api/types/SmsMessage.js +5 -0
- package/api/types/UnauthorizedErrorBody.d.ts +6 -0
- package/api/types/UnauthorizedErrorBody.js +5 -0
- package/api/types/UpdateSettingsResponse.d.ts +6 -0
- package/api/types/UpdateSettingsResponse.js +5 -0
- package/api/types/Url.d.ts +9 -0
- package/api/types/Url.js +5 -0
- package/api/types/ViewLocation.d.ts +11 -0
- package/api/types/ViewLocation.js +5 -0
- package/api/types/index.d.ts +34 -0
- package/api/types/index.js +50 -0
- package/core/fetcher/APIResponse.d.ts +10 -0
- package/core/fetcher/APIResponse.js +2 -0
- package/core/fetcher/Fetcher.d.ts +39 -0
- package/core/fetcher/Fetcher.js +99 -0
- package/core/fetcher/Supplier.d.ts +4 -0
- package/core/fetcher/Supplier.js +22 -0
- 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 +5 -0
- package/core/fetcher/index.js +9 -0
- 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 -0
- package/core/index.js +32 -0
- 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 +85 -0
- package/core/schemas/Schema.js +22 -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.d.ts +2 -0
- package/core/schemas/builders/date/date.js +63 -0
- package/core/schemas/builders/date/index.d.ts +1 -0
- package/core/schemas/builders/date/index.js +5 -0
- package/core/schemas/builders/enum/enum.d.ts +2 -0
- package/core/schemas/builders/enum/enum.js +39 -0
- package/core/schemas/builders/enum/index.d.ts +1 -0
- package/core/schemas/builders/enum/index.js +5 -0
- package/core/schemas/builders/index.d.ts +14 -0
- package/core/schemas/builders/index.js +30 -0
- package/core/schemas/builders/lazy/index.d.ts +3 -0
- package/core/schemas/builders/lazy/index.js +7 -0
- package/core/schemas/builders/lazy/lazy.d.ts +5 -0
- package/core/schemas/builders/lazy/lazy.js +25 -0
- package/core/schemas/builders/lazy/lazyObject.d.ts +3 -0
- package/core/schemas/builders/lazy/lazyObject.js +12 -0
- package/core/schemas/builders/list/index.d.ts +1 -0
- package/core/schemas/builders/list/index.js +5 -0
- package/core/schemas/builders/list/list.d.ts +2 -0
- package/core/schemas/builders/list/list.js +55 -0
- 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 +2 -0
- package/core/schemas/builders/literals/index.js +7 -0
- package/core/schemas/builders/literals/stringLiteral.d.ts +2 -0
- package/core/schemas/builders/literals/stringLiteral.js +29 -0
- package/core/schemas/builders/object/index.d.ts +6 -0
- package/core/schemas/builders/object/index.js +11 -0
- package/core/schemas/builders/object/object.d.ts +3 -0
- package/core/schemas/builders/object/object.js +233 -0
- package/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +6 -0
- package/core/schemas/builders/object/objectWithoutOptionalProperties.js +8 -0
- package/core/schemas/builders/object/property.d.ts +8 -0
- package/core/schemas/builders/object/property.js +16 -0
- package/core/schemas/builders/object/types.d.ts +26 -0
- package/core/schemas/builders/object/types.js +2 -0
- package/core/schemas/builders/object-like/getObjectLikeUtils.d.ts +9 -0
- package/core/schemas/builders/object-like/getObjectLikeUtils.js +54 -0
- package/core/schemas/builders/object-like/index.d.ts +2 -0
- package/core/schemas/builders/object-like/index.js +6 -0
- package/core/schemas/builders/object-like/types.d.ts +7 -0
- package/core/schemas/builders/object-like/types.js +2 -0
- package/core/schemas/builders/primitives/any.d.ts +1 -0
- package/core/schemas/builders/primitives/any.js +6 -0
- package/core/schemas/builders/primitives/boolean.d.ts +1 -0
- package/core/schemas/builders/primitives/boolean.js +25 -0
- package/core/schemas/builders/primitives/index.d.ts +5 -0
- package/core/schemas/builders/primitives/index.js +13 -0
- package/core/schemas/builders/primitives/number.d.ts +1 -0
- package/core/schemas/builders/primitives/number.js +25 -0
- package/core/schemas/builders/primitives/string.d.ts +1 -0
- package/core/schemas/builders/primitives/string.js +25 -0
- package/core/schemas/builders/primitives/unknown.d.ts +1 -0
- package/core/schemas/builders/primitives/unknown.js +6 -0
- package/core/schemas/builders/record/index.d.ts +2 -0
- package/core/schemas/builders/record/index.js +5 -0
- package/core/schemas/builders/record/record.d.ts +3 -0
- package/core/schemas/builders/record/record.js +95 -0
- package/core/schemas/builders/record/types.d.ts +4 -0
- package/core/schemas/builders/record/types.js +2 -0
- package/core/schemas/builders/schema-utils/JsonError.d.ts +5 -0
- package/core/schemas/builders/schema-utils/JsonError.js +12 -0
- package/core/schemas/builders/schema-utils/ParseError.d.ts +5 -0
- package/core/schemas/builders/schema-utils/ParseError.js +12 -0
- package/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +17 -0
- package/core/schemas/builders/schema-utils/getSchemaUtils.js +82 -0
- package/core/schemas/builders/schema-utils/index.d.ts +4 -0
- package/core/schemas/builders/schema-utils/index.js +11 -0
- package/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts +2 -0
- package/core/schemas/builders/schema-utils/stringifyValidationErrors.js +10 -0
- package/core/schemas/builders/set/index.d.ts +1 -0
- package/core/schemas/builders/set/index.js +5 -0
- package/core/schemas/builders/set/set.d.ts +2 -0
- package/core/schemas/builders/set/set.js +44 -0
- 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/types.js +2 -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/discriminant.d.ts +5 -0
- package/core/schemas/builders/union/discriminant.js +10 -0
- package/core/schemas/builders/union/index.d.ts +4 -0
- package/core/schemas/builders/union/index.js +7 -0
- package/core/schemas/builders/union/types.d.ts +13 -0
- package/core/schemas/builders/union/types.js +2 -0
- package/core/schemas/builders/union/union.d.ts +4 -0
- package/core/schemas/builders/union/union.js +130 -0
- package/core/schemas/index.d.ts +2 -0
- package/core/schemas/index.js +17 -0
- package/core/schemas/utils/MaybePromise.d.ts +1 -0
- package/core/schemas/utils/MaybePromise.js +2 -0
- package/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +7 -0
- package/core/schemas/utils/addQuestionMarksToNullableProperties.js +2 -0
- package/core/schemas/utils/createIdentitySchemaCreator.d.ts +2 -0
- package/core/schemas/utils/createIdentitySchemaCreator.js +16 -0
- package/core/schemas/utils/entries.d.ts +1 -0
- package/core/schemas/utils/entries.js +7 -0
- package/core/schemas/utils/filterObject.d.ts +1 -0
- package/core/schemas/utils/filterObject.js +14 -0
- package/core/schemas/utils/getErrorMessageForIncorrectType.d.ts +1 -0
- package/core/schemas/utils/getErrorMessageForIncorrectType.js +28 -0
- package/core/schemas/utils/isPlainObject.d.ts +1 -0
- package/core/schemas/utils/isPlainObject.js +18 -0
- package/core/schemas/utils/keys.d.ts +1 -0
- package/core/schemas/utils/keys.js +7 -0
- package/core/schemas/utils/maybeSkipValidation.d.ts +2 -0
- package/core/schemas/utils/maybeSkipValidation.js +28 -0
- package/core/schemas/utils/partition.d.ts +1 -0
- package/core/schemas/utils/partition.js +16 -0
- package/dist/Client.d.ts +93 -0
- package/dist/Client.js +384 -0
- package/dist/api/client/index.d.ts +1 -0
- package/dist/api/client/index.js +17 -0
- package/dist/api/client/requests/CheckRcsCapabilityRequest.d.ts +21 -0
- package/dist/api/client/requests/CheckRcsCapabilityRequest.js +5 -0
- package/dist/api/client/requests/UpdateSettingsRequest.d.ts +13 -0
- package/dist/api/client/requests/UpdateSettingsRequest.js +5 -0
- package/dist/api/client/requests/index.d.ts +2 -0
- package/dist/api/client/requests/index.js +2 -0
- package/dist/api/errors/BadRequestError.d.ts +8 -0
- package/dist/api/errors/BadRequestError.js +41 -0
- package/dist/api/errors/InternalServerError.d.ts +8 -0
- package/dist/api/errors/InternalServerError.js +41 -0
- package/dist/api/errors/UnauthorizedError.d.ts +8 -0
- package/dist/api/errors/UnauthorizedError.js +41 -0
- package/dist/api/errors/index.d.ts +3 -0
- package/dist/api/errors/index.js +19 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +19 -0
- package/dist/api/types/Action.d.ts +5 -0
- package/dist/api/types/Action.js +5 -0
- package/dist/api/types/BadRequestErrorBody.d.ts +6 -0
- package/dist/api/types/BadRequestErrorBody.js +5 -0
- package/dist/api/types/BasicRcs.d.ts +13 -0
- package/dist/api/types/BasicRcs.js +5 -0
- package/dist/api/types/BasicRcsMessage.d.ts +10 -0
- package/dist/api/types/BasicRcsMessage.js +5 -0
- package/dist/api/types/Call.d.ts +9 -0
- package/dist/api/types/Call.js +5 -0
- package/dist/api/types/Card.d.ts +16 -0
- package/dist/api/types/Card.js +5 -0
- package/dist/api/types/CardRcs.d.ts +12 -0
- package/dist/api/types/CardRcs.js +5 -0
- package/dist/api/types/CardRcsMessage.d.ts +13 -0
- package/dist/api/types/CardRcsMessage.js +5 -0
- package/dist/api/types/CardStyle.d.ts +16 -0
- package/dist/api/types/CardStyle.js +5 -0
- package/dist/api/types/CardStyleImageAlignment.d.ts +11 -0
- package/dist/api/types/CardStyleImageAlignment.js +10 -0
- package/dist/api/types/CardStyleMediaHeight.d.ts +12 -0
- package/dist/api/types/CardStyleMediaHeight.js +11 -0
- package/dist/api/types/CardStyleOrientation.d.ts +11 -0
- package/dist/api/types/CardStyleOrientation.js +10 -0
- package/dist/api/types/CardStyleWidth.d.ts +11 -0
- package/dist/api/types/CardStyleWidth.js +10 -0
- package/dist/api/types/CarouselRcs.d.ts +12 -0
- package/dist/api/types/CarouselRcs.js +5 -0
- package/dist/api/types/CarouselRcsMessage.d.ts +13 -0
- package/dist/api/types/CarouselRcsMessage.js +5 -0
- package/dist/api/types/CheckRcsCapabilityResponse.d.ts +7 -0
- package/dist/api/types/CheckRcsCapabilityResponse.js +5 -0
- package/dist/api/types/Event.d.ts +15 -0
- package/dist/api/types/Event.js +5 -0
- package/dist/api/types/GetAccountNumberResponse.d.ts +7 -0
- package/dist/api/types/GetAccountNumberResponse.js +5 -0
- package/dist/api/types/InternalServerErrorBody.d.ts +6 -0
- package/dist/api/types/InternalServerErrorBody.js +5 -0
- package/dist/api/types/LatLng.d.ts +12 -0
- package/dist/api/types/LatLng.js +5 -0
- package/dist/api/types/MediaRcs.d.ts +12 -0
- package/dist/api/types/MediaRcs.js +5 -0
- package/dist/api/types/MediaRcsMessage.d.ts +14 -0
- package/dist/api/types/MediaRcsMessage.js +5 -0
- package/dist/api/types/MediaType.d.ts +14 -0
- package/dist/api/types/MediaType.js +13 -0
- package/dist/api/types/PhoneNumber.d.ts +7 -0
- package/dist/api/types/PhoneNumber.js +5 -0
- package/dist/api/types/Postback.d.ts +11 -0
- package/dist/api/types/Postback.js +5 -0
- package/dist/api/types/SendRequest.d.ts +5 -0
- package/dist/api/types/SendRequest.js +5 -0
- package/dist/api/types/SendResponse.d.ts +7 -0
- package/dist/api/types/SendResponse.js +5 -0
- package/dist/api/types/ShareLocation.d.ts +7 -0
- package/dist/api/types/ShareLocation.js +5 -0
- package/dist/api/types/Sms.d.ts +12 -0
- package/dist/api/types/Sms.js +5 -0
- package/dist/api/types/SmsMessage.d.ts +12 -0
- package/dist/api/types/SmsMessage.js +5 -0
- package/dist/api/types/UnauthorizedErrorBody.d.ts +6 -0
- package/dist/api/types/UnauthorizedErrorBody.js +5 -0
- package/dist/api/types/UpdateSettingsResponse.d.ts +6 -0
- package/dist/api/types/UpdateSettingsResponse.js +5 -0
- package/dist/api/types/Url.d.ts +9 -0
- package/dist/api/types/Url.js +5 -0
- package/dist/api/types/ViewLocation.d.ts +11 -0
- package/dist/api/types/ViewLocation.js +5 -0
- package/dist/api/types/index.d.ts +34 -0
- package/dist/api/types/index.js +50 -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 +3 -0
- package/dist/core/index.js +32 -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/environments.d.ts +7 -0
- package/dist/environments.js +9 -0
- package/dist/errors/PinnacleError.d.ts +12 -0
- package/dist/errors/PinnacleError.js +32 -0
- package/dist/errors/PinnacleTimeoutError.d.ts +6 -0
- package/dist/errors/PinnacleTimeoutError.js +13 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +32 -5
- package/dist/serialization/client/index.d.ts +1 -0
- package/dist/serialization/client/index.js +17 -0
- package/dist/serialization/client/requests/UpdateSettingsRequest.d.ts +12 -0
- package/dist/serialization/client/requests/UpdateSettingsRequest.js +33 -0
- package/dist/serialization/client/requests/index.d.ts +1 -0
- package/dist/serialization/client/requests/index.js +5 -0
- package/dist/serialization/index.d.ts +2 -0
- package/dist/serialization/index.js +18 -0
- package/dist/serialization/types/Action.d.ts +15 -0
- package/dist/serialization/types/Action.js +36 -0
- package/dist/serialization/types/BadRequestErrorBody.d.ts +12 -0
- package/dist/serialization/types/BadRequestErrorBody.js +33 -0
- package/dist/serialization/types/BasicRcs.d.ts +18 -0
- package/dist/serialization/types/BasicRcs.js +39 -0
- package/dist/serialization/types/BasicRcsMessage.d.ts +12 -0
- package/dist/serialization/types/BasicRcsMessage.js +33 -0
- package/dist/serialization/types/Call.d.ts +13 -0
- package/dist/serialization/types/Call.js +34 -0
- package/dist/serialization/types/Card.d.ts +18 -0
- package/dist/serialization/types/Card.js +39 -0
- package/dist/serialization/types/CardRcs.d.ts +16 -0
- package/dist/serialization/types/CardRcs.js +37 -0
- package/dist/serialization/types/CardRcsMessage.d.ts +15 -0
- package/dist/serialization/types/CardRcsMessage.js +36 -0
- package/dist/serialization/types/CardStyle.d.ts +20 -0
- package/dist/serialization/types/CardStyle.js +41 -0
- package/dist/serialization/types/CardStyleImageAlignment.d.ts +10 -0
- package/dist/serialization/types/CardStyleImageAlignment.js +31 -0
- package/dist/serialization/types/CardStyleMediaHeight.d.ts +10 -0
- package/dist/serialization/types/CardStyleMediaHeight.js +31 -0
- package/dist/serialization/types/CardStyleOrientation.d.ts +10 -0
- package/dist/serialization/types/CardStyleOrientation.js +31 -0
- package/dist/serialization/types/CardStyleWidth.d.ts +10 -0
- package/dist/serialization/types/CardStyleWidth.js +31 -0
- package/dist/serialization/types/CarouselRcs.d.ts +16 -0
- package/dist/serialization/types/CarouselRcs.js +37 -0
- package/dist/serialization/types/CarouselRcsMessage.d.ts +15 -0
- package/dist/serialization/types/CarouselRcsMessage.js +36 -0
- package/dist/serialization/types/CheckRcsCapabilityResponse.d.ts +13 -0
- package/dist/serialization/types/CheckRcsCapabilityResponse.js +34 -0
- package/dist/serialization/types/Event.d.ts +16 -0
- package/dist/serialization/types/Event.js +37 -0
- package/dist/serialization/types/GetAccountNumberResponse.d.ts +12 -0
- package/dist/serialization/types/GetAccountNumberResponse.js +33 -0
- package/dist/serialization/types/InternalServerErrorBody.d.ts +12 -0
- package/dist/serialization/types/InternalServerErrorBody.js +33 -0
- package/dist/serialization/types/LatLng.d.ts +13 -0
- package/dist/serialization/types/LatLng.js +34 -0
- package/dist/serialization/types/MediaRcs.d.ts +16 -0
- package/dist/serialization/types/MediaRcs.js +37 -0
- package/dist/serialization/types/MediaRcsMessage.d.ts +16 -0
- package/dist/serialization/types/MediaRcsMessage.js +37 -0
- package/dist/serialization/types/MediaType.d.ts +10 -0
- package/dist/serialization/types/MediaType.js +31 -0
- package/dist/serialization/types/PhoneNumber.d.ts +10 -0
- package/dist/serialization/types/PhoneNumber.js +31 -0
- package/dist/serialization/types/Postback.d.ts +14 -0
- package/dist/serialization/types/Postback.js +35 -0
- package/dist/serialization/types/SendRequest.d.ts +15 -0
- package/dist/serialization/types/SendRequest.js +36 -0
- package/dist/serialization/types/SendResponse.d.ts +12 -0
- package/dist/serialization/types/SendResponse.js +33 -0
- package/dist/serialization/types/ShareLocation.d.ts +12 -0
- package/dist/serialization/types/ShareLocation.js +33 -0
- package/dist/serialization/types/Sms.d.ts +16 -0
- package/dist/serialization/types/Sms.js +37 -0
- package/dist/serialization/types/SmsMessage.d.ts +13 -0
- package/dist/serialization/types/SmsMessage.js +34 -0
- package/dist/serialization/types/UnauthorizedErrorBody.d.ts +12 -0
- package/dist/serialization/types/UnauthorizedErrorBody.js +33 -0
- package/dist/serialization/types/UpdateSettingsResponse.d.ts +12 -0
- package/dist/serialization/types/UpdateSettingsResponse.js +33 -0
- package/dist/serialization/types/Url.d.ts +13 -0
- package/dist/serialization/types/Url.js +34 -0
- package/dist/serialization/types/ViewLocation.d.ts +15 -0
- package/dist/serialization/types/ViewLocation.js +36 -0
- package/dist/serialization/types/index.d.ts +34 -0
- package/dist/serialization/types/index.js +50 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +4 -0
- package/environments.d.ts +7 -0
- package/environments.js +9 -0
- package/errors/PinnacleError.d.ts +12 -0
- package/errors/PinnacleError.js +32 -0
- package/errors/PinnacleTimeoutError.d.ts +6 -0
- package/errors/PinnacleTimeoutError.js +13 -0
- package/errors/index.d.ts +2 -0
- package/errors/index.js +7 -0
- package/index.d.ts +4 -0
- package/index.js +34 -0
- package/jest.config.js +5 -0
- package/package.json +42 -24
- package/reference.md +76 -0
- package/serialization/client/index.d.ts +1 -0
- package/serialization/client/index.js +17 -0
- package/serialization/client/requests/UpdateSettingsRequest.d.ts +12 -0
- package/serialization/client/requests/UpdateSettingsRequest.js +33 -0
- package/serialization/client/requests/index.d.ts +1 -0
- package/serialization/client/requests/index.js +5 -0
- package/serialization/index.d.ts +2 -0
- package/serialization/index.js +18 -0
- package/serialization/types/Action.d.ts +15 -0
- package/serialization/types/Action.js +36 -0
- package/serialization/types/BadRequestErrorBody.d.ts +12 -0
- package/serialization/types/BadRequestErrorBody.js +33 -0
- package/serialization/types/BasicRcs.d.ts +18 -0
- package/serialization/types/BasicRcs.js +39 -0
- package/serialization/types/BasicRcsMessage.d.ts +12 -0
- package/serialization/types/BasicRcsMessage.js +33 -0
- package/serialization/types/Call.d.ts +13 -0
- package/serialization/types/Call.js +34 -0
- package/serialization/types/Card.d.ts +18 -0
- package/serialization/types/Card.js +39 -0
- package/serialization/types/CardRcs.d.ts +16 -0
- package/serialization/types/CardRcs.js +37 -0
- package/serialization/types/CardRcsMessage.d.ts +15 -0
- package/serialization/types/CardRcsMessage.js +36 -0
- package/serialization/types/CardStyle.d.ts +20 -0
- package/serialization/types/CardStyle.js +41 -0
- package/serialization/types/CardStyleImageAlignment.d.ts +10 -0
- package/serialization/types/CardStyleImageAlignment.js +31 -0
- package/serialization/types/CardStyleMediaHeight.d.ts +10 -0
- package/serialization/types/CardStyleMediaHeight.js +31 -0
- package/serialization/types/CardStyleOrientation.d.ts +10 -0
- package/serialization/types/CardStyleOrientation.js +31 -0
- package/serialization/types/CardStyleWidth.d.ts +10 -0
- package/serialization/types/CardStyleWidth.js +31 -0
- package/serialization/types/CarouselRcs.d.ts +16 -0
- package/serialization/types/CarouselRcs.js +37 -0
- package/serialization/types/CarouselRcsMessage.d.ts +15 -0
- package/serialization/types/CarouselRcsMessage.js +36 -0
- package/serialization/types/CheckRcsCapabilityResponse.d.ts +13 -0
- package/serialization/types/CheckRcsCapabilityResponse.js +34 -0
- package/serialization/types/Event.d.ts +16 -0
- package/serialization/types/Event.js +37 -0
- package/serialization/types/GetAccountNumberResponse.d.ts +12 -0
- package/serialization/types/GetAccountNumberResponse.js +33 -0
- package/serialization/types/InternalServerErrorBody.d.ts +12 -0
- package/serialization/types/InternalServerErrorBody.js +33 -0
- package/serialization/types/LatLng.d.ts +13 -0
- package/serialization/types/LatLng.js +34 -0
- package/serialization/types/MediaRcs.d.ts +16 -0
- package/serialization/types/MediaRcs.js +37 -0
- package/serialization/types/MediaRcsMessage.d.ts +16 -0
- package/serialization/types/MediaRcsMessage.js +37 -0
- package/serialization/types/MediaType.d.ts +10 -0
- package/serialization/types/MediaType.js +31 -0
- package/serialization/types/PhoneNumber.d.ts +10 -0
- package/serialization/types/PhoneNumber.js +31 -0
- package/serialization/types/Postback.d.ts +14 -0
- package/serialization/types/Postback.js +35 -0
- package/serialization/types/SendRequest.d.ts +15 -0
- package/serialization/types/SendRequest.js +36 -0
- package/serialization/types/SendResponse.d.ts +12 -0
- package/serialization/types/SendResponse.js +33 -0
- package/serialization/types/ShareLocation.d.ts +12 -0
- package/serialization/types/ShareLocation.js +33 -0
- package/serialization/types/Sms.d.ts +16 -0
- package/serialization/types/Sms.js +37 -0
- package/serialization/types/SmsMessage.d.ts +13 -0
- package/serialization/types/SmsMessage.js +34 -0
- package/serialization/types/UnauthorizedErrorBody.d.ts +12 -0
- package/serialization/types/UnauthorizedErrorBody.js +33 -0
- package/serialization/types/UpdateSettingsResponse.d.ts +12 -0
- package/serialization/types/UpdateSettingsResponse.js +33 -0
- package/serialization/types/Url.d.ts +13 -0
- package/serialization/types/Url.js +34 -0
- package/serialization/types/ViewLocation.d.ts +15 -0
- package/serialization/types/ViewLocation.js +36 -0
- package/serialization/types/index.d.ts +34 -0
- package/serialization/types/index.js +50 -0
- package/version.d.ts +1 -0
- package/version.js +4 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.date = void 0;
|
|
4
|
+
const Schema_1 = require("../../Schema");
|
|
5
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
6
|
+
const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
|
|
7
|
+
const schema_utils_1 = require("../schema-utils");
|
|
8
|
+
// https://stackoverflow.com/questions/12756159/regex-and-iso8601-formatted-datetime
|
|
9
|
+
const ISO_8601_REGEX = /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
|
|
10
|
+
function date() {
|
|
11
|
+
const baseSchema = {
|
|
12
|
+
parse: (raw, { breadcrumbsPrefix = [] } = {}) => {
|
|
13
|
+
if (typeof raw !== "string") {
|
|
14
|
+
return {
|
|
15
|
+
ok: false,
|
|
16
|
+
errors: [
|
|
17
|
+
{
|
|
18
|
+
path: breadcrumbsPrefix,
|
|
19
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "string"),
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (!ISO_8601_REGEX.test(raw)) {
|
|
25
|
+
return {
|
|
26
|
+
ok: false,
|
|
27
|
+
errors: [
|
|
28
|
+
{
|
|
29
|
+
path: breadcrumbsPrefix,
|
|
30
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "ISO 8601 date string"),
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
ok: true,
|
|
37
|
+
value: new Date(raw),
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
json: (date, { breadcrumbsPrefix = [] } = {}) => {
|
|
41
|
+
if (date instanceof Date) {
|
|
42
|
+
return {
|
|
43
|
+
ok: true,
|
|
44
|
+
value: date.toISOString(),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return {
|
|
49
|
+
ok: false,
|
|
50
|
+
errors: [
|
|
51
|
+
{
|
|
52
|
+
path: breadcrumbsPrefix,
|
|
53
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(date, "Date object"),
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
getType: () => Schema_1.SchemaType.DATE,
|
|
60
|
+
};
|
|
61
|
+
return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
|
|
62
|
+
}
|
|
63
|
+
exports.date = date;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { date } from "./date";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enum_ = void 0;
|
|
4
|
+
const Schema_1 = require("../../Schema");
|
|
5
|
+
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
7
|
+
function enum_(values) {
|
|
8
|
+
const validValues = new Set(values);
|
|
9
|
+
const schemaCreator = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.ENUM, (value, { allowUnrecognizedEnumValues, breadcrumbsPrefix = [] } = {}) => {
|
|
10
|
+
if (typeof value !== "string") {
|
|
11
|
+
return {
|
|
12
|
+
ok: false,
|
|
13
|
+
errors: [
|
|
14
|
+
{
|
|
15
|
+
path: breadcrumbsPrefix,
|
|
16
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "string"),
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (!validValues.has(value) && !allowUnrecognizedEnumValues) {
|
|
22
|
+
return {
|
|
23
|
+
ok: false,
|
|
24
|
+
errors: [
|
|
25
|
+
{
|
|
26
|
+
path: breadcrumbsPrefix,
|
|
27
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "enum"),
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
ok: true,
|
|
34
|
+
value: value,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
return schemaCreator();
|
|
38
|
+
}
|
|
39
|
+
exports.enum_ = enum_;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { enum_ } from "./enum";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./bigint";
|
|
2
|
+
export * from "./date";
|
|
3
|
+
export * from "./enum";
|
|
4
|
+
export * from "./lazy";
|
|
5
|
+
export * from "./list";
|
|
6
|
+
export * from "./literals";
|
|
7
|
+
export * from "./object";
|
|
8
|
+
export * from "./object-like";
|
|
9
|
+
export * from "./primitives";
|
|
10
|
+
export * from "./record";
|
|
11
|
+
export * from "./schema-utils";
|
|
12
|
+
export * from "./set";
|
|
13
|
+
export * from "./undiscriminated-union";
|
|
14
|
+
export * from "./union";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./bigint"), exports);
|
|
18
|
+
__exportStar(require("./date"), exports);
|
|
19
|
+
__exportStar(require("./enum"), exports);
|
|
20
|
+
__exportStar(require("./lazy"), exports);
|
|
21
|
+
__exportStar(require("./list"), exports);
|
|
22
|
+
__exportStar(require("./literals"), exports);
|
|
23
|
+
__exportStar(require("./object"), exports);
|
|
24
|
+
__exportStar(require("./object-like"), exports);
|
|
25
|
+
__exportStar(require("./primitives"), exports);
|
|
26
|
+
__exportStar(require("./record"), exports);
|
|
27
|
+
__exportStar(require("./schema-utils"), exports);
|
|
28
|
+
__exportStar(require("./set"), exports);
|
|
29
|
+
__exportStar(require("./undiscriminated-union"), exports);
|
|
30
|
+
__exportStar(require("./union"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lazyObject = exports.lazy = void 0;
|
|
4
|
+
var lazy_1 = require("./lazy");
|
|
5
|
+
Object.defineProperty(exports, "lazy", { enumerable: true, get: function () { return lazy_1.lazy; } });
|
|
6
|
+
var lazyObject_1 = require("./lazyObject");
|
|
7
|
+
Object.defineProperty(exports, "lazyObject", { enumerable: true, get: function () { return lazyObject_1.lazyObject; } });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BaseSchema, Schema } from "../../Schema";
|
|
2
|
+
export declare type SchemaGetter<SchemaType extends Schema<any, any>> = () => SchemaType;
|
|
3
|
+
export declare function lazy<Raw, Parsed>(getter: SchemaGetter<Schema<Raw, Parsed>>): Schema<Raw, Parsed>;
|
|
4
|
+
export declare function constructLazyBaseSchema<Raw, Parsed>(getter: SchemaGetter<Schema<Raw, Parsed>>): BaseSchema<Raw, Parsed>;
|
|
5
|
+
export declare function getMemoizedSchema<SchemaType extends Schema<any, any>>(getter: SchemaGetter<SchemaType>): SchemaType;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMemoizedSchema = exports.constructLazyBaseSchema = exports.lazy = void 0;
|
|
4
|
+
const schema_utils_1 = require("../schema-utils");
|
|
5
|
+
function lazy(getter) {
|
|
6
|
+
const baseSchema = constructLazyBaseSchema(getter);
|
|
7
|
+
return Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema));
|
|
8
|
+
}
|
|
9
|
+
exports.lazy = lazy;
|
|
10
|
+
function constructLazyBaseSchema(getter) {
|
|
11
|
+
return {
|
|
12
|
+
parse: (raw, opts) => getMemoizedSchema(getter).parse(raw, opts),
|
|
13
|
+
json: (parsed, opts) => getMemoizedSchema(getter).json(parsed, opts),
|
|
14
|
+
getType: () => getMemoizedSchema(getter).getType(),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.constructLazyBaseSchema = constructLazyBaseSchema;
|
|
18
|
+
function getMemoizedSchema(getter) {
|
|
19
|
+
const castedGetter = getter;
|
|
20
|
+
if (castedGetter.__zurg_memoized == null) {
|
|
21
|
+
castedGetter.__zurg_memoized = getter();
|
|
22
|
+
}
|
|
23
|
+
return castedGetter.__zurg_memoized;
|
|
24
|
+
}
|
|
25
|
+
exports.getMemoizedSchema = getMemoizedSchema;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lazyObject = void 0;
|
|
4
|
+
const object_1 = require("../object");
|
|
5
|
+
const object_like_1 = require("../object-like");
|
|
6
|
+
const schema_utils_1 = require("../schema-utils");
|
|
7
|
+
const lazy_1 = require("./lazy");
|
|
8
|
+
function lazyObject(getter) {
|
|
9
|
+
const baseSchema = Object.assign(Object.assign({}, (0, lazy_1.constructLazyBaseSchema)(getter)), { _getRawProperties: () => (0, lazy_1.getMemoizedSchema)(getter)._getRawProperties(), _getParsedProperties: () => (0, lazy_1.getMemoizedSchema)(getter)._getParsedProperties() });
|
|
10
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), (0, object_1.getObjectUtils)(baseSchema));
|
|
11
|
+
}
|
|
12
|
+
exports.lazyObject = lazyObject;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { list } from "./list";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.list = void 0;
|
|
4
|
+
const Schema_1 = require("../../Schema");
|
|
5
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
6
|
+
const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
|
|
7
|
+
const schema_utils_1 = require("../schema-utils");
|
|
8
|
+
function list(schema) {
|
|
9
|
+
const baseSchema = {
|
|
10
|
+
parse: (raw, opts) => validateAndTransformArray(raw, (item, index) => {
|
|
11
|
+
var _a;
|
|
12
|
+
return schema.parse(item, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `[${index}]`] }));
|
|
13
|
+
}),
|
|
14
|
+
json: (parsed, opts) => validateAndTransformArray(parsed, (item, index) => {
|
|
15
|
+
var _a;
|
|
16
|
+
return schema.json(item, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `[${index}]`] }));
|
|
17
|
+
}),
|
|
18
|
+
getType: () => Schema_1.SchemaType.LIST,
|
|
19
|
+
};
|
|
20
|
+
return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
|
|
21
|
+
}
|
|
22
|
+
exports.list = list;
|
|
23
|
+
function validateAndTransformArray(value, transformItem) {
|
|
24
|
+
if (!Array.isArray(value)) {
|
|
25
|
+
return {
|
|
26
|
+
ok: false,
|
|
27
|
+
errors: [
|
|
28
|
+
{
|
|
29
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "list"),
|
|
30
|
+
path: [],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const maybeValidItems = value.map((item, index) => transformItem(item, index));
|
|
36
|
+
return maybeValidItems.reduce((acc, item) => {
|
|
37
|
+
if (acc.ok && item.ok) {
|
|
38
|
+
return {
|
|
39
|
+
ok: true,
|
|
40
|
+
value: [...acc.value, item.value],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const errors = [];
|
|
44
|
+
if (!acc.ok) {
|
|
45
|
+
errors.push(...acc.errors);
|
|
46
|
+
}
|
|
47
|
+
if (!item.ok) {
|
|
48
|
+
errors.push(...item.errors);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
ok: false,
|
|
52
|
+
errors,
|
|
53
|
+
};
|
|
54
|
+
}, { ok: true, value: [] });
|
|
55
|
+
}
|
|
@@ -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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.booleanLiteral = exports.stringLiteral = void 0;
|
|
4
|
+
var stringLiteral_1 = require("./stringLiteral");
|
|
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; } });
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringLiteral = void 0;
|
|
4
|
+
const Schema_1 = require("../../Schema");
|
|
5
|
+
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
7
|
+
function stringLiteral(literal) {
|
|
8
|
+
const schemaCreator = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.STRING_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}"`),
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return schemaCreator();
|
|
28
|
+
}
|
|
29
|
+
exports.stringLiteral = stringLiteral;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { getObjectUtils, object } from "./object";
|
|
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";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.property = exports.isProperty = exports.objectWithoutOptionalProperties = exports.object = exports.getObjectUtils = void 0;
|
|
4
|
+
var object_1 = require("./object");
|
|
5
|
+
Object.defineProperty(exports, "getObjectUtils", { enumerable: true, get: function () { return object_1.getObjectUtils; } });
|
|
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; } });
|
|
9
|
+
var property_1 = require("./property");
|
|
10
|
+
Object.defineProperty(exports, "isProperty", { enumerable: true, get: function () { return property_1.isProperty; } });
|
|
11
|
+
Object.defineProperty(exports, "property", { enumerable: true, get: function () { return property_1.property; } });
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { BaseObjectSchema, inferObjectSchemaFromPropertySchemas, ObjectUtils, PropertySchemas } from "./types";
|
|
2
|
+
export declare function object<ParsedKeys extends string, T extends PropertySchemas<ParsedKeys>>(schemas: T): inferObjectSchemaFromPropertySchemas<T>;
|
|
3
|
+
export declare function getObjectUtils<Raw, Parsed>(schema: BaseObjectSchema<Raw, Parsed>): ObjectUtils<Raw, Parsed>;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getObjectUtils = exports.object = void 0;
|
|
4
|
+
const Schema_1 = require("../../Schema");
|
|
5
|
+
const entries_1 = require("../../utils/entries");
|
|
6
|
+
const filterObject_1 = require("../../utils/filterObject");
|
|
7
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
8
|
+
const isPlainObject_1 = require("../../utils/isPlainObject");
|
|
9
|
+
const keys_1 = require("../../utils/keys");
|
|
10
|
+
const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
|
|
11
|
+
const partition_1 = require("../../utils/partition");
|
|
12
|
+
const object_like_1 = require("../object-like");
|
|
13
|
+
const schema_utils_1 = require("../schema-utils");
|
|
14
|
+
const property_1 = require("./property");
|
|
15
|
+
function object(schemas) {
|
|
16
|
+
const baseSchema = {
|
|
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) => {
|
|
20
|
+
const rawKeyToProperty = {};
|
|
21
|
+
const requiredKeys = [];
|
|
22
|
+
for (const [parsedKey, schemaOrObjectProperty] of (0, entries_1.entries)(schemas)) {
|
|
23
|
+
const rawKey = (0, property_1.isProperty)(schemaOrObjectProperty) ? schemaOrObjectProperty.rawKey : parsedKey;
|
|
24
|
+
const valueSchema = (0, property_1.isProperty)(schemaOrObjectProperty)
|
|
25
|
+
? schemaOrObjectProperty.valueSchema
|
|
26
|
+
: schemaOrObjectProperty;
|
|
27
|
+
const property = {
|
|
28
|
+
rawKey,
|
|
29
|
+
parsedKey: parsedKey,
|
|
30
|
+
valueSchema,
|
|
31
|
+
};
|
|
32
|
+
rawKeyToProperty[rawKey] = property;
|
|
33
|
+
if (isSchemaRequired(valueSchema)) {
|
|
34
|
+
requiredKeys.push(rawKey);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return validateAndTransformObject({
|
|
38
|
+
value: raw,
|
|
39
|
+
requiredKeys,
|
|
40
|
+
getProperty: (rawKey) => {
|
|
41
|
+
const property = rawKeyToProperty[rawKey];
|
|
42
|
+
if (property == null) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
transformedKey: property.parsedKey,
|
|
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
|
+
},
|
|
51
|
+
};
|
|
52
|
+
},
|
|
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,
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
json: (parsed, opts) => {
|
|
60
|
+
const requiredKeys = [];
|
|
61
|
+
for (const [parsedKey, schemaOrObjectProperty] of (0, entries_1.entries)(schemas)) {
|
|
62
|
+
const valueSchema = (0, property_1.isProperty)(schemaOrObjectProperty)
|
|
63
|
+
? schemaOrObjectProperty.valueSchema
|
|
64
|
+
: schemaOrObjectProperty;
|
|
65
|
+
if (isSchemaRequired(valueSchema)) {
|
|
66
|
+
requiredKeys.push(parsedKey);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return validateAndTransformObject({
|
|
70
|
+
value: parsed,
|
|
71
|
+
requiredKeys,
|
|
72
|
+
getProperty: (parsedKey) => {
|
|
73
|
+
const property = schemas[parsedKey];
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
75
|
+
if (property == null) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
if ((0, property_1.isProperty)(property)) {
|
|
79
|
+
return {
|
|
80
|
+
transformedKey: property.rawKey,
|
|
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
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
return {
|
|
89
|
+
transformedKey: parsedKey,
|
|
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
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
},
|
|
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,
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
getType: () => Schema_1.SchemaType.OBJECT,
|
|
104
|
+
};
|
|
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));
|
|
106
|
+
}
|
|
107
|
+
exports.object = object;
|
|
108
|
+
function validateAndTransformObject({ value, requiredKeys, getProperty, unrecognizedObjectKeys = "fail", skipValidation = false, breadcrumbsPrefix = [], }) {
|
|
109
|
+
if (!(0, isPlainObject_1.isPlainObject)(value)) {
|
|
110
|
+
return {
|
|
111
|
+
ok: false,
|
|
112
|
+
errors: [
|
|
113
|
+
{
|
|
114
|
+
path: breadcrumbsPrefix,
|
|
115
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "object"),
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const missingRequiredKeys = new Set(requiredKeys);
|
|
121
|
+
const errors = [];
|
|
122
|
+
const transformed = {};
|
|
123
|
+
for (const [preTransformedKey, preTransformedItemValue] of Object.entries(value)) {
|
|
124
|
+
const property = getProperty(preTransformedKey);
|
|
125
|
+
if (property != null) {
|
|
126
|
+
missingRequiredKeys.delete(preTransformedKey);
|
|
127
|
+
const value = property.transform(preTransformedItemValue);
|
|
128
|
+
if (value.ok) {
|
|
129
|
+
transformed[property.transformedKey] = value.value;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
transformed[preTransformedKey] = preTransformedItemValue;
|
|
133
|
+
errors.push(...value.errors);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
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
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
errors.push(...requiredKeys
|
|
153
|
+
.filter((key) => missingRequiredKeys.has(key))
|
|
154
|
+
.map((key) => ({
|
|
155
|
+
path: breadcrumbsPrefix,
|
|
156
|
+
message: `Missing required key "${key}"`,
|
|
157
|
+
})));
|
|
158
|
+
if (errors.length === 0 || skipValidation) {
|
|
159
|
+
return {
|
|
160
|
+
ok: true,
|
|
161
|
+
value: transformed,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
return {
|
|
166
|
+
ok: false,
|
|
167
|
+
errors,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function getObjectUtils(schema) {
|
|
172
|
+
return {
|
|
173
|
+
extend: (extension) => {
|
|
174
|
+
const baseSchema = {
|
|
175
|
+
_getParsedProperties: () => [...schema._getParsedProperties(), ...extension._getParsedProperties()],
|
|
176
|
+
_getRawProperties: () => [...schema._getRawProperties(), ...extension._getRawProperties()],
|
|
177
|
+
parse: (raw, opts) => {
|
|
178
|
+
return validateAndTransformExtendedObject({
|
|
179
|
+
extensionKeys: extension._getRawProperties(),
|
|
180
|
+
value: raw,
|
|
181
|
+
transformBase: (rawBase) => schema.parse(rawBase, opts),
|
|
182
|
+
transformExtension: (rawExtension) => extension.parse(rawExtension, opts),
|
|
183
|
+
});
|
|
184
|
+
},
|
|
185
|
+
json: (parsed, opts) => {
|
|
186
|
+
return validateAndTransformExtendedObject({
|
|
187
|
+
extensionKeys: extension._getParsedProperties(),
|
|
188
|
+
value: parsed,
|
|
189
|
+
transformBase: (parsedBase) => schema.json(parsedBase, opts),
|
|
190
|
+
transformExtension: (parsedExtension) => extension.json(parsedExtension, opts),
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
getType: () => Schema_1.SchemaType.OBJECT,
|
|
194
|
+
};
|
|
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));
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
exports.getObjectUtils = getObjectUtils;
|
|
200
|
+
function validateAndTransformExtendedObject({ extensionKeys, value, transformBase, transformExtension, }) {
|
|
201
|
+
const extensionPropertiesSet = new Set(extensionKeys);
|
|
202
|
+
const [extensionProperties, baseProperties] = (0, partition_1.partition)((0, keys_1.keys)(value), (key) => extensionPropertiesSet.has(key));
|
|
203
|
+
const transformedBase = transformBase((0, filterObject_1.filterObject)(value, baseProperties));
|
|
204
|
+
const transformedExtension = transformExtension((0, filterObject_1.filterObject)(value, extensionProperties));
|
|
205
|
+
if (transformedBase.ok && transformedExtension.ok) {
|
|
206
|
+
return {
|
|
207
|
+
ok: true,
|
|
208
|
+
value: Object.assign(Object.assign({}, transformedBase.value), transformedExtension.value),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
return {
|
|
213
|
+
ok: false,
|
|
214
|
+
errors: [
|
|
215
|
+
...(transformedBase.ok ? [] : transformedBase.errors),
|
|
216
|
+
...(transformedExtension.ok ? [] : transformedExtension.errors),
|
|
217
|
+
],
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function isSchemaRequired(schema) {
|
|
222
|
+
return !isSchemaOptional(schema);
|
|
223
|
+
}
|
|
224
|
+
function isSchemaOptional(schema) {
|
|
225
|
+
switch (schema.getType()) {
|
|
226
|
+
case Schema_1.SchemaType.ANY:
|
|
227
|
+
case Schema_1.SchemaType.UNKNOWN:
|
|
228
|
+
case Schema_1.SchemaType.OPTIONAL:
|
|
229
|
+
return true;
|
|
230
|
+
default:
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
}
|