@vibeorm/sql 2.0.0-alpha.7 → 2.0.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.
@@ -0,0 +1,71 @@
1
+ import type { FieldIR, RlsContextIR, SchemaIR } from "@vibeorm/schema";
2
+ import type { SqlDialect } from "../dialect.ts";
3
+ import type { RenderedQuery } from "../render.ts";
4
+ /** Managed identity and namespace, shared by migration and readiness checks. */
5
+ export declare const NATIVE_RLS: {
6
+ readonly policyName: "vibeorm_managed";
7
+ readonly tableSchema: "public";
8
+ readonly settingPrefix: "vibeorm.";
9
+ readonly parentAlias: "parent";
10
+ };
11
+ /** ENABLE is one statement; migrate owns transaction/order and pairs it with FORCE. */
12
+ export declare function renderRlsEnable(params: {
13
+ dialect: SqlDialect;
14
+ table: string;
15
+ }): RenderedQuery;
16
+ /** FORCE is separate so migration step ordering stays explicit. */
17
+ export declare function renderRlsForce(params: {
18
+ dialect: SqlDialect;
19
+ table: string;
20
+ }): RenderedQuery;
21
+ /** DISABLE is separate; migrate owns acknowledgement and teardown ordering. */
22
+ export declare function renderRlsDisable({ dialect, table }: {
23
+ dialect: SqlDialect;
24
+ table: string;
25
+ }): RenderedQuery;
26
+ /** NO FORCE precedes DISABLE when migrate deliberately removes protection. */
27
+ export declare function renderRlsNoForce({ dialect, table }: {
28
+ dialect: SqlDialect;
29
+ table: string;
30
+ }): RenderedQuery;
31
+ /** Drop one named policy; migrate owns child-first dependency ordering. */
32
+ export declare function renderRlsDropPolicy({ dialect, table, policyName }: {
33
+ dialect: SqlDialect;
34
+ table: string;
35
+ policyName?: string;
36
+ }): RenderedQuery;
37
+ /**
38
+ * Context casts use the physical base type, NOT typmods: varchar(n), numeric(p,s)
39
+ * and timestamp(p) casts can truncate/round another identity into an allowed one.
40
+ * Unknown/user-defined casts refuse rather than splice raw nativeType into SQL.
41
+ */
42
+ export declare function renderRlsColumnType(params: {
43
+ dialect: SqlDialect;
44
+ field: FieldIR;
45
+ }): string;
46
+ /** Desired predicate only, for drift probes; it is NOT server-canonical deparse. */
47
+ export declare function renderRlsPredicate(params: {
48
+ dialect: SqlDialect;
49
+ schema: SchemaIR;
50
+ model: string;
51
+ }): string;
52
+ /** One PERMISSIVE ALL/PUBLIC policy with equal existing/proposed-row checks. */
53
+ export declare function renderRlsPolicy(params: {
54
+ dialect: SqlDialect;
55
+ schema: SchemaIR;
56
+ model: string;
57
+ policyName?: string;
58
+ targetSchema?: "public" | "pg_temp";
59
+ }): RenderedQuery;
60
+ /** Every declared setting, parameterized in declaration order and transaction-local. */
61
+ export declare function renderRlsContext(params: {
62
+ dialect: SqlDialect;
63
+ context: RlsContextIR;
64
+ values: Readonly<Record<string, string | null>>;
65
+ }): RenderedQuery;
66
+ /** First transaction statement on eligible PGlite only; server roles are login roles. */
67
+ export declare function renderRlsRole(params: {
68
+ dialect: SqlDialect;
69
+ role: string;
70
+ }): RenderedQuery;
71
+ //# sourceMappingURL=postgres-rls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-rls.d.ts","sourceRoot":"","sources":["../../src/dialects/postgres-rls.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAW,YAAY,EAAoB,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAClG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,gFAAgF;AAChF,eAAO,MAAM,UAAU,EAAE;IACvB,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC;CAC4F,CAAC;AAoC9H,uFAAuF;AACvF,wBAAgB,eAAe,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,UAAU,CAAC;IAA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Y,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CACrC,GAAG,aAAa,CAMhB;AAED,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,OAAO,EAAE,UAAU,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;CACjD,GAAG,aAAa,CAoBhB;AAED,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAO1F"}
@@ -1 +1 @@
1
- {"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../src/dialects/postgres.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,eAAO,MAAM,eAAe,EAAE,UA0C7B,CAAC"}
1
+ {"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../src/dialects/postgres.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,eAAO,MAAM,eAAe,EAAE,UA2D7B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/dialects/sqlite.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,eAAO,MAAM,aAAa,EAAE,UAyD3B,CAAC"}
1
+ {"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/dialects/sqlite.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,eAAO,MAAM,aAAa,EAAE,UA2E3B,CAAC"}
package/dist/index.d.ts CHANGED
@@ -4,18 +4,29 @@
4
4
  * SQL AST + per-dialect renderers + capability tables. Every SQL-text decision
5
5
  * lives in this package; see the root sql-catalog.md for the reviewable surface.
6
6
  */
