@intentius/chant-lexicon-sql 0.116.0 → 0.118.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clickhouse/access.d.ts +132 -0
- package/dist/clickhouse/access.d.ts.map +1 -0
- package/dist/clickhouse/apply/apply.d.ts.map +1 -1
- package/dist/clickhouse/apply/statements.d.ts +2 -0
- package/dist/clickhouse/apply/statements.d.ts.map +1 -1
- package/dist/clickhouse/entities.d.ts +171 -2
- package/dist/clickhouse/entities.d.ts.map +1 -1
- package/dist/clickhouse/http.d.ts +3 -0
- package/dist/clickhouse/http.d.ts.map +1 -1
- package/dist/clickhouse/import/generator.d.ts +28 -0
- package/dist/clickhouse/import/generator.d.ts.map +1 -1
- package/dist/clickhouse/import/ir.d.ts.map +1 -1
- package/dist/clickhouse/import/parser.d.ts +3 -3
- package/dist/clickhouse/import/parser.d.ts.map +1 -1
- package/dist/clickhouse/live/bind.d.ts.map +1 -1
- package/dist/clickhouse/live/catalog.d.ts +41 -6
- package/dist/clickhouse/live/catalog.d.ts.map +1 -1
- package/dist/clickhouse/live/describe-resources.d.ts +3 -2
- package/dist/clickhouse/live/describe-resources.d.ts.map +1 -1
- package/dist/clickhouse/parser.d.ts +54 -3
- package/dist/clickhouse/parser.d.ts.map +1 -1
- package/dist/clickhouse/plan/commands.d.ts +3 -1
- package/dist/clickhouse/plan/commands.d.ts.map +1 -1
- package/dist/clickhouse/plan/deep.d.ts.map +1 -1
- package/dist/clickhouse/plan/diff.d.ts +12 -0
- package/dist/clickhouse/plan/diff.d.ts.map +1 -1
- package/dist/clickhouse/plan/normalize.d.ts +61 -1
- package/dist/clickhouse/plan/normalize.d.ts.map +1 -1
- package/dist/clickhouse/plan/report.d.ts.map +1 -1
- package/dist/clickhouse/plan/rules.d.ts +7 -0
- package/dist/clickhouse/plan/rules.d.ts.map +1 -1
- package/dist/clickhouse/plan/schema.d.ts +8 -4
- package/dist/clickhouse/plan/schema.d.ts.map +1 -1
- package/dist/clickhouse/rebuild/backfill.d.ts +3 -1
- package/dist/clickhouse/rebuild/backfill.d.ts.map +1 -1
- package/dist/clickhouse/rebuild/observe.d.ts +7 -3
- package/dist/clickhouse/rebuild/observe.d.ts.map +1 -1
- package/dist/clickhouse/rebuild/op.d.ts +8 -0
- package/dist/clickhouse/rebuild/op.d.ts.map +1 -1
- package/dist/clickhouse/rebuild/steps.d.ts +48 -0
- package/dist/clickhouse/rebuild/steps.d.ts.map +1 -1
- package/dist/clickhouse/testing/fake-server.d.ts.map +1 -1
- package/dist/clickhouse/testing/writable-server.d.ts.map +1 -1
- package/dist/clickhouse/topology.d.ts.map +1 -1
- package/dist/clickhouse.d.ts +1 -1
- package/dist/clickhouse.d.ts.map +1 -1
- package/dist/codegen/classifier-page.d.ts.map +1 -1
- package/dist/codegen/registry.d.ts.map +1 -1
- package/dist/config.d.ts +70 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/core/references.d.ts +4 -2
- package/dist/core/references.d.ts.map +1 -1
- package/dist/core/statements.d.ts +11 -0
- package/dist/core/statements.d.ts.map +1 -1
- package/dist/files/build-root.d.ts +26 -0
- package/dist/files/build-root.d.ts.map +1 -0
- package/dist/files/clickhouse.d.ts +19 -0
- package/dist/files/clickhouse.d.ts.map +1 -0
- package/dist/files/common.d.ts +25 -0
- package/dist/files/common.d.ts.map +1 -0
- package/dist/files/postgres.d.ts +36 -0
- package/dist/files/postgres.d.ts.map +1 -0
- package/dist/import-parser.d.ts +25 -0
- package/dist/import-parser.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/integrity.json +8 -8
- package/dist/lint/rules/sqlch001.d.ts +1 -1
- package/dist/lint/rules/sqlch001.d.ts.map +1 -1
- package/dist/lint/rules/sqlch002.d.ts.map +1 -1
- package/dist/lint/rules/sqlpg001.d.ts.map +1 -1
- package/dist/lint/rules/templates.d.ts +1 -1
- package/dist/lint/rules/templates.d.ts.map +1 -1
- package/dist/lsp/postgres-template.d.ts.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/meta.json +50 -0
- package/dist/okf/index.md +11 -1
- package/dist/okf/rules/SQLCH001.md +2 -2
- package/dist/okf/types/Dictionary.md +9 -0
- package/dist/okf/types/Function.md +9 -0
- package/dist/okf/types/Grant.md +9 -0
- package/dist/okf/types/PostgresDefaultPrivileges.md +9 -0
- package/dist/okf/types/PostgresGrant.md +9 -0
- package/dist/okf/types/PostgresPolicy.md +9 -0
- package/dist/okf/types/PostgresRole.md +9 -0
- package/dist/okf/types/Role.md +9 -0
- package/dist/okf/types/RowPolicy.md +9 -0
- package/dist/okf/types/User.md +9 -0
- package/dist/op/activities/clickhouse-rebuild.d.ts.map +1 -1
- package/dist/op/activities/postgres-migration.d.ts.map +1 -1
- package/dist/op/activity-contracts.d.ts +19 -0
- package/dist/op/activity-contracts.d.ts.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/postgres/access/acl.d.ts +119 -0
- package/dist/postgres/access/acl.d.ts.map +1 -0
- package/dist/postgres/access/import.d.ts +13 -0
- package/dist/postgres/access/import.d.ts.map +1 -0
- package/dist/postgres/access/live.d.ts +24 -0
- package/dist/postgres/access/live.d.ts.map +1 -0
- package/dist/postgres/apply/apply.d.ts.map +1 -1
- package/dist/postgres/apply/statements.d.ts +71 -0
- package/dist/postgres/apply/statements.d.ts.map +1 -1
- package/dist/postgres/entities.d.ts +106 -4
- package/dist/postgres/entities.d.ts.map +1 -1
- package/dist/postgres/entity-types.d.ts +4 -0
- package/dist/postgres/entity-types.d.ts.map +1 -1
- package/dist/postgres/import/generator.d.ts +37 -1
- package/dist/postgres/import/generator.d.ts.map +1 -1
- package/dist/postgres/import/live-export.d.ts +6 -0
- package/dist/postgres/import/live-export.d.ts.map +1 -1
- package/dist/postgres/live/bind.d.ts +2 -0
- package/dist/postgres/live/bind.d.ts.map +1 -1
- package/dist/postgres/live/catalog.d.ts +11 -2
- package/dist/postgres/live/catalog.d.ts.map +1 -1
- package/dist/postgres/live/client.d.ts +3 -0
- package/dist/postgres/live/client.d.ts.map +1 -1
- package/dist/postgres/live/describe-resources.d.ts +9 -0
- package/dist/postgres/live/describe-resources.d.ts.map +1 -1
- package/dist/postgres/migrate/op.d.ts +29 -0
- package/dist/postgres/migrate/op.d.ts.map +1 -1
- package/dist/postgres/parser.d.ts +76 -3
- package/dist/postgres/parser.d.ts.map +1 -1
- package/dist/postgres/plan/commands.d.ts +12 -0
- package/dist/postgres/plan/commands.d.ts.map +1 -1
- package/dist/postgres/plan/deep.d.ts.map +1 -1
- package/dist/postgres/plan/diff.d.ts +10 -1
- package/dist/postgres/plan/diff.d.ts.map +1 -1
- package/dist/postgres/plan/normalize.d.ts +8 -1
- package/dist/postgres/plan/normalize.d.ts.map +1 -1
- package/dist/postgres/plan/rules.d.ts +8 -0
- package/dist/postgres/plan/rules.d.ts.map +1 -1
- package/dist/postgres/plan/schema.d.ts +2 -1
- package/dist/postgres/plan/schema.d.ts.map +1 -1
- package/dist/postgres/plan/server-normalize.d.ts +4 -1
- package/dist/postgres/plan/server-normalize.d.ts.map +1 -1
- package/dist/postgres.d.ts +1 -1
- package/dist/postgres.d.ts.map +1 -1
- package/dist/rules/postgres-templates.ts +2 -2
- package/dist/rules/sqlch001.ts +26 -4
- package/dist/rules/sqlch002.ts +3 -2
- package/dist/rules/sqlpg001.ts +7 -4
- package/dist/rules/templates.ts +2 -2
- package/dist/serializer.d.ts +2 -1
- package/dist/serializer.d.ts.map +1 -1
- package/dist/sql-files.d.ts +79 -0
- package/dist/sql-files.d.ts.map +1 -0
- package/dist/token-source.d.ts +88 -0
- package/dist/token-source.d.ts.map +1 -0
- package/dist/validate.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/clickhouse/access.test.ts +203 -0
- package/src/clickhouse/access.ts +595 -0
- package/src/clickhouse/apply/apply.ts +29 -20
- package/src/clickhouse/apply/statements.ts +105 -8
- package/src/clickhouse/dictionary.test.ts +177 -0
- package/src/clickhouse/entities.ts +356 -6
- package/src/clickhouse/function.test.ts +91 -0
- package/src/clickhouse/http.ts +11 -2
- package/src/clickhouse/import/generator.ts +81 -46
- package/src/clickhouse/import/import.test.ts +9 -3
- package/src/clickhouse/import/ir.ts +6 -2
- package/src/clickhouse/import/parser.ts +10 -18
- package/src/clickhouse/live/access.e2e.test.ts +218 -0
- package/src/clickhouse/live/bind.ts +17 -6
- package/src/clickhouse/live/catalog.ts +106 -10
- package/src/clickhouse/live/describe-resources.ts +23 -10
- package/src/clickhouse/live/dictionaries.e2e.test.ts +186 -0
- package/src/clickhouse/live/functions.e2e.test.ts +155 -0
- package/src/clickhouse/live/live.test.ts +2 -2
- package/src/clickhouse/parser.ts +136 -4
- package/src/clickhouse/plan/commands.ts +18 -7
- package/src/clickhouse/plan/deep.ts +71 -11
- package/src/clickhouse/plan/diff.ts +65 -2
- package/src/clickhouse/plan/normalize.ts +200 -6
- package/src/clickhouse/plan/report.ts +14 -3
- package/src/clickhouse/plan/rules.ts +44 -1
- package/src/clickhouse/plan/schema.ts +40 -17
- package/src/clickhouse/plan/server-format.ts +1 -1
- package/src/clickhouse/rebuild/backfill.ts +5 -25
- package/src/clickhouse/rebuild/observe.ts +7 -3
- package/src/clickhouse/rebuild/op.ts +9 -0
- package/src/clickhouse/rebuild/rebuild.e2e.test.ts +62 -0
- package/src/clickhouse/rebuild/rebuild.test.ts +54 -0
- package/src/clickhouse/rebuild/steps.ts +136 -1
- package/src/clickhouse/testing/fake-server.ts +2 -0
- package/src/clickhouse/testing/writable-server.ts +2 -0
- package/src/clickhouse/topology.ts +17 -2
- package/src/clickhouse.ts +19 -0
- package/src/codegen/classifier-page.ts +2 -0
- package/src/codegen/registry.ts +10 -0
- package/src/config.ts +22 -3
- package/src/core/references.ts +5 -3
- package/src/core/statements.ts +11 -1
- package/src/files/build-root.ts +62 -0
- package/src/files/clickhouse.ts +52 -0
- package/src/files/common.ts +54 -0
- package/src/files/postgres.ts +371 -0
- package/src/generated/lexicon-sql.json +50 -0
- package/src/import-parser.ts +61 -0
- package/src/index.ts +14 -1
- package/src/lint/rules/postgres-templates.ts +2 -2
- package/src/lint/rules/sqlch001.ts +26 -4
- package/src/lint/rules/sqlch002.ts +3 -2
- package/src/lint/rules/sqlpg001.ts +7 -4
- package/src/lint/rules/templates.ts +2 -2
- package/src/lsp/postgres-template.ts +2 -0
- package/src/lsp/template.ts +3 -3
- package/src/mcp/index.ts +6 -6
- package/src/mcp/postgres.ts +1 -1
- package/src/migration-statements.test.ts +25 -0
- package/src/migration-statements.ts +8 -0
- package/src/op/activities/clickhouse-rebuild.ts +1 -0
- package/src/op/activities/postgres-migration.ts +27 -2
- package/src/op/activity-contracts.ts +2 -0
- package/src/plugin.ts +29 -5
- package/src/postgres/access/access.e2e.test.ts +191 -0
- package/src/postgres/access/access.test.ts +147 -0
- package/src/postgres/access/acl.ts +400 -0
- package/src/postgres/access/import.ts +64 -0
- package/src/postgres/access/live.ts +123 -0
- package/src/postgres/apply/apply.ts +117 -4
- package/src/postgres/apply/constraint-sequences.e2e.test.ts +179 -0
- package/src/postgres/apply/safe-sequences.e2e.test.ts +176 -0
- package/src/postgres/apply/statements.test.ts +138 -6
- package/src/postgres/apply/statements.ts +210 -18
- package/src/postgres/entities.ts +287 -11
- package/src/postgres/entity-types.ts +4 -0
- package/src/postgres/import/generator.ts +129 -46
- package/src/postgres/import/live-export.ts +12 -2
- package/src/postgres/live/bind.ts +20 -6
- package/src/postgres/live/catalog.ts +79 -3
- package/src/postgres/live/client.ts +10 -2
- package/src/postgres/live/describe-resources.ts +27 -3
- package/src/postgres/migrate/migrate.test.ts +24 -1
- package/src/postgres/migrate/op.ts +80 -35
- package/src/postgres/migrate/outer.e2e.test.ts +163 -0
- package/src/postgres/parser.ts +247 -8
- package/src/postgres/plan/commands.ts +60 -7
- package/src/postgres/plan/deep.ts +24 -3
- package/src/postgres/plan/diff.ts +71 -6
- package/src/postgres/plan/normalize.ts +115 -2
- package/src/postgres/plan/plan.test.ts +2 -2
- package/src/postgres/plan/rules.ts +49 -5
- package/src/postgres/plan/schema.ts +4 -2
- package/src/postgres/plan/server-normalize.ts +29 -1
- package/src/postgres.ts +11 -0
- package/src/serializer.ts +14 -9
- package/src/skill-defs.ts +1 -1
- package/src/skills/chant-sql-postgres-migration.md +3 -1
- package/src/skills/chant-sql-postgres-plan.md +3 -3
- package/src/skills/chant-sql-postgres.md +9 -2
- package/src/skills/chant-sql-rebuild.md +3 -2
- package/src/skills/chant-sql.md +7 -1
- package/src/sql-files.test.ts +188 -0
- package/src/sql-files.ts +218 -0
- package/src/token-source.e2e.test.ts +142 -0
- package/src/token-source.test.ts +119 -0
- package/src/token-source.ts +189 -0
- package/src/validate.ts +10 -0
|
@@ -43,6 +43,8 @@ export interface PgServerPlan {
|
|
|
43
43
|
diff: PgSchemaDiff;
|
|
44
44
|
/** The major the changes were classified for: the server's, else the one asked for. */
|
|
45
45
|
major?: number;
|
|
46
|
+
/** The schemas the read was limited to; undefined is every schema. */
|
|
47
|
+
scope?: string[];
|
|
46
48
|
}
|
|
47
49
|
/**
|
|
48
50
|
* The declared objects (a build's, keyed by export name) against what a
|
|
@@ -56,6 +58,16 @@ export declare function planAgainstClient(client: PostgresClient, target: Postgr
|
|
|
56
58
|
readLive?: typeof readLiveSchema;
|
|
57
59
|
serverNormalize?: typeof serverNormalized;
|
|
58
60
|
}): Promise<PgServerPlan>;
|
|
61
|
+
/**
|
|
62
|
+
* The declarations a plan compares: all of them where the profile manages
|
|
63
|
+
* access; otherwise none of the policies, roles, grants and default
|
|
64
|
+
* privileges, and no table's row-level security, so a project that manages
|
|
65
|
+
* access elsewhere is not affected. `unmanaged` counts what was left out.
|
|
66
|
+
*/
|
|
67
|
+
export declare function accessScoped(objects: readonly PgSchemaObject[], managed: boolean): {
|
|
68
|
+
kept: PgSchemaObject[];
|
|
69
|
+
unmanaged: number;
|
|
70
|
+
};
|
|
59
71
|
/** The declared objects against the server, keys by qualified name and labels with the export name. */
|
|
60
72
|
export declare function planPgAgainstServer(environment: string, buildFile: string, options?: Omit<BindOptions, "environment">): Promise<PgSchemaDiff>;
|
|
61
73
|
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAA+B,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAClG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAqB,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEvF,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE1D,OAAO,EAAmF,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAChI,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAA+B,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAClG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAqB,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEvF,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE1D,OAAO,EAAmF,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAChI,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAQtD,wBAAgB,MAAM,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAG/E;AAED,gGAAgG;AAChG,wBAAsB,YAAY,CAAC,OAAO,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AE,SAAS,cAAc,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG;IAAE,IAAI,EAAE,cAAc,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAgBhI;AAED,uGAAuG;AACvG,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,WAAW,EAAE,aAAa,CAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAYvJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/deep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAmB,KAAK,qBAAqB,EAAgC,MAAM,mCAAmC,CAAC;AAE9H,OAAO,EAAyC,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AACvF,OAAO,EAA2B,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI7E,OAAO,EAAkD,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIrG,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"deep.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/deep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAmB,KAAK,qBAAqB,EAAgC,MAAM,mCAAmC,CAAC;AAE9H,OAAO,EAAyC,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AACvF,OAAO,EAA2B,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI7E,OAAO,EAAkD,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIrG,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAqBrC,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,CAAC,EAAE,YAAY,GAAG,KAAK,CAGhD;AA+ED,uGAAuG;AACvG,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,GAAG,KAAK,CAmDpH;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE;IACP,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CAC/E,GAAG,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,GACnC,OAAO,CAAC,qBAAqB,CAAC,CA0DhC"}
|
|
@@ -16,11 +16,18 @@ import { type ChangeSet, type ClassifiedChange } from "../../core/classifier.js"
|
|
|
16
16
|
import { matchByIdentity } from "../../core/diff.js";
|
|
17
17
|
import { type PgChangeClass, type PgClassifierRuleId } from "./rules.js";
|
|
18
18
|
import { type CanonicalConstraint } from "./normalize.js";
|
|
19
|
+
import { type AccessChange } from "../access/acl.js";
|
|
19
20
|
import { type PgDiffObject, type PgSchemaObject } from "./schema.js";
|
|
20
21
|
import type { PostgresMigrationOpSuggestion } from "../migrate/handoff.js";
|
|
21
22
|
/** What the diff needs to know beyond the two schemas: the server's major (`sql.postgresMajor`, else the newest pinned). */
|
|
22
23
|
export interface PgDiffOptions {
|
|
23
24
|
major?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to compare the access the two sides declare (grants, revokes,
|
|
27
|
+
* default privileges). On by default, for a diff between two builds; a plan
|
|
28
|
+
* against a server compares the server's access itself (`./commands.ts`).
|
|
29
|
+
*/
|
|
30
|
+
access?: boolean;
|
|
24
31
|
}
|
|
25
32
|
export type PgChange = ClassifiedChange<PgClassifierRuleId, PgChangeClass>;
|
|
26
33
|
export interface PgSchemaDiff extends ChangeSet<PgChange> {
|
|
@@ -28,6 +35,8 @@ export interface PgSchemaDiff extends ChangeSet<PgChange> {
|
|
|
28
35
|
refused: PgChange[];
|
|
29
36
|
/** The `PostgresMigrationOp` to run for each refused column rename or type change (#3281). */
|
|
30
37
|
migrationOps?: PostgresMigrationOpSuggestion[];
|
|
38
|
+
/** The access changes among `changes`, each with its GRANT, REVOKE or ALTER DEFAULT PRIVILEGES statements (#3681). */
|
|
39
|
+
access?: AccessChange[];
|
|
31
40
|
}
|
|
32
41
|
/** The rule adding a constraint falls under. */
|
|
33
42
|
export declare function addConstraintRule(c: CanonicalConstraint): PgClassifierRuleId;
|
|
@@ -41,5 +50,5 @@ export declare function addConstraintRule(c: CanonicalConstraint): PgClassifierR
|
|
|
41
50
|
* (`../apply/`) match the same way.
|
|
42
51
|
*/
|
|
43
52
|
export declare function matchPgObjects(before: readonly PgSchemaObject[], after: readonly PgSchemaObject[]): ReturnType<typeof matchByIdentity<PgDiffObject>>;
|
|
44
|
-
export declare function diffPgSchemas(
|
|
53
|
+
export declare function diffPgSchemas(beforeAll: readonly PgSchemaObject[], afterAll: readonly PgSchemaObject[], options?: PgDiffOptions): PgSchemaDiff;
|
|
45
54
|
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAoB,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAuB,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/diff.ts"],"names":[],"mappings":"AAAA;;;;;;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AE,EAAE,QAAQ,EAAE,SAAS,cAAc,EAAE,EAAE,OAAO,GAAE,aAAkB,GAAG,YAAY,CAqClJ"}
|
|
@@ -85,7 +85,11 @@ export interface CanonicalConstraint {
|
|
|
85
85
|
notValid?: boolean;
|
|
86
86
|
comment?: string;
|
|
87
87
|
}
|
|
88
|
-
export type CanonicalKind = "schema" | "table" | "index" | "view" | "materializedView" | "sequence" | "enum" | "domain" | "extension" | "function" | "procedure" | "trigger";
|
|
88
|
+
export type CanonicalKind = "schema" | "table" | "index" | "view" | "materializedView" | "sequence" | "enum" | "domain" | "extension" | "function" | "procedure" | "trigger" | "policy" | "role" | "grant" | "defaultPrivileges";
|
|
89
|
+
/** The kinds whose declarations are privileges, compared as the access they add up to (`../access/`), not one by one. */
|
|
90
|
+
export declare const ACCESS_KINDS: ReadonlySet<CanonicalKind>;
|
|
91
|
+
/** The kinds a profile manages only when it says so (`sql.profiles.<env>.access`). */
|
|
92
|
+
export declare const ACCESS_MANAGED_KINDS: ReadonlySet<CanonicalKind>;
|
|
89
93
|
export interface CanonicalPgObject {
|
|
90
94
|
kind: CanonicalKind;
|
|
91
95
|
schema?: string;
|
|
@@ -115,6 +119,9 @@ export declare function canonicalSequenceOptions(o: {
|
|
|
115
119
|
export declare function canonicalArgType(text: string, defaultSchema: string): string;
|
|
116
120
|
/** A routine's identity among its overloads: its input parameter types, `(integer,text)`. */
|
|
117
121
|
export declare function routineSignature(p: Pick<RoutineProps, "args">, defaultSchema: string): string;
|
|
122
|
+
/** A routine named with its parameters as a GRANT writes it (`app.f(int, text)`), as the target the catalog names: `app.f(integer,text)`. */
|
|
123
|
+
export declare function canonicalRoutineTarget(text: string, defaultSchema: string): string;
|
|
124
|
+
export declare function canonicalRoleAttributes(options: readonly string[]): string[];
|
|
118
125
|
/**
|
|
119
126
|
* A definition in canonical form. `props` is an entity's props, declared or
|
|
120
127
|
* parsed from what the server printed; `defaultSchema` qualifies a bare name.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAQH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAQH,OAAO,KAAK,EAeV,YAAY,EAKb,MAAM,aAAa,CAAC;AAsCrB,sFAAsF;AACtF,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SAAiE,CAAC;AAEjI,uHAAuH;AACvH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ1E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,aAAa,SAAW,GAAG,MAAM,GAAG,SAAS,CAgCpG;AA8CD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAyB1E;AAmDD,2HAA2H;AAC3H,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAS7F;AAID,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,C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assifierRule;
|
|
88
|
+
readonly SQLPG291: PgClassifierRule;
|
|
89
|
+
readonly SQLPG292: PgClassifierRule;
|
|
90
|
+
readonly SQLPG293: PgClassifierRule;
|
|
91
|
+
readonly SQLPG294: PgClassifierRule;
|
|
92
|
+
readonly SQLPG296: PgClassifierRule;
|
|
93
|
+
readonly SQLPG297: PgClassifierRule;
|
|
94
|
+
readonly SQLPG298: PgClassifierRule;
|
|
87
95
|
readonly SQLPG270: PgClassifierRule;
|
|
88
96
|
};
|
|
89
97
|
export type PgClassifierRuleId = keyof typeof PG_CLASSIFIER_RULES;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAkB,KAAK,aAAa,EAAE,KAAK,cAAc,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAErH,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,UAAU,GAAG,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEhH,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAEhE,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAAC,aAAa,CAY1D,CAAC;AASF,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAkB,KAAK,aAAa,EAAE,KAAK,cAAc,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAErH,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,UAAU,GAAG,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEhH,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAEhE,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAAC,aAAa,CAY1D,CAAC;AASF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAySqB,CAAC;AAEtD,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,mBAAmB,CAAC"}
|
|
@@ -43,7 +43,8 @@ export declare function pgSchemaFromBuildFile(path: string, defaultSchema?: stri
|
|
|
43
43
|
* The namespace an object's name is unique in: relations (tables, views,
|
|
44
44
|
* sequences, indexes) share one per schema, types and domains another,
|
|
45
45
|
* functions and procedures a third (told apart by their parameter types),
|
|
46
|
-
*
|
|
46
|
+
* a trigger's or a policy's name is unique on its table, and a role's in the
|
|
47
|
+
* cluster.
|
|
47
48
|
*/
|
|
48
49
|
export declare function pgNamespace(kind: string): string;
|
|
49
50
|
/** The identity an object has on a server: its kind's namespace, its qualified name, and its signature where it has one. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGxE,oHAAoH;AACpH,MAAM,WAAW,YAAa,SAAQ,iBAAiB;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,0CAA0C;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,yCAA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AAI,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED,4HAA4H;AAC5H,wBAAgB,YAAY,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAE3G;AAED,uFAAuF;AACvF,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,GAAG,cAAc,EAAE,CAEzF;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,YAAY,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,cAAc,EAAE,CAUvG"}
|
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
* (`CREATE TEMP VIEW`, or a `CREATE TEMP TABLE` holding the columns' types,
|
|
9
9
|
* defaults and generated expressions and the checks) inside a transaction
|
|
10
10
|
* that is always rolled back, with a short `lock_timeout`, and read back with
|
|
11
|
-
* the same printers the catalog read uses.
|
|
11
|
+
* the same printers the catalog read uses. A trigger's `WHEN` and a policy's
|
|
12
|
+
* `USING` and `WITH CHECK`, which the server prints with the casts it
|
|
13
|
+
* resolved, are read back from a trigger or policy on a temporary copy of the
|
|
14
|
+
* table (`CREATE TEMP TABLE ... (LIKE table)`). Nothing is left behind: Postgres
|
|
12
15
|
* DDL is transactional and a temporary object lives in the session's own
|
|
13
16
|
* schema. A server that refuses (no TEMP privilege, a lock not granted in
|
|
14
17
|
* time, an expression it rejects) leaves the rules' answer standing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-normalize.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/server-normalize.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"server-normalize.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/server-normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAiHpE;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,iBAAiB,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAmC5J"}
|
package/dist/postgres.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* the statements are Postgres's own DDL, parsed at build time into entities,
|
|
6
6
|
* and the names fold and quote as Postgres folds and quotes them.
|
|
7
7
|
*/
|
|
8
|
-
export { schema, table, index, view, sequence, type, domain, extension, func, procedure, trigger, literal, SqlLiteral, SqlTemplateError, PostgresObject, POSTGRES_ENTITY_TYPES, isPostgresObject, isColumnRef, quoteIdent, type PostgresEntityType, type PostgresSchema, type PostgresRelation, type PostgresTable, type PostgresView, type PostgresIndex, type PostgresSequence, type PostgresEnum, type PostgresDomain, type PostgresExtension, type PostgresFunction, type PostgresProcedure, type PostgresTrigger, type ColumnDef, type KeyDef, type CheckDef, type ForeignKeyDef, type ExclusionDef, type SchemaProps, type TableProps, type IndexProps, type ViewProps, type SequenceProps, type EnumProps, type DomainProps, type ExtensionProps, type RoutineProps, type RoutineArgDef, type FunctionProps, type ProcedureProps, type TriggerProps, type LineageEdge, } from "./postgres/entities.js";
|
|
8
|
+
export { schema, table, index, view, sequence, type, domain, extension, func, procedure, trigger, policy, role, grant, literal, SqlLiteral, SqlTemplateError, PostgresObject, POSTGRES_ENTITY_TYPES, isPostgresObject, isColumnRef, quoteIdent, type PostgresEntityType, type PostgresSchema, type PostgresRelation, type PostgresTable, type PostgresView, type PostgresIndex, type PostgresSequence, type PostgresEnum, type PostgresDomain, type PostgresExtension, type PostgresFunction, type PostgresProcedure, type PostgresTrigger, type PostgresPolicy, type PostgresRole, type PostgresGrant, type ColumnDef, type KeyDef, type CheckDef, type ForeignKeyDef, type ExclusionDef, type SchemaProps, type TableProps, type IndexProps, type ViewProps, type SequenceProps, type EnumProps, type DomainProps, type ExtensionProps, type RoutineProps, type RoutineArgDef, type FunctionProps, type ProcedureProps, type TriggerProps, type PolicyProps, type RoleProps, type GrantProps, type DefaultPrivilegesProps, type PrivilegeDef, type LineageEdge, } from "./postgres/entities.js";
|
|
9
9
|
export { POSTGRES_PROVIDERS, COMMON_REFUSED, providerData, isPostgresProvider, providerAllowsExtension, isProviderOwned, refusedStatement, normalizeStatement, type PostgresProvider, type ProviderData, type ProviderSource, type RefusedStatement, type LiveObjectRef, } from "./postgres/providers/index.js";
|
|
10
10
|
export { PostgresMigrationOp, type PostgresMigrationOpConfig, type PostgresMigrationOpResources, type PostgresMigrationArgs, } from "./postgres/migrate/op.js";
|
|
11
11
|
export { POSTGRES_RECEIPTS_TABLE } from "./postgres/migrate/receipts.js";
|
package/dist/postgres.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../src/postgres.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,SAAS,EACT,IAAI,EACJ,SAAS,EACT,OAAO,EACP,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,WAAW,GACjB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,mBAAmB,EACnB,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../src/postgres.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,SAAS,EACT,IAAI,EACJ,SAAS,EACT,OAAO,EACP,MAAM,EACN,IAAI,EACJ,KAAK,EACL,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,KAAK,kBAAkB,EACvB,KAAK,cA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>[] =
|
|
|
17
17
|
{
|
|
18
18
|
dialect: "postgres",
|
|
19
19
|
modules: ["@intentius/chant-lexicon-sql/postgres"],
|
|
20
|
-
tags: ["schema", "table", "index", "view", "sequence", "type", "domain", "extension", "func", "procedure", "trigger"],
|
|
20
|
+
tags: ["schema", "table", "index", "view", "sequence", "type", "domain", "extension", "func", "procedure", "trigger", "policy", "role", "grant"],
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
dialect: "postgres",
|
|
24
24
|
modules: ["@intentius/chant-lexicon-sql"],
|
|
25
|
-
tags: ["schema", "index", "sequence", "type", "domain", "extension", "func", "procedure", "trigger"],
|
|
25
|
+
tags: ["schema", "index", "sequence", "type", "domain", "extension", "func", "procedure", "trigger", "policy", "role", "grant"],
|
|
26
26
|
},
|
|
27
27
|
];
|
|
28
28
|
|
package/dist/rules/sqlch001.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import type { LintContext, LintDiagnostic, LintRule } from "@intentius/chant/lint/rule";
|
|
2
2
|
import { parseCreate } from "../../clickhouse/parser";
|
|
3
|
+
import { parseAccess } from "../../clickhouse/access";
|
|
3
4
|
import { SqlSyntaxError } from "../../clickhouse/tokens";
|
|
4
5
|
import { findTemplates, templatePosition, tokensOf } from "./templates";
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
+
const ACCESS_TAGS = new Set(["user", "role", "policy", "grant"]);
|
|
8
|
+
const ACCESS_STATEMENT: Record<string, string> = { user: "CREATE USER", role: "CREATE ROLE", rowPolicy: "CREATE ROW POLICY", grant: "GRANT" };
|
|
9
|
+
|
|
10
|
+
const STATEMENT: Record<string, string> = { database: "CREATE DATABASE", table: "CREATE TABLE", view: "CREATE VIEW", dictionary: "CREATE DICTIONARY", function: "CREATE FUNCTION" };
|
|
11
|
+
/** The tag a statement belongs in: `func` for a function, the statement's own name otherwise. */
|
|
12
|
+
const tagOf = (statement: string): string => (statement === "function" ? "func" : statement);
|
|
7
13
|
|
|
8
14
|
/**
|
|
9
|
-
* SQLCH001: the DDL in a `database`, `table`
|
|
15
|
+
* SQLCH001: the DDL in a ClickHouse template (`database`, `table`, `view`, `dictionary`, `func`, `user`, `role`, `policy`, `grant`) does not parse, or holds another statement than its tag.
|
|
10
16
|
*
|
|
11
17
|
* The same parse runs when the build calls the tag, and fails the build there.
|
|
12
18
|
* This rule reports it in the editor and in `chant lint`, at the token, before
|
|
@@ -27,12 +33,28 @@ export const sqlch001: LintRule = {
|
|
|
27
33
|
let tokens;
|
|
28
34
|
try {
|
|
29
35
|
tokens = tokensOf(found);
|
|
36
|
+
if (ACCESS_TAGS.has(found.tag)) {
|
|
37
|
+
const node = parseAccess(tokens);
|
|
38
|
+
const tag = node.statement === "rowPolicy" ? "policy" : node.statement;
|
|
39
|
+
if (tag !== found.tag || node.revoke) {
|
|
40
|
+
out.push({
|
|
41
|
+
ruleId: "SQLCH001",
|
|
42
|
+
severity: "error",
|
|
43
|
+
message: node.revoke
|
|
44
|
+
? `${found.tag}\`...\` holds a REVOKE; declare the grants a grantee keeps, and a plan revokes the rest`
|
|
45
|
+
: `${found.tag}\`...\` holds a ${ACCESS_STATEMENT[node.statement]}; use the ${tag} tag`,
|
|
46
|
+
file: context.filePath,
|
|
47
|
+
...templatePosition(source, found, 0, 0),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
30
52
|
const node = parseCreate(tokens);
|
|
31
|
-
if (node.statement !== found.tag) {
|
|
53
|
+
if (tagOf(node.statement) !== found.tag) {
|
|
32
54
|
out.push({
|
|
33
55
|
ruleId: "SQLCH001",
|
|
34
56
|
severity: "error",
|
|
35
|
-
message: `${found.tag}\`...\` holds a ${STATEMENT[node.statement]}; use the ${node.statement} tag`,
|
|
57
|
+
message: `${found.tag}\`...\` holds a ${STATEMENT[node.statement]}; use the ${tagOf(node.statement)} tag`,
|
|
36
58
|
file: context.filePath,
|
|
37
59
|
...templatePosition(source, found, 0, 0),
|
|
38
60
|
});
|
package/dist/rules/sqlch002.ts
CHANGED
|
@@ -41,7 +41,8 @@ function keyColumns(tokens: Token[], span: Span): Array<{ name: string; token: T
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function allowsNullableKey(tokens: Token[], node: CreateNode): boolean {
|
|
44
|
-
if (node.statement
|
|
44
|
+
if (node.statement !== "table" && node.statement !== "view") return false;
|
|
45
|
+
if (!node.settings) return false;
|
|
45
46
|
const s = node.settings.find((x) => x.key === "allow_nullable_key");
|
|
46
47
|
if (!s) return false;
|
|
47
48
|
const v = tokens.slice(s.value.from, s.value.to).map((t) => t.text).join("").trim().toLowerCase().replace(/'/g, "");
|
|
@@ -74,7 +75,7 @@ export const sqlch002: LintRule = {
|
|
|
74
75
|
if (err instanceof SqlSyntaxError) continue; // SQLCH001 reports it
|
|
75
76
|
throw err;
|
|
76
77
|
}
|
|
77
|
-
if (node.statement
|
|
78
|
+
if ((node.statement !== "table" && node.statement !== "view") || allowsNullableKey(tokens, node)) continue;
|
|
78
79
|
const nullable = new Set(node.columns.filter((c) => c.name && isNullable(tokens, c)).map((c) => c.name));
|
|
79
80
|
if (nullable.size === 0) continue;
|
|
80
81
|
const reported = new Set<string>();
|
package/dist/rules/sqlpg001.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LintContext, LintDiagnostic, LintRule } from "@intentius/chant/lint/rule";
|
|
2
2
|
import { parseStatements, SqlSyntaxError } from "../../postgres/parser";
|
|
3
|
-
import { STATEMENT_NAMES, type PostgresTag } from "../../postgres/entities";
|
|
3
|
+
import { followOnStray, STATEMENT_NAMES, type PostgresTag } from "../../postgres/entities";
|
|
4
4
|
import { findPostgresTemplates, postgresTokensOf, templatePosition, tokenPosition } from "./postgres-templates";
|
|
5
5
|
|
|
6
6
|
/** The statement each tag holds. */
|
|
@@ -16,6 +16,9 @@ const STATEMENT: Record<PostgresTag, string> = {
|
|
|
16
16
|
func: "function",
|
|
17
17
|
procedure: "procedure",
|
|
18
18
|
trigger: "trigger",
|
|
19
|
+
policy: "policy",
|
|
20
|
+
role: "role",
|
|
21
|
+
grant: "grant",
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
const TAG_OF: Record<string, PostgresTag> = Object.fromEntries(Object.entries(STATEMENT).map(([tag, statement]) => [statement, tag as PostgresTag]));
|
|
@@ -62,15 +65,15 @@ export const sqlpg001: LintRule = {
|
|
|
62
65
|
report(
|
|
63
66
|
use
|
|
64
67
|
? `${found.tag}\`...\` holds a ${STATEMENT_NAMES[node!.statement]}; use the ${use} tag`
|
|
65
|
-
: `${found.tag}\`...\` starts with a
|
|
68
|
+
: `${found.tag}\`...\` starts with a ${STATEMENT_NAMES[node!.statement]}; it goes after the CREATE it belongs to`,
|
|
66
69
|
templatePosition(source, found, 0, 0),
|
|
67
70
|
);
|
|
68
71
|
continue;
|
|
69
72
|
}
|
|
70
|
-
const stray =
|
|
73
|
+
const stray = followOnStray(found.tag, rest);
|
|
71
74
|
if (stray) {
|
|
72
75
|
report(
|
|
73
|
-
`${found.tag}\`...\` holds a second statement (${STATEMENT_NAMES[stray.statement]}); a template declares one object, followed only by COMMENT ON statements for it`,
|
|
76
|
+
`${found.tag}\`...\` holds a second statement (${STATEMENT_NAMES[stray.statement]}); a template declares one object, followed only by COMMENT ON statements for it${found.tag === "table" ? " and ALTER TABLE ... ROW LEVEL SECURITY" : ""}`,
|
|
74
77
|
templatePosition(source, found, 0, 0),
|
|
75
78
|
);
|
|
76
79
|
}
|
package/dist/rules/templates.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { findSqlTemplates, type FoundTemplate as SqlFoundTemplate, type Template
|
|
|
13
13
|
|
|
14
14
|
export { templatePosition, tokenPosition } from "../../core/find-templates";
|
|
15
15
|
|
|
16
|
-
export type SqlTag = "database" | "table" | "view";
|
|
16
|
+
export type SqlTag = "database" | "table" | "view" | "dictionary" | "func" | "user" | "role" | "policy" | "grant";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The ClickHouse tags, by the modules they are imported from. The package
|
|
@@ -22,7 +22,7 @@ export type SqlTag = "database" | "table" | "view";
|
|
|
22
22
|
export const CLICKHOUSE_TEMPLATE_SOURCE: TemplateSource<SqlTag> = {
|
|
23
23
|
dialect: "clickhouse",
|
|
24
24
|
modules: ["@intentius/chant-lexicon-sql", "@intentius/chant-lexicon-sql/clickhouse"],
|
|
25
|
-
tags: ["database", "table", "view"],
|
|
25
|
+
tags: ["database", "table", "view", "dictionary", "func", "user", "role", "policy", "grant"],
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
export type FoundTemplate = SqlFoundTemplate<SqlTag>;
|
package/dist/serializer.d.ts
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
*
|
|
13
13
|
* The order is the dependency order of the references: a view after the
|
|
14
14
|
* tables it reads, a materialized view after its target, a table after its
|
|
15
|
-
* database.
|
|
15
|
+
* database. An object read from a `.sql` file (`./sql-files.ts`) that a
|
|
16
|
+
* template names in its text counts as referenced too. Ties break by export name, so the output is the same however the
|
|
16
17
|
* files were discovered. A reference cycle is an error naming the cycle.
|
|
17
18
|
*
|
|
18
19
|
* One build holds one dialect: the dialect is the document's, and a project
|
package/dist/serializer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAc,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AASjF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAEpD,gEAAgE;AAChE,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAmEhD,eAAO,MAAM,aAAa,EAAE,UAuC3B,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain `.sql` files as a schema source (#3646): DDL read into the same
|
|
3
|
+
* declarations the tagged templates make. Also at the package root.
|
|
4
|
+
*
|
|
5
|
+
* - {@link readSqlFile}: the objects a file of DDL declares, each with its
|
|
6
|
+
* export name, type, qualified name and DDL.
|
|
7
|
+
* - {@link sqlFileDeclarations}: the same file as TypeScript, one `schema.ts`
|
|
8
|
+
* of `table`, `view`, ... templates, as `chant import <file>.sql` writes it.
|
|
9
|
+
* - {@link sqlFileEntities}: the declarations themselves, with the references
|
|
10
|
+
* between the files' objects, and to objects declared elsewhere, as
|
|
11
|
+
* interpolations, so dependency order comes from the graph. The build uses
|
|
12
|
+
* it for every `.sql` file in the source directory.
|
|
13
|
+
*
|
|
14
|
+
* Postgres reads each `CREATE`, `GRANT`, `REVOKE` and `ALTER DEFAULT
|
|
15
|
+
* PRIVILEGES` as an object, with `COMMENT ON`, `ALTER TABLE ... ROW LEVEL
|
|
16
|
+
* SECURITY` and `ALTER TABLE ... ADD <table constraint>` folded into the
|
|
17
|
+
* object they finish; ClickHouse reads `CREATE DATABASE`, `TABLE`, `VIEW`,
|
|
18
|
+
* `MATERIALIZED VIEW`, `DICTIONARY` and `FUNCTION`. Any other statement, and any
|
|
19
|
+
* statement that does not parse, throws a {@link SqlFileError} naming every
|
|
20
|
+
* such statement: none is left out.
|
|
21
|
+
*
|
|
22
|
+
* A name is a reference where it is qualified (`app.users`), or bare where an
|
|
23
|
+
* object is named (`REFERENCES users`, `FROM users`, an index's table, a
|
|
24
|
+
* column of an enum type) and an object declared without a schema has it.
|
|
25
|
+
*/
|
|
26
|
+
import type { Declarable } from "@intentius/chant/declarable";
|
|
27
|
+
import type { SqlDialect } from "./dialects.js";
|
|
28
|
+
import { SqlFileError, type ReadOptions } from "./files/common.js";
|
|
29
|
+
export { SqlFileError };
|
|
30
|
+
export type { ReadOptions as SqlFileOptions };
|
|
31
|
+
/** One object a file of DDL declares. */
|
|
32
|
+
export interface SqlFileObject {
|
|
33
|
+
/** The export it is declared as. */
|
|
34
|
+
export: string;
|
|
35
|
+
/** Its entity type, `Postgres::Table`. */
|
|
36
|
+
type: string;
|
|
37
|
+
/** `schema.name` (Postgres), `database.name` (ClickHouse); the name alone when the DDL does not qualify it. */
|
|
38
|
+
name: string;
|
|
39
|
+
/** Its statements: the CREATE, then what was folded into it. */
|
|
40
|
+
ddl: string;
|
|
41
|
+
/** The file it came from, the `origin` it was read under. */
|
|
42
|
+
origin: string;
|
|
43
|
+
}
|
|
44
|
+
/** A file to read: its DDL and the name errors give it. */
|
|
45
|
+
export interface SqlFileSource extends ReadOptions {
|
|
46
|
+
ddl: string;
|
|
47
|
+
}
|
|
48
|
+
/** The objects a file of DDL declares. Throws a {@link SqlFileError} naming each statement it cannot read. */
|
|
49
|
+
export declare function readSqlFile(dialect: SqlDialect, ddl: string, options: ReadOptions): SqlFileObject[];
|
|
50
|
+
/**
|
|
51
|
+
* A file of DDL as TypeScript declarations: the `schema.ts` `chant import`
|
|
52
|
+
* writes, with `header` as comment lines at its top, and the objects in it.
|
|
53
|
+
*/
|
|
54
|
+
export declare function sqlFileDeclarations(dialect: SqlDialect, ddl: string, options: ReadOptions & {
|
|
55
|
+
header?: string;
|
|
56
|
+
}): {
|
|
57
|
+
content: string;
|
|
58
|
+
objects: SqlFileObject[];
|
|
59
|
+
};
|
|
60
|
+
/** Where an entity read from a `.sql` file came from: its `origin`. Undefined for any other entity. */
|
|
61
|
+
export declare function sqlFileOf(entity: unknown): string | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* The declarations the files make, by export name. `known` holds the
|
|
64
|
+
* entities declared elsewhere (the project's tagged templates): a file's
|
|
65
|
+
* reference to one of them is an interpolation of it, as an import would
|
|
66
|
+
* write it, and an export name or an object one of them already declares is
|
|
67
|
+
* an error naming both.
|
|
68
|
+
*/
|
|
69
|
+
export declare function sqlFileEntities(dialect: SqlDialect, sources: readonly SqlFileSource[], options?: {
|
|
70
|
+
known?: ReadonlyMap<string, Declarable>;
|
|
71
|
+
}): Map<string, Declarable>;
|
|
72
|
+
/**
|
|
73
|
+
* The objects read from `.sql` files that each other object names in its
|
|
74
|
+
* DDL as text, by export name: a tagged template cannot import a file's
|
|
75
|
+
* object, so it names it, and this is the edge the dependency order needs.
|
|
76
|
+
* Empty when no object came from a file.
|
|
77
|
+
*/
|
|
78
|
+
export declare function sqlFileReferences(dialect: SqlDialect, objects: ReadonlyMap<string, Declarable>): Map<string, string[]>;
|
|
79
|
+
//# sourceMappingURL=sql-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-files.d.ts","sourceRoot":"","sources":["../src/sql-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAUhE,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,YAAY,EAAE,WAAW,IAAI,cAAc,EAAE,CAAC;AAE9C,yCAAyC;AACzC,MAAM,WAAW,aAAa;IAC5B,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,+GAA+G;IAC/G,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,GAAG,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,2DAA2D;AAC3D,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,GAAG,EAAE,MAAM,CAAC;CACb;AAuBD,8GAA8G;AAC9G,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,aAAa,EAAE,CAInG;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,aAAa,EAAE,CAAA;CAAE,CAW/J;AAED,uGAAuG;AACvG,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAE7D;AA4BD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,aAAa,EAAE,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CAAO,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAqD1K;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAatH"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Short-lived database credentials (#3685): a profile's `password` can name a
|
|
3
|
+
* token source instead of an environment variable, and the token is minted
|
|
4
|
+
* when a connection needs it.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* profiles: {
|
|
8
|
+
* prod: { url: "postgres://db.abc.us-east-1.rds.amazonaws.com:5432/shop", user: { env: "PG_USER" }, password: { token: "rds-iam" } },
|
|
9
|
+
* ci: { url: "postgres://db.internal:5432/shop", password: { token: "command", command: ["./mint-token.sh"], ttlSeconds: 600 } },
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Each cloud source runs that cloud's own command line, which reads the job's
|
|
14
|
+
* ambient identity (an OIDC-federated role in CI, a workload identity, a
|
|
15
|
+
* logged-in developer), so chant holds no cloud SDK and no long-lived secret:
|
|
16
|
+
*
|
|
17
|
+
* - `rds-iam`: `aws rds generate-db-auth-token`, for RDS and Aurora. The host
|
|
18
|
+
* and port come from the profile's URL, the user from its `user`, the region
|
|
19
|
+
* from `region`, else `AWS_REGION`, else the RDS host name.
|
|
20
|
+
* - `cloud-sql-iam`: `gcloud sql generate-login-token`.
|
|
21
|
+
* - `entra`: `az account get-access-token` for Azure Database for PostgreSQL.
|
|
22
|
+
* - `command`: any command that prints a password on its standard output.
|
|
23
|
+
*
|
|
24
|
+
* A token is reused until most of its lifetime has passed and minted again
|
|
25
|
+
* after, so a long apply, whose ClickHouse requests each carry the password
|
|
26
|
+
* and whose Postgres connections each authenticate when opened, never sends
|
|
27
|
+
* an expired one. A token is never written to a message, an outcome or a log.
|
|
28
|
+
*/
|
|
29
|
+
import { z } from "zod";
|
|
30
|
+
/** The token sources a profile's `password` can name. */
|
|
31
|
+
export declare const tokenSourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
32
|
+
token: z.ZodLiteral<"rds-iam">;
|
|
33
|
+
/** The AWS region. `AWS_REGION`, `AWS_DEFAULT_REGION`, else the RDS host name's, when omitted. */
|
|
34
|
+
region: z.ZodOptional<z.ZodString>;
|
|
35
|
+
/** How long a token is valid, in seconds. 900, the RDS lifetime, when omitted. */
|
|
36
|
+
ttlSeconds: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
38
|
+
token: z.ZodLiteral<"cloud-sql-iam">;
|
|
39
|
+
/** How long a token is valid, in seconds. 3600 when omitted. */
|
|
40
|
+
ttlSeconds: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
42
|
+
token: z.ZodLiteral<"entra">;
|
|
43
|
+
/** How long a token is valid, in seconds. 3600 when omitted. */
|
|
44
|
+
ttlSeconds: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
46
|
+
token: z.ZodLiteral<"command">;
|
|
47
|
+
/** The program and its arguments, run without a shell; its standard output, trimmed, is the password. */
|
|
48
|
+
command: z.ZodArray<z.ZodString>;
|
|
49
|
+
/** How long a token is valid, in seconds. 300 when omitted. */
|
|
50
|
+
ttlSeconds: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
}, z.core.$strict>], "token">;
|
|
52
|
+
export type TokenSourceConfig = z.infer<typeof tokenSourceSchema>;
|
|
53
|
+
/** The cloud sources, which mint for a Postgres server only. */
|
|
54
|
+
export declare const POSTGRES_ONLY_TOKEN_SOURCES: ReadonlySet<string>;
|
|
55
|
+
/** A token source that could not mint. The message names the source and the command, never what it printed. */
|
|
56
|
+
export declare class TokenSourceError extends Error {
|
|
57
|
+
constructor(message: string);
|
|
58
|
+
}
|
|
59
|
+
/** Runs a program without a shell and returns its standard output. */
|
|
60
|
+
export type RunCommand = (argv: readonly string[], env: Record<string, string | undefined>) => Promise<string>;
|
|
61
|
+
/** Where a token is minted, and the cached token. */
|
|
62
|
+
export interface CredentialSource {
|
|
63
|
+
/** What the token is minted by, for a message: `sql.profiles.prod.password (rds-iam)`. */
|
|
64
|
+
readonly source: string;
|
|
65
|
+
/** A valid token: the cached one, or a new one when it has expired. */
|
|
66
|
+
get(): Promise<string>;
|
|
67
|
+
/** Forget the cached token, so the next `get()` mints again. */
|
|
68
|
+
invalidate(): void;
|
|
69
|
+
}
|
|
70
|
+
/** The program a source runs. Pure, for tests. */
|
|
71
|
+
export declare function tokenCommand(config: TokenSourceConfig, input: {
|
|
72
|
+
url: string;
|
|
73
|
+
user?: string;
|
|
74
|
+
env: Record<string, string | undefined>;
|
|
75
|
+
}): readonly string[];
|
|
76
|
+
/**
|
|
77
|
+
* A source that mints with `config` when asked. Nothing runs until `get()`.
|
|
78
|
+
* `now` and `run` are for tests.
|
|
79
|
+
*/
|
|
80
|
+
export declare function credentialSource(config: TokenSourceConfig, input: {
|
|
81
|
+
url: string;
|
|
82
|
+
user?: string;
|
|
83
|
+
env: Record<string, string | undefined>;
|
|
84
|
+
source: string;
|
|
85
|
+
run?: RunCommand;
|
|
86
|
+
now?: () => number;
|
|
87
|
+
}): CredentialSource;
|
|
88
|
+
//# sourceMappingURL=token-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-source.d.ts","sourceRoot":"","sources":["../src/token-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,yDAAyD;AACzD,eAAO,MAAM,iBAAiB;;IAG1B,kGAAkG;;IAElG,kFAAkF;;;;IAKlF,gEAAgE;;;;IAKhE,gEAAgE;;;;IAKhE,yGAAyG;;IAEzG,+DAA+D;;6BAGjE,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE,gEAAgE;AAChE,eAAO,MAAM,2BAA2B,EAAE,WAAW,CAAC,MAAM,CAAkD,CAAC;AAY/G,+GAA+G;AAC/G,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM;CAI5B;AAED,sEAAsE;AACtE,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAU/G,qDAAqD;AACrD,MAAM,WAAW,gBAAgB;IAC/B,0FAA0F;IAC1F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACvB,gEAAgE;IAChE,UAAU,IAAI,IAAI,CAAC;CACpB;AAED,kDAAkD;AAClD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CAAE,GAC7E,SAAS,MAAM,EAAE,CA0BnB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE;IACL,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB,GACA,gBAAgB,CAoClB"}
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,EAAgD,KAAK,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAMtH,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,EAAgD,KAAK,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAMtH,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AA0EvF,wBAAsB,QAAQ,CAAC,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAoEpF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-sql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.118.0",
|
|
4
4
|
"description": "SQL lexicon for chant — database schema as typed declarations, one dialect at a time; ClickHouse first, with types read from a pinned server's catalog",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://intentius.io/chant",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"typescript": "^5.9.3"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"@intentius/chant": "^0.
|
|
73
|
+
"@intentius/chant": "^0.118.0",
|
|
74
74
|
"typescript": "^5.9.3"
|
|
75
75
|
}
|
|
76
76
|
}
|