@supatype/cli 0.3.6 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +432 -0
- package/bin/supatype.js +25 -4
- package/deno.d.ts +11 -0
- package/dist/admin-prompt-state.d.ts +13 -0
- package/dist/admin-prompt-state.d.ts.map +1 -0
- package/dist/admin-prompt-state.js +30 -0
- package/dist/admin-prompt-state.js.map +1 -0
- package/dist/adopt-columns.d.ts +157 -0
- package/dist/adopt-columns.d.ts.map +1 -0
- package/dist/adopt-columns.js +785 -0
- package/dist/adopt-columns.js.map +1 -0
- package/dist/adopt-walkthrough.d.ts +50 -15
- package/dist/adopt-walkthrough.d.ts.map +1 -1
- package/dist/adopt-walkthrough.js +93 -61
- package/dist/adopt-walkthrough.js.map +1 -1
- package/dist/api-config-cache.d.ts +3 -3
- package/dist/api-config-cache.d.ts.map +1 -1
- package/dist/api-config-cache.js +14 -20
- package/dist/api-config-cache.js.map +1 -1
- package/dist/app/framework.d.ts.map +1 -1
- package/dist/app/framework.js +5 -5
- package/dist/app/framework.js.map +1 -1
- package/dist/app/proxy-dev-app.d.ts.map +1 -1
- package/dist/app/proxy-dev-app.js +3 -2
- package/dist/app/proxy-dev-app.js.map +1 -1
- package/dist/app-config.d.ts +1 -1
- package/dist/app-config.d.ts.map +1 -1
- package/dist/app-config.js +103 -144
- package/dist/app-config.js.map +1 -1
- package/dist/applied-ast-artifacts.d.ts +16 -0
- package/dist/applied-ast-artifacts.d.ts.map +1 -0
- package/dist/applied-ast-artifacts.js +37 -0
- package/dist/applied-ast-artifacts.js.map +1 -0
- package/dist/archive-extract.d.ts +3 -0
- package/dist/archive-extract.d.ts.map +1 -0
- package/dist/archive-extract.js +19 -0
- package/dist/archive-extract.js.map +1 -0
- package/dist/ast-read.d.ts +17 -0
- package/dist/ast-read.d.ts.map +1 -0
- package/dist/ast-read.js +32 -0
- package/dist/ast-read.js.map +1 -0
- package/dist/augmentation-generator.d.ts +14 -2
- package/dist/augmentation-generator.d.ts.map +1 -1
- package/dist/augmentation-generator.js +194 -61
- package/dist/augmentation-generator.js.map +1 -1
- package/dist/augmentation-relationships.d.ts +32 -0
- package/dist/augmentation-relationships.d.ts.map +1 -0
- package/dist/augmentation-relationships.js +122 -0
- package/dist/augmentation-relationships.js.map +1 -0
- package/dist/auth-answer.d.ts +16 -0
- package/dist/auth-answer.d.ts.map +1 -0
- package/dist/auth-answer.js +21 -0
- package/dist/auth-answer.js.map +1 -0
- package/dist/auth-providers.d.ts +89 -0
- package/dist/auth-providers.d.ts.map +1 -0
- package/dist/auth-providers.js +243 -0
- package/dist/auth-providers.js.map +1 -0
- package/dist/binary-cache.d.ts +34 -8
- package/dist/binary-cache.d.ts.map +1 -1
- package/dist/binary-cache.js +253 -115
- package/dist/binary-cache.js.map +1 -1
- package/dist/binary-download-lock.d.ts.map +1 -1
- package/dist/binary-download-lock.js +14 -13
- package/dist/binary-download-lock.js.map +1 -1
- package/dist/byo-preflight.d.ts +26 -0
- package/dist/byo-preflight.d.ts.map +1 -0
- package/dist/byo-preflight.js +61 -0
- package/dist/byo-preflight.js.map +1 -0
- package/dist/cache-identity-scope.d.ts +7 -3
- package/dist/cache-identity-scope.d.ts.map +1 -1
- package/dist/cache-identity-scope.js +20 -10
- package/dist/cache-identity-scope.js.map +1 -1
- package/dist/cache-pins.d.ts.map +1 -1
- package/dist/cache-pins.js +2 -2
- package/dist/cache-pins.js.map +1 -1
- package/dist/cache-provider.d.ts +17 -18
- package/dist/cache-provider.d.ts.map +1 -1
- package/dist/cache-provider.js +27 -25
- package/dist/cache-provider.js.map +1 -1
- package/dist/cli-package-version.d.ts.map +1 -1
- package/dist/cli-package-version.js +2 -2
- package/dist/cli-package-version.js.map +1 -1
- package/dist/cli-standalone.d.ts.map +1 -1
- package/dist/cli-standalone.js +2 -6
- package/dist/cli-standalone.js.map +1 -1
- package/dist/cli-version-embedded.js +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/client-generator.d.ts +5 -2
- package/dist/client-generator.d.ts.map +1 -1
- package/dist/client-generator.js +32 -22
- package/dist/client-generator.js.map +1 -1
- package/dist/cloud-credentials.d.ts +6 -0
- package/dist/cloud-credentials.d.ts.map +1 -1
- package/dist/cloud-credentials.js +45 -26
- package/dist/cloud-credentials.js.map +1 -1
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +3 -2
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/admin.d.ts +51 -16
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +174 -148
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/adopt.d.ts +23 -0
- package/dist/commands/adopt.d.ts.map +1 -1
- package/dist/commands/adopt.js +205 -42
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/app.d.ts.map +1 -1
- package/dist/commands/app.js +31 -11
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/cache.d.ts.map +1 -1
- package/dist/commands/cache.js +7 -5
- package/dist/commands/cache.js.map +1 -1
- package/dist/commands/cloud.d.ts +4 -1
- package/dist/commands/cloud.d.ts.map +1 -1
- package/dist/commands/cloud.js +49 -27
- package/dist/commands/cloud.js.map +1 -1
- package/dist/commands/db.d.ts.map +1 -1
- package/dist/commands/db.js +122 -110
- package/dist/commands/db.js.map +1 -1
- package/dist/commands/deploy.d.ts +6 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +67 -19
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +54 -2
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +582 -469
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts +56 -8
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +180 -61
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/engine.d.ts +1 -1
- package/dist/commands/engine.d.ts.map +1 -1
- package/dist/commands/engine.js +14 -13
- package/dist/commands/engine.js.map +1 -1
- package/dist/commands/functions.d.ts +30 -0
- package/dist/commands/functions.d.ts.map +1 -1
- package/dist/commands/functions.js +530 -545
- package/dist/commands/functions.js.map +1 -1
- package/dist/commands/generate.d.ts +6 -0
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +25 -22
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/hooks.js +26 -11
- package/dist/commands/hooks.js.map +1 -1
- package/dist/commands/init.d.ts +33 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +330 -213
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/internal.d.ts.map +1 -1
- package/dist/commands/internal.js +5 -3
- package/dist/commands/internal.js.map +1 -1
- package/dist/commands/keys.d.ts +36 -10
- package/dist/commands/keys.d.ts.map +1 -1
- package/dist/commands/keys.js +168 -128
- package/dist/commands/keys.js.map +1 -1
- package/dist/commands/link-helpers.d.ts.map +1 -1
- package/dist/commands/link-helpers.js +46 -17
- package/dist/commands/link-helpers.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +2 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +5 -4
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/migrate.d.ts +43 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +99 -48
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/pg.d.ts.map +1 -1
- package/dist/commands/pg.js +26 -23
- package/dist/commands/pg.js.map +1 -1
- package/dist/commands/plugins.d.ts.map +1 -1
- package/dist/commands/plugins.js +53 -34
- package/dist/commands/plugins.js.map +1 -1
- package/dist/commands/pull.d.ts.map +1 -1
- package/dist/commands/pull.js +6 -5
- package/dist/commands/pull.js.map +1 -1
- package/dist/commands/push.d.ts +60 -0
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +411 -131
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/rename.d.ts +20 -0
- package/dist/commands/rename.d.ts.map +1 -0
- package/dist/commands/rename.js +74 -0
- package/dist/commands/rename.js.map +1 -0
- package/dist/commands/seed.d.ts +47 -0
- package/dist/commands/seed.d.ts.map +1 -1
- package/dist/commands/seed.js +123 -36
- package/dist/commands/seed.js.map +1 -1
- package/dist/commands/self-host.d.ts.map +1 -1
- package/dist/commands/self-host.js +136 -38
- package/dist/commands/self-host.js.map +1 -1
- package/dist/commands/self-update.d.ts.map +1 -1
- package/dist/commands/self-update.js +2 -1
- package/dist/commands/self-update.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +21 -17
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/types.js +10 -11
- package/dist/commands/types.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +213 -98
- package/dist/commands/update.js.map +1 -1
- package/dist/component-launch.d.ts +11 -0
- package/dist/component-launch.d.ts.map +1 -0
- package/dist/component-launch.js +35 -0
- package/dist/component-launch.js.map +1 -0
- package/dist/components.d.ts +7 -2
- package/dist/components.d.ts.map +1 -1
- package/dist/components.js +7 -2
- package/dist/components.js.map +1 -1
- package/dist/compose-db-psql.d.ts +20 -0
- package/dist/compose-db-psql.d.ts.map +1 -0
- package/dist/compose-db-psql.js +30 -0
- package/dist/compose-db-psql.js.map +1 -0
- package/dist/compose-db-roles.d.ts +41 -0
- package/dist/compose-db-roles.d.ts.map +1 -0
- package/dist/compose-db-roles.js +109 -0
- package/dist/compose-db-roles.js.map +1 -0
- package/dist/compose-engine-run.d.ts +28 -0
- package/dist/compose-engine-run.d.ts.map +1 -0
- package/dist/compose-engine-run.js +68 -0
- package/dist/compose-engine-run.js.map +1 -0
- package/dist/compose-engine-service.d.ts +10 -0
- package/dist/compose-engine-service.d.ts.map +1 -0
- package/dist/compose-engine-service.js +16 -0
- package/dist/compose-engine-service.js.map +1 -0
- package/dist/compose-host-path.d.ts +14 -0
- package/dist/compose-host-path.d.ts.map +1 -0
- package/dist/compose-host-path.js +18 -0
- package/dist/compose-host-path.js.map +1 -0
- package/dist/compose-image-pull.d.ts +43 -0
- package/dist/compose-image-pull.d.ts.map +1 -0
- package/dist/compose-image-pull.js +27 -0
- package/dist/compose-image-pull.js.map +1 -0
- package/dist/compose-kong.d.ts +31 -0
- package/dist/compose-kong.d.ts.map +1 -0
- package/dist/compose-kong.js +149 -0
- package/dist/compose-kong.js.map +1 -0
- package/dist/compose-local-server-image.d.ts.map +1 -1
- package/dist/compose-local-server-image.js +7 -3
- package/dist/compose-local-server-image.js.map +1 -1
- package/dist/compose-rename.d.ts.map +1 -1
- package/dist/compose-rename.js +2 -2
- package/dist/compose-rename.js.map +1 -1
- package/dist/compose-render-mode.d.ts +41 -0
- package/dist/compose-render-mode.d.ts.map +1 -0
- package/dist/compose-render-mode.js +73 -0
- package/dist/compose-render-mode.js.map +1 -0
- package/dist/compose-services.d.ts +12 -2
- package/dist/compose-services.d.ts.map +1 -1
- package/dist/compose-services.js +29 -13
- package/dist/compose-services.js.map +1 -1
- package/dist/config-snapshot.d.ts +6 -0
- package/dist/config-snapshot.d.ts.map +1 -0
- package/dist/config-snapshot.js +23 -0
- package/dist/config-snapshot.js.map +1 -0
- package/dist/config.d.ts +20 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +52 -13
- package/dist/config.js.map +1 -1
- package/dist/database-url-owner.d.ts +57 -0
- package/dist/database-url-owner.d.ts.map +1 -0
- package/dist/database-url-owner.js +130 -0
- package/dist/database-url-owner.js.map +1 -0
- package/dist/db-port-offer.d.ts +18 -0
- package/dist/db-port-offer.d.ts.map +1 -0
- package/dist/db-port-offer.js +68 -0
- package/dist/db-port-offer.js.map +1 -0
- package/dist/db-port.d.ts +87 -21
- package/dist/db-port.d.ts.map +1 -1
- package/dist/db-port.js +90 -48
- package/dist/db-port.js.map +1 -1
- package/dist/db-preflight.d.ts +30 -8
- package/dist/db-preflight.d.ts.map +1 -1
- package/dist/db-preflight.js +103 -46
- package/dist/db-preflight.js.map +1 -1
- package/dist/db-rows.d.ts +31 -0
- package/dist/db-rows.d.ts.map +1 -0
- package/dist/db-rows.js +47 -0
- package/dist/db-rows.js.map +1 -0
- package/dist/debounce.d.ts +11 -0
- package/dist/debounce.d.ts.map +1 -0
- package/dist/debounce.js +23 -0
- package/dist/debounce.js.map +1 -0
- package/dist/destructive-consent.d.ts +88 -0
- package/dist/destructive-consent.d.ts.map +1 -0
- package/dist/destructive-consent.js +184 -0
- package/dist/destructive-consent.js.map +1 -0
- package/dist/dev-api-keys.d.ts +36 -0
- package/dist/dev-api-keys.d.ts.map +1 -0
- package/dist/dev-api-keys.js +68 -0
- package/dist/dev-api-keys.js.map +1 -0
- package/dist/dev-compose.d.ts +96 -26
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +739 -620
- package/dist/dev-compose.js.map +1 -1
- package/dist/dev-db-ready.d.ts +20 -0
- package/dist/dev-db-ready.d.ts.map +1 -0
- package/dist/dev-db-ready.js +22 -0
- package/dist/dev-db-ready.js.map +1 -0
- package/dist/dev-db-reset.d.ts.map +1 -1
- package/dist/dev-db-reset.js +5 -4
- package/dist/dev-db-reset.js.map +1 -1
- package/dist/dev-functions-watch.d.ts +24 -0
- package/dist/dev-functions-watch.d.ts.map +1 -0
- package/dist/dev-functions-watch.js +71 -0
- package/dist/dev-functions-watch.js.map +1 -0
- package/dist/dev-initial-push.d.ts +41 -6
- package/dist/dev-initial-push.d.ts.map +1 -1
- package/dist/dev-initial-push.js +84 -31
- package/dist/dev-initial-push.js.map +1 -1
- package/dist/dev-ports.d.ts +73 -6
- package/dist/dev-ports.d.ts.map +1 -1
- package/dist/dev-ports.js +185 -54
- package/dist/dev-ports.js.map +1 -1
- package/dist/dev-ready-panel.d.ts +5 -0
- package/dist/dev-ready-panel.d.ts.map +1 -1
- package/dist/dev-ready-panel.js +13 -0
- package/dist/dev-ready-panel.js.map +1 -1
- package/dist/dev-schema-watch.d.ts +19 -0
- package/dist/dev-schema-watch.d.ts.map +1 -0
- package/dist/dev-schema-watch.js +44 -0
- package/dist/dev-schema-watch.js.map +1 -0
- package/dist/dev-session-lock.d.ts +30 -1
- package/dist/dev-session-lock.d.ts.map +1 -1
- package/dist/dev-session-lock.js +87 -13
- package/dist/dev-session-lock.js.map +1 -1
- package/dist/dev-session.d.ts.map +1 -1
- package/dist/dev-session.js +3 -0
- package/dist/dev-session.js.map +1 -1
- package/dist/dev-shutdown.d.ts +62 -3
- package/dist/dev-shutdown.d.ts.map +1 -1
- package/dist/dev-shutdown.js +251 -32
- package/dist/dev-shutdown.js.map +1 -1
- package/dist/diff-output.d.ts +71 -3
- package/dist/diff-output.d.ts.map +1 -1
- package/dist/diff-output.js +173 -18
- package/dist/diff-output.js.map +1 -1
- package/dist/docker-address-pool.d.ts +23 -0
- package/dist/docker-address-pool.d.ts.map +1 -0
- package/dist/docker-address-pool.js +56 -0
- package/dist/docker-address-pool.js.map +1 -0
- package/dist/docker-env.d.ts +16 -0
- package/dist/docker-env.d.ts.map +1 -0
- package/dist/docker-env.js +16 -0
- package/dist/docker-env.js.map +1 -0
- package/dist/docker-exec.d.ts +92 -0
- package/dist/docker-exec.d.ts.map +1 -0
- package/dist/docker-exec.js +139 -0
- package/dist/docker-exec.js.map +1 -0
- package/dist/docker-postgres.d.ts +1 -6
- package/dist/docker-postgres.d.ts.map +1 -1
- package/dist/docker-postgres.js +75 -88
- package/dist/docker-postgres.js.map +1 -1
- package/dist/docker-runtime.d.ts +12 -1
- package/dist/docker-runtime.d.ts.map +1 -1
- package/dist/docker-runtime.js +48 -23
- package/dist/docker-runtime.js.map +1 -1
- package/dist/dotenv-parse.d.ts +22 -0
- package/dist/dotenv-parse.d.ts.map +1 -0
- package/dist/dotenv-parse.js +63 -0
- package/dist/dotenv-parse.js.map +1 -0
- package/dist/drift-consent.d.ts +36 -0
- package/dist/drift-consent.d.ts.map +1 -0
- package/dist/drift-consent.js +78 -0
- package/dist/drift-consent.js.map +1 -0
- package/dist/engine-answers.d.ts +49 -0
- package/dist/engine-answers.d.ts.map +1 -0
- package/dist/engine-answers.js +184 -0
- package/dist/engine-answers.js.map +1 -0
- package/dist/engine-client.d.ts +156 -9
- package/dist/engine-client.d.ts.map +1 -1
- package/dist/engine-client.js +313 -129
- package/dist/engine-client.js.map +1 -1
- package/dist/engine-floor.d.ts +39 -0
- package/dist/engine-floor.d.ts.map +1 -1
- package/dist/engine-floor.js +84 -0
- package/dist/engine-floor.js.map +1 -1
- package/dist/engine-json-line.d.ts +9 -0
- package/dist/engine-json-line.d.ts.map +1 -0
- package/dist/engine-json-line.js +23 -0
- package/dist/engine-json-line.js.map +1 -0
- package/dist/engine-ownership-gate.d.ts +89 -0
- package/dist/engine-ownership-gate.d.ts.map +1 -0
- package/dist/engine-ownership-gate.js +238 -0
- package/dist/engine-ownership-gate.js.map +1 -0
- package/dist/engine-push-output.d.ts +23 -2
- package/dist/engine-push-output.d.ts.map +1 -1
- package/dist/engine-push-output.js +22 -15
- package/dist/engine-push-output.js.map +1 -1
- package/dist/ensure-binary.d.ts +9 -0
- package/dist/ensure-binary.d.ts.map +1 -1
- package/dist/ensure-binary.js +38 -5
- package/dist/ensure-binary.js.map +1 -1
- package/dist/ensure-component-binaries.d.ts.map +1 -1
- package/dist/ensure-component-binaries.js +2 -1
- package/dist/ensure-component-binaries.js.map +1 -1
- package/dist/env-file.d.ts +41 -8
- package/dist/env-file.d.ts.map +1 -1
- package/dist/env-file.js +123 -57
- package/dist/env-file.js.map +1 -1
- package/dist/env-lines.d.ts +11 -0
- package/dist/env-lines.d.ts.map +1 -0
- package/dist/env-lines.js +36 -0
- package/dist/env-lines.js.map +1 -0
- package/dist/error-message.d.ts +38 -0
- package/dist/error-message.d.ts.map +1 -0
- package/dist/error-message.js +111 -0
- package/dist/error-message.js.map +1 -0
- package/dist/fetch-within.d.ts +10 -0
- package/dist/fetch-within.d.ts.map +1 -0
- package/dist/fetch-within.js +12 -0
- package/dist/fetch-within.js.map +1 -0
- package/dist/field-bounds.d.ts +8 -2
- package/dist/field-bounds.d.ts.map +1 -1
- package/dist/field-bounds.js +9 -15
- package/dist/field-bounds.js.map +1 -1
- package/dist/field-masking-tier.d.ts +4 -3
- package/dist/field-masking-tier.d.ts.map +1 -1
- package/dist/field-masking-tier.js +38 -13
- package/dist/field-masking-tier.js.map +1 -1
- package/dist/functions-context-refresh.d.ts +6 -2
- package/dist/functions-context-refresh.d.ts.map +1 -1
- package/dist/functions-context-refresh.js +11 -3
- package/dist/functions-context-refresh.js.map +1 -1
- package/dist/functions-deno-types.d.ts +8 -8
- package/dist/functions-deno-types.d.ts.map +1 -1
- package/dist/functions-deno-types.js +61 -26
- package/dist/functions-deno-types.js.map +1 -1
- package/dist/functions-discovery.d.ts +31 -0
- package/dist/functions-discovery.d.ts.map +1 -0
- package/dist/functions-discovery.js +87 -0
- package/dist/functions-discovery.js.map +1 -0
- package/dist/functions-template.d.ts +10 -0
- package/dist/functions-template.d.ts.map +1 -0
- package/dist/functions-template.js +47 -0
- package/dist/functions-template.js.map +1 -0
- package/dist/functions-worker-files.d.ts +55 -0
- package/dist/functions-worker-files.d.ts.map +1 -0
- package/dist/functions-worker-files.js +149 -0
- package/dist/functions-worker-files.js.map +1 -0
- package/dist/generated/functions-worker-source.d.ts +2 -0
- package/dist/generated/functions-worker-source.d.ts.map +1 -0
- package/dist/generated/functions-worker-source.js +12 -0
- package/dist/generated/functions-worker-source.js.map +1 -0
- package/dist/generated/release-images.d.ts +18 -0
- package/dist/generated/release-images.d.ts.map +1 -0
- package/dist/generated/release-images.js +8 -0
- package/dist/generated/release-images.js.map +1 -0
- package/dist/generated-files-engine.d.ts +33 -0
- package/dist/generated-files-engine.d.ts.map +1 -0
- package/dist/generated-files-engine.js +45 -0
- package/dist/generated-files-engine.js.map +1 -0
- package/dist/hook-upload.d.ts +29 -15
- package/dist/hook-upload.d.ts.map +1 -1
- package/dist/hook-upload.js +88 -59
- package/dist/hook-upload.js.map +1 -1
- package/dist/hooks-generator.d.ts +5 -0
- package/dist/hooks-generator.d.ts.map +1 -1
- package/dist/hooks-generator.js +117 -85
- package/dist/hooks-generator.js.map +1 -1
- package/dist/host-database.d.ts +46 -5
- package/dist/host-database.d.ts.map +1 -1
- package/dist/host-database.js +102 -18
- package/dist/host-database.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/init-dependency-versions.d.ts +3 -1
- package/dist/init-dependency-versions.d.ts.map +1 -1
- package/dist/init-dependency-versions.js +30 -7
- package/dist/init-dependency-versions.js.map +1 -1
- package/dist/init-example.d.ts +48 -0
- package/dist/init-example.d.ts.map +1 -0
- package/dist/init-example.js +110 -0
- package/dist/init-example.js.map +1 -0
- package/dist/init-package-json.d.ts.map +1 -1
- package/dist/init-package-json.js +2 -0
- package/dist/init-package-json.js.map +1 -1
- package/dist/init-project-detect.d.ts.map +1 -1
- package/dist/init-project-detect.js +3 -2
- package/dist/init-project-detect.js.map +1 -1
- package/dist/init-setup-steps.d.ts +37 -0
- package/dist/init-setup-steps.d.ts.map +1 -0
- package/dist/init-setup-steps.js +118 -0
- package/dist/init-setup-steps.js.map +1 -0
- package/dist/json-file.d.ts +15 -0
- package/dist/json-file.d.ts.map +1 -0
- package/dist/json-file.js +38 -0
- package/dist/json-file.js.map +1 -0
- package/dist/json-type-text.d.ts +18 -0
- package/dist/json-type-text.d.ts.map +1 -0
- package/dist/json-type-text.js +112 -0
- package/dist/json-type-text.js.map +1 -0
- package/dist/jwt-secret-length.d.ts +14 -0
- package/dist/jwt-secret-length.d.ts.map +1 -0
- package/dist/jwt-secret-length.js +21 -0
- package/dist/jwt-secret-length.js.map +1 -0
- package/dist/jwt-secret-rules.d.ts +24 -0
- package/dist/jwt-secret-rules.d.ts.map +1 -0
- package/dist/jwt-secret-rules.js +46 -0
- package/dist/jwt-secret-rules.js.map +1 -0
- package/dist/jwt.d.ts +5 -0
- package/dist/jwt.d.ts.map +1 -1
- package/dist/jwt.js +25 -1
- package/dist/jwt.js.map +1 -1
- package/dist/link.d.ts +5 -1
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +47 -5
- package/dist/link.js.map +1 -1
- package/dist/local-gateway.d.ts +10 -4
- package/dist/local-gateway.d.ts.map +1 -1
- package/dist/local-gateway.js +19 -5
- package/dist/local-gateway.js.map +1 -1
- package/dist/local-secrets.d.ts +176 -10
- package/dist/local-secrets.d.ts.map +1 -1
- package/dist/local-secrets.js +261 -16
- package/dist/local-secrets.js.map +1 -1
- package/dist/local-stack.d.ts +30 -0
- package/dist/local-stack.d.ts.map +1 -0
- package/dist/local-stack.js +76 -0
- package/dist/local-stack.js.map +1 -0
- package/dist/local-storage.d.ts +7 -2
- package/dist/local-storage.d.ts.map +1 -1
- package/dist/local-storage.js +11 -3
- package/dist/local-storage.js.map +1 -1
- package/dist/mailer-autoconfirm.d.ts +37 -0
- package/dist/mailer-autoconfirm.d.ts.map +1 -0
- package/dist/mailer-autoconfirm.js +69 -0
- package/dist/mailer-autoconfirm.js.map +1 -0
- package/dist/mailer-env.d.ts +37 -0
- package/dist/mailer-env.d.ts.map +1 -0
- package/dist/mailer-env.js +98 -0
- package/dist/mailer-env.js.map +1 -0
- package/dist/model-cache.d.ts +10 -10
- package/dist/model-cache.d.ts.map +1 -1
- package/dist/model-cache.js +33 -27
- package/dist/model-cache.js.map +1 -1
- package/dist/model-hooks.d.ts +24 -13
- package/dist/model-hooks.d.ts.map +1 -1
- package/dist/model-hooks.js +133 -175
- package/dist/model-hooks.js.map +1 -1
- package/dist/model-versioning.d.ts +7 -1
- package/dist/model-versioning.d.ts.map +1 -1
- package/dist/model-versioning.js +24 -27
- package/dist/model-versioning.js.map +1 -1
- package/dist/native-dev-env.d.ts +75 -0
- package/dist/native-dev-env.d.ts.map +1 -0
- package/dist/native-dev-env.js +112 -0
- package/dist/native-dev-env.js.map +1 -0
- package/dist/native-functions-watch.d.ts +62 -0
- package/dist/native-functions-watch.d.ts.map +1 -0
- package/dist/native-functions-watch.js +140 -0
- package/dist/native-functions-watch.js.map +1 -0
- package/dist/native-keyspace.d.ts +23 -0
- package/dist/native-keyspace.d.ts.map +1 -0
- package/dist/native-keyspace.js +53 -0
- package/dist/native-keyspace.js.map +1 -0
- package/dist/native-pg-auth.d.ts +46 -0
- package/dist/native-pg-auth.d.ts.map +1 -0
- package/dist/native-pg-auth.js +107 -0
- package/dist/native-pg-auth.js.map +1 -0
- package/dist/native-realtime.d.ts +34 -0
- package/dist/native-realtime.d.ts.map +1 -0
- package/dist/native-realtime.js +195 -0
- package/dist/native-realtime.js.map +1 -0
- package/dist/native-roles-sql.d.ts +41 -0
- package/dist/native-roles-sql.d.ts.map +1 -0
- package/dist/native-roles-sql.js +154 -0
- package/dist/native-roles-sql.js.map +1 -0
- package/dist/native-storage-import.d.ts +19 -0
- package/dist/native-storage-import.d.ts.map +1 -0
- package/dist/native-storage-import.js +327 -0
- package/dist/native-storage-import.js.map +1 -0
- package/dist/native-storage.d.ts +45 -0
- package/dist/native-storage.d.ts.map +1 -0
- package/dist/native-storage.js +140 -0
- package/dist/native-storage.js.map +1 -0
- package/dist/native-worker.d.ts +26 -0
- package/dist/native-worker.d.ts.map +1 -0
- package/dist/native-worker.js +63 -0
- package/dist/native-worker.js.map +1 -0
- package/dist/owner-default.d.ts +27 -0
- package/dist/owner-default.d.ts.map +1 -0
- package/dist/owner-default.js +55 -0
- package/dist/owner-default.js.map +1 -0
- package/dist/package-json.d.ts +20 -0
- package/dist/package-json.d.ts.map +1 -0
- package/dist/package-json.js +29 -0
- package/dist/package-json.js.map +1 -0
- package/dist/parent-watch.d.ts +40 -0
- package/dist/parent-watch.d.ts.map +1 -0
- package/dist/parent-watch.js +75 -0
- package/dist/parent-watch.js.map +1 -0
- package/dist/post-apply.d.ts +3 -0
- package/dist/post-apply.d.ts.map +1 -0
- package/dist/post-apply.js +17 -0
- package/dist/post-apply.js.map +1 -0
- package/dist/postgres-ctl.d.ts +125 -11
- package/dist/postgres-ctl.d.ts.map +1 -1
- package/dist/postgres-ctl.js +336 -53
- package/dist/postgres-ctl.js.map +1 -1
- package/dist/postgres-image.d.ts +47 -0
- package/dist/postgres-image.d.ts.map +1 -0
- package/dist/postgres-image.js +130 -0
- package/dist/postgres-image.js.map +1 -0
- package/dist/postgrest-release.d.ts +34 -0
- package/dist/postgrest-release.d.ts.map +1 -0
- package/dist/postgrest-release.js +58 -0
- package/dist/postgrest-release.js.map +1 -0
- package/dist/process-manager.d.ts.map +1 -1
- package/dist/process-manager.js +3 -1
- package/dist/process-manager.js.map +1 -1
- package/dist/project-config.d.ts +185 -24
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +310 -116
- package/dist/project-config.js.map +1 -1
- package/dist/project-name-override.d.ts +25 -0
- package/dist/project-name-override.d.ts.map +1 -0
- package/dist/project-name-override.js +52 -0
- package/dist/project-name-override.js.map +1 -0
- package/dist/pull-utils.d.ts +41 -3
- package/dist/pull-utils.d.ts.map +1 -1
- package/dist/pull-utils.js +182 -17
- package/dist/pull-utils.js.map +1 -1
- package/dist/push-audit.d.ts +39 -0
- package/dist/push-audit.d.ts.map +1 -0
- package/dist/push-audit.js +116 -0
- package/dist/push-audit.js.map +1 -0
- package/dist/push-refusal.d.ts +94 -0
- package/dist/push-refusal.d.ts.map +1 -0
- package/dist/push-refusal.js +276 -0
- package/dist/push-refusal.js.map +1 -0
- package/dist/realtime-launch.d.ts +2 -5
- package/dist/realtime-launch.d.ts.map +1 -1
- package/dist/realtime-launch.js +6 -23
- package/dist/realtime-launch.js.map +1 -1
- package/dist/recorded-field-masking-tier.d.ts +43 -0
- package/dist/recorded-field-masking-tier.d.ts.map +1 -0
- package/dist/recorded-field-masking-tier.js +89 -0
- package/dist/recorded-field-masking-tier.js.map +1 -0
- package/dist/release-images.d.ts +31 -0
- package/dist/release-images.d.ts.map +1 -0
- package/dist/release-images.js +90 -0
- package/dist/release-images.js.map +1 -0
- package/dist/rename-journal.d.ts +54 -0
- package/dist/rename-journal.d.ts.map +1 -0
- package/dist/rename-journal.js +150 -0
- package/dist/rename-journal.js.map +1 -0
- package/dist/required-host-components.d.ts.map +1 -1
- package/dist/required-host-components.js +4 -0
- package/dist/required-host-components.js.map +1 -1
- package/dist/resolve-api-url.d.ts +17 -3
- package/dist/resolve-api-url.d.ts.map +1 -1
- package/dist/resolve-api-url.js +72 -30
- package/dist/resolve-api-url.js.map +1 -1
- package/dist/resolve-target.d.ts +147 -26
- package/dist/resolve-target.d.ts.map +1 -1
- package/dist/resolve-target.js +279 -82
- package/dist/resolve-target.js.map +1 -1
- package/dist/rest-cache-admin.d.ts +9 -8
- package/dist/rest-cache-admin.d.ts.map +1 -1
- package/dist/rest-cache-admin.js +32 -9
- package/dist/rest-cache-admin.js.map +1 -1
- package/dist/rest-ready.d.ts +28 -0
- package/dist/rest-ready.d.ts.map +1 -0
- package/dist/rest-ready.js +54 -0
- package/dist/rest-ready.js.map +1 -0
- package/dist/restore-system-relation-targets.d.ts.map +1 -1
- package/dist/restore-system-relation-targets.js +49 -31
- package/dist/restore-system-relation-targets.js.map +1 -1
- package/dist/route-manifest.d.ts +25 -2
- package/dist/route-manifest.d.ts.map +1 -1
- package/dist/route-manifest.js +51 -13
- package/dist/route-manifest.js.map +1 -1
- package/dist/run-until-stopped.d.ts +12 -0
- package/dist/run-until-stopped.d.ts.map +1 -0
- package/dist/run-until-stopped.js +42 -0
- package/dist/run-until-stopped.js.map +1 -0
- package/dist/runtime-routes.d.ts.map +1 -1
- package/dist/runtime-routes.js +23 -28
- package/dist/runtime-routes.js.map +1 -1
- package/dist/schema-ast-v2.d.ts +37 -2
- package/dist/schema-ast-v2.d.ts.map +1 -1
- package/dist/schema-ast-v2.js +22 -7
- package/dist/schema-ast-v2.js.map +1 -1
- package/dist/schema-push-lock.d.ts.map +1 -1
- package/dist/schema-push-lock.js +70 -80
- package/dist/schema-push-lock.js.map +1 -1
- package/dist/schema-sources.d.ts +26 -5
- package/dist/schema-sources.d.ts.map +1 -1
- package/dist/schema-sources.js +73 -41
- package/dist/schema-sources.js.map +1 -1
- package/dist/seed-auth-connect.d.ts +14 -0
- package/dist/seed-auth-connect.d.ts.map +1 -0
- package/dist/seed-auth-connect.js +97 -0
- package/dist/seed-auth-connect.js.map +1 -0
- package/dist/seed-ir.d.ts.map +1 -1
- package/dist/seed-ir.js +30 -9
- package/dist/seed-ir.js.map +1 -1
- package/dist/seed-runner.d.ts.map +1 -1
- package/dist/seed-runner.js +47 -3
- package/dist/seed-runner.js.map +1 -1
- package/dist/seed.d.ts +37 -7
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +3 -1
- package/dist/seed.js.map +1 -1
- package/dist/self-host-compose.d.ts +83 -19
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +541 -217
- package/dist/self-host-compose.js.map +1 -1
- package/dist/service-role-key-file.d.ts +32 -0
- package/dist/service-role-key-file.d.ts.map +1 -0
- package/dist/service-role-key-file.js +90 -0
- package/dist/service-role-key-file.js.map +1 -0
- package/dist/shell-ports.d.ts +37 -0
- package/dist/shell-ports.d.ts.map +1 -0
- package/dist/shell-ports.js +67 -0
- package/dist/shell-ports.js.map +1 -0
- package/dist/stop-signals.d.ts +7 -0
- package/dist/stop-signals.d.ts.map +1 -0
- package/dist/stop-signals.js +12 -0
- package/dist/stop-signals.js.map +1 -0
- package/dist/storage-launch.d.ts +11 -0
- package/dist/storage-launch.d.ts.map +1 -0
- package/dist/storage-launch.js +41 -0
- package/dist/storage-launch.js.map +1 -0
- package/dist/storage-provision.d.ts +69 -7
- package/dist/storage-provision.d.ts.map +1 -1
- package/dist/storage-provision.js +112 -32
- package/dist/storage-provision.js.map +1 -1
- package/dist/studio-admin-roles.d.ts.map +1 -1
- package/dist/studio-admin-roles.js +2 -1
- package/dist/studio-admin-roles.js.map +1 -1
- package/dist/studio-auth-config.d.ts +22 -0
- package/dist/studio-auth-config.d.ts.map +1 -0
- package/dist/studio-auth-config.js +45 -0
- package/dist/studio-auth-config.js.map +1 -0
- package/dist/studio-roles.d.ts +13 -0
- package/dist/studio-roles.d.ts.map +1 -0
- package/dist/studio-roles.js +12 -0
- package/dist/studio-roles.js.map +1 -0
- package/dist/systemd.d.ts +1 -1
- package/dist/systemd.d.ts.map +1 -1
- package/dist/systemd.js +26 -11
- package/dist/systemd.js.map +1 -1
- package/dist/tar-reader.d.ts +29 -0
- package/dist/tar-reader.d.ts.map +1 -0
- package/dist/tar-reader.js +99 -0
- package/dist/tar-reader.js.map +1 -0
- package/dist/target-client.d.ts +27 -3
- package/dist/target-client.d.ts.map +1 -1
- package/dist/target-client.js +173 -46
- package/dist/target-client.js.map +1 -1
- package/dist/target-request.d.ts +25 -0
- package/dist/target-request.d.ts.map +1 -0
- package/dist/target-request.js +33 -0
- package/dist/target-request.js.map +1 -0
- package/dist/target-warning.d.ts +7 -0
- package/dist/target-warning.d.ts.map +1 -0
- package/dist/target-warning.js +12 -0
- package/dist/target-warning.js.map +1 -0
- package/dist/tsx-runner.d.ts +13 -0
- package/dist/tsx-runner.d.ts.map +1 -1
- package/dist/tsx-runner.js +36 -19
- package/dist/tsx-runner.js.map +1 -1
- package/dist/type-extractor.d.ts +8 -0
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +518 -155
- package/dist/type-extractor.js.map +1 -1
- package/dist/type-generation.d.ts +35 -5
- package/dist/type-generation.d.ts.map +1 -1
- package/dist/type-generation.js +57 -27
- package/dist/type-generation.js.map +1 -1
- package/dist/type-resolver.d.ts.map +1 -1
- package/dist/type-resolver.js +8 -1
- package/dist/type-resolver.js.map +1 -1
- package/dist/ui/clack-api.d.ts +3 -0
- package/dist/ui/clack-api.d.ts.map +1 -1
- package/dist/ui/clack-api.js +14 -7
- package/dist/ui/clack-api.js.map +1 -1
- package/dist/ui/clack.d.ts.map +1 -1
- package/dist/ui/clack.js +19 -7
- package/dist/ui/clack.js.map +1 -1
- package/dist/ui/components/PromptPanel.d.ts +1 -0
- package/dist/ui/components/PromptPanel.d.ts.map +1 -1
- package/dist/ui/components/PromptPanel.js +2 -1
- package/dist/ui/components/PromptPanel.js.map +1 -1
- package/dist/ui/confirm.d.ts +8 -0
- package/dist/ui/confirm.d.ts.map +1 -1
- package/dist/ui/confirm.js +12 -0
- package/dist/ui/confirm.js.map +1 -1
- package/dist/ui/dev/DevDashboard.d.ts.map +1 -1
- package/dist/ui/dev/DevDashboard.js +23 -6
- package/dist/ui/dev/DevDashboard.js.map +1 -1
- package/dist/ui/fatal.d.ts.map +1 -1
- package/dist/ui/fatal.js +6 -7
- package/dist/ui/fatal.js.map +1 -1
- package/dist/ui/flows/FlowApp.d.ts.map +1 -1
- package/dist/ui/flows/FlowApp.js +32 -1
- package/dist/ui/flows/FlowApp.js.map +1 -1
- package/dist/ui/flows/prompt-fields.d.ts +18 -0
- package/dist/ui/flows/prompt-fields.d.ts.map +1 -1
- package/dist/ui/flows/prompt-fields.js +25 -5
- package/dist/ui/flows/prompt-fields.js.map +1 -1
- package/dist/ui/flows/types.d.ts +2 -1
- package/dist/ui/flows/types.d.ts.map +1 -1
- package/dist/ui/messages.d.ts +6 -0
- package/dist/ui/messages.d.ts.map +1 -1
- package/dist/ui/messages.js +17 -0
- package/dist/ui/messages.js.map +1 -1
- package/dist/ui/progress.d.ts +7 -0
- package/dist/ui/progress.d.ts.map +1 -1
- package/dist/ui/progress.js +22 -8
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/runtime/cancel.d.ts +5 -0
- package/dist/ui/runtime/cancel.d.ts.map +1 -1
- package/dist/ui/runtime/cancel.js +7 -0
- package/dist/ui/runtime/cancel.js.map +1 -1
- package/dist/ui/runtime/command-chrome.d.ts.map +1 -1
- package/dist/ui/runtime/command-chrome.js +2 -0
- package/dist/ui/runtime/command-chrome.js.map +1 -1
- package/dist/ui/runtime/dev-prompt-queue.d.ts +5 -4
- package/dist/ui/runtime/dev-prompt-queue.d.ts.map +1 -1
- package/dist/ui/runtime/dev-prompt-queue.js +2 -5
- package/dist/ui/runtime/dev-prompt-queue.js.map +1 -1
- package/dist/ui/runtime/prompt-interrupt.d.ts +10 -0
- package/dist/ui/runtime/prompt-interrupt.d.ts.map +1 -0
- package/dist/ui/runtime/prompt-interrupt.js +24 -0
- package/dist/ui/runtime/prompt-interrupt.js.map +1 -0
- package/dist/ui/runtime/run-clack-flow.d.ts.map +1 -1
- package/dist/ui/runtime/run-clack-flow.js +5 -2
- package/dist/ui/runtime/run-clack-flow.js.map +1 -1
- package/dist/ui/runtime/stdin-after-ink.d.ts +14 -1
- package/dist/ui/runtime/stdin-after-ink.d.ts.map +1 -1
- package/dist/ui/runtime/stdin-after-ink.js +44 -3
- package/dist/ui/runtime/stdin-after-ink.js.map +1 -1
- package/dist/unique-file-token.d.ts +10 -0
- package/dist/unique-file-token.d.ts.map +1 -0
- package/dist/unique-file-token.js +13 -0
- package/dist/unique-file-token.js.map +1 -0
- package/dist/url-safe-passwords.d.ts +25 -0
- package/dist/url-safe-passwords.d.ts.map +1 -0
- package/dist/url-safe-passwords.js +70 -0
- package/dist/url-safe-passwords.js.map +1 -0
- package/dist/valkey-sidecar.d.ts +33 -6
- package/dist/valkey-sidecar.d.ts.map +1 -1
- package/dist/valkey-sidecar.js +90 -61
- package/dist/valkey-sidecar.js.map +1 -1
- package/dist/worker-module-files.d.ts +3 -0
- package/dist/worker-module-files.d.ts.map +1 -0
- package/dist/worker-module-files.js +18 -0
- package/dist/worker-module-files.js.map +1 -0
- package/package.json +20 -7
- package/.turbo/turbo-build.log +0 -4
- package/.turbo/turbo-test.log +0 -583
- package/.turbo/turbo-typecheck.log +0 -4
- package/assets/supatype-logo-wordmark.ascii.txt +0 -6
- package/bin/dev-entry.ts +0 -3
- package/dist/functions-router-gen.d.ts +0 -14
- package/dist/functions-router-gen.d.ts.map +0 -1
- package/dist/functions-router-gen.js +0 -231
- package/dist/functions-router-gen.js.map +0 -1
- package/dist/supatype-eval-1781522769253.d.mts +0 -2
- package/dist/supatype-eval-1781522769253.d.mts.map +0 -1
- package/dist/supatype-eval-1781522769253.mjs +0 -3
- package/dist/supatype-eval-1781522769253.mjs.map +0 -1
- package/scripts/build-release-artifacts.sh +0 -112
- package/scripts/generate-homebrew-formula.mjs +0 -123
- package/scripts/mirror-deno-release.sh +0 -76
- package/src/TYPE-RESOLUTION.md +0 -294
- package/src/adopt-walkthrough.ts +0 -142
- package/src/api-config-cache.ts +0 -172
- package/src/app/framework.ts +0 -247
- package/src/app/proxy-dev-app.ts +0 -175
- package/src/app-config.ts +0 -208
- package/src/app-vite-env.ts +0 -27
- package/src/augmentation-generator.ts +0 -279
- package/src/binary-cache.ts +0 -998
- package/src/binary-download-lock.ts +0 -124
- package/src/cache-clean.ts +0 -81
- package/src/cache-identity-scope.ts +0 -92
- package/src/cache-pins.ts +0 -243
- package/src/cache-provider.ts +0 -61
- package/src/cli-artifacts.ts +0 -65
- package/src/cli-install-method.ts +0 -98
- package/src/cli-package-version.ts +0 -19
- package/src/cli-standalone.ts +0 -144
- package/src/cli-version-embedded.ts +0 -12
- package/src/cli.ts +0 -87
- package/src/client-generator.ts +0 -122
- package/src/cloud-credentials.ts +0 -183
- package/src/commands/add.ts +0 -105
- package/src/commands/admin.ts +0 -819
- package/src/commands/adopt.ts +0 -81
- package/src/commands/app.ts +0 -100
- package/src/commands/cache.ts +0 -233
- package/src/commands/cloud.ts +0 -299
- package/src/commands/db.ts +0 -301
- package/src/commands/deploy-types.ts +0 -49
- package/src/commands/deploy.ts +0 -464
- package/src/commands/dev.ts +0 -1217
- package/src/commands/diff.ts +0 -73
- package/src/commands/doctor.ts +0 -197
- package/src/commands/engine.ts +0 -31
- package/src/commands/functions.ts +0 -1010
- package/src/commands/generate.ts +0 -45
- package/src/commands/hooks.ts +0 -138
- package/src/commands/init.ts +0 -1537
- package/src/commands/internal.ts +0 -60
- package/src/commands/introspect.ts +0 -48
- package/src/commands/keys.ts +0 -269
- package/src/commands/link-helpers.ts +0 -281
- package/src/commands/login.ts +0 -127
- package/src/commands/logs.ts +0 -56
- package/src/commands/migrate-from-v1.ts +0 -132
- package/src/commands/migrate.ts +0 -231
- package/src/commands/pg.ts +0 -128
- package/src/commands/plugins.ts +0 -517
- package/src/commands/pull.ts +0 -46
- package/src/commands/push.ts +0 -427
- package/src/commands/seed.ts +0 -319
- package/src/commands/self-host.ts +0 -404
- package/src/commands/self-update.ts +0 -89
- package/src/commands/status.ts +0 -117
- package/src/commands/types.ts +0 -77
- package/src/commands/update.ts +0 -172
- package/src/components.ts +0 -6
- package/src/compose-local-server-image.ts +0 -85
- package/src/compose-rename.ts +0 -73
- package/src/compose-services.ts +0 -175
- package/src/config.ts +0 -276
- package/src/db-port.ts +0 -99
- package/src/db-preflight.ts +0 -663
- package/src/dev-compose.ts +0 -1650
- package/src/dev-db-reset.ts +0 -95
- package/src/dev-initial-push.ts +0 -134
- package/src/dev-log-bus.ts +0 -121
- package/src/dev-log-filter.ts +0 -74
- package/src/dev-logo.ts +0 -61
- package/src/dev-ports.ts +0 -271
- package/src/dev-ready-panel.ts +0 -80
- package/src/dev-session-lock.ts +0 -98
- package/src/dev-session.ts +0 -210
- package/src/dev-shutdown.ts +0 -159
- package/src/dev-task-colors.ts +0 -66
- package/src/diff-output.ts +0 -90
- package/src/docker-postgres.ts +0 -295
- package/src/docker-runtime.ts +0 -151
- package/src/engine-client.ts +0 -350
- package/src/engine-floor.ts +0 -261
- package/src/engine-push-output.ts +0 -98
- package/src/ensure-binary.ts +0 -68
- package/src/ensure-component-binaries.ts +0 -71
- package/src/ensure-dev-api-config.ts +0 -18
- package/src/env-file.ts +0 -183
- package/src/field-bounds.ts +0 -359
- package/src/field-masking-tier.ts +0 -107
- package/src/functions-context-refresh.ts +0 -25
- package/src/functions-deno-types.ts +0 -258
- package/src/functions-router-gen.ts +0 -256
- package/src/gitignore.ts +0 -76
- package/src/hook-upload.ts +0 -107
- package/src/hooks-generator.ts +0 -444
- package/src/host-database.ts +0 -176
- package/src/index.ts +0 -11
- package/src/init-dependency-versions.ts +0 -69
- package/src/init-package-json.ts +0 -63
- package/src/init-project-detect.ts +0 -99
- package/src/jwt.ts +0 -14
- package/src/kong-config.ts +0 -116
- package/src/link.ts +0 -250
- package/src/local-gateway.ts +0 -9
- package/src/local-secrets.ts +0 -104
- package/src/local-storage.ts +0 -14
- package/src/main.ts +0 -20
- package/src/model-cache.ts +0 -122
- package/src/model-hooks.ts +0 -430
- package/src/model-versioning.ts +0 -167
- package/src/pgbouncer-userlist.ts +0 -15
- package/src/postgres-ctl.ts +0 -333
- package/src/preview-config-check.ts +0 -52
- package/src/process-manager.ts +0 -224
- package/src/project-config.ts +0 -939
- package/src/prompts.ts +0 -2
- package/src/pull-utils.ts +0 -275
- package/src/realtime-launch.ts +0 -52
- package/src/release-pins.ts +0 -31
- package/src/release-public-key.ts +0 -12
- package/src/required-host-components.ts +0 -37
- package/src/resolve-api-url.ts +0 -44
- package/src/resolve-target.ts +0 -480
- package/src/rest-cache-admin.ts +0 -141
- package/src/restore-system-relation-targets.ts +0 -45
- package/src/retired-no-cache.ts +0 -27
- package/src/route-manifest.ts +0 -17
- package/src/runtime-routes.ts +0 -298
- package/src/schema-ast-v2.ts +0 -488
- package/src/schema-push-lock.ts +0 -170
- package/src/schema-sources.ts +0 -248
- package/src/scripts/postinstall.ts +0 -20
- package/src/seed-ir.ts +0 -311
- package/src/seed-runner.ts +0 -109
- package/src/seed.ts +0 -451
- package/src/self-host-compose.ts +0 -1246
- package/src/service-role-check.ts +0 -111
- package/src/storage-provision.ts +0 -90
- package/src/strict.ts +0 -40
- package/src/studio-admin-roles.ts +0 -30
- package/src/studio-dev-server.ts +0 -70
- package/src/supatype-eval-1781522769253.mts +0 -1
- package/src/systemd.ts +0 -137
- package/src/target-client.ts +0 -127
- package/src/tsx-runner.ts +0 -128
- package/src/type-extractor.ts +0 -3365
- package/src/type-generation.ts +0 -169
- package/src/type-resolver.ts +0 -457
- package/src/ui/README.md +0 -21
- package/src/ui/brand.ts +0 -6
- package/src/ui/clack-api.ts +0 -123
- package/src/ui/clack.ts +0 -153
- package/src/ui/components/FlowSpinner.tsx +0 -15
- package/src/ui/components/LogoWordmark.tsx +0 -36
- package/src/ui/components/PromptPanel.tsx +0 -17
- package/src/ui/components/SelectField.tsx +0 -58
- package/src/ui/confirm.ts +0 -39
- package/src/ui/dev/DevDashboard.tsx +0 -223
- package/src/ui/dev/DevReadyPanelView.tsx +0 -134
- package/src/ui/fatal.ts +0 -38
- package/src/ui/flows/FlowApp.tsx +0 -69
- package/src/ui/flows/prompt-fields.tsx +0 -198
- package/src/ui/flows/types.ts +0 -50
- package/src/ui/index.ts +0 -8
- package/src/ui/interactive.ts +0 -4
- package/src/ui/messages.ts +0 -85
- package/src/ui/next-steps.ts +0 -10
- package/src/ui/progress.ts +0 -39
- package/src/ui/prompts.ts +0 -48
- package/src/ui/runtime/cancel.ts +0 -6
- package/src/ui/runtime/command-chrome.ts +0 -147
- package/src/ui/runtime/dev-prompt-queue.ts +0 -84
- package/src/ui/runtime/flow-session.ts +0 -11
- package/src/ui/runtime/run-clack-flow.tsx +0 -65
- package/src/ui/runtime/stdin-after-ink.ts +0 -20
- package/src/ui/theme.ts +0 -41
- package/src/valkey-sidecar.ts +0 -126
- package/tests/access-composition.test.ts +0 -790
- package/tests/admin-ensure.test.ts +0 -139
- package/tests/admin-studio-membership.test.ts +0 -121
- package/tests/adopt-result.test.ts +0 -27
- package/tests/adopt-walkthrough.test.ts +0 -129
- package/tests/api-config-cache-seed.test.ts +0 -180
- package/tests/api-schemas.test.ts +0 -83
- package/tests/app-command.test.ts +0 -64
- package/tests/archive-name-alias.test.ts +0 -42
- package/tests/ast-derived-outputs.test.ts +0 -92
- package/tests/augmentation-generator.test.ts +0 -393
- package/tests/binary-cache-cloud-overrides.test.ts +0 -123
- package/tests/binary-download-lock.test.ts +0 -41
- package/tests/cache-clean.test.ts +0 -206
- package/tests/cache-identity-scope.test.ts +0 -61
- package/tests/cache-provider-config.test.ts +0 -132
- package/tests/cached-artifact-format.test.ts +0 -84
- package/tests/cli-help.test.ts +0 -170
- package/tests/cli-install-method.test.ts +0 -66
- package/tests/cli-package-version.test.ts +0 -15
- package/tests/client-generator.test.ts +0 -103
- package/tests/command-chrome-coverage.test.ts +0 -154
- package/tests/command-chrome-wrap.test.ts +0 -52
- package/tests/compose-parsable-defaults.test.ts +0 -60
- package/tests/compose-services.test.ts +0 -144
- package/tests/config-load-failure.test.ts +0 -44
- package/tests/config.test.ts +0 -301
- package/tests/db-port.test.ts +0 -128
- package/tests/db-preflight.test.ts +0 -152
- package/tests/db-published-and-addressable.test.ts +0 -69
- package/tests/dev-db-reset.test.ts +0 -162
- package/tests/dev-initial-push.test.ts +0 -142
- package/tests/dev-ports-owner.test.ts +0 -40
- package/tests/dev-ports.test.ts +0 -41
- package/tests/dev-ready-panel.test.ts +0 -37
- package/tests/dev-session-lock.test.ts +0 -54
- package/tests/dev-ui.test.ts +0 -202
- package/tests/docker-postgres.test.ts +0 -39
- package/tests/docker-runtime.test.ts +0 -225
- package/tests/doctor-render.test.ts +0 -62
- package/tests/doctor-service-role.test.ts +0 -55
- package/tests/engine-floor.test.ts +0 -238
- package/tests/engine-push-output.test.ts +0 -96
- package/tests/ensure-binary.test.ts +0 -59
- package/tests/ensure-dev-api-config.test.ts +0 -22
- package/tests/env-file.test.ts +0 -121
- package/tests/external-database-compose.test.ts +0 -262
- package/tests/external-database-config.test.ts +0 -154
- package/tests/field-bounds-matrix.test.ts +0 -163
- package/tests/field-bounds.test.ts +0 -139
- package/tests/field-masking-tier.test.ts +0 -184
- package/tests/field-validators.test.ts +0 -139
- package/tests/fixtures/identity-scope-corpus.json +0 -42
- package/tests/fixtures/seed_golden_ir.json +0 -186
- package/tests/functions-concurrency.test.ts +0 -71
- package/tests/functions-context-refresh.test.ts +0 -86
- package/tests/functions-deno-types.test.ts +0 -197
- package/tests/gitignore-secrets.test.ts +0 -90
- package/tests/homebrew-formula.test.ts +0 -100
- package/tests/hook-upload.test.ts +0 -125
- package/tests/hooks-generator.test.ts +0 -298
- package/tests/host-connection-targets.test.ts +0 -84
- package/tests/host-database.test.ts +0 -176
- package/tests/init-dependency-versions.test.ts +0 -62
- package/tests/init-package-json.test.ts +0 -18
- package/tests/init-project-detect.test.ts +0 -53
- package/tests/init.test.ts +0 -369
- package/tests/keys-write.test.ts +0 -148
- package/tests/keys.test.ts +0 -166
- package/tests/link.test.ts +0 -148
- package/tests/local-secrets.test.ts +0 -92
- package/tests/local-server-image-env.test.ts +0 -93
- package/tests/migrate-from-v1.test.ts +0 -29
- package/tests/minisign.test.ts +0 -102
- package/tests/model-cache-declaration.test.ts +0 -229
- package/tests/model-cache-manifest.test.ts +0 -99
- package/tests/model-constraints.test.ts +0 -293
- package/tests/model-hooks.test.ts +0 -433
- package/tests/model-versions.test.ts +0 -229
- package/tests/native-keyspace.test.ts +0 -130
- package/tests/normalize-admin-config.test.ts +0 -48
- package/tests/pg-spawn-env.test.ts +0 -18
- package/tests/port-in-use.test.ts +0 -58
- package/tests/postgres-archive-tag.test.ts +0 -9
- package/tests/preview-config-check.test.ts +0 -104
- package/tests/proxy-dev-app.test.ts +0 -77
- package/tests/pull-utils.test.ts +0 -151
- package/tests/readiness-poll.test.ts +0 -84
- package/tests/realtime-launch.test.ts +0 -25
- package/tests/release-pins.test.ts +0 -28
- package/tests/required-host-components.test.ts +0 -53
- package/tests/resolve-api-url.test.ts +0 -23
- package/tests/rest-cache-admin.test.ts +0 -64
- package/tests/retired-no-cache.test.ts +0 -46
- package/tests/route-manifest.test.ts +0 -29
- package/tests/runtime-contract.test.ts +0 -948
- package/tests/schema-sources.test.ts +0 -119
- package/tests/seed-discover.test.ts +0 -31
- package/tests/seed-ir.test.ts +0 -436
- package/tests/self-host-keys.test.ts +0 -92
- package/tests/service-role-check.test.ts +0 -109
- package/tests/service-role-routes.test.ts +0 -51
- package/tests/stdin-after-ink.test.ts +0 -8
- package/tests/storage-provision.test.ts +0 -100
- package/tests/strict.test.ts +0 -78
- package/tests/studio-admin-roles.test.ts +0 -59
- package/tests/target-client-refresh.test.ts +0 -94
- package/tests/tsconfig.json +0 -15
- package/tests/tsx-runner.test.ts +0 -66
- package/tests/type-extractor.test.ts +0 -1601
- package/tests/type-resolver.test.ts +0 -59
- package/tests/ui-confirm.test.ts +0 -45
- package/tests/ui-messages.test.ts +0 -52
- package/tsconfig.json +0 -11
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -21
package/dist/type-extractor.js
CHANGED
|
@@ -2,9 +2,12 @@ import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
4
4
|
import ts from "typescript";
|
|
5
|
+
import { isJsonObject, isOneOf } from "@supatype/shared";
|
|
5
6
|
import { isIdentityDependent } from "./cache-identity-scope.js";
|
|
6
7
|
import { applyImportRename, createResolveContext, needsChecker, resolveTypeNode, tryResolveTypeReference, unknownTypeError, } from "./type-resolver.js";
|
|
7
|
-
import { emitField, emitModel, emitSchema, defaultPgTypeForKind, scalar, } from "./schema-ast-v2.js";
|
|
8
|
+
import { emitField, emitModel, emitSchema, defaultPgTypeForKind, isFieldKind, scalar, } from "./schema-ast-v2.js";
|
|
9
|
+
import { jsonTypeArgText } from "./json-type-text.js";
|
|
10
|
+
import { callerOwnedIds } from "./owner-default.js";
|
|
8
11
|
import { compileBounds, measureFormFor } from "./field-bounds.js";
|
|
9
12
|
export function extractSchemaAstFromTypes(schemaPath, cwd = process.cwd()) {
|
|
10
13
|
const absPath = resolve(cwd, schemaPath);
|
|
@@ -47,13 +50,14 @@ export function extractSchemaAstFromTypes(schemaPath, cwd = process.cwd()) {
|
|
|
47
50
|
const modelTypeName = stmt.type.typeName.getText(sourceFile);
|
|
48
51
|
if (modelTypeName !== "Model" && modelTypeName !== "LocalizedModel")
|
|
49
52
|
continue;
|
|
50
|
-
const [fieldsArg,
|
|
53
|
+
const [fieldsArg, optionsArg] = stmt.type.typeArguments ?? [];
|
|
51
54
|
if (!fieldsArg)
|
|
52
55
|
continue;
|
|
53
56
|
const fieldsLiteral = unwrapModelFields(fieldsArg, sourceFile, resolveCtx);
|
|
54
57
|
if (!fieldsLiteral)
|
|
55
58
|
continue;
|
|
56
|
-
const
|
|
59
|
+
const metaArg = resolveModelOptions(optionsArg, sourceFile, resolveCtx, stmt.name.text);
|
|
60
|
+
const metaHints = parseMetaLiteral(metaArg, sourceFile, resolveCtx, stmt.name.text);
|
|
57
61
|
const fieldContext = {
|
|
58
62
|
autoLocalize: modelTypeName === "LocalizedModel" || metaHints.autoLocalize === true,
|
|
59
63
|
};
|
|
@@ -64,10 +68,12 @@ export function extractSchemaAstFromTypes(schemaPath, cwd = process.cwd()) {
|
|
|
64
68
|
const name = getPropertyName(member.name);
|
|
65
69
|
if (!name)
|
|
66
70
|
continue;
|
|
71
|
+
if (member.questionToken !== undefined)
|
|
72
|
+
refuseQuestionToken(member.type, stmt.name.text, name);
|
|
67
73
|
fields[name] = parseFieldType(name, member.type, sourceFile, blockAliases, bucketAliases, bucketsById, fieldContext, resolveCtx);
|
|
68
74
|
}
|
|
69
75
|
const { tableName, access, options, indexes, constraints, hooks, validators, searchFields, cache, } = parseModelMeta(metaArg, sourceFile, stmt.name.text, fieldsArg, fields, resolveCtx);
|
|
70
|
-
models.push(emitModel(stmt.name.text, fields, options, tableName, access, indexes, hooks, constraints, validators, searchFields, cache));
|
|
76
|
+
models.push(emitModel(stmt.name.text, withUuidKeyDefaults(fields, access["create"]), options, tableName, access, indexes, hooks, constraints, validators, searchFields, cache));
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
79
|
if (models.length === 0)
|
|
@@ -91,8 +97,36 @@ export function extractSchemaAstFromTypes(schemaPath, cwd = process.cwd()) {
|
|
|
91
97
|
}),
|
|
92
98
|
});
|
|
93
99
|
}
|
|
94
|
-
|
|
100
|
+
/**
|
|
101
|
+
* A `?` on a model field reads as "nullable" but the column comes out NOT NULL, because nullability
|
|
102
|
+
* is carried by `Optional<>`, not by the property. Refuse it so the two never disagree silently.
|
|
103
|
+
*/
|
|
104
|
+
function refuseQuestionToken(type, modelName, fieldName) {
|
|
105
|
+
// From the field's own file: a field can come from another one through an intersection.
|
|
106
|
+
const typeText = type.getText();
|
|
107
|
+
throw new Error(`${modelName}.${fieldName} is declared with \`?\`, which Supatype does not read as nullable. ` +
|
|
108
|
+
`Write \`${fieldName}: Optional<${typeText}>\` for a nullable column, or drop the \`?\` for a required one.`);
|
|
109
|
+
}
|
|
110
|
+
const GEO_SHAPES = ["point", "polygon", "linestring"];
|
|
111
|
+
/** The shape of `Geo<"polygon">`; a bare `Geo` is a point. */
|
|
112
|
+
function parseGeoShape(arg, fieldName, sourceFile) {
|
|
113
|
+
if (arg === undefined)
|
|
114
|
+
return "point";
|
|
115
|
+
const shape = literalStringType(arg);
|
|
116
|
+
if (shape !== null && isOneOf(GEO_SHAPES)(shape))
|
|
117
|
+
return shape;
|
|
118
|
+
throw new Error(`Field "${fieldName}": Geo<${arg.getText(sourceFile)}> is not a shape Geo has. Use point, polygon or linestring.`);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The project root as a real path, so it compares with the real paths of the files under it. A
|
|
122
|
+
* root reached through a symlink (macOS `/var` is `/private/var`) otherwise puts every file "outside".
|
|
123
|
+
*/
|
|
124
|
+
function realProjectRoot(projectRoot) {
|
|
95
125
|
const root = resolve(projectRoot);
|
|
126
|
+
return existsSync(root) ? realpathSync(root) : root;
|
|
127
|
+
}
|
|
128
|
+
export function collectSchemaSourcePaths(entryAbsPath, projectRoot) {
|
|
129
|
+
const root = realProjectRoot(projectRoot);
|
|
96
130
|
const entryReal = realpathSync(entryAbsPath);
|
|
97
131
|
const entryPoint = relative(root, entryReal).replace(/\\/g, "/");
|
|
98
132
|
if (entryPoint.startsWith("..")) {
|
|
@@ -117,7 +151,8 @@ export function collectSchemaSourcePaths(entryAbsPath, projectRoot) {
|
|
|
117
151
|
files.sort((a, b) => a.relativePath.localeCompare(b.relativePath));
|
|
118
152
|
return { entryPoint, files };
|
|
119
153
|
}
|
|
120
|
-
|
|
154
|
+
/** Every schema source file the entry reaches through relative imports, entry first. */
|
|
155
|
+
export function walkSchemaSourceAbsPaths(entryPath) {
|
|
121
156
|
const visited = new Set();
|
|
122
157
|
const paths = [];
|
|
123
158
|
const queue = [entryPath];
|
|
@@ -350,6 +385,19 @@ function isArrayLikeTypeNode(node, sourceFile) {
|
|
|
350
385
|
}
|
|
351
386
|
return false;
|
|
352
387
|
}
|
|
388
|
+
/**
|
|
389
|
+
* `fields` with `gen_random_uuid()` on each uuid primary key that declares no default of its own,
|
|
390
|
+
* except an auth user id `createRule` makes the caller's: a random uuid would name no user, and the
|
|
391
|
+
* engine defaults that column to the caller instead. A default the schema writes is never touched.
|
|
392
|
+
*/
|
|
393
|
+
function withUuidKeyDefaults(fields, createRule) {
|
|
394
|
+
const callerOwned = callerOwnedIds(createRule, fields);
|
|
395
|
+
const entries = Object.entries(fields).map(([name, field]) => {
|
|
396
|
+
const randomKey = field.kind === "uuid" && field["primaryKey"] === true && field["default"] === undefined && !callerOwned.has(name);
|
|
397
|
+
return [name, randomKey ? { ...field, default: { kind: "genRandomUuid" } } : field];
|
|
398
|
+
});
|
|
399
|
+
return Object.fromEntries(entries);
|
|
400
|
+
}
|
|
353
401
|
function parseFieldType(fieldName, typeNode, sourceFile, blockAliases, bucketAliases, bucketsById, context = {}, resolveCtx) {
|
|
354
402
|
const flags = {
|
|
355
403
|
required: true,
|
|
@@ -357,7 +405,6 @@ function parseFieldType(fieldName, typeNode, sourceFile, blockAliases, bucketAli
|
|
|
357
405
|
index: false,
|
|
358
406
|
primaryKey: false,
|
|
359
407
|
serverGenerated: false,
|
|
360
|
-
autoIncrement: false,
|
|
361
408
|
relationCardinality: undefined,
|
|
362
409
|
relationTarget: undefined,
|
|
363
410
|
editorReadOnly: false,
|
|
@@ -368,6 +415,13 @@ function parseFieldType(fieldName, typeNode, sourceFile, blockAliases, bucketAli
|
|
|
368
415
|
notLocalized: false,
|
|
369
416
|
searchable: false,
|
|
370
417
|
bounds: {},
|
|
418
|
+
/** `Identity<>` / `AutoIncrement<>`: the mode, and whether the integer came as `number` or `bigint`. */
|
|
419
|
+
identity: undefined,
|
|
420
|
+
identityKeyword: undefined,
|
|
421
|
+
/** `AutoIncrement<>`: an identity by default that a live serial column satisfies. */
|
|
422
|
+
autoIncrement: false,
|
|
423
|
+
/** `Generated<T, expr>`. */
|
|
424
|
+
generated: undefined,
|
|
371
425
|
};
|
|
372
426
|
const resolving = new Set();
|
|
373
427
|
let current = typeNode;
|
|
@@ -390,11 +444,38 @@ function parseFieldType(fieldName, typeNode, sourceFile, blockAliases, bucketAli
|
|
|
390
444
|
flags.serverGenerated = true;
|
|
391
445
|
current = current.typeArguments?.[0] ?? current;
|
|
392
446
|
continue;
|
|
393
|
-
case "
|
|
394
|
-
|
|
395
|
-
|
|
447
|
+
case "Identity":
|
|
448
|
+
case "AutoIncrement": {
|
|
449
|
+
// `AutoIncrement<T>` is `Identity<T, "by-default">`, and says so to the engine, which then
|
|
450
|
+
// leaves a serial column made when it compiled to one (identity-contract). Either defaults
|
|
451
|
+
// to `number`.
|
|
452
|
+
const mode = typeName === "Identity" ? literalStringType(current.typeArguments?.[1]) : "by-default";
|
|
453
|
+
if (typeName === "Identity" && current.typeArguments?.[1] !== undefined && mode === null) {
|
|
454
|
+
throw new Error(`Field "${fieldName}": an identity is "always" or "by-default".`);
|
|
455
|
+
}
|
|
456
|
+
flags.identity = identityAst(mode ?? "always", fieldName);
|
|
457
|
+
flags.autoIncrement = typeName === "AutoIncrement";
|
|
458
|
+
const inner = current.typeArguments?.[0];
|
|
459
|
+
if (inner === undefined || inner.kind === ts.SyntaxKind.NumberKeyword) {
|
|
460
|
+
flags.identityKeyword = "integer";
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
if (inner.kind === ts.SyntaxKind.BigIntKeyword) {
|
|
464
|
+
flags.identityKeyword = "bigInt";
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
current = inner;
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
case "Generated": {
|
|
471
|
+
const expression = literalStringType(current.typeArguments?.[1]);
|
|
472
|
+
if (expression === null || expression.trim() === "") {
|
|
473
|
+
throw new Error(`Field "${fieldName}": Generated<T, expression> takes the column's SQL expression as a string literal, such as Generated<string, "lower(name)">.`);
|
|
474
|
+
}
|
|
475
|
+
flags.generated = expression;
|
|
396
476
|
current = current.typeArguments?.[0] ?? current;
|
|
397
477
|
continue;
|
|
478
|
+
}
|
|
398
479
|
case "PrimaryKey":
|
|
399
480
|
flags.primaryKey = true;
|
|
400
481
|
flags.required = true;
|
|
@@ -545,7 +626,9 @@ function parseFieldType(fieldName, typeNode, sourceFile, blockAliases, bucketAli
|
|
|
545
626
|
}
|
|
546
627
|
break;
|
|
547
628
|
}
|
|
548
|
-
const scalarBase =
|
|
629
|
+
const scalarBase = flags.identityKeyword !== undefined
|
|
630
|
+
? scalar(flags.identityKeyword)
|
|
631
|
+
: parseScalarType(current, sourceFile, blockAliases, bucketAliases, bucketsById, context, resolveCtx, fieldName, resolving);
|
|
549
632
|
let parsed = {
|
|
550
633
|
kind: scalarBase.kind,
|
|
551
634
|
kernel: {
|
|
@@ -564,9 +647,9 @@ function parseFieldType(fieldName, typeNode, sourceFile, blockAliases, bucketAli
|
|
|
564
647
|
...(flags.searchable && { searchable: true }),
|
|
565
648
|
},
|
|
566
649
|
};
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
650
|
+
parsed = withGeneration(fieldName, parsed, flags.identity, flags.generated);
|
|
651
|
+
if (flags.autoIncrement)
|
|
652
|
+
parsed = { ...parsed, kernel: { ...parsed.kernel, autoIncrement: true } };
|
|
570
653
|
if (fieldName === "id" && parsed.kind === "uuid" && flags.primaryKey === false) {
|
|
571
654
|
parsed = {
|
|
572
655
|
...parsed,
|
|
@@ -583,14 +666,8 @@ function parseFieldType(fieldName, typeNode, sourceFile, blockAliases, bucketAli
|
|
|
583
666
|
kernel: { ...parsed.kernel, default: { kind: "value", value: flags.fieldDefault } },
|
|
584
667
|
};
|
|
585
668
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
...parsed,
|
|
589
|
-
kernel: { ...parsed.kernel, default: { kind: "genRandomUuid" } },
|
|
590
|
-
};
|
|
591
|
-
}
|
|
592
|
-
else if (parsed.kernel.primaryKey === true &&
|
|
593
|
-
(parsed.kind === "serial" || parsed.kind === "bigSerial")) {
|
|
669
|
+
// A uuid key's default waits for the model's access rule: withUuidKeyDefaults decides it.
|
|
670
|
+
if (parsed.kernel.primaryKey === true && (parsed.kind === "serial" || parsed.kind === "bigSerial")) {
|
|
594
671
|
flags.serverGenerated = true;
|
|
595
672
|
}
|
|
596
673
|
if (flags.serverGenerated === true) {
|
|
@@ -631,6 +708,14 @@ function parseFieldType(fieldName, typeNode, sourceFile, blockAliases, bucketAli
|
|
|
631
708
|
if (jsonIsArray) {
|
|
632
709
|
parsed = { ...parsed, kernel: { ...parsed.kernel, jsonArray: true } };
|
|
633
710
|
}
|
|
711
|
+
// `JSON<T>` keeps its `T` in the generated row. Kinds that set their own shape (`Duration`,
|
|
712
|
+
// `Code`, `Currency`) are JSON too and already carry `tsType`; theirs stands.
|
|
713
|
+
const jsonType = parsed.kind === "json" && parsed.kernel.tsType === undefined
|
|
714
|
+
? jsonTypeArgText(current, resolveCtx)
|
|
715
|
+
: undefined;
|
|
716
|
+
if (jsonType !== undefined) {
|
|
717
|
+
parsed = { ...parsed, kernel: { ...parsed.kernel, tsType: jsonType } };
|
|
718
|
+
}
|
|
634
719
|
if (Object.keys(flags.bounds).length > 0) {
|
|
635
720
|
const compiled = compileBounds(fieldName, parsed.kind, flags.bounds, { jsonIsArray });
|
|
636
721
|
parsed = {
|
|
@@ -646,12 +731,44 @@ function parseFieldType(fieldName, typeNode, sourceFile, blockAliases, bucketAli
|
|
|
646
731
|
}
|
|
647
732
|
return emitField(finalizeParsedField(parsed, flags, context));
|
|
648
733
|
}
|
|
734
|
+
/**
|
|
735
|
+
* The field with how the database fills it (identity-contract): the alias forms (`Identity<>`,
|
|
736
|
+
* `AutoIncrement<>`, `Generated<>`) and the options form arrive here as one. An identity column is an
|
|
737
|
+
* integer and NOT NULL; neither kind takes a default; both may be left out of an insert.
|
|
738
|
+
*/
|
|
739
|
+
function withGeneration(fieldName, parsed, aliasIdentity, aliasGenerated) {
|
|
740
|
+
const identity = aliasIdentity ?? parsed.kernel.identity;
|
|
741
|
+
const generated = aliasGenerated !== undefined ? { expression: aliasGenerated, stored: true } : parsed.kernel.generated;
|
|
742
|
+
if (identity === undefined && generated === undefined)
|
|
743
|
+
return parsed;
|
|
744
|
+
if (identity !== undefined && generated !== undefined) {
|
|
745
|
+
throw new Error(`Field "${fieldName}": a column is an identity column or a generated one, not both.`);
|
|
746
|
+
}
|
|
747
|
+
if (identity !== undefined && !["integer", "smallInt", "bigInt"].includes(parsed.kind)) {
|
|
748
|
+
throw new Error(`Field "${fieldName}": only an integer field (Int, SmallInt or BigInt) can be an identity column.`);
|
|
749
|
+
}
|
|
750
|
+
if (parsed.kernel.default !== undefined) {
|
|
751
|
+
throw new Error(`Field "${fieldName}": an identity or generated column cannot also have a default.`);
|
|
752
|
+
}
|
|
753
|
+
return {
|
|
754
|
+
...parsed,
|
|
755
|
+
kernel: {
|
|
756
|
+
...parsed.kernel,
|
|
757
|
+
...(identity !== undefined && { identity, required: true }),
|
|
758
|
+
...(generated !== undefined && { generated }),
|
|
759
|
+
},
|
|
760
|
+
db: { ...parsed.db, serverGenerated: true },
|
|
761
|
+
};
|
|
762
|
+
}
|
|
649
763
|
function finalizeParsedField(parsed, flags, context) {
|
|
650
764
|
let localized = flags.localized;
|
|
651
765
|
if (!localized &&
|
|
652
766
|
!flags.notLocalized &&
|
|
653
767
|
context.autoLocalize &&
|
|
654
|
-
shouldAutoLocalizeFieldKind(parsed.kind)
|
|
768
|
+
shouldAutoLocalizeFieldKind(parsed.kind) &&
|
|
769
|
+
// The database computes it from the row: one value, not one per locale.
|
|
770
|
+
parsed.kernel.generated === undefined &&
|
|
771
|
+
parsed.kernel.identity === undefined) {
|
|
655
772
|
localized = true;
|
|
656
773
|
}
|
|
657
774
|
if (parsed.kind === "blocks" && parsed.kernel.blocks && context.autoLocalize && !localized) {
|
|
@@ -686,7 +803,7 @@ function localizeFieldWire(field) {
|
|
|
686
803
|
return field;
|
|
687
804
|
if (!shouldAutoLocalizeFieldKind(field.kind))
|
|
688
805
|
return field;
|
|
689
|
-
const annotations =
|
|
806
|
+
const annotations = field.annotations ?? {};
|
|
690
807
|
return {
|
|
691
808
|
...field,
|
|
692
809
|
localized: true,
|
|
@@ -704,13 +821,12 @@ function parseScalarType(typeNode, sourceFile, blockAliases, bucketAliases, buck
|
|
|
704
821
|
});
|
|
705
822
|
}
|
|
706
823
|
if (ts.isUnionTypeNode(typeNode)) {
|
|
707
|
-
const
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
});
|
|
824
|
+
const strings = typeNode.types
|
|
825
|
+
.filter(ts.isLiteralTypeNode)
|
|
826
|
+
.map((lit) => lit.literal)
|
|
827
|
+
.filter(ts.isStringLiteral);
|
|
828
|
+
if (strings.length === typeNode.types.length) {
|
|
829
|
+
return scalar("enum", { kernel: { values: strings.map((lit) => lit.text) } });
|
|
714
830
|
}
|
|
715
831
|
const nonNull = typeNode.types.find((t) => t.kind !== ts.SyntaxKind.NullKeyword);
|
|
716
832
|
if (nonNull) {
|
|
@@ -727,10 +843,19 @@ function parseScalarType(typeNode, sourceFile, blockAliases, bucketAliases, buck
|
|
|
727
843
|
const ref = ts.isIdentifier(typeNode.typeName)
|
|
728
844
|
? applyImportRename(typeNode.typeName.text, sourceFile, resolveCtx.renameMap)
|
|
729
845
|
: typeNode.typeName.getText(sourceFile);
|
|
846
|
+
// A scalar field type's options, its last type argument: `Int<{ identity: "always" }>`.
|
|
847
|
+
const options = (allow = {}) => parseScalarFieldOptions(typeNode.typeArguments?.[0], fieldName, ref, allow.identity === true);
|
|
730
848
|
switch (ref) {
|
|
731
849
|
case "UUID":
|
|
732
|
-
|
|
733
|
-
|
|
850
|
+
return scalar("uuid", { kernel: options() });
|
|
851
|
+
// Marked, because the engine cannot tell an auth user id from any other UUID: a model keyed
|
|
852
|
+
// by one is a user's own, which an owner relation may point at (O1).
|
|
853
|
+
case "SupatypeAuthUserId": {
|
|
854
|
+
const onDelete = parseAuthUserOnDelete(typeNode.typeArguments?.[0], fieldName);
|
|
855
|
+
return scalar("uuid", {
|
|
856
|
+
db: { authUserId: true, ...(onDelete !== undefined && { authUserOnDelete: onDelete }) },
|
|
857
|
+
});
|
|
858
|
+
}
|
|
734
859
|
case "RichText": {
|
|
735
860
|
const defaultArg = typeNode.typeArguments?.[0];
|
|
736
861
|
if (!defaultArg)
|
|
@@ -752,28 +877,28 @@ function parseScalarType(typeNode, sourceFile, blockAliases, bucketAliases, buck
|
|
|
752
877
|
return scalar("slug", { kernel: { from: fromLiteral ?? "title" } });
|
|
753
878
|
}
|
|
754
879
|
case "Email":
|
|
755
|
-
return scalar("email");
|
|
880
|
+
return scalar("email", { kernel: options() });
|
|
756
881
|
case "URL":
|
|
757
|
-
return scalar("url");
|
|
882
|
+
return scalar("url", { kernel: options() });
|
|
758
883
|
case "Markdown":
|
|
759
884
|
case "PhoneNumber":
|
|
760
|
-
return scalar("text");
|
|
885
|
+
return scalar("text", { kernel: options() });
|
|
761
886
|
case "Color":
|
|
762
|
-
return scalar("color");
|
|
887
|
+
return scalar("color", { kernel: options() });
|
|
763
888
|
case "IPAddress":
|
|
764
|
-
return scalar("ip");
|
|
889
|
+
return scalar("ip", { kernel: options() });
|
|
765
890
|
case "CIDR":
|
|
766
|
-
return scalar("cidr");
|
|
891
|
+
return scalar("cidr", { kernel: options() });
|
|
767
892
|
case "MacAddress":
|
|
768
|
-
return scalar("macaddr");
|
|
893
|
+
return scalar("macaddr", { kernel: options() });
|
|
769
894
|
case "XML":
|
|
770
|
-
return scalar("xml");
|
|
895
|
+
return scalar("xml", { kernel: options() });
|
|
771
896
|
case "TSQuery":
|
|
772
|
-
return scalar("tsQuery");
|
|
897
|
+
return scalar("tsQuery", { kernel: options() });
|
|
773
898
|
case "TSVector":
|
|
774
|
-
return scalar("tsVector");
|
|
899
|
+
return scalar("tsVector", { kernel: options() });
|
|
775
900
|
case "Money":
|
|
776
|
-
return scalar("money");
|
|
901
|
+
return scalar("money", { kernel: options() });
|
|
777
902
|
case "Decimal": {
|
|
778
903
|
// `Decimal<10, 2>` names a precision and a scale, and the engine renders `NUMERIC(p, s)`
|
|
779
904
|
// from them: but nothing used to read the type arguments, so every Decimal became an
|
|
@@ -788,21 +913,21 @@ function parseScalarType(typeNode, sourceFile, blockAliases, bucketAliases, buck
|
|
|
788
913
|
});
|
|
789
914
|
}
|
|
790
915
|
case "DateOnly":
|
|
791
|
-
return scalar("date");
|
|
916
|
+
return scalar("date", { kernel: options() });
|
|
792
917
|
case "Date":
|
|
793
918
|
case "DateTime":
|
|
794
919
|
case "Timestamp":
|
|
795
|
-
return scalar("datetime", { db: { pgType: "TIMESTAMP WITH TIME ZONE" } });
|
|
920
|
+
return scalar("datetime", { db: { pgType: "TIMESTAMP WITH TIME ZONE" }, kernel: options() });
|
|
796
921
|
case "Int":
|
|
797
|
-
return scalar("integer");
|
|
922
|
+
return scalar("integer", { kernel: options({ identity: true }) });
|
|
798
923
|
case "SmallInt":
|
|
799
|
-
return scalar("smallInt");
|
|
924
|
+
return scalar("smallInt", { kernel: options({ identity: true }) });
|
|
800
925
|
case "BigInt":
|
|
801
|
-
return scalar("bigInt");
|
|
926
|
+
return scalar("bigInt", { kernel: options({ identity: true }) });
|
|
802
927
|
case "Float":
|
|
803
|
-
return scalar("float");
|
|
928
|
+
return scalar("float", { kernel: options() });
|
|
804
929
|
case "Bytea":
|
|
805
|
-
return scalar("bytes");
|
|
930
|
+
return scalar("bytes", { kernel: options() });
|
|
806
931
|
case "JSON":
|
|
807
932
|
return scalar("json");
|
|
808
933
|
case "Button":
|
|
@@ -839,7 +964,7 @@ function parseScalarType(typeNode, sourceFile, blockAliases, bucketAliases, buck
|
|
|
839
964
|
}
|
|
840
965
|
case "GeoPoint":
|
|
841
966
|
case "Geo":
|
|
842
|
-
return scalar("geo", { kernel: { geoType:
|
|
967
|
+
return scalar("geo", { kernel: { geoType: parseGeoShape(typeNode.typeArguments?.[0], fieldName, sourceFile), srid: 4326 } });
|
|
843
968
|
case "Asset":
|
|
844
969
|
case "FileAsset": {
|
|
845
970
|
const bucket = resolveBucketName(typeNode.typeArguments?.[0], sourceFile, bucketAliases, "assets");
|
|
@@ -976,12 +1101,12 @@ function collectBucketContext(sourceFile, resolveCtx) {
|
|
|
976
1101
|
return { aliases, bucketsById };
|
|
977
1102
|
}
|
|
978
1103
|
function buildExtractedBucketAst(id, parsed) {
|
|
979
|
-
|
|
980
|
-
|
|
1104
|
+
// Visibility only when the schema names it: a push leaves an unnamed one as the live bucket has
|
|
1105
|
+
// it, and a filled-in `private` named it, undoing a runtime change on every push.
|
|
1106
|
+
const mode = parsed.accessMode;
|
|
981
1107
|
const row = {
|
|
982
1108
|
id,
|
|
983
|
-
public:
|
|
984
|
-
accessMode: mode,
|
|
1109
|
+
...(mode !== undefined && { public: mode === "public", accessMode: mode }),
|
|
985
1110
|
...(parsed.allowedMimeTypes !== undefined && parsed.allowedMimeTypes.length > 0
|
|
986
1111
|
? { allowedMimeTypes: parsed.allowedMimeTypes }
|
|
987
1112
|
: {}),
|
|
@@ -1015,9 +1140,9 @@ function parseBucketTypeLiteral(lit, sourceFile, bucketId, resolveCtx) {
|
|
|
1015
1140
|
continue;
|
|
1016
1141
|
}
|
|
1017
1142
|
if (key === "accept") {
|
|
1018
|
-
const types =
|
|
1019
|
-
if (types
|
|
1020
|
-
out.allowedMimeTypes = types;
|
|
1143
|
+
const types = acceptList(member.type, sourceFile, bucketId);
|
|
1144
|
+
if (types.length > 0)
|
|
1145
|
+
out.allowedMimeTypes = acceptedMimeTypes(bucketId, types);
|
|
1021
1146
|
continue;
|
|
1022
1147
|
}
|
|
1023
1148
|
if (key === "access") {
|
|
@@ -1047,32 +1172,51 @@ function parseSizeStringLiteral(typeNode, sourceFile) {
|
|
|
1047
1172
|
function parseJsonStringLiteral(typeNode, sourceFile) {
|
|
1048
1173
|
return parseSizeStringLiteral(typeNode, sourceFile);
|
|
1049
1174
|
}
|
|
1050
|
-
|
|
1175
|
+
/**
|
|
1176
|
+
* A MIME type a bucket can accept: `type/subtype` in RFC 6838's restricted names, or `type/*`. The
|
|
1177
|
+
* storage service's own rule (`packages/storage/src/bucket-rules.ts`), so a type it would refuse at
|
|
1178
|
+
* provisioning stops the schema here instead.
|
|
1179
|
+
*/
|
|
1180
|
+
export const BUCKET_MIME_TYPE = /^[a-z0-9][a-z0-9!#$&^_.+-]{0,126}\/(\*|[a-z0-9][a-z0-9!#$&^_.+-]{0,126})$/i;
|
|
1181
|
+
/** `types`, when each is a MIME type a bucket can accept; throws naming the first that is not. */
|
|
1182
|
+
function acceptedMimeTypes(bucketId, types) {
|
|
1183
|
+
const bad = types.find((type) => !BUCKET_MIME_TYPE.test(type));
|
|
1184
|
+
if (bad === undefined)
|
|
1185
|
+
return types;
|
|
1186
|
+
throw new Error(`Bucket "${bucketId}": accept holds "${bad}", which is not a MIME type. ` +
|
|
1187
|
+
`Use "type/subtype" or "type/*", such as "image/png" or "image/*".`);
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* The MIME types a bucket's `accept` lists, an empty list meaning no limit. Any form but string
|
|
1191
|
+
* literals written in place is refused: it was read as no list at all, so the bucket took every type.
|
|
1192
|
+
*/
|
|
1193
|
+
function acceptList(typeNode, sourceFile, bucketId) {
|
|
1194
|
+
const types = parseMimeAcceptList(typeNode);
|
|
1195
|
+
if (types !== null)
|
|
1196
|
+
return types;
|
|
1197
|
+
throw new Error(`Bucket "${bucketId}": could not read its \`accept\` list from \`${typeNode.getText(sourceFile)}\`.\n` +
|
|
1198
|
+
` accept lists MIME types as string literals in place, e.g. accept: ["image/png", "image/*"]`);
|
|
1199
|
+
}
|
|
1200
|
+
/** The string literals a tuple or a union lists, or null when it is written any other way. */
|
|
1201
|
+
function parseMimeAcceptList(typeNode) {
|
|
1051
1202
|
if (ts.isTypeOperatorNode(typeNode) && typeNode.operator === ts.SyntaxKind.ReadonlyKeyword) {
|
|
1052
|
-
return parseMimeAcceptList(typeNode.type
|
|
1203
|
+
return parseMimeAcceptList(typeNode.type);
|
|
1053
1204
|
}
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
for (const u of typeNode.types) {
|
|
1068
|
-
const s = literalStringType(u);
|
|
1069
|
-
if (!s)
|
|
1070
|
-
return undefined;
|
|
1071
|
-
values.push(s);
|
|
1072
|
-
}
|
|
1073
|
-
return values.length > 0 ? values : undefined;
|
|
1205
|
+
const members = ts.isTupleTypeNode(typeNode)
|
|
1206
|
+
? typeNode.elements.map((el) => (ts.isNamedTupleMember(el) ? el.type : el))
|
|
1207
|
+
: ts.isUnionTypeNode(typeNode)
|
|
1208
|
+
? [...typeNode.types]
|
|
1209
|
+
: null;
|
|
1210
|
+
if (members === null)
|
|
1211
|
+
return null;
|
|
1212
|
+
const values = [];
|
|
1213
|
+
for (const node of members) {
|
|
1214
|
+
const value = literalStringType(node);
|
|
1215
|
+
if (!value)
|
|
1216
|
+
return null;
|
|
1217
|
+
values.push(value);
|
|
1074
1218
|
}
|
|
1075
|
-
return
|
|
1219
|
+
return values;
|
|
1076
1220
|
}
|
|
1077
1221
|
/** The operations a bucket's `access` may name, the same four a model's may. */
|
|
1078
1222
|
const BUCKET_RULE_KEYS = new Set(["read", "create", "update", "delete"]);
|
|
@@ -1105,25 +1249,32 @@ function parsePartialBucketAccess(typeNode, sourceFile, bucketId, resolveCtx) {
|
|
|
1105
1249
|
}
|
|
1106
1250
|
return access;
|
|
1107
1251
|
}
|
|
1108
|
-
/**
|
|
1252
|
+
/** Each size unit `maxSize` reads, as a power of two. */
|
|
1253
|
+
const SIZE_UNIT_EXPONENTS = { B: 0, KB: 10, MB: 20, GB: 30 };
|
|
1254
|
+
/** The units `maxSize` reads, as a sentence names them: "B, KB, MB or GB". */
|
|
1255
|
+
function sizeUnitList() {
|
|
1256
|
+
const units = Object.keys(SIZE_UNIT_EXPONENTS);
|
|
1257
|
+
return `${units.slice(0, -1).join(", ")} or ${units.at(-1) ?? ""}`;
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* Parse human-readable size from schema types, e.g. `50MB`. A number and a unit it does not read,
|
|
1261
|
+
* or a size past the most bytes a number holds exactly, are each named as what they are: both used
|
|
1262
|
+
* to say only "Invalid maxSize literal" (local test round 3b).
|
|
1263
|
+
*/
|
|
1109
1264
|
function parseDataSizeBytes(lit) {
|
|
1110
|
-
const m = lit.trim().match(/^(\d+(?:\.\d+)?)\s*(
|
|
1265
|
+
const m = lit.trim().match(/^(\d+(?:\.\d+)?)\s*([A-Za-z]+)$/);
|
|
1111
1266
|
if (!m?.[1] || !m[2])
|
|
1112
1267
|
throw new Error(`Invalid maxSize literal: "${lit}". Use forms like "50MB", "100KB".`);
|
|
1113
|
-
const
|
|
1114
|
-
if (
|
|
1115
|
-
throw new Error(`Invalid maxSize
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
const exp = pow[unit];
|
|
1124
|
-
if (exp === undefined)
|
|
1125
|
-
throw new Error(`Unsupported maxSize unit in: "${lit}"`);
|
|
1126
|
-
return Math.round(n * Math.pow(2, exp));
|
|
1268
|
+
const exp = SIZE_UNIT_EXPONENTS[m[2].toUpperCase()];
|
|
1269
|
+
if (exp === undefined) {
|
|
1270
|
+
throw new Error(`Invalid maxSize "${lit}": "${m[2]}" is not a size unit here: use ${sizeUnitList()}.`);
|
|
1271
|
+
}
|
|
1272
|
+
const bytes = Math.round(Number(m[1]) * Math.pow(2, exp));
|
|
1273
|
+
if (!Number.isSafeInteger(bytes)) {
|
|
1274
|
+
const largest = `${Math.floor(Number.MAX_SAFE_INTEGER / Math.pow(2, 30))}GB`;
|
|
1275
|
+
throw new Error(`maxSize "${lit}" is too big: the largest is ${largest} (${Number.MAX_SAFE_INTEGER} bytes).`);
|
|
1276
|
+
}
|
|
1277
|
+
return bytes;
|
|
1127
1278
|
}
|
|
1128
1279
|
function stripQuotes(s) {
|
|
1129
1280
|
return s.replace(/^['"]|['"]$/g, "");
|
|
@@ -1138,10 +1289,12 @@ function bucketsEqual(a, b) {
|
|
|
1138
1289
|
}
|
|
1139
1290
|
function attachStorageFieldMeta(field, bucketId, bucketsById) {
|
|
1140
1291
|
const cfg = bucketsById.get(bucketId);
|
|
1141
|
-
if (cfg
|
|
1292
|
+
if (cfg !== undefined) {
|
|
1293
|
+
// A bucket that names no mode reads as private, as the storage service treats one; only the
|
|
1294
|
+
// bucket entry leaves it out, so a push keeps the live bucket's visibility.
|
|
1142
1295
|
return {
|
|
1143
1296
|
...field,
|
|
1144
|
-
kernel: { ...field.kernel, accessMode: cfg.accessMode },
|
|
1297
|
+
kernel: { ...field.kernel, accessMode: cfg.accessMode ?? "private" },
|
|
1145
1298
|
};
|
|
1146
1299
|
}
|
|
1147
1300
|
return field;
|
|
@@ -1149,22 +1302,47 @@ function attachStorageFieldMeta(field, bucketId, bucketsById) {
|
|
|
1149
1302
|
function parseBlocksTypeDefinitions(blocksArg, sourceFile, blockAliases, bucketAliases, bucketsById, context = {}, resolveCtx) {
|
|
1150
1303
|
if (!blocksArg)
|
|
1151
1304
|
return [];
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1305
|
+
return blockMembers(blocksArg, sourceFile, resolveCtx, new Set()).flatMap(({ ref, name, file }) => {
|
|
1306
|
+
const block = name === "Block"
|
|
1307
|
+
? parseInlineBlockDefinition(ref, file, blockAliases, bucketAliases, bucketsById, context, resolveCtx)
|
|
1308
|
+
: blockAliases.get(name);
|
|
1309
|
+
return block ? [block] : [];
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* The block types a `Blocks<...>` argument names: `Block<...>` written in place, or an alias of one,
|
|
1314
|
+
* followed through aliases that name a union of them (`type PageBlock = HeroBlock | ProseBlock`).
|
|
1315
|
+
* Anything else is refused: it used to be dropped, so `Blocks<PageBlock>` declared no blocks at all
|
|
1316
|
+
* and Studio offered nothing to add.
|
|
1317
|
+
*/
|
|
1318
|
+
function blockMembers(node, file, resolveCtx, seen) {
|
|
1319
|
+
if (ts.isParenthesizedTypeNode(node))
|
|
1320
|
+
return blockMembers(node.type, file, resolveCtx, seen);
|
|
1321
|
+
if (ts.isUnionTypeNode(node))
|
|
1322
|
+
return node.types.flatMap((t) => blockMembers(t, file, resolveCtx, seen));
|
|
1323
|
+
if (!ts.isTypeReferenceNode(node) || !ts.isIdentifier(node.typeName))
|
|
1324
|
+
throw notABlock(node.getText(file));
|
|
1325
|
+
const name = node.typeName.text;
|
|
1326
|
+
const alias = resolveCtx.aliasRegistry.get(name);
|
|
1327
|
+
if (name === "Block" || (alias !== undefined && referenceName(alias.body) === "Block")) {
|
|
1328
|
+
return [{ ref: node, name, file }];
|
|
1329
|
+
}
|
|
1330
|
+
if (alias === undefined || seen.has(name) || !namesBlocks(alias.body))
|
|
1331
|
+
throw notABlock(name);
|
|
1332
|
+
seen.add(name);
|
|
1333
|
+
return blockMembers(alias.body, alias.sourceFile, resolveCtx, seen);
|
|
1334
|
+
}
|
|
1335
|
+
/** The plain name a type reference uses, `HeroBlock` in `HeroBlock` or `Block` in `Block<...>`. */
|
|
1336
|
+
function referenceName(node) {
|
|
1337
|
+
return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) ? node.typeName.text : null;
|
|
1338
|
+
}
|
|
1339
|
+
/** Whether an alias body can name blocks: a union, a reference, or either in parentheses. */
|
|
1340
|
+
function namesBlocks(node) {
|
|
1341
|
+
return ts.isUnionTypeNode(node) || ts.isParenthesizedTypeNode(node) || referenceName(node) !== null;
|
|
1342
|
+
}
|
|
1343
|
+
function notABlock(name) {
|
|
1344
|
+
return new Error(`Blocks<...> takes Block<...> types, or aliases of them; "${name}" is not a Block. ` +
|
|
1345
|
+
`Declare it as Block<"name", { ...fields }>.`);
|
|
1168
1346
|
}
|
|
1169
1347
|
function parseInlineBlockDefinition(ref, sourceFile, blockAliases, bucketAliases, bucketsById, context = {}, resolveCtx) {
|
|
1170
1348
|
const [nameArg, fieldsArg, metaArg] = ref.typeArguments ?? [];
|
|
@@ -1202,9 +1380,83 @@ function parseInlineBlockDefinition(ref, sourceFile, blockAliases, bucketAliases
|
|
|
1202
1380
|
name,
|
|
1203
1381
|
...(label !== undefined && { label }),
|
|
1204
1382
|
...(icon !== undefined && { icon }),
|
|
1205
|
-
|
|
1383
|
+
// A block has no access rule of its own, so none of its uuid keys is the caller's.
|
|
1384
|
+
fields: withUuidKeyDefaults(fields, undefined),
|
|
1206
1385
|
};
|
|
1207
1386
|
}
|
|
1387
|
+
/** `"always"` / `"by-default"`, the TypeScript spelling, as the AST spells it (identity-contract). */
|
|
1388
|
+
function identityAst(mode, fieldName) {
|
|
1389
|
+
if (mode === "always")
|
|
1390
|
+
return "always";
|
|
1391
|
+
if (mode === "by-default")
|
|
1392
|
+
return "byDefault";
|
|
1393
|
+
throw new Error(`Field "${fieldName}": an identity is "always" or "by-default", not "${mode}".`);
|
|
1394
|
+
}
|
|
1395
|
+
/**
|
|
1396
|
+
* A scalar field type's options object, `{ identity?, generated? }`, read from its syntax: the
|
|
1397
|
+
* root form `Identity<>` and `Generated<>` resolve to (identity-contract). `identity` only where the
|
|
1398
|
+
* type is an integer one.
|
|
1399
|
+
*/
|
|
1400
|
+
function parseScalarFieldOptions(node, fieldName, typeName, allowIdentity) {
|
|
1401
|
+
if (node === undefined)
|
|
1402
|
+
return {};
|
|
1403
|
+
if (!ts.isTypeLiteralNode(node)) {
|
|
1404
|
+
throw new Error(`Field "${fieldName}": the options of ${typeName}<…> are an object type, such as { generated: "lower(name)" }.`);
|
|
1405
|
+
}
|
|
1406
|
+
const out = {};
|
|
1407
|
+
for (const member of node.members) {
|
|
1408
|
+
if (!ts.isPropertySignature(member) || !member.name || !member.type)
|
|
1409
|
+
continue;
|
|
1410
|
+
const key = getPropertyName(member.name);
|
|
1411
|
+
const text = literalStringType(member.type);
|
|
1412
|
+
if (key === "identity") {
|
|
1413
|
+
if (!allowIdentity) {
|
|
1414
|
+
throw new Error(`Field "${fieldName}": only an integer field (Int, SmallInt or BigInt) can be an identity column, not ${typeName}.`);
|
|
1415
|
+
}
|
|
1416
|
+
if (text === null) {
|
|
1417
|
+
throw new Error(`Field "${fieldName}": identity is "always" or "by-default".`);
|
|
1418
|
+
}
|
|
1419
|
+
out.identity = identityAst(text, fieldName);
|
|
1420
|
+
}
|
|
1421
|
+
else if (key === "generated") {
|
|
1422
|
+
if (text === null || text.trim() === "") {
|
|
1423
|
+
throw new Error(`Field "${fieldName}": generated is the column's SQL expression as a string literal, such as "lower(name)".`);
|
|
1424
|
+
}
|
|
1425
|
+
out.generated = { expression: text, stored: true };
|
|
1426
|
+
}
|
|
1427
|
+
else {
|
|
1428
|
+
throw new Error(`Field "${fieldName}": ${typeName}<…> takes ${allowIdentity ? "identity and generated" : "generated"}, not ${key ?? "that option"}.`);
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
return out;
|
|
1432
|
+
}
|
|
1433
|
+
const isAuthUserOnDelete = isOneOf(["cascade", "restrict", "setNull"]);
|
|
1434
|
+
/**
|
|
1435
|
+
* `SupatypeAuthUserId<{ onDelete }>`: what deleting the user does to the row, when the field opts
|
|
1436
|
+
* in to a foreign key to `auth.users`. `onDelete` is the only option an auth user id takes.
|
|
1437
|
+
*/
|
|
1438
|
+
function parseAuthUserOnDelete(node, fieldName) {
|
|
1439
|
+
if (node === undefined)
|
|
1440
|
+
return undefined;
|
|
1441
|
+
if (!ts.isTypeLiteralNode(node)) {
|
|
1442
|
+
throw new Error(`Field "${fieldName}": the options of SupatypeAuthUserId<…> are an object type, such as { onDelete: "cascade" }.`);
|
|
1443
|
+
}
|
|
1444
|
+
let onDelete;
|
|
1445
|
+
for (const member of node.members) {
|
|
1446
|
+
if (!ts.isPropertySignature(member) || !member.name || !member.type)
|
|
1447
|
+
continue;
|
|
1448
|
+
const key = getPropertyName(member.name);
|
|
1449
|
+
if (key !== "onDelete") {
|
|
1450
|
+
throw new Error(`Field "${fieldName}": SupatypeAuthUserId<…> takes onDelete, not ${key ?? "that option"}.`);
|
|
1451
|
+
}
|
|
1452
|
+
const action = literalStringType(member.type);
|
|
1453
|
+
if (!isAuthUserOnDelete(action)) {
|
|
1454
|
+
throw new Error(`Field "${fieldName}": onDelete is "cascade", "restrict" or "setNull".`);
|
|
1455
|
+
}
|
|
1456
|
+
onDelete = action;
|
|
1457
|
+
}
|
|
1458
|
+
return onDelete;
|
|
1459
|
+
}
|
|
1208
1460
|
function literalStringType(typeNode) {
|
|
1209
1461
|
if (!typeNode)
|
|
1210
1462
|
return null;
|
|
@@ -1319,22 +1571,34 @@ function parseAssetFieldOptions(optionsArg, sourceFile) {
|
|
|
1319
1571
|
/** Versions kept per record when a model states no retention. Mirrors `model-versioning.ts`. */
|
|
1320
1572
|
const DEFAULT_VERSIONS_KEPT = 20;
|
|
1321
1573
|
/**
|
|
1322
|
-
* `versions: true` or `versions: { drafts, keep }
|
|
1574
|
+
* `versions: true` or `versions: { drafts, keep }`, written out or through a type alias.
|
|
1323
1575
|
*
|
|
1324
1576
|
* A malformed member is ignored rather than fatal, matching every other key here: the declaration is
|
|
1325
1577
|
* a *type*, so TypeScript has already refused anything `ModelVersionsOptions` does not allow, and
|
|
1326
|
-
* this parser's job is reading what compiled rather than validating it a second time.
|
|
1578
|
+
* this parser's job is reading what compiled rather than validating it a second time. A value it
|
|
1579
|
+
* cannot resolve at all is refused: read as no `versions`, it made no draft tables and said nothing.
|
|
1327
1580
|
*/
|
|
1328
|
-
function parseVersions(
|
|
1581
|
+
function parseVersions(declared, sourceFile, resolveCtx, modelName) {
|
|
1582
|
+
const typeNode = ts.isTypeReferenceNode(declared)
|
|
1583
|
+
? (tryResolveTypeReference(declared, sourceFile, resolveCtx) ?? declared)
|
|
1584
|
+
: declared;
|
|
1329
1585
|
if (isBooleanLiteralType(typeNode, true)) {
|
|
1330
1586
|
return { drafts: true, keep: DEFAULT_VERSIONS_KEPT };
|
|
1331
1587
|
}
|
|
1332
1588
|
if (isBooleanLiteralType(typeNode, false))
|
|
1333
1589
|
return undefined;
|
|
1334
|
-
|
|
1335
|
-
|
|
1590
|
+
const literal = resolveAccessLiteral(typeNode, sourceFile, resolveCtx);
|
|
1591
|
+
if (!literal) {
|
|
1592
|
+
throw new Error(`Model "${modelName}": could not resolve \`versions\` from \`${ownerText(declared, sourceFile)}\`.\n` +
|
|
1593
|
+
" versions must be `true`, or an object type such as `{ drafts: true; keep: 20 }`, written\n" +
|
|
1594
|
+
" out or as a type alias declared in the schema's files.");
|
|
1595
|
+
}
|
|
1596
|
+
return parsedVersionsMembers(literal);
|
|
1597
|
+
}
|
|
1598
|
+
/** The `drafts` and `keep` members of a resolved `versions` object. */
|
|
1599
|
+
function parsedVersionsMembers(literal) {
|
|
1336
1600
|
const parsed = { drafts: true, keep: DEFAULT_VERSIONS_KEPT };
|
|
1337
|
-
for (const member of
|
|
1601
|
+
for (const member of literal.members) {
|
|
1338
1602
|
if (!ts.isPropertySignature(member) || !member.type)
|
|
1339
1603
|
continue;
|
|
1340
1604
|
const key = getPropertyName(member.name);
|
|
@@ -1356,7 +1620,24 @@ function parseVersions(typeNode) {
|
|
|
1356
1620
|
}
|
|
1357
1621
|
return parsed;
|
|
1358
1622
|
}
|
|
1359
|
-
|
|
1623
|
+
/**
|
|
1624
|
+
* A model's options as one object type: written out, or a type alias for one (generic, or joined
|
|
1625
|
+
* with `&` to options written out). Every option is read off what this returns, so an alias the
|
|
1626
|
+
* extractor read as syntax lost them all: `versions`, `tableName` and `access` alike. Options it
|
|
1627
|
+
* cannot resolve are refused, since dropping them would push the model with none of them.
|
|
1628
|
+
*/
|
|
1629
|
+
function resolveModelOptions(optionsArg, sourceFile, resolveCtx, modelName) {
|
|
1630
|
+
if (!optionsArg)
|
|
1631
|
+
return undefined;
|
|
1632
|
+
const literal = resolveAccessLiteral(optionsArg, sourceFile, resolveCtx);
|
|
1633
|
+
if (literal)
|
|
1634
|
+
return literal;
|
|
1635
|
+
throw new Error(`Model "${modelName}": could not resolve its options from \`${ownerText(optionsArg, sourceFile)}\`.\n` +
|
|
1636
|
+
" The second argument of Model<> must be an object type, or a type alias for one declared in\n" +
|
|
1637
|
+
" the schema's files. Refusing to continue: unresolved options would push the model without\n" +
|
|
1638
|
+
" its table name, access rules or versions.");
|
|
1639
|
+
}
|
|
1640
|
+
function parseMetaLiteral(metaArg, sourceFile, resolveCtx, modelName) {
|
|
1360
1641
|
const result = {};
|
|
1361
1642
|
if (!metaArg || !ts.isTypeLiteralNode(metaArg))
|
|
1362
1643
|
return result;
|
|
@@ -1390,7 +1671,7 @@ function parseMetaLiteral(metaArg, sourceFile) {
|
|
|
1390
1671
|
.filter((name) => name !== null);
|
|
1391
1672
|
}
|
|
1392
1673
|
else if (key === "versions") {
|
|
1393
|
-
const versions = parseVersions(member.type);
|
|
1674
|
+
const versions = parseVersions(member.type, sourceFile, resolveCtx, modelName);
|
|
1394
1675
|
if (versions !== undefined)
|
|
1395
1676
|
result.versions = versions;
|
|
1396
1677
|
}
|
|
@@ -1417,7 +1698,7 @@ function hasCompositeWrapper(typeNode, wrapperName) {
|
|
|
1417
1698
|
return false;
|
|
1418
1699
|
}
|
|
1419
1700
|
function parseModelMeta(metaArg, sourceFile, modelName, fieldsArg, fields, resolveCtx) {
|
|
1420
|
-
const literal = parseMetaLiteral(metaArg, sourceFile);
|
|
1701
|
+
const literal = parseMetaLiteral(metaArg, sourceFile, resolveCtx, modelName);
|
|
1421
1702
|
const singleton = literal.singleton === true;
|
|
1422
1703
|
const tableName = literal.tableName ?? (singleton ? `_global_${toSnakeCase(modelName)}` : toSnakeCase(modelName));
|
|
1423
1704
|
const timestamps = literal.timestamps ??
|
|
@@ -1473,8 +1754,7 @@ function parseModelMeta(metaArg, sourceFile, modelName, fieldsArg, fields, resol
|
|
|
1473
1754
|
*/
|
|
1474
1755
|
function assertCacheIsServable(cache, access, fields, model) {
|
|
1475
1756
|
if (cache.public === true) {
|
|
1476
|
-
|
|
1477
|
-
if (isIdentityDependent(read)) {
|
|
1757
|
+
if (isIdentityDependent(access["read"])) {
|
|
1478
1758
|
throw new Error(`Model "${model}": \`cache.public\` cannot be used with an \`access.read\` rule that ` +
|
|
1479
1759
|
`varies by caller. A public cache entry is shared by everyone, so one caller's rows ` +
|
|
1480
1760
|
`would be served to another. Use \`cache: { enabled: true }\` for per-user entries, or ` +
|
|
@@ -1600,7 +1880,7 @@ function assertConstraintIsEnforceable(node, model, index) {
|
|
|
1600
1880
|
assertConstraintIsEnforceable(item, model, index);
|
|
1601
1881
|
return;
|
|
1602
1882
|
}
|
|
1603
|
-
if (
|
|
1883
|
+
if (!isJsonObject(node))
|
|
1604
1884
|
return;
|
|
1605
1885
|
const record = node;
|
|
1606
1886
|
for (const key of ["type", "kind"]) {
|
|
@@ -1631,7 +1911,7 @@ function resolveConstraintMeasures(node, fields, model, index) {
|
|
|
1631
1911
|
resolveConstraintMeasures(item, fields, model, index);
|
|
1632
1912
|
return;
|
|
1633
1913
|
}
|
|
1634
|
-
if (
|
|
1914
|
+
if (!isJsonObject(node))
|
|
1635
1915
|
return;
|
|
1636
1916
|
const record = node;
|
|
1637
1917
|
const kind = record["kind"];
|
|
@@ -1643,9 +1923,9 @@ function resolveConstraintMeasures(node, fields, model, index) {
|
|
|
1643
1923
|
"this model. Measures need a declared field, because the measure depends on its type.");
|
|
1644
1924
|
}
|
|
1645
1925
|
const measure = kind === "length" ? "length" : "items";
|
|
1646
|
-
const resolved =
|
|
1647
|
-
jsonIsArray: field["jsonArray"] === true
|
|
1648
|
-
|
|
1926
|
+
const resolved = isFieldKind(field.kind)
|
|
1927
|
+
? measureFormFor(field.kind, measure, { jsonIsArray: field["jsonArray"] === true })
|
|
1928
|
+
: { instead: `a ${field.kind} field cannot be measured that way` };
|
|
1649
1929
|
if (resolved.form === undefined) {
|
|
1650
1930
|
throw new Error(`Model "${model}": constraint ${index + 1} uses ` +
|
|
1651
1931
|
`\`${kind === "length" ? "Length" : "ItemCount"}<"${column}">\`, but ` +
|
|
@@ -1823,6 +2103,9 @@ function parseModelIndexes(metaArg, sourceFile, fields) {
|
|
|
1823
2103
|
else if (key === "unique" && isBooleanLiteralType(member.type, true)) {
|
|
1824
2104
|
indexDef.unique = true;
|
|
1825
2105
|
}
|
|
2106
|
+
else if (key === "using" || key === "distance") {
|
|
2107
|
+
indexDef[key] = indexOption(key, literalStringType(member.type));
|
|
2108
|
+
}
|
|
1826
2109
|
else if (key === "fields" && ts.isTupleTypeNode(member.type)) {
|
|
1827
2110
|
indexDef.fields = member.type.elements
|
|
1828
2111
|
.map((fieldNode) => {
|
|
@@ -1839,6 +2122,19 @@ function parseModelIndexes(metaArg, sourceFile, fields) {
|
|
|
1839
2122
|
}
|
|
1840
2123
|
return indexes;
|
|
1841
2124
|
}
|
|
2125
|
+
/** The values `ModelIndex.using` and `ModelIndex.distance` accept, as `@supatype/types` lists them. */
|
|
2126
|
+
const INDEX_OPTIONS = {
|
|
2127
|
+
using: ["btree", "gin", "gist", "hnsw", "brin"],
|
|
2128
|
+
distance: ["cosine", "l2", "innerProduct"],
|
|
2129
|
+
};
|
|
2130
|
+
/** An index option's value, refused when it is not one the engine knows. */
|
|
2131
|
+
function indexOption(key, value) {
|
|
2132
|
+
const allowed = INDEX_OPTIONS[key];
|
|
2133
|
+
if (value === null || !allowed.includes(value)) {
|
|
2134
|
+
throw new Error(`An index's \`${key}\` must be one of ${allowed.map((v) => `"${v}"`).join(", ")}.`);
|
|
2135
|
+
}
|
|
2136
|
+
return value;
|
|
2137
|
+
}
|
|
1842
2138
|
function resolveIndexFieldName(fieldName, fields) {
|
|
1843
2139
|
if (fields[fieldName] !== undefined) {
|
|
1844
2140
|
const field = fields[fieldName];
|
|
@@ -1879,7 +2175,7 @@ function assertAccessRuleIsRenderable(node, model, operation) {
|
|
|
1879
2175
|
assertAccessRuleIsRenderable(item, model, operation);
|
|
1880
2176
|
return;
|
|
1881
2177
|
}
|
|
1882
|
-
if (
|
|
2178
|
+
if (!isJsonObject(node))
|
|
1883
2179
|
return;
|
|
1884
2180
|
const record = node;
|
|
1885
2181
|
// Operands are tagged `kind`, rules `type`, so both are checked: `Matches` is a rule.
|
|
@@ -2091,6 +2387,82 @@ function ownerText(node, fallback) {
|
|
|
2091
2387
|
const own = node.pos >= 0 ? node.getSourceFile() : undefined;
|
|
2092
2388
|
return node.getText(own ?? fallback);
|
|
2093
2389
|
}
|
|
2390
|
+
/**
|
|
2391
|
+
* The string an access rule's type argument spells, as in `Role<"editor">`.
|
|
2392
|
+
*
|
|
2393
|
+
* Read from the literal itself. Stripping quote characters from the source text instead turned
|
|
2394
|
+
* `Role<"o'brien">` into the role `obrien`, a different role, so the intended one was denied with
|
|
2395
|
+
* nothing said (E26).
|
|
2396
|
+
*/
|
|
2397
|
+
function ruleStringArg(arg, rule, sourceFile) {
|
|
2398
|
+
if (ts.isLiteralTypeNode(arg) && ts.isStringLiteral(arg.literal))
|
|
2399
|
+
return arg.literal.text;
|
|
2400
|
+
throw new Error(`\`${rule}<>\` takes a string literal, as in \`${rule}<"name">\`, but found \`${ownerText(arg, sourceFile)}\`.`);
|
|
2401
|
+
}
|
|
2402
|
+
/** A role name from `Role<>` or `BucketRole<>`, refused when it holds a quote character. */
|
|
2403
|
+
function roleNameArg(arg, rule, sourceFile) {
|
|
2404
|
+
const role = ruleStringArg(arg, rule, sourceFile);
|
|
2405
|
+
if (/['"]/.test(role)) {
|
|
2406
|
+
throw new Error(`The role name "${role}" in \`${rule}<>\` contains a quote character. Postgres role names ` +
|
|
2407
|
+
"used by Supatype access rules may not contain ' or \"; rename the role.");
|
|
2408
|
+
}
|
|
2409
|
+
return role;
|
|
2410
|
+
}
|
|
2411
|
+
/**
|
|
2412
|
+
* Every access rule the parser accepts, with the form it is written in. The parser's switch is
|
|
2413
|
+
* typed against these names, so a rule added to one and not the other does not compile, and the
|
|
2414
|
+
* unknown-rule error lists them from here. A hand-written list there had left out three.
|
|
2415
|
+
*/
|
|
2416
|
+
const ACCESS_RULE_FORMS = {
|
|
2417
|
+
Public: "Public",
|
|
2418
|
+
Private: "Private",
|
|
2419
|
+
LoggedIn: "LoggedIn",
|
|
2420
|
+
Owner: 'Owner<"field">',
|
|
2421
|
+
OwnerFrom: 'OwnerFrom<"relation">',
|
|
2422
|
+
Role: 'Role<"name">',
|
|
2423
|
+
Any: "Any<[rule, ...]>",
|
|
2424
|
+
All: "All<[rule, ...]>",
|
|
2425
|
+
Not: "Not<rule>",
|
|
2426
|
+
Eq: "Eq<left, right>",
|
|
2427
|
+
Neq: "Neq<left, right>",
|
|
2428
|
+
Gt: "Gt<left, right>",
|
|
2429
|
+
Gte: "Gte<left, right>",
|
|
2430
|
+
Lt: "Lt<left, right>",
|
|
2431
|
+
Lte: "Lte<left, right>",
|
|
2432
|
+
Like: "Like<left, right>",
|
|
2433
|
+
Matches: 'Matches<"column", "pattern">',
|
|
2434
|
+
IsNull: "IsNull<operand>",
|
|
2435
|
+
NotNull: "NotNull<operand>",
|
|
2436
|
+
Exists: "Exists<source>",
|
|
2437
|
+
In: 'In<"column", source>',
|
|
2438
|
+
BucketPublic: "BucketPublic",
|
|
2439
|
+
BucketPrivate: "BucketPrivate",
|
|
2440
|
+
BucketLoggedIn: "BucketLoggedIn",
|
|
2441
|
+
BucketOwner: "BucketOwner",
|
|
2442
|
+
BucketRole: 'BucketRole<"name">',
|
|
2443
|
+
};
|
|
2444
|
+
function isAccessRuleName(ref) {
|
|
2445
|
+
return Object.hasOwn(ACCESS_RULE_FORMS, ref);
|
|
2446
|
+
}
|
|
2447
|
+
/** The error for a rule the parser does not know, listing every rule it does. */
|
|
2448
|
+
function unknownAccessRuleMessage(ref) {
|
|
2449
|
+
const forms = Object.entries(ACCESS_RULE_FORMS);
|
|
2450
|
+
const listed = (bucket) => forms.filter(([name]) => name.startsWith("Bucket") === bucket).map(([, form]) => form).join(", ");
|
|
2451
|
+
return `Unknown access rule "${ref}". Supported: ${listed(false)} (buckets also accept ${listed(true)}).`;
|
|
2452
|
+
}
|
|
2453
|
+
/** A name that is not a built-in rule: a named alias standing for one, or an error naming it. */
|
|
2454
|
+
function parseAccessAlias(typeNode, ref, sourceFile, resolveCtx, depth) {
|
|
2455
|
+
// Possibly parameterised, standing for a rule. Expanded before giving up, so
|
|
2456
|
+
// `SiteAccess<"site_id">` works.
|
|
2457
|
+
if (resolveCtx && depth < 16) {
|
|
2458
|
+
const expanded = resolveAccessAliasNode(typeNode, sourceFile, resolveCtx);
|
|
2459
|
+
if (expanded)
|
|
2460
|
+
return parseAccessRule(expanded, sourceFile, resolveCtx, depth + 1);
|
|
2461
|
+
}
|
|
2462
|
+
// Falling back to `private` here would silently deny an operation the author believed they had
|
|
2463
|
+
// granted, and with deny-by-default there is no longer any need for a permissive guess.
|
|
2464
|
+
throw new Error(unknownAccessRuleMessage(ref));
|
|
2465
|
+
}
|
|
2094
2466
|
function parseAccessRule(typeNode, sourceFile, resolveCtx, depth = 0) {
|
|
2095
2467
|
// Reuse a single rule from a shared set: `access: { read: Rules["read"] }`.
|
|
2096
2468
|
if (ts.isIndexedAccessTypeNode(typeNode) && resolveCtx) {
|
|
@@ -2112,6 +2484,8 @@ function parseAccessRule(typeNode, sourceFile, resolveCtx, depth = 0) {
|
|
|
2112
2484
|
`\`${head}["${rest.join(".")}"]\`, not \`${text}\`.`);
|
|
2113
2485
|
}
|
|
2114
2486
|
const ref = ownerText(typeNode.typeName, sourceFile);
|
|
2487
|
+
if (!isAccessRuleName(ref))
|
|
2488
|
+
return parseAccessAlias(typeNode, ref, sourceFile, resolveCtx, depth);
|
|
2115
2489
|
switch (ref) {
|
|
2116
2490
|
case "Public":
|
|
2117
2491
|
case "BucketPublic":
|
|
@@ -2130,13 +2504,13 @@ function parseAccessRule(typeNode, sourceFile, resolveCtx, depth = 0) {
|
|
|
2130
2504
|
// Must match engine `AccessRule::Owner { field }` (see supatype-schema-engine parser/ast.rs).
|
|
2131
2505
|
return {
|
|
2132
2506
|
type: "owner",
|
|
2133
|
-
field: keyArg ?
|
|
2507
|
+
field: keyArg ? ruleStringArg(keyArg, "Owner", sourceFile) : "user_id",
|
|
2134
2508
|
};
|
|
2135
2509
|
}
|
|
2136
2510
|
case "OwnerFrom": {
|
|
2137
2511
|
const relationArg = typeNode.typeArguments?.[0];
|
|
2138
2512
|
const relationField = relationArg
|
|
2139
|
-
?
|
|
2513
|
+
? ruleStringArg(relationArg, "OwnerFrom", sourceFile)
|
|
2140
2514
|
: "owner";
|
|
2141
2515
|
return { type: "owner", field: relationField };
|
|
2142
2516
|
}
|
|
@@ -2145,7 +2519,7 @@ function parseAccessRule(typeNode, sourceFile, resolveCtx, depth = 0) {
|
|
|
2145
2519
|
const roleArg = typeNode.typeArguments?.[0];
|
|
2146
2520
|
return {
|
|
2147
2521
|
type: "role",
|
|
2148
|
-
roles: [roleArg ?
|
|
2522
|
+
roles: [roleArg ? roleNameArg(roleArg, ref, sourceFile) : "admin"],
|
|
2149
2523
|
};
|
|
2150
2524
|
}
|
|
2151
2525
|
case "Any": {
|
|
@@ -2270,21 +2644,8 @@ function parseAccessRule(typeNode, sourceFile, resolveCtx, depth = 0) {
|
|
|
2270
2644
|
};
|
|
2271
2645
|
}
|
|
2272
2646
|
default: {
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
if (resolveCtx && depth < 16) {
|
|
2276
|
-
const expanded = resolveAccessAliasNode(typeNode, sourceFile, resolveCtx);
|
|
2277
|
-
if (expanded)
|
|
2278
|
-
return parseAccessRule(expanded, sourceFile, resolveCtx, depth + 1);
|
|
2279
|
-
}
|
|
2280
|
-
// Falling back to `private` here would silently deny an operation the
|
|
2281
|
-
// author believed they had granted, and with deny-by-default there is no
|
|
2282
|
-
// longer any need for a permissive guess. Name the offending rule instead.
|
|
2283
|
-
throw new Error(`Unknown access rule "${ref}". Supported: Public, Private, LoggedIn, ` +
|
|
2284
|
-
`Owner<"field">, OwnerFrom<"relation">, Role<"name">, ` +
|
|
2285
|
-
`Any<[rule, …]>, All<[rule, …]>, Not<rule>, ` +
|
|
2286
|
-
`Eq/Neq/Gt/Gte/Lt/Lte/Like<left, right>, IsNull<operand>, NotNull<operand>` +
|
|
2287
|
-
` (buckets also accept BucketPublic, BucketPrivate, BucketLoggedIn, BucketOwner, BucketRole).`);
|
|
2647
|
+
const unhandled = ref;
|
|
2648
|
+
throw new Error(unknownAccessRuleMessage(unhandled));
|
|
2288
2649
|
}
|
|
2289
2650
|
}
|
|
2290
2651
|
}
|
|
@@ -2382,6 +2743,8 @@ const TIME_UNITS = [
|
|
|
2382
2743
|
];
|
|
2383
2744
|
/** Granularities for `StartOf<>`. */
|
|
2384
2745
|
const TRUNC_UNITS = ["day", "week", "month", "year"];
|
|
2746
|
+
const isTimeUnit = isOneOf(TIME_UNITS);
|
|
2747
|
+
const isTruncUnit = isOneOf(TRUNC_UNITS);
|
|
2385
2748
|
/**
|
|
2386
2749
|
* `After<Base, { days: 30, hours: 9 }>` / `Before<...>`: a point in time plus or minus a
|
|
2387
2750
|
* multi-unit duration.
|
|
@@ -2417,7 +2780,7 @@ function parseOffsetOperand(ref, args, sourceFile) {
|
|
|
2417
2780
|
throw new Error(`\`${ref}<>\` interval members must be \`unit: amount\` pairs.`);
|
|
2418
2781
|
}
|
|
2419
2782
|
const unit = member.name.getText(sourceFile).replace(/["']/g, "");
|
|
2420
|
-
if (!
|
|
2783
|
+
if (!isTimeUnit(unit)) {
|
|
2421
2784
|
throw new Error(`\`${unit}\` is not a unit of time. Use one of: ${TIME_UNITS.join(", ")} (plural).`);
|
|
2422
2785
|
}
|
|
2423
2786
|
const amountNode = member.type;
|
|
@@ -2484,7 +2847,7 @@ function parseDurationOperand(ref, args, sourceFile) {
|
|
|
2484
2847
|
`take integers, so a fraction would be silently truncated or rejected.`);
|
|
2485
2848
|
}
|
|
2486
2849
|
const unit = stringLiteralArg(args[1], ref, "unit");
|
|
2487
|
-
if (!
|
|
2850
|
+
if (!isTimeUnit(unit)) {
|
|
2488
2851
|
throw new Error(`\`${ref}<${amount}, "${unit}">\` is not a valid unit. Use one of: ` +
|
|
2489
2852
|
`${TIME_UNITS.join(", ")} (plural).`);
|
|
2490
2853
|
}
|
|
@@ -2570,7 +2933,7 @@ function parseAccessOperand(typeNode, sourceFile) {
|
|
|
2570
2933
|
return { kind: "now" };
|
|
2571
2934
|
case "StartOf": {
|
|
2572
2935
|
const unit = stringLiteralArg(operandArgs[0], "StartOf", "unit");
|
|
2573
|
-
if (!
|
|
2936
|
+
if (!isTruncUnit(unit)) {
|
|
2574
2937
|
throw new Error(`\`StartOf<"${unit}">\` is not a valid granularity. Use one of: ` +
|
|
2575
2938
|
`${TRUNC_UNITS.join(", ")}.`);
|
|
2576
2939
|
}
|