primitive-admin 1.2.0-alpha.9 → 1.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +258 -186
- package/assets/skill/skills/primitive-platform/SKILL.md +93 -27
- package/dist/bin/primitive.js +15 -89
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/admins.js +80 -17
- package/dist/src/commands/admins.js.map +1 -1
- package/dist/src/commands/agent-sessions.d.ts +129 -0
- package/dist/src/commands/agent-sessions.js +532 -20
- package/dist/src/commands/agent-sessions.js.map +1 -1
- package/dist/src/commands/analytics.js +207 -155
- package/dist/src/commands/analytics.js.map +1 -1
- package/dist/src/commands/apps-children.js +3 -0
- package/dist/src/commands/apps-children.js.map +1 -1
- package/dist/src/commands/apps-transitions.d.ts +39 -0
- package/dist/src/commands/apps-transitions.js +198 -0
- package/dist/src/commands/apps-transitions.js.map +1 -0
- package/dist/src/commands/apps.d.ts +17 -0
- package/dist/src/commands/apps.js +108 -3
- package/dist/src/commands/apps.js.map +1 -1
- package/dist/src/commands/auth-sessions.js +2 -0
- package/dist/src/commands/auth-sessions.js.map +1 -1
- package/dist/src/commands/auth.js +138 -44
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/blob-buckets.js +2 -0
- package/dist/src/commands/blob-buckets.js.map +1 -1
- package/dist/src/commands/collections.js +318 -256
- package/dist/src/commands/collections.js.map +1 -1
- package/dist/src/commands/comparisons.js +2 -0
- package/dist/src/commands/comparisons.js.map +1 -1
- package/dist/src/commands/config.d.ts +2 -2
- package/dist/src/commands/config.js +59 -33
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/connections.js +2 -0
- package/dist/src/commands/connections.js.map +1 -1
- package/dist/src/commands/database-type-configs.js +5 -3
- package/dist/src/commands/database-type-configs.js.map +1 -1
- package/dist/src/commands/databases.js +6 -4
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/db3-types.d.ts +15 -0
- package/dist/src/commands/db3-types.js +159 -0
- package/dist/src/commands/db3-types.js.map +1 -0
- package/dist/src/commands/db3.d.ts +24 -0
- package/dist/src/commands/db3.js +1444 -0
- package/dist/src/commands/db3.js.map +1 -0
- package/dist/src/commands/documents.d.ts +110 -10
- package/dist/src/commands/documents.js +1012 -748
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/email-templates.js +74 -0
- package/dist/src/commands/email-templates.js.map +1 -1
- package/dist/src/commands/env.js +8 -4
- package/dist/src/commands/env.js.map +1 -1
- package/dist/src/commands/function-trigger-commands.d.ts +28 -0
- package/dist/src/commands/function-trigger-commands.js +341 -0
- package/dist/src/commands/function-trigger-commands.js.map +1 -0
- package/dist/src/commands/functions.js +376 -30
- package/dist/src/commands/functions.js.map +1 -1
- package/dist/src/commands/groups.js +168 -50
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/guides.js +7 -5
- package/dist/src/commands/guides.js.map +1 -1
- package/dist/src/commands/hosting.d.ts +8 -0
- package/dist/src/commands/hosting.js +346 -0
- package/dist/src/commands/hosting.js.map +1 -0
- package/dist/src/commands/init.js +129 -38
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.js +82 -53
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/locks.d.ts +5 -3
- package/dist/src/commands/locks.js +19 -61
- package/dist/src/commands/locks.js.map +1 -1
- package/dist/src/commands/metadata-category-configs.d.ts +2 -2
- package/dist/src/commands/metadata-category-configs.js +4 -2
- package/dist/src/commands/metadata-category-configs.js.map +1 -1
- package/dist/src/commands/metadata.js +41 -0
- package/dist/src/commands/metadata.js.map +1 -1
- package/dist/src/commands/prompts.js +75 -52
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/rate-counters.d.ts +19 -0
- package/dist/src/commands/rate-counters.js +104 -0
- package/dist/src/commands/rate-counters.js.map +1 -0
- package/dist/src/commands/rule-sets.d.ts +1 -1
- package/dist/src/commands/rule-sets.js +2 -1
- package/dist/src/commands/rule-sets.js.map +1 -1
- package/dist/src/commands/schemas.d.ts +15 -0
- package/dist/src/commands/schemas.js +122 -0
- package/dist/src/commands/schemas.js.map +1 -0
- package/dist/src/commands/scripts.d.ts +9 -17
- package/dist/src/commands/scripts.js +24 -479
- package/dist/src/commands/scripts.js.map +1 -1
- package/dist/src/commands/secrets.js +47 -3
- package/dist/src/commands/secrets.js.map +1 -1
- package/dist/src/commands/sessions.js +2 -0
- package/dist/src/commands/sessions.js.map +1 -1
- package/dist/src/commands/skill.js +2 -0
- package/dist/src/commands/skill.js.map +1 -1
- package/dist/src/commands/sync-schemas.d.ts +202 -0
- package/dist/src/commands/sync-schemas.js +629 -0
- package/dist/src/commands/sync-schemas.js.map +1 -0
- package/dist/src/commands/sync-user-properties.d.ts +118 -0
- package/dist/src/commands/sync-user-properties.js +276 -0
- package/dist/src/commands/sync-user-properties.js.map +1 -0
- package/dist/src/commands/sync.d.ts +518 -546
- package/dist/src/commands/sync.js +3010 -4877
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/tokens.js +5 -3
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/commands/transitions.d.ts +54 -0
- package/dist/src/commands/transitions.js +418 -0
- package/dist/src/commands/transitions.js.map +1 -0
- package/dist/src/commands/usage.d.ts +18 -0
- package/dist/src/commands/usage.js +343 -0
- package/dist/src/commands/usage.js.map +1 -0
- package/dist/src/commands/user-properties.d.ts +14 -0
- package/dist/src/commands/user-properties.js +79 -0
- package/dist/src/commands/user-properties.js.map +1 -0
- package/dist/src/commands/users.js +911 -18
- package/dist/src/commands/users.js.map +1 -1
- package/dist/src/commands/vars.js +2 -0
- package/dist/src/commands/vars.js.map +1 -1
- package/dist/src/commands/waitlist.js +39 -4
- package/dist/src/commands/waitlist.js.map +1 -1
- package/dist/src/commands/workflows.d.ts +5 -83
- package/dist/src/commands/workflows.js +57 -2282
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/analytics-query.d.ts +58 -0
- package/dist/src/lib/analytics-query.js +134 -0
- package/dist/src/lib/analytics-query.js.map +1 -0
- package/dist/src/lib/api-client.d.ts +1818 -438
- package/dist/src/lib/api-client.js +965 -544
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +1 -1
- package/dist/src/lib/app-settings-descriptor.js +6 -0
- package/dist/src/lib/app-settings-descriptor.js.map +1 -1
- package/dist/src/lib/auth-fixtures.d.ts +44 -0
- package/dist/src/lib/auth-fixtures.js +61 -0
- package/dist/src/lib/auth-fixtures.js.map +1 -0
- package/dist/src/lib/auth-flow.d.ts +34 -1
- package/dist/src/lib/auth-flow.js +429 -13
- package/dist/src/lib/auth-flow.js.map +1 -1
- package/dist/src/lib/block-layout.d.ts +12 -23
- package/dist/src/lib/block-layout.js +26 -92
- package/dist/src/lib/block-layout.js.map +1 -1
- package/dist/src/lib/block-selector.d.ts +8 -14
- package/dist/src/lib/block-selector.js +8 -19
- package/dist/src/lib/block-selector.js.map +1 -1
- package/dist/src/lib/child-apps-local.d.ts +3 -1
- package/dist/src/lib/child-apps-local.js +9 -1
- package/dist/src/lib/child-apps-local.js.map +1 -1
- package/dist/src/lib/cli-manifest.d.ts +9 -0
- package/dist/src/lib/cli-manifest.js +10 -1
- package/dist/src/lib/cli-manifest.js.map +1 -1
- package/dist/src/lib/cli-version.d.ts +14 -0
- package/dist/src/lib/cli-version.js +38 -0
- package/dist/src/lib/cli-version.js.map +1 -0
- package/dist/src/lib/codegen-shared/prettierStable.d.ts +41 -0
- package/dist/src/lib/codegen-shared/prettierStable.js +146 -24
- package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -1
- package/dist/src/lib/collection-export.d.ts +76 -15
- package/dist/src/lib/collection-export.js +116 -23
- package/dist/src/lib/collection-export.js.map +1 -1
- package/dist/src/lib/collection-principal.d.ts +22 -0
- package/dist/src/lib/collection-principal.js +35 -0
- package/dist/src/lib/collection-principal.js.map +1 -0
- package/dist/src/lib/command-groups.d.ts +30 -0
- package/dist/src/lib/command-groups.js +109 -0
- package/dist/src/lib/command-groups.js.map +1 -0
- package/dist/src/lib/command-status.d.ts +147 -0
- package/dist/src/lib/command-status.js +266 -0
- package/dist/src/lib/command-status.js.map +1 -0
- package/dist/src/lib/config-object-descriptor.d.ts +9 -22
- package/dist/src/lib/config-object-descriptor.js +107 -276
- package/dist/src/lib/config-object-descriptor.js.map +1 -1
- package/dist/src/lib/config-surface.d.ts +3 -7
- package/dist/src/lib/config-surface.js +9 -13
- package/dist/src/lib/config-surface.js.map +1 -1
- package/dist/src/lib/config-toml.d.ts +11 -2
- package/dist/src/lib/config-toml.js +25 -2
- package/dist/src/lib/config-toml.js.map +1 -1
- package/dist/src/lib/credentials-home.d.ts +7 -0
- package/dist/src/lib/credentials-home.js +45 -10
- package/dist/src/lib/credentials-home.js.map +1 -1
- package/dist/src/lib/credentials-lock.d.ts +14 -6
- package/dist/src/lib/credentials-lock.js +90 -10
- package/dist/src/lib/credentials-lock.js.map +1 -1
- package/dist/src/lib/credentials-store.d.ts +123 -70
- package/dist/src/lib/credentials-store.js +358 -113
- package/dist/src/lib/credentials-store.js.map +1 -1
- package/dist/src/lib/custodian.d.ts +8 -0
- package/dist/src/lib/custodian.js +18 -0
- package/dist/src/lib/custodian.js.map +1 -0
- package/dist/src/lib/data-input.d.ts +1 -1
- package/dist/src/lib/data-input.js +1 -1
- package/dist/src/lib/db-codegen/dbTsTypes.d.ts +1 -1
- package/dist/src/lib/db-codegen/dbTsTypes.js +3 -0
- package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTypeIR.d.ts +38 -1
- package/dist/src/lib/db-codegen/dbTypeIR.js +29 -7
- package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
- package/dist/src/lib/db-type-records.d.ts +106 -0
- package/dist/src/lib/db-type-records.js +224 -0
- package/dist/src/lib/db-type-records.js.map +1 -0
- package/dist/src/lib/db3-export.d.ts +287 -0
- package/dist/src/lib/db3-export.js +647 -0
- package/dist/src/lib/db3-export.js.map +1 -0
- package/dist/src/lib/db3-index-output.d.ts +116 -0
- package/dist/src/lib/db3-index-output.js +223 -0
- package/dist/src/lib/db3-index-output.js.map +1 -0
- package/dist/src/lib/db3-type-models.d.ts +134 -0
- package/dist/src/lib/db3-type-models.js +452 -0
- package/dist/src/lib/db3-type-models.js.map +1 -0
- package/dist/src/lib/deprecation.d.ts +2 -2
- package/dist/src/lib/deprecation.js +2 -2
- package/dist/src/lib/document-ingest-artifact.d.ts +13 -0
- package/dist/src/lib/document-ingest-artifact.js +36 -6
- package/dist/src/lib/document-ingest-artifact.js.map +1 -1
- package/dist/src/lib/document-ingest-format2.d.ts +36 -0
- package/dist/src/lib/document-ingest-format2.js +78 -0
- package/dist/src/lib/document-ingest-format2.js.map +1 -0
- package/dist/src/lib/document-ingest-input.d.ts +9 -0
- package/dist/src/lib/document-ingest-input.js +28 -1
- package/dist/src/lib/document-ingest-input.js.map +1 -1
- package/dist/src/lib/document-ingest.d.ts +11 -1
- package/dist/src/lib/document-ingest.js +16 -0
- package/dist/src/lib/document-ingest.js.map +1 -1
- package/dist/src/lib/document-schema-rows.d.ts +42 -0
- package/dist/src/lib/document-schema-rows.js +53 -0
- package/dist/src/lib/document-schema-rows.js.map +1 -0
- package/dist/src/lib/experimental-apis.d.ts +36 -0
- package/dist/src/lib/experimental-apis.js +46 -0
- package/dist/src/lib/experimental-apis.js.map +1 -0
- package/dist/src/lib/file-attachment.d.ts +24 -0
- package/dist/src/lib/file-attachment.js +31 -0
- package/dist/src/lib/file-attachment.js.map +1 -0
- package/dist/src/lib/function-authorize-check.d.ts +142 -0
- package/dist/src/lib/function-authorize-check.js +311 -0
- package/dist/src/lib/function-authorize-check.js.map +1 -0
- package/dist/src/lib/function-authorize-view.d.ts +27 -0
- package/dist/src/lib/function-authorize-view.js +88 -0
- package/dist/src/lib/function-authorize-view.js.map +1 -0
- package/dist/src/lib/function-bundle.d.ts +27 -5
- package/dist/src/lib/function-bundle.js +142 -7
- package/dist/src/lib/function-bundle.js.map +1 -1
- package/dist/src/lib/function-collect.d.ts +90 -12
- package/dist/src/lib/function-collect.js +482 -12
- package/dist/src/lib/function-collect.js.map +1 -1
- package/dist/src/lib/function-db-types.d.ts +65 -11
- package/dist/src/lib/function-db-types.js +297 -157
- package/dist/src/lib/function-db-types.js.map +1 -1
- package/dist/src/lib/function-document-types.d.ts +19 -7
- package/dist/src/lib/function-document-types.js +24 -12
- package/dist/src/lib/function-document-types.js.map +1 -1
- package/dist/src/lib/function-lint.d.ts +57 -0
- package/dist/src/lib/function-lint.js +234 -0
- package/dist/src/lib/function-lint.js.map +1 -0
- package/dist/src/lib/function-log-row.js +21 -2
- package/dist/src/lib/function-log-row.js.map +1 -1
- package/dist/src/lib/function-run.d.ts +13 -21
- package/dist/src/lib/function-run.js +14 -27
- package/dist/src/lib/function-run.js.map +1 -1
- package/dist/src/lib/function-schema-codegen.d.ts +86 -22
- package/dist/src/lib/function-schema-codegen.js +194 -88
- package/dist/src/lib/function-schema-codegen.js.map +1 -1
- package/dist/src/lib/function-schema-refs.d.ts +98 -0
- package/dist/src/lib/function-schema-refs.js +177 -0
- package/dist/src/lib/function-schema-refs.js.map +1 -0
- package/dist/src/lib/function-sync.d.ts +109 -6
- package/dist/src/lib/function-sync.js +179 -26
- package/dist/src/lib/function-sync.js.map +1 -1
- package/dist/src/lib/function-trigger-listing.d.ts +11 -6
- package/dist/src/lib/function-trigger-listing.js +32 -11
- package/dist/src/lib/function-trigger-listing.js.map +1 -1
- package/dist/src/lib/function-typecheck.d.ts +52 -0
- package/dist/src/lib/function-typecheck.js +174 -54
- package/dist/src/lib/function-typecheck.js.map +1 -1
- package/dist/src/lib/function-versions.d.ts +2 -0
- package/dist/src/lib/function-versions.js +1 -0
- package/dist/src/lib/function-versions.js.map +1 -1
- package/dist/src/lib/generated-build-flags.d.ts +13 -0
- package/dist/src/lib/generated-build-flags.js +14 -0
- package/dist/src/lib/generated-build-flags.js.map +1 -0
- package/dist/src/lib/generated-command-status.d.ts +6 -0
- package/dist/src/lib/generated-command-status.js +469 -0
- package/dist/src/lib/generated-command-status.js.map +1 -0
- package/dist/src/lib/generated-config-surfaces.d.ts +538 -141
- package/dist/src/lib/generated-config-surfaces.js +1772 -1854
- package/dist/src/lib/generated-config-surfaces.js.map +1 -1
- package/dist/src/lib/generated-sdk-types.d.ts +1 -1
- package/dist/src/lib/generated-sdk-types.js +1 -1
- package/dist/src/lib/generated-sdk-types.js.map +1 -1
- package/dist/src/lib/hosting-build.d.ts +97 -0
- package/dist/src/lib/hosting-build.js +204 -0
- package/dist/src/lib/hosting-build.js.map +1 -0
- package/dist/src/lib/hosting-client.d.ts +167 -0
- package/dist/src/lib/hosting-client.js +340 -0
- package/dist/src/lib/hosting-client.js.map +1 -0
- package/dist/src/lib/hosting-environments.d.ts +32 -0
- package/dist/src/lib/hosting-environments.js +74 -0
- package/dist/src/lib/hosting-environments.js.map +1 -0
- package/dist/src/lib/hosting-errors.d.ts +30 -0
- package/dist/src/lib/hosting-errors.js +43 -0
- package/dist/src/lib/hosting-errors.js.map +1 -0
- package/dist/src/lib/hosting-token.d.ts +46 -0
- package/dist/src/lib/hosting-token.js +60 -0
- package/dist/src/lib/hosting-token.js.map +1 -0
- package/dist/src/lib/hosting-wait.d.ts +42 -0
- package/dist/src/lib/hosting-wait.js +84 -0
- package/dist/src/lib/hosting-wait.js.map +1 -0
- package/dist/src/lib/hosting-wfp-upload.d.ts +86 -0
- package/dist/src/lib/hosting-wfp-upload.js +149 -0
- package/dist/src/lib/hosting-wfp-upload.js.map +1 -0
- package/dist/src/lib/init-assets.d.ts +2 -6
- package/dist/src/lib/init-assets.js +11 -27
- package/dist/src/lib/init-assets.js.map +1 -1
- package/dist/src/lib/init-ios-links.d.ts +11 -7
- package/dist/src/lib/init-ios-links.js +28 -22
- package/dist/src/lib/init-ios-links.js.map +1 -1
- package/dist/src/lib/init-login-note.d.ts +13 -0
- package/dist/src/lib/init-login-note.js +22 -0
- package/dist/src/lib/init-login-note.js.map +1 -0
- package/dist/src/lib/init-schema.d.ts +15 -0
- package/dist/src/lib/init-schema.js +54 -0
- package/dist/src/lib/init-schema.js.map +1 -1
- package/dist/src/lib/integration-test-request.d.ts +54 -0
- package/dist/src/lib/integration-test-request.js +207 -0
- package/dist/src/lib/integration-test-request.js.map +1 -0
- package/dist/src/lib/invoker-shared-enums.d.ts +35 -0
- package/dist/src/lib/invoker-shared-enums.js +98 -0
- package/dist/src/lib/invoker-shared-enums.js.map +1 -0
- package/dist/src/lib/json-value.d.ts +6 -0
- package/dist/src/lib/json-value.js +13 -0
- package/dist/src/lib/json-value.js.map +1 -0
- package/dist/src/lib/load-routes.d.ts +33 -0
- package/dist/src/lib/load-routes.js +35 -0
- package/dist/src/lib/load-routes.js.map +1 -0
- package/dist/src/lib/log-inspection.d.ts +23 -4
- package/dist/src/lib/log-inspection.js +14 -5
- package/dist/src/lib/log-inspection.js.map +1 -1
- package/dist/src/lib/login-exchange-check.d.ts +18 -0
- package/dist/src/lib/login-exchange-check.js +27 -0
- package/dist/src/lib/login-exchange-check.js.map +1 -0
- package/dist/src/lib/login-scope-lines.d.ts +17 -7
- package/dist/src/lib/login-scope-lines.js +33 -10
- package/dist/src/lib/login-scope-lines.js.map +1 -1
- package/dist/src/lib/metadata-report.d.ts +85 -0
- package/dist/src/lib/metadata-report.js +81 -0
- package/dist/src/lib/metadata-report.js.map +1 -0
- package/dist/src/lib/object-status-filter.d.ts +9 -1
- package/dist/src/lib/object-status-filter.js +9 -1
- package/dist/src/lib/object-status-filter.js.map +1 -1
- package/dist/src/lib/output.d.ts +1 -1
- package/dist/src/lib/output.js +3 -1
- package/dist/src/lib/output.js.map +1 -1
- package/dist/src/lib/pin-refusal-hint.d.ts +12 -0
- package/dist/src/lib/pin-refusal-hint.js +35 -0
- package/dist/src/lib/pin-refusal-hint.js.map +1 -0
- package/dist/src/lib/platform-owned.js +5 -0
- package/dist/src/lib/platform-owned.js.map +1 -1
- package/dist/src/lib/primitive-declaration-names.d.ts +21 -0
- package/dist/src/lib/primitive-declaration-names.js +22 -0
- package/dist/src/lib/primitive-declaration-names.js.map +1 -0
- package/dist/src/lib/primitive-declaration.d.ts +174 -0
- package/dist/src/lib/primitive-declaration.js +792 -0
- package/dist/src/lib/primitive-declaration.js.map +1 -0
- package/dist/src/lib/primitive-env-plugin.d.ts +99 -0
- package/dist/src/lib/primitive-env-plugin.js +408 -0
- package/dist/src/lib/primitive-env-plugin.js.map +1 -0
- package/dist/src/lib/project-login-apps.d.ts +8 -0
- package/dist/src/lib/project-login-apps.js +27 -0
- package/dist/src/lib/project-login-apps.js.map +1 -0
- package/dist/src/lib/prompt-schema-codegen.d.ts +36 -12
- package/dist/src/lib/prompt-schema-codegen.js +96 -100
- package/dist/src/lib/prompt-schema-codegen.js.map +1 -1
- package/dist/src/lib/prompt-schema-document.d.ts +35 -0
- package/dist/src/lib/prompt-schema-document.js +92 -0
- package/dist/src/lib/prompt-schema-document.js.map +1 -0
- package/dist/src/lib/prompt-schema-refs.d.ts +173 -0
- package/dist/src/lib/prompt-schema-refs.js +478 -0
- package/dist/src/lib/prompt-schema-refs.js.map +1 -0
- package/dist/src/lib/records-verbs.d.ts +79 -0
- package/dist/src/lib/records-verbs.js +45 -0
- package/dist/src/lib/records-verbs.js.map +1 -0
- package/dist/src/lib/register-commands.d.ts +36 -0
- package/dist/src/lib/register-commands.js +37 -0
- package/dist/src/lib/register-commands.js.map +1 -0
- package/dist/src/lib/retired-imports.d.ts +53 -0
- package/dist/src/lib/retired-imports.js +120 -0
- package/dist/src/lib/retired-imports.js.map +1 -0
- package/dist/src/lib/run-status.d.ts +1 -1
- package/dist/src/lib/run-status.generated.d.ts +2 -2
- package/dist/src/lib/run-status.generated.js +3 -1
- package/dist/src/lib/run-status.generated.js.map +1 -1
- package/dist/src/lib/run-status.js +1 -1
- package/dist/src/lib/schema-codegen/compiledSpace.d.ts +62 -0
- package/dist/src/lib/schema-codegen/compiledSpace.js +103 -0
- package/dist/src/lib/schema-codegen/compiledSpace.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-db3-bridge.d.ts +86 -0
- package/dist/src/lib/schema-codegen/generated-db3-bridge.js +227 -0
- package/dist/src/lib/schema-codegen/generated-db3-bridge.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.d.ts +85 -0
- package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js +86 -0
- package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-field-grammar.d.ts +218 -0
- package/dist/src/lib/schema-codegen/generated-field-grammar.js +397 -0
- package/dist/src/lib/schema-codegen/generated-field-grammar.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-field-table.d.ts +80 -0
- package/dist/src/lib/schema-codegen/generated-field-table.js +542 -0
- package/dist/src/lib/schema-codegen/generated-field-table.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-prompt-schemas.d.ts +195 -0
- package/dist/src/lib/schema-codegen/generated-prompt-schemas.js +503 -0
- package/dist/src/lib/schema-codegen/generated-prompt-schemas.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-descriptor.d.ts +258 -0
- package/dist/src/lib/schema-codegen/generated-schema-descriptor.js +422 -0
- package/dist/src/lib/schema-codegen/generated-schema-descriptor.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-file.d.ts +129 -0
- package/dist/src/lib/schema-codegen/generated-schema-file.js +475 -0
- package/dist/src/lib/schema-codegen/generated-schema-file.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-provenance.d.ts +115 -0
- package/dist/src/lib/schema-codegen/generated-schema-provenance.js +274 -0
- package/dist/src/lib/schema-codegen/generated-schema-provenance.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-refs.d.ts +366 -0
- package/dist/src/lib/schema-codegen/generated-schema-refs.js +1789 -0
- package/dist/src/lib/schema-codegen/generated-schema-refs.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-shape.d.ts +27 -0
- package/dist/src/lib/schema-codegen/generated-schema-shape.js +126 -0
- package/dist/src/lib/schema-codegen/generated-schema-shape.js.map +1 -0
- package/dist/src/lib/schema-codegen/namedRefs.d.ts +56 -0
- package/dist/src/lib/schema-codegen/namedRefs.js +143 -0
- package/dist/src/lib/schema-codegen/namedRefs.js.map +1 -0
- package/dist/src/lib/schema-codegen/naming.d.ts +35 -0
- package/dist/src/lib/schema-codegen/naming.js +83 -0
- package/dist/src/lib/schema-codegen/naming.js.map +1 -0
- package/dist/src/lib/schema-codegen/schemaChanges.d.ts +74 -0
- package/dist/src/lib/schema-codegen/schemaChanges.js +277 -0
- package/dist/src/lib/schema-codegen/schemaChanges.js.map +1 -0
- package/dist/src/lib/schema-codegen/schemaDocs.d.ts +69 -0
- package/dist/src/lib/schema-codegen/schemaDocs.js +219 -0
- package/dist/src/lib/schema-codegen/schemaDocs.js.map +1 -0
- package/dist/src/lib/schema-codegen/schemaIR.d.ts +158 -0
- package/dist/src/lib/schema-codegen/schemaIR.js +279 -0
- package/dist/src/lib/schema-codegen/schemaIR.js.map +1 -0
- package/dist/src/lib/schema-codegen/schemaToTs.d.ts +109 -0
- package/dist/src/lib/schema-codegen/schemaToTs.js +269 -0
- package/dist/src/lib/schema-codegen/schemaToTs.js.map +1 -0
- package/dist/src/lib/schema-codegen/valuesLists.d.ts +48 -0
- package/dist/src/lib/schema-codegen/valuesLists.js +144 -0
- package/dist/src/lib/schema-codegen/valuesLists.js.map +1 -0
- package/dist/src/lib/schema-family-index.d.ts +228 -0
- package/dist/src/lib/schema-family-index.js +813 -0
- package/dist/src/lib/schema-family-index.js.map +1 -0
- package/dist/src/lib/schema-pins.d.ts +82 -0
- package/dist/src/lib/schema-pins.js +198 -0
- package/dist/src/lib/schema-pins.js.map +1 -0
- package/dist/src/lib/schema-preview.d.ts +244 -0
- package/dist/src/lib/schema-preview.js +498 -0
- package/dist/src/lib/schema-preview.js.map +1 -0
- package/dist/src/lib/scope-request.d.ts +23 -11
- package/dist/src/lib/scope-request.js +69 -31
- package/dist/src/lib/scope-request.js.map +1 -1
- package/dist/src/lib/session-scope.d.ts +26 -0
- package/dist/src/lib/session-scope.js +58 -0
- package/dist/src/lib/session-scope.js.map +1 -0
- package/dist/src/lib/skill-installer.d.ts +2 -2
- package/dist/src/lib/skill-installer.js +2 -21
- package/dist/src/lib/skill-installer.js.map +1 -1
- package/dist/src/lib/step-run-table.d.ts +1 -2
- package/dist/src/lib/step-run-table.js +1 -2
- package/dist/src/lib/step-run-table.js.map +1 -1
- package/dist/src/lib/swift-codegen/agentGenerator.d.ts +2 -1
- package/dist/src/lib/swift-codegen/agentGenerator.js +25 -23
- package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/banners.d.ts +12 -0
- package/dist/src/lib/swift-codegen/banners.js +12 -0
- package/dist/src/lib/swift-codegen/banners.js.map +1 -1
- package/dist/src/lib/swift-codegen/functionGenerator.d.ts +36 -1
- package/dist/src/lib/swift-codegen/functionGenerator.js +169 -51
- package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +33 -9
- package/dist/src/lib/swift-codegen/schemaToSwift.js +215 -179
- package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -1
- package/dist/src/lib/swift-codegen/sharedGenerator.d.ts +45 -0
- package/dist/src/lib/swift-codegen/sharedGenerator.js +165 -0
- package/dist/src/lib/swift-codegen/sharedGenerator.js.map +1 -0
- package/dist/src/lib/swift-codegen/swiftKeys.d.ts +19 -0
- package/dist/src/lib/swift-codegen/swiftKeys.js +31 -0
- package/dist/src/lib/swift-codegen/swiftKeys.js.map +1 -0
- package/dist/src/lib/swift-codegen/userPropertiesGenerator.d.ts +30 -0
- package/dist/src/lib/swift-codegen/userPropertiesGenerator.js +69 -0
- package/dist/src/lib/swift-codegen/userPropertiesGenerator.js.map +1 -0
- package/dist/src/lib/sync-resource-types.d.ts +117 -31
- package/dist/src/lib/sync-resource-types.js +197 -189
- package/dist/src/lib/sync-resource-types.js.map +1 -1
- package/dist/src/lib/sync-selectors.d.ts +7 -0
- package/dist/src/lib/sync-selectors.js +22 -2
- package/dist/src/lib/sync-selectors.js.map +1 -1
- package/dist/src/lib/template.d.ts +39 -3
- package/dist/src/lib/template.js +103 -14
- package/dist/src/lib/template.js.map +1 -1
- package/dist/src/lib/test-case-file-names.d.ts +3 -5
- package/dist/src/lib/test-case-file-names.js +3 -5
- package/dist/src/lib/test-case-file-names.js.map +1 -1
- package/dist/src/lib/test-runs.d.ts +45 -0
- package/dist/src/lib/test-runs.js +150 -0
- package/dist/src/lib/test-runs.js.map +1 -0
- package/dist/src/lib/test-users.d.ts +25 -0
- package/dist/src/lib/test-users.js +36 -0
- package/dist/src/lib/test-users.js.map +1 -0
- package/dist/src/lib/toml-database-config.d.ts +4 -2
- package/dist/src/lib/toml-database-config.js +11 -6
- package/dist/src/lib/toml-database-config.js.map +1 -1
- package/dist/src/lib/toml-scalar-edit.js +6 -4
- package/dist/src/lib/toml-scalar-edit.js.map +1 -1
- package/dist/src/lib/transition-warnings.d.ts +21 -0
- package/dist/src/lib/transition-warnings.js +49 -0
- package/dist/src/lib/transition-warnings.js.map +1 -0
- package/dist/src/lib/user-index.d.ts +80 -0
- package/dist/src/lib/user-index.js +166 -0
- package/dist/src/lib/user-index.js.map +1 -0
- package/dist/src/lib/user-properties/generated-properties-schema.d.ts +159 -0
- package/dist/src/lib/user-properties/generated-properties-schema.js +471 -0
- package/dist/src/lib/user-properties/generated-properties-schema.js.map +1 -0
- package/dist/src/lib/user-properties/user-properties-codegen.d.ts +55 -0
- package/dist/src/lib/user-properties/user-properties-codegen.js +129 -0
- package/dist/src/lib/user-properties/user-properties-codegen.js.map +1 -0
- package/dist/src/lib/user-walk.d.ts +31 -0
- package/dist/src/lib/user-walk.js +102 -0
- package/dist/src/lib/user-walk.js.map +1 -0
- package/dist/src/lib/webhook-capture.d.ts +43 -0
- package/dist/src/lib/webhook-capture.js +91 -0
- package/dist/src/lib/webhook-capture.js.map +1 -0
- package/dist/src/lib/webhook-deliver.d.ts +18 -20
- package/dist/src/lib/webhook-deliver.js +34 -89
- package/dist/src/lib/webhook-deliver.js.map +1 -1
- package/dist/src/lib/webhook-test-run.d.ts +32 -0
- package/dist/src/lib/webhook-test-run.js +108 -0
- package/dist/src/lib/webhook-test-run.js.map +1 -0
- package/dist/src/lib/worker-perf-format.d.ts +22 -0
- package/dist/src/lib/worker-perf-format.js +27 -0
- package/dist/src/lib/worker-perf-format.js.map +1 -0
- package/dist/src/types/index.d.ts +20 -65
- package/dist/src/validators.d.ts +7 -55
- package/dist/src/validators.js +7 -53
- package/dist/src/validators.js.map +1 -1
- package/dist/src/vite.d.ts +17 -0
- package/dist/src/vite.js +18 -0
- package/dist/src/vite.js.map +1 -0
- package/package.json +20 -9
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* `cli/tests/unit/config-surface-drift-guard.test.ts`) fails if this committed
|
|
15
15
|
* copy does not match the source.
|
|
16
16
|
*/
|
|
17
|
+
import { ONEOF_SIBLING_CONSTRAINT_KEYS, SCHEMA_KEYWORDS, refusedSchemaKeywords, } from "./schema-codegen/generated-schema-descriptor.js";
|
|
17
18
|
// ── src/config-surface/helpers.ts ────────────────────────────────────────
|
|
18
19
|
/**
|
|
19
20
|
* Shared spellings used by every configuration-object definition (issue #2644).
|
|
@@ -91,10 +92,11 @@ export function writableFieldNames(table, mode) {
|
|
|
91
92
|
.map((f) => f.field);
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
94
|
-
* The field names the server
|
|
95
|
-
* fields, plus the `deprecated` classifications — "still
|
|
96
|
-
*
|
|
97
|
-
* a handler still honors (`
|
|
95
|
+
* The field names the server ACCEPTS for this table in `mode`: the writable
|
|
96
|
+
* fields, plus the `deprecated` classifications — "still accepted, superseded
|
|
97
|
+
* or scheduled for removal" is what that kind means (`types.ts`), so a
|
|
98
|
+
* superseded key a handler still honors (`protected`) and a retired one it
|
|
99
|
+
* accepts and ignores (`accessRule`, #4872) belong in every accepted set, and a
|
|
98
100
|
* field that is NOT writable belongs in none of them.
|
|
99
101
|
*
|
|
100
102
|
* Stated once here because three consumers need the same answer: the generated
|
|
@@ -2160,7 +2162,15 @@ export function requestSchemaKeys(table, mode) {
|
|
|
2160
2162
|
*/
|
|
2161
2163
|
export function configRequestSchema(table, mode) {
|
|
2162
2164
|
const properties = {};
|
|
2163
|
-
|
|
2165
|
+
// Two sources say a key is deprecated: a field that carries `deprecated`
|
|
2166
|
+
// (#1815), and a model field classified `deprecated` in `notExposed` — a key
|
|
2167
|
+
// still accepted on the wire and kept out of the TOML surface (#4872).
|
|
2168
|
+
const deprecatedFields = new Set([
|
|
2169
|
+
...table.fields.filter((f) => f.deprecated).map((f) => f.field),
|
|
2170
|
+
...Object.entries(table.notExposed)
|
|
2171
|
+
.filter(([, classification]) => classification.kind === "deprecated")
|
|
2172
|
+
.map(([field]) => field),
|
|
2173
|
+
]);
|
|
2164
2174
|
for (const key of requestSchemaKeys(table, mode)) {
|
|
2165
2175
|
properties[key] = deprecatedFields.has(key) ? { deprecated: true } : {};
|
|
2166
2176
|
}
|
|
@@ -2402,41 +2412,6 @@ export const RETIRED_CONFIG_KEYS = {
|
|
|
2402
2412
|
"spelling is retired (#4283). Send the rule set's id.",
|
|
2403
2413
|
},
|
|
2404
2414
|
},
|
|
2405
|
-
// #2645 — pausing moved off `state` onto its own field, so `state` stopped
|
|
2406
|
-
// being author-writable rather than becoming a second way to say "paused".
|
|
2407
|
-
// Every pre-#2645 pull wrote the line, so existing repos hit this on their
|
|
2408
|
-
// first push after upgrading: the failure is deliberate (sponsor decision at
|
|
2409
|
-
// the approval gate, 2026-08-15), because the line has to be removed, not
|
|
2410
|
-
// silently ignored, or the file keeps claiming a pause state push does not
|
|
2411
|
-
// apply.
|
|
2412
|
-
//
|
|
2413
|
-
// #2907 — each of these names TWO verbs, not one. An author writing
|
|
2414
|
-
// `status = "archived"` was not asking about availability: they were asking
|
|
2415
|
-
// to retire the object, which is the delete flow and is spelled
|
|
2416
|
-
// `primitive <noun> archive`. Answering with `enable|disable` alone sent
|
|
2417
|
-
// exactly that author away with verbs that cannot do what they asked.
|
|
2418
|
-
cronTrigger: {
|
|
2419
|
-
state: {
|
|
2420
|
-
toml: "`state` is no longer authored in TOML (#2645), and #2803 replaced it " +
|
|
2421
|
-
"with the server-owned `status`. Availability is " +
|
|
2422
|
-
"`primitive cron-triggers enable|disable`; retiring the trigger is " +
|
|
2423
|
-
"`primitive cron-triggers archive` (#2907). Delete the line and push " +
|
|
2424
|
-
"again.",
|
|
2425
|
-
request: "`state` is server-owned and superseded by `status` (#2645, #2803). " +
|
|
2426
|
-
"Use `primitive cron-triggers enable|disable` to change availability, " +
|
|
2427
|
-
"or `primitive cron-triggers archive` to retire the trigger (#2907).",
|
|
2428
|
-
},
|
|
2429
|
-
status: {
|
|
2430
|
-
toml: "`status` is no longer authored in TOML (#2803). Availability is " +
|
|
2431
|
-
"server-owned: use `primitive cron-triggers enable|disable`. " +
|
|
2432
|
-
"Retiring the trigger is `primitive cron-triggers archive` (#2907) — " +
|
|
2433
|
-
"the archived row keeps its key and its slot under the per-app cap. " +
|
|
2434
|
-
"Delete the line and push again.",
|
|
2435
|
-
request: "`status` is server-owned (#2803). Use " +
|
|
2436
|
-
"`primitive cron-triggers enable|disable` to change availability, or " +
|
|
2437
|
-
"`primitive cron-triggers archive` to retire the trigger (#2907).",
|
|
2438
|
-
},
|
|
2439
|
-
},
|
|
2440
2415
|
// #3997 — keyed by each table's TOML prefix. Only `database-type-config`
|
|
2441
2416
|
// uses `[type]`, so that entry cannot reach another surface. The blob
|
|
2442
2417
|
// bucket's `[bucket] ruleSetId` has its own entry under `bucket` (#4283).
|
|
@@ -2478,6 +2453,8 @@ export const RETIRED_CONFIG_KEYS = {
|
|
|
2478
2453
|
"its own readRule and writeRule; omit the field.",
|
|
2479
2454
|
},
|
|
2480
2455
|
},
|
|
2456
|
+
// The type-config sections themselves retired in #4731; their #3997 entries
|
|
2457
|
+
// stay, so a section an old tree still carries reads the same guidance.
|
|
2481
2458
|
groupTypeConfig: { ruleSetId: RULE_SET_ID_RETIRED },
|
|
2482
2459
|
collectionTypeConfig: { ruleSetId: RULE_SET_ID_RETIRED },
|
|
2483
2460
|
// #2803 — the OBJECT-level availability leaves TOML. The per-version
|
|
@@ -2529,26 +2506,6 @@ export const RETIRED_CONFIG_KEYS = {
|
|
|
2529
2506
|
"`primitive integrations archive` to retire the integration (#2907).",
|
|
2530
2507
|
},
|
|
2531
2508
|
},
|
|
2532
|
-
// #2803 — availability is one server-owned `status`. As a TOML key it made
|
|
2533
|
-
// `config push` a second writer: pushing a file pulled before an operator ran
|
|
2534
|
-
// `webhooks disable` put the endpoint back in service as a side effect. The
|
|
2535
|
-
// tenant app-API create/update also stored the value UNVALIDATED, so any app
|
|
2536
|
-
// admin could write any string into the field the receiver gates on.
|
|
2537
|
-
webhook: {
|
|
2538
|
-
status: {
|
|
2539
|
-
toml: "`status` is no longer authored in TOML (#2803). Availability is " +
|
|
2540
|
-
"server-owned: use `primitive webhooks enable|disable`. Retiring the " +
|
|
2541
|
-
"webhook is `primitive webhooks archive` (#2907) — the archived row " +
|
|
2542
|
-
"keeps its key and its slot under the per-app cap. Delete the " +
|
|
2543
|
-
"line and push again. If this file describes an ARCHIVED webhook, " +
|
|
2544
|
-
"delete the file instead — pull no longer exports tombstones, and the " +
|
|
2545
|
-
"next confirmed `config push --prune` hard-deletes the row, freeing " +
|
|
2546
|
-
"its slot and its key.",
|
|
2547
|
-
request: "`status` is server-owned (#2803). Use " +
|
|
2548
|
-
"`primitive webhooks enable|disable` to change availability, or " +
|
|
2549
|
-
"`primitive webhooks archive` to retire the webhook (#2907).",
|
|
2550
|
-
},
|
|
2551
|
-
},
|
|
2552
2509
|
// #3179 — server functions are the SIXTH status-carrying type, and they take
|
|
2553
2510
|
// the rule at birth rather than inheriting it: a function's whole point is
|
|
2554
2511
|
// that it runs code on request, so a `config push` that re-enabled a function
|
|
@@ -2637,21 +2594,91 @@ export const RETIRED_CONFIG_KEYS = {
|
|
|
2637
2594
|
"`evaluatorConfigName`.",
|
|
2638
2595
|
},
|
|
2639
2596
|
},
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2597
|
+
};
|
|
2598
|
+
// #4872 — nothing evaluates a prompt's or an integration's rule: the only
|
|
2599
|
+
// call paths are a server function's `ctx.prompts.run` and
|
|
2600
|
+
// `ctx.integrations.call`, which skip it. The window is the one `[app].protected`
|
|
2601
|
+
// announced, so the platform schedules one break.
|
|
2602
|
+
function accessRuleDeprecated(noun, decides) {
|
|
2603
|
+
return {
|
|
2604
|
+
toml: `\`accessRule\` is deprecated and ignored: nothing evaluates ${noun}'s ` +
|
|
2605
|
+
`rule, because ${decides}. It will be removed in the first breaking ` +
|
|
2606
|
+
"release after 2026-12-15. Run `primitive config pull` to rewrite this " +
|
|
2607
|
+
"file without it.",
|
|
2608
|
+
};
|
|
2609
|
+
}
|
|
2610
|
+
export const DEPRECATED_CONFIG_KEYS = {
|
|
2611
|
+
prompt: {
|
|
2612
|
+
accessRule: accessRuleDeprecated("a prompt", "the calling function's `authorize` decides who may run it"),
|
|
2613
|
+
},
|
|
2614
|
+
integration: {
|
|
2615
|
+
accessRule: accessRuleDeprecated("an integration", "the calling function's `authorize` and its `integration:<key>` " +
|
|
2616
|
+
"capability decide who may call it"),
|
|
2653
2617
|
},
|
|
2654
2618
|
};
|
|
2619
|
+
/** The deprecated-key entry for `key` under `prefix`, or null when it is not deprecated. */
|
|
2620
|
+
export function deprecatedConfigKey(prefix, key) {
|
|
2621
|
+
return DEPRECATED_CONFIG_KEYS[prefix]?.[key] ?? null;
|
|
2622
|
+
}
|
|
2623
|
+
/**
|
|
2624
|
+
* Config-tree directories whose object type retired — #3190, server-functions
|
|
2625
|
+
* phase 7. The DSL engine, the Rhai runtime and the standalone webhook and
|
|
2626
|
+
* cron objects are gone, so `config push` refuses a tree that still holds one
|
|
2627
|
+
* of these directories, by name and before it writes anything, rather than
|
|
2628
|
+
* ignoring files an author still expects to take effect.
|
|
2629
|
+
*
|
|
2630
|
+
* Each entry is one sentence: what retired, what replaces it, and the docs page
|
|
2631
|
+
* that shows the replacement.
|
|
2632
|
+
*/
|
|
2633
|
+
export const RETIRED_CONFIG_DIRECTORIES = {
|
|
2634
|
+
workflows: "`workflows/` is no longer part of a config tree (#3190): DSL workflows " +
|
|
2635
|
+
"are retired. Write the logic as a server function under `functions/` " +
|
|
2636
|
+
"(docs: getting-started/server-functions), then delete `workflows/` and " +
|
|
2637
|
+
"push again.",
|
|
2638
|
+
transforms: "`transforms/` is no longer part of a config tree (#3190): scripts and " +
|
|
2639
|
+
"the Rhai runtime are retired. A transform is a pure function under " +
|
|
2640
|
+
"`functions/` (docs: getting-started/server-functions); delete " +
|
|
2641
|
+
"`transforms/` and push again.",
|
|
2642
|
+
webhooks: "`webhooks/` is no longer part of a config tree (#3190): standalone " +
|
|
2643
|
+
"webhooks are retired. Declare the endpoint as " +
|
|
2644
|
+
"`[function.triggers.webhook]` on the server function that handles it " +
|
|
2645
|
+
"(docs: getting-started/inbound-webhooks), then delete `webhooks/` and " +
|
|
2646
|
+
"push again.",
|
|
2647
|
+
"cron-triggers": "`cron-triggers/` is no longer part of a config tree (#3190): standalone " +
|
|
2648
|
+
"cron triggers are retired. Declare the schedule as " +
|
|
2649
|
+
"`[[function.triggers.cron]]` on the server function it runs (docs: " +
|
|
2650
|
+
"getting-started/server-functions), then delete `cron-triggers/` and " +
|
|
2651
|
+
"push again.",
|
|
2652
|
+
};
|
|
2653
|
+
/**
|
|
2654
|
+
* The type-config directories a config tree no longer has (#4731, project
|
|
2655
|
+
* `role-based-groups-collections`). Groups and collections have fixed roles,
|
|
2656
|
+
* so their per-type configuration retired with its routes; `config push`
|
|
2657
|
+
* refuses a tree that still holds a file in either, naming each file, rather
|
|
2658
|
+
* than ignoring files an author still expects to take effect. The rows the
|
|
2659
|
+
* server already stored are not touched.
|
|
2660
|
+
*
|
|
2661
|
+
* Each entry is one sentence: what retired, and what replaces it.
|
|
2662
|
+
*/
|
|
2663
|
+
export const RETIRED_TYPE_CONFIG_DIRECTORIES = {
|
|
2664
|
+
"group-type-configs": "`group-type-configs/` is no longer part of a config tree: groups have " +
|
|
2665
|
+
"fixed roles (owner, manager, member). Write a rule the roles do not " +
|
|
2666
|
+
"express as a server function that checks `requireMember` (docs: " +
|
|
2667
|
+
"getting-started/server-functions), and a group metadata manifest as a " +
|
|
2668
|
+
"metadata category config; then delete `group-type-configs/` and push again.",
|
|
2669
|
+
"collection-type-configs": "`collection-type-configs/` is no longer part of a config tree: " +
|
|
2670
|
+
"collections have fixed roles (owner, manager, editor, contributor, " +
|
|
2671
|
+
"viewer). Write a rule the roles do not express as a server function that " +
|
|
2672
|
+
"checks `requireCollectionRole` (docs: getting-started/server-functions), " +
|
|
2673
|
+
"and a collection metadata manifest as a metadata category config; then " +
|
|
2674
|
+
"delete `collection-type-configs/` and push again.",
|
|
2675
|
+
};
|
|
2676
|
+
/** The retirement sentence for a config-tree directory, or null when it is live. */
|
|
2677
|
+
export function retiredConfigDirectory(dir) {
|
|
2678
|
+
return Object.prototype.hasOwnProperty.call(RETIRED_CONFIG_DIRECTORIES, dir)
|
|
2679
|
+
? RETIRED_CONFIG_DIRECTORIES[dir]
|
|
2680
|
+
: null;
|
|
2681
|
+
}
|
|
2655
2682
|
/**
|
|
2656
2683
|
* Top-level TOML tables a configuration object's FILE retired — keyed by the
|
|
2657
2684
|
* surface's label, then by the table key. Only the TOML half exists: these were
|
|
@@ -2713,6 +2740,16 @@ export const RETIRED_TOML_SPELLINGS = {
|
|
|
2713
2740
|
// #3642 — the nine chat keys at the prompt `[[configs]]` root. The admin
|
|
2714
2741
|
// API's create and update bodies still carry them flat; only the TOML
|
|
2715
2742
|
// grouping (#3626) moved them under `[configs.chat]`.
|
|
2743
|
+
// #4802 — a `db3-types/<name>.toml` file names its type `[type] name`; the
|
|
2744
|
+
// database type file's `databaseType` is a key this surface does not take.
|
|
2745
|
+
// The database type file still declares `databaseType`, so the sentence is
|
|
2746
|
+
// only ever reached from a db3 type file.
|
|
2747
|
+
type: {
|
|
2748
|
+
databaseType: {
|
|
2749
|
+
toml: "`databaseType` names a database type file's type; a db3 type file " +
|
|
2750
|
+
"says `name` (`[type] name = \"<type>\"`). Rename the key and push again.",
|
|
2751
|
+
},
|
|
2752
|
+
},
|
|
2716
2753
|
configs: {
|
|
2717
2754
|
systemPrompt: flatChatKeySpelling("systemPrompt", true),
|
|
2718
2755
|
userPromptTemplate: flatChatKeySpelling("userPromptTemplate", false),
|
|
@@ -2725,12 +2762,36 @@ export const RETIRED_TOML_SPELLINGS = {
|
|
|
2725
2762
|
reasoningBudget: flatChatKeySpelling("reasoningBudget", true),
|
|
2726
2763
|
},
|
|
2727
2764
|
};
|
|
2765
|
+
// #5993 — a db3 type takes no rule set. Nothing evaluates one: every
|
|
2766
|
+
// `db3-types` route is for app admins and owners, who bypass rule sets. The
|
|
2767
|
+
// database type file still takes `ruleSetName`, and its `ruleSetId` keeps the
|
|
2768
|
+
// #3997 sentence, so these are keyed by the db3 type's surface.
|
|
2769
|
+
const DB3_TYPE_RULE_SET_SENTENCE = "A db3 type takes no rule set: nothing evaluated the one this line names, " +
|
|
2770
|
+
"and managing a type is for app admins and owners. Delete the line and " +
|
|
2771
|
+
"push again (`config pull` rewrites the file without it).";
|
|
2772
|
+
/**
|
|
2773
|
+
* Guidance keyed by surface label, then TOML prefix, then key — consulted
|
|
2774
|
+
* before `RETIRED_CONFIG_KEYS` and `RETIRED_TOML_SPELLINGS` when the caller
|
|
2775
|
+
* knows the surface.
|
|
2776
|
+
*/
|
|
2777
|
+
export const RETIRED_SURFACE_TOML_KEYS = {
|
|
2778
|
+
"db3-type": {
|
|
2779
|
+
type: {
|
|
2780
|
+
ruleSetName: { toml: DB3_TYPE_RULE_SET_SENTENCE, emptyAccepted: true },
|
|
2781
|
+
ruleSetId: { toml: DB3_TYPE_RULE_SET_SENTENCE },
|
|
2782
|
+
},
|
|
2783
|
+
},
|
|
2784
|
+
};
|
|
2728
2785
|
/**
|
|
2729
|
-
* The TOML guidance for `key` under `prefix`:
|
|
2730
|
-
*
|
|
2786
|
+
* The TOML guidance for `key` under `prefix`: the surface's own when
|
|
2787
|
+
* `surfaceLabel` names one, else a fully retired key's, else a retired
|
|
2788
|
+
* spelling's, else null when the key is simply unknown.
|
|
2731
2789
|
*/
|
|
2732
|
-
export function retiredTomlKey(prefix, key) {
|
|
2733
|
-
return (
|
|
2790
|
+
export function retiredTomlKey(prefix, key, surfaceLabel) {
|
|
2791
|
+
return ((surfaceLabel ? RETIRED_SURFACE_TOML_KEYS[surfaceLabel]?.[prefix]?.[key] : undefined) ??
|
|
2792
|
+
retiredConfigKey(prefix, key) ??
|
|
2793
|
+
RETIRED_TOML_SPELLINGS[prefix]?.[key] ??
|
|
2794
|
+
null);
|
|
2734
2795
|
}
|
|
2735
2796
|
// ── src/config-surface/function-grants.ts ────────────────────────────────
|
|
2736
2797
|
/**
|
|
@@ -2755,7 +2816,10 @@ export function retiredTomlKey(prefix, key) {
|
|
|
2755
2816
|
* `secret:<NAME>` credential least privilege — which secret VALUES may
|
|
2756
2817
|
* cross into the sandbox at all;
|
|
2757
2818
|
* the high-blast list {@link HIGH_BLAST_CAPABILITIES} — the operations
|
|
2758
|
-
* whose blast radius the intent keeps opt-in
|
|
2819
|
+
* whose blast radius the intent keeps opt-in;
|
|
2820
|
+
* the subject grants {@link SUBJECT_GRANT_CAPABILITIES} — naming another
|
|
2821
|
+
* member on a call about one user, in a run a plain
|
|
2822
|
+
* member invoked.
|
|
2759
2823
|
*
|
|
2760
2824
|
* Every other string a function used to declare is RETIRED, and the grammar
|
|
2761
2825
|
* says so by name: an author who still writes `database:orders/Order:read`
|
|
@@ -2808,7 +2872,13 @@ export const KEYED_GRANT_FAMILIES = ["integration", "secret"];
|
|
|
2808
2872
|
* other — `databases:create` is not permission to delete a database.
|
|
2809
2873
|
*
|
|
2810
2874
|
* The database ROLE mutations are here because they hand out persistent
|
|
2811
|
-
* authority: a group grant assigns the manager role (D3279-003).
|
|
2875
|
+
* authority: a group grant assigns the manager role (D3279-003). A db3's sync
|
|
2876
|
+
* switch (`db3:setSync`, the intent's `db3-sync` grant) is here because
|
|
2877
|
+
* turning sync off suspends every grant on the db3 (#4799); a db3's transfer
|
|
2878
|
+
* and its owner-row change (`db3:transfer`, `db3:setOwnerRow`, the intent's
|
|
2879
|
+
* `db3-grant` grant) because they move who holds the db3 and its owner row
|
|
2880
|
+
* (#4800); its app access (`db3:setAppAccess`, the same grant's third string)
|
|
2881
|
+
* because it grants the db3 to every user of the app (#4801). App deletion
|
|
2812
2882
|
* and secret writes have no app-API route today; they are recorded, not gated,
|
|
2813
2883
|
* and the profile generator refuses to admit a future such route without a row
|
|
2814
2884
|
* here (`HIGH_BLAST_WATCH` in `scripts/lib/function-profile.mjs`).
|
|
@@ -2825,17 +2895,49 @@ export const HIGH_BLAST_CAPABILITIES = [
|
|
|
2825
2895
|
"users:setRole",
|
|
2826
2896
|
"blobBuckets:createBucket",
|
|
2827
2897
|
"blobBuckets:deleteBucket",
|
|
2898
|
+
"db3:setSync",
|
|
2899
|
+
"db3:transfer",
|
|
2900
|
+
"db3:setOwnerRow",
|
|
2901
|
+
"db3:setAppAccess",
|
|
2902
|
+
];
|
|
2903
|
+
/**
|
|
2904
|
+
* The subject grants — #4909.
|
|
2905
|
+
*
|
|
2906
|
+
* A run a plain member invoked may name nobody but its caller on a call that
|
|
2907
|
+
* is about one user (#4142's subject rule): `SUBJECT_USER_FORBIDDEN`. A
|
|
2908
|
+
* function whose own code chooses that user — a class's teacher removing a
|
|
2909
|
+
* student and reading where else the student is enrolled — declares it here,
|
|
2910
|
+
* in a line a reviewer can find:
|
|
2911
|
+
*
|
|
2912
|
+
* `users:readAny` the user-subject READS may name another member
|
|
2913
|
+
* (memberships, a member's collections, their db3s
|
|
2914
|
+
* (owned and shared), inbox, devices, agent sessions);
|
|
2915
|
+
* `users:actAsAny` the calls that ACT as a member may name another member
|
|
2916
|
+
* (marking their notifications read, their devices, an
|
|
2917
|
+
* agent session as them, `ctx.db3` `asUser`, their
|
|
2918
|
+
* aliases).
|
|
2919
|
+
*
|
|
2920
|
+
* Each admits only its own kind. Neither changes a run with no caller, an
|
|
2921
|
+
* owner- or admin-invoked run, or a run an agent drives (refused either way),
|
|
2922
|
+
* and a nested child reads its own version's. They are not high-blast rows:
|
|
2923
|
+
* those are 1:1 with an operation id, and these name a rule, not an operation.
|
|
2924
|
+
*/
|
|
2925
|
+
export const SUBJECT_GRANT_CAPABILITIES = ["users:readAny", "users:actAsAny"];
|
|
2926
|
+
/** The exact strings: the high-blast list and the subject grants. */
|
|
2927
|
+
export const EXACT_GRANT_STRINGS = [
|
|
2928
|
+
...HIGH_BLAST_CAPABILITIES,
|
|
2929
|
+
...SUBJECT_GRANT_CAPABILITIES,
|
|
2828
2930
|
];
|
|
2829
|
-
/** The exact strings, which since #3279 are exactly the high-blast list. */
|
|
2830
|
-
export const EXACT_GRANT_STRINGS = HIGH_BLAST_CAPABILITIES;
|
|
2831
2931
|
/**
|
|
2832
2932
|
* What stays, in one sentence, for every retirement to point at. An author
|
|
2833
2933
|
* who reads a refusal should not need the guide to know what to write next.
|
|
2834
2934
|
*/
|
|
2835
2935
|
const KEPT_KINDS = "Capabilities are declared only for `integration:<key>` (the egress " +
|
|
2836
|
-
"allowlist), `secret:<NAME>` (which secret values may enter the sandbox) " +
|
|
2837
|
-
"
|
|
2936
|
+
"allowlist), `secret:<NAME>` (which secret values may enter the sandbox), " +
|
|
2937
|
+
"the high-blast-radius opt-ins (" +
|
|
2838
2938
|
HIGH_BLAST_CAPABILITIES.map((entry) => `\`${entry}\``).join(", ") +
|
|
2939
|
+
") and the subject grants (" +
|
|
2940
|
+
SUBJECT_GRANT_CAPABILITIES.map((entry) => `\`${entry}\``).join(", ") +
|
|
2839
2941
|
").";
|
|
2840
2942
|
/**
|
|
2841
2943
|
* The retired FAMILIES (#3279), each with the reason it is gone.
|
|
@@ -2903,9 +3005,11 @@ const KEYED_FAMILY_PLACEHOLDERS = {
|
|
|
2903
3005
|
secret: "NAME",
|
|
2904
3006
|
};
|
|
2905
3007
|
/** Every accepted shape, in one sentence, for the unknown-family error. */
|
|
2906
|
-
const ACCEPTED_FAMILIES = "`integration:<integrationKey>`, `secret:<NAME>`,
|
|
3008
|
+
const ACCEPTED_FAMILIES = "`integration:<integrationKey>`, `secret:<NAME>`, the high-blast " +
|
|
2907
3009
|
"opt-ins " +
|
|
2908
|
-
HIGH_BLAST_CAPABILITIES.map((entry) => `\`${entry}\``).join(", ")
|
|
3010
|
+
HIGH_BLAST_CAPABILITIES.map((entry) => `\`${entry}\``).join(", ") +
|
|
3011
|
+
", and the subject grants " +
|
|
3012
|
+
SUBJECT_GRANT_CAPABILITIES.map((entry) => `\`${entry}\``).join(", ");
|
|
2909
3013
|
/**
|
|
2910
3014
|
* A channel name's ceiling, and the reason it has one.
|
|
2911
3015
|
*
|
|
@@ -3170,7 +3274,37 @@ export function validateKeyedGrantsAgainstTargets(grants, known) {
|
|
|
3170
3274
|
* A version-1 manifest still parses: it records registrations only.
|
|
3171
3275
|
*/
|
|
3172
3276
|
export const FUNCTION_MANIFEST_SCHEMA_VERSION = 2;
|
|
3173
|
-
export const FUNCTION_MANIFEST_SCHEMA_VERSIONS = [1, 2];
|
|
3277
|
+
export const FUNCTION_MANIFEST_SCHEMA_VERSIONS = [1, 2, 3];
|
|
3278
|
+
/**
|
|
3279
|
+
* Version 3 (#4730) adds what a version's `authorize` admits: the
|
|
3280
|
+
* `authorize` block and the `writeFamilies` its handler reaches. Only a
|
|
3281
|
+
* FLAGGED build emits it — the manifest is inside the envelope hash, so a
|
|
3282
|
+
* universal bump would make every untouched bare-handler tree a new version
|
|
3283
|
+
* on its next push. A bare-handler tree keeps emitting version 2.
|
|
3284
|
+
*/
|
|
3285
|
+
export const FUNCTION_MANIFEST_AUTHORIZE_SCHEMA_VERSION = 3;
|
|
3286
|
+
/** The `auth.*` families an `authorize` can read, as the manifest names them. */
|
|
3287
|
+
export const AUTH_FAMILIES = [
|
|
3288
|
+
"auth.user",
|
|
3289
|
+
"auth.trigger",
|
|
3290
|
+
"auth.memberships",
|
|
3291
|
+
"auth.collections",
|
|
3292
|
+
"auth.doc",
|
|
3293
|
+
"auth.db",
|
|
3294
|
+
"auth.configVar",
|
|
3295
|
+
];
|
|
3296
|
+
/** The SDK helpers that build an `authorize`, as the manifest names them. */
|
|
3297
|
+
export const AUTHORIZE_HELPERS = [
|
|
3298
|
+
"allowAnyone",
|
|
3299
|
+
"allowCallers",
|
|
3300
|
+
"requireSignedIn",
|
|
3301
|
+
"requireRole",
|
|
3302
|
+
"requireMember",
|
|
3303
|
+
"requireCollectionRole",
|
|
3304
|
+
"requireDocumentOwner",
|
|
3305
|
+
];
|
|
3306
|
+
/** How many function keys an `allowCallers` block may list. */
|
|
3307
|
+
export const MAX_MANIFEST_CALLER_FUNCTIONS = 200;
|
|
3174
3308
|
/** Bounds, so a manifest cannot be a way to store an unbounded blob. */
|
|
3175
3309
|
export const MAX_MANIFEST_QUERIES = 200;
|
|
3176
3310
|
export const MAX_MANIFEST_NAME_LENGTH = 120;
|
|
@@ -3260,7 +3394,8 @@ export function parseFunctionManifest(value) {
|
|
|
3260
3394
|
}
|
|
3261
3395
|
const schemaVersion = Number(document.schemaVersion);
|
|
3262
3396
|
if (!FUNCTION_MANIFEST_SCHEMA_VERSIONS.includes(schemaVersion)) {
|
|
3263
|
-
return fail(`the manifest declares schemaVersion ${JSON.stringify(document.schemaVersion)}; this platform reads versions ${FUNCTION_MANIFEST_SCHEMA_VERSIONS.join("
|
|
3397
|
+
return fail(`the manifest declares schemaVersion ${JSON.stringify(document.schemaVersion)}; this platform reads versions ${FUNCTION_MANIFEST_SCHEMA_VERSIONS.slice(0, -1).join(", ")} ` +
|
|
3398
|
+
`and ${FUNCTION_MANIFEST_SCHEMA_VERSIONS[FUNCTION_MANIFEST_SCHEMA_VERSIONS.length - 1]}.`);
|
|
3264
3399
|
}
|
|
3265
3400
|
if (!Array.isArray(document.queries)) {
|
|
3266
3401
|
return fail("the manifest's `queries` must be an array.");
|
|
@@ -3405,21 +3540,246 @@ export function parseFunctionManifest(value) {
|
|
|
3405
3540
|
if (schemaVersion >= 2 && document.dynamicModels !== undefined && typeof document.dynamicModels !== "boolean") {
|
|
3406
3541
|
errors.push("the manifest's `dynamicModels` must be a boolean.");
|
|
3407
3542
|
}
|
|
3543
|
+
// Version 3's additions. Set ONLY for a version-3 document: the server
|
|
3544
|
+
// re-serializes the parsed object into the envelope it hashes, so a key
|
|
3545
|
+
// added to a version-1 or version-2 object would move every legacy hash.
|
|
3546
|
+
const writeFamilies = schemaVersion >= FUNCTION_MANIFEST_AUTHORIZE_SCHEMA_VERSION
|
|
3547
|
+
? names("writeFamilies", MAX_MANIFEST_FAMILIES)
|
|
3548
|
+
: null;
|
|
3549
|
+
const authorize = schemaVersion >= FUNCTION_MANIFEST_AUTHORIZE_SCHEMA_VERSION
|
|
3550
|
+
? parseManifestAuthorize(document.authorize, errors)
|
|
3551
|
+
: null;
|
|
3408
3552
|
if (errors.length > 0)
|
|
3409
3553
|
return { ok: false, manifest: null, errors };
|
|
3410
3554
|
queries.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
3555
|
+
const manifest = {
|
|
3556
|
+
schemaVersion,
|
|
3557
|
+
queries,
|
|
3558
|
+
models: models ?? [],
|
|
3559
|
+
families: families ?? [],
|
|
3560
|
+
dynamicModels: schemaVersion >= 2 && document.dynamicModels === true,
|
|
3561
|
+
};
|
|
3562
|
+
if (schemaVersion >= FUNCTION_MANIFEST_AUTHORIZE_SCHEMA_VERSION) {
|
|
3563
|
+
manifest.writeFamilies = writeFamilies ?? [];
|
|
3564
|
+
manifest.authorize = authorize;
|
|
3565
|
+
}
|
|
3566
|
+
return { ok: true, manifest, errors: [] };
|
|
3567
|
+
}
|
|
3568
|
+
/** One `authorize` block, normalized in a fixed key order, or null with errors pushed. */
|
|
3569
|
+
function parseManifestAuthorize(raw, errors) {
|
|
3570
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
3571
|
+
errors.push("a version-3 manifest must carry an `authorize` object.");
|
|
3572
|
+
return null;
|
|
3573
|
+
}
|
|
3574
|
+
const before = errors.length;
|
|
3575
|
+
if (raw.present !== true)
|
|
3576
|
+
errors.push("the manifest's `authorize.present` must be true.");
|
|
3577
|
+
if (typeof raw.public !== "boolean") {
|
|
3578
|
+
errors.push("the manifest's `authorize.public` must be a boolean.");
|
|
3579
|
+
}
|
|
3580
|
+
const helper = raw.helper === undefined || raw.helper === null ? null : raw.helper;
|
|
3581
|
+
if (helper !== null && !AUTHORIZE_HELPERS.includes(helper)) {
|
|
3582
|
+
errors.push(`the manifest's \`authorize.helper\` must be null or one of ${AUTHORIZE_HELPERS.join(", ")}.`);
|
|
3583
|
+
}
|
|
3584
|
+
if (!Array.isArray(raw.families) ||
|
|
3585
|
+
raw.families.some((f) => !AUTH_FAMILIES.includes(f))) {
|
|
3586
|
+
errors.push(`the manifest's \`authorize.families\` must be an array of ${AUTH_FAMILIES.join(", ")}.`);
|
|
3587
|
+
}
|
|
3588
|
+
let callers = null;
|
|
3589
|
+
if (raw.callers !== undefined && raw.callers !== null) {
|
|
3590
|
+
callers = parseManifestCallers(raw.callers, errors);
|
|
3591
|
+
}
|
|
3592
|
+
if (errors.length > before)
|
|
3593
|
+
return null;
|
|
3411
3594
|
return {
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3595
|
+
present: true,
|
|
3596
|
+
public: raw.public,
|
|
3597
|
+
helper,
|
|
3598
|
+
callers,
|
|
3599
|
+
families: [...new Set(raw.families.map(String))].sort(),
|
|
3600
|
+
};
|
|
3601
|
+
}
|
|
3602
|
+
function parseManifestCallers(raw, errors) {
|
|
3603
|
+
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
3604
|
+
errors.push("the manifest's `authorize.callers` must be null or an object.");
|
|
3605
|
+
return null;
|
|
3606
|
+
}
|
|
3607
|
+
const before = errors.length;
|
|
3608
|
+
for (const door of ["webhook", "cron", "manual"]) {
|
|
3609
|
+
if (typeof raw[door] !== "boolean") {
|
|
3610
|
+
errors.push(`the manifest's \`authorize.callers.${door}\` must be a boolean.`);
|
|
3611
|
+
}
|
|
3612
|
+
}
|
|
3613
|
+
const functions = raw.functions;
|
|
3614
|
+
if (!Array.isArray(functions) || functions.some((k) => typeof k !== "string")) {
|
|
3615
|
+
errors.push("the manifest's `authorize.callers.functions` must be an array of function keys.");
|
|
3616
|
+
}
|
|
3617
|
+
else if (functions.length > MAX_MANIFEST_CALLER_FUNCTIONS) {
|
|
3618
|
+
errors.push(`the manifest's \`authorize.callers.functions\` lists ${functions.length} keys, over the ` +
|
|
3619
|
+
`${MAX_MANIFEST_CALLER_FUNCTIONS} limit.`);
|
|
3620
|
+
}
|
|
3621
|
+
else if (functions.some((k) => k === "" || k.length > MAX_MANIFEST_NAME_LENGTH)) {
|
|
3622
|
+
errors.push("the manifest's `authorize.callers.functions` carries a key that is empty or over " +
|
|
3623
|
+
`${MAX_MANIFEST_NAME_LENGTH} characters.`);
|
|
3624
|
+
}
|
|
3625
|
+
if (raw.agents !== true && raw.agents !== false && raw.agents !== "rule") {
|
|
3626
|
+
errors.push('the manifest\'s `authorize.callers.agents` must be true, false or "rule".');
|
|
3627
|
+
}
|
|
3628
|
+
if (raw.users !== false && raw.users !== "rule") {
|
|
3629
|
+
errors.push('the manifest\'s `authorize.callers.users` must be false or "rule".');
|
|
3630
|
+
}
|
|
3631
|
+
if (raw.db3 !== undefined && typeof raw.db3 !== "boolean") {
|
|
3632
|
+
errors.push("the manifest's `authorize.callers.db3` must be a boolean when present.");
|
|
3633
|
+
}
|
|
3634
|
+
const usersBatch = raw.usersBatch;
|
|
3635
|
+
if (usersBatch !== undefined && typeof usersBatch !== "boolean") {
|
|
3636
|
+
if (!Array.isArray(usersBatch) || usersBatch.some((k) => typeof k !== "string")) {
|
|
3637
|
+
errors.push("the manifest's `authorize.callers.usersBatch` must be a boolean or an array of function keys when present.");
|
|
3638
|
+
}
|
|
3639
|
+
else if (usersBatch.length > MAX_MANIFEST_CALLER_FUNCTIONS) {
|
|
3640
|
+
errors.push(`the manifest's \`authorize.callers.usersBatch\` lists ${usersBatch.length} keys, over the ` +
|
|
3641
|
+
`${MAX_MANIFEST_CALLER_FUNCTIONS} limit.`);
|
|
3642
|
+
}
|
|
3643
|
+
else if (usersBatch.some((k) => k === "" || k.length > MAX_MANIFEST_NAME_LENGTH)) {
|
|
3644
|
+
errors.push("the manifest's `authorize.callers.usersBatch` carries a key that is empty or over " +
|
|
3645
|
+
`${MAX_MANIFEST_NAME_LENGTH} characters.`);
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3648
|
+
if (errors.length > before)
|
|
3649
|
+
return null;
|
|
3650
|
+
return {
|
|
3651
|
+
webhook: raw.webhook,
|
|
3652
|
+
cron: raw.cron,
|
|
3653
|
+
manual: raw.manual,
|
|
3654
|
+
functions: [...new Set(functions)].sort(),
|
|
3655
|
+
agents: raw.agents,
|
|
3656
|
+
users: raw.users,
|
|
3657
|
+
...(raw.db3 !== undefined ? { db3: raw.db3 } : {}),
|
|
3658
|
+
...(usersBatch !== undefined
|
|
3659
|
+
? { usersBatch: Array.isArray(usersBatch) ? [...new Set(usersBatch)].sort() : usersBatch }
|
|
3660
|
+
: {}),
|
|
3661
|
+
};
|
|
3662
|
+
}
|
|
3663
|
+
/**
|
|
3664
|
+
* Whether a top-level input schema is one the closed-schema default leaves
|
|
3665
|
+
* OPEN under its union exemption — #4730, criterion 9.
|
|
3666
|
+
*
|
|
3667
|
+
* The validator closes an object against the root's OWN `properties` only,
|
|
3668
|
+
* so a root whose `anyOf` or `oneOf` members declare `properties` of their
|
|
3669
|
+
* own would, closed, refuse the very keys its members declare. Such a root is
|
|
3670
|
+
* left open, and `config push` warns its author to say `additionalProperties`
|
|
3671
|
+
* explicitly. Shared by the server (`closedInputSchemaFor`) and the CLI's
|
|
3672
|
+
* push warning, so both sides read one rule.
|
|
3673
|
+
*/
|
|
3674
|
+
export function inputSchemaRootLeftOpen(schema) {
|
|
3675
|
+
if (!isClosableObjectSchema(schema))
|
|
3676
|
+
return false;
|
|
3677
|
+
const root = schema;
|
|
3678
|
+
for (const key of ["anyOf", "oneOf"]) {
|
|
3679
|
+
const members = root[key];
|
|
3680
|
+
if (!Array.isArray(members))
|
|
3681
|
+
continue;
|
|
3682
|
+
for (const member of members) {
|
|
3683
|
+
if (member && typeof member === "object" && !Array.isArray(member)) {
|
|
3684
|
+
const properties = member.properties;
|
|
3685
|
+
if (properties && typeof properties === "object")
|
|
3686
|
+
return true;
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3690
|
+
return false;
|
|
3691
|
+
}
|
|
3692
|
+
/**
|
|
3693
|
+
* A top-level object schema that sets no `additionalProperties`: `type` is or
|
|
3694
|
+
* includes `"object"`, or it declares `properties` with no `type`.
|
|
3695
|
+
*/
|
|
3696
|
+
function isClosableObjectSchema(schema) {
|
|
3697
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema))
|
|
3698
|
+
return false;
|
|
3699
|
+
const root = schema;
|
|
3700
|
+
if (root.additionalProperties !== undefined)
|
|
3701
|
+
return false;
|
|
3702
|
+
const type = root.type;
|
|
3703
|
+
if (type === "object")
|
|
3704
|
+
return true;
|
|
3705
|
+
if (Array.isArray(type))
|
|
3706
|
+
return type.includes("object");
|
|
3707
|
+
return type === undefined && !!root.properties && typeof root.properties === "object";
|
|
3708
|
+
}
|
|
3709
|
+
/**
|
|
3710
|
+
* The schema a flagged version validates against — #4730, criterion 9.
|
|
3711
|
+
*
|
|
3712
|
+
* A top-level object schema that sets no `additionalProperties` reads as
|
|
3713
|
+
* closed: a shallow copy with `additionalProperties: false`. Every other
|
|
3714
|
+
* schema is answered as it is — an explicit `additionalProperties`, a
|
|
3715
|
+
* non-object root, an empty `{}`, and a root left open under
|
|
3716
|
+
* {@link inputSchemaRootLeftOpen}. Nested objects are not touched. Applied at
|
|
3717
|
+
* run time and never written to the header.
|
|
3718
|
+
*/
|
|
3719
|
+
export function closedObjectSchema(schema) {
|
|
3720
|
+
if (!isClosableObjectSchema(schema) || inputSchemaRootLeftOpen(schema))
|
|
3721
|
+
return schema;
|
|
3722
|
+
return { ...schema, additionalProperties: false };
|
|
3723
|
+
}
|
|
3724
|
+
/**
|
|
3725
|
+
* `[function] public`, read from the authored TOML's `[function]` table —
|
|
3726
|
+
* #4730, criterion 13. Absent reads as false; anything but a boolean is
|
|
3727
|
+
* refused. Read by the CLI's preflight and by the server from the envelope's
|
|
3728
|
+
* TOML, never stored.
|
|
3729
|
+
*/
|
|
3730
|
+
export function declaredPublicOf(functionTable) {
|
|
3731
|
+
const value = functionTable && typeof functionTable === "object"
|
|
3732
|
+
? functionTable.public
|
|
3733
|
+
: undefined;
|
|
3734
|
+
if (value === undefined)
|
|
3735
|
+
return { ok: true, value: false };
|
|
3736
|
+
if (typeof value === "boolean")
|
|
3737
|
+
return { ok: true, value };
|
|
3738
|
+
return {
|
|
3739
|
+
ok: false,
|
|
3740
|
+
error: "`public` under [function] must be true or false.",
|
|
3421
3741
|
};
|
|
3422
3742
|
}
|
|
3743
|
+
/**
|
|
3744
|
+
* What makes a version write-capable for the public-writer lint — #4730: a
|
|
3745
|
+
* mutation registration, a family the manifest records a write or send verb
|
|
3746
|
+
* on, or a declared `integration:<key>`, high-blast or subject-grant
|
|
3747
|
+
* capability (#4909: a function anyone may invoke that names any member is
|
|
3748
|
+
* the same hazard). One phrase per reason, for the refusal to quote.
|
|
3749
|
+
*/
|
|
3750
|
+
export function writeCapableReasons(manifest, capabilities) {
|
|
3751
|
+
const reasons = [];
|
|
3752
|
+
const mutations = (manifest?.queries ?? []).filter((q) => q.kind === "mutation").map((q) => q.name);
|
|
3753
|
+
if (mutations.length > 0) {
|
|
3754
|
+
reasons.push(`it registers the mutation${mutations.length > 1 ? "s" : ""} ${mutations.map((n) => `'${n}'`).join(", ")}`);
|
|
3755
|
+
}
|
|
3756
|
+
const writes = manifest?.writeFamilies ?? [];
|
|
3757
|
+
if (writes.length > 0)
|
|
3758
|
+
reasons.push(`it writes or sends through ${writes.join(", ")}`);
|
|
3759
|
+
const exact = [...HIGH_BLAST_CAPABILITIES, ...SUBJECT_GRANT_CAPABILITIES];
|
|
3760
|
+
const declared = capabilities.filter((c) => c.startsWith("integration:") || exact.includes(c));
|
|
3761
|
+
if (declared.length > 0)
|
|
3762
|
+
reasons.push(`it declares ${declared.join(", ")}`);
|
|
3763
|
+
return reasons;
|
|
3764
|
+
}
|
|
3765
|
+
/**
|
|
3766
|
+
* The public-writer refusal — #4730, criterion 13: a version whose manifest
|
|
3767
|
+
* records `authorize.public` (an `allowAnyone()`, or an `allowCallers` arm
|
|
3768
|
+
* that is one) and that is write-capable needs `public = true` under
|
|
3769
|
+
* `[function]`. The sentence names the function, what makes it write-capable
|
|
3770
|
+
* and the fix; null when the push is fine. The CLI refuses at preflight and
|
|
3771
|
+
* the server at push, from this one rule.
|
|
3772
|
+
*/
|
|
3773
|
+
export function publicWriterRefusal(input) {
|
|
3774
|
+
if (input.declaredPublic || input.manifest?.authorize?.public !== true)
|
|
3775
|
+
return null;
|
|
3776
|
+
const reasons = writeCapableReasons(input.manifest, input.capabilities);
|
|
3777
|
+
if (reasons.length === 0)
|
|
3778
|
+
return null;
|
|
3779
|
+
return (`function '${input.functionKey}': its authorize admits anyone, and the version can write: ` +
|
|
3780
|
+
`${reasons.join("; ")}. If anyone may really call it, add \`public = true\` under [function] in ` +
|
|
3781
|
+
`functions/${input.functionKey}.toml; otherwise require a caller, such as requireSignedIn() or allowCallers({ ... }).`);
|
|
3782
|
+
}
|
|
3423
3783
|
// ── src/config-surface/function-retired-keys.ts ──────────────────────────
|
|
3424
3784
|
/**
|
|
3425
3785
|
* The runtime keys a `functions/<key>.toml` no longer decides anything with —
|
|
@@ -3594,6 +3954,77 @@ function retiredDatabaseTriggerValue(functionTable) {
|
|
|
3594
3954
|
}
|
|
3595
3955
|
return triggers.database;
|
|
3596
3956
|
}
|
|
3957
|
+
// ── src/config-surface/trigger-declaration.ts ────────────────────────────
|
|
3958
|
+
/**
|
|
3959
|
+
* The trigger blocks a function declares, derived from its authored TOML
|
|
3960
|
+
* (#3181, project `server-functions`, criterion 4).
|
|
3961
|
+
*
|
|
3962
|
+
* ── The declaration is derived, never supplied ────────────────────────────
|
|
3963
|
+
*
|
|
3964
|
+
* A config-version push carries the authored `functions/<key>.toml` bytes
|
|
3965
|
+
* inside its envelope, and `envelopeHash` covers them. If the push ALSO
|
|
3966
|
+
* carried a parsed `triggers` payload, the two could disagree: a direct API
|
|
3967
|
+
* caller could ship a public webhook trigger the authored file does not
|
|
3968
|
+
* declare, and two pushes with identical envelopes but different trigger
|
|
3969
|
+
* payloads would collapse to one version. So the server parses the envelope's
|
|
3970
|
+
* own bytes here (D3181-005) and there is no payload field to disagree with —
|
|
3971
|
+
* trigger behavior is bound to the version's identity by construction.
|
|
3972
|
+
*
|
|
3973
|
+
* ── Shape only ────────────────────────────────────────────────────────────
|
|
3974
|
+
*
|
|
3975
|
+
* This module decides what the file SAYS: the accepted key set, the required
|
|
3976
|
+
* values, and the rules that need nothing but the document (scheme `none`,
|
|
3977
|
+
* a nameless or duplicated cron entry, an entry count past the per-function
|
|
3978
|
+
* cap, a webhook or database block on a task version). Everything that needs the
|
|
3979
|
+
* app's state — whether a referenced secret exists, whether the
|
|
3980
|
+
* scheme-specific config is valid, whether the app is at its webhook or cron
|
|
3981
|
+
* cap, whether a standalone webhook holds the key — belongs to the push
|
|
3982
|
+
* boundary, which runs the SAME validators the standalone create runs
|
|
3983
|
+
* (D3181-006).
|
|
3984
|
+
*
|
|
3985
|
+
* ── One implementation, two readers (#3320) ───────────────────────────────
|
|
3986
|
+
*
|
|
3987
|
+
* The CLI checks the same rules against the author's own file before a request
|
|
3988
|
+
* is made. It used to do that from a hand-written restatement
|
|
3989
|
+
* (`cli/src/lib/function-triggers.ts`), kept in step only by a paired-fixture
|
|
3990
|
+
* test — so a rule added here with no fixture drifted silently. The rules
|
|
3991
|
+
* therefore live in `src/config-surface/`, which `cli/scripts/
|
|
3992
|
+
* gen-config-surfaces.mjs` vendors verbatim into the committed artifact
|
|
3993
|
+
* `cli/src/lib/generated-config-surfaces.ts`. There is one implementation, and
|
|
3994
|
+
* a change here that is not regenerated fails `--check` (a build failure)
|
|
3995
|
+
* rather than a fixture list that happens not to cover it.
|
|
3996
|
+
*
|
|
3997
|
+
* Reading the authored BYTES is the one thing that stayed server-side:
|
|
3998
|
+
* `deriveTriggerDeclaration` in `src/server-functions/trigger-declaration.ts`
|
|
3999
|
+
* parses them and calls `normalizeTriggerDeclaration` here. This directory
|
|
4000
|
+
* imports nothing but itself (asserted by `config-surface-drift-guard.test.ts`),
|
|
4001
|
+
* and the CLI has already parsed its own file by the time it asks.
|
|
4002
|
+
*/
|
|
4003
|
+
/**
|
|
4004
|
+
* Why a webhook trigger is the request runtime, and a cron fire a task run —
|
|
4005
|
+
* #3482, the intent's "Mode vocabulary?" decision of 2026-09-15.
|
|
4006
|
+
*
|
|
4007
|
+
* Neither is a rule about the FUNCTION any more, so neither is a refusal: a
|
|
4008
|
+
* function is a function, and the DOOR decides which runtime runs it. A
|
|
4009
|
+
* webhook delivery runs inside the receiver because the provider is holding
|
|
4010
|
+
* the connection open waiting for an answer; a cron fire starts a task run
|
|
4011
|
+
* because it is waiting for nothing. A function that must not run under one of
|
|
4012
|
+
* them tests for it in code with `assertRuntime`, which is the only lock left.
|
|
4013
|
+
*
|
|
4014
|
+
* What survives here is the SHAPE of a declaration — the keys, the names, the
|
|
4015
|
+
* cron expression, the caps. The retired `mode` keys are accepted and reported
|
|
4016
|
+
* as ignored by `ignoredFunctionKeys` in `function-retired-keys.ts`.
|
|
4017
|
+
*/
|
|
4018
|
+
/** A function's single webhook trigger, normalized. */
|
|
4019
|
+
/**
|
|
4020
|
+
* The db3 type-name prefix the platform reserves for its own types (#4882,
|
|
4021
|
+
* project `agent-sessions-db3`): no app pushes, attaches or watches a type
|
|
4022
|
+
* whose name starts with it.
|
|
4023
|
+
*/
|
|
4024
|
+
export const RESERVED_DB3_TYPE_PREFIX = "primitive:";
|
|
4025
|
+
/** The most handshake rules and allowlist entries one webhook block may carry. */
|
|
4026
|
+
export const MAX_WEBHOOK_HANDSHAKE_RULES = 10;
|
|
4027
|
+
export const MAX_WEBHOOK_IP_CIDRS = 50;
|
|
3597
4028
|
export const EMPTY_TRIGGER_DECLARATION = {
|
|
3598
4029
|
webhook: null,
|
|
3599
4030
|
cron: [],
|
|
@@ -3608,10 +4039,16 @@ export const EMPTY_TRIGGER_DECLARATION = {
|
|
|
3608
4039
|
*/
|
|
3609
4040
|
export const MAX_CRON_TRIGGERS_PER_FUNCTION = 10;
|
|
3610
4041
|
/**
|
|
3611
|
-
*
|
|
3612
|
-
*
|
|
3613
|
-
*
|
|
3614
|
-
|
|
4042
|
+
* The most db3 types one function may watch — the cron cap's per-object
|
|
4043
|
+
* reasoning (#4803). The per-app ceiling is `MAX_DB3_TRIGGERS_PER_APP`, checked
|
|
4044
|
+
* at the push boundary.
|
|
4045
|
+
*/
|
|
4046
|
+
export const MAX_DB3_TRIGGERS_PER_FUNCTION = 10;
|
|
4047
|
+
const DB3_KEYS = new Set(["type"]);
|
|
4048
|
+
/**
|
|
4049
|
+
* Cron entry names follow the charset the retired standalone `triggerKey` had
|
|
4050
|
+
* (#3190), minus its ability to hold a `:` — which is exactly what keeps
|
|
4051
|
+
* `<functionKey>:<name>` unambiguous (the intent, "Key namespace?").
|
|
3615
4052
|
*/
|
|
3616
4053
|
const CRON_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/;
|
|
3617
4054
|
const WEBHOOK_KEYS = new Set([
|
|
@@ -3623,6 +4060,8 @@ const WEBHOOK_KEYS = new Set([
|
|
|
3623
4060
|
"maxBodyBytes",
|
|
3624
4061
|
"secretGracePeriodMs",
|
|
3625
4062
|
"verification",
|
|
4063
|
+
"handshakeRules",
|
|
4064
|
+
"allowedIpCidrs",
|
|
3626
4065
|
]);
|
|
3627
4066
|
const CRON_KEYS = new Set([
|
|
3628
4067
|
"name",
|
|
@@ -3659,6 +4098,8 @@ export const TRIGGER_RULE_IDS = [
|
|
|
3659
4098
|
"webhook-trigger-number",
|
|
3660
4099
|
"webhook-trigger-dedup-boolean",
|
|
3661
4100
|
"webhook-trigger-verification-table",
|
|
4101
|
+
"webhook-trigger-handshake-rules",
|
|
4102
|
+
"webhook-trigger-ip-allowlist",
|
|
3662
4103
|
"cron-trigger-cap",
|
|
3663
4104
|
"cron-trigger-entry",
|
|
3664
4105
|
"cron-trigger-keys",
|
|
@@ -3667,6 +4108,14 @@ export const TRIGGER_RULE_IDS = [
|
|
|
3667
4108
|
"cron-trigger-duplicate",
|
|
3668
4109
|
"cron-trigger-expression-required",
|
|
3669
4110
|
"cron-trigger-overlap-policy",
|
|
4111
|
+
// #4803 — `[[function.triggers.db3]]`, the db3 change trigger.
|
|
4112
|
+
"db3-trigger-cap",
|
|
4113
|
+
"db3-trigger-entry",
|
|
4114
|
+
"db3-trigger-keys",
|
|
4115
|
+
"db3-trigger-type-required",
|
|
4116
|
+
// #4882 — a `primitive:` type is the platform's.
|
|
4117
|
+
"db3-trigger-type-reserved",
|
|
4118
|
+
"db3-trigger-duplicate",
|
|
3670
4119
|
];
|
|
3671
4120
|
/**
|
|
3672
4121
|
* A broken trigger rule. `ruleId` names which one, for a reader that wants to
|
|
@@ -3687,7 +4136,9 @@ function refuseTrigger(ruleId, message) {
|
|
|
3687
4136
|
}
|
|
3688
4137
|
/** Is anything at all declared? Used to skip work on the common case. */
|
|
3689
4138
|
export function hasDeclaredTriggers(declaration) {
|
|
3690
|
-
return declaration.webhook !== null ||
|
|
4139
|
+
return (declaration.webhook !== null ||
|
|
4140
|
+
declaration.cron.length > 0 ||
|
|
4141
|
+
(declaration.db3?.length ?? 0) > 0);
|
|
3691
4142
|
}
|
|
3692
4143
|
/**
|
|
3693
4144
|
* Normalize the `triggers` table of an already-parsed `[function]` table.
|
|
@@ -3704,7 +4155,7 @@ export function normalizeTriggerDeclaration(functionTable) {
|
|
|
3704
4155
|
return EMPTY_TRIGGER_DECLARATION;
|
|
3705
4156
|
}
|
|
3706
4157
|
if (typeof triggers !== "object" || Array.isArray(triggers)) {
|
|
3707
|
-
refuseTrigger("triggers-table", "[function.triggers] must be a table declaring `webhook` and/or `
|
|
4158
|
+
refuseTrigger("triggers-table", "[function.triggers] must be a table declaring `webhook`, `cron` and/or `db3`");
|
|
3708
4159
|
}
|
|
3709
4160
|
// #3483 — checked BEFORE the unknown-kind rule, so an author who declares
|
|
3710
4161
|
// the block hears why it went rather than that `database` is not a word the
|
|
@@ -3715,14 +4166,15 @@ export function normalizeTriggerDeclaration(functionTable) {
|
|
|
3715
4166
|
refuseTrigger("database-trigger-removed", DATABASE_TRIGGER_REMOVED);
|
|
3716
4167
|
}
|
|
3717
4168
|
for (const key of Object.keys(triggers)) {
|
|
3718
|
-
if (key !== "webhook" && key !== "cron") {
|
|
4169
|
+
if (key !== "webhook" && key !== "cron" && key !== "db3") {
|
|
3719
4170
|
refuseTrigger("trigger-kind", `unknown trigger kind '${key}' under [function.triggers]: the kinds are ` +
|
|
3720
|
-
"`webhook` and `
|
|
4171
|
+
"`webhook`, `cron` and `db3`");
|
|
3721
4172
|
}
|
|
3722
4173
|
}
|
|
3723
4174
|
const webhook = normalizeWebhook(triggers.webhook);
|
|
3724
4175
|
const cron = normalizeCron(triggers.cron);
|
|
3725
|
-
|
|
4176
|
+
const db3 = normalizeDb3(triggers.db3);
|
|
4177
|
+
return db3.length > 0 ? { webhook, cron, db3 } : { webhook, cron };
|
|
3726
4178
|
}
|
|
3727
4179
|
/**
|
|
3728
4180
|
* The sentence an author who declared the block is owed — D3483-001.
|
|
@@ -3799,8 +4251,110 @@ function normalizeWebhook(raw) {
|
|
|
3799
4251
|
}
|
|
3800
4252
|
declaration.verification = jsonSafe(verification);
|
|
3801
4253
|
}
|
|
4254
|
+
if (table.handshakeRules !== undefined) {
|
|
4255
|
+
declaration.handshakeRules = normalizeHandshakeRules(table.handshakeRules);
|
|
4256
|
+
}
|
|
4257
|
+
if (table.allowedIpCidrs !== undefined) {
|
|
4258
|
+
declaration.allowedIpCidrs = normalizeIpAllowlist(table.allowedIpCidrs);
|
|
4259
|
+
}
|
|
3802
4260
|
return declaration;
|
|
3803
4261
|
}
|
|
4262
|
+
const HANDSHAKE_RESPONSE_KEYS = new Set(["status", "contentType", "body"]);
|
|
4263
|
+
/**
|
|
4264
|
+
* `[[function.triggers.webhook.handshakeRules]]` — the shape the receiver's
|
|
4265
|
+
* `parseHandshakeRules` reads: a non-empty CEL `when` and a `response` table of
|
|
4266
|
+
* an integer `status`, a `contentType` and a `body` template. The receiver
|
|
4267
|
+
* skips a malformed rule silently, so a typo here would be a handshake that
|
|
4268
|
+
* never answers; the push refuses it instead.
|
|
4269
|
+
*/
|
|
4270
|
+
function normalizeHandshakeRules(raw) {
|
|
4271
|
+
const refuse = (detail) => refuseTrigger("webhook-trigger-handshake-rules", `[[function.triggers.webhook.handshakeRules]] ${detail}`);
|
|
4272
|
+
if (!Array.isArray(raw))
|
|
4273
|
+
refuse("must be an array of tables");
|
|
4274
|
+
const entries = raw;
|
|
4275
|
+
if (entries.length > MAX_WEBHOOK_HANDSHAKE_RULES) {
|
|
4276
|
+
refuse(`may declare at most ${MAX_WEBHOOK_HANDSHAKE_RULES} rules`);
|
|
4277
|
+
}
|
|
4278
|
+
return entries.map((entry, index) => {
|
|
4279
|
+
const at = `entry ${index + 1}`;
|
|
4280
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
4281
|
+
refuse(`${at} must be a table with \`when\` and \`response\``);
|
|
4282
|
+
}
|
|
4283
|
+
const rule = entry;
|
|
4284
|
+
for (const key of Object.keys(rule)) {
|
|
4285
|
+
if (key !== "when" && key !== "response") {
|
|
4286
|
+
refuse(`${at}: unknown key '${key}' (accepted keys are when, response)`);
|
|
4287
|
+
}
|
|
4288
|
+
}
|
|
4289
|
+
if (typeof rule.when !== "string" || !rule.when.trim()) {
|
|
4290
|
+
refuse(`${at}: \`when\` must be a non-empty CEL expression`);
|
|
4291
|
+
}
|
|
4292
|
+
const response = rule.response;
|
|
4293
|
+
if (!response || typeof response !== "object" || Array.isArray(response)) {
|
|
4294
|
+
refuse(`${at}: \`response\` must be a table`);
|
|
4295
|
+
}
|
|
4296
|
+
const fields = response;
|
|
4297
|
+
for (const key of Object.keys(fields)) {
|
|
4298
|
+
if (!HANDSHAKE_RESPONSE_KEYS.has(key)) {
|
|
4299
|
+
refuse(`${at}: unknown response key '${key}' (accepted keys are ` +
|
|
4300
|
+
`${[...HANDSHAKE_RESPONSE_KEYS].join(", ")})`);
|
|
4301
|
+
}
|
|
4302
|
+
}
|
|
4303
|
+
const out = {
|
|
4304
|
+
when: String(rule.when),
|
|
4305
|
+
response: {},
|
|
4306
|
+
};
|
|
4307
|
+
if (fields.status !== undefined) {
|
|
4308
|
+
const status = fields.status;
|
|
4309
|
+
if (typeof status !== "number" ||
|
|
4310
|
+
!Number.isInteger(status) ||
|
|
4311
|
+
status < 200 ||
|
|
4312
|
+
status > 599) {
|
|
4313
|
+
refuse(`${at}: response \`status\` must be an integer HTTP status (200-599)`);
|
|
4314
|
+
}
|
|
4315
|
+
out.response.status = status;
|
|
4316
|
+
}
|
|
4317
|
+
for (const key of ["contentType", "body"]) {
|
|
4318
|
+
if (fields[key] === undefined)
|
|
4319
|
+
continue;
|
|
4320
|
+
if (typeof fields[key] !== "string") {
|
|
4321
|
+
refuse(`${at}: response \`${key}\` must be a string`);
|
|
4322
|
+
}
|
|
4323
|
+
out.response[key] = fields[key];
|
|
4324
|
+
}
|
|
4325
|
+
return out;
|
|
4326
|
+
});
|
|
4327
|
+
}
|
|
4328
|
+
/** An IPv4 address, optionally with a prefix length — what the receiver matches. */
|
|
4329
|
+
const IPV4_CIDR = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(?:\/(\d{1,2}))?$/;
|
|
4330
|
+
/**
|
|
4331
|
+
* `allowedIpCidrs = ["203.0.113.0/24", "198.51.100.7"]` — the sender addresses
|
|
4332
|
+
* the receiver accepts a delivery from, checked before verification. The
|
|
4333
|
+
* receiver matches IPv4 addresses and prefixes, so that is what the push
|
|
4334
|
+
* accepts; an entry it could never match would refuse every delivery.
|
|
4335
|
+
*/
|
|
4336
|
+
function normalizeIpAllowlist(raw) {
|
|
4337
|
+
const refuse = (detail) => refuseTrigger("webhook-trigger-ip-allowlist", `[function.triggers.webhook] allowedIpCidrs ${detail}`);
|
|
4338
|
+
if (!Array.isArray(raw))
|
|
4339
|
+
refuse("must be an array of IPv4 addresses or CIDR prefixes");
|
|
4340
|
+
const entries = raw;
|
|
4341
|
+
if (entries.length === 0)
|
|
4342
|
+
refuse("must name at least one address (omit the key to accept any)");
|
|
4343
|
+
if (entries.length > MAX_WEBHOOK_IP_CIDRS) {
|
|
4344
|
+
refuse(`may list at most ${MAX_WEBHOOK_IP_CIDRS} entries`);
|
|
4345
|
+
}
|
|
4346
|
+
return entries.map((entry) => {
|
|
4347
|
+
const value = typeof entry === "string" ? entry.trim() : "";
|
|
4348
|
+
const match = IPV4_CIDR.exec(value);
|
|
4349
|
+
const valid = match !== null &&
|
|
4350
|
+
match.slice(1, 5).every((octet) => Number(octet) <= 255) &&
|
|
4351
|
+
(match[5] === undefined || Number(match[5]) <= 32);
|
|
4352
|
+
if (!valid) {
|
|
4353
|
+
refuse(`entry '${String(entry)}' is not an IPv4 address or CIDR prefix (e.g. 203.0.113.0/24)`);
|
|
4354
|
+
}
|
|
4355
|
+
return value;
|
|
4356
|
+
});
|
|
4357
|
+
}
|
|
3804
4358
|
function normalizeCron(raw) {
|
|
3805
4359
|
if (raw === undefined || raw === null)
|
|
3806
4360
|
return [];
|
|
@@ -3868,6 +4422,60 @@ function normalizeCron(raw) {
|
|
|
3868
4422
|
normalized.sort((a, b) => a.name.localeCompare(b.name));
|
|
3869
4423
|
return normalized;
|
|
3870
4424
|
}
|
|
4425
|
+
/**
|
|
4426
|
+
* `[[function.triggers.db3]]` — the db3 types whose flushes start this
|
|
4427
|
+
* function (#4803). The cron block's shape: an array of tables (the
|
|
4428
|
+
* single-table spelling is one entry), at most ten, each type once, sorted so
|
|
4429
|
+
* the stored declaration is canonical.
|
|
4430
|
+
*
|
|
4431
|
+
* The type is not checked against the app's types here or at push (sponsor,
|
|
4432
|
+
* 2026-10-26): `config push` applies `functions/` before `db3-types/`, so a
|
|
4433
|
+
* same-run push of a type and its watcher would otherwise refuse itself, and a
|
|
4434
|
+
* watcher of a type no db3 holds simply never fires.
|
|
4435
|
+
*/
|
|
4436
|
+
function normalizeDb3(raw) {
|
|
4437
|
+
if (raw === undefined || raw === null)
|
|
4438
|
+
return [];
|
|
4439
|
+
const entries = Array.isArray(raw) ? raw : [raw];
|
|
4440
|
+
if (entries.length === 0)
|
|
4441
|
+
return [];
|
|
4442
|
+
if (entries.length > MAX_DB3_TRIGGERS_PER_FUNCTION) {
|
|
4443
|
+
refuseTrigger("db3-trigger-cap", `a function may declare at most ${MAX_DB3_TRIGGERS_PER_FUNCTION} ` +
|
|
4444
|
+
`[[function.triggers.db3]] entries, and this one declares ${entries.length}`);
|
|
4445
|
+
}
|
|
4446
|
+
const seen = new Set();
|
|
4447
|
+
const normalized = [];
|
|
4448
|
+
for (const entry of entries) {
|
|
4449
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
|
|
4450
|
+
refuseTrigger("db3-trigger-entry", "each [[function.triggers.db3]] entry must be a table: " +
|
|
4451
|
+
'[[function.triggers.db3]] type = "<db3 type>"');
|
|
4452
|
+
}
|
|
4453
|
+
const table = entry;
|
|
4454
|
+
for (const key of Object.keys(table)) {
|
|
4455
|
+
if (!DB3_KEYS.has(key)) {
|
|
4456
|
+
refuseTrigger("db3-trigger-keys", `unknown key '${key}' in a [[function.triggers.db3]] entry: the only ` +
|
|
4457
|
+
"key is `type`");
|
|
4458
|
+
}
|
|
4459
|
+
}
|
|
4460
|
+
const type = typeof table.type === "string" ? table.type.trim() : "";
|
|
4461
|
+
if (!type || type.includes("#")) {
|
|
4462
|
+
refuseTrigger("db3-trigger-type-required", "each [[function.triggers.db3]] entry needs a `type`: the name of the " +
|
|
4463
|
+
"db3 type it watches, a non-empty string without '#'");
|
|
4464
|
+
}
|
|
4465
|
+
if (type.startsWith(RESERVED_DB3_TYPE_PREFIX)) {
|
|
4466
|
+
refuseTrigger("db3-trigger-type-reserved", `[[function.triggers.db3]] type '${type}' is reserved: a type whose name starts ` +
|
|
4467
|
+
`'${RESERVED_DB3_TYPE_PREFIX}' is the platform's, and no app function watches it`);
|
|
4468
|
+
}
|
|
4469
|
+
if (seen.has(type)) {
|
|
4470
|
+
refuseTrigger("db3-trigger-duplicate", `duplicate [[function.triggers.db3]] type '${type}': a function watches ` +
|
|
4471
|
+
"each type once");
|
|
4472
|
+
}
|
|
4473
|
+
seen.add(type);
|
|
4474
|
+
normalized.push({ type });
|
|
4475
|
+
}
|
|
4476
|
+
normalized.sort((a, b) => (a.type < b.type ? -1 : a.type > b.type ? 1 : 0));
|
|
4477
|
+
return normalized;
|
|
4478
|
+
}
|
|
3871
4479
|
/**
|
|
3872
4480
|
* TOML values that JSON cannot carry (dates, and the bigints `smol-toml`
|
|
3873
4481
|
* produces for large integers) become their string / number form, so the
|
|
@@ -3910,9 +4518,11 @@ export function parseStoredTriggerDeclaration(stored) {
|
|
|
3910
4518
|
}
|
|
3911
4519
|
try {
|
|
3912
4520
|
const parsed = JSON.parse(stored);
|
|
4521
|
+
const db3 = Array.isArray(parsed?.db3) && parsed.db3.length > 0 ? parsed.db3 : null;
|
|
3913
4522
|
return {
|
|
3914
4523
|
webhook: parsed?.webhook ?? null,
|
|
3915
4524
|
cron: Array.isArray(parsed?.cron) ? parsed.cron : [],
|
|
4525
|
+
...(db3 ? { db3 } : {}),
|
|
3916
4526
|
// #3483 — a stored `databases` key is DROPPED, not read. A version
|
|
3917
4527
|
// pushed before the refusal existed still carries one in its immutable
|
|
3918
4528
|
// JSON, and the row is never rewritten; answering nothing at all is what
|
|
@@ -3957,6 +4567,23 @@ export function cronTriggerNameFrom(functionKey, triggerKey) {
|
|
|
3957
4567
|
? triggerKey.slice(prefix.length)
|
|
3958
4568
|
: triggerKey;
|
|
3959
4569
|
}
|
|
4570
|
+
/**
|
|
4571
|
+
* The `ServerFunctionTrigger.triggerKey` a db3 entry owns (#4803):
|
|
4572
|
+
* `<functionKey>:db3:<type>`. A cron name cannot hold `:`, so the key never
|
|
4573
|
+
* collides with a cron entry's `<functionKey>:<name>`.
|
|
4574
|
+
*/
|
|
4575
|
+
export function db3TriggerKeyFor(functionKey, type) {
|
|
4576
|
+
return `${functionKey}:db3:${type}`;
|
|
4577
|
+
}
|
|
4578
|
+
/**
|
|
4579
|
+
* The type a db3 trigger key carries, or null when the key is not this
|
|
4580
|
+
* function's db3 key. Read by stripping the prefix, never by splitting: a type
|
|
4581
|
+
* name may hold `:` and `/`.
|
|
4582
|
+
*/
|
|
4583
|
+
export function db3TriggerTypeFrom(functionKey, triggerKey) {
|
|
4584
|
+
const prefix = `${functionKey}:db3:`;
|
|
4585
|
+
return triggerKey.startsWith(prefix) ? triggerKey.slice(prefix.length) : null;
|
|
4586
|
+
}
|
|
3960
4587
|
// ── src/config-surface/secret-reference.ts ───────────────────────────────
|
|
3961
4588
|
/**
|
|
3962
4589
|
* The `{{secrets.KEY}}` reference SHAPE, decided from the value alone.
|
|
@@ -4265,588 +4892,80 @@ export function validateSigningSecretDeclaration(input) {
|
|
|
4265
4892
|
}
|
|
4266
4893
|
return null;
|
|
4267
4894
|
}
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
*
|
|
4275
|
-
* `runAs = "system"` beside a non-empty `accessRule` is dead config: a system
|
|
4276
|
-
* run can only be started by the system and never evaluates its access rule
|
|
4277
|
-
* (#1258, broadening #1172). The server refused it at save time
|
|
4278
|
-
* (`validateWorkflowIdentityConfig`) and the CLI refused it in the push
|
|
4279
|
-
* preflight (`validateWorkflowIdentity`), and the two carried the conjunction
|
|
4280
|
-
* byte-for-byte as separate copies kept in step by a comment. This module is
|
|
4281
|
-
* the one copy: it decides, and returns a STRUCTURED violation — the rule id
|
|
4282
|
-
* and the server's sentence — that each site renders in its own words. The
|
|
4283
|
-
* server pushes the sentence into its `string[]`; the CLI keeps its own hint,
|
|
4284
|
-
* which names the preflight remedy. Neither message changed.
|
|
4285
|
-
*
|
|
4286
|
-
* ── Why a `*-rules.ts` module ────────────────────────────────────────────
|
|
4287
|
-
*
|
|
4288
|
-
* The registry's unclaimed-export check (`findUnclaimedRuleModuleExports`)
|
|
4289
|
-
* keys on this name under `src/config-surface/`: every exported function here
|
|
4290
|
-
* is a rule, so one no surface declares fails `cli-unit-tests`. Shared
|
|
4291
|
-
* predicates that are not rules live elsewhere (`webhook-signing-secret.ts`).
|
|
4292
|
-
* The module is vendored into the CLI artifact like the rest of the
|
|
4293
|
-
* directory, which is what lets `workflow`'s declaration call the rule
|
|
4294
|
-
* `preflight`.
|
|
4295
|
-
*/
|
|
4296
|
-
/** The rule ids this module owns — the union type below anchors them (#3373). */
|
|
4297
|
-
export const WORKFLOW_RULE_IDS = [
|
|
4298
|
-
"system-access-rule",
|
|
4299
|
-
"retired-database-step-kind",
|
|
4895
|
+
const FIELD_RANGES = [
|
|
4896
|
+
{ name: "minute", min: 0, max: 59 },
|
|
4897
|
+
{ name: "hour", min: 0, max: 23 },
|
|
4898
|
+
{ name: "day-of-month", min: 1, max: 31 },
|
|
4899
|
+
{ name: "month", min: 1, max: 12 },
|
|
4900
|
+
{ name: "day-of-week", min: 0, max: 6 },
|
|
4300
4901
|
];
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4902
|
+
function parseField(field, min, max, fieldName) {
|
|
4903
|
+
const result = new Set();
|
|
4904
|
+
const parts = field.split(",");
|
|
4905
|
+
for (const partRaw of parts) {
|
|
4906
|
+
const part = partRaw.trim();
|
|
4907
|
+
if (!part) {
|
|
4908
|
+
throw new Error(`Invalid ${fieldName} field: empty segment`);
|
|
4909
|
+
}
|
|
4910
|
+
let step = 1;
|
|
4911
|
+
let rangePart = part;
|
|
4912
|
+
const slashIdx = part.indexOf("/");
|
|
4913
|
+
if (slashIdx !== -1) {
|
|
4914
|
+
rangePart = part.slice(0, slashIdx);
|
|
4915
|
+
const stepStr = part.slice(slashIdx + 1);
|
|
4916
|
+
const stepNum = Number(stepStr);
|
|
4917
|
+
if (!Number.isInteger(stepNum) || stepNum <= 0) {
|
|
4918
|
+
throw new Error(`Invalid ${fieldName} step: "${stepStr}"`);
|
|
4919
|
+
}
|
|
4920
|
+
step = stepNum;
|
|
4921
|
+
}
|
|
4922
|
+
let lo;
|
|
4923
|
+
let hi;
|
|
4924
|
+
if (rangePart === "*") {
|
|
4925
|
+
lo = min;
|
|
4926
|
+
hi = max;
|
|
4927
|
+
}
|
|
4928
|
+
else if (rangePart.includes("-")) {
|
|
4929
|
+
const [loStr, hiStr] = rangePart.split("-");
|
|
4930
|
+
lo = Number(loStr);
|
|
4931
|
+
hi = Number(hiStr);
|
|
4932
|
+
if (!Number.isInteger(lo) || !Number.isInteger(hi)) {
|
|
4933
|
+
throw new Error(`Invalid ${fieldName} range: "${rangePart}"`);
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
else {
|
|
4937
|
+
const exact = Number(rangePart);
|
|
4938
|
+
if (!Number.isInteger(exact)) {
|
|
4939
|
+
throw new Error(`Invalid ${fieldName} value: "${rangePart}"`);
|
|
4940
|
+
}
|
|
4941
|
+
lo = exact;
|
|
4942
|
+
hi = exact;
|
|
4943
|
+
}
|
|
4944
|
+
// Normalize day-of-week 7 -> 0 (Sunday). We only do this for bare
|
|
4945
|
+
// values, not inside a range — `5-7` would otherwise become `5-0`
|
|
4946
|
+
// which then fails the `lo > hi` check with a confusing error. Users
|
|
4947
|
+
// who want Fri–Sun should write `5-0,0` or `5,6,0`; we reject 7 in
|
|
4948
|
+
// ranges outright with a clearer message.
|
|
4949
|
+
if (fieldName === "day-of-week") {
|
|
4950
|
+
const isRange = rangePart.includes("-");
|
|
4951
|
+
if (isRange && (lo === 7 || hi === 7)) {
|
|
4952
|
+
throw new Error(`Invalid day-of-week range "${rangePart}": 7 (Sunday) is only allowed as a single value, not inside a range. Use 0 for Sunday in ranges.`);
|
|
4953
|
+
}
|
|
4954
|
+
if (!isRange) {
|
|
4955
|
+
if (lo === 7)
|
|
4956
|
+
lo = 0;
|
|
4957
|
+
if (hi === 7)
|
|
4958
|
+
hi = 0;
|
|
4959
|
+
}
|
|
4960
|
+
}
|
|
4961
|
+
if (lo < min || hi > max || lo > hi) {
|
|
4962
|
+
throw new Error(`Invalid ${fieldName} range: ${lo}-${hi} (allowed ${min}-${max})`);
|
|
4963
|
+
}
|
|
4964
|
+
for (let v = lo; v <= hi; v += step) {
|
|
4965
|
+
result.add(v);
|
|
4966
|
+
}
|
|
4320
4967
|
}
|
|
4321
|
-
return
|
|
4322
|
-
}
|
|
4323
|
-
/**
|
|
4324
|
-
* The DSL step kinds that executed a registered database operation (#3189,
|
|
4325
|
-
* phase 6 of project `server-functions`, matrix row M8).
|
|
4326
|
-
*
|
|
4327
|
-
* Every `database.*` runner except `database.syncIndexes` called
|
|
4328
|
-
* `DatabaseOperationsController.execute`, so retiring database operations
|
|
4329
|
-
* retires these fourteen kinds with them: the seven base kinds and their seven
|
|
4330
|
-
* `*ForUser` twins. `database.syncIndexes` (which calls the records index
|
|
4331
|
-
* route), `database.create` and `database.delete` (resource lifecycle) are not
|
|
4332
|
-
* here and keep running until the engine retires.
|
|
4333
|
-
*/
|
|
4334
|
-
export const RETIRED_DATABASE_STEP_KINDS = [
|
|
4335
|
-
"database.query",
|
|
4336
|
-
"database.mutate",
|
|
4337
|
-
"database.count",
|
|
4338
|
-
"database.aggregate",
|
|
4339
|
-
"database.pipeline",
|
|
4340
|
-
"database.applyToQuery",
|
|
4341
|
-
"database.batch",
|
|
4342
|
-
"database.queryForUser",
|
|
4343
|
-
"database.mutateForUser",
|
|
4344
|
-
"database.countForUser",
|
|
4345
|
-
"database.aggregateForUser",
|
|
4346
|
-
"database.pipelineForUser",
|
|
4347
|
-
"database.applyToQueryForUser",
|
|
4348
|
-
"database.batchForUser",
|
|
4349
|
-
];
|
|
4350
|
-
/**
|
|
4351
|
-
* Every step in a definition — or the one step a run has reached — whose kind
|
|
4352
|
-
* is a retired database kind, with the sentence naming the replacement.
|
|
4353
|
-
*
|
|
4354
|
-
* Walks the top-level `steps` and a `collect` step's nested `step`, the one
|
|
4355
|
-
* place a step definition nests another. Push (the CLI preflight), save, the
|
|
4356
|
-
* activation lint and the engine all ask this one question, so a definition is
|
|
4357
|
-
* refused by the same words wherever it is caught, and a run that reaches such
|
|
4358
|
-
* a step fails with them.
|
|
4359
|
-
*/
|
|
4360
|
-
export function checkWorkflowRetiredStepKinds(input) {
|
|
4361
|
-
const violations = [];
|
|
4362
|
-
const visit = (step) => {
|
|
4363
|
-
if (!step || typeof step !== "object" || Array.isArray(step))
|
|
4364
|
-
return;
|
|
4365
|
-
const kind = step.kind;
|
|
4366
|
-
const id = step.id;
|
|
4367
|
-
if (typeof kind === "string" &&
|
|
4368
|
-
RETIRED_DATABASE_STEP_KINDS.includes(kind)) {
|
|
4369
|
-
const name = typeof id === "string" && id ? `step "${id}"` : "a step";
|
|
4370
|
-
violations.push(refuseWorkflowRule("retired-database-step-kind", `${name} uses ${kind}, which was retired with database operations — ` +
|
|
4371
|
-
"move its work into a server function (ctx.db(databaseId).model(name)) " +
|
|
4372
|
-
"and call that function from the workflow with a workflow.call step"));
|
|
4373
|
-
}
|
|
4374
|
-
if (kind === "collect")
|
|
4375
|
-
visit(step.step);
|
|
4376
|
-
};
|
|
4377
|
-
if (Array.isArray(input.steps))
|
|
4378
|
-
input.steps.forEach(visit);
|
|
4379
|
-
return violations;
|
|
4380
|
-
}
|
|
4381
|
-
// ── src/config-surface/workflow.ts ───────────────────────────────────────
|
|
4382
|
-
/**
|
|
4383
|
-
* The `workflow` configuration object's definition (issue #2644, phase 1).
|
|
4384
|
-
*
|
|
4385
|
-
* One place records the `[workflow]` field surface: which `WorkflowDefinition`
|
|
4386
|
-
* fields the server accepts on create/update, which TOML key each carries,
|
|
4387
|
-
* whether `config pull` always emits it, and — for every field with real
|
|
4388
|
-
* behavior — the handler that owns that behavior. `createAppWorkflow` /
|
|
4389
|
-
* `updateAppWorkflow` take their accepted set from here (`pickWritableFields`),
|
|
4390
|
-
* the CLI's push builder and pull serializer read the vendored copy, and the
|
|
4391
|
-
* coverage guard cross-checks the whole thing against `models.yaml`.
|
|
4392
|
-
*
|
|
4393
|
-
* Supersedes `cli/src/lib/workflow-field-descriptor.ts` (#2326) and
|
|
4394
|
-
* `WORKFLOW_PAYLOAD_FIELDS_CREATE` / `_UPDATE`
|
|
4395
|
-
* (`cli/src/lib/workflow-payload.ts`, #1177), both deleted with this change.
|
|
4396
|
-
*/
|
|
4397
|
-
const HANDLERS = "src/workflows/config/workflow-field-handlers.ts";
|
|
4398
|
-
const handler = (name) => handledBy(HANDLERS, name, "apply");
|
|
4399
|
-
/**
|
|
4400
|
-
* The save-time rules the server runs and the CLI does not (#3374). They need
|
|
4401
|
-
* the runner's vocabulary (`isValidRunAs`, `GRANTABLE_SENSITIVE_CAPS`), which
|
|
4402
|
-
* this directory cannot import, so they are `apply`; the module carries the
|
|
4403
|
-
* rule-id anchor and `definition-store.ts` re-exports it.
|
|
4404
|
-
*/
|
|
4405
|
-
const WORKFLOW_SAVE_RULES = "src/workflows/config/workflow-save-rules.ts";
|
|
4406
|
-
const workflowApplyRule = (id, exportName, description) => ({
|
|
4407
|
-
id,
|
|
4408
|
-
description,
|
|
4409
|
-
stage: "apply",
|
|
4410
|
-
handler: enforcedBy(WORKFLOW_SAVE_RULES, exportName),
|
|
4411
|
-
});
|
|
4412
|
-
/**
|
|
4413
|
-
* The five per-app / per-user queue limits (#1177). All share one handler: a
|
|
4414
|
-
* finite non-negative number, floored.
|
|
4415
|
-
*/
|
|
4416
|
-
const QUEUE_LIMITS = [
|
|
4417
|
-
"perUserMaxRunning",
|
|
4418
|
-
"perUserMaxQueued",
|
|
4419
|
-
"perAppMaxRunning",
|
|
4420
|
-
"perAppMaxQueued",
|
|
4421
|
-
"queueTtlSeconds",
|
|
4422
|
-
];
|
|
4423
|
-
const queueLimitFields = QUEUE_LIMITS.map((field) => ({
|
|
4424
|
-
field,
|
|
4425
|
-
tomlKey: field,
|
|
4426
|
-
type: "number",
|
|
4427
|
-
emit: "whenSet",
|
|
4428
|
-
writableOn: BOTH,
|
|
4429
|
-
validation: handler("normalizeWorkflowQueueLimit"),
|
|
4430
|
-
}));
|
|
4431
|
-
export const WORKFLOW_SURFACE = {
|
|
4432
|
-
label: "workflow",
|
|
4433
|
-
tables: [
|
|
4434
|
-
{
|
|
4435
|
-
tomlPath: ["workflow"],
|
|
4436
|
-
repeated: false,
|
|
4437
|
-
model: "WorkflowDefinition",
|
|
4438
|
-
// Declaration order is the order `config pull` writes the keys, so it
|
|
4439
|
-
// deliberately matches the pre-#2644 hand-written serializer — migrating
|
|
4440
|
-
// to the definition must not reshuffle every workflow TOML file.
|
|
4441
|
-
fields: [
|
|
4442
|
-
{
|
|
4443
|
-
field: "name",
|
|
4444
|
-
tomlKey: "name",
|
|
4445
|
-
type: "string",
|
|
4446
|
-
emit: "always",
|
|
4447
|
-
writableOn: BOTH,
|
|
4448
|
-
validation: handler("normalizeWorkflowName"),
|
|
4449
|
-
},
|
|
4450
|
-
{
|
|
4451
|
-
field: "description",
|
|
4452
|
-
tomlKey: "description",
|
|
4453
|
-
type: "string",
|
|
4454
|
-
emit: "always",
|
|
4455
|
-
writableOn: BOTH,
|
|
4456
|
-
validation: handler("normalizeWorkflowDescription"),
|
|
4457
|
-
},
|
|
4458
|
-
{
|
|
4459
|
-
field: "accessRule",
|
|
4460
|
-
tomlKey: "accessRule",
|
|
4461
|
-
type: "string",
|
|
4462
|
-
emit: "whenSet",
|
|
4463
|
-
writableOn: BOTH,
|
|
4464
|
-
validation: handler("normalizeWorkflowAccessRule"),
|
|
4465
|
-
},
|
|
4466
|
-
{
|
|
4467
|
-
field: "runAs",
|
|
4468
|
-
tomlKey: "runAs",
|
|
4469
|
-
type: "string",
|
|
4470
|
-
emit: "whenSet",
|
|
4471
|
-
writableOn: BOTH,
|
|
4472
|
-
validation: handler("normalizeWorkflowRunAs"),
|
|
4473
|
-
},
|
|
4474
|
-
// #1078 Tier 1b — StringSetField on the model, string array in TOML/JSON.
|
|
4475
|
-
{
|
|
4476
|
-
field: "capabilities",
|
|
4477
|
-
tomlKey: "capabilities",
|
|
4478
|
-
type: "string[]",
|
|
4479
|
-
emit: "whenSet",
|
|
4480
|
-
writableOn: BOTH,
|
|
4481
|
-
validation: handler("normalizeWorkflowCapabilities"),
|
|
4482
|
-
},
|
|
4483
|
-
...queueLimitFields,
|
|
4484
|
-
{
|
|
4485
|
-
field: "dequeueOrder",
|
|
4486
|
-
tomlKey: "dequeueOrder",
|
|
4487
|
-
type: "string",
|
|
4488
|
-
emit: "always",
|
|
4489
|
-
writableOn: BOTH,
|
|
4490
|
-
validation: handler("normalizeWorkflowDequeueOrder"),
|
|
4491
|
-
},
|
|
4492
|
-
{
|
|
4493
|
-
field: "requiresClientApply",
|
|
4494
|
-
tomlKey: "requiresClientApply",
|
|
4495
|
-
type: "boolean",
|
|
4496
|
-
emit: "always",
|
|
4497
|
-
writableOn: BOTH,
|
|
4498
|
-
validation: handler("normalizeWorkflowOptOutFlag"),
|
|
4499
|
-
},
|
|
4500
|
-
// Accepted on BOTH modes — #807's deferred second PATCH is an update
|
|
4501
|
-
// call. The CLI's create-only send is a sequencing invariant owned by
|
|
4502
|
-
// `applyWorkflowBody`, not a statement about what the server accepts.
|
|
4503
|
-
// #3188 retired the synchronous run route this flag opted into; the
|
|
4504
|
-
// field still round-trips (pull, diff, push) until the workflow
|
|
4505
|
-
// surface itself retires, and `config push` notes a `true` as
|
|
4506
|
-
// ignored. Its step-kind rule went with the route.
|
|
4507
|
-
{
|
|
4508
|
-
field: "syncCallable",
|
|
4509
|
-
tomlKey: "syncCallable",
|
|
4510
|
-
type: "boolean",
|
|
4511
|
-
emit: "always",
|
|
4512
|
-
writableOn: BOTH,
|
|
4513
|
-
validation: handler("normalizeWorkflowSyncCallable"),
|
|
4514
|
-
},
|
|
4515
|
-
// JSON Schema objects. TOML may present them as an inline table OR as a
|
|
4516
|
-
// JSON string; the handler owns that parse.
|
|
4517
|
-
{
|
|
4518
|
-
field: "inputSchema",
|
|
4519
|
-
tomlKey: "inputSchema",
|
|
4520
|
-
type: "json",
|
|
4521
|
-
emit: "whenSet",
|
|
4522
|
-
writableOn: BOTH,
|
|
4523
|
-
validation: handler("normalizeWorkflowSchemaValue"),
|
|
4524
|
-
},
|
|
4525
|
-
{
|
|
4526
|
-
field: "outputSchema",
|
|
4527
|
-
tomlKey: "outputSchema",
|
|
4528
|
-
type: "json",
|
|
4529
|
-
emit: "whenSet",
|
|
4530
|
-
writableOn: BOTH,
|
|
4531
|
-
validation: handler("normalizeWorkflowSchemaValue"),
|
|
4532
|
-
},
|
|
4533
|
-
// #1518/#1972 — declarative run-scoped lock. `[workflow.lock]` inline
|
|
4534
|
-
// table on the TOML side, JSON on the wire.
|
|
4535
|
-
{
|
|
4536
|
-
field: "lock",
|
|
4537
|
-
tomlKey: "lock",
|
|
4538
|
-
type: "json",
|
|
4539
|
-
emit: "whenSet",
|
|
4540
|
-
writableOn: BOTH,
|
|
4541
|
-
validation: handler("normalizeWorkflowLockValue"),
|
|
4542
|
-
},
|
|
4543
|
-
],
|
|
4544
|
-
notExposed: {
|
|
4545
|
-
workflowId: {
|
|
4546
|
-
kind: "server-owned",
|
|
4547
|
-
note: "ULID assigned on create; never author-authored.",
|
|
4548
|
-
},
|
|
4549
|
-
// #2803 — `status` is the ONE availability control and it is
|
|
4550
|
-
// server-owned. It used to be a `[workflow]` key, which made `config
|
|
4551
|
-
// push` a second writer: pushing a file pulled before an operator ran
|
|
4552
|
-
// `workflows disable` put the workflow back in service as a side
|
|
4553
|
-
// effect. `server-owned` keeps it out of both the TOML surface and the
|
|
4554
|
-
// create/update request schemas, so the only writers are
|
|
4555
|
-
// `workflows enable|disable` and create (which assigns `active`).
|
|
4556
|
-
status: {
|
|
4557
|
-
kind: "server-owned",
|
|
4558
|
-
note: "Availability (#2803, #2887): active | inactive | archived. " +
|
|
4559
|
-
"Written only by `workflows enable|disable`, the delete flow (a " +
|
|
4560
|
-
"plain DELETE writes the `archived` tombstone; `?hard=true` " +
|
|
4561
|
-
"destroys), and create, which always assigns `active`. Never " +
|
|
4562
|
-
"authored in TOML: `config pull` does not emit it and a file that " +
|
|
4563
|
-
"still carries the key fails push (RETIRED_TOML_KEYS).",
|
|
4564
|
-
},
|
|
4565
|
-
// #2645 criterion 9 — the operational toggle. Configuration is
|
|
4566
|
-
// authored in TOML and applied with `config push`, so anything this
|
|
4567
|
-
// table exposes has the repo as its single writer. Taking a workflow
|
|
4568
|
-
// out of service is an operation with its own single writer
|
|
4569
|
-
// (`workflows disable|enable`), so this field must never appear in
|
|
4570
|
-
// the `[workflow]` table: `server-owned` keeps it out of both request
|
|
4571
|
-
// schemas and the TOML surface, and the coverage guard fails if it is
|
|
4572
|
-
// ever moved into `fields`.
|
|
4573
|
-
operationallyDisabled: {
|
|
4574
|
-
kind: "server-owned",
|
|
4575
|
-
note: "Operational toggle (#2645). Written only by the disable/enable " +
|
|
4576
|
-
"endpoints (`workflows disable|enable`); read by the dispatch " +
|
|
4577
|
-
"path. Never authored in TOML and never accepted on the config " +
|
|
4578
|
-
"create/update wire.",
|
|
4579
|
-
},
|
|
4580
|
-
appId: {
|
|
4581
|
-
kind: "server-owned",
|
|
4582
|
-
note: "Tenant scope, taken from the route; never on the wire.",
|
|
4583
|
-
},
|
|
4584
|
-
workflowKey: {
|
|
4585
|
-
kind: "structural",
|
|
4586
|
-
// Create carries it in the body; update does not read it at all —
|
|
4587
|
-
// the URL names the workflow and the CLI checks a contradicting
|
|
4588
|
-
// TOML key locally (`workflowKeyMismatchError`).
|
|
4589
|
-
requestModes: ["create"],
|
|
4590
|
-
note: "The workflow's identity. Comes from the TOML file name / --key and " +
|
|
4591
|
-
"is attached by the caller, not spread from the [workflow] table. Its " +
|
|
4592
|
-
"TOML spelling is declared in tomlOnlyKeys as `key`.",
|
|
4593
|
-
},
|
|
4594
|
-
activeConfigId: {
|
|
4595
|
-
kind: "server-owned",
|
|
4596
|
-
note: "Pointer to the active WorkflowConfiguration, computed on publish.",
|
|
4597
|
-
},
|
|
4598
|
-
metadataManifest: {
|
|
4599
|
-
kind: "structural",
|
|
4600
|
-
note: "#1304 declared-access manifest. Travels as the top-level [metadata] / " +
|
|
4601
|
-
"secrets tables and is validated by validateManifestShape, not as a " +
|
|
4602
|
-
"[workflow] key.",
|
|
4603
|
-
},
|
|
4604
|
-
// The legacy revision/draft slots are `server-owned`, not `deprecated`:
|
|
4605
|
-
// `deprecated` means "still WRITABLE, superseded by another field"
|
|
4606
|
-
// (`types.ts`), and phase 5's generated request schemas admit every
|
|
4607
|
-
// deprecated key for exactly that reason. None of these six is writable
|
|
4608
|
-
// — create and update never read them off the body; the draft save path
|
|
4609
|
-
// and the R2 writer assign them — so classifying them `deprecated` made
|
|
4610
|
-
// the schema accept a key the handler then dropped, which is the 200-on
|
|
4611
|
-
// -a-key-that-did-nothing this issue exists to end. Their models.yaml
|
|
4612
|
-
// DEPRECATED marking is about the field's future, not about who writes it.
|
|
4613
|
-
latestRevision: {
|
|
4614
|
-
kind: "server-owned",
|
|
4615
|
-
note: "Legacy revision pointer, marked DEPRECATED in models.yaml. " +
|
|
4616
|
-
"Written by the revision save path, never accepted on the wire.",
|
|
4617
|
-
},
|
|
4618
|
-
stepsR2Key: {
|
|
4619
|
-
kind: "server-owned",
|
|
4620
|
-
note: "Legacy steps pointer, marked DEPRECATED in models.yaml. Assigned " +
|
|
4621
|
-
"by the R2 write, never accepted on the wire.",
|
|
4622
|
-
},
|
|
4623
|
-
draftStepsR2Key: {
|
|
4624
|
-
kind: "server-owned",
|
|
4625
|
-
note: "Legacy draft steps pointer, marked DEPRECATED in models.yaml. " +
|
|
4626
|
-
"Assigned by the draft save path, never accepted on the wire.",
|
|
4627
|
-
},
|
|
4628
|
-
draftInputSchema: {
|
|
4629
|
-
kind: "server-owned",
|
|
4630
|
-
note: "Legacy draft slot, marked DEPRECATED in models.yaml. Written by " +
|
|
4631
|
-
"the draft save path from `inputSchema`, never accepted on the wire.",
|
|
4632
|
-
},
|
|
4633
|
-
draftOutputSchema: {
|
|
4634
|
-
kind: "server-owned",
|
|
4635
|
-
note: "Legacy draft slot, marked DEPRECATED in models.yaml. Written by " +
|
|
4636
|
-
"the draft save path from `outputSchema`, never accepted on the wire.",
|
|
4637
|
-
},
|
|
4638
|
-
draftModifiedAt: {
|
|
4639
|
-
kind: "server-owned",
|
|
4640
|
-
note: "Legacy draft timestamp, marked DEPRECATED in models.yaml. Stamped " +
|
|
4641
|
-
"by the draft save path, never accepted on the wire.",
|
|
4642
|
-
},
|
|
4643
|
-
createdBy: {
|
|
4644
|
-
kind: "server-owned",
|
|
4645
|
-
note: "Admin who created the workflow; assigned server-side.",
|
|
4646
|
-
},
|
|
4647
|
-
createdAt: {
|
|
4648
|
-
kind: "server-owned",
|
|
4649
|
-
note: "Timestamp, assigned server-side.",
|
|
4650
|
-
},
|
|
4651
|
-
modifiedAt: {
|
|
4652
|
-
kind: "server-owned",
|
|
4653
|
-
note: "Timestamp, assigned server-side.",
|
|
4654
|
-
},
|
|
4655
|
-
},
|
|
4656
|
-
tomlOnlyKeys: {
|
|
4657
|
-
key: {
|
|
4658
|
-
kind: "structural",
|
|
4659
|
-
note: "The workflow key. `config pull` writes it for readability; push takes " +
|
|
4660
|
-
"the identity from the file name and attaches `workflowKey` itself.",
|
|
4661
|
-
},
|
|
4662
|
-
activeConfigName: {
|
|
4663
|
-
kind: "structural",
|
|
4664
|
-
note: "Names which [[configs]] entry is active. Consumed by the push apply " +
|
|
4665
|
-
"path (which activates the matching config by id), not sent as a " +
|
|
4666
|
-
"[workflow] field.",
|
|
4667
|
-
},
|
|
4668
|
-
},
|
|
4669
|
-
requestOnlyKeys: {
|
|
4670
|
-
steps: {
|
|
4671
|
-
// CREATE only: `updateAppWorkflow` never reads `steps` off the body —
|
|
4672
|
-
// an update writes them through the workflow-config / draft
|
|
4673
|
-
// endpoints (`applyWorkflowBody`) — so a PATCH carrying steps used to
|
|
4674
|
-
// return 200 having saved none of them.
|
|
4675
|
-
modes: CREATE_ONLY,
|
|
4676
|
-
note: "The workflow's step list. Not a `WorkflowDefinition` field — it " +
|
|
4677
|
-
"lives on the active WorkflowConfiguration (and in R2) — but the " +
|
|
4678
|
-
"create call carries it in the same body so a new workflow lands " +
|
|
4679
|
-
"with its steps in one request. Validated by the step allowlist " +
|
|
4680
|
-
"(`cli/src/lib/generated-allowlist.ts`, #998) and the server's " +
|
|
4681
|
-
"definition validation.",
|
|
4682
|
-
},
|
|
4683
|
-
expressions: {
|
|
4684
|
-
// CREATE only, for the same reason as `steps`: they travel on the
|
|
4685
|
-
// steps payload, which an update writes through its own endpoint.
|
|
4686
|
-
modes: CREATE_ONLY,
|
|
4687
|
-
note: "#1614 — the named `expr.*` definitions, which travel on the same " +
|
|
4688
|
-
"steps payload rather than as a definition field.",
|
|
4689
|
-
},
|
|
4690
|
-
},
|
|
4691
|
-
responseOnlyKeys: {
|
|
4692
|
-
platformOwned: {
|
|
4693
|
-
kind: "server-owned",
|
|
4694
|
-
note: "#1660 — derived flag marking a reserved `__internal.` workflow. " +
|
|
4695
|
-
"Computed at serialize time; not persisted, never writable.",
|
|
4696
|
-
},
|
|
4697
|
-
},
|
|
4698
|
-
},
|
|
4699
|
-
],
|
|
4700
|
-
tomlDocumentKeys: {
|
|
4701
|
-
steps: {
|
|
4702
|
-
kind: "structural",
|
|
4703
|
-
note: "The `[[steps]]` array. Validated by the step allowlist " +
|
|
4704
|
-
"(`cli/src/lib/generated-allowlist.ts`, #998) and the server's " +
|
|
4705
|
-
"definition validation; its shape is checked by validateWorkflowToml.",
|
|
4706
|
-
},
|
|
4707
|
-
configs: {
|
|
4708
|
-
kind: "structural",
|
|
4709
|
-
note: "RETIRED as an inline list (#2645): named configurations are authored " +
|
|
4710
|
-
"one per file at `workflows/<key>.configs/<name>.toml` and selected by " +
|
|
4711
|
-
"`[workflow].activeConfigName`. Pull writes the sidecars, push applies " +
|
|
4712
|
-
"them through the workflow-config endpoints, and a file still carrying " +
|
|
4713
|
-
"`[[configs]]` fails validation (validateWorkflowToml) rather than " +
|
|
4714
|
-
"having the list quietly ignored. Declared here so the document-shape " +
|
|
4715
|
-
"check defers to that targeted message.",
|
|
4716
|
-
},
|
|
4717
|
-
...DECLARED_ACCESS_MANIFEST_KEYS,
|
|
4718
|
-
expr: {
|
|
4719
|
-
kind: "structural",
|
|
4720
|
-
note: "#1614 — the named `[expr.cel]` guard definitions, which travel on the " +
|
|
4721
|
-
"steps payload (parseWorkflowExpressionsToml).",
|
|
4722
|
-
},
|
|
4723
|
-
include: {
|
|
4724
|
-
kind: "structural",
|
|
4725
|
-
note: "Workflow fragments (`include = [\"name\"]` or repeated `[[include]]` " +
|
|
4726
|
-
"tables), expanded into `steps` by expandWorkflowTomlData before push.",
|
|
4727
|
-
},
|
|
4728
|
-
},
|
|
4729
|
-
// ── Cross-field rules (#3374) ─────────────────────────────────────────────
|
|
4730
|
-
//
|
|
4731
|
-
// Two rules the CLI's push preflight runs — through the vendored copy of
|
|
4732
|
-
// `workflow-rules.ts` (the server runs both too) — and six more the server
|
|
4733
|
-
// runs at save time. What stays
|
|
4734
|
-
// UNDECLARED, on purpose: the step-body validation (`validateWorkflowDefinition`
|
|
4735
|
-
// and the `steps` structural sub-tree, which is not a field-table rule), and
|
|
4736
|
-
// the enable-time activation lint (`workflow-activation-lint.ts`, a transition
|
|
4737
|
-
// check rather than a write rule). `runAs`'s VALUE is checked twice today —
|
|
4738
|
-
// by its field handler and again inside the identity validator — which is
|
|
4739
|
-
// stated here as a finding, not fixed.
|
|
4740
|
-
crossFieldRules: [
|
|
4741
|
-
{
|
|
4742
|
-
id: "system-access-rule",
|
|
4743
|
-
description: 'A `runAs = "system"` workflow may not carry a non-empty `accessRule`: ' +
|
|
4744
|
-
"a system run never evaluates its rule, so any rule there is dead " +
|
|
4745
|
-
"config. The one predicate both runners share; each renders its own " +
|
|
4746
|
-
"message.",
|
|
4747
|
-
stage: "preflight",
|
|
4748
|
-
handler: enforcedBy("src/config-surface/workflow-rules.ts", "checkWorkflowSystemAccessRule"),
|
|
4749
|
-
},
|
|
4750
|
-
{
|
|
4751
|
-
id: "retired-database-step-kind",
|
|
4752
|
-
description: "A step may not use a retired `database.*` kind (`database.query`, " +
|
|
4753
|
-
"`mutate`, `count`, `aggregate`, `pipeline`, `applyToQuery`, `batch` " +
|
|
4754
|
-
"and their `*ForUser` twins): each executed a registered database " +
|
|
4755
|
-
"operation, and operations retired (#3189). `database.syncIndexes`, " +
|
|
4756
|
-
"`database.create` and `database.delete` stay. Push, save, the " +
|
|
4757
|
-
"activation lint and the engine ask the same predicate.",
|
|
4758
|
-
stage: "preflight",
|
|
4759
|
-
handler: enforcedBy("src/config-surface/workflow-rules.ts", "checkWorkflowRetiredStepKinds"),
|
|
4760
|
-
},
|
|
4761
|
-
workflowApplyRule("run-as-value", "validateWorkflowIdentityConfig", '`runAs` must be "caller" or "system" when present — the runner has no ' +
|
|
4762
|
-
"third identity."),
|
|
4763
|
-
workflowApplyRule("capabilities-shape", "validateWorkflowIdentityConfig", "`capabilities` must be an array or set of capability strings."),
|
|
4764
|
-
workflowApplyRule("capability-grantable", "validateWorkflowIdentityConfig", "Every declared capability must be one the runner can grant; the " +
|
|
4765
|
-
"always-on data baseline is never declared."),
|
|
4766
|
-
workflowApplyRule("iterate-users-system-only", "validateWorkflowIdentityConfig", 'An `iterate-users` step may appear only in a `runAs = "system"` ' +
|
|
4767
|
-
"workflow — fanning out over every user is not a member-as-themselves " +
|
|
4768
|
-
"operation."),
|
|
4769
|
-
workflowApplyRule("access-rule-type", "validateWorkflowIdentityConfig", "On create, a supplied `accessRule` must be a string — a non-string is " +
|
|
4770
|
-
"malformed input, reported as such rather than as an omission."),
|
|
4771
|
-
workflowApplyRule("access-rule-required", "validateWorkflowIdentityConfig", "On create, a caller-mode workflow must state its `accessRule` (`\"true\"` " +
|
|
4772
|
-
"for any app member), so a locked workflow is a decision rather than a " +
|
|
4773
|
-
"default."),
|
|
4774
|
-
],
|
|
4775
|
-
};
|
|
4776
|
-
const FIELD_RANGES = [
|
|
4777
|
-
{ name: "minute", min: 0, max: 59 },
|
|
4778
|
-
{ name: "hour", min: 0, max: 23 },
|
|
4779
|
-
{ name: "day-of-month", min: 1, max: 31 },
|
|
4780
|
-
{ name: "month", min: 1, max: 12 },
|
|
4781
|
-
{ name: "day-of-week", min: 0, max: 6 },
|
|
4782
|
-
];
|
|
4783
|
-
function parseField(field, min, max, fieldName) {
|
|
4784
|
-
const result = new Set();
|
|
4785
|
-
const parts = field.split(",");
|
|
4786
|
-
for (const partRaw of parts) {
|
|
4787
|
-
const part = partRaw.trim();
|
|
4788
|
-
if (!part) {
|
|
4789
|
-
throw new Error(`Invalid ${fieldName} field: empty segment`);
|
|
4790
|
-
}
|
|
4791
|
-
let step = 1;
|
|
4792
|
-
let rangePart = part;
|
|
4793
|
-
const slashIdx = part.indexOf("/");
|
|
4794
|
-
if (slashIdx !== -1) {
|
|
4795
|
-
rangePart = part.slice(0, slashIdx);
|
|
4796
|
-
const stepStr = part.slice(slashIdx + 1);
|
|
4797
|
-
const stepNum = Number(stepStr);
|
|
4798
|
-
if (!Number.isInteger(stepNum) || stepNum <= 0) {
|
|
4799
|
-
throw new Error(`Invalid ${fieldName} step: "${stepStr}"`);
|
|
4800
|
-
}
|
|
4801
|
-
step = stepNum;
|
|
4802
|
-
}
|
|
4803
|
-
let lo;
|
|
4804
|
-
let hi;
|
|
4805
|
-
if (rangePart === "*") {
|
|
4806
|
-
lo = min;
|
|
4807
|
-
hi = max;
|
|
4808
|
-
}
|
|
4809
|
-
else if (rangePart.includes("-")) {
|
|
4810
|
-
const [loStr, hiStr] = rangePart.split("-");
|
|
4811
|
-
lo = Number(loStr);
|
|
4812
|
-
hi = Number(hiStr);
|
|
4813
|
-
if (!Number.isInteger(lo) || !Number.isInteger(hi)) {
|
|
4814
|
-
throw new Error(`Invalid ${fieldName} range: "${rangePart}"`);
|
|
4815
|
-
}
|
|
4816
|
-
}
|
|
4817
|
-
else {
|
|
4818
|
-
const exact = Number(rangePart);
|
|
4819
|
-
if (!Number.isInteger(exact)) {
|
|
4820
|
-
throw new Error(`Invalid ${fieldName} value: "${rangePart}"`);
|
|
4821
|
-
}
|
|
4822
|
-
lo = exact;
|
|
4823
|
-
hi = exact;
|
|
4824
|
-
}
|
|
4825
|
-
// Normalize day-of-week 7 -> 0 (Sunday). We only do this for bare
|
|
4826
|
-
// values, not inside a range — `5-7` would otherwise become `5-0`
|
|
4827
|
-
// which then fails the `lo > hi` check with a confusing error. Users
|
|
4828
|
-
// who want Fri–Sun should write `5-0,0` or `5,6,0`; we reject 7 in
|
|
4829
|
-
// ranges outright with a clearer message.
|
|
4830
|
-
if (fieldName === "day-of-week") {
|
|
4831
|
-
const isRange = rangePart.includes("-");
|
|
4832
|
-
if (isRange && (lo === 7 || hi === 7)) {
|
|
4833
|
-
throw new Error(`Invalid day-of-week range "${rangePart}": 7 (Sunday) is only allowed as a single value, not inside a range. Use 0 for Sunday in ranges.`);
|
|
4834
|
-
}
|
|
4835
|
-
if (!isRange) {
|
|
4836
|
-
if (lo === 7)
|
|
4837
|
-
lo = 0;
|
|
4838
|
-
if (hi === 7)
|
|
4839
|
-
hi = 0;
|
|
4840
|
-
}
|
|
4841
|
-
}
|
|
4842
|
-
if (lo < min || hi > max || lo > hi) {
|
|
4843
|
-
throw new Error(`Invalid ${fieldName} range: ${lo}-${hi} (allowed ${min}-${max})`);
|
|
4844
|
-
}
|
|
4845
|
-
for (let v = lo; v <= hi; v += step) {
|
|
4846
|
-
result.add(v);
|
|
4847
|
-
}
|
|
4848
|
-
}
|
|
4849
|
-
return result;
|
|
4968
|
+
return result;
|
|
4850
4969
|
}
|
|
4851
4970
|
export function parseCron(expr) {
|
|
4852
4971
|
if (!expr || typeof expr !== "string") {
|
|
@@ -4936,15 +5055,6 @@ export function isValidTimezone(name) {
|
|
|
4936
5055
|
* pins. So the grammar and the `Intl` probe live next door in
|
|
4937
5056
|
* `cron-expression.ts`, which is a shared-predicate module rather than a rules
|
|
4938
5057
|
* module, and this one only decides and renders.
|
|
4939
|
-
*
|
|
4940
|
-
* ── What is NOT shared ───────────────────────────────────────────────────
|
|
4941
|
-
*
|
|
4942
|
-
* The standalone cron routes ask the same two predicates and render their own
|
|
4943
|
-
* `Invalid cron expression: …` / `Invalid timezone: …`, with their own
|
|
4944
|
-
* defaulting (create reads an absent timezone as UTC, update does not). That
|
|
4945
|
-
* is intent assumption 2 in the form its own fallback describes, and the shape
|
|
4946
|
-
* `workflow-rules.ts` set in phase 2: one predicate, each site's message and
|
|
4947
|
-
* defaulting preserved. No refusal message changed anywhere.
|
|
4948
5058
|
*/
|
|
4949
5059
|
/** The rule ids this module owns — the union type below anchors them (#3373). */
|
|
4950
5060
|
export const CRON_TRIGGER_RULE_IDS = [
|
|
@@ -6585,33 +6695,23 @@ const GEMINI_TYPES = [
|
|
|
6585
6695
|
"array",
|
|
6586
6696
|
];
|
|
6587
6697
|
/**
|
|
6588
|
-
*
|
|
6589
|
-
*
|
|
6590
|
-
*
|
|
6698
|
+
* What Gemini's function `Schema` does with one keyword, from the keyword
|
|
6699
|
+
* table: `pass` (spelled the same way, with the same meaning — `required`
|
|
6700
|
+
* among them, and Gemini's own `nullable`, `propertyOrdering` and `example`),
|
|
6701
|
+
* `drop` (an annotation with no value meaning, dropped in silence, spec §3),
|
|
6702
|
+
* `rule` (handled by its own rule below) or `refuse`. A key the table does not
|
|
6703
|
+
* name is refused: a keyword nobody classified could mean anything.
|
|
6591
6704
|
*/
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
"maxItems",
|
|
6603
|
-
"minProperties",
|
|
6604
|
-
"maxProperties",
|
|
6605
|
-
"required",
|
|
6606
|
-
// Gemini's own spellings, accepted as authored.
|
|
6607
|
-
"nullable",
|
|
6608
|
-
"propertyOrdering",
|
|
6609
|
-
"example",
|
|
6610
|
-
];
|
|
6611
|
-
/** Annotations with no value meaning: dropped in silence (spec §3). */
|
|
6612
|
-
const GEMINI_DROPPED_KEYWORDS = ["$schema", "$id", "$comment"];
|
|
6613
|
-
/** Keywords handled by their own rule below, not by the tables. */
|
|
6614
|
-
const GEMINI_STRUCTURAL_KEYWORDS = [
|
|
6705
|
+
export function geminiKeywordVerdict(keyword) {
|
|
6706
|
+
return Object.prototype.hasOwnProperty.call(SCHEMA_KEYWORDS, keyword)
|
|
6707
|
+
? SCHEMA_KEYWORDS[keyword].gemini
|
|
6708
|
+
: "refuse";
|
|
6709
|
+
}
|
|
6710
|
+
/**
|
|
6711
|
+
* Keywords handled by their own rule below: exactly the table's `rule` rows,
|
|
6712
|
+
* which the keyword-table conformance test holds it to.
|
|
6713
|
+
*/
|
|
6714
|
+
export const GEMINI_STRUCTURAL_KEYWORDS = [
|
|
6615
6715
|
"type",
|
|
6616
6716
|
"enum",
|
|
6617
6717
|
"const",
|
|
@@ -6632,10 +6732,12 @@ const GEMINI_FORMATS = [
|
|
|
6632
6732
|
"double",
|
|
6633
6733
|
];
|
|
6634
6734
|
/**
|
|
6635
|
-
*
|
|
6636
|
-
*
|
|
6735
|
+
* Why Gemini's function `Schema` cannot carry a refused keyword, for the ones
|
|
6736
|
+
* with a reason of their own. Each is refused rather than dropped: dropping any
|
|
6737
|
+
* of them widens what the model may produce. A refused keyword with no entry
|
|
6738
|
+
* here gets the generic reason.
|
|
6637
6739
|
*/
|
|
6638
|
-
const
|
|
6740
|
+
export const GEMINI_REFUSAL_REASONS = {
|
|
6639
6741
|
$ref: "Gemini's function Schema has no $ref — inline the referenced schema",
|
|
6640
6742
|
$defs: "Gemini's function Schema has no $defs — inline each definition where it is used",
|
|
6641
6743
|
definitions: "Gemini's function Schema has no definitions — inline each definition where it is used",
|
|
@@ -6662,21 +6764,10 @@ const GEMINI_REFUSED_KEYWORDS = {
|
|
|
6662
6764
|
writeOnly: "Gemini's function Schema has no writeOnly — drop it, or say so in description",
|
|
6663
6765
|
deprecated: "Gemini's function Schema has no deprecated — say so in description",
|
|
6664
6766
|
};
|
|
6665
|
-
/**
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
* discriminated union is, restated here because that module is vendored
|
|
6670
|
-
* separately and cannot be imported from `src/config-surface/`.
|
|
6671
|
-
*/
|
|
6672
|
-
const ONEOF_SIBLING_KEYWORDS = [
|
|
6673
|
-
"type",
|
|
6674
|
-
"properties",
|
|
6675
|
-
"required",
|
|
6676
|
-
"additionalProperties",
|
|
6677
|
-
"items",
|
|
6678
|
-
"enum",
|
|
6679
|
-
];
|
|
6767
|
+
/** The reason a key the table does not classify, or classifies without one, is refused. */
|
|
6768
|
+
const GEMINI_UNCLASSIFIED_REASON = "is not a keyword Gemini's function Schema carries, and dropping a " +
|
|
6769
|
+
"keyword whose meaning the platform does not know could widen what the " +
|
|
6770
|
+
"model may produce";
|
|
6680
6771
|
function isPlainSchemaObject(value) {
|
|
6681
6772
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6682
6773
|
}
|
|
@@ -6730,7 +6821,7 @@ function memberTagLiterals(member) {
|
|
|
6730
6821
|
* and the platform validator reject but an `anyOf` of the same members accepts
|
|
6731
6822
|
* — so the rewrite would widen what the model may produce. The platform
|
|
6732
6823
|
* validator already rejects a value whose tag is missing
|
|
6733
|
-
* (`src/
|
|
6824
|
+
* (`src/function-runs/schema-validation.ts`), so requiring it refuses nothing the
|
|
6734
6825
|
* platform accepts at run time.
|
|
6735
6826
|
*/
|
|
6736
6827
|
function discriminatedOneOf(node, members) {
|
|
@@ -6743,7 +6834,10 @@ function discriminatedOneOf(node, members) {
|
|
|
6743
6834
|
'members, every one of them type = "object"',
|
|
6744
6835
|
};
|
|
6745
6836
|
}
|
|
6746
|
-
|
|
6837
|
+
// Sibling keywords that make a `oneOf` node a MIXED schema rather than a
|
|
6838
|
+
// clean tagged union: `describeSchema`'s own list, the platform's rule for
|
|
6839
|
+
// what a discriminated union is.
|
|
6840
|
+
const sibling = ONEOF_SIBLING_CONSTRAINT_KEYS.filter((key) => Object.prototype.hasOwnProperty.call(node, key));
|
|
6747
6841
|
if (sibling.length > 0) {
|
|
6748
6842
|
return {
|
|
6749
6843
|
ok: false,
|
|
@@ -6825,7 +6919,8 @@ function translateGeminiNode(node, path, out) {
|
|
|
6825
6919
|
// ── Pass one: the tables, in the author's own key order ────────────────
|
|
6826
6920
|
const deferred = new Set();
|
|
6827
6921
|
for (const key of Object.keys(node)) {
|
|
6828
|
-
|
|
6922
|
+
const verdict = geminiKeywordVerdict(key);
|
|
6923
|
+
if (verdict === "drop")
|
|
6829
6924
|
continue;
|
|
6830
6925
|
if (key === "additionalProperties") {
|
|
6831
6926
|
// Dropped for `false` and `true` alike: Gemini has no closed-object
|
|
@@ -6840,22 +6935,19 @@ function translateGeminiNode(node, path, out) {
|
|
|
6840
6935
|
"but the platform validates the original schema)");
|
|
6841
6936
|
continue;
|
|
6842
6937
|
}
|
|
6843
|
-
if (
|
|
6844
|
-
refuse(key, GEMINI_REFUSED_KEYWORDS[key]);
|
|
6845
|
-
continue;
|
|
6846
|
-
}
|
|
6847
|
-
if (GEMINI_PASS_KEYWORDS.includes(key)) {
|
|
6938
|
+
if (verdict === "pass") {
|
|
6848
6939
|
result[key] = schemaCopy(node[key]);
|
|
6849
6940
|
continue;
|
|
6850
6941
|
}
|
|
6851
|
-
if (GEMINI_STRUCTURAL_KEYWORDS.includes(key)) {
|
|
6942
|
+
if (verdict === "rule" && GEMINI_STRUCTURAL_KEYWORDS.includes(key)) {
|
|
6852
6943
|
deferred.add(key);
|
|
6853
6944
|
continue;
|
|
6854
6945
|
}
|
|
6855
|
-
// Fail closed: a keyword nobody classified could mean
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6946
|
+
// Fail closed: a refused keyword, or one nobody classified, could mean
|
|
6947
|
+
// anything to the model.
|
|
6948
|
+
refuse(key, Object.prototype.hasOwnProperty.call(GEMINI_REFUSAL_REASONS, key)
|
|
6949
|
+
? GEMINI_REFUSAL_REASONS[key]
|
|
6950
|
+
: GEMINI_UNCLASSIFIED_REASON);
|
|
6859
6951
|
}
|
|
6860
6952
|
// ── Pass two: the structural keywords, in a fixed order ────────────────
|
|
6861
6953
|
if (deferred.has("enum")) {
|
|
@@ -7300,6 +7392,324 @@ export function agentSchemaDeficitRefusal(deficit) {
|
|
|
7300
7392
|
`rewrite the schema, or archive every ${provider} config of this prompt`,
|
|
7301
7393
|
};
|
|
7302
7394
|
}
|
|
7395
|
+
// ── src/config-surface/prompt-schema-refusals.ts ─────────────────────────
|
|
7396
|
+
/**
|
|
7397
|
+
* What a prompt push refuses — #5536 (project `unified-schemas` phase 5)
|
|
7398
|
+
* reported it, #5538 (phase 6, intent criterion 8) refuses it.
|
|
7399
|
+
*
|
|
7400
|
+
* Two checks judge a prompt's schemas: the lossless Gemini translator
|
|
7401
|
+
* (`translateSchemaForProvider`) on the output schemas a Gemini config sends,
|
|
7402
|
+
* and the engine (the function push's rules) on every schema. A write
|
|
7403
|
+
* carrying a keyword either would refuse is refused, each keyword named with
|
|
7404
|
+
* its fix and a code: `PROMPT_SCHEMA_NOT_TRANSLATABLE` for the translator,
|
|
7405
|
+
* `PROMPT_SCHEMA_UNSUPPORTED_KEYWORD` for the engine. The admin prompt routes,
|
|
7406
|
+
* the CLI preflight (through the vendored copy), the Gemini call path and the
|
|
7407
|
+
* audit (`scripts/lib/schema-audit-core.ts`) all read this module, so they
|
|
7408
|
+
* cannot disagree about which schemas are refused.
|
|
7409
|
+
*
|
|
7410
|
+
* An agent's translator refusals are not here: they are already the push
|
|
7411
|
+
* error `AGENT_SCHEMA_NOT_TRANSLATABLE` (DSO-5536-002).
|
|
7412
|
+
*/
|
|
7413
|
+
/**
|
|
7414
|
+
* The code a prompt write is refused with for a keyword the lossless Gemini
|
|
7415
|
+
* translator cannot carry, and the code a run of a stored prompt whose output
|
|
7416
|
+
* schema it cannot carry fails with.
|
|
7417
|
+
*/
|
|
7418
|
+
export const PROMPT_SCHEMA_NOT_TRANSLATABLE = "PROMPT_SCHEMA_NOT_TRANSLATABLE";
|
|
7419
|
+
/** The code a prompt write is refused with for a keyword or a shape the schema check would not enforce. */
|
|
7420
|
+
export const PROMPT_SCHEMA_UNSUPPORTED_KEYWORD = "PROMPT_SCHEMA_UNSUPPORTED_KEYWORD";
|
|
7421
|
+
/**
|
|
7422
|
+
* The fix for each keyword the engine refuses: one entry per refused row of
|
|
7423
|
+
* the keyword table, and no other key.
|
|
7424
|
+
*/
|
|
7425
|
+
export const ENGINE_REFUSAL_FIXES = {
|
|
7426
|
+
$dynamicRef: "Write a local $ref to #/$defs/<Name> instead",
|
|
7427
|
+
$recursiveRef: "Write a local $ref to #/$defs/<Name> instead",
|
|
7428
|
+
allOf: "Merge the members into one schema",
|
|
7429
|
+
not: "State what is allowed instead",
|
|
7430
|
+
if: "Declare a discriminated oneOf instead",
|
|
7431
|
+
then: "Declare a discriminated oneOf instead",
|
|
7432
|
+
else: "Declare a discriminated oneOf instead",
|
|
7433
|
+
patternProperties: "Name the properties",
|
|
7434
|
+
propertyNames: "Name the properties",
|
|
7435
|
+
dependencies: "Declare a discriminated oneOf instead",
|
|
7436
|
+
dependentRequired: "Declare a discriminated oneOf instead",
|
|
7437
|
+
dependentSchemas: "Declare a discriminated oneOf instead",
|
|
7438
|
+
unevaluatedProperties: "Use additionalProperties: false instead",
|
|
7439
|
+
contains: "Declare items, and bound the count with minItems/maxItems",
|
|
7440
|
+
minContains: "Declare items, and bound the count with minItems/maxItems",
|
|
7441
|
+
maxContains: "Declare items, and bound the count with minItems/maxItems",
|
|
7442
|
+
prefixItems: "Declare one items schema",
|
|
7443
|
+
additionalItems: "Declare one items schema",
|
|
7444
|
+
unevaluatedItems: "Declare one items schema",
|
|
7445
|
+
};
|
|
7446
|
+
/**
|
|
7447
|
+
* The fix for a translator refusal whose reason states only what would be
|
|
7448
|
+
* lost, appended to the refusal line (DSO-5536-008: the translator's own
|
|
7449
|
+
* texts are refusal texts elsewhere and stay as they are). `"*"` is the fix
|
|
7450
|
+
* for a keyword the translator has no reason of its own for.
|
|
7451
|
+
*/
|
|
7452
|
+
export const TRANSLATOR_REFUSAL_FIXES = {
|
|
7453
|
+
exclusiveMinimum: "for an integer, write minimum one above the bound; otherwise drop it and check the bound in the code that reads the answer, or run the prompt on a non-Gemini config",
|
|
7454
|
+
exclusiveMaximum: "for an integer, write maximum one below the bound; otherwise drop it and check the bound in the code that reads the answer, or run the prompt on a non-Gemini config",
|
|
7455
|
+
multipleOf: "drop it and check the value in the code that reads the answer, or run the prompt on a non-Gemini config",
|
|
7456
|
+
uniqueItems: "drop it and de-duplicate in the code that reads the answer, or run the prompt on a non-Gemini config",
|
|
7457
|
+
"*": "remove the keyword, or run the prompt on a non-Gemini config",
|
|
7458
|
+
};
|
|
7459
|
+
/** The type names the engine reads. */
|
|
7460
|
+
const ENGINE_SCHEMA_TYPES = ["object", "array", "string", "number", "integer", "boolean", "null"];
|
|
7461
|
+
function isJudgedSchemaObject(value) {
|
|
7462
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
7463
|
+
}
|
|
7464
|
+
function judgedPath(path, segment) {
|
|
7465
|
+
if (segment.startsWith("["))
|
|
7466
|
+
return `${path}${segment}`;
|
|
7467
|
+
return path ? `${path}.${segment}` : segment;
|
|
7468
|
+
}
|
|
7469
|
+
/**
|
|
7470
|
+
* Every keyword of `schema` the function push's rules refuse, over the nodes
|
|
7471
|
+
* they check (the root, `properties`, `items`, `anyOf`, `oneOf`; never
|
|
7472
|
+
* `$defs`): the keyword table's refused class, each reason ending with its
|
|
7473
|
+
* fix, and the shape rules. An enforced constraint (`uniqueItems`,
|
|
7474
|
+
* `multipleOf`, …) is never one: only the translator refuses those.
|
|
7475
|
+
*
|
|
7476
|
+
* The walk keeps its own work stack rather than recursing: the compiler
|
|
7477
|
+
* accepts a schema nested deeper than the call stack, and every refusal must
|
|
7478
|
+
* still be named for it.
|
|
7479
|
+
*/
|
|
7480
|
+
export function engineSchemaRefusals(schema, path = "") {
|
|
7481
|
+
const out = [];
|
|
7482
|
+
const work = [{ node: schema, path }];
|
|
7483
|
+
while (work.length > 0) {
|
|
7484
|
+
const step = work.pop();
|
|
7485
|
+
if ("refusal" in step) {
|
|
7486
|
+
out.push(step.refusal);
|
|
7487
|
+
continue;
|
|
7488
|
+
}
|
|
7489
|
+
// A node's steps in report order, pushed reversed so they pop in order.
|
|
7490
|
+
const steps = [];
|
|
7491
|
+
const fault = (keyword, reason) => steps.push({ refusal: { path: step.path, keyword, reason } });
|
|
7492
|
+
const node = step.node;
|
|
7493
|
+
if (!isJudgedSchemaObject(node)) {
|
|
7494
|
+
fault("(schema)", "must be a JSON Schema object");
|
|
7495
|
+
}
|
|
7496
|
+
else {
|
|
7497
|
+
for (const keyword of refusedSchemaKeywords()) {
|
|
7498
|
+
if (Object.prototype.hasOwnProperty.call(node, keyword)) {
|
|
7499
|
+
fault(keyword, `${keyword} is not supported: the schema check would not enforce it. ${ENGINE_REFUSAL_FIXES[keyword]}`);
|
|
7500
|
+
}
|
|
7501
|
+
}
|
|
7502
|
+
if (node.additionalProperties !== undefined && typeof node.additionalProperties !== "boolean") {
|
|
7503
|
+
fault("additionalProperties", "must be true or false; a schema for the extra properties is not supported");
|
|
7504
|
+
}
|
|
7505
|
+
if (node.type !== undefined) {
|
|
7506
|
+
const types = Array.isArray(node.type) ? node.type : [node.type];
|
|
7507
|
+
if (types.length === 0)
|
|
7508
|
+
fault("type", "must name at least one JSON Schema type");
|
|
7509
|
+
const unknown = types.find((type) => !ENGINE_SCHEMA_TYPES.includes(type));
|
|
7510
|
+
if (unknown !== undefined)
|
|
7511
|
+
fault("type", `must be one of ${ENGINE_SCHEMA_TYPES.join(", ")}, not ${JSON.stringify(unknown)}`);
|
|
7512
|
+
}
|
|
7513
|
+
if (node.enum !== undefined && !Array.isArray(node.enum))
|
|
7514
|
+
fault("enum", "must be an array of allowed values");
|
|
7515
|
+
if (node.required !== undefined && (!Array.isArray(node.required) || node.required.some((name) => typeof name !== "string"))) {
|
|
7516
|
+
fault("required", "must be an array of property names");
|
|
7517
|
+
}
|
|
7518
|
+
if (node.properties !== undefined) {
|
|
7519
|
+
if (!isJudgedSchemaObject(node.properties)) {
|
|
7520
|
+
fault("properties", "must be an object of property schemas");
|
|
7521
|
+
}
|
|
7522
|
+
else {
|
|
7523
|
+
for (const [name, child] of Object.entries(node.properties)) {
|
|
7524
|
+
steps.push({ node: child, path: judgedPath(judgedPath(step.path, "properties"), name) });
|
|
7525
|
+
}
|
|
7526
|
+
}
|
|
7527
|
+
}
|
|
7528
|
+
if (node.items !== undefined) {
|
|
7529
|
+
if (Array.isArray(node.items))
|
|
7530
|
+
fault("items", "must be one schema for every item; a list of item schemas is not supported");
|
|
7531
|
+
else
|
|
7532
|
+
steps.push({ node: node.items, path: judgedPath(step.path, "items") });
|
|
7533
|
+
}
|
|
7534
|
+
for (const keyword of ["anyOf", "oneOf"]) {
|
|
7535
|
+
const value = node[keyword];
|
|
7536
|
+
if (value === undefined)
|
|
7537
|
+
continue;
|
|
7538
|
+
if (!Array.isArray(value)) {
|
|
7539
|
+
fault(keyword, "must be an array of schemas");
|
|
7540
|
+
continue;
|
|
7541
|
+
}
|
|
7542
|
+
value.forEach((child, index) => steps.push({ node: child, path: judgedPath(judgedPath(step.path, keyword), `[${index}]`) }));
|
|
7543
|
+
}
|
|
7544
|
+
}
|
|
7545
|
+
for (let i = steps.length - 1; i >= 0; i--)
|
|
7546
|
+
work.push(steps[i]);
|
|
7547
|
+
}
|
|
7548
|
+
return out;
|
|
7549
|
+
}
|
|
7550
|
+
/**
|
|
7551
|
+
* The schemas an agent's model reads from its declaration (a table or one
|
|
7552
|
+
* JSON string): each client tool's `inputSchema` and `outputSchema`, each
|
|
7553
|
+
* event's `schema` and the turn context's. Never a server tool's: those are
|
|
7554
|
+
* its function's, judged at the function push.
|
|
7555
|
+
*/
|
|
7556
|
+
export function agentDeclarationSchemas(agent) {
|
|
7557
|
+
const declaration = parseAgentDeclarationBlock(agent);
|
|
7558
|
+
if (!declaration)
|
|
7559
|
+
return [];
|
|
7560
|
+
const out = [];
|
|
7561
|
+
for (const tool of Array.isArray(declaration.tools) ? declaration.tools : []) {
|
|
7562
|
+
if (!isJudgedSchemaObject(tool) || (typeof tool.function === "string" && tool.function.trim() !== ""))
|
|
7563
|
+
continue;
|
|
7564
|
+
for (const which of ["inputSchema", "outputSchema"]) {
|
|
7565
|
+
if (tool[which] !== undefined)
|
|
7566
|
+
out.push({ subject: `agent tool "${String(tool.name)}" ${which}`, schema: tool[which] });
|
|
7567
|
+
}
|
|
7568
|
+
}
|
|
7569
|
+
for (const event of Array.isArray(declaration.events) ? declaration.events : []) {
|
|
7570
|
+
if (isJudgedSchemaObject(event) && event.schema !== undefined)
|
|
7571
|
+
out.push({ subject: `agent event "${String(event.name)}" schema`, schema: event.schema });
|
|
7572
|
+
}
|
|
7573
|
+
const turnContext = declaration.turnContext;
|
|
7574
|
+
if (isJudgedSchemaObject(turnContext) && turnContext.schema !== undefined)
|
|
7575
|
+
out.push({ subject: "agent turnContext.schema", schema: turnContext.schema });
|
|
7576
|
+
return out;
|
|
7577
|
+
}
|
|
7578
|
+
/**
|
|
7579
|
+
* A schema field's value as judged: `undefined` for an absent or cleared one
|
|
7580
|
+
* (`null`, `""`), a JSON-string spelling parsed, a string that does not parse
|
|
7581
|
+
* kept as it is (the engine reports it as no schema object).
|
|
7582
|
+
*/
|
|
7583
|
+
function judgedSchemaValue(value) {
|
|
7584
|
+
if (value === undefined || value === null || value === "")
|
|
7585
|
+
return undefined;
|
|
7586
|
+
if (typeof value !== "string")
|
|
7587
|
+
return value;
|
|
7588
|
+
try {
|
|
7589
|
+
return JSON.parse(value);
|
|
7590
|
+
}
|
|
7591
|
+
catch {
|
|
7592
|
+
return value;
|
|
7593
|
+
}
|
|
7594
|
+
}
|
|
7595
|
+
/** A config the server would store as non-archived on Gemini: status and provider read as the write normalizes them. */
|
|
7596
|
+
function isLiveGemini(config) {
|
|
7597
|
+
return (String(config.status ?? "active").trim().toLowerCase() !== "archived" &&
|
|
7598
|
+
String(config.provider).trim().toLowerCase() === "gemini");
|
|
7599
|
+
}
|
|
7600
|
+
/** The reason a schema nested deeper than the translator's walk is refused with. */
|
|
7601
|
+
const TRANSLATOR_OVERFLOW_REASON = "is nested deeper than the translator walks; flatten the schema";
|
|
7602
|
+
/**
|
|
7603
|
+
* `translateSchemaForProvider(schema, "gemini")`, failing closed. The
|
|
7604
|
+
* translator recurses, so a schema nested deeper than the call stack cannot be
|
|
7605
|
+
* translated: it is one refusal about the whole document (`(schema)`, the
|
|
7606
|
+
* engine's spelling), so a schema Gemini would never be sent is refused at
|
|
7607
|
+
* push and at call time rather than accepted unread. Any other error is a
|
|
7608
|
+
* fault and propagates.
|
|
7609
|
+
*/
|
|
7610
|
+
export function translateSchemaForGemini(schema) {
|
|
7611
|
+
try {
|
|
7612
|
+
return translateSchemaForProvider(schema, "gemini");
|
|
7613
|
+
}
|
|
7614
|
+
catch (error) {
|
|
7615
|
+
if (error instanceof RangeError) {
|
|
7616
|
+
return { ok: false, refusals: [{ path: "", keyword: "(schema)", reason: TRANSLATOR_OVERFLOW_REASON }] };
|
|
7617
|
+
}
|
|
7618
|
+
throw error;
|
|
7619
|
+
}
|
|
7620
|
+
}
|
|
7621
|
+
/** The translator's refusals for one schema: `translateSchemaForGemini`'s, or none. */
|
|
7622
|
+
export function translatorRefusals(schema) {
|
|
7623
|
+
const translated = translateSchemaForGemini(schema);
|
|
7624
|
+
return translated.ok === false ? translated.refusals : [];
|
|
7625
|
+
}
|
|
7626
|
+
/**
|
|
7627
|
+
* Every keyword of a prompt's schemas the translator or the engine would
|
|
7628
|
+
* refuse. The translator judges `outputSchema` when a non-archived config
|
|
7629
|
+
* names Gemini (case-insensitive), and each Gemini config's own
|
|
7630
|
+
* `outputSchema` unless that config is archived; `inputSchema` is never
|
|
7631
|
+
* translated, and an agent's schemas are judged by the engine only. Order:
|
|
7632
|
+
* `inputSchema`, `outputSchema`, the agent's schemas, then each config; per
|
|
7633
|
+
* schema the translator first. A top-level value that is no schema object
|
|
7634
|
+
* is reported once, by the engine.
|
|
7635
|
+
*/
|
|
7636
|
+
export function promptSchemaDeficits(input) {
|
|
7637
|
+
const configs = input.configs ?? [];
|
|
7638
|
+
const out = [];
|
|
7639
|
+
const judge = (subject, field, value, translate, config) => {
|
|
7640
|
+
const schema = judgedSchemaValue(value);
|
|
7641
|
+
if (schema === undefined)
|
|
7642
|
+
return;
|
|
7643
|
+
const where = config === undefined ? { subject, field } : { subject, field, config };
|
|
7644
|
+
if (translate && isJudgedSchemaObject(schema)) {
|
|
7645
|
+
for (const refusal of translatorRefusals(schema))
|
|
7646
|
+
out.push({ ...where, check: "translator", provider: "gemini", ...refusal });
|
|
7647
|
+
}
|
|
7648
|
+
for (const refusal of engineSchemaRefusals(schema))
|
|
7649
|
+
out.push({ ...where, check: "engine", ...refusal });
|
|
7650
|
+
};
|
|
7651
|
+
judge("inputSchema", "inputSchema", input.inputSchema, false);
|
|
7652
|
+
judge("outputSchema", "outputSchema", input.outputSchema, configs.some(isLiveGemini));
|
|
7653
|
+
if (judgedSchemaValue(input.agent) !== undefined) {
|
|
7654
|
+
for (const { subject, schema } of agentDeclarationSchemas(input.agent)) {
|
|
7655
|
+
for (const refusal of engineSchemaRefusals(schema))
|
|
7656
|
+
out.push({ subject, field: "agent", check: "engine", ...refusal });
|
|
7657
|
+
}
|
|
7658
|
+
}
|
|
7659
|
+
for (const config of configs) {
|
|
7660
|
+
judge(`config "${config.name}" outputSchema`, "outputSchema", config.outputSchema, isLiveGemini(config), config.name);
|
|
7661
|
+
}
|
|
7662
|
+
return out;
|
|
7663
|
+
}
|
|
7664
|
+
/**
|
|
7665
|
+
* The fix a translator line appends: the table's for a lossy constraint, the
|
|
7666
|
+
* default for a keyword the translator has no reason of its own for, and none
|
|
7667
|
+
* where the reason already says what to write (a keyword with a reason of its
|
|
7668
|
+
* own, or one the translator handles by its own rule).
|
|
7669
|
+
*/
|
|
7670
|
+
function translatorFix(keyword) {
|
|
7671
|
+
if (Object.prototype.hasOwnProperty.call(TRANSLATOR_REFUSAL_FIXES, keyword))
|
|
7672
|
+
return TRANSLATOR_REFUSAL_FIXES[keyword];
|
|
7673
|
+
if (Object.prototype.hasOwnProperty.call(GEMINI_REFUSAL_REASONS, keyword))
|
|
7674
|
+
return null;
|
|
7675
|
+
if (keyword === "(schema)" || GEMINI_STRUCTURAL_KEYWORDS.includes(keyword))
|
|
7676
|
+
return null;
|
|
7677
|
+
return TRANSLATOR_REFUSAL_FIXES["*"];
|
|
7678
|
+
}
|
|
7679
|
+
/**
|
|
7680
|
+
* The refusal line for one deficit: the subject, the path, the keyword, why,
|
|
7681
|
+
* and the fix. A translator reason with no fix of its own names what Gemini
|
|
7682
|
+
* needs instead (`properties`, `type`, the overflow's "flatten the schema").
|
|
7683
|
+
*/
|
|
7684
|
+
export function promptSchemaRefusalLine(deficit) {
|
|
7685
|
+
const at = `${deficit.subject} at ${schemaPathLabel(deficit.path)}`;
|
|
7686
|
+
if (deficit.check === "translator") {
|
|
7687
|
+
const fix = translatorFix(deficit.keyword);
|
|
7688
|
+
return `${at}: ${deficit.keyword} cannot be translated for gemini without losing meaning — ${deficit.reason}${fix ? `. Fix: ${fix}` : ""}`;
|
|
7689
|
+
}
|
|
7690
|
+
const named = deficit.keyword === "(schema)"
|
|
7691
|
+
? `the schema ${deficit.reason}`
|
|
7692
|
+
: deficit.reason.startsWith(`${deficit.keyword} `)
|
|
7693
|
+
? deficit.reason
|
|
7694
|
+
: `${deficit.keyword} ${deficit.reason}`;
|
|
7695
|
+
return `${at}: ${named}`;
|
|
7696
|
+
}
|
|
7697
|
+
/** The code a write is refused with for one deficit. */
|
|
7698
|
+
export function promptSchemaDeficitCode(deficit) {
|
|
7699
|
+
return deficit.check === "translator" ? PROMPT_SCHEMA_NOT_TRANSLATABLE : PROMPT_SCHEMA_UNSUPPORTED_KEYWORD;
|
|
7700
|
+
}
|
|
7701
|
+
/** A refused write's `details.refusals`: one entry per deficit, in `promptSchemaDeficits` order. */
|
|
7702
|
+
export function promptSchemaRefusals(deficits) {
|
|
7703
|
+
return deficits.map((deficit) => ({
|
|
7704
|
+
code: promptSchemaDeficitCode(deficit),
|
|
7705
|
+
message: promptSchemaRefusalLine(deficit),
|
|
7706
|
+
subject: deficit.subject,
|
|
7707
|
+
field: deficit.field,
|
|
7708
|
+
...(deficit.config !== undefined ? { config: deficit.config } : {}),
|
|
7709
|
+
path: deficit.path,
|
|
7710
|
+
keyword: deficit.keyword,
|
|
7711
|
+
}));
|
|
7712
|
+
}
|
|
7303
7713
|
// ── src/config-surface/agent-function-change.ts ──────────────────────────
|
|
7304
7714
|
/**
|
|
7305
7715
|
* A change to a server function that an agent uses — issue #4441.
|
|
@@ -7861,19 +8271,6 @@ export const PROMPT_SURFACE = {
|
|
|
7861
8271
|
writableOn: BOTH,
|
|
7862
8272
|
validation: handledBy(PROMPT_HANDLER, "AdminAPI", "apply"),
|
|
7863
8273
|
},
|
|
7864
|
-
// #2652 — the CEL rule gating who may execute the prompt. Required at
|
|
7865
|
-
// create; an explicit null/"" on update clears it (fail-closed). This
|
|
7866
|
-
// declaration is the whole authoring channel: the admin routes' unknown
|
|
7867
|
-
// key guard reads the same table, so it is what makes `accessRule` an
|
|
7868
|
-
// accepted body key as well as a pulled and pushed TOML line.
|
|
7869
|
-
{
|
|
7870
|
-
field: "accessRule",
|
|
7871
|
-
tomlKey: "accessRule",
|
|
7872
|
-
type: "string",
|
|
7873
|
-
emit: "whenSet",
|
|
7874
|
-
writableOn: BOTH,
|
|
7875
|
-
validation: handledBy(PROMPT_HANDLER, "AdminAPI", "apply"),
|
|
7876
|
-
},
|
|
7877
8274
|
// #3798 — an AGENT's contract: its tools, event kinds, turn context,
|
|
7878
8275
|
// history selection, who answers a paused call, and its limits. One
|
|
7879
8276
|
// prompt-level block because they belong to the prompt, like
|
|
@@ -7892,12 +8289,41 @@ export const PROMPT_SURFACE = {
|
|
|
7892
8289
|
writableOn: BOTH,
|
|
7893
8290
|
validation: handledBy("src/config-surface/agent-declaration.ts", "resolveAgentDeclaration", "apply"),
|
|
7894
8291
|
},
|
|
8292
|
+
// #5249 — the prompt that judges this prompt's test cases by default,
|
|
8293
|
+
// authored as its KEY and resolved to the stored id at push, as #3998
|
|
8294
|
+
// did for a test case's `evaluatorPromptKey`. The id has no TOML
|
|
8295
|
+
// spelling. Present-only (intent decision): an absent key leaves the
|
|
8296
|
+
// stored link alone, so a tree written before this keeps every link
|
|
8297
|
+
// made in the web admin, and `""` clears it.
|
|
8298
|
+
//
|
|
8299
|
+
// UPDATE_ONLY because push links through the update route, after this
|
|
8300
|
+
// push's creates, so a prompt can name an evaluator created in the same
|
|
8301
|
+
// push. The create route is unchanged: it accepts the key and ignores
|
|
8302
|
+
// it (`requestOnlyKeys` below). The resolver needs the app's prompt
|
|
8303
|
+
// listing, so it is not decidable from the file alone.
|
|
8304
|
+
{
|
|
8305
|
+
field: "defaultEvaluatorPromptId",
|
|
8306
|
+
tomlKey: "defaultEvaluatorPromptKey",
|
|
8307
|
+
type: "string",
|
|
8308
|
+
emit: "whenSet",
|
|
8309
|
+
writableOn: UPDATE_ONLY,
|
|
8310
|
+
validation: handledBy("cli/src/commands/sync.ts", "resolvePromptEvaluatorLinks", "apply"),
|
|
8311
|
+
},
|
|
7895
8312
|
],
|
|
7896
8313
|
notExposed: {
|
|
7897
8314
|
promptId: {
|
|
7898
8315
|
kind: "server-owned",
|
|
7899
8316
|
note: "ULID assigned on create; never author-authored.",
|
|
7900
8317
|
},
|
|
8318
|
+
accessRule: {
|
|
8319
|
+
kind: "deprecated",
|
|
8320
|
+
note: "The CEL rule that once gated who may execute the prompt, " +
|
|
8321
|
+
"retired (#4872): the only call path is a server function's " +
|
|
8322
|
+
"`ctx.prompts.run`, whose `authorize` decides. Still accepted on " +
|
|
8323
|
+
"create and update so a pre-change CLI keeps pushing, and " +
|
|
8324
|
+
"ignored: never parsed, stored, echoed or read. Its TOML " +
|
|
8325
|
+
"spelling is declared in tomlOnlyKeys.",
|
|
8326
|
+
},
|
|
7901
8327
|
// #2803 — the OBJECT-level availability, server-owned. Distinct from
|
|
7902
8328
|
// the per-version `[[configs]] status` below, which stays a TOML key:
|
|
7903
8329
|
// that says which named config is retired, this says whether the
|
|
@@ -7929,16 +8355,32 @@ export const PROMPT_SURFACE = {
|
|
|
7929
8355
|
kind: "server-owned",
|
|
7930
8356
|
note: "Provenance stamp written when a prompt is copied from the catalog.",
|
|
7931
8357
|
},
|
|
8358
|
+
// #5534 — the authored schemas and their provenance, kept beside the
|
|
8359
|
+
// compiled ones in the fields above. Written by the server's compile;
|
|
8360
|
+
// read back as the detail's `source` and `provenance`.
|
|
8361
|
+
schemaSource: {
|
|
8362
|
+
kind: "server-owned",
|
|
8363
|
+
note: "The authored inputSchema, outputSchema and agent of a write whose " +
|
|
8364
|
+
"compile inlined a ref, as one JSON object; returned as `source`.",
|
|
8365
|
+
},
|
|
8366
|
+
schemaSourceR2Key: {
|
|
8367
|
+
kind: "server-owned",
|
|
8368
|
+
note: "Where an oversized schemaSource was offloaded, under a per-write key.",
|
|
8369
|
+
},
|
|
8370
|
+
schemaProvenance: {
|
|
8371
|
+
kind: "server-owned",
|
|
8372
|
+
note: "Each schema field's pointer → ref chain map, with the h1: hash of " +
|
|
8373
|
+
"each inlined definition; returned as `provenance`.",
|
|
8374
|
+
},
|
|
8375
|
+
schemaProvenanceR2Key: {
|
|
8376
|
+
kind: "server-owned",
|
|
8377
|
+
note: "Where an oversized schemaProvenance was offloaded, under a per-write key.",
|
|
8378
|
+
},
|
|
7932
8379
|
activeConfigId: {
|
|
7933
8380
|
kind: "server-owned",
|
|
7934
8381
|
note: "Pointer to the active AppPromptConfig. Activation is its own " +
|
|
7935
8382
|
"endpoint (activatePromptConfig), not a [prompt] key.",
|
|
7936
8383
|
},
|
|
7937
|
-
defaultEvaluatorPromptId: {
|
|
7938
|
-
kind: "server-owned",
|
|
7939
|
-
note: "Link to the evaluator prompt, written when an evaluator is created " +
|
|
7940
|
-
"against this prompt. Managed through the prompts API, not TOML.",
|
|
7941
|
-
},
|
|
7942
8384
|
createdBy: {
|
|
7943
8385
|
kind: "server-owned",
|
|
7944
8386
|
note: "Admin who created the prompt; assigned server-side.",
|
|
@@ -7953,11 +8395,25 @@ export const PROMPT_SURFACE = {
|
|
|
7953
8395
|
},
|
|
7954
8396
|
},
|
|
7955
8397
|
requestOnlyKeys: {
|
|
8398
|
+
// #5534 — the CLI's compile of the schemas the body carries, which the
|
|
8399
|
+
// server recompiles and compares; never stored as sent.
|
|
8400
|
+
compiled: {
|
|
8401
|
+
note: "The compiled form of each schema field the body carries " +
|
|
8402
|
+
"({ inputSchema?, outputSchema?, agent? }), sent by `config push`. " +
|
|
8403
|
+
"The server recompiles and refuses PROMPT_SCHEMA_COMPILED_MISMATCH " +
|
|
8404
|
+
"when they differ.",
|
|
8405
|
+
},
|
|
8406
|
+
provenance: {
|
|
8407
|
+
note: "The provenance of each field in `compiled`, which the server " +
|
|
8408
|
+
"compares with its own; required with `compiled`.",
|
|
8409
|
+
},
|
|
7956
8410
|
defaultEvaluatorPromptId: {
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
8411
|
+
// #5249 — the field above is update-only; the create route has always
|
|
8412
|
+
// accepted this key and ignored it, and still does.
|
|
8413
|
+
modes: ["create"],
|
|
8414
|
+
note: "Accepted and ignored by the create route: a create links an " +
|
|
8415
|
+
"evaluator only through `sourcePromptId`. `config push` links " +
|
|
8416
|
+
"through the update route after its creates.",
|
|
7961
8417
|
},
|
|
7962
8418
|
},
|
|
7963
8419
|
tomlOnlyKeys: {
|
|
@@ -7971,8 +8427,27 @@ export const PROMPT_SURFACE = {
|
|
|
7971
8427
|
"deployed — and typed by `functions codegen` — under the DECLARED " +
|
|
7972
8428
|
"key (#3330).",
|
|
7973
8429
|
},
|
|
8430
|
+
accessRule: {
|
|
8431
|
+
kind: "deprecated",
|
|
8432
|
+
note: "`accessRule = \"…\"` — retired (#4872); the calling function's " +
|
|
8433
|
+
"`authorize` decides who may run the prompt. Accepted so an " +
|
|
8434
|
+
"untouched tree still validates, never sent, and `config push` " +
|
|
8435
|
+
"prints the `DEPRECATED_CONFIG_KEYS` sentence once per file. " +
|
|
8436
|
+
"`config pull` rewrites the file without it.",
|
|
8437
|
+
},
|
|
7974
8438
|
},
|
|
7975
8439
|
responseOnlyKeys: {
|
|
8440
|
+
// #5534 — the authored schemas and their provenance, on the detail
|
|
8441
|
+
// and the write responses (not the list).
|
|
8442
|
+
source: {
|
|
8443
|
+
kind: "server-owned",
|
|
8444
|
+
note: "The authored schema of each field whose compile inlined a ref " +
|
|
8445
|
+
"(null when none did); `config pull` writes it back.",
|
|
8446
|
+
},
|
|
8447
|
+
provenance: {
|
|
8448
|
+
kind: "server-owned",
|
|
8449
|
+
note: "Each such field's pointer → ref chain map; read by `config diff` for pins.",
|
|
8450
|
+
},
|
|
7976
8451
|
configs: {
|
|
7977
8452
|
kind: "structural",
|
|
7978
8453
|
note: "The prompt's AppPromptConfig rows, returned inline on the detail " +
|
|
@@ -8256,6 +8731,27 @@ export const PROMPT_SURFACE = {
|
|
|
8256
8731
|
note: "Where an oversized userPromptTemplate was offloaded. Assigned by " +
|
|
8257
8732
|
"storeField; the value round-trips through `userPromptTemplate`.",
|
|
8258
8733
|
},
|
|
8734
|
+
// #5534 — the authored schemas and their provenance, kept beside the
|
|
8735
|
+
// compiled ones in the fields above. Written by the server's compile;
|
|
8736
|
+
// read back as the detail's `source` and `provenance`.
|
|
8737
|
+
schemaSource: {
|
|
8738
|
+
kind: "server-owned",
|
|
8739
|
+
note: "The authored outputSchema of a write whose compile inlined a ref, " +
|
|
8740
|
+
"as one JSON object; returned as `source`.",
|
|
8741
|
+
},
|
|
8742
|
+
schemaSourceR2Key: {
|
|
8743
|
+
kind: "server-owned",
|
|
8744
|
+
note: "Where an oversized schemaSource was offloaded, under a per-write key.",
|
|
8745
|
+
},
|
|
8746
|
+
schemaProvenance: {
|
|
8747
|
+
kind: "server-owned",
|
|
8748
|
+
note: "The outputSchema's pointer → ref chain map, with the h1: hash of " +
|
|
8749
|
+
"each inlined definition; returned as `provenance`.",
|
|
8750
|
+
},
|
|
8751
|
+
schemaProvenanceR2Key: {
|
|
8752
|
+
kind: "server-owned",
|
|
8753
|
+
note: "Where an oversized schemaProvenance was offloaded, under a per-write key.",
|
|
8754
|
+
},
|
|
8259
8755
|
createdBy: {
|
|
8260
8756
|
kind: "server-owned",
|
|
8261
8757
|
note: "Admin who created the config; assigned server-side.",
|
|
@@ -8282,7 +8778,33 @@ export const PROMPT_SURFACE = {
|
|
|
8282
8778
|
"(activatePromptConfig), never as a config-body key.",
|
|
8283
8779
|
},
|
|
8284
8780
|
},
|
|
8285
|
-
|
|
8781
|
+
requestOnlyKeys: {
|
|
8782
|
+
// #5534 — the CLI's compile of the schemas the body carries, which the
|
|
8783
|
+
// server recompiles and compares; never stored as sent.
|
|
8784
|
+
compiled: {
|
|
8785
|
+
note: "The compiled form of each schema field the body carries " +
|
|
8786
|
+
"({ outputSchema? }), sent by `config push`. " +
|
|
8787
|
+
"The server recompiles and refuses PROMPT_SCHEMA_COMPILED_MISMATCH " +
|
|
8788
|
+
"when they differ.",
|
|
8789
|
+
},
|
|
8790
|
+
provenance: {
|
|
8791
|
+
note: "The provenance of each field in `compiled`, which the server " +
|
|
8792
|
+
"compares with its own; required with `compiled`.",
|
|
8793
|
+
},
|
|
8794
|
+
},
|
|
8795
|
+
responseOnlyKeys: {
|
|
8796
|
+
// #5534 — the authored schemas and their provenance, on every config
|
|
8797
|
+
// response.
|
|
8798
|
+
source: {
|
|
8799
|
+
kind: "server-owned",
|
|
8800
|
+
note: "The authored schema of each field whose compile inlined a ref " +
|
|
8801
|
+
"(null when none did); `config pull` writes it back.",
|
|
8802
|
+
},
|
|
8803
|
+
provenance: {
|
|
8804
|
+
kind: "server-owned",
|
|
8805
|
+
note: "Each such field's pointer → ref chain map; read by `config diff` for pins.",
|
|
8806
|
+
},
|
|
8807
|
+
},
|
|
8286
8808
|
},
|
|
8287
8809
|
],
|
|
8288
8810
|
// Both of a prompt file's tables ARE field tables (`[prompt]` and the
|
|
@@ -8362,22 +8884,22 @@ export const INTEGRATION_SURFACE = {
|
|
|
8362
8884
|
// Same create default, same reason (#2880 DSO-002): 1 MiB.
|
|
8363
8885
|
serverDefault: 1048576,
|
|
8364
8886
|
},
|
|
8365
|
-
// #2631 — the CEL rule gating who may invoke the integration. Required
|
|
8366
|
-
// at create; an explicit null/"" on update clears it (fail-closed).
|
|
8367
|
-
{
|
|
8368
|
-
field: "accessRule",
|
|
8369
|
-
tomlKey: "accessRule",
|
|
8370
|
-
type: "string",
|
|
8371
|
-
emit: "whenSet",
|
|
8372
|
-
writableOn: BOTH,
|
|
8373
|
-
validation: handledBy(INTEGRATION_HANDLER, "AdminAPI", "apply"),
|
|
8374
|
-
},
|
|
8375
8887
|
],
|
|
8376
8888
|
notExposed: {
|
|
8377
8889
|
integrationId: {
|
|
8378
8890
|
kind: "server-owned",
|
|
8379
8891
|
note: "ULID assigned on create; never author-authored.",
|
|
8380
8892
|
},
|
|
8893
|
+
accessRule: {
|
|
8894
|
+
kind: "deprecated",
|
|
8895
|
+
note: "The CEL rule that once gated who may invoke the integration, " +
|
|
8896
|
+
"retired (#4872): the only call path is a server function's " +
|
|
8897
|
+
"`ctx.integrations.call`, decided by its `authorize` and its " +
|
|
8898
|
+
"`integration:<key>` capability. Still accepted on create and " +
|
|
8899
|
+
"update so a pre-change CLI keeps pushing, and ignored: never " +
|
|
8900
|
+
"parsed, stored, echoed or read. Its TOML spelling is declared " +
|
|
8901
|
+
"in tomlOnlyKeys.",
|
|
8902
|
+
},
|
|
8381
8903
|
// #2803 — availability, server-owned. `draft` is gone from the model;
|
|
8382
8904
|
// a stored one reads `inactive` through the canonical normalizer.
|
|
8383
8905
|
status: {
|
|
@@ -8440,6 +8962,14 @@ export const INTEGRATION_SURFACE = {
|
|
|
8440
8962
|
"takes the identity from the file name and attaches " +
|
|
8441
8963
|
"`integrationKey` itself.",
|
|
8442
8964
|
},
|
|
8965
|
+
accessRule: {
|
|
8966
|
+
kind: "deprecated",
|
|
8967
|
+
note: "`accessRule = \"…\"` — retired (#4872); the calling function's " +
|
|
8968
|
+
"`authorize` and `integration:<key>` capability decide. Accepted " +
|
|
8969
|
+
"so an untouched tree still validates, never sent, and `config " +
|
|
8970
|
+
"push` prints the `DEPRECATED_CONFIG_KEYS` sentence once per " +
|
|
8971
|
+
"file. `config pull` rewrites the file without it.",
|
|
8972
|
+
},
|
|
8443
8973
|
},
|
|
8444
8974
|
responseOnlyKeys: {},
|
|
8445
8975
|
},
|
|
@@ -8453,61 +8983,33 @@ export const INTEGRATION_SURFACE = {
|
|
|
8453
8983
|
},
|
|
8454
8984
|
},
|
|
8455
8985
|
};
|
|
8456
|
-
// ── src/config-surface/
|
|
8457
|
-
/**
|
|
8458
|
-
* The `
|
|
8459
|
-
*
|
|
8460
|
-
* `
|
|
8461
|
-
*
|
|
8462
|
-
* `
|
|
8463
|
-
*
|
|
8464
|
-
*
|
|
8465
|
-
*
|
|
8466
|
-
*
|
|
8467
|
-
*
|
|
8468
|
-
*
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
* (`/secret|token|password|credential/i`), so none of it can be decided by
|
|
8474
|
-
* silence.
|
|
8475
|
-
*
|
|
8476
|
-
* On the `validation` classifications: `createAppWebhook` / `updateAppWebhook`
|
|
8477
|
-
* are not decomposed into per-field handlers, so a field names the shared
|
|
8478
|
-
* validator that owns it where one exists, and `src/admin-api.ts#AdminAPI`
|
|
8479
|
-
* otherwise.
|
|
8480
|
-
*/
|
|
8481
|
-
const WEBHOOK_HANDLER = "src/admin-api.ts";
|
|
8482
|
-
const WEBHOOK_CONFIG_VALIDATION = "src/app-api/services/webhook-verification/config-validation.ts";
|
|
8483
|
-
// #3320 — the reference-only `signingSecret` rule is decidable from the value
|
|
8484
|
-
// alone, so it moved beside the definitions where `config push`'s preflight can
|
|
8485
|
-
// run the server's own copy of it.
|
|
8486
|
-
const WEBHOOK_SIGNING_SECRET_RULE = "src/config-surface/webhook-signing-secret.ts";
|
|
8487
|
-
/**
|
|
8488
|
-
* Every rule of this object is `apply` (#3374): the standalone webhook's CLI
|
|
8489
|
-
* path runs field-shape checks only, and everything else needs the app's state
|
|
8490
|
-
* or the STORED row. A module-local builder, named so it cannot collide with a
|
|
8491
|
-
* sibling's once the directory is concatenated into the artifact.
|
|
8492
|
-
*/
|
|
8493
|
-
const webhookApplyRules = (modulePath, exportName, entries) => entries.map(([id, description]) => ({
|
|
8494
|
-
id,
|
|
8495
|
-
description,
|
|
8496
|
-
stage: "apply",
|
|
8497
|
-
handler: enforcedBy(modulePath, exportName),
|
|
8498
|
-
}));
|
|
8499
|
-
export const WEBHOOK_SURFACE = {
|
|
8500
|
-
label: "webhook",
|
|
8986
|
+
// ── src/config-surface/blob-bucket.ts ────────────────────────────────────
|
|
8987
|
+
/**
|
|
8988
|
+
* The `blob-bucket` configuration object's definition (issue #2644, phase 2).
|
|
8989
|
+
*
|
|
8990
|
+
* `blob-buckets/<key>.toml` carries a single `[bucket]` table.
|
|
8991
|
+
*
|
|
8992
|
+
* `ttlTier` is `writableOn: ["create"]`: the update handler does not read it, so
|
|
8993
|
+
* the retention tier is fixed at creation. `preset` and the rule set are the two
|
|
8994
|
+
* halves of the access model (#1020), and the only access keys: at most one may
|
|
8995
|
+
* change per request, which is the controller's rule and stays there. The rule
|
|
8996
|
+
* set is authored by name (`ruleSetName`) and sent as `ruleSetId`, as the type
|
|
8997
|
+
* configs do (#4116). The id spelling in TOML (#4283) and the pre-#1020
|
|
8998
|
+
* `accessPolicy` spelling (#3996) are retired keys (`retired-keys.ts`).
|
|
8999
|
+
*/
|
|
9000
|
+
const BLOB_BUCKET_HANDLER = "src/app-api/controllers/blob-buckets-controller.ts";
|
|
9001
|
+
export const BLOB_BUCKET_SURFACE = {
|
|
9002
|
+
label: "blob-bucket",
|
|
8501
9003
|
tables: [
|
|
8502
9004
|
{
|
|
8503
|
-
tomlPath: ["
|
|
9005
|
+
tomlPath: ["bucket"],
|
|
8504
9006
|
repeated: false,
|
|
8505
|
-
model: "
|
|
9007
|
+
model: "BlobBucket",
|
|
8506
9008
|
// Declaration order reproduces the pre-#2644 serializer's key order.
|
|
8507
9009
|
fields: [
|
|
8508
9010
|
{
|
|
8509
|
-
field: "
|
|
8510
|
-
tomlKey: "
|
|
9011
|
+
field: "name",
|
|
9012
|
+
tomlKey: "name",
|
|
8511
9013
|
type: "string",
|
|
8512
9014
|
emit: "always",
|
|
8513
9015
|
writableOn: BOTH,
|
|
@@ -8522,686 +9024,67 @@ export const WEBHOOK_SURFACE = {
|
|
|
8522
9024
|
validation: "passthrough",
|
|
8523
9025
|
},
|
|
8524
9026
|
{
|
|
8525
|
-
field: "
|
|
8526
|
-
tomlKey: "
|
|
9027
|
+
field: "ttlTier",
|
|
9028
|
+
tomlKey: "ttlTier",
|
|
8527
9029
|
type: "string",
|
|
8528
9030
|
emit: "always",
|
|
8529
|
-
writableOn:
|
|
8530
|
-
|
|
9031
|
+
writableOn: CREATE_ONLY,
|
|
9032
|
+
// Immutable after create: `update` never reads it.
|
|
9033
|
+
validation: handledBy(BLOB_BUCKET_HANDLER, "BlobBucketsController", "apply"),
|
|
8531
9034
|
},
|
|
8532
9035
|
{
|
|
8533
|
-
field: "
|
|
8534
|
-
tomlKey: "
|
|
9036
|
+
field: "preset",
|
|
9037
|
+
tomlKey: "preset",
|
|
8535
9038
|
type: "string",
|
|
8536
|
-
emit: "always",
|
|
8537
|
-
writableOn: BOTH,
|
|
8538
|
-
validation: handledBy(WEBHOOK_HANDLER, "AdminAPI", "apply"),
|
|
8539
|
-
},
|
|
8540
|
-
{
|
|
8541
|
-
field: "toleranceSeconds",
|
|
8542
|
-
tomlKey: "toleranceSeconds",
|
|
8543
|
-
type: "number",
|
|
8544
|
-
emit: "always",
|
|
8545
|
-
writableOn: BOTH,
|
|
8546
|
-
validation: handledBy(WEBHOOK_CONFIG_VALIDATION, "validateReplayProtection", "apply"),
|
|
8547
|
-
},
|
|
8548
|
-
{
|
|
8549
|
-
field: "deduplicationEnabled",
|
|
8550
|
-
tomlKey: "deduplicationEnabled",
|
|
8551
|
-
type: "boolean",
|
|
8552
|
-
emit: "always",
|
|
8553
|
-
writableOn: BOTH,
|
|
8554
|
-
validation: handledBy(WEBHOOK_CONFIG_VALIDATION, "validateReplayProtection", "apply"),
|
|
8555
|
-
},
|
|
8556
|
-
{
|
|
8557
|
-
field: "deduplicationWindowMs",
|
|
8558
|
-
tomlKey: "deduplicationWindowMs",
|
|
8559
|
-
type: "number",
|
|
8560
|
-
emit: "always",
|
|
8561
|
-
writableOn: BOTH,
|
|
8562
|
-
validation: handledBy(WEBHOOK_CONFIG_VALIDATION, "validateReplayProtection", "apply"),
|
|
8563
|
-
},
|
|
8564
|
-
// Per-webhook inbound body cap. Unset means the platform default
|
|
8565
|
-
// (5 MiB), so it is omitted from TOML rather than written as a zero.
|
|
8566
|
-
{
|
|
8567
|
-
field: "maxBodyBytes",
|
|
8568
|
-
tomlKey: "maxBodyBytes",
|
|
8569
|
-
type: "number",
|
|
8570
9039
|
emit: "whenSet",
|
|
8571
9040
|
writableOn: BOTH,
|
|
8572
|
-
|
|
8573
|
-
|
|
8574
|
-
|
|
8575
|
-
field: "secretGracePeriodMs",
|
|
8576
|
-
tomlKey: "secretGracePeriodMs",
|
|
8577
|
-
type: "number",
|
|
8578
|
-
emit: "always",
|
|
8579
|
-
writableOn: BOTH,
|
|
8580
|
-
validation: handledBy(WEBHOOK_CONFIG_VALIDATION, "normalizeSecretGracePeriodMs", "apply"),
|
|
9041
|
+
// #1020 — the honest access field. A rule-set-backed bucket reports
|
|
9042
|
+
// "custom", which is not written back as a preset.
|
|
9043
|
+
validation: handledBy("src/app-api/resource-types/blob-bucket.ts", "resolveBucketPreset", "apply"),
|
|
8581
9044
|
},
|
|
8582
|
-
// #2254 — reference-only: a whole `{{secrets.KEY}}` reference naming an
|
|
8583
|
-
// existing app secret, and nothing else. The server never returns
|
|
8584
|
-
// credential material here, so the reference round-trips verbatim
|
|
8585
|
-
// (#1235) and a legacy literal is withheld (no line is written).
|
|
8586
9045
|
{
|
|
8587
|
-
field: "
|
|
8588
|
-
tomlKey: "
|
|
9046
|
+
field: "ruleSetId",
|
|
9047
|
+
tomlKey: "ruleSetName",
|
|
8589
9048
|
type: "string",
|
|
8590
9049
|
emit: "whenSet",
|
|
8591
9050
|
writableOn: BOTH,
|
|
8592
|
-
|
|
9051
|
+
// Authored as a name, sent as an id (#4116), so a tree copied into
|
|
9052
|
+
// another app binds that app's rule set. Existence-checked against
|
|
9053
|
+
// AccessRuleSet; mutually exclusive with a preset change in the same
|
|
9054
|
+
// request. The TOML spelling of the id is a retired key (#4283).
|
|
9055
|
+
validation: handledBy(BLOB_BUCKET_HANDLER, "BlobBucketsController", "apply"),
|
|
8593
9056
|
},
|
|
8594
9057
|
],
|
|
8595
9058
|
notExposed: {
|
|
8596
|
-
|
|
9059
|
+
bucketId: {
|
|
8597
9060
|
kind: "server-owned",
|
|
8598
9061
|
note: "ULID assigned on create; never author-authored.",
|
|
8599
9062
|
},
|
|
8600
|
-
// #3181 — the two fields a FUNCTION-owned row carries. Neither is ever
|
|
8601
|
-
// authored on a `[webhook]` table: a function declares its trigger in
|
|
8602
|
-
// its own `functions/<key>.toml`, and this file's whole surface is the
|
|
8603
|
-
// standalone object. A hidden row is written only by
|
|
8604
|
-
// `function-trigger-reconcile.ts`.
|
|
8605
|
-
functionId: {
|
|
8606
|
-
kind: "server-owned",
|
|
8607
|
-
note: "The server function whose config owns this row (#3181). Set only " +
|
|
8608
|
-
"by the trigger reconcile; a standalone webhook never has one, and " +
|
|
8609
|
-
"its presence is what every hiding filter branches on.",
|
|
8610
|
-
},
|
|
8611
|
-
declaredSigningSecret: {
|
|
8612
|
-
kind: "secret",
|
|
8613
|
-
note: "The authored `{{secrets.KEY}}` reference the last function-trigger " +
|
|
8614
|
-
"reconcile applied (#3181, D3181-004). Server-owned bookkeeping " +
|
|
8615
|
-
"that makes an operational `rotate-secret` survive later pushes: " +
|
|
8616
|
-
"the secret fields move only when THIS marker and the authored " +
|
|
8617
|
-
"value disagree. Never authored, and never on a standalone row.",
|
|
8618
|
-
},
|
|
8619
|
-
// #2803 — availability is server-owned. As a `[webhook]` key it made
|
|
8620
|
-
// `config push` a second writer: a file pulled before an operator
|
|
8621
|
-
// paused the webhook put the endpoint back in service on the next
|
|
8622
|
-
// push. `server-owned` keeps it out of the TOML surface AND out of the
|
|
8623
|
-
// create/update request schemas, closing the tenant app-API path that
|
|
8624
|
-
// stored `body.status` unvalidated.
|
|
8625
|
-
status: {
|
|
8626
|
-
kind: "server-owned",
|
|
8627
|
-
note: "Availability (#2803): active | inactive | archived. Written only " +
|
|
8628
|
-
"by `webhooks enable|disable` and by the delete flow's tombstone. " +
|
|
8629
|
-
"Never authored in TOML: pull does not emit it, pull skips " +
|
|
8630
|
-
"archived rows entirely, and a file carrying the key fails push.",
|
|
8631
|
-
},
|
|
8632
9063
|
appId: {
|
|
8633
9064
|
kind: "server-owned",
|
|
8634
9065
|
note: "Tenant scope, taken from the route; never on the wire.",
|
|
8635
9066
|
},
|
|
8636
|
-
|
|
9067
|
+
bucketKey: {
|
|
8637
9068
|
kind: "structural",
|
|
8638
|
-
//
|
|
8639
|
-
//
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
9069
|
+
// Create carries it in the body; update does NOT — the key is
|
|
9070
|
+
// immutable (`blob-buckets-controller.ts` update) and the URL already
|
|
9071
|
+
// names the bucket, so a body carrying it is a 400 rather than a
|
|
9072
|
+
// rename that silently did nothing.
|
|
9073
|
+
requestModes: ["create"],
|
|
9074
|
+
note: "The bucket's identity. Comes from the TOML file name and is " +
|
|
9075
|
+
"attached by the caller, not spread from the [bucket] table. Its " +
|
|
8643
9076
|
"TOML spelling is declared in tomlOnlyKeys as `key`.",
|
|
8644
9077
|
},
|
|
8645
|
-
|
|
8646
|
-
kind: "server-owned",
|
|
8647
|
-
note: "Resolved from `workflowKey` server-side; the author writes the key.",
|
|
8648
|
-
},
|
|
8649
|
-
previousSigningSecret: {
|
|
8650
|
-
kind: "secret",
|
|
8651
|
-
note: "#2383 rotation slot. Written by the rotate endpoint, never by an " +
|
|
8652
|
-
"author, and reported through the derived signingSecretStatus " +
|
|
8653
|
-
"fields rather than as a TOML key.",
|
|
8654
|
-
},
|
|
8655
|
-
secretRotatedAt: {
|
|
8656
|
-
kind: "server-owned",
|
|
8657
|
-
note: "Stamped by the rotate endpoint; reported, never authored.",
|
|
8658
|
-
},
|
|
8659
|
-
config: {
|
|
8660
|
-
kind: "structural",
|
|
8661
|
-
note: "Per-scheme verification settings. Authored as the top-level " +
|
|
8662
|
-
"[verification.<scheme>] table and converted by " +
|
|
8663
|
-
"webhookConfigToTomlTable / tomlTableToWebhookConfig, whose stored " +
|
|
8664
|
-
"shape differs per scheme (#2109), not as a [webhook] key.",
|
|
8665
|
-
},
|
|
8666
|
-
allowedIpCidrs: {
|
|
8667
|
-
kind: "structural",
|
|
8668
|
-
note: "Authored as the top-level [allowedIps] table (`cidrs = [...]`) and " +
|
|
8669
|
-
"stored as a JSON string, not as a [webhook] key.",
|
|
8670
|
-
},
|
|
8671
|
-
inputMapping: {
|
|
8672
|
-
kind: "structural",
|
|
8673
|
-
note: "Authored as the top-level [inputMapping] table and stored as a " +
|
|
8674
|
-
"JSON string, not as a [webhook] key.",
|
|
8675
|
-
},
|
|
8676
|
-
metadata: {
|
|
8677
|
-
kind: "structural",
|
|
8678
|
-
note: "Authored as the top-level [metadata] table and stored as a JSON " +
|
|
8679
|
-
"string, not as a [webhook] key.",
|
|
8680
|
-
},
|
|
8681
|
-
handshakeRules: {
|
|
8682
|
-
kind: "structural",
|
|
8683
|
-
note: "Provider handshake/challenge rules, validated by " +
|
|
8684
|
-
"src/app-api/services/webhook-handshake.ts. Accepted by the admin " +
|
|
8685
|
-
"API but not part of the TOML surface — `config push` never sends it, " +
|
|
8686
|
-
"so the stored value is left alone rather than cleared.",
|
|
8687
|
-
},
|
|
8688
|
-
lastTriggeredAt: {
|
|
9078
|
+
accessPolicy: {
|
|
8689
9079
|
kind: "server-owned",
|
|
8690
|
-
note: "
|
|
9080
|
+
note: "RETIRED from the write surface by #3996, superseded by `preset` " +
|
|
9081
|
+
"(#1020). The attribute stays declared so `resolveBucketPreset` " +
|
|
9082
|
+
"can read a pre-#1020 row; no write path accepts it and no " +
|
|
9083
|
+
"serializer emits it.",
|
|
8691
9084
|
},
|
|
8692
9085
|
createdBy: {
|
|
8693
9086
|
kind: "server-owned",
|
|
8694
|
-
note: "User who created the
|
|
8695
|
-
},
|
|
8696
|
-
createdAt: {
|
|
8697
|
-
kind: "server-owned",
|
|
8698
|
-
note: "Timestamp, assigned server-side.",
|
|
8699
|
-
},
|
|
8700
|
-
modifiedAt: {
|
|
8701
|
-
kind: "server-owned",
|
|
8702
|
-
note: "Timestamp, assigned server-side.",
|
|
8703
|
-
},
|
|
8704
|
-
},
|
|
8705
|
-
tomlOnlyKeys: {
|
|
8706
|
-
key: {
|
|
8707
|
-
kind: "structural",
|
|
8708
|
-
note: "The webhook key. `config pull` writes it for readability; push takes " +
|
|
8709
|
-
"the identity from the file name and attaches `webhookKey` itself.",
|
|
8710
|
-
},
|
|
8711
|
-
},
|
|
8712
|
-
responseOnlyKeys: {
|
|
8713
|
-
signingSecretStatus: {
|
|
8714
|
-
kind: "server-owned",
|
|
8715
|
-
note: "#2254 — derived disclosure state of the stored secret (reference / " +
|
|
8716
|
-
"withheld literal / unset). Computed at serialize time; read-only.",
|
|
8717
|
-
},
|
|
8718
|
-
previousSigningSecretStatus: {
|
|
8719
|
-
kind: "server-owned",
|
|
8720
|
-
note: "Same derivation for the rotation slot. Read-only.",
|
|
8721
|
-
},
|
|
8722
|
-
signingSecretHealth: {
|
|
8723
|
-
kind: "server-owned",
|
|
8724
|
-
note: "#2383 — derived health report on the stored secret. Read-only.",
|
|
8725
|
-
},
|
|
8726
|
-
previousSigningSecretHealth: {
|
|
8727
|
-
kind: "server-owned",
|
|
8728
|
-
note: "Same report for the rotation slot. Read-only.",
|
|
8729
|
-
},
|
|
8730
|
-
},
|
|
8731
|
-
},
|
|
8732
|
-
],
|
|
8733
|
-
tomlDocumentKeys: {
|
|
8734
|
-
verification: {
|
|
8735
|
-
kind: "structural",
|
|
8736
|
-
note: "The `[verification.<scheme>]` table carrying the scheme's settings " +
|
|
8737
|
-
"(#2109). Converted to/from the stored `config` blob by " +
|
|
8738
|
-
"webhookConfigToTomlTable / tomlTableToWebhookConfig.",
|
|
8739
|
-
},
|
|
8740
|
-
allowedIps: {
|
|
8741
|
-
kind: "structural",
|
|
8742
|
-
note: "`[allowedIps] cidrs = [...]` — the source allow-list, stored as the " +
|
|
8743
|
-
"JSON string `allowedIpCidrs`.",
|
|
8744
|
-
},
|
|
8745
|
-
inputMapping: {
|
|
8746
|
-
kind: "structural",
|
|
8747
|
-
note: "The authored payload mapping, stored as the JSON string " +
|
|
8748
|
-
"`inputMapping`; a table rather than a [webhook] key so it can nest.",
|
|
8749
|
-
},
|
|
8750
|
-
metadata: {
|
|
8751
|
-
kind: "structural",
|
|
8752
|
-
note: "The webhook's authored metadata table, stored as the JSON string " +
|
|
8753
|
-
"`metadata`. Unrelated to the declared-access manifest of the type " +
|
|
8754
|
-
"configs, which spells `[metadata]` the same way.",
|
|
8755
|
-
},
|
|
8756
|
-
},
|
|
8757
|
-
// ── Cross-field rules (#3374) ─────────────────────────────────────────────
|
|
8758
|
-
//
|
|
8759
|
-
// Nothing here is `preflight`. Stage is a property of the (surface, rule)
|
|
8760
|
-
// pair, and on THIS surface even the file-decidable signing-secret rule is
|
|
8761
|
-
// enforced mid-apply: the standalone webhook CLI path runs no signing-secret
|
|
8762
|
-
// preflight (`function-sync.ts` is that rule's only CLI caller), and an
|
|
8763
|
-
// update that omits `signingSecret` keeps the stored one, so a local check
|
|
8764
|
-
// would need update-retains-stored-secret semantics the intent lists as a
|
|
8765
|
-
// non-goal. Declaring `preflight` would promise a refusal that lands after
|
|
8766
|
-
// sibling entities are written.
|
|
8767
|
-
//
|
|
8768
|
-
// The residue, named: `webhook-verification/config-validation.ts` is not a
|
|
8769
|
-
// rules module (it builds forty-odd refusals, most single-field). Its
|
|
8770
|
-
// cross-field refusals — scheme × config, replay protection, config secret
|
|
8771
|
-
// references — reach a write only through `validateWebhookSettings`, which
|
|
8772
|
-
// re-builds each under its own pipeline id, so they are declared here under
|
|
8773
|
-
// those ids; the module itself is unmigrated.
|
|
8774
|
-
crossFieldRules: [
|
|
8775
|
-
...webhookApplyRules(WEBHOOK_SIGNING_SECRET_RULE, "validateSigningSecretDeclaration", [
|
|
8776
|
-
[
|
|
8777
|
-
"signing-secret-required",
|
|
8778
|
-
"A scheme that verifies with an HMAC secret must be given a " +
|
|
8779
|
-
"`signingSecret`. The same handler the function surface runs in " +
|
|
8780
|
-
"preflight; here it runs at apply because the standalone CLI path " +
|
|
8781
|
-
"never calls it and an update preserves an omitted stored secret.",
|
|
8782
|
-
],
|
|
8783
|
-
[
|
|
8784
|
-
"whole-secret-reference",
|
|
8785
|
-
"A supplied `signingSecret` is a whole `{{secrets.KEY}}` reference " +
|
|
8786
|
-
"and nothing else — a literal is never stored (#2254).",
|
|
8787
|
-
],
|
|
8788
|
-
[
|
|
8789
|
-
"signing-secret-not-supported",
|
|
8790
|
-
"A scheme whose key material lives in its config (`discord`, `jwt`, " +
|
|
8791
|
-
"`plaid`) or that verifies nothing (`none`) refuses a `signingSecret`.",
|
|
8792
|
-
],
|
|
8793
|
-
]),
|
|
8794
|
-
...webhookApplyRules("src/app-api/services/webhook-limits.ts", "validateWebhookCountUnderCap", [
|
|
8795
|
-
[
|
|
8796
|
-
"webhook-cap",
|
|
8797
|
-
"An app holds at most fifty webhook rows, archived included; a " +
|
|
8798
|
-
"create that would add one past the cap is refused with " +
|
|
8799
|
-
"`WEBHOOK_LIMIT_REACHED` (#2232). Read early by `config push` as an " +
|
|
8800
|
-
"advisory check; the server decides.",
|
|
8801
|
-
],
|
|
8802
|
-
]),
|
|
8803
|
-
...webhookApplyRules("src/app-api/services/webhook-settings-validation.ts", "validateWebhookSettings", [
|
|
8804
|
-
["verification-scheme-required", "A webhook names its `verificationScheme`."],
|
|
8805
|
-
["verification-scheme-value", "The scheme is one the receiver knows."],
|
|
8806
|
-
[
|
|
8807
|
-
"verification-config",
|
|
8808
|
-
"The scheme's `config` is valid for that scheme under this " +
|
|
8809
|
-
"environment's JWKS policy, and carries no literal credential.",
|
|
8810
|
-
],
|
|
8811
|
-
[
|
|
8812
|
-
"replay-protection",
|
|
8813
|
-
"A signed scheme keeps deduplication on, with a window and tolerance " +
|
|
8814
|
-
"in range and long enough to cover the signature's freshness window.",
|
|
8815
|
-
],
|
|
8816
|
-
[
|
|
8817
|
-
"signing-secret-exists",
|
|
8818
|
-
"The app secret a `signingSecret` reference names must exist, so a " +
|
|
8819
|
-
"missing key fails the write rather than the first delivery.",
|
|
8820
|
-
],
|
|
8821
|
-
[
|
|
8822
|
-
"verification-config-secrets-exist",
|
|
8823
|
-
"Every secret reference the active scheme's `config` resolves at " +
|
|
8824
|
-
"delivery must name an existing app secret.",
|
|
8825
|
-
],
|
|
8826
|
-
]),
|
|
8827
|
-
...webhookApplyRules("src/app-api/services/webhook-verification/signing-secret-migration.ts", "validateSigningSecretMigration", [
|
|
8828
|
-
[
|
|
8829
|
-
"signing-secret-migration",
|
|
8830
|
-
"A row whose STORED `signingSecret` is still a legacy literal cannot " +
|
|
8831
|
-
"be updated until the write migrates it to a reference (#2332); " +
|
|
8832
|
-
"gated on the scheme and status the row will end up with.",
|
|
8833
|
-
],
|
|
8834
|
-
[
|
|
8835
|
-
"signing-secret-migration-malformed",
|
|
8836
|
-
"The same gate for a stored value carrying reference syntax that does " +
|
|
8837
|
-
"not resolve — every signed delivery is already failing, and the " +
|
|
8838
|
-
"message says so.",
|
|
8839
|
-
],
|
|
8840
|
-
]),
|
|
8841
|
-
],
|
|
8842
|
-
};
|
|
8843
|
-
// ── src/config-surface/cron-trigger.ts ───────────────────────────────────
|
|
8844
|
-
/**
|
|
8845
|
-
* The `cron-trigger` configuration object's definition (issue #2644, phase 2).
|
|
8846
|
-
*
|
|
8847
|
-
* `cron-triggers/<key>.toml` carries one `[cronTrigger]` field table plus the
|
|
8848
|
-
* top-level `[rootInput]` and `[inputMapping]` tables, which are authored JSON
|
|
8849
|
-
* structures with their own normalizer and are declared `structural`.
|
|
8850
|
-
*
|
|
8851
|
-
* `state` is classified `structural` (update-only), not a field (#2645):
|
|
8852
|
-
* pausing moved onto the `operationallyDisabled` toggle written by
|
|
8853
|
-
* `cron-triggers pause|resume`, so `state` left the TOML surface — pull does
|
|
8854
|
-
* not emit it, and push REJECTS a file that still carries the line (with
|
|
8855
|
-
* guidance naming the pause verbs; see `RETIRED_TOML_KEYS` in the CLI's
|
|
8856
|
-
* `commands/sync.ts`) — while the update handler keeps reading it for the
|
|
8857
|
-
* console.
|
|
8858
|
-
*/
|
|
8859
|
-
const CRON_TRIGGER_HANDLER = "src/app-api/controllers/cron-triggers-controller.ts";
|
|
8860
|
-
export const CRON_TRIGGER_SURFACE = {
|
|
8861
|
-
label: "cron-trigger",
|
|
8862
|
-
tables: [
|
|
8863
|
-
{
|
|
8864
|
-
tomlPath: ["cronTrigger"],
|
|
8865
|
-
repeated: false,
|
|
8866
|
-
model: "CronTrigger",
|
|
8867
|
-
// Declaration order reproduces the pre-#2644 serializer's key order.
|
|
8868
|
-
fields: [
|
|
8869
|
-
{
|
|
8870
|
-
field: "displayName",
|
|
8871
|
-
tomlKey: "displayName",
|
|
8872
|
-
type: "string",
|
|
8873
|
-
emit: "always",
|
|
8874
|
-
writableOn: BOTH,
|
|
8875
|
-
validation: "passthrough",
|
|
8876
|
-
},
|
|
8877
|
-
{
|
|
8878
|
-
field: "description",
|
|
8879
|
-
tomlKey: "description",
|
|
8880
|
-
type: "string",
|
|
8881
|
-
emit: "whenSet",
|
|
8882
|
-
writableOn: BOTH,
|
|
8883
|
-
validation: "passthrough",
|
|
8884
|
-
},
|
|
8885
|
-
{
|
|
8886
|
-
field: "cron",
|
|
8887
|
-
tomlKey: "cron",
|
|
8888
|
-
type: "string",
|
|
8889
|
-
emit: "always",
|
|
8890
|
-
writableOn: BOTH,
|
|
8891
|
-
// #3376 — re-pointed from `src/cron-parser.ts`, which now only
|
|
8892
|
-
// re-exports the parser: the drift guard resolves `export function
|
|
8893
|
-
// <name>` in the named module's OWN source, so the declaring module
|
|
8894
|
-
// is the only one it can name.
|
|
8895
|
-
//
|
|
8896
|
-
// `apply`, not `preflight`, even though the predicate is vendored
|
|
8897
|
-
// and the rule is decidable from the file: no CLI check reads a
|
|
8898
|
-
// standalone `cron-triggers/<key>.toml`'s VALUES.
|
|
8899
|
-
// `collectConfigFileValidationErrors` is definition-driven and
|
|
8900
|
-
// cannot dispatch through a `handledBy` string (#1976), so this
|
|
8901
|
-
// file still fails at apply with the controller's message.
|
|
8902
|
-
// `preflight` would make the registry promise a refusal that in
|
|
8903
|
-
// fact lands mid-apply — and the reachability walker could not
|
|
8904
|
-
// catch the lie, because the FUNCTION leg reaches this same
|
|
8905
|
-
// predicate. Building that standalone leg, with its `config diff`
|
|
8906
|
-
// twin, is a finding for #3379.
|
|
8907
|
-
validation: handledBy("src/config-surface/cron-expression.ts", "cronExpressionError", "apply"),
|
|
8908
|
-
},
|
|
8909
|
-
{
|
|
8910
|
-
field: "timezone",
|
|
8911
|
-
tomlKey: "timezone",
|
|
8912
|
-
type: "string",
|
|
8913
|
-
emit: "always",
|
|
8914
|
-
writableOn: BOTH,
|
|
8915
|
-
// Validated against Intl; unset reads as "UTC". #3376 named the
|
|
8916
|
-
// predicate itself rather than the controller class: the probe the
|
|
8917
|
-
// three sites used to spell out is one function now, and this is
|
|
8918
|
-
// one of the two surfaces that own it. `apply` for the same reason
|
|
8919
|
-
// as `cron` above — no standalone CLI preflight runs it (#3379).
|
|
8920
|
-
validation: handledBy("src/config-surface/cron-expression.ts", "isValidTimezone", "apply"),
|
|
8921
|
-
// `cron-triggers-controller.ts` stores `timezone || "UTC"`, so a file
|
|
8922
|
-
// that omits the key describes a trigger running in UTC — compared
|
|
8923
|
-
// and pushed as that, rather than as a difference no push can clear
|
|
8924
|
-
// (#2880 DSO-002).
|
|
8925
|
-
serverDefault: "UTC",
|
|
8926
|
-
},
|
|
8927
|
-
{
|
|
8928
|
-
field: "workflowKey",
|
|
8929
|
-
tomlKey: "workflowKey",
|
|
8930
|
-
type: "string",
|
|
8931
|
-
emit: "always",
|
|
8932
|
-
writableOn: BOTH,
|
|
8933
|
-
// #1002 — a reserved `__internal.` key is rejected at save time.
|
|
8934
|
-
validation: handledBy(CRON_TRIGGER_HANDLER, "CronTriggersController", "apply"),
|
|
8935
|
-
},
|
|
8936
|
-
{
|
|
8937
|
-
field: "overlapPolicy",
|
|
8938
|
-
tomlKey: "overlapPolicy",
|
|
8939
|
-
type: "string",
|
|
8940
|
-
emit: "always",
|
|
8941
|
-
writableOn: BOTH,
|
|
8942
|
-
// skip | allow.
|
|
8943
|
-
validation: handledBy(CRON_TRIGGER_HANDLER, "CronTriggersController", "apply"),
|
|
8944
|
-
// Same store-time default as `timezone` (#2880 DSO-002).
|
|
8945
|
-
serverDefault: "skip",
|
|
8946
|
-
},
|
|
8947
|
-
],
|
|
8948
|
-
notExposed: {
|
|
8949
|
-
// #3181 — a function-declared cron entry creates a hidden row keyed
|
|
8950
|
-
// `<functionKey>:<name>`, and this is the discriminator every standalone
|
|
8951
|
-
// surface hides on. Never authored on a `[cronTrigger]` table: the
|
|
8952
|
-
// declaration lives in the function's own file.
|
|
8953
|
-
functionId: {
|
|
8954
|
-
kind: "server-owned",
|
|
8955
|
-
note: "The server function whose config owns this row (#3181). Written " +
|
|
8956
|
-
"only by the trigger reconcile; a standalone trigger never has one.",
|
|
8957
|
-
},
|
|
8958
|
-
// #2803 — the ONE availability control, server-owned. Written only by
|
|
8959
|
-
// `cron-triggers enable|disable`, the delete flow (the `archived`
|
|
8960
|
-
// tombstone) and the alarm's error-pause path. `server-owned` keeps it
|
|
8961
|
-
// out of both the TOML surface and the create/update request schemas,
|
|
8962
|
-
// so no configuration write can change availability as a side effect.
|
|
8963
|
-
status: {
|
|
8964
|
-
kind: "server-owned",
|
|
8965
|
-
note: "Availability (#2803): active | inactive | archived. Written only " +
|
|
8966
|
-
"by `cron-triggers enable|disable`, the delete flow and the " +
|
|
8967
|
-
"error-pause path. Never authored in TOML: pull does not emit it " +
|
|
8968
|
-
"and a file that still carries the key fails push.",
|
|
8969
|
-
},
|
|
8970
|
-
// #2645 criterion 9 moved pausing off `state`; #2803 retired the field
|
|
8971
|
-
// entirely. It mixed lifecycle (`archived`, `error_paused`) with
|
|
8972
|
-
// availability (`paused`), which is what made two writers possible in
|
|
8973
|
-
// the first place. `server-owned` now, not `structural` with an
|
|
8974
|
-
// update-only mode: the console's carve-out is gone with it, so the
|
|
8975
|
-
// generic update rejects a supplied `state` exactly as create always
|
|
8976
|
-
// did.
|
|
8977
|
-
state: {
|
|
8978
|
-
kind: "server-owned",
|
|
8979
|
-
note: "DEPRECATED (#2803), superseded by `status`. Read only by " +
|
|
8980
|
-
"`canonicalCronStatus()`; normalized back to `active` by " +
|
|
8981
|
-
"`cron-triggers enable`. Never authored in TOML and never accepted " +
|
|
8982
|
-
"on the wire.",
|
|
8983
|
-
},
|
|
8984
|
-
operationallyDisabled: {
|
|
8985
|
-
kind: "server-owned",
|
|
8986
|
-
note: "DEPRECATED (#2803), superseded by `status`. The #2645 operational " +
|
|
8987
|
-
"toggle, cleared by `cron-triggers enable|disable` as rows are " +
|
|
8988
|
-
"touched. Never authored in TOML and never accepted on the config " +
|
|
8989
|
-
"create/update wire.",
|
|
8990
|
-
},
|
|
8991
|
-
triggerId: {
|
|
8992
|
-
kind: "server-owned",
|
|
8993
|
-
note: "ULID assigned on create; never author-authored.",
|
|
8994
|
-
},
|
|
8995
|
-
appId: {
|
|
8996
|
-
kind: "server-owned",
|
|
8997
|
-
note: "Tenant scope, taken from the route; never on the wire.",
|
|
8998
|
-
},
|
|
8999
|
-
triggerKey: {
|
|
9000
|
-
kind: "structural",
|
|
9001
|
-
// Both modes: the update handler ignores it, but the shipped CLI
|
|
9002
|
-
// attaches it to every cron-trigger update body (see integration.ts).
|
|
9003
|
-
requestModes: ["create", "update"],
|
|
9004
|
-
note: "The trigger's identity. Comes from the TOML file name and is " +
|
|
9005
|
-
"attached by the caller, not spread from the [cronTrigger] table. " +
|
|
9006
|
-
"Its TOML spelling is declared in tomlOnlyKeys as `key`.",
|
|
9007
|
-
},
|
|
9008
|
-
rootInput: {
|
|
9009
|
-
kind: "structural",
|
|
9010
|
-
note: "Authored as the top-level [rootInput] table and stored as a JSON " +
|
|
9011
|
-
"string (normalizeJsonString), not as a [cronTrigger] key.",
|
|
9012
|
-
},
|
|
9013
|
-
inputMapping: {
|
|
9014
|
-
kind: "structural",
|
|
9015
|
-
note: "Authored as the top-level [inputMapping] table and stored as a " +
|
|
9016
|
-
"JSON string (normalizeJsonString), not as a [cronTrigger] key.",
|
|
9017
|
-
},
|
|
9018
|
-
lastError: {
|
|
9019
|
-
kind: "server-owned",
|
|
9020
|
-
note: "Last fire failure, written by the trigger DO and cleared on resume.",
|
|
9021
|
-
},
|
|
9022
|
-
lastTriggeredAt: {
|
|
9023
|
-
kind: "server-owned",
|
|
9024
|
-
note: "Stamped on fire; reported, never authored.",
|
|
9025
|
-
},
|
|
9026
|
-
lastTriggeredRunId: {
|
|
9027
|
-
kind: "server-owned",
|
|
9028
|
-
note: "Run started by the last fire; reported, never authored.",
|
|
9029
|
-
},
|
|
9030
|
-
skippedCount: {
|
|
9031
|
-
kind: "server-owned",
|
|
9032
|
-
note: "Runtime counter maintained by the trigger DO.",
|
|
9033
|
-
},
|
|
9034
|
-
firedCount: {
|
|
9035
|
-
kind: "server-owned",
|
|
9036
|
-
note: "Runtime counter maintained by the trigger DO.",
|
|
9037
|
-
},
|
|
9038
|
-
consecutiveNotActiveCount: {
|
|
9039
|
-
kind: "server-owned",
|
|
9040
|
-
note: "Runtime counter behind the auto-pause rule; DO-maintained.",
|
|
9041
|
-
},
|
|
9042
|
-
nextFireAt: {
|
|
9043
|
-
kind: "server-owned",
|
|
9044
|
-
note: "Projected next fire, computed from the schedule by the DO.",
|
|
9045
|
-
},
|
|
9046
|
-
createdBy: {
|
|
9047
|
-
kind: "server-owned",
|
|
9048
|
-
note: "User who created the trigger; assigned server-side.",
|
|
9049
|
-
},
|
|
9050
|
-
createdAt: {
|
|
9051
|
-
kind: "server-owned",
|
|
9052
|
-
note: "Timestamp, assigned server-side.",
|
|
9053
|
-
},
|
|
9054
|
-
modifiedAt: {
|
|
9055
|
-
kind: "server-owned",
|
|
9056
|
-
note: "Timestamp, assigned server-side.",
|
|
9057
|
-
},
|
|
9058
|
-
},
|
|
9059
|
-
requestOnlyKeys: {
|
|
9060
|
-
key: {
|
|
9061
|
-
// CREATE only: `update` never reads it — the trigger is addressed by
|
|
9062
|
-
// id in the path, and its key is immutable — so a `key` sent on
|
|
9063
|
-
// update is a 400 rather than a silently ignored rename.
|
|
9064
|
-
modes: CREATE_ONLY,
|
|
9065
|
-
note: "Alias for `triggerKey` on create, accepted by the controller " +
|
|
9066
|
-
"(`triggerKey || key`) since before sync existed. Declared so the " +
|
|
9067
|
-
"generated request schema keeps accepting a client that uses it.",
|
|
9068
|
-
},
|
|
9069
|
-
name: {
|
|
9070
|
-
note: "Alias for `displayName`, accepted on create and update " +
|
|
9071
|
-
"(`displayName ?? name`). Same reason as `key`.",
|
|
9072
|
-
},
|
|
9073
|
-
},
|
|
9074
|
-
tomlOnlyKeys: {
|
|
9075
|
-
key: {
|
|
9076
|
-
kind: "structural",
|
|
9077
|
-
note: "The trigger key. `config pull` writes it for readability; push takes " +
|
|
9078
|
-
"the identity from the file name and attaches `triggerKey` itself.",
|
|
9079
|
-
},
|
|
9080
|
-
},
|
|
9081
|
-
responseOnlyKeys: {
|
|
9082
|
-
runtime: {
|
|
9083
|
-
kind: "server-owned",
|
|
9084
|
-
note: "DO-derived schedule status (`scheduledAlarm` / `scheduledAlarmAt`) " +
|
|
9085
|
-
"attached to the detail response. Computed, never persisted here.",
|
|
9086
|
-
},
|
|
9087
|
-
},
|
|
9088
|
-
},
|
|
9089
|
-
],
|
|
9090
|
-
tomlDocumentKeys: {
|
|
9091
|
-
rootInput: {
|
|
9092
|
-
kind: "structural",
|
|
9093
|
-
note: "The authored root input for each fire, stored as the JSON string " +
|
|
9094
|
-
"`rootInput` (normalizeJsonString).",
|
|
9095
|
-
},
|
|
9096
|
-
inputMapping: {
|
|
9097
|
-
kind: "structural",
|
|
9098
|
-
note: "The authored input mapping, stored as the JSON string `inputMapping` " +
|
|
9099
|
-
"(normalizeJsonString).",
|
|
9100
|
-
},
|
|
9101
|
-
},
|
|
9102
|
-
};
|
|
9103
|
-
// ── src/config-surface/blob-bucket.ts ────────────────────────────────────
|
|
9104
|
-
/**
|
|
9105
|
-
* The `blob-bucket` configuration object's definition (issue #2644, phase 2).
|
|
9106
|
-
*
|
|
9107
|
-
* `blob-buckets/<key>.toml` carries a single `[bucket]` table.
|
|
9108
|
-
*
|
|
9109
|
-
* `ttlTier` is `writableOn: ["create"]`: the update handler does not read it, so
|
|
9110
|
-
* the retention tier is fixed at creation. `preset` and the rule set are the two
|
|
9111
|
-
* halves of the access model (#1020), and the only access keys: at most one may
|
|
9112
|
-
* change per request, which is the controller's rule and stays there. The rule
|
|
9113
|
-
* set is authored by name (`ruleSetName`) and sent as `ruleSetId`, as the type
|
|
9114
|
-
* configs do (#4116). The id spelling in TOML (#4283) and the pre-#1020
|
|
9115
|
-
* `accessPolicy` spelling (#3996) are retired keys (`retired-keys.ts`).
|
|
9116
|
-
*/
|
|
9117
|
-
const BLOB_BUCKET_HANDLER = "src/app-api/controllers/blob-buckets-controller.ts";
|
|
9118
|
-
export const BLOB_BUCKET_SURFACE = {
|
|
9119
|
-
label: "blob-bucket",
|
|
9120
|
-
tables: [
|
|
9121
|
-
{
|
|
9122
|
-
tomlPath: ["bucket"],
|
|
9123
|
-
repeated: false,
|
|
9124
|
-
model: "BlobBucket",
|
|
9125
|
-
// Declaration order reproduces the pre-#2644 serializer's key order.
|
|
9126
|
-
fields: [
|
|
9127
|
-
{
|
|
9128
|
-
field: "name",
|
|
9129
|
-
tomlKey: "name",
|
|
9130
|
-
type: "string",
|
|
9131
|
-
emit: "always",
|
|
9132
|
-
writableOn: BOTH,
|
|
9133
|
-
validation: "passthrough",
|
|
9134
|
-
},
|
|
9135
|
-
{
|
|
9136
|
-
field: "description",
|
|
9137
|
-
tomlKey: "description",
|
|
9138
|
-
type: "string",
|
|
9139
|
-
emit: "whenSet",
|
|
9140
|
-
writableOn: BOTH,
|
|
9141
|
-
validation: "passthrough",
|
|
9142
|
-
},
|
|
9143
|
-
{
|
|
9144
|
-
field: "ttlTier",
|
|
9145
|
-
tomlKey: "ttlTier",
|
|
9146
|
-
type: "string",
|
|
9147
|
-
emit: "always",
|
|
9148
|
-
writableOn: CREATE_ONLY,
|
|
9149
|
-
// Immutable after create: `update` never reads it.
|
|
9150
|
-
validation: handledBy(BLOB_BUCKET_HANDLER, "BlobBucketsController", "apply"),
|
|
9151
|
-
},
|
|
9152
|
-
{
|
|
9153
|
-
field: "preset",
|
|
9154
|
-
tomlKey: "preset",
|
|
9155
|
-
type: "string",
|
|
9156
|
-
emit: "whenSet",
|
|
9157
|
-
writableOn: BOTH,
|
|
9158
|
-
// #1020 — the honest access field. A rule-set-backed bucket reports
|
|
9159
|
-
// "custom", which is not written back as a preset.
|
|
9160
|
-
validation: handledBy("src/app-api/resource-types/blob-bucket.ts", "resolveBucketPreset", "apply"),
|
|
9161
|
-
},
|
|
9162
|
-
{
|
|
9163
|
-
field: "ruleSetId",
|
|
9164
|
-
tomlKey: "ruleSetName",
|
|
9165
|
-
type: "string",
|
|
9166
|
-
emit: "whenSet",
|
|
9167
|
-
writableOn: BOTH,
|
|
9168
|
-
// Authored as a name, sent as an id (#4116), so a tree copied into
|
|
9169
|
-
// another app binds that app's rule set. Existence-checked against
|
|
9170
|
-
// AccessRuleSet; mutually exclusive with a preset change in the same
|
|
9171
|
-
// request. The TOML spelling of the id is a retired key (#4283).
|
|
9172
|
-
validation: handledBy(BLOB_BUCKET_HANDLER, "BlobBucketsController", "apply"),
|
|
9173
|
-
},
|
|
9174
|
-
],
|
|
9175
|
-
notExposed: {
|
|
9176
|
-
bucketId: {
|
|
9177
|
-
kind: "server-owned",
|
|
9178
|
-
note: "ULID assigned on create; never author-authored.",
|
|
9179
|
-
},
|
|
9180
|
-
appId: {
|
|
9181
|
-
kind: "server-owned",
|
|
9182
|
-
note: "Tenant scope, taken from the route; never on the wire.",
|
|
9183
|
-
},
|
|
9184
|
-
bucketKey: {
|
|
9185
|
-
kind: "structural",
|
|
9186
|
-
// Create carries it in the body; update does NOT — the key is
|
|
9187
|
-
// immutable (`blob-buckets-controller.ts` update) and the URL already
|
|
9188
|
-
// names the bucket, so a body carrying it is a 400 rather than a
|
|
9189
|
-
// rename that silently did nothing.
|
|
9190
|
-
requestModes: ["create"],
|
|
9191
|
-
note: "The bucket's identity. Comes from the TOML file name and is " +
|
|
9192
|
-
"attached by the caller, not spread from the [bucket] table. Its " +
|
|
9193
|
-
"TOML spelling is declared in tomlOnlyKeys as `key`.",
|
|
9194
|
-
},
|
|
9195
|
-
accessPolicy: {
|
|
9196
|
-
kind: "server-owned",
|
|
9197
|
-
note: "RETIRED from the write surface by #3996, superseded by `preset` " +
|
|
9198
|
-
"(#1020). The attribute stays declared so `resolveBucketPreset` " +
|
|
9199
|
-
"can read a pre-#1020 row; no write path accepts it and no " +
|
|
9200
|
-
"serializer emits it.",
|
|
9201
|
-
},
|
|
9202
|
-
createdBy: {
|
|
9203
|
-
kind: "server-owned",
|
|
9204
|
-
note: "User who created the bucket; assigned server-side.",
|
|
9087
|
+
note: "User who created the bucket; assigned server-side.",
|
|
9205
9088
|
},
|
|
9206
9089
|
createdAt: {
|
|
9207
9090
|
kind: "server-owned",
|
|
@@ -9505,12 +9388,106 @@ export const DATABASE_TYPE_SURFACE = {
|
|
|
9505
9388
|
kind: "server-owned",
|
|
9506
9389
|
note: "Timestamp, assigned server-side.",
|
|
9507
9390
|
},
|
|
9508
|
-
createdBy: {
|
|
9509
|
-
kind: "server-owned",
|
|
9510
|
-
note: "User who created the config; assigned server-side.",
|
|
9391
|
+
createdBy: {
|
|
9392
|
+
kind: "server-owned",
|
|
9393
|
+
note: "User who created the config; assigned server-side.",
|
|
9394
|
+
},
|
|
9395
|
+
},
|
|
9396
|
+
tomlOnlyKeys: {},
|
|
9397
|
+
requestOnlyKeys: {},
|
|
9398
|
+
responseOnlyKeys: {},
|
|
9399
|
+
},
|
|
9400
|
+
],
|
|
9401
|
+
tomlDocumentKeys: {
|
|
9402
|
+
models: {
|
|
9403
|
+
kind: "structural",
|
|
9404
|
+
note: "#666 — the `[models.<Name>.fields.*]` blocks, re-serialized into the " +
|
|
9405
|
+
"stored `schema` TOML string on push and merged back on pull.",
|
|
9406
|
+
},
|
|
9407
|
+
triggers: {
|
|
9408
|
+
kind: "structural",
|
|
9409
|
+
note: "The type's authored trigger table, stored on the type config as " +
|
|
9410
|
+
"`triggers` and validated server-side.",
|
|
9411
|
+
},
|
|
9412
|
+
...DECLARED_ACCESS_MANIFEST_KEYS,
|
|
9413
|
+
},
|
|
9414
|
+
};
|
|
9415
|
+
// ── src/config-surface/db3-type.ts ───────────────────────────────────────
|
|
9416
|
+
/**
|
|
9417
|
+
* The `db3-type` configuration object's definition (#4802, project
|
|
9418
|
+
* `db3-databases` phase 6).
|
|
9419
|
+
*
|
|
9420
|
+
* `db3-types/<name>.toml` is a db3 type: the `DatabaseTypeConfig` row a
|
|
9421
|
+
* database type is, read by db3s. One namespace, so the file's surface is the
|
|
9422
|
+
* database type file's with two differences: the type is named by `[type]
|
|
9423
|
+
* name`, where a database type file says `databaseType` (a retired spelling
|
|
9424
|
+
* here, `retired-keys.ts`), and it takes no rule set (#5993): nothing
|
|
9425
|
+
* evaluates one for a db3 type, whose management is for app admins and
|
|
9426
|
+
* owners, so `ruleSetName` and `ruleSetId` are refused here with that
|
|
9427
|
+
* sentence. The `[models.*]`, `[triggers]` and `[metadata]` /
|
|
9428
|
+
* `secrets` sub-trees are the database type's, kept by the validators that
|
|
9429
|
+
* own them; a db3 ignores the manifest. `config push` applies the file with
|
|
9430
|
+
* `PUT db3-types/:name`, which pushes the new revision to every db3 of the
|
|
9431
|
+
* type.
|
|
9432
|
+
*/
|
|
9433
|
+
const DB3_TYPES_HANDLER = "src/app-api/controllers/db3-types-controller.ts";
|
|
9434
|
+
const LEGACY_TYPE_TABLE = DATABASE_TYPE_SURFACE.tables[0];
|
|
9435
|
+
export const DB3_TYPE_SURFACE = {
|
|
9436
|
+
label: "db3-type",
|
|
9437
|
+
tables: [
|
|
9438
|
+
{
|
|
9439
|
+
tomlPath: ["type"],
|
|
9440
|
+
repeated: false,
|
|
9441
|
+
model: "DatabaseTypeConfig",
|
|
9442
|
+
fields: [
|
|
9443
|
+
{
|
|
9444
|
+
field: "databaseType",
|
|
9445
|
+
tomlKey: "name",
|
|
9446
|
+
type: "string",
|
|
9447
|
+
emit: "always",
|
|
9448
|
+
writableOn: CREATE_ONLY,
|
|
9449
|
+
// The type's identity: taken from the file name's route segment on
|
|
9450
|
+
// a push, `#`-free.
|
|
9451
|
+
validation: handledBy(DB3_TYPES_HANDLER, "Db3TypesController", "apply"),
|
|
9452
|
+
},
|
|
9453
|
+
{
|
|
9454
|
+
field: "autoPopulatedFields",
|
|
9455
|
+
tomlKey: "autoPopulatedFields",
|
|
9456
|
+
type: "json",
|
|
9457
|
+
emit: "whenSet",
|
|
9458
|
+
writableOn: BOTH,
|
|
9459
|
+
validation: handledBy(DB3_TYPES_HANDLER, "Db3TypesController", "apply"),
|
|
9460
|
+
},
|
|
9461
|
+
{
|
|
9462
|
+
field: "timestamps",
|
|
9463
|
+
tomlKey: "timestamps",
|
|
9464
|
+
type: "json",
|
|
9465
|
+
emit: "whenSet",
|
|
9466
|
+
writableOn: BOTH,
|
|
9467
|
+
validation: handledBy(DB3_TYPES_HANDLER, "Db3TypesController", "apply"),
|
|
9468
|
+
},
|
|
9469
|
+
],
|
|
9470
|
+
// A copy: the database type table's own classification stays as it is.
|
|
9471
|
+
notExposed: {
|
|
9472
|
+
...LEGACY_TYPE_TABLE.notExposed,
|
|
9473
|
+
ruleSetId: {
|
|
9474
|
+
kind: "structural",
|
|
9475
|
+
// Never in a `PUT db3-types/:name` body: the route refuses a bound one.
|
|
9476
|
+
requestModes: [],
|
|
9477
|
+
note: "The database type's rule set, authored as `ruleSetName` in " +
|
|
9478
|
+
"`database-type-configs/` only. A db3 type takes none: nothing " +
|
|
9479
|
+
"evaluates it, and managing a type is for app admins and owners.",
|
|
9480
|
+
},
|
|
9481
|
+
},
|
|
9482
|
+
tomlOnlyKeys: {
|
|
9483
|
+
models: {
|
|
9484
|
+
kind: "structural",
|
|
9485
|
+
note: "The models this type holds that another file of `db3-types/` " +
|
|
9486
|
+
"declares, by name: `models = [\"securities\"]`. `config push` " +
|
|
9487
|
+
"copies each named `[models.<name>]` declaration into the pushed " +
|
|
9488
|
+
"`schema`, so the server never sees the key.",
|
|
9511
9489
|
},
|
|
9512
9490
|
},
|
|
9513
|
-
tomlOnlyKeys: {},
|
|
9514
9491
|
requestOnlyKeys: {},
|
|
9515
9492
|
responseOnlyKeys: {},
|
|
9516
9493
|
},
|
|
@@ -9518,16 +9495,22 @@ export const DATABASE_TYPE_SURFACE = {
|
|
|
9518
9495
|
tomlDocumentKeys: {
|
|
9519
9496
|
models: {
|
|
9520
9497
|
kind: "structural",
|
|
9521
|
-
note: "
|
|
9522
|
-
"stored `schema` TOML string on
|
|
9498
|
+
note: "The `[models.<Name>.fields.*]` blocks: the declarations a db3 of the " +
|
|
9499
|
+
"type installs, re-serialized into the stored `schema` TOML string on " +
|
|
9500
|
+
"push and merged back on pull.",
|
|
9523
9501
|
},
|
|
9524
9502
|
triggers: {
|
|
9525
9503
|
kind: "structural",
|
|
9526
|
-
note: "The type's
|
|
9527
|
-
"`
|
|
9504
|
+
note: "The type's triggers, `[triggers.<Model>] triggers = [...]`, each " +
|
|
9505
|
+
"setting fields (`set`) or refusing the write (`refuse`), validated " +
|
|
9506
|
+
"server-side.",
|
|
9528
9507
|
},
|
|
9529
9508
|
...DECLARED_ACCESS_MANIFEST_KEYS,
|
|
9530
9509
|
},
|
|
9510
|
+
noCrossFieldRules: {
|
|
9511
|
+
note: "Every rule of a db3 type is a database type's: the type routes' own " +
|
|
9512
|
+
"validators judge the body, and each db3's room judges what it installs.",
|
|
9513
|
+
},
|
|
9531
9514
|
};
|
|
9532
9515
|
// ── src/config-surface/rule-set.ts ───────────────────────────────────────
|
|
9533
9516
|
/**
|
|
@@ -9545,6 +9528,33 @@ export const DATABASE_TYPE_SURFACE = {
|
|
|
9545
9528
|
* fixed at creation.
|
|
9546
9529
|
*/
|
|
9547
9530
|
const RULE_SET_HANDLER = "src/app-api/controllers/rule-sets-controller.ts";
|
|
9531
|
+
/**
|
|
9532
|
+
* Rule-set resource types that no longer exist (#4959), with the one refusal
|
|
9533
|
+
* both the rule-set routes and `config push`'s preflight answer for a set of
|
|
9534
|
+
* that type, so the two cannot drift.
|
|
9535
|
+
*
|
|
9536
|
+
* `lock` — locks are server-function-only, and the calling function's
|
|
9537
|
+
* `authorize` decides who may lock which key. A stored row can still be listed
|
|
9538
|
+
* and deleted; nothing evaluates it.
|
|
9539
|
+
*/
|
|
9540
|
+
export const RETIRED_RULE_SET_RESOURCE_TYPES = {
|
|
9541
|
+
lock: {
|
|
9542
|
+
code: "LOCK_RULE_SET_RETIRED",
|
|
9543
|
+
message: "`lock` is no longer a rule-set resource type. Locks are " +
|
|
9544
|
+
"server-function-only: the calling function's `authorize` decides who " +
|
|
9545
|
+
"may lock which key, and nothing evaluates a lock rule. Delete " +
|
|
9546
|
+
"`rule-sets/<name>.toml` and run `primitive config push --prune` to " +
|
|
9547
|
+
"remove this rule set.",
|
|
9548
|
+
},
|
|
9549
|
+
};
|
|
9550
|
+
/** The retirement for `resourceType`, or `null` for a live type. */
|
|
9551
|
+
export function retiredRuleSetResourceType(resourceType) {
|
|
9552
|
+
if (typeof resourceType !== "string")
|
|
9553
|
+
return null;
|
|
9554
|
+
return Object.prototype.hasOwnProperty.call(RETIRED_RULE_SET_RESOURCE_TYPES, resourceType)
|
|
9555
|
+
? RETIRED_RULE_SET_RESOURCE_TYPES[resourceType]
|
|
9556
|
+
: null;
|
|
9557
|
+
}
|
|
9548
9558
|
export const RULE_SET_SURFACE = {
|
|
9549
9559
|
label: "rule-set",
|
|
9550
9560
|
tables: [
|
|
@@ -9627,178 +9637,6 @@ export const RULE_SET_SURFACE = {
|
|
|
9627
9637
|
},
|
|
9628
9638
|
},
|
|
9629
9639
|
};
|
|
9630
|
-
// ── src/config-surface/group-type-config.ts ──────────────────────────────
|
|
9631
|
-
/**
|
|
9632
|
-
* The `group-type-config` configuration object's definition (issue #2644,
|
|
9633
|
-
* phase 3).
|
|
9634
|
-
*
|
|
9635
|
-
* `group-type-configs/<groupType>.toml` carries a single `[groupTypeConfig]`
|
|
9636
|
-
* table, plus the declared-access manifest's top-level `[metadata]` / `secrets`
|
|
9637
|
-
* fragments — which are `structural`: authored elsewhere in the file, with
|
|
9638
|
-
* their own validator (`validateDeclaredAccessManifest` locally,
|
|
9639
|
-
* `validateManifestShape` server-side).
|
|
9640
|
-
*
|
|
9641
|
-
* The rule-set reference is stored as `ruleSetId` but AUTHORED as
|
|
9642
|
-
* `ruleSetName`, because a name is portable across apps and an id is not. The
|
|
9643
|
-
* name → id resolution is the CLI's (`config push` resolves against the app's
|
|
9644
|
-
* rule sets); the server validates that the id exists and has
|
|
9645
|
-
* `resourceType: "group"`. The id spelling is refused on push (#3997), with
|
|
9646
|
-
* the guidance in `retired-keys.ts`.
|
|
9647
|
-
*/
|
|
9648
|
-
const GROUP_TYPE_HANDLER = "src/app-api/controllers/group-type-config-controller.ts";
|
|
9649
|
-
export const GROUP_TYPE_CONFIG_SURFACE = {
|
|
9650
|
-
label: "group-type-config",
|
|
9651
|
-
tables: [
|
|
9652
|
-
{
|
|
9653
|
-
tomlPath: ["groupTypeConfig"],
|
|
9654
|
-
repeated: false,
|
|
9655
|
-
model: "GroupTypeConfig",
|
|
9656
|
-
// Declaration order reproduces the pre-#2644 serializer's key order.
|
|
9657
|
-
fields: [
|
|
9658
|
-
{
|
|
9659
|
-
field: "groupType",
|
|
9660
|
-
tomlKey: "groupType",
|
|
9661
|
-
type: "string",
|
|
9662
|
-
emit: "always",
|
|
9663
|
-
writableOn: CREATE_ONLY,
|
|
9664
|
-
// The config's identity: required and `#`-free on create, taken from
|
|
9665
|
-
// the URL on update.
|
|
9666
|
-
validation: handledBy(GROUP_TYPE_HANDLER, "GroupTypeConfigController", "apply"),
|
|
9667
|
-
},
|
|
9668
|
-
{
|
|
9669
|
-
field: "ruleSetId",
|
|
9670
|
-
tomlKey: "ruleSetName",
|
|
9671
|
-
type: "string",
|
|
9672
|
-
emit: "always",
|
|
9673
|
-
writableOn: BOTH,
|
|
9674
|
-
// Authored as a name, sent as an id; existence and resourceType are
|
|
9675
|
-
// checked server-side, and an empty value clears the reference. The
|
|
9676
|
-
// id spelling is retired in TOML (#3997): `retired-keys.ts`,
|
|
9677
|
-
// `groupTypeConfig`.
|
|
9678
|
-
validation: handledBy(GROUP_TYPE_HANDLER, "GroupTypeConfigController", "apply"),
|
|
9679
|
-
},
|
|
9680
|
-
{
|
|
9681
|
-
field: "autoAddCreator",
|
|
9682
|
-
tomlKey: "autoAddCreator",
|
|
9683
|
-
type: "boolean",
|
|
9684
|
-
emit: "always",
|
|
9685
|
-
writableOn: BOTH,
|
|
9686
|
-
// Defaults to `true` when absent on create, and is coerced with `!!`
|
|
9687
|
-
// on update — not a stored-as-is passthrough.
|
|
9688
|
-
validation: handledBy(GROUP_TYPE_HANDLER, "GroupTypeConfigController", "apply"),
|
|
9689
|
-
},
|
|
9690
|
-
],
|
|
9691
|
-
notExposed: {
|
|
9692
|
-
appId: {
|
|
9693
|
-
kind: "server-owned",
|
|
9694
|
-
note: "Tenant scope, taken from the route; never on the wire.",
|
|
9695
|
-
},
|
|
9696
|
-
metadataManifest: {
|
|
9697
|
-
kind: "structural",
|
|
9698
|
-
note: "The declared-access manifest (#1350, extending #1304): authored " +
|
|
9699
|
-
"as the file's top-level `[metadata]` + `secrets` fragments, not " +
|
|
9700
|
-
"as a key inside [groupTypeConfig]. Validated by " +
|
|
9701
|
-
"`validateDeclaredAccessManifest` (cli/src/lib/toml-metadata-config.ts) " +
|
|
9702
|
-
"before push and `validateManifestShape` at persist time.",
|
|
9703
|
-
},
|
|
9704
|
-
createdAt: {
|
|
9705
|
-
kind: "server-owned",
|
|
9706
|
-
note: "Timestamp, assigned server-side.",
|
|
9707
|
-
},
|
|
9708
|
-
modifiedAt: {
|
|
9709
|
-
kind: "server-owned",
|
|
9710
|
-
note: "Timestamp, assigned server-side.",
|
|
9711
|
-
},
|
|
9712
|
-
createdBy: {
|
|
9713
|
-
kind: "server-owned",
|
|
9714
|
-
note: "User who created the config; assigned server-side.",
|
|
9715
|
-
},
|
|
9716
|
-
},
|
|
9717
|
-
tomlOnlyKeys: {},
|
|
9718
|
-
responseOnlyKeys: {},
|
|
9719
|
-
},
|
|
9720
|
-
],
|
|
9721
|
-
tomlDocumentKeys: { ...DECLARED_ACCESS_MANIFEST_KEYS },
|
|
9722
|
-
};
|
|
9723
|
-
// ── src/config-surface/collection-type-config.ts ─────────────────────────
|
|
9724
|
-
/**
|
|
9725
|
-
* The `collection-type-config` configuration object's definition (issue #2644,
|
|
9726
|
-
* phase 3).
|
|
9727
|
-
*
|
|
9728
|
-
* `collection-type-configs/<collectionType>.toml` carries a single
|
|
9729
|
-
* `[collectionTypeConfig]` table plus the declared-access manifest's top-level
|
|
9730
|
-
* `[metadata]` / `secrets` fragments (declared `structural`, as on every other
|
|
9731
|
-
* config that carries one).
|
|
9732
|
-
*
|
|
9733
|
-
* Same shape as `group-type-config` minus `autoAddCreator`: the rule-set
|
|
9734
|
-
* reference is stored as `ruleSetId` and authored as `ruleSetName`, and the
|
|
9735
|
-
* server checks the referenced set has `resourceType: "collection"`.
|
|
9736
|
-
*/
|
|
9737
|
-
const COLLECTION_TYPE_HANDLER = "src/app-api/controllers/collection-type-config-controller.ts";
|
|
9738
|
-
export const COLLECTION_TYPE_CONFIG_SURFACE = {
|
|
9739
|
-
label: "collection-type-config",
|
|
9740
|
-
tables: [
|
|
9741
|
-
{
|
|
9742
|
-
tomlPath: ["collectionTypeConfig"],
|
|
9743
|
-
repeated: false,
|
|
9744
|
-
model: "CollectionTypeConfig",
|
|
9745
|
-
// Declaration order reproduces the pre-#2644 serializer's key order.
|
|
9746
|
-
fields: [
|
|
9747
|
-
{
|
|
9748
|
-
field: "collectionType",
|
|
9749
|
-
tomlKey: "collectionType",
|
|
9750
|
-
type: "string",
|
|
9751
|
-
emit: "always",
|
|
9752
|
-
writableOn: CREATE_ONLY,
|
|
9753
|
-
// The config's identity: required on create, taken from the URL on
|
|
9754
|
-
// update.
|
|
9755
|
-
validation: handledBy(COLLECTION_TYPE_HANDLER, "CollectionTypeConfigController", "apply"),
|
|
9756
|
-
},
|
|
9757
|
-
{
|
|
9758
|
-
field: "ruleSetId",
|
|
9759
|
-
tomlKey: "ruleSetName",
|
|
9760
|
-
type: "string",
|
|
9761
|
-
emit: "always",
|
|
9762
|
-
writableOn: BOTH,
|
|
9763
|
-
// Authored as a name, sent as an id; existence and resourceType are
|
|
9764
|
-
// checked server-side, and an empty value clears the reference. The
|
|
9765
|
-
// id spelling is retired in TOML (#3997): `retired-keys.ts`,
|
|
9766
|
-
// `collectionTypeConfig`.
|
|
9767
|
-
validation: handledBy(COLLECTION_TYPE_HANDLER, "CollectionTypeConfigController", "apply"),
|
|
9768
|
-
},
|
|
9769
|
-
],
|
|
9770
|
-
notExposed: {
|
|
9771
|
-
appId: {
|
|
9772
|
-
kind: "server-owned",
|
|
9773
|
-
note: "Tenant scope, taken from the route; never on the wire.",
|
|
9774
|
-
},
|
|
9775
|
-
metadataManifest: {
|
|
9776
|
-
kind: "structural",
|
|
9777
|
-
note: "The declared-access manifest (#1304 P-C): authored as the file's " +
|
|
9778
|
-
"top-level `[metadata]` + `secrets` fragments, not as a key inside " +
|
|
9779
|
-
"[collectionTypeConfig]. Validated by " +
|
|
9780
|
-
"`validateDeclaredAccessManifest` (cli/src/lib/toml-metadata-config.ts) " +
|
|
9781
|
-
"before push and `validateManifestShape` at persist time.",
|
|
9782
|
-
},
|
|
9783
|
-
createdAt: {
|
|
9784
|
-
kind: "server-owned",
|
|
9785
|
-
note: "Timestamp, assigned server-side.",
|
|
9786
|
-
},
|
|
9787
|
-
modifiedAt: {
|
|
9788
|
-
kind: "server-owned",
|
|
9789
|
-
note: "Timestamp, assigned server-side.",
|
|
9790
|
-
},
|
|
9791
|
-
createdBy: {
|
|
9792
|
-
kind: "server-owned",
|
|
9793
|
-
note: "User who created the config; assigned server-side.",
|
|
9794
|
-
},
|
|
9795
|
-
},
|
|
9796
|
-
tomlOnlyKeys: {},
|
|
9797
|
-
responseOnlyKeys: {},
|
|
9798
|
-
},
|
|
9799
|
-
],
|
|
9800
|
-
tomlDocumentKeys: { ...DECLARED_ACCESS_MANIFEST_KEYS },
|
|
9801
|
-
};
|
|
9802
9640
|
// ── src/config-surface/metadata-category-config.ts ───────────────────────
|
|
9803
9641
|
/**
|
|
9804
9642
|
* The `metadata-category-config` configuration object's definition (issue
|
|
@@ -9952,47 +9790,6 @@ export const METADATA_CATEGORY_CONFIG_SURFACE = {
|
|
|
9952
9790
|
],
|
|
9953
9791
|
tomlDocumentKeys: { ...DECLARED_ACCESS_MANIFEST_KEYS },
|
|
9954
9792
|
};
|
|
9955
|
-
// ── src/config-surface/transform.ts ──────────────────────────────────────
|
|
9956
|
-
/**
|
|
9957
|
-
* The `transform` configuration object's definition (issue #2644, phase 3).
|
|
9958
|
-
*
|
|
9959
|
-
* Transforms are the one synced type with NO TOML field table: a transform is
|
|
9960
|
-
* `transforms/<name>.rhai`, a Rhai source file, and its whole authored surface
|
|
9961
|
-
* is the script body. `config pull` writes the active `ScriptConfig`'s body and
|
|
9962
|
-
* `config push` sends it back; there is no key/value table to define, and the
|
|
9963
|
-
* `Script` / `ScriptConfig` scalars around it (name, description, inputSchema,
|
|
9964
|
-
* limits, status) are not authorable through the sync slot today.
|
|
9965
|
-
*
|
|
9966
|
-
* The entry exists so that is a DECISION rather than an absence. Criterion 3's
|
|
9967
|
-
* registry guard reads `SYNC_RESOURCE_TYPES` and requires a surface per label;
|
|
9968
|
-
* without this module `transform` would have to sit in an exemption list, which
|
|
9969
|
-
* is precisely the "absent from a hand-written list" failure mode this epic
|
|
9970
|
-
* exists to end.
|
|
9971
|
-
*/
|
|
9972
|
-
export const TRANSFORM_SURFACE = {
|
|
9973
|
-
label: "transform",
|
|
9974
|
-
tables: [],
|
|
9975
|
-
// No TOML file at all, so no top-level TOML keys either — stated rather than
|
|
9976
|
-
// left to `noFieldTable` to imply.
|
|
9977
|
-
tomlDocumentKeys: {},
|
|
9978
|
-
noFieldTable: {
|
|
9979
|
-
note: "A transform is a Rhai source file (`transforms/<name>.rhai`); its " +
|
|
9980
|
-
"authored surface is the script body, which config pull writes from the " +
|
|
9981
|
-
"active ScriptConfig and config push sends back whole. The Script / " +
|
|
9982
|
-
"ScriptConfig scalars (name, description, inputSchema, limits, status) " +
|
|
9983
|
-
"are managed through `primitive transforms`, not through a TOML table, " +
|
|
9984
|
-
"so this object has no field surface to define. Its sidecar test cases " +
|
|
9985
|
-
"(`transforms/<name>.tests/`) are the separate `test-case` surface.",
|
|
9986
|
-
},
|
|
9987
|
-
noCrossFieldRules: {
|
|
9988
|
-
note: "A cross-field rule refuses a COMBINATION of authored fields, and this " +
|
|
9989
|
-
"object has no field table at all (see `noFieldTable`) — there are no " +
|
|
9990
|
-
"two fields to cross. The Rhai body's own validity is the transform " +
|
|
9991
|
-
"compiler's answer, not a configuration rule. Stated rather than left " +
|
|
9992
|
-
"absent, so `transform` is a decision instead of the one surface nobody " +
|
|
9993
|
-
"got to (#3373).",
|
|
9994
|
-
},
|
|
9995
|
-
};
|
|
9996
9793
|
// ── src/config-surface/server-function.ts ────────────────────────────────
|
|
9997
9794
|
/**
|
|
9998
9795
|
* The `function` configuration object's definition (#3179, project
|
|
@@ -10058,7 +9855,7 @@ const functionRules = (stage, modulePath, exportName, entries) => entries.map(([
|
|
|
10058
9855
|
/** The trigger blocks' shape rules — one id per refusal (#3181, #3184, #3334). */
|
|
10059
9856
|
const TRIGGER_DECLARATION_RULES = functionRules("preflight", "src/config-surface/trigger-declaration.ts", "normalizeTriggerDeclaration", [
|
|
10060
9857
|
["triggers-table", "`[function.triggers]` must be a table."],
|
|
10061
|
-
["trigger-kind", "Only `webhook` and `
|
|
9858
|
+
["trigger-kind", "Only `webhook`, `cron` and `db3` are trigger kinds."],
|
|
10062
9859
|
[
|
|
10063
9860
|
"database-trigger-removed",
|
|
10064
9861
|
"`[[function.triggers.database]]` is refused: the trigger was removed " +
|
|
@@ -10084,6 +9881,16 @@ const TRIGGER_DECLARATION_RULES = functionRules("preflight", "src/config-surface
|
|
|
10084
9881
|
"webhook-trigger-verification-table",
|
|
10085
9882
|
"`[function.triggers.webhook.verification]` must be a table.",
|
|
10086
9883
|
],
|
|
9884
|
+
[
|
|
9885
|
+
"webhook-trigger-handshake-rules",
|
|
9886
|
+
"`[[function.triggers.webhook.handshakeRules]]` entries carry a CEL " +
|
|
9887
|
+
"`when` and a `response` table (`status`, `contentType`, `body`).",
|
|
9888
|
+
],
|
|
9889
|
+
[
|
|
9890
|
+
"webhook-trigger-ip-allowlist",
|
|
9891
|
+
"`allowedIpCidrs` lists IPv4 addresses or CIDR prefixes the receiver " +
|
|
9892
|
+
"can match.",
|
|
9893
|
+
],
|
|
10087
9894
|
["cron-trigger-cap", "A function declares at most ten cron entries."],
|
|
10088
9895
|
["cron-trigger-entry", "Each `[[function.triggers.cron]]` entry is a table."],
|
|
10089
9896
|
["cron-trigger-keys", "A cron entry accepts only its declared keys."],
|
|
@@ -10091,10 +9898,23 @@ const TRIGGER_DECLARATION_RULES = functionRules("preflight", "src/config-surface
|
|
|
10091
9898
|
"cron-trigger-name-required",
|
|
10092
9899
|
"A cron entry names itself: the name is half of its trigger key.",
|
|
10093
9900
|
],
|
|
10094
|
-
["cron-trigger-name-charset", "A cron name uses
|
|
9901
|
+
["cron-trigger-name-charset", "A cron name starts with a letter or digit and uses letters, digits, `_` and `-`."],
|
|
10095
9902
|
["cron-trigger-duplicate", "Each cron name appears once within the function."],
|
|
10096
9903
|
["cron-trigger-expression-required", "A cron entry carries a `cron` expression."],
|
|
10097
9904
|
["cron-trigger-overlap-policy", "`overlapPolicy` is `skip` or `allow`."],
|
|
9905
|
+
["db3-trigger-cap", "A function watches at most ten db3 types."],
|
|
9906
|
+
["db3-trigger-entry", "Each `[[function.triggers.db3]]` entry is a table."],
|
|
9907
|
+
["db3-trigger-keys", "A db3 trigger entry accepts only `type`."],
|
|
9908
|
+
[
|
|
9909
|
+
"db3-trigger-type-required",
|
|
9910
|
+
"A db3 trigger entry names the db3 type it watches: a non-empty string " +
|
|
9911
|
+
"without `#`.",
|
|
9912
|
+
],
|
|
9913
|
+
[
|
|
9914
|
+
"db3-trigger-type-reserved",
|
|
9915
|
+
"A db3 trigger entry does not name a type starting `primitive:`: those are the platform's.",
|
|
9916
|
+
],
|
|
9917
|
+
["db3-trigger-duplicate", "Each db3 type appears once within the function."],
|
|
10098
9918
|
]);
|
|
10099
9919
|
/**
|
|
10100
9920
|
* The retired runtime keys (#3188). `mode`, `durable` and a cron entry's
|
|
@@ -10112,9 +9932,7 @@ const RETIRED_RUNTIME_KEY_RULES = functionRules("preflight", "src/config-surface
|
|
|
10112
9932
|
]);
|
|
10113
9933
|
/**
|
|
10114
9934
|
* The file-decidable half of the webhook `signingSecret` rule (#3320). The
|
|
10115
|
-
*
|
|
10116
|
-
* `webhook` surface, whose CLI path does not run it: stage is a property of
|
|
10117
|
-
* the (surface, rule) pair.
|
|
9935
|
+
* standalone `webhook` surface that also declared it retired with #3190.
|
|
10118
9936
|
*/
|
|
10119
9937
|
const SIGNING_SECRET_RULES = functionRules("preflight", "src/config-surface/webhook-signing-secret.ts", "validateSigningSecretDeclaration", [
|
|
10120
9938
|
[
|
|
@@ -10157,25 +9975,63 @@ const CRON_SCHEDULE_RULES = functionRules("preflight", "src/config-surface/cron-
|
|
|
10157
9975
|
const FUNCTION_TRIGGER_STATE_RULES = functionRules("apply", "src/services/function-trigger-validation.ts", "validateFunctionTriggerDeclaration", [
|
|
10158
9976
|
[
|
|
10159
9977
|
"webhook-trigger-settings",
|
|
10160
|
-
"The webhook block's verification settings pass the
|
|
10161
|
-
"
|
|
10162
|
-
"
|
|
9978
|
+
"The webhook block's verification settings pass the shared settings " +
|
|
9979
|
+
"pipeline (scheme config, replay protection, secret existence), " +
|
|
9980
|
+
"prefixed `[function.triggers.webhook]: `.",
|
|
10163
9981
|
],
|
|
10164
9982
|
[
|
|
10165
9983
|
"webhook-trigger-key-held",
|
|
10166
|
-
"
|
|
10167
|
-
"trigger — nobody else's
|
|
9984
|
+
"Another function's trigger row on the function's key blocks the " +
|
|
9985
|
+
"trigger — nobody else's trigger is rewritten.",
|
|
10168
9986
|
],
|
|
10169
9987
|
[
|
|
10170
9988
|
"function-webhook-cap",
|
|
10171
9989
|
"The per-app webhook cap, measured prospectively over what this push " +
|
|
10172
|
-
"would add
|
|
9990
|
+
"would add.",
|
|
10173
9991
|
],
|
|
10174
9992
|
[
|
|
10175
9993
|
"function-cron-cap",
|
|
10176
9994
|
"The per-app cron-trigger cap, measured prospectively over what this " +
|
|
10177
9995
|
"push would add.",
|
|
10178
9996
|
],
|
|
9997
|
+
[
|
|
9998
|
+
"function-db3-trigger-cap",
|
|
9999
|
+
"The per-app db3-trigger cap (fifty rows, archived included), measured " +
|
|
10000
|
+
"prospectively over what this push would add.",
|
|
10001
|
+
],
|
|
10002
|
+
]);
|
|
10003
|
+
/**
|
|
10004
|
+
* The shared verification-settings pipeline the webhook block passes, by its
|
|
10005
|
+
* own rule ids (#3374). `webhook-trigger-settings` above is the refusal the
|
|
10006
|
+
* push renders; these name which rule inside the pipeline refused. The
|
|
10007
|
+
* standalone `webhook` surface declared them until #3190 retired it, which
|
|
10008
|
+
* left the function push the pipeline's one caller.
|
|
10009
|
+
*/
|
|
10010
|
+
const WEBHOOK_SETTINGS_RULES = functionRules("apply", "src/app-api/services/webhook-settings-validation.ts", "validateWebhookSettings", [
|
|
10011
|
+
["verification-scheme-required", "A webhook names its `verificationScheme`."],
|
|
10012
|
+
["verification-scheme-value", "The scheme is one the receiver knows."],
|
|
10013
|
+
[
|
|
10014
|
+
"verification-config",
|
|
10015
|
+
"The scheme's `config` is valid for that scheme under this " +
|
|
10016
|
+
"environment's JWKS policy, and carries no literal credential.",
|
|
10017
|
+
],
|
|
10018
|
+
[
|
|
10019
|
+
"replay-protection",
|
|
10020
|
+
"A signed scheme keeps deduplication on, with a window and tolerance " +
|
|
10021
|
+
"in range and long enough to cover the signature's freshness window.",
|
|
10022
|
+
],
|
|
10023
|
+
[
|
|
10024
|
+
"signing-secret-exists",
|
|
10025
|
+
"The app secret a `signingSecret` reference names must exist, so a " +
|
|
10026
|
+
"missing key fails the push rather than the first delivery — unless " +
|
|
10027
|
+
"the push carries the reference unchanged (#2109).",
|
|
10028
|
+
],
|
|
10029
|
+
[
|
|
10030
|
+
"verification-config-secrets-exist",
|
|
10031
|
+
"Every secret reference the active scheme's `config` resolves at " +
|
|
10032
|
+
"delivery must name an existing app secret — unless the push carries " +
|
|
10033
|
+
"it unchanged (#2109).",
|
|
10034
|
+
],
|
|
10179
10035
|
]);
|
|
10180
10036
|
export const SERVER_FUNCTION_SURFACE = {
|
|
10181
10037
|
label: "function",
|
|
@@ -10193,18 +10049,6 @@ export const SERVER_FUNCTION_SURFACE = {
|
|
|
10193
10049
|
writableOn: BOTH,
|
|
10194
10050
|
validation: "passthrough",
|
|
10195
10051
|
},
|
|
10196
|
-
{
|
|
10197
|
-
field: "access",
|
|
10198
|
-
tomlKey: "access",
|
|
10199
|
-
type: "string",
|
|
10200
|
-
emit: "always",
|
|
10201
|
-
writableOn: BOTH,
|
|
10202
|
-
// A CEL expression, and REQUIRED before code can be pushed: a
|
|
10203
|
-
// function with no gate fails closed at invoke, so accepting a bundle
|
|
10204
|
-
// for one would report a successful push of something that can never
|
|
10205
|
-
// run.
|
|
10206
|
-
validation: handledBy(FUNCTION_HANDLER, "ServerFunctionsController", "apply"),
|
|
10207
|
-
},
|
|
10208
10052
|
{
|
|
10209
10053
|
field: "inputSchema",
|
|
10210
10054
|
tomlKey: "inputSchema",
|
|
@@ -10274,6 +10118,14 @@ export const SERVER_FUNCTION_SURFACE = {
|
|
|
10274
10118
|
"scan or sees the lease. Held for minutes at a time by one " +
|
|
10275
10119
|
"request, never authored and never pulled.",
|
|
10276
10120
|
},
|
|
10121
|
+
access: {
|
|
10122
|
+
kind: "server-owned",
|
|
10123
|
+
note: "The header's CEL gate, FROZEN at its last value (#4738): a " +
|
|
10124
|
+
"version without `authorize` (a legacy version) still runs it, " +
|
|
10125
|
+
"including after it is re-activated, and no route sets or changes " +
|
|
10126
|
+
"it. Never on the wire, never compared and never pulled; its TOML " +
|
|
10127
|
+
"spelling is declared in tomlOnlyKeys.",
|
|
10128
|
+
},
|
|
10277
10129
|
createdBy: {
|
|
10278
10130
|
kind: "server-owned",
|
|
10279
10131
|
note: "Admin who created the function; assigned server-side.",
|
|
@@ -10346,6 +10198,23 @@ export const SERVER_FUNCTION_SURFACE = {
|
|
|
10346
10198
|
"the file a human reviews is the authority — a push cannot store a " +
|
|
10347
10199
|
"capability the TOML does not declare.",
|
|
10348
10200
|
},
|
|
10201
|
+
access: {
|
|
10202
|
+
kind: "deprecated",
|
|
10203
|
+
note: "`access = \"…\"` — superseded by the entry's `authorize` (#4738). " +
|
|
10204
|
+
"Accepted so an untouched legacy tree still validates and reaches " +
|
|
10205
|
+
"the envelope comparison, where an unchanged envelope is a no-op. " +
|
|
10206
|
+
"Never sent; a new version that carries it beside `authorize` is " +
|
|
10207
|
+
"refused as ambiguous.",
|
|
10208
|
+
},
|
|
10209
|
+
public: {
|
|
10210
|
+
kind: "structural",
|
|
10211
|
+
note: "`public = true` (#4730) — the opt-in that confirms a function " +
|
|
10212
|
+
"whose authorize admits anyone (`allowAnyone()`) may write: " +
|
|
10213
|
+
"without it, such a write-capable version is refused at push. A " +
|
|
10214
|
+
"boolean, read from these authored bytes by the CLI preflight and " +
|
|
10215
|
+
"by the server from the envelope's TOML; never stored on its own, " +
|
|
10216
|
+
"and it changes nothing for any other function.",
|
|
10217
|
+
},
|
|
10349
10218
|
},
|
|
10350
10219
|
responseOnlyKeys: {},
|
|
10351
10220
|
},
|
|
@@ -10367,16 +10236,66 @@ export const SERVER_FUNCTION_SURFACE = {
|
|
|
10367
10236
|
// `functionTomlPreflightErrors` runs them in.
|
|
10368
10237
|
...CRON_SCHEDULE_RULES,
|
|
10369
10238
|
...FUNCTION_TRIGGER_STATE_RULES,
|
|
10239
|
+
...WEBHOOK_SETTINGS_RULES,
|
|
10370
10240
|
],
|
|
10371
10241
|
};
|
|
10242
|
+
// ── The break's sentences ───────────────────────────────────────────────────
|
|
10243
|
+
//
|
|
10244
|
+
// Said once here and vendored into the CLI, so the push preflight and the
|
|
10245
|
+
// server's refusal are the same words (#4738).
|
|
10246
|
+
// Spelled through a constant: this directory's import guard reads any quoted
|
|
10247
|
+
// module name after `from` as an import.
|
|
10248
|
+
const SDK_MODULE = JSON.stringify("primitive-functions");
|
|
10249
|
+
/**
|
|
10250
|
+
* The refusal of a new version whose default export has no `authorize`: it
|
|
10251
|
+
* names the function and shows the object form with the function's key. A
|
|
10252
|
+
* `file` prefixes the sentence the way the CLI reports a file it refuses.
|
|
10253
|
+
*/
|
|
10254
|
+
export function authorizeRequiredMessage(functionKey, file) {
|
|
10255
|
+
const message = `Function '${functionKey}' has no \`authorize\`: every new version must define one. ` +
|
|
10256
|
+
"Export the object form:\n\n" +
|
|
10257
|
+
` import { defineFunction, requireSignedIn } from ${SDK_MODULE};\n\n` +
|
|
10258
|
+
` export default defineFunction(${JSON.stringify(functionKey)}, {\n` +
|
|
10259
|
+
" authorize: requireSignedIn(),\n" +
|
|
10260
|
+
" handler: async (input, ctx) => { /* ... */ },\n" +
|
|
10261
|
+
" });\n\n" +
|
|
10262
|
+
"The deployed version keeps running under its stored `access` rule until a " +
|
|
10263
|
+
"version with `authorize` is pushed. The access-control guide's porting table " +
|
|
10264
|
+
"maps each `access` expression to a helper.";
|
|
10265
|
+
return file ? `${file}: ${message}` : message;
|
|
10266
|
+
}
|
|
10267
|
+
/**
|
|
10268
|
+
* The refusal of a version that declares `public = true` and has no
|
|
10269
|
+
* `authorize` — #5840. `public = true` opens the function to signed-out
|
|
10270
|
+
* callers, and the version's own `authorize` is what decides about them.
|
|
10271
|
+
*/
|
|
10272
|
+
export function publicRequiresAuthorizeMessage(functionKey, file) {
|
|
10273
|
+
const message = `Function '${functionKey}' declares \`public = true\` and has no \`authorize\`: ` +
|
|
10274
|
+
"a public function decides who may call it, signed-out callers included, in its own " +
|
|
10275
|
+
"`authorize`. Export the object form with one, such as `authorize: allowAnyone()`, " +
|
|
10276
|
+
`or remove \`public\` from functions/${functionKey}.toml.`;
|
|
10277
|
+
return file ? `${file}: ${message}` : message;
|
|
10278
|
+
}
|
|
10279
|
+
/**
|
|
10280
|
+
* The refusal of a new version that defines `authorize` while its TOML still
|
|
10281
|
+
* carries `access`.
|
|
10282
|
+
*/
|
|
10283
|
+
export function accessAmbiguousMessage(functionKey) {
|
|
10284
|
+
return (`Function '${functionKey}' defines \`authorize\` and its TOML still carries ` +
|
|
10285
|
+
"`access`: the two would disagree about who may run it. " +
|
|
10286
|
+
`Remove \`access\` from functions/${functionKey}.toml; \`authorize\` decides.`);
|
|
10287
|
+
}
|
|
10288
|
+
/** The refusal of a create or update body that carries `access`. */
|
|
10289
|
+
export const FUNCTION_ACCESS_FROZEN_REQUEST = "`access` is frozen: a function's stored rule is kept for its legacy versions " +
|
|
10290
|
+
"and can no longer be set or changed. Omit the field; the version's `authorize` " +
|
|
10291
|
+
"decides who may run it.";
|
|
10372
10292
|
// ── src/config-surface/test-case.ts ──────────────────────────────────────
|
|
10373
10293
|
/**
|
|
10374
10294
|
* The `test-case` configuration object's definition (issue #2644, phase 3).
|
|
10375
10295
|
*
|
|
10376
10296
|
* Test cases round-trip without being one of the per-entity directories: they
|
|
10377
10297
|
* live in a sidecar `<key>.tests/` folder beside the block they test — a
|
|
10378
|
-
* prompt
|
|
10379
|
-
* `[test]` table per file. They are not
|
|
10298
|
+
* prompt or (since #2769) an integration — one `[test]` table per file. They are not
|
|
10380
10299
|
* a `SYNC_RESOURCE_TYPES` label (that table is per-entity directory metadata),
|
|
10381
10300
|
* which is exactly why the spec names them explicitly: nothing that syncs sits
|
|
10382
10301
|
* outside the registry.
|
|
@@ -10610,8 +10529,7 @@ export const TEST_CASE_SURFACE = {
|
|
|
10610
10529
|
blockType: {
|
|
10611
10530
|
kind: "structural",
|
|
10612
10531
|
requestModes: [],
|
|
10613
|
-
note: "Which kind of block the case tests (prompt |
|
|
10614
|
-
"integration). " +
|
|
10532
|
+
note: "Which kind of block the case tests (prompt | integration). " +
|
|
10615
10533
|
"Comes from the directory the `<key>.tests/` folder sits in and " +
|
|
10616
10534
|
"travels in the URL path, not in the body.",
|
|
10617
10535
|
},
|
|
@@ -10787,6 +10705,32 @@ export const APP_SETTINGS_SURFACE = {
|
|
|
10787
10705
|
// (`parseRootDocumentFormatSetting`).
|
|
10788
10706
|
validation: handledBy(SETTINGS_HANDLER, "SettingsController", "apply"),
|
|
10789
10707
|
},
|
|
10708
|
+
{
|
|
10709
|
+
field: "signedOutAccess",
|
|
10710
|
+
tomlKey: "signedOutAccess",
|
|
10711
|
+
type: "boolean",
|
|
10712
|
+
// Always: a pulled file states whether signed-out callers may
|
|
10713
|
+
// invoke the app's `public` functions, rather than leaving it to the
|
|
10714
|
+
// absence of a key (#5840).
|
|
10715
|
+
emit: "always",
|
|
10716
|
+
writableOn: UPDATE_ONLY,
|
|
10717
|
+
// A boolean, refused otherwise; the route answers the functions
|
|
10718
|
+
// turning it on opens (`signedOutFunctions`).
|
|
10719
|
+
validation: handledBy(SETTINGS_HANDLER, "SettingsController", "apply"),
|
|
10720
|
+
},
|
|
10721
|
+
{
|
|
10722
|
+
field: "allowFieldRemoval",
|
|
10723
|
+
tomlKey: "allowFieldRemoval",
|
|
10724
|
+
type: "boolean",
|
|
10725
|
+
// Whenever the app set it. An app that never did may not remove
|
|
10726
|
+
// fields from an in-use db3 type, and a pulled file should not grow
|
|
10727
|
+
// a key for it (#6019).
|
|
10728
|
+
emit: "whenSet",
|
|
10729
|
+
writableOn: UPDATE_ONLY,
|
|
10730
|
+
// A boolean or cleared, refused otherwise; a type write reads the
|
|
10731
|
+
// stored value before it takes `allowFieldRemoval=true`.
|
|
10732
|
+
validation: handledBy(SETTINGS_HANDLER, "SettingsController", "apply"),
|
|
10733
|
+
},
|
|
10790
10734
|
{
|
|
10791
10735
|
field: "protection",
|
|
10792
10736
|
tomlKey: "protection",
|
|
@@ -10875,6 +10819,11 @@ export const APP_SETTINGS_SURFACE = {
|
|
|
10875
10819
|
kind: "server-owned",
|
|
10876
10820
|
note: "When the app last saw counted activity; written by the server.",
|
|
10877
10821
|
},
|
|
10822
|
+
transitions: {
|
|
10823
|
+
kind: "server-owned",
|
|
10824
|
+
note: "The app's platform transition overrides (#5821); set only by a " +
|
|
10825
|
+
"super-admin through the transitions routes, so sync never sees it.",
|
|
10826
|
+
},
|
|
10878
10827
|
passkeyRpId: {
|
|
10879
10828
|
kind: "server-owned",
|
|
10880
10829
|
note: "RETIRED from the write surface by #2891, superseded by " +
|
|
@@ -11161,6 +11110,79 @@ export const APP_SETTINGS_SURFACE = {
|
|
|
11161
11110
|
// top-level key. (App config VARS live in their own `vars.toml`.)
|
|
11162
11111
|
tomlDocumentKeys: {},
|
|
11163
11112
|
};
|
|
11113
|
+
// ── src/config-surface/user-properties.ts ────────────────────────────────
|
|
11114
|
+
/**
|
|
11115
|
+
* The `user-properties` configuration object's definition (#5385, project
|
|
11116
|
+
* `user-index-properties` phase 2).
|
|
11117
|
+
*
|
|
11118
|
+
* `user-properties.toml` is a root singleton beside `app.toml`, so — like
|
|
11119
|
+
* `app-settings` and `test-case` — it is named explicitly rather than reached
|
|
11120
|
+
* through `SYNC_RESOURCE_TYPES`. Its keys are the app's own: each
|
|
11121
|
+
* `[fields.<name>]` table declares a property in the db3 field grammar plus
|
|
11122
|
+
* `client`, and each `[[unique_constraints]]` entry names two or more of them.
|
|
11123
|
+
* There is no fixed key/value table to define, so the surface declares
|
|
11124
|
+
* `noFieldTable`; the file is parsed, normalized and judged by one module,
|
|
11125
|
+
* `src/user-index/properties-schema.ts`, which the CLI vendors byte for byte
|
|
11126
|
+
* (`cli/src/lib/user-properties/generated-properties-schema.ts`) and which
|
|
11127
|
+
* `config push`'s preflight runs before anything is applied. The pushed
|
|
11128
|
+
* schema is stored on the app's `UserPropertiesConfig` row.
|
|
11129
|
+
*/
|
|
11130
|
+
export const USER_PROPERTIES_SURFACE = {
|
|
11131
|
+
label: "user-properties",
|
|
11132
|
+
tables: [],
|
|
11133
|
+
noFieldTable: {
|
|
11134
|
+
note: "Every key under [fields] is a property name the app declares; the field grammar, the client values and the " +
|
|
11135
|
+
"constraint rules are the schema module's (src/user-index/properties-schema.ts), run by config push's preflight " +
|
|
11136
|
+
"through its vendored copy and again by the push route",
|
|
11137
|
+
},
|
|
11138
|
+
tomlDocumentKeys: {
|
|
11139
|
+
fields: {
|
|
11140
|
+
kind: "structural",
|
|
11141
|
+
note: "[fields.<name>] tables: one property each, parsed whole by parseUserPropertiesToml and sent as the file's text",
|
|
11142
|
+
},
|
|
11143
|
+
unique_constraints: {
|
|
11144
|
+
kind: "structural",
|
|
11145
|
+
note: "[[unique_constraints]] entries { name, fields }, parsed whole by parseUserPropertiesToml with the fields",
|
|
11146
|
+
},
|
|
11147
|
+
},
|
|
11148
|
+
noCrossFieldRules: {
|
|
11149
|
+
note: "The file's rules span fields and constraints but are not field-table rules: parseUserPropertiesToml " +
|
|
11150
|
+
"(src/user-index/properties-schema.ts) decides every one, from the file alone, at config push's preflight",
|
|
11151
|
+
},
|
|
11152
|
+
};
|
|
11153
|
+
// ── src/config-surface/schema-file.ts ────────────────────────────────────
|
|
11154
|
+
/**
|
|
11155
|
+
* The `schema` configuration object's definition (#5532, project
|
|
11156
|
+
* `unified-schemas` phase 3).
|
|
11157
|
+
*
|
|
11158
|
+
* `schemas/<file>.toml` holds shared shapes: each `[defs.<Name>]` table is
|
|
11159
|
+
* one JSON Schema document, named by the file's stem and the def's name
|
|
11160
|
+
* (`schemas:<file>#/$defs/<Name>`). There is no fixed key/value table to
|
|
11161
|
+
* define, so the surface declares `noFieldTable`; the file is checked and
|
|
11162
|
+
* compiled by one module, `src/function-runs/schema-file.ts`, which the CLI
|
|
11163
|
+
* vendors (`cli/src/lib/schema-codegen/generated-schema-file.ts`), runs in
|
|
11164
|
+
* `config push`'s preflight and sends compiled with the source, and which the
|
|
11165
|
+
* push route runs again.
|
|
11166
|
+
*/
|
|
11167
|
+
export const SCHEMA_FILE_SURFACE = {
|
|
11168
|
+
label: "schema",
|
|
11169
|
+
tables: [],
|
|
11170
|
+
noFieldTable: {
|
|
11171
|
+
note: "Every key under [defs] is a def name the file declares, and each def is a JSON Schema document; the shape, " +
|
|
11172
|
+
"keyword and compile rules are the schemas/ file module's (src/function-runs/schema-file.ts), run by config " +
|
|
11173
|
+
"push's preflight through its vendored copy and again by the push route",
|
|
11174
|
+
},
|
|
11175
|
+
tomlDocumentKeys: {
|
|
11176
|
+
defs: {
|
|
11177
|
+
kind: "structural",
|
|
11178
|
+
note: "[defs.<Name>] tables: one shared shape each, compiled whole by compileSchemaFile and sent as the file's text",
|
|
11179
|
+
},
|
|
11180
|
+
},
|
|
11181
|
+
noCrossFieldRules: {
|
|
11182
|
+
note: "The file's rules span defs but are not field-table rules: compileSchemaFile (src/function-runs/schema-file.ts) " +
|
|
11183
|
+
"decides every one, from the file alone, at config push's preflight",
|
|
11184
|
+
},
|
|
11185
|
+
};
|
|
11164
11186
|
// ── src/config-surface/index.ts ──────────────────────────────────────────
|
|
11165
11187
|
/**
|
|
11166
11188
|
* The configuration-object registry (issue #2644).
|
|
@@ -11178,30 +11200,28 @@ export const APP_SETTINGS_SURFACE = {
|
|
|
11178
11200
|
/**
|
|
11179
11201
|
* Every configuration object whose field surface is defined here.
|
|
11180
11202
|
*
|
|
11181
|
-
* One entry per `SYNC_RESOURCE_TYPES` label, plus the
|
|
11182
|
-
* round-trip without being a per-entity file: `app-settings` (`app.toml`)
|
|
11183
|
-
* `
|
|
11203
|
+
* One entry per `SYNC_RESOURCE_TYPES` label, plus the three surfaces that
|
|
11204
|
+
* round-trip without being a per-entity file: `app-settings` (`app.toml`),
|
|
11205
|
+
* `user-properties` (`user-properties.toml`, #5385) and `test-case`
|
|
11206
|
+
* (`<key>.tests/`). Nothing that syncs sits outside the registry —
|
|
11184
11207
|
* `PENDING_MIGRATION`, the migration's temporary exemption list, is gone as of
|
|
11185
11208
|
* phase 3, so a new synced type has nowhere to be parked and fails the registry
|
|
11186
11209
|
* guard until it is defined (#2644 criterion 3).
|
|
11187
11210
|
*/
|
|
11188
11211
|
export const CONFIG_SURFACES = [
|
|
11189
|
-
WORKFLOW_SURFACE,
|
|
11190
11212
|
PROMPT_SURFACE,
|
|
11191
11213
|
INTEGRATION_SURFACE,
|
|
11192
|
-
WEBHOOK_SURFACE,
|
|
11193
|
-
CRON_TRIGGER_SURFACE,
|
|
11194
11214
|
BLOB_BUCKET_SURFACE,
|
|
11195
11215
|
EMAIL_TEMPLATE_SURFACE,
|
|
11196
11216
|
DATABASE_TYPE_SURFACE,
|
|
11217
|
+
DB3_TYPE_SURFACE,
|
|
11197
11218
|
RULE_SET_SURFACE,
|
|
11198
|
-
GROUP_TYPE_CONFIG_SURFACE,
|
|
11199
|
-
COLLECTION_TYPE_CONFIG_SURFACE,
|
|
11200
11219
|
METADATA_CATEGORY_CONFIG_SURFACE,
|
|
11201
|
-
TRANSFORM_SURFACE,
|
|
11202
11220
|
SERVER_FUNCTION_SURFACE,
|
|
11203
11221
|
TEST_CASE_SURFACE,
|
|
11204
11222
|
APP_SETTINGS_SURFACE,
|
|
11223
|
+
USER_PROPERTIES_SURFACE,
|
|
11224
|
+
SCHEMA_FILE_SURFACE,
|
|
11205
11225
|
];
|
|
11206
11226
|
/**
|
|
11207
11227
|
* The configuration surfaces that have not declared their CROSS-FIELD rules yet
|
|
@@ -11223,13 +11243,10 @@ export const CONFIG_SURFACES = [
|
|
|
11223
11243
|
export const CROSS_FIELD_RULES_UNMIGRATED = [
|
|
11224
11244
|
"prompt",
|
|
11225
11245
|
"integration",
|
|
11226
|
-
"cron-trigger",
|
|
11227
11246
|
"blob-bucket",
|
|
11228
11247
|
"email-template",
|
|
11229
11248
|
"database-type-config",
|
|
11230
11249
|
"rule-set",
|
|
11231
|
-
"group-type-config",
|
|
11232
|
-
"collection-type-config",
|
|
11233
11250
|
"metadata-category-config",
|
|
11234
11251
|
"test-case",
|
|
11235
11252
|
"app-settings",
|
|
@@ -11301,6 +11318,8 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
|
|
|
11301
11318
|
"memberInvitationLimit",
|
|
11302
11319
|
"largeDocumentWindowDays",
|
|
11303
11320
|
"rootDocumentFormat",
|
|
11321
|
+
"signedOutAccess",
|
|
11322
|
+
"allowFieldRemoval",
|
|
11304
11323
|
"protection",
|
|
11305
11324
|
"protected",
|
|
11306
11325
|
"parentAppId",
|
|
@@ -11315,6 +11334,7 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
|
|
|
11315
11334
|
"previewOrigins",
|
|
11316
11335
|
"childPartition",
|
|
11317
11336
|
"lastActivityAt",
|
|
11337
|
+
"transitions",
|
|
11318
11338
|
"createdAt",
|
|
11319
11339
|
"modifiedAt",
|
|
11320
11340
|
],
|
|
@@ -11347,6 +11367,10 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
|
|
|
11347
11367
|
"copiedFromCatalogId",
|
|
11348
11368
|
"inputSchema",
|
|
11349
11369
|
"outputSchema",
|
|
11370
|
+
"schemaSource",
|
|
11371
|
+
"schemaSourceR2Key",
|
|
11372
|
+
"schemaProvenance",
|
|
11373
|
+
"schemaProvenanceR2Key",
|
|
11350
11374
|
"activeConfigId",
|
|
11351
11375
|
"defaultEvaluatorPromptId",
|
|
11352
11376
|
"status",
|
|
@@ -11373,6 +11397,10 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
|
|
|
11373
11397
|
"maxTokens",
|
|
11374
11398
|
"outputFormat",
|
|
11375
11399
|
"outputSchema",
|
|
11400
|
+
"schemaSource",
|
|
11401
|
+
"schemaSourceR2Key",
|
|
11402
|
+
"schemaProvenance",
|
|
11403
|
+
"schemaProvenanceR2Key",
|
|
11376
11404
|
"providerConfig",
|
|
11377
11405
|
"questions",
|
|
11378
11406
|
"reasoningEffort",
|
|
@@ -11383,36 +11411,6 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
|
|
|
11383
11411
|
"createdAt",
|
|
11384
11412
|
"modifiedAt",
|
|
11385
11413
|
],
|
|
11386
|
-
"AppWebhook": [
|
|
11387
|
-
"webhookId",
|
|
11388
|
-
"appId",
|
|
11389
|
-
"webhookKey",
|
|
11390
|
-
"displayName",
|
|
11391
|
-
"description",
|
|
11392
|
-
"status",
|
|
11393
|
-
"workflowKey",
|
|
11394
|
-
"workflowId",
|
|
11395
|
-
"verificationScheme",
|
|
11396
|
-
"signingSecret",
|
|
11397
|
-
"previousSigningSecret",
|
|
11398
|
-
"secretRotatedAt",
|
|
11399
|
-
"functionId",
|
|
11400
|
-
"declaredSigningSecret",
|
|
11401
|
-
"secretGracePeriodMs",
|
|
11402
|
-
"toleranceSeconds",
|
|
11403
|
-
"deduplicationEnabled",
|
|
11404
|
-
"deduplicationWindowMs",
|
|
11405
|
-
"maxBodyBytes",
|
|
11406
|
-
"inputMapping",
|
|
11407
|
-
"allowedIpCidrs",
|
|
11408
|
-
"handshakeRules",
|
|
11409
|
-
"config",
|
|
11410
|
-
"metadata",
|
|
11411
|
-
"lastTriggeredAt",
|
|
11412
|
-
"createdBy",
|
|
11413
|
-
"createdAt",
|
|
11414
|
-
"modifiedAt",
|
|
11415
|
-
],
|
|
11416
11414
|
"BlobBucket": [
|
|
11417
11415
|
"bucketId",
|
|
11418
11416
|
"appId",
|
|
@@ -11455,42 +11453,6 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
|
|
|
11455
11453
|
"createdAt",
|
|
11456
11454
|
"modifiedAt",
|
|
11457
11455
|
],
|
|
11458
|
-
"CollectionTypeConfig": [
|
|
11459
|
-
"appId",
|
|
11460
|
-
"collectionType",
|
|
11461
|
-
"ruleSetId",
|
|
11462
|
-
"metadataManifest",
|
|
11463
|
-
"createdAt",
|
|
11464
|
-
"modifiedAt",
|
|
11465
|
-
"createdBy",
|
|
11466
|
-
],
|
|
11467
|
-
"CronTrigger": [
|
|
11468
|
-
"triggerId",
|
|
11469
|
-
"appId",
|
|
11470
|
-
"triggerKey",
|
|
11471
|
-
"displayName",
|
|
11472
|
-
"description",
|
|
11473
|
-
"cron",
|
|
11474
|
-
"timezone",
|
|
11475
|
-
"workflowKey",
|
|
11476
|
-
"functionId",
|
|
11477
|
-
"overlapPolicy",
|
|
11478
|
-
"rootInput",
|
|
11479
|
-
"inputMapping",
|
|
11480
|
-
"status",
|
|
11481
|
-
"state",
|
|
11482
|
-
"operationallyDisabled",
|
|
11483
|
-
"lastError",
|
|
11484
|
-
"lastTriggeredAt",
|
|
11485
|
-
"lastTriggeredRunId",
|
|
11486
|
-
"skippedCount",
|
|
11487
|
-
"firedCount",
|
|
11488
|
-
"consecutiveNotActiveCount",
|
|
11489
|
-
"nextFireAt",
|
|
11490
|
-
"createdBy",
|
|
11491
|
-
"createdAt",
|
|
11492
|
-
"modifiedAt",
|
|
11493
|
-
],
|
|
11494
11456
|
"DatabaseTypeConfig": [
|
|
11495
11457
|
"appId",
|
|
11496
11458
|
"databaseType",
|
|
@@ -11515,16 +11477,6 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
|
|
|
11515
11477
|
"createdAt",
|
|
11516
11478
|
"modifiedAt",
|
|
11517
11479
|
],
|
|
11518
|
-
"GroupTypeConfig": [
|
|
11519
|
-
"appId",
|
|
11520
|
-
"groupType",
|
|
11521
|
-
"ruleSetId",
|
|
11522
|
-
"metadataManifest",
|
|
11523
|
-
"autoAddCreator",
|
|
11524
|
-
"createdAt",
|
|
11525
|
-
"modifiedAt",
|
|
11526
|
-
"createdBy",
|
|
11527
|
-
],
|
|
11528
11480
|
"MetadataCategoryConfig": [
|
|
11529
11481
|
"appId",
|
|
11530
11482
|
"categoryKey",
|
|
@@ -11559,39 +11511,5 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
|
|
|
11559
11511
|
"createdAt",
|
|
11560
11512
|
"modifiedAt",
|
|
11561
11513
|
],
|
|
11562
|
-
"WorkflowDefinition": [
|
|
11563
|
-
"workflowId",
|
|
11564
|
-
"appId",
|
|
11565
|
-
"workflowKey",
|
|
11566
|
-
"name",
|
|
11567
|
-
"status",
|
|
11568
|
-
"latestRevision",
|
|
11569
|
-
"description",
|
|
11570
|
-
"stepsR2Key",
|
|
11571
|
-
"draftStepsR2Key",
|
|
11572
|
-
"draftInputSchema",
|
|
11573
|
-
"draftOutputSchema",
|
|
11574
|
-
"draftModifiedAt",
|
|
11575
|
-
"activeConfigId",
|
|
11576
|
-
"inputSchema",
|
|
11577
|
-
"outputSchema",
|
|
11578
|
-
"perUserMaxRunning",
|
|
11579
|
-
"perUserMaxQueued",
|
|
11580
|
-
"perAppMaxRunning",
|
|
11581
|
-
"perAppMaxQueued",
|
|
11582
|
-
"queueTtlSeconds",
|
|
11583
|
-
"dequeueOrder",
|
|
11584
|
-
"requiresClientApply",
|
|
11585
|
-
"syncCallable",
|
|
11586
|
-
"accessRule",
|
|
11587
|
-
"metadataManifest",
|
|
11588
|
-
"runAs",
|
|
11589
|
-
"lock",
|
|
11590
|
-
"capabilities",
|
|
11591
|
-
"operationallyDisabled",
|
|
11592
|
-
"createdBy",
|
|
11593
|
-
"createdAt",
|
|
11594
|
-
"modifiedAt",
|
|
11595
|
-
],
|
|
11596
11514
|
};
|
|
11597
11515
|
//# sourceMappingURL=generated-config-surfaces.js.map
|