okmodel 0.0.0 → 0.1.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 (147) hide show
  1. package/README.md +246 -1
  2. package/dist/adapters/capabilities.d.ts +62 -0
  3. package/dist/adapters/error.d.ts +91 -0
  4. package/dist/adapters/failure.d.ts +39 -0
  5. package/dist/adapters/pg/batch.d.ts +36 -0
  6. package/dist/adapters/pg/call.d.ts +59 -0
  7. package/dist/adapters/pg/pglite.d.ts +21 -0
  8. package/dist/adapters/pg/postgres-extra.d.ts +43 -0
  9. package/dist/adapters/pg/postgresjs.d.ts +95 -0
  10. package/dist/adapters/pg/result.d.ts +30 -0
  11. package/dist/contracts/catalog/build.d.ts +18 -0
  12. package/dist/contracts/catalog/document.d.ts +79 -0
  13. package/dist/contracts/catalog/enum.d.ts +35 -0
  14. package/dist/contracts/catalog/identifier.d.ts +71 -0
  15. package/dist/contracts/catalog/identity.d.ts +98 -0
  16. package/dist/contracts/catalog/index.d.ts +11 -0
  17. package/dist/contracts/catalog/json.d.ts +17 -0
  18. package/dist/contracts/catalog/object.d.ts +142 -0
  19. package/dist/contracts/catalog/order.d.ts +43 -0
  20. package/dist/contracts/catalog/rewrite.d.ts +18 -0
  21. package/dist/contracts/catalog/types.d.ts +292 -0
  22. package/dist/contracts/catalog/words.d.ts +13 -0
  23. package/dist/contracts/connection.d.ts +33 -0
  24. package/dist/contracts/driver.d.ts +163 -0
  25. package/dist/contracts/error.d.ts +298 -0
  26. package/dist/contracts/index.d.ts +11 -0
  27. package/dist/contracts/index.js +16 -0
  28. package/dist/contracts/internal.d.ts +15 -0
  29. package/dist/contracts/internal.js +68 -0
  30. package/dist/contracts/nearest.d.ts +15 -0
  31. package/dist/contracts/rows.d.ts +84 -0
  32. package/dist/contracts/sha256.d.ts +14 -0
  33. package/dist/contracts/utf8.d.ts +33 -0
  34. package/dist/dialects/pg/array-literal.d.ts +25 -0
  35. package/dist/dialects/pg/bool.d.ts +46 -0
  36. package/dist/dialects/pg/column.d.ts +386 -0
  37. package/dist/dialects/pg/compile.d.ts +81 -0
  38. package/dist/dialects/pg/custom.d.ts +21 -0
  39. package/dist/dialects/pg/ddl.d.ts +70 -0
  40. package/dist/dialects/pg/decimal.d.ts +62 -0
  41. package/dist/dialects/pg/declarations.d.ts +34 -0
  42. package/dist/dialects/pg/emit.d.ts +18 -0
  43. package/dist/dialects/pg/enum.d.ts +30 -0
  44. package/dist/dialects/pg/errors.d.ts +30 -0
  45. package/dist/dialects/pg/finite.d.ts +15 -0
  46. package/dist/dialects/pg/geometry.d.ts +55 -0
  47. package/dist/dialects/pg/index.d.ts +45 -0
  48. package/dist/dialects/pg/index.js +1821 -0
  49. package/dist/dialects/pg/integer.d.ts +96 -0
  50. package/dist/dialects/pg/introspect.d.ts +43 -0
  51. package/dist/dialects/pg/json.d.ts +43 -0
  52. package/dist/dialects/pg/keys.d.ts +32 -0
  53. package/dist/dialects/pg/misuse.d.ts +31 -0
  54. package/dist/dialects/pg/model.d.ts +71 -0
  55. package/dist/dialects/pg/namespace.d.ts +63 -0
  56. package/dist/dialects/pg/network.d.ts +28 -0
  57. package/dist/dialects/pg/operators.d.ts +71 -0
  58. package/dist/dialects/pg/ops/between.d.ts +10 -0
  59. package/dist/dialects/pg/ops/contains.d.ts +8 -0
  60. package/dist/dialects/pg/ops/endsWith.d.ts +8 -0
  61. package/dist/dialects/pg/ops/eq.d.ts +9 -0
  62. package/dist/dialects/pg/ops/every.d.ts +9 -0
  63. package/dist/dialects/pg/ops/gt.d.ts +9 -0
  64. package/dist/dialects/pg/ops/gte.d.ts +9 -0
  65. package/dist/dialects/pg/ops/has.d.ts +9 -0
  66. package/dist/dialects/pg/ops/ilike.d.ts +8 -0
  67. package/dist/dialects/pg/ops/inList.d.ts +9 -0
  68. package/dist/dialects/pg/ops/inc.d.ts +13 -0
  69. package/dist/dialects/pg/ops/like.d.ts +8 -0
  70. package/dist/dialects/pg/ops/lt.d.ts +9 -0
  71. package/dist/dialects/pg/ops/lte.d.ts +9 -0
  72. package/dist/dialects/pg/ops/none.d.ts +9 -0
  73. package/dist/dialects/pg/ops/not.d.ts +9 -0
  74. package/dist/dialects/pg/ops/notIn.d.ts +9 -0
  75. package/dist/dialects/pg/ops/or.d.ts +9 -0
  76. package/dist/dialects/pg/ops/startsWith.d.ts +8 -0
  77. package/dist/dialects/pg/quote.d.ts +24 -0
  78. package/dist/dialects/pg/range.d.ts +50 -0
  79. package/dist/dialects/pg/relations.d.ts +45 -0
  80. package/dist/dialects/pg/schema.d.ts +77 -0
  81. package/dist/dialects/pg/search.d.ts +23 -0
  82. package/dist/dialects/pg/table.d.ts +201 -0
  83. package/dist/dialects/pg/temporal.d.ts +211 -0
  84. package/dist/dialects/pg/text.d.ts +44 -0
  85. package/dist/dialects/pg/time.d.ts +46 -0
  86. package/dist/okm.js +2 -0
  87. package/dist/okmodel.js +2 -0
  88. package/dist/runtime/client.d.ts +47 -0
  89. package/dist/runtime/conflict.d.ts +38 -0
  90. package/dist/runtime/drift-detail.d.ts +32 -0
  91. package/dist/runtime/drift.d.ts +29 -0
  92. package/dist/runtime/include.d.ts +15 -0
  93. package/dist/runtime/pg/pglite.d.ts +25 -0
  94. package/dist/runtime/pg/pglite.js +48 -0
  95. package/dist/runtime/pg/postgresjs.d.ts +29 -0
  96. package/dist/runtime/pg/postgresjs.js +62 -0
  97. package/dist/runtime/plan.d.ts +167 -0
  98. package/dist/runtime/tx.d.ts +29 -0
  99. package/dist/runtime/types.d.ts +385 -0
  100. package/dist/runtime/write.d.ts +48 -0
  101. package/dist/shared/05w44d8g.js +1524 -0
  102. package/dist/shared/523ft3e8.js +171 -0
  103. package/dist/shared/8b04d28c.js +14 -0
  104. package/dist/shared/cn0n68ft.js +16 -0
  105. package/dist/shared/dkn3y60a.js +374 -0
  106. package/dist/shared/dynq16vb.js +81 -0
  107. package/dist/shared/fgqgsb5z.js +281 -0
  108. package/dist/shared/g5fhqmwe.js +188 -0
  109. package/dist/shared/gk7cs7sp.js +566 -0
  110. package/dist/shared/hadrfb9h.js +398 -0
  111. package/dist/shared/hd293j9g.js +98 -0
  112. package/dist/shared/j5cn2963.js +701 -0
  113. package/dist/shared/jjb7yht9.js +37 -0
  114. package/dist/shared/kprcwaha.js +30 -0
  115. package/dist/shared/m3ypagh5.js +347 -0
  116. package/dist/shared/mkjmqjv4.js +456 -0
  117. package/dist/shared/mtkwv8wx.js +18 -0
  118. package/dist/shared/ngk8gj61.js +40 -0
  119. package/dist/shared/p0cbr3g2.js +79 -0
  120. package/dist/shared/qk3hxfja.js +83 -0
  121. package/dist/shared/rgs0st28.js +1066 -0
  122. package/dist/shared/w8samvk1.js +18 -0
  123. package/dist/shared/x5x59srr.js +566 -0
  124. package/dist/shared/xqbhg6cn.js +119 -0
  125. package/dist/shared/xy79j5hq.js +177 -0
  126. package/dist/shared/y9m15dfv.js +888 -0
  127. package/dist/shared/ycwz42az.js +412 -0
  128. package/dist/shared/yd1kzwn2.js +148 -0
  129. package/dist/shared/zhc5vmgf.js +257 -0
  130. package/dist/tooling/cli.d.ts +1 -0
  131. package/dist/tooling/cli.js +193 -0
  132. package/dist/tooling/errors/registry.d.ts +33 -0
  133. package/dist/tooling/migrate/apply.d.ts +86 -0
  134. package/dist/tooling/migrate/commands.d.ts +21 -0
  135. package/dist/tooling/migrate/config.d.ts +48 -0
  136. package/dist/tooling/migrate/dev.d.ts +16 -0
  137. package/dist/tooling/migrate/equal.d.ts +15 -0
  138. package/dist/tooling/migrate/files.d.ts +19 -0
  139. package/dist/tooling/migrate/index.d.ts +7 -0
  140. package/dist/tooling/migrate/index.js +7 -0
  141. package/dist/tooling/migrate/plan.d.ts +76 -0
  142. package/dist/tooling/migrate/policy.d.ts +78 -0
  143. package/dist/tooling/migrate/project.d.ts +69 -0
  144. package/dist/tooling/migrate/status.d.ts +74 -0
  145. package/dist/tooling/migrate/values.d.ts +29 -0
  146. package/package.json +109 -7
  147. package/dist/index.js +0 -0
