@hypequery/clickhouse 2.10.1 → 2.11.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 (77) hide show
  1. package/dist/core/cte-scope.d.ts +91 -0
  2. package/dist/core/cte-scope.d.ts.map +1 -0
  3. package/dist/core/cte-scope.js +52 -0
  4. package/dist/core/dialects/clickhouse-dialect.d.ts.map +1 -1
  5. package/dist/core/dialects/clickhouse-dialect.js +4 -1
  6. package/dist/core/features/analytics.d.ts +13 -2
  7. package/dist/core/features/analytics.d.ts.map +1 -1
  8. package/dist/core/features/analytics.js +49 -3
  9. package/dist/core/features/joins.d.ts +5 -1
  10. package/dist/core/features/joins.d.ts.map +1 -1
  11. package/dist/core/features/joins.js +5 -1
  12. package/dist/core/formatters/sql-formatter.d.ts +1 -0
  13. package/dist/core/formatters/sql-formatter.d.ts.map +1 -1
  14. package/dist/core/formatters/sql-formatter.js +10 -3
  15. package/dist/core/query-builder.d.ts +89 -12
  16. package/dist/core/query-builder.d.ts.map +1 -1
  17. package/dist/core/query-builder.js +56 -4
  18. package/dist/core/query-node.d.ts.map +1 -1
  19. package/dist/core/query-node.js +7 -1
  20. package/dist/core/tests/integration/setup.d.ts +9 -0
  21. package/dist/core/tests/integration/setup.d.ts.map +1 -1
  22. package/dist/core/tests/test-utils.d.ts +23 -1
  23. package/dist/core/tests/test-utils.d.ts.map +1 -1
  24. package/dist/core/tests/test-utils.js +12 -3
  25. package/dist/core/types/builder-state.d.ts +68 -9
  26. package/dist/core/types/builder-state.d.ts.map +1 -1
  27. package/dist/core/types/builder-state.js +1 -0
  28. package/dist/core/types/select-types.d.ts +4 -2
  29. package/dist/core/types/select-types.d.ts.map +1 -1
  30. package/dist/core/utils/compound-parameter.d.ts +6 -0
  31. package/dist/core/utils/compound-parameter.d.ts.map +1 -0
  32. package/dist/core/utils/compound-parameter.js +70 -0
  33. package/dist/core/utils/cte-fragments.d.ts +17 -0
  34. package/dist/core/utils/cte-fragments.d.ts.map +1 -0
  35. package/dist/core/utils/cte-fragments.js +20 -0
  36. package/dist/core/utils/cte-scope-state.d.ts +5 -0
  37. package/dist/core/utils/cte-scope-state.d.ts.map +1 -0
  38. package/dist/core/utils/cte-scope-state.js +16 -0
  39. package/dist/core/utils/named-parameters.d.ts +30 -0
  40. package/dist/core/utils/named-parameters.d.ts.map +1 -0
  41. package/dist/core/utils/named-parameters.js +108 -0
  42. package/dist/core/utils/parameter-type.d.ts +10 -0
  43. package/dist/core/utils/parameter-type.d.ts.map +1 -0
  44. package/dist/core/utils/parameter-type.js +46 -0
  45. package/dist/core/utils/record-guards.d.ts +3 -0
  46. package/dist/core/utils/record-guards.d.ts.map +1 -0
  47. package/dist/core/utils/record-guards.js +7 -0
  48. package/dist/core/utils/sql-parens.d.ts +6 -0
  49. package/dist/core/utils/sql-parens.d.ts.map +1 -1
  50. package/dist/core/utils/sql-parens.js +6 -1
  51. package/dist/index.d.ts +4 -2
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +1 -5
  54. package/dist/types/base.d.ts +39 -0
  55. package/dist/types/base.d.ts.map +1 -1
  56. package/package.json +3 -4
  57. package/dist/core/compiled/compile.d.ts +0 -25
  58. package/dist/core/compiled/compile.d.ts.map +0 -1
  59. package/dist/core/compiled/compile.js +0 -134
  60. package/dist/core/compiled/debug.d.ts +0 -7
  61. package/dist/core/compiled/debug.d.ts.map +0 -1
  62. package/dist/core/compiled/debug.js +0 -25
  63. package/dist/core/compiled/errors.d.ts +0 -38
  64. package/dist/core/compiled/errors.d.ts.map +0 -1
  65. package/dist/core/compiled/errors.js +0 -91
  66. package/dist/core/compiled/index.d.ts +0 -15
  67. package/dist/core/compiled/index.d.ts.map +0 -1
  68. package/dist/core/compiled/index.js +0 -14
  69. package/dist/core/compiled/parameters.d.ts +0 -28
  70. package/dist/core/compiled/parameters.d.ts.map +0 -1
  71. package/dist/core/compiled/parameters.js +0 -282
  72. package/dist/core/compiled/settings.d.ts +0 -49
  73. package/dist/core/compiled/settings.d.ts.map +0 -1
  74. package/dist/core/compiled/settings.js +0 -65
  75. package/dist/core/compiled/types.d.ts +0 -115
  76. package/dist/core/compiled/types.d.ts.map +0 -1
  77. package/dist/core/compiled/types.js +0 -13