7
- export type { AggFn, AggRef, AggSelect, ColRef, ComparisonOp, DeleteStatement, InnerJoin, InsertStatement, JsonFilterOp, LateralJoin, ListSetOperation, OnConflictClause, OnConflictDoNothing, OnConflictUpdate, OrderByAggregate, OrderByColumn, OrderBySubquery, OrderTerm, RowNumberProjection, DbNowMarker, JsonParamCell, SelectExpr, SelectStatement, SetOperation, SetOperator, SqlExpr, SqlStatement, TableRef, UpdateStatement, } from "./ast.ts";
8
- export { SQL_DEFAULT_CELL, dbNowMarker, isDbNowMarker, isJsonParamCell, isListSetOperation, isSetOperation, isSqlDefaultCell, jsonParamCell, } from "./ast.ts";
7
+ export type { AggFn, AggRef, AggSelect, ColRef, ComparisonOp, DeleteStatement, ExcludedRef, InnerJoin, InsertStatement, JsonFilterOp, LateralJoin, ListSetOperation, OnConflictClause, OnConflictDoNothing, OnConflictUpdate, OrderByAggregate, OrderByColumn, OrderBySubquery, OrderTerm, RowNumberProjection, DbNowMarker, JsonParamCell, SelectExpr, SelectStatement, SetOperation, SetOperator, SqlExpr, SqlStatement, TableRef, UpdateStatement, } from "./ast.ts";
8
+ export { SQL_DEFAULT_CELL, dbNowMarker, excludedRef, isDbNowMarker, isExcludedRef, isJsonParamCell, isListSetOperation, isSetOperation, isSqlDefaultCell, jsonParamCell, } from "./ast.ts";
9
9
  export type { SqlDialect } from "./dialect.ts";
10
10
  export { postgresDialect } from "./dialects/postgres.ts";
11
11
  export { sqliteDialect } from "./dialects/sqlite.ts";
12
12
  export { mysqlDialect } from "./dialects/mysql.ts";
13
13
  export { SQL_DIALECTS, getSqlDialect } from "./dialects/registry.ts";
14
14
  export { DIALECT_CAPABILITIES, MYSQL_CAPABILITIES, POSTGRES_CAPABILITIES, SQLITE_CAPABILITIES, } from "./capabilities.ts";
15
- export { DIALECT_CODECS, MYSQL_CODECS, POSTGRES_CODECS, SQLITE_CODECS, decodeIsNoop, } from "./codecs.ts";
15
+ export { DIALECT_CODECS, MYSQL_CODECS, POSTGRES_CODECS, SQLITE_CODECS, decodeIsNoop, enumMembershipCodec, } from "./codecs.ts";
16
16
  export type { CodecTable, ScalarCodec, WireFidelity } from "./codecs.ts";
17
17
  export { renderExpr, renderFragment, renderStatement } from "./render.ts";
18
18
  export type { RenderedQuery } from "./render.ts";
19
19
  export { ParamCollector } from "./params.ts";
20
+ export { NATIVE_RLS, renderRlsColumnType, renderRlsContext, renderRlsDisable, renderRlsDropPolicy, renderRlsEnable, renderRlsForce, renderRlsNoForce, renderRlsPolicy, renderRlsPredicate, renderRlsRole } from "./dialects/postgres-rls.ts";
21
+ export type { RlsContextStatement, RlsDisableStatement, RlsDropPolicyStatement, RlsEnableStatement, RlsForceStatement, RlsNoForceStatement, RlsPolicyStatement, RlsRoleStatement } from "./ast.ts";
20
22
  export { containsPattern, endsWithPattern, escapeGlobPattern, escapeLikePattern, startsWithPattern, strictMatchPattern } from "./like.ts";
23
+ export { RLS_READINESS_SQL, NATIVE_RLS_PROBE_POLICY, renderRlsReadinessQuery, renderRlsProbeTable, renderRlsPolicyPath } from "./dialects/postgres-rls-readiness.ts";
24
+ export type { RlsReadinessQuery } from "./dialects/postgres-rls-readiness.ts";
25
+ export { isFixedDiagnostic, renderDiagnostic } from "./dialects/diagnostics.ts";
26
+ export type { DiagnosticStatement, FixedDiagnosticQuery } from "./dialects/diagnostics.ts";
27
+ export { POSTGRES_DIAGNOSTIC_SQL, POSTGRES_WORKLOAD_LIMITS, renderPostgresExplain, renderPostgresWorkload, } from "./dialects/postgres-diagnostics.ts";
28
+ export type { PostgresExplainOptions, PostgresWorkloadQuery } from "./dialects/postgres-diagnostics.ts";
29
+ export { renderColumnStateQuery, renderConstraintStateQuery, renderIndexStateQuery, renderMigrationSessionRead, renderMigrationSessionRestore, renderMigrationSessionSet, renderRelationStateQuery, } from "./dialects/postgres-migration.ts";
30
+ export type { MigrationSessionSetting } from "./dialects/postgres-migration.ts";
31
+ export { parsePgArrayLiteral, toPgArrayLiteral } from "./pg-array.ts";
21
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,YAAY,EACV,KAAK,EACL,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,eAAe,EACf,SAAS,EACT,eAAe,EACf,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,UAAU,EACV,eAAe,EACf,YAAY,EACZ,WAAW,EACX,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,eAAe,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,aAAa,GACd,MAAM,UAAU,CAAC;AAIlB,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIrE,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACL,cAAc,EACd,YAAY,EACZ,eAAe,EACf,aAAa,EACb,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,YAAY,EAA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