@go-mondo/identity-sdk 0.0.2-beta.8 → 0.0.2-beta.9
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 +8 -0
- package/dist/cjs/action/schema/base.d.ts.map +1 -1
- package/dist/cjs/action/schema/base.js +3 -1
- package/dist/cjs/action/schema/base.test.d.ts +2 -0
- package/dist/cjs/action/schema/base.test.d.ts.map +1 -0
- package/dist/cjs/action/schema/base.test.js +122 -0
- package/dist/cjs/action/schema/operations/set-password.js +1 -1
- package/dist/cjs/action/schema/operations/set-password.test.d.ts +2 -0
- package/dist/cjs/action/schema/operations/set-password.test.d.ts.map +1 -0
- package/dist/cjs/action/schema/operations/set-password.test.js +167 -0
- package/dist/cjs/action/schema/operations/sign-up-verification.js +1 -1
- package/dist/cjs/action/schema/operations/sign-up-verification.test.d.ts +2 -0
- package/dist/cjs/action/schema/operations/sign-up-verification.test.d.ts.map +1 -0
- package/dist/cjs/action/schema/operations/sign-up-verification.test.js +141 -0
- package/dist/cjs/action/schema/operations/sign-up.test.d.ts +2 -0
- package/dist/cjs/action/schema/operations/sign-up.test.d.ts.map +1 -0
- package/dist/cjs/action/schema/operations/sign-up.test.js +174 -0
- package/dist/cjs/action/schema/operations/user-attribute-verification.js +1 -1
- package/dist/cjs/action/schema/operations/user-attribute-verification.test.d.ts +2 -0
- package/dist/cjs/action/schema/operations/user-attribute-verification.test.d.ts.map +1 -0
- package/dist/cjs/action/schema/operations/user-attribute-verification.test.js +129 -0
- package/dist/cjs/action/schema/schema.test.d.ts +2 -0
- package/dist/cjs/action/schema/schema.test.d.ts.map +1 -0
- package/dist/cjs/action/schema/schema.test.js +191 -0
- package/dist/cjs/action/schema/utils.d.ts +7 -0
- package/dist/cjs/action/schema/utils.d.ts.map +1 -0
- package/dist/cjs/action/schema/utils.js +16 -0
- package/dist/cjs/action/schema/utils.test.d.ts +2 -0
- package/dist/cjs/action/schema/utils.test.d.ts.map +1 -0
- package/dist/cjs/action/schema/utils.test.js +26 -0
- package/dist/cjs/activity/resources.test.d.ts +2 -0
- package/dist/cjs/activity/resources.test.d.ts.map +1 -0
- package/dist/cjs/activity/resources.test.js +224 -0
- package/dist/cjs/activity/schema/base.d.ts +1 -1
- package/dist/cjs/activity/schema/base.d.ts.map +1 -1
- package/dist/cjs/activity/schema/base.js +5 -4
- package/dist/cjs/activity/schema/base.test.d.ts +2 -0
- package/dist/cjs/activity/schema/base.test.d.ts.map +1 -0
- package/dist/cjs/activity/schema/base.test.js +239 -0
- package/dist/cjs/activity/schema/schema.d.ts +5 -5
- package/dist/cjs/activity/schema/schema.test.d.ts +2 -0
- package/dist/cjs/activity/schema/schema.test.d.ts.map +1 -0
- package/dist/cjs/activity/schema/schema.test.js +344 -0
- package/dist/cjs/activity/schema/types/authentication.d.ts +1 -1
- package/dist/cjs/activity/schema/types/authentication.js +1 -1
- package/dist/cjs/activity/schema/types/authentication.test.d.ts +2 -0
- package/dist/cjs/activity/schema/types/authentication.test.d.ts.map +1 -0
- package/dist/cjs/activity/schema/types/authentication.test.js +303 -0
- package/dist/cjs/activity/schema/types/authorization.d.ts +1 -1
- package/dist/cjs/activity/schema/types/authorization.js +1 -1
- package/dist/cjs/activity/schema/types/authorization.test.d.ts +2 -0
- package/dist/cjs/activity/schema/types/authorization.test.d.ts.map +1 -0
- package/dist/cjs/activity/schema/types/authorization.test.js +341 -0
- package/dist/cjs/activity/schema/types/note.d.ts +1 -1
- package/dist/cjs/activity/schema/types/note.test.d.ts +2 -0
- package/dist/cjs/activity/schema/types/note.test.d.ts.map +1 -0
- package/dist/cjs/activity/schema/types/note.test.js +319 -0
- package/dist/cjs/activity/schema/types/operation.d.ts +1 -1
- package/dist/cjs/activity/schema/types/operation.test.d.ts +2 -0
- package/dist/cjs/activity/schema/types/operation.test.d.ts.map +1 -0
- package/dist/cjs/activity/schema/types/operation.test.js +344 -0
- package/dist/cjs/activity/schema/types/unknown.d.ts +1 -1
- package/dist/cjs/activity/schema/types/unknown.test.d.ts +2 -0
- package/dist/cjs/activity/schema/types/unknown.test.d.ts.map +1 -0
- package/dist/cjs/activity/schema/types/unknown.test.js +275 -0
- package/dist/cjs/activity/schema/utils.test.d.ts +2 -0
- package/dist/cjs/activity/schema/utils.test.d.ts.map +1 -0
- package/dist/cjs/activity/schema/utils.test.js +26 -0
- package/dist/cjs/app/authorization/schema.d.ts +6 -6
- package/dist/cjs/app/authorization/schema.d.ts.map +1 -1
- package/dist/cjs/app/authorization/schema.js +39 -26
- package/dist/cjs/app/authorization/schema.test.d.ts +2 -0
- package/dist/cjs/app/authorization/schema.test.d.ts.map +1 -0
- package/dist/cjs/app/authorization/schema.test.js +353 -0
- package/dist/cjs/app/oauth/schema.d.ts +1 -1
- package/dist/cjs/app/oauth/schema.d.ts.map +1 -1
- package/dist/cjs/app/oauth/schema.js +2 -1
- package/dist/cjs/app/oauth/schema.test.d.ts +2 -0
- package/dist/cjs/app/oauth/schema.test.d.ts.map +1 -0
- package/dist/cjs/app/oauth/schema.test.js +173 -0
- package/dist/cjs/app/oidc/schema.d.ts +2 -2
- package/dist/cjs/app/oidc/schema.d.ts.map +1 -1
- package/dist/cjs/app/oidc/schema.js +1 -1
- package/dist/cjs/app/oidc/schema.test.d.ts +2 -0
- package/dist/cjs/app/oidc/schema.test.d.ts.map +1 -0
- package/dist/cjs/app/oidc/schema.test.js +95 -0
- package/dist/cjs/app/registration/resources.test.d.ts +2 -0
- package/dist/cjs/app/registration/resources.test.d.ts.map +1 -0
- package/dist/cjs/app/registration/resources.test.js +295 -0
- package/dist/cjs/app/registration/schema.d.ts +1 -1
- package/dist/cjs/app/registration/schema.test.d.ts +2 -0
- package/dist/cjs/app/registration/schema.test.d.ts.map +1 -0
- package/dist/cjs/app/registration/schema.test.js +262 -0
- package/dist/cjs/app/resources.test.d.ts +2 -0
- package/dist/cjs/app/resources.test.d.ts.map +1 -0
- package/dist/cjs/app/resources.test.js +288 -0
- package/dist/cjs/app/saml/schema.d.ts +3 -3
- package/dist/cjs/app/saml/schema.d.ts.map +1 -1
- package/dist/cjs/app/saml/schema.js +2 -2
- package/dist/cjs/app/schema.d.ts +5 -1
- package/dist/cjs/app/schema.d.ts.map +1 -1
- package/dist/cjs/app/schema.js +7 -2
- package/dist/cjs/app/schema.test.d.ts +2 -0
- package/dist/cjs/app/schema.test.d.ts.map +1 -0
- package/dist/cjs/app/schema.test.js +184 -0
- package/dist/cjs/app/utils.test.d.ts +2 -0
- package/dist/cjs/app/utils.test.d.ts.map +1 -0
- package/dist/cjs/app/utils.test.js +42 -0
- package/dist/cjs/association/schema.d.ts +23 -23
- package/dist/cjs/association/schema.js +3 -3
- package/dist/cjs/association/schema.test.d.ts +2 -0
- package/dist/cjs/association/schema.test.d.ts.map +1 -0
- package/dist/cjs/association/schema.test.js +121 -0
- package/dist/cjs/authentication/factors/schema.test.js +19 -18
- package/dist/cjs/authentication/providers/schema.js +1 -1
- package/dist/cjs/authentication/sessions/schema.d.ts +5 -5
- package/dist/cjs/authentication/sessions/schema.d.ts.map +1 -1
- package/dist/cjs/authentication/sessions/schema.js +4 -2
- package/dist/cjs/authentication/settings/schema.d.ts +1 -1
- package/dist/cjs/authentication/settings/schema.js +1 -1
- package/dist/cjs/authentication/settings/schema.test.d.ts +2 -0
- package/dist/cjs/authentication/settings/schema.test.d.ts.map +1 -0
- package/dist/cjs/authentication/settings/schema.test.js +73 -0
- package/dist/cjs/authentication/strategies/schema/base.d.ts +1 -1
- package/dist/cjs/authentication/strategies/schema/base.d.ts.map +1 -1
- package/dist/cjs/authentication/strategies/schema/base.js +3 -1
- package/dist/cjs/authentication/strategies/schema/schema.d.ts +3 -3
- package/dist/cjs/authentication/strategies/schema/types/email.d.ts +1 -1
- package/dist/cjs/authentication/strategies/schema/types/email.test.d.ts +2 -0
- package/dist/cjs/authentication/strategies/schema/types/email.test.d.ts.map +1 -0
- package/dist/cjs/authentication/strategies/schema/types/email.test.js +205 -0
- package/dist/cjs/authentication/strategies/schema/types/password.d.ts +1 -1
- package/dist/cjs/authentication/strategies/schema/types/totp.d.ts +1 -1
- package/dist/cjs/authentication/utils.d.ts +13 -0
- package/dist/cjs/authentication/utils.d.ts.map +1 -0
- package/dist/cjs/authentication/utils.js +25 -0
- package/dist/cjs/authentication/utils.test.d.ts +2 -0
- package/dist/cjs/authentication/utils.test.d.ts.map +1 -0
- package/dist/cjs/authentication/utils.test.js +142 -0
- package/dist/cjs/authorization/index.d.ts +1 -1
- package/dist/cjs/authorization/index.d.ts.map +1 -1
- package/dist/cjs/authorization/index.js +1 -1
- package/dist/cjs/authorization/permissions/schema.d.ts +1 -2
- package/dist/cjs/authorization/permissions/schema.d.ts.map +1 -1
- package/dist/cjs/authorization/permissions/schema.js +9 -10
- package/dist/cjs/authorization/permissions/schema.test.d.ts +2 -0
- package/dist/cjs/authorization/permissions/schema.test.d.ts.map +1 -0
- package/dist/cjs/authorization/permissions/schema.test.js +217 -0
- package/dist/cjs/authorization/roles/schema.d.ts +3 -3
- package/dist/cjs/authorization/roles/schema.d.ts.map +1 -1
- package/dist/cjs/authorization/roles/schema.js +10 -10
- package/dist/cjs/authorization/roles/schema.test.d.ts +2 -0
- package/dist/cjs/authorization/roles/schema.test.d.ts.map +1 -0
- package/dist/cjs/authorization/roles/schema.test.js +236 -0
- package/dist/cjs/authorization/schema.d.ts +17 -0
- package/dist/cjs/authorization/schema.d.ts.map +1 -0
- package/dist/cjs/authorization/{utils.js → schema.js} +7 -1
- package/dist/cjs/authorization/schema.test.d.ts +2 -0
- package/dist/cjs/authorization/schema.test.d.ts.map +1 -0
- package/dist/cjs/authorization/schema.test.js +42 -0
- package/dist/cjs/common/errors/http.test.d.ts +2 -0
- package/dist/cjs/common/errors/http.test.d.ts.map +1 -0
- package/dist/cjs/common/errors/http.test.js +71 -0
- package/dist/cjs/common/errors/validation.test.d.ts +2 -0
- package/dist/cjs/common/errors/validation.test.d.ts.map +1 -0
- package/dist/cjs/common/errors/validation.test.js +92 -0
- package/dist/cjs/common/resources/init.d.ts +2 -2
- package/dist/cjs/common/resources/init.d.ts.map +1 -1
- package/dist/cjs/common/resources/init.js +1 -1
- package/dist/cjs/common/resources/init.test.d.ts +2 -0
- package/dist/cjs/common/resources/init.test.d.ts.map +1 -0
- package/dist/cjs/common/resources/init.test.js +233 -0
- package/dist/cjs/common/resources/operations.test.d.ts +2 -0
- package/dist/cjs/common/resources/operations.test.d.ts.map +1 -0
- package/dist/cjs/common/resources/operations.test.js +356 -0
- package/dist/cjs/common/resources/utils.d.ts +1 -1
- package/dist/cjs/common/resources/utils.d.ts.map +1 -1
- package/dist/cjs/common/resources/utils.test.d.ts +2 -0
- package/dist/cjs/common/resources/utils.test.d.ts.map +1 -0
- package/dist/cjs/common/resources/utils.test.js +163 -0
- package/dist/cjs/common/schema/aggregate.test.d.ts +2 -0
- package/dist/cjs/common/schema/aggregate.test.d.ts.map +1 -0
- package/dist/cjs/common/schema/aggregate.test.js +75 -0
- package/dist/cjs/common/schema/collection.d.ts +2 -2
- package/dist/cjs/common/schema/collection.test.d.ts +2 -0
- package/dist/cjs/common/schema/collection.test.d.ts.map +1 -0
- package/dist/cjs/common/schema/collection.test.js +98 -0
- package/dist/cjs/common/schema/id.d.ts +2 -0
- package/dist/cjs/common/schema/id.d.ts.map +1 -0
- package/dist/cjs/common/schema/id.js +6 -0
- package/dist/cjs/common/schema/id.test.d.ts +2 -0
- package/dist/cjs/common/schema/id.test.d.ts.map +1 -0
- package/dist/cjs/common/schema/id.test.js +116 -0
- package/dist/cjs/common/schema/jwt.test.d.ts +2 -0
- package/dist/cjs/common/schema/jwt.test.d.ts.map +1 -0
- package/dist/cjs/common/schema/jwt.test.js +56 -0
- package/dist/cjs/common/schema/metadata.d.ts +9 -3
- package/dist/cjs/common/schema/metadata.d.ts.map +1 -1
- package/dist/cjs/common/schema/metadata.js +27 -8
- package/dist/cjs/common/schema/metadata.test.js +49 -0
- package/dist/cjs/common/schema/pagination.d.ts +2 -2
- package/dist/cjs/common/schema/pagination.js +2 -2
- package/dist/cjs/common/schema/pagination.test.d.ts +2 -0
- package/dist/cjs/common/schema/pagination.test.d.ts.map +1 -0
- package/dist/cjs/common/schema/pagination.test.js +68 -0
- package/dist/cjs/common/schema/sets.test.d.ts +2 -0
- package/dist/cjs/common/schema/sets.test.d.ts.map +1 -0
- package/dist/cjs/common/schema/sets.test.js +84 -0
- package/dist/cjs/common/schema/url.test.d.ts +2 -0
- package/dist/cjs/common/schema/url.test.d.ts.map +1 -0
- package/dist/cjs/common/schema/url.test.js +74 -0
- package/dist/cjs/customer/index.d.ts +2 -1
- package/dist/cjs/customer/index.d.ts.map +1 -1
- package/dist/cjs/customer/index.js +2 -1
- package/dist/cjs/customer/{schema/organization.d.ts → organization/schema.d.ts} +4 -3
- package/dist/cjs/customer/organization/schema.d.ts.map +1 -0
- package/dist/cjs/customer/{schema/organization.js → organization/schema.js} +9 -7
- package/dist/cjs/customer/schema.d.ts +17 -0
- package/dist/cjs/customer/schema.d.ts.map +1 -0
- package/dist/cjs/customer/{schema/utils.js → schema.js} +7 -1
- package/dist/cjs/customer/schema.test.d.ts +2 -0
- package/dist/cjs/customer/schema.test.d.ts.map +1 -0
- package/dist/cjs/customer/schema.test.js +42 -0
- package/dist/cjs/customer/users/schema.d.ts +4 -3
- package/dist/cjs/customer/users/schema.d.ts.map +1 -1
- package/dist/cjs/customer/users/schema.js +29 -26
- package/dist/cjs/customer/users/schema.test.js +13 -12
- package/dist/cjs/customer/users/utils.test.d.ts +2 -0
- package/dist/cjs/customer/users/utils.test.d.ts.map +1 -0
- package/dist/cjs/customer/users/utils.test.js +145 -0
- package/dist/cjs/identity/schema.test.d.ts +2 -0
- package/dist/cjs/identity/schema.test.d.ts.map +1 -0
- package/dist/cjs/identity/schema.test.js +40 -0
- package/dist/cjs/oauth/authorize/schema/grants/authorization-code.d.ts.map +1 -1
- package/dist/cjs/oauth/authorize/schema/grants/authorization-code.js +22 -3
- package/dist/cjs/oauth/authorize/schema/grants/authorization-code.test.d.ts +2 -0
- package/dist/cjs/oauth/authorize/schema/grants/authorization-code.test.d.ts.map +1 -0
- package/dist/cjs/oauth/authorize/schema/grants/authorization-code.test.js +334 -0
- package/dist/cjs/oauth/common/schema.test.d.ts +2 -0
- package/dist/cjs/oauth/common/schema.test.d.ts.map +1 -0
- package/dist/cjs/oauth/common/schema.test.js +290 -0
- package/dist/cjs/oauth/token/schema/schema.test.d.ts +2 -0
- package/dist/cjs/oauth/token/schema/schema.test.d.ts.map +1 -0
- package/dist/cjs/oauth/token/schema/schema.test.js +122 -0
- package/dist/cjs/workspace/settings/schema.test.d.ts +2 -0
- package/dist/cjs/workspace/settings/schema.test.d.ts.map +1 -0
- package/dist/cjs/workspace/settings/schema.test.js +73 -0
- package/dist/cjs/workspace/tenant/schema.d.ts +1 -0
- package/dist/cjs/workspace/tenant/schema.d.ts.map +1 -1
- package/dist/cjs/workspace/tenant/schema.js +8 -7
- package/dist/cjs/workspace/user/notifications/schema.d.ts.map +1 -1
- package/dist/cjs/workspace/user/notifications/schema.js +3 -2
- package/dist/cjs/workspace/user/preferences/schema.js +2 -2
- package/dist/cjs/workspace/utils.d.ts +0 -3
- package/dist/cjs/workspace/utils.d.ts.map +1 -1
- package/dist/cjs/workspace/utils.js +0 -3
- package/dist/cjs/workspace/utils.test.d.ts +2 -0
- package/dist/cjs/workspace/utils.test.d.ts.map +1 -0
- package/dist/cjs/workspace/utils.test.js +63 -0
- package/dist/esm/action/schema/base.d.ts.map +1 -1
- package/dist/esm/action/schema/base.js +3 -1
- package/dist/esm/action/schema/base.test.d.ts +2 -0
- package/dist/esm/action/schema/base.test.d.ts.map +1 -0
- package/dist/esm/action/schema/base.test.js +120 -0
- package/dist/esm/action/schema/operations/set-password.js +1 -1
- package/dist/esm/action/schema/operations/set-password.test.d.ts +2 -0
- package/dist/esm/action/schema/operations/set-password.test.d.ts.map +1 -0
- package/dist/esm/action/schema/operations/set-password.test.js +165 -0
- package/dist/esm/action/schema/operations/sign-up-verification.js +1 -1
- package/dist/esm/action/schema/operations/sign-up-verification.test.d.ts +2 -0
- package/dist/esm/action/schema/operations/sign-up-verification.test.d.ts.map +1 -0
- package/dist/esm/action/schema/operations/sign-up-verification.test.js +139 -0
- package/dist/esm/action/schema/operations/sign-up.test.d.ts +2 -0
- package/dist/esm/action/schema/operations/sign-up.test.d.ts.map +1 -0
- package/dist/esm/action/schema/operations/sign-up.test.js +172 -0
- package/dist/esm/action/schema/operations/user-attribute-verification.js +1 -1
- package/dist/esm/action/schema/operations/user-attribute-verification.test.d.ts +2 -0
- package/dist/esm/action/schema/operations/user-attribute-verification.test.d.ts.map +1 -0
- package/dist/esm/action/schema/operations/user-attribute-verification.test.js +127 -0
- package/dist/esm/action/schema/schema.test.d.ts +2 -0
- package/dist/esm/action/schema/schema.test.d.ts.map +1 -0
- package/dist/esm/action/schema/schema.test.js +189 -0
- package/dist/esm/action/schema/utils.d.ts +7 -0
- package/dist/esm/action/schema/utils.d.ts.map +1 -0
- package/dist/esm/action/schema/utils.js +9 -0
- package/dist/esm/action/schema/utils.test.d.ts +2 -0
- package/dist/esm/action/schema/utils.test.d.ts.map +1 -0
- package/dist/esm/action/schema/utils.test.js +24 -0
- package/dist/esm/activity/resources.test.d.ts +2 -0
- package/dist/esm/activity/resources.test.d.ts.map +1 -0
- package/dist/esm/activity/resources.test.js +189 -0
- package/dist/esm/activity/schema/base.d.ts +1 -1
- package/dist/esm/activity/schema/base.d.ts.map +1 -1
- package/dist/esm/activity/schema/base.js +7 -6
- package/dist/esm/activity/schema/base.test.d.ts +2 -0
- package/dist/esm/activity/schema/base.test.d.ts.map +1 -0
- package/dist/esm/activity/schema/base.test.js +237 -0
- package/dist/esm/activity/schema/schema.d.ts +5 -5
- package/dist/esm/activity/schema/schema.test.d.ts +2 -0
- package/dist/esm/activity/schema/schema.test.d.ts.map +1 -0
- package/dist/esm/activity/schema/schema.test.js +342 -0
- package/dist/esm/activity/schema/types/authentication.d.ts +1 -1
- package/dist/esm/activity/schema/types/authentication.js +1 -1
- package/dist/esm/activity/schema/types/authentication.test.d.ts +2 -0
- package/dist/esm/activity/schema/types/authentication.test.d.ts.map +1 -0
- package/dist/esm/activity/schema/types/authentication.test.js +301 -0
- package/dist/esm/activity/schema/types/authorization.d.ts +1 -1
- package/dist/esm/activity/schema/types/authorization.js +1 -1
- package/dist/esm/activity/schema/types/authorization.test.d.ts +2 -0
- package/dist/esm/activity/schema/types/authorization.test.d.ts.map +1 -0
- package/dist/esm/activity/schema/types/authorization.test.js +339 -0
- package/dist/esm/activity/schema/types/note.d.ts +1 -1
- package/dist/esm/activity/schema/types/note.test.d.ts +2 -0
- package/dist/esm/activity/schema/types/note.test.d.ts.map +1 -0
- package/dist/esm/activity/schema/types/note.test.js +317 -0
- package/dist/esm/activity/schema/types/operation.d.ts +1 -1
- package/dist/esm/activity/schema/types/operation.test.d.ts +2 -0
- package/dist/esm/activity/schema/types/operation.test.d.ts.map +1 -0
- package/dist/esm/activity/schema/types/operation.test.js +342 -0
- package/dist/esm/activity/schema/types/unknown.d.ts +1 -1
- package/dist/esm/activity/schema/types/unknown.test.d.ts +2 -0
- package/dist/esm/activity/schema/types/unknown.test.d.ts.map +1 -0
- package/dist/esm/activity/schema/types/unknown.test.js +273 -0
- package/dist/esm/activity/schema/utils.test.d.ts +2 -0
- package/dist/esm/activity/schema/utils.test.d.ts.map +1 -0
- package/dist/esm/activity/schema/utils.test.js +24 -0
- package/dist/esm/app/authorization/schema.d.ts +6 -6
- package/dist/esm/app/authorization/schema.d.ts.map +1 -1
- package/dist/esm/app/authorization/schema.js +40 -27
- package/dist/esm/app/authorization/schema.test.d.ts +2 -0
- package/dist/esm/app/authorization/schema.test.d.ts.map +1 -0
- package/dist/esm/app/authorization/schema.test.js +351 -0
- package/dist/esm/app/oauth/schema.d.ts +1 -1
- package/dist/esm/app/oauth/schema.d.ts.map +1 -1
- package/dist/esm/app/oauth/schema.js +3 -2
- package/dist/esm/app/oauth/schema.test.d.ts +2 -0
- package/dist/esm/app/oauth/schema.test.d.ts.map +1 -0
- package/dist/esm/app/oauth/schema.test.js +171 -0
- package/dist/esm/app/oidc/schema.d.ts +2 -2
- package/dist/esm/app/oidc/schema.d.ts.map +1 -1
- package/dist/esm/app/oidc/schema.js +2 -2
- package/dist/esm/app/oidc/schema.test.d.ts +2 -0
- package/dist/esm/app/oidc/schema.test.d.ts.map +1 -0
- package/dist/esm/app/oidc/schema.test.js +93 -0
- package/dist/esm/app/registration/resources.test.d.ts +2 -0
- package/dist/esm/app/registration/resources.test.d.ts.map +1 -0
- package/dist/esm/app/registration/resources.test.js +260 -0
- package/dist/esm/app/registration/schema.d.ts +1 -1
- package/dist/esm/app/registration/schema.test.d.ts +2 -0
- package/dist/esm/app/registration/schema.test.d.ts.map +1 -0
- package/dist/esm/app/registration/schema.test.js +260 -0
- package/dist/esm/app/resources.test.d.ts +2 -0
- package/dist/esm/app/resources.test.d.ts.map +1 -0
- package/dist/esm/app/resources.test.js +253 -0
- package/dist/esm/app/saml/schema.d.ts +3 -3
- package/dist/esm/app/saml/schema.d.ts.map +1 -1
- package/dist/esm/app/saml/schema.js +3 -3
- package/dist/esm/app/schema.d.ts +5 -1
- package/dist/esm/app/schema.d.ts.map +1 -1
- package/dist/esm/app/schema.js +7 -2
- package/dist/esm/app/schema.test.d.ts +2 -0
- package/dist/esm/app/schema.test.d.ts.map +1 -0
- package/dist/esm/app/schema.test.js +182 -0
- package/dist/esm/app/utils.test.d.ts +2 -0
- package/dist/esm/app/utils.test.d.ts.map +1 -0
- package/dist/esm/app/utils.test.js +40 -0
- package/dist/esm/association/schema.d.ts +23 -23
- package/dist/esm/association/schema.js +1 -1
- package/dist/esm/association/schema.test.d.ts +2 -0
- package/dist/esm/association/schema.test.d.ts.map +1 -0
- package/dist/esm/association/schema.test.js +119 -0
- package/dist/esm/authentication/factors/schema.test.js +19 -18
- package/dist/esm/authentication/providers/schema.js +1 -1
- package/dist/esm/authentication/sessions/schema.d.ts +5 -5
- package/dist/esm/authentication/sessions/schema.d.ts.map +1 -1
- package/dist/esm/authentication/sessions/schema.js +4 -2
- package/dist/esm/authentication/settings/schema.d.ts +1 -1
- package/dist/esm/authentication/settings/schema.js +2 -2
- package/dist/esm/authentication/settings/schema.test.d.ts +2 -0
- package/dist/esm/authentication/settings/schema.test.d.ts.map +1 -0
- package/dist/esm/authentication/settings/schema.test.js +71 -0
- package/dist/esm/authentication/strategies/schema/base.d.ts +1 -1
- package/dist/esm/authentication/strategies/schema/base.d.ts.map +1 -1
- package/dist/esm/authentication/strategies/schema/base.js +3 -1
- package/dist/esm/authentication/strategies/schema/schema.d.ts +3 -3
- package/dist/esm/authentication/strategies/schema/types/email.d.ts +1 -1
- package/dist/esm/authentication/strategies/schema/types/email.test.d.ts +2 -0
- package/dist/esm/authentication/strategies/schema/types/email.test.d.ts.map +1 -0
- package/dist/esm/authentication/strategies/schema/types/email.test.js +203 -0
- package/dist/esm/authentication/strategies/schema/types/password.d.ts +1 -1
- package/dist/esm/authentication/strategies/schema/types/totp.d.ts +1 -1
- package/dist/esm/authentication/utils.d.ts +13 -0
- package/dist/esm/authentication/utils.d.ts.map +1 -0
- package/dist/esm/authentication/utils.js +17 -0
- package/dist/esm/authentication/utils.test.d.ts +2 -0
- package/dist/esm/authentication/utils.test.d.ts.map +1 -0
- package/dist/esm/authentication/utils.test.js +140 -0
- package/dist/esm/authorization/index.d.ts +1 -1
- package/dist/esm/authorization/index.d.ts.map +1 -1
- package/dist/esm/authorization/index.js +1 -1
- package/dist/esm/authorization/permissions/schema.d.ts +1 -2
- package/dist/esm/authorization/permissions/schema.d.ts.map +1 -1
- package/dist/esm/authorization/permissions/schema.js +7 -8
- package/dist/esm/authorization/permissions/schema.test.d.ts +2 -0
- package/dist/esm/authorization/permissions/schema.test.d.ts.map +1 -0
- package/dist/esm/authorization/permissions/schema.test.js +215 -0
- package/dist/esm/authorization/roles/schema.d.ts +3 -3
- package/dist/esm/authorization/roles/schema.d.ts.map +1 -1
- package/dist/esm/authorization/roles/schema.js +9 -9
- package/dist/esm/authorization/roles/schema.test.d.ts +2 -0
- package/dist/esm/authorization/roles/schema.test.d.ts.map +1 -0
- package/dist/esm/authorization/roles/schema.test.js +234 -0
- package/dist/esm/authorization/schema.d.ts +17 -0
- package/dist/esm/authorization/schema.d.ts.map +1 -0
- package/dist/esm/authorization/schema.js +21 -0
- package/dist/esm/authorization/schema.test.d.ts +2 -0
- package/dist/esm/authorization/schema.test.d.ts.map +1 -0
- package/dist/esm/authorization/schema.test.js +40 -0
- package/dist/esm/common/errors/http.test.d.ts +2 -0
- package/dist/esm/common/errors/http.test.d.ts.map +1 -0
- package/dist/esm/common/errors/http.test.js +69 -0
- package/dist/esm/common/errors/validation.test.d.ts +2 -0
- package/dist/esm/common/errors/validation.test.d.ts.map +1 -0
- package/dist/esm/common/errors/validation.test.js +90 -0
- package/dist/esm/common/resources/init.d.ts +2 -2
- package/dist/esm/common/resources/init.d.ts.map +1 -1
- package/dist/esm/common/resources/init.js +1 -1
- package/dist/esm/common/resources/init.test.d.ts +2 -0
- package/dist/esm/common/resources/init.test.d.ts.map +1 -0
- package/dist/esm/common/resources/init.test.js +231 -0
- package/dist/esm/common/resources/operations.test.d.ts +2 -0
- package/dist/esm/common/resources/operations.test.d.ts.map +1 -0
- package/dist/esm/common/resources/operations.test.js +354 -0
- package/dist/esm/common/resources/utils.d.ts +1 -1
- package/dist/esm/common/resources/utils.d.ts.map +1 -1
- package/dist/esm/common/resources/utils.test.d.ts +2 -0
- package/dist/esm/common/resources/utils.test.d.ts.map +1 -0
- package/dist/esm/common/resources/utils.test.js +161 -0
- package/dist/esm/common/schema/aggregate.test.d.ts +2 -0
- package/dist/esm/common/schema/aggregate.test.d.ts.map +1 -0
- package/dist/esm/common/schema/aggregate.test.js +73 -0
- package/dist/esm/common/schema/collection.d.ts +2 -2
- package/dist/esm/common/schema/collection.test.d.ts +2 -0
- package/dist/esm/common/schema/collection.test.d.ts.map +1 -0
- package/dist/esm/common/schema/collection.test.js +96 -0
- package/dist/esm/common/schema/id.d.ts +2 -0
- package/dist/esm/common/schema/id.d.ts.map +1 -0
- package/dist/esm/common/schema/id.js +2 -0
- package/dist/esm/common/schema/id.test.d.ts +2 -0
- package/dist/esm/common/schema/id.test.d.ts.map +1 -0
- package/dist/esm/common/schema/id.test.js +114 -0
- package/dist/esm/common/schema/jwt.test.d.ts +2 -0
- package/dist/esm/common/schema/jwt.test.d.ts.map +1 -0
- package/dist/esm/common/schema/jwt.test.js +54 -0
- package/dist/esm/common/schema/metadata.d.ts +9 -3
- package/dist/esm/common/schema/metadata.d.ts.map +1 -1
- package/dist/esm/common/schema/metadata.js +24 -6
- package/dist/esm/common/schema/metadata.test.js +50 -1
- package/dist/esm/common/schema/pagination.d.ts +2 -2
- package/dist/esm/common/schema/pagination.js +2 -2
- package/dist/esm/common/schema/pagination.test.d.ts +2 -0
- package/dist/esm/common/schema/pagination.test.d.ts.map +1 -0
- package/dist/esm/common/schema/pagination.test.js +66 -0
- package/dist/esm/common/schema/sets.test.d.ts +2 -0
- package/dist/esm/common/schema/sets.test.d.ts.map +1 -0
- package/dist/esm/common/schema/sets.test.js +82 -0
- package/dist/esm/common/schema/url.test.d.ts +2 -0
- package/dist/esm/common/schema/url.test.d.ts.map +1 -0
- package/dist/esm/common/schema/url.test.js +72 -0
- package/dist/esm/customer/index.d.ts +2 -1
- package/dist/esm/customer/index.d.ts.map +1 -1
- package/dist/esm/customer/index.js +2 -1
- package/dist/esm/customer/{schema/organization.d.ts → organization/schema.d.ts} +4 -3
- package/dist/esm/customer/organization/schema.d.ts.map +1 -0
- package/dist/esm/customer/{schema/organization.js → organization/schema.js} +7 -5
- package/dist/esm/customer/schema.d.ts +17 -0
- package/dist/esm/customer/schema.d.ts.map +1 -0
- package/dist/esm/customer/schema.js +21 -0
- package/dist/esm/customer/schema.test.d.ts +2 -0
- package/dist/esm/customer/schema.test.d.ts.map +1 -0
- package/dist/esm/customer/schema.test.js +40 -0
- package/dist/esm/customer/users/schema.d.ts +4 -3
- package/dist/esm/customer/users/schema.d.ts.map +1 -1
- package/dist/esm/customer/users/schema.js +9 -6
- package/dist/esm/customer/users/schema.test.js +6 -5
- package/dist/esm/customer/users/utils.test.d.ts +2 -0
- package/dist/esm/customer/users/utils.test.d.ts.map +1 -0
- package/dist/esm/customer/users/utils.test.js +143 -0
- package/dist/esm/identity/schema.test.d.ts +2 -0
- package/dist/esm/identity/schema.test.d.ts.map +1 -0
- package/dist/esm/identity/schema.test.js +38 -0
- package/dist/esm/oauth/authorize/schema/grants/authorization-code.d.ts.map +1 -1
- package/dist/esm/oauth/authorize/schema/grants/authorization-code.js +22 -3
- package/dist/esm/oauth/authorize/schema/grants/authorization-code.test.d.ts +2 -0
- package/dist/esm/oauth/authorize/schema/grants/authorization-code.test.d.ts.map +1 -0
- package/dist/esm/oauth/authorize/schema/grants/authorization-code.test.js +332 -0
- package/dist/esm/oauth/common/schema.test.d.ts +2 -0
- package/dist/esm/oauth/common/schema.test.d.ts.map +1 -0
- package/dist/esm/oauth/common/schema.test.js +288 -0
- package/dist/esm/oauth/token/schema/schema.test.d.ts +2 -0
- package/dist/esm/oauth/token/schema/schema.test.d.ts.map +1 -0
- package/dist/esm/oauth/token/schema/schema.test.js +120 -0
- package/dist/esm/workspace/settings/schema.test.d.ts +2 -0
- package/dist/esm/workspace/settings/schema.test.d.ts.map +1 -0
- package/dist/esm/workspace/settings/schema.test.js +71 -0
- package/dist/esm/workspace/tenant/schema.d.ts +1 -0
- package/dist/esm/workspace/tenant/schema.d.ts.map +1 -1
- package/dist/esm/workspace/tenant/schema.js +4 -3
- package/dist/esm/workspace/user/notifications/schema.d.ts.map +1 -1
- package/dist/esm/workspace/user/notifications/schema.js +4 -3
- package/dist/esm/workspace/user/preferences/schema.js +3 -3
- package/dist/esm/workspace/utils.d.ts +0 -3
- package/dist/esm/workspace/utils.d.ts.map +1 -1
- package/dist/esm/workspace/utils.js +0 -3
- package/dist/esm/workspace/utils.test.d.ts +2 -0
- package/dist/esm/workspace/utils.test.d.ts.map +1 -0
- package/dist/esm/workspace/utils.test.js +61 -0
- package/package.json +1 -1
- package/dist/cjs/authorization/utils.d.ts +0 -11
- package/dist/cjs/authorization/utils.d.ts.map +0 -1
- package/dist/cjs/customer/schema/organization.d.ts.map +0 -1
- package/dist/cjs/customer/schema/schema.d.ts +0 -4
- package/dist/cjs/customer/schema/schema.d.ts.map +0 -1
- package/dist/cjs/customer/schema/schema.js +0 -19
- package/dist/cjs/customer/schema/utils.d.ts +0 -11
- package/dist/cjs/customer/schema/utils.d.ts.map +0 -1
- package/dist/esm/authorization/utils.d.ts +0 -11
- package/dist/esm/authorization/utils.d.ts.map +0 -1
- package/dist/esm/authorization/utils.js +0 -15
- package/dist/esm/customer/schema/organization.d.ts.map +0 -1
- package/dist/esm/customer/schema/schema.d.ts +0 -4
- package/dist/esm/customer/schema/schema.d.ts.map +0 -1
- package/dist/esm/customer/schema/schema.js +0 -3
- package/dist/esm/customer/schema/utils.d.ts +0 -11
- package/dist/esm/customer/schema/utils.d.ts.map +0 -1
- package/dist/esm/customer/schema/utils.js +0 -15
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { type } from 'arktype';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { generateAppId } from '../../app/utils.js';
|
|
4
|
+
import { PermissionIdSchema, generatePermissionId, generateRoleId, } from '../schema.js';
|
|
5
|
+
import { InsertPermissionPayloadSchema, PermissionAssociationReferenceSchema, PermissionAssociationsSchema, PermissionIdPropertySchema, PermissionSchema, PermissionStatus, UpdatePermissionPayloadSchema, } from './schema.js';
|
|
6
|
+
describe('Authorization Permissions - Schema', () => {
|
|
7
|
+
describe('PermissionStatus constants', () => {
|
|
8
|
+
test('should have correct status values', () => {
|
|
9
|
+
expect(PermissionStatus.ENABLED).toBe('enabled');
|
|
10
|
+
expect(PermissionStatus.DISABLED).toBe('disabled');
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
describe('PermissionIdSchema', () => {
|
|
14
|
+
test('should accept valid string ID', () => {
|
|
15
|
+
const result = PermissionIdSchema(generatePermissionId());
|
|
16
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
17
|
+
});
|
|
18
|
+
test('should reject non-string values', () => {
|
|
19
|
+
expect(PermissionIdSchema(123)).toBeInstanceOf(type.errors);
|
|
20
|
+
expect(PermissionIdSchema(null)).toBeInstanceOf(type.errors);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe('PermissionIdPropertySchema', () => {
|
|
24
|
+
test('should accept valid id property', () => {
|
|
25
|
+
const payload = { id: generatePermissionId() };
|
|
26
|
+
const result = PermissionIdPropertySchema(payload);
|
|
27
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
28
|
+
expect(result).toEqual({ id: payload.id });
|
|
29
|
+
});
|
|
30
|
+
test('should reject missing id', () => {
|
|
31
|
+
const result = PermissionIdPropertySchema({});
|
|
32
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe('PermissionAssociationsSchema', () => {
|
|
36
|
+
const payload = {
|
|
37
|
+
apps: [generateAppId(), generateAppId()],
|
|
38
|
+
roles: [generateRoleId(), generateRoleId()],
|
|
39
|
+
};
|
|
40
|
+
test('should accept valid associations', () => {
|
|
41
|
+
const result = PermissionAssociationsSchema(payload);
|
|
42
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
43
|
+
expect(result).toEqual({
|
|
44
|
+
apps: payload.apps,
|
|
45
|
+
roles: payload.roles,
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
test('should accept optional associations', () => {
|
|
49
|
+
const result = PermissionAssociationsSchema({});
|
|
50
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
51
|
+
expect(result).toEqual({});
|
|
52
|
+
});
|
|
53
|
+
test('should accept undefined associations', () => {
|
|
54
|
+
const result = PermissionAssociationsSchema({
|
|
55
|
+
apps: undefined,
|
|
56
|
+
roles: [generateRoleId()],
|
|
57
|
+
});
|
|
58
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
59
|
+
});
|
|
60
|
+
test('should reject non-array associations', () => {
|
|
61
|
+
const result = PermissionAssociationsSchema({
|
|
62
|
+
apps: 'not-an-array',
|
|
63
|
+
});
|
|
64
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
describe('PermissionSchema', () => {
|
|
68
|
+
test('should accept complete permission object', () => {
|
|
69
|
+
const permission = {
|
|
70
|
+
id: generatePermissionId(),
|
|
71
|
+
name: 'read:users',
|
|
72
|
+
status: 'enabled',
|
|
73
|
+
description: 'Read user data',
|
|
74
|
+
apps: { ids: [generateAppId()], count: 1 },
|
|
75
|
+
roles: { ids: [generateRoleId()], count: 1 },
|
|
76
|
+
createdAt: new Date(),
|
|
77
|
+
updatedAt: new Date(),
|
|
78
|
+
metadata: { key: 'value' },
|
|
79
|
+
};
|
|
80
|
+
const result = PermissionSchema(permission);
|
|
81
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
82
|
+
});
|
|
83
|
+
test('should accept minimal permission object', () => {
|
|
84
|
+
const permission = {
|
|
85
|
+
id: generatePermissionId(),
|
|
86
|
+
name: 'read:users',
|
|
87
|
+
status: 'enabled',
|
|
88
|
+
createdAt: new Date(),
|
|
89
|
+
updatedAt: new Date(),
|
|
90
|
+
metadata: {},
|
|
91
|
+
};
|
|
92
|
+
const result = PermissionSchema(permission);
|
|
93
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
94
|
+
});
|
|
95
|
+
test('should reject invalid status', () => {
|
|
96
|
+
const permission = {
|
|
97
|
+
id: generatePermissionId(),
|
|
98
|
+
name: 'read:users',
|
|
99
|
+
status: 'invalid',
|
|
100
|
+
createdAt: new Date(),
|
|
101
|
+
updatedAt: new Date(),
|
|
102
|
+
metadata: {},
|
|
103
|
+
};
|
|
104
|
+
const result = PermissionSchema(permission);
|
|
105
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
106
|
+
});
|
|
107
|
+
test('should reject missing required fields', () => {
|
|
108
|
+
const permission = {
|
|
109
|
+
id: generatePermissionId(),
|
|
110
|
+
name: 'read:users',
|
|
111
|
+
};
|
|
112
|
+
const result = PermissionSchema(permission);
|
|
113
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
describe('InsertPermissionPayloadSchema', () => {
|
|
117
|
+
test('should accept complete insert payload', () => {
|
|
118
|
+
const payload = {
|
|
119
|
+
id: generatePermissionId(),
|
|
120
|
+
name: 'read:users',
|
|
121
|
+
status: 'enabled',
|
|
122
|
+
description: 'Read user data',
|
|
123
|
+
apps: [generateAppId()],
|
|
124
|
+
roles: [generateRoleId()],
|
|
125
|
+
metadata: { key: 'value' },
|
|
126
|
+
};
|
|
127
|
+
const result = InsertPermissionPayloadSchema(payload);
|
|
128
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
129
|
+
});
|
|
130
|
+
test('should accept minimal insert payload', () => {
|
|
131
|
+
const payload = {
|
|
132
|
+
name: 'read:users',
|
|
133
|
+
};
|
|
134
|
+
const result = InsertPermissionPayloadSchema(payload);
|
|
135
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
136
|
+
expect(result.status).toBe('enabled'); // default value
|
|
137
|
+
});
|
|
138
|
+
test('should generate default ID when not provided', () => {
|
|
139
|
+
const payload = { name: 'read:users' };
|
|
140
|
+
const result = InsertPermissionPayloadSchema(payload);
|
|
141
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
142
|
+
expect(result.id).toMatch(/^per_/);
|
|
143
|
+
});
|
|
144
|
+
test('should reject missing name', () => {
|
|
145
|
+
const result = InsertPermissionPayloadSchema({});
|
|
146
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
describe('UpdatePermissionPayloadSchema', () => {
|
|
150
|
+
test('should accept all optional fields', () => {
|
|
151
|
+
const payload = {
|
|
152
|
+
name: 'updated:permission',
|
|
153
|
+
status: 'disabled',
|
|
154
|
+
description: 'Updated description',
|
|
155
|
+
metadata: { updated: true },
|
|
156
|
+
};
|
|
157
|
+
const result = UpdatePermissionPayloadSchema(payload);
|
|
158
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
159
|
+
expect(result).toEqual(payload);
|
|
160
|
+
});
|
|
161
|
+
test('should accept empty update payload', () => {
|
|
162
|
+
const result = UpdatePermissionPayloadSchema({});
|
|
163
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
164
|
+
expect(result).toEqual({});
|
|
165
|
+
});
|
|
166
|
+
test('should accept partial updates', () => {
|
|
167
|
+
const payload = { name: 'new:name' };
|
|
168
|
+
const result = UpdatePermissionPayloadSchema(payload);
|
|
169
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
170
|
+
expect(result).toEqual(payload);
|
|
171
|
+
});
|
|
172
|
+
test('should reject invalid status', () => {
|
|
173
|
+
const payload = { status: 'invalid-status' };
|
|
174
|
+
const result = UpdatePermissionPayloadSchema(payload);
|
|
175
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
describe('PermissionAssociationReferenceSchema', () => {
|
|
179
|
+
test('should accept complete association reference', () => {
|
|
180
|
+
const reference = {
|
|
181
|
+
id: generatePermissionId(),
|
|
182
|
+
name: 'read:users',
|
|
183
|
+
status: 'enabled',
|
|
184
|
+
model: 'Permission',
|
|
185
|
+
};
|
|
186
|
+
const result = PermissionAssociationReferenceSchema(reference);
|
|
187
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
188
|
+
expect(result).toEqual(reference);
|
|
189
|
+
});
|
|
190
|
+
test('should use default status when not provided', () => {
|
|
191
|
+
const reference = {
|
|
192
|
+
id: generatePermissionId(),
|
|
193
|
+
name: 'read:users',
|
|
194
|
+
model: 'Permission',
|
|
195
|
+
};
|
|
196
|
+
const result = PermissionAssociationReferenceSchema(reference);
|
|
197
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
198
|
+
expect(result.status).toBe('disabled'); // default value
|
|
199
|
+
});
|
|
200
|
+
test('should reject missing required fields', () => {
|
|
201
|
+
const reference = { id: generatePermissionId() };
|
|
202
|
+
const result = PermissionAssociationReferenceSchema(reference);
|
|
203
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
204
|
+
});
|
|
205
|
+
test('should reject invalid model value', () => {
|
|
206
|
+
const reference = {
|
|
207
|
+
id: generatePermissionId(),
|
|
208
|
+
name: 'read:users',
|
|
209
|
+
model: 'InvalidModel',
|
|
210
|
+
};
|
|
211
|
+
const result = PermissionAssociationReferenceSchema(reference);
|
|
212
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
});
|
|
@@ -34,7 +34,7 @@ export declare const RoleSchema: import("arktype/internal/methods/object.ts").Ob
|
|
|
34
34
|
updatedAt: Date | ((In: string) => import("arktype/internal/attributes.ts").To<Date>);
|
|
35
35
|
deletedAt?: Date | ((In: string) => import("arktype/internal/attributes.ts").To<Date>) | undefined;
|
|
36
36
|
deactivatedAt?: Date | ((In: string) => import("arktype/internal/attributes.ts").To<Date>) | undefined;
|
|
37
|
-
metadata: (In: import("arktype/internal/attributes.ts").Default<unknown, Map<string, string | number | boolean>>) => import("arktype").Out<Map<string, string | number | boolean
|
|
37
|
+
metadata: (In: import("arktype/internal/attributes.ts").Default<unknown, Map<string, string | number | boolean>>) => import("arktype").Out<Map<string, string | number | boolean>>;
|
|
38
38
|
}, {}>;
|
|
39
39
|
export type RoleProperties = typeof RoleSchema.inferIn;
|
|
40
40
|
export type Role = typeof RoleSchema.inferOut;
|
|
@@ -81,7 +81,7 @@ export declare const InsertRolePayloadSchema: import("arktype/internal/methods/o
|
|
|
81
81
|
[x: string]: string | number | boolean;
|
|
82
82
|
} | Map<string, string | number | boolean> | null | undefined) => import("arktype").Out<{
|
|
83
83
|
[x: string]: string | number | boolean;
|
|
84
|
-
} |
|
|
84
|
+
} | null>) | undefined;
|
|
85
85
|
}, {}>;
|
|
86
86
|
export type InsertRoleInput = typeof InsertRolePayloadSchema.inferIn;
|
|
87
87
|
export type InsertRolePayload = typeof InsertRolePayloadSchema.inferOut;
|
|
@@ -96,7 +96,7 @@ export declare const UpdateRolePayloadSchema: import("arktype/internal/methods/o
|
|
|
96
96
|
[x: string]: string | number | boolean;
|
|
97
97
|
} | Map<string, string | number | boolean> | null | undefined) => import("arktype").Out<{
|
|
98
98
|
[x: string]: string | number | boolean;
|
|
99
|
-
} |
|
|
99
|
+
} | null>) | undefined;
|
|
100
100
|
}, {}>;
|
|
101
101
|
export type UpdateRoleInput = typeof UpdateRolePayloadSchema.inferIn;
|
|
102
102
|
export type UpdateRolePayload = typeof UpdateRolePayloadSchema.inferOut;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/authorization/roles/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/authorization/roles/schema.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,UAAU;;;CAGb,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEzE,eAAO,MAAM,oBAAoB;;MAE/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,oBAAoB,CAAC,QAAQ,CAAC;AAIlE,eAAO,MAAM,sBAAsB;;;;MAIjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,sBAAsB,CAAC,QAAQ,CAAC;AAWtE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;MAOU,CAAC;AAClC,MAAM,MAAM,cAAc,GAAG,OAAO,UAAU,CAAC,OAAO,CAAC;AACvD,MAAM,MAAM,IAAI,GAAG,OAAO,UAAU,CAAC,QAAQ,CAAC;AAE9C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;MAOO,CAAC;AACtC,MAAM,MAAM,WAAW,GAAG,OAAO,iBAAiB,CAAC,QAAQ,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;MAOO,CAAC;AAC5C,MAAM,MAAM,eAAe,GAAG,OAAO,uBAAuB,CAAC,OAAO,CAAC;AACrE,MAAM,MAAM,iBAAiB,GAAG,OAAO,uBAAuB,CAAC,QAAQ,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;MAIO,CAAC;AAC5C,MAAM,MAAM,eAAe,GAAG,OAAO,uBAAuB,CAAC,OAAO,CAAC;AACrE,MAAM,MAAM,iBAAiB,GAAG,OAAO,uBAAuB,CAAC,QAAQ,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,8BAA8B;;;;;MAIzC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAClC,OAAO,8BAA8B,CAAC,QAAQ,CAAC"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { type } from 'arktype';
|
|
2
|
+
import { AppIdAssociationsSchema } from '../../app/schema.js';
|
|
2
3
|
import { OptionalDatePayloadSchema, OptionalDateSchema, RequiredDatePayloadSchema, RequiredDateSchema, } from '../../common/index.js';
|
|
3
4
|
import { AggregateSchema } from '../../common/schema/aggregate.js';
|
|
4
|
-
import { MetadataMapPropertySchema, MetadataPayloadPropertySchema, } from '../../common/schema/metadata.js';
|
|
5
|
-
import {
|
|
5
|
+
import { MetadataMapPropertySchema, MetadataPayloadPropertySchema, UpsertMetadataPropertyPayloadSchema, } from '../../common/schema/metadata.js';
|
|
6
|
+
import { UserIdAssociationsSchema } from '../../customer/schema.js';
|
|
7
|
+
import { PermissionIdAssociationsSchema, RoleIdSchema, generateRoleId, } from '../schema.js';
|
|
6
8
|
export const RoleStatus = {
|
|
7
9
|
ENABLED: 'enabled',
|
|
8
10
|
DISABLED: 'disabled',
|
|
9
11
|
};
|
|
10
|
-
const RoleIdSchema = type.string;
|
|
11
12
|
export const RoleIdPropertySchema = type({
|
|
12
13
|
id: RoleIdSchema,
|
|
13
14
|
});
|
|
14
15
|
const StatusSchema = type.enumerated(RoleStatus.ENABLED, RoleStatus.DISABLED);
|
|
15
|
-
const AssociationSchema = type('string[] | undefined');
|
|
16
16
|
export const RoleAssociationsSchema = type({
|
|
17
|
-
apps:
|
|
18
|
-
permissions:
|
|
19
|
-
users:
|
|
17
|
+
apps: AppIdAssociationsSchema.optional(),
|
|
18
|
+
permissions: PermissionIdAssociationsSchema.optional(),
|
|
19
|
+
users: UserIdAssociationsSchema.optional(),
|
|
20
20
|
});
|
|
21
21
|
const BaseSchema = RoleIdPropertySchema.and({
|
|
22
22
|
name: type('string'),
|
|
@@ -52,7 +52,7 @@ export const InsertRolePayloadSchema = type({
|
|
|
52
52
|
description: type('string').optional(),
|
|
53
53
|
})
|
|
54
54
|
.and(RoleAssociationsSchema)
|
|
55
|
-
.and(
|
|
55
|
+
.and(UpsertMetadataPropertyPayloadSchema);
|
|
56
56
|
/**
|
|
57
57
|
* Update
|
|
58
58
|
*/
|
|
@@ -60,7 +60,7 @@ export const UpdateRolePayloadSchema = type({
|
|
|
60
60
|
name: type('string').optional(),
|
|
61
61
|
status: StatusSchema.optional(),
|
|
62
62
|
description: type('string').optional(),
|
|
63
|
-
}).and(
|
|
63
|
+
}).and(UpsertMetadataPropertyPayloadSchema);
|
|
64
64
|
/**
|
|
65
65
|
* Association
|
|
66
66
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.test.d.ts","sourceRoot":"","sources":["../../../../src/authorization/roles/schema.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { type } from 'arktype';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { generateAppId } from '../../app/utils.js';
|
|
4
|
+
import { generateUserId } from '../../customer/schema.js';
|
|
5
|
+
import { generatePermissionId, generateRoleId } from '../schema.js';
|
|
6
|
+
import { InsertRolePayloadSchema, RoleAssociationReferenceSchema, RoleAssociationsSchema, RoleIdPropertySchema, RoleSchema, RoleStatus, UpdateRolePayloadSchema, } from './schema.js';
|
|
7
|
+
describe('Authorization Roles - Schema', () => {
|
|
8
|
+
describe('RoleStatus constants', () => {
|
|
9
|
+
test('should have correct status values', () => {
|
|
10
|
+
expect(RoleStatus.ENABLED).toBe('enabled');
|
|
11
|
+
expect(RoleStatus.DISABLED).toBe('disabled');
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
describe('RoleIdPropertySchema', () => {
|
|
15
|
+
test('should accept valid id property', () => {
|
|
16
|
+
const payload = { id: generateRoleId() };
|
|
17
|
+
const result = RoleIdPropertySchema(payload);
|
|
18
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
19
|
+
expect(result).toEqual({ id: payload.id });
|
|
20
|
+
});
|
|
21
|
+
test('should reject missing id', () => {
|
|
22
|
+
const result = RoleIdPropertySchema({});
|
|
23
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
describe('RoleAssociationsSchema', () => {
|
|
27
|
+
test('should accept valid associations', () => {
|
|
28
|
+
const payload = {
|
|
29
|
+
apps: [generateAppId(), generateAppId()],
|
|
30
|
+
permissions: [generatePermissionId(), generatePermissionId()],
|
|
31
|
+
users: [generateUserId(), generateUserId()],
|
|
32
|
+
};
|
|
33
|
+
const result = RoleAssociationsSchema(payload);
|
|
34
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
35
|
+
expect(result).toEqual({
|
|
36
|
+
apps: payload.apps,
|
|
37
|
+
permissions: payload.permissions,
|
|
38
|
+
users: payload.users,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
test('should accept optional associations', () => {
|
|
42
|
+
const result = RoleAssociationsSchema({});
|
|
43
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
44
|
+
expect(result).toEqual({});
|
|
45
|
+
});
|
|
46
|
+
test('should accept partial associations', () => {
|
|
47
|
+
const result = RoleAssociationsSchema({
|
|
48
|
+
permissions: [generatePermissionId()],
|
|
49
|
+
users: undefined,
|
|
50
|
+
});
|
|
51
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
52
|
+
});
|
|
53
|
+
test('should reject non-array associations', () => {
|
|
54
|
+
const result = RoleAssociationsSchema({
|
|
55
|
+
apps: 'not-an-array',
|
|
56
|
+
});
|
|
57
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
describe('RoleSchema', () => {
|
|
61
|
+
test('should accept complete role object', () => {
|
|
62
|
+
const role = {
|
|
63
|
+
id: generateRoleId(),
|
|
64
|
+
name: 'admin',
|
|
65
|
+
status: 'enabled',
|
|
66
|
+
description: 'Administrator role',
|
|
67
|
+
apps: { ids: [generateAppId()], count: 1 },
|
|
68
|
+
users: { ids: [generateUserId()], count: 1 },
|
|
69
|
+
permissions: { ids: [generatePermissionId()], count: 1 },
|
|
70
|
+
createdAt: new Date(),
|
|
71
|
+
updatedAt: new Date(),
|
|
72
|
+
metadata: { key: 'value' },
|
|
73
|
+
};
|
|
74
|
+
const result = RoleSchema(role);
|
|
75
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
76
|
+
});
|
|
77
|
+
test('should accept minimal role object', () => {
|
|
78
|
+
const role = {
|
|
79
|
+
id: generateRoleId(),
|
|
80
|
+
name: 'user',
|
|
81
|
+
status: 'enabled',
|
|
82
|
+
createdAt: new Date(),
|
|
83
|
+
updatedAt: new Date(),
|
|
84
|
+
metadata: {},
|
|
85
|
+
};
|
|
86
|
+
const result = RoleSchema(role);
|
|
87
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
88
|
+
});
|
|
89
|
+
test('should accept role with optional dates', () => {
|
|
90
|
+
const role = {
|
|
91
|
+
id: generateRoleId(),
|
|
92
|
+
name: 'user',
|
|
93
|
+
status: 'disabled',
|
|
94
|
+
createdAt: new Date(),
|
|
95
|
+
updatedAt: new Date(),
|
|
96
|
+
deletedAt: new Date(),
|
|
97
|
+
deactivatedAt: new Date(),
|
|
98
|
+
metadata: {},
|
|
99
|
+
};
|
|
100
|
+
const result = RoleSchema(role);
|
|
101
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
102
|
+
});
|
|
103
|
+
test('should reject invalid status', () => {
|
|
104
|
+
const role = {
|
|
105
|
+
id: generateRoleId(),
|
|
106
|
+
name: 'admin',
|
|
107
|
+
status: 'invalid',
|
|
108
|
+
createdAt: new Date(),
|
|
109
|
+
updatedAt: new Date(),
|
|
110
|
+
metadata: {},
|
|
111
|
+
};
|
|
112
|
+
const result = RoleSchema(role);
|
|
113
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
114
|
+
});
|
|
115
|
+
test('should reject missing required fields', () => {
|
|
116
|
+
const role = {
|
|
117
|
+
id: generateRoleId(),
|
|
118
|
+
name: 'admin',
|
|
119
|
+
};
|
|
120
|
+
const result = RoleSchema(role);
|
|
121
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
describe('InsertRolePayloadSchema', () => {
|
|
125
|
+
test('should accept complete insert payload', () => {
|
|
126
|
+
const payload = {
|
|
127
|
+
id: generateRoleId(),
|
|
128
|
+
name: 'admin',
|
|
129
|
+
status: 'enabled',
|
|
130
|
+
description: 'Administrator role',
|
|
131
|
+
apps: [generateAppId()],
|
|
132
|
+
permissions: [generatePermissionId()],
|
|
133
|
+
users: [generateUserId()],
|
|
134
|
+
metadata: { key: 'value' },
|
|
135
|
+
};
|
|
136
|
+
const result = InsertRolePayloadSchema(payload);
|
|
137
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
138
|
+
});
|
|
139
|
+
test('should accept minimal insert payload', () => {
|
|
140
|
+
const payload = {
|
|
141
|
+
name: 'user',
|
|
142
|
+
};
|
|
143
|
+
const result = InsertRolePayloadSchema(payload);
|
|
144
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
145
|
+
expect(result.status).toBe('enabled'); // default value
|
|
146
|
+
});
|
|
147
|
+
test('should generate default ID when not provided', () => {
|
|
148
|
+
const payload = { name: 'admin' };
|
|
149
|
+
const result = InsertRolePayloadSchema(payload);
|
|
150
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
151
|
+
expect(result.id).toMatch(/^rol_/);
|
|
152
|
+
});
|
|
153
|
+
test('should reject missing name', () => {
|
|
154
|
+
const result = InsertRolePayloadSchema({});
|
|
155
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
156
|
+
});
|
|
157
|
+
test('should accept associations in insert payload', () => {
|
|
158
|
+
const payload = {
|
|
159
|
+
name: 'moderator',
|
|
160
|
+
apps: [generateAppId(), generateAppId()],
|
|
161
|
+
permissions: [generatePermissionId(), generatePermissionId()],
|
|
162
|
+
users: [generateUserId()],
|
|
163
|
+
};
|
|
164
|
+
const result = InsertRolePayloadSchema(payload);
|
|
165
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
describe('UpdateRolePayloadSchema', () => {
|
|
169
|
+
test('should accept all optional fields', () => {
|
|
170
|
+
const payload = {
|
|
171
|
+
name: 'updated-role',
|
|
172
|
+
status: 'disabled',
|
|
173
|
+
description: 'Updated description',
|
|
174
|
+
metadata: { updated: true },
|
|
175
|
+
};
|
|
176
|
+
const result = UpdateRolePayloadSchema(payload);
|
|
177
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
178
|
+
expect(result).toEqual(payload);
|
|
179
|
+
});
|
|
180
|
+
test('should accept empty update payload', () => {
|
|
181
|
+
const result = UpdateRolePayloadSchema({});
|
|
182
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
183
|
+
expect(result).toEqual({});
|
|
184
|
+
});
|
|
185
|
+
test('should accept partial updates', () => {
|
|
186
|
+
const payload = { name: 'new-name' };
|
|
187
|
+
const result = UpdateRolePayloadSchema(payload);
|
|
188
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
189
|
+
expect(result).toEqual(payload);
|
|
190
|
+
});
|
|
191
|
+
test('should reject invalid status', () => {
|
|
192
|
+
const payload = { status: 'invalid-status' };
|
|
193
|
+
const result = UpdateRolePayloadSchema(payload);
|
|
194
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
describe('RoleAssociationReferenceSchema', () => {
|
|
198
|
+
test('should accept complete association reference', () => {
|
|
199
|
+
const reference = {
|
|
200
|
+
id: generateRoleId(),
|
|
201
|
+
name: 'admin',
|
|
202
|
+
status: 'enabled',
|
|
203
|
+
model: 'Role',
|
|
204
|
+
};
|
|
205
|
+
const result = RoleAssociationReferenceSchema(reference);
|
|
206
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
207
|
+
expect(result).toEqual(reference);
|
|
208
|
+
});
|
|
209
|
+
test('should use default status when not provided', () => {
|
|
210
|
+
const reference = {
|
|
211
|
+
id: generateRoleId(),
|
|
212
|
+
name: 'admin',
|
|
213
|
+
model: 'Role',
|
|
214
|
+
};
|
|
215
|
+
const result = RoleAssociationReferenceSchema(reference);
|
|
216
|
+
expect(result).not.toBeInstanceOf(type.errors);
|
|
217
|
+
expect(result.status).toBe('disabled'); // default value
|
|
218
|
+
});
|
|
219
|
+
test('should reject missing required fields', () => {
|
|
220
|
+
const reference = { id: generateRoleId() };
|
|
221
|
+
const result = RoleAssociationReferenceSchema(reference);
|
|
222
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
223
|
+
});
|
|
224
|
+
test('should reject invalid model value', () => {
|
|
225
|
+
const reference = {
|
|
226
|
+
id: generateRoleId(),
|
|
227
|
+
name: 'admin',
|
|
228
|
+
model: 'InvalidModel',
|
|
229
|
+
};
|
|
230
|
+
const result = RoleAssociationReferenceSchema(reference);
|
|
231
|
+
expect(result).toBeInstanceOf(type.errors);
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const Model: {
|
|
2
|
+
readonly Permission: {
|
|
3
|
+
readonly UIDPrefix: "per";
|
|
4
|
+
};
|
|
5
|
+
readonly Role: {
|
|
6
|
+
readonly UIDPrefix: "rol";
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare function generatePermissionId(): string;
|
|
10
|
+
export declare function generateRoleId(): string;
|
|
11
|
+
export declare const RoleIdSchema: import("arktype/internal/methods/string.ts").StringType<string, {}>;
|
|
12
|
+
export type RoleId = typeof RoleIdSchema.inferOut;
|
|
13
|
+
export declare const RoleIdAssociationsSchema: import("arktype").BaseType<string[] | undefined, {}>;
|
|
14
|
+
export declare const PermissionIdSchema: import("arktype/internal/methods/string.ts").StringType<string, {}>;
|
|
15
|
+
export type PermissionId = typeof PermissionIdSchema.inferOut;
|
|
16
|
+
export declare const PermissionIdAssociationsSchema: import("arktype").BaseType<string[] | undefined, {}>;
|
|
17
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/authorization/schema.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK;;;;;;;CAOR,CAAC;AAEX,wBAAgB,oBAAoB,WAEnC;AAED,wBAAgB,cAAc,WAE7B;AAED,eAAO,MAAM,YAAY,qEAAoC,CAAC;AAC9D,MAAM,MAAM,MAAM,GAAG,OAAO,YAAY,CAAC,QAAQ,CAAC;AAElD,eAAO,MAAM,wBAAwB,sDAEpC,CAAC;AAEF,eAAO,MAAM,kBAAkB,qEAA0C,CAAC;AAC1E,MAAM,MAAM,YAAY,GAAG,OAAO,kBAAkB,CAAC,QAAQ,CAAC;AAE9D,eAAO,MAAM,8BAA8B,sDAE1C,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type } from 'arktype';
|
|
2
|
+
import KSUID from 'ksuid';
|
|
3
|
+
import { KSUIDSchema } from '../common/schema/id.js';
|
|
4
|
+
export const Model = {
|
|
5
|
+
Permission: {
|
|
6
|
+
UIDPrefix: 'per',
|
|
7
|
+
},
|
|
8
|
+
Role: {
|
|
9
|
+
UIDPrefix: 'rol',
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
export function generatePermissionId() {
|
|
13
|
+
return `${Model.Permission.UIDPrefix}_${KSUID.randomSync().string}`;
|
|
14
|
+
}
|
|
15
|
+
export function generateRoleId() {
|
|
16
|
+
return `${Model.Role.UIDPrefix}_${KSUID.randomSync().string}`;
|
|
17
|
+
}
|
|
18
|
+
export const RoleIdSchema = KSUIDSchema(Model.Role.UIDPrefix);
|
|
19
|
+
export const RoleIdAssociationsSchema = type('undefined').or(RoleIdSchema.array());
|
|
20
|
+
export const PermissionIdSchema = KSUIDSchema(Model.Permission.UIDPrefix);
|
|
21
|
+
export const PermissionIdAssociationsSchema = type('undefined').or(PermissionIdSchema.array());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.test.d.ts","sourceRoot":"","sources":["../../../src/authorization/schema.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { Model, generatePermissionId, generateRoleId } from './schema.js';
|
|
3
|
+
describe('Authorization - Utils', () => {
|
|
4
|
+
describe('Model constants', () => {
|
|
5
|
+
test('should have correct UID prefixes', () => {
|
|
6
|
+
expect(Model.Permission.UIDPrefix).toBe('per');
|
|
7
|
+
expect(Model.Role.UIDPrefix).toBe('rol');
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
describe('generatePermissionId', () => {
|
|
11
|
+
test('should generate ID with correct prefix', () => {
|
|
12
|
+
const id = generatePermissionId();
|
|
13
|
+
expect(id).toMatch(/^per_[A-Za-z0-9]+$/);
|
|
14
|
+
});
|
|
15
|
+
test('should generate unique IDs', () => {
|
|
16
|
+
const id1 = generatePermissionId();
|
|
17
|
+
const id2 = generatePermissionId();
|
|
18
|
+
expect(id1).not.toBe(id2);
|
|
19
|
+
});
|
|
20
|
+
test('should generate IDs with correct length', () => {
|
|
21
|
+
const id = generatePermissionId();
|
|
22
|
+
expect(id.length).toBeGreaterThan(4); // prefix + underscore + KSUID
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('generateRoleId', () => {
|
|
26
|
+
test('should generate ID with correct prefix', () => {
|
|
27
|
+
const id = generateRoleId();
|
|
28
|
+
expect(id).toMatch(/^rol_[A-Za-z0-9]+$/);
|
|
29
|
+
});
|
|
30
|
+
test('should generate unique IDs', () => {
|
|
31
|
+
const id1 = generateRoleId();
|
|
32
|
+
const id2 = generateRoleId();
|
|
33
|
+
expect(id1).not.toBe(id2);
|
|
34
|
+
});
|
|
35
|
+
test('should generate IDs with correct length', () => {
|
|
36
|
+
const id = generateRoleId();
|
|
37
|
+
expect(id.length).toBeGreaterThan(4); // prefix + underscore + KSUID
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.test.d.ts","sourceRoot":"","sources":["../../../../src/common/errors/http.test.ts"],"names":[],"mappings":""}
|