okmodel 0.1.0 → 0.2.1

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.
Files changed (181) hide show
  1. package/README.md +237 -19
  2. package/dist/adapters/capabilities.d.ts +34 -0
  3. package/dist/adapters/pg/bunsql-extra.d.ts +17 -0
  4. package/dist/adapters/pg/bunsql.d.ts +60 -0
  5. package/dist/adapters/pg/call.d.ts +2 -12
  6. package/dist/adapters/pg/nodepostgres-extra.d.ts +18 -0
  7. package/dist/adapters/pg/nodepostgres.d.ts +57 -0
  8. package/dist/adapters/pg/postgres-extra.d.ts +50 -1
  9. package/dist/adapters/pg/postgresjs.d.ts +0 -4
  10. package/dist/adapters/pg/session.d.ts +94 -0
  11. package/dist/adapters/pg/watch.d.ts +18 -0
  12. package/dist/contracts/catalog/object.d.ts +1 -0
  13. package/dist/contracts/catalog/types.d.ts +15 -8
  14. package/dist/contracts/connection.d.ts +13 -0
  15. package/dist/contracts/driver.d.ts +18 -5
  16. package/dist/contracts/error.d.ts +17 -1
  17. package/dist/contracts/generator.d.ts +63 -0
  18. package/dist/contracts/index.d.ts +2 -2
  19. package/dist/contracts/index.js +1 -1
  20. package/dist/contracts/internal.js +11 -9
  21. package/dist/contracts/location.d.ts +24 -0
  22. package/dist/contracts/rows.d.ts +15 -0
  23. package/dist/dialects/pg/archive-bind.d.ts +22 -0
  24. package/dist/dialects/pg/column.d.ts +126 -9
  25. package/dist/dialects/pg/compile.d.ts +1 -0
  26. package/dist/dialects/pg/custom.d.ts +6 -0
  27. package/dist/dialects/pg/filter-parse.d.ts +19 -0
  28. package/dist/dialects/pg/filters.d.ts +19 -0
  29. package/dist/dialects/pg/index.d.ts +11 -2
  30. package/dist/dialects/pg/index.js +159 -1063
  31. package/dist/dialects/pg/keys.d.ts +19 -3
  32. package/dist/dialects/pg/model.d.ts +223 -2
  33. package/dist/dialects/pg/operator-fit.d.ts +86 -0
  34. package/dist/dialects/pg/operators.d.ts +39 -1
  35. package/dist/dialects/pg/ops/arr-append.d.ts +9 -0
  36. package/dist/dialects/pg/ops/arr-ns.d.ts +7 -0
  37. package/dist/dialects/pg/ops/arr-remove.d.ts +9 -0
  38. package/dist/dialects/pg/ops/containedBy.d.ts +9 -0
  39. package/dist/dialects/pg/ops/contains.d.ts +8 -4
  40. package/dist/dialects/pg/ops/hasAnyKey.d.ts +8 -0
  41. package/dist/dialects/pg/ops/hasKey.d.ts +8 -0
  42. package/dist/dialects/pg/ops/json-ns.d.ts +6 -0
  43. package/dist/dialects/pg/ops/json-set.d.ts +12 -0
  44. package/dist/dialects/pg/ops/matches.d.ts +16 -0
  45. package/dist/dialects/pg/ops/overlaps.d.ts +9 -0
  46. package/dist/dialects/pg/ops/path.d.ts +13 -0
  47. package/dist/dialects/pg/preset.d.ts +76 -0
  48. package/dist/dialects/pg/relations.d.ts +59 -2
  49. package/dist/dialects/pg/schema.d.ts +109 -5
  50. package/dist/dialects/pg/table.d.ts +130 -11
  51. package/dist/dialects/pg/temporal.d.ts +9 -7
  52. package/dist/dialects/pg/tenancy.d.ts +94 -0
  53. package/dist/dialects/pg/through.d.ts +21 -0
  54. package/dist/dialects/pg/trait.d.ts +141 -0
  55. package/dist/dialects/pg/where.d.ts +37 -0
  56. package/dist/runtime/aggregate.d.ts +25 -0
  57. package/dist/runtime/archive-handle.d.ts +18 -0
  58. package/dist/runtime/archive-rules.d.ts +12 -0
  59. package/dist/runtime/archive.d.ts +73 -0
  60. package/dist/runtime/batch.d.ts +20 -0
  61. package/dist/runtime/client.d.ts +114 -5
  62. package/dist/runtime/conflict.d.ts +2 -1
  63. package/dist/runtime/exposure.d.ts +27 -0
  64. package/dist/runtime/hookm.d.ts +39 -0
  65. package/dist/runtime/ids/index.d.ts +11 -0
  66. package/dist/runtime/ids/index.js +193 -0
  67. package/dist/runtime/ids/okid-extended.d.ts +19 -0
  68. package/dist/runtime/ids/okid-generator.d.ts +21 -0
  69. package/dist/runtime/ids/okid-shared.d.ts +89 -0
  70. package/dist/runtime/ids/okid.d.ts +24 -0
  71. package/dist/runtime/ids/uuid.d.ts +21 -0
  72. package/dist/runtime/lock.d.ts +22 -0
  73. package/dist/runtime/operator-sql.d.ts +8 -0
  74. package/dist/runtime/page.d.ts +25 -0
  75. package/dist/runtime/pg/bun.d.ts +30 -0
  76. package/dist/runtime/pg/bun.js +52 -0
  77. package/dist/runtime/pg/pg.d.ts +29 -0
  78. package/dist/runtime/pg/pg.js +52 -0
  79. package/dist/runtime/pg/pglite.js +16 -17
  80. package/dist/runtime/pg/postgresjs.js +14 -24
  81. package/dist/runtime/plan.d.ts +146 -7
  82. package/dist/runtime/preset-stack.d.ts +17 -0
  83. package/dist/runtime/presets.d.ts +48 -0
  84. package/dist/runtime/read-stream.d.ts +26 -0
  85. package/dist/runtime/safety/index.d.ts +159 -0
  86. package/dist/runtime/safety/index.js +294 -0
  87. package/dist/runtime/safety-hook.d.ts +42 -0
  88. package/dist/runtime/server-check.d.ts +34 -0
  89. package/dist/runtime/tenancy/index.d.ts +37 -0
  90. package/dist/runtime/tenancy/index.js +365 -0
  91. package/dist/runtime/trait-read.d.ts +30 -0
  92. package/dist/runtime/traits/index.d.ts +128 -0
  93. package/dist/runtime/traits/index.js +509 -0
  94. package/dist/runtime/transaction.d.ts +19 -0
  95. package/dist/runtime/tx.d.ts +22 -7
  96. package/dist/runtime/types.d.ts +390 -25
  97. package/dist/runtime/validate/bind.d.ts +11 -0
  98. package/dist/runtime/validate/closed.d.ts +16 -0
  99. package/dist/runtime/validate/engine.d.ts +41 -0
  100. package/dist/runtime/validate/hook.d.ts +17 -0
  101. package/dist/runtime/validate/index.d.ts +21 -0
  102. package/dist/runtime/validate/index.js +175 -0
  103. package/dist/runtime/validate/load.d.ts +13 -0
  104. package/dist/runtime/validate/places.d.ts +41 -0
  105. package/dist/runtime/validate/rules.d.ts +108 -0
  106. package/dist/runtime/validate/surface.d.ts +102 -0
  107. package/dist/runtime/write.d.ts +30 -5
  108. package/dist/shared/{fgqgsb5z.js → 0qkxbm1f.js} +2 -2
  109. package/dist/shared/0v1g424p.js +26 -0
  110. package/dist/shared/10tjenmd.js +210 -0
  111. package/dist/shared/{tb4ze1tr.js → 1dp5knt7.js} +95 -10
  112. package/dist/shared/38crxbgn.js +229 -0
  113. package/dist/shared/3a5ne750.js +158 -0
  114. package/dist/shared/4b9da9d7.js +138 -0
  115. package/dist/shared/4e4c6vq2.js +62 -0
  116. package/dist/shared/{ckb1p0a4.js → 4jzzghr6.js} +416 -83
  117. package/dist/shared/{ycwz42az.js → 52szzakm.js} +6 -26
  118. package/dist/shared/{kynx7vbm.js → 5z4q2zda.js} +604 -21
  119. package/dist/shared/672t5vym.js +12 -0
  120. package/dist/shared/7m88x3e9.js +45 -0
  121. package/dist/shared/7mht49yd.js +1091 -0
  122. package/dist/shared/{mtkwv8wx.js → 7p2wbz7f.js} +1 -1
  123. package/dist/shared/83eaefwr.js +10 -0
  124. package/dist/shared/96ps4g1z.js +32 -0
  125. package/dist/shared/97g2jnrw.js +76 -0
  126. package/dist/shared/{xy79j5hq.js → 9k6vetvf.js} +25 -36
  127. package/dist/shared/{w8samvk1.js → a1gdp7j9.js} +1 -1
  128. package/dist/shared/a5sxz52y.js +13 -0
  129. package/dist/shared/{dynq16vb.js → b066g80h.js} +8 -6
  130. package/dist/shared/cstgkzdx.js +154 -0
  131. package/dist/shared/{ax16zpvm.js → d04j53v8.js} +6 -5
  132. package/dist/shared/{y9m15dfv.js → d2whjz4k.js} +15 -9
  133. package/dist/shared/dd4f8mnx.js +307 -0
  134. package/dist/shared/e6wg00wd.js +164 -0
  135. package/dist/shared/e7a268fy.js +195 -0
  136. package/dist/shared/{vkm3q4x1.js → eaxwrgby.js} +4 -3
  137. package/dist/shared/{7ck0dtry.js → ecdzej21.js} +160 -81
  138. package/dist/shared/{px90pf9p.js → edwqqryd.js} +21 -16
  139. package/dist/shared/{g2v6gnc8.js → eqmtn1bj.js} +57 -5
  140. package/dist/shared/g1b5zzj9.js +75 -0
  141. package/dist/shared/g9f0zqce.js +376 -0
  142. package/dist/shared/ge03bfca.js +64 -0
  143. package/dist/shared/{79ggp945.js → jns2wx4t.js} +55 -12
  144. package/dist/shared/k3ted12y.js +33 -0
  145. package/dist/shared/k7dwkhvq.js +31 -0
  146. package/dist/shared/{hd293j9g.js → kyxb62mc.js} +14 -2
  147. package/dist/shared/m9tv7xn7.js +404 -0
  148. package/dist/shared/mrq77sgw.js +55 -0
  149. package/dist/shared/mxmcdsh5.js +450 -0
  150. package/dist/shared/n442h54c.js +14 -0
  151. package/dist/shared/n47rd821.js +442 -0
  152. package/dist/shared/n4jqhpqz.js +27 -0
  153. package/dist/shared/{mkjmqjv4.js → nfzc5z0w.js} +2 -104
  154. package/dist/shared/nsva2a6b.js +42 -0
  155. package/dist/shared/ps43134h.js +69 -0
  156. package/dist/shared/{8b04d28c.js → py3nh7jy.js} +2 -2
  157. package/dist/shared/qa5dsc7z.js +86 -0
  158. package/dist/shared/{g5fhqmwe.js → qxa0yb9j.js} +6 -4
  159. package/dist/shared/r6nwkxnt.js +86 -0
  160. package/dist/shared/{4j72449d.js → rtnaqre0.js} +3 -3
  161. package/dist/shared/rwmrejjz.js +26 -0
  162. package/dist/shared/{zhc5vmgf.js → s6gqfn5j.js} +2 -2
  163. package/dist/shared/sacqha1y.js +70 -0
  164. package/dist/shared/{qk3hxfja.js → sfh4pk75.js} +5 -5
  165. package/dist/shared/{j5cn2963.js → t4tbsy9h.js} +13 -64
  166. package/dist/shared/{ngk8gj61.js → tbszx8mz.js} +15 -1
  167. package/dist/shared/v18jva5b.js +90 -0
  168. package/dist/shared/x9v1qgeb.js +201 -0
  169. package/dist/shared/xatfg0gn.js +193 -0
  170. package/dist/shared/xkz8g6by.js +225 -0
  171. package/dist/shared/{f5thc1s0.js → xrfnq5k8.js} +237 -418
  172. package/dist/shared/ytg3xf9p.js +149 -0
  173. package/dist/shared/yw5c610b.js +48 -0
  174. package/dist/shared/zd93g3rq.js +31 -0
  175. package/dist/shared/zt8y0wzb.js +132 -0
  176. package/dist/shared/{p0cbr3g2.js → zwmqxb0g.js} +1 -1
  177. package/dist/tooling/cli.js +14 -10
  178. package/dist/tooling/migrate/commands.d.ts +10 -0
  179. package/dist/tooling/migrate/engine.d.ts +36 -0
  180. package/package.json +56 -4
  181. package/dist/shared/gk7cs7sp.js +0 -566
