@antelopejs/interface-dms 0.10.4 → 0.13.0
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/CHANGELOG.md +126 -0
- package/README.md +21 -10
- package/dist/attachments.d.ts +15 -2
- package/dist/attachments.js +14 -1
- package/dist/attachments.js.map +1 -1
- package/dist/auth/db/models/sessions.model.d.ts +7 -5
- package/dist/auth/db/models/sessions.model.js +2 -9
- package/dist/auth/db/models/sessions.model.js.map +1 -1
- package/dist/auth/db/models/userExternalIdentities.model.d.ts +7 -5
- package/dist/auth/db/models/users.model.d.ts +7 -5
- package/dist/auth/db/tables/users.table.d.ts +2 -2
- package/dist/auth/db/tables/users.table.js.map +1 -1
- package/dist/auth/index.d.ts +4 -4
- package/dist/auth/internal/jwt-auth-decorator.d.ts +1 -1
- package/dist/auth/internal/jwt-auth-decorator.js +6 -3
- package/dist/auth/internal/jwt-auth-decorator.js.map +1 -1
- package/dist/auth/internal/request-authenticators.d.ts +12 -0
- package/dist/auth/internal/request-authenticators.js +53 -10
- package/dist/auth/internal/request-authenticators.js.map +1 -1
- package/dist/base/activity-feed.d.ts +34 -32
- package/dist/base/activity-feed.js +2 -0
- package/dist/base/activity-feed.js.map +1 -1
- package/dist/base/banner.d.ts +12 -10
- package/dist/base/banner.js +2 -0
- package/dist/base/banner.js.map +1 -1
- package/dist/base/block-registry/internal/describe.js +4 -12
- package/dist/base/block-registry/internal/describe.js.map +1 -1
- package/dist/base/block-registry/internal/ui.js +1 -1
- package/dist/base/block-registry/internal/ui.js.map +1 -1
- package/dist/base/card.d.ts +11 -9
- package/dist/base/card.js +2 -0
- package/dist/base/card.js.map +1 -1
- package/dist/base/chart-card.d.ts +4 -2
- package/dist/base/chart-card.js +2 -0
- package/dist/base/chart-card.js.map +1 -1
- package/dist/base/chart-schemas.d.ts +148 -148
- package/dist/base/chart.d.ts +65 -0
- package/dist/base/chart.js +65 -0
- package/dist/base/chart.js.map +1 -1
- package/dist/base/code-block.d.ts +5 -3
- package/dist/base/code-block.js +2 -0
- package/dist/base/code-block.js.map +1 -1
- package/dist/base/custom.d.ts +5 -0
- package/dist/base/custom.js +5 -0
- package/dist/base/custom.js.map +1 -1
- package/dist/base/data-types/default/address.d.ts +5 -0
- package/dist/base/data-types/default/address.js +5 -0
- package/dist/base/data-types/default/address.js.map +1 -1
- package/dist/base/data-types/default/choices.d.ts +20 -0
- package/dist/base/data-types/default/choices.js +20 -0
- package/dist/base/data-types/default/choices.js.map +1 -1
- package/dist/base/data-types/default/files.d.ts +22 -5
- package/dist/base/data-types/default/files.js +20 -0
- package/dist/base/data-types/default/files.js.map +1 -1
- package/dist/base/data-types/default/numbers.d.ts +15 -0
- package/dist/base/data-types/default/numbers.js +25 -9
- package/dist/base/data-types/default/numbers.js.map +1 -1
- package/dist/base/data-types/default/relations.d.ts +10 -2
- package/dist/base/data-types/default/relations.js +9 -6
- package/dist/base/data-types/default/relations.js.map +1 -1
- package/dist/base/data-types/default/strings.d.ts +25 -0
- package/dist/base/data-types/default/strings.js +25 -0
- package/dist/base/data-types/default/strings.js.map +1 -1
- package/dist/base/data-types/default-types.d.ts +1 -1
- package/dist/base/data-types/field-types.d.ts +10 -0
- package/dist/base/data-types/field-types.js +10 -0
- package/dist/base/data-types/field-types.js.map +1 -1
- package/dist/base/data-types/internal/relation-endpoints.js +1 -0
- package/dist/base/data-types/internal/relation-endpoints.js.map +1 -1
- package/dist/base/data-types/status-type.d.ts +5 -0
- package/dist/base/data-types/status-type.js +5 -0
- package/dist/base/data-types/status-type.js.map +1 -1
- package/dist/base/display.d.ts +6 -6
- package/dist/base/empty-state.d.ts +15 -13
- package/dist/base/empty-state.js +2 -0
- package/dist/base/empty-state.js.map +1 -1
- package/dist/base/form-block-schema.d.ts +50 -50
- package/dist/base/form-schema.d.ts +2 -0
- package/dist/base/form-schema.js +2 -0
- package/dist/base/form-schema.js.map +1 -1
- package/dist/base/grid.d.ts +4 -0
- package/dist/base/grid.js +4 -0
- package/dist/base/grid.js.map +1 -1
- package/dist/base/guard.d.ts +30 -28
- package/dist/base/guard.js +2 -0
- package/dist/base/guard.js.map +1 -1
- package/dist/base/helpers/archive-mode-helpers.d.ts +1 -1
- package/dist/base/helpers/file-refs.js +15 -15
- package/dist/base/helpers/file-refs.js.map +1 -1
- package/dist/base/internal/form-schema-validation.js +7 -1
- package/dist/base/internal/form-schema-validation.js.map +1 -1
- package/dist/base/internal/realtime-topics.js.map +1 -1
- package/dist/base/internal/searchable.d.ts +2 -1
- package/dist/base/internal/searchable.js +1 -3
- package/dist/base/internal/searchable.js.map +1 -1
- package/dist/base/key-value-list.d.ts +21 -19
- package/dist/base/key-value-list.js +2 -0
- package/dist/base/key-value-list.js.map +1 -1
- package/dist/base/kpi-card.d.ts +4 -2
- package/dist/base/kpi-card.js +2 -0
- package/dist/base/kpi-card.js.map +1 -1
- package/dist/base/live-toggle.d.ts +2 -0
- package/dist/base/live-toggle.js +2 -0
- package/dist/base/live-toggle.js.map +1 -1
- package/dist/base/meter.d.ts +23 -21
- package/dist/base/meter.js +2 -0
- package/dist/base/meter.js.map +1 -1
- package/dist/base/nav-card-grid.d.ts +24 -19
- package/dist/base/nav-card-grid.js +5 -0
- package/dist/base/nav-card-grid.js.map +1 -1
- package/dist/base/page-toolbar.d.ts +2 -0
- package/dist/base/page-toolbar.js +2 -0
- package/dist/base/page-toolbar.js.map +1 -1
- package/dist/base/period-selector.d.ts +3 -1
- package/dist/base/period-selector.js +2 -0
- package/dist/base/period-selector.js.map +1 -1
- package/dist/base/placeholder.d.ts +2 -0
- package/dist/base/placeholder.js +2 -0
- package/dist/base/placeholder.js.map +1 -1
- package/dist/base/resource-form-schema.d.ts +2 -2
- package/dist/base/searchable.d.ts +3 -2
- package/dist/base/searchable.js +2 -2
- package/dist/base/searchable.js.map +1 -1
- package/dist/base/section.d.ts +6 -2
- package/dist/base/section.js +4 -0
- package/dist/base/section.js.map +1 -1
- package/dist/base/stack.d.ts +6 -0
- package/dist/base/stack.js +6 -0
- package/dist/base/stack.js.map +1 -1
- package/dist/base/stat-group.d.ts +16 -14
- package/dist/base/stat-group.js +2 -0
- package/dist/base/stat-group.js.map +1 -1
- package/dist/base/tab.d.ts +10 -8
- package/dist/base/tab.js +2 -0
- package/dist/base/tab.js.map +1 -1
- package/dist/base/table-view/column-display.d.ts +1 -1
- package/dist/base/table-view/column-display.js.map +1 -1
- package/dist/base/table-view/data-functions.d.ts +10 -4
- package/dist/base/table-view/data-functions.js.map +1 -1
- package/dist/base/table-view/factory.d.ts +5 -0
- package/dist/base/table-view/factory.js +8 -4
- package/dist/base/table-view/factory.js.map +1 -1
- package/dist/base/table-view/internal/auth.d.ts +17 -3
- package/dist/base/table-view/internal/auth.js +26 -5
- package/dist/base/table-view/internal/auth.js.map +1 -1
- package/dist/base/table-view/internal/column-conditions.d.ts +8 -1
- package/dist/base/table-view/internal/column-conditions.js +25 -13
- package/dist/base/table-view/internal/column-conditions.js.map +1 -1
- package/dist/base/table-view/internal/column-display.d.ts +1 -2
- package/dist/base/table-view/internal/column-display.js +3 -9
- package/dist/base/table-view/internal/column-display.js.map +1 -1
- package/dist/base/table-view/internal/factory-helpers.d.ts +1 -1
- package/dist/base/table-view/internal/factory-helpers.js +17 -14
- package/dist/base/table-view/internal/factory-helpers.js.map +1 -1
- package/dist/base/table-view/internal/factory-lifecycle-created.d.ts +2 -3
- package/dist/base/table-view/internal/factory-lifecycle-created.js +5 -5
- package/dist/base/table-view/internal/factory-lifecycle-created.js.map +1 -1
- package/dist/base/table-view/internal/factory-lifecycle-filter.d.ts +2 -2
- package/dist/base/table-view/internal/factory-private-actions.d.ts +2 -2
- package/dist/base/table-view/internal/files.d.ts +2 -1
- package/dist/base/table-view/internal/files.js +14 -5
- package/dist/base/table-view/internal/files.js.map +1 -1
- package/dist/base/table-view/internal/footer.d.ts +3 -3
- package/dist/base/table-view/internal/footer.js +16 -15
- package/dist/base/table-view/internal/footer.js.map +1 -1
- package/dist/base/table-view/internal/guards.d.ts +27 -5
- package/dist/base/table-view/internal/guards.js +133 -49
- package/dist/base/table-view/internal/guards.js.map +1 -1
- package/dist/base/table-view/internal/meta-helpers.d.ts +1 -1
- package/dist/base/table-view/internal/meta-helpers.js +3 -4
- package/dist/base/table-view/internal/meta-helpers.js.map +1 -1
- package/dist/base/table-view/internal/meta.js +2 -3
- package/dist/base/table-view/internal/meta.js.map +1 -1
- package/dist/base/table-view/internal/option-contract.d.ts +9 -1
- package/dist/base/table-view/internal/option-footer.d.ts +2 -2
- package/dist/base/table-view/internal/option-row-actions.d.ts +1 -1
- package/dist/base/table-view/internal/realtime.d.ts +52 -11
- package/dist/base/table-view/internal/realtime.js +23 -16
- package/dist/base/table-view/internal/realtime.js.map +1 -1
- package/dist/base/table-view/internal/resource-form.d.ts +1 -1
- package/dist/base/table-view/internal/resource-form.js +1 -1
- package/dist/base/table-view/internal/resource-form.js.map +1 -1
- package/dist/base/table-view/internal/row-actions-schema.d.ts +12 -12
- package/dist/base/table-view/internal/row-rule-shape.d.ts +11 -5
- package/dist/base/table-view/internal/row-rule-shape.js +60 -30
- package/dist/base/table-view/internal/row-rule-shape.js.map +1 -1
- package/dist/base/table-view/internal/row-rules.d.ts +28 -1
- package/dist/base/table-view/internal/row-rules.js +8 -19
- package/dist/base/table-view/internal/row-rules.js.map +1 -1
- package/dist/base/table-view/internal/tabs.d.ts +1 -1
- package/dist/base/table-view/internal/tabs.js +1 -4
- package/dist/base/table-view/internal/tabs.js.map +1 -1
- package/dist/base/table-view/internal/validation.d.ts +2 -2
- package/dist/base/table-view/internal/validation.js +7 -7
- package/dist/base/table-view/internal/validation.js.map +1 -1
- package/dist/base/table-view/meta.d.ts +7 -6
- package/dist/base/table-view/meta.js +12 -7
- package/dist/base/table-view/meta.js.map +1 -1
- package/dist/base/table-view/resource-form.d.ts +3 -1
- package/dist/base/table-view/resource-form.js +2 -0
- package/dist/base/table-view/resource-form.js.map +1 -1
- package/dist/base/table-view/routes.d.ts +73 -21
- package/dist/base/table-view/routes.js +13 -10
- package/dist/base/table-view/routes.js.map +1 -1
- package/dist/base/table-view/schema.d.ts +157 -152
- package/dist/base/table-view/schema.js +2 -1
- package/dist/base/table-view/schema.js.map +1 -1
- package/dist/base/table-view/source.js +4 -1
- package/dist/base/table-view/source.js.map +1 -1
- package/dist/base/table-view.d.ts +1 -1
- package/dist/base/table-view.js.map +1 -1
- package/dist/base/top-list-card.d.ts +35 -33
- package/dist/base/top-list-card.js +2 -0
- package/dist/base/top-list-card.js.map +1 -1
- package/dist/base/types/error.js +5 -2
- package/dist/base/types/error.js.map +1 -1
- package/dist/base/types/guards.d.ts +4 -4
- package/dist/base/types/json.d.ts +1 -10
- package/dist/base/types/row-action.d.ts +7 -7
- package/dist/component-options/confirm-dialog.d.ts +2 -0
- package/dist/component-options/confirm-dialog.js.map +1 -1
- package/dist/component-options/data-type.d.ts +2 -2
- package/dist/component-options/data-type.js +7 -7
- package/dist/component-options/data-type.js.map +1 -1
- package/dist/component-options/page-layout.d.ts +3 -2
- package/dist/component-options/page-layout.js.map +1 -1
- package/dist/component-options/row-action.d.ts +14 -9
- package/dist/component-slots.d.ts +11 -2
- package/dist/component-slots.js +1 -0
- package/dist/component-slots.js.map +1 -1
- package/dist/component.d.ts +7 -8
- package/dist/component.js +17 -25
- package/dist/component.js.map +1 -1
- package/dist/data-controllers/members.d.ts +11 -7
- package/dist/data-controllers/members.js +1 -1
- package/dist/data-controllers/members.js.map +1 -1
- package/dist/data-controllers/roles.d.ts +32 -10
- package/dist/db/internal/exportJobs.model.d.ts +7 -5
- package/dist/db/internal/inviteResolutions.model.d.ts +7 -5
- package/dist/db/internal/tenantLifecycle.model.d.ts +15 -7
- package/dist/db/internal/tenantLifecycle.model.js +16 -7
- package/dist/db/internal/tenantLifecycle.model.js.map +1 -1
- package/dist/db/models/roles.model.d.ts +7 -5
- package/dist/db/models/tenantMembers.model.d.ts +7 -5
- package/dist/db/models/tenants.model.d.ts +7 -5
- package/dist/db/models/user_invites.model.d.ts +7 -5
- package/dist/guards.d.ts +1 -1
- package/dist/hooks.d.ts +1 -2
- package/dist/hooks.js +33 -26
- package/dist/hooks.js.map +1 -1
- package/dist/internal/attachments.d.ts +2 -2
- package/dist/internal/component-builder.js +2 -1
- package/dist/internal/component-builder.js.map +1 -1
- package/dist/internal/component-serialization.d.ts +2 -4
- package/dist/internal/component-serialization.js +4 -3
- package/dist/internal/component-serialization.js.map +1 -1
- package/dist/internal/component-slots.d.ts +19 -2
- package/dist/internal/component-slots.js +35 -12
- package/dist/internal/component-slots.js.map +1 -1
- package/dist/internal/component-watch-filter.d.ts +11 -0
- package/dist/internal/component-watch-filter.js +22 -0
- package/dist/internal/component-watch-filter.js.map +1 -0
- package/dist/internal/component-watches.js +0 -1
- package/dist/internal/component-watches.js.map +1 -1
- package/dist/internal/own-entry.d.ts +7 -0
- package/dist/internal/own-entry.js +13 -0
- package/dist/internal/own-entry.js.map +1 -0
- package/dist/internal/uploads.d.ts +30 -0
- package/dist/internal/uploads.js +19 -0
- package/dist/internal/uploads.js.map +1 -1
- package/dist/invite-extension-payloads.d.ts +14 -2
- package/dist/invite-extensions/internal/delivery.js +1 -2
- package/dist/invite-extensions/internal/delivery.js.map +1 -1
- package/dist/invite-extensions/internal/edit.d.ts +2 -1
- package/dist/invite-extensions/internal/edit.js +8 -9
- package/dist/invite-extensions/internal/edit.js.map +1 -1
- package/dist/invite-extensions/internal/form-slot.js +8 -15
- package/dist/invite-extensions/internal/form-slot.js.map +1 -1
- package/dist/invite-extensions/internal/payload-slices.d.ts +33 -3
- package/dist/invite-extensions/internal/payload-slices.js +84 -19
- package/dist/invite-extensions/internal/payload-slices.js.map +1 -1
- package/dist/invite-extensions/internal/types.d.ts +10 -1
- package/dist/invite-resolution.js +6 -4
- package/dist/invite-resolution.js.map +1 -1
- package/dist/json.d.ts +10 -0
- package/dist/json.js +3 -0
- package/dist/json.js.map +1 -0
- package/dist/layout-banners.d.ts +5 -2
- package/dist/layout-banners.js.map +1 -1
- package/dist/page/controllers.d.ts +2 -2
- package/dist/page/internal/extension-validation.js +3 -2
- package/dist/page/internal/extension-validation.js.map +1 -1
- package/dist/page/internal/metadata-layout.js +1 -1
- package/dist/page/internal/metadata-layout.js.map +1 -1
- package/dist/page/internal/metadata-publish.js +3 -2
- package/dist/page/internal/metadata-publish.js.map +1 -1
- package/dist/page/internal/metadata-registration.js +5 -4
- package/dist/page/internal/metadata-registration.js.map +1 -1
- package/dist/page/internal/metadata-upload-registration.d.ts +4 -2
- package/dist/page/internal/metadata-upload-registration.js +13 -4
- package/dist/page/internal/metadata-upload-registration.js.map +1 -1
- package/dist/page/internal/metadata-uploads.d.ts +5 -5
- package/dist/page/internal/metadata-uploads.js +4 -8
- package/dist/page/internal/metadata-uploads.js.map +1 -1
- package/dist/page/internal/page-record.d.ts +2 -3
- package/dist/page/internal/page-record.js +23 -16
- package/dist/page/internal/page-record.js.map +1 -1
- package/dist/page/layout-filter.js +17 -6
- package/dist/page/layout-filter.js.map +1 -1
- package/dist/page/metadata.js +5 -7
- package/dist/page/metadata.js.map +1 -1
- package/dist/request-tenant.d.ts +10 -4
- package/dist/request-tenant.js +16 -34
- package/dist/request-tenant.js.map +1 -1
- package/dist/tenant-export.d.ts +2 -1
- package/dist/tenant-lifecycle.d.ts +43 -4
- package/dist/tenant-lifecycle.js +97 -18
- package/dist/tenant-lifecycle.js.map +1 -1
- package/dist/types.d.ts +20 -0
- package/dist/uploads.d.ts +1 -1
- package/dist/uploads.js +39 -60
- package/dist/uploads.js.map +1 -1
- package/dist/utils/fire-and-forget.js.map +1 -1
- package/dist/utils/internal/decorated-class.d.ts +14 -0
- package/dist/utils/internal/decorated-class.js +37 -0
- package/dist/utils/internal/decorated-class.js.map +1 -0
- package/dist/utils/internal/type-check.d.ts +9 -0
- package/dist/utils/internal/type-check.js +13 -5
- package/dist/utils/internal/type-check.js.map +1 -1
- package/dist/utils/internal/value-parser.d.ts +1 -1
- package/dist/utils/internal/value-parser.js +22 -9
- package/dist/utils/internal/value-parser.js.map +1 -1
- package/dist/watch-actions.d.ts +1 -1
- package/docs/1.core/1.introduction.md +82 -77
- package/docs/1.core/10.layout-banners.md +57 -45
- package/docs/1.core/11.modules-and-dynamic-menus.md +178 -0
- package/docs/1.core/12.frontend-modules-and-request-helpers.md +155 -0
- package/docs/1.core/13.tenant-data-export.md +120 -0
- package/docs/1.core/2.pages-and-modules.md +140 -367
- package/docs/1.core/3.components.md +21 -22
- package/docs/1.core/4.permissions.md +92 -71
- package/docs/1.core/5.tenancy.md +150 -86
- package/docs/1.core/6.invites.md +90 -65
- package/docs/1.core/7.hooks.md +96 -166
- package/docs/1.core/8.realtime.md +44 -45
- package/docs/1.core/9.quick-actions.md +37 -30
- package/docs/2.auth/1.introduction.md +33 -35
- package/docs/2.auth/2.authentication.md +60 -38
- package/docs/2.auth/3.tokens-and-sessions.md +56 -55
- package/docs/2.auth/4.users.md +79 -51
- package/docs/2.auth/5.external-identities.md +25 -26
- package/docs/3.base/1.introduction.md +64 -60
- package/docs/3.base/10.display-blocks.md +15 -16
- package/docs/3.base/11.page-layouts.md +270 -0
- package/docs/3.base/12.table-row-actions.md +122 -0
- package/docs/3.base/13.table-filters-and-forms.md +104 -0
- package/docs/3.base/14.table-events-and-helpers.md +114 -0
- package/docs/3.base/15.table-sources-and-gates.md +24 -0
- package/docs/3.base/2.types.md +44 -41
- package/docs/3.base/3.forms.md +27 -28
- package/docs/3.base/4.tables.md +35 -368
- package/docs/3.base/5.charts-and-widgets.md +28 -29
- package/docs/3.base/6.layout.md +21 -270
- package/docs/3.base/8.data-types.md +39 -40
- package/docs/3.base/9.helpers.md +36 -38
- package/docs/4.notifications/1.introduction.md +22 -26
- package/docs/4.notifications/2.categories-and-subjects.md +58 -55
- package/docs/4.notifications/3.sending.md +72 -68
- package/docs/5.html-render/1.introduction.md +119 -81
- package/docs/5.html-render/2.built-in-emails.md +71 -51
- package/docs/index.md +18 -29
- package/docs/tsconfig.json +4 -0
- package/package.json +11 -11
- package/docs/images/emails-admin-invite.png +0 -0
- package/docs/images/emails-change-notice.png +0 -0
- package/docs/images/emails-change-verification.png +0 -0
- package/docs/images/emails-digest-logo-dark.png +0 -0
- package/docs/images/emails-digest-logo-light.png +0 -0
- package/docs/images/emails-digest.png +0 -0
- package/docs/images/emails-export-partial.png +0 -0
- package/docs/images/emails-export-ready.png +0 -0
- package/docs/images/emails-reset-password.png +0 -0
- package/docs/images/emails-two-factor.png +0 -0
- package/docs/images/emails-user-validation.png +0 -0
|
@@ -1,13 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The release of an invocation that finished or refused failed on every try.
|
|
3
|
+
* Its admission stays, so the deletion of `tenantId` is blocked until
|
|
4
|
+
* {@link releaseTenantLifecycleAttempt} retires `attemptId`. The `cause` is the
|
|
5
|
+
* failure of the last try.
|
|
6
|
+
*/
|
|
7
|
+
export declare class TenantLifecycleReleaseError extends Error {
|
|
8
|
+
readonly tenantId: string;
|
|
9
|
+
readonly attemptId: string;
|
|
10
|
+
constructor(tenantId: string, attemptId: string, cause: unknown);
|
|
11
|
+
}
|
|
1
12
|
/**
|
|
2
13
|
* Admits one invocation. Work must await every producer effect and start no
|
|
3
14
|
* detached writer. Failure retains its admission; an independent replay must
|
|
4
|
-
* never retire this invocation's identity.
|
|
15
|
+
* never retire this invocation's identity. Each call takes its own admission,
|
|
16
|
+
* so work never calls this again for the same tenant.
|
|
17
|
+
*
|
|
18
|
+
* A success, and a deliberate refusal (an HTTP 4xx), are the exceptions: work
|
|
19
|
+
* that awaits every effect has none left in flight once it finishes or
|
|
20
|
+
* refuses, so keeping the admission would only block the tenant's deletion
|
|
21
|
+
* forever. The release is tried {@link RELEASE_ATTEMPTS} times, with a pause
|
|
22
|
+
* between tries. If every try fails, the admission stays, the failure is
|
|
23
|
+
* logged and the call rejects, so the blocked deletion is reported instead of
|
|
24
|
+
* hidden: with an `AggregateError` of the refusal and a
|
|
25
|
+
* {@link TenantLifecycleReleaseError} after a refusal, with the
|
|
26
|
+
* {@link TenantLifecycleReleaseError} after a success.
|
|
5
27
|
*
|
|
6
|
-
* A
|
|
7
|
-
*
|
|
8
|
-
*
|
|
28
|
+
* A refusal is read by shape, not `instanceof`, because it can come from
|
|
29
|
+
* another module's copy of the API interface (a dms-saas seat limit raised
|
|
30
|
+
* from a hook, for instance).
|
|
9
31
|
*/
|
|
10
32
|
export declare function runTenantLifecycleOperation<T>(tenantId: string, work: () => Promise<T>): Promise<T>;
|
|
33
|
+
/**
|
|
34
|
+
* Retires one admission by hand: the operator path for a deletion that
|
|
35
|
+
* {@link closeTenantLifecycleAdmission} reports blocked.
|
|
36
|
+
*
|
|
37
|
+
* Call it with the `tenantId` and `attemptId` of a
|
|
38
|
+
* {@link TenantLifecycleReleaseError} once the database answers again. That
|
|
39
|
+
* invocation finished or refused, so none of its effects is in flight. Any
|
|
40
|
+
* other attempt that {@link observeTenantLifecycle} lists retains its admission
|
|
41
|
+
* because its effects may be indeterminate: retire it only after confirming
|
|
42
|
+
* that its work left no write in flight, since deletion may then overtake it.
|
|
43
|
+
*
|
|
44
|
+
* Resolves true when it retired the admission. Resolves false, and writes
|
|
45
|
+
* nothing, when the tenant holds no such admission: the attempt was already
|
|
46
|
+
* retired, or an id is wrong. Never call it from a
|
|
47
|
+
* `runTenantLifecycleOperation` callback or on a timer.
|
|
48
|
+
*/
|
|
49
|
+
export declare function releaseTenantLifecycleAttempt(tenantId: string, attemptId: string): Promise<boolean>;
|
|
11
50
|
/**
|
|
12
51
|
* Must succeed before any destructive tenant phase. Closure is permanent;
|
|
13
52
|
* rejection requires preserving data, never timeout-based takeover or reopening.
|
package/dist/tenant-lifecycle.js
CHANGED
|
@@ -1,38 +1,88 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TenantLifecycleReleaseError = void 0;
|
|
3
4
|
exports.runTenantLifecycleOperation = runTenantLifecycleOperation;
|
|
5
|
+
exports.releaseTenantLifecycleAttempt = releaseTenantLifecycleAttempt;
|
|
4
6
|
exports.closeTenantLifecycleAdmission = closeTenantLifecycleAdmission;
|
|
5
7
|
exports.observeTenantLifecycle = observeTenantLifecycle;
|
|
6
8
|
exports.pauseTenantLifecycleAdmission = pauseTenantLifecycleAdmission;
|
|
7
9
|
exports.resumeTenantLifecycleAdmission = resumeTenantLifecycleAdmission;
|
|
8
10
|
const node_crypto_1 = require("node:crypto");
|
|
11
|
+
const promises_1 = require("node:timers/promises");
|
|
12
|
+
const logging_1 = require("@antelopejs/interface-core/logging");
|
|
9
13
|
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
10
14
|
const tenantLifecycle_model_1 = require("./db/internal/tenantLifecycle.model");
|
|
11
15
|
const HTTP_CLIENT_ERROR_MIN = 400;
|
|
12
16
|
const HTTP_SERVER_ERROR_MIN = 500;
|
|
17
|
+
const RELEASE_ATTEMPTS = 3;
|
|
18
|
+
const RELEASE_BACKOFF_MS = 200;
|
|
13
19
|
/**
|
|
14
|
-
* Whether
|
|
15
|
-
* than an effect whose outcome is unknown.
|
|
16
|
-
* because the refusal can come from another module's copy of the API
|
|
17
|
-
* interface (a dms-saas seat limit raised from a hook, for instance).
|
|
20
|
+
* Whether a status is an HTTP 4xx: a refusal on purpose, a decision rather
|
|
21
|
+
* than an effect whose outcome is unknown.
|
|
18
22
|
*/
|
|
19
|
-
function
|
|
20
|
-
// oxlint-disable-next-line anti-slop/require-safety-comment-for-type-assertion -- Legacy refusal detection reads getStatus from any thrown value without validating its shape; adding validation would change proxy and getter behavior.
|
|
21
|
-
const getStatus = error?.getStatus;
|
|
22
|
-
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- Refusals can originate in another copy of the API; the existing callable shape check intentionally avoids instanceof.
|
|
23
|
-
if (typeof getStatus !== "function")
|
|
24
|
-
return false;
|
|
25
|
-
const status = getStatus.call(error);
|
|
23
|
+
function isClientErrorStatus(status) {
|
|
26
24
|
return status >= HTTP_CLIENT_ERROR_MIN && status < HTTP_SERVER_ERROR_MIN;
|
|
27
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The release of an invocation that finished or refused failed on every try.
|
|
28
|
+
* Its admission stays, so the deletion of `tenantId` is blocked until
|
|
29
|
+
* {@link releaseTenantLifecycleAttempt} retires `attemptId`. The `cause` is the
|
|
30
|
+
* failure of the last try.
|
|
31
|
+
*/
|
|
32
|
+
class TenantLifecycleReleaseError extends Error {
|
|
33
|
+
tenantId;
|
|
34
|
+
attemptId;
|
|
35
|
+
constructor(tenantId, attemptId, cause) {
|
|
36
|
+
super(`Tenant lifecycle release of attempt '${attemptId}' failed ${RELEASE_ATTEMPTS} times; deletion of tenant '${tenantId}' stays blocked until releaseTenantLifecycleAttempt('${tenantId}', '${attemptId}') succeeds`, { cause });
|
|
37
|
+
this.name = "TenantLifecycleReleaseError";
|
|
38
|
+
this.tenantId = tenantId;
|
|
39
|
+
this.attemptId = attemptId;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.TenantLifecycleReleaseError = TenantLifecycleReleaseError;
|
|
43
|
+
/**
|
|
44
|
+
* Releases the admission of an invocation whose effects are all known: it
|
|
45
|
+
* finished, or it refused on purpose. Releasing is idempotent, so a failed
|
|
46
|
+
* release is tried again after a pause that doubles each time, which rides out
|
|
47
|
+
* a short outage. When every try fails, the failure is logged and returned,
|
|
48
|
+
* never swallowed.
|
|
49
|
+
*/
|
|
50
|
+
async function releaseAttempt(model, tenantId, attemptId) {
|
|
51
|
+
let failure;
|
|
52
|
+
for (let attempt = 0; attempt < RELEASE_ATTEMPTS; attempt++) {
|
|
53
|
+
if (attempt > 0)
|
|
54
|
+
await (0, promises_1.setTimeout)(RELEASE_BACKOFF_MS * 2 ** (attempt - 1));
|
|
55
|
+
try {
|
|
56
|
+
await model.finish(tenantId, attemptId);
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
catch (releaseFailure) {
|
|
60
|
+
failure = releaseFailure;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const error = new TenantLifecycleReleaseError(tenantId, attemptId, failure);
|
|
64
|
+
logging_1.Logging.Error(error.message, failure);
|
|
65
|
+
return error;
|
|
66
|
+
}
|
|
28
67
|
/**
|
|
29
68
|
* Admits one invocation. Work must await every producer effect and start no
|
|
30
69
|
* detached writer. Failure retains its admission; an independent replay must
|
|
31
|
-
* never retire this invocation's identity.
|
|
70
|
+
* never retire this invocation's identity. Each call takes its own admission,
|
|
71
|
+
* so work never calls this again for the same tenant.
|
|
32
72
|
*
|
|
33
|
-
* A deliberate refusal (an HTTP 4xx)
|
|
34
|
-
* effect has none left in flight once it
|
|
35
|
-
* would only block the tenant's deletion
|
|
73
|
+
* A success, and a deliberate refusal (an HTTP 4xx), are the exceptions: work
|
|
74
|
+
* that awaits every effect has none left in flight once it finishes or
|
|
75
|
+
* refuses, so keeping the admission would only block the tenant's deletion
|
|
76
|
+
* forever. The release is tried {@link RELEASE_ATTEMPTS} times, with a pause
|
|
77
|
+
* between tries. If every try fails, the admission stays, the failure is
|
|
78
|
+
* logged and the call rejects, so the blocked deletion is reported instead of
|
|
79
|
+
* hidden: with an `AggregateError` of the refusal and a
|
|
80
|
+
* {@link TenantLifecycleReleaseError} after a refusal, with the
|
|
81
|
+
* {@link TenantLifecycleReleaseError} after a success.
|
|
82
|
+
*
|
|
83
|
+
* A refusal is read by shape, not `instanceof`, because it can come from
|
|
84
|
+
* another module's copy of the API interface (a dms-saas seat limit raised
|
|
85
|
+
* from a hook, for instance).
|
|
36
86
|
*/
|
|
37
87
|
async function runTenantLifecycleOperation(tenantId, work) {
|
|
38
88
|
const model = (0, interface_database_decorators_1.GetModel)(tenantLifecycle_model_1.TenantLifecycleModel, tenantId);
|
|
@@ -43,14 +93,43 @@ async function runTenantLifecycleOperation(tenantId, work) {
|
|
|
43
93
|
result = await work();
|
|
44
94
|
}
|
|
45
95
|
catch (error) {
|
|
46
|
-
|
|
47
|
-
|
|
96
|
+
// oxlint-disable-next-line anti-slop/require-safety-comment-for-type-assertion -- Legacy refusal detection reads getStatus from any thrown value without validating its shape; adding validation would change proxy and getter behavior.
|
|
97
|
+
const getStatus = error?.getStatus;
|
|
98
|
+
if (
|
|
99
|
+
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- Refusals can originate in another copy of the API; the existing callable shape check intentionally avoids instanceof.
|
|
100
|
+
typeof getStatus === "function" &&
|
|
101
|
+
isClientErrorStatus(getStatus.call(error))) {
|
|
102
|
+
const releaseFailure = await releaseAttempt(model, tenantId, attemptId);
|
|
103
|
+
if (releaseFailure) {
|
|
104
|
+
throw new AggregateError([error, releaseFailure], `Tenant lifecycle admission of tenant '${tenantId}' refused the work but could not release attempt '${attemptId}'; deletion of this tenant stays blocked`);
|
|
105
|
+
}
|
|
48
106
|
}
|
|
49
107
|
throw error;
|
|
50
108
|
}
|
|
51
|
-
await model
|
|
109
|
+
const releaseFailure = await releaseAttempt(model, tenantId, attemptId);
|
|
110
|
+
if (releaseFailure)
|
|
111
|
+
throw releaseFailure;
|
|
52
112
|
return result;
|
|
53
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Retires one admission by hand: the operator path for a deletion that
|
|
116
|
+
* {@link closeTenantLifecycleAdmission} reports blocked.
|
|
117
|
+
*
|
|
118
|
+
* Call it with the `tenantId` and `attemptId` of a
|
|
119
|
+
* {@link TenantLifecycleReleaseError} once the database answers again. That
|
|
120
|
+
* invocation finished or refused, so none of its effects is in flight. Any
|
|
121
|
+
* other attempt that {@link observeTenantLifecycle} lists retains its admission
|
|
122
|
+
* because its effects may be indeterminate: retire it only after confirming
|
|
123
|
+
* that its work left no write in flight, since deletion may then overtake it.
|
|
124
|
+
*
|
|
125
|
+
* Resolves true when it retired the admission. Resolves false, and writes
|
|
126
|
+
* nothing, when the tenant holds no such admission: the attempt was already
|
|
127
|
+
* retired, or an id is wrong. Never call it from a
|
|
128
|
+
* `runTenantLifecycleOperation` callback or on a timer.
|
|
129
|
+
*/
|
|
130
|
+
async function releaseTenantLifecycleAttempt(tenantId, attemptId) {
|
|
131
|
+
return (0, interface_database_decorators_1.GetModel)(tenantLifecycle_model_1.TenantLifecycleModel, tenantId).finish(tenantId, attemptId);
|
|
132
|
+
}
|
|
54
133
|
/**
|
|
55
134
|
* Must succeed before any destructive tenant phase. Closure is permanent;
|
|
56
135
|
* rejection requires preserving data, never timeout-based takeover or reopening.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenant-lifecycle.js","sourceRoot":"","sources":["../src/tenant-lifecycle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tenant-lifecycle.js","sourceRoot":"","sources":["../src/tenant-lifecycle.ts"],"names":[],"mappings":";;;AA4FA,kEA+BC;AAkBD,sEAKC;AAMD,sEAIC;AAWD,wDAUC;AAWD,sEAUC;AASD,wEAKC;AApND,6CAAyC;AACzC,mDAA2D;AAC3D,gEAA6D;AAC7D,6FAAqE;AACrE,+EAA2E;AAE3E,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAO/B;;;GAGG;AACH,SAAS,mBAAmB,CAAC,MAAc;IACzC,OAAO,MAAM,IAAI,qBAAqB,IAAI,MAAM,GAAG,qBAAqB,CAAC;AAC3E,CAAC;AAED;;;;;GAKG;AACH,MAAa,2BAA4B,SAAQ,KAAK;IAC3C,QAAQ,CAAS;IACjB,SAAS,CAAS;IAE3B,YAAY,QAAgB,EAAE,SAAiB,EAAE,KAAc;QAC7D,KAAK,CACH,wCAAwC,SAAS,YAAY,gBAAgB,+BAA+B,QAAQ,wDAAwD,QAAQ,OAAO,SAAS,aAAa,EACjN,EAAE,KAAK,EAAE,CACV,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,S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I,IAAI;QAClC,gBAAgB,EAAE,CAAC,GAAG,KAAK,CAAC,gBAAgB,CAAC;QAC7C,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,6BAA6B,CACjD,QAAgB,EAChB,SAAiB,EACjB,gBAAwB;IAExB,OAAO,IAAA,wCAAQ,EAAC,4CAAoB,EAAE,QAAQ,CAAC,CAAC,KAAK,CACnD,QAAQ,EACR,SAAS,EACT,gBAAgB,CACjB,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,8BAA8B,CAClD,QAAgB,EAChB,SAAiB;IAEjB,OAAO,IAAA,wCAAQ,EAAC,4CAAoB,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
|
+
import type { ControllerClass } from "@antelopejs/interface-api";
|
|
1
2
|
export type MaybePromise<T> = T | Promise<T>;
|
|
3
|
+
/** An image stored by key, as the image data type and `User.avatar` hold it. */
|
|
4
|
+
export interface ImageValue {
|
|
5
|
+
key: string;
|
|
6
|
+
alt?: string;
|
|
7
|
+
principal?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The page a component is placed on, as its `onCreated` hook receives it once
|
|
11
|
+
* the page registers. `PageMetadata` implements it.
|
|
12
|
+
*/
|
|
13
|
+
export interface CreatedPage {
|
|
14
|
+
/** The page controller the component is placed on. */
|
|
15
|
+
readonly target: ControllerClass;
|
|
16
|
+
/** The id and slug the page registered under, from the root category. */
|
|
17
|
+
readonly pageInfo?: {
|
|
18
|
+
readonly fullId: string;
|
|
19
|
+
readonly fullSlug: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
package/dist/uploads.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RegisteringProxy } from "@antelopejs/interface-core";
|
|
2
|
-
import type
|
|
2
|
+
import { type NativeUploadFieldRegistration, type UploadTokenClaims } from "./internal/uploads";
|
|
3
3
|
/** @internal */
|
|
4
4
|
export declare namespace internal {
|
|
5
5
|
const RegisterNativeUploadField: RegisteringProxy<(registration: NativeUploadFieldRegistration) => void>;
|
package/dist/uploads.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SignUploadToken = exports.internal = void 0;
|
|
4
4
|
exports.StampUploadFieldTokens = StampUploadFieldTokens;
|
|
5
5
|
const interface_core_1 = require("@antelopejs/interface-core");
|
|
6
|
+
const uploads_1 = require("./internal/uploads");
|
|
6
7
|
/** @internal */
|
|
7
8
|
var internal;
|
|
8
9
|
(function (internal) {
|
|
@@ -17,68 +18,44 @@ var internal;
|
|
|
17
18
|
* @internal
|
|
18
19
|
*/
|
|
19
20
|
exports.SignUploadToken = (0, interface_core_1.InterfaceFunction)();
|
|
20
|
-
|
|
21
|
+
function isTraversable(value) {
|
|
22
|
+
return !!value && typeof value === "object";
|
|
23
|
+
}
|
|
21
24
|
function isUploadFieldNode(node) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
typeof candidate.type === "string" &&
|
|
29
|
-
UPLOAD_FIELD_TYPES.has(candidate.type) &&
|
|
30
|
-
!!candidate.component &&
|
|
31
|
-
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- Preserve the serialized-node shape check before accessing the component's options.
|
|
32
|
-
typeof candidate.component === "object");
|
|
25
|
+
return (isTraversable(node) &&
|
|
26
|
+
!Array.isArray(node) &&
|
|
27
|
+
"type" in node &&
|
|
28
|
+
(node.type === "file" || node.type === "image") &&
|
|
29
|
+
"component" in node &&
|
|
30
|
+
isTraversable(node.component));
|
|
33
31
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
return Object.values(node).some(hasUploadField);
|
|
32
|
+
/** Every upload field of a serialized value, an enclosing one before the ones it holds. */
|
|
33
|
+
// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Walks every value of the serialized options a component declares, its own T, at any depth that declaration has, to find the upload fields among them.
|
|
34
|
+
function uploadFieldNodes(node) {
|
|
35
|
+
if (!isTraversable(node))
|
|
36
|
+
return [];
|
|
37
|
+
return [
|
|
38
|
+
...(isUploadFieldNode(node) ? [node] : []),
|
|
39
|
+
...Object.values(node).flatMap(uploadFieldNodes),
|
|
40
|
+
];
|
|
46
41
|
}
|
|
47
42
|
async function stampNode(node) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
options.uploadToken = await (0, exports.SignUploadToken)({
|
|
65
|
-
pageId: "",
|
|
66
|
-
componentId: "",
|
|
67
|
-
storage:
|
|
68
|
-
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- Serialized consumer storage values contribute to claims only when strings.
|
|
69
|
-
typeof options.storage === "string" ? options.storage : undefined,
|
|
70
|
-
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- Only a string serialized path is copied into upload claims.
|
|
71
|
-
path: typeof options.path === "string" ? options.path : undefined,
|
|
72
|
-
field:
|
|
73
|
-
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- Only a string attachmentField identifies the server-declared upload field.
|
|
74
|
-
typeof options.attachmentField === "string"
|
|
75
|
-
? options.attachmentField
|
|
76
|
-
: undefined,
|
|
77
|
-
visibility: options.visibility === "public" ? "public" : "private",
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
for (const value of Object.values(node))
|
|
81
|
-
await stampNode(value);
|
|
43
|
+
const options = (0, uploads_1.readUploadFieldOptions)(node);
|
|
44
|
+
options.uploadToken = await (0, exports.SignUploadToken)({
|
|
45
|
+
pageId: "",
|
|
46
|
+
componentId: "",
|
|
47
|
+
storage:
|
|
48
|
+
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- Serialized consumer storage values contribute to claims only when strings.
|
|
49
|
+
typeof options.storage === "string" ? options.storage : undefined,
|
|
50
|
+
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- Only a string serialized path is copied into upload claims.
|
|
51
|
+
path: typeof options.path === "string" ? options.path : undefined,
|
|
52
|
+
field:
|
|
53
|
+
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- Only a string attachmentField identifies the server-declared upload field.
|
|
54
|
+
typeof options.attachmentField === "string"
|
|
55
|
+
? options.attachmentField
|
|
56
|
+
: undefined,
|
|
57
|
+
visibility: options.visibility === "public" ? "public" : "private",
|
|
58
|
+
});
|
|
82
59
|
}
|
|
83
60
|
/**
|
|
84
61
|
* Stamp a signed upload token into every File/Image field found in a
|
|
@@ -95,11 +72,13 @@ async function stampNode(node) {
|
|
|
95
72
|
* start from the untransformed declaration.
|
|
96
73
|
*/
|
|
97
74
|
async function StampUploadFieldTokens(options) {
|
|
98
|
-
if (
|
|
75
|
+
if (uploadFieldNodes(options).length === 0) {
|
|
99
76
|
return options;
|
|
100
77
|
}
|
|
78
|
+
// oxlint-disable-next-line typescript/no-unsafe-assignment -- The JSON round trip clones the caller's options as any and types the clone as its T, kept by the 2026-11-02 16:00 ruling because any other clone changes the upload answer.
|
|
101
79
|
const cloned = JSON.parse(JSON.stringify(options));
|
|
102
|
-
|
|
80
|
+
for (const node of uploadFieldNodes(cloned))
|
|
81
|
+
await stampNode(node);
|
|
103
82
|
return cloned;
|
|
104
83
|
}
|
|
105
84
|
//# sourceMappingURL=uploads.js.map
|
package/dist/uploads.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploads.js","sourceRoot":"","sources":["../src/uploads.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"uploads.js","sourceRoot":"","sources":["../src/uploads.ts"],"names":[],"mappings":";;;AA2FA,wDAQC;AAnGD,+DAGoC;AACpC,gDAI4B;AAE5B,gBAAgB;AAChB,IAAiB,QAAQ,CAIxB;AAJD,WAAiB,QAAQ;IACV,kCAAyB,GAAG,IAAI,iCAAgB,EAE1D,CAAC;AACN,CAAC,EAJgB,QAAQ,wBAAR,QAAQ,QAIxB;AAED;;;;;;;GAOG;AACU,QAAA,eAAe,GAC1B,IAAA,kCAAiB,GAAkD,CAAC;AAOtE,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC9C,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAa;IACtC,OAAO,CACL,aAAa,CAAC,IAAI,CAAC;QACnB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACpB,MAAM,IAAI,IAAI;QACd,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC;QAC/C,WAAW,IAAI,IAAI;QACnB,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAC9B,CAAC;AACJ,CAAC;AAED,2FAA2F;AAC3F,oNAAoN;AACpN,SAAS,gBAAgB,CAAC,IAAa;IACrC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IACpC,OAAO;QACL,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC;KACjD,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,SAAS,CA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CAOC;AAbD,gEAA6D;AAE7D;;;GAGG;AACH,SAAgB,aAAa,CAC3B,IAAsB,EACtB,WAAmB;IAEnB,IAAI,CAAC,KAAK,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"fire-and-forget.js","sourceRoot":"","sources":["../../src/utils/fire-and-forget.ts"],"names":[],"mappings":";;AAMA,sCAOC;AAbD,gEAA6D;AAE7D;;;GAGG;AACH,SAAgB,aAAa,CAC3B,IAAsB,EACtB,WAAmB;IAEnB,IAAI,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QAC5B,iBAAO,CAAC,KAAK,CAAC,oBAAoB,WAAW,YAAY,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Class, DecoratorTarget } from "@antelopejs/interface-core/decorators";
|
|
2
|
+
/**
|
|
3
|
+
* The class a member decorator decorates: its target's `constructor`.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare function decoratedClass(target: DecoratorTarget): Class;
|
|
8
|
+
/**
|
|
9
|
+
* The prototype a class's instance members are decorated on.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
* @throws {TypeError} When the class has no prototype object.
|
|
13
|
+
*/
|
|
14
|
+
export declare function prototypeOf(owner: Class): DecoratorTarget;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decoratedClass = decoratedClass;
|
|
4
|
+
exports.prototypeOf = prototypeOf;
|
|
5
|
+
const type_check_1 = require("./type-check");
|
|
6
|
+
/**
|
|
7
|
+
* The class a member decorator decorates: its target's `constructor`.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
function decoratedClass(target) {
|
|
12
|
+
const owner = target.constructor;
|
|
13
|
+
if (!(0, type_check_1.isClass)(owner)) {
|
|
14
|
+
throw new TypeError("A member decorator applies to a class.");
|
|
15
|
+
}
|
|
16
|
+
return owner;
|
|
17
|
+
}
|
|
18
|
+
function isDecoratorTarget(value) {
|
|
19
|
+
return (typeof value === "object" &&
|
|
20
|
+
value !== null &&
|
|
21
|
+
"constructor" in value &&
|
|
22
|
+
typeof value.constructor === "function");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The prototype a class's instance members are decorated on.
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
* @throws {TypeError} When the class has no prototype object.
|
|
29
|
+
*/
|
|
30
|
+
function prototypeOf(owner) {
|
|
31
|
+
const prototype = owner.prototype;
|
|
32
|
+
if (!isDecoratorTarget(prototype)) {
|
|
33
|
+
throw new TypeError(`${owner.name} has no prototype to decorate`);
|
|
34
|
+
}
|
|
35
|
+
return prototype;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=decorated-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorated-class.js","sourceRoot":"","sources":["../../../src/utils/internal/decorated-class.ts"],"names":[],"mappings":";;AAYA,wCAMC;AAiBD,kCAMC;AApCD,6CAAuC;AAEvC;;;;GAIG;AACH,SAAgB,cAAc,CAAC,MAAuB;IACpD,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC;IACjC,IAAI,CAAC,IAAA,oBAAO,EAAC,KAAK,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,aAAa,IAAI,KAAK;QACtB,OAAO,KAAK,CAAC,WAAW,KAAK,UAAU,CACxC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,KAAY;IACtC,MAAM,SAAS,GAAY,KAAK,CAAC,SAAS,CAAC;IAC3C,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,CAAC,IAAI,+BAA+B,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Class } from "@antelopejs/interface-core/decorators";
|
|
1
2
|
declare const primitiveTypes: readonly ["string", "number", "boolean", "undefined", "bigint", "symbol"];
|
|
2
3
|
type Primitive = (typeof primitiveTypes)[number];
|
|
3
4
|
interface PrimitiveValueByTag {
|
|
@@ -21,6 +22,14 @@ export declare const isUndefined: (v: unknown) => v is undefined;
|
|
|
21
22
|
export declare const isObject: (v: unknown) => v is object;
|
|
22
23
|
/** @internal */
|
|
23
24
|
export declare const isFunction: (v: unknown) => v is (...args: unknown[]) => unknown;
|
|
25
|
+
/**
|
|
26
|
+
* Whether a value is a class: a function with an object `prototype`, which
|
|
27
|
+
* arrow functions, methods and bound functions lack. A generator function has
|
|
28
|
+
* one too, a language limit this check shares with every `prototype` test.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare const isClass: (value: unknown) => value is Class;
|
|
24
33
|
/** @internal */
|
|
25
34
|
export declare const isBigint: (v: unknown) => v is bigint;
|
|
26
35
|
/** @internal */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isJSON = exports.isDate = exports.isNull = exports.isPrimitive = exports.isSymbol = exports.isBigint = exports.isFunction = exports.isObject = exports.isUndefined = exports.isBoolean = exports.isNumber = exports.isString = void 0;
|
|
3
|
+
exports.isJSON = exports.isDate = exports.isNull = exports.isPrimitive = exports.isSymbol = exports.isBigint = exports.isClass = exports.isFunction = exports.isObject = exports.isUndefined = exports.isBoolean = exports.isNumber = exports.isString = void 0;
|
|
4
4
|
const primitiveTypes = [
|
|
5
5
|
"string",
|
|
6
6
|
"number",
|
|
@@ -9,9 +9,7 @@ const primitiveTypes = [
|
|
|
9
9
|
"bigint",
|
|
10
10
|
"symbol",
|
|
11
11
|
];
|
|
12
|
-
const createTypeGuard = (type) => (v) =>
|
|
13
|
-
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- These published primitive predicates implement JavaScript tag checks, including the legacy object/null behavior, rather than schema validation.
|
|
14
|
-
typeof v === type;
|
|
12
|
+
const createTypeGuard = (type) => (v) => typeof v === type;
|
|
15
13
|
/** @internal */
|
|
16
14
|
exports.isString = createTypeGuard("string");
|
|
17
15
|
/** @internal */
|
|
@@ -26,6 +24,17 @@ exports.isObject = createTypeGuard("object");
|
|
|
26
24
|
exports.isFunction =
|
|
27
25
|
// oxlint-disable-next-line anti-slop/no-unknown-returns -- The published function predicate promises no result shape for arbitrary callable values.
|
|
28
26
|
createTypeGuard("function");
|
|
27
|
+
/**
|
|
28
|
+
* Whether a value is a class: a function with an object `prototype`, which
|
|
29
|
+
* arrow functions, methods and bound functions lack. A generator function has
|
|
30
|
+
* one too, a language limit this check shares with every `prototype` test.
|
|
31
|
+
*
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
const isClass = (value) => typeof value === "function" &&
|
|
35
|
+
typeof value.prototype === "object" &&
|
|
36
|
+
value.prototype !== null;
|
|
37
|
+
exports.isClass = isClass;
|
|
29
38
|
/** @internal */
|
|
30
39
|
exports.isBigint = createTypeGuard("bigint");
|
|
31
40
|
/** @internal */
|
|
@@ -33,7 +42,6 @@ exports.isSymbol = createTypeGuard("symbol");
|
|
|
33
42
|
/** @internal */
|
|
34
43
|
const isPrimitive = (value) => {
|
|
35
44
|
const types = primitiveTypes;
|
|
36
|
-
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- This published predicate classifies JavaScript tags and narrows to the primitive values whose tags it accepts.
|
|
37
45
|
return types.includes(typeof value);
|
|
38
46
|
};
|
|
39
47
|
exports.isPrimitive = isPrimitive;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-check.js","sourceRoot":"","sources":["../../../src/utils/internal/type-check.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"type-check.js","sourceRoot":"","sources":["../../../src/utils/internal/type-check.ts"],"names":[],"mappings":";;;AAEA,MAAM,cAAc,GAAG;IACrB,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,WAAW;IACX,QAAQ;IACR,QAAQ;CACA,CAAC;AA6BX,MAAM,eAAe,GACnB,CAAI,IAAkB,EAAE,EAAE,CAC1B,CAAC,CAAU,EAAU,EAAE,CACrB,OAAO,CAAC,KAAK,IAAI,CAAC;AAEtB,gBAAgB;AACH,QAAA,QAAQ,GAAG,eAAe,CAAS,QAAQ,CAAC,CAAC;AAC1D,gBAAgB;AACH,QAAA,QAAQ,GAAG,eAAe,CAAS,QAAQ,CAAC,CAAC;AAC1D,gBAAgB;AACH,QAAA,SAAS,GAAG,eAAe,CAAU,SAAS,CAAC,CAAC;AAC7D,gBAAgB;AACH,QAAA,WAAW,GAAG,eAAe,CAAY,WAAW,CAAC,CAAC;AACnE,gBAAgB;AACH,QAAA,QAAQ,GAAG,eAAe,CAAS,QAAQ,CAAC,CAAC;AAC1D,gBAAgB;AACH,QAAA,UAAU;AACrB,oJAAoJ;AACpJ,eAAe,CAAkC,UAAU,CAAC,CAAC;AAC/D;;;;;;GAMG;AACI,MAAM,OAAO,GAAG,CAAC,KAAc,EAAkB,EAAE,CACxD,OAAO,KAAK,KAAK,UAAU;IAC3B,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ;IACnC,KAAK,CAAC,SAAS,KAAK,IAAI,CAAC;AAHd,QAAA,OAAO,WAGO;AAC3B,gBAAgB;AACH,QAAA,QAAQ,GAAG,eAAe,CAAS,QAAQ,CAAC,CAAC;AAC1D,gBAAgB;AACH,QAAA,QAAQ,GAAG,eAAe,CAAS,QAAQ,CAAC,CAAC;AAE1D,gBAAgB;AACT,MAAM,WAAW,GAAG,CAAC,KAAc,EAA2B,EAAE;IACrE,MAAM,KAAK,GAAsB,cAAc,CAAC;IAChD,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,CAAC,CAAC;AAHW,QAAA,WAAW,eAGtB;AAEF,gBAAgB;AACT,MAAM,MAAM,GAAG,CAAC,KAAc,EAAiB,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC;AAA3D,QAAA,MAAM,UAAqD;AAExE,gBAAgB;AACT,MAAM,MAAM,GAAG,CAAC,KAAc,EAAiB,EAAE,CACtD,KAAK,YAAY,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AAD7C,QAAA,MAAM,UACuC;AAE1D,gBAAgB;AAChB,4JAA4J;AACrJ,MAAM,MAAM,GAAG,CAAC,KAAc,EAAW,EAAE;IAChD,IAAI,CAAC,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1C,OAAO,IAAA,gBAAQ,EAAC,MAAM,CAAC,IAAI,CAAC,IAAA,cAAM,EAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAVW,QAAA,MAAM,UAUjB"}
|
|
@@ -83,4 +83,4 @@ export declare function isStringDate(value: string): boolean;
|
|
|
83
83
|
*/
|
|
84
84
|
export declare function isStringJSON(value: string): boolean;
|
|
85
85
|
/** @internal */
|
|
86
|
-
export declare
|
|
86
|
+
export declare function assertPrimitiveValue(value: unknown): asserts value is string | number | boolean | Date | null;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertPrimitiveValue = void 0;
|
|
4
3
|
exports.parseValue = parseValue;
|
|
5
4
|
exports.parseObject = parseObject;
|
|
6
5
|
exports.isStringKeyword = isStringKeyword;
|
|
7
6
|
exports.isStringNumber = isStringNumber;
|
|
8
7
|
exports.isStringDate = isStringDate;
|
|
9
8
|
exports.isStringJSON = isStringJSON;
|
|
9
|
+
exports.assertPrimitiveValue = assertPrimitiveValue;
|
|
10
10
|
const type_check_1 = require("./type-check");
|
|
11
11
|
const KEYWORD_VALUES = {
|
|
12
12
|
true: true,
|
|
@@ -15,6 +15,23 @@ const KEYWORD_VALUES = {
|
|
|
15
15
|
undefined: undefined,
|
|
16
16
|
};
|
|
17
17
|
const KEYWORD_LOOKUP = new Map(Object.entries(KEYWORD_VALUES));
|
|
18
|
+
/** What `JSON.parse` answers, read as the value it holds. */
|
|
19
|
+
function parseJsonText(text) {
|
|
20
|
+
const parsed = JSON.parse(text);
|
|
21
|
+
if ((0, type_check_1.isString)(parsed) ||
|
|
22
|
+
(0, type_check_1.isNumber)(parsed) ||
|
|
23
|
+
(0, type_check_1.isBoolean)(parsed) ||
|
|
24
|
+
(0, type_check_1.isNull)(parsed)) {
|
|
25
|
+
return parsed;
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(parsed)) {
|
|
28
|
+
const items = parsed;
|
|
29
|
+
return items;
|
|
30
|
+
}
|
|
31
|
+
if ((0, type_check_1.isObject)(parsed))
|
|
32
|
+
return Object.fromEntries(Object.entries(parsed));
|
|
33
|
+
throw new TypeError("JSON text parsed to a value JSON cannot hold");
|
|
34
|
+
}
|
|
18
35
|
const STRING_TYPE_PARSERS = [
|
|
19
36
|
{
|
|
20
37
|
test: isStringKeyword,
|
|
@@ -30,7 +47,7 @@ const STRING_TYPE_PARSERS = [
|
|
|
30
47
|
},
|
|
31
48
|
{
|
|
32
49
|
test: isStringJSON,
|
|
33
|
-
parse:
|
|
50
|
+
parse: parseJsonText,
|
|
34
51
|
},
|
|
35
52
|
];
|
|
36
53
|
/**
|
|
@@ -152,14 +169,10 @@ const PRIMITIVE_TYPE_VALIDATORS = [
|
|
|
152
169
|
type_check_1.isNull,
|
|
153
170
|
];
|
|
154
171
|
/** @internal */
|
|
155
|
-
|
|
156
|
-
const assertPrimitiveValue = (value) => {
|
|
172
|
+
function assertPrimitiveValue(value) {
|
|
157
173
|
if (PRIMITIVE_TYPE_VALIDATORS.some((test) => test(value))) {
|
|
158
174
|
return;
|
|
159
175
|
}
|
|
160
|
-
throw new Error(
|
|
161
|
-
|
|
162
|
-
`Value must be a string, number, boolean, or Date for is comparison. Got: ${typeof value}`);
|
|
163
|
-
};
|
|
164
|
-
exports.assertPrimitiveValue = assertPrimitiveValue;
|
|
176
|
+
throw new Error(`Value must be a string, number, boolean, or Date for is comparison. Got: ${typeof value}`);
|
|
177
|
+
}
|
|
165
178
|
//# sourceMappingURL=value-parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value-parser.js","sourceRoot":"","sources":["../../../src/utils/internal/value-parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"value-parser.js","sourceRoot":"","sources":["../../../src/utils/internal/value-parser.ts"],"names":[],"mappings":";;AAqFA,gCAOC;AAcD,kCASC;AAYD,0CAEC;AAaD,wCAEC;AAaD,oCAMC;AAcD,oCAOC;AAUD,oDASC;AA3MD,6CAOsB;AActB,MAAM,cAAc,GAAG;IACrB,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,IAAI;IACV,SAAS,EAAE,SAAS;CACrB,CAAC;AAEF,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;AAE/D,6DAA6D;AAC7D,SAAS,aAAa,CAAC,IAAY;IACjC,MAAM,MAAM,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