simetra 0.2.0 → 0.3.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/channel-grant-BATD6oQu.js +15 -0
- package/dist/compiler/index.d.ts +732 -85
- package/dist/compiler/index.js +26488 -13752
- package/dist/data/centrifugo/index.d.ts +24 -0
- package/dist/data/centrifugo/index.js +173 -0
- package/dist/data/index.d.ts +27 -0
- package/dist/data/index.js +10115 -0
- package/dist/data/react/index.d.ts +103 -0
- package/dist/data/react/index.js +214 -0
- package/dist/grant-Zg0hmqK7.d.ts +11 -0
- package/dist/handle-C6PFsnUX.js +44 -0
- package/dist/holder-CkR-qRYU.d.ts +585 -0
- package/dist/model/index.d.ts +4396 -400
- package/dist/model/index.js +4425 -380
- package/dist/schema/index.d.ts +1545 -572
- package/dist/schema/index.js +8554 -4215
- package/dist/server/index.d.ts +710 -21
- package/dist/server/index.js +4663 -483
- package/dist/server/signals/index.d.ts +92 -0
- package/dist/server/signals/index.js +140 -0
- package/dist/shell/index.d.ts +112 -0
- package/dist/shell/index.js +159 -0
- package/dist/ui/index.d.ts +213 -0
- package/dist/ui/index.js +1098 -0
- package/package.json +75 -3
- package/schemas/accumulation-registers.schema.json +46 -5
- package/schemas/catalogs.schema.json +113 -33
- package/schemas/constants.schema.json +31 -5
- package/schemas/custom-tables.schema.json +24 -0
- package/schemas/documents.schema.json +86 -31
- package/schemas/functions.schema.json +129 -0
- package/schemas/information-registers.schema.json +47 -5
- package/schemas/project.schema.json +206 -1
- package/schemas/rights-sets.schema.json +19 -1
- package/schemas/roles.schema.json +23 -2
package/dist/compiler/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { AttributeCase, CatalogUnit, CustomTable, DatabaseProvider, Dml, GrantPurpose, KIND_REGISTRY, LocalizedString, LogicalType, MetadataKind, MetadataRef, NumberingSpec,
|
|
2
|
+
import { AttributeCase, CatalogTable, CatalogUnit, ClientCatalog, CustomTable, DatabaseProvider, Dml, GrantPurpose, IdentitySource, KIND_REGISTRY, LocalizedString, LogicalType, MetadataKind, MetadataRef, NumberingSpec, ObjectOrigin, ObjectTable, PhysicalColumn, PhysicalSnapshot, PhysicalTable, Project, ReferenceRole, RequestRolePurpose, RightsSystemCatalog, RuntimeCatalog, RuntimeObject, SchemaRule, SqlFunctionDeclaration, SqlUnitClass, StandardColumnDef, SubscriptionEvent, VirtualTableKind } from "simetra/model";
|
|
3
3
|
import { Constraint, IndexElem, IndexStmt, Node, Node as Node$1, RangeVar } from "libpg-query";
|
|
4
4
|
type Severity = "error" | "warning";
|
|
5
5
|
/** Коди правил самого компілятора; коди перевірок схем T0 — `SCHEMA_RULES`. */
|
|
6
|
-
export declare const COMPILER_RULES: readonly ["project.missing", "project.timezone-unknown", "project.database-required", "file.unknown-path", "file.orphan", "file.invalid-json", "file.schema", "file.unknown-key", "file.kind-mismatch", "file.name-mismatch", "file.movements-block", "file.movements-marker-indented", "sql.parse", "sql.statement-not-allowed", "sql.unit-duplicate", "sql.namespace-conflict", "sql.generated-grant", "sql.kind-table-verbatim", "sql.function-body-statement", "sql.platform-function-call", "sql.expression-call-not-allowed", "sql.dependency-cycle", "sql.closed-shell", "sql.command-context-write", "sql.head-not-allowed", "sql.domain-check-not-allowed", "sql.function-settings-shell", "sql.function-overload", "sql.row-rule-grammar", "sql.row-rule-foreign-table", "sql.row-rule-outside-module", "sql.row-rule-name-taken", "sql.bare-current-user", "sql.debt-grows", "sql.debt-stale", "sql.debt-session-write", "sql.debt-extension-schema", "sql.definer-reads-rls", "rewrite.ambiguous-name", "rewrite.unqualified-table", "rewrite.unsupported", "rewrite.trigger-binding", "rewrite.label-literal", "rewrite.dynamic-sql", "rewrite.unresolved-type", "rewrite.body-quoting", "rewrite.verification-failed", "rewrite.contract-change", "rewrite.dynamic-sql-unscoped", "identity.id-missing", "identity.id-duplicate", "identity.physical-name-missing", "identity.kind-label-missing", "identity.kind-label-retained", "identity.kind-label-duplicate", "identity.assigned-once-changed", "identity.name-duplicate", "identity.name-case", "identity.name-reserved", "reference.unresolved", "reference.ambiguous", "customTable.column-unknown", "register.balance-control-resource", "register.balance-control-duplicate", "posting.field-unknown", "posting.register-field-unknown", "posting.tabular-section-unknown", "scope.declaration-missing", "scope.unknown-kind", "scope.attribute-name-collision", "scope.root-duplicate", "scope.root-key", "scope.root-hierarchy", "scope.root-declaration", "scope.root-self-reference", "scope.root-cascade-not-kind", "scope.global-to-scoped", "scope.cross-kind", "scope.recorder-mismatch", "scope.custom-table-column", "scope.cross-scope-redundant", "scope.custom-table-cross-tenant", "scope.set-function-missing", "scope.set-function-signature", "scope.membership-missing", "storage.bucket-duplicate", "storage.scope-kind-unknown", "subscription.source-not-table", "subscription.provider-table-unknown", "subscription.when-changed-unknown", "subscription.when-changed-duplicate", "subscription.source-duplicate", "subscription.name-duplicate", "subscription.when-changed-on-delete", "subscription.handler-missing", "subscription.handler-signature", "subscription.handler-not-closed", "subscription.handler-assigns-mechanics", "subscription.handler-assigns-carrier", "subscription.handler-reads-carrier", "subscription.trigger-name-taken", "subscription.when-changed-mechanics", "users.catalog-duplicate", "users.scope-not-none", "users.description-required", "users.provision-unsafe", "users.catalog-missing", "membership.not-scoped", "membership.user-not-users-ref", "membership.duplicate", "rights.action-unknown", "rights.custom-action-reserved", "rights.custom-action-effects", "rights.requires-cycle", "rights.attribute-unknown", "rights.carrier-not-ref", "rights.carrier-cross-tenant", "rights.carrier-column-taken", "rights.carrier-path-adopted", "rights.register-access-dimension", "rights.dimension-name-reserved", "rights.ownership-target", "rights.container-target", "rights.container-self", "rights.dimension-unknown", "rights.dimension-target", "rights.dimension-relation", "rights.access-target", "rights.access-duplicate", "rights.dimension-function-missing", "rights.dimension-function-signature", "rights.dimension-function-reads-rights", "rights.source-table", "rights.source-forced-rls", "rights.source-member-key", "rights.source-member-unique", "rights.source-column-type", "rights.source-where", "rights.source-role-key", "rights.source-scope-column", "rights.membership-source-duplicate", "rights.source-container-column", "rights.scope-kind-unknown", "rights.users-missing", "rights.public-read-forbidden", "rights.include-target", "rights.include-cycle", "rights.scope-without-membership", "rights.full-access-level", "rights.root-creator-level", "rights.root-creator-duplicate", "rights.root-creator-membership", "rights.root-creator-set-function", "rights.root-creator-assignments", "rights.root-creator-assignment-required", "rights.root-creator-subscription", "rights.root-create-author", "rights.root-creator-no-admin", "rights.root-creator-unreachable", "rights.source-unknown", "rights.source-key-level", "rights.source-key-duplicate", "rights.grant-level", "rights.extent-unsupported", "rights.requires-missing", "rights.custom-table-no-contract", "rights.object-without-rights", "rights.custom-action-multi-object", "rights.system-catalog-missing", "rights.system-catalog-duplicate", "rights.system-catalog-scope", "rights.system-catalog-description", "rights.system-catalog-parallel", "rights.system-catalog-custom-action", "rights.adopted-source-writes", "rights.scope-kind-unread", "rights.snapshot-source-unknown", "rights.snapshot-exempt-writer", "reference.not-referenceable", "reference.custom-table-key", "reference.custom-table-deferrable-key", "reference.default-to-table", "reference.default-unknown-value", "reference.polymorphic-target-kind", "attribute.unique-within-place", "index.attribute-unknown", "index.attribute-duplicate", "catalog.owner-kind", "register.recorder-kind", "posting.register-kind", "posting.register-independent", "posting.register-undeclared", "posting.source-missing", "posting.source-ambiguous", "posting.query-not-select", "posting.query-order-missing", "posting.recorder-not-allowed", "posting.fields-incomplete", "posting.row-in-document-source", "posting.aggregate-in-section-source", "posting.movement-type", "posting.period-not-allowed", "posting.type-mismatch", "physical.table-duplicate", "physical.relation-duplicate", "physical.column-duplicate", "physical.function-duplicate", "physical.reserved-word", "physical.name-too-long", "physical.constraint-name-required", "customTable.foreign-key-arity", "customTable.foreign-key-deferrable-target", "customTable.fk-action-on-kind-table", "customTable.fk-target-not-key", "customTable.generated-conflict", "customTable.key-column-nullable", "presentation.unknown-standard-attribute", "operation.physical-name-too-long", "operation.input-invalid", "operation.target-not-found", "operation.object-exists", "operation.collection-unknown", "operation.delete-referenced", "promote.column-unplaced", "promote.mapping-unknown", "promote.unit-unsupported", "promote.reference-not-promoted", "promote.retired-referenced", "promote.unclassified", "promote.write-path", "promote.debt-writes-table", "promote.cascade-to-restrict", "promote.provider-user-reference", "promote.enum-labels", "promote.type-unsupported", "promote.default-unplaced", "promote.fill-missing", "promote.expression-invalid", "promote.debt-text-reference", "promote.text-conflict", "promote.property-not-equivalent", "engine.diagnostic", "engine.unmodeled-drift", "engine.shadow-load-failed", "engine.desired-rejected", "engine.clone-failed", "engine.preamble-unknown", "engine.unrepresentable", "engine.unmodeled-class", "engine.census-mismatch", "engine.unmodeled-property", "engine.out-of-scope", "engine.owner-not-member", "apply.state-format", "apply.ledger-without-marker", "apply.cascade", "apply.non-transactional", "apply.commit-boundary", "apply.permission-required", "apply.permission-unknown", "apply.first-apply", "apply.drift", "apply.drift-partial", "apply.versions-changed", "apply.plan-versions", "apply.plan-format", "apply.plan-hash", "apply.plan-stale", "apply.busy", "apply.api-role", "apply.server-unsupported", "apply.role-mismatch", "apply.chain", "apply.target-changed", "apply.verify-failed", "apply.step-failed", "apply.lock-timeout", "apply.lock-privilege", "apply.lock-footprint-exceeded", "apply.connection-lost", "apply.type-narrowing", "apply.type-guard-failed", "apply.preservation-failed", "apply.preservation-measure-failed", "apply.function-check-failed", "apply.function-check-blind", "apply.deferred-constraint-failed", "apply.constraint-invalid", "apply.rehearsal-proof-failed", "apply.rehearsal-required", "apply.rehearsal-stale", "apply.rehearsal-copy-empty", "apply.rehearsal-fewer-rows", "apply.rehearsal-timeout-unbounded", "apply.temp-name-taken", "apply.plpgsql-check-unavailable", "apply.replication-role", "apply.data-step-failed", "apply.data-step-narrowing", "apply.data-write-mismatch", "plan.unparsable-step", "plan.clone-mismatch", "plan.proof-not-empty", "plan.fingerprint-disagrees", "plan.schema-only-proof", "plan.owner-mismatch", "plan.platform-role-missing", "plan.platform-role-shape", "plan.type-guard-unsupported", "plan.type-change-dependent", "plan.promotion-record-missing", "plan.promotion-record-invalid", "plan.promotion-base", "plan.promotion-record-mismatch", "plan.promotion-record-stale", "plan.promotion-needs-marker", "plan.promotion-multiple", "plan.promotion-unsupported", "plan.promotion-applied", "plan.promotion-not-applicable", "plan.rename-not-realized", "plan.removal-unclassified", "plan.platform-replacement-missing", "plan.property-not-reproduced", "plan.write-path", "plan.service-role-access-lost", "plan.update-of-narrowed", "plan.foreign-exclusive-lock", "plan.plpgsql-check-unavailable", "plan.temp-name-taken", "plan.data-step-volatile", "plan.data-step-function-changed", "plan.temp-privilege", "plan.replication-role", "plan.preservation-type", "plan.provider-trigger-taken", "plan.numbering-not-generated", "plan.rights-source-access", "plan.rights-source-unknown-keys", "plan.rights-full-access-lost", "plan.rights-orphans", "database.failed", "roles.create-role-denied", "roles.admin-option-missing", "maintenance.model-mismatch", "maintenance.unknown-role", "maintenance.role-level", "maintenance.role-ambiguous", "maintenance.unknown-scope-kind", "maintenance.no-catalog", "maintenance.scope-missing", "maintenance.unknown-user", "maintenance.busy", "maintenance.not-first", "maintenance.holder-exists", "maintenance.not-effective", "maintenance.invalid-member", "maintenance.member-required", "maintenance.refused", "maintenance.outcome-unknown", "introspect.unrepresentable", "introspect.identity-conflict", "introspect.project-mismatch", "introspect.path-collision"];
|
|
6
|
+
export declare const COMPILER_RULES: readonly ["project.missing", "project.timezone-unknown", "project.database-required", "file.unknown-path", "file.orphan", "file.invalid-json", "file.schema", "file.unknown-key", "file.kind-mismatch", "file.name-mismatch", "file.movements-block", "file.movements-marker-indented", "sql.parse", "sql.statement-not-allowed", "sql.unit-duplicate", "sql.namespace-conflict", "sql.generated-grant", "sql.kind-table-verbatim", "sql.function-body-statement", "sql.function-body-session-setting", "sql.function-body-temp-type", "sql.function-body-session-builtin", "sql.platform-function-call", "sql.expression-call-not-allowed", "sql.dependency-cycle", "sql.closed-shell", "sql.command-context-write", "sql.head-not-allowed", "sql.domain-check-not-allowed", "sql.function-settings-shell", "sql.head-settings", "sql.function-overload", "sql.row-rule-grammar", "sql.row-rule-foreign-table", "sql.row-rule-outside-module", "sql.row-rule-name-taken", "sql.bare-current-user", "sql.debt-grows", "sql.debt-stale", "sql.debt-session-write", "sql.debt-extension-schema", "sql.definer-reads-rls", "sql.definer-caller-unchecked", "sql.policy-helper-correlated", "sql.declaration-target-missing", "sql.declaration-overload", "sql.declaration-duplicate", "sql.declaration-platform-form", "sql.declaration-platform-form-widens", "sql.declaration-execute-widened", "sql.declaration-check-missing", "sql.declaration-check-form", "sql.declaration-check-not-applied", "sql.declaration-anonymous-definer", "sql.default-privileges-execute", "sql.function-argument-type-reference", "rewrite.ambiguous-name", "rewrite.unqualified-table", "rewrite.unsupported", "rewrite.trigger-binding", "rewrite.label-literal", "rewrite.dynamic-sql", "rewrite.unresolved-type", "rewrite.body-quoting", "rewrite.verification-failed", "rewrite.contract-change", "rewrite.dynamic-sql-unscoped", "identity.id-missing", "identity.id-duplicate", "identity.physical-name-missing", "identity.kind-label-missing", "identity.kind-label-retained", "identity.kind-label-duplicate", "identity.assigned-once-changed", "identity.name-duplicate", "identity.name-case", "identity.name-reserved", "identity.name-structural", "reference.unresolved", "reference.ambiguous", "customTable.column-unknown", "customTable.index-derived-column", "register.balance-control-resource", "register.balance-control-duplicate", "posting.field-unknown", "posting.register-field-unknown", "posting.tabular-section-unknown", "scope.declaration-missing", "scope.unknown-kind", "scope.attribute-name-collision", "scope.root-duplicate", "scope.root-key", "scope.root-hierarchy", "scope.root-declaration", "scope.root-self-reference", "scope.root-cascade-not-kind", "scope.global-to-scoped", "scope.cross-kind", "scope.recorder-mismatch", "scope.custom-table-column", "scope.cross-scope-redundant", "scope.custom-table-cross-tenant", "scope.set-function-missing", "scope.set-function-signature", "scope.membership-missing", "storage.bucket-duplicate", "storage.scope-kind-unknown", "subscription.source-not-table", "subscription.provider-table-unknown", "subscription.when-changed-unknown", "subscription.when-changed-duplicate", "subscription.source-duplicate", "subscription.name-duplicate", "subscription.when-changed-on-delete", "subscription.handler-missing", "subscription.handler-signature", "subscription.handler-not-closed", "subscription.handler-assigns-mechanics", "subscription.handler-assigns-carrier", "subscription.handler-reads-carrier", "subscription.trigger-name-taken", "subscription.when-changed-mechanics", "users.catalog-duplicate", "users.scope-not-none", "users.description-required", "users.provision-unsafe", "users.catalog-missing", "languages.catalog-duplicate", "languages.scope-not-none", "languages.code-form", "languages.description-required", "languages.public-read", "languages.predefined-items", "languages.seed-unsafe", "languages.primary-missing", "languages.primary-without-catalog", "membership.not-scoped", "membership.user-not-users-ref", "membership.duplicate", "rights.action-unknown", "rights.custom-action-reserved", "rights.custom-action-effects", "rights.requires-cycle", "rights.attribute-unknown", "rights.carrier-not-ref", "rights.carrier-cross-tenant", "rights.carrier-column-taken", "rights.carrier-path-adopted", "rights.carrier-lazy", "rights.register-access-dimension", "rights.dimension-name-reserved", "rights.ownership-target", "rights.container-target", "rights.container-self", "rights.container-binding-cycle", "rights.dimension-unknown", "rights.dimension-target", "rights.dimension-relation", "rights.access-target", "rights.access-duplicate", "rights.dimension-function-missing", "rights.dimension-function-signature", "rights.dimension-function-reads-rights", "rights.source-table", "rights.source-forced-rls", "rights.source-member-key", "rights.source-member-unique", "rights.source-column-type", "rights.source-where", "rights.source-role-key", "rights.source-scope-column", "rights.membership-source-duplicate", "rights.source-container-column", "rights.scope-kind-unknown", "rights.users-missing", "rights.public-read-forbidden", "rights.public-read-published-kind", "rights.public-read-published-rights", "rights.public-read-published-read", "rights.include-target", "rights.include-cycle", "rights.scope-without-membership", "rights.full-access-level", "rights.root-creator-level", "rights.root-creator-duplicate", "rights.root-creator-membership", "rights.root-creator-set-function", "rights.root-creator-assignments", "rights.root-creator-assignment-required", "rights.root-creator-subscription", "rights.platform-action", "rights.invitations-unused", "rights.invitation-subscription", "rights.root-create-author", "rights.root-creator-no-admin", "rights.root-creator-unreachable", "rights.source-unknown", "rights.source-key-level", "rights.source-key-duplicate", "rights.grant-level", "rights.extent-unsupported", "rights.requires-missing", "rights.custom-table-no-contract", "rights.object-without-rights", "rights.custom-action-multi-object", "rights.system-catalog-missing", "rights.system-catalog-duplicate", "rights.system-catalog-scope", "rights.system-catalog-description", "rights.system-catalog-parallel", "rights.system-catalog-custom-action", "rights.adopted-source-writes", "rights.scope-kind-unread", "project.self-sign-up", "project.self-sign-up-role", "project.self-sign-up-stale", "rights.snapshot-source-unknown", "rights.snapshot-exempt-writer", "rights.signal-source-unknown", "reference.not-referenceable", "reference.custom-table-key", "reference.custom-table-deferrable-key", "reference.default-to-table", "reference.default-unknown-value", "reference.polymorphic-target-kind", "attribute.unique-within-place", "attribute.row-over-budget", "attribute.lazy-over-budget", "index.attribute-unknown", "index.attribute-duplicate", "index.attribute-rich-text", "search.field-unknown", "search.field-duplicate", "search.field-tabular", "search.field-ref", "search.field-generated", "search.field-rich-text", "catalog.owner-kind", "register.recorder-kind", "posting.register-kind", "posting.register-independent", "posting.register-undeclared", "posting.source-missing", "posting.source-ambiguous", "posting.query-not-select", "posting.query-order-missing", "posting.recorder-not-allowed", "posting.fields-incomplete", "posting.row-in-document-source", "posting.aggregate-in-section-source", "posting.movement-type", "posting.period-not-allowed", "posting.type-mismatch", "physical.table-duplicate", "physical.relation-duplicate", "physical.column-duplicate", "physical.function-duplicate", "physical.reserved-word", "physical.name-too-long", "physical.constraint-name-required", "customTable.foreign-key-arity", "customTable.foreign-key-deferrable-target", "customTable.fk-action-on-kind-table", "customTable.fk-target-not-key", "customTable.generated-conflict", "customTable.key-column-nullable", "presentation.unknown-standard-attribute", "operation.physical-name-too-long", "operation.input-invalid", "operation.target-not-found", "operation.object-exists", "operation.collection-unknown", "operation.delete-referenced", "promote.column-unplaced", "promote.mapping-unknown", "promote.unit-unsupported", "promote.reference-not-promoted", "promote.retired-referenced", "promote.unclassified", "promote.write-path", "promote.debt-writes-table", "promote.cascade-to-restrict", "promote.provider-user-reference", "promote.enum-labels", "promote.type-unsupported", "promote.default-unplaced", "promote.fill-missing", "promote.expression-invalid", "promote.debt-text-reference", "promote.text-conflict", "promote.property-not-equivalent", "engine.diagnostic", "engine.unmodeled-drift", "engine.shadow-load-failed", "engine.shadow-drop-failed", "engine.desired-rejected", "engine.clone-failed", "engine.environment-failed", "engine.preamble-unknown", "engine.unrepresentable", "engine.unmodeled-class", "engine.census-mismatch", "engine.unmodeled-property", "engine.out-of-scope", "engine.owner-not-member", "apply.state-format", "apply.ledger-without-marker", "apply.cascade", "apply.non-transactional", "apply.commit-boundary", "apply.permission-required", "apply.permission-unknown", "apply.first-apply", "apply.drift", "apply.drift-partial", "apply.drift-unverifiable", "apply.versions-changed", "apply.primary-language-changed", "apply.plan-versions", "apply.plan-format", "apply.plan-hash", "apply.plan-stale", "apply.busy", "apply.api-role", "apply.server-unsupported", "apply.role-mismatch", "apply.chain", "apply.target-changed", "apply.verify-failed", "apply.step-failed", "apply.lock-timeout", "apply.lock-privilege", "apply.lock-footprint-exceeded", "apply.connection-lost", "apply.type-narrowing", "apply.type-guard-failed", "apply.preservation-failed", "apply.preservation-measure-failed", "apply.function-check-failed", "apply.function-check-blind", "apply.deferred-constraint-failed", "apply.constraint-invalid", "apply.rehearsal-proof-failed", "apply.rehearsal-required", "apply.rehearsal-stale", "apply.rehearsal-copy-empty", "apply.rehearsal-fewer-rows", "apply.rehearsal-timeout-unbounded", "apply.temp-name-taken", "apply.plpgsql-check-unavailable", "apply.extension-unavailable", "apply.replication-role", "apply.data-step-failed", "apply.data-step-narrowing", "apply.data-write-mismatch", "apply.not-null-violation", "apply.backfill-rows-changed", "apply.backfill-triggers-changed", "plan.unparsable-step", "plan.clone-mismatch", "plan.proof-not-empty", "plan.fingerprint-disagrees", "plan.schema-only-proof", "plan.owner-mismatch", "plan.platform-role-missing", "plan.platform-role-shape", "plan.owner-not-bypassrls", "plan.owner-provider-login", "plan.shadow-base-unsupported", "plan.identity-table-missing", "plan.identity-trigger-locked", "plan.storage-added", "plan.storage-removed", "plan.type-guard-unsupported", "plan.type-change-dependent", "plan.promotion-record-missing", "plan.promotion-record-invalid", "plan.promotion-base", "plan.promotion-record-mismatch", "plan.promotion-record-stale", "plan.promotion-needs-marker", "plan.promotion-multiple", "plan.promotion-unsupported", "plan.promotion-applied", "plan.promotion-not-applicable", "plan.rename-not-realized", "plan.removal-unclassified", "plan.platform-replacement-missing", "plan.property-not-reproduced", "plan.write-path", "plan.service-role-access-lost", "plan.update-of-narrowed", "plan.foreign-exclusive-lock", "plan.plpgsql-check-unavailable", "plan.temp-name-taken", "plan.data-step-volatile", "plan.data-step-function-changed", "plan.temp-privilege", "plan.replication-role", "plan.preservation-type", "plan.provider-trigger-taken", "plan.provider-trigger-undeclared", "plan.trigger-function-unseedable", "plan.row-version-first", "plan.numbering-not-generated", "plan.not-null-violation", "plan.backfill-order", "plan.backfill-unique", "plan.backfill-check", "plan.backfill-carrier-source", "plan.backfill-rights-guard", "plan.backfill-count-failed", "plan.rights-source-access", "plan.rights-source-unknown-keys", "plan.rights-full-access-lost", "plan.rights-orphans", "database.failed", "data.scope-unspecified", "roles.create-role-denied", "roles.admin-option-missing", "roles.membership-grant-denied", "roles.superuser-required", "roles.unsafe-schema", "roles.unsafe-template", "roles.database-owner", "roles.database-locale", "roles.shared-cluster", "roles.extension-unavailable", "roles.dev-passwords-unsupported", "roles.dev-password-missing", "roles.dev-passwords-remote", "maintenance.model-mismatch", "maintenance.unknown-role", "maintenance.role-level", "maintenance.role-ambiguous", "maintenance.unknown-scope-kind", "maintenance.no-catalog", "maintenance.scope-missing", "maintenance.unknown-user", "maintenance.busy", "maintenance.not-first", "maintenance.holder-exists", "maintenance.not-effective", "maintenance.invalid-member", "maintenance.member-required", "maintenance.refused", "maintenance.outcome-unknown", "introspect.unrepresentable", "introspect.identity-conflict", "introspect.project-mismatch", "introspect.path-collision", "introspect.definer-check-unknown", "introspect.execute-narrowed", "introspect.definer-platform-form-candidate", "introspect.definer-foreign-grant", "introspect.definer-callers-drift", "introspect.definer-acl-changed"];
|
|
7
7
|
type CompilerRule = (typeof COMPILER_RULES)[number];
|
|
8
8
|
type RuleCode = SchemaRule | CompilerRule;
|
|
9
9
|
type DiagnosticParams = Record<string, string | number>;
|
|
@@ -36,6 +36,8 @@ interface Diagnostic {
|
|
|
36
36
|
/** Заповнює `locate` для файлів, що є в мапі; відображення pointer → рядок і колонка. */
|
|
37
37
|
range?: Range;
|
|
38
38
|
}
|
|
39
|
+
/** Помилка, яку режим `repair` пропускає повз гейт стадій. */
|
|
40
|
+
export declare function isRepairError(d: Diagnostic): boolean;
|
|
39
41
|
/** Діагностика з каталогу повідомлень; серйозність — властивість правила. */
|
|
40
42
|
export declare function diagnostic(code: RuleCode, file: string, pointer: string, params?: DiagnosticParams): Diagnostic;
|
|
41
43
|
/** Значення за JSON Pointer; `""` — сам корінь. */
|
|
@@ -128,14 +130,17 @@ interface ResolvedReference {
|
|
|
128
130
|
/** 1-базний рядок маркера в `.sql`: pointer на весь файл місця не вказує. */
|
|
129
131
|
line?: number;
|
|
130
132
|
}
|
|
131
|
-
/**
|
|
133
|
+
/**
|
|
134
|
+
* CHECK таблиці та колонки, які читає його вираз, у порядку колонок таблиці:
|
|
135
|
+
* одна — для CHECK реквізиту, кілька — для правила рядка.
|
|
136
|
+
*/
|
|
132
137
|
interface CheckColumn {
|
|
133
138
|
table: {
|
|
134
139
|
schema: string;
|
|
135
140
|
name: string;
|
|
136
141
|
};
|
|
137
142
|
check: string;
|
|
138
|
-
|
|
143
|
+
columns: string[];
|
|
139
144
|
}
|
|
140
145
|
/** Форма ключа цілі FK на таблицю виду (спека прав §4.7). */
|
|
141
146
|
type KindKey = Extract<CustomTable["foreignKeys"][number]["references"], {
|
|
@@ -252,7 +257,12 @@ interface SqlUnit {
|
|
|
252
257
|
requires?: readonly CreationNode[];
|
|
253
258
|
}
|
|
254
259
|
/** Хто згенерував одиницю. */
|
|
255
|
-
type UnitGenerator = "movementQuery" | "membership" | "platformLayer" | "access" | "functionExecute" | "mechanics" | "key" | "subscription" | "rights" | "rightsGuards" | "rightsExplain" | "carriers" | "command" | "effects" | "catalogCommand";
|
|
260
|
+
type UnitGenerator = "movementQuery" | "membership" | "platformLayer" | "access" | "functionExecute" | "mechanics" | "key" | "subscription" | "rights" | "rightsGuards" | "rightsRequire" | "rightsExplain" | "carriers" | "command" | "effects" | "catalogCommand" | "schemaUsage" | "signalOutbox" | "storage" | "signal" | "rightsClientSnapshot" | "rightsSignal" | "invitations";
|
|
261
|
+
/**
|
|
262
|
+
* Чи одиниця — тіло, фіксоване платформою (`FIXED_BODY`): одне джерело і для
|
|
263
|
+
* `plpgsql_check`, і для еталона теки в reverse.
|
|
264
|
+
*/
|
|
265
|
+
export declare function hasFixedBody(unit: Pick<SqlUnit, "generator">): boolean;
|
|
256
266
|
/**
|
|
257
267
|
* Сигнатури функцій платформи (`<схема>.<ім'я>(<типи>)`, як у ідентичності)
|
|
258
268
|
* — ознака за походженням одиниці, а не за схемою. Типи аргументів
|
|
@@ -260,6 +270,17 @@ type UnitGenerator = "movementQuery" | "membership" | "platformLayer" | "access"
|
|
|
260
270
|
* `to_regprocedure` незалежно від шляху.
|
|
261
271
|
*/
|
|
262
272
|
export declare function platformFunctionSignatures(units: readonly Pick<SqlUnit, "class" | "identity" | "file" | "generator">[]): string[];
|
|
273
|
+
/** Обгортка запиту рухів: поля рухів обов'язкові. */
|
|
274
|
+
interface MovementQueryUnit extends SqlUnit {
|
|
275
|
+
class: "movementQuery";
|
|
276
|
+
generator: "movementQuery";
|
|
277
|
+
ownerObjectId: string;
|
|
278
|
+
queryTree: unknown;
|
|
279
|
+
registerId: string;
|
|
280
|
+
documentId: string;
|
|
281
|
+
source: "query" | "constructor";
|
|
282
|
+
}
|
|
283
|
+
export declare function isMovementQuery(unit: SqlUnit): unit is MovementQueryUnit;
|
|
263
284
|
/** Дослівна одиниця з місцем у файлі; власника-об'єкт резолвить компілятор. */
|
|
264
285
|
interface VerbatimUnit {
|
|
265
286
|
class: SqlUnitClass;
|
|
@@ -297,6 +318,8 @@ interface SqlSource {
|
|
|
297
318
|
schema: string;
|
|
298
319
|
ownerFile?: string;
|
|
299
320
|
}
|
|
321
|
+
/** Класи, що живуть у просторі імен функцій Postgres (`pg_proc`). */
|
|
322
|
+
export declare const FUNCTION_CLASSES: ReadonlySet<SqlUnitClass>;
|
|
300
323
|
/**
|
|
301
324
|
* Розбирає дослівні `.sql` на одиниці (платформна спека §6.3): гейт дозволених
|
|
302
325
|
* операторів та ідентичність за класом. Блоки запиту рухів вирізано
|
|
@@ -318,6 +341,11 @@ export declare function readSqlUnits(sources: readonly SqlSource[], parse: SqlPa
|
|
|
318
341
|
* зокрема тіло `$$…$$`, лишається дослівно — спека §8.3.
|
|
319
342
|
*/
|
|
320
343
|
export declare function withoutLocations(value: unknown): unknown;
|
|
344
|
+
/**
|
|
345
|
+
* Ролі частини ідентичності гранту (`grantParts`) іменами каталогу: ім'я в
|
|
346
|
+
* лапках — без лапок, ключове слово (`public`) — як є.
|
|
347
|
+
*/
|
|
348
|
+
export declare function grantRoles(roles: string): string[];
|
|
321
349
|
interface QualifiedName {
|
|
322
350
|
schema: string;
|
|
323
351
|
name: string;
|
|
@@ -470,6 +498,42 @@ interface PredefinedContract {
|
|
|
470
498
|
label: string;
|
|
471
499
|
}[];
|
|
472
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* Передвизначений рядок до засіву (Р-B2-7): крок даних apply вставляє його після
|
|
503
|
+
* DDL `INSERT … ON CONFLICT (<мітка>) WHERE <предикат> DO NOTHING`. Apply читає
|
|
504
|
+
* лише цей факт, а не `project.meta.json`; факт входить у хеш моделі, тож зміна
|
|
505
|
+
* поля проєкту, з якого взято рядок, не дає плану `unchanged` в обхід звірки.
|
|
506
|
+
* Імена колонок — фізичні.
|
|
507
|
+
*/
|
|
508
|
+
interface PredefinedSeedContract {
|
|
509
|
+
objectId: string;
|
|
510
|
+
table: QualifiedName;
|
|
511
|
+
/**
|
|
512
|
+
* Колонка мітки, мітка рядка й предикат часткового унікального індексу мітки —
|
|
513
|
+
* арбітр `ON CONFLICT`.
|
|
514
|
+
*/
|
|
515
|
+
label: {
|
|
516
|
+
column: string;
|
|
517
|
+
value: string;
|
|
518
|
+
where: string;
|
|
519
|
+
};
|
|
520
|
+
/** Ключ рядка: значення дає `gen_random_uuid()` засіву (DEFAULT ключа немає). */
|
|
521
|
+
keyColumn: string;
|
|
522
|
+
/** Значення колонок рядка, у порядку колонок таблиці. */
|
|
523
|
+
values: {
|
|
524
|
+
column: string;
|
|
525
|
+
value: string | boolean;
|
|
526
|
+
}[];
|
|
527
|
+
/**
|
|
528
|
+
* Звірка цілі перед засівом (Р-B2-8). `unique` — колонки, значення яких з
|
|
529
|
+
* `values` не може мати рядок без мітки; рядок з міткою мусить мати значення
|
|
530
|
+
* з `values` у колонках `unique` і `fixed`.
|
|
531
|
+
*/
|
|
532
|
+
unique: string[];
|
|
533
|
+
fixed: string[];
|
|
534
|
+
/** Значення, яким діагностика звірки називає рядок (код основної мови). */
|
|
535
|
+
subject: string;
|
|
536
|
+
}
|
|
473
537
|
/**
|
|
474
538
|
* Нумерація першим записом (спека П2, М21): номер призначає оболонка при
|
|
475
539
|
* першому записі; лічильники й генерацію — П3. Префікса поки немає.
|
|
@@ -577,6 +641,15 @@ interface AccessContract {
|
|
|
577
641
|
};
|
|
578
642
|
/** Ролі запиту, яким відкрито всі рядки: `anon` → обидві, `authenticated` → `user`. */
|
|
579
643
|
publicRead: RequestRolePurpose[];
|
|
644
|
+
/**
|
|
645
|
+
* Умовна форма `publicRead` (спека публічної частини §5.1): фізичні колонки
|
|
646
|
+
* умови публікації цієї таблиці — на шапці її `published` і `deletion_mark`,
|
|
647
|
+
* на ТЧ — їхні копії. Немає — `publicRead` відкриває всі рядки.
|
|
648
|
+
*/
|
|
649
|
+
published?: {
|
|
650
|
+
column: string;
|
|
651
|
+
mark: string;
|
|
652
|
+
};
|
|
580
653
|
/** Основна таблиця кореня виду скоупу: без межі тенанта на `INSERT` (спека прав §5.2). */
|
|
581
654
|
root: boolean;
|
|
582
655
|
/**
|
|
@@ -598,6 +671,17 @@ interface AccessContract {
|
|
|
598
671
|
update: string[];
|
|
599
672
|
delete: boolean;
|
|
600
673
|
};
|
|
674
|
+
/**
|
|
675
|
+
* Читання опублікованих рядків (Р-B2-5) — лише основної таблиці довідника
|
|
676
|
+
* з фактом ролі: фізичні колонка стану й колонки, які бачить гість.
|
|
677
|
+
* Політика `<t>_published_read` незалежна від функцій прав і від
|
|
678
|
+
* `publicRead`, а політики прав читання лишаються.
|
|
679
|
+
*/
|
|
680
|
+
publishedRead?: {
|
|
681
|
+
stateColumn: string;
|
|
682
|
+
publishedState: string;
|
|
683
|
+
guestColumns: string[];
|
|
684
|
+
};
|
|
601
685
|
}
|
|
602
686
|
/** Обсяг, яким грант може обмежити дію (спека прав §3). */
|
|
603
687
|
type RightsExtent = {
|
|
@@ -635,6 +719,16 @@ interface RightsAction {
|
|
|
635
719
|
from?: boolean;
|
|
636
720
|
to?: boolean;
|
|
637
721
|
};
|
|
722
|
+
/** Пов'язана колонка: фізична колонка й її значення після дії (факт реєстру). */
|
|
723
|
+
coupled?: {
|
|
724
|
+
column: string;
|
|
725
|
+
value: boolean;
|
|
726
|
+
};
|
|
727
|
+
/**
|
|
728
|
+
* Платформна дія (факт реєстру): її не дає жоден грант, набір, дельта чи
|
|
729
|
+
* `fullAccess` — рівень ролі її не дозволяє (`allowedActions`).
|
|
730
|
+
*/
|
|
731
|
+
platform?: true;
|
|
638
732
|
extents: RightsExtent[];
|
|
639
733
|
}
|
|
640
734
|
/** Носій прав у таблиці: власна колонка або крок шляху (Рх21). */
|
|
@@ -646,7 +740,10 @@ interface CarrierContract {
|
|
|
646
740
|
* носія — `column`, у шляху — його копія (`origin.copyOf`).
|
|
647
741
|
*/
|
|
648
742
|
value: string;
|
|
649
|
-
/**
|
|
743
|
+
/**
|
|
744
|
+
* Шлях: колонка в основній таблиці цілі першого кроку; ланцюжок прив'язки —
|
|
745
|
+
* колонка зі значенням прив'язки цілі (її реквізит чи її копія).
|
|
746
|
+
*/
|
|
650
747
|
via?: {
|
|
651
748
|
objectId: string;
|
|
652
749
|
table: QualifiedName;
|
|
@@ -685,7 +782,7 @@ interface RightsContract {
|
|
|
685
782
|
root?: true;
|
|
686
783
|
/**
|
|
687
784
|
* Корінь: колонка автора (`createdBy`), коли вона — власний носій
|
|
688
|
-
* власності. Лише її судить `create@own` кореня (спека прав §5.2
|
|
785
|
+
* власності. Лише її судить `create@own` кореня (спека прав §5.2).
|
|
689
786
|
*/
|
|
690
787
|
rootAuthor?: string;
|
|
691
788
|
/** Стандартні дії в порядку реєстру, далі кастомні за `id`. */
|
|
@@ -916,6 +1013,8 @@ interface Contracts {
|
|
|
916
1013
|
predefined: PredefinedContract[];
|
|
917
1014
|
/** За `objectId`. */
|
|
918
1015
|
numbering: NumberingContract[];
|
|
1016
|
+
/** За `objectId`: передвизначені рядки, які засіває apply (Р-B2-7). */
|
|
1017
|
+
predefinedSeeds: PredefinedSeedContract[];
|
|
919
1018
|
/** За `table.schema`, далі `table.name`: кожна таблиця виду з RLS. */
|
|
920
1019
|
access: AccessContract[];
|
|
921
1020
|
/** За `bucket`: вид скоупу вказано id, бо ім'я виду може змінитися. */
|
|
@@ -947,26 +1046,30 @@ interface Contracts {
|
|
|
947
1046
|
rightsCatalogs: RightsCatalogContract[];
|
|
948
1047
|
}
|
|
949
1048
|
/** Основна таблиця об'єкта (не ТЧ і не підсумки). */
|
|
950
|
-
export declare function mainTableOf(physical: PhysicalSnapshot, objectId: string):
|
|
1049
|
+
export declare function mainTableOf(physical: PhysicalSnapshot, objectId: string): ObjectTable | undefined;
|
|
951
1050
|
/**
|
|
952
1051
|
* Імена тригерів копій носіїв на таблиці: `derive` — на таблиці з копіями,
|
|
953
|
-
* обидва тригери поширення — на таблиці-джерелі.
|
|
954
|
-
* `BEFORE`, тож іде спільним префіксом групи: інакше на
|
|
955
|
-
* спрацював би не між авторством і механікою. Поширення
|
|
956
|
-
*
|
|
1052
|
+
* обидва тригери поширення й переприв'язування — на таблиці-джерелі.
|
|
1053
|
+
* `derive` — рядковий `BEFORE`, тож іде спільним префіксом групи: інакше на
|
|
1054
|
+
* довгій назві він спрацював би не між авторством і механікою. Поширення й
|
|
1055
|
+
* переприв'язування — `AFTER`, на `NEW` не впливають, і лишаються на
|
|
1056
|
+
* алгоритмі Postgres, що тримає мітку цілою.
|
|
957
1057
|
*/
|
|
958
1058
|
export declare function carrierTriggerNames(table: QualifiedName): {
|
|
959
1059
|
derive: string;
|
|
960
1060
|
propagate: string;
|
|
961
1061
|
propagateInsert: string;
|
|
1062
|
+
rebind: string;
|
|
962
1063
|
};
|
|
963
1064
|
/**
|
|
964
1065
|
* Функції носіїв у схемі таблиці: виведення — на таблиці з копіями,
|
|
965
|
-
* поширення — одна на джерело для обох його
|
|
1066
|
+
* поширення — одна на джерело для обох його тригерів, переприв'язування —
|
|
1067
|
+
* на джерелі ланцюжка.
|
|
966
1068
|
*/
|
|
967
1069
|
export declare function carrierFunctionNames(table: QualifiedName): {
|
|
968
1070
|
derive: QualifiedName;
|
|
969
1071
|
propagate: QualifiedName;
|
|
1072
|
+
rebind: QualifiedName;
|
|
970
1073
|
};
|
|
971
1074
|
/**
|
|
972
1075
|
* Зв'язок таблиці з копіями з її джерелом через одну локальну колонку:
|
|
@@ -977,8 +1080,8 @@ export declare function carrierFunctionNames(table: QualifiedName): {
|
|
|
977
1080
|
* скоупу не дублюється.
|
|
978
1081
|
*/
|
|
979
1082
|
interface CarrierLink {
|
|
980
|
-
table:
|
|
981
|
-
source:
|
|
1083
|
+
table: ObjectTable;
|
|
1084
|
+
source: ObjectTable;
|
|
982
1085
|
through: string;
|
|
983
1086
|
pairs: {
|
|
984
1087
|
local: string;
|
|
@@ -1052,6 +1155,22 @@ interface PlpgsqlFunction {
|
|
|
1052
1155
|
* мовчки: споживач сам вирішує, що робити з непрочитаним.
|
|
1053
1156
|
*/
|
|
1054
1157
|
readonly unreadLines: readonly number[];
|
|
1158
|
+
/**
|
|
1159
|
+
* Зовнішній блок автора. Плаский `statements` не відрізняє його від
|
|
1160
|
+
* вкладених блоків і від синтетичної обгортки секції `EXCEPTION`, а доказ
|
|
1161
|
+
* запобіжника судить саме перший оператор цього блоку.
|
|
1162
|
+
*/
|
|
1163
|
+
readonly author: PlpgsqlAuthorBlock;
|
|
1164
|
+
}
|
|
1165
|
+
interface PlpgsqlAuthorBlock {
|
|
1166
|
+
/**
|
|
1167
|
+
* Перший оператор блоку автора без фіктивного `RETURN`, який парсер додає
|
|
1168
|
+
* в кінець; `undefined`, коли блок порожній. Вирази — лише прямі, як у
|
|
1169
|
+
* `statements`.
|
|
1170
|
+
*/
|
|
1171
|
+
readonly firstStatement?: PlpgsqlStatement;
|
|
1172
|
+
/** Блок автора має секцію `EXCEPTION` (парсер загортає його в обгортку). */
|
|
1173
|
+
readonly hasExceptionBlock: boolean;
|
|
1055
1174
|
}
|
|
1056
1175
|
interface PlpgsqlVariable {
|
|
1057
1176
|
/** Ім'я, на яке може послатися автор; безіменних службових рядків тут немає. */
|
|
@@ -1144,7 +1263,7 @@ export declare function memberCheckFunctionName(table: QualifiedName): Qualified
|
|
|
1144
1263
|
interface CatalogCommandContract {
|
|
1145
1264
|
objectId: string;
|
|
1146
1265
|
kindLabel: string;
|
|
1147
|
-
table:
|
|
1266
|
+
table: ObjectTable;
|
|
1148
1267
|
/** Колонка з `origin.scopeKindId`; у кореня виду скоупу — сам ключ. */
|
|
1149
1268
|
scopeColumn?: string;
|
|
1150
1269
|
key: string;
|
|
@@ -1152,6 +1271,9 @@ interface CatalogCommandContract {
|
|
|
1152
1271
|
save: QualifiedName;
|
|
1153
1272
|
markDeletion?: QualifiedName;
|
|
1154
1273
|
delete?: QualifiedName;
|
|
1274
|
+
/** Ядра публікації — лише умовного об'єкта (Р-D1-11). */
|
|
1275
|
+
publish?: QualifiedName;
|
|
1276
|
+
unpublish?: QualifiedName;
|
|
1155
1277
|
/** Ядро `create` кореня виду скоупу (спека П4 §6.13) — лише на корені. */
|
|
1156
1278
|
createRoot?: QualifiedName;
|
|
1157
1279
|
};
|
|
@@ -1161,6 +1283,8 @@ interface CatalogCommandContract {
|
|
|
1161
1283
|
update: string;
|
|
1162
1284
|
markDeletion?: string;
|
|
1163
1285
|
delete?: string;
|
|
1286
|
+
publish?: string;
|
|
1287
|
+
unpublish?: string;
|
|
1164
1288
|
createRoot?: string;
|
|
1165
1289
|
};
|
|
1166
1290
|
/** Ключі `p_item` створення й зміни (спека П4 §6.6) — з гранту ролі команд. */
|
|
@@ -1181,7 +1305,7 @@ interface CatalogCommandContract {
|
|
|
1181
1305
|
}
|
|
1182
1306
|
/** ТЧ довідника в контракті ядра; ключ ТЧ у `p_item.tabular` — `table.name`. */
|
|
1183
1307
|
interface CatalogCommandSection {
|
|
1184
|
-
table:
|
|
1308
|
+
table: ObjectTable;
|
|
1185
1309
|
key: string;
|
|
1186
1310
|
parent: string;
|
|
1187
1311
|
lineNumber: string;
|
|
@@ -1208,6 +1332,11 @@ type CommandReference = {
|
|
|
1208
1332
|
array: boolean;
|
|
1209
1333
|
/** Свідомо між тенантами: ядро не звіряє скоуп цілі. */
|
|
1210
1334
|
crossScope?: true;
|
|
1335
|
+
/**
|
|
1336
|
+
* Ціль — довідник «Користувачі» (роль реєстру `users`): значення, що
|
|
1337
|
+
* дорівнює `current_user_id()`, видиме без права на них (спека П4 §6.6).
|
|
1338
|
+
*/
|
|
1339
|
+
users?: true;
|
|
1211
1340
|
} | {
|
|
1212
1341
|
form: "pair";
|
|
1213
1342
|
typeColumn: string;
|
|
@@ -1216,7 +1345,7 @@ type CommandReference = {
|
|
|
1216
1345
|
crossScope?: true;
|
|
1217
1346
|
targets: {
|
|
1218
1347
|
label: string;
|
|
1219
|
-
table:
|
|
1348
|
+
table: ObjectTable;
|
|
1220
1349
|
key: string;
|
|
1221
1350
|
scopeColumn?: string;
|
|
1222
1351
|
}[];
|
|
@@ -1260,6 +1389,132 @@ interface Presentation {
|
|
|
1260
1389
|
defaultLocale: string;
|
|
1261
1390
|
objects: PresentationBlock[];
|
|
1262
1391
|
}
|
|
1392
|
+
/**
|
|
1393
|
+
* Форма платформи: функція, призначення якої задають метадані чи, для
|
|
1394
|
+
* функції політики, політики-викликачі (спека декларацій функцій §5.8).
|
|
1395
|
+
*/
|
|
1396
|
+
type PlatformForm = "setFunction" | "subscriptionHandler" | "dimension" | "policyFunction";
|
|
1397
|
+
/** Чим функція виходить за закриту оболонку (спека промоції §9.4). */
|
|
1398
|
+
type ClosedShellProblem = "language" | "volatility" | "searchPath" | "dynamicSql" | "body";
|
|
1399
|
+
/** Одиниця, чию оболонку судять: дерево `CREATE FUNCTION` і його текст. */
|
|
1400
|
+
interface ShellUnit {
|
|
1401
|
+
tree: Node$1;
|
|
1402
|
+
sql: string;
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Закрита оболонка функції (спека П2 §3, «Дослівний SQL»): мова `sql` чи
|
|
1406
|
+
* `plpgsql`, явна волатильність, `SECURITY DEFINER` лише з `SET search_path
|
|
1407
|
+
* = ''`. Оболонка — те, що компілятор може перевірити статично: тіло лишається
|
|
1408
|
+
* кодом застосунку, а мова C чи неявна `VOLATILE` ховали б від рамки те, що
|
|
1409
|
+
* функція робить. Тіло plpgsql має розбиратися і не виконувати динамічний
|
|
1410
|
+
* SQL: рядок, зібраний під час виконання, не бачить ні граф залежностей, ні
|
|
1411
|
+
* рамка. Парсер plpgsql кличеться лише для `LANGUAGE plpgsql`: на тілі
|
|
1412
|
+
* `LANGUAGE sql … BEGIN ATOMIC` він аварійно завершується, і кожне тіло
|
|
1413
|
+
* стандарту SQL хибно вважалося б нерозбірним. Не функція (процедура, інший
|
|
1414
|
+
* оператор) — `undefined`: оболонка описує лише `CREATE FUNCTION`.
|
|
1415
|
+
*/
|
|
1416
|
+
export declare function closedShellProblem(unit: ShellUnit, plpgsql: PlpgsqlParser): ClosedShellProblem | undefined;
|
|
1417
|
+
/**
|
|
1418
|
+
* Схема, куди `CREATE EXTENSION` ставить свої об'єкти (опція `SCHEMA`);
|
|
1419
|
+
* без неї — `undefined`: розширення стає в першу схему `search_path` сесії,
|
|
1420
|
+
* яка статично не відома.
|
|
1421
|
+
*/
|
|
1422
|
+
export declare function extensionSchema(tree: unknown): string | undefined;
|
|
1423
|
+
/** Функція політики: форма пройдена, призначення `EXECUTE` виведено. */
|
|
1424
|
+
interface PolicyFunction {
|
|
1425
|
+
function: {
|
|
1426
|
+
schema: string;
|
|
1427
|
+
name: string;
|
|
1428
|
+
};
|
|
1429
|
+
unit: VerbatimUnit;
|
|
1430
|
+
/** Таблиця T, на якій стоять усі політики-викликачі. */
|
|
1431
|
+
table: {
|
|
1432
|
+
schema: string;
|
|
1433
|
+
name: string;
|
|
1434
|
+
};
|
|
1435
|
+
callers: readonly VerbatimUnit[];
|
|
1436
|
+
/** Призначення ролей `TO` політик-викликачів `SELECT`/`ALL` з `USING`. */
|
|
1437
|
+
purposes: readonly GrantPurpose[];
|
|
1438
|
+
}
|
|
1439
|
+
interface PolicyFunctions {
|
|
1440
|
+
functions: PolicyFunction[];
|
|
1441
|
+
/** `sql.policy-helper-correlated`: одна на функцію поза формою. */
|
|
1442
|
+
diagnostics: Diagnostic[];
|
|
1443
|
+
/**
|
|
1444
|
+
* Ідентичності одиниць цих діагностик: поки функція має
|
|
1445
|
+
* `sql.policy-helper-correlated`, інші коди ремонту тієї самої функції
|
|
1446
|
+
* вона поглинає (одна функція — одна причина ремонту, §5.8).
|
|
1447
|
+
*/
|
|
1448
|
+
refused: string[];
|
|
1449
|
+
}
|
|
1450
|
+
/** Function with an EXECUTE group the platform derives (one entry per target). */
|
|
1451
|
+
interface ExecuteEntry {
|
|
1452
|
+
identity: string;
|
|
1453
|
+
schema: string;
|
|
1454
|
+
name: string;
|
|
1455
|
+
purposes: readonly GrantPurpose[];
|
|
1456
|
+
/** Set when the function is a platform form (the form decides the group). */
|
|
1457
|
+
form?: PlatformForm;
|
|
1458
|
+
}
|
|
1459
|
+
/**
|
|
1460
|
+
* Об'єкти, ACL яких належить платформі (платформна спека §6.7). Ключ —
|
|
1461
|
+
* `function|<сигнатура>` чи `table|<схема.ім'я>`: `grantTargetKeys`.
|
|
1462
|
+
* Функція — ціль будь-якої згенерованої одиниці `grant` (`functionExecute`,
|
|
1463
|
+
* членство, платформний шар); таблиця — лише таблиця з контрактом доступу,
|
|
1464
|
+
* тобто ціль грантів генератора `access`.
|
|
1465
|
+
*/
|
|
1466
|
+
export declare function platformGrantTargets(units: readonly Pick<SqlUnit, "class" | "name" | "sql" | "file" | "generator">[], parse: SqlParser): Set<string>;
|
|
1467
|
+
/**
|
|
1468
|
+
* Чи ціль гранту — об'єкт платформи. `ON FUNCTION f` без списку аргументів
|
|
1469
|
+
* Postgres резолвить у єдину функцію з цим ім'ям, тож вона збігається з
|
|
1470
|
+
* функцією платформи тієї самої схеми й імені.
|
|
1471
|
+
*/
|
|
1472
|
+
export declare function ownsTarget(owned: ReadonlySet<string>, target: string): boolean;
|
|
1473
|
+
/**
|
|
1474
|
+
* Цілі гранту-функції чи гранту-таблиці; ціль іншого виду (схема, тип,
|
|
1475
|
+
* послідовність) платформі в цьому правилі не належить, тож ключа не має.
|
|
1476
|
+
*/
|
|
1477
|
+
export declare function grantTargetKeys(unit: Pick<SqlUnit, "class" | "name" | "sql">, parse: SqlParser): string[];
|
|
1478
|
+
/** Причини `sql.declaration-check-not-applied` (спека декларацій функцій §5.2). */
|
|
1479
|
+
type GuardReason = "language" | "declareSection" | "firstStatement" | "arguments" | "exceptionBlock";
|
|
1480
|
+
/**
|
|
1481
|
+
* Verdict of the call guard of one declared function, for `explain`: derived
|
|
1482
|
+
* from the same declarations and the same judge as `checkDeclaredGuards`, and
|
|
1483
|
+
* kept outside the model hash.
|
|
1484
|
+
*/
|
|
1485
|
+
interface DeclaredFunctionState {
|
|
1486
|
+
schema: string;
|
|
1487
|
+
name: string;
|
|
1488
|
+
/** Declared callers (what the file says; not necessarily what is granted). */
|
|
1489
|
+
callers: SqlFunctionDeclaration["callers"];
|
|
1490
|
+
/** Purposes that really get EXECUTE: a platform form wins over the declaration. */
|
|
1491
|
+
purposes: readonly GrantPurpose[];
|
|
1492
|
+
check?: NonNullable<SqlFunctionDeclaration["check"]>;
|
|
1493
|
+
/** `none`: no check declared, or an invoker function (RLS judges it). */
|
|
1494
|
+
state: "applied" | "not-applied" | "none";
|
|
1495
|
+
/** Only for `not-applied`. */
|
|
1496
|
+
reason?: GuardReason;
|
|
1497
|
+
}
|
|
1498
|
+
/** Аргументи запобіжника виклику першого оператора тіла (читає зворотна генерація). */
|
|
1499
|
+
interface GuardArgs {
|
|
1500
|
+
/** Яка функція запобіжника: ціль `row` (`require`) чи `scope` (`requireScope`). */
|
|
1501
|
+
form: "require" | "requireScope";
|
|
1502
|
+
/** Рядок дії: ім'я стандартної дії або UUID кастомної. */
|
|
1503
|
+
action: string;
|
|
1504
|
+
/** Мітка виду об'єкта. */
|
|
1505
|
+
kindLabel: string;
|
|
1506
|
+
/** Параметр цілі; `null` — `NULL` (дія без цілі). */
|
|
1507
|
+
target: string | null;
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Читач аргументів запобіжника поруч із `guardOf`: той самий розбір форми
|
|
1511
|
+
* (plpgsql, без `DECLARE`, `PERFORM` єдиного прямого виклику першим
|
|
1512
|
+
* оператором, без `EXCEPTION`), але без декларації — зворотна генерація з
|
|
1513
|
+
* аргументів пише `check`. Нічого не повертає для тіла без запобіжника чи з
|
|
1514
|
+
* аргументами іншої форми (дві рядкові константи й голе ім'я чи `NULL`):
|
|
1515
|
+
* вигаданого `check` не буде.
|
|
1516
|
+
*/
|
|
1517
|
+
export declare function guardArgsOf(unit: VerbatimUnit, plpgsql: PlpgsqlParser, parse: SqlParser): GuardArgs | undefined;
|
|
1263
1518
|
interface SourceObject {
|
|
1264
1519
|
id: string;
|
|
1265
1520
|
kind: MetadataKind;
|
|
@@ -1301,6 +1556,17 @@ interface CompiledScopeKind {
|
|
|
1301
1556
|
membership: string;
|
|
1302
1557
|
assignments: string;
|
|
1303
1558
|
};
|
|
1559
|
+
/**
|
|
1560
|
+
* Вид із запрошеннями (спека запрошень §1): проєкт оголошує `invitations`,
|
|
1561
|
+
* а вид має довідник членства й системні «Призначення ролей» без прийнятих
|
|
1562
|
+
* джерел. Id обох довідників і строк, який генератор видачі кладе
|
|
1563
|
+
* літералом. Похідний від проєкту й метаданих, тож у хеш моделі не входить.
|
|
1564
|
+
*/
|
|
1565
|
+
invitations?: {
|
|
1566
|
+
membership: string;
|
|
1567
|
+
assignments: string;
|
|
1568
|
+
expiresInHours: number;
|
|
1569
|
+
};
|
|
1304
1570
|
}
|
|
1305
1571
|
interface CompiledModel {
|
|
1306
1572
|
project: Project;
|
|
@@ -1333,11 +1599,18 @@ interface CompiledModel {
|
|
|
1333
1599
|
*/
|
|
1334
1600
|
catalogCommands: CatalogCommandContract[];
|
|
1335
1601
|
/**
|
|
1336
|
-
*
|
|
1337
|
-
* мапінгу `23514` каталогом
|
|
1602
|
+
* Колонки CHECK за призначеним іменем — колонка CHECK реквізиту чи
|
|
1603
|
+
* колонки, які читає правило рядка, — для мапінгу `23514` каталогом рантайму. Похідне від знімка, тож
|
|
1338
1604
|
* канонічний знімок його не читає і хеш від нього не залежить.
|
|
1339
1605
|
*/
|
|
1340
1606
|
checkColumns: CheckColumn[];
|
|
1607
|
+
/**
|
|
1608
|
+
* Колонки з позначкою `copy` (`copyColumns`) за таблицею `schema.table`,
|
|
1609
|
+
* лише таблиці з такими колонками. Похідне від знімка й парсера, тож
|
|
1610
|
+
* канонічний знімок його не читає і хеш від нього не залежить: поле знімка
|
|
1611
|
+
* змінило б `snapshotHash` кожного проєкту.
|
|
1612
|
+
*/
|
|
1613
|
+
copyColumns: ReadonlyMap<string, ReadonlySet<string>>;
|
|
1341
1614
|
/**
|
|
1342
1615
|
* Спільний порядок створення енам-типів, таблиць і одиниць: розширення
|
|
1343
1616
|
* перші, далі топологічно з tie-break (тип вузла, схема, ім'я/ідентичність).
|
|
@@ -1355,8 +1628,23 @@ interface CompiledModel {
|
|
|
1355
1628
|
interface CompileResult {
|
|
1356
1629
|
ok: boolean;
|
|
1357
1630
|
diagnostics: Diagnostic[];
|
|
1358
|
-
/**
|
|
1631
|
+
/**
|
|
1632
|
+
* Лише коли прогін без помилок: наступні шари не бачать напівмоделі. Режим
|
|
1633
|
+
* `repair` — виняток: модель є й тоді, коли кожна помилка — класу ремонту.
|
|
1634
|
+
*/
|
|
1359
1635
|
model?: CompiledModel;
|
|
1636
|
+
/**
|
|
1637
|
+
* Declared functions with the call-guard verdict, for `explain`. Present
|
|
1638
|
+
* together with the model but not part of it: the model hash does not
|
|
1639
|
+
* depend on declarations.
|
|
1640
|
+
*/
|
|
1641
|
+
declaredFunctions?: DeclaredFunctionState[];
|
|
1642
|
+
/**
|
|
1643
|
+
* Functions whose EXECUTE the platform derives (declared, platform forms,
|
|
1644
|
+
* module functions), from the same groups as the grant generator; for
|
|
1645
|
+
* `explain`. Outside the model hash, like `declaredFunctions`.
|
|
1646
|
+
*/
|
|
1647
|
+
functionExecute?: ExecuteEntry[];
|
|
1360
1648
|
}
|
|
1361
1649
|
interface CompileOptions {
|
|
1362
1650
|
/**
|
|
@@ -1364,6 +1652,13 @@ interface CompileOptions {
|
|
|
1364
1652
|
* призначені раз, звіряються з нею; немає — перевірки немає.
|
|
1365
1653
|
*/
|
|
1366
1654
|
baseline?: ReadonlyMap<string, string>;
|
|
1655
|
+
/**
|
|
1656
|
+
* Режим ремонту (спека декларацій функцій §5.1): модель повертається й
|
|
1657
|
+
* тоді, коли кожна помилка — класу ремонту (`REPAIR_CLASS`), а `ok`
|
|
1658
|
+
* лишається `false`. Передають лише мутації, що лагодять теку крок за
|
|
1659
|
+
* кроком (`create`, `add`); без поля модель — лише з чистого прогону.
|
|
1660
|
+
*/
|
|
1661
|
+
repair?: true;
|
|
1367
1662
|
}
|
|
1368
1663
|
/**
|
|
1369
1664
|
* Компілятор — чиста функція над мапою «шлях відносно `metadata/` → вміст»
|
|
@@ -1372,6 +1667,12 @@ interface CompileOptions {
|
|
|
1372
1667
|
* Асинхронна, бо парсер Postgres — WASM, який вантажиться один раз на процес.
|
|
1373
1668
|
*/
|
|
1374
1669
|
export declare function compile(files: ReadonlyMap<string, string>, options?: CompileOptions): Promise<CompileResult>;
|
|
1670
|
+
/**
|
|
1671
|
+
* Функції політик теки (спека декларацій функцій §5.8) — той самий результат
|
|
1672
|
+
* розпізнавача, що бачить компілятор: операції, які судять форми платформи
|
|
1673
|
+
* (`toPlatformForms`, `declare-function`), будують його з тих самих одиниць.
|
|
1674
|
+
*/
|
|
1675
|
+
export declare function formPolicies(files: ReadonlyMap<string, string>): Promise<PolicyFunctions>;
|
|
1375
1676
|
/**
|
|
1376
1677
|
* Повний борг дослівного SQL теки (спека П2 §8.6) —
|
|
1377
1678
|
* відсортовані ідентичності одиниць, які ратчет вимагає мати в
|
|
@@ -1382,6 +1683,94 @@ export declare function compile(files: ReadonlyMap<string, string>, options?: Co
|
|
|
1382
1683
|
* мовчки прибрало б справжні записи.
|
|
1383
1684
|
*/
|
|
1384
1685
|
export declare function currentDebt(files: ReadonlyMap<string, string>): Promise<string[] | undefined>;
|
|
1686
|
+
/**
|
|
1687
|
+
* Імена політик таблиці (платформна спека §6.8, спека прав §5.2): мітка після
|
|
1688
|
+
* імені таблиці, як у Postgres, тож довга назва скорочується, а не перевищує
|
|
1689
|
+
* 63 байти. `rights` бере мітку обсягу без `read_` (`any`, `own_<колонка>`,
|
|
1690
|
+
* `in_<контейнер>_<обсяг>`, вимір): мітку понад 40 байтів цілком замінюють її
|
|
1691
|
+
* перші 31 байт, `_` і 8 hex-знаків `sha256` повної мітки (спека прав §5.2) — інакше
|
|
1692
|
+
* довгі мітки однієї таблиці після обрізання таблиці до нуля збіглися б.
|
|
1693
|
+
* `command<Dml>` — запобіжник контексту команди, `write` — політика запису
|
|
1694
|
+
* родини `root` чи `rest` з тією самою межею мітки.
|
|
1695
|
+
*/
|
|
1696
|
+
export declare function accessPolicyNames(table: {
|
|
1697
|
+
name: string;
|
|
1698
|
+
}): {
|
|
1699
|
+
scopeRead: string;
|
|
1700
|
+
scopeInsert: string;
|
|
1701
|
+
scopeUpdate: string;
|
|
1702
|
+
scopeDelete: string;
|
|
1703
|
+
publicRead: string;
|
|
1704
|
+
publishedRead: string;
|
|
1705
|
+
commandInsert: string;
|
|
1706
|
+
commandUpdate: string;
|
|
1707
|
+
commandDelete: string;
|
|
1708
|
+
rights(label: string): string;
|
|
1709
|
+
write(dml: Dml, family: WriteFamily, label: string): string;
|
|
1710
|
+
};
|
|
1711
|
+
/** Родина політики запису (спека прав §5.3): кореневий рядок команди чи решта рядків. */
|
|
1712
|
+
type WriteFamily = "root" | "rest";
|
|
1713
|
+
/**
|
|
1714
|
+
* Контракти прав лише з метаданих, без SQL-стадій: зворотна генерація
|
|
1715
|
+
* розв'язує за ними мітку виду й дію запобіжника. `undefined` — метадані
|
|
1716
|
+
* не доходять до моделі (помилка стадій 1–3) чи контракти не будуються.
|
|
1717
|
+
*/
|
|
1718
|
+
export declare function metadataRights(files: ReadonlyMap<string, string>): {
|
|
1719
|
+
objects: readonly {
|
|
1720
|
+
id: string;
|
|
1721
|
+
kind: MetadataKind;
|
|
1722
|
+
name: string;
|
|
1723
|
+
}[];
|
|
1724
|
+
rights: RightsContract[];
|
|
1725
|
+
} | undefined;
|
|
1726
|
+
/**
|
|
1727
|
+
* Ідентичність SQL-одиниці (спека П2 §3, §8.3): `<клас>:<ключ>`, де кожна
|
|
1728
|
+
* частина імені — за `quoteIdent`, а роздільники `.` `,` `:` `(` `)` стоять
|
|
1729
|
+
* лише поза лапками. Тож різні об'єкти Postgres мають різні ідентичності
|
|
1730
|
+
* (`"a.b".c` ≠ `a."b.c"`), а ключ функції — валідний підпис SQL. Цей модуль —
|
|
1731
|
+
* єдине місце, що складає й розбирає рядок ідентичності: склеєна вручну
|
|
1732
|
+
* частина без лапок знову зробила б ідентичність неін'єктивною (#297).
|
|
1733
|
+
*/
|
|
1734
|
+
/**
|
|
1735
|
+
* Клас ідентичності: клас SQL-одиниці або об'єкт моделі (таблиця, енам-тип),
|
|
1736
|
+
* що ділить із одиницями простір міток — у конфліктах імен і графі
|
|
1737
|
+
* створення.
|
|
1738
|
+
*/
|
|
1739
|
+
type IdentityClass = SqlUnitClass | "table" | "enumType";
|
|
1740
|
+
/** Кваліфіковане ім'я: частини за `quoteIdent` через `.`. */
|
|
1741
|
+
export declare function qualifiedName(...parts: readonly string[]): string;
|
|
1742
|
+
/** Ідентичність з ключем із частин імені: `view:public."V"`. */
|
|
1743
|
+
export declare function unitIdentity(cls: IdentityClass, ...parts: readonly string[]): string;
|
|
1744
|
+
/**
|
|
1745
|
+
* Ідентичність із готовим ключем: підписом (`signatureKey`) чи складеним
|
|
1746
|
+
* ключем гранту, коментаря, публікації. Частини такого ключа вже зібрано
|
|
1747
|
+
* функціями цього модуля.
|
|
1748
|
+
*/
|
|
1749
|
+
export declare function keyIdentity(cls: IdentityClass, key: string): string;
|
|
1750
|
+
/** Ключ ідентичності: усе після класу (клас двокрапки не містить). */
|
|
1751
|
+
export declare function identityKey(identity: string): string;
|
|
1752
|
+
/**
|
|
1753
|
+
* Частини імені ключа з крапками (в'юха, тригер, політика:
|
|
1754
|
+
* схема, таблиця, ім'я) — імена каталогу, без лапок.
|
|
1755
|
+
*/
|
|
1756
|
+
export declare function identityParts(identity: string): string[];
|
|
1757
|
+
/** Частина імені з ключа як ім'я каталогу: обернення `quoteIdent`. */
|
|
1758
|
+
export declare function unquoteIdent(part: string): string;
|
|
1759
|
+
/**
|
|
1760
|
+
* Частини ідентичності між роздільниками `separator` поза лапками й дужками:
|
|
1761
|
+
* роль чи ціль у лапках може містити і кому, і двокрапку.
|
|
1762
|
+
*/
|
|
1763
|
+
export declare function splitIdentity(text: string, separator: string): string[];
|
|
1764
|
+
/**
|
|
1765
|
+
* Ключ функції з уже відрендерених типів аргументів: `схема.ім'я(т1,т2)`.
|
|
1766
|
+
* Агрегат без списку аргументів — тип `*`.
|
|
1767
|
+
*/
|
|
1768
|
+
export declare function functionKey(schema: string, name: string, types: readonly string[]): string;
|
|
1769
|
+
/**
|
|
1770
|
+
* Names of the platform triggers on the identity table of the provider; the
|
|
1771
|
+
* map `TRIGGERS` stays their source.
|
|
1772
|
+
*/
|
|
1773
|
+
export declare const IDENTITY_TRIGGERS: readonly string[];
|
|
1385
1774
|
/**
|
|
1386
1775
|
* Безпека самої схеми `simetra` (спека користувачів §3): `REVOKE ALL` від
|
|
1387
1776
|
* `PUBLIC` і `USAGE` ролям API й ролі команд. Одна функція на два
|
|
@@ -1391,6 +1780,60 @@ export declare function currentDebt(files: ReadonlyMap<string, string>): Promise
|
|
|
1391
1780
|
* описані.
|
|
1392
1781
|
*/
|
|
1393
1782
|
export declare function platformSchemaGrants(provider: DatabaseProvider): string[];
|
|
1783
|
+
/**
|
|
1784
|
+
* What the platform installs in every database of a provider: the snapshot
|
|
1785
|
+
* tables with a platform origin (no owner object) and the units the compiler
|
|
1786
|
+
* generates for a project without any object.
|
|
1787
|
+
*/
|
|
1788
|
+
interface PlatformInstall {
|
|
1789
|
+
tables: readonly PhysicalTable[];
|
|
1790
|
+
units: readonly SqlUnit[];
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* The platform install of `provider`, derived from the compiled empty project
|
|
1794
|
+
* — the same generators that put it into every project, not a list per
|
|
1795
|
+
* object: a new platform table or unit appears here without a second edit.
|
|
1796
|
+
* It is a reference of `platformRecogniser`, which tells platform content
|
|
1797
|
+
* from the application's by content, not by name.
|
|
1798
|
+
*/
|
|
1799
|
+
export declare function platformInstall(provider: DatabaseProvider): Promise<PlatformInstall>;
|
|
1800
|
+
/**
|
|
1801
|
+
* Atoms `<grant|revoke>|<class>|<object>|<role>|<privilege>` of a grant unit,
|
|
1802
|
+
* read from its identity
|
|
1803
|
+
* `grant:<grant|revoke>:<class>:<objects>:<roles>:<privileges>`; a column
|
|
1804
|
+
* privilege is one atom per column (`insert(method)`), and the grant option
|
|
1805
|
+
* stays on each atom (`select*`, `insert(method)*`), so a grant with the
|
|
1806
|
+
* option never matches an atom of the install, which gives none. Only for
|
|
1807
|
+
* identities without SQL (the plan of `diff`); a catalog unit is judged by
|
|
1808
|
+
* `platformRecogniser`, which takes its atoms from the parse tree.
|
|
1809
|
+
*/
|
|
1810
|
+
export declare function grantAtoms(identity: string): string[];
|
|
1811
|
+
/**
|
|
1812
|
+
* What the platform itself installs or renders, as the recogniser compares
|
|
1813
|
+
* it: tables of the platform (no owner object) and generated units.
|
|
1814
|
+
*/
|
|
1815
|
+
interface PlatformReference {
|
|
1816
|
+
tables: readonly PhysicalTable[];
|
|
1817
|
+
units: readonly Pick<SqlUnit, "class" | "identity" | "sql">[];
|
|
1818
|
+
}
|
|
1819
|
+
/** A unit of a live catalog, as the recogniser reads it. */
|
|
1820
|
+
type RecognisedUnit = Pick<CatalogUnit, "class" | "identity" | "sql">;
|
|
1821
|
+
/**
|
|
1822
|
+
* Recogniser of platform content among the objects of a catalog: a table or
|
|
1823
|
+
* unit is the platform's only when its content matches the reference. A
|
|
1824
|
+
* grant is the platform's when every atom of its parse tree (action, object,
|
|
1825
|
+
* role, privilege with column, grant option, behaviour, grantor) is an atom
|
|
1826
|
+
* of a reference grant; any other unit when its normalised parse tree equals
|
|
1827
|
+
* the tree of the reference unit with the same identity; a table when the
|
|
1828
|
+
* catalog comparison with the reference table finds no difference. What does
|
|
1829
|
+
* not parse, has no reference or differs without a normalisation rule is not
|
|
1830
|
+
* the platform's: the folder gets it and the compiler judges it.
|
|
1831
|
+
*/
|
|
1832
|
+
interface PlatformRecogniser {
|
|
1833
|
+
table(table: CatalogTable): boolean;
|
|
1834
|
+
unit(unit: RecognisedUnit): boolean;
|
|
1835
|
+
}
|
|
1836
|
+
export declare function platformRecogniser(reference: PlatformReference, parse: SqlParser): PlatformRecogniser;
|
|
1394
1837
|
/**
|
|
1395
1838
|
* Право виконання згенерованої функції — лише ролям названих призначень
|
|
1396
1839
|
* (платформна спека §6.7: дефолт — `REVOKE ALL`). Postgres дає `EXECUTE`
|
|
@@ -1402,6 +1845,89 @@ export declare function platformSchemaGrants(provider: DatabaseProvider): string
|
|
|
1402
1845
|
* `схема.ім'я(типи)`, як у `ON FUNCTION`.
|
|
1403
1846
|
*/
|
|
1404
1847
|
export declare function executeGrants(signature: string, purposes: readonly GrantPurpose[], provider: DatabaseProvider): string[];
|
|
1848
|
+
/**
|
|
1849
|
+
* Обернення `grantRole`: роль бази → викликачі декларації (зворотна генерація,
|
|
1850
|
+
* спека декларацій функцій §5.5). Таблицю пар не дублює — обертає `grantRole`
|
|
1851
|
+
* по всіх призначеннях, тож нове призначення потрапляє сюди саме. `PUBLIC`
|
|
1852
|
+
* дає кожне призначення, що має роль у профілі (роль без сесії теж: її
|
|
1853
|
+
* відкидає і про це попереджає читач). Роль поза призначеннями профілю
|
|
1854
|
+
* (`signalConsumer`, `files`, власна роль застосунку) — `undefined`: викликача для неї
|
|
1855
|
+
* немає, і це не мовчазна згода, а підстава відмови читача.
|
|
1856
|
+
*/
|
|
1857
|
+
export declare function callersOfRole(role: string, provider: DatabaseProvider): GrantPurpose[] | undefined;
|
|
1858
|
+
export declare const PUBLIC = "PUBLIC";
|
|
1859
|
+
/** Дослівний `GRANT`/`REVOKE` на функцію чи відношення. */
|
|
1860
|
+
interface GrantFact {
|
|
1861
|
+
keys: readonly string[];
|
|
1862
|
+
grant: boolean;
|
|
1863
|
+
/** `REVOKE GRANT OPTION FOR` — сам привілей лишається. */
|
|
1864
|
+
optionOnly: boolean;
|
|
1865
|
+
/** Отримувачі: `PUBLIC` чи ім'я ролі. */
|
|
1866
|
+
roles: ReadonlySet<string>;
|
|
1867
|
+
/** Привілеї; порожньо — `ALL`. `columns` — лише на колонки. */
|
|
1868
|
+
privileges: readonly {
|
|
1869
|
+
name: string;
|
|
1870
|
+
columns: boolean;
|
|
1871
|
+
}[];
|
|
1872
|
+
}
|
|
1873
|
+
export declare function grantFacts(units: readonly VerbatimUnit[], parse: SqlParser): GrantFact[];
|
|
1874
|
+
/** Одиниця шару, що не залежить від моделі: модуль додає той, хто її кладе. */
|
|
1875
|
+
type RenderedUnit = Omit<SqlUnit, "module">;
|
|
1876
|
+
/** Одна функція механіки на всі таблиці: тіло не залежить від таблиці. */
|
|
1877
|
+
export declare const MECHANICS_FUNCTION: QualifiedName;
|
|
1878
|
+
/**
|
|
1879
|
+
* Єдине джерело версій рядків бази: усі таблиці механіки беруть версію з неї,
|
|
1880
|
+
* тож ключ, видалений і створений знову, не повторює вже видану версію.
|
|
1881
|
+
*/
|
|
1882
|
+
export declare const ROW_VERSION_SEQUENCE: {
|
|
1883
|
+
readonly schema: "simetra";
|
|
1884
|
+
readonly name: "row_version";
|
|
1885
|
+
};
|
|
1886
|
+
/**
|
|
1887
|
+
* Префікс налаштування транзакції, у яке `touch` кладе видану версію рядка
|
|
1888
|
+
* (`<префікс><OID таблиці>`): `currval` зсували б інші тригери, а це
|
|
1889
|
+
* налаштування пише лише `touch` (вставка й оновлення) тієї самої таблиці.
|
|
1890
|
+
*/
|
|
1891
|
+
export declare const ROW_VERSION_SETTING = "simetra.row_version_";
|
|
1892
|
+
/**
|
|
1893
|
+
* Ім'я тригера механіки на таблиці. Спільний префікс рядкових `BEFORE`-тригерів
|
|
1894
|
+
* ставить механіку останньою на будь-якій довжині назви, а зворотна генерація
|
|
1895
|
+
* й промоція впізнають тригер за тим самим іменем.
|
|
1896
|
+
*/
|
|
1897
|
+
export declare function mechanicsTriggerName(table: string): string;
|
|
1898
|
+
/**
|
|
1899
|
+
* Ім'я тригера механіки на `UPDATE` таблиці з копіями носіїв: там механіка
|
|
1900
|
+
* розділена на вставку й оновлення з умовою `contentChangeCondition`.
|
|
1901
|
+
*/
|
|
1902
|
+
export declare function mechanicsUpdateTriggerName(table: string): string;
|
|
1903
|
+
/** Колонки авторства таблиці — за `origin.standard`, у порядку таблиці. */
|
|
1904
|
+
export declare function authorTableColumns(table: Pick<PhysicalTable, "columns">, attributeCase: AttributeCase): PhysicalColumn[];
|
|
1905
|
+
/**
|
|
1906
|
+
* Умова «змінився зміст рядка» таблиці з копіями носіїв (спека прав §5.2):
|
|
1907
|
+
* `(<зміст змінився>) OR NOT (<копії змінилися>)`. Поширення копій
|
|
1908
|
+
* платформою — не зміна змісту: воно пише лише копії, тож придушується, а
|
|
1909
|
+
* звичайне перезбереження без змін (нічого не змінилося) поводиться, як на
|
|
1910
|
+
* будь-якій таблиці. Умова `BEFORE`-тригера рахується з `NEW` після
|
|
1911
|
+
* попередніх тригерів, але поширення пише лише копії за будь-якого порядку
|
|
1912
|
+
* тригерів, тож результат від порядку імен не залежить. Зміст —
|
|
1913
|
+
* `contentColumns`. Таблиця без копій умови не має.
|
|
1914
|
+
*
|
|
1915
|
+
* `watched` (спека П4 §6.8) — колонки поза змістом, зміна яких теж має спрацювати:
|
|
1916
|
+
* авторство для тригерів механіки, авторства й ефектів. Копія носія може
|
|
1917
|
+
* виводитися з `createdBy`, тож зміна лише `created_by_id` змінює й копію, і
|
|
1918
|
+
* без `watched` умова була б хибною: ефекти не відмовили б незмінному
|
|
1919
|
+
* автору, а механіка не підвищила б версію. Підписки `watched` не беруть.
|
|
1920
|
+
*/
|
|
1921
|
+
export declare function contentChangeCondition(table: Pick<PhysicalTable, "columns">, attributeCase: AttributeCase, watched?: readonly PhysicalColumn[]): string | undefined;
|
|
1922
|
+
/**
|
|
1923
|
+
* Таблиці механіки моделі: ті, чиї колонки реєстр дав як службові дату й
|
|
1924
|
+
* версію (за `origin.standard`, а не за іменем колонки). Єдине рішення, яке
|
|
1925
|
+
* читають і генератор тригерів, і засів послідовності версій у стані
|
|
1926
|
+
* застосування, тож вони не розходяться.
|
|
1927
|
+
*/
|
|
1928
|
+
export declare function mechanicsTables(physical: Pick<PhysicalSnapshot, "tables">, attributeCase: AttributeCase): ObjectTable[];
|
|
1929
|
+
/** Фізичне ім'я колонки версії рядка таблиць механіки. */
|
|
1930
|
+
export declare const ROW_VERSION_COLUMN: string;
|
|
1405
1931
|
/** Одна функція авторства на проєкт: тіло не залежить від таблиці. */
|
|
1406
1932
|
export declare const AUTHOR_FUNCTION: QualifiedName;
|
|
1407
1933
|
/**
|
|
@@ -1423,13 +1949,25 @@ export declare function hierarchyNames(table: QualifiedName): {
|
|
|
1423
1949
|
update: string;
|
|
1424
1950
|
fn: QualifiedName;
|
|
1425
1951
|
};
|
|
1426
|
-
|
|
1952
|
+
/**
|
|
1953
|
+
* Імена тригерів стану мови (Р-B2-4). Рядковий — `BEFORE` у групі платформи
|
|
1954
|
+
* перед `simetra_touch`: відмовлений запис не бере версії. Запобіжник
|
|
1955
|
+
* `TRUNCATE` — операторний, тож у групу не входить і лишається на алгоритмі
|
|
1956
|
+
* імен Postgres. Обидва кличуть одну функцію в схемі таблиці з іменем
|
|
1957
|
+
* рядкового тригера.
|
|
1958
|
+
*/
|
|
1959
|
+
export declare function languageStateNames(table: QualifiedName): {
|
|
1960
|
+
row: string;
|
|
1961
|
+
truncate: string;
|
|
1962
|
+
fn: QualifiedName;
|
|
1963
|
+
};
|
|
1964
|
+
type PlatformTriggerFamily = "mechanics" | "author" | "key" | "carriers" | "hierarchy" | "languageState" | "effects" | "rightsGuards" | "rightsSignals" | "storage" | "invitations";
|
|
1427
1965
|
interface PlatformTrigger {
|
|
1428
1966
|
family: PlatformTriggerFamily;
|
|
1429
1967
|
trigger: string;
|
|
1430
1968
|
function: QualifiedName;
|
|
1431
1969
|
/** Генератор одиниці тригера (`SqlUnit.generator`). */
|
|
1432
|
-
generator: "mechanics" | "key" | "carriers" | "effects" | "rightsGuards";
|
|
1970
|
+
generator: "mechanics" | "key" | "carriers" | "effects" | "rightsGuards" | "rightsSignal" | "storage" | "invitations";
|
|
1433
1971
|
/** Тригер оновлення, платформний лише з умовою змісту таблиці. */
|
|
1434
1972
|
contentUpdate: boolean;
|
|
1435
1973
|
}
|
|
@@ -1443,6 +1981,21 @@ export declare const SHARED_TRIGGER_FUNCTIONS: readonly QualifiedName[];
|
|
|
1443
1981
|
* він лише впізнає їх за іменем і функцією.
|
|
1444
1982
|
*/
|
|
1445
1983
|
export declare function platformTriggers(table: QualifiedName): PlatformTrigger[];
|
|
1984
|
+
/**
|
|
1985
|
+
* Шар, що не залежить від моделі, для таблиці: спільні функції механіки,
|
|
1986
|
+
* авторства й ключа з їхніми грантами та тригери цих родин у формі без
|
|
1987
|
+
* `WHEN` змісту (таблиця без копій носіїв). Той самий текст, що кладуть
|
|
1988
|
+
* `build*Units`, — еталон зворотної генерації не має другої копії.
|
|
1989
|
+
* Варіанти з `WHEN` залежать від копій носіїв моделі й сюди не входять.
|
|
1990
|
+
* Чи таблиця має колонки, яких вимагає тригер, вирішує споживач.
|
|
1991
|
+
*/
|
|
1992
|
+
export declare function renderModelIndependentLayer(table: QualifiedName, provider: DatabaseProvider, parse: SqlParser): RenderedUnit[];
|
|
1993
|
+
/**
|
|
1994
|
+
* Спільні функції механіки, авторства й ключа з їхніми грантами: частина
|
|
1995
|
+
* шару, що не залежить ні від моделі, ні від таблиці, — еталон зворотної
|
|
1996
|
+
* генерації бере її й без жодного тригера.
|
|
1997
|
+
*/
|
|
1998
|
+
export declare function renderSharedTriggerFunctions(provider: DatabaseProvider, parse: SqlParser): RenderedUnit[];
|
|
1446
1999
|
/** Одна функція незмінності ключа на проєкт: тіло не залежить від таблиці. */
|
|
1447
2000
|
export declare const KEY_FUNCTION: QualifiedName;
|
|
1448
2001
|
/**
|
|
@@ -1456,45 +2009,13 @@ export declare function keyTriggerNames(table: string): {
|
|
|
1456
2009
|
before: string;
|
|
1457
2010
|
after: string;
|
|
1458
2011
|
};
|
|
1459
|
-
/** Одна функція механіки на всі таблиці: тіло не залежить від таблиці. */
|
|
1460
|
-
export declare const MECHANICS_FUNCTION: QualifiedName;
|
|
1461
|
-
/**
|
|
1462
|
-
* Ім'я тригера механіки на таблиці. Спільний префікс рядкових `BEFORE`-тригерів
|
|
1463
|
-
* ставить механіку останньою на будь-якій довжині назви, а зворотна генерація
|
|
1464
|
-
* й промоція впізнають тригер за тим самим іменем.
|
|
1465
|
-
*/
|
|
1466
|
-
export declare function mechanicsTriggerName(table: string): string;
|
|
1467
|
-
/**
|
|
1468
|
-
* Ім'я тригера механіки на `UPDATE` таблиці з копіями носіїв: там механіка
|
|
1469
|
-
* розділена на вставку й оновлення з умовою `contentChangeCondition`.
|
|
1470
|
-
*/
|
|
1471
|
-
export declare function mechanicsUpdateTriggerName(table: string): string;
|
|
1472
|
-
/** Колонки авторства таблиці — за `origin.standard`, у порядку таблиці. */
|
|
1473
|
-
export declare function authorTableColumns(table: Pick<PhysicalTable, "columns">, attributeCase: AttributeCase): PhysicalColumn[];
|
|
1474
|
-
/**
|
|
1475
|
-
* Умова «змінився зміст рядка» таблиці з копіями носіїв (спека прав §5.2):
|
|
1476
|
-
* `(<зміст змінився>) OR NOT (<копії змінилися>)`. Поширення копій
|
|
1477
|
-
* платформою — не зміна змісту: воно пише лише копії, тож придушується, а
|
|
1478
|
-
* звичайне перезбереження без змін (нічого не змінилося) поводиться, як на
|
|
1479
|
-
* будь-якій таблиці. Умова `BEFORE`-тригера рахується з `NEW` після
|
|
1480
|
-
* попередніх тригерів, але поширення пише лише копії за будь-якого порядку
|
|
1481
|
-
* тригерів, тож результат від порядку імен не залежить. Зміст —
|
|
1482
|
-
* `contentColumns`. Таблиця без копій умови не має.
|
|
1483
|
-
*
|
|
1484
|
-
* `watched` (спека П4 §6.8) — колонки поза змістом, зміна яких теж має спрацювати:
|
|
1485
|
-
* авторство для тригерів механіки, авторства й ефектів. Копія носія може
|
|
1486
|
-
* виводитися з `createdBy`, тож зміна лише `created_by_id` змінює й копію, і
|
|
1487
|
-
* без `watched` умова була б хибною: ефекти не відмовили б незмінному
|
|
1488
|
-
* автору, а механіка не підвищила б версію. Підписки `watched` не беруть.
|
|
1489
|
-
*/
|
|
1490
|
-
export declare function contentChangeCondition(table: Pick<PhysicalTable, "columns">, attributeCase: AttributeCase, watched?: readonly PhysicalColumn[]): string | undefined;
|
|
1491
2012
|
/**
|
|
1492
2013
|
* Мітки рядкових `BEFORE`-тригерів платформи в порядку спрацювання.
|
|
1493
2014
|
* Postgres запускає тригери одного часу за іменем (порівняння байтів), тож
|
|
1494
|
-
* порядок `author → carriers → key → touch` тримається, лише коли всі імена групи
|
|
2015
|
+
* порядок `author → carriers → key → language → touch` тримається, лише коли всі імена групи
|
|
1495
2016
|
* мають один префікс, а мітки сортуються як цей масив.
|
|
1496
2017
|
*/
|
|
1497
|
-
export declare const PLATFORM_BEFORE_ROW_LABELS: readonly ["simetra_author", "simetra_author_update", "simetra_carriers", "simetra_key", "simetra_touch", "simetra_touch_update"];
|
|
2018
|
+
export declare const PLATFORM_BEFORE_ROW_LABELS: readonly ["simetra_author", "simetra_author_update", "simetra_carriers", "simetra_key", "simetra_language", "simetra_touch", "simetra_touch_update"];
|
|
1498
2019
|
type PlatformBeforeRowLabel = (typeof PLATFORM_BEFORE_ROW_LABELS)[number];
|
|
1499
2020
|
/**
|
|
1500
2021
|
* Ім'я рядкового `BEFORE`-тригера платформи. `makeObjectName` обрізав би назву
|
|
@@ -1517,24 +2038,14 @@ export declare function effectsTriggerNames(table: QualifiedName): {
|
|
|
1517
2038
|
/** Функція ефектів у схемі таблиці — одна для обох її тригерів. */
|
|
1518
2039
|
export declare function effectsFunctionName(table: QualifiedName): QualifiedName;
|
|
1519
2040
|
/**
|
|
1520
|
-
*
|
|
1521
|
-
* `
|
|
1522
|
-
*
|
|
1523
|
-
* членство, платформний шар); таблиця — лише таблиця з контрактом доступу,
|
|
1524
|
-
* тобто ціль грантів генератора `access`.
|
|
1525
|
-
*/
|
|
1526
|
-
export declare function platformGrantTargets(units: readonly Pick<SqlUnit, "class" | "name" | "sql" | "file" | "generator">[], parse: SqlParser): Set<string>;
|
|
1527
|
-
/**
|
|
1528
|
-
* Чи ціль гранту — об'єкт платформи. `ON FUNCTION f` без списку аргументів
|
|
1529
|
-
* Postgres резолвить у єдину функцію з цим ім'ям, тож вона збігається з
|
|
1530
|
-
* функцією платформи тієї самої схеми й імені.
|
|
1531
|
-
*/
|
|
1532
|
-
export declare function ownsTarget(owned: ReadonlySet<string>, target: string): boolean;
|
|
1533
|
-
/**
|
|
1534
|
-
* Цілі гранту-функції чи гранту-таблиці; ціль іншого виду (схема, тип,
|
|
1535
|
-
* послідовність) платформі в цьому правилі не належить, тож ключа не має.
|
|
2041
|
+
* Чи функція чи процедура виконується від власника: `SECURITY DEFINER` у
|
|
2042
|
+
* `CREATE` чи в окремому `ALTER FUNCTION` (порядок не моделюється —
|
|
2043
|
+
* fail-closed).
|
|
1536
2044
|
*/
|
|
1537
|
-
export declare function
|
|
2045
|
+
export declare function isSecurityDefiner(unit: VerbatimUnit, units: readonly VerbatimUnit[]): boolean;
|
|
2046
|
+
/** Чи функція — тригерна: її кличе лише тригер. */
|
|
2047
|
+
export declare function isTriggerFunction(unit: VerbatimUnit): boolean;
|
|
2048
|
+
export declare const FUNCTIONS_SCHEMA_FILE = "functions.schema.json";
|
|
1538
2049
|
/**
|
|
1539
2050
|
* Ціль одиниці — об'єкт, на який діє оператор без власного об'єкта в схемі
|
|
1540
2051
|
* (грант, коментар, типові привілеї, членство в publication) чи з об'єктом,
|
|
@@ -1577,11 +2088,19 @@ export declare function unitTargets(unit: TargetUnit, parse: SqlParser): UnitTar
|
|
|
1577
2088
|
* для межі керування й для діагностики межі, одним правилом.
|
|
1578
2089
|
*/
|
|
1579
2090
|
export declare function unitPlacement(unit: TargetUnit, parse: SqlParser): UnitTarget[];
|
|
2091
|
+
/** Функція, яку кличе тригер: у `EXECUTE FUNCTION` чи в умові `WHEN`. */
|
|
2092
|
+
interface TriggerFunctionCall {
|
|
2093
|
+
where: "execute" | "when";
|
|
2094
|
+
schema: string;
|
|
2095
|
+
name: string;
|
|
2096
|
+
}
|
|
1580
2097
|
/**
|
|
1581
|
-
*
|
|
1582
|
-
*
|
|
2098
|
+
* Функції, які кличе тригер, — лише кваліфіковані імена: без схеми функцію
|
|
2099
|
+
* знаходить `search_path` бази чи тригера, тож у межу вона не потрапляє
|
|
2100
|
+
* залежністю схеми. Межу тригера на таблиці провайдера судять усі його
|
|
2101
|
+
* функції-залежності (`providerTriggerInBoundarySql`).
|
|
1583
2102
|
*/
|
|
1584
|
-
export declare function
|
|
2103
|
+
export declare function triggerFunctionCalls(unit: TargetUnit, parse: SqlParser): TriggerFunctionCall[];
|
|
1585
2104
|
/**
|
|
1586
2105
|
* Ключ предмета класу конверсії промоції (спека промоції §8): об'єкт,
|
|
1587
2106
|
* який клас покриває, коли одиниця зникає з бажаного стану. Будується з
|
|
@@ -1736,6 +2255,10 @@ interface ValueSource {
|
|
|
1736
2255
|
interface ElementSource extends ValueSource {
|
|
1737
2256
|
id?: string;
|
|
1738
2257
|
name: string;
|
|
2258
|
+
/** `load` реквізиту з метаданих (Рд25); у колонки `CustomTable` немає. */
|
|
2259
|
+
load?: "eager" | "lazy";
|
|
2260
|
+
/** Явний `maxBytes` реквізиту (Рд26); типове за типом дає `effectiveMaxBytes`. */
|
|
2261
|
+
maxBytes?: number;
|
|
1739
2262
|
}
|
|
1740
2263
|
/** Стандартні колонки (за логічним ім'ям у стилі проєкту) й елементи таблиці. */
|
|
1741
2264
|
interface EntityContext {
|
|
@@ -1765,7 +2288,8 @@ interface EntityField {
|
|
|
1765
2288
|
* скоупу (ім'я поля — ім'я виду), колонка без походження в метаданих — за
|
|
1766
2289
|
* фізичним іменем. Ключ-одинак пропускається: службовий ключ рядка-одинака
|
|
1767
2290
|
* (завжди `true`, значення дає DEFAULT) у скоупленій формі не існує, тож і
|
|
1768
|
-
* поля сутності не дає.
|
|
2291
|
+
* поля сутності не дає. Нормалізована колонка пошуку (`origin.searchOf`) —
|
|
2292
|
+
* теж не поле: її значення — функція поля, і клієнт її не бачить.
|
|
1769
2293
|
*/
|
|
1770
2294
|
export declare function entityFields(model: CompiledModel, table: PhysicalTable, context: EntityContext): EntityField[];
|
|
1771
2295
|
/**
|
|
@@ -1777,6 +2301,17 @@ export declare function entityFields(model: CompiledModel, table: PhysicalTable,
|
|
|
1777
2301
|
* тобто з гранту ролі команд.
|
|
1778
2302
|
*/
|
|
1779
2303
|
export declare function buildRuntimeCatalog(model: CompiledModel): RuntimeCatalog;
|
|
2304
|
+
/**
|
|
2305
|
+
* The kernel contract hash of a catalog entry (P4-B spec Рд12): SHA-256 of
|
|
2306
|
+
* the canonical form of its operations — command functions and contexts.
|
|
2307
|
+
* An entry without operations hashes the empty form.
|
|
2308
|
+
*/
|
|
2309
|
+
export declare function kernelHashOf(operations: RuntimeObject["operations"]): string;
|
|
2310
|
+
/**
|
|
2311
|
+
* The client catalog of a runtime catalog: each entry projected onto the
|
|
2312
|
+
* shared part, in the runtime order (P4-B spec §3).
|
|
2313
|
+
*/
|
|
2314
|
+
export declare function buildClientCatalog(runtime: RuntimeCatalog): ClientCatalog;
|
|
1780
2315
|
/**
|
|
1781
2316
|
* Канонічна JSON-форма за RFC 8785 (JCS). Власна реалізація: примітиви
|
|
1782
2317
|
* серіалізує `JSON.stringify` — це саме ES Number::toString та екранування
|
|
@@ -1822,8 +2357,14 @@ interface FileChange {
|
|
|
1822
2357
|
content: string | null;
|
|
1823
2358
|
}
|
|
1824
2359
|
interface OperationResult {
|
|
1825
|
-
/** Компіляція результату без помилок;
|
|
2360
|
+
/** Компіляція результату без помилок; тоді обгортка пише зміни. */
|
|
1826
2361
|
ok: boolean;
|
|
2362
|
+
/**
|
|
2363
|
+
* Лише в хвості режиму `repair` (спека декларацій функцій §5.1): результат
|
|
2364
|
+
* з помилками лише класу ремонту, жодна з яких не нова, прийнято — `ok`
|
|
2365
|
+
* лишається `false`, а обгортка пише зміни.
|
|
2366
|
+
*/
|
|
2367
|
+
written?: true;
|
|
1827
2368
|
changes: FileChange[];
|
|
1828
2369
|
diagnostics: Diagnostic[];
|
|
1829
2370
|
}
|
|
@@ -1883,6 +2424,13 @@ export declare function sqlDebtText(units: readonly string[], schemaPath: Schema
|
|
|
1883
2424
|
* справа — лагодити саме вхід. `changes` — лише файли зі зміненим текстом.
|
|
1884
2425
|
* Борг рахується над доповненою текою: типи рядків таблиць, від яких
|
|
1885
2426
|
* залежать ідентичності функцій, з'являються лише з id і фізичними іменами.
|
|
2427
|
+
*
|
|
2428
|
+
* Режим ремонту (спека декларацій функцій §5.6, Р2): після механічного
|
|
2429
|
+
* доповнення (і `id` записам `.functions.json`) `fix` лагодить клас ремонту —
|
|
2430
|
+
* (г) декларація функції, що стала формою платформи, (д) вирізання ADP на
|
|
2431
|
+
* функції, (в) запобіжник виклику з `check`. Результат з помилками класу
|
|
2432
|
+
* ремонту несе `written`, якщо не додав нових, прибрав хоча б одну й не має
|
|
2433
|
+
* помилок поза класом.
|
|
1886
2434
|
*/
|
|
1887
2435
|
export declare function fixFiles(files: ReadonlyMap<string, string>, o: CompletionOptions): Promise<OperationResult>;
|
|
1888
2436
|
/**
|
|
@@ -1976,6 +2524,27 @@ export declare const addElementInput: z.ZodObject<{
|
|
|
1976
2524
|
}, z.core.$strict>], "kind">;
|
|
1977
2525
|
collection: z.ZodString;
|
|
1978
2526
|
element: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
2527
|
+
scopes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
2528
|
+
scope: z.ZodString;
|
|
2529
|
+
scopeColumn: z.ZodOptional<z.ZodString>;
|
|
2530
|
+
}, z.core.$strict>>>;
|
|
2531
|
+
objects: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
2532
|
+
kind: z.ZodEnum<{
|
|
2533
|
+
Catalog: "Catalog";
|
|
2534
|
+
Document: "Document";
|
|
2535
|
+
Enumeration: "Enumeration";
|
|
2536
|
+
InformationRegister: "InformationRegister";
|
|
2537
|
+
AccumulationRegister: "AccumulationRegister";
|
|
2538
|
+
Constant: "Constant";
|
|
2539
|
+
CustomTable: "CustomTable";
|
|
2540
|
+
PgEnum: "PgEnum";
|
|
2541
|
+
EventSubscription: "EventSubscription";
|
|
2542
|
+
RightsSet: "RightsSet";
|
|
2543
|
+
Role: "Role";
|
|
2544
|
+
}>;
|
|
2545
|
+
name: z.ZodString;
|
|
2546
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2547
|
+
}, z.core.$strict>>>;
|
|
1979
2548
|
}, z.core.$strict>;
|
|
1980
2549
|
type AddElementInput = z.infer<typeof addElementInput>;
|
|
1981
2550
|
export declare const renameInput: z.ZodObject<{
|
|
@@ -2031,10 +2600,10 @@ type DeleteInput = z.infer<typeof deleteInput>;
|
|
|
2031
2600
|
* файлів.
|
|
2032
2601
|
*/
|
|
2033
2602
|
export declare const conversionClass: z.ZodEnum<{
|
|
2603
|
+
metadata: "metadata";
|
|
2034
2604
|
platform: "platform";
|
|
2035
2605
|
property: "property";
|
|
2036
2606
|
rowRule: "rowRule";
|
|
2037
|
-
metadata: "metadata";
|
|
2038
2607
|
applicationCode: "applicationCode";
|
|
2039
2608
|
removed: "removed";
|
|
2040
2609
|
}>;
|
|
@@ -2061,8 +2630,8 @@ export declare const promoteInput: z.ZodObject<{
|
|
|
2061
2630
|
to: z.ZodLiteral<"attribute">;
|
|
2062
2631
|
collection: z.ZodDefault<z.ZodEnum<{
|
|
2063
2632
|
attributes: "attributes";
|
|
2064
|
-
dimensions: "dimensions";
|
|
2065
2633
|
resources: "resources";
|
|
2634
|
+
dimensions: "dimensions";
|
|
2066
2635
|
}>>;
|
|
2067
2636
|
element: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
2068
2637
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -2081,8 +2650,8 @@ export declare const promoteInput: z.ZodObject<{
|
|
|
2081
2650
|
to: z.ZodLiteral<"attribute">;
|
|
2082
2651
|
collection: z.ZodDefault<z.ZodEnum<{
|
|
2083
2652
|
attributes: "attributes";
|
|
2084
|
-
dimensions: "dimensions";
|
|
2085
2653
|
resources: "resources";
|
|
2654
|
+
dimensions: "dimensions";
|
|
2086
2655
|
}>>;
|
|
2087
2656
|
element: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
2088
2657
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -2101,10 +2670,10 @@ export declare const promoteInput: z.ZodObject<{
|
|
|
2101
2670
|
expression: z.ZodString;
|
|
2102
2671
|
}, z.core.$strict>>>;
|
|
2103
2672
|
conversions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
2673
|
+
metadata: "metadata";
|
|
2104
2674
|
platform: "platform";
|
|
2105
2675
|
property: "property";
|
|
2106
2676
|
rowRule: "rowRule";
|
|
2107
|
-
metadata: "metadata";
|
|
2108
2677
|
applicationCode: "applicationCode";
|
|
2109
2678
|
removed: "removed";
|
|
2110
2679
|
}>>>;
|
|
@@ -2112,6 +2681,45 @@ export declare const promoteInput: z.ZodObject<{
|
|
|
2112
2681
|
consumerLabels: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
2113
2682
|
}, z.core.$strict>;
|
|
2114
2683
|
type PromoteInput = z.infer<typeof promoteInput>;
|
|
2684
|
+
/**
|
|
2685
|
+
* Запис декларації функції без `id`: його видає операція, а наявний зберігає.
|
|
2686
|
+
* Схема — із T0 (єдине джерело форми запису), тож нове поле запису стає
|
|
2687
|
+
* доступним без змін тут.
|
|
2688
|
+
*/
|
|
2689
|
+
export declare const declareFunctionInput: z.ZodObject<{
|
|
2690
|
+
function: z.ZodObject<{
|
|
2691
|
+
schema: z.ZodOptional<z.ZodString>;
|
|
2692
|
+
name: z.ZodString;
|
|
2693
|
+
}, z.core.$strict>;
|
|
2694
|
+
check: z.ZodOptional<z.ZodObject<{
|
|
2695
|
+
action: z.ZodString;
|
|
2696
|
+
object: z.ZodObject<{
|
|
2697
|
+
kind: z.ZodEnum<{
|
|
2698
|
+
Catalog: "Catalog";
|
|
2699
|
+
Document: "Document";
|
|
2700
|
+
Enumeration: "Enumeration";
|
|
2701
|
+
InformationRegister: "InformationRegister";
|
|
2702
|
+
AccumulationRegister: "AccumulationRegister";
|
|
2703
|
+
Constant: "Constant";
|
|
2704
|
+
CustomTable: "CustomTable";
|
|
2705
|
+
PgEnum: "PgEnum";
|
|
2706
|
+
EventSubscription: "EventSubscription";
|
|
2707
|
+
RightsSet: "RightsSet";
|
|
2708
|
+
Role: "Role";
|
|
2709
|
+
}>;
|
|
2710
|
+
name: z.ZodString;
|
|
2711
|
+
}, z.core.$strict>;
|
|
2712
|
+
row: z.ZodOptional<z.ZodString>;
|
|
2713
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
2714
|
+
}, z.core.$strict>>;
|
|
2715
|
+
callers: z.ZodArray<z.ZodEnum<{
|
|
2716
|
+
user: "user";
|
|
2717
|
+
anonymous: "anonymous";
|
|
2718
|
+
service: "service";
|
|
2719
|
+
command: "command";
|
|
2720
|
+
}>>;
|
|
2721
|
+
}, z.core.$strict>;
|
|
2722
|
+
type DeclareFunctionInput = z.infer<typeof declareFunctionInput>;
|
|
2115
2723
|
/**
|
|
2116
2724
|
* Створює об'єкт (спека П2 §8.6): файл `<тека виду>/<Name>/<Name>.meta.json`
|
|
2117
2725
|
* з `kind`, `name` і полями `data`; id, `physicalName`, `$schema` і канонічну
|
|
@@ -2125,6 +2733,18 @@ export declare function createObject(files: ReadonlyMap<string, string>, input:
|
|
|
2125
2733
|
* контейнера, тож нова колекція схеми стає доступною без змін тут.
|
|
2126
2734
|
*/
|
|
2127
2735
|
export declare function addElement(files: ReadonlyMap<string, string>, input: AddElementInput, o: CompletionOptions): Promise<OperationResult>;
|
|
2736
|
+
/**
|
|
2737
|
+
* Створює чи замінює запис декларації однієї функції в `<основа>.functions.json`
|
|
2738
|
+
* поруч із `.sql`, що її створює (спека декларацій функцій §5.6, Р1): повна
|
|
2739
|
+
* заміна `callers` і `check`, `id` наявного зберігається, новому його
|
|
2740
|
+
* видає операція. Режим `repair`, як у `addElement`: тека з помилками класу
|
|
2741
|
+
* ремонту приймається, а хвіст не дає додати нову — крім самої цілі, яка може
|
|
2742
|
+
* перейти в `check-not-applied` з причиною `firstStatement`, коли `fix`
|
|
2743
|
+
* гарантовано вставить запобіжник (`guardInsertionPoint`): інакше ланцюжок
|
|
2744
|
+
* `declare-function` → `fix` неможливий, бо недекларована функція, ставши
|
|
2745
|
+
* задекларованою, дістає новий ключ помилки.
|
|
2746
|
+
*/
|
|
2747
|
+
export declare function declareFunction(files: ReadonlyMap<string, string>, input: DeclareFunctionInput, o: CompletionOptions): Promise<OperationResult>;
|
|
2128
2748
|
/**
|
|
2129
2749
|
* Перейменовує об'єкт чи вкладений іменований елемент (спека П2 §3, §8.6):
|
|
2130
2750
|
* поле `name` цілі плюс каскад — кожне посилання індексу з id цілі. Id і
|
|
@@ -2474,7 +3094,7 @@ interface Explanation {
|
|
|
2474
3094
|
tables: {
|
|
2475
3095
|
schema: string;
|
|
2476
3096
|
name: string;
|
|
2477
|
-
part?: "main" | "tabularSection" |
|
|
3097
|
+
part?: "main" | "tabularSection" | ObjectOrigin["part"];
|
|
2478
3098
|
columns: {
|
|
2479
3099
|
name: string;
|
|
2480
3100
|
type: string;
|
|
@@ -2529,4 +3149,31 @@ export declare function explainObject(model: CompiledModel, target: {
|
|
|
2529
3149
|
kind: MetadataKind;
|
|
2530
3150
|
name: string;
|
|
2531
3151
|
}): Explanation | undefined;
|
|
2532
|
-
|
|
3152
|
+
/** Explanation of one SQL function; see `explainFunction`. */
|
|
3153
|
+
interface FunctionExplanation {
|
|
3154
|
+
function: {
|
|
3155
|
+
schema: string;
|
|
3156
|
+
name: string;
|
|
3157
|
+
};
|
|
3158
|
+
/** Declared callers; absent when the function is not declared (verbatim grants are not guessed). */
|
|
3159
|
+
callers?: string[];
|
|
3160
|
+
/** Profile roles that get the derived EXECUTE, per provider (a platform form wins over the declared callers). */
|
|
3161
|
+
roles?: Record<DatabaseProvider, {
|
|
3162
|
+
caller: string;
|
|
3163
|
+
role: string;
|
|
3164
|
+
}[]>;
|
|
3165
|
+
/** The declared check in words. */
|
|
3166
|
+
check?: string;
|
|
3167
|
+
/** Whether the body applies the declared check; `none` when no check is declared; a platform form names its form. */
|
|
3168
|
+
state: "applied" | `not-applied (${string})` | `platform-form (${PlatformForm})` | "none";
|
|
3169
|
+
}
|
|
3170
|
+
/**
|
|
3171
|
+
* Explains a function by `schema.name` from the compile result (not the
|
|
3172
|
+
* model: it holds no declarations). `undefined` when the folder has no such
|
|
3173
|
+
* function.
|
|
3174
|
+
*/
|
|
3175
|
+
export declare function explainFunction(compiled: Pick<CompileResult, "model" | "declaredFunctions" | "functionExecute">, target: {
|
|
3176
|
+
schema: string;
|
|
3177
|
+
name: string;
|
|
3178
|
+
}): FunctionExplanation | undefined;
|
|
3179
|
+
export type { AddElementInput, AssignmentSourceContract, CarrierBackfillStatement, CompileOptions, CompileResult, CompiledModel, CompiledScopeKind, CompilerRule, CompletionOptions, Constraint, ContainerTarget, Contracts, ConversionClass, CreateObjectInput, CreationNode, DeclareFunctionInput, DeleteInput, DerivedFacts, Diagnostic, DiagnosticParams, ElementSource, ElementTarget, EntityContext, EntityField, Explanation, FieldDifference, FileChange, FunctionExplanation, GrantFact, GuardArgs, IdSource, IndexElem, IndexStmt, KindKey, Locale, MembershipSourceContract, MessageEntry, ModelFunctions, Node, OperationResult, OutOfScopeReason, PlatformBeforeRowLabel, PlatformInstall, PlatformRecogniser, PlatformReference, PlatformTrigger, PlatformTriggerFamily, PlpgsqlParser, Position, PostingContract, PredefinedSeedContract, Presentation, PresentationBlock, PromoteInput, PromoteResult, PromotionFacts, PromotionMapping, PromotionObject, PromotionRecord, QualifiedName, Range, RangeVar, RecognisedUnit, RegisterContract, RenameInput, ResolvedReference, ResolvedTarget, ResourceMeasure, RightsLevelKey, RuleCode, SchemaPathResolver, Severity, SourceObject, SqlParser, SqlSource, SqlUnit, UniqueShape, UnitSubjectKey, UnitTarget, VerbatimUnit, VirtualTableColumn, VirtualTableContract };
|