@go-mondo/identity-sdk 0.0.2-beta.12 → 0.0.2-beta.13
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/.release-please-manifest.json +1 -1
- package/.tsbuildinfo/cjs.json +1 -1
- package/.tsbuildinfo/esm.json +1 -1
- package/CHANGELOG.md +7 -0
- package/dist/cjs/action/schema/base.d.ts +22 -20
- package/dist/cjs/action/schema/base.d.ts.map +1 -1
- package/dist/cjs/action/schema/base.js +15 -8
- package/dist/cjs/action/schema/base.test.js +50 -34
- package/dist/cjs/action/schema/operations/set-password.d.ts +30 -30
- package/dist/cjs/action/schema/operations/set-password.d.ts.map +1 -1
- package/dist/cjs/action/schema/operations/set-password.js +9 -8
- package/dist/cjs/action/schema/operations/set-password.test.js +30 -29
- package/dist/cjs/action/schema/operations/sign-up-verification.d.ts +21 -21
- package/dist/cjs/action/schema/operations/sign-up-verification.d.ts.map +1 -1
- package/dist/cjs/action/schema/operations/sign-up-verification.js +8 -7
- package/dist/cjs/action/schema/operations/sign-up-verification.test.js +28 -29
- package/dist/cjs/action/schema/operations/sign-up.d.ts +40 -43
- package/dist/cjs/action/schema/operations/sign-up.d.ts.map +1 -1
- package/dist/cjs/action/schema/operations/sign-up.js +24 -15
- package/dist/cjs/action/schema/operations/sign-up.test.js +33 -34
- package/dist/cjs/action/schema/operations/user-attribute-verification.d.ts +19 -19
- package/dist/cjs/action/schema/operations/user-attribute-verification.d.ts.map +1 -1
- package/dist/cjs/action/schema/operations/user-attribute-verification.js +6 -5
- package/dist/cjs/action/schema/operations/user-attribute-verification.test.js +25 -26
- package/dist/cjs/action/schema/schema.d.ts +70 -76
- package/dist/cjs/action/schema/schema.d.ts.map +1 -1
- package/dist/cjs/action/schema/schema.test.js +26 -27
- package/dist/cjs/activity/resources.d.ts.map +1 -1
- package/dist/cjs/activity/resources.js +1 -1
- package/dist/cjs/activity/schema/base.d.ts +88 -69
- package/dist/cjs/activity/schema/base.d.ts.map +1 -1
- package/dist/cjs/activity/schema/base.js +30 -18
- package/dist/cjs/activity/schema/base.test.js +85 -55
- package/dist/cjs/activity/schema/schema.d.ts +293 -226
- package/dist/cjs/activity/schema/schema.d.ts.map +1 -1
- package/dist/cjs/activity/schema/schema.test.js +47 -48
- package/dist/cjs/activity/schema/types/authentication.d.ts +64 -46
- package/dist/cjs/activity/schema/types/authentication.d.ts.map +1 -1
- package/dist/cjs/activity/schema/types/authentication.js +16 -7
- package/dist/cjs/activity/schema/types/authentication.test.js +37 -38
- package/dist/cjs/activity/schema/types/authorization.d.ts +64 -46
- package/dist/cjs/activity/schema/types/authorization.d.ts.map +1 -1
- package/dist/cjs/activity/schema/types/authorization.js +16 -7
- package/dist/cjs/activity/schema/types/authorization.test.js +41 -42
- package/dist/cjs/activity/schema/types/note.d.ts +83 -70
- package/dist/cjs/activity/schema/types/note.d.ts.map +1 -1
- package/dist/cjs/activity/schema/types/note.js +20 -12
- package/dist/cjs/activity/schema/types/note.test.js +48 -49
- package/dist/cjs/activity/schema/types/operation.d.ts +64 -45
- package/dist/cjs/activity/schema/types/operation.d.ts.map +1 -1
- package/dist/cjs/activity/schema/types/operation.js +19 -8
- package/dist/cjs/activity/schema/types/operation.test.js +34 -35
- package/dist/cjs/activity/schema/types/unknown.d.ts +50 -41
- package/dist/cjs/activity/schema/types/unknown.d.ts.map +1 -1
- package/dist/cjs/activity/schema/types/unknown.js +12 -6
- package/dist/cjs/activity/schema/types/unknown.test.js +29 -30
- package/dist/cjs/app/authorization/resources.d.ts.map +1 -1
- package/dist/cjs/app/authorization/resources.js +2 -3
- package/dist/cjs/app/authorization/schema.d.ts +96 -52
- package/dist/cjs/app/authorization/schema.d.ts.map +1 -1
- package/dist/cjs/app/authorization/schema.js +61 -52
- package/dist/cjs/app/authorization/schema.test.js +96 -71
- package/dist/cjs/app/oauth/resources.d.ts.map +1 -1
- package/dist/cjs/app/oauth/resources.js +2 -3
- package/dist/cjs/app/oauth/schema.d.ts +34 -41
- package/dist/cjs/app/oauth/schema.d.ts.map +1 -1
- package/dist/cjs/app/oauth/schema.js +23 -17
- package/dist/cjs/app/oauth/schema.test.js +38 -39
- package/dist/cjs/app/oidc/resources.d.ts.map +1 -1
- package/dist/cjs/app/oidc/resources.js +4 -5
- package/dist/cjs/app/oidc/schema.d.ts +26 -37
- package/dist/cjs/app/oidc/schema.d.ts.map +1 -1
- package/dist/cjs/app/oidc/schema.js +17 -12
- package/dist/cjs/app/oidc/schema.test.js +45 -26
- package/dist/cjs/app/registration/resources.d.ts.map +1 -1
- package/dist/cjs/app/registration/resources.js +2 -3
- package/dist/cjs/app/registration/schema.d.ts +24 -31
- package/dist/cjs/app/registration/schema.d.ts.map +1 -1
- package/dist/cjs/app/registration/schema.js +23 -16
- package/dist/cjs/app/registration/schema.test.js +68 -150
- package/dist/cjs/app/resources.d.ts.map +1 -1
- package/dist/cjs/app/resources.js +5 -5
- package/dist/cjs/app/saml/resources.d.ts.map +1 -1
- package/dist/cjs/app/saml/resources.js +4 -5
- package/dist/cjs/app/saml/schema.d.ts +26 -37
- package/dist/cjs/app/saml/schema.d.ts.map +1 -1
- package/dist/cjs/app/saml/schema.js +17 -12
- package/dist/cjs/app/schema.d.ts +72 -68
- package/dist/cjs/app/schema.d.ts.map +1 -1
- package/dist/cjs/app/schema.js +34 -27
- package/dist/cjs/app/schema.test.js +38 -41
- package/dist/cjs/association/resources.d.ts.map +1 -1
- package/dist/cjs/association/resources.js +3 -5
- package/dist/cjs/association/schema.d.ts +225 -181
- package/dist/cjs/association/schema.d.ts.map +1 -1
- package/dist/cjs/association/schema.js +28 -22
- package/dist/cjs/association/schema.test.js +36 -28
- package/dist/cjs/authentication/factors/schema.d.ts +18 -55
- package/dist/cjs/authentication/factors/schema.d.ts.map +1 -1
- package/dist/cjs/authentication/factors/schema.js +21 -23
- package/dist/cjs/authentication/factors/schema.test.js +33 -34
- package/dist/cjs/authentication/providers/schema.d.ts +23 -22
- package/dist/cjs/authentication/providers/schema.d.ts.map +1 -1
- package/dist/cjs/authentication/providers/schema.js +10 -8
- package/dist/cjs/authentication/sessions/resources.d.ts.map +1 -1
- package/dist/cjs/authentication/sessions/resources.js +2 -2
- package/dist/cjs/authentication/sessions/schema.d.ts +101 -74
- package/dist/cjs/authentication/sessions/schema.d.ts.map +1 -1
- package/dist/cjs/authentication/sessions/schema.js +56 -25
- package/dist/cjs/authentication/settings/resources.d.ts.map +1 -1
- package/dist/cjs/authentication/settings/resources.js +2 -3
- package/dist/cjs/authentication/settings/schema.d.ts +25 -68
- package/dist/cjs/authentication/settings/schema.d.ts.map +1 -1
- package/dist/cjs/authentication/settings/schema.js +13 -10
- package/dist/cjs/authentication/settings/schema.test.js +28 -19
- package/dist/cjs/authentication/strategies/resources.d.ts.map +1 -1
- package/dist/cjs/authentication/strategies/resources.js +5 -5
- package/dist/cjs/authentication/strategies/schema/base.d.ts +59 -51
- package/dist/cjs/authentication/strategies/schema/base.d.ts.map +1 -1
- package/dist/cjs/authentication/strategies/schema/base.js +26 -15
- package/dist/cjs/authentication/strategies/schema/schema.d.ts +206 -197
- package/dist/cjs/authentication/strategies/schema/schema.d.ts.map +1 -1
- package/dist/cjs/authentication/strategies/schema/types/email.d.ts +61 -60
- package/dist/cjs/authentication/strategies/schema/types/email.d.ts.map +1 -1
- package/dist/cjs/authentication/strategies/schema/types/email.js +24 -14
- package/dist/cjs/authentication/strategies/schema/types/email.test.js +49 -50
- package/dist/cjs/authentication/strategies/schema/types/password.d.ts +129 -122
- package/dist/cjs/authentication/strategies/schema/types/password.d.ts.map +1 -1
- package/dist/cjs/authentication/strategies/schema/types/password.js +33 -25
- package/dist/cjs/authentication/strategies/schema/types/totp.d.ts +107 -94
- package/dist/cjs/authentication/strategies/schema/types/totp.d.ts.map +1 -1
- package/dist/cjs/authentication/strategies/schema/types/totp.js +50 -26
- package/dist/cjs/authorization/permissions/resources.d.ts.map +1 -1
- package/dist/cjs/authorization/permissions/resources.js +5 -5
- package/dist/cjs/authorization/permissions/schema.d.ts +92 -88
- package/dist/cjs/authorization/permissions/schema.d.ts.map +1 -1
- package/dist/cjs/authorization/permissions/schema.js +38 -28
- package/dist/cjs/authorization/permissions/schema.test.js +57 -59
- package/dist/cjs/authorization/roles/resources.d.ts.map +1 -1
- package/dist/cjs/authorization/roles/resources.js +5 -5
- package/dist/cjs/authorization/roles/schema.d.ts +102 -98
- package/dist/cjs/authorization/roles/schema.d.ts.map +1 -1
- package/dist/cjs/authorization/roles/schema.js +35 -32
- package/dist/cjs/authorization/roles/schema.test.js +58 -59
- package/dist/cjs/authorization/schema.d.ts +7 -6
- package/dist/cjs/authorization/schema.d.ts.map +1 -1
- package/dist/cjs/authorization/schema.js +9 -3
- package/dist/cjs/common/resources/init.d.ts +7 -6
- package/dist/cjs/common/resources/init.d.ts.map +1 -1
- package/dist/cjs/common/resources/init.js +17 -9
- package/dist/cjs/common/resources/utils.d.ts +0 -9
- package/dist/cjs/common/resources/utils.d.ts.map +1 -1
- package/dist/cjs/common/resources/utils.js +0 -26
- package/dist/cjs/common/resources/utils.test.js +0 -29
- package/dist/cjs/common/schema/aggregate.d.ts +6 -5
- package/dist/cjs/common/schema/aggregate.d.ts.map +1 -1
- package/dist/cjs/common/schema/aggregate.js +4 -4
- package/dist/cjs/common/schema/aggregate.test.js +21 -22
- package/dist/cjs/common/schema/collection.d.ts +11 -10
- package/dist/cjs/common/schema/collection.d.ts.map +1 -1
- package/dist/cjs/common/schema/collection.js +6 -4
- package/dist/cjs/common/schema/collection.test.js +66 -48
- package/dist/cjs/common/schema/dates.d.ts +27 -26
- package/dist/cjs/common/schema/dates.d.ts.map +1 -1
- package/dist/cjs/common/schema/dates.js +17 -11
- package/dist/cjs/common/schema/dates.test.js +24 -13
- package/dist/cjs/common/schema/id.d.ts +2 -1
- package/dist/cjs/common/schema/id.d.ts.map +1 -1
- package/dist/cjs/common/schema/id.js +2 -2
- package/dist/cjs/common/schema/id.test.js +70 -38
- package/dist/cjs/common/schema/jwt.d.ts +27 -14
- package/dist/cjs/common/schema/jwt.d.ts.map +1 -1
- package/dist/cjs/common/schema/jwt.js +14 -2
- package/dist/cjs/common/schema/jwt.test.js +25 -19
- package/dist/cjs/common/schema/metadata.d.ts +24 -41
- package/dist/cjs/common/schema/metadata.d.ts.map +1 -1
- package/dist/cjs/common/schema/metadata.js +38 -37
- package/dist/cjs/common/schema/metadata.test.js +36 -37
- package/dist/cjs/common/schema/pagination.d.ts +6 -5
- package/dist/cjs/common/schema/pagination.d.ts.map +1 -1
- package/dist/cjs/common/schema/pagination.js +4 -4
- package/dist/cjs/common/schema/pagination.test.js +19 -20
- package/dist/cjs/common/schema/schema.d.ts +4 -4
- package/dist/cjs/common/schema/schema.d.ts.map +1 -1
- package/dist/cjs/common/schema/schema.js +6 -5
- package/dist/cjs/common/schema/schema.test.js +9 -15
- package/dist/cjs/common/schema/sets.d.ts +3 -2
- package/dist/cjs/common/schema/sets.d.ts.map +1 -1
- package/dist/cjs/common/schema/sets.js +9 -6
- package/dist/cjs/common/schema/sets.test.js +52 -43
- package/dist/cjs/customer/organization/schema.d.ts +44 -46
- package/dist/cjs/customer/organization/schema.d.ts.map +1 -1
- package/dist/cjs/customer/organization/schema.js +26 -20
- package/dist/cjs/customer/schema.d.ts +7 -6
- package/dist/cjs/customer/schema.d.ts.map +1 -1
- package/dist/cjs/customer/schema.js +9 -3
- package/dist/cjs/customer/users/resources.d.ts.map +1 -1
- package/dist/cjs/customer/users/resources.js +5 -5
- package/dist/cjs/customer/users/schema.d.ts +140 -139
- package/dist/cjs/customer/users/schema.d.ts.map +1 -1
- package/dist/cjs/customer/users/schema.js +58 -46
- package/dist/cjs/customer/users/schema.test.js +22 -35
- package/dist/cjs/customer/users/utils.d.ts +3 -2
- package/dist/cjs/customer/users/utils.d.ts.map +1 -1
- package/dist/cjs/identity/schema.d.ts +5 -1
- package/dist/cjs/identity/schema.d.ts.map +1 -1
- package/dist/cjs/identity/schema.js +5 -2
- package/dist/cjs/identity/schema.test.js +21 -16
- package/dist/cjs/oauth/authorize/schema/grants/authorization-code.d.ts +31 -28
- package/dist/cjs/oauth/authorize/schema/grants/authorization-code.d.ts.map +1 -1
- package/dist/cjs/oauth/authorize/schema/grants/authorization-code.js +56 -37
- package/dist/cjs/oauth/authorize/schema/grants/authorization-code.test.js +44 -45
- package/dist/cjs/oauth/authorize/schema/grants/implicit.d.ts +16 -10
- package/dist/cjs/oauth/authorize/schema/grants/implicit.d.ts.map +1 -1
- package/dist/cjs/oauth/authorize/schema/grants/implicit.js +19 -10
- package/dist/cjs/oauth/authorize/schema/schema.d.ts +44 -36
- package/dist/cjs/oauth/authorize/schema/schema.d.ts.map +1 -1
- package/dist/cjs/oauth/common/schema.d.ts +21 -7
- package/dist/cjs/oauth/common/schema.d.ts.map +1 -1
- package/dist/cjs/oauth/common/schema.js +20 -7
- package/dist/cjs/oauth/common/schema.test.js +25 -26
- package/dist/cjs/oauth/token/schema/grants/authorization-code.d.ts +12 -9
- package/dist/cjs/oauth/token/schema/grants/authorization-code.d.ts.map +1 -1
- package/dist/cjs/oauth/token/schema/grants/authorization-code.js +11 -10
- package/dist/cjs/oauth/token/schema/grants/client-credentials.d.ts +20 -15
- package/dist/cjs/oauth/token/schema/grants/client-credentials.d.ts.map +1 -1
- package/dist/cjs/oauth/token/schema/grants/client-credentials.js +13 -8
- package/dist/cjs/oauth/token/schema/grants/refresh-token.d.ts +11 -8
- package/dist/cjs/oauth/token/schema/grants/refresh-token.d.ts.map +1 -1
- package/dist/cjs/oauth/token/schema/grants/refresh-token.js +6 -6
- package/dist/cjs/oauth/token/schema/schema.d.ts +28 -21
- package/dist/cjs/oauth/token/schema/schema.d.ts.map +1 -1
- package/dist/cjs/oauth/token/schema/schema.test.js +42 -28
- package/dist/cjs/workspace/authorization/schema.d.ts +44 -27
- package/dist/cjs/workspace/authorization/schema.d.ts.map +1 -1
- package/dist/cjs/workspace/authorization/schema.js +16 -11
- package/dist/cjs/workspace/branding/schema.d.ts +30 -37
- package/dist/cjs/workspace/branding/schema.d.ts.map +1 -1
- package/dist/cjs/workspace/branding/schema.js +20 -15
- package/dist/cjs/workspace/membership/schema.d.ts +21 -20
- package/dist/cjs/workspace/membership/schema.d.ts.map +1 -1
- package/dist/cjs/workspace/membership/schema.js +6 -6
- package/dist/cjs/workspace/registration/schema.d.ts +26 -27
- package/dist/cjs/workspace/registration/schema.d.ts.map +1 -1
- package/dist/cjs/workspace/registration/schema.js +13 -11
- package/dist/cjs/workspace/settings/schema.d.ts +12 -19
- package/dist/cjs/workspace/settings/schema.d.ts.map +1 -1
- package/dist/cjs/workspace/settings/schema.js +7 -6
- package/dist/cjs/workspace/settings/schema.test.js +18 -19
- package/dist/cjs/workspace/tenant/schema.d.ts +55 -57
- package/dist/cjs/workspace/tenant/schema.d.ts.map +1 -1
- package/dist/cjs/workspace/tenant/schema.js +17 -12
- package/dist/cjs/workspace/user/notifications/schema.d.ts +50 -56
- package/dist/cjs/workspace/user/notifications/schema.d.ts.map +1 -1
- package/dist/cjs/workspace/user/notifications/schema.js +26 -23
- package/dist/cjs/workspace/user/preferences/schema.d.ts +18 -25
- package/dist/cjs/workspace/user/preferences/schema.d.ts.map +1 -1
- package/dist/cjs/workspace/user/preferences/schema.js +16 -11
- package/dist/esm/action/schema/base.d.ts +22 -20
- package/dist/esm/action/schema/base.d.ts.map +1 -1
- package/dist/esm/action/schema/base.js +15 -8
- package/dist/esm/action/schema/base.test.js +50 -34
- package/dist/esm/action/schema/operations/set-password.d.ts +30 -30
- package/dist/esm/action/schema/operations/set-password.d.ts.map +1 -1
- package/dist/esm/action/schema/operations/set-password.js +9 -8
- package/dist/esm/action/schema/operations/set-password.test.js +30 -29
- package/dist/esm/action/schema/operations/sign-up-verification.d.ts +21 -21
- package/dist/esm/action/schema/operations/sign-up-verification.d.ts.map +1 -1
- package/dist/esm/action/schema/operations/sign-up-verification.js +8 -7
- package/dist/esm/action/schema/operations/sign-up-verification.test.js +28 -29
- package/dist/esm/action/schema/operations/sign-up.d.ts +40 -43
- package/dist/esm/action/schema/operations/sign-up.d.ts.map +1 -1
- package/dist/esm/action/schema/operations/sign-up.js +19 -10
- package/dist/esm/action/schema/operations/sign-up.test.js +33 -34
- package/dist/esm/action/schema/operations/user-attribute-verification.d.ts +19 -19
- package/dist/esm/action/schema/operations/user-attribute-verification.d.ts.map +1 -1
- package/dist/esm/action/schema/operations/user-attribute-verification.js +6 -5
- package/dist/esm/action/schema/operations/user-attribute-verification.test.js +25 -26
- package/dist/esm/action/schema/schema.d.ts +70 -76
- package/dist/esm/action/schema/schema.d.ts.map +1 -1
- package/dist/esm/action/schema/schema.test.js +26 -27
- package/dist/esm/activity/resources.d.ts.map +1 -1
- package/dist/esm/activity/resources.js +2 -2
- package/dist/esm/activity/schema/base.d.ts +88 -69
- package/dist/esm/activity/schema/base.d.ts.map +1 -1
- package/dist/esm/activity/schema/base.js +30 -18
- package/dist/esm/activity/schema/base.test.js +85 -55
- package/dist/esm/activity/schema/schema.d.ts +293 -226
- package/dist/esm/activity/schema/schema.d.ts.map +1 -1
- package/dist/esm/activity/schema/schema.test.js +47 -48
- package/dist/esm/activity/schema/types/authentication.d.ts +64 -46
- package/dist/esm/activity/schema/types/authentication.d.ts.map +1 -1
- package/dist/esm/activity/schema/types/authentication.js +16 -7
- package/dist/esm/activity/schema/types/authentication.test.js +37 -38
- package/dist/esm/activity/schema/types/authorization.d.ts +64 -46
- package/dist/esm/activity/schema/types/authorization.d.ts.map +1 -1
- package/dist/esm/activity/schema/types/authorization.js +16 -7
- package/dist/esm/activity/schema/types/authorization.test.js +41 -42
- package/dist/esm/activity/schema/types/note.d.ts +83 -70
- package/dist/esm/activity/schema/types/note.d.ts.map +1 -1
- package/dist/esm/activity/schema/types/note.js +20 -12
- package/dist/esm/activity/schema/types/note.test.js +48 -49
- package/dist/esm/activity/schema/types/operation.d.ts +64 -45
- package/dist/esm/activity/schema/types/operation.d.ts.map +1 -1
- package/dist/esm/activity/schema/types/operation.js +19 -8
- package/dist/esm/activity/schema/types/operation.test.js +34 -35
- package/dist/esm/activity/schema/types/unknown.d.ts +50 -41
- package/dist/esm/activity/schema/types/unknown.d.ts.map +1 -1
- package/dist/esm/activity/schema/types/unknown.js +12 -6
- package/dist/esm/activity/schema/types/unknown.test.js +29 -30
- package/dist/esm/app/authorization/resources.d.ts.map +1 -1
- package/dist/esm/app/authorization/resources.js +2 -3
- package/dist/esm/app/authorization/schema.d.ts +96 -52
- package/dist/esm/app/authorization/schema.d.ts.map +1 -1
- package/dist/esm/app/authorization/schema.js +61 -52
- package/dist/esm/app/authorization/schema.test.js +96 -71
- package/dist/esm/app/oauth/resources.d.ts.map +1 -1
- package/dist/esm/app/oauth/resources.js +2 -3
- package/dist/esm/app/oauth/schema.d.ts +34 -41
- package/dist/esm/app/oauth/schema.d.ts.map +1 -1
- package/dist/esm/app/oauth/schema.js +23 -17
- package/dist/esm/app/oauth/schema.test.js +38 -39
- package/dist/esm/app/oidc/resources.d.ts.map +1 -1
- package/dist/esm/app/oidc/resources.js +4 -5
- package/dist/esm/app/oidc/schema.d.ts +26 -37
- package/dist/esm/app/oidc/schema.d.ts.map +1 -1
- package/dist/esm/app/oidc/schema.js +17 -12
- package/dist/esm/app/oidc/schema.test.js +45 -26
- package/dist/esm/app/registration/resources.d.ts.map +1 -1
- package/dist/esm/app/registration/resources.js +2 -3
- package/dist/esm/app/registration/schema.d.ts +24 -31
- package/dist/esm/app/registration/schema.d.ts.map +1 -1
- package/dist/esm/app/registration/schema.js +23 -16
- package/dist/esm/app/registration/schema.test.js +68 -150
- package/dist/esm/app/resources.d.ts.map +1 -1
- package/dist/esm/app/resources.js +6 -6
- package/dist/esm/app/saml/resources.d.ts.map +1 -1
- package/dist/esm/app/saml/resources.js +4 -5
- package/dist/esm/app/saml/schema.d.ts +26 -37
- package/dist/esm/app/saml/schema.d.ts.map +1 -1
- package/dist/esm/app/saml/schema.js +17 -12
- package/dist/esm/app/schema.d.ts +72 -68
- package/dist/esm/app/schema.d.ts.map +1 -1
- package/dist/esm/app/schema.js +34 -27
- package/dist/esm/app/schema.test.js +38 -41
- package/dist/esm/association/resources.d.ts.map +1 -1
- package/dist/esm/association/resources.js +4 -6
- package/dist/esm/association/schema.d.ts +225 -181
- package/dist/esm/association/schema.d.ts.map +1 -1
- package/dist/esm/association/schema.js +28 -22
- package/dist/esm/association/schema.test.js +36 -28
- package/dist/esm/authentication/factors/schema.d.ts +18 -55
- package/dist/esm/authentication/factors/schema.d.ts.map +1 -1
- package/dist/esm/authentication/factors/schema.js +21 -23
- package/dist/esm/authentication/factors/schema.test.js +33 -34
- package/dist/esm/authentication/providers/schema.d.ts +23 -22
- package/dist/esm/authentication/providers/schema.d.ts.map +1 -1
- package/dist/esm/authentication/providers/schema.js +10 -8
- package/dist/esm/authentication/sessions/resources.d.ts.map +1 -1
- package/dist/esm/authentication/sessions/resources.js +3 -3
- package/dist/esm/authentication/sessions/schema.d.ts +101 -74
- package/dist/esm/authentication/sessions/schema.d.ts.map +1 -1
- package/dist/esm/authentication/sessions/schema.js +56 -25
- package/dist/esm/authentication/settings/resources.d.ts.map +1 -1
- package/dist/esm/authentication/settings/resources.js +2 -3
- package/dist/esm/authentication/settings/schema.d.ts +25 -68
- package/dist/esm/authentication/settings/schema.d.ts.map +1 -1
- package/dist/esm/authentication/settings/schema.js +13 -10
- package/dist/esm/authentication/settings/schema.test.js +28 -19
- package/dist/esm/authentication/strategies/resources.d.ts.map +1 -1
- package/dist/esm/authentication/strategies/resources.js +6 -6
- package/dist/esm/authentication/strategies/schema/base.d.ts +59 -51
- package/dist/esm/authentication/strategies/schema/base.d.ts.map +1 -1
- package/dist/esm/authentication/strategies/schema/base.js +26 -15
- package/dist/esm/authentication/strategies/schema/schema.d.ts +206 -197
- package/dist/esm/authentication/strategies/schema/schema.d.ts.map +1 -1
- package/dist/esm/authentication/strategies/schema/types/email.d.ts +61 -60
- package/dist/esm/authentication/strategies/schema/types/email.d.ts.map +1 -1
- package/dist/esm/authentication/strategies/schema/types/email.js +24 -14
- package/dist/esm/authentication/strategies/schema/types/email.test.js +49 -50
- package/dist/esm/authentication/strategies/schema/types/password.d.ts +129 -122
- package/dist/esm/authentication/strategies/schema/types/password.d.ts.map +1 -1
- package/dist/esm/authentication/strategies/schema/types/password.js +33 -25
- package/dist/esm/authentication/strategies/schema/types/totp.d.ts +107 -94
- package/dist/esm/authentication/strategies/schema/types/totp.d.ts.map +1 -1
- package/dist/esm/authentication/strategies/schema/types/totp.js +50 -26
- package/dist/esm/authorization/permissions/resources.d.ts.map +1 -1
- package/dist/esm/authorization/permissions/resources.js +6 -6
- package/dist/esm/authorization/permissions/schema.d.ts +92 -88
- package/dist/esm/authorization/permissions/schema.d.ts.map +1 -1
- package/dist/esm/authorization/permissions/schema.js +38 -28
- package/dist/esm/authorization/permissions/schema.test.js +57 -59
- package/dist/esm/authorization/roles/resources.d.ts.map +1 -1
- package/dist/esm/authorization/roles/resources.js +6 -6
- package/dist/esm/authorization/roles/schema.d.ts +102 -98
- package/dist/esm/authorization/roles/schema.d.ts.map +1 -1
- package/dist/esm/authorization/roles/schema.js +35 -32
- package/dist/esm/authorization/roles/schema.test.js +58 -59
- package/dist/esm/authorization/schema.d.ts +7 -6
- package/dist/esm/authorization/schema.d.ts.map +1 -1
- package/dist/esm/authorization/schema.js +9 -3
- package/dist/esm/common/resources/init.d.ts +7 -6
- package/dist/esm/common/resources/init.d.ts.map +1 -1
- package/dist/esm/common/resources/init.js +17 -9
- package/dist/esm/common/resources/utils.d.ts +0 -9
- package/dist/esm/common/resources/utils.d.ts.map +1 -1
- package/dist/esm/common/resources/utils.js +0 -24
- package/dist/esm/common/resources/utils.test.js +1 -30
- package/dist/esm/common/schema/aggregate.d.ts +6 -5
- package/dist/esm/common/schema/aggregate.d.ts.map +1 -1
- package/dist/esm/common/schema/aggregate.js +4 -4
- package/dist/esm/common/schema/aggregate.test.js +21 -22
- package/dist/esm/common/schema/collection.d.ts +11 -10
- package/dist/esm/common/schema/collection.d.ts.map +1 -1
- package/dist/esm/common/schema/collection.js +4 -4
- package/dist/esm/common/schema/collection.test.js +66 -48
- package/dist/esm/common/schema/dates.d.ts +27 -26
- package/dist/esm/common/schema/dates.d.ts.map +1 -1
- package/dist/esm/common/schema/dates.js +17 -11
- package/dist/esm/common/schema/dates.test.js +24 -13
- package/dist/esm/common/schema/id.d.ts +2 -1
- package/dist/esm/common/schema/id.d.ts.map +1 -1
- package/dist/esm/common/schema/id.js +2 -2
- package/dist/esm/common/schema/id.test.js +70 -38
- package/dist/esm/common/schema/jwt.d.ts +27 -14
- package/dist/esm/common/schema/jwt.d.ts.map +1 -1
- package/dist/esm/common/schema/jwt.js +14 -2
- package/dist/esm/common/schema/jwt.test.js +25 -19
- package/dist/esm/common/schema/metadata.d.ts +24 -41
- package/dist/esm/common/schema/metadata.d.ts.map +1 -1
- package/dist/esm/common/schema/metadata.js +38 -37
- package/dist/esm/common/schema/metadata.test.js +36 -37
- package/dist/esm/common/schema/pagination.d.ts +6 -5
- package/dist/esm/common/schema/pagination.d.ts.map +1 -1
- package/dist/esm/common/schema/pagination.js +4 -4
- package/dist/esm/common/schema/pagination.test.js +19 -20
- package/dist/esm/common/schema/schema.d.ts +4 -4
- package/dist/esm/common/schema/schema.d.ts.map +1 -1
- package/dist/esm/common/schema/schema.js +6 -5
- package/dist/esm/common/schema/schema.test.js +9 -15
- package/dist/esm/common/schema/sets.d.ts +3 -2
- package/dist/esm/common/schema/sets.d.ts.map +1 -1
- package/dist/esm/common/schema/sets.js +9 -6
- package/dist/esm/common/schema/sets.test.js +53 -44
- package/dist/esm/customer/organization/schema.d.ts +44 -46
- package/dist/esm/customer/organization/schema.d.ts.map +1 -1
- package/dist/esm/customer/organization/schema.js +26 -20
- package/dist/esm/customer/schema.d.ts +7 -6
- package/dist/esm/customer/schema.d.ts.map +1 -1
- package/dist/esm/customer/schema.js +9 -3
- package/dist/esm/customer/users/resources.d.ts.map +1 -1
- package/dist/esm/customer/users/resources.js +6 -6
- package/dist/esm/customer/users/schema.d.ts +140 -139
- package/dist/esm/customer/users/schema.d.ts.map +1 -1
- package/dist/esm/customer/users/schema.js +58 -46
- package/dist/esm/customer/users/schema.test.js +22 -35
- package/dist/esm/customer/users/utils.d.ts +3 -2
- package/dist/esm/customer/users/utils.d.ts.map +1 -1
- package/dist/esm/customer/users/utils.test.js +1 -1
- package/dist/esm/identity/schema.d.ts +5 -1
- package/dist/esm/identity/schema.d.ts.map +1 -1
- package/dist/esm/identity/schema.js +5 -2
- package/dist/esm/identity/schema.test.js +21 -16
- package/dist/esm/oauth/authorize/schema/grants/authorization-code.d.ts +31 -28
- package/dist/esm/oauth/authorize/schema/grants/authorization-code.d.ts.map +1 -1
- package/dist/esm/oauth/authorize/schema/grants/authorization-code.js +56 -37
- package/dist/esm/oauth/authorize/schema/grants/authorization-code.test.js +44 -45
- package/dist/esm/oauth/authorize/schema/grants/implicit.d.ts +16 -10
- package/dist/esm/oauth/authorize/schema/grants/implicit.d.ts.map +1 -1
- package/dist/esm/oauth/authorize/schema/grants/implicit.js +19 -10
- package/dist/esm/oauth/authorize/schema/schema.d.ts +44 -36
- package/dist/esm/oauth/authorize/schema/schema.d.ts.map +1 -1
- package/dist/esm/oauth/common/schema.d.ts +21 -7
- package/dist/esm/oauth/common/schema.d.ts.map +1 -1
- package/dist/esm/oauth/common/schema.js +20 -7
- package/dist/esm/oauth/common/schema.test.js +25 -26
- package/dist/esm/oauth/token/schema/grants/authorization-code.d.ts +12 -9
- package/dist/esm/oauth/token/schema/grants/authorization-code.d.ts.map +1 -1
- package/dist/esm/oauth/token/schema/grants/authorization-code.js +11 -10
- package/dist/esm/oauth/token/schema/grants/client-credentials.d.ts +20 -15
- package/dist/esm/oauth/token/schema/grants/client-credentials.d.ts.map +1 -1
- package/dist/esm/oauth/token/schema/grants/client-credentials.js +13 -8
- package/dist/esm/oauth/token/schema/grants/refresh-token.d.ts +11 -8
- package/dist/esm/oauth/token/schema/grants/refresh-token.d.ts.map +1 -1
- package/dist/esm/oauth/token/schema/grants/refresh-token.js +6 -6
- package/dist/esm/oauth/token/schema/schema.d.ts +28 -21
- package/dist/esm/oauth/token/schema/schema.d.ts.map +1 -1
- package/dist/esm/oauth/token/schema/schema.test.js +42 -28
- package/dist/esm/workspace/authorization/schema.d.ts +44 -27
- package/dist/esm/workspace/authorization/schema.d.ts.map +1 -1
- package/dist/esm/workspace/authorization/schema.js +16 -11
- package/dist/esm/workspace/branding/schema.d.ts +30 -37
- package/dist/esm/workspace/branding/schema.d.ts.map +1 -1
- package/dist/esm/workspace/branding/schema.js +20 -15
- package/dist/esm/workspace/membership/schema.d.ts +21 -20
- package/dist/esm/workspace/membership/schema.d.ts.map +1 -1
- package/dist/esm/workspace/membership/schema.js +6 -6
- package/dist/esm/workspace/registration/schema.d.ts +26 -27
- package/dist/esm/workspace/registration/schema.d.ts.map +1 -1
- package/dist/esm/workspace/registration/schema.js +13 -11
- package/dist/esm/workspace/settings/schema.d.ts +12 -19
- package/dist/esm/workspace/settings/schema.d.ts.map +1 -1
- package/dist/esm/workspace/settings/schema.js +7 -6
- package/dist/esm/workspace/settings/schema.test.js +18 -19
- package/dist/esm/workspace/tenant/schema.d.ts +55 -57
- package/dist/esm/workspace/tenant/schema.d.ts.map +1 -1
- package/dist/esm/workspace/tenant/schema.js +17 -12
- package/dist/esm/workspace/user/notifications/schema.d.ts +50 -56
- package/dist/esm/workspace/user/notifications/schema.d.ts.map +1 -1
- package/dist/esm/workspace/user/notifications/schema.js +26 -23
- package/dist/esm/workspace/user/preferences/schema.d.ts +18 -25
- package/dist/esm/workspace/user/preferences/schema.d.ts.map +1 -1
- package/dist/esm/workspace/user/preferences/schema.js +16 -11
- package/package.json +3 -3
- package/src/action/schema/base.test.ts.bak +152 -0
- package/src/action/schema/operations/set-password.test.ts.bak +197 -0
- package/src/action/schema/operations/sign-up-verification.test.ts.bak +163 -0
- package/src/action/schema/operations/sign-up.test.ts.bak +203 -0
- package/src/action/schema/operations/user-attribute-verification.test.ts.bak +148 -0
- package/src/action/schema/schema.test.ts.bak +218 -0
- package/src/activity/schema/base.test.ts.bak +291 -0
- package/src/activity/schema/schema.test.ts.bak +392 -0
- package/src/activity/schema/types/authentication.test.ts.bak +337 -0
- package/src/activity/schema/types/authorization.test.ts.bak +379 -0
- package/src/activity/schema/types/note.test.ts.bak +367 -0
- package/src/activity/schema/types/operation.test.ts.bak +379 -0
- package/src/activity/schema/types/unknown.test.ts.bak +304 -0
- package/src/app/authorization/schema.test.ts.bak +412 -0
- package/src/app/oidc/schema.test.ts.bak +117 -0
- package/src/app/registration/schema.test.ts.bak +308 -0
- package/src/app/schema.test.ts.bak +221 -0
- package/src/association/schema.test.ts.bak +148 -0
- package/src/authentication/factors/schema.test.ts.bak +174 -0
- package/src/authentication/settings/schema.test.ts.bak +91 -0
- package/src/authentication/strategies/schema/types/email.test.ts.bak +252 -0
- package/src/authorization/permissions/schema.test.ts.bak +267 -0
- package/src/authorization/roles/schema.test.ts.bak +283 -0
- package/src/common/schema/aggregate.test.ts.bak +89 -0
- package/src/common/schema/collection.test.ts.bak +116 -0
- package/src/common/schema/dates.test.ts.bak +49 -0
- package/src/common/schema/id.test.ts.bak +149 -0
- package/src/common/schema/jwt.test.ts.bak +61 -0
- package/src/common/schema/metadata.test.ts.bak +141 -0
- package/src/common/schema/pagination.test.ts.bak +80 -0
- package/src/common/schema/schema.test.ts.bak +41 -0
- package/src/common/schema/sets.test.ts.bak +108 -0
- package/src/customer/users/schema.test.ts.bak +138 -0
- package/src/identity/schema.test.ts.bak +48 -0
- package/src/oauth/token/schema/schema.test.ts.bak +142 -0
- package/src/workspace/settings/schema.test.ts.bak +88 -0
|
@@ -1,31 +1,42 @@
|
|
|
1
|
-
import { type } from 'arktype';
|
|
2
1
|
import { describe, expect, test } from 'vitest';
|
|
3
2
|
import { RequiredDatePayloadSchema, RequiredDateSchema } from './dates.js';
|
|
4
3
|
describe('Common - Dates', () => {
|
|
5
4
|
describe('Date Schema', () => {
|
|
6
5
|
test('should accept an iso string', async () => {
|
|
7
|
-
const result = RequiredDateSchema(new Date().toISOString());
|
|
8
|
-
|
|
9
|
-
expect(result).
|
|
6
|
+
const result = RequiredDateSchema.safeParse(new Date().toISOString());
|
|
7
|
+
// Parse succeeds for valid data
|
|
8
|
+
expect(result.success).toBe(true);
|
|
9
|
+
if (result.success) {
|
|
10
|
+
expect(result.data).toBeInstanceOf(Date);
|
|
11
|
+
}
|
|
10
12
|
});
|
|
11
13
|
test('should accept a Date object', async () => {
|
|
12
|
-
const result = RequiredDateSchema(new Date());
|
|
13
|
-
|
|
14
|
-
expect(result).
|
|
14
|
+
const result = RequiredDateSchema.safeParse(new Date());
|
|
15
|
+
// Parse succeeds for valid data
|
|
16
|
+
expect(result.success).toBe(true);
|
|
17
|
+
if (result.success) {
|
|
18
|
+
expect(result.data).toBeInstanceOf(Date);
|
|
19
|
+
}
|
|
15
20
|
});
|
|
16
21
|
});
|
|
17
22
|
describe('Payload Schema', () => {
|
|
18
23
|
test('should parse a Date to an ISO string', async () => {
|
|
19
24
|
const iso = new Date().toISOString();
|
|
20
|
-
const result = RequiredDatePayloadSchema(new Date(iso));
|
|
21
|
-
|
|
22
|
-
expect(result).
|
|
25
|
+
const result = RequiredDatePayloadSchema.safeParse(new Date(iso));
|
|
26
|
+
// Parse succeeds for valid data
|
|
27
|
+
expect(result.success).toBe(true);
|
|
28
|
+
if (result.success) {
|
|
29
|
+
expect(result.data).toBe(iso);
|
|
30
|
+
}
|
|
23
31
|
});
|
|
24
32
|
test('should parse an ISO to an ISO string', async () => {
|
|
25
33
|
const iso = new Date().toISOString();
|
|
26
|
-
const result = RequiredDatePayloadSchema(iso);
|
|
27
|
-
|
|
28
|
-
expect(result).
|
|
34
|
+
const result = RequiredDatePayloadSchema.safeParse(iso);
|
|
35
|
+
// Parse succeeds for valid data
|
|
36
|
+
expect(result.success).toBe(true);
|
|
37
|
+
if (result.success) {
|
|
38
|
+
expect(result.data).toBe(iso);
|
|
39
|
+
}
|
|
29
40
|
});
|
|
30
41
|
});
|
|
31
42
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../../../src/common/schema/id.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../../../src/common/schema/id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,gBACmB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const KSUIDSchema = (prefix) =>
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const KSUIDSchema = (prefix) => z.string().regex(new RegExp(`^${prefix}_[A-Za-z0-9]{27}$`));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type } from 'arktype';
|
|
2
1
|
import { describe, expect, test } from 'vitest';
|
|
3
2
|
import { KSUIDSchema } from './id.js';
|
|
4
3
|
describe('Common Schema - ID', () => {
|
|
@@ -6,8 +5,11 @@ describe('Common Schema - ID', () => {
|
|
|
6
5
|
test('should accept valid KSUID with correct prefix', () => {
|
|
7
6
|
const schema = KSUIDSchema('usr');
|
|
8
7
|
const validId = 'usr_123456789012345678901234567';
|
|
9
|
-
const result = schema(validId);
|
|
10
|
-
expect(result).toBe(
|
|
8
|
+
const result = schema.safeParse(validId);
|
|
9
|
+
expect(result.success).toBe(true);
|
|
10
|
+
if (result.success) {
|
|
11
|
+
expect(result.data).toBe(validId);
|
|
12
|
+
}
|
|
11
13
|
});
|
|
12
14
|
test('should accept KSUID with different prefixes', () => {
|
|
13
15
|
const userSchema = KSUIDSchema('usr');
|
|
@@ -16,87 +18,109 @@ describe('Common Schema - ID', () => {
|
|
|
16
18
|
const userId = 'usr_abcdefghijklmnopqrstuvwxy12';
|
|
17
19
|
const appId = 'app_1234567890ABCDEFGHIJKLMNOP1';
|
|
18
20
|
const activityId = 'act_abcDEF123456789012345678901';
|
|
19
|
-
|
|
20
|
-
expect(
|
|
21
|
-
|
|
21
|
+
const userResult = userSchema.safeParse(userId);
|
|
22
|
+
expect(userResult.success).toBe(true);
|
|
23
|
+
if (userResult.success)
|
|
24
|
+
expect(userResult.data).toBe(userId);
|
|
25
|
+
const appResult = appSchema.safeParse(appId);
|
|
26
|
+
expect(appResult.success).toBe(true);
|
|
27
|
+
if (appResult.success)
|
|
28
|
+
expect(appResult.data).toBe(appId);
|
|
29
|
+
const activityResult = activitySchema.safeParse(activityId);
|
|
30
|
+
expect(activityResult.success).toBe(true);
|
|
31
|
+
if (activityResult.success)
|
|
32
|
+
expect(activityResult.data).toBe(activityId);
|
|
22
33
|
});
|
|
23
34
|
test('should accept KSUID with mixed alphanumeric characters', () => {
|
|
24
35
|
const schema = KSUIDSchema('test');
|
|
25
36
|
const mixedId = 'test_1a2B3c4D5e6F7g8H9i0JkLmNoPq';
|
|
26
|
-
const result = schema(mixedId);
|
|
27
|
-
expect(result).toBe(
|
|
37
|
+
const result = schema.safeParse(mixedId);
|
|
38
|
+
expect(result.success).toBe(true);
|
|
39
|
+
if (result.success) {
|
|
40
|
+
expect(result.data).toBe(mixedId);
|
|
41
|
+
}
|
|
28
42
|
});
|
|
29
43
|
test('should reject KSUID with wrong prefix', () => {
|
|
30
44
|
const schema = KSUIDSchema('usr');
|
|
31
45
|
const wrongPrefixId = 'app_123456789012345678901234567';
|
|
32
|
-
const result = schema(wrongPrefixId);
|
|
33
|
-
expect(result).
|
|
46
|
+
const result = schema.safeParse(wrongPrefixId);
|
|
47
|
+
expect(result.success).toBe(false);
|
|
34
48
|
});
|
|
35
49
|
test('should reject KSUID with missing prefix', () => {
|
|
36
50
|
const schema = KSUIDSchema('usr');
|
|
37
51
|
const noPrefixId = '123456789012345678901234567';
|
|
38
|
-
const result = schema(noPrefixId);
|
|
39
|
-
expect(result).
|
|
52
|
+
const result = schema.safeParse(noPrefixId);
|
|
53
|
+
expect(result.success).toBe(false);
|
|
40
54
|
});
|
|
41
55
|
test('should reject KSUID with missing underscore', () => {
|
|
42
56
|
const schema = KSUIDSchema('usr');
|
|
43
57
|
const noUnderscoreId = 'usr123456789012345678901234567';
|
|
44
|
-
const result = schema(noUnderscoreId);
|
|
45
|
-
expect(result).
|
|
58
|
+
const result = schema.safeParse(noUnderscoreId);
|
|
59
|
+
expect(result.success).toBe(false);
|
|
46
60
|
});
|
|
47
61
|
test('should reject KSUID with incorrect suffix length (too short)', () => {
|
|
48
62
|
const schema = KSUIDSchema('usr');
|
|
49
63
|
const shortId = 'usr_12345678901234567890123456';
|
|
50
|
-
const result = schema(shortId);
|
|
51
|
-
expect(result).
|
|
64
|
+
const result = schema.safeParse(shortId);
|
|
65
|
+
expect(result.success).toBe(false);
|
|
52
66
|
});
|
|
53
67
|
test('should reject KSUID with incorrect suffix length (too long)', () => {
|
|
54
68
|
const schema = KSUIDSchema('usr');
|
|
55
69
|
const longId = 'usr_1234567890123456789012345678';
|
|
56
|
-
const result = schema(longId);
|
|
57
|
-
expect(result).
|
|
70
|
+
const result = schema.safeParse(longId);
|
|
71
|
+
expect(result.success).toBe(false);
|
|
58
72
|
});
|
|
59
73
|
test('should reject KSUID with invalid characters in suffix', () => {
|
|
60
74
|
const schema = KSUIDSchema('usr');
|
|
61
75
|
const invalidCharsId = 'usr_123456789012345678901234_*';
|
|
62
|
-
const result = schema(invalidCharsId);
|
|
63
|
-
expect(result).
|
|
76
|
+
const result = schema.safeParse(invalidCharsId);
|
|
77
|
+
expect(result.success).toBe(false);
|
|
64
78
|
});
|
|
65
79
|
test('should reject KSUID with special characters in suffix', () => {
|
|
66
80
|
const schema = KSUIDSchema('usr');
|
|
67
81
|
const specialCharsId = 'usr_12345678901234567890123456@';
|
|
68
|
-
const result = schema(specialCharsId);
|
|
69
|
-
expect(result).
|
|
82
|
+
const result = schema.safeParse(specialCharsId);
|
|
83
|
+
expect(result.success).toBe(false);
|
|
70
84
|
});
|
|
71
85
|
test('should reject KSUID with spaces', () => {
|
|
72
86
|
const schema = KSUIDSchema('usr');
|
|
73
87
|
const spaceId = 'usr_1234567890123456789012345 7';
|
|
74
|
-
const result = schema(spaceId);
|
|
75
|
-
expect(result).
|
|
88
|
+
const result = schema.safeParse(spaceId);
|
|
89
|
+
expect(result.success).toBe(false);
|
|
76
90
|
});
|
|
77
91
|
test('should reject empty string', () => {
|
|
78
92
|
const schema = KSUIDSchema('usr');
|
|
79
|
-
const result = schema('');
|
|
80
|
-
expect(result).
|
|
93
|
+
const result = schema.safeParse('');
|
|
94
|
+
expect(result.success).toBe(false);
|
|
81
95
|
});
|
|
82
96
|
test('should reject non-string values', () => {
|
|
83
97
|
const schema = KSUIDSchema('usr');
|
|
84
|
-
|
|
85
|
-
expect(
|
|
86
|
-
|
|
87
|
-
expect(
|
|
98
|
+
const result1 = schema.safeParse(123);
|
|
99
|
+
expect(result1.success).toBe(false);
|
|
100
|
+
const result2 = schema.safeParse(null);
|
|
101
|
+
expect(result2.success).toBe(false);
|
|
102
|
+
const result3 = schema.safeParse(undefined);
|
|
103
|
+
expect(result3.success).toBe(false);
|
|
104
|
+
const result4 = schema.safeParse({});
|
|
105
|
+
expect(result4.success).toBe(false);
|
|
88
106
|
});
|
|
89
107
|
test('should work with complex prefixes', () => {
|
|
90
108
|
const complexSchema = KSUIDSchema('app_config');
|
|
91
109
|
const validComplexId = 'app_config_123456789012345678901234567';
|
|
92
|
-
const result = complexSchema(validComplexId);
|
|
93
|
-
expect(result).toBe(
|
|
110
|
+
const result = complexSchema.safeParse(validComplexId);
|
|
111
|
+
expect(result.success).toBe(true);
|
|
112
|
+
if (result.success) {
|
|
113
|
+
expect(result.data).toBe(validComplexId);
|
|
114
|
+
}
|
|
94
115
|
});
|
|
95
116
|
test('should work with single character prefix', () => {
|
|
96
117
|
const singleCharSchema = KSUIDSchema('a');
|
|
97
118
|
const validSingleCharId = 'a_123456789012345678901234567';
|
|
98
|
-
const result = singleCharSchema(validSingleCharId);
|
|
99
|
-
expect(result).toBe(
|
|
119
|
+
const result = singleCharSchema.safeParse(validSingleCharId);
|
|
120
|
+
expect(result.success).toBe(true);
|
|
121
|
+
if (result.success) {
|
|
122
|
+
expect(result.data).toBe(validSingleCharId);
|
|
123
|
+
}
|
|
100
124
|
});
|
|
101
125
|
test('should create different schemas for different prefixes', () => {
|
|
102
126
|
const userSchema = KSUIDSchema('usr');
|
|
@@ -104,11 +128,19 @@ describe('Common Schema - ID', () => {
|
|
|
104
128
|
const userId = 'usr_123456789012345678901234567';
|
|
105
129
|
const orgId = 'org_123456789012345678901234567';
|
|
106
130
|
// User schema should accept user ID but reject org ID
|
|
107
|
-
|
|
108
|
-
expect(
|
|
131
|
+
const userResult = userSchema.safeParse(userId);
|
|
132
|
+
expect(userResult.success).toBe(true);
|
|
133
|
+
if (userResult.success)
|
|
134
|
+
expect(userResult.data).toBe(userId);
|
|
135
|
+
const userOrgResult = userSchema.safeParse(orgId);
|
|
136
|
+
expect(userOrgResult.success).toBe(false);
|
|
109
137
|
// Org schema should accept org ID but reject user ID
|
|
110
|
-
|
|
111
|
-
expect(
|
|
138
|
+
const orgResult = orgSchema.safeParse(orgId);
|
|
139
|
+
expect(orgResult.success).toBe(true);
|
|
140
|
+
if (orgResult.success)
|
|
141
|
+
expect(orgResult.data).toBe(orgId);
|
|
142
|
+
const orgUserResult = orgSchema.safeParse(userId);
|
|
143
|
+
expect(orgUserResult.success).toBe(false);
|
|
112
144
|
});
|
|
113
145
|
});
|
|
114
146
|
});
|
|
@@ -1,21 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
/**
|
|
2
3
|
* Ref: https://datatracker.ietf.org/doc/html/rfc7518#section-3.1
|
|
3
4
|
*/
|
|
4
5
|
export declare const Algorithm: {
|
|
5
|
-
DEFAULT:
|
|
6
|
-
HS256:
|
|
7
|
-
HS384:
|
|
8
|
-
HS512:
|
|
9
|
-
RS256:
|
|
10
|
-
RS384:
|
|
11
|
-
RS512:
|
|
12
|
-
ES256:
|
|
13
|
-
ES384:
|
|
14
|
-
ES512:
|
|
15
|
-
PS256:
|
|
16
|
-
PS384:
|
|
17
|
-
PS512:
|
|
6
|
+
readonly DEFAULT: "RS256";
|
|
7
|
+
readonly HS256: "HS256";
|
|
8
|
+
readonly HS384: "HS384";
|
|
9
|
+
readonly HS512: "HS512";
|
|
10
|
+
readonly RS256: "RS256";
|
|
11
|
+
readonly RS384: "RS384";
|
|
12
|
+
readonly RS512: "RS512";
|
|
13
|
+
readonly ES256: "ES256";
|
|
14
|
+
readonly ES384: "ES384";
|
|
15
|
+
readonly ES512: "ES512";
|
|
16
|
+
readonly PS256: "PS256";
|
|
17
|
+
readonly PS384: "PS384";
|
|
18
|
+
readonly PS512: "PS512";
|
|
18
19
|
};
|
|
19
20
|
export type AnyAlgorithm = (typeof Algorithm)[keyof typeof Algorithm];
|
|
20
|
-
export declare const AlgorithmSchema:
|
|
21
|
+
export declare const AlgorithmSchema: z.ZodEnum<{
|
|
22
|
+
RS256: "RS256";
|
|
23
|
+
HS256: "HS256";
|
|
24
|
+
HS384: "HS384";
|
|
25
|
+
HS512: "HS512";
|
|
26
|
+
RS384: "RS384";
|
|
27
|
+
RS512: "RS512";
|
|
28
|
+
ES256: "ES256";
|
|
29
|
+
ES384: "ES384";
|
|
30
|
+
PS256: "PS256";
|
|
31
|
+
PS384: "PS384";
|
|
32
|
+
PS512: "PS512";
|
|
33
|
+
}>;
|
|
21
34
|
//# sourceMappingURL=jwt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../../../src/common/schema/jwt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../../../src/common/schema/jwt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;CAeZ,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAEtE,eAAO,MAAM,eAAe;;;;;;;;;;;;EAYjB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
/**
|
|
3
3
|
* Ref: https://datatracker.ietf.org/doc/html/rfc7518#section-3.1
|
|
4
4
|
*/
|
|
@@ -18,4 +18,16 @@ export const Algorithm = {
|
|
|
18
18
|
PS384: 'PS384',
|
|
19
19
|
PS512: 'PS512',
|
|
20
20
|
};
|
|
21
|
-
export const AlgorithmSchema =
|
|
21
|
+
export const AlgorithmSchema = z.enum([
|
|
22
|
+
Algorithm.HS256,
|
|
23
|
+
Algorithm.HS384,
|
|
24
|
+
Algorithm.HS512,
|
|
25
|
+
Algorithm.RS256,
|
|
26
|
+
Algorithm.RS384,
|
|
27
|
+
Algorithm.RS512,
|
|
28
|
+
Algorithm.ES256,
|
|
29
|
+
Algorithm.ES384,
|
|
30
|
+
Algorithm.PS256,
|
|
31
|
+
Algorithm.PS384,
|
|
32
|
+
Algorithm.PS512,
|
|
33
|
+
]);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type } from 'arktype';
|
|
2
1
|
import { describe, expect, test } from 'vitest';
|
|
3
2
|
import { Algorithm, AlgorithmSchema } from './jwt.js';
|
|
4
3
|
describe('Common Schema - JWT', () => {
|
|
@@ -21,34 +20,41 @@ describe('Common Schema - JWT', () => {
|
|
|
21
20
|
});
|
|
22
21
|
describe('AlgorithmSchema', () => {
|
|
23
22
|
test('should accept valid HMAC algorithms', () => {
|
|
24
|
-
expect(AlgorithmSchema('HS256')).
|
|
25
|
-
expect(AlgorithmSchema('HS384')).
|
|
26
|
-
expect(AlgorithmSchema('HS512')).
|
|
23
|
+
expect(AlgorithmSchema.safeParse('HS256').success).toBe(true);
|
|
24
|
+
expect(AlgorithmSchema.safeParse('HS384').success).toBe(true);
|
|
25
|
+
expect(AlgorithmSchema.safeParse('HS512').success).toBe(true);
|
|
27
26
|
});
|
|
28
27
|
test('should accept valid RSA algorithms', () => {
|
|
29
|
-
expect(AlgorithmSchema('RS256')).
|
|
30
|
-
expect(AlgorithmSchema('RS384')).
|
|
31
|
-
expect(AlgorithmSchema('RS512')).
|
|
28
|
+
expect(AlgorithmSchema.safeParse('RS256').success).toBe(true);
|
|
29
|
+
expect(AlgorithmSchema.safeParse('RS384').success).toBe(true);
|
|
30
|
+
expect(AlgorithmSchema.safeParse('RS512').success).toBe(true);
|
|
32
31
|
});
|
|
33
32
|
test('should accept valid ECDSA algorithms', () => {
|
|
34
|
-
expect(AlgorithmSchema('ES256')).
|
|
35
|
-
expect(AlgorithmSchema('ES384')).
|
|
33
|
+
expect(AlgorithmSchema.safeParse('ES256').success).toBe(true);
|
|
34
|
+
expect(AlgorithmSchema.safeParse('ES384').success).toBe(true);
|
|
36
35
|
});
|
|
37
36
|
test('should accept valid PSS algorithms', () => {
|
|
38
|
-
expect(AlgorithmSchema('PS256')).
|
|
39
|
-
expect(AlgorithmSchema('PS384')).
|
|
40
|
-
expect(AlgorithmSchema('PS512')).
|
|
37
|
+
expect(AlgorithmSchema.safeParse('PS256').success).toBe(true);
|
|
38
|
+
expect(AlgorithmSchema.safeParse('PS384').success).toBe(true);
|
|
39
|
+
expect(AlgorithmSchema.safeParse('PS512').success).toBe(true);
|
|
41
40
|
});
|
|
42
41
|
test('should reject invalid algorithms', () => {
|
|
43
|
-
|
|
44
|
-
expect(
|
|
45
|
-
|
|
46
|
-
expect(
|
|
42
|
+
const result1 = AlgorithmSchema.safeParse('INVALID');
|
|
43
|
+
expect(result1.success).toBe(false);
|
|
44
|
+
const result2 = AlgorithmSchema.safeParse('HS128');
|
|
45
|
+
expect(result2.success).toBe(false);
|
|
46
|
+
const result3 = AlgorithmSchema.safeParse('RS128');
|
|
47
|
+
expect(result3.success).toBe(false);
|
|
48
|
+
const result4 = AlgorithmSchema.safeParse('');
|
|
49
|
+
expect(result4.success).toBe(false);
|
|
47
50
|
});
|
|
48
51
|
test('should reject non-string values', () => {
|
|
49
|
-
|
|
50
|
-
expect(
|
|
51
|
-
|
|
52
|
+
const result1 = AlgorithmSchema.safeParse(123);
|
|
53
|
+
expect(result1.success).toBe(false);
|
|
54
|
+
const result2 = AlgorithmSchema.safeParse(null);
|
|
55
|
+
expect(result2.success).toBe(false);
|
|
56
|
+
const result3 = AlgorithmSchema.safeParse(undefined);
|
|
57
|
+
expect(result3.success).toBe(false);
|
|
52
58
|
});
|
|
53
59
|
});
|
|
54
60
|
});
|
|
@@ -1,55 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
/**
|
|
2
3
|
* Value
|
|
3
4
|
*/
|
|
4
|
-
export declare const MetadataValueSchema:
|
|
5
|
+
export declare const MetadataValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
5
6
|
/**
|
|
6
7
|
* Record
|
|
7
8
|
*/
|
|
8
|
-
declare const MetadataRecordSchema:
|
|
9
|
-
|
|
10
|
-
}, {}>;
|
|
11
|
-
export type MetadataRecord = typeof MetadataRecordSchema.inferOut;
|
|
9
|
+
declare const MetadataRecordSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
10
|
+
export type MetadataRecord = z.output<typeof MetadataRecordSchema>;
|
|
12
11
|
/**
|
|
13
12
|
* Map
|
|
14
13
|
*/
|
|
15
|
-
declare const MetadataMapSchema:
|
|
16
|
-
export type MetadataMap = typeof MetadataMapSchema
|
|
17
|
-
export declare const MetadataPayloadSchema:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
export type
|
|
23
|
-
export declare const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export type
|
|
31
|
-
export declare const UpsertMetadataPayloadSchema: import("arktype/internal/methods/object.ts").ObjectType<(In: {
|
|
32
|
-
[x: string]: string | number | boolean;
|
|
33
|
-
} | Map<string, string | number | boolean> | null | undefined) => import("arktype").Out<{
|
|
34
|
-
[x: string]: string | number | boolean;
|
|
35
|
-
} | null>, {}>;
|
|
36
|
-
export type UpsertMetadataInput = typeof UpsertMetadataPayloadSchema.inferIn;
|
|
37
|
-
export type UpsertMetadataPayload = typeof UpsertMetadataPayloadSchema.inferOut;
|
|
38
|
-
export declare const UpsertMetadataPropertyPayloadSchema: import("arktype/internal/methods/object.ts").ObjectType<{
|
|
39
|
-
metadata?: ((In: {
|
|
40
|
-
[x: string]: string | number | boolean;
|
|
41
|
-
} | Map<string, string | number | boolean> | null | undefined) => import("arktype").Out<{
|
|
42
|
-
[x: string]: string | number | boolean;
|
|
43
|
-
} | null>) | undefined;
|
|
44
|
-
}, {}>;
|
|
45
|
-
export type UpsertMetadataPropertyInput = typeof UpsertMetadataPropertyPayloadSchema.inferIn;
|
|
46
|
-
export type UpsertMetadataPropertyPayload = typeof UpsertMetadataPropertyPayloadSchema.inferOut;
|
|
14
|
+
declare const MetadataMapSchema: z.ZodCustom<Map<string, string | number | boolean>, Map<string, string | number | boolean>>;
|
|
15
|
+
export type MetadataMap = z.output<typeof MetadataMapSchema>;
|
|
16
|
+
export declare const MetadataPayloadSchema: z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodNull, z.ZodCustom<Map<string, string | number | boolean>, Map<string, string | number | boolean>>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>, z.ZodTransform<Record<string, string | number | boolean> | undefined, Record<string, string | number | boolean> | Map<string, string | number | boolean> | null | undefined>>;
|
|
17
|
+
export type MetadataPayload = z.output<typeof MetadataPayloadSchema>;
|
|
18
|
+
export declare const MetadataPayloadPropertySchema: z.ZodObject<{
|
|
19
|
+
metadata: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodNull, z.ZodCustom<Map<string, string | number | boolean>, Map<string, string | number | boolean>>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>, z.ZodTransform<Record<string, string | number | boolean> | undefined, Record<string, string | number | boolean> | Map<string, string | number | boolean> | null | undefined>>>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export type MetadataPayloadProperty = z.output<typeof MetadataPayloadPropertySchema>;
|
|
22
|
+
export declare const UpsertMetadataPayloadSchema: z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodNull, z.ZodCustom<Map<string, string | number | boolean>, Map<string, string | number | boolean>>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>, z.ZodTransform<Record<string, string | number | boolean> | null | undefined, Record<string, string | number | boolean> | Map<string, string | number | boolean> | null | undefined>>;
|
|
23
|
+
export type UpsertMetadataInput = z.input<typeof UpsertMetadataPayloadSchema>;
|
|
24
|
+
export type UpsertMetadataPayload = z.output<typeof UpsertMetadataPayloadSchema>;
|
|
25
|
+
export declare const UpsertMetadataPropertyPayloadSchema: z.ZodObject<{
|
|
26
|
+
metadata: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodNull, z.ZodCustom<Map<string, string | number | boolean>, Map<string, string | number | boolean>>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>, z.ZodTransform<Record<string, string | number | boolean> | null | undefined, Record<string, string | number | boolean> | Map<string, string | number | boolean> | null | undefined>>>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export type UpsertMetadataPropertyInput = z.input<typeof UpsertMetadataPropertyPayloadSchema>;
|
|
29
|
+
export type UpsertMetadataPropertyPayload = z.output<typeof UpsertMetadataPropertyPayloadSchema>;
|
|
47
30
|
export declare function buildMetadataPayload(map: MetadataMap | MetadataRecord): MetadataRecord | undefined;
|
|
48
31
|
export declare function buildUpsertMetadataPayload(map: MetadataMap | MetadataRecord): MetadataRecord | null;
|
|
49
32
|
export declare function buildUpsertMetadataPayloadFromIterable(metadata: Iterable<[string, string | number | boolean]> | null): MetadataRecord | null;
|
|
50
|
-
export declare const MetadataMapPropertySchema:
|
|
51
|
-
metadata:
|
|
52
|
-
},
|
|
53
|
-
export type MetadataMapProperty = typeof MetadataMapPropertySchema
|
|
33
|
+
export declare const MetadataMapPropertySchema: z.ZodObject<{
|
|
34
|
+
metadata: z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodNull, z.ZodCustom<Map<string, string | number | boolean>, Map<string, string | number | boolean>>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>, z.ZodTransform<Map<string, string | number | boolean>, Record<string, string | number | boolean> | Map<string, string | number | boolean> | null | undefined>>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
export type MetadataMapProperty = z.output<typeof MetadataMapPropertySchema>;
|
|
54
37
|
export {};
|
|
55
38
|
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../../../src/common/schema/metadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../../../src/common/schema/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,mBAAmB,+DAI9B,CAAC;AAEH;;GAEG;AACH,QAAA,MAAM,oBAAoB,yFAA4C,CAAC;AACvE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEnE;;GAEG;AACH,QAAA,MAAM,iBAAiB,6FAEtB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAuB7D,eAAO,MAAM,qBAAqB,iaAK9B,CAAC;AACL,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAErE,eAAO,MAAM,6BAA6B;;iBAExC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAC5C,OAAO,6BAA6B,CACrC,CAAC;AAEF,eAAO,MAAM,2BAA2B,waAOpC,CAAC;AACL,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAC9E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAC1C,OAAO,2BAA2B,CACnC,CAAC;AAEF,eAAO,MAAM,mCAAmC;;iBAE9C,CAAC;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,mCAAmC,CAC3C,CAAC;AACF,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAClD,OAAO,mCAAmC,CAC3C,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,WAAW,GAAG,cAAc,GAChC,cAAc,GAAG,SAAS,CAgB5B;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,WAAW,GAAG,cAAc,GAChC,cAAc,GAAG,IAAI,CAMvB;AAED,wBAAgB,sCAAsC,CACpD,QAAQ,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,GAC7D,cAAc,GAAG,IAAI,CAgBvB;AASD,eAAO,MAAM,yBAAyB;;iBAEpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
|
|
@@ -1,50 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
/**
|
|
3
3
|
* Value
|
|
4
4
|
*/
|
|
5
|
-
export const MetadataValueSchema =
|
|
5
|
+
export const MetadataValueSchema = z.union([
|
|
6
|
+
z.string(),
|
|
7
|
+
z.number(),
|
|
8
|
+
z.boolean(),
|
|
9
|
+
]);
|
|
6
10
|
/**
|
|
7
11
|
* Record
|
|
8
12
|
*/
|
|
9
|
-
const MetadataRecordSchema =
|
|
13
|
+
const MetadataRecordSchema = z.record(z.string(), MetadataValueSchema);
|
|
10
14
|
/**
|
|
11
15
|
* Map
|
|
12
16
|
*/
|
|
13
|
-
const MetadataMapSchema =
|
|
17
|
+
const MetadataMapSchema = z.instanceof((Map));
|
|
14
18
|
/**
|
|
15
|
-
* Record To Map
|
|
19
|
+
* Record To Map transformation function
|
|
16
20
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.
|
|
28
|
-
?
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
function transformToMetadataMap(input) {
|
|
22
|
+
if (input == null) {
|
|
23
|
+
return new Map();
|
|
24
|
+
}
|
|
25
|
+
if (input instanceof Map) {
|
|
26
|
+
return new Map(input);
|
|
27
|
+
}
|
|
28
|
+
return new Map(Object.entries(input || {}).map(([key, value]) => [key, value]));
|
|
29
|
+
}
|
|
30
|
+
export const MetadataPayloadSchema = z
|
|
31
|
+
.union([z.undefined(), z.null(), MetadataMapSchema, MetadataRecordSchema])
|
|
32
|
+
.transform((map) => (map ? buildMetadataPayload(map) : undefined))
|
|
33
|
+
.refine((n) => !n || Object.keys(n).length <= 10, {
|
|
34
|
+
message: 'Metadata must have 10 items or less',
|
|
35
|
+
});
|
|
36
|
+
export const MetadataPayloadPropertySchema = z.object({
|
|
37
|
+
metadata: MetadataPayloadSchema.optional(),
|
|
38
|
+
});
|
|
39
|
+
export const UpsertMetadataPayloadSchema = z
|
|
40
|
+
.union([z.undefined(), z.null(), MetadataMapSchema, MetadataRecordSchema])
|
|
41
|
+
.pipe(z.transform((map) => (map ? buildUpsertMetadataPayload(map) || null : map)))
|
|
42
|
+
.refine((n) => !n || Object.keys(n).length <= 10, {
|
|
43
|
+
message: 'Metadata must have 10 items or less',
|
|
35
44
|
});
|
|
36
|
-
export const
|
|
37
|
-
.
|
|
38
|
-
.or(MetadataRecordSchema)
|
|
39
|
-
.pipe((map) => (map ? buildUpsertMetadataPayload(map) || null : null))
|
|
40
|
-
.narrow((n, ctx) => n && Object.keys(n).length > 10
|
|
41
|
-
? ctx.reject({
|
|
42
|
-
expected: '10 items or less',
|
|
43
|
-
actual: `${Object.keys(n).length}`,
|
|
44
|
-
})
|
|
45
|
-
: true);
|
|
46
|
-
export const UpsertMetadataPropertyPayloadSchema = type({
|
|
47
|
-
'metadata?': UpsertMetadataPayloadSchema,
|
|
45
|
+
export const UpsertMetadataPropertyPayloadSchema = z.object({
|
|
46
|
+
metadata: UpsertMetadataPayloadSchema.optional(),
|
|
48
47
|
});
|
|
49
48
|
export function buildMetadataPayload(map) {
|
|
50
49
|
if (!(map instanceof Map)) {
|
|
@@ -81,8 +80,10 @@ export function buildUpsertMetadataPayloadFromIterable(metadata) {
|
|
|
81
80
|
/**
|
|
82
81
|
* Map
|
|
83
82
|
*/
|
|
84
|
-
const ToMetadataMapSchema =
|
|
85
|
-
|
|
83
|
+
const ToMetadataMapSchema = z
|
|
84
|
+
.union([z.undefined(), z.null(), MetadataMapSchema, MetadataRecordSchema])
|
|
85
|
+
.pipe(z.transform(transformToMetadataMap));
|
|
86
|
+
export const MetadataMapPropertySchema = z.object({
|
|
86
87
|
metadata: ToMetadataMapSchema,
|
|
87
88
|
});
|
|
88
89
|
// export const metadataAttributeScope = scope({
|