@hypequery/cli 1.21.2 → 1.23.0

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 (185) hide show
  1. package/README.md +1 -0
  2. package/dist/bin/cli.js +77 -12
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +33 -15
  5. package/dist/commands/deploy.d.ts +5 -0
  6. package/dist/commands/deploy.d.ts.map +1 -1
  7. package/dist/commands/deploy.js +10 -0
  8. package/dist/commands/deployment-status.d.ts +16 -0
  9. package/dist/commands/deployment-status.d.ts.map +1 -0
  10. package/dist/commands/deployment-status.js +36 -0
  11. package/dist/commands/dev.d.ts.map +1 -1
  12. package/dist/commands/dev.js +25 -5
  13. package/dist/commands/generate-datasets.d.ts +0 -6
  14. package/dist/commands/generate-datasets.d.ts.map +1 -1
  15. package/dist/commands/generate-datasets.js +17 -1
  16. package/dist/commands/generate-manifest.d.ts.map +1 -1
  17. package/dist/commands/generate-manifest.js +4 -0
  18. package/dist/commands/generate.d.ts.map +1 -1
  19. package/dist/commands/generate.js +14 -1
  20. package/dist/commands/init.d.ts.map +1 -1
  21. package/dist/commands/init.js +80 -55
  22. package/dist/commands/live-source.d.ts.map +1 -1
  23. package/dist/commands/live-source.js +3 -21
  24. package/dist/commands/mcp.d.ts +10 -0
  25. package/dist/commands/mcp.d.ts.map +1 -1
  26. package/dist/commands/mcp.js +93 -8
  27. package/dist/commands/telemetry.d.ts +3 -0
  28. package/dist/commands/telemetry.d.ts.map +1 -0
  29. package/dist/commands/telemetry.js +19 -0
  30. package/dist/generators/chdb.d.ts +3 -0
  31. package/dist/generators/chdb.d.ts.map +1 -1
  32. package/dist/generators/chdb.js +2 -0
  33. package/dist/generators/clickhouse.d.ts +3 -1
  34. package/dist/generators/clickhouse.d.ts.map +1 -1
  35. package/dist/generators/clickhouse.js +2 -0
  36. package/dist/test-utils.d.ts +1 -1
  37. package/dist/typegen/generate-types.d.ts +3 -0
  38. package/dist/typegen/generate-types.d.ts.map +1 -1
  39. package/dist/typegen/generate-types.js +5 -1
  40. package/dist/typegen/type-parsing.d.ts +1 -1
  41. package/dist/typegen/type-parsing.d.ts.map +1 -1
  42. package/dist/typegen/type-parsing.js +11 -7
  43. package/dist/utils/chdb-gitignore-entry.d.ts +2 -0
  44. package/dist/utils/chdb-gitignore-entry.d.ts.map +1 -0
  45. package/dist/utils/chdb-gitignore-entry.js +17 -0
  46. package/dist/utils/cli-version.d.ts +2 -0
  47. package/dist/utils/cli-version.d.ts.map +1 -0
  48. package/dist/utils/cli-version.js +11 -0
  49. package/dist/utils/cloud-credential-store.d.ts.map +1 -1
  50. package/dist/utils/cloud-credential-store.js +2 -13
  51. package/dist/utils/command-exit.d.ts +13 -0
  52. package/dist/utils/command-exit.d.ts.map +1 -0
  53. package/dist/utils/command-exit.js +31 -0
  54. package/dist/utils/config-directory.d.ts +3 -0
  55. package/dist/utils/config-directory.d.ts.map +1 -0
  56. package/dist/utils/config-directory.js +14 -0
  57. package/dist/utils/deployment-target.d.ts +7 -0
  58. package/dist/utils/deployment-target.d.ts.map +1 -0
  59. package/dist/utils/deployment-target.js +19 -0
  60. package/dist/utils/detect-database-environment.d.ts +3 -0
  61. package/dist/utils/detect-database-environment.d.ts.map +1 -0
  62. package/dist/utils/detect-database-environment.js +8 -0
  63. package/dist/utils/detect-database.d.ts.map +1 -1
  64. package/dist/utils/detect-database.js +4 -8
  65. package/dist/utils/hosted-endpoints-output.d.ts +4 -0
  66. package/dist/utils/hosted-endpoints-output.d.ts.map +1 -0
  67. package/dist/utils/hosted-endpoints-output.js +27 -0
  68. package/dist/utils/hosted-endpoints.d.ts +37 -0
  69. package/dist/utils/hosted-endpoints.d.ts.map +1 -0
  70. package/dist/utils/hosted-endpoints.js +81 -0
  71. package/dist/utils/init-options.d.ts +11 -0
  72. package/dist/utils/init-options.d.ts.map +1 -0
  73. package/dist/utils/init-options.js +28 -0
  74. package/dist/utils/live-deployment.d.ts +6 -0
  75. package/dist/utils/live-deployment.d.ts.map +1 -1
  76. package/dist/utils/live-deployment.js +6 -1
  77. package/dist/utils/load-api.d.ts +2 -0
  78. package/dist/utils/load-api.d.ts.map +1 -1
  79. package/dist/utils/load-api.js +50 -51
  80. package/dist/utils/load-env-files.d.ts +10 -0
  81. package/dist/utils/load-env-files.d.ts.map +1 -0
  82. package/dist/utils/load-env-files.js +27 -0
  83. package/dist/utils/mcp-remote-check.d.ts +19 -0
  84. package/dist/utils/mcp-remote-check.d.ts.map +1 -0
  85. package/dist/utils/mcp-remote-check.js +96 -0
  86. package/dist/utils/mcp-response.d.ts +3 -0
  87. package/dist/utils/mcp-response.d.ts.map +1 -0
  88. package/dist/utils/mcp-response.js +58 -0
  89. package/dist/utils/project-root.d.ts +14 -0
  90. package/dist/utils/project-root.d.ts.map +1 -0
  91. package/dist/utils/project-root.js +41 -0
  92. package/dist/utils/telemetry/buckets.d.ts +5 -0
  93. package/dist/utils/telemetry/buckets.d.ts.map +1 -0
  94. package/dist/utils/telemetry/buckets.js +23 -0
  95. package/dist/utils/telemetry/catalog-docs.d.ts +3 -0
  96. package/dist/utils/telemetry/catalog-docs.d.ts.map +1 -0
  97. package/dist/utils/telemetry/catalog-docs.js +52 -0
  98. package/dist/utils/telemetry/catalog.d.ts +1124 -0
  99. package/dist/utils/telemetry/catalog.d.ts.map +1 -0
  100. package/dist/utils/telemetry/catalog.js +154 -0
  101. package/dist/utils/telemetry/command-context.d.ts +17 -0
  102. package/dist/utils/telemetry/command-context.d.ts.map +1 -0
  103. package/dist/utils/telemetry/command-context.js +30 -0
  104. package/dist/utils/telemetry/config-schema.d.ts +12 -0
  105. package/dist/utils/telemetry/config-schema.d.ts.map +1 -0
  106. package/dist/utils/telemetry/config-schema.js +33 -0
  107. package/dist/utils/telemetry/config-store.d.ts +35 -0
  108. package/dist/utils/telemetry/config-store.d.ts.map +1 -0
  109. package/dist/utils/telemetry/config-store.js +147 -0
  110. package/dist/utils/telemetry/delivery.d.ts +13 -0
  111. package/dist/utils/telemetry/delivery.d.ts.map +1 -0
  112. package/dist/utils/telemetry/delivery.js +26 -0
  113. package/dist/utils/telemetry/detached-dispatch.d.ts +12 -0
  114. package/dist/utils/telemetry/detached-dispatch.d.ts.map +1 -0
  115. package/dist/utils/telemetry/detached-dispatch.js +33 -0
  116. package/dist/utils/telemetry/detached-sender.d.ts +2 -0
  117. package/dist/utils/telemetry/detached-sender.d.ts.map +1 -0
  118. package/dist/utils/telemetry/detached-sender.js +31 -0
  119. package/dist/utils/telemetry/dev-session.d.ts +15 -0
  120. package/dist/utils/telemetry/dev-session.d.ts.map +1 -0
  121. package/dist/utils/telemetry/dev-session.js +25 -0
  122. package/dist/utils/telemetry/domains.d.ts +69 -0
  123. package/dist/utils/telemetry/domains.d.ts.map +1 -0
  124. package/dist/utils/telemetry/domains.js +64 -0
  125. package/dist/utils/telemetry/endpoint.d.ts +3 -0
  126. package/dist/utils/telemetry/endpoint.d.ts.map +1 -0
  127. package/dist/utils/telemetry/endpoint.js +15 -0
  128. package/dist/utils/telemetry/environment.d.ts +27 -0
  129. package/dist/utils/telemetry/environment.d.ts.map +1 -0
  130. package/dist/utils/telemetry/environment.js +95 -0
  131. package/dist/utils/telemetry/error-code.d.ts +4 -0
  132. package/dist/utils/telemetry/error-code.d.ts.map +1 -0
  133. package/dist/utils/telemetry/error-code.js +57 -0
  134. package/dist/utils/telemetry/flags.d.ts +5 -0
  135. package/dist/utils/telemetry/flags.d.ts.map +1 -0
  136. package/dist/utils/telemetry/flags.js +41 -0
  137. package/dist/utils/telemetry/generation-metrics.d.ts +15 -0
  138. package/dist/utils/telemetry/generation-metrics.d.ts.map +1 -0
  139. package/dist/utils/telemetry/generation-metrics.js +35 -0
  140. package/dist/utils/telemetry/identity.d.ts +12 -0
  141. package/dist/utils/telemetry/identity.d.ts.map +1 -0
  142. package/dist/utils/telemetry/identity.js +42 -0
  143. package/dist/utils/telemetry/init-funnel.d.ts +15 -0
  144. package/dist/utils/telemetry/init-funnel.d.ts.map +1 -0
  145. package/dist/utils/telemetry/init-funnel.js +25 -0
  146. package/dist/utils/telemetry/invocation.d.ts +22 -0
  147. package/dist/utils/telemetry/invocation.d.ts.map +1 -0
  148. package/dist/utils/telemetry/invocation.js +46 -0
  149. package/dist/utils/telemetry/lifecycle.d.ts +32 -0
  150. package/dist/utils/telemetry/lifecycle.d.ts.map +1 -0
  151. package/dist/utils/telemetry/lifecycle.js +99 -0
  152. package/dist/utils/telemetry/mcp-session.d.ts +10 -0
  153. package/dist/utils/telemetry/mcp-session.d.ts.map +1 -0
  154. package/dist/utils/telemetry/mcp-session.js +36 -0
  155. package/dist/utils/telemetry/notice.d.ts +11 -0
  156. package/dist/utils/telemetry/notice.d.ts.map +1 -0
  157. package/dist/utils/telemetry/notice.js +24 -0
  158. package/dist/utils/telemetry/opt-out.d.ts +16 -0
  159. package/dist/utils/telemetry/opt-out.d.ts.map +1 -0
  160. package/dist/utils/telemetry/opt-out.js +32 -0
  161. package/dist/utils/telemetry/post-json.d.ts +13 -0
  162. package/dist/utils/telemetry/post-json.d.ts.map +1 -0
  163. package/dist/utils/telemetry/post-json.js +32 -0
  164. package/dist/utils/telemetry/project-context.d.ts +15 -0
  165. package/dist/utils/telemetry/project-context.d.ts.map +1 -0
  166. package/dist/utils/telemetry/project-context.js +86 -0
  167. package/dist/utils/telemetry/schema.d.ts +72 -0
  168. package/dist/utils/telemetry/schema.d.ts.map +1 -0
  169. package/dist/utils/telemetry/schema.js +17 -0
  170. package/dist/utils/telemetry/session-config.d.ts +6 -0
  171. package/dist/utils/telemetry/session-config.d.ts.map +1 -0
  172. package/dist/utils/telemetry/session-config.js +17 -0
  173. package/dist/utils/telemetry/settings-lock.d.ts +36 -0
  174. package/dist/utils/telemetry/settings-lock.d.ts.map +1 -0
  175. package/dist/utils/telemetry/settings-lock.js +102 -0
  176. package/dist/utils/telemetry/transport.d.ts +25 -0
  177. package/dist/utils/telemetry/transport.d.ts.map +1 -0
  178. package/dist/utils/telemetry/transport.js +76 -0
  179. package/dist/utils/telemetry/validation.d.ts +10 -0
  180. package/dist/utils/telemetry/validation.d.ts.map +1 -0
  181. package/dist/utils/telemetry/validation.js +77 -0
  182. package/dist/utils/telemetry/value-formats.d.ts +30 -0
  183. package/dist/utils/telemetry/value-formats.d.ts.map +1 -0
  184. package/dist/utils/telemetry/value-formats.js +13 -0
  185. package/package.json +16 -12
