data-finder-ts 0.1.0 → 0.1.4

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 (64) hide show
  1. package/README.md +17 -55
  2. package/dist/chunk-4JVW4TAB.js +180 -0
  3. package/dist/chunk-4JVW4TAB.js.map +1 -0
  4. package/dist/chunk-4LNZV6EN.js +500 -0
  5. package/dist/chunk-4LNZV6EN.js.map +1 -0
  6. package/dist/chunk-FJYA2ASS.js +136 -0
  7. package/dist/chunk-FJYA2ASS.js.map +1 -0
  8. package/dist/chunk-FLEIUDZZ.js +14 -0
  9. package/dist/chunk-FLEIUDZZ.js.map +1 -0
  10. package/dist/chunk-MH4XMYVB.js +696 -0
  11. package/dist/chunk-MH4XMYVB.js.map +1 -0
  12. package/dist/chunk-PMPLCEWQ.js +90 -0
  13. package/dist/chunk-PMPLCEWQ.js.map +1 -0
  14. package/dist/chunk-UYMOE6YU.js +509 -0
  15. package/dist/chunk-UYMOE6YU.js.map +1 -0
  16. package/dist/datafinder/attribute.cjs +320 -0
  17. package/dist/datafinder/attribute.cjs.map +1 -0
  18. package/dist/datafinder/attribute.d.cts +86 -0
  19. package/dist/datafinder/attribute.d.ts +86 -0
  20. package/dist/datafinder/attribute.js +8 -0
  21. package/dist/datafinder/attribute.js.map +1 -0
  22. package/dist/datafinder/finder-registry.cjs +39 -0
  23. package/dist/datafinder/finder-registry.cjs.map +1 -0
  24. package/dist/datafinder/finder-registry.d.cts +4 -0
  25. package/dist/datafinder/finder-registry.d.ts +4 -0
  26. package/dist/datafinder/finder-registry.js +9 -0
  27. package/dist/datafinder/finder-registry.js.map +1 -0
  28. package/dist/datafinder/runner.cjs +1595 -0
  29. package/dist/datafinder/runner.cjs.map +1 -0
  30. package/dist/datafinder/runner.d.cts +44 -0
  31. package/dist/datafinder/runner.d.ts +44 -0
  32. package/dist/datafinder/runner.js +26 -0
  33. package/dist/datafinder/runner.js.map +1 -0
  34. package/dist/datafinder/sql-generator.cjs +1467 -0
  35. package/dist/datafinder/sql-generator.cjs.map +1 -0
  36. package/dist/datafinder/sql-generator.d.cts +8 -0
  37. package/dist/datafinder/sql-generator.d.ts +8 -0
  38. package/dist/datafinder/sql-generator.js +15 -0
  39. package/dist/datafinder/sql-generator.js.map +1 -0
  40. package/dist/datafinder/typed-attributes.cjs +909 -0
  41. package/dist/datafinder/typed-attributes.cjs.map +1 -0
  42. package/dist/datafinder/typed-attributes.d.cts +242 -0
  43. package/dist/datafinder/typed-attributes.d.ts +242 -0
  44. package/dist/datafinder/typed-attributes.js +25 -0
  45. package/dist/datafinder/typed-attributes.js.map +1 -0
  46. package/dist/index.cjs +2153 -0
  47. package/dist/index.cjs.map +1 -0
  48. package/dist/index.d.cts +28 -0
  49. package/dist/index.d.ts +28 -0
  50. package/dist/index.js +199 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/model/milestoning.cjs +145 -0
  53. package/dist/model/milestoning.cjs.map +1 -0
  54. package/dist/model/milestoning.d.cts +40 -0
  55. package/dist/model/milestoning.d.ts +40 -0
  56. package/dist/model/milestoning.js +18 -0
  57. package/dist/model/milestoning.js.map +1 -0
  58. package/dist/model/relational.cjs +579 -0
  59. package/dist/model/relational.cjs.map +1 -0
  60. package/dist/model/relational.d.cts +291 -0
  61. package/dist/model/relational.d.ts +291 -0
  62. package/dist/model/relational.js +99 -0
  63. package/dist/model/relational.js.map +1 -0
  64. package/package.json +6 -4
@@ -0,0 +1,320 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/datafinder/attribute.ts
21
+ var attribute_exports = {};
22
+ __export(attribute_exports, {
23
+ Attribute: () => Attribute
24
+ });
25
+ module.exports = __toCommonJS(attribute_exports);
26
+
27
+ // src/model/relational.ts
28
+ var RelationalOperationElement = class {
29
+ };
30
+ var Operation = class extends RelationalOperationElement {
31
+ andOp(other) {
32
+ return new LogicalOperation(this, "AND" /* AND */, other);
33
+ }
34
+ };
35
+ var UnaryOperation = class extends Operation {
36
+ constructor(element) {
37
+ super();
38
+ this.element = element;
39
+ }
40
+ element;
41
+ };
42
+ var BinaryOperation = class extends Operation {
43
+ constructor(left, right) {
44
+ super();
45
+ this.left = left;
46
+ this.right = right;
47
+ }
48
+ left;
49
+ right;
50
+ };
51
+ var IsNullOperation = class extends UnaryOperation {
52
+ };
53
+ var IsNotNullOperation = class extends UnaryOperation {
54
+ };
55
+ var LogicalOperation = class extends BinaryOperation {
56
+ constructor(left, operator, right) {
57
+ super(left, right);
58
+ this.operator = operator;
59
+ }
60
+ operator;
61
+ };
62
+ var WindowSpecification = class {
63
+ constructor(partitionBy = [], orderBy = []) {
64
+ this.partitionBy = partitionBy;
65
+ this.orderBy = orderBy;
66
+ }
67
+ partitionBy;
68
+ orderBy;
69
+ };
70
+ var AggregateOperation = class _AggregateOperation extends UnaryOperation {
71
+ constructor(element, operator, displayName, window) {
72
+ super(element);
73
+ this.operator = operator;
74
+ this.displayName = displayName;
75
+ this.window = window;
76
+ }
77
+ operator;
78
+ displayName;
79
+ window;
80
+ over(partitionBy, orderBy) {
81
+ return new _AggregateOperation(
82
+ this.element,
83
+ this.operator,
84
+ this.displayName,
85
+ new WindowSpecification(partitionBy ?? [], orderBy ?? [])
86
+ );
87
+ }
88
+ };
89
+ var WindowFunctionOperation = class _WindowFunctionOperation extends UnaryOperation {
90
+ constructor(element, func, displayName, secondArg, extraArgs = [], window) {
91
+ super(element);
92
+ this.func = func;
93
+ this.displayName = displayName;
94
+ this.secondArg = secondArg;
95
+ this.extraArgs = extraArgs;
96
+ this.window = window;
97
+ }
98
+ func;
99
+ displayName;
100
+ secondArg;
101
+ extraArgs;
102
+ window;
103
+ over(partitionBy, orderBy) {
104
+ return new _WindowFunctionOperation(
105
+ this.element,
106
+ this.func,
107
+ this.displayName,
108
+ this.secondArg,
109
+ [...this.extraArgs],
110
+ new WindowSpecification(partitionBy ?? [], orderBy ?? [])
111
+ );
112
+ }
113
+ };
114
+ var Column = class extends RelationalOperationElement {
115
+ constructor(name, type, owner, primaryKey = false) {
116
+ super();
117
+ this.name = name;
118
+ this.type = type;
119
+ this.owner = owner;
120
+ this.primaryKey = primaryKey;
121
+ }
122
+ name;
123
+ type;
124
+ owner;
125
+ primaryKey;
126
+ table;
127
+ };
128
+ var ColumnWithJoin = class extends RelationalOperationElement {
129
+ /**
130
+ * `embedded` is an alternate reference to a flat (denormalized) column on the owning table that
131
+ * holds the same value without the join; the SQL generator uses it when the join can be elided.
132
+ */
133
+ constructor(column, parent, embedded) {
134
+ super();
135
+ this.column = column;
136
+ this.parent = parent;
137
+ this.embedded = embedded;
138
+ }
139
+ column;
140
+ parent;
141
+ embedded;
142
+ };
143
+ var SortOperation = class {
144
+ constructor(column, direction) {
145
+ this.column = column;
146
+ this.direction = direction;
147
+ }
148
+ column;
149
+ direction;
150
+ };
151
+
152
+ // src/datafinder/attribute.ts
153
+ var Attribute = class _Attribute {
154
+ _displayName;
155
+ _column;
156
+ _owner;
157
+ _parent;
158
+ _embedded;
159
+ constructor(displayName, columnName, columnDbType, owner, parent, embedded) {
160
+ this._displayName = displayName;
161
+ this._column = new Column(columnName, columnDbType, owner);
162
+ this._owner = owner;
163
+ this._parent = parent;
164
+ this._embedded = embedded;
165
+ }
166
+ column() {
167
+ return this._column;
168
+ }
169
+ owner() {
170
+ return this._owner;
171
+ }
172
+ parent() {
173
+ return this._parent;
174
+ }
175
+ displayName() {
176
+ return this._displayName;
177
+ }
178
+ /** Alternate attribute on a flat column of the owning table, used in place of this one when its join is elided. */
179
+ embedded() {
180
+ return this._embedded;
181
+ }
182
+ cwj() {
183
+ return new ColumnWithJoin(this._column, this._parent, this._embedded?.cwj());
184
+ }
185
+ /** Count the number of non-null values. Use in a projection with `groupByOp` to aggregate per group. */
186
+ count() {
187
+ return new AggregateOperation(
188
+ this.cwj(),
189
+ "COUNT" /* COUNT */,
190
+ this._displayName + " Count"
191
+ );
192
+ }
193
+ /** Sort this attribute in ascending order. Pass to `orderByOp` or a window function's `orderBy`. */
194
+ ascending() {
195
+ return new SortOperation(this.cwj(), "ASC" /* ASC */);
196
+ }
197
+ /** Sort this attribute in descending order. Pass to `orderByOp` or a window function's `orderBy`. */
198
+ descending() {
199
+ return new SortOperation(this.cwj(), "DESC" /* DESC */);
200
+ }
201
+ /** Filter to rows where this attribute has no value. */
202
+ isNull() {
203
+ return new IsNullOperation(this.cwj());
204
+ }
205
+ /** Filter to rows where this attribute has a value. */
206
+ isNotNull() {
207
+ return new IsNotNullOperation(this.cwj());
208
+ }
209
+ _windowSpec(partitionBy, orderBy) {
210
+ const pbArr = partitionBy === void 0 ? [] : Array.isArray(partitionBy) ? partitionBy : [partitionBy];
211
+ const pb = pbArr.map((x) => x instanceof _Attribute ? x.cwj() : x);
212
+ const ob = orderBy === void 0 ? [] : Array.isArray(orderBy) ? orderBy : [orderBy];
213
+ return new WindowSpecification(pb, ob);
214
+ }
215
+ /**
216
+ * Assign a rank to each row within the ordered window, following pandas `Series.rank` conventions.
217
+ *
218
+ * `method` controls tie-breaking (default `'min'`):
219
+ * - `'min'` — tied rows share the lowest rank; the next rank skips.
220
+ * - `'dense'` — like `'min'` but ranks are contiguous (no gaps).
221
+ * - `'first'` — each row gets a unique sequential integer (no ties).
222
+ * - `'max'` — only meaningful with `pct: true` (see below).
223
+ *
224
+ * When `pct: true` the result is a relative rank between 0 and 1:
225
+ * - `method: 'min'` (default) → fraction of values strictly below this row (PERCENT_RANK).
226
+ * - `method: 'max'` → fraction of values at or below this row (cumulative distribution).
227
+ *
228
+ * `partitionBy` restarts the ranking within each group of distinct values.
229
+ */
230
+ rank(opts = {}) {
231
+ const { method = "min", pct = false, partitionBy, orderBy } = opts;
232
+ let func;
233
+ let name;
234
+ if (pct) {
235
+ if (method === "max") {
236
+ func = "CUME_DIST" /* CUME_DIST */;
237
+ name = "Cume Dist";
238
+ } else {
239
+ func = "PERCENT_RANK" /* PERCENT_RANK */;
240
+ name = "Percent Rank";
241
+ }
242
+ } else if (method === "first") {
243
+ func = "ROW_NUMBER" /* ROW_NUMBER */;
244
+ name = "Row Number";
245
+ } else if (method === "dense") {
246
+ func = "DENSE_RANK" /* DENSE_RANK */;
247
+ name = "Dense Rank";
248
+ } else {
249
+ func = "RANK" /* RANK */;
250
+ name = "Rank";
251
+ }
252
+ return new WindowFunctionOperation(null, func, name, void 0, [], this._windowSpec(partitionBy, orderBy));
253
+ }
254
+ /**
255
+ * Split rows into `buckets` equal-sized quantile bins ordered by `orderBy`.
256
+ * Each row receives a bucket number from 1 (lowest) to `buckets` (highest).
257
+ * Named after `pandas.qcut`.
258
+ */
259
+ qcut(buckets, opts = {}) {
260
+ return new WindowFunctionOperation(
261
+ null,
262
+ "NTILE" /* NTILE */,
263
+ "Quantile",
264
+ buckets,
265
+ [],
266
+ this._windowSpec(opts.partitionBy, opts.orderBy)
267
+ );
268
+ }
269
+ /**
270
+ * Return the value of this attribute from `periods` rows earlier (positive) or later (negative)
271
+ * within the ordered window, following `pandas.Series.shift`.
272
+ * Rows with no neighbour at the given offset return `null` (or `fillValue` if provided).
273
+ */
274
+ shift(periods = 1, opts = {}) {
275
+ const extraArgs = opts.fillValue !== void 0 ? [opts.fillValue] : [];
276
+ const func = periods >= 0 ? "LAG" /* LAG */ : "LEAD" /* LEAD */;
277
+ const label = periods >= 0 ? "Lag" : "Lead";
278
+ return new WindowFunctionOperation(
279
+ this.cwj(),
280
+ func,
281
+ label + " " + this._displayName,
282
+ Math.abs(periods),
283
+ extraArgs,
284
+ this._windowSpec(opts.partitionBy, opts.orderBy)
285
+ );
286
+ }
287
+ /**
288
+ * Return the first value of this attribute in the window frame.
289
+ * Use `partitionBy` to restart the frame for each group.
290
+ */
291
+ first(opts = {}) {
292
+ return new WindowFunctionOperation(
293
+ this.cwj(),
294
+ "FIRST_VALUE" /* FIRST_VALUE */,
295
+ "First " + this._displayName,
296
+ void 0,
297
+ [],
298
+ this._windowSpec(opts.partitionBy, opts.orderBy)
299
+ );
300
+ }
301
+ /**
302
+ * Return the last value of this attribute in the window frame.
303
+ * Use `partitionBy` to restart the frame for each group.
304
+ */
305
+ last(opts = {}) {
306
+ return new WindowFunctionOperation(
307
+ this.cwj(),
308
+ "LAST_VALUE" /* LAST_VALUE */,
309
+ "Last " + this._displayName,
310
+ void 0,
311
+ [],
312
+ this._windowSpec(opts.partitionBy, opts.orderBy)
313
+ );
314
+ }
315
+ };
316
+ // Annotate the CommonJS export names for ESM import in node:
317
+ 0 && (module.exports = {
318
+ Attribute
319
+ });
320
+ //# sourceMappingURL=attribute.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/datafinder/attribute.ts","../../src/model/relational.ts"],"sourcesContent":["import {\n Column,\n AggregateOperation,\n AggregateOperator,\n ColumnWithJoin,\n SortOperation,\n SortDirection,\n IsNullOperation,\n IsNotNullOperation,\n JoinTreeNodeOperation,\n WindowFunction,\n WindowFunctionOperation,\n WindowSpecification,\n} from '../model/relational';\n\nexport abstract class Attribute {\n private readonly _displayName: string;\n private readonly _column: Column;\n private readonly _owner: string;\n private readonly _parent?: JoinTreeNodeOperation;\n private readonly _embedded?: Attribute;\n\n constructor(\n displayName: string,\n columnName: string,\n columnDbType: string,\n owner: string,\n parent?: JoinTreeNodeOperation,\n embedded?: Attribute,\n ) {\n this._displayName = displayName;\n this._column = new Column(columnName, columnDbType, owner);\n this._owner = owner;\n this._parent = parent;\n this._embedded = embedded;\n }\n\n column(): Column { return this._column; }\n owner(): string { return this._owner; }\n parent(): JoinTreeNodeOperation | undefined { return this._parent; }\n displayName(): string { return this._displayName; }\n\n /** Alternate attribute on a flat column of the owning table, used in place of this one when its join is elided. */\n embedded(): Attribute | undefined { return this._embedded; }\n\n cwj(): ColumnWithJoin {\n return new ColumnWithJoin(this._column, this._parent, this._embedded?.cwj());\n }\n\n /** Count the number of non-null values. Use in a projection with `groupByOp` to aggregate per group. */\n count(): AggregateOperation {\n return new AggregateOperation(\n this.cwj(),\n AggregateOperator.COUNT,\n this._displayName + ' Count',\n );\n }\n\n /** Sort this attribute in ascending order. Pass to `orderByOp` or a window function's `orderBy`. */\n ascending(): SortOperation {\n return new SortOperation(this.cwj(), SortDirection.ASC);\n }\n\n /** Sort this attribute in descending order. Pass to `orderByOp` or a window function's `orderBy`. */\n descending(): SortOperation {\n return new SortOperation(this.cwj(), SortDirection.DESC);\n }\n\n /** Filter to rows where this attribute has no value. */\n isNull(): IsNullOperation {\n return new IsNullOperation(this.cwj());\n }\n\n /** Filter to rows where this attribute has a value. */\n isNotNull(): IsNotNullOperation {\n return new IsNotNullOperation(this.cwj());\n }\n\n private _windowSpec(\n partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[],\n orderBy?: SortOperation | SortOperation[],\n ): WindowSpecification {\n const pbArr = partitionBy === undefined ? [] : Array.isArray(partitionBy) ? partitionBy : [partitionBy];\n const pb = pbArr.map(x => x instanceof Attribute ? x.cwj() : x);\n const ob = orderBy === undefined ? [] : Array.isArray(orderBy) ? orderBy : [orderBy];\n return new WindowSpecification(pb, ob);\n }\n\n /**\n * Assign a rank to each row within the ordered window, following pandas `Series.rank` conventions.\n *\n * `method` controls tie-breaking (default `'min'`):\n * - `'min'` — tied rows share the lowest rank; the next rank skips.\n * - `'dense'` — like `'min'` but ranks are contiguous (no gaps).\n * - `'first'` — each row gets a unique sequential integer (no ties).\n * - `'max'` — only meaningful with `pct: true` (see below).\n *\n * When `pct: true` the result is a relative rank between 0 and 1:\n * - `method: 'min'` (default) → fraction of values strictly below this row (PERCENT_RANK).\n * - `method: 'max'` → fraction of values at or below this row (cumulative distribution).\n *\n * `partitionBy` restarts the ranking within each group of distinct values.\n */\n rank(opts: {\n method?: 'min' | 'dense' | 'first' | 'max';\n pct?: boolean;\n partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];\n orderBy?: SortOperation | SortOperation[];\n } = {}): WindowFunctionOperation {\n const { method = 'min', pct = false, partitionBy, orderBy } = opts;\n let func: WindowFunction;\n let name: string;\n if (pct) {\n if (method === 'max') { func = WindowFunction.CUME_DIST; name = 'Cume Dist'; }\n else { func = WindowFunction.PERCENT_RANK; name = 'Percent Rank'; }\n } else if (method === 'first') { func = WindowFunction.ROW_NUMBER; name = 'Row Number'; }\n else if (method === 'dense') { func = WindowFunction.DENSE_RANK; name = 'Dense Rank'; }\n else { func = WindowFunction.RANK; name = 'Rank'; }\n return new WindowFunctionOperation(null, func, name, undefined, [], this._windowSpec(partitionBy, orderBy));\n }\n\n /**\n * Split rows into `buckets` equal-sized quantile bins ordered by `orderBy`.\n * Each row receives a bucket number from 1 (lowest) to `buckets` (highest).\n * Named after `pandas.qcut`.\n */\n qcut(buckets: number, opts: {\n partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];\n orderBy?: SortOperation | SortOperation[];\n } = {}): WindowFunctionOperation {\n return new WindowFunctionOperation(null, WindowFunction.NTILE, 'Quantile', buckets, [],\n this._windowSpec(opts.partitionBy, opts.orderBy));\n }\n\n /**\n * Return the value of this attribute from `periods` rows earlier (positive) or later (negative)\n * within the ordered window, following `pandas.Series.shift`.\n * Rows with no neighbour at the given offset return `null` (or `fillValue` if provided).\n */\n shift(periods = 1, opts: {\n fillValue?: string | number;\n partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];\n orderBy?: SortOperation | SortOperation[];\n } = {}): WindowFunctionOperation {\n const extraArgs: (string | number)[] = opts.fillValue !== undefined ? [opts.fillValue] : [];\n const func = periods >= 0 ? WindowFunction.LAG : WindowFunction.LEAD;\n const label = periods >= 0 ? 'Lag' : 'Lead';\n return new WindowFunctionOperation(\n this.cwj(),\n func,\n label + ' ' + this._displayName,\n Math.abs(periods),\n extraArgs,\n this._windowSpec(opts.partitionBy, opts.orderBy),\n );\n }\n\n /**\n * Return the first value of this attribute in the window frame.\n * Use `partitionBy` to restart the frame for each group.\n */\n first(opts: {\n partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];\n orderBy?: SortOperation | SortOperation[];\n } = {}): WindowFunctionOperation {\n return new WindowFunctionOperation(\n this.cwj(),\n WindowFunction.FIRST_VALUE,\n 'First ' + this._displayName,\n undefined, [],\n this._windowSpec(opts.partitionBy, opts.orderBy),\n );\n }\n\n /**\n * Return the last value of this attribute in the window frame.\n * Use `partitionBy` to restart the frame for each group.\n */\n last(opts: {\n partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];\n orderBy?: SortOperation | SortOperation[];\n } = {}): WindowFunctionOperation {\n return new WindowFunctionOperation(\n this.cwj(),\n WindowFunction.LAST_VALUE,\n 'Last ' + this._displayName,\n undefined, [],\n this._windowSpec(opts.partitionBy, opts.orderBy),\n );\n }\n}\n","export enum ComparisonOperator {\n EQUAL = 'EQUAL',\n NOT_EQUAL = 'NOT_EQUAL',\n LESS_THAN = 'LESS_THAN',\n GREATER_THAN = 'GREATER_THAN',\n LESS_THAN_OR_EQUAL_TO = 'LESS_THAN_OR_EQUAL_TO',\n GREATER_THAN_OR_EQUAL_TO = 'GREATER_THAN_OR_EQUAL_TO',\n LIKE = 'LIKE',\n NOT_LIKE = 'NOT_LIKE',\n}\n\nexport enum LogicalOperator {\n AND = 'AND',\n OR = 'OR',\n}\n\nexport enum AggregateOperator {\n COUNT = 'COUNT',\n SUM = 'SUM',\n MIN = 'MIN',\n MAX = 'MAX',\n AVERAGE = 'AVERAGE',\n}\n\nexport enum ScalarFunction {\n ABS = 'ABS',\n CEILING = 'CEILING',\n FLOOR = 'FLOOR',\n MOD = 'MOD',\n POWER = 'POWER',\n SQRT = 'SQRT',\n ROUND = 'ROUND',\n UPPER = 'UPPER',\n LOWER = 'LOWER',\n TRIM = 'TRIM',\n LTRIM = 'LTRIM',\n RTRIM = 'RTRIM',\n LENGTH = 'LENGTH',\n REVERSE = 'REVERSE',\n LEFT = 'LEFT',\n RIGHT = 'RIGHT',\n REPEAT = 'REPEAT',\n REPLACE = 'REPLACE',\n SUBSTRING = 'SUBSTRING',\n}\n\nexport enum DatePart {\n YEAR = 'YEAR',\n MONTH = 'MONTH',\n DAY = 'DAY',\n HOUR = 'HOUR',\n MINUTE = 'MINUTE',\n SECOND = 'SECOND',\n QUARTER = 'QUARTER',\n WEEK = 'WEEK',\n DOW = 'DOW',\n}\n\nexport enum SortDirection {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport abstract class RelationalOperationElement {}\n\nexport abstract class Operation extends RelationalOperationElement {\n andOp(other: RelationalOperationElement): Operation {\n return new LogicalOperation(this, LogicalOperator.AND, other);\n }\n}\n\nexport class NoOperation extends Operation {\n andOp(other: RelationalOperationElement): Operation {\n return other as Operation;\n }\n}\n\nexport abstract class ConstantOperation extends RelationalOperationElement {}\n\nexport class IntegerConstantOperation extends ConstantOperation {\n constructor(readonly value: number) { super(); }\n}\n\nexport class FloatConstantOperation extends ConstantOperation {\n constructor(readonly value: number) { super(); }\n}\n\nexport class StringConstantOperation extends ConstantOperation {\n constructor(readonly value: string) { super(); }\n}\n\nexport class DateConstantOperation extends ConstantOperation {\n constructor(readonly value: Date) { super(); }\n}\n\nexport class DateTimeConstantOperation extends ConstantOperation {\n constructor(readonly value: Date) { super(); }\n}\n\nexport class DecimalConstantOperation extends ConstantOperation {\n constructor(readonly value: number) { super(); }\n}\n\nexport class BooleanConstantOperation extends ConstantOperation {\n constructor(readonly value: boolean) { super(); }\n}\n\nexport abstract class UnaryOperation extends Operation {\n constructor(readonly element: RelationalOperationElement) { super(); }\n}\n\nexport abstract class BinaryOperation extends Operation {\n constructor(\n readonly left: RelationalOperationElement,\n readonly right: RelationalOperationElement,\n ) { super(); }\n}\n\nexport class IsNullOperation extends UnaryOperation {}\n\nexport class IsNotNullOperation extends UnaryOperation {}\n\nexport class ComparisonOperation extends BinaryOperation {\n constructor(\n left: RelationalOperationElement,\n readonly operator: ComparisonOperator,\n right: RelationalOperationElement,\n ) { super(left, right); }\n}\n\nexport class LogicalOperation extends BinaryOperation {\n constructor(\n left: RelationalOperationElement,\n readonly operator: LogicalOperator,\n right: RelationalOperationElement,\n ) { super(left, right); }\n}\n\nexport class WindowSpecification {\n constructor(\n readonly partitionBy: RelationalOperationElement[] = [],\n readonly orderBy: SortOperation[] = [],\n ) {}\n}\n\nexport class AggregateOperation extends UnaryOperation {\n constructor(\n element: RelationalOperationElement,\n readonly operator: AggregateOperator,\n readonly displayName?: string,\n readonly window?: WindowSpecification,\n ) { super(element); }\n\n over(partitionBy?: RelationalOperationElement[], orderBy?: SortOperation[]): AggregateOperation {\n return new AggregateOperation(this.element, this.operator, this.displayName,\n new WindowSpecification(partitionBy ?? [], orderBy ?? []));\n }\n}\n\nexport enum WindowFunction {\n ROW_NUMBER = 'ROW_NUMBER',\n RANK = 'RANK',\n DENSE_RANK = 'DENSE_RANK',\n NTILE = 'NTILE',\n LAG = 'LAG',\n LEAD = 'LEAD',\n FIRST_VALUE = 'FIRST_VALUE',\n LAST_VALUE = 'LAST_VALUE',\n CUME_DIST = 'CUME_DIST',\n PERCENT_RANK = 'PERCENT_RANK',\n}\n\nexport class WindowFunctionOperation extends UnaryOperation {\n constructor(\n element: RelationalOperationElement | null,\n readonly func: WindowFunction,\n readonly displayName?: string,\n readonly secondArg?: number,\n readonly extraArgs: (string | number)[] = [],\n readonly window?: WindowSpecification,\n ) { super(element as RelationalOperationElement); }\n\n over(partitionBy?: RelationalOperationElement[], orderBy?: SortOperation[]): WindowFunctionOperation {\n return new WindowFunctionOperation(this.element, this.func, this.displayName, this.secondArg,\n [...this.extraArgs], new WindowSpecification(partitionBy ?? [], orderBy ?? []));\n }\n}\n\nexport class ScalarFunctionOperation extends UnaryOperation {\n constructor(\n element: RelationalOperationElement,\n readonly func: ScalarFunction,\n readonly displayName?: string,\n readonly secondArg?: number,\n readonly extraArgs: (string | number)[] = [],\n ) { super(element); }\n}\n\nexport class DateExtractOperation extends UnaryOperation {\n constructor(\n element: RelationalOperationElement,\n readonly part: DatePart,\n readonly displayName?: string,\n ) { super(element); }\n}\n\nexport class DateArithmeticOperation extends UnaryOperation {\n constructor(\n element: RelationalOperationElement,\n readonly n: number,\n readonly unit: DatePart,\n readonly isAdd: boolean = true,\n readonly displayName?: string,\n ) { super(element); }\n}\n\nexport class DateDiffOperation extends UnaryOperation {\n constructor(\n element: RelationalOperationElement,\n readonly other: Date,\n readonly unit: DatePart,\n readonly displayName?: string,\n ) { super(element); }\n}\n\nexport class Column extends RelationalOperationElement {\n table?: Table;\n\n constructor(\n readonly name: string,\n readonly type: string,\n readonly owner?: string,\n readonly primaryKey: boolean = false,\n ) { super(); }\n}\n\nexport class ForeignKey {\n constructor(readonly column: Column, readonly references: Column) {}\n}\n\nexport abstract class DataStore {\n readonly schemas: Schema[] = [];\n\n constructor(readonly name: string) {}\n\n abstract namespace(schemaName: string): string;\n}\n\nexport class Database extends DataStore {\n constructor(name: string, readonly location?: string) { super(name); }\n\n namespace(schemaName: string): string { return schemaName; }\n}\n\nexport class DataCatalog extends DataStore {\n constructor(name: string) { super(name); }\n\n namespace(schemaName: string): string { return `${this.name}.${schemaName}`; }\n}\n\nexport class Schema {\n readonly tables: Table[] = [];\n\n constructor(readonly name: string, readonly datastore?: DataStore) {\n datastore?.schemas.push(this);\n }\n}\n\nexport class Table {\n private readonly _columnsByName: Map<string, Column> = new Map();\n readonly foreignKeys: ForeignKey[] = [];\n\n constructor(readonly name: string, columns: Column[], readonly schema?: Schema) {\n for (const col of columns) {\n if (this._columnsByName.has(col.name)) {\n throw new Error(`Duplicate column name '${col.name}' in table '${name}'`);\n }\n this._columnsByName.set(col.name, col);\n col.table = this;\n }\n schema?.tables.push(this);\n }\n\n get columns(): Column[] {\n return Array.from(this._columnsByName.values());\n }\n\n get qualifiedName(): string {\n if (!this.schema) return this.name;\n if (!this.schema.datastore) return `${this.schema.name}.${this.name}`;\n return `${this.schema.datastore.namespace(this.schema.name)}.${this.name}`;\n }\n}\n\nexport class JoinOperation {\n filter?: RelationalOperationElement;\n /** Property-equality filters on the join target (property id -> value), set by a related finder given a filter. */\n filterKwargs: Record<string, unknown> = {};\n /** Maps property ids to [column, type, table] for `filterKwargs`. */\n filterColumnMap: Record<string, [string, string, string]> = {};\n\n constructor(\n readonly name: string,\n readonly target: Table,\n readonly left: Column,\n readonly right: Column,\n filter?: RelationalOperationElement,\n ) {\n this.filter = filter;\n }\n}\n\nexport class JoinTreeNodeOperation {\n constructor(\n readonly join: JoinOperation,\n readonly parent?: JoinTreeNodeOperation,\n ) {}\n}\n\nexport class ColumnWithJoin extends RelationalOperationElement {\n /**\n * `embedded` is an alternate reference to a flat (denormalized) column on the owning table that\n * holds the same value without the join; the SQL generator uses it when the join can be elided.\n */\n constructor(\n readonly column: Column,\n readonly parent?: JoinTreeNodeOperation,\n readonly embedded?: ColumnWithJoin,\n ) { super(); }\n}\n\nexport class SortOperation {\n constructor(\n readonly column: ColumnWithJoin,\n readonly direction: SortDirection,\n ) {}\n}\n\nexport class CountAllOperation extends RelationalOperationElement {\n constructor(readonly table: string) { super(); }\n}\n\nexport class Alias extends RelationalOperationElement {\n constructor(readonly element: RelationalOperationElement, readonly name: string) { super(); }\n}\n\n/** Returned by `RelatedFinder.exists()`. A backend translates it to a join-presence check. */\nexport class ExistsOperation extends RelationalOperationElement {\n constructor(readonly node: JoinTreeNodeOperation) { super(); }\n\n andOp(other: RelationalOperationElement): LogicalOperation {\n return new LogicalOperation(this, LogicalOperator.AND, other);\n }\n}\n\n/** Returned by `RelatedFinder.notExists()`. A backend translates it to a join-absence check. */\nexport class NotExistsOperation extends RelationalOperationElement {\n constructor(readonly node: JoinTreeNodeOperation) { super(); }\n\n andOp(other: RelationalOperationElement): LogicalOperation {\n return new LogicalOperation(this, LogicalOperator.AND, other);\n }\n}\n\nexport class SelectOperation {\n constructor(\n readonly display: RelationalOperationElement[],\n readonly filter: RelationalOperationElement,\n readonly orderBy: SortOperation[] = [],\n readonly groupBy: RelationalOperationElement[] = [],\n readonly limit?: number,\n readonly table?: Table,\n /**\n * Extra ON conditions for this query's joins (milestoning and property filters), keyed by join node.\n * Held here rather than on the shared JoinOperation, so queries that use the same node can't affect each other.\n */\n readonly joinFilters: ReadonlyMap<JoinTreeNodeOperation, Operation> = new Map(),\n ) {}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC+DO,IAAe,6BAAf,MAA0C;AAAC;AAE3C,IAAe,YAAf,cAAiC,2BAA2B;AAAA,EACjE,MAAM,OAA8C;AAClD,WAAO,IAAI,iBAAiB,MAAM,iBAAqB,KAAK;AAAA,EAC9D;AACF;AAsCO,IAAe,iBAAf,cAAsC,UAAU;AAAA,EACrD,YAAqB,SAAqC;AAAE,UAAM;AAA7C;AAAA,EAAgD;AAAA,EAAhD;AACvB;AAEO,IAAe,kBAAf,cAAuC,UAAU;AAAA,EACtD,YACW,MACA,OACT;AAAE,UAAM;AAFC;AACA;AAAA,EACE;AAAA,EAFF;AAAA,EACA;AAEb;AAEO,IAAM,kBAAN,cAA8B,eAAe;AAAC;AAE9C,IAAM,qBAAN,cAAiC,eAAe;AAAC;AAUjD,IAAM,mBAAN,cAA+B,gBAAgB;AAAA,EACpD,YACE,MACS,UACT,OACA;AAAE,UAAM,MAAM,KAAK;AAFV;AAAA,EAEa;AAAA,EAFb;AAGb;AAEO,IAAM,sBAAN,MAA0B;AAAA,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iC,KAAK,cAAc,SAAY,CAAC,KAAK,SAAS,IAAI,CAAC;AAC1F,UAAM,OAAO,WAAW;AACxB,UAAM,QAAQ,WAAW,IAAI,QAAQ;AACrC,WAAO,IAAI;AAAA,MACT,KAAK,IAAI;AAAA,MACT;AAAA,MACA,QAAQ,MAAM,KAAK;AAAA,MACnB,KAAK,IAAI,OAAO;AAAA,MAChB;AAAA,MACA,KAAK,YAAY,KAAK,aAAa,KAAK,OAAO;AAAA,IACjD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAGF,CAAC,GAA4B;AAC/B,WAAO,IAAI;AAAA,MACT,KAAK,IAAI;AAAA;AAAA,MAET,WAAW,KAAK;AAAA,MAChB;AAAA,MAAW,CAAC;AAAA,MACZ,KAAK,YAAY,KAAK,aAAa,KAAK,OAAO;AAAA,IACjD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,KAAK,OAGD,CAAC,GAA4B;AAC/B,WAAO,IAAI;AAAA,MACT,KAAK,IAAI;AAAA;AAAA,MAET,UAAU,KAAK;AAAA,MACf;AAAA,MAAW,CAAC;AAAA,MACZ,KAAK,YAAY,KAAK,aAAa,KAAK,OAAO;AAAA,IACjD;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,86 @@
1
+ import { JoinTreeNodeOperation, Column, ColumnWithJoin, AggregateOperation, SortOperation, IsNullOperation, IsNotNullOperation, WindowFunctionOperation } from '../model/relational.cjs';
2
+
3
+ declare abstract class Attribute {
4
+ private readonly _displayName;
5
+ private readonly _column;
6
+ private readonly _owner;
7
+ private readonly _parent?;
8
+ private readonly _embedded?;
9
+ constructor(displayName: string, columnName: string, columnDbType: string, owner: string, parent?: JoinTreeNodeOperation, embedded?: Attribute);
10
+ column(): Column;
11
+ owner(): string;
12
+ parent(): JoinTreeNodeOperation | undefined;
13
+ displayName(): string;
14
+ /** Alternate attribute on a flat column of the owning table, used in place of this one when its join is elided. */
15
+ embedded(): Attribute | undefined;
16
+ cwj(): ColumnWithJoin;
17
+ /** Count the number of non-null values. Use in a projection with `groupByOp` to aggregate per group. */
18
+ count(): AggregateOperation;
19
+ /** Sort this attribute in ascending order. Pass to `orderByOp` or a window function's `orderBy`. */
20
+ ascending(): SortOperation;
21
+ /** Sort this attribute in descending order. Pass to `orderByOp` or a window function's `orderBy`. */
22
+ descending(): SortOperation;
23
+ /** Filter to rows where this attribute has no value. */
24
+ isNull(): IsNullOperation;
25
+ /** Filter to rows where this attribute has a value. */
26
+ isNotNull(): IsNotNullOperation;
27
+ private _windowSpec;
28
+ /**
29
+ * Assign a rank to each row within the ordered window, following pandas `Series.rank` conventions.
30
+ *
31
+ * `method` controls tie-breaking (default `'min'`):
32
+ * - `'min'` — tied rows share the lowest rank; the next rank skips.
33
+ * - `'dense'` — like `'min'` but ranks are contiguous (no gaps).
34
+ * - `'first'` — each row gets a unique sequential integer (no ties).
35
+ * - `'max'` — only meaningful with `pct: true` (see below).
36
+ *
37
+ * When `pct: true` the result is a relative rank between 0 and 1:
38
+ * - `method: 'min'` (default) → fraction of values strictly below this row (PERCENT_RANK).
39
+ * - `method: 'max'` → fraction of values at or below this row (cumulative distribution).
40
+ *
41
+ * `partitionBy` restarts the ranking within each group of distinct values.
42
+ */
43
+ rank(opts?: {
44
+ method?: 'min' | 'dense' | 'first' | 'max';
45
+ pct?: boolean;
46
+ partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];
47
+ orderBy?: SortOperation | SortOperation[];
48
+ }): WindowFunctionOperation;
49
+ /**
50
+ * Split rows into `buckets` equal-sized quantile bins ordered by `orderBy`.
51
+ * Each row receives a bucket number from 1 (lowest) to `buckets` (highest).
52
+ * Named after `pandas.qcut`.
53
+ */
54
+ qcut(buckets: number, opts?: {
55
+ partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];
56
+ orderBy?: SortOperation | SortOperation[];
57
+ }): WindowFunctionOperation;
58
+ /**
59
+ * Return the value of this attribute from `periods` rows earlier (positive) or later (negative)
60
+ * within the ordered window, following `pandas.Series.shift`.
61
+ * Rows with no neighbour at the given offset return `null` (or `fillValue` if provided).
62
+ */
63
+ shift(periods?: number, opts?: {
64
+ fillValue?: string | number;
65
+ partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];
66
+ orderBy?: SortOperation | SortOperation[];
67
+ }): WindowFunctionOperation;
68
+ /**
69
+ * Return the first value of this attribute in the window frame.
70
+ * Use `partitionBy` to restart the frame for each group.
71
+ */
72
+ first(opts?: {
73
+ partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];
74
+ orderBy?: SortOperation | SortOperation[];
75
+ }): WindowFunctionOperation;
76
+ /**
77
+ * Return the last value of this attribute in the window frame.
78
+ * Use `partitionBy` to restart the frame for each group.
79
+ */
80
+ last(opts?: {
81
+ partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];
82
+ orderBy?: SortOperation | SortOperation[];
83
+ }): WindowFunctionOperation;
84
+ }
85
+
86
+ export { Attribute };
@@ -0,0 +1,86 @@
1
+ import { JoinTreeNodeOperation, Column, ColumnWithJoin, AggregateOperation, SortOperation, IsNullOperation, IsNotNullOperation, WindowFunctionOperation } from '../model/relational.js';
2
+
3
+ declare abstract class Attribute {
4
+ private readonly _displayName;
5
+ private readonly _column;
6
+ private readonly _owner;
7
+ private readonly _parent?;
8
+ private readonly _embedded?;
9
+ constructor(displayName: string, columnName: string, columnDbType: string, owner: string, parent?: JoinTreeNodeOperation, embedded?: Attribute);
10
+ column(): Column;
11
+ owner(): string;
12
+ parent(): JoinTreeNodeOperation | undefined;
13
+ displayName(): string;
14
+ /** Alternate attribute on a flat column of the owning table, used in place of this one when its join is elided. */
15
+ embedded(): Attribute | undefined;
16
+ cwj(): ColumnWithJoin;
17
+ /** Count the number of non-null values. Use in a projection with `groupByOp` to aggregate per group. */
18
+ count(): AggregateOperation;
19
+ /** Sort this attribute in ascending order. Pass to `orderByOp` or a window function's `orderBy`. */
20
+ ascending(): SortOperation;
21
+ /** Sort this attribute in descending order. Pass to `orderByOp` or a window function's `orderBy`. */
22
+ descending(): SortOperation;
23
+ /** Filter to rows where this attribute has no value. */
24
+ isNull(): IsNullOperation;
25
+ /** Filter to rows where this attribute has a value. */
26
+ isNotNull(): IsNotNullOperation;
27
+ private _windowSpec;
28
+ /**
29
+ * Assign a rank to each row within the ordered window, following pandas `Series.rank` conventions.
30
+ *
31
+ * `method` controls tie-breaking (default `'min'`):
32
+ * - `'min'` — tied rows share the lowest rank; the next rank skips.
33
+ * - `'dense'` — like `'min'` but ranks are contiguous (no gaps).
34
+ * - `'first'` — each row gets a unique sequential integer (no ties).
35
+ * - `'max'` — only meaningful with `pct: true` (see below).
36
+ *
37
+ * When `pct: true` the result is a relative rank between 0 and 1:
38
+ * - `method: 'min'` (default) → fraction of values strictly below this row (PERCENT_RANK).
39
+ * - `method: 'max'` → fraction of values at or below this row (cumulative distribution).
40
+ *
41
+ * `partitionBy` restarts the ranking within each group of distinct values.
42
+ */
43
+ rank(opts?: {
44
+ method?: 'min' | 'dense' | 'first' | 'max';
45
+ pct?: boolean;
46
+ partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];
47
+ orderBy?: SortOperation | SortOperation[];
48
+ }): WindowFunctionOperation;
49
+ /**
50
+ * Split rows into `buckets` equal-sized quantile bins ordered by `orderBy`.
51
+ * Each row receives a bucket number from 1 (lowest) to `buckets` (highest).
52
+ * Named after `pandas.qcut`.
53
+ */
54
+ qcut(buckets: number, opts?: {
55
+ partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];
56
+ orderBy?: SortOperation | SortOperation[];
57
+ }): WindowFunctionOperation;
58
+ /**
59
+ * Return the value of this attribute from `periods` rows earlier (positive) or later (negative)
60
+ * within the ordered window, following `pandas.Series.shift`.
61
+ * Rows with no neighbour at the given offset return `null` (or `fillValue` if provided).
62
+ */
63
+ shift(periods?: number, opts?: {
64
+ fillValue?: string | number;
65
+ partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];
66
+ orderBy?: SortOperation | SortOperation[];
67
+ }): WindowFunctionOperation;
68
+ /**
69
+ * Return the first value of this attribute in the window frame.
70
+ * Use `partitionBy` to restart the frame for each group.
71
+ */
72
+ first(opts?: {
73
+ partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];
74
+ orderBy?: SortOperation | SortOperation[];
75
+ }): WindowFunctionOperation;
76
+ /**
77
+ * Return the last value of this attribute in the window frame.
78
+ * Use `partitionBy` to restart the frame for each group.
79
+ */
80
+ last(opts?: {
81
+ partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];
82
+ orderBy?: SortOperation | SortOperation[];
83
+ }): WindowFunctionOperation;
84
+ }
85
+
86
+ export { Attribute };
@@ -0,0 +1,8 @@
1
+ import {
2
+ Attribute
3
+ } from "../chunk-4JVW4TAB.js";
4
+ import "../chunk-UYMOE6YU.js";
5
+ export {
6
+ Attribute
7
+ };
8
+ //# sourceMappingURL=attribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/datafinder/finder-registry.ts
21
+ var finder_registry_exports = {};
22
+ __export(finder_registry_exports, {
23
+ getRelatedFinderClass: () => getRelatedFinderClass,
24
+ registerRelatedFinderClass: () => registerRelatedFinderClass
25
+ });
26
+ module.exports = __toCommonJS(finder_registry_exports);
27
+ var _registry = /* @__PURE__ */ new Map();
28
+ function registerRelatedFinderClass(name, cls) {
29
+ _registry.set(name, cls);
30
+ }
31
+ function getRelatedFinderClass(name) {
32
+ return _registry.get(name);
33
+ }
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ getRelatedFinderClass,
37
+ registerRelatedFinderClass
38
+ });
39
+ //# sourceMappingURL=finder-registry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/datafinder/finder-registry.ts"],"sourcesContent":["const _registry = new Map<string, new (...args: any[]) => unknown>();\n\nexport function registerRelatedFinderClass(name: string, cls: new (...args: any[]) => unknown): void {\n _registry.set(name, cls);\n}\n\nexport function getRelatedFinderClass(name: string): (new (...args: any[]) => unknown) | undefined {\n return _registry.get(name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,YAAY,oBAAI,IAA6C;AAE5D,SAAS,2BAA2B,MAAc,KAA4C;AACnG,YAAU,IAAI,MAAM,GAAG;AACzB;AAEO,SAAS,sBAAsB,MAA6D;AACjG,SAAO,UAAU,IAAI,IAAI;AAC3B;","names":[]}
@@ -0,0 +1,4 @@
1
+ declare function registerRelatedFinderClass(name: string, cls: new (...args: any[]) => unknown): void;
2
+ declare function getRelatedFinderClass(name: string): (new (...args: any[]) => unknown) | undefined;
3
+
4
+ export { getRelatedFinderClass, registerRelatedFinderClass };
@@ -0,0 +1,4 @@
1
+ declare function registerRelatedFinderClass(name: string, cls: new (...args: any[]) => unknown): void;
2
+ declare function getRelatedFinderClass(name: string): (new (...args: any[]) => unknown) | undefined;
3
+
4
+ export { getRelatedFinderClass, registerRelatedFinderClass };
@@ -0,0 +1,9 @@
1
+ import {
2
+ getRelatedFinderClass,
3
+ registerRelatedFinderClass
4
+ } from "../chunk-FLEIUDZZ.js";
5
+ export {
6
+ getRelatedFinderClass,
7
+ registerRelatedFinderClass
8
+ };
9
+ //# sourceMappingURL=finder-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}