@wildo-ai/saas-models 1.1.2 → 1.1.3
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/dist/esm/applications/applications-context.schemas.d.ts +14 -10
- package/dist/esm/applications/applications-context.schemas.d.ts.map +1 -1
- package/dist/esm/applications/applications.shared.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/applications/applications.shared.resources-config.schemas.js +4 -3
- package/dist/esm/applications/applications.shared.resources-config.schemas.js.map +1 -1
- package/dist/esm/billing/billing-configuration.shared.schemas.d.ts +0 -4
- package/dist/esm/billing/billing-configuration.shared.schemas.d.ts.map +1 -1
- package/dist/esm/billing/billing-configuration.shared.schemas.js +59 -17
- package/dist/esm/billing/billing-configuration.shared.schemas.js.map +1 -1
- package/dist/esm/billing/billing-enums.shared.schemas.d.ts +77 -21
- package/dist/esm/billing/billing-enums.shared.schemas.d.ts.map +1 -1
- package/dist/esm/billing/billing-enums.shared.schemas.js +85 -23
- package/dist/esm/billing/billing-enums.shared.schemas.js.map +1 -1
- package/dist/esm/billing/billing-types.shared.schemas.d.ts +3 -3
- package/dist/esm/billing/price.shared.schemas.d.ts.map +1 -1
- package/dist/esm/billing/price.shared.schemas.js +7 -1
- package/dist/esm/billing/price.shared.schemas.js.map +1 -1
- package/dist/esm/billing/product-behavior-policy.shared.schemas.d.ts.map +1 -1
- package/dist/esm/billing/product-behavior-policy.shared.schemas.js +52 -11
- package/dist/esm/billing/product-behavior-policy.shared.schemas.js.map +1 -1
- package/dist/esm/billing/product-definition.shared.schemas.d.ts +2 -2
- package/dist/esm/billing/product.shared.resources-config.schemas.d.ts +2 -2
- package/dist/esm/billing/product.shared.schemas.d.ts +2 -2
- package/dist/esm/billing/product.shared.schemas.d.ts.map +1 -1
- package/dist/esm/billing/product.shared.schemas.js +7 -3
- package/dist/esm/billing/product.shared.schemas.js.map +1 -1
- package/dist/esm/billing/subscription.shared.resources-config.schemas.d.ts +1 -1
- package/dist/esm/billing/subscription.shared.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/billing/subscription.shared.resources-config.schemas.js +15 -1
- package/dist/esm/billing/subscription.shared.resources-config.schemas.js.map +1 -1
- package/dist/esm/billing/usage-record.shared.schemas.d.ts +7 -3
- package/dist/esm/billing/usage-record.shared.schemas.d.ts.map +1 -1
- package/dist/esm/billing/usage-record.shared.schemas.js +22 -3
- package/dist/esm/billing/usage-record.shared.schemas.js.map +1 -1
- package/dist/esm/companion/provider-discovery.shared.schemas.d.ts +69 -2
- package/dist/esm/companion/provider-discovery.shared.schemas.d.ts.map +1 -1
- package/dist/esm/companion/provider-discovery.shared.schemas.js +20 -1
- package/dist/esm/companion/provider-discovery.shared.schemas.js.map +1 -1
- package/dist/esm/compliance/audit-trails/application-audit-logs.shared.resources-config.schemas.d.ts +85 -0
- package/dist/esm/compliance/audit-trails/application-audit-logs.shared.resources-config.schemas.d.ts.map +1 -0
- package/dist/esm/compliance/audit-trails/application-audit-logs.shared.resources-config.schemas.js +157 -0
- package/dist/esm/compliance/audit-trails/application-audit-logs.shared.resources-config.schemas.js.map +1 -0
- package/dist/esm/compliance/audit-trails/audit-trail-config.shared.schemas.d.ts +23 -0
- package/dist/esm/compliance/audit-trails/audit-trail-config.shared.schemas.d.ts.map +1 -1
- package/dist/esm/compliance/audit-trails/audit-trail-config.shared.schemas.js +56 -0
- package/dist/esm/compliance/audit-trails/audit-trail-config.shared.schemas.js.map +1 -1
- package/dist/esm/compliance/audit-trails/auditable-events.shared.schema.d.ts +480 -20
- package/dist/esm/compliance/audit-trails/auditable-events.shared.schema.d.ts.map +1 -1
- package/dist/esm/compliance/audit-trails/auditable-events.shared.schema.js +547 -23
- package/dist/esm/compliance/audit-trails/auditable-events.shared.schema.js.map +1 -1
- package/dist/esm/compliance/audit-trails/security-audit-event-envelope.shared.schema.d.ts.map +1 -1
- package/dist/esm/compliance/audit-trails/security-audit-event-envelope.shared.schema.js +82 -3
- package/dist/esm/compliance/audit-trails/security-audit-event-envelope.shared.schema.js.map +1 -1
- package/dist/esm/compliance/privacy/operating-jurisdictions.shared.schemas.d.ts +31 -30
- package/dist/esm/compliance/privacy/operating-jurisdictions.shared.schemas.d.ts.map +1 -1
- package/dist/esm/compliance/privacy/operating-jurisdictions.shared.schemas.js +98 -3
- package/dist/esm/compliance/privacy/operating-jurisdictions.shared.schemas.js.map +1 -1
- package/dist/esm/compliance/privacy/privacy.shared.schemas.d.ts +17 -0
- package/dist/esm/compliance/privacy/privacy.shared.schemas.d.ts.map +1 -1
- package/dist/esm/compliance/privacy/privacy.shared.schemas.js +27 -4
- package/dist/esm/compliance/privacy/privacy.shared.schemas.js.map +1 -1
- package/dist/esm/compliance/privacy/redaction.shared.schemas.d.ts +82 -29
- package/dist/esm/compliance/privacy/redaction.shared.schemas.d.ts.map +1 -1
- package/dist/esm/compliance/privacy/redaction.shared.schemas.js +95 -29
- package/dist/esm/compliance/privacy/redaction.shared.schemas.js.map +1 -1
- package/dist/esm/compliance/privacy/subject-export.shared.schemas.d.ts.map +1 -1
- package/dist/esm/compliance/privacy/subject-export.shared.schemas.js +12 -5
- package/dist/esm/compliance/privacy/subject-export.shared.schemas.js.map +1 -1
- package/dist/esm/config/analytics-value-moments.shared.schemas.d.ts +21 -0
- package/dist/esm/config/analytics-value-moments.shared.schemas.d.ts.map +1 -1
- package/dist/esm/config/analytics-value-moments.shared.schemas.js +20 -0
- package/dist/esm/config/analytics-value-moments.shared.schemas.js.map +1 -1
- package/dist/esm/config/app-configuration-shared.shared.schemas.d.ts +7 -5
- package/dist/esm/config/app-configuration-shared.shared.schemas.d.ts.map +1 -1
- package/dist/esm/config/auth-config-resolution.shared.utils.d.ts +8 -1
- package/dist/esm/config/auth-config-resolution.shared.utils.d.ts.map +1 -1
- package/dist/esm/config/auth-config-resolution.shared.utils.js +29 -0
- package/dist/esm/config/auth-config-resolution.shared.utils.js.map +1 -1
- package/dist/esm/config/entity-identity-config.shared.schemas.d.ts +95 -17
- package/dist/esm/config/entity-identity-config.shared.schemas.d.ts.map +1 -1
- package/dist/esm/config/entity-identity-config.shared.schemas.js +86 -8
- package/dist/esm/config/entity-identity-config.shared.schemas.js.map +1 -1
- package/dist/esm/config/frontend/chart-definition.shared.schemas.d.ts +12 -12
- package/dist/esm/errors/errors.custom-message-ref.shared.definitions.d.ts +28 -0
- package/dist/esm/errors/errors.custom-message-ref.shared.definitions.d.ts.map +1 -1
- package/dist/esm/errors/errors.custom-message-ref.shared.definitions.js +28 -0
- package/dist/esm/errors/errors.custom-message-ref.shared.definitions.js.map +1 -1
- package/dist/esm/external-data/external-data-pipeline.shared.schemas.d.ts +45 -12
- package/dist/esm/external-data/external-data-pipeline.shared.schemas.d.ts.map +1 -1
- package/dist/esm/external-data/external-data-pipeline.shared.schemas.js.map +1 -1
- package/dist/esm/external-providers/engine-capabilities.shared.schemas.d.ts +103 -58
- package/dist/esm/external-providers/engine-capabilities.shared.schemas.d.ts.map +1 -1
- package/dist/esm/external-providers/engine-capabilities.shared.schemas.js +176 -15
- package/dist/esm/external-providers/engine-capabilities.shared.schemas.js.map +1 -1
- package/dist/esm/external-providers/engine-capability-resolution-mode.shared.d.ts +15 -3
- package/dist/esm/external-providers/engine-capability-resolution-mode.shared.d.ts.map +1 -1
- package/dist/esm/external-providers/engine-capability-resolution-mode.shared.js +32 -5
- package/dist/esm/external-providers/engine-capability-resolution-mode.shared.js.map +1 -1
- package/dist/esm/external-providers/frontend-bootstrap.shared.schemas.d.ts +83 -7
- package/dist/esm/external-providers/frontend-bootstrap.shared.schemas.d.ts.map +1 -1
- package/dist/esm/external-providers/frontend-capability-public-config.shared.schemas.d.ts +59 -0
- package/dist/esm/external-providers/frontend-capability-public-config.shared.schemas.d.ts.map +1 -0
- package/dist/esm/external-providers/frontend-capability-public-config.shared.schemas.js +61 -0
- package/dist/esm/external-providers/frontend-capability-public-config.shared.schemas.js.map +1 -0
- package/dist/esm/external-providers/frontend-capability-runtime.shared.types.d.ts +97 -0
- package/dist/esm/external-providers/frontend-capability-runtime.shared.types.d.ts.map +1 -0
- package/dist/esm/external-providers/frontend-capability-runtime.shared.types.js +41 -0
- package/dist/esm/external-providers/frontend-capability-runtime.shared.types.js.map +1 -0
- package/dist/esm/external-providers/frontend-provider-entry.shared.schemas.d.ts +148 -2
- package/dist/esm/external-providers/frontend-provider-entry.shared.schemas.d.ts.map +1 -1
- package/dist/esm/external-providers/frontend-provider-entry.shared.schemas.js +56 -1
- package/dist/esm/external-providers/frontend-provider-entry.shared.schemas.js.map +1 -1
- package/dist/esm/external-providers/provider-capability.shared.schemas.d.ts +5 -28
- package/dist/esm/external-providers/provider-capability.shared.schemas.d.ts.map +1 -1
- package/dist/esm/external-providers/provider-capability.shared.schemas.js +4 -2
- package/dist/esm/external-providers/provider-capability.shared.schemas.js.map +1 -1
- package/dist/esm/external-providers/provider-compliance-profile.shared.schemas.d.ts +18 -8
- package/dist/esm/external-providers/provider-compliance-profile.shared.schemas.d.ts.map +1 -1
- package/dist/esm/external-providers/provider-compliance-profile.shared.schemas.js +9 -4
- package/dist/esm/external-providers/provider-compliance-profile.shared.schemas.js.map +1 -1
- package/dist/esm/external-providers/provider-frontend-surface.shared.schemas.d.ts +338 -0
- package/dist/esm/external-providers/provider-frontend-surface.shared.schemas.d.ts.map +1 -0
- package/dist/esm/external-providers/provider-frontend-surface.shared.schemas.js +332 -0
- package/dist/esm/external-providers/provider-frontend-surface.shared.schemas.js.map +1 -0
- package/dist/esm/external-providers/provider-metadata.shared.schemas.d.ts +178 -9
- package/dist/esm/external-providers/provider-metadata.shared.schemas.d.ts.map +1 -1
- package/dist/esm/external-providers/provider-metadata.shared.schemas.js +181 -9
- package/dist/esm/external-providers/provider-metadata.shared.schemas.js.map +1 -1
- package/dist/esm/external-providers/provider-protocol.shared.schemas.d.ts +7 -5
- package/dist/esm/external-providers/provider-protocol.shared.schemas.d.ts.map +1 -1
- package/dist/esm/external-providers/provider-protocol.shared.schemas.js +7 -5
- package/dist/esm/external-providers/provider-protocol.shared.schemas.js.map +1 -1
- package/dist/esm/external-providers/provider-tier-rule.shared.utils.d.ts +40 -0
- package/dist/esm/external-providers/provider-tier-rule.shared.utils.d.ts.map +1 -0
- package/dist/esm/external-providers/provider-tier-rule.shared.utils.js +80 -0
- package/dist/esm/external-providers/provider-tier-rule.shared.utils.js.map +1 -0
- package/dist/esm/features/core-feature-definitions.shared.d.ts.map +1 -1
- package/dist/esm/features/core-feature-definitions.shared.js +7 -1
- package/dist/esm/features/core-feature-definitions.shared.js.map +1 -1
- package/dist/esm/features/feature-builders.shared.d.ts +32 -0
- package/dist/esm/features/feature-builders.shared.d.ts.map +1 -1
- package/dist/esm/features/feature-builders.shared.js +32 -0
- package/dist/esm/features/feature-builders.shared.js.map +1 -1
- package/dist/esm/files/file-upload-grant.shared.schemas.d.ts +14 -2
- package/dist/esm/files/file-upload-grant.shared.schemas.d.ts.map +1 -1
- package/dist/esm/files/file-upload-grant.shared.schemas.js +44 -5
- package/dist/esm/files/file-upload-grant.shared.schemas.js.map +1 -1
- package/dist/esm/files/files.shared.schemas.d.ts +15 -8
- package/dist/esm/files/files.shared.schemas.d.ts.map +1 -1
- package/dist/esm/files/files.shared.schemas.js +15 -8
- package/dist/esm/files/files.shared.schemas.js.map +1 -1
- package/dist/esm/flows-actors/actors.shared.schemas.d.ts.map +1 -1
- package/dist/esm/flows-actors/actors.shared.schemas.js +3 -2
- package/dist/esm/flows-actors/actors.shared.schemas.js.map +1 -1
- package/dist/esm/flows-actors/agents.shared.schemas.d.ts +54 -5
- package/dist/esm/flows-actors/agents.shared.schemas.d.ts.map +1 -1
- package/dist/esm/flows-actors/agents.shared.schemas.js.map +1 -1
- package/dist/esm/flows-actors/apps-blueprint/apps-blueprint.shared.schemas.d.ts +6 -6
- package/dist/esm/flows-actors/deliberation.shared.schemas.d.ts +0 -3
- package/dist/esm/flows-actors/deliberation.shared.schemas.d.ts.map +1 -1
- package/dist/esm/flows-actors/deliberation.shared.schemas.js +0 -5
- package/dist/esm/flows-actors/deliberation.shared.schemas.js.map +1 -1
- package/dist/esm/flows-actors/flows-actors-execution.shared.schemas.d.ts +14 -0
- package/dist/esm/flows-actors/flows-actors-execution.shared.schemas.d.ts.map +1 -1
- package/dist/esm/flows-actors/flows-actors-execution.shared.schemas.js +40 -3
- package/dist/esm/flows-actors/flows-actors-execution.shared.schemas.js.map +1 -1
- package/dist/esm/flows-actors/flows-actors.commons.shared.schemas.d.ts +19 -0
- package/dist/esm/flows-actors/flows-actors.commons.shared.schemas.d.ts.map +1 -1
- package/dist/esm/flows-actors/flows-actors.commons.shared.schemas.js +33 -0
- package/dist/esm/flows-actors/flows-actors.commons.shared.schemas.js.map +1 -1
- package/dist/esm/flows-actors/flows-actors.io.shared.schemas.d.ts +14 -9
- package/dist/esm/flows-actors/flows-actors.io.shared.schemas.d.ts.map +1 -1
- package/dist/esm/flows-actors/flows-actors.io.shared.schemas.js +14 -9
- package/dist/esm/flows-actors/flows-actors.io.shared.schemas.js.map +1 -1
- package/dist/esm/flows-actors/flows-actors.system.shared.schemas.d.ts.map +1 -1
- package/dist/esm/flows-actors/flows-actors.system.shared.schemas.js +3 -2
- package/dist/esm/flows-actors/flows-actors.system.shared.schemas.js.map +1 -1
- package/dist/esm/flows-actors/flows.shared.schemas.d.ts.map +1 -1
- package/dist/esm/flows-actors/flows.shared.schemas.js +3 -2
- package/dist/esm/flows-actors/flows.shared.schemas.js.map +1 -1
- package/dist/esm/flows-actors/mcp-servers.shared.schemas.d.ts +128 -0
- package/dist/esm/flows-actors/mcp-servers.shared.schemas.d.ts.map +1 -0
- package/dist/esm/flows-actors/mcp-servers.shared.schemas.js +142 -0
- package/dist/esm/flows-actors/mcp-servers.shared.schemas.js.map +1 -0
- package/dist/esm/flows-actors/meta-workflows/budget-authority.meta-workflows.shared.schemas.d.ts +0 -3
- package/dist/esm/flows-actors/meta-workflows/budget-authority.meta-workflows.shared.schemas.d.ts.map +1 -1
- package/dist/esm/flows-actors/meta-workflows/budget-authority.meta-workflows.shared.schemas.js +1 -4
- package/dist/esm/flows-actors/meta-workflows/budget-authority.meta-workflows.shared.schemas.js.map +1 -1
- package/dist/esm/flows-actors/meta-workflows/context-selection.meta-workflows.shared.schemas.d.ts +0 -16
- package/dist/esm/flows-actors/meta-workflows/context-selection.meta-workflows.shared.schemas.d.ts.map +1 -1
- package/dist/esm/flows-actors/meta-workflows/context-selection.meta-workflows.shared.schemas.js +1 -17
- package/dist/esm/flows-actors/meta-workflows/context-selection.meta-workflows.shared.schemas.js.map +1 -1
- package/dist/esm/flows-actors/meta-workflows/decisions.meta-workflows.shared.schemas.d.ts +3 -3
- package/dist/esm/flows-actors/meta-workflows/decisions.meta-workflows.shared.schemas.js +3 -3
- package/dist/esm/flows-actors/meta-workflows/decisions.meta-workflows.shared.schemas.js.map +1 -1
- package/dist/esm/flows-actors/meta-workflows/execution-binding-common.meta-workflows.shared.schemas.d.ts +2 -8
- package/dist/esm/flows-actors/meta-workflows/execution-binding-common.meta-workflows.shared.schemas.d.ts.map +1 -1
- package/dist/esm/flows-actors/meta-workflows/execution-binding-common.meta-workflows.shared.schemas.js +4 -15
- package/dist/esm/flows-actors/meta-workflows/execution-binding-common.meta-workflows.shared.schemas.js.map +1 -1
- package/dist/esm/guidance/guidance-state.shared.utils.d.ts.map +1 -1
- package/dist/esm/guidance/guidance-state.shared.utils.js +1 -0
- package/dist/esm/guidance/guidance-state.shared.utils.js.map +1 -1
- package/dist/esm/guidance/progression-state.shared.resources-config.schemas.d.ts +8 -0
- package/dist/esm/guidance/progression-state.shared.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/guidance/progression-state.shared.schemas.d.ts +46 -0
- package/dist/esm/guidance/progression-state.shared.schemas.d.ts.map +1 -1
- package/dist/esm/guidance/progression-state.shared.schemas.js +49 -0
- package/dist/esm/guidance/progression-state.shared.schemas.js.map +1 -1
- package/dist/esm/http-api-binding/http-api-binding.shared.schemas.d.ts +320 -50
- package/dist/esm/http-api-binding/http-api-binding.shared.schemas.d.ts.map +1 -1
- package/dist/esm/http-api-binding/http-api-binding.shared.schemas.js +137 -36
- package/dist/esm/http-api-binding/http-api-binding.shared.schemas.js.map +1 -1
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/notifications/email/email-template-registry.shared.schemas.d.ts +11 -2
- package/dist/esm/notifications/email/email-template-registry.shared.schemas.d.ts.map +1 -1
- package/dist/esm/notifications/email/email-template-registry.shared.schemas.js.map +1 -1
- package/dist/esm/notifications/email/email-template.shared.enums.d.ts +15 -0
- package/dist/esm/notifications/email/email-template.shared.enums.d.ts.map +1 -1
- package/dist/esm/notifications/email/email-template.shared.enums.js +15 -0
- package/dist/esm/notifications/email/email-template.shared.enums.js.map +1 -1
- package/dist/esm/notifications/m2m/webhook-config.shared.resources-config.schemas.d.ts +1 -0
- package/dist/esm/notifications/m2m/webhook-config.shared.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/notifications/m2m/webhook-config.shared.resources-config.schemas.js +19 -0
- package/dist/esm/notifications/m2m/webhook-config.shared.resources-config.schemas.js.map +1 -1
- package/dist/esm/notifications/m2m/webhook-config.shared.schemas.d.ts +30 -0
- package/dist/esm/notifications/m2m/webhook-config.shared.schemas.d.ts.map +1 -1
- package/dist/esm/notifications/m2m/webhook-config.shared.schemas.js +65 -1
- package/dist/esm/notifications/m2m/webhook-config.shared.schemas.js.map +1 -1
- package/dist/esm/notifications/notification-badges.core.definitions.d.ts +6 -4
- package/dist/esm/notifications/notification-badges.core.definitions.d.ts.map +1 -1
- package/dist/esm/notifications/notification-badges.core.definitions.js +6 -4
- package/dist/esm/notifications/notification-badges.core.definitions.js.map +1 -1
- package/dist/esm/notifications/notification-badges.schemas.d.ts +167 -5
- package/dist/esm/notifications/notification-badges.schemas.d.ts.map +1 -1
- package/dist/esm/notifications/notification-badges.schemas.js +191 -6
- package/dist/esm/notifications/notification-badges.schemas.js.map +1 -1
- package/dist/esm/notifications/notifications.shared.schemas.d.ts +107 -0
- package/dist/esm/notifications/notifications.shared.schemas.d.ts.map +1 -1
- package/dist/esm/notifications/notifications.shared.schemas.js +149 -1
- package/dist/esm/notifications/notifications.shared.schemas.js.map +1 -1
- package/dist/esm/organizations/organization-notifications.shared.schemas.d.ts.map +1 -1
- package/dist/esm/organizations/organization-notifications.shared.schemas.js +22 -1
- package/dist/esm/organizations/organization-notifications.shared.schemas.js.map +1 -1
- package/dist/esm/organizations/organization-preferences.shared.schemas.d.ts +26 -0
- package/dist/esm/organizations/organization-preferences.shared.schemas.d.ts.map +1 -1
- package/dist/esm/organizations/organization-preferences.shared.schemas.js +25 -0
- package/dist/esm/organizations/organization-preferences.shared.schemas.js.map +1 -1
- package/dist/esm/organizations/organization-profile.shared.schemas.d.ts +25 -0
- package/dist/esm/organizations/organization-profile.shared.schemas.d.ts.map +1 -1
- package/dist/esm/organizations/organization-profile.shared.schemas.js +42 -17
- package/dist/esm/organizations/organization-profile.shared.schemas.js.map +1 -1
- package/dist/esm/organizations/organization-unit-narrowing.shared.d.ts +3 -2
- package/dist/esm/organizations/organization-unit-narrowing.shared.d.ts.map +1 -1
- package/dist/esm/organizations/organization-unit-narrowing.shared.js +9 -2
- package/dist/esm/organizations/organization-unit-narrowing.shared.js.map +1 -1
- package/dist/esm/organizations/organizations.shared.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/organizations/organizations.shared.resources-config.schemas.js +18 -3
- package/dist/esm/organizations/organizations.shared.resources-config.schemas.js.map +1 -1
- package/dist/esm/public-runtime/index.d.ts +49 -2
- package/dist/esm/public-runtime/index.d.ts.map +1 -1
- package/dist/esm/public-runtime/index.js +48 -1
- package/dist/esm/public-runtime/index.js.map +1 -1
- package/dist/esm/queue/jobs.shared.resources-config.schemas.d.ts +6 -5
- package/dist/esm/queue/jobs.shared.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/queue/jobs.shared.resources-config.schemas.js +6 -5
- package/dist/esm/queue/jobs.shared.resources-config.schemas.js.map +1 -1
- package/dist/esm/queue/jobs.shared.schemas.d.ts +16 -3
- package/dist/esm/queue/jobs.shared.schemas.d.ts.map +1 -1
- package/dist/esm/queue/jobs.shared.schemas.js +16 -3
- package/dist/esm/queue/jobs.shared.schemas.js.map +1 -1
- package/dist/esm/requests/manual-controllers-routes-documentation.d.ts +137 -0
- package/dist/esm/requests/manual-controllers-routes-documentation.d.ts.map +1 -0
- package/dist/esm/requests/manual-controllers-routes-documentation.js +1201 -0
- package/dist/esm/requests/manual-controllers-routes-documentation.js.map +1 -0
- package/dist/esm/requests/manual-controllers-routes-urls.d.ts +67 -0
- package/dist/esm/requests/manual-controllers-routes-urls.d.ts.map +1 -1
- package/dist/esm/requests/manual-controllers-routes-urls.js +78 -0
- package/dist/esm/requests/manual-controllers-routes-urls.js.map +1 -1
- package/dist/esm/requests/rate-limits.shared.schemas.d.ts +11 -1
- package/dist/esm/requests/rate-limits.shared.schemas.d.ts.map +1 -1
- package/dist/esm/requests/rate-limits.shared.schemas.js +11 -1
- package/dist/esm/requests/rate-limits.shared.schemas.js.map +1 -1
- package/dist/esm/requests/websocket.shared.schemas.d.ts +27 -4
- package/dist/esm/requests/websocket.shared.schemas.d.ts.map +1 -1
- package/dist/esm/requests/websocket.shared.schemas.js +35 -0
- package/dist/esm/requests/websocket.shared.schemas.js.map +1 -1
- package/dist/esm/resources/resources-config.shared.factory.d.ts +1 -0
- package/dist/esm/resources/resources-config.shared.factory.d.ts.map +1 -1
- package/dist/esm/resources/resources-config.shared.factory.js +105 -20
- package/dist/esm/resources/resources-config.shared.factory.js.map +1 -1
- package/dist/esm/resources/resources-config.shared.schemas.d.ts +254 -72
- package/dist/esm/resources/resources-config.shared.schemas.d.ts.map +1 -1
- package/dist/esm/resources/resources-config.shared.schemas.js.map +1 -1
- package/dist/esm/resources/resources-registry.shared.core.definitions.d.ts.map +1 -1
- package/dist/esm/resources/resources-registry.shared.core.definitions.js +97 -5
- package/dist/esm/resources/resources-registry.shared.core.definitions.js.map +1 -1
- package/dist/esm/resources/resources-relationships.shared.factory.d.ts.map +1 -1
- package/dist/esm/resources/resources-relationships.shared.factory.js +15 -0
- package/dist/esm/resources/resources-relationships.shared.factory.js.map +1 -1
- package/dist/esm/resources/resources.shared.core.definitions.d.ts +37 -0
- package/dist/esm/resources/resources.shared.core.definitions.d.ts.map +1 -1
- package/dist/esm/resources/resources.shared.core.definitions.js +51 -0
- package/dist/esm/resources/resources.shared.core.definitions.js.map +1 -1
- package/dist/esm/resources/resources.shared.schemas.d.ts +11 -2
- package/dist/esm/resources/resources.shared.schemas.d.ts.map +1 -1
- package/dist/esm/resources/resources.shared.schemas.js +34 -3
- package/dist/esm/resources/resources.shared.schemas.js.map +1 -1
- package/dist/esm/resources/utils/field-value-disclosure.utils.d.ts +51 -0
- package/dist/esm/resources/utils/field-value-disclosure.utils.d.ts.map +1 -0
- package/dist/esm/resources/utils/field-value-disclosure.utils.js +53 -0
- package/dist/esm/resources/utils/field-value-disclosure.utils.js.map +1 -0
- package/dist/esm/resources/utils/resources-summary.utils.d.ts +16 -2
- package/dist/esm/resources/utils/resources-summary.utils.d.ts.map +1 -1
- package/dist/esm/resources/utils/resources-summary.utils.js +19 -5
- package/dist/esm/resources/utils/resources-summary.utils.js.map +1 -1
- package/dist/esm/resources/utils/shared-persistence-collection.utils.d.ts.map +1 -1
- package/dist/esm/resources/utils/shared-persistence-collection.utils.js +11 -0
- package/dist/esm/resources/utils/shared-persistence-collection.utils.js.map +1 -1
- package/dist/esm/runtime/domain-module.shared.definitions.d.ts +25 -0
- package/dist/esm/runtime/domain-module.shared.definitions.d.ts.map +1 -1
- package/dist/esm/runtime/domain-module.shared.definitions.js.map +1 -1
- package/dist/esm/security/api-keys/api-keys-application.shared.resources-config.schemas.d.ts +1 -0
- package/dist/esm/security/api-keys/api-keys-application.shared.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/security/api-keys/api-keys-application.shared.resources-config.schemas.js +38 -0
- package/dist/esm/security/api-keys/api-keys-application.shared.resources-config.schemas.js.map +1 -1
- package/dist/esm/security/api-keys/api-keys-organization.shared.resources-config.schemas.d.ts +1 -0
- package/dist/esm/security/api-keys/api-keys-organization.shared.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/security/api-keys/api-keys-organization.shared.resources-config.schemas.js +38 -0
- package/dist/esm/security/api-keys/api-keys-organization.shared.resources-config.schemas.js.map +1 -1
- package/dist/esm/security/authentications/authentication.shared.dto.schemas.d.ts +4 -11
- package/dist/esm/security/authentications/authentication.shared.dto.schemas.d.ts.map +1 -1
- package/dist/esm/security/authentications/authentication.shared.dto.schemas.js +0 -1
- package/dist/esm/security/authentications/authentication.shared.dto.schemas.js.map +1 -1
- package/dist/esm/security/authentications/authentication.shared.schemas.d.ts +84 -5
- package/dist/esm/security/authentications/authentication.shared.schemas.d.ts.map +1 -1
- package/dist/esm/security/authentications/authentication.shared.schemas.js +83 -3
- package/dist/esm/security/authentications/authentication.shared.schemas.js.map +1 -1
- package/dist/esm/security/authentications/registration.shared.dto.schemas.d.ts +1 -0
- package/dist/esm/security/authentications/registration.shared.dto.schemas.d.ts.map +1 -1
- package/dist/esm/security/authentications/registration.shared.dto.schemas.js +11 -0
- package/dist/esm/security/authentications/registration.shared.dto.schemas.js.map +1 -1
- package/dist/esm/security/authentications/scim/scim-provisioning-config.shared.schemas.d.ts +15 -0
- package/dist/esm/security/authentications/scim/scim-provisioning-config.shared.schemas.d.ts.map +1 -1
- package/dist/esm/security/authentications/scim/scim-provisioning-config.shared.schemas.js +21 -4
- package/dist/esm/security/authentications/scim/scim-provisioning-config.shared.schemas.js.map +1 -1
- package/dist/esm/security/authentications/sso/sso-config.shared.resources-config.schemas.d.ts +61 -1
- package/dist/esm/security/authentications/sso/sso-config.shared.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/security/authentications/sso/sso-config.shared.resources-config.schemas.js +208 -6
- package/dist/esm/security/authentications/sso/sso-config.shared.resources-config.schemas.js.map +1 -1
- package/dist/esm/security/authentications/sso/sso-config.shared.schemas.d.ts +37 -27
- package/dist/esm/security/authentications/sso/sso-config.shared.schemas.d.ts.map +1 -1
- package/dist/esm/security/authentications/sso/sso-config.shared.schemas.js +134 -12
- package/dist/esm/security/authentications/sso/sso-config.shared.schemas.js.map +1 -1
- package/dist/esm/security/authentications/sso/sso-connection.shared.schemas.d.ts +0 -6
- package/dist/esm/security/authentications/sso/sso-connection.shared.schemas.d.ts.map +1 -1
- package/dist/esm/security/authentications/sso/sso-connection.shared.schemas.js +17 -8
- package/dist/esm/security/authentications/sso/sso-connection.shared.schemas.js.map +1 -1
- package/dist/esm/security/authorizations/platform-access-grants.shared.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/security/authorizations/platform-access-grants.shared.resources-config.schemas.js +27 -0
- package/dist/esm/security/authorizations/platform-access-grants.shared.resources-config.schemas.js.map +1 -1
- package/dist/esm/security/authorizations/platform-access-grants.shared.schemas.d.ts +52 -7
- package/dist/esm/security/authorizations/platform-access-grants.shared.schemas.d.ts.map +1 -1
- package/dist/esm/security/authorizations/platform-access-grants.shared.schemas.js +45 -8
- package/dist/esm/security/authorizations/platform-access-grants.shared.schemas.js.map +1 -1
- package/dist/esm/security/connected-accounts/provider-credentials-organization.shared.resources-config.schemas.d.ts +31 -0
- package/dist/esm/security/connected-accounts/provider-credentials-organization.shared.resources-config.schemas.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/provider-credentials-organization.shared.resources-config.schemas.js +198 -0
- package/dist/esm/security/connected-accounts/provider-credentials-organization.shared.resources-config.schemas.js.map +1 -0
- package/dist/esm/security/connected-accounts/provider-credentials-user.shared.resources-config.schemas.d.ts +31 -0
- package/dist/esm/security/connected-accounts/provider-credentials-user.shared.resources-config.schemas.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/provider-credentials-user.shared.resources-config.schemas.js +191 -0
- package/dist/esm/security/connected-accounts/provider-credentials-user.shared.resources-config.schemas.js.map +1 -0
- package/dist/esm/security/connected-accounts/provider-credentials.shared.schemas.d.ts +250 -0
- package/dist/esm/security/connected-accounts/provider-credentials.shared.schemas.d.ts.map +1 -0
- package/dist/esm/security/connected-accounts/provider-credentials.shared.schemas.js +486 -0
- package/dist/esm/security/connected-accounts/provider-credentials.shared.schemas.js.map +1 -0
- package/dist/esm/security/oauth-clients/oauth-clients-application.shared.resources-config.schemas.d.ts +4 -1
- package/dist/esm/security/oauth-clients/oauth-clients-application.shared.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/security/oauth-clients/oauth-clients-application.shared.resources-config.schemas.js +29 -0
- package/dist/esm/security/oauth-clients/oauth-clients-application.shared.resources-config.schemas.js.map +1 -1
- package/dist/esm/security/oauth-clients/oauth-clients-organization.shared.resources-config.schemas.d.ts +4 -1
- package/dist/esm/security/oauth-clients/oauth-clients-organization.shared.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/security/oauth-clients/oauth-clients-organization.shared.resources-config.schemas.js +29 -0
- package/dist/esm/security/oauth-clients/oauth-clients-organization.shared.resources-config.schemas.js.map +1 -1
- package/dist/esm/security/oauth-clients/oauth-clients.shared.schemas.d.ts +6 -0
- package/dist/esm/security/oauth-clients/oauth-clients.shared.schemas.d.ts.map +1 -1
- package/dist/esm/security/oauth-clients/oauth-clients.shared.schemas.js +31 -0
- package/dist/esm/security/oauth-clients/oauth-clients.shared.schemas.js.map +1 -1
- package/dist/esm/security/oauth-clients/oauth-consent-grants.shared.schemas.d.ts +13 -0
- package/dist/esm/security/oauth-clients/oauth-consent-grants.shared.schemas.d.ts.map +1 -1
- package/dist/esm/security/oauth-clients/oauth-consent-grants.shared.schemas.js +24 -3
- package/dist/esm/security/oauth-clients/oauth-consent-grants.shared.schemas.js.map +1 -1
- package/dist/esm/users/user-preferences.shared.resources-config.schemas.d.ts +4 -4
- package/dist/esm/users/user-self-preferences.shared.resources-config.schemas.d.ts +4 -4
- package/dist/esm/users/user-self.shared.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/users/user-self.shared.resources-config.schemas.js +33 -3
- package/dist/esm/users/user-self.shared.resources-config.schemas.js.map +1 -1
- package/dist/esm/users/users.shared.resources-config.schemas.d.ts +17 -1
- package/dist/esm/users/users.shared.resources-config.schemas.d.ts.map +1 -1
- package/dist/esm/users/users.shared.resources-config.schemas.js +136 -5
- package/dist/esm/users/users.shared.resources-config.schemas.js.map +1 -1
- package/dist/esm/users/users.shared.schemas.d.ts +43 -12
- package/dist/esm/users/users.shared.schemas.d.ts.map +1 -1
- package/dist/esm/users/users.shared.schemas.js +38 -7
- package/dist/esm/users/users.shared.schemas.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { isBackendOnlyField, isWriteOnlySecretField } from '@wildo-ai/zod-decorators';
|
|
2
|
+
/**
|
|
3
|
+
* THE ONE RULE for "may this field's VALUE leave the backend?" — the disclosure seam every
|
|
4
|
+
* outward-facing surface derives from, rather than restating.
|
|
5
|
+
*
|
|
6
|
+
* ## What it answers, and what it deliberately does not
|
|
7
|
+
*
|
|
8
|
+
* A field's value is non-disclosable when it is `.isBackendOnly()` (the response DTO drops it) or
|
|
9
|
+
* `.isWriteOnlySecret()` (the response DTO masks it). Those two decorators ARE the disclosure
|
|
10
|
+
* boundary; nothing else is. In particular:
|
|
11
|
+
*
|
|
12
|
+
* - `.isHidden()` gates CHART AGGREGATES (`field-access-validator`), which is a question about
|
|
13
|
+
* which aggregate may expose a value, not about whether the value may be disclosed at all;
|
|
14
|
+
* - `.isEphemeral()` gates the audit field-access trail and a one-time frontend display. An
|
|
15
|
+
* ephemeral field is RETURNED — once, deliberately — so withholding it here would withhold
|
|
16
|
+
* something the response contract promises.
|
|
17
|
+
*
|
|
18
|
+
* Adding either to this predicate would silently narrow surfaces that are working as designed, so
|
|
19
|
+
* they are named here as considered-and-excluded rather than left to the next reader to re-derive.
|
|
20
|
+
*
|
|
21
|
+
* ## Why BOTH decorators are tested, rather than one implying the other
|
|
22
|
+
*
|
|
23
|
+
* They are independent decorators. A future authoring form — or an application — may set one
|
|
24
|
+
* without the other, and a predicate that assumed the implication would open a disclosure path the
|
|
25
|
+
* day that happened. This reasoning is not new: `isFieldWithheldFromSubjectExport` wrote it down
|
|
26
|
+
* for the subject-export surface first, and this module is that rule extracted so the two surfaces
|
|
27
|
+
* cannot drift apart.
|
|
28
|
+
*
|
|
29
|
+
* ## Why it exists as its own module (issue #95)
|
|
30
|
+
*
|
|
31
|
+
* The rule had TWO independent hand-written copies and one surface that carried only half of it:
|
|
32
|
+
*
|
|
33
|
+
* | surface | `.isBackendOnly()` | `.isWriteOnlySecret()` |
|
|
34
|
+
* |---|---|---|
|
|
35
|
+
* | response DTO / `toResponseSafeToolOutput` (REST, MCP `tools/call`, A2A resource tools) | dropped | masked |
|
|
36
|
+
* | subject export (`isFieldWithheldFromSubjectExport`) | withheld | withheld |
|
|
37
|
+
* | RAG retrieval row header (`getSummaryFieldNames`) | excluded | **rendered in full** |
|
|
38
|
+
*
|
|
39
|
+
* The third row is the defect this module closes. A resource may declare a field BOTH
|
|
40
|
+
* `.isSummaryField()` and `.isWriteOnlySecret()` — nothing forbids it — and the retrieval header
|
|
41
|
+
* would then render, verbatim and into a provider payload, the value the response DTO exists to
|
|
42
|
+
* mask. No resource declares that pair today, so the hole was latent; the header is assembled from
|
|
43
|
+
* declarations an application controls, so it stays latent only until one does.
|
|
44
|
+
*
|
|
45
|
+
* assurance-control: WILDO.DATA.CONFIDENTIALITY — material a schema declares non-disclosable does
|
|
46
|
+
* not cross the client boundary. The registered objective names `.isBackendOnly()`; this rule is
|
|
47
|
+
* where its sibling decorator `.isWriteOnlySecret()` is held to the same boundary, since both
|
|
48
|
+
* describe a value the response DTO refuses to emit as authored.
|
|
49
|
+
*/
|
|
50
|
+
export function isNonDisclosableFieldValue(fieldSchema) {
|
|
51
|
+
return isBackendOnlyField(fieldSchema) || isWriteOnlySecretField(fieldSchema);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=field-value-disclosure.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-value-disclosure.utils.js","sourceRoot":"","sources":["../../../../../src/resources/utils/field-value-disclosure.utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,UAAU,0BAA0B,CAAC,WAAyB;IAClE,OAAO,kBAAkB,CAAC,WAAW,CAAC,IAAI,sBAAsB,CAAC,WAAW,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import type { z } from 'zod';\nimport { isBackendOnlyField, isWriteOnlySecretField } from '@wildo-ai/zod-decorators';\n\n/**\n * THE ONE RULE for \"may this field's VALUE leave the backend?\" — the disclosure seam every\n * outward-facing surface derives from, rather than restating.\n *\n * ## What it answers, and what it deliberately does not\n *\n * A field's value is non-disclosable when it is `.isBackendOnly()` (the response DTO drops it) or\n * `.isWriteOnlySecret()` (the response DTO masks it). Those two decorators ARE the disclosure\n * boundary; nothing else is. In particular:\n *\n * - `.isHidden()` gates CHART AGGREGATES (`field-access-validator`), which is a question about\n * which aggregate may expose a value, not about whether the value may be disclosed at all;\n * - `.isEphemeral()` gates the audit field-access trail and a one-time frontend display. An\n * ephemeral field is RETURNED — once, deliberately — so withholding it here would withhold\n * something the response contract promises.\n *\n * Adding either to this predicate would silently narrow surfaces that are working as designed, so\n * they are named here as considered-and-excluded rather than left to the next reader to re-derive.\n *\n * ## Why BOTH decorators are tested, rather than one implying the other\n *\n * They are independent decorators. A future authoring form — or an application — may set one\n * without the other, and a predicate that assumed the implication would open a disclosure path the\n * day that happened. This reasoning is not new: `isFieldWithheldFromSubjectExport` wrote it down\n * for the subject-export surface first, and this module is that rule extracted so the two surfaces\n * cannot drift apart.\n *\n * ## Why it exists as its own module (issue #95)\n *\n * The rule had TWO independent hand-written copies and one surface that carried only half of it:\n *\n * | surface | `.isBackendOnly()` | `.isWriteOnlySecret()` |\n * |---|---|---|\n * | response DTO / `toResponseSafeToolOutput` (REST, MCP `tools/call`, A2A resource tools) | dropped | masked |\n * | subject export (`isFieldWithheldFromSubjectExport`) | withheld | withheld |\n * | RAG retrieval row header (`getSummaryFieldNames`) | excluded | **rendered in full** |\n *\n * The third row is the defect this module closes. A resource may declare a field BOTH\n * `.isSummaryField()` and `.isWriteOnlySecret()` — nothing forbids it — and the retrieval header\n * would then render, verbatim and into a provider payload, the value the response DTO exists to\n * mask. No resource declares that pair today, so the hole was latent; the header is assembled from\n * declarations an application controls, so it stays latent only until one does.\n *\n * assurance-control: WILDO.DATA.CONFIDENTIALITY — material a schema declares non-disclosable does\n * not cross the client boundary. The registered objective names `.isBackendOnly()`; this rule is\n * where its sibling decorator `.isWriteOnlySecret()` is held to the same boundary, since both\n * describe a value the response DTO refuses to emit as authored.\n */\nexport function isNonDisclosableFieldValue(fieldSchema: z.ZodTypeAny): boolean {\n return isBackendOnlyField(fieldSchema) || isWriteOnlySecretField(fieldSchema);\n}\n"]}
|
|
@@ -70,11 +70,25 @@ export declare class ResourcesSummaryUtils {
|
|
|
70
70
|
*/
|
|
71
71
|
static deriveSummarySchemaForDiscriminatedUnion<TMainSchema extends z.ZodObject<z.ZodRawShape>>(mainSchema: TMainSchema, inheritanceDefinition: ResourceConfiguration_InheritanceSchemaDefinition<any, TMainSchema>, options?: DeriveSummaryOptions): z.ZodTypeAny;
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
73
|
+
* Is this a summary field whose VALUE may be disclosed?
|
|
74
|
+
*
|
|
75
|
+
* Both halves are load-bearing. `isSummaryField` is the application's declaration that the field
|
|
76
|
+
* is the human-readable face of a row; {@link isNonDisclosableFieldValue} is the framework's
|
|
77
|
+
* answer to whether that value may leave the backend at all — and the application's declaration
|
|
78
|
+
* never overrides it. A field declared BOTH `.isSummaryField()` and `.isWriteOnlySecret()` is
|
|
79
|
+
* legal to author and must not be rendered anywhere a response DTO would have masked it.
|
|
80
|
+
*
|
|
81
|
+
* The disclosure half is DERIVED, never restated here: it is the same predicate the subject-export
|
|
82
|
+
* surface withholds on, so the two cannot drift (issue #95).
|
|
74
83
|
*/
|
|
75
84
|
static isValidSummaryField(fieldSchema: z.ZodTypeAny): boolean;
|
|
76
85
|
/**
|
|
77
|
-
* Get all summary field names from a schema.
|
|
86
|
+
* Get all summary field names from a schema whose values may be disclosed.
|
|
87
|
+
*
|
|
88
|
+
* Routed through {@link isValidSummaryField} rather than repeating its test — the two said the
|
|
89
|
+
* same thing in two places, and when the disclosure rule grew from "not backend-only" to the full
|
|
90
|
+
* boundary, one of them would have been updated and the other left behind. That is the defect
|
|
91
|
+
* class this whole change is about, in miniature.
|
|
78
92
|
*/
|
|
79
93
|
static getSummaryFieldNames(schema: z.ZodTypeAny): string[];
|
|
80
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources-summary.utils.d.ts","sourceRoot":"","sources":["../../../../../src/resources/utils/resources-summary.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EAAE,iDAAiD,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"resources-summary.utils.d.ts","sourceRoot":"","sources":["../../../../../src/resources/utils/resources-summary.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EAAE,iDAAiD,EAAE,MAAM,oCAAoC,CAAC;AAGvG;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gEAAgE;IAChE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,iDAAiD;IACjD,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAiBD;;GAEG;AACH,qBAAa,qBAAqB;IAEhC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,mBAAmB,CACxB,UAAU,EAAE,CAAC,CAAC,UAAU,EACxB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;IA0C7B;;;;;;OAMG;IACH,MAAM,CAAC,qBAAqB,CAC1B,aAAa,EAAE,CAAC,CAAC,UAAU,EAC3B,UAAU,EAAE,CAAC,CAAC,UAAU,GACvB,uBAAuB;IA0B1B;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,wCAAwC,CAC7C,WAAW,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EAE9C,UAAU,EAAE,WAAW,EACvB,qBAAqB,EAAE,iDAAiD,CAAC,GAAG,EAAE,WAAW,CAAC,EAC1F,OAAO,CAAC,EAAE,oBAAoB,GAC7B,CAAC,CAAC,UAAU;IA6Df;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,CAAC,CAAC,UAAU,GAAG,OAAO;IAI9D;;;;;;;OAOG;IACH,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,GAAG,MAAM,EAAE;CAkB5D"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
import { getZodObjectShape, isSummaryField, isBackendOnlyField, } from '@wildo-ai/zod-decorators';
|
|
11
|
+
import { isNonDisclosableFieldValue } from './field-value-disclosure.utils.js';
|
|
11
12
|
/**
|
|
12
13
|
* Default summary derivation options
|
|
13
14
|
*/
|
|
@@ -155,21 +156,34 @@ export class ResourcesSummaryUtils {
|
|
|
155
156
|
return baseSummary;
|
|
156
157
|
}
|
|
157
158
|
/**
|
|
158
|
-
*
|
|
159
|
+
* Is this a summary field whose VALUE may be disclosed?
|
|
160
|
+
*
|
|
161
|
+
* Both halves are load-bearing. `isSummaryField` is the application's declaration that the field
|
|
162
|
+
* is the human-readable face of a row; {@link isNonDisclosableFieldValue} is the framework's
|
|
163
|
+
* answer to whether that value may leave the backend at all — and the application's declaration
|
|
164
|
+
* never overrides it. A field declared BOTH `.isSummaryField()` and `.isWriteOnlySecret()` is
|
|
165
|
+
* legal to author and must not be rendered anywhere a response DTO would have masked it.
|
|
166
|
+
*
|
|
167
|
+
* The disclosure half is DERIVED, never restated here: it is the same predicate the subject-export
|
|
168
|
+
* surface withholds on, so the two cannot drift (issue #95).
|
|
159
169
|
*/
|
|
160
170
|
static isValidSummaryField(fieldSchema) {
|
|
161
|
-
return isSummaryField(fieldSchema) && !
|
|
171
|
+
return isSummaryField(fieldSchema) && !isNonDisclosableFieldValue(fieldSchema);
|
|
162
172
|
}
|
|
163
173
|
/**
|
|
164
|
-
* Get all summary field names from a schema.
|
|
174
|
+
* Get all summary field names from a schema whose values may be disclosed.
|
|
175
|
+
*
|
|
176
|
+
* Routed through {@link isValidSummaryField} rather than repeating its test — the two said the
|
|
177
|
+
* same thing in two places, and when the disclosure rule grew from "not backend-only" to the full
|
|
178
|
+
* boundary, one of them would have been updated and the other left behind. That is the defect
|
|
179
|
+
* class this whole change is about, in miniature.
|
|
165
180
|
*/
|
|
166
181
|
static getSummaryFieldNames(schema) {
|
|
167
182
|
const result = [];
|
|
168
183
|
try {
|
|
169
184
|
const shape = getZodObjectShape(schema);
|
|
170
185
|
for (const [fieldName, fieldSchema] of Object.entries(shape)) {
|
|
171
|
-
|
|
172
|
-
if (isSummaryField(typedSchema) && !isBackendOnlyField(typedSchema)) {
|
|
186
|
+
if (ResourcesSummaryUtils.isValidSummaryField(fieldSchema)) {
|
|
173
187
|
result.push(fieldName);
|
|
174
188
|
}
|
|
175
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources-summary.utils.js","sourceRoot":"","sources":["../../../../../src/resources/utils/resources-summary.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAyBlC;;GAEG;AACH,MAAM,sBAAsB,GAAyB;IACnD,SAAS,EAAE,IAAI;IACf,kBAAkB,EAAE,KAAK;IACzB,gBAAgB,EAAE,EAAE;IACpB,aAAa,EAAE,EAAE;CAClB,CAAC;AAOF;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAEhC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,mBAAmB,CACxB,UAAwB,EACxB,OAA8B;QAE9B,MAAM,IAAI,GAAG,EAAE,GAAG,sBAAsB,EAAE,GAAG,OAAO,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC5C,MAAM,YAAY,GAAoB,EAAE,CAAC;QAEzC,kCAAkC;QAClC,IAAI,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;YAChC,YAAY,CAAC,GAAG,GAAG,KAAK,CAAC,GAAmB,CAAC;QAC/C,CAAC;QAED,iDAAiD;QACjD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,gBAAgB,IAAI,EAAE,EAAE,CAAC;YAChD,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzD,YAAY,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAiB,CAAC;YACrD,CAAC;QACH,CAAC;QAED,+CAA+C;QAC/C,KAAK,MAAM,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YACH,MAAM,KAAK,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAExC,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7D,MAAM,WAAW,GAAG,WAA2B,CAAC;gBAEhD,IAAI,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;oBACpE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,8BAA8B;QAChC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CAEF","sourcesContent":["/**\n * Resource Summary Utilities\n *\n * Utilities for deriving summary schemas from main schemas using decorators.\n * Summary schemas are lighter versions used for list/search operations.\n *\n * @see Section 4.3 of RESOURCE_DERIVED_OBJECTS_RATIONALIZATION.md\n */\n\nimport { z } from 'zod';\nimport {\n getZodObjectShape,\n isSummaryField,\n isBackendOnlyField,\n} from '@wildo-ai/zod-decorators';\nimport { ResourceConfiguration_InheritanceSchemaDefinition } from '../resources-config.shared.schemas';\n\n/**\n * Options for deriving a summary schema\n */\nexport interface DeriveSummaryOptions {\n /** Always include _id field (default: true) */\n includeId?: boolean;\n /** Include foreign key fields automatically (default: false) */\n includeForeignKeys?: boolean;\n /** Additional fields to include regardless of decorators */\n additionalFields?: string[];\n /** Fields to exclude regardless of decorators */\n excludeFields?: string[];\n}\n\n/**\n * Result of summary schema validation\n */\nexport interface SummaryValidationResult {\n valid: boolean;\n issues: string[];\n}\n\n/**\n * Default summary derivation options\n */\nconst DEFAULT_DERIVE_OPTIONS: DeriveSummaryOptions = {\n includeId: true,\n includeForeignKeys: false,\n additionalFields: [],\n excludeFields: [],\n};\n\n/**\n * Mutable shape type for building schemas\n */\ntype MutableZodShape = Record<string, z.ZodTypeAny>;\n\n/**\n * Utility class for deriving and validating summary schemas.\n */\nexport class ResourcesSummaryUtils {\n\n /**\n * Derive a summary schema from a main schema using decorator metadata.\n *\n * Rules:\n * - Include fields with `isSummaryField` decorator\n * - Include virtual fields that have BOTH `isVirtual` AND `isSummaryField` decorators\n * - Skip `isBackendOnly` fields\n * - Always include `_id` (unless explicitly excluded)\n * - Do NOT auto-include `isForeignKey` fields (must be explicit)\n *\n * @param mainSchema - The main schema to derive from\n * @param options - Configuration options\n * @returns A new Zod schema containing only summary fields\n */\n static deriveSummarySchema(\n mainSchema: z.ZodTypeAny,\n options?: DeriveSummaryOptions\n ): z.ZodObject<z.ZodRawShape> {\n const opts = { ...DEFAULT_DERIVE_OPTIONS, ...options };\n const shape = getZodObjectShape(mainSchema);\n const summaryShape: MutableZodShape = {};\n\n // Always include _id if requested\n if (opts.includeId && shape._id) {\n summaryShape._id = shape._id as z.ZodTypeAny;\n }\n\n // Include additional explicitly requested fields\n for (const field of opts.additionalFields || []) {\n if (shape[field] && !opts.excludeFields?.includes(field)) {\n summaryShape[field] = shape[field] as z.ZodTypeAny;\n }\n }\n\n // Scan all fields for isSummaryField decorator\n for (const [fieldName, fieldSchema] of Object.entries(shape)) {\n // Skip if already added or excluded\n if (summaryShape[fieldName] || opts.excludeFields?.includes(fieldName)) {\n continue;\n }\n\n const typedSchema = fieldSchema as z.ZodTypeAny;\n\n // Skip backend-only fields\n if (isBackendOnlyField(typedSchema)) {\n continue;\n }\n\n // Include if has isSummaryField decorator\n if (isSummaryField(typedSchema)) {\n // Virtual fields with isSummaryField are also included\n // The virtual field computation happens at the service layer\n summaryShape[fieldName] = typedSchema;\n }\n }\n\n return z.object(summaryShape as z.ZodRawShape);\n }\n\n /**\n * Validate that a summary schema does not contain backend-only fields.\n *\n * @param summarySchema - The summary schema to validate\n * @param mainSchema - The main schema for reference\n * @returns Validation result with issues list\n */\n static validateSummarySchema(\n summarySchema: z.ZodTypeAny,\n mainSchema: z.ZodTypeAny\n ): SummaryValidationResult {\n const issues: string[] = [];\n\n try {\n const summaryShape = getZodObjectShape(summarySchema);\n const mainShape = getZodObjectShape(mainSchema);\n\n for (const [fieldName] of Object.entries(summaryShape)) {\n const mainFieldSchema = mainShape[fieldName];\n\n if (mainFieldSchema && isBackendOnlyField(mainFieldSchema as z.ZodTypeAny)) {\n issues.push(\n `Field '${fieldName}' has isBackendOnly decorator but is included in summary schema`\n );\n }\n }\n } catch (error) {\n issues.push(`Failed to validate summary schema: ${error}`);\n }\n\n return {\n valid: issues.length === 0,\n issues,\n };\n }\n\n /**\n * Derive summary schema for a discriminated union (inheritance).\n *\n * Creates a discriminated union of summary schemas where:\n * - Base summary fields apply to all variants\n * - Variant-specific summary fields apply only to that variant\n * - Discriminator field is always included in all variants\n *\n * @param mainSchema - The base schema\n * @param inheritanceDefinition - The inheritance schema definition\n * @param options - Derivation options\n * @returns A discriminated union summary schema or base summary\n */\n static deriveSummarySchemaForDiscriminatedUnion<\n TMainSchema extends z.ZodObject<z.ZodRawShape>\n >(\n mainSchema: TMainSchema,\n inheritanceDefinition: ResourceConfiguration_InheritanceSchemaDefinition<any, TMainSchema>,\n options?: DeriveSummaryOptions\n ): z.ZodTypeAny {\n\n const discriminatorField = inheritanceDefinition.discriminatorField;\n const baseSummary = this.deriveSummarySchema(mainSchema, options);\n const baseShape = getZodObjectShape(baseSummary);\n\n // Ensure discriminator field is included - create mutable copy\n const mainShape = getZodObjectShape(mainSchema);\n const mutableBaseShape: MutableZodShape = {};\n for (const [key, value] of Object.entries(baseShape)) {\n mutableBaseShape[key] = value as z.ZodTypeAny;\n }\n if (!mutableBaseShape[discriminatorField] && mainShape[discriminatorField]) {\n mutableBaseShape[discriminatorField] = mainShape[discriminatorField] as z.ZodTypeAny;\n }\n\n const variantSummaries: z.ZodObject<z.ZodRawShape>[] = [];\n\n // Add base variants (values without inheritance)\n const baseValues = inheritanceDefinition.withoutInheritanceDiscriminatorFieldValues || [];\n for (const value of baseValues) {\n variantSummaries.push(\n z.object({\n ...mutableBaseShape,\n [discriminatorField]: z.literal(value),\n } as z.ZodRawShape)\n );\n }\n\n // Add inherited variant summaries\n for (const inherited of inheritanceDefinition.inheritedSchemas || []) {\n const inheritedSummary = this.deriveSummarySchema(inherited.schema, options);\n const inheritedShape = getZodObjectShape(inheritedSummary);\n\n // Merge base summary with inherited summary\n const mergedShape: MutableZodShape = { ...mutableBaseShape };\n for (const [key, value] of Object.entries(inheritedShape)) {\n mergedShape[key] = value as z.ZodTypeAny;\n }\n mergedShape[discriminatorField] = z.literal(inherited.discriminatorFieldValue);\n\n variantSummaries.push(z.object(mergedShape as z.ZodRawShape));\n }\n\n // If only one variant, return it directly\n if (variantSummaries.length === 1) {\n return variantSummaries[0];\n }\n\n // Create discriminated union (use any to avoid Zod 4 type complexity)\n if (variantSummaries.length >= 2) {\n return z.discriminatedUnion(\n discriminatorField,\n variantSummaries as any\n );\n }\n\n // Fallback to base summary if no variants\n return baseSummary;\n }\n\n /**\n * Check if a field is a valid summary field (has decorator and is not backend-only).\n */\n static isValidSummaryField(fieldSchema: z.ZodTypeAny): boolean {\n return isSummaryField(fieldSchema) && !isBackendOnlyField(fieldSchema);\n }\n\n /**\n * Get all summary field names from a schema.\n */\n static getSummaryFieldNames(schema: z.ZodTypeAny): string[] {\n const result: string[] = [];\n\n try {\n const shape = getZodObjectShape(schema);\n\n for (const [fieldName, fieldSchema] of Object.entries(shape)) {\n const typedSchema = fieldSchema as z.ZodTypeAny;\n\n if (isSummaryField(typedSchema) && !isBackendOnlyField(typedSchema)) {\n result.push(fieldName);\n }\n }\n } catch {\n // Schema may not be an object\n }\n\n return result;\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resources-summary.utils.js","sourceRoot":"","sources":["../../../../../src/resources/utils/resources-summary.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;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AAI,CAAC,SAAS,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,8BAA8B;QAChC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CAEF","sourcesContent":["/**\n * Resource Summary Utilities\n *\n * Utilities for deriving summary schemas from main schemas using decorators.\n * Summary schemas are lighter versions used for list/search operations.\n *\n * @see Section 4.3 of RESOURCE_DERIVED_OBJECTS_RATIONALIZATION.md\n */\n\nimport { z } from 'zod';\nimport {\n getZodObjectShape,\n isSummaryField,\n isBackendOnlyField,\n} from '@wildo-ai/zod-decorators';\nimport { ResourceConfiguration_InheritanceSchemaDefinition } from '../resources-config.shared.schemas';\nimport { isNonDisclosableFieldValue } from './field-value-disclosure.utils';\n\n/**\n * Options for deriving a summary schema\n */\nexport interface DeriveSummaryOptions {\n /** Always include _id field (default: true) */\n includeId?: boolean;\n /** Include foreign key fields automatically (default: false) */\n includeForeignKeys?: boolean;\n /** Additional fields to include regardless of decorators */\n additionalFields?: string[];\n /** Fields to exclude regardless of decorators */\n excludeFields?: string[];\n}\n\n/**\n * Result of summary schema validation\n */\nexport interface SummaryValidationResult {\n valid: boolean;\n issues: string[];\n}\n\n/**\n * Default summary derivation options\n */\nconst DEFAULT_DERIVE_OPTIONS: DeriveSummaryOptions = {\n includeId: true,\n includeForeignKeys: false,\n additionalFields: [],\n excludeFields: [],\n};\n\n/**\n * Mutable shape type for building schemas\n */\ntype MutableZodShape = Record<string, z.ZodTypeAny>;\n\n/**\n * Utility class for deriving and validating summary schemas.\n */\nexport class ResourcesSummaryUtils {\n\n /**\n * Derive a summary schema from a main schema using decorator metadata.\n *\n * Rules:\n * - Include fields with `isSummaryField` decorator\n * - Include virtual fields that have BOTH `isVirtual` AND `isSummaryField` decorators\n * - Skip `isBackendOnly` fields\n * - Always include `_id` (unless explicitly excluded)\n * - Do NOT auto-include `isForeignKey` fields (must be explicit)\n *\n * @param mainSchema - The main schema to derive from\n * @param options - Configuration options\n * @returns A new Zod schema containing only summary fields\n */\n static deriveSummarySchema(\n mainSchema: z.ZodTypeAny,\n options?: DeriveSummaryOptions\n ): z.ZodObject<z.ZodRawShape> {\n const opts = { ...DEFAULT_DERIVE_OPTIONS, ...options };\n const shape = getZodObjectShape(mainSchema);\n const summaryShape: MutableZodShape = {};\n\n // Always include _id if requested\n if (opts.includeId && shape._id) {\n summaryShape._id = shape._id as z.ZodTypeAny;\n }\n\n // Include additional explicitly requested fields\n for (const field of opts.additionalFields || []) {\n if (shape[field] && !opts.excludeFields?.includes(field)) {\n summaryShape[field] = shape[field] as z.ZodTypeAny;\n }\n }\n\n // Scan all fields for isSummaryField decorator\n for (const [fieldName, fieldSchema] of Object.entries(shape)) {\n // Skip if already added or excluded\n if (summaryShape[fieldName] || opts.excludeFields?.includes(fieldName)) {\n continue;\n }\n\n const typedSchema = fieldSchema as z.ZodTypeAny;\n\n // Skip backend-only fields\n if (isBackendOnlyField(typedSchema)) {\n continue;\n }\n\n // Include if has isSummaryField decorator\n if (isSummaryField(typedSchema)) {\n // Virtual fields with isSummaryField are also included\n // The virtual field computation happens at the service layer\n summaryShape[fieldName] = typedSchema;\n }\n }\n\n return z.object(summaryShape as z.ZodRawShape);\n }\n\n /**\n * Validate that a summary schema does not contain backend-only fields.\n *\n * @param summarySchema - The summary schema to validate\n * @param mainSchema - The main schema for reference\n * @returns Validation result with issues list\n */\n static validateSummarySchema(\n summarySchema: z.ZodTypeAny,\n mainSchema: z.ZodTypeAny\n ): SummaryValidationResult {\n const issues: string[] = [];\n\n try {\n const summaryShape = getZodObjectShape(summarySchema);\n const mainShape = getZodObjectShape(mainSchema);\n\n for (const [fieldName] of Object.entries(summaryShape)) {\n const mainFieldSchema = mainShape[fieldName];\n\n if (mainFieldSchema && isBackendOnlyField(mainFieldSchema as z.ZodTypeAny)) {\n issues.push(\n `Field '${fieldName}' has isBackendOnly decorator but is included in summary schema`\n );\n }\n }\n } catch (error) {\n issues.push(`Failed to validate summary schema: ${error}`);\n }\n\n return {\n valid: issues.length === 0,\n issues,\n };\n }\n\n /**\n * Derive summary schema for a discriminated union (inheritance).\n *\n * Creates a discriminated union of summary schemas where:\n * - Base summary fields apply to all variants\n * - Variant-specific summary fields apply only to that variant\n * - Discriminator field is always included in all variants\n *\n * @param mainSchema - The base schema\n * @param inheritanceDefinition - The inheritance schema definition\n * @param options - Derivation options\n * @returns A discriminated union summary schema or base summary\n */\n static deriveSummarySchemaForDiscriminatedUnion<\n TMainSchema extends z.ZodObject<z.ZodRawShape>\n >(\n mainSchema: TMainSchema,\n inheritanceDefinition: ResourceConfiguration_InheritanceSchemaDefinition<any, TMainSchema>,\n options?: DeriveSummaryOptions\n ): z.ZodTypeAny {\n\n const discriminatorField = inheritanceDefinition.discriminatorField;\n const baseSummary = this.deriveSummarySchema(mainSchema, options);\n const baseShape = getZodObjectShape(baseSummary);\n\n // Ensure discriminator field is included - create mutable copy\n const mainShape = getZodObjectShape(mainSchema);\n const mutableBaseShape: MutableZodShape = {};\n for (const [key, value] of Object.entries(baseShape)) {\n mutableBaseShape[key] = value as z.ZodTypeAny;\n }\n if (!mutableBaseShape[discriminatorField] && mainShape[discriminatorField]) {\n mutableBaseShape[discriminatorField] = mainShape[discriminatorField] as z.ZodTypeAny;\n }\n\n const variantSummaries: z.ZodObject<z.ZodRawShape>[] = [];\n\n // Add base variants (values without inheritance)\n const baseValues = inheritanceDefinition.withoutInheritanceDiscriminatorFieldValues || [];\n for (const value of baseValues) {\n variantSummaries.push(\n z.object({\n ...mutableBaseShape,\n [discriminatorField]: z.literal(value),\n } as z.ZodRawShape)\n );\n }\n\n // Add inherited variant summaries\n for (const inherited of inheritanceDefinition.inheritedSchemas || []) {\n const inheritedSummary = this.deriveSummarySchema(inherited.schema, options);\n const inheritedShape = getZodObjectShape(inheritedSummary);\n\n // Merge base summary with inherited summary\n const mergedShape: MutableZodShape = { ...mutableBaseShape };\n for (const [key, value] of Object.entries(inheritedShape)) {\n mergedShape[key] = value as z.ZodTypeAny;\n }\n mergedShape[discriminatorField] = z.literal(inherited.discriminatorFieldValue);\n\n variantSummaries.push(z.object(mergedShape as z.ZodRawShape));\n }\n\n // If only one variant, return it directly\n if (variantSummaries.length === 1) {\n return variantSummaries[0];\n }\n\n // Create discriminated union (use any to avoid Zod 4 type complexity)\n if (variantSummaries.length >= 2) {\n return z.discriminatedUnion(\n discriminatorField,\n variantSummaries as any\n );\n }\n\n // Fallback to base summary if no variants\n return baseSummary;\n }\n\n /**\n * Is this a summary field whose VALUE may be disclosed?\n *\n * Both halves are load-bearing. `isSummaryField` is the application's declaration that the field\n * is the human-readable face of a row; {@link isNonDisclosableFieldValue} is the framework's\n * answer to whether that value may leave the backend at all — and the application's declaration\n * never overrides it. A field declared BOTH `.isSummaryField()` and `.isWriteOnlySecret()` is\n * legal to author and must not be rendered anywhere a response DTO would have masked it.\n *\n * The disclosure half is DERIVED, never restated here: it is the same predicate the subject-export\n * surface withholds on, so the two cannot drift (issue #95).\n */\n static isValidSummaryField(fieldSchema: z.ZodTypeAny): boolean {\n return isSummaryField(fieldSchema) && !isNonDisclosableFieldValue(fieldSchema);\n }\n\n /**\n * Get all summary field names from a schema whose values may be disclosed.\n *\n * Routed through {@link isValidSummaryField} rather than repeating its test — the two said the\n * same thing in two places, and when the disclosure rule grew from \"not backend-only\" to the full\n * boundary, one of them would have been updated and the other left behind. That is the defect\n * class this whole change is about, in miniature.\n */\n static getSummaryFieldNames(schema: z.ZodTypeAny): string[] {\n const result: string[] = [];\n\n try {\n const shape = getZodObjectShape(schema);\n\n for (const [fieldName, fieldSchema] of Object.entries(shape)) {\n if (ResourcesSummaryUtils.isValidSummaryField(fieldSchema as z.ZodTypeAny)) {\n result.push(fieldName);\n }\n }\n } catch {\n // Schema may not be an object\n }\n\n return result;\n }\n\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-persistence-collection.utils.d.ts","sourceRoot":"","sources":["../../../../../src/resources/utils/shared-persistence-collection.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2DAA2D,CAAC;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,8CAA8C,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"shared-persistence-collection.utils.d.ts","sourceRoot":"","sources":["../../../../../src/resources/utils/shared-persistence-collection.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2DAA2D,CAAC;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,8CAA8C,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAe3F,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sCAAsC,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAEzF;AAED,iGAAiG;AACjG,MAAM,WAAW,2CAA2C;IAC1D,QAAQ,CAAC,kBAAkB,EAAE,YAAY,CAAC;IAC1C,yFAAyF;IACzF,QAAQ,CAAC,kBAAkB,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;CAClE;AAED,gFAAgF;AAChF,MAAM,WAAW,6CAA6C;IAC5D,sEAAsE;IACtE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,yFAAyF;IACzF,QAAQ,CAAC,QAAQ,EAAE,SAAS;QAAE,YAAY,EAAE,YAAY,CAAC;QAAC,OAAO,EAAE,sBAAsB,CAAA;KAAE,EAAE,CAAC;IAC9F,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,kDAAkD,CAChE,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,2CAA2C,CAAC,EACnF,yBAAyB,EAAE,sBAAsB,GAChD,6CAA6C,EAAE,CAsDjD;AAED,mGAAmG;AACnG,MAAM,WAAW,6CAA6C;IAC5D,QAAQ,CAAC,kBAAkB,EAAE,YAAY,CAAC;IAC1C,QAAQ,CAAC,eAAe,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,oBAAoB,CAAA;KAAE,GAAG,SAAS,CAAC;CACxE;AAyBD,iFAAiF;AACjF,MAAM,WAAW,+CAA+C;IAC9D,8DAA8D;IAC9D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,sFAAsF;IACtF,QAAQ,CAAC,QAAQ,EAAE,SAAS;QAAE,YAAY,EAAE,YAAY,CAAC;QAAC,IAAI,EAAE,oBAAoB,GAAG,SAAS,CAAA;KAAE,EAAE,CAAC;IACrG,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,wBAAgB,oDAAoD,CAClE,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,6CAA6C,CAAC,GACpF,+CAA+C,EAAE,CA0DnD"}
|
|
@@ -53,6 +53,17 @@ export const RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES = {
|
|
|
53
53
|
[CoreResourceType.USER_SELF]: CoreResourceType.USERS,
|
|
54
54
|
[CoreResourceType.USER_SELF_PROFILES]: CoreResourceType.USER_PROFILES,
|
|
55
55
|
[CoreResourceType.USER_SELF_PREFERENCES]: CoreResourceType.USER_PREFERENCES,
|
|
56
|
+
/*
|
|
57
|
+
* The application-scoped audit door addresses the organization-scoped resource's rows (#317).
|
|
58
|
+
*
|
|
59
|
+
* Unlike the `USER_SELF` group above — where the alias exists so a principal can address its OWN
|
|
60
|
+
* row through a narrower door — this pair exists because the two doors see DIFFERENT SUBSETS of
|
|
61
|
+
* one set: the organization door is tenant-filtered and structurally cannot return the rows that
|
|
62
|
+
* carry no organization (logins, session evictions, application-wide policy changes), which is
|
|
63
|
+
* 74% of them on a measured dogfood application. Splitting the storage would split the audit
|
|
64
|
+
* trail itself, so the alias is load-bearing rather than a convenience.
|
|
65
|
+
*/
|
|
66
|
+
[CoreResourceType.APPLICATION_AUDIT_LOGS]: CoreResourceType.AUDIT_LOGS,
|
|
56
67
|
};
|
|
57
68
|
/**
|
|
58
69
|
* The persistence collection a resource type's rows live in — its alias target
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-persistence-collection.utils.js","sourceRoot":"","sources":["../../../../../src/resources/utils/shared-persistence-collection.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAKxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,CAAC,MAAM,8CAA8C,GAAqC;IAC9F,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC,KAAK;IACpD,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,EAAE,gBAAgB,CAAC,aAAa;IACrE,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,EAAE,gBAAgB,CAAC,gBAAgB;CAC5E,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,sCAAsC,CAAC,YAA0B;IAC/E,OAAO,8CAA8C,CAAC,YAAsB,CAAC,IAAK,YAAuB,CAAC;AAC5G,CAAC;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,IAAI,CAAC;YAChB,cAAc;YACd,QAAQ;YACR,OAAO,EACL,qBAAqB,QAAQ,uBAAuB,cAAc,2BAA2B;gBAC7F,gGAAgG;gBAChG,+FAA+F;gBAC/F,iGAAiG;gBACjG,+FAA+F;gBAC/F,2FAA2F;gBAC3F,6FAA6F;gBAC7F,gGAAgG;gBAChG,6FAA6F;gBAC7F,8BAA8B;SACjC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { CoreResourceType } from '../resources.shared.core.definitions';\nimport type { ResourceType } from '../resources.shared.schemas';\nimport type { PersistenceAdapterType } from '../resources-config.shared.schemas';\nimport { ErasureRetentionMode } from '../../compliance/privacy/impersonalization.shared.schemas';\n\n/**\n * Resource types that deliberately project onto ANOTHER resource type's\n * persistence collection — THE authority for \"which configs address the same\n * physical rows?\".\n *\n * ## What this expresses\n *\n * A `USER_SELF*` resource is not a different record set; it is a different DOOR\n * onto the SAME record set, with its own operations, roles and scoping. The\n * `USERS` door is the admin surface (list every user, delete a user); the\n * `USER_SELF` door is the self surface (read/update MY row). They intentionally\n * share `UserSchema` and they intentionally share storage — the persistence\n * layer builds a SEPARATE model per resource config over ONE collection.\n *\n * Anything not listed here stores under its own resource type.\n *\n * ## Why it is a single named authority\n *\n * This mapping had already been copied twice inside the backend (the\n * zod→mongoose model builder, which is what actually creates and reads the\n * collection, and the aggregation collection resolver — whose earlier\n * divergence made every aggregation query a non-existent collection and return\n * zero rows). It now has a third consumer of a completely different kind:\n * {@link findSharedPersistenceCollectionRetentionIncoherences}, a boot-time\n * coherence guard. A per-resource config factory structurally cannot see this\n * relationship — it validates ONE config at a time — so the fact has to live\n * where every layer can read it, and it has to live exactly once.\n *\n * ## The alias belongs to the RESOURCE, not to the storage adapter\n *\n * Every persistence path resolves through this map, and each adapter has\n * exactly ONE composition point that does so: MongoDB's model builder and its\n * aggregation resolver, and — on the SQL side — the single\n * `resolveTableNameForResource` helper that the hybrid planner, the PostgreSQL\n * repository and the boot-time table verifier all call.\n *\n * This was NOT always true, and the way it failed is the reason to keep it\n * true: PostgreSQL used to derive its table name straight from\n * `resourceIdentifier`, so `USER_SELF` planned, wrote and verified a `userself`\n * table while `USERS` used `users`. An adapter choice must never silently\n * change WHICH RECORDS a resource addresses — that is not a storage detail, it\n * is the \"two doors, one record set\" contract itself. On the SQL side the\n * resolved name is additionally normalised into a SQL identifier; casing is an\n * adapter concern, the alias is not.\n *\n * The one thing a shared resolver still cannot see is an alias group whose\n * members are pointed at DIFFERENT adapters — each config is individually\n * valid, and only the pair is wrong. That is what\n * {@link findSharedPersistenceCollectionAdapterIncoherences} fails closed on.\n */\nexport const RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES: Readonly<Record<string, string>> = {\n [CoreResourceType.USER_SELF]: CoreResourceType.USERS,\n [CoreResourceType.USER_SELF_PROFILES]: CoreResourceType.USER_PROFILES,\n [CoreResourceType.USER_SELF_PREFERENCES]: CoreResourceType.USER_PREFERENCES,\n};\n\n/**\n * The persistence collection a resource type's rows live in — its alias target\n * when it declares one, otherwise the resource type itself.\n *\n * @param resourceType - the resource type whose storage location is wanted.\n * @returns the collection name, as a plain string.\n */\nexport function resolveSharedPersistenceCollectionName(resourceType: ResourceType): string {\n return RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES[resourceType as string] ?? (resourceType as string);\n}\n\n/** The minimal config shape {@link findSharedPersistenceCollectionAdapterIncoherences} reads. */\nexport interface SharedPersistenceCollectionAdapterCandidate {\n readonly resourceIdentifier: ResourceType;\n /** The config's OWN declaration; `undefined` means \"inherit the application default\". */\n readonly persistenceAdapter?: PersistenceAdapterType | undefined;\n}\n\n/** One collection whose resource configs are pointed at different databases. */\nexport interface SharedPersistenceCollectionAdapterIncoherence {\n /** The shared collection the disagreeing configs claim to address. */\n readonly collectionName: string;\n /** Every resource config addressing that collection, with the adapter it RESOLVED to. */\n readonly adapters: readonly { resourceType: ResourceType; adapter: PersistenceAdapterType }[];\n /** Operator-facing explanation naming the consequence and the fix. */\n readonly message: string;\n}\n\n/**\n * Registry-ASSEMBLY guardrail: every resource config that resolves to the SAME\n * persistence collection must resolve to the SAME persistence adapter.\n *\n * ## Why the shared resolver cannot cover this on its own\n *\n * {@link resolveSharedPersistenceCollectionName} makes the alias\n * adapter-independent: whichever database a resource lands in, it addresses the\n * aliased NAME. That is necessary and not sufficient. A name is only an address\n * WITHIN one database, so pointing `USERS` at PostgreSQL while `USER_SELF`\n * inherits MongoDB yields two stores that both believe they own the same rows.\n * Nothing downstream can detect it: each config is individually valid, each\n * repository is correctly built, and every per-resource check passes.\n *\n * ## The failure it prevents\n *\n * The doors silently stop sharing records. The admin door lists users the self\n * door cannot read; a self-service update writes to a row the admin door will\n * never see; and — because retention is enforced against ROWS — an erasure\n * performed through one door leaves the other door's copy completely\n * untouched, which is the same compliance-grade lie that\n * {@link findSharedPersistenceCollectionRetentionIncoherences} exists to\n * prevent, arrived at from a different direction.\n *\n * The table name is not the only thing that follows from the adapter. Id FORMAT\n * does too — the PostgreSQL repository validates ids as UUIDs while Mongo\n * expects ObjectIds, each resolved from its OWN resource's adapter — so a split\n * group would also reject through one door the very ids the other door mints.\n * Anything keyed on \"this resource's adapter\" inherits this invariant.\n *\n * ## Why this is permanent, not a capability gate\n *\n * Unlike adapter gaps that close when the missing support is implemented, this\n * one has no future in which it becomes valid: two databases cannot hold one\n * set of rows. It is deliberately NOT a ban on aliased resources using\n * PostgreSQL — an alias group that agrees on PostgreSQL resolves to one shared\n * table, and whether that table was actually provisioned is a separate,\n * already-enforced question (the boot-time table verifier).\n *\n * Resources inherit the application default when they declare nothing, so the\n * caller supplies the resolved default rather than this function guessing it.\n *\n * Pure and side-effect free: it reports, the caller throws.\n *\n * @param resourceConfigurations - every assembled resource config, keyed by resource type.\n * @param defaultPersistenceAdapter - the adapter a config with no declaration inherits.\n * @returns one entry per incoherent collection; empty when the registry is coherent.\n */\nexport function findSharedPersistenceCollectionAdapterIncoherences(\n resourceConfigurations: Record<string, SharedPersistenceCollectionAdapterCandidate>,\n defaultPersistenceAdapter: PersistenceAdapterType,\n): SharedPersistenceCollectionAdapterIncoherence[] {\n const adaptersByCollection = new Map<\n string,\n { resourceType: ResourceType; adapter: PersistenceAdapterType }[]\n >();\n\n for (const [resourceTypeKey, resourceConfig] of Object.entries(resourceConfigurations)) {\n // Same reasoning as the retention guard: prefer the config's OWN identifier so a mis-keyed\n // registry entry is diagnosed against the name its author actually wrote.\n const resourceType = (resourceConfig?.resourceIdentifier ?? resourceTypeKey) as ResourceType;\n const collectionName = resolveSharedPersistenceCollectionName(resourceType);\n const entry = {\n resourceType,\n adapter: resourceConfig?.persistenceAdapter ?? defaultPersistenceAdapter,\n };\n\n const existing = adaptersByCollection.get(collectionName);\n if (existing) {\n existing.push(entry);\n } else {\n adaptersByCollection.set(collectionName, [entry]);\n }\n }\n\n const incoherences: SharedPersistenceCollectionAdapterIncoherence[] = [];\n\n for (const [collectionName, adapters] of adaptersByCollection) {\n if (adapters.length < 2) {\n continue;\n }\n if (new Set(adapters.map((entry) => entry.adapter)).size < 2) {\n continue;\n }\n\n const declared = adapters\n .map((entry) => `'${String(entry.resourceType)}' → ${entry.adapter}`)\n .join(', ');\n\n incoherences.push({\n collectionName,\n adapters,\n message:\n `Resource configs [${declared}] all address the '${collectionName}' persistence collection but ` +\n `resolve to DIFFERENT persistence adapters. These configs are separate doors onto ONE set of ` +\n `rows, and a collection name only addresses rows within a single database, so this splits them ` +\n `across two stores that each believe they own the records: the admin door lists rows the self ` +\n `door cannot read, a self-service write lands where the admin door will never see it, and an ` +\n `erasure performed through one door leaves the other door's copy fully intact. Give every ` +\n `config listed above the same persistenceAdapter (a resource sharing a collection cannot pick ` +\n `its database alone), or stop sharing the collection.`,\n });\n }\n\n return incoherences;\n}\n\n/** The minimal config shape {@link findSharedPersistenceCollectionRetentionIncoherences} reads. */\nexport interface SharedPersistenceCollectionRetentionCandidate {\n readonly resourceIdentifier: ResourceType;\n readonly retentionPolicy?: { mode?: ErasureRetentionMode } | undefined;\n}\n\n/**\n * Canonical comparison key for a resource's retention POSTURE.\n *\n * Compares the WHOLE resolved policy, not just `mode`. `ResourceRetentionPolicy` carries a single\n * axis today, so `mode` alone would be exhaustive — but this guard exists precisely because config\n * checks that look sufficient go quietly wrong later, and a second axis (a disposal clock, a\n * jurisdiction) added to the policy would otherwise escape the comparison with no compile-time\n * signal. Two configs over one collection must agree on ALL of it.\n *\n * Key order is normalised so authoring order cannot masquerade as a disagreement. `undefined` gets\n * its own key rather than being skipped: \"rows of this resource are hard-deleted\" is a positive\n * claim, and the in-vs-out asymmetry is what produces both failure modes documented below.\n */\nfunction buildRetentionPostureKey(retentionPolicy: { mode?: ErasureRetentionMode } | undefined): string {\n if (retentionPolicy === undefined || retentionPolicy === null) {\n return 'NOT_GOVERNED';\n }\n const entries = Object.entries(retentionPolicy as Record<string, unknown>)\n .filter(([, value]) => value !== undefined)\n .sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey));\n return entries.length === 0 ? 'NOT_GOVERNED' : JSON.stringify(entries);\n}\n\n/** One collection whose resource configs disagree about retention governance. */\nexport interface SharedPersistenceCollectionRetentionIncoherence {\n /** The shared collection the disagreeing configs write to. */\n readonly collectionName: string;\n /** Every resource config addressing that collection, with the posture it declared. */\n readonly postures: readonly { resourceType: ResourceType; mode: ErasureRetentionMode | undefined }[];\n /** Operator-facing explanation naming both failure modes and the fix. */\n readonly message: string;\n}\n\n/**\n * Registry-ASSEMBLY guardrail: every resource config that resolves to the SAME\n * persistence collection must declare the SAME retention posture.\n *\n * ## Why a config that passes every per-resource check can still be broken\n *\n * `retentionPolicy` is validated PER RESOURCE CONFIG by the config factory: it\n * checks that resource's operations, its field treatments, its system-access\n * grants. It cannot check what a SIBLING config declares, because a factory\n * invocation never sees one. But retention is enforced against ROWS, and two\n * configs can own the same rows (see\n * {@link RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES}). So a pair that\n * disagrees produces a config where every individual resource is valid and the\n * COLLECTION is not.\n *\n * ## The two concrete failure modes\n *\n * **1. Fail-open erasure.** The retention hide filter (rows marked `RETAINED`\n * are invisible) and the immutability freeze are injected per resource config,\n * in `buildContextualFilter`. A row erased through the governed door stays\n * fully READABLE and UPDATABLE through the ungoverned one. For the\n * `USERS`/`USER_SELF` pair that ungoverned door exposes READ + UPDATE to\n * `APP_USER` — i.e. the erased subject can still read and edit their own\n * \"erased\" record. The row is erased only from the door that was opted in,\n * which is a compliance-grade lie about the record.\n *\n * **2. Unique-index collision — a hard functional abort.** A retention-governed\n * config scopes each unique index to NON-retained rows (a partial filter on the\n * retention marker), precisely so scrubbed rows leave the index and cannot\n * collide on the shared mask value. An ungoverned config over the same\n * collection emits a PLAIN unique index on the same field. The FIRST erasure\n * succeeds; the SECOND writes the same mask value, hits the plain index, and\n * fails E11000 — inside the erasure transaction, so the whole erasure rolls\n * back. The capability is silently single-use.\n *\n * Both modes are invisible until a real erasure runs, which is why this is a\n * BOOT-time guard and not a test: the point is that a config which passes at\n * boot must actually be able to perform an erasure.\n *\n * ## Why \"one opted in, one not\" is a disagreement, not a default\n *\n * An absent `retentionPolicy` is a positive statement — \"rows of this resource\n * are hard-deleted\" — not an unset value the governed sibling can supply. Both\n * failure modes above are produced by exactly that asymmetry, so `undefined`\n * participates in the comparison as its own posture rather than being skipped.\n *\n * Pure and side-effect free: it reports, the caller throws. That keeps the\n * shared-collection fact and its invariant in the layer both persistence and\n * validation can import, while the registry owns the error shape.\n *\n * @param resourceConfigurations - every assembled resource config, keyed by resource type.\n * @returns one entry per incoherent collection; empty when the registry is coherent.\n */\nexport function findSharedPersistenceCollectionRetentionIncoherences(\n resourceConfigurations: Record<string, SharedPersistenceCollectionRetentionCandidate>,\n): SharedPersistenceCollectionRetentionIncoherence[] {\n const posturesByCollection = new Map<\n string,\n { resourceType: ResourceType; mode: ErasureRetentionMode | undefined; postureKey: string }[]\n >();\n\n for (const [resourceTypeKey, resourceConfig] of Object.entries(resourceConfigurations)) {\n // Prefer the config's OWN identifier over the map key: the registry keys by resource type, but a\n // host that mis-keyed an entry would otherwise be diagnosed against a name it never authored.\n const resourceType = (resourceConfig?.resourceIdentifier ?? resourceTypeKey) as ResourceType;\n const collectionName = resolveSharedPersistenceCollectionName(resourceType);\n const posture = {\n resourceType,\n mode: resourceConfig?.retentionPolicy?.mode,\n postureKey: buildRetentionPostureKey(resourceConfig?.retentionPolicy),\n };\n\n const existing = posturesByCollection.get(collectionName);\n if (existing) {\n existing.push(posture);\n } else {\n posturesByCollection.set(collectionName, [posture]);\n }\n }\n\n const incoherences: SharedPersistenceCollectionRetentionIncoherence[] = [];\n\n for (const [collectionName, postures] of posturesByCollection) {\n if (postures.length < 2) {\n continue;\n }\n const distinctPostures = new Set(postures.map((posture) => posture.postureKey));\n if (distinctPostures.size < 2) {\n continue;\n }\n\n const declared = postures\n .map((posture) => `'${String(posture.resourceType)}' → ${posture.mode ?? 'NOT retention-governed'}`)\n .join(', ');\n\n incoherences.push({\n collectionName,\n postures,\n message:\n `Resource configs [${declared}] all store in the '${collectionName}' collection but declare ` +\n `DIFFERENT retention postures. They are separate models over ONE set of rows, and retention is ` +\n `enforced per resource config, so this ships two defects that only appear when a real erasure ` +\n `runs: (1) FAIL-OPEN ERASURE — the retention hide filter and the immutability freeze are absent ` +\n `on the ungoverned door, leaving an erased row readable and updatable there; (2) UNIQUE-INDEX ` +\n `COLLISION — the governed config scopes its unique indexes to non-retained rows while the ` +\n `ungoverned one emits plain unique indexes on the same collection, so the SECOND erased row ` +\n `collides (E11000) and the erasure transaction rolls back. Declare the SAME retentionPolicy on ` +\n `every config listed above (a resource sharing a collection cannot opt in or out alone), or ` +\n `stop sharing the collection.`,\n });\n }\n\n return incoherences;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"shared-persistence-collection.utils.js","sourceRoot":"","sources":["../../../../../src/resources/utils/shared-persistence-collection.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC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,CAAC;IAE3E,KAAK,MAAM,CAAC,cAAc,EAAE,QAAQ,CAAC,IAAI,oBAAoB,EAAE,CAAC;QAC9D,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,SAAS;QACX,CAAC;QACD,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;QAChF,IAAI,gBAAgB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAC9B,SAAS;QACX,CAAC;QAED,MAAM,QAAQ,GAAG,QAAQ;aACtB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,OAAO,CAAC,IAAI,IAAI,wBAAwB,EAAE,CAAC;aACnG,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,YAAY,CAAC,IAAI,CAAC;YAChB,cAAc;YACd,QAAQ;YACR,OAAO,EACL,qBAAqB,QAAQ,uBAAuB,cAAc,2BAA2B;gBAC7F,gGAAgG;gBAChG,+FAA+F;gBAC/F,iGAAiG;gBACjG,+FAA+F;gBAC/F,2FAA2F;gBAC3F,6FAA6F;gBAC7F,gGAAgG;gBAChG,6FAA6F;gBAC7F,8BAA8B;SACjC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { CoreResourceType } from '../resources.shared.core.definitions';\nimport type { ResourceType } from '../resources.shared.schemas';\nimport type { PersistenceAdapterType } from '../resources-config.shared.schemas';\nimport { ErasureRetentionMode } from '../../compliance/privacy/impersonalization.shared.schemas';\n\n/**\n * Resource types that deliberately project onto ANOTHER resource type's\n * persistence collection — THE authority for \"which configs address the same\n * physical rows?\".\n *\n * ## What this expresses\n *\n * A `USER_SELF*` resource is not a different record set; it is a different DOOR\n * onto the SAME record set, with its own operations, roles and scoping. The\n * `USERS` door is the admin surface (list every user, delete a user); the\n * `USER_SELF` door is the self surface (read/update MY row). They intentionally\n * share `UserSchema` and they intentionally share storage — the persistence\n * layer builds a SEPARATE model per resource config over ONE collection.\n *\n * Anything not listed here stores under its own resource type.\n *\n * ## Why it is a single named authority\n *\n * This mapping had already been copied twice inside the backend (the\n * zod→mongoose model builder, which is what actually creates and reads the\n * collection, and the aggregation collection resolver — whose earlier\n * divergence made every aggregation query a non-existent collection and return\n * zero rows). It now has a third consumer of a completely different kind:\n * {@link findSharedPersistenceCollectionRetentionIncoherences}, a boot-time\n * coherence guard. A per-resource config factory structurally cannot see this\n * relationship — it validates ONE config at a time — so the fact has to live\n * where every layer can read it, and it has to live exactly once.\n *\n * ## The alias belongs to the RESOURCE, not to the storage adapter\n *\n * Every persistence path resolves through this map, and each adapter has\n * exactly ONE composition point that does so: MongoDB's model builder and its\n * aggregation resolver, and — on the SQL side — the single\n * `resolveTableNameForResource` helper that the hybrid planner, the PostgreSQL\n * repository and the boot-time table verifier all call.\n *\n * This was NOT always true, and the way it failed is the reason to keep it\n * true: PostgreSQL used to derive its table name straight from\n * `resourceIdentifier`, so `USER_SELF` planned, wrote and verified a `userself`\n * table while `USERS` used `users`. An adapter choice must never silently\n * change WHICH RECORDS a resource addresses — that is not a storage detail, it\n * is the \"two doors, one record set\" contract itself. On the SQL side the\n * resolved name is additionally normalised into a SQL identifier; casing is an\n * adapter concern, the alias is not.\n *\n * The one thing a shared resolver still cannot see is an alias group whose\n * members are pointed at DIFFERENT adapters — each config is individually\n * valid, and only the pair is wrong. That is what\n * {@link findSharedPersistenceCollectionAdapterIncoherences} fails closed on.\n */\nexport const RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES: Readonly<Record<string, string>> = {\n [CoreResourceType.USER_SELF]: CoreResourceType.USERS,\n [CoreResourceType.USER_SELF_PROFILES]: CoreResourceType.USER_PROFILES,\n [CoreResourceType.USER_SELF_PREFERENCES]: CoreResourceType.USER_PREFERENCES,\n /*\n * The application-scoped audit door addresses the organization-scoped resource's rows (#317).\n *\n * Unlike the `USER_SELF` group above — where the alias exists so a principal can address its OWN\n * row through a narrower door — this pair exists because the two doors see DIFFERENT SUBSETS of\n * one set: the organization door is tenant-filtered and structurally cannot return the rows that\n * carry no organization (logins, session evictions, application-wide policy changes), which is\n * 74% of them on a measured dogfood application. Splitting the storage would split the audit\n * trail itself, so the alias is load-bearing rather than a convenience.\n */\n [CoreResourceType.APPLICATION_AUDIT_LOGS]: CoreResourceType.AUDIT_LOGS,\n};\n\n/**\n * The persistence collection a resource type's rows live in — its alias target\n * when it declares one, otherwise the resource type itself.\n *\n * @param resourceType - the resource type whose storage location is wanted.\n * @returns the collection name, as a plain string.\n */\nexport function resolveSharedPersistenceCollectionName(resourceType: ResourceType): string {\n return RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES[resourceType as string] ?? (resourceType as string);\n}\n\n/** The minimal config shape {@link findSharedPersistenceCollectionAdapterIncoherences} reads. */\nexport interface SharedPersistenceCollectionAdapterCandidate {\n readonly resourceIdentifier: ResourceType;\n /** The config's OWN declaration; `undefined` means \"inherit the application default\". */\n readonly persistenceAdapter?: PersistenceAdapterType | undefined;\n}\n\n/** One collection whose resource configs are pointed at different databases. */\nexport interface SharedPersistenceCollectionAdapterIncoherence {\n /** The shared collection the disagreeing configs claim to address. */\n readonly collectionName: string;\n /** Every resource config addressing that collection, with the adapter it RESOLVED to. */\n readonly adapters: readonly { resourceType: ResourceType; adapter: PersistenceAdapterType }[];\n /** Operator-facing explanation naming the consequence and the fix. */\n readonly message: string;\n}\n\n/**\n * Registry-ASSEMBLY guardrail: every resource config that resolves to the SAME\n * persistence collection must resolve to the SAME persistence adapter.\n *\n * ## Why the shared resolver cannot cover this on its own\n *\n * {@link resolveSharedPersistenceCollectionName} makes the alias\n * adapter-independent: whichever database a resource lands in, it addresses the\n * aliased NAME. That is necessary and not sufficient. A name is only an address\n * WITHIN one database, so pointing `USERS` at PostgreSQL while `USER_SELF`\n * inherits MongoDB yields two stores that both believe they own the same rows.\n * Nothing downstream can detect it: each config is individually valid, each\n * repository is correctly built, and every per-resource check passes.\n *\n * ## The failure it prevents\n *\n * The doors silently stop sharing records. The admin door lists users the self\n * door cannot read; a self-service update writes to a row the admin door will\n * never see; and — because retention is enforced against ROWS — an erasure\n * performed through one door leaves the other door's copy completely\n * untouched, which is the same compliance-grade lie that\n * {@link findSharedPersistenceCollectionRetentionIncoherences} exists to\n * prevent, arrived at from a different direction.\n *\n * The table name is not the only thing that follows from the adapter. Id FORMAT\n * does too — the PostgreSQL repository validates ids as UUIDs while Mongo\n * expects ObjectIds, each resolved from its OWN resource's adapter — so a split\n * group would also reject through one door the very ids the other door mints.\n * Anything keyed on \"this resource's adapter\" inherits this invariant.\n *\n * ## Why this is permanent, not a capability gate\n *\n * Unlike adapter gaps that close when the missing support is implemented, this\n * one has no future in which it becomes valid: two databases cannot hold one\n * set of rows. It is deliberately NOT a ban on aliased resources using\n * PostgreSQL — an alias group that agrees on PostgreSQL resolves to one shared\n * table, and whether that table was actually provisioned is a separate,\n * already-enforced question (the boot-time table verifier).\n *\n * Resources inherit the application default when they declare nothing, so the\n * caller supplies the resolved default rather than this function guessing it.\n *\n * Pure and side-effect free: it reports, the caller throws.\n *\n * @param resourceConfigurations - every assembled resource config, keyed by resource type.\n * @param defaultPersistenceAdapter - the adapter a config with no declaration inherits.\n * @returns one entry per incoherent collection; empty when the registry is coherent.\n */\nexport function findSharedPersistenceCollectionAdapterIncoherences(\n resourceConfigurations: Record<string, SharedPersistenceCollectionAdapterCandidate>,\n defaultPersistenceAdapter: PersistenceAdapterType,\n): SharedPersistenceCollectionAdapterIncoherence[] {\n const adaptersByCollection = new Map<\n string,\n { resourceType: ResourceType; adapter: PersistenceAdapterType }[]\n >();\n\n for (const [resourceTypeKey, resourceConfig] of Object.entries(resourceConfigurations)) {\n // Same reasoning as the retention guard: prefer the config's OWN identifier so a mis-keyed\n // registry entry is diagnosed against the name its author actually wrote.\n const resourceType = (resourceConfig?.resourceIdentifier ?? resourceTypeKey) as ResourceType;\n const collectionName = resolveSharedPersistenceCollectionName(resourceType);\n const entry = {\n resourceType,\n adapter: resourceConfig?.persistenceAdapter ?? defaultPersistenceAdapter,\n };\n\n const existing = adaptersByCollection.get(collectionName);\n if (existing) {\n existing.push(entry);\n } else {\n adaptersByCollection.set(collectionName, [entry]);\n }\n }\n\n const incoherences: SharedPersistenceCollectionAdapterIncoherence[] = [];\n\n for (const [collectionName, adapters] of adaptersByCollection) {\n if (adapters.length < 2) {\n continue;\n }\n if (new Set(adapters.map((entry) => entry.adapter)).size < 2) {\n continue;\n }\n\n const declared = adapters\n .map((entry) => `'${String(entry.resourceType)}' → ${entry.adapter}`)\n .join(', ');\n\n incoherences.push({\n collectionName,\n adapters,\n message:\n `Resource configs [${declared}] all address the '${collectionName}' persistence collection but ` +\n `resolve to DIFFERENT persistence adapters. These configs are separate doors onto ONE set of ` +\n `rows, and a collection name only addresses rows within a single database, so this splits them ` +\n `across two stores that each believe they own the records: the admin door lists rows the self ` +\n `door cannot read, a self-service write lands where the admin door will never see it, and an ` +\n `erasure performed through one door leaves the other door's copy fully intact. Give every ` +\n `config listed above the same persistenceAdapter (a resource sharing a collection cannot pick ` +\n `its database alone), or stop sharing the collection.`,\n });\n }\n\n return incoherences;\n}\n\n/** The minimal config shape {@link findSharedPersistenceCollectionRetentionIncoherences} reads. */\nexport interface SharedPersistenceCollectionRetentionCandidate {\n readonly resourceIdentifier: ResourceType;\n readonly retentionPolicy?: { mode?: ErasureRetentionMode } | undefined;\n}\n\n/**\n * Canonical comparison key for a resource's retention POSTURE.\n *\n * Compares the WHOLE resolved policy, not just `mode`. `ResourceRetentionPolicy` carries a single\n * axis today, so `mode` alone would be exhaustive — but this guard exists precisely because config\n * checks that look sufficient go quietly wrong later, and a second axis (a disposal clock, a\n * jurisdiction) added to the policy would otherwise escape the comparison with no compile-time\n * signal. Two configs over one collection must agree on ALL of it.\n *\n * Key order is normalised so authoring order cannot masquerade as a disagreement. `undefined` gets\n * its own key rather than being skipped: \"rows of this resource are hard-deleted\" is a positive\n * claim, and the in-vs-out asymmetry is what produces both failure modes documented below.\n */\nfunction buildRetentionPostureKey(retentionPolicy: { mode?: ErasureRetentionMode } | undefined): string {\n if (retentionPolicy === undefined || retentionPolicy === null) {\n return 'NOT_GOVERNED';\n }\n const entries = Object.entries(retentionPolicy as Record<string, unknown>)\n .filter(([, value]) => value !== undefined)\n .sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey));\n return entries.length === 0 ? 'NOT_GOVERNED' : JSON.stringify(entries);\n}\n\n/** One collection whose resource configs disagree about retention governance. */\nexport interface SharedPersistenceCollectionRetentionIncoherence {\n /** The shared collection the disagreeing configs write to. */\n readonly collectionName: string;\n /** Every resource config addressing that collection, with the posture it declared. */\n readonly postures: readonly { resourceType: ResourceType; mode: ErasureRetentionMode | undefined }[];\n /** Operator-facing explanation naming both failure modes and the fix. */\n readonly message: string;\n}\n\n/**\n * Registry-ASSEMBLY guardrail: every resource config that resolves to the SAME\n * persistence collection must declare the SAME retention posture.\n *\n * ## Why a config that passes every per-resource check can still be broken\n *\n * `retentionPolicy` is validated PER RESOURCE CONFIG by the config factory: it\n * checks that resource's operations, its field treatments, its system-access\n * grants. It cannot check what a SIBLING config declares, because a factory\n * invocation never sees one. But retention is enforced against ROWS, and two\n * configs can own the same rows (see\n * {@link RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES}). So a pair that\n * disagrees produces a config where every individual resource is valid and the\n * COLLECTION is not.\n *\n * ## The two concrete failure modes\n *\n * **1. Fail-open erasure.** The retention hide filter (rows marked `RETAINED`\n * are invisible) and the immutability freeze are injected per resource config,\n * in `buildContextualFilter`. A row erased through the governed door stays\n * fully READABLE and UPDATABLE through the ungoverned one. For the\n * `USERS`/`USER_SELF` pair that ungoverned door exposes READ + UPDATE to\n * `APP_USER` — i.e. the erased subject can still read and edit their own\n * \"erased\" record. The row is erased only from the door that was opted in,\n * which is a compliance-grade lie about the record.\n *\n * **2. Unique-index collision — a hard functional abort.** A retention-governed\n * config scopes each unique index to NON-retained rows (a partial filter on the\n * retention marker), precisely so scrubbed rows leave the index and cannot\n * collide on the shared mask value. An ungoverned config over the same\n * collection emits a PLAIN unique index on the same field. The FIRST erasure\n * succeeds; the SECOND writes the same mask value, hits the plain index, and\n * fails E11000 — inside the erasure transaction, so the whole erasure rolls\n * back. The capability is silently single-use.\n *\n * Both modes are invisible until a real erasure runs, which is why this is a\n * BOOT-time guard and not a test: the point is that a config which passes at\n * boot must actually be able to perform an erasure.\n *\n * ## Why \"one opted in, one not\" is a disagreement, not a default\n *\n * An absent `retentionPolicy` is a positive statement — \"rows of this resource\n * are hard-deleted\" — not an unset value the governed sibling can supply. Both\n * failure modes above are produced by exactly that asymmetry, so `undefined`\n * participates in the comparison as its own posture rather than being skipped.\n *\n * Pure and side-effect free: it reports, the caller throws. That keeps the\n * shared-collection fact and its invariant in the layer both persistence and\n * validation can import, while the registry owns the error shape.\n *\n * @param resourceConfigurations - every assembled resource config, keyed by resource type.\n * @returns one entry per incoherent collection; empty when the registry is coherent.\n */\nexport function findSharedPersistenceCollectionRetentionIncoherences(\n resourceConfigurations: Record<string, SharedPersistenceCollectionRetentionCandidate>,\n): SharedPersistenceCollectionRetentionIncoherence[] {\n const posturesByCollection = new Map<\n string,\n { resourceType: ResourceType; mode: ErasureRetentionMode | undefined; postureKey: string }[]\n >();\n\n for (const [resourceTypeKey, resourceConfig] of Object.entries(resourceConfigurations)) {\n // Prefer the config's OWN identifier over the map key: the registry keys by resource type, but a\n // host that mis-keyed an entry would otherwise be diagnosed against a name it never authored.\n const resourceType = (resourceConfig?.resourceIdentifier ?? resourceTypeKey) as ResourceType;\n const collectionName = resolveSharedPersistenceCollectionName(resourceType);\n const posture = {\n resourceType,\n mode: resourceConfig?.retentionPolicy?.mode,\n postureKey: buildRetentionPostureKey(resourceConfig?.retentionPolicy),\n };\n\n const existing = posturesByCollection.get(collectionName);\n if (existing) {\n existing.push(posture);\n } else {\n posturesByCollection.set(collectionName, [posture]);\n }\n }\n\n const incoherences: SharedPersistenceCollectionRetentionIncoherence[] = [];\n\n for (const [collectionName, postures] of posturesByCollection) {\n if (postures.length < 2) {\n continue;\n }\n const distinctPostures = new Set(postures.map((posture) => posture.postureKey));\n if (distinctPostures.size < 2) {\n continue;\n }\n\n const declared = postures\n .map((posture) => `'${String(posture.resourceType)}' → ${posture.mode ?? 'NOT retention-governed'}`)\n .join(', ');\n\n incoherences.push({\n collectionName,\n postures,\n message:\n `Resource configs [${declared}] all store in the '${collectionName}' collection but declare ` +\n `DIFFERENT retention postures. They are separate models over ONE set of rows, and retention is ` +\n `enforced per resource config, so this ships two defects that only appear when a real erasure ` +\n `runs: (1) FAIL-OPEN ERASURE — the retention hide filter and the immutability freeze are absent ` +\n `on the ungoverned door, leaving an erased row readable and updatable there; (2) UNIQUE-INDEX ` +\n `COLLISION — the governed config scopes its unique indexes to non-retained rows while the ` +\n `ungoverned one emits plain unique indexes on the same collection, so the SECOND erased row ` +\n `collides (E11000) and the erasure transaction rolls back. Declare the SAME retentionPolicy on ` +\n `every config listed above (a resource sharing a collection cannot opt in or out alone), or ` +\n `stop sharing the collection.`,\n });\n }\n\n return incoherences;\n}\n"]}
|
|
@@ -36,6 +36,18 @@ export interface SharedSaaSModule extends SharedDomainModule {
|
|
|
36
36
|
defaultProfile?: string;
|
|
37
37
|
unavailabilityPolicy?: Partial<FeatureConfiguration['unavailabilityPolicy']>;
|
|
38
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Progression milestones this module owns.
|
|
41
|
+
*
|
|
42
|
+
* ⚠️ **Milestones need the ANALYTICS capability enabled to appear at all.** The frontend fetches
|
|
43
|
+
* milestone definitions only when analytics is on and returns an empty list otherwise, so with it
|
|
44
|
+
* off the definitions never arrive and the progression tracker renders nothing — declared
|
|
45
|
+
* correctly, and invisible.
|
|
46
|
+
*
|
|
47
|
+
* Enabling analytics with an EMPTY provider list is what lights up the internal progression plane
|
|
48
|
+
* without any telemetry leaving the application. That is the configuration to reach for when an
|
|
49
|
+
* application wants progression and not tracking.
|
|
50
|
+
*/
|
|
39
51
|
customMilestoneDefinitions?: MilestoneDefinition[];
|
|
40
52
|
productDefinitions?: ProductDefinition[];
|
|
41
53
|
/**
|
|
@@ -44,6 +56,19 @@ export interface SharedSaaSModule extends SharedDomainModule {
|
|
|
44
56
|
* an "incomplete todos" count). Aggregated across modules by
|
|
45
57
|
* `buildSharedSaaSModulesRegistry` and threaded into the app init config, so a
|
|
46
58
|
* module owns its badge concern end-to-end with no app-level wiring.
|
|
59
|
+
*
|
|
60
|
+
* The framework ships NO badges of its own — every badge in an application is one that application
|
|
61
|
+
* declared.
|
|
62
|
+
*
|
|
63
|
+
* Two limits worth knowing before designing around one. A badge is scoped to a USER or to an
|
|
64
|
+
* ORGANIZATION and to nothing else; there is no application-wide scope. And a DERIVED badge is
|
|
65
|
+
* recomputed off the resource operation's own dispatch, so a change written by some other route
|
|
66
|
+
* does not move it — a client sees the corrected count on its next connection rather than
|
|
67
|
+
* immediately.
|
|
68
|
+
*
|
|
69
|
+
* A badge reference that does not resolve renders nothing, deliberately. The configuration
|
|
70
|
+
* verifier is what makes that loud: an unresolvable badge reference on a launcher item is reported
|
|
71
|
+
* when the application's navigation content is checked.
|
|
47
72
|
*/
|
|
48
73
|
notificationBadgeDefinitions?: NotificationBadgeDefinition[];
|
|
49
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-module.shared.definitions.d.ts","sourceRoot":"","sources":["../../../../src/runtime/domain-module.shared.definitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,KAAK,EAAE,oBAAoB,EAAiC,MAAM,+CAA+C,CAAC;AAKzH,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAA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C,CAAC,CAAC;KAC9E,CAAC;IACF,0BAA0B,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACnD,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACzC
|
|
1
|
+
{"version":3,"file":"domain-module.shared.definitions.d.ts","sourceRoot":"","sources":["../../../../src/runtime/domain-module.shared.definitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,KAAK,EAAE,oBAAoB,EAAiC,MAAM,+CAA+C,CAAC;AAKzH,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAC3F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAChG,OAAO,KAAK,EACV,2CAA2C,EAC3C,8CAA8C,EAC/C,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AAE1F;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,2CAA2C,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACpG,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,qBAAqB,CAAC,EAAE,oBAAoB,EAAE,CAAC;CAChD;AAED,wBAAgB,wBAAwB,CACtC,GAAG,OAAO,EAAE,kBAAkB,EAAE,GAC/B,kBAAkB,CAYpB;AACD,8DAA8D;AAE9D,MAAM,MAAM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AE,GAC7B,yBAAyB,CAgD3B;AAED,wBAAgB,sCAAsC,CACpD,QAAQ,EAAE,yBAAyB,GAClC,+BAA+B,GAAG,SAAS,CAuC7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-module.shared.definitions.js","sourceRoot":"","sources":["../../../../src/runtime/domain-module.shared.definitions.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,6BAA6B,IAAI,iCAAiC,EAClE,2BAA2B,GAC5B,MAAM,+CAA+C,CAAC;AAwBvD,MAAM,UAAU,wBAAwB,CACtC,GAAG,OAA6B;IAEhC,OAAO;QACL,sBAAsB,EAAE,MAAM,CAAC,MAAM,CACnC,EAAE,EACF,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CACgB;QAC/E,wBAAwB,EAAE,MAAM,CAAC,MAAM,CACrC,EAAE,EACF,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CACtC;QAC3B,qBAAqB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,qBAAqB,IAAI,EAAE,CAAC;KAC3E,CAAC;AACJ,CAAC;AA8CD,MAAM,UAAU,8BAA8B,CAC5C,GAAG,OAA2B;IAE9B,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,GAAG,OAAO,CAAC,CAAC;IAChE,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CACzC,EAAE,EACF,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,0BAA0B,EAAE,QAAQ,IAAI,EAAE,CAAC,CAC7C,CAAC;IACnC,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,MA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AQ,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS;QACjF,cAAc,EAAE,QAAQ,CAAC,0BAA0B,EAAE,cAAc;QACnE,oBAAoB,EAAE,4BAA4B;KACnD,CAAC;AACJ,CAAC","sourcesContent":["import type { ProductDefinition } from '../billing/product-definition.shared.schemas';\nimport type { FeatureConfiguration, FeatureUnavailabilityBehavior } from '../features/feature-definition.shared.schemas';\nimport {\n FeatureUnavailabilityBehavior as FeatureUnavailabilityBehaviorEnum,\n FeatureUnavailabilityReason,\n} from '../features/feature-definition.shared.schemas';\nimport type { FeatureDefinitionWithAutoRegister } from '../features/feature-builders.shared';\nimport type { CustomFeatureConfigurationInput } from '../features/feature-registry.shared';\nimport type { ScopeFeatures } from '../features/scope-features.shared.schemas';\nimport type { MilestoneDefinition } from '../guidance/milestone-definition.shared.schemas';\nimport type { NotificationBadgeDefinition } from '../notifications/notification-badges.schemas';\nimport type {\n ResourceConfiguration_InitializationFactory,\n ResourceConfiguration_InitializationFactoryMap,\n} from '../resources/resources-config.shared.schemas';\nimport type { ResourceRelationship } from '../resources/resources.shared.schemas';\nimport type { RolesConfiguration } from '../security/authorizations/roles.shared.schemas';\n\n/**\n * @wildo_source:part:start saas.models.shared-domain-module facet:layer:shared facet:family:module\n *\n * Cross-runtime module slice: resource factories, field identifiers, and relationship declarations merged across packages.\n */\nexport interface SharedDomainModule {\n resourceConfigurations?: Record<string, ResourceConfiguration_InitializationFactory<any, any, any>>;\n resourceFieldIdentifiers?: Record<string, string>;\n resourceRelationships?: ResourceRelationship[];\n}\n\nexport function mergeSharedDomainModules(\n ...modules: SharedDomainModule[]\n): SharedDomainModule {\n return {\n resourceConfigurations: Object.assign(\n {},\n ...modules.map(m => m.resourceConfigurations).filter(Boolean),\n ) as Record<string, ResourceConfiguration_InitializationFactory<any, any, any>>,\n resourceFieldIdentifiers: Object.assign(\n {},\n ...modules.map(m => m.resourceFieldIdentifiers).filter(Boolean),\n ) as Record<string, string>,\n resourceRelationships: modules.flatMap(m => m.resourceRelationships ?? []),\n };\n}\n/** @wildo_source:part:end saas.models.shared-domain-module */\n\nexport type ApplicationModuleKind = 'domain' | 'engine';\n\n/**\n * @wildo_source:part:start saas.models.shared-saas-module facet:layer:shared facet:family:module\n *\n * App module contract: id, kind, roles, feature/milestone/product/notification-badge definition hooks layered on shared resources.\n */\nexport interface SharedSaaSModule extends SharedDomainModule {\n moduleId: string;\n kind?: ApplicationModuleKind;\n customRoles?: RolesConfiguration;\n customFeatureDefinitions?: FeatureDefinitionWithAutoRegister[];\n customFeatureConfiguration?: {\n profiles?: Record<string, ScopeFeatures>;\n defaultProfile?: string;\n unavailabilityPolicy?: Partial<FeatureConfiguration['unavailabilityPolicy']>;\n };\n customMilestoneDefinitions?: MilestoneDefinition[];\n productDefinitions?: ProductDefinition[];\n /**\n * Notification badge definitions owned by this module (a module declares the\n * badges derived from / driven by its own resources — e.g. a tasks module owns\n * an \"incomplete todos\" count). Aggregated across modules by\n * `buildSharedSaaSModulesRegistry` and threaded into the app init config, so a\n * module owns its badge concern end-to-end with no app-level wiring.\n */\n notificationBadgeDefinitions?: NotificationBadgeDefinition[];\n}\n/** @wildo_source:part:end saas.models.shared-saas-module */\n\nexport interface SharedSaaSModulesRegistry {\n moduleIds: string[];\n resourceConfigurations: ResourceConfiguration_InitializationFactoryMap;\n resourceFieldIdentifiers: Record<string, string>;\n resourceRelationships: ResourceRelationship[];\n customRoles?: RolesConfiguration;\n customFeatureDefinitions: FeatureDefinitionWithAutoRegister[];\n customFeatureConfiguration?: SharedSaaSModule['customFeatureConfiguration'];\n customMilestoneDefinitions: MilestoneDefinition[];\n productDefinitions: ProductDefinition[];\n notificationBadgeDefinitions: NotificationBadgeDefinition[];\n}\n\nexport function buildSharedSaaSModulesRegistry(\n ...modules: SharedSaaSModule[]\n): SharedSaaSModulesRegistry {\n const mergedSharedModule = mergeSharedDomainModules(...modules);\n const mergedFeatureProfiles = Object.assign(\n {},\n ...modules.map((module) => module.customFeatureConfiguration?.profiles ?? {}),\n ) as Record<string, ScopeFeatures>;\n const hasFeatureProfiles = Object.keys(mergedFeatureProfiles).length > 0;\n\n const mergedUnavailabilityPolicy = Object.assign(\n {},\n ...modules\n .map((module) => module.customFeatureConfiguration?.unavailabilityPolicy)\n .filter(Boolean),\n ) as Partial<FeatureConfiguration['unavailabilityPolicy']>;\n const hasUnavailabilityPolicy = Object.keys(mergedUnavailabilityPolicy).length > 0;\n\n const defaultProfile = [...modules]\n .reverse()\n .find((module) => module.customFeatureConfiguration?.defaultProfile)\n ?.customFeatureConfiguration?.defaultProfile;\n\n const customFeatureConfiguration = hasFeatureProfiles || defaultProfile || hasUnavailabilityPolicy\n ? {\n profiles: hasFeatureProfiles ? mergedFeatureProfiles : undefined,\n defaultProfile,\n unavailabilityPolicy: hasUnavailabilityPolicy ? mergedUnavailabilityPolicy : undefined,\n }\n : undefined;\n\n const mergedRoles = Object.assign(\n {},\n ...modules.map((module) => module.customRoles ?? {}),\n ) as RolesConfiguration;\n\n return {\n moduleIds: modules\n .filter((module) => module.kind !== 'engine')\n .map((module) => module.moduleId),\n resourceConfigurations: (mergedSharedModule.resourceConfigurations ?? {}) as ResourceConfiguration_InitializationFactoryMap,\n resourceFieldIdentifiers: mergedSharedModule.resourceFieldIdentifiers ?? {},\n resourceRelationships: mergedSharedModule.resourceRelationships ?? [],\n customRoles: Object.keys(mergedRoles).length > 0 ? mergedRoles : undefined,\n customFeatureDefinitions: modules.flatMap((module) => module.customFeatureDefinitions ?? []),\n customFeatureConfiguration,\n customMilestoneDefinitions: modules.flatMap((module) => module.customMilestoneDefinitions ?? []),\n productDefinitions: modules.flatMap((module) => module.productDefinitions ?? []),\n notificationBadgeDefinitions: modules.flatMap((module) => module.notificationBadgeDefinitions ?? []),\n };\n}\n\nexport function buildFrontendFeatureConfigurationInput(\n registry: SharedSaaSModulesRegistry,\n): CustomFeatureConfigurationInput | undefined {\n const hasDefinitions = registry.customFeatureDefinitions.length > 0;\n const hasProfiles = Boolean(registry.customFeatureConfiguration?.profiles)\n && Object.keys(registry.customFeatureConfiguration?.profiles ?? {}).length > 0;\n const hasDefaultProfile = Boolean(registry.customFeatureConfiguration?.defaultProfile);\n const hasPolicy = Boolean(registry.customFeatureConfiguration?.unavailabilityPolicy)\n && Object.keys(registry.customFeatureConfiguration?.unavailabilityPolicy ?? {}).length > 0;\n\n const resolvedUnavailabilityPolicy: FeatureConfiguration['unavailabilityPolicy'] | undefined = hasPolicy\n ? {\n defaultBehavior: registry.customFeatureConfiguration?.unavailabilityPolicy?.defaultBehavior\n ?? FeatureUnavailabilityBehaviorEnum.UPGRADE_PROMPT,\n whenBillingDisabled: registry.customFeatureConfiguration?.unavailabilityPolicy?.whenBillingDisabled\n ?? FeatureUnavailabilityBehaviorEnum.HIDE,\n roleDefaults: registry.customFeatureConfiguration?.unavailabilityPolicy?.roleDefaults ?? {},\n reasonDefaults: {\n [FeatureUnavailabilityReason.FEATURE_NOT_ENABLED]:\n registry.customFeatureConfiguration?.unavailabilityPolicy?.reasonDefaults?.[FeatureUnavailabilityReason.FEATURE_NOT_ENABLED]\n ?? FeatureUnavailabilityBehaviorEnum.UPGRADE_PROMPT,\n [FeatureUnavailabilityReason.LIMIT_EXCEEDED]:\n registry.customFeatureConfiguration?.unavailabilityPolicy?.reasonDefaults?.[FeatureUnavailabilityReason.LIMIT_EXCEEDED]\n ?? FeatureUnavailabilityBehaviorEnum.LIMIT_UPGRADE_PROMPT,\n [FeatureUnavailabilityReason.NOT_CONFIGURED]:\n registry.customFeatureConfiguration?.unavailabilityPolicy?.reasonDefaults?.[FeatureUnavailabilityReason.NOT_CONFIGURED]\n ?? FeatureUnavailabilityBehaviorEnum.HIDE,\n },\n }\n : undefined;\n\n if (!hasDefinitions && !hasProfiles && !hasDefaultProfile && !hasPolicy) {\n return undefined;\n }\n\n return {\n definitions: hasDefinitions ? registry.customFeatureDefinitions : undefined,\n profiles: hasProfiles ? registry.customFeatureConfiguration?.profiles : undefined,\n defaultProfile: registry.customFeatureConfiguration?.defaultProfile,\n unavailabilityPolicy: resolvedUnavailabilityPolicy,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"domain-module.shared.definitions.js","sourceRoot":"","sources":["../../../../src/runtime/domain-module.shared.definitions.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,6BAA6B,IAAI,iCAAiC,EAClE,2BAA2B,GAC5B,MAAM,+CAA+C,CAAC;AAwBvD,MAAM,UAAU,wBAAwB,CACtC,GAAG,OAA6B;IAEhC,OAAO;QACL,sBAAsB,EAAE,MAAM,CAAC,MAAM,CACnC,EAAE,EACF,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CACgB;QAC/E,wBAAwB,EAAE,MAAM,CAAC,MAAM,CACrC,EAAE,EACF,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CACtC;QAC3B,qBAAqB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,qBAAqB,IAAI,EAAE,CAAC;KAC3E,CAAC;AACJ,CAAC;AAuED,MAAM,UAAU,8BAA8B,CAC5C,GAAG,OAA2B;IAE9B,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,GAAG,OAAO,CAAC,CAAC;IAChE,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CACzC,EAAE,EACF,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,0BAA0B,EAAE,QAAQ,IAAI,EAAE,CAAC,CAC7C,CAAC;IACnC,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAEzE,MAAM,0BAA0B,GAAG,MAAM,C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QACjF,cAAc,EAAE,QAAQ,CAAC,0BAA0B,EAAE,cAAc;QACnE,oBAAoB,EAAE,4BAA4B;KACnD,CAAC;AACJ,CAAC","sourcesContent":["import type { ProductDefinition } from '../billing/product-definition.shared.schemas';\nimport type { FeatureConfiguration, FeatureUnavailabilityBehavior } from '../features/feature-definition.shared.schemas';\nimport {\n FeatureUnavailabilityBehavior as FeatureUnavailabilityBehaviorEnum,\n FeatureUnavailabilityReason,\n} from '../features/feature-definition.shared.schemas';\nimport type { FeatureDefinitionWithAutoRegister } from '../features/feature-builders.shared';\nimport type { CustomFeatureConfigurationInput } from '../features/feature-registry.shared';\nimport type { ScopeFeatures } from '../features/scope-features.shared.schemas';\nimport type { MilestoneDefinition } from '../guidance/milestone-definition.shared.schemas';\nimport type { NotificationBadgeDefinition } from '../notifications/notification-badges.schemas';\nimport type {\n ResourceConfiguration_InitializationFactory,\n ResourceConfiguration_InitializationFactoryMap,\n} from '../resources/resources-config.shared.schemas';\nimport type { ResourceRelationship } from '../resources/resources.shared.schemas';\nimport type { RolesConfiguration } from '../security/authorizations/roles.shared.schemas';\n\n/**\n * @wildo_source:part:start saas.models.shared-domain-module facet:layer:shared facet:family:module\n *\n * Cross-runtime module slice: resource factories, field identifiers, and relationship declarations merged across packages.\n */\nexport interface SharedDomainModule {\n resourceConfigurations?: Record<string, ResourceConfiguration_InitializationFactory<any, any, any>>;\n resourceFieldIdentifiers?: Record<string, string>;\n resourceRelationships?: ResourceRelationship[];\n}\n\nexport function mergeSharedDomainModules(\n ...modules: SharedDomainModule[]\n): SharedDomainModule {\n return {\n resourceConfigurations: Object.assign(\n {},\n ...modules.map(m => m.resourceConfigurations).filter(Boolean),\n ) as Record<string, ResourceConfiguration_InitializationFactory<any, any, any>>,\n resourceFieldIdentifiers: Object.assign(\n {},\n ...modules.map(m => m.resourceFieldIdentifiers).filter(Boolean),\n ) as Record<string, string>,\n resourceRelationships: modules.flatMap(m => m.resourceRelationships ?? []),\n };\n}\n/** @wildo_source:part:end saas.models.shared-domain-module */\n\nexport type ApplicationModuleKind = 'domain' | 'engine';\n\n/**\n * @wildo_source:part:start saas.models.shared-saas-module facet:layer:shared facet:family:module\n *\n * App module contract: id, kind, roles, feature/milestone/product/notification-badge definition hooks layered on shared resources.\n */\nexport interface SharedSaaSModule extends SharedDomainModule {\n moduleId: string;\n kind?: ApplicationModuleKind;\n customRoles?: RolesConfiguration;\n customFeatureDefinitions?: FeatureDefinitionWithAutoRegister[];\n customFeatureConfiguration?: {\n profiles?: Record<string, ScopeFeatures>;\n defaultProfile?: string;\n unavailabilityPolicy?: Partial<FeatureConfiguration['unavailabilityPolicy']>;\n };\n /**\n * Progression milestones this module owns.\n *\n * ⚠️ **Milestones need the ANALYTICS capability enabled to appear at all.** The frontend fetches\n * milestone definitions only when analytics is on and returns an empty list otherwise, so with it\n * off the definitions never arrive and the progression tracker renders nothing — declared\n * correctly, and invisible.\n *\n * Enabling analytics with an EMPTY provider list is what lights up the internal progression plane\n * without any telemetry leaving the application. That is the configuration to reach for when an\n * application wants progression and not tracking.\n */\n customMilestoneDefinitions?: MilestoneDefinition[];\n productDefinitions?: ProductDefinition[];\n /**\n * Notification badge definitions owned by this module (a module declares the\n * badges derived from / driven by its own resources — e.g. a tasks module owns\n * an \"incomplete todos\" count). Aggregated across modules by\n * `buildSharedSaaSModulesRegistry` and threaded into the app init config, so a\n * module owns its badge concern end-to-end with no app-level wiring.\n *\n * The framework ships NO badges of its own — every badge in an application is one that application\n * declared.\n *\n * Two limits worth knowing before designing around one. A badge is scoped to a USER or to an\n * ORGANIZATION and to nothing else; there is no application-wide scope. And a DERIVED badge is\n * recomputed off the resource operation's own dispatch, so a change written by some other route\n * does not move it — a client sees the corrected count on its next connection rather than\n * immediately.\n *\n * A badge reference that does not resolve renders nothing, deliberately. The configuration\n * verifier is what makes that loud: an unresolvable badge reference on a launcher item is reported\n * when the application's navigation content is checked.\n */\n notificationBadgeDefinitions?: NotificationBadgeDefinition[];\n}\n/** @wildo_source:part:end saas.models.shared-saas-module */\n\nexport interface SharedSaaSModulesRegistry {\n moduleIds: string[];\n resourceConfigurations: ResourceConfiguration_InitializationFactoryMap;\n resourceFieldIdentifiers: Record<string, string>;\n resourceRelationships: ResourceRelationship[];\n customRoles?: RolesConfiguration;\n customFeatureDefinitions: FeatureDefinitionWithAutoRegister[];\n customFeatureConfiguration?: SharedSaaSModule['customFeatureConfiguration'];\n customMilestoneDefinitions: MilestoneDefinition[];\n productDefinitions: ProductDefinition[];\n notificationBadgeDefinitions: NotificationBadgeDefinition[];\n}\n\nexport function buildSharedSaaSModulesRegistry(\n ...modules: SharedSaaSModule[]\n): SharedSaaSModulesRegistry {\n const mergedSharedModule = mergeSharedDomainModules(...modules);\n const mergedFeatureProfiles = Object.assign(\n {},\n ...modules.map((module) => module.customFeatureConfiguration?.profiles ?? {}),\n ) as Record<string, ScopeFeatures>;\n const hasFeatureProfiles = Object.keys(mergedFeatureProfiles).length > 0;\n\n const mergedUnavailabilityPolicy = Object.assign(\n {},\n ...modules\n .map((module) => module.customFeatureConfiguration?.unavailabilityPolicy)\n .filter(Boolean),\n ) as Partial<FeatureConfiguration['unavailabilityPolicy']>;\n const hasUnavailabilityPolicy = Object.keys(mergedUnavailabilityPolicy).length > 0;\n\n const defaultProfile = [...modules]\n .reverse()\n .find((module) => module.customFeatureConfiguration?.defaultProfile)\n ?.customFeatureConfiguration?.defaultProfile;\n\n const customFeatureConfiguration = hasFeatureProfiles || defaultProfile || hasUnavailabilityPolicy\n ? {\n profiles: hasFeatureProfiles ? mergedFeatureProfiles : undefined,\n defaultProfile,\n unavailabilityPolicy: hasUnavailabilityPolicy ? mergedUnavailabilityPolicy : undefined,\n }\n : undefined;\n\n const mergedRoles = Object.assign(\n {},\n ...modules.map((module) => module.customRoles ?? {}),\n ) as RolesConfiguration;\n\n return {\n moduleIds: modules\n .filter((module) => module.kind !== 'engine')\n .map((module) => module.moduleId),\n resourceConfigurations: (mergedSharedModule.resourceConfigurations ?? {}) as ResourceConfiguration_InitializationFactoryMap,\n resourceFieldIdentifiers: mergedSharedModule.resourceFieldIdentifiers ?? {},\n resourceRelationships: mergedSharedModule.resourceRelationships ?? [],\n customRoles: Object.keys(mergedRoles).length > 0 ? mergedRoles : undefined,\n customFeatureDefinitions: modules.flatMap((module) => module.customFeatureDefinitions ?? []),\n customFeatureConfiguration,\n customMilestoneDefinitions: modules.flatMap((module) => module.customMilestoneDefinitions ?? []),\n productDefinitions: modules.flatMap((module) => module.productDefinitions ?? []),\n notificationBadgeDefinitions: modules.flatMap((module) => module.notificationBadgeDefinitions ?? []),\n };\n}\n\nexport function buildFrontendFeatureConfigurationInput(\n registry: SharedSaaSModulesRegistry,\n): CustomFeatureConfigurationInput | undefined {\n const hasDefinitions = registry.customFeatureDefinitions.length > 0;\n const hasProfiles = Boolean(registry.customFeatureConfiguration?.profiles)\n && Object.keys(registry.customFeatureConfiguration?.profiles ?? {}).length > 0;\n const hasDefaultProfile = Boolean(registry.customFeatureConfiguration?.defaultProfile);\n const hasPolicy = Boolean(registry.customFeatureConfiguration?.unavailabilityPolicy)\n && Object.keys(registry.customFeatureConfiguration?.unavailabilityPolicy ?? {}).length > 0;\n\n const resolvedUnavailabilityPolicy: FeatureConfiguration['unavailabilityPolicy'] | undefined = hasPolicy\n ? {\n defaultBehavior: registry.customFeatureConfiguration?.unavailabilityPolicy?.defaultBehavior\n ?? FeatureUnavailabilityBehaviorEnum.UPGRADE_PROMPT,\n whenBillingDisabled: registry.customFeatureConfiguration?.unavailabilityPolicy?.whenBillingDisabled\n ?? FeatureUnavailabilityBehaviorEnum.HIDE,\n roleDefaults: registry.customFeatureConfiguration?.unavailabilityPolicy?.roleDefaults ?? {},\n reasonDefaults: {\n [FeatureUnavailabilityReason.FEATURE_NOT_ENABLED]:\n registry.customFeatureConfiguration?.unavailabilityPolicy?.reasonDefaults?.[FeatureUnavailabilityReason.FEATURE_NOT_ENABLED]\n ?? FeatureUnavailabilityBehaviorEnum.UPGRADE_PROMPT,\n [FeatureUnavailabilityReason.LIMIT_EXCEEDED]:\n registry.customFeatureConfiguration?.unavailabilityPolicy?.reasonDefaults?.[FeatureUnavailabilityReason.LIMIT_EXCEEDED]\n ?? FeatureUnavailabilityBehaviorEnum.LIMIT_UPGRADE_PROMPT,\n [FeatureUnavailabilityReason.NOT_CONFIGURED]:\n registry.customFeatureConfiguration?.unavailabilityPolicy?.reasonDefaults?.[FeatureUnavailabilityReason.NOT_CONFIGURED]\n ?? FeatureUnavailabilityBehaviorEnum.HIDE,\n },\n }\n : undefined;\n\n if (!hasDefinitions && !hasProfiles && !hasDefaultProfile && !hasPolicy) {\n return undefined;\n }\n\n return {\n definitions: hasDefinitions ? registry.customFeatureDefinitions : undefined,\n profiles: hasProfiles ? registry.customFeatureConfiguration?.profiles : undefined,\n defaultProfile: registry.customFeatureConfiguration?.defaultProfile,\n unavailabilityPolicy: resolvedUnavailabilityPolicy,\n };\n}\n"]}
|
package/dist/esm/security/api-keys/api-keys-application.shared.resources-config.schemas.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare enum AppApiKeys_Operations {
|
|
|
15
15
|
DEACTIVATE = "deactivate",// Deactivate key
|
|
16
16
|
REACTIVATE = "reactivate",// Reactivate key
|
|
17
17
|
EXTEND_EXPIRY = "extend_expiry",// Extend expiration date
|
|
18
|
+
EXPIRE = "expire",// ACTIVE → EXPIRED once `expiresAt` has passed (dispatched by the sweep, not by an operator)
|
|
18
19
|
USAGE_STATS = "usage_stats"
|
|
19
20
|
}
|
|
20
21
|
type AppApiKeysCoreOperations = CoreResourceOperation.READ | CoreResourceOperation.LIST | CoreResourceOperation.SEARCH | CoreResourceOperation.CREATE | CoreResourceOperation.DELETE;
|
package/dist/esm/security/api-keys/api-keys-application.shared.resources-config.schemas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-keys-application.shared.resources-config.schemas.d.ts","sourceRoot":"","sources":["../../../../../src/security/api-keys/api-keys-application.shared.resources-config.schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,YAAY,EACb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAoD,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAMlI,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAgBxE,oBAAY,qBAAqB;IAC/B,MAAM,WAAW,CAAE,0CAA0C;IAC7D,UAAU,eAAe,CAAE,gDAAgD;IAC3E,UAAU,eAAe,CAAE,iBAAiB;IAC5C,UAAU,eAAe,CAAE,iBAAiB;IAC5C,aAAa,kBAAkB,CAAE,yBAAyB;IAC1D,WAAW,gBAAgB;CAC5B;AAED,KAAK,wBAAwB,GACzB,qBAAqB,CAAC,IAAI,GAC1B,qBAAqB,CAAC,IAAI,GAC1B,qBAAqB,CAAC,MAAM,GAC5B,qBAAqB,CAAC,MAAM,GAC5B,qBAAqB,CAAC,MAAM,CAAC;AAKjC,eAAO,MAAM,qDAAqD,GAAI,wBAAwB,oBAAoB,EAAE;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"api-keys-application.shared.resources-config.schemas.d.ts","sourceRoot":"","sources":["../../../../../src/security/api-keys/api-keys-application.shared.resources-config.schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,YAAY,EACb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAoD,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAMlI,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAgBxE,oBAAY,qBAAqB;IAC/B,MAAM,WAAW,CAAE,0CAA0C;IAC7D,UAAU,eAAe,CAAE,gDAAgD;IAC3E,UAAU,eAAe,CAAE,iBAAiB;IAC5C,UAAU,eAAe,CAAE,iBAAiB;IAC5C,aAAa,kBAAkB,CAAE,yBAAyB;IAC1D,MAAM,WAAW,CAAE,6FAA6F;IAChH,WAAW,gBAAgB;CAC5B;AAED,KAAK,wBAAwB,GACzB,qBAAqB,CAAC,IAAI,GAC1B,qBAAqB,CAAC,IAAI,GAC1B,qBAAqB,CAAC,MAAM,GAC5B,qBAAqB,CAAC,MAAM,GAC5B,qBAAqB,CAAC,MAAM,CAAC;AAKjC,eAAO,MAAM,qDAAqD,GAAI,wBAAwB,oBAAoB,EAAE;;;;;;;;;;;;;;;;;kBAyTlH,CAAC"}
|
|
@@ -31,6 +31,7 @@ export var AppApiKeys_Operations;
|
|
|
31
31
|
AppApiKeys_Operations["DEACTIVATE"] = "deactivate";
|
|
32
32
|
AppApiKeys_Operations["REACTIVATE"] = "reactivate";
|
|
33
33
|
AppApiKeys_Operations["EXTEND_EXPIRY"] = "extend_expiry";
|
|
34
|
+
AppApiKeys_Operations["EXPIRE"] = "expire";
|
|
34
35
|
AppApiKeys_Operations["USAGE_STATS"] = "usage_stats";
|
|
35
36
|
})(AppApiKeys_Operations || (AppApiKeys_Operations = {}));
|
|
36
37
|
/*
|
|
@@ -254,6 +255,43 @@ export const appApiKeysResourceConfiguration_InitializationFactory = (resourcesR
|
|
|
254
255
|
}
|
|
255
256
|
]
|
|
256
257
|
},
|
|
258
|
+
/**
|
|
259
|
+
* ACTIVE → EXPIRED, dispatched by the credential-expiry sweep once `expiresAt` has passed
|
|
260
|
+
* (#413). INTERNAL_CALL, so no HTTP route is mounted and no frontend affordance is offered:
|
|
261
|
+
* the sweep is the only caller.
|
|
262
|
+
*
|
|
263
|
+
* Not an operator verb, deliberately. An administrator who wants a key gone uses DEACTIVATE and
|
|
264
|
+
* one who wants it to last longer uses EXTEND_EXPIRY; there is no reason for a human to declare
|
|
265
|
+
* that a date has passed. Being INTERNAL_CALL also removes, rather than defends against, the
|
|
266
|
+
* hazard DEACTIVATE documents at length — with no route there is no request contract to
|
|
267
|
+
* auto-derive and no `PUT .../expire` that could carry `status: active`.
|
|
268
|
+
*
|
|
269
|
+
* It exists so the sweep writes through a GUARDED door rather than setting `status` directly: a
|
|
270
|
+
* direct write would be a second authority over the field and would skip the ACTIVE-only
|
|
271
|
+
* precondition, which lives in the paired prefix implementation
|
|
272
|
+
* (`api-keys.custom-impl.backend.service.ts`) because that is the enforcement an
|
|
273
|
+
* `enabledCondition` cannot be.
|
|
274
|
+
*/
|
|
275
|
+
[AppApiKeys_Operations.EXPIRE]: {
|
|
276
|
+
variants: [
|
|
277
|
+
{
|
|
278
|
+
variantType: ResourceOperationVariantType.INTERNAL_CALL,
|
|
279
|
+
isDefault: true,
|
|
280
|
+
roles: [CORE_APP_ROLES.APP_ADMIN_SUPER_ADMIN],
|
|
281
|
+
riskLevel: ResourceOperationRiskLevel.LOW,
|
|
282
|
+
resourceOperationLike: CoreResourceOperation.UPDATE,
|
|
283
|
+
// EMPTY BY CONTRACT, not by omission. The credential-expiry sweep dispatches this verb with `{}`
|
|
284
|
+
// and the paired prefix implementation forces the status transition itself, so there is no field
|
|
285
|
+
// a caller may supply. Declaring nothing is NOT the same as declaring this: an operation without
|
|
286
|
+
// a `requestDto` inherits the resource's ENTIRE update contract, which would let an INTERNAL_CALL
|
|
287
|
+
// that accepts nothing advertise every field — `status` included, the one field this verb owns.
|
|
288
|
+
requestDto: z.object({}),
|
|
289
|
+
}
|
|
290
|
+
],
|
|
291
|
+
// No notification: expiry is the scheduled consequence of a date the administrator set, not
|
|
292
|
+
// an event. The signal that would be worth sending — a key ABOUT to expire — is a different
|
|
293
|
+
// feature and is not this one.
|
|
294
|
+
},
|
|
257
295
|
[AppApiKeys_Operations.EXTEND_EXPIRY]: {
|
|
258
296
|
variants: [
|
|
259
297
|
{
|