@@ -1,115 +0,0 @@
1
- import type { ProtocolIdentifier, TaggedValue } from '@hypequery/protocol';
2
- /**
3
- * Execution-request contract from RFC 0010 (compiled query, error, cancellation),
4
- * realized for the ClickHouse runtime.
5
- *
6
- * This is the versioned shape a runtime hands to an adapter. It sits *beside* the
7
- * legacy positional path (`adapter.query(sql, params: unknown[])`, which renders
8
- * values into SQL text via `substituteParameters`). Nothing here lets a request
9
- * author SQL, tenant proof, or settings — those are trusted build/policy output.
10
- *
11
- * NOTE: distinct from the internal `CompiledQuery` in `../../types/base.ts`, which
12
- * is the SQL-formatter fragment `{ query, parameters }`.
13
- */
14
- export declare const COMPILED_QUERY_VERSION: 1;
15
- /** Closed operation set (RFC 0010 §Operations). The operation belongs to the compiled
16
- * query, never to the request. */
17
- export type CompiledOperation = 'query' | 'command' | 'insert';
18
- /**
19
- * A logical parameter type. The logical tag drives validation and the `{name:Type}`
20
- * placeholder the adapter sends; `clickHouseType` is the concrete server type string
21
- * (e.g. `UInt64`, `DateTime64(3, 'UTC')`, `Array(String)`).
22
- */
23
- export interface CompiledParameterType {
24
- /** RFC 0001 logical tag, or a scalar shorthand for native JSON scalars. */
25
- readonly logical: TaggedValue['$hypequery']['type'] | 'boolean' | 'string' | 'float' | 'null';
26
- /** Concrete ClickHouse server type used to build the native placeholder. */
27
- readonly clickHouseType: string;
28
- }
29
- /**
30
- * A named, typed parameter declaration carried beside the SQL text. A request supplies
31
- * only values for declared names; it can neither add names nor change types.
32
- */
33
- export interface CompiledParameterDeclaration {
34
- readonly name: ProtocolIdentifier;
35
- readonly type: CompiledParameterType;
36
- /** Optional parameters may be absent from a request; required ones fail closed. */
37
- readonly optional: boolean;
38
- }
39
- /** A supplied parameter value: an RFC 0001 tagged value or a native JSON scalar. */
40
- export type CompiledParameterValue = TaggedValue | string | number | boolean | null;
41
- /**
42
- * The resolved `{name: value}` map the adapter binds to native server parameters.
43
- * Every key is a declared parameter name; no value is ever rendered into SQL text.
44
- */
45
- export type CompiledParameterBindings = Readonly<Record<string, CompiledParameterValue>>;
46
- /**
47
- * Data sensitivity metadata. Marks whether the query touches tenant-scoped or otherwise
48
- * sensitive data so diagnostics/redaction downstream can act without inspecting values.
49
- */
50
- export interface CompiledSensitivity {
51
- /** The compiled SQL already contains trusted tenant predicates (RFC 0010 §Operations). */
52
- readonly tenantScoped: boolean;
53
- /** Free-form trusted classification labels (e.g. 'pii'); never request-supplied. */
54
- readonly labels: readonly string[];
55
- }
56
- /**
57
- * Bounded settings the runtime applies per execution. These originate only from trusted
58
- * components; a request can never set, override, or relax them. See `settings.ts` for the
59
- * closed allow-list and ranges.
60
- */
61
- export interface CompiledSettings {
62
- /** Wall-clock ceiling for server-side execution, milliseconds. Always enforced. */
63
- readonly maxExecutionMs?: number;
64
- /** Maximum rows the result may contain. */
65
- readonly maxResultRows?: number;
66
- /** Maximum bytes the result may contain. */
67
- readonly maxResultBytes?: number;
68
- }
69
- /** Effective deadline + cancellation inputs (RFC 0010 §Deadline and cancellation). */
70
- export interface CompiledDeadline {
71
- /** Epoch-millis absolute deadline. Earlier of caller-supplied and policy-derived. */
72
- readonly atEpochMs: number;
73
- /** Which side set the effective deadline, for honest diagnostics. */
74
- readonly source: 'caller' | 'policy';
75
- }
76
- /** Authoritative + optional correlation identifiers (RFC 0010 §Query identifier). */
77
- export interface CompiledIdentifiers {
78
- /** Server-generated, unique per execution, unguessable, safe for logs/cache metadata. */
79
- readonly queryId: string;
80
- /** Caller-supplied, non-authoritative, ≤1024 UTF-8 bytes, no control chars; never
81
- * influences routing, cache keys, or authorization. */
82
- readonly correlationId?: string;
83
- }
84
- /**
85
- * Redacted, non-executable debug form (RFC 0010 §Debug form). Shows SQL structure with
86
- * placeholders and declared types; carries no values, tenant values, credentials, or
87
- * settings beyond their names. `sql` here is deliberately not valid database SQL.
88
- */
89
- export interface CompiledDebugForm {
90
- readonly sql: string;
91
- readonly parameters: readonly {
92
- readonly name: string;
93
- readonly type: string;
94
- readonly optional: boolean;
95
- }[];
96
- readonly settings: readonly string[];
97
- }
98
- /**
99
- * The compiled query: the only way a runtime asks a ClickHouse adapter to execute.
100
- */
101
- export interface CompiledQueryV1 {
102
- readonly version: typeof COMPILED_QUERY_VERSION;
103
- readonly operation: CompiledOperation;
104
- /** Trusted build/server output. Callers influence execution only via `bindings`. */
105
- readonly sql: string;
106
- readonly parameters: readonly CompiledParameterDeclaration[];
107
- /** Resolved values for declared names, bound to native server parameters. */
108
- readonly bindings: CompiledParameterBindings;
109
- readonly settings: CompiledSettings;
110
- readonly identifiers: CompiledIdentifiers;
111
- readonly deadline?: CompiledDeadline;
112
- readonly sensitivity: CompiledSensitivity;
113
- readonly debug: CompiledDebugForm;
114
- }
115
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/compiled/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE3E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,EAAG,CAAU,CAAC;AAEjD;kCACkC;AAClC,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/D;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IAC9F,4EAA4E;IAC5E,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CA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E,SAAS;QAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;KAC5B,EAAE,CAAC;IACJ,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,OAAO,sBAAsB,CAAC;IAChD,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,oFAAoF;IACpF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,SAAS,4BAA4B,EAAE,CAAC;IAC7D,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;CACnC"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Execution-request contract from RFC 0010 (compiled query, error, cancellation),
3
- * realized for the ClickHouse runtime.
4
- *
5
- * This is the versioned shape a runtime hands to an adapter. It sits *beside* the
6
- * legacy positional path (`adapter.query(sql, params: unknown[])`, which renders
7
- * values into SQL text via `substituteParameters`). Nothing here lets a request
8
- * author SQL, tenant proof, or settings — those are trusted build/policy output.
9
- *
10
- * NOTE: distinct from the internal `CompiledQuery` in `../../types/base.ts`, which
11
- * is the SQL-formatter fragment `{ query, parameters }`.
12
- */
13
- export const COMPILED_QUERY_VERSION = 1;