@@ -0,0 +1,158 @@
1
+ import {
2
+ ColumnBuilder2
3
+ } from "./dd4f8mnx.js";
4
+ import {
5
+ definition
6
+ } from "./xatfg0gn.js";
7
+ import {
8
+ OkmError2
9
+ } from "./52szzakm.js";
10
+
11
+ // src/runtime/validate/places.ts
12
+ function assertValidation(schema) {
13
+ const record = schema;
14
+ const tables = record.tables;
15
+ if (tables === undefined)
16
+ return;
17
+ for (const item of tables)
18
+ validationGate(record.validation, item);
19
+ }
20
+ function validationGate(schemaFlag, table) {
21
+ return buildGate(schemaFlag, table);
22
+ }
23
+ function writeWouldValidate(schemaFlag, table, options) {
24
+ if (options.validate === false)
25
+ return false;
26
+ const setting = tableSetting(readSetting(schemaFlag, "schema()"), table.options);
27
+ if (setting.enabled)
28
+ return true;
29
+ const section = table.options;
30
+ if (section?.validate !== undefined)
31
+ return true;
32
+ for (const builder of Object.values(table.columns)) {
33
+ if (builder instanceof ColumnBuilder2 && builder.state.validate !== undefined)
34
+ return true;
35
+ }
36
+ return false;
37
+ }
38
+ function buildGate(schemaFlag, table) {
39
+ const setting = tableSetting(readSetting(schemaFlag, "schema()"), table.options);
40
+ const section = readSection(table.name, table.options);
41
+ if (setting.style === "inline" && section.rowPresent)
42
+ conflict(table.name, "$row");
43
+ const fields = {};
44
+ const required = [];
45
+ const notNull = [];
46
+ const pick = {};
47
+ const names = new Set;
48
+ for (const [field, builder] of Object.entries(table.columns)) {
49
+ if (!(builder instanceof ColumnBuilder2))
50
+ continue;
51
+ names.add(field);
52
+ const inline = builder.state.validate?.rules;
53
+ const named = Object.hasOwn(section.fields, field) ? section.fields[field] : undefined;
54
+ const rules = takeRules(table.name, field, inline, named, setting.style);
55
+ if (rules !== undefined)
56
+ fields[field] = rules;
57
+ const state = builder.state;
58
+ const writable = state.guarded !== true && state.omitWrite !== true && state.generated === undefined;
59
+ if (setting.enabled && writable) {
60
+ if (!state.nullable && state.hasDefault !== true)
61
+ required.push(field);
62
+ if (!state.nullable)
63
+ notNull.push(field);
64
+ if (state.picklist !== undefined)
65
+ pick[field] = state.picklist.values;
66
+ }
67
+ }
68
+ for (const field of Object.keys(section.fields)) {
69
+ if (!names.has(field))
70
+ definition(`Table ${table.name} validate.${field} is not a column.`);
71
+ }
72
+ if (!setting.enabled)
73
+ return;
74
+ return { onRead: setting.onRead, row: section.row, fields, required, notNull, pick };
75
+ }
76
+ function readSetting(value, where) {
77
+ if (value === undefined || value === false)
78
+ return { enabled: false, onRead: false, style: undefined };
79
+ if (value === true)
80
+ return { enabled: true, onRead: false, style: undefined };
81
+ if (isPlain(value)) {
82
+ return {
83
+ enabled: value.enabled === undefined ? true : value.enabled === true,
84
+ onRead: value.onRead === true,
85
+ style: readStyle(value.style)
86
+ };
87
+ }
88
+ definition(`${where} validation must be a boolean or { enabled, onRead, style }.`);
89
+ }
90
+ function tableSetting(schemaSetting, options) {
91
+ const value = options === undefined ? undefined : options.validation;
92
+ if (value === undefined)
93
+ return schemaSetting;
94
+ if (value === true)
95
+ return { enabled: true, onRead: schemaSetting.onRead, style: schemaSetting.style };
96
+ if (value === false)
97
+ return { enabled: false, onRead: schemaSetting.onRead, style: schemaSetting.style };
98
+ if (isPlain(value)) {
99
+ return {
100
+ enabled: value.enabled === undefined ? true : value.enabled === true,
101
+ onRead: value.onRead === undefined ? schemaSetting.onRead : value.onRead === true,
102
+ style: value.style === undefined ? schemaSetting.style : readStyle(value.style)
103
+ };
104
+ }
105
+ definition("table() validation must be a boolean or { enabled, onRead, style }.");
106
+ }
107
+ function readStyle(value) {
108
+ if (value === undefined)
109
+ return;
110
+ if (value === "inline" || value === "section")
111
+ return value;
112
+ definition("validation.style must be inline or section.");
113
+ }
114
+ function readSection(table, options) {
115
+ const validate = options === undefined ? undefined : options.validate;
116
+ if (validate === undefined)
117
+ return { fields: {}, row: [], rowPresent: false };
118
+ if (!isPlain(validate)) {
119
+ definition(`Table ${table} option validate must be { field: rules, $row: rules }.`);
120
+ }
121
+ const fields = {};
122
+ let row = [];
123
+ let rowPresent = false;
124
+ for (const key of Object.keys(validate)) {
125
+ const item = validate[key];
126
+ if (!Array.isArray(item))
127
+ definition(`Table ${table} validate.${key} must be a list of rules.`);
128
+ if (key === "$row") {
129
+ row = item;
130
+ rowPresent = true;
131
+ } else
132
+ fields[key] = item;
133
+ }
134
+ return { fields, row, rowPresent };
135
+ }
136
+ function takeRules(table, field, inline, section, style) {
137
+ const hasInline = inline !== undefined;
138
+ const hasSection = section !== undefined;
139
+ if (hasInline && hasSection || style === "inline" && hasSection || style === "section" && hasInline) {
140
+ conflict(table, field);
141
+ }
142
+ if (hasInline && inline.length > 0)
143
+ return inline;
144
+ if (hasSection && section.length > 0)
145
+ return section;
146
+ return;
147
+ }
148
+ function conflict(table, field) {
149
+ throw new OkmError2("OKM1030", `Field ${table}.${field} is validated in two places. Keep the column rules or the validate section.`, {
150
+ ...field === "$row" ? {} : { columns: [field] },
151
+ fix: { summary: "Keep one validation for the field." }
152
+ });
153
+ }
154
+ function isPlain(value) {
155
+ return typeof value === "object" && value !== null && !Array.isArray(value);
156
+ }
157
+
158
+ export { assertValidation, validationGate, writeWouldValidate };
@@ -0,0 +1,138 @@
1
+ import {
2
+ assertOperatorFits,
3
+ sqlType,
4
+ assertNoControl,
5
+ assertBoundText,
6
+ assertRegconfig,
7
+ textArray
8
+ } from "./zt8y0wzb.js";
9
+ import {
10
+ installOperatorSql,
11
+ isRecord,
12
+ fail
13
+ } from "./xrfnq5k8.js";
14
+ import {
15
+ isOperator,
16
+ operatorName,
17
+ operatorValue
18
+ } from "./cn0n68ft.js";
19
+
20
+ // src/runtime/operator-sql.ts
21
+ function emitStructured(column, ref, name, value, sink) {
22
+ if (name === "contains" || name === "containedBy" || name === "overlaps") {
23
+ emitContainment(column, ref, name, value, sink);
24
+ return;
25
+ }
26
+ if (name === "hasKey" || name === "hasAnyKey") {
27
+ emitJsonKey(column, ref, name, value, sink);
28
+ return;
29
+ }
30
+ if (name === "path") {
31
+ emitPath(column, ref, value, sink);
32
+ return;
33
+ }
34
+ if (name === "matches") {
35
+ emitMatches(column, ref, value, sink);
36
+ return;
37
+ }
38
+ assertOperatorFits(column, name);
39
+ fail("OKM1121", `${name} is not a value operator on ${column.field}. Use has, none, or every on a relation.`);
40
+ }
41
+ function emitContainment(column, ref, name, value, sink) {
42
+ assertOperatorFits(column, name);
43
+ const op = name === "contains" ? " @> " : name === "containedBy" ? " <@ " : " && ";
44
+ sink.text(ref);
45
+ sink.text(op);
46
+ sink.param(column.encode(value));
47
+ sink.text("::");
48
+ sink.text(sqlType(column.dataType, column));
49
+ }
50
+ function emitJsonKey(column, ref, name, value, sink) {
51
+ assertOperatorFits(column, name);
52
+ if (name === "hasKey") {
53
+ if (typeof value !== "string")
54
+ fail("OKM1121", `hasKey on ${column.field} needs a key.`);
55
+ assertBoundText(value, `key on ${column.field}`);
56
+ sink.text("jsonb_exists(");
57
+ sink.text(ref);
58
+ sink.text(", ");
59
+ sink.param(value);
60
+ sink.text(")");
61
+ return;
62
+ }
63
+ if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) {
64
+ fail("OKM1121", `hasAnyKey on ${column.field} needs a list of keys.`);
65
+ }
66
+ sink.text("jsonb_exists_any(");
67
+ sink.text(ref);
68
+ sink.text(", ");
69
+ sink.param(textArray(value, `key on ${column.field}`));
70
+ sink.text("::text[])");
71
+ }
72
+ function emitPath(column, ref, value, sink) {
73
+ assertOperatorFits(column, "path");
74
+ if (!isRecord(value) || !Array.isArray(value.segments) || !isOperator(value.op)) {
75
+ fail("OKM1121", `path on ${column.field} needs segments and a comparison.`);
76
+ }
77
+ const segments = value.segments;
78
+ if (segments.length === 0 || segments.some((item) => typeof item !== "string")) {
79
+ fail("OKM1121", `path on ${column.field} needs a list of segments.`);
80
+ }
81
+ const opName = operatorName(value.op);
82
+ if (opName !== "eq" && opName !== "lt" && opName !== "lte" && opName !== "gt" && opName !== "gte") {
83
+ fail("OKM1121", `path on ${column.field} compares with eq, lt, lte, gt, or gte.`);
84
+ }
85
+ const operand = operatorValue(value.op);
86
+ const cast = pathCast(column, operand);
87
+ const sql = opName === "eq" ? " = " : opName === "lt" ? " < " : opName === "lte" ? " <= " : opName === "gt" ? " > " : " >= ";
88
+ sink.text("(");
89
+ sink.text(ref);
90
+ sink.text(" #>> ");
91
+ sink.param(textArray(segments, `path on ${column.field}`));
92
+ sink.text("::text[])::");
93
+ sink.text(cast);
94
+ sink.text(sql);
95
+ sink.param(pathParam(operand));
96
+ }
97
+ function pathCast(column, operand) {
98
+ if (typeof operand === "number")
99
+ return "numeric";
100
+ if (typeof operand === "boolean")
101
+ return "boolean";
102
+ if (typeof operand === "string")
103
+ return "text";
104
+ fail("OKM1121", `path on ${column.field} compares a string, number, or boolean.`);
105
+ }
106
+ function pathParam(operand) {
107
+ if (typeof operand === "number")
108
+ return String(operand);
109
+ if (typeof operand === "boolean")
110
+ return operand ? "true" : "false";
111
+ if (typeof operand === "string")
112
+ return operand;
113
+ return "";
114
+ }
115
+ function emitMatches(column, ref, value, sink) {
116
+ assertOperatorFits(column, "matches");
117
+ if (!isRecord(value) || typeof value.query !== "string") {
118
+ fail("OKM1121", `matches on ${column.field} needs search text.`);
119
+ }
120
+ assertNoControl(value.query, `matches on ${column.field}`);
121
+ const mode = value.mode ?? "websearch";
122
+ const fn = mode === "websearch" ? "websearch_to_tsquery" : mode === "plain" ? "plainto_tsquery" : mode === "phrase" ? "phraseto_tsquery" : undefined;
123
+ if (fn === undefined) {
124
+ fail("OKM1121", `matches on ${column.field} mode must be websearch, plain, or phrase.`);
125
+ }
126
+ sink.text(ref);
127
+ sink.text(" @@ ");
128
+ sink.text(fn);
129
+ sink.text("(");
130
+ if (typeof value.config === "string") {
131
+ assertRegconfig(value.config);
132
+ sink.param(value.config);
133
+ sink.text("::regconfig, ");
134
+ }
135
+ sink.param(value.query);
136
+ sink.text(")");
137
+ }
138
+ installOperatorSql(emitStructured);
@@ -0,0 +1,62 @@
1
+ // src/contracts/catalog/types.ts
2
+ var OWNERS2 = ["managed", "external", "ignored"];
3
+ var OBJECT_KINDS2 = [
4
+ "table",
5
+ "column",
6
+ "index",
7
+ "constraint",
8
+ "sequence",
9
+ "view",
10
+ "materializedView",
11
+ "type",
12
+ "function",
13
+ "trigger",
14
+ "policy",
15
+ "extension",
16
+ "role",
17
+ "grant",
18
+ "defaultPrivilege"
19
+ ];
20
+ var BUILT_KINDS2 = ["table", "column", "index", "constraint", "sequence", "type"];
21
+ var OBJECT_OPERATIONS2 = [
22
+ "create",
23
+ "replace",
24
+ "alter",
25
+ "drop",
26
+ "recreateWithDependents"
27
+ ];
28
+ var KIND_OPERATIONS2 = {
29
+ table: ["create", "alter", "drop", "recreateWithDependents"],
30
+ column: ["create", "alter", "drop", "recreateWithDependents"],
31
+ index: ["create", "drop", "recreateWithDependents"],
32
+ constraint: ["create", "alter", "drop", "recreateWithDependents"],
33
+ sequence: ["create", "alter", "drop"],
34
+ view: ["create", "replace", "drop", "recreateWithDependents"],
35
+ materializedView: ["create", "drop", "recreateWithDependents"],
36
+ type: ["create", "alter", "drop"],
37
+ function: ["create", "replace", "drop", "recreateWithDependents"],
38
+ trigger: ["create", "drop", "recreateWithDependents"],
39
+ policy: ["create", "alter", "drop"],
40
+ extension: ["create", "alter", "drop"],
41
+ role: ["create", "alter"],
42
+ grant: ["create", "drop"],
43
+ defaultPrivilege: ["create", "alter", "drop"]
44
+ };
45
+ var REFERENTIAL_ACTIONS = [
46
+ "cascade",
47
+ "no action",
48
+ "restrict",
49
+ "set default",
50
+ "set null"
51
+ ];
52
+ function referentialAction(value) {
53
+ for (const action of REFERENTIAL_ACTIONS) {
54
+ if (action === value) {
55
+ return action;
56
+ }
57
+ }
58
+ return;
59
+ }
60
+ var CATALOG_VERSION2 = 1;
61
+
62
+ export { OWNERS2, OBJECT_KINDS2, BUILT_KINDS2, OBJECT_OPERATIONS2, KIND_OPERATIONS2, REFERENTIAL_ACTIONS, referentialAction, CATALOG_VERSION2 };