@supabase/pg-delta 0.0.0 → 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +149 -0
- package/dist/cli/app.d.ts +1 -0
- package/dist/cli/app.js +26 -0
- package/dist/cli/bin/cli.d.ts +2 -0
- package/dist/cli/bin/cli.js +7 -0
- package/dist/cli/commands/apply.d.ts +5 -0
- package/dist/cli/commands/apply.js +85 -0
- package/dist/cli/commands/plan.d.ts +5 -0
- package/dist/cli/commands/plan.js +137 -0
- package/dist/cli/commands/sync.d.ts +5 -0
- package/dist/cli/commands/sync.js +141 -0
- package/dist/cli/formatters/index.d.ts +4 -0
- package/dist/cli/formatters/index.js +4 -0
- package/dist/cli/formatters/tree/tree-builder.d.ts +10 -0
- package/dist/cli/formatters/tree/tree-builder.js +333 -0
- package/dist/cli/formatters/tree/tree-renderer.d.ts +45 -0
- package/dist/cli/formatters/tree/tree-renderer.js +303 -0
- package/dist/cli/formatters/tree/tree.d.ts +8 -0
- package/dist/cli/formatters/tree/tree.js +161 -0
- package/dist/cli/utils/integrations.d.ts +13 -0
- package/dist/cli/utils/integrations.js +35 -0
- package/dist/cli/utils.d.ts +64 -0
- package/dist/cli/utils.js +160 -0
- package/dist/core/catalog.diff.d.ts +5 -0
- package/dist/core/catalog.diff.js +147 -0
- package/dist/core/catalog.model.d.ts +93 -0
- package/dist/core/catalog.model.js +254 -0
- package/dist/core/change.types.d.ts +22 -0
- package/dist/core/change.types.js +1 -0
- package/dist/core/context.d.ts +11 -0
- package/dist/core/context.js +12 -0
- package/dist/core/depend.d.ts +31 -0
- package/dist/core/depend.js +1833 -0
- package/dist/core/expand-replace-dependencies.d.ts +14 -0
- package/dist/core/expand-replace-dependencies.js +280 -0
- package/dist/core/fingerprint.d.ts +23 -0
- package/dist/core/fingerprint.js +174 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.js +14 -0
- package/dist/core/integrations/filter/dsl.d.ts +97 -0
- package/dist/core/integrations/filter/dsl.js +107 -0
- package/dist/core/integrations/filter/extractors.d.ts +12 -0
- package/dist/core/integrations/filter/extractors.js +136 -0
- package/dist/core/integrations/integration-dsl.d.ts +22 -0
- package/dist/core/integrations/integration-dsl.js +6 -0
- package/dist/core/integrations/integration.types.d.ts +5 -0
- package/dist/core/integrations/integration.types.js +1 -0
- package/dist/core/integrations/serialize/dsl.d.ts +58 -0
- package/dist/core/integrations/serialize/dsl.js +42 -0
- package/dist/core/main.d.ts +5 -0
- package/dist/core/main.js +44 -0
- package/dist/core/objects/aggregate/aggregate.diff.d.ts +10 -0
- package/dist/core/objects/aggregate/aggregate.diff.js +186 -0
- package/dist/core/objects/aggregate/aggregate.model.d.ts +174 -0
- package/dist/core/objects/aggregate/aggregate.model.js +297 -0
- package/dist/core/objects/aggregate/changes/aggregate.alter.d.ts +19 -0
- package/dist/core/objects/aggregate/changes/aggregate.alter.js +25 -0
- package/dist/core/objects/aggregate/changes/aggregate.base.d.ts +17 -0
- package/dist/core/objects/aggregate/changes/aggregate.base.js +13 -0
- package/dist/core/objects/aggregate/changes/aggregate.comment.d.ts +23 -0
- package/dist/core/objects/aggregate/changes/aggregate.comment.js +44 -0
- package/dist/core/objects/aggregate/changes/aggregate.create.d.ts +19 -0
- package/dist/core/objects/aggregate/changes/aggregate.create.js +228 -0
- package/dist/core/objects/aggregate/changes/aggregate.drop.d.ts +17 -0
- package/dist/core/objects/aggregate/changes/aggregate.drop.js +26 -0
- package/dist/core/objects/aggregate/changes/aggregate.privilege.d.ts +62 -0
- package/dist/core/objects/aggregate/changes/aggregate.privilege.js +102 -0
- package/dist/core/objects/aggregate/changes/aggregate.types.d.ts +6 -0
- package/dist/core/objects/aggregate/changes/aggregate.types.js +1 -0
- package/dist/core/objects/base.change.d.ts +46 -0
- package/dist/core/objects/base.change.js +38 -0
- package/dist/core/objects/base.default-privileges.d.ts +29 -0
- package/dist/core/objects/base.default-privileges.js +167 -0
- package/dist/core/objects/base.diff.d.ts +6 -0
- package/dist/core/objects/base.diff.js +12 -0
- package/dist/core/objects/base.model.d.ts +74 -0
- package/dist/core/objects/base.model.js +47 -0
- package/dist/core/objects/base.privilege-diff.d.ts +54 -0
- package/dist/core/objects/base.privilege-diff.js +216 -0
- package/dist/core/objects/base.privilege.d.ts +27 -0
- package/dist/core/objects/base.privilege.js +169 -0
- package/dist/core/objects/collation/changes/collation.alter.d.ts +45 -0
- package/dist/core/objects/collation/changes/collation.alter.js +52 -0
- package/dist/core/objects/collation/changes/collation.base.d.ts +17 -0
- package/dist/core/objects/collation/changes/collation.base.js +13 -0
- package/dist/core/objects/collation/changes/collation.comment.d.ts +26 -0
- package/dist/core/objects/collation/changes/collation.comment.js +50 -0
- package/dist/core/objects/collation/changes/collation.create.d.ts +32 -0
- package/dist/core/objects/collation/changes/collation.create.js +86 -0
- package/dist/core/objects/collation/changes/collation.drop.d.ts +22 -0
- package/dist/core/objects/collation/changes/collation.drop.js +31 -0
- package/dist/core/objects/collation/changes/collation.types.d.ts +5 -0
- package/dist/core/objects/collation/changes/collation.types.js +1 -0
- package/dist/core/objects/collation/collation.diff.d.ts +13 -0
- package/dist/core/objects/collation/collation.diff.js +85 -0
- package/dist/core/objects/collation/collation.model.d.ts +67 -0
- package/dist/core/objects/collation/collation.model.js +207 -0
- package/dist/core/objects/domain/changes/domain.alter.d.ts +143 -0
- package/dist/core/objects/domain/changes/domain.alter.js +191 -0
- package/dist/core/objects/domain/changes/domain.base.d.ts +17 -0
- package/dist/core/objects/domain/changes/domain.base.js +13 -0
- package/dist/core/objects/domain/changes/domain.comment.d.ts +25 -0
- package/dist/core/objects/domain/changes/domain.comment.js +47 -0
- package/dist/core/objects/domain/changes/domain.create.d.ts +30 -0
- package/dist/core/objects/domain/changes/domain.create.js +92 -0
- package/dist/core/objects/domain/changes/domain.drop.d.ts +22 -0
- package/dist/core/objects/domain/changes/domain.drop.js +28 -0
- package/dist/core/objects/domain/changes/domain.privilege.d.ts +97 -0
- package/dist/core/objects/domain/changes/domain.privilege.js +127 -0
- package/dist/core/objects/domain/changes/domain.types.d.ts +6 -0
- package/dist/core/objects/domain/changes/domain.types.js +1 -0
- package/dist/core/objects/domain/domain.diff.d.ts +18 -0
- package/dist/core/objects/domain/domain.diff.js +244 -0
- package/dist/core/objects/domain/domain.model.d.ts +103 -0
- package/dist/core/objects/domain/domain.model.js +172 -0
- package/dist/core/objects/event-trigger/changes/event-trigger.alter.d.ts +44 -0
- package/dist/core/objects/event-trigger/changes/event-trigger.alter.js +51 -0
- package/dist/core/objects/event-trigger/changes/event-trigger.base.d.ts +17 -0
- package/dist/core/objects/event-trigger/changes/event-trigger.base.js +13 -0
- package/dist/core/objects/event-trigger/changes/event-trigger.comment.d.ts +23 -0
- package/dist/core/objects/event-trigger/changes/event-trigger.comment.js +46 -0
- package/dist/core/objects/event-trigger/changes/event-trigger.create.d.ts +25 -0
- package/dist/core/objects/event-trigger/changes/event-trigger.create.js +55 -0
- package/dist/core/objects/event-trigger/changes/event-trigger.drop.d.ts +22 -0
- package/dist/core/objects/event-trigger/changes/event-trigger.drop.js +28 -0
- package/dist/core/objects/event-trigger/changes/event-trigger.types.d.ts +5 -0
- package/dist/core/objects/event-trigger/changes/event-trigger.types.js +1 -0
- package/dist/core/objects/event-trigger/event-trigger.diff.d.ts +13 -0
- package/dist/core/objects/event-trigger/event-trigger.diff.js +81 -0
- package/dist/core/objects/event-trigger/event-trigger.model.d.ts +45 -0
- package/dist/core/objects/event-trigger/event-trigger.model.js +89 -0
- package/dist/core/objects/extension/changes/extension.alter.d.ts +44 -0
- package/dist/core/objects/extension/changes/extension.alter.js +51 -0
- package/dist/core/objects/extension/changes/extension.base.d.ts +17 -0
- package/dist/core/objects/extension/changes/extension.base.js +13 -0
- package/dist/core/objects/extension/changes/extension.comment.d.ts +26 -0
- package/dist/core/objects/extension/changes/extension.comment.js +46 -0
- package/dist/core/objects/extension/changes/extension.create.d.ts +25 -0
- package/dist/core/objects/extension/changes/extension.create.js +49 -0
- package/dist/core/objects/extension/changes/extension.drop.d.ts +22 -0
- package/dist/core/objects/extension/changes/extension.drop.js +28 -0
- package/dist/core/objects/extension/changes/extension.types.d.ts +5 -0
- package/dist/core/objects/extension/changes/extension.types.js +1 -0
- package/dist/core/objects/extension/extension.diff.d.ts +10 -0
- package/dist/core/objects/extension/extension.diff.js +65 -0
- package/dist/core/objects/extension/extension.model.d.ts +52 -0
- package/dist/core/objects/extension/extension.model.js +268 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.alter.d.ts +51 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.alter.js +61 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.base.d.ts +17 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.base.js +13 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.comment.d.ts +26 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.comment.js +50 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.create.d.ts +25 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.create.js +78 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.drop.d.ts +22 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.drop.js +28 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.privilege.d.ts +97 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.privilege.js +123 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.types.d.ts +6 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.types.js +1 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/foreign-data-wrapper.diff.d.ts +18 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/foreign-data-wrapper.diff.js +221 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/foreign-data-wrapper.model.d.ts +59 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper/foreign-data-wrapper.model.js +128 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper.types.d.ts +5 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-data-wrapper.types.js +1 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.alter.d.ts +163 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.alter.js +248 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.base.d.ts +17 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.base.js +13 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.comment.d.ts +26 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.comment.js +50 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.create.d.ts +25 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.create.js +64 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.drop.d.ts +22 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.drop.js +31 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.privilege.d.ts +97 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.privilege.js +129 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.types.d.ts +6 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.types.js +1 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/foreign-table.diff.d.ts +18 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/foreign-table.diff.js +268 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/foreign-table.model.d.ts +117 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/foreign-table.model.js +215 -0
- package/dist/core/objects/foreign-data-wrapper/server/changes/server.alter.d.ts +65 -0
- package/dist/core/objects/foreign-data-wrapper/server/changes/server.alter.js +84 -0
- package/dist/core/objects/foreign-data-wrapper/server/changes/server.base.d.ts +17 -0
- package/dist/core/objects/foreign-data-wrapper/server/changes/server.base.js +13 -0
- package/dist/core/objects/foreign-data-wrapper/server/changes/server.comment.d.ts +26 -0
- package/dist/core/objects/foreign-data-wrapper/server/changes/server.comment.js +43 -0
- package/dist/core/objects/foreign-data-wrapper/server/changes/server.create.d.ts +24 -0
- package/dist/core/objects/foreign-data-wrapper/server/changes/server.create.js +62 -0
- package/dist/core/objects/foreign-data-wrapper/server/changes/server.drop.d.ts +22 -0
- package/dist/core/objects/foreign-data-wrapper/server/changes/server.drop.js +28 -0
- package/dist/core/objects/foreign-data-wrapper/server/changes/server.privilege.d.ts +97 -0
- package/dist/core/objects/foreign-data-wrapper/server/changes/server.privilege.js +123 -0
- package/dist/core/objects/foreign-data-wrapper/server/changes/server.types.d.ts +6 -0
- package/dist/core/objects/foreign-data-wrapper/server/changes/server.types.js +1 -0
- package/dist/core/objects/foreign-data-wrapper/server/server.diff.d.ts +18 -0
- package/dist/core/objects/foreign-data-wrapper/server/server.diff.js +209 -0
- package/dist/core/objects/foreign-data-wrapper/server/server.model.d.ts +62 -0
- package/dist/core/objects/foreign-data-wrapper/server/server.model.js +118 -0
- package/dist/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.alter.d.ts +37 -0
- package/dist/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.alter.js +38 -0
- package/dist/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.base.d.ts +17 -0
- package/dist/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.base.js +13 -0
- package/dist/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.create.d.ts +24 -0
- package/dist/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.create.js +52 -0
- package/dist/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.drop.d.ts +23 -0
- package/dist/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.drop.js +34 -0
- package/dist/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.types.d.ts +4 -0
- package/dist/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.types.js +1 -0
- package/dist/core/objects/foreign-data-wrapper/user-mapping/user-mapping.diff.d.ts +10 -0
- package/dist/core/objects/foreign-data-wrapper/user-mapping/user-mapping.diff.js +77 -0
- package/dist/core/objects/foreign-data-wrapper/user-mapping/user-mapping.model.d.ts +36 -0
- package/dist/core/objects/foreign-data-wrapper/user-mapping/user-mapping.model.js +85 -0
- package/dist/core/objects/index/changes/index.alter.d.ts +76 -0
- package/dist/core/objects/index/changes/index.alter.js +94 -0
- package/dist/core/objects/index/changes/index.base.d.ts +17 -0
- package/dist/core/objects/index/changes/index.base.js +13 -0
- package/dist/core/objects/index/changes/index.comment.d.ts +26 -0
- package/dist/core/objects/index/changes/index.comment.js +50 -0
- package/dist/core/objects/index/changes/index.create.d.ts +30 -0
- package/dist/core/objects/index/changes/index.create.js +53 -0
- package/dist/core/objects/index/changes/index.drop.d.ts +22 -0
- package/dist/core/objects/index/changes/index.drop.js +28 -0
- package/dist/core/objects/index/changes/index.types.d.ts +5 -0
- package/dist/core/objects/index/changes/index.types.js +1 -0
- package/dist/core/objects/index/changes/utils.d.ts +3 -0
- package/dist/core/objects/index/changes/utils.js +6 -0
- package/dist/core/objects/index/index.diff.d.ts +12 -0
- package/dist/core/objects/index/index.diff.js +182 -0
- package/dist/core/objects/index/index.model.d.ts +150 -0
- package/dist/core/objects/index/index.model.js +340 -0
- package/dist/core/objects/language/changes/language.alter.d.ts +32 -0
- package/dist/core/objects/language/changes/language.alter.js +30 -0
- package/dist/core/objects/language/changes/language.base.d.ts +17 -0
- package/dist/core/objects/language/changes/language.base.js +13 -0
- package/dist/core/objects/language/changes/language.comment.d.ts +26 -0
- package/dist/core/objects/language/changes/language.comment.js +45 -0
- package/dist/core/objects/language/changes/language.create.d.ts +25 -0
- package/dist/core/objects/language/changes/language.create.js +76 -0
- package/dist/core/objects/language/changes/language.drop.d.ts +22 -0
- package/dist/core/objects/language/changes/language.drop.js +31 -0
- package/dist/core/objects/language/changes/language.privilege.d.ts +97 -0
- package/dist/core/objects/language/changes/language.privilege.js +128 -0
- package/dist/core/objects/language/changes/language.types.d.ts +6 -0
- package/dist/core/objects/language/changes/language.types.js +1 -0
- package/dist/core/objects/language/language.diff.d.ts +15 -0
- package/dist/core/objects/language/language.diff.js +117 -0
- package/dist/core/objects/language/language.model.d.ts +62 -0
- package/dist/core/objects/language/language.model.js +128 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.alter.d.ts +67 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.alter.js +63 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.base.d.ts +17 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.base.js +13 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.comment.d.ts +53 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.comment.js +112 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.create.d.ts +35 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.create.js +71 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.drop.d.ts +26 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.drop.js +42 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.privilege.d.ts +105 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.privilege.js +151 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.types.d.ts +6 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.types.js +1 -0
- package/dist/core/objects/materialized-view/materialized-view.diff.d.ts +18 -0
- package/dist/core/objects/materialized-view/materialized-view.diff.js +335 -0
- package/dist/core/objects/materialized-view/materialized-view.model.d.ts +152 -0
- package/dist/core/objects/materialized-view/materialized-view.model.js +228 -0
- package/dist/core/objects/procedure/changes/procedure.alter.d.ts +143 -0
- package/dist/core/objects/procedure/changes/procedure.alter.js +207 -0
- package/dist/core/objects/procedure/changes/procedure.base.d.ts +17 -0
- package/dist/core/objects/procedure/changes/procedure.base.js +13 -0
- package/dist/core/objects/procedure/changes/procedure.comment.d.ts +26 -0
- package/dist/core/objects/procedure/changes/procedure.comment.js +52 -0
- package/dist/core/objects/procedure/changes/procedure.create.d.ts +42 -0
- package/dist/core/objects/procedure/changes/procedure.create.js +77 -0
- package/dist/core/objects/procedure/changes/procedure.drop.d.ts +23 -0
- package/dist/core/objects/procedure/changes/procedure.drop.js +37 -0
- package/dist/core/objects/procedure/changes/procedure.privilege.d.ts +98 -0
- package/dist/core/objects/procedure/changes/procedure.privilege.js +144 -0
- package/dist/core/objects/procedure/changes/procedure.types.d.ts +6 -0
- package/dist/core/objects/procedure/changes/procedure.types.js +1 -0
- package/dist/core/objects/procedure/procedure.diff.d.ts +18 -0
- package/dist/core/objects/procedure/procedure.diff.js +282 -0
- package/dist/core/objects/procedure/procedure.model.d.ts +132 -0
- package/dist/core/objects/procedure/procedure.model.js +244 -0
- package/dist/core/objects/procedure/utils.d.ts +14 -0
- package/dist/core/objects/procedure/utils.js +55 -0
- package/dist/core/objects/publication/changes/publication.alter.d.ts +88 -0
- package/dist/core/objects/publication/changes/publication.alter.js +176 -0
- package/dist/core/objects/publication/changes/publication.base.d.ts +17 -0
- package/dist/core/objects/publication/changes/publication.base.js +13 -0
- package/dist/core/objects/publication/changes/publication.comment.d.ts +23 -0
- package/dist/core/objects/publication/changes/publication.comment.js +46 -0
- package/dist/core/objects/publication/changes/publication.create.d.ts +17 -0
- package/dist/core/objects/publication/changes/publication.create.js +61 -0
- package/dist/core/objects/publication/changes/publication.drop.d.ts +17 -0
- package/dist/core/objects/publication/changes/publication.drop.js +23 -0
- package/dist/core/objects/publication/changes/publication.types.d.ts +5 -0
- package/dist/core/objects/publication/changes/publication.types.js +1 -0
- package/dist/core/objects/publication/publication.diff.d.ts +5 -0
- package/dist/core/objects/publication/publication.diff.js +161 -0
- package/dist/core/objects/publication/publication.model.d.ts +96 -0
- package/dist/core/objects/publication/publication.model.js +186 -0
- package/dist/core/objects/publication/utils.d.ts +5 -0
- package/dist/core/objects/publication/utils.js +45 -0
- package/dist/core/objects/rls-policy/changes/rls-policy.alter.d.ts +62 -0
- package/dist/core/objects/rls-policy/changes/rls-policy.alter.js +90 -0
- package/dist/core/objects/rls-policy/changes/rls-policy.base.d.ts +17 -0
- package/dist/core/objects/rls-policy/changes/rls-policy.base.js +13 -0
- package/dist/core/objects/rls-policy/changes/rls-policy.comment.d.ts +23 -0
- package/dist/core/objects/rls-policy/changes/rls-policy.comment.js +51 -0
- package/dist/core/objects/rls-policy/changes/rls-policy.create.d.ts +27 -0
- package/dist/core/objects/rls-policy/changes/rls-policy.create.js +79 -0
- package/dist/core/objects/rls-policy/changes/rls-policy.drop.d.ts +22 -0
- package/dist/core/objects/rls-policy/changes/rls-policy.drop.js +33 -0
- package/dist/core/objects/rls-policy/changes/rls-policy.types.d.ts +5 -0
- package/dist/core/objects/rls-policy/changes/rls-policy.types.js +1 -0
- package/dist/core/objects/rls-policy/rls-policy.diff.d.ts +10 -0
- package/dist/core/objects/rls-policy/rls-policy.diff.js +80 -0
- package/dist/core/objects/rls-policy/rls-policy.model.d.ts +52 -0
- package/dist/core/objects/rls-policy/rls-policy.model.js +127 -0
- package/dist/core/objects/role/changes/role.alter.d.ts +78 -0
- package/dist/core/objects/role/changes/role.alter.js +55 -0
- package/dist/core/objects/role/changes/role.base.d.ts +17 -0
- package/dist/core/objects/role/changes/role.base.js +13 -0
- package/dist/core/objects/role/changes/role.comment.d.ts +23 -0
- package/dist/core/objects/role/changes/role.comment.js +42 -0
- package/dist/core/objects/role/changes/role.create.d.ts +38 -0
- package/dist/core/objects/role/changes/role.create.js +83 -0
- package/dist/core/objects/role/changes/role.drop.d.ts +22 -0
- package/dist/core/objects/role/changes/role.drop.js +28 -0
- package/dist/core/objects/role/changes/role.privilege.d.ts +148 -0
- package/dist/core/objects/role/changes/role.privilege.js +283 -0
- package/dist/core/objects/role/changes/role.types.d.ts +6 -0
- package/dist/core/objects/role/changes/role.types.js +1 -0
- package/dist/core/objects/role/role.diff.d.ts +13 -0
- package/dist/core/objects/role/role.diff.js +386 -0
- package/dist/core/objects/role/role.model.d.ts +89 -0
- package/dist/core/objects/role/role.model.js +312 -0
- package/dist/core/objects/rule/changes/rule.alter.d.ts +22 -0
- package/dist/core/objects/rule/changes/rule.alter.js +58 -0
- package/dist/core/objects/rule/changes/rule.base.d.ts +17 -0
- package/dist/core/objects/rule/changes/rule.base.js +13 -0
- package/dist/core/objects/rule/changes/rule.comment.d.ts +22 -0
- package/dist/core/objects/rule/changes/rule.comment.js +51 -0
- package/dist/core/objects/rule/changes/rule.create.d.ts +14 -0
- package/dist/core/objects/rule/changes/rule.create.js +28 -0
- package/dist/core/objects/rule/changes/rule.drop.d.ts +12 -0
- package/dist/core/objects/rule/changes/rule.drop.js +23 -0
- package/dist/core/objects/rule/changes/rule.types.d.ts +5 -0
- package/dist/core/objects/rule/changes/rule.types.js +1 -0
- package/dist/core/objects/rule/rule.diff.d.ts +3 -0
- package/dist/core/objects/rule/rule.diff.js +53 -0
- package/dist/core/objects/rule/rule.model.d.ts +72 -0
- package/dist/core/objects/rule/rule.model.js +156 -0
- package/dist/core/objects/schema/changes/schema.alter.d.ts +32 -0
- package/dist/core/objects/schema/changes/schema.alter.js +25 -0
- package/dist/core/objects/schema/changes/schema.base.d.ts +17 -0
- package/dist/core/objects/schema/changes/schema.base.js +13 -0
- package/dist/core/objects/schema/changes/schema.comment.d.ts +23 -0
- package/dist/core/objects/schema/changes/schema.comment.js +43 -0
- package/dist/core/objects/schema/changes/schema.create.d.ts +27 -0
- package/dist/core/objects/schema/changes/schema.create.js +38 -0
- package/dist/core/objects/schema/changes/schema.drop.d.ts +22 -0
- package/dist/core/objects/schema/changes/schema.drop.js +28 -0
- package/dist/core/objects/schema/changes/schema.privilege.d.ts +97 -0
- package/dist/core/objects/schema/changes/schema.privilege.js +131 -0
- package/dist/core/objects/schema/changes/schema.types.d.ts +6 -0
- package/dist/core/objects/schema/changes/schema.types.js +1 -0
- package/dist/core/objects/schema/schema.diff.d.ts +18 -0
- package/dist/core/objects/schema/schema.diff.js +142 -0
- package/dist/core/objects/schema/schema.model.d.ts +47 -0
- package/dist/core/objects/schema/schema.model.js +91 -0
- package/dist/core/objects/sequence/changes/sequence.alter.d.ts +59 -0
- package/dist/core/objects/sequence/changes/sequence.alter.js +75 -0
- package/dist/core/objects/sequence/changes/sequence.base.d.ts +17 -0
- package/dist/core/objects/sequence/changes/sequence.base.js +13 -0
- package/dist/core/objects/sequence/changes/sequence.comment.d.ts +23 -0
- package/dist/core/objects/sequence/changes/sequence.comment.js +47 -0
- package/dist/core/objects/sequence/changes/sequence.create.d.ts +25 -0
- package/dist/core/objects/sequence/changes/sequence.create.js +78 -0
- package/dist/core/objects/sequence/changes/sequence.drop.d.ts +22 -0
- package/dist/core/objects/sequence/changes/sequence.drop.js +31 -0
- package/dist/core/objects/sequence/changes/sequence.privilege.d.ts +101 -0
- package/dist/core/objects/sequence/changes/sequence.privilege.js +135 -0
- package/dist/core/objects/sequence/changes/sequence.types.d.ts +6 -0
- package/dist/core/objects/sequence/changes/sequence.types.js +1 -0
- package/dist/core/objects/sequence/sequence.diff.d.ts +20 -0
- package/dist/core/objects/sequence/sequence.diff.js +258 -0
- package/dist/core/objects/sequence/sequence.model.d.ts +76 -0
- package/dist/core/objects/sequence/sequence.model.js +169 -0
- package/dist/core/objects/subscription/changes/subscription.alter.d.ts +56 -0
- package/dist/core/objects/subscription/changes/subscription.alter.js +82 -0
- package/dist/core/objects/subscription/changes/subscription.base.d.ts +17 -0
- package/dist/core/objects/subscription/changes/subscription.base.js +13 -0
- package/dist/core/objects/subscription/changes/subscription.comment.d.ts +23 -0
- package/dist/core/objects/subscription/changes/subscription.comment.js +46 -0
- package/dist/core/objects/subscription/changes/subscription.create.d.ts +12 -0
- package/dist/core/objects/subscription/changes/subscription.create.js +52 -0
- package/dist/core/objects/subscription/changes/subscription.drop.d.ts +11 -0
- package/dist/core/objects/subscription/changes/subscription.drop.js +15 -0
- package/dist/core/objects/subscription/changes/subscription.types.d.ts +5 -0
- package/dist/core/objects/subscription/changes/subscription.types.js +1 -0
- package/dist/core/objects/subscription/subscription.diff.d.ts +5 -0
- package/dist/core/objects/subscription/subscription.diff.js +167 -0
- package/dist/core/objects/subscription/subscription.model.d.ts +80 -0
- package/dist/core/objects/subscription/subscription.model.js +166 -0
- package/dist/core/objects/subscription/utils.d.ts +37 -0
- package/dist/core/objects/subscription/utils.js +112 -0
- package/dist/core/objects/table/changes/table.alter.d.ts +357 -0
- package/dist/core/objects/table/changes/table.alter.js +607 -0
- package/dist/core/objects/table/changes/table.base.d.ts +17 -0
- package/dist/core/objects/table/changes/table.base.js +13 -0
- package/dist/core/objects/table/changes/table.comment.d.ts +106 -0
- package/dist/core/objects/table/changes/table.comment.js +175 -0
- package/dist/core/objects/table/changes/table.create.d.ts +33 -0
- package/dist/core/objects/table/changes/table.create.js +145 -0
- package/dist/core/objects/table/changes/table.drop.d.ts +22 -0
- package/dist/core/objects/table/changes/table.drop.js +35 -0
- package/dist/core/objects/table/changes/table.privilege.d.ts +107 -0
- package/dist/core/objects/table/changes/table.privilege.js +150 -0
- package/dist/core/objects/table/changes/table.types.d.ts +6 -0
- package/dist/core/objects/table/changes/table.types.js +1 -0
- package/dist/core/objects/table/table.diff.d.ts +18 -0
- package/dist/core/objects/table/table.diff.js +668 -0
- package/dist/core/objects/table/table.model.d.ts +341 -0
- package/dist/core/objects/table/table.model.js +426 -0
- package/dist/core/objects/trigger/changes/trigger.alter.d.ts +29 -0
- package/dist/core/objects/trigger/changes/trigger.alter.js +27 -0
- package/dist/core/objects/trigger/changes/trigger.base.d.ts +17 -0
- package/dist/core/objects/trigger/changes/trigger.base.js +13 -0
- package/dist/core/objects/trigger/changes/trigger.comment.d.ts +23 -0
- package/dist/core/objects/trigger/changes/trigger.comment.js +51 -0
- package/dist/core/objects/trigger/changes/trigger.create.d.ts +41 -0
- package/dist/core/objects/trigger/changes/trigger.create.js +61 -0
- package/dist/core/objects/trigger/changes/trigger.drop.d.ts +22 -0
- package/dist/core/objects/trigger/changes/trigger.drop.js +33 -0
- package/dist/core/objects/trigger/changes/trigger.types.d.ts +5 -0
- package/dist/core/objects/trigger/changes/trigger.types.js +1 -0
- package/dist/core/objects/trigger/trigger.diff.d.ts +11 -0
- package/dist/core/objects/trigger/trigger.diff.js +84 -0
- package/dist/core/objects/trigger/trigger.model.d.ts +92 -0
- package/dist/core/objects/trigger/trigger.model.js +235 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.alter.d.ts +81 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.alter.js +123 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.base.d.ts +17 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.base.js +13 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.comment.d.ts +53 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.comment.js +108 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.create.d.ts +23 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.create.js +72 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.drop.d.ts +22 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.drop.js +31 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.privilege.d.ts +97 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.privilege.js +131 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.types.d.ts +6 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.types.js +1 -0
- package/dist/core/objects/type/composite-type/composite-type.diff.d.ts +18 -0
- package/dist/core/objects/type/composite-type/composite-type.diff.js +250 -0
- package/dist/core/objects/type/composite-type/composite-type.model.d.ts +148 -0
- package/dist/core/objects/type/composite-type/composite-type.model.js +223 -0
- package/dist/core/objects/type/enum/changes/enum.alter.d.ts +52 -0
- package/dist/core/objects/type/enum/changes/enum.alter.js +60 -0
- package/dist/core/objects/type/enum/changes/enum.base.d.ts +17 -0
- package/dist/core/objects/type/enum/changes/enum.base.js +13 -0
- package/dist/core/objects/type/enum/changes/enum.comment.d.ts +26 -0
- package/dist/core/objects/type/enum/changes/enum.comment.js +47 -0
- package/dist/core/objects/type/enum/changes/enum.create.d.ts +22 -0
- package/dist/core/objects/type/enum/changes/enum.create.js +43 -0
- package/dist/core/objects/type/enum/changes/enum.drop.d.ts +22 -0
- package/dist/core/objects/type/enum/changes/enum.drop.js +28 -0
- package/dist/core/objects/type/enum/changes/enum.privilege.d.ts +97 -0
- package/dist/core/objects/type/enum/changes/enum.privilege.js +131 -0
- package/dist/core/objects/type/enum/changes/enum.types.d.ts +6 -0
- package/dist/core/objects/type/enum/changes/enum.types.js +1 -0
- package/dist/core/objects/type/enum/enum.diff.d.ts +18 -0
- package/dist/core/objects/type/enum/enum.diff.js +268 -0
- package/dist/core/objects/type/enum/enum.model.d.ts +66 -0
- package/dist/core/objects/type/enum/enum.model.js +154 -0
- package/dist/core/objects/type/range/changes/range.alter.d.ts +33 -0
- package/dist/core/objects/type/range/changes/range.alter.js +30 -0
- package/dist/core/objects/type/range/changes/range.base.d.ts +17 -0
- package/dist/core/objects/type/range/changes/range.base.js +13 -0
- package/dist/core/objects/type/range/changes/range.comment.d.ts +26 -0
- package/dist/core/objects/type/range/changes/range.comment.js +47 -0
- package/dist/core/objects/type/range/changes/range.create.d.ts +31 -0
- package/dist/core/objects/type/range/changes/range.create.js +113 -0
- package/dist/core/objects/type/range/changes/range.drop.d.ts +22 -0
- package/dist/core/objects/type/range/changes/range.drop.js +28 -0
- package/dist/core/objects/type/range/changes/range.privilege.d.ts +97 -0
- package/dist/core/objects/type/range/changes/range.privilege.js +131 -0
- package/dist/core/objects/type/range/changes/range.types.d.ts +6 -0
- package/dist/core/objects/type/range/changes/range.types.js +1 -0
- package/dist/core/objects/type/range/range.diff.d.ts +18 -0
- package/dist/core/objects/type/range/range.diff.js +172 -0
- package/dist/core/objects/type/range/range.model.d.ts +81 -0
- package/dist/core/objects/type/range/range.model.js +165 -0
- package/dist/core/objects/type/type.types.d.ts +4 -0
- package/dist/core/objects/type/type.types.js +1 -0
- package/dist/core/objects/utils.d.ts +57 -0
- package/dist/core/objects/utils.js +137 -0
- package/dist/core/objects/view/changes/view.alter.d.ts +62 -0
- package/dist/core/objects/view/changes/view.alter.js +75 -0
- package/dist/core/objects/view/changes/view.base.d.ts +17 -0
- package/dist/core/objects/view/changes/view.base.js +13 -0
- package/dist/core/objects/view/changes/view.comment.d.ts +23 -0
- package/dist/core/objects/view/changes/view.comment.js +46 -0
- package/dist/core/objects/view/changes/view.create.d.ts +27 -0
- package/dist/core/objects/view/changes/view.create.js +57 -0
- package/dist/core/objects/view/changes/view.drop.d.ts +17 -0
- package/dist/core/objects/view/changes/view.drop.js +30 -0
- package/dist/core/objects/view/changes/view.privilege.d.ts +107 -0
- package/dist/core/objects/view/changes/view.privilege.js +150 -0
- package/dist/core/objects/view/changes/view.types.d.ts +6 -0
- package/dist/core/objects/view/changes/view.types.js +1 -0
- package/dist/core/objects/view/view.diff.d.ts +18 -0
- package/dist/core/objects/view/view.diff.js +270 -0
- package/dist/core/objects/view/view.model.d.ts +152 -0
- package/dist/core/objects/view/view.model.js +250 -0
- package/dist/core/plan/apply.d.ts +33 -0
- package/dist/core/plan/apply.js +112 -0
- package/dist/core/plan/create.d.ts +22 -0
- package/dist/core/plan/create.js +228 -0
- package/dist/core/plan/hierarchy.d.ts +19 -0
- package/dist/core/plan/hierarchy.js +488 -0
- package/dist/core/plan/index.d.ts +19 -0
- package/dist/core/plan/index.js +21 -0
- package/dist/core/plan/io.d.ts +12 -0
- package/dist/core/plan/io.js +17 -0
- package/dist/core/plan/risk.d.ts +10 -0
- package/dist/core/plan/risk.js +38 -0
- package/dist/core/plan/serialize.d.ts +26 -0
- package/dist/core/plan/serialize.js +176 -0
- package/dist/core/plan/statements.d.ts +8 -0
- package/dist/core/plan/statements.js +13 -0
- package/dist/core/plan/types.d.ts +153 -0
- package/dist/core/plan/types.js +32 -0
- package/dist/core/postgres-config.d.ts +8 -0
- package/dist/core/postgres-config.js +46 -0
- package/dist/core/sort/custom-constraints.d.ts +9 -0
- package/dist/core/sort/custom-constraints.js +133 -0
- package/dist/core/sort/debug-visualization.d.ts +8 -0
- package/dist/core/sort/debug-visualization.js +145 -0
- package/dist/core/sort/dependency-filter.d.ts +19 -0
- package/dist/core/sort/dependency-filter.js +152 -0
- package/dist/core/sort/graph-builder.d.ts +37 -0
- package/dist/core/sort/graph-builder.js +172 -0
- package/dist/core/sort/graph-utils.d.ts +14 -0
- package/dist/core/sort/graph-utils.js +41 -0
- package/dist/core/sort/logical-sort.d.ts +26 -0
- package/dist/core/sort/logical-sort.js +532 -0
- package/dist/core/sort/sort-changes.d.ts +28 -0
- package/dist/core/sort/sort-changes.js +147 -0
- package/dist/core/sort/topological-sort.d.ts +20 -0
- package/dist/core/sort/topological-sort.js +138 -0
- package/dist/core/sort/types.d.ts +102 -0
- package/dist/core/sort/types.js +1 -0
- package/dist/core/sort/utils.d.ts +23 -0
- package/dist/core/sort/utils.js +51 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +58 -12
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base utilities and helpers for object privilege changes.
|
|
3
|
+
* These functions support GRANT/REVOKE operations across different database objects.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Returns the complete set of available privileges for a given object kind.
|
|
7
|
+
* This is used to determine whether a privilege list represents "ALL PRIVILEGES".
|
|
8
|
+
*
|
|
9
|
+
* @param kind - The PostgreSQL object kind (TABLE, VIEW, SEQUENCE, etc.)
|
|
10
|
+
* @param version - The PostgreSQL version number (e.g., 170000 for 17.0.0)
|
|
11
|
+
* @returns An array of privilege names available for this object kind
|
|
12
|
+
*/
|
|
13
|
+
function objectPrivilegeUniverse(kind, version) {
|
|
14
|
+
switch (kind) {
|
|
15
|
+
case "TABLE": {
|
|
16
|
+
const includesMaintain = (version ?? 170000) >= 170000;
|
|
17
|
+
return [
|
|
18
|
+
"DELETE",
|
|
19
|
+
"INSERT",
|
|
20
|
+
...(includesMaintain ? ["MAINTAIN"] : []),
|
|
21
|
+
"REFERENCES",
|
|
22
|
+
"SELECT",
|
|
23
|
+
"TRIGGER",
|
|
24
|
+
"TRUNCATE",
|
|
25
|
+
"UPDATE",
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
case "VIEW": {
|
|
29
|
+
// Per PostgreSQL docs, views are table-like and share the table privilege set
|
|
30
|
+
// for GRANT/REVOKE purposes. MAINTAIN exists on PostgreSQL >= 17
|
|
31
|
+
const includesMaintain = (version ?? 170000) >= 170000;
|
|
32
|
+
return [
|
|
33
|
+
"DELETE",
|
|
34
|
+
"INSERT",
|
|
35
|
+
...(includesMaintain ? ["MAINTAIN"] : []),
|
|
36
|
+
"REFERENCES",
|
|
37
|
+
"SELECT",
|
|
38
|
+
"TRIGGER",
|
|
39
|
+
"TRUNCATE",
|
|
40
|
+
"UPDATE",
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
case "MATERIALIZED VIEW": {
|
|
44
|
+
// Materialized views support the same table-like privileges as tables/views
|
|
45
|
+
// Per PostgreSQL docs, materialized views are table-like for GRANT/REVOKE purposes
|
|
46
|
+
const includesMaintain = (version ?? 170000) >= 170000;
|
|
47
|
+
return [
|
|
48
|
+
"DELETE",
|
|
49
|
+
"INSERT",
|
|
50
|
+
...(includesMaintain ? ["MAINTAIN"] : []),
|
|
51
|
+
"REFERENCES",
|
|
52
|
+
"SELECT",
|
|
53
|
+
"TRIGGER",
|
|
54
|
+
"TRUNCATE",
|
|
55
|
+
"UPDATE",
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
case "SEQUENCE":
|
|
59
|
+
return ["SELECT", "UPDATE", "USAGE"].sort();
|
|
60
|
+
case "SCHEMA":
|
|
61
|
+
return ["CREATE", "USAGE"].sort();
|
|
62
|
+
case "LANGUAGE":
|
|
63
|
+
return ["USAGE"];
|
|
64
|
+
case "FUNCTION":
|
|
65
|
+
case "PROCEDURE":
|
|
66
|
+
case "ROUTINE":
|
|
67
|
+
return ["EXECUTE"];
|
|
68
|
+
case "TYPE":
|
|
69
|
+
case "DOMAIN":
|
|
70
|
+
return ["USAGE"];
|
|
71
|
+
case "FOREIGN DATA WRAPPER":
|
|
72
|
+
return ["USAGE"];
|
|
73
|
+
case "SERVER":
|
|
74
|
+
return ["USAGE"];
|
|
75
|
+
case "FOREIGN TABLE": {
|
|
76
|
+
const includesMaintain = (version ?? 170000) >= 170000;
|
|
77
|
+
return [
|
|
78
|
+
"DELETE",
|
|
79
|
+
"INSERT",
|
|
80
|
+
...(includesMaintain ? ["MAINTAIN"] : []),
|
|
81
|
+
"REFERENCES",
|
|
82
|
+
"SELECT",
|
|
83
|
+
"TRIGGER",
|
|
84
|
+
"TRUNCATE",
|
|
85
|
+
"UPDATE",
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
default:
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Checks if a privilege list represents the full set of privileges for an object kind.
|
|
94
|
+
* This determines whether we can use "ALL PRIVILEGES" shorthand in SQL.
|
|
95
|
+
*
|
|
96
|
+
* @param kind - The PostgreSQL object kind
|
|
97
|
+
* @param list - Array of privilege names to check
|
|
98
|
+
* @param version - The PostgreSQL version number
|
|
99
|
+
* @returns true if the list contains all available privileges for this object kind
|
|
100
|
+
*/
|
|
101
|
+
function isFullObjectPrivilegeSet(kind, list, version) {
|
|
102
|
+
const uniqSorted = [...new Set(list)].sort();
|
|
103
|
+
const fullSorted = [...objectPrivilegeUniverse(kind, version)].sort();
|
|
104
|
+
if (uniqSorted.length !== fullSorted.length)
|
|
105
|
+
return false;
|
|
106
|
+
for (let i = 0; i < uniqSorted.length; i++) {
|
|
107
|
+
if (uniqSorted[i] !== fullSorted[i])
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Formats a list of privileges for use in GRANT/REVOKE statements.
|
|
114
|
+
* If the list represents all privileges, returns "ALL", otherwise returns a comma-separated list.
|
|
115
|
+
*
|
|
116
|
+
* @param kind - The PostgreSQL object kind
|
|
117
|
+
* @param list - Array of privilege names to format
|
|
118
|
+
* @param version - The PostgreSQL version number
|
|
119
|
+
* @returns A SQL-formatted privilege list (either "ALL" or "PRIV1, PRIV2, ...")
|
|
120
|
+
*/
|
|
121
|
+
export function formatObjectPrivilegeList(kind, list, version) {
|
|
122
|
+
const uniqSorted = [...new Set(list)].sort();
|
|
123
|
+
return isFullObjectPrivilegeSet(kind, uniqSorted, version)
|
|
124
|
+
? "ALL"
|
|
125
|
+
: uniqSorted.join(", ");
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Gets the SQL keyword prefix for a given object kind in GRANT/REVOKE statements.
|
|
129
|
+
*
|
|
130
|
+
* @param objectKind - The PostgreSQL object kind
|
|
131
|
+
* @returns The SQL prefix (e.g., "ON SCHEMA", "ON DOMAIN", "ON")
|
|
132
|
+
*/
|
|
133
|
+
export function getObjectKindPrefix(objectKind) {
|
|
134
|
+
switch (objectKind) {
|
|
135
|
+
case "FUNCTION":
|
|
136
|
+
return "ON FUNCTION";
|
|
137
|
+
case "PROCEDURE":
|
|
138
|
+
return "ON PROCEDURE";
|
|
139
|
+
case "ROUTINE":
|
|
140
|
+
return "ON ROUTINE";
|
|
141
|
+
case "LANGUAGE":
|
|
142
|
+
return "ON LANGUAGE";
|
|
143
|
+
case "SCHEMA":
|
|
144
|
+
return "ON SCHEMA";
|
|
145
|
+
case "SEQUENCE":
|
|
146
|
+
return "ON SEQUENCE";
|
|
147
|
+
case "DOMAIN":
|
|
148
|
+
return "ON DOMAIN";
|
|
149
|
+
case "TYPE":
|
|
150
|
+
return "ON TYPE";
|
|
151
|
+
case "FOREIGN TABLE":
|
|
152
|
+
return "ON FOREIGN TABLE";
|
|
153
|
+
default:
|
|
154
|
+
return "ON";
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
export function normalizePrivileges(privileges) {
|
|
158
|
+
return privileges
|
|
159
|
+
.map((privilege) => ({
|
|
160
|
+
grantee: privilege.grantee,
|
|
161
|
+
privilege: privilege.privilege,
|
|
162
|
+
grantable: privilege.grantable,
|
|
163
|
+
}))
|
|
164
|
+
.sort((a, b) => {
|
|
165
|
+
if (a.grantee !== b.grantee)
|
|
166
|
+
return a.grantee.localeCompare(b.grantee);
|
|
167
|
+
return a.privilege.localeCompare(b.privilege);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Collation } from "../collation.model.ts";
|
|
2
|
+
import { AlterCollationChange } from "./collation.base.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Alter a collation.
|
|
5
|
+
*
|
|
6
|
+
* @see https://www.postgresql.org/docs/17/sql-altercollation.html
|
|
7
|
+
*
|
|
8
|
+
* Synopsis
|
|
9
|
+
* ```sql
|
|
10
|
+
* ALTER COLLATION name REFRESH VERSION
|
|
11
|
+
* ALTER COLLATION name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
|
|
12
|
+
* ALTER COLLATION name RENAME TO new_name
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export type AlterCollation = AlterCollationChangeOwner | AlterCollationRefreshVersion;
|
|
16
|
+
/**
|
|
17
|
+
* ALTER COLLATION ... OWNER TO ...
|
|
18
|
+
*/
|
|
19
|
+
export declare class AlterCollationChangeOwner extends AlterCollationChange {
|
|
20
|
+
readonly collation: Collation;
|
|
21
|
+
readonly owner: string;
|
|
22
|
+
readonly scope: "object";
|
|
23
|
+
constructor(props: {
|
|
24
|
+
collation: Collation;
|
|
25
|
+
owner: string;
|
|
26
|
+
});
|
|
27
|
+
get requires(): `collation:${string}`[];
|
|
28
|
+
serialize(): string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* ALTER COLLATION ... REFRESH VERSION
|
|
32
|
+
*/
|
|
33
|
+
export declare class AlterCollationRefreshVersion extends AlterCollationChange {
|
|
34
|
+
readonly collation: Collation;
|
|
35
|
+
readonly scope: "object";
|
|
36
|
+
constructor(props: {
|
|
37
|
+
collation: Collation;
|
|
38
|
+
});
|
|
39
|
+
get requires(): `collation:${string}`[];
|
|
40
|
+
serialize(): string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Replace a collation by dropping and recreating it.
|
|
44
|
+
* This is used when properties that cannot be altered via ALTER COLLATION change.
|
|
45
|
+
*/
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AlterCollationChange } from "./collation.base.js";
|
|
2
|
+
/**
|
|
3
|
+
* ALTER COLLATION ... OWNER TO ...
|
|
4
|
+
*/
|
|
5
|
+
export class AlterCollationChangeOwner extends AlterCollationChange {
|
|
6
|
+
collation;
|
|
7
|
+
owner;
|
|
8
|
+
scope = "object";
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super();
|
|
11
|
+
this.collation = props.collation;
|
|
12
|
+
this.owner = props.owner;
|
|
13
|
+
}
|
|
14
|
+
get requires() {
|
|
15
|
+
return [this.collation.stableId];
|
|
16
|
+
}
|
|
17
|
+
serialize() {
|
|
18
|
+
return [
|
|
19
|
+
"ALTER COLLATION",
|
|
20
|
+
`${this.collation.schema}.${this.collation.name}`,
|
|
21
|
+
"OWNER TO",
|
|
22
|
+
this.owner,
|
|
23
|
+
].join(" ");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* ALTER COLLATION ... REFRESH VERSION
|
|
28
|
+
*/
|
|
29
|
+
export class AlterCollationRefreshVersion extends AlterCollationChange {
|
|
30
|
+
collation;
|
|
31
|
+
scope = "object";
|
|
32
|
+
constructor(props) {
|
|
33
|
+
super();
|
|
34
|
+
this.collation = props.collation;
|
|
35
|
+
}
|
|
36
|
+
get requires() {
|
|
37
|
+
return [this.collation.stableId];
|
|
38
|
+
}
|
|
39
|
+
serialize() {
|
|
40
|
+
return [
|
|
41
|
+
"ALTER COLLATION",
|
|
42
|
+
`${this.collation.schema}.${this.collation.name}`,
|
|
43
|
+
"REFRESH VERSION",
|
|
44
|
+
].join(" ");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Replace a collation by dropping and recreating it.
|
|
49
|
+
* This is used when properties that cannot be altered via ALTER COLLATION change.
|
|
50
|
+
*/
|
|
51
|
+
// NOTE: ReplaceCollation has been removed. Non-alterable property changes
|
|
52
|
+
// are modeled as separate DropCollation + CreateCollation changes in collation.diff.ts.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseChange } from "../../base.change.ts";
|
|
2
|
+
import type { Collation } from "../collation.model.ts";
|
|
3
|
+
declare abstract class BaseCollationChange extends BaseChange {
|
|
4
|
+
abstract readonly collation: Collation;
|
|
5
|
+
abstract readonly scope: "object" | "comment";
|
|
6
|
+
readonly objectType: "collation";
|
|
7
|
+
}
|
|
8
|
+
export declare abstract class CreateCollationChange extends BaseCollationChange {
|
|
9
|
+
readonly operation: "create";
|
|
10
|
+
}
|
|
11
|
+
export declare abstract class AlterCollationChange extends BaseCollationChange {
|
|
12
|
+
readonly operation: "alter";
|
|
13
|
+
}
|
|
14
|
+
export declare abstract class DropCollationChange extends BaseCollationChange {
|
|
15
|
+
readonly operation: "drop";
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseChange } from "../../base.change.js";
|
|
2
|
+
class BaseCollationChange extends BaseChange {
|
|
3
|
+
objectType = "collation";
|
|
4
|
+
}
|
|
5
|
+
export class CreateCollationChange extends BaseCollationChange {
|
|
6
|
+
operation = "create";
|
|
7
|
+
}
|
|
8
|
+
export class AlterCollationChange extends BaseCollationChange {
|
|
9
|
+
operation = "alter";
|
|
10
|
+
}
|
|
11
|
+
export class DropCollationChange extends BaseCollationChange {
|
|
12
|
+
operation = "drop";
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Collation } from "../collation.model.ts";
|
|
2
|
+
import { CreateCollationChange, DropCollationChange } from "./collation.base.ts";
|
|
3
|
+
export type CommentCollation = CreateCommentOnCollation | DropCommentOnCollation;
|
|
4
|
+
/**
|
|
5
|
+
* Create/drop comments on collations.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CreateCommentOnCollation extends CreateCollationChange {
|
|
8
|
+
readonly collation: Collation;
|
|
9
|
+
readonly scope: "comment";
|
|
10
|
+
constructor(props: {
|
|
11
|
+
collation: Collation;
|
|
12
|
+
});
|
|
13
|
+
get creates(): `comment:${string}`[];
|
|
14
|
+
get requires(): `collation:${string}`[];
|
|
15
|
+
serialize(): string;
|
|
16
|
+
}
|
|
17
|
+
export declare class DropCommentOnCollation extends DropCollationChange {
|
|
18
|
+
readonly collation: Collation;
|
|
19
|
+
readonly scope: "comment";
|
|
20
|
+
constructor(props: {
|
|
21
|
+
collation: Collation;
|
|
22
|
+
});
|
|
23
|
+
get requires(): (`comment:${string}` | `collation:${string}`)[];
|
|
24
|
+
get drops(): `comment:${string}`[];
|
|
25
|
+
serialize(): string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { quoteLiteral } from "../../base.change.js";
|
|
2
|
+
import { stableId } from "../../utils.js";
|
|
3
|
+
import { CreateCollationChange, DropCollationChange, } from "./collation.base.js";
|
|
4
|
+
/**
|
|
5
|
+
* Create/drop comments on collations.
|
|
6
|
+
*/
|
|
7
|
+
export class CreateCommentOnCollation extends CreateCollationChange {
|
|
8
|
+
collation;
|
|
9
|
+
scope = "comment";
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super();
|
|
12
|
+
this.collation = props.collation;
|
|
13
|
+
}
|
|
14
|
+
get creates() {
|
|
15
|
+
return [stableId.comment(this.collation.stableId)];
|
|
16
|
+
}
|
|
17
|
+
get requires() {
|
|
18
|
+
return [this.collation.stableId];
|
|
19
|
+
}
|
|
20
|
+
serialize() {
|
|
21
|
+
return [
|
|
22
|
+
"COMMENT ON COLLATION",
|
|
23
|
+
`${this.collation.schema}.${this.collation.name}`,
|
|
24
|
+
"IS",
|
|
25
|
+
// biome-ignore lint/style/noNonNullAssertion: collation comment is not nullable in this case
|
|
26
|
+
quoteLiteral(this.collation.comment),
|
|
27
|
+
].join(" ");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class DropCommentOnCollation extends DropCollationChange {
|
|
31
|
+
collation;
|
|
32
|
+
scope = "comment";
|
|
33
|
+
constructor(props) {
|
|
34
|
+
super();
|
|
35
|
+
this.collation = props.collation;
|
|
36
|
+
}
|
|
37
|
+
get requires() {
|
|
38
|
+
return [this.collation.stableId, stableId.comment(this.collation.stableId)];
|
|
39
|
+
}
|
|
40
|
+
get drops() {
|
|
41
|
+
return [stableId.comment(this.collation.stableId)];
|
|
42
|
+
}
|
|
43
|
+
serialize() {
|
|
44
|
+
return [
|
|
45
|
+
"COMMENT ON COLLATION",
|
|
46
|
+
`${this.collation.schema}.${this.collation.name}`,
|
|
47
|
+
"IS NULL",
|
|
48
|
+
].join(" ");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Collation } from "../collation.model.ts";
|
|
2
|
+
import { CreateCollationChange } from "./collation.base.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Create a collation.
|
|
5
|
+
*
|
|
6
|
+
* @see https://www.postgresql.org/docs/17/sql-createcollation.html
|
|
7
|
+
*
|
|
8
|
+
* Synopsis
|
|
9
|
+
* ```sql
|
|
10
|
+
* CREATE COLLATION [ IF NOT EXISTS ] name (
|
|
11
|
+
* [ LOCALE = locale, ]
|
|
12
|
+
* [ LC_COLLATE = lc_collate, ]
|
|
13
|
+
* [ LC_CTYPE = lc_ctype, ]
|
|
14
|
+
* [ PROVIDER = provider, ]
|
|
15
|
+
* [ DETERMINISTIC = boolean, ]
|
|
16
|
+
* [ RULES = rules, ]
|
|
17
|
+
* [ VERSION = version ]
|
|
18
|
+
* )
|
|
19
|
+
*
|
|
20
|
+
* CREATE COLLATION [ IF NOT EXISTS ] name FROM existing_collation
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class CreateCollation extends CreateCollationChange {
|
|
24
|
+
readonly collation: Collation;
|
|
25
|
+
readonly scope: "object";
|
|
26
|
+
constructor(props: {
|
|
27
|
+
collation: Collation;
|
|
28
|
+
});
|
|
29
|
+
get creates(): `collation:${string}`[];
|
|
30
|
+
get requires(): string[];
|
|
31
|
+
serialize(): string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { quoteLiteral } from "../../base.change.js";
|
|
2
|
+
import { stableId } from "../../utils.js";
|
|
3
|
+
import { CreateCollationChange } from "./collation.base.js";
|
|
4
|
+
/**
|
|
5
|
+
* Create a collation.
|
|
6
|
+
*
|
|
7
|
+
* @see https://www.postgresql.org/docs/17/sql-createcollation.html
|
|
8
|
+
*
|
|
9
|
+
* Synopsis
|
|
10
|
+
* ```sql
|
|
11
|
+
* CREATE COLLATION [ IF NOT EXISTS ] name (
|
|
12
|
+
* [ LOCALE = locale, ]
|
|
13
|
+
* [ LC_COLLATE = lc_collate, ]
|
|
14
|
+
* [ LC_CTYPE = lc_ctype, ]
|
|
15
|
+
* [ PROVIDER = provider, ]
|
|
16
|
+
* [ DETERMINISTIC = boolean, ]
|
|
17
|
+
* [ RULES = rules, ]
|
|
18
|
+
* [ VERSION = version ]
|
|
19
|
+
* )
|
|
20
|
+
*
|
|
21
|
+
* CREATE COLLATION [ IF NOT EXISTS ] name FROM existing_collation
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export class CreateCollation extends CreateCollationChange {
|
|
25
|
+
collation;
|
|
26
|
+
scope = "object";
|
|
27
|
+
constructor(props) {
|
|
28
|
+
super();
|
|
29
|
+
this.collation = props.collation;
|
|
30
|
+
}
|
|
31
|
+
get creates() {
|
|
32
|
+
return [this.collation.stableId];
|
|
33
|
+
}
|
|
34
|
+
get requires() {
|
|
35
|
+
const dependencies = new Set();
|
|
36
|
+
// Schema dependency
|
|
37
|
+
dependencies.add(stableId.schema(this.collation.schema));
|
|
38
|
+
// Owner dependency
|
|
39
|
+
dependencies.add(stableId.role(this.collation.owner));
|
|
40
|
+
return Array.from(dependencies);
|
|
41
|
+
}
|
|
42
|
+
serialize() {
|
|
43
|
+
const parts = ["CREATE COLLATION"];
|
|
44
|
+
// Add schema and name (already quoted in model extraction)
|
|
45
|
+
parts.push(`${this.collation.schema}.${this.collation.name}`);
|
|
46
|
+
// Add properties
|
|
47
|
+
const properties = [];
|
|
48
|
+
// LOCALE
|
|
49
|
+
if (this.collation.locale) {
|
|
50
|
+
properties.push(`LOCALE = ${quoteLiteral(this.collation.locale)}`);
|
|
51
|
+
}
|
|
52
|
+
// LC_COLLATE
|
|
53
|
+
if (this.collation.collate) {
|
|
54
|
+
properties.push(`LC_COLLATE = ${quoteLiteral(this.collation.collate)}`);
|
|
55
|
+
}
|
|
56
|
+
// LC_CTYPE
|
|
57
|
+
if (this.collation.ctype) {
|
|
58
|
+
properties.push(`LC_CTYPE = ${quoteLiteral(this.collation.ctype)}`);
|
|
59
|
+
}
|
|
60
|
+
// PROVIDER
|
|
61
|
+
const providerMap = {
|
|
62
|
+
c: "libc",
|
|
63
|
+
i: "icu",
|
|
64
|
+
b: "builtin",
|
|
65
|
+
};
|
|
66
|
+
// provider 'd' means default provider in catalog; omit PROVIDER clause
|
|
67
|
+
if (this.collation.provider !== "d") {
|
|
68
|
+
properties.push(`PROVIDER = ${providerMap[this.collation.provider]}`);
|
|
69
|
+
}
|
|
70
|
+
// DETERMINISTIC
|
|
71
|
+
// DETERMINISTIC (only emit when false; true is default in PG)
|
|
72
|
+
if (this.collation.is_deterministic === false) {
|
|
73
|
+
properties.push(`DETERMINISTIC = false`);
|
|
74
|
+
}
|
|
75
|
+
// RULES (ICU rules)
|
|
76
|
+
if (this.collation.icu_rules) {
|
|
77
|
+
properties.push(`RULES = ${quoteLiteral(this.collation.icu_rules)}`);
|
|
78
|
+
}
|
|
79
|
+
// VERSION
|
|
80
|
+
if (this.collation.version) {
|
|
81
|
+
properties.push(`VERSION = ${quoteLiteral(this.collation.version)}`);
|
|
82
|
+
}
|
|
83
|
+
parts.push(["(", properties.join(", "), ")"].join(""));
|
|
84
|
+
return parts.join(" ");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Collation } from "../collation.model.ts";
|
|
2
|
+
import { DropCollationChange } from "./collation.base.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Drop a collation.
|
|
5
|
+
*
|
|
6
|
+
* @see https://www.postgresql.org/docs/17/sql-dropcollation.html
|
|
7
|
+
*
|
|
8
|
+
* Synopsis
|
|
9
|
+
* ```sql
|
|
10
|
+
* DROP COLLATION [ IF EXISTS ] name [ CASCADE | RESTRICT ]
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare class DropCollation extends DropCollationChange {
|
|
14
|
+
readonly collation: Collation;
|
|
15
|
+
readonly scope: "object";
|
|
16
|
+
constructor(props: {
|
|
17
|
+
collation: Collation;
|
|
18
|
+
});
|
|
19
|
+
get requires(): `collation:${string}`[];
|
|
20
|
+
get drops(): `collation:${string}`[];
|
|
21
|
+
serialize(): string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DropCollationChange } from "./collation.base.js";
|
|
2
|
+
/**
|
|
3
|
+
* Drop a collation.
|
|
4
|
+
*
|
|
5
|
+
* @see https://www.postgresql.org/docs/17/sql-dropcollation.html
|
|
6
|
+
*
|
|
7
|
+
* Synopsis
|
|
8
|
+
* ```sql
|
|
9
|
+
* DROP COLLATION [ IF EXISTS ] name [ CASCADE | RESTRICT ]
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export class DropCollation extends DropCollationChange {
|
|
13
|
+
collation;
|
|
14
|
+
scope = "object";
|
|
15
|
+
constructor(props) {
|
|
16
|
+
super();
|
|
17
|
+
this.collation = props.collation;
|
|
18
|
+
}
|
|
19
|
+
get requires() {
|
|
20
|
+
return [this.collation.stableId];
|
|
21
|
+
}
|
|
22
|
+
get drops() {
|
|
23
|
+
return [this.collation.stableId];
|
|
24
|
+
}
|
|
25
|
+
serialize() {
|
|
26
|
+
return [
|
|
27
|
+
"DROP COLLATION",
|
|
28
|
+
`${this.collation.schema}.${this.collation.name}`,
|
|
29
|
+
].join(" ");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AlterCollation } from "./collation.alter.ts";
|
|
2
|
+
import type { CommentCollation } from "./collation.comment.ts";
|
|
3
|
+
import type { CreateCollation } from "./collation.create.ts";
|
|
4
|
+
import type { DropCollation } from "./collation.drop.ts";
|
|
5
|
+
export type CollationChange = AlterCollation | CommentCollation | CreateCollation | DropCollation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CollationChange } from "./changes/collation.types.ts";
|
|
2
|
+
import type { Collation } from "./collation.model.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Diff two sets of collations from main and branch catalogs.
|
|
5
|
+
*
|
|
6
|
+
* @param ctx - Context containing currentUser
|
|
7
|
+
* @param main - The collations in the main catalog.
|
|
8
|
+
* @param branch - The collations in the branch catalog.
|
|
9
|
+
* @returns A list of changes to apply to main to make it match branch.
|
|
10
|
+
*/
|
|
11
|
+
export declare function diffCollations(ctx: {
|
|
12
|
+
currentUser: string;
|
|
13
|
+
}, main: Record<string, Collation>, branch: Record<string, Collation>): CollationChange[];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { diffObjects } from "../base.diff.js";
|
|
2
|
+
import { hasNonAlterableChanges } from "../utils.js";
|
|
3
|
+
import { AlterCollationChangeOwner, AlterCollationRefreshVersion, } from "./changes/collation.alter.js";
|
|
4
|
+
import { CreateCommentOnCollation, DropCommentOnCollation, } from "./changes/collation.comment.js";
|
|
5
|
+
import { CreateCollation } from "./changes/collation.create.js";
|
|
6
|
+
import { DropCollation } from "./changes/collation.drop.js";
|
|
7
|
+
/**
|
|
8
|
+
* Diff two sets of collations from main and branch catalogs.
|
|
9
|
+
*
|
|
10
|
+
* @param ctx - Context containing currentUser
|
|
11
|
+
* @param main - The collations in the main catalog.
|
|
12
|
+
* @param branch - The collations in the branch catalog.
|
|
13
|
+
* @returns A list of changes to apply to main to make it match branch.
|
|
14
|
+
*/
|
|
15
|
+
export function diffCollations(ctx, main, branch) {
|
|
16
|
+
const { created, dropped, altered } = diffObjects(main, branch);
|
|
17
|
+
const changes = [];
|
|
18
|
+
for (const collationId of created) {
|
|
19
|
+
const coll = branch[collationId];
|
|
20
|
+
changes.push(new CreateCollation({ collation: coll }));
|
|
21
|
+
// OWNER: If the collation should be owned by someone other than the current user,
|
|
22
|
+
// emit ALTER COLLATION ... OWNER TO after creation
|
|
23
|
+
if (coll.owner !== ctx.currentUser) {
|
|
24
|
+
changes.push(new AlterCollationChangeOwner({
|
|
25
|
+
collation: coll,
|
|
26
|
+
owner: coll.owner,
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
if (coll.comment !== null) {
|
|
30
|
+
changes.push(new CreateCommentOnCollation({ collation: coll }));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
for (const collationId of dropped) {
|
|
34
|
+
changes.push(new DropCollation({ collation: main[collationId] }));
|
|
35
|
+
}
|
|
36
|
+
for (const collationId of altered) {
|
|
37
|
+
const mainCollation = main[collationId];
|
|
38
|
+
const branchCollation = branch[collationId];
|
|
39
|
+
// Check if non-alterable properties have changed
|
|
40
|
+
// These require dropping and recreating the collation
|
|
41
|
+
const NON_ALTERABLE_FIELDS = [
|
|
42
|
+
"provider",
|
|
43
|
+
"is_deterministic",
|
|
44
|
+
"encoding",
|
|
45
|
+
"collate",
|
|
46
|
+
"ctype",
|
|
47
|
+
"locale",
|
|
48
|
+
"icu_rules",
|
|
49
|
+
];
|
|
50
|
+
const nonAlterablePropsChanged = hasNonAlterableChanges(mainCollation, branchCollation, NON_ALTERABLE_FIELDS);
|
|
51
|
+
if (nonAlterablePropsChanged) {
|
|
52
|
+
// Replace the entire collation (drop + create)
|
|
53
|
+
changes.push(new DropCollation({ collation: mainCollation }), new CreateCollation({ collation: branchCollation }));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Only alterable properties changed - check each one
|
|
57
|
+
// VERSION
|
|
58
|
+
if (mainCollation.version !== branchCollation.version) {
|
|
59
|
+
changes.push(new AlterCollationRefreshVersion({
|
|
60
|
+
collation: mainCollation,
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
// OWNER
|
|
64
|
+
if (mainCollation.owner !== branchCollation.owner) {
|
|
65
|
+
changes.push(new AlterCollationChangeOwner({
|
|
66
|
+
collation: mainCollation,
|
|
67
|
+
owner: branchCollation.owner,
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
// COMMENT
|
|
71
|
+
if (mainCollation.comment !== branchCollation.comment) {
|
|
72
|
+
if (branchCollation.comment === null) {
|
|
73
|
+
changes.push(new DropCommentOnCollation({ collation: mainCollation }));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
changes.push(new CreateCommentOnCollation({ collation: branchCollation }));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Note: Collation renaming would also use ALTER COLLATION ... RENAME TO ...
|
|
80
|
+
// But since our Collation model uses 'name' as the identity field,
|
|
81
|
+
// a name change would be handled as drop + create by diffObjects()
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return changes;
|
|
85
|
+
}
|