@@ -0,0 +1,281 @@
1
+ import {
2
+ PGLITE_CAPABILITIES,
3
+ driverErrors,
4
+ rejectClosed,
5
+ rejectCancelled,
6
+ rejectTimedOut,
7
+ mapFailure,
8
+ nextTransactionDepth,
9
+ runCall,
10
+ EMPTY_NOTICES,
11
+ resultFrom
12
+ } from "./xy79j5hq.js";
13
+
14
+ // src/adapters/pg/pglite.ts
15
+ import { PGlite } from "@electric-sql/pglite";
16
+ var RESET_ALL = "RESET ALL";
17
+ var UNLOCK = "SELECT pg_advisory_unlock_all()";
18
+ async function open3(config = {}) {
19
+ const db = new PGlite({
20
+ dataDir: config.dataDir ?? "memory://",
21
+ parsers: WIRE,
22
+ serializers: WIRE
23
+ });
24
+ await db.waitReady;
25
+ const acquireMs = config.timeouts?.acquire;
26
+ const slot = new Slot;
27
+ const notices = noticeBuffer();
28
+ const queryOptions = {
29
+ rowMode: "array",
30
+ parsers: WIRE,
31
+ serializers: WIRE,
32
+ onNotice(notice) {
33
+ notices.push(notice);
34
+ }
35
+ };
36
+ let closed = false;
37
+ let inflight = 0;
38
+ const session = new PgliteSession(db, queryOptions, notices, () => {
39
+ inflight += 1;
40
+ }, () => {
41
+ inflight = Math.max(0, inflight - 1);
42
+ });
43
+ async function lease() {
44
+ if (closed)
45
+ return rejectClosed();
46
+ await slot.acquire(acquireMs);
47
+ let released = false;
48
+ return {
49
+ execute: (text, params, options) => runCall(closed, options, (watch) => session.query(text, params, watch)),
50
+ batch: (statements, options) => runCall(closed, options, async (watch) => {
51
+ const { runAtomicBatch } = await import("./dynq16vb.js");
52
+ return runAtomicBatch(session, statements, watch);
53
+ }),
54
+ async release() {
55
+ if (released)
56
+ return;
57
+ released = true;
58
+ try {
59
+ await reset(session);
60
+ } finally {
61
+ slot.release();
62
+ }
63
+ }
64
+ };
65
+ }
66
+ return {
67
+ capabilities: PGLITE_CAPABILITIES,
68
+ execute(text, params, options) {
69
+ return runCall(closed, options, async (watch) => {
70
+ await slot.acquire(acquireMs);
71
+ try {
72
+ return await session.query(text, params, watch);
73
+ } finally {
74
+ slot.release();
75
+ }
76
+ });
77
+ },
78
+ async batch(statements, options) {
79
+ const connection = await lease();
80
+ try {
81
+ return await connection.batch(statements, options);
82
+ } finally {
83
+ await connection.release();
84
+ }
85
+ },
86
+ reserve: () => lease(),
87
+ async describe(text) {
88
+ await slot.acquire(acquireMs);
89
+ try {
90
+ const described = await db.describeQuery(text);
91
+ return {
92
+ columns: described.resultFields.map((field) => field.name),
93
+ parameterCount: described.queryParams.length
94
+ };
95
+ } finally {
96
+ slot.release();
97
+ }
98
+ },
99
+ async listen(channel, onNotify) {
100
+ const unlisten = await db.listen(channel, onNotify);
101
+ return async () => {
102
+ await unlisten();
103
+ };
104
+ },
105
+ stats() {
106
+ return { size: 1, idle: slot.idle, inflight, waiting: slot.waiting };
107
+ },
108
+ async close() {
109
+ closed = true;
110
+ await db.close();
111
+ }
112
+ };
113
+ }
114
+
115
+ class PgliteSession {
116
+ canCancel = false;
117
+ transactionDepth = 0;
118
+ db;
119
+ options;
120
+ notices;
121
+ enter;
122
+ leave;
123
+ constructor(db, options, notices, enter, leave) {
124
+ this.db = db;
125
+ this.options = options;
126
+ this.notices = notices;
127
+ this.enter = enter;
128
+ this.leave = leave;
129
+ }
130
+ query(text, params, watch) {
131
+ const why = watch?.reason();
132
+ if (why === "timeout")
133
+ return rejectTimedOut();
134
+ if (why === "cancelled" || watch?.signal.aborted === true)
135
+ return rejectCancelled();
136
+ this.enter();
137
+ const pending = params === undefined || params.length === 0 ? this.db.query(text, undefined, this.options) : this.db.query(text, params, this.options);
138
+ return pending.then((result) => {
139
+ this.leave();
140
+ this.note(text);
141
+ return resultFrom(result, this.notices.take());
142
+ }, (error) => {
143
+ this.leave();
144
+ this.notices.take();
145
+ return mapFailure(error).then((mapped) => {
146
+ throw mapped;
147
+ });
148
+ });
149
+ }
150
+ inTransaction() {
151
+ return this.transactionDepth > 0;
152
+ }
153
+ abandon() {
154
+ this.transactionDepth = 0;
155
+ }
156
+ rollback() {
157
+ return this.query("ROLLBACK", undefined, undefined).then(() => {
158
+ this.transactionDepth = 0;
159
+ }, (error) => {
160
+ this.transactionDepth = 0;
161
+ throw error;
162
+ });
163
+ }
164
+ note(text) {
165
+ this.transactionDepth = nextTransactionDepth(this.transactionDepth, text);
166
+ }
167
+ }
168
+ function noticeBuffer() {
169
+ let notices;
170
+ return {
171
+ push(notice) {
172
+ const severity = notice.severity ?? "";
173
+ const message = notice.message ?? "";
174
+ const code = notice.code !== undefined && notice.code.length > 0 ? notice.code : undefined;
175
+ const entry = code === undefined ? { severity, message } : { severity, message, code };
176
+ (notices ??= []).push(entry);
177
+ },
178
+ take() {
179
+ const taken = notices ?? EMPTY_NOTICES;
180
+ notices = undefined;
181
+ return taken;
182
+ }
183
+ };
184
+ }
185
+
186
+ class Slot {
187
+ held = false;
188
+ waiters = [];
189
+ acquire(acquireMs) {
190
+ if (!this.held) {
191
+ this.held = true;
192
+ return Promise.resolve();
193
+ }
194
+ return new Promise((resolve, reject) => {
195
+ const waiter = {
196
+ resolve,
197
+ timer: undefined
198
+ };
199
+ if (acquireMs !== undefined) {
200
+ waiter.timer = setTimeout(() => {
201
+ const index = this.waiters.indexOf(waiter);
202
+ if (index !== -1)
203
+ this.waiters.splice(index, 1);
204
+ driverErrors().then((errors) => {
205
+ reject(errors.acquireTimeout());
206
+ });
207
+ }, acquireMs);
208
+ }
209
+ this.waiters.push(waiter);
210
+ });
211
+ }
212
+ release() {
213
+ const next = this.waiters.shift();
214
+ if (next === undefined) {
215
+ this.held = false;
216
+ return;
217
+ }
218
+ if (next.timer !== undefined)
219
+ clearTimeout(next.timer);
220
+ next.resolve();
221
+ }
222
+ get idle() {
223
+ return this.held ? 0 : 1;
224
+ }
225
+ get waiting() {
226
+ return this.waiters.length;
227
+ }
228
+ }
229
+ async function reset(session) {
230
+ if (session.inTransaction())
231
+ await session.rollback().catch(() => {
232
+ return;
233
+ });
234
+ try {
235
+ await session.query(RESET_ALL, undefined, undefined);
236
+ await session.query(UNLOCK, undefined, undefined);
237
+ } catch {
238
+ await session.rollback().catch(() => {
239
+ return;
240
+ });
241
+ await session.query(RESET_ALL, undefined, undefined);
242
+ await session.query(UNLOCK, undefined, undefined);
243
+ }
244
+ }
245
+ function wireMap(oids) {
246
+ const parsers = {};
247
+ for (const oid of oids)
248
+ parsers[oid] = (value) => value;
249
+ return parsers;
250
+ }
251
+ var WIRE = wireMap([
252
+ 16,
253
+ 17,
254
+ 20,
255
+ 21,
256
+ 23,
257
+ 25,
258
+ 114,
259
+ 700,
260
+ 701,
261
+ 1043,
262
+ 1082,
263
+ 1114,
264
+ 1184,
265
+ 1700,
266
+ 2950,
267
+ 3802,
268
+ 1000,
269
+ 1005,
270
+ 1007,
271
+ 1009,
272
+ 1016,
273
+ 1115,
274
+ 1182,
275
+ 1185,
276
+ 1231,
277
+ 199,
278
+ 3807
279
+ ]);
280
+
281
+ export { open3 };
@@ -0,0 +1,188 @@
1
+ import {
2
+ CATALOG_VERSION2,
3
+ assertNamespace2,
4
+ identityKey2,
5
+ identityLabel2,
6
+ normaliseEdges,
7
+ compareText,
8
+ assertProvenance
9
+ } from "./j5cn2963.js";
10
+ import {
11
+ assertIdentifier2,
12
+ assertStoredText
13
+ } from "./mkjmqjv4.js";
14
+ import {
15
+ catalogError2
16
+ } from "./ycwz42az.js";
17
+
18
+ // src/contracts/catalog/order.ts
19
+ function indexObjects(objects) {
20
+ const seen = new Set;
21
+ const indexed = [];
22
+ for (const object of objects) {
23
+ const key = identityKey2(object.identity);
24
+ if (seen.has(key)) {
25
+ catalogError2("OKM1023", `Duplicate identity for ${identityLabel2(object.identity)}.`);
26
+ }
27
+ seen.add(key);
28
+ indexed.push({ key, object });
29
+ }
30
+ return indexed;
31
+ }
32
+ function dependencyOrder(objects) {
33
+ return orderIndexed(indexObjects(objects));
34
+ }
35
+ function orderIndexed(indexed) {
36
+ const byKey = new Map;
37
+ for (const item of indexed) {
38
+ byKey.set(item.key, item.object);
39
+ }
40
+ const dependents = new Map;
41
+ const remaining = new Map;
42
+ for (const item of indexed) {
43
+ dependents.set(item.key, []);
44
+ remaining.set(item.key, 0);
45
+ }
46
+ for (const item of indexed) {
47
+ const seen = new Set;
48
+ for (const edge of item.object.dependencies) {
49
+ const dependency = identityKey2(edge.target);
50
+ if (dependency === item.key) {
51
+ catalogError2("OKM1020", `${identityLabel2(item.object.identity)} depends on itself.`);
52
+ }
53
+ if (!byKey.has(dependency)) {
54
+ catalogError2("OKM1020", `${identityLabel2(item.object.identity)} depends on ${identityLabel2(edge.target)}, which is not in the catalog.`);
55
+ }
56
+ if (seen.has(dependency)) {
57
+ continue;
58
+ }
59
+ seen.add(dependency);
60
+ remaining.set(item.key, (remaining.get(item.key) ?? 0) + 1);
61
+ dependents.get(dependency)?.push(item.key);
62
+ }
63
+ }
64
+ const ready = indexed.filter((item) => remaining.get(item.key) === 0).map((item) => item.key);
65
+ ready.sort(compareText);
66
+ const ordered = [];
67
+ let cursor = 0;
68
+ while (cursor < ready.length) {
69
+ const key = ready[cursor];
70
+ if (key === undefined) {
71
+ break;
72
+ }
73
+ cursor += 1;
74
+ const object = byKey.get(key);
75
+ if (object === undefined) {
76
+ catalogError2("OKM1020", "Dependency order lost an object while sorting.");
77
+ }
78
+ ordered.push(object);
79
+ for (const dependent of dependents.get(key) ?? []) {
80
+ const left = (remaining.get(dependent) ?? 0) - 1;
81
+ remaining.set(dependent, left);
82
+ if (left === 0) {
83
+ insertSorted(ready, cursor, dependent);
84
+ }
85
+ }
86
+ }
87
+ if (ordered.length !== byKey.size) {
88
+ catalogError2("OKM1026", "Catalog has a dependency cycle.");
89
+ }
90
+ return ordered;
91
+ }
92
+ function insertSorted(ready, from, key) {
93
+ let index = from;
94
+ while (index < ready.length && compareText(ready[index] ?? "", key) < 0) {
95
+ index += 1;
96
+ }
97
+ ready.splice(index, 0, key);
98
+ }
99
+
100
+ // src/contracts/catalog/build.ts
101
+ function catalog(objects) {
102
+ for (const object of objects) {
103
+ if (object.kind !== object.identity.kind) {
104
+ catalogError2("OKM1020", `${identityLabel2(object.identity)} has kind ${object.kind}.`);
105
+ }
106
+ }
107
+ const indexed = indexObjects(objects);
108
+ const keys = new Set;
109
+ for (const item of indexed) {
110
+ keys.add(item.key);
111
+ }
112
+ assertForeignKeys(objects, keys);
113
+ orderIndexed(indexed);
114
+ const sorted = [...indexed].sort((left, right) => compareText(left.key, right.key));
115
+ return { version: CATALOG_VERSION2, objects: sorted.map((item) => item.object) };
116
+ }
117
+ function assertForeignKeys(objects, keys) {
118
+ for (const object of objects) {
119
+ if (object.kind !== "constraint" || object.definition.constraintKind !== "foreignKey") {
120
+ continue;
121
+ }
122
+ const references = object.definition.references;
123
+ if (references === undefined) {
124
+ catalogError2("OKM1021", `Foreign key ${object.identity.name} is missing its target.`);
125
+ }
126
+ const tableKey = identityKey2({
127
+ kind: "table",
128
+ namespace: references.parent.namespace,
129
+ name: references.parent.name
130
+ });
131
+ if (!keys.has(tableKey)) {
132
+ catalogError2("OKM1021", `Foreign key ${object.identity.name} references missing table ${references.parent.name}.`);
133
+ }
134
+ for (const name of references.columns) {
135
+ const columnKey = identityKey2({ kind: "column", parent: references.parent, name });
136
+ if (!keys.has(columnKey)) {
137
+ catalogError2("OKM1021", `Foreign key ${object.identity.name} references missing column ${name}.`);
138
+ }
139
+ }
140
+ }
141
+ }
142
+
143
+ // src/contracts/catalog/enum.ts
144
+ function enumType(input) {
145
+ assertNamespace2(input.namespace);
146
+ assertIdentifier2(input.name, "type");
147
+ assertProvenance(input.provenance);
148
+ if (input.labels.length === 0) {
149
+ catalogError2("OKM1020", `Enum ${input.name} must list at least one label.`);
150
+ }
151
+ const labels = [];
152
+ const seen = new Set;
153
+ for (const label of input.labels) {
154
+ assertStoredText(label, "enum label");
155
+ if (label.length === 0) {
156
+ catalogError2("OKM1020", `Enum ${input.name} has an empty label.`);
157
+ }
158
+ if (seen.has(label)) {
159
+ catalogError2("OKM1020", `Enum ${input.name} repeats label ${label}.`);
160
+ }
161
+ seen.add(label);
162
+ labels.push(label);
163
+ }
164
+ const identity = {
165
+ kind: "type",
166
+ namespace: input.namespace,
167
+ name: input.name
168
+ };
169
+ return {
170
+ kind: "type",
171
+ identity,
172
+ owner: input.owner ?? "managed",
173
+ definition: { labels },
174
+ dependencies: normaliseEdges(input.dependencies ?? []),
175
+ provenance: input.provenance
176
+ };
177
+ }
178
+ function sameEnumLabels(left, right) {
179
+ if (left.length !== right.length)
180
+ return false;
181
+ for (let index = 0;index < left.length; index += 1) {
182
+ if (left[index] !== right[index])
183
+ return false;
184
+ }
185
+ return true;
186
+ }
187
+
188
+ export { dependencyOrder, catalog, enumType, sameEnumLabels };