@@ -1,8 +1,10 @@
1
- import { clickhouseToTsType } from '../typegen/index.js';
1
+ import { clickhouseToTsType, type GenerateTypesOptions } from '../typegen/index.js';
2
2
  export interface ClickHouseGeneratorOptions {
3
3
  outputPath: string;
4
4
  includeTables?: string[];
5
5
  excludeTables?: string[];
6
+ onColumn?: GenerateTypesOptions['onColumn'];
7
+ onUnsupportedType?: GenerateTypesOptions['onUnsupportedType'];
6
8
  }
7
9
  export { clickhouseToTsType };
8
10
  export declare function generateClickHouseTypes(options: ClickHouseGeneratorOptions): Promise<string[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"clickhouse.d.ts","sourceRoot":"","sources":["../../src/generators/clickhouse.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAGnB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,0BAA0B,qBAUhF"}
1
+ {"version":3,"file":"clickhouse.d.ts","sourceRoot":"","sources":["../../src/generators/clickhouse.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAElB,KAAK,oBAAoB,EAC1B,MAAM,qBAAqB,CAAC;AAG7B,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,oBAAoB,CAAC,UAAU,CAAC,CAAC;IAC5C,iBAAiB,CAAC,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,CAAC;CAC/D;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,0BAA0B,qBAYhF"}
@@ -6,6 +6,8 @@ export async function generateClickHouseTypes(options) {
6
6
  client: getClickHouseClient(),
7
7
  generatedBy: 'hypequery',
8
8
  includeUsageExample: false,
9
+ ...(options.onColumn ? { onColumn: options.onColumn } : {}),
10
+ ...(options.onUnsupportedType ? { onUnsupportedType: options.onUnsupportedType } : {}),
9
11
  ...(options.includeTables ? { includeTables: options.includeTables } : {}),
10
12
  ...(options.excludeTables ? { excludeTables: options.excludeTables } : {}),
11
13
  };
@@ -8,7 +8,7 @@ export declare class ProcessExitError extends Error {
8
8
  constructor(code: number);
9
9
  }
10
10
  export declare function mockProcessExit(): {
11
- exitMock: Mock<(...args: any[]) => any>;
11
+ exitMock: Mock;
12
12
  restore: () => void;
13
13
  };
14
14
  //# sourceMappingURL=test-utils.d.ts.map
@@ -33,6 +33,9 @@ export interface GenerateTypesOptions {
33
33
  generatedBy?: string;
34
34
  /** Append the historical usage-example comment block. */
35
35
  includeUsageExample?: boolean;
36
+ /** Optional aggregate-observation hooks; errors never affect generation. */
37
+ onColumn?: () => void;
38
+ onUnsupportedType?: (type: string) => void;
36
39
  }
37
40
  /**
38
41
  * Generates the TypeScript type definition source from a ClickHouse client.
@@ -1 +1 @@
1
- {"version":3,"file":"generate-types.d.ts","sourceRoot":"","sources":["../../src/typegen/generate-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C,KAAK,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,aAAa,CA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AE,MAAM,EAAE,CAAC;IACzB,qCAAqC;IACrC,MAAM,EAAE,8BAA8B,CAAC;IACvC,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AA2HD;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,8BAA8B,EACtC,OAAO,GAAE,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAM,GACjD,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,MAAM,EAAE,CAAC,CAYnB"}
@@ -72,7 +72,11 @@ export interface IntrospectedSchema {`;
72
72
  const columns = await describeTable(client, table.name);
73
73
  typeDefinitions += `export interface ${capitalizeFirstLetter(table.name)}Record {`;
74
74
  for (const column of columns) {
75
- const tsType = clickhouseToTsType(column.type);
75
+ try {
76
+ options.onColumn?.();
77
+ }
78
+ catch { /* Preserve type output. */ }
79
+ const tsType = clickhouseToTsType(column.type, options.onUnsupportedType);
76
80
  typeDefinitions += `\n '${column.name}': ${tsType};`;
77
81
  }
78
82
  typeDefinitions += '\n}\n\n';
@@ -2,5 +2,5 @@
2
2
  * Converts a ClickHouse type string, as returned by `DESCRIBE TABLE`, into the
3
3
  * equivalent TypeScript type string.
4
4
  */
5
- export declare const clickhouseToTsType: (type: string) => string;
5
+ export declare const clickhouseToTsType: (type: string, onUnsupported?: (type: string) => void) => string;
6
6
  //# sourceMappingURL=type-parsing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type-parsing.d.ts","sourceRoot":"","sources":["../../src/typegen/type-parsing.ts"],"names":[],"mappings":"AAwLA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,KAAG,MA6CjD,CAAC"}
1
+ {"version":3,"file":"type-parsing.d.ts","sourceRoot":"","sources":["../../src/typegen/type-parsing.ts"],"names":[],"mappings":"AAwLA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,EAAE,gBAAgB,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,KAAG,MA8CzF,CAAC"}
@@ -167,19 +167,19 @@ function getPrimitiveTsType(type) {
167
167
  * Converts a ClickHouse type string, as returned by `DESCRIBE TABLE`, into the
168
168
  * equivalent TypeScript type string.
169
169
  */
170
- export const clickhouseToTsType = (type) => {
170
+ export const clickhouseToTsType = (type, onUnsupported) => {
171
171
  const normalizedType = type.trim();
172
172
  const wrappedArrayType = unwrapType(normalizedType, 'Array');
173
173
  if (wrappedArrayType) {
174
- return `Array<${clickhouseToTsType(wrappedArrayType)}>`;
174
+ return `Array<${clickhouseToTsType(wrappedArrayType, onUnsupported)}>`;
175
175
  }
176
176
  const wrappedNullableType = unwrapType(normalizedType, 'Nullable');
177
177
  if (wrappedNullableType) {
178
- return `${clickhouseToTsType(wrappedNullableType)} | null`;
178
+ return `${clickhouseToTsType(wrappedNullableType, onUnsupported)} | null`;
179
179
  }
180
180
  const wrappedLowCardinalityType = unwrapType(normalizedType, 'LowCardinality');
181
181
  if (wrappedLowCardinalityType) {
182
- return clickhouseToTsType(wrappedLowCardinalityType);
182
+ return clickhouseToTsType(wrappedLowCardinalityType, onUnsupported);
183
183
  }
184
184
  const wrappedTupleType = unwrapType(normalizedType, 'Tuple');
185
185
  if (wrappedTupleType) {
@@ -187,10 +187,10 @@ export const clickhouseToTsType = (type) => {
187
187
  const namedParts = tupleParts.map(parseNamedTuplePart);
188
188
  if (namedParts.length > 0 && namedParts.every((part) => part !== null)) {
189
189
  return `{ ${namedParts
190
- .map((part) => `${formatTypeScriptProperty(part.name)}: ${clickhouseToTsType(part.type)}`)
190
+ .map((part) => `${formatTypeScriptProperty(part.name)}: ${clickhouseToTsType(part.type, onUnsupported)}`)
191
191
  .join('; ')} }`;
192
192
  }
193
- return `[${tupleParts.map((part) => clickhouseToTsType(part)).join(', ')}]`;
193
+ return `[${tupleParts.map((part) => clickhouseToTsType(part, onUnsupported)).join(', ')}]`;
194
194
  }
195
195
  const wrappedMapType = unwrapType(normalizedType, 'Map');
196
196
  if (wrappedMapType) {
@@ -198,7 +198,7 @@ export const clickhouseToTsType = (type) => {
198
198
  if (mapParts.length === 2) {
199
199
  const [, valueType] = mapParts;
200
200
  // JSON object keys are strings even when ClickHouse map keys are numeric.
201
- return `Record<string, ${clickhouseToTsType(valueType)}>`;
201
+ return `Record<string, ${clickhouseToTsType(valueType, onUnsupported)}>`;
202
202
  }
203
203
  return 'Record<string, unknown>';
204
204
  }
@@ -206,5 +206,9 @@ export const clickhouseToTsType = (type) => {
206
206
  if (primitiveType)
207
207
  return primitiveType;
208
208
  // Unsupported or more complex ClickHouse types currently preserve the historical fallback.
209
+ try {
210
+ onUnsupported?.(normalizedType);
211
+ }
212
+ catch { /* Optional observers cannot change generated types. */ }
209
213
  return 'string';
210
214
  };
@@ -0,0 +1,2 @@
1
+ export declare function getChdbGitignoreEntry(chdbPath: string | undefined, cwd: string): string | undefined;
2
+ //# sourceMappingURL=chdb-gitignore-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chdb-gitignore-entry.d.ts","sourceRoot":"","sources":["../../src/utils/chdb-gitignore-entry.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAmBnG"}
@@ -0,0 +1,17 @@
1
+ import path from 'node:path';
2
+ export function getChdbGitignoreEntry(chdbPath, cwd) {
3
+ if (!chdbPath || /[\0\r\n]/.test(chdbPath)) {
4
+ return undefined;
5
+ }
6
+ cwd = path.resolve(cwd);
7
+ const relativePath = path.relative(cwd, path.resolve(cwd, chdbPath));
8
+ if (relativePath.length === 0 ||
9
+ relativePath === '..' ||
10
+ relativePath.startsWith(`..${path.sep}`) ||
11
+ path.isAbsolute(relativePath)) {
12
+ return undefined;
13
+ }
14
+ const normalizedPath = relativePath.split(path.sep).join('/');
15
+ const escapedPath = normalizedPath.replace(/[\\*?[\]]/g, '\\$&');
16
+ return `/${escapedPath}/`;
17
+ }
@@ -0,0 +1,2 @@
1
+ export declare function getCliVersion(): string;
2
+ //# sourceMappingURL=cli-version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-version.d.ts","sourceRoot":"","sources":["../../src/utils/cli-version.ts"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,IAAI,MAAM,CAKtC"}
@@ -0,0 +1,11 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ export function getCliVersion() {
4
+ try {
5
+ const pkg = JSON.parse(readFileSync(fileURLToPath(new URL('../../package.json', import.meta.url)), 'utf8'));
6
+ return pkg.version ?? '0.0.0';
7
+ }
8
+ catch {
9
+ return '0.0.0';
10
+ }
11
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"cloud-credential-store.d.ts","sourceRoot":"","sources":["../../src/utils/cloud-credential-store.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AACtD,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAGrE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,+BAA+B,C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gCAAqC,iBAkEpD;AAED,wBAAsB,mBAAmB,CACvC,YAAY,GAAE,gCAAqC,GAClD,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAsBvC;AA0BD,wBAAsB,qBAAqB,CACzC,YAAY,GAAE,gCAAqC,iBA0BpD"}
@@ -1,24 +1,13 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { chmod, mkdir, readFile, rename, unlink, writeFile } from 'node:fs/promises';
3
- import { homedir } from 'node:os';
4
3
  import path from 'node:path';
4
+ import { configDirectory } from './config-directory.js';
5
5
  import { validateProtocolDeploymentReleaseTarget, } from '@hypequery/protocol';
6
6
  const KEYCHAIN_SERVICE = 'dev.hypequery.cli';
7
7
  const PROFILE_FILE = 'cloud-profile.json';
8
8
  export const CLOUD_DEPLOYMENT_SCOPE = 'deploy:submit';
9
9
  export const CLOUD_SOURCE_SCOPE = 'deploy:submit deploy:read-source';
10
10
  const MAX_KEYCHAIN_ACCOUNT_LENGTH = 2048;
11
- function defaultConfigDirectory(env, platform) {
12
- if (env.HYPEQUERY_CONFIG_DIR)
13
- return env.HYPEQUERY_CONFIG_DIR;
14
- if (platform === 'win32') {
15
- return path.join(env.APPDATA ?? env.LOCALAPPDATA ?? homedir(), 'hypequery');
16
- }
17
- if (platform === 'darwin') {
18
- return path.join(homedir(), 'Library', 'Application Support', 'hypequery');
19
- }
20
- return path.join(env.XDG_CONFIG_HOME ?? path.join(homedir(), '.config'), 'hypequery');
21
- }
22
11
  function vaultUnavailable(error) {
23
12
  return new Error('The operating-system credential vault is unavailable. '
24
13
  + 'Install its keyring service or use HYPEQUERY_API_TOKEN for manual authentication.', { cause: error });
@@ -36,7 +25,7 @@ function paths(dependencies) {
36
25
  const env = dependencies.env ?? process.env;
37
26
  const platform = dependencies.platform ?? process.platform;
38
27
  const directory = dependencies.configDirectory
39
- ?? defaultConfigDirectory(env, platform);
28
+ ?? configDirectory(env, platform);
40
29
  return { directory, profile: path.join(directory, PROFILE_FILE) };
41
30
  }
42
31
  export function normalizeCloudOrigin(input) {
@@ -0,0 +1,13 @@
1
+ import type { ERROR_CODES, OUTCOMES } from './telemetry/domains.js';
2
+ export declare class CommandExit extends Error {
3
+ readonly exitCode: number;
4
+ readonly outcome: typeof OUTCOMES[number];
5
+ readonly errorCode?: (typeof ERROR_CODES)[number] | undefined;
6
+ constructor(exitCode: number, outcome: typeof OUTCOMES[number], errorCode?: (typeof ERROR_CODES)[number] | undefined);
7
+ }
8
+ /** Only the executable installs this; standalone command calls preserve their legacy exits. */
9
+ export declare function installCommandExitFinalizer(finish: (exit: CommandExit) => Promise<void>): () => void;
10
+ export declare function exitWith(code: number, outcome?: CommandExit['outcome'], errorCode?: CommandExit['errorCode']): never;
11
+ /** Signal-driven shutdown runs after the owning command's resource cleanup. */
12
+ export declare function finishAndExit(code: number, outcome: CommandExit['outcome'], errorCode?: CommandExit['errorCode']): Promise<never>;
13
+ //# sourceMappingURL=command-exit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-exit.d.ts","sourceRoot":"","sources":["../../src/utils/command-exit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEpE,qBAAa,WAAY,SAAQ,KAAK;IAElC,QAAQ,CAAC,QAAQ,EAAE,MAAM;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAA,OAAO,WAAW,EAAC,MAAM,CAAC;gBAFtC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,QAAQ,CAAC,MAAM,CAAC,EAChC,SAAS,CAAC,EAAE,CAAA,OAAO,WAAW,EAAC,MAAM,CAAC,YAAA;CAElD;AAID,+FAA+F;AAC/F,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,CAGpG;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAW,CAAC,SAAS,CAAwC,EAAE,SAAS,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,KAAK,CAG1J;AAED,+EAA+E;AAC/E,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAGvI"}
@@ -0,0 +1,31 @@
1
+ export class CommandExit extends Error {
2
+ exitCode;
3
+ outcome;
4
+ errorCode;
5
+ constructor(exitCode, outcome, errorCode) {
6
+ super('Command requested exit');
7
+ this.exitCode = exitCode;
8
+ this.outcome = outcome;
9
+ this.errorCode = errorCode;
10
+ }
11
+ }
12
+ let finalizer;
13
+ /** Only the executable installs this; standalone command calls preserve their legacy exits. */
14
+ export function installCommandExitFinalizer(finish) {
15
+ finalizer = finish;
16
+ return () => { if (finalizer === finish)
17
+ finalizer = undefined; };
18
+ }
19
+ export function exitWith(code, outcome = code === 0 ? 'cancelled' : 'failure', errorCode) {
20
+ if (finalizer)
21
+ throw new CommandExit(code, outcome, errorCode);
22
+ return process.exit(code);
23
+ }
24
+ /** Signal-driven shutdown runs after the owning command's resource cleanup. */
25
+ export async function finishAndExit(code, outcome, errorCode) {
26
+ try {
27
+ await finalizer?.(new CommandExit(code, outcome, errorCode));
28
+ }
29
+ catch { /* Preserve exit semantics. */ }
30
+ return process.exit(code);
31
+ }
@@ -0,0 +1,3 @@
1
+ /** Shared location for CLI settings and the Cloud credential profile. */
2
+ export declare function configDirectory(env: Readonly<Record<string, string | undefined>>, platform: NodeJS.Platform, home?: string): string;
3
+ //# sourceMappingURL=config-directory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-directory.d.ts","sourceRoot":"","sources":["../../src/utils/config-directory.ts"],"names":[],"mappings":"AAGA,yEAAyE;AACzE,wBAAgB,eAAe,CAC7B,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EACjD,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,IAAI,SAAY,GACf,MAAM,CASR"}
@@ -0,0 +1,14 @@
1
+ import { homedir } from 'node:os';
2
+ import path from 'node:path';
3
+ /** Shared location for CLI settings and the Cloud credential profile. */
4
+ export function configDirectory(env, platform, home = homedir()) {
5
+ if (env.HYPEQUERY_CONFIG_DIR)
6
+ return env.HYPEQUERY_CONFIG_DIR;
7
+ if (platform === 'win32') {
8
+ return path.join(env.APPDATA ?? env.LOCALAPPDATA ?? home, 'hypequery');
9
+ }
10
+ if (platform === 'darwin') {
11
+ return path.join(home, 'Library', 'Application Support', 'hypequery');
12
+ }
13
+ return path.join(env.XDG_CONFIG_HOME ?? path.join(home, '.config'), 'hypequery');
14
+ }
@@ -0,0 +1,7 @@
1
+ import { type ProtocolDeploymentReleaseTarget } from '@hypequery/protocol';
2
+ import type { StoredCloudCredential } from './cloud-credential-store.js';
3
+ export declare function deploymentTargetFromOptions(options: {
4
+ readonly project?: string;
5
+ readonly environment?: string;
6
+ }, credential: StoredCloudCredential | undefined): ProtocolDeploymentReleaseTarget;
7
+ //# sourceMappingURL=deployment-target.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployment-target.d.ts","sourceRoot":"","sources":["../../src/utils/deployment-target.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,wBAAgB,2BAA2B,CACzC,OAAO,EAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,EACrE,UAAU,EAAE,qBAAqB,GAAG,SAAS,GAC5C,+BAA+B,CAkBjC"}
@@ -0,0 +1,19 @@
1
+ import { validateProtocolDeploymentReleaseTarget, } from '@hypequery/protocol';
2
+ export function deploymentTargetFromOptions(options, credential) {
3
+ if ((options.project === undefined) !== (options.environment === undefined)) {
4
+ throw new Error('Pass both --project and --environment, or omit both.');
5
+ }
6
+ const input = options.project === undefined
7
+ ? credential?.target
8
+ : { project: options.project, environment: options.environment };
9
+ if (!input) {
10
+ throw new Error('Missing deployment target. Run `hypequery login` or pass both '
11
+ + '--project and --environment.');
12
+ }
13
+ try {
14
+ return validateProtocolDeploymentReleaseTarget(input);
15
+ }
16
+ catch {
17
+ throw new Error('The deployment target is invalid.');
18
+ }
19
+ }
@@ -0,0 +1,3 @@
1
+ /** Detect backend intent without reading values into diagnostics or contacting a server. */
2
+ export declare function detectDatabaseFromEnvironment(env: Readonly<Record<string, string | undefined>>): 'clickhouse' | 'bigquery' | undefined;
3
+ //# sourceMappingURL=detect-database-environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-database-environment.d.ts","sourceRoot":"","sources":["../../src/utils/detect-database-environment.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAChD,YAAY,GAAG,UAAU,GAAG,SAAS,CAIvC"}
@@ -0,0 +1,8 @@
1
+ /** Detect backend intent without reading values into diagnostics or contacting a server. */
2
+ export function detectDatabaseFromEnvironment(env) {
3
+ if (env.CLICKHOUSE_HOST || env.CLICKHOUSE_URL || env.CLICKHOUSE_DATABASE)
4
+ return 'clickhouse';
5
+ if (env.BIGQUERY_PROJECT_ID || env.GOOGLE_APPLICATION_CREDENTIALS)
6
+ return 'bigquery';
7
+ return undefined;
8
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"detect-database.d.ts","sourceRoot":"","sources":["../../src/utils/detect-database.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;AAE1E;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,YAAY,CAAC,CAuD5D;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,OAAO,CAAC,CAWlB;AAuBD;;GAEG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CASjB;AAyBD;;GAEG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,EAAE,CAAC,CASnB"}
1
+ {"version":3,"file":"detect-database.d.ts","sourceRoot":"","sources":["../../src/utils/detect-database.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;AAE1E;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,YAAY,CAAC,CA8C5D;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,OAAO,CAAC,CAWlB;AAuBD;;GAEG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CASjB;AAyBD;;GAEG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,EAAE,CAAC,CASnB"}
@@ -2,19 +2,15 @@ import { access, readFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { getClickHouseClient } from './clickhouse-client.js';
4
4
  import { validateChdb, getChdbTables } from './chdb-client.js';
5
+ import { detectDatabaseFromEnvironment } from './detect-database-environment.js';
5
6
  /**
6
7
  * Auto-detect database type from environment or config files
7
8
  */
8
9
  export async function detectDatabase() {
9
10
  // Check environment variables
10
- if (process.env.CLICKHOUSE_HOST ||
11
- process.env.CLICKHOUSE_URL ||
12
- process.env.CLICKHOUSE_DATABASE) {
13
- return 'clickhouse';
14
- }
15
- if (process.env.BIGQUERY_PROJECT_ID || process.env.GOOGLE_APPLICATION_CREDENTIALS) {
16
- return 'bigquery';
17
- }
11
+ const detected = detectDatabaseFromEnvironment(process.env);
12
+ if (detected)
13
+ return detected;
18
14
  // Check for .env file and parse it
19
15
  try {
20
16
  const envPath = path.join(process.cwd(), '.env');
@@ -0,0 +1,4 @@
1
+ import { type HostedEndpoints } from './hosted-endpoints.js';
2
+ /** Print Cloud's URLs without ever reading or writing runtime API keys. */
3
+ export declare function printHostedEndpoints(endpoints: HostedEndpoints, mcpConfig: boolean): void;
4
+ //# sourceMappingURL=hosted-endpoints-output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-endpoints-output.d.ts","sourceRoot":"","sources":["../../src/utils/hosted-endpoints-output.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAE/B,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI,CAqBzF"}
@@ -0,0 +1,27 @@
1
+ import { logger } from './logger.js';
2
+ import { MCP_API_KEY_VARIABLE, mcpClientConfiguration, } from './hosted-endpoints.js';
3
+ /** Print Cloud's URLs without ever reading or writing runtime API keys. */
4
+ export function printHostedEndpoints(endpoints, mcpConfig) {
5
+ logger.newline();
6
+ logger.info('Hosted endpoints');
7
+ logger.indent(`REST ${endpoints.rest.baseUrl}`);
8
+ const width = Math.max(0, ...endpoints.rest.datasets.map((dataset) => dataset.name.length));
9
+ for (const dataset of endpoints.rest.datasets) {
10
+ logger.indent(` ${dataset.name.padEnd(width)} POST ${dataset.url}`);
11
+ }
12
+ logger.indent(`MCP ${endpoints.mcp.url}`);
13
+ logger.newline();
14
+ if (endpoints.active) {
15
+ logger.info(`Set ${MCP_API_KEY_VARIABLE} from your secret store. Check MCP without running a query:`);
16
+ logger.indent(`hypequery mcp --self-test --url ${endpoints.mcp.url}`);
17
+ }
18
+ else {
19
+ logger.info('These URLs will serve the target after a release is live.');
20
+ }
21
+ if (mcpConfig) {
22
+ logger.newline();
23
+ logger.info(`MCP client configuration (the client reads the key from ${MCP_API_KEY_VARIABLE}):`);
24
+ for (const line of mcpClientConfiguration(endpoints.mcp.url).split('\n'))
25
+ logger.indent(line);
26
+ }
27
+ }
@@ -0,0 +1,37 @@
1
+ import type { ProtocolDeploymentReleaseTarget } from '@hypequery/protocol';
2
+ import { type LiveDeploymentFetch } from './live-deployment.js';
3
+ /** Where Cloud serves a deployed target. Cloud owns this layout, not the CLI. */
4
+ export type HostedEndpoints = {
5
+ readonly active: boolean;
6
+ readonly rest: {
7
+ readonly baseUrl: string;
8
+ readonly datasets: readonly {
9
+ readonly name: string;
10
+ readonly url: string;
11
+ }[];
12
+ };
13
+ readonly mcp: {
14
+ readonly url: string;
15
+ };
16
+ };
17
+ export declare function parseHostedEndpoints(input: unknown): HostedEndpoints | undefined;
18
+ /**
19
+ * Asks Cloud where the target is served. Never throws: the deployment has
20
+ * already succeeded, so an older Cloud (404), a network failure, or an
21
+ * unexpected response just means there is nothing to print.
22
+ */
23
+ export declare function fetchHostedEndpoints(input: {
24
+ readonly endpoint: string;
25
+ readonly token: string;
26
+ readonly target: ProtocolDeploymentReleaseTarget;
27
+ readonly fetch?: LiveDeploymentFetch;
28
+ }): Promise<HostedEndpoints | undefined>;
29
+ /** The environment variable generated configuration reads the key from. */
30
+ export declare const MCP_API_KEY_VARIABLE = "HYPEQUERY_API_KEY";
31
+ /**
32
+ * Client configuration for the hosted MCP endpoint. The key is a placeholder
33
+ * the client expands from its environment: the CLI never writes a credential
34
+ * into anything it prints.
35
+ */
36
+ export declare function mcpClientConfiguration(mcpUrl: string): string;
37
+ //# sourceMappingURL=hosted-endpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-endpoints.d.ts","sourceRoot":"","sources":["../../src/utils/hosted-endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAW,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAIzE,iFAAiF;AACjF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS;YAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KAC/E,CAAC;IACF,QAAQ,CAAC,GAAG,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC,CAAC;AAYF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAkBhF;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAChD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,+BAA+B,CAAC;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,mBAAmB,CAAC;CACtC,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAiBvC;AAED,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAc7D"}
@@ -0,0 +1,81 @@
1
+ import { liveUrl } from './live-deployment.js';
2
+ const MAX_RESPONSE_BYTES = 256 * 1024;
3
+ function httpUrl(value) {
4
+ if (typeof value !== 'string')
5
+ return undefined;
6
+ try {
7
+ const url = new URL(value);
8
+ return url.protocol === 'https:' || url.protocol === 'http:' ? url.toString() : undefined;
9
+ }
10
+ catch {
11
+ return undefined;
12
+ }
13
+ }
14
+ export function parseHostedEndpoints(input) {
15
+ if (typeof input !== 'object' || input === null)
16
+ return undefined;
17
+ const value = input;
18
+ if (value.kind !== 'hypequery-hosted-endpoints' || value.version !== 1)
19
+ return undefined;
20
+ const baseUrl = httpUrl(value.rest?.baseUrl);
21
+ const mcp = httpUrl(value.mcp?.url);
22
+ if (!baseUrl || !mcp || !Array.isArray(value.rest?.datasets))
23
+ return undefined;
24
+ const datasets = [];
25
+ for (const dataset of value.rest.datasets) {
26
+ const url = httpUrl(dataset?.url);
27
+ if (typeof dataset?.name !== 'string' || !url)
28
+ return undefined;
29
+ datasets.push(Object.freeze({ name: dataset.name, url }));
30
+ }
31
+ return Object.freeze({
32
+ active: value.active === true,
33
+ rest: Object.freeze({ baseUrl, datasets: Object.freeze(datasets) }),
34
+ mcp: Object.freeze({ url: mcp }),
35
+ });
36
+ }
37
+ /**
38
+ * Asks Cloud where the target is served. Never throws: the deployment has
39
+ * already succeeded, so an older Cloud (404), a network failure, or an
40
+ * unexpected response just means there is nothing to print.
41
+ */
42
+ export async function fetchHostedEndpoints(input) {
43
+ try {
44
+ const url = liveUrl(input.endpoint, input.target, 'endpoints');
45
+ if (!url)
46
+ return undefined;
47
+ const response = await (input.fetch ?? fetch)(url, {
48
+ method: 'GET',
49
+ headers: { Accept: 'application/json', Authorization: `Bearer ${input.token}` },
50
+ redirect: 'error',
51
+ signal: AbortSignal.timeout(10_000),
52
+ });
53
+ if (!response.ok)
54
+ return undefined;
55
+ const bytes = new Uint8Array(await response.arrayBuffer());
56
+ if (bytes.byteLength > MAX_RESPONSE_BYTES)
57
+ return undefined;
58
+ return parseHostedEndpoints(JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes)));
59
+ }
60
+ catch {
61
+ return undefined;
62
+ }
63
+ }
64
+ /** The environment variable generated configuration reads the key from. */
65
+ export const MCP_API_KEY_VARIABLE = 'HYPEQUERY_API_KEY';
66
+ /**
67
+ * Client configuration for the hosted MCP endpoint. The key is a placeholder
68
+ * the client expands from its environment: the CLI never writes a credential
69
+ * into anything it prints.
70
+ */
71
+ export function mcpClientConfiguration(mcpUrl) {
72
+ return JSON.stringify({
73
+ mcpServers: {
74
+ hypequery: {
75
+ type: 'http',
76
+ url: mcpUrl,
77
+ headers: { Authorization: `Bearer \${${MCP_API_KEY_VARIABLE}}` },
78
+ },
79
+ },
80
+ }, null, 2);
81
+ }
@@ -0,0 +1,11 @@
1
+ import type { InitOptions } from '../commands/init.js';
2
+ import type { InitStyle } from './prompts.js';
3
+ import type { AuthTemplateMode } from '../templates/queries.js';
4
+ import type { DatabaseType } from './detect-database.js';
5
+ type InitDatabase = Extract<DatabaseType, 'clickhouse' | 'chdb'>;
6
+ export declare function normalizeInitDatabase(database: InitOptions['database']): InitDatabase;
7
+ export declare function normalizeInitStyle(style: InitOptions['style']): InitStyle;
8
+ export declare function normalizeAuthMode(auth: InitOptions['auth']): AuthTemplateMode;
9
+ export declare function parseTableList(value: string | undefined): string[] | undefined;
10
+ export {};
11
+ //# sourceMappingURL=init-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-options.d.ts","sourceRoot":"","sources":["../../src/utils/init-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,KAAK,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAAC,CAAC;AAEjE,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,GAAG,YAAY,CAQrF;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,SAAS,CAEzE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,gBAAgB,CAQ7E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,SAAS,CAO9E"}
@@ -0,0 +1,28 @@
1
+ export function normalizeInitDatabase(database) {
2
+ if (!database || database === 'clickhouse') {
3
+ return 'clickhouse';
4
+ }
5
+ if (database === 'chdb') {
6
+ return 'chdb';
7
+ }
8
+ throw new Error(`Unsupported database "${database}". Use "clickhouse" or "chdb".`);
9
+ }
10
+ export function normalizeInitStyle(style) {
11
+ return style === 'datasets' ? 'datasets' : 'queries';
12
+ }
13
+ export function normalizeAuthMode(auth) {
14
+ if (!auth || auth === 'none') {
15
+ return 'none';
16
+ }
17
+ if (auth === 'context') {
18
+ return 'context';
19
+ }
20
+ throw new Error(`Unsupported auth mode "${auth}". Use "none" or "context".`);
21
+ }
22
+ export function parseTableList(value) {
23
+ const parsed = value
24
+ ?.split(',')
25
+ .map((table) => table.trim())
26
+ .filter(Boolean);
27
+ return parsed && parsed.length > 0 ? parsed : undefined;
28
+ }
@@ -26,6 +26,12 @@ export type LiveDeployment = {
26
26
  };
27
27
  };
28
28
  export type LiveDeploymentFetch = typeof fetch;
29
+ /**
30
+ * The Cloud target resource beside a submissions endpoint, or undefined when
31
+ * the endpoint is not a Cloud submissions URL. Refuses anything but https (or
32
+ * loopback http) so a credential is never sent in the clear.
33
+ */
34
+ export declare function liveUrl(endpoint: string, target: ProtocolDeploymentReleaseTarget, resource: 'state' | 'source' | 'endpoints'): string | undefined;
29
35
  export declare function fetchLiveDeployment(input: {
30
36
  readonly endpoint: string;
31
37
  readonly token: string;
@@ -1 +1 @@
1
- {"version":3,"file":"live-deployment.d.ts","sourceRoot":"","sources":["../../src/utils/live-deployment.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,+BAA+B,EACrC,MAAM,qBAAqB,CAAC;AAO7B,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,wBAAwB,EAAE,CAAC;IACpD,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAClB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;QACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;KACzB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,MAAM,EAAE,+BAA+B,CAAC;IACjD,QAAQ,CAAC,MAAM,EAAE,IAAI,GAAG;QACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,eAAe,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