data-finder-ts 0.1.3 → 0.1.5

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 (62) hide show
  1. package/README.md +17 -55
  2. package/dist/chunk-BGEX377Q.js +230 -0
  3. package/dist/chunk-BGEX377Q.js.map +1 -0
  4. package/dist/chunk-BKPWV3OF.js +962 -0
  5. package/dist/chunk-BKPWV3OF.js.map +1 -0
  6. package/dist/{chunk-EYXBYV2X.js → chunk-GPHWC533.js} +2 -2
  7. package/dist/chunk-KAK75RVS.js +198 -0
  8. package/dist/chunk-KAK75RVS.js.map +1 -0
  9. package/dist/chunk-MGEL5RWM.js +628 -0
  10. package/dist/chunk-MGEL5RWM.js.map +1 -0
  11. package/dist/chunk-PF6EJZHB.js +1015 -0
  12. package/dist/chunk-PF6EJZHB.js.map +1 -0
  13. package/dist/datafinder/attribute.cjs +595 -18
  14. package/dist/datafinder/attribute.cjs.map +1 -1
  15. package/dist/datafinder/attribute.d.cts +73 -10
  16. package/dist/datafinder/attribute.d.ts +73 -10
  17. package/dist/datafinder/attribute.js +2 -2
  18. package/dist/datafinder/runner.cjs +1589 -288
  19. package/dist/datafinder/runner.cjs.map +1 -1
  20. package/dist/datafinder/runner.d.cts +41 -7
  21. package/dist/datafinder/runner.d.ts +41 -7
  22. package/dist/datafinder/runner.js +12 -6
  23. package/dist/datafinder/sql-generator.cjs +1484 -281
  24. package/dist/datafinder/sql-generator.cjs.map +1 -1
  25. package/dist/datafinder/sql-generator.d.cts +19 -14
  26. package/dist/datafinder/sql-generator.d.ts +19 -14
  27. package/dist/datafinder/sql-generator.js +9 -7
  28. package/dist/datafinder/typed-attributes.cjs +856 -93
  29. package/dist/datafinder/typed-attributes.cjs.map +1 -1
  30. package/dist/datafinder/typed-attributes.d.cts +3 -135
  31. package/dist/datafinder/typed-attributes.d.ts +3 -135
  32. package/dist/datafinder/typed-attributes.js +3 -3
  33. package/dist/dialect-CogGPm_y.d.cts +38 -0
  34. package/dist/dialect-aaG1bDi5.d.ts +38 -0
  35. package/dist/index.cjs +2080 -480
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +119 -14
  38. package/dist/index.d.ts +119 -14
  39. package/dist/index.js +362 -12
  40. package/dist/index.js.map +1 -1
  41. package/dist/model/milestoning.cjs +529 -0
  42. package/dist/model/milestoning.cjs.map +1 -1
  43. package/dist/model/milestoning.js +2 -2
  44. package/dist/model/relational.cjs +608 -12
  45. package/dist/model/relational.cjs.map +1 -1
  46. package/dist/model/relational.d.cts +456 -47
  47. package/dist/model/relational.d.ts +456 -47
  48. package/dist/model/relational.js +61 -3
  49. package/dist/typed-attributes-CUTf_6Ru.d.ts +328 -0
  50. package/dist/typed-attributes-CdWXq_78.d.cts +328 -0
  51. package/package.json +5 -2
  52. package/dist/chunk-3SSWFES4.js +0 -448
  53. package/dist/chunk-3SSWFES4.js.map +0 -1
  54. package/dist/chunk-5K2Z3YDY.js +0 -393
  55. package/dist/chunk-5K2Z3YDY.js.map +0 -1
  56. package/dist/chunk-6QTCGJWX.js +0 -98
  57. package/dist/chunk-6QTCGJWX.js.map +0 -1
  58. package/dist/chunk-DFYZVBII.js +0 -652
  59. package/dist/chunk-DFYZVBII.js.map +0 -1
  60. package/dist/chunk-V647VNMY.js +0 -135
  61. package/dist/chunk-V647VNMY.js.map +0 -1
  62. /package/dist/{chunk-EYXBYV2X.js.map → chunk-GPHWC533.js.map} +0 -0
@@ -1,13 +1,22 @@
1
1
  import { Attribute } from './attribute.cjs';
2
- import { RelationalOperationElement, SortOperation } from '../model/relational.cjs';
2
+ import { b as DialectName, S as SqlDialect } from '../dialect-CogGPm_y.cjs';
3
+ import { RelationalOperationElement, SortOperation, Operation } from '../model/relational.cjs';
3
4
 
4
5
  type Row = unknown[];
6
+ declare const DEFAULT_TIMEOUT_MS = 60000;
7
+ /** Thrown by a QueryRunner when a query runs longer than the timeout set on its FinderResult. */
8
+ declare class QueryTimeoutError extends Error {
9
+ readonly timeoutMs: number;
10
+ constructor(timeoutMs: number);
11
+ }
5
12
  /** Minimum interface satisfied by both Table (SQL) and GraphQLQuery (GraphQL). */
6
13
  interface QueryTarget {
7
14
  readonly name: string;
8
15
  }
9
16
  interface QueryRunner {
10
- select(businessDate: Date | null, processingDatetime: Date | null, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op: RelationalOperationElement, orderBy?: SortOperation[], groupBy?: Attribute[], limit?: number): Promise<Row[]>;
17
+ /** The SQL a runner that executes SQL sends: `toSql()` writes it for this dialect. Postgres when absent. */
18
+ readonly dialect?: DialectName | SqlDialect;
19
+ select(businessDate: Date | null, processingDatetime: Date | null, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op: RelationalOperationElement, orderBy?: SortOperation[], groupBy?: Attribute[], limit?: number, timeoutMs?: number, businessDateTo?: Date | null, distinct?: boolean, offset?: number, having?: Operation): Promise<Row[]>;
11
20
  }
12
21
  declare function registerRunner(runner: QueryRunner): void;
13
22
  declare function clearRunner(): void;
@@ -18,16 +27,41 @@ declare class FinderResult {
18
27
  private readonly _columns;
19
28
  private readonly _table;
20
29
  private readonly _op;
30
+ private readonly _businessDateTo;
21
31
  private _orderBy;
22
32
  private _groupBy;
23
33
  private _limit?;
24
- constructor(_businessDate: Date | null, _processingDatetime: Date | null, _columns: (Attribute | RelationalOperationElement)[], _table: QueryTarget, _op: RelationalOperationElement);
25
- orderByOp(...sorts: SortOperation[]): this;
26
- groupByOp(...attrs: Attribute[]): this;
34
+ private _distinct;
35
+ private _offset?;
36
+ private _having?;
37
+ private _timeoutMs;
38
+ constructor(_businessDate: Date | null, _processingDatetime: Date | null, _columns: (Attribute | RelationalOperationElement)[], _table: QueryTarget, _op: RelationalOperationElement, _businessDateTo?: Date | null);
39
+ /**
40
+ * Order the rows. Calls accumulate: the sorts of the latest call take priority and earlier ones order the
41
+ * rows it leaves tied, as in a chain of `sortBy` calls. Sorting a column again replaces its earlier direction.
42
+ */
43
+ orderBy(...sorts: SortOperation[]): this;
44
+ groupBy(...attrs: Attribute[]): this;
27
45
  limit(n: number): this;
28
- toSql(): string;
46
+ /** Skip the first `n` rows. Sort the rows first: without an order, which rows are first is not defined. */
47
+ offset(n: number): this;
48
+ /** Rows `start` up to but not including `stop`, counting from 0: `offset(start).limit(stop - start)`. */
49
+ slice(start: number, stop: number): this;
50
+ /**
51
+ * Keep the groups for which every condition holds: `HAVING`. A condition tests an aggregate or a grouping column:
52
+ * `f.findAll(null, null, [f.category(), countAll()]).groupBy(f.category()).having(countAll().gt(1))`.
53
+ * Calls accumulate, as `and` does.
54
+ */
55
+ having(...conditions: Operation[]): this;
56
+ /** Return each distinct row once: `SELECT DISTINCT`. A sort on a distinct query has to use a selected column. */
57
+ distinct(): this;
58
+ /** Abort the query and throw QueryTimeoutError if it runs longer than `milliseconds` (default 60000). */
59
+ timeout(milliseconds: number): this;
60
+ /** The query as SQL, in Postgres unless a dialect is given: `toSql('databricks')`. Nothing is run. */
61
+ toSql(dialect?: DialectName | SqlDialect): string;
29
62
  toRows(): Promise<Row[]>;
30
63
  }
31
64
  declare function convertInputsAndSelect(businessDate: Date | string | null, processingDatetime: Date | string | null, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op?: RelationalOperationElement): FinderResult;
65
+ declare function convertInputsAndSelectForDateRange(businessDateFrom: Date | string, businessDateTo: Date | string, processingDatetime: Date | string, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op?: RelationalOperationElement): FinderResult;
32
66
 
33
- export { FinderResult, type QueryRunner, type QueryTarget, type Row, clearRunner, convertInputsAndSelect, getRunner, registerRunner };
67
+ export { DEFAULT_TIMEOUT_MS, FinderResult, type QueryRunner, type QueryTarget, QueryTimeoutError, type Row, clearRunner, convertInputsAndSelect, convertInputsAndSelectForDateRange, getRunner, registerRunner };
@@ -1,13 +1,22 @@
1
1
  import { Attribute } from './attribute.js';
2
- import { RelationalOperationElement, SortOperation } from '../model/relational.js';
2
+ import { b as DialectName, S as SqlDialect } from '../dialect-aaG1bDi5.js';
3
+ import { RelationalOperationElement, SortOperation, Operation } from '../model/relational.js';
3
4
 
4
5
  type Row = unknown[];
6
+ declare const DEFAULT_TIMEOUT_MS = 60000;
7
+ /** Thrown by a QueryRunner when a query runs longer than the timeout set on its FinderResult. */
8
+ declare class QueryTimeoutError extends Error {
9
+ readonly timeoutMs: number;
10
+ constructor(timeoutMs: number);
11
+ }
5
12
  /** Minimum interface satisfied by both Table (SQL) and GraphQLQuery (GraphQL). */
6
13
  interface QueryTarget {
7
14
  readonly name: string;
8
15
  }
9
16
  interface QueryRunner {
10
- select(businessDate: Date | null, processingDatetime: Date | null, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op: RelationalOperationElement, orderBy?: SortOperation[], groupBy?: Attribute[], limit?: number): Promise<Row[]>;
17
+ /** The SQL a runner that executes SQL sends: `toSql()` writes it for this dialect. Postgres when absent. */
18
+ readonly dialect?: DialectName | SqlDialect;
19
+ select(businessDate: Date | null, processingDatetime: Date | null, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op: RelationalOperationElement, orderBy?: SortOperation[], groupBy?: Attribute[], limit?: number, timeoutMs?: number, businessDateTo?: Date | null, distinct?: boolean, offset?: number, having?: Operation): Promise<Row[]>;
11
20
  }
12
21
  declare function registerRunner(runner: QueryRunner): void;
13
22
  declare function clearRunner(): void;
@@ -18,16 +27,41 @@ declare class FinderResult {
18
27
  private readonly _columns;
19
28
  private readonly _table;
20
29
  private readonly _op;
30
+ private readonly _businessDateTo;
21
31
  private _orderBy;
22
32
  private _groupBy;
23
33
  private _limit?;
24
- constructor(_businessDate: Date | null, _processingDatetime: Date | null, _columns: (Attribute | RelationalOperationElement)[], _table: QueryTarget, _op: RelationalOperationElement);
25
- orderByOp(...sorts: SortOperation[]): this;
26
- groupByOp(...attrs: Attribute[]): this;
34
+ private _distinct;
35
+ private _offset?;
36
+ private _having?;
37
+ private _timeoutMs;
38
+ constructor(_businessDate: Date | null, _processingDatetime: Date | null, _columns: (Attribute | RelationalOperationElement)[], _table: QueryTarget, _op: RelationalOperationElement, _businessDateTo?: Date | null);
39
+ /**
40
+ * Order the rows. Calls accumulate: the sorts of the latest call take priority and earlier ones order the
41
+ * rows it leaves tied, as in a chain of `sortBy` calls. Sorting a column again replaces its earlier direction.
42
+ */
43
+ orderBy(...sorts: SortOperation[]): this;
44
+ groupBy(...attrs: Attribute[]): this;
27
45
  limit(n: number): this;
28
- toSql(): string;
46
+ /** Skip the first `n` rows. Sort the rows first: without an order, which rows are first is not defined. */
47
+ offset(n: number): this;
48
+ /** Rows `start` up to but not including `stop`, counting from 0: `offset(start).limit(stop - start)`. */
49
+ slice(start: number, stop: number): this;
50
+ /**
51
+ * Keep the groups for which every condition holds: `HAVING`. A condition tests an aggregate or a grouping column:
52
+ * `f.findAll(null, null, [f.category(), countAll()]).groupBy(f.category()).having(countAll().gt(1))`.
53
+ * Calls accumulate, as `and` does.
54
+ */
55
+ having(...conditions: Operation[]): this;
56
+ /** Return each distinct row once: `SELECT DISTINCT`. A sort on a distinct query has to use a selected column. */
57
+ distinct(): this;
58
+ /** Abort the query and throw QueryTimeoutError if it runs longer than `milliseconds` (default 60000). */
59
+ timeout(milliseconds: number): this;
60
+ /** The query as SQL, in Postgres unless a dialect is given: `toSql('databricks')`. Nothing is run. */
61
+ toSql(dialect?: DialectName | SqlDialect): string;
29
62
  toRows(): Promise<Row[]>;
30
63
  }
31
64
  declare function convertInputsAndSelect(businessDate: Date | string | null, processingDatetime: Date | string | null, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op?: RelationalOperationElement): FinderResult;
65
+ declare function convertInputsAndSelectForDateRange(businessDateFrom: Date | string, businessDateTo: Date | string, processingDatetime: Date | string, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op?: RelationalOperationElement): FinderResult;
32
66
 
33
- export { FinderResult, type QueryRunner, type QueryTarget, type Row, clearRunner, convertInputsAndSelect, getRunner, registerRunner };
67
+ export { DEFAULT_TIMEOUT_MS, FinderResult, type QueryRunner, type QueryTarget, QueryTimeoutError, type Row, clearRunner, convertInputsAndSelect, convertInputsAndSelectForDateRange, getRunner, registerRunner };
@@ -1,19 +1,25 @@
1
1
  import {
2
+ DEFAULT_TIMEOUT_MS,
2
3
  FinderResult,
4
+ QueryTimeoutError,
3
5
  clearRunner,
4
6
  convertInputsAndSelect,
7
+ convertInputsAndSelectForDateRange,
5
8
  getRunner,
6
9
  registerRunner
7
- } from "../chunk-6QTCGJWX.js";
8
- import "../chunk-DFYZVBII.js";
9
- import "../chunk-EYXBYV2X.js";
10
- import "../chunk-5K2Z3YDY.js";
11
- import "../chunk-V647VNMY.js";
12
- import "../chunk-3SSWFES4.js";
10
+ } from "../chunk-KAK75RVS.js";
11
+ import "../chunk-BKPWV3OF.js";
12
+ import "../chunk-GPHWC533.js";
13
+ import "../chunk-MGEL5RWM.js";
14
+ import "../chunk-BGEX377Q.js";
15
+ import "../chunk-PF6EJZHB.js";
13
16
  export {
17
+ DEFAULT_TIMEOUT_MS,
14
18
  FinderResult,
19
+ QueryTimeoutError,
15
20
  clearRunner,
16
21
  convertInputsAndSelect,
22
+ convertInputsAndSelectForDateRange,
17
23
  getRunner,
18
24
  registerRunner
19
25
  };