@hypequery/cli 1.22.0 → 1.24.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 (156) hide show
  1. package/dist/bin/cli.js +77 -12
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +20 -15
  4. package/dist/commands/dev.d.ts.map +1 -1
  5. package/dist/commands/dev.js +25 -5
  6. package/dist/commands/generate-datasets.d.ts +0 -6
  7. package/dist/commands/generate-datasets.d.ts.map +1 -1
  8. package/dist/commands/generate-datasets.js +17 -1
  9. package/dist/commands/generate-manifest.d.ts.map +1 -1
  10. package/dist/commands/generate-manifest.js +4 -0
  11. package/dist/commands/generate.d.ts.map +1 -1
  12. package/dist/commands/generate.js +14 -1
  13. package/dist/commands/init.d.ts.map +1 -1
  14. package/dist/commands/init.js +80 -55
  15. package/dist/commands/mcp.d.ts.map +1 -1
  16. package/dist/commands/mcp.js +47 -10
  17. package/dist/commands/telemetry.d.ts +3 -0
  18. package/dist/commands/telemetry.d.ts.map +1 -0
  19. package/dist/commands/telemetry.js +19 -0
  20. package/dist/generators/chdb.d.ts +3 -0
  21. package/dist/generators/chdb.d.ts.map +1 -1
  22. package/dist/generators/chdb.js +2 -0
  23. package/dist/generators/clickhouse.d.ts +3 -1
  24. package/dist/generators/clickhouse.d.ts.map +1 -1
  25. package/dist/generators/clickhouse.js +2 -0
  26. package/dist/typegen/generate-types.d.ts +3 -0
  27. package/dist/typegen/generate-types.d.ts.map +1 -1
  28. package/dist/typegen/generate-types.js +5 -1
  29. package/dist/typegen/type-parsing.d.ts +1 -1
  30. package/dist/typegen/type-parsing.d.ts.map +1 -1
  31. package/dist/typegen/type-parsing.js +11 -7
  32. package/dist/utils/chdb-gitignore-entry.d.ts +2 -0
  33. package/dist/utils/chdb-gitignore-entry.d.ts.map +1 -0
  34. package/dist/utils/chdb-gitignore-entry.js +17 -0
  35. package/dist/utils/cli-version.d.ts +2 -0
  36. package/dist/utils/cli-version.d.ts.map +1 -0
  37. package/dist/utils/cli-version.js +11 -0
  38. package/dist/utils/cloud-credential-store.d.ts.map +1 -1
  39. package/dist/utils/cloud-credential-store.js +2 -13
  40. package/dist/utils/command-exit.d.ts +13 -0
  41. package/dist/utils/command-exit.d.ts.map +1 -0
  42. package/dist/utils/command-exit.js +31 -0
  43. package/dist/utils/config-directory.d.ts +3 -0
  44. package/dist/utils/config-directory.d.ts.map +1 -0
  45. package/dist/utils/config-directory.js +14 -0
  46. package/dist/utils/detect-database-environment.d.ts +3 -0
  47. package/dist/utils/detect-database-environment.d.ts.map +1 -0
  48. package/dist/utils/detect-database-environment.js +8 -0
  49. package/dist/utils/detect-database.d.ts.map +1 -1
  50. package/dist/utils/detect-database.js +4 -8
  51. package/dist/utils/init-options.d.ts +11 -0
  52. package/dist/utils/init-options.d.ts.map +1 -0
  53. package/dist/utils/init-options.js +28 -0
  54. package/dist/utils/load-api.d.ts +2 -0
  55. package/dist/utils/load-api.d.ts.map +1 -1
  56. package/dist/utils/load-api.js +50 -51
  57. package/dist/utils/load-env-files.d.ts +10 -0
  58. package/dist/utils/load-env-files.d.ts.map +1 -0
  59. package/dist/utils/load-env-files.js +27 -0
  60. package/dist/utils/project-root.d.ts +14 -0
  61. package/dist/utils/project-root.d.ts.map +1 -0
  62. package/dist/utils/project-root.js +41 -0
  63. package/dist/utils/telemetry/buckets.d.ts +5 -0
  64. package/dist/utils/telemetry/buckets.d.ts.map +1 -0
  65. package/dist/utils/telemetry/buckets.js +23 -0
  66. package/dist/utils/telemetry/catalog-docs.d.ts +3 -0
  67. package/dist/utils/telemetry/catalog-docs.d.ts.map +1 -0
  68. package/dist/utils/telemetry/catalog-docs.js +52 -0
  69. package/dist/utils/telemetry/catalog.d.ts +1124 -0
  70. package/dist/utils/telemetry/catalog.d.ts.map +1 -0
  71. package/dist/utils/telemetry/catalog.js +154 -0
  72. package/dist/utils/telemetry/command-context.d.ts +17 -0
  73. package/dist/utils/telemetry/command-context.d.ts.map +1 -0
  74. package/dist/utils/telemetry/command-context.js +30 -0
  75. package/dist/utils/telemetry/config-schema.d.ts +14 -0
  76. package/dist/utils/telemetry/config-schema.d.ts.map +1 -0
  77. package/dist/utils/telemetry/config-schema.js +35 -0
  78. package/dist/utils/telemetry/config-store.d.ts +35 -0
  79. package/dist/utils/telemetry/config-store.d.ts.map +1 -0
  80. package/dist/utils/telemetry/config-store.js +147 -0
  81. package/dist/utils/telemetry/delivery.d.ts +13 -0
  82. package/dist/utils/telemetry/delivery.d.ts.map +1 -0
  83. package/dist/utils/telemetry/delivery.js +26 -0
  84. package/dist/utils/telemetry/detached-dispatch.d.ts +12 -0
  85. package/dist/utils/telemetry/detached-dispatch.d.ts.map +1 -0
  86. package/dist/utils/telemetry/detached-dispatch.js +33 -0
  87. package/dist/utils/telemetry/detached-sender.d.ts +2 -0
  88. package/dist/utils/telemetry/detached-sender.d.ts.map +1 -0
  89. package/dist/utils/telemetry/detached-sender.js +31 -0
  90. package/dist/utils/telemetry/dev-session.d.ts +15 -0
  91. package/dist/utils/telemetry/dev-session.d.ts.map +1 -0
  92. package/dist/utils/telemetry/dev-session.js +25 -0
  93. package/dist/utils/telemetry/domains.d.ts +69 -0
  94. package/dist/utils/telemetry/domains.d.ts.map +1 -0
  95. package/dist/utils/telemetry/domains.js +64 -0
  96. package/dist/utils/telemetry/endpoint.d.ts +3 -0
  97. package/dist/utils/telemetry/endpoint.d.ts.map +1 -0
  98. package/dist/utils/telemetry/endpoint.js +15 -0
  99. package/dist/utils/telemetry/environment.d.ts +27 -0
  100. package/dist/utils/telemetry/environment.d.ts.map +1 -0
  101. package/dist/utils/telemetry/environment.js +95 -0
  102. package/dist/utils/telemetry/error-code.d.ts +4 -0
  103. package/dist/utils/telemetry/error-code.d.ts.map +1 -0
  104. package/dist/utils/telemetry/error-code.js +57 -0
  105. package/dist/utils/telemetry/flags.d.ts +5 -0
  106. package/dist/utils/telemetry/flags.d.ts.map +1 -0
  107. package/dist/utils/telemetry/flags.js +41 -0
  108. package/dist/utils/telemetry/generation-metrics.d.ts +15 -0
  109. package/dist/utils/telemetry/generation-metrics.d.ts.map +1 -0
  110. package/dist/utils/telemetry/generation-metrics.js +35 -0
  111. package/dist/utils/telemetry/identity.d.ts +12 -0
  112. package/dist/utils/telemetry/identity.d.ts.map +1 -0
  113. package/dist/utils/telemetry/identity.js +42 -0
  114. package/dist/utils/telemetry/init-funnel.d.ts +15 -0
  115. package/dist/utils/telemetry/init-funnel.d.ts.map +1 -0
  116. package/dist/utils/telemetry/init-funnel.js +25 -0
  117. package/dist/utils/telemetry/invocation.d.ts +22 -0
  118. package/dist/utils/telemetry/invocation.d.ts.map +1 -0
  119. package/dist/utils/telemetry/invocation.js +44 -0
  120. package/dist/utils/telemetry/lifecycle.d.ts +32 -0
  121. package/dist/utils/telemetry/lifecycle.d.ts.map +1 -0
  122. package/dist/utils/telemetry/lifecycle.js +99 -0
  123. package/dist/utils/telemetry/mcp-session.d.ts +10 -0
  124. package/dist/utils/telemetry/mcp-session.d.ts.map +1 -0
  125. package/dist/utils/telemetry/mcp-session.js +36 -0
  126. package/dist/utils/telemetry/notice.d.ts +11 -0
  127. package/dist/utils/telemetry/notice.d.ts.map +1 -0
  128. package/dist/utils/telemetry/notice.js +24 -0
  129. package/dist/utils/telemetry/opt-out.d.ts +16 -0
  130. package/dist/utils/telemetry/opt-out.d.ts.map +1 -0
  131. package/dist/utils/telemetry/opt-out.js +32 -0
  132. package/dist/utils/telemetry/post-json.d.ts +13 -0
  133. package/dist/utils/telemetry/post-json.d.ts.map +1 -0
  134. package/dist/utils/telemetry/post-json.js +32 -0
  135. package/dist/utils/telemetry/project-context.d.ts +15 -0
  136. package/dist/utils/telemetry/project-context.d.ts.map +1 -0
  137. package/dist/utils/telemetry/project-context.js +86 -0
  138. package/dist/utils/telemetry/schema.d.ts +72 -0
  139. package/dist/utils/telemetry/schema.d.ts.map +1 -0
  140. package/dist/utils/telemetry/schema.js +17 -0
  141. package/dist/utils/telemetry/session-config.d.ts +6 -0
  142. package/dist/utils/telemetry/session-config.d.ts.map +1 -0
  143. package/dist/utils/telemetry/session-config.js +17 -0
  144. package/dist/utils/telemetry/settings-lock.d.ts +36 -0
  145. package/dist/utils/telemetry/settings-lock.d.ts.map +1 -0
  146. package/dist/utils/telemetry/settings-lock.js +102 -0
  147. package/dist/utils/telemetry/transport.d.ts +25 -0
  148. package/dist/utils/telemetry/transport.d.ts.map +1 -0
  149. package/dist/utils/telemetry/transport.js +76 -0
  150. package/dist/utils/telemetry/validation.d.ts +10 -0
  151. package/dist/utils/telemetry/validation.d.ts.map +1 -0
  152. package/dist/utils/telemetry/validation.js +77 -0
  153. package/dist/utils/telemetry/value-formats.d.ts +30 -0
  154. package/dist/utils/telemetry/value-formats.d.ts.map +1 -0
  155. package/dist/utils/telemetry/value-formats.js +13 -0
  156. package/package.json +12 -8
@@ -0,0 +1,25 @@
1
+ import { countBucket } from './buckets.js';
2
+ import { startCommandSession } from './command-context.js';
3
+ import { telemetryErrorCode } from './error-code.js';
4
+ import { devSessionConfig } from './session-config.js';
5
+ /** Counters only: no retained API, reload paths, errors, queries, or requests. */
6
+ export class DevSession {
7
+ reloads = 0;
8
+ reloadErrors = 0;
9
+ failures = {};
10
+ start(resolved, explicit, options) {
11
+ startCommandSession('dev', devSessionConfig(resolved, explicit, options), () => this.snapshot());
12
+ }
13
+ reload() { this.reloads++; }
14
+ reloadFailed() { this.reloadErrors++; }
15
+ loadFailed(error) {
16
+ const code = telemetryErrorCode(error);
17
+ const stable = code === 'unknown' ? 'load_error' : code;
18
+ this.failures[stable] = (this.failures[stable] ?? 0) + 1;
19
+ return stable;
20
+ }
21
+ snapshot() {
22
+ return { reload_count_bucket: countBucket(this.reloads), reload_error_count_bucket: countBucket(this.reloadErrors),
23
+ load_failures: Object.fromEntries(Object.entries(this.failures).map(([code, count]) => [code, countBucket(count)])) };
24
+ }
25
+ }
@@ -0,0 +1,69 @@
1
+ /** Stable domains: never populate these from user-provided names or messages. */
2
+ export declare const COUNT_BUCKETS: readonly ["0", "1", "2-5", "6-20", "21-100", "101+"];
3
+ export declare const DURATION_BUCKETS: readonly ["<100ms", "100ms-1s", "1s-10s", "10s-1m", "1m-10m", "10m-1h", "1h+"];
4
+ export declare const ERROR_CODES: readonly ["unknown", "connection_failed", "auth_failed", "entrypoint_not_found", "compile_error", "prompt_cancelled", "validation_failed", "cloud_network_error", "cloud_rejected", "not_installed", "engine_error", "no_tables", "no_datasets", "tenant_required", "load_error", "output_missing", "output_out_of_date", "unknown_command", "unknown_option"];
5
+ export declare const OUTCOMES: readonly ["success", "failure", "cancelled", "interrupted"];
6
+ export declare const DATABASES: readonly ["clickhouse", "chdb", "bigquery", "unknown"];
7
+ export declare const COMMANDS: readonly ["init", "dev", "mcp", "generate", "generate:types", "generate:datasets", "generate:manifest", "login", "logout", "deploy", "deployment:build", "deployment:validate", "deployment:release", "deployment:submit", "deployment:status", "pull", "diff", "help", "version", "telemetry", "unknown"];
8
+ export type TelemetryCommand = typeof COMMANDS[number];
9
+ /** Canonical long names, including negated flags. Values and aliases never leave the CLI. */
10
+ export declare const COMMAND_FLAGS: {
11
+ readonly init: readonly ["--path", "--style", "--database", "--chdb-path", "--auth", "--all-tables", "--tables", "--exclude-tables", "--no-example", "--no-interactive", "--force", "--skip-connection"];
12
+ readonly dev: readonly ["--port", "--hostname", "--no-watch", "--no-cache", "--cache", "--redis-url", "--open", "--cors", "--path", "--quiet"];
13
+ readonly mcp: readonly ["--path", "--tenant", "--self-test", "--url"];
14
+ readonly generate: readonly ["--output", "--path", "--tables", "--database", "--chdb-path"];
15
+ readonly 'generate:types': readonly ["--output", "--path", "--tables", "--database", "--chdb-path"];
16
+ readonly 'generate:datasets': readonly ["--output", "--path", "--tables", "--exclude-tables", "--tenant-column", "--force", "--check", "--diff"];
17
+ readonly 'generate:manifest': readonly ["--output"];
18
+ readonly login: readonly ["--cloud-url", "--environment"];
19
+ readonly logout: readonly [];
20
+ readonly deploy: readonly ["--bundle-output", "--release-output", "--project", "--environment", "--no-source", "--endpoint", "--replace-restored", "--mcp-config"];
21
+ readonly 'deployment:build': readonly ["--bundle-output", "--no-source"];
22
+ readonly 'deployment:validate': readonly [];
23
+ readonly 'deployment:release': readonly ["--project", "--environment", "--output"];
24
+ readonly 'deployment:submit': readonly ["--release", "--endpoint", "--replace-restored"];
25
+ readonly 'deployment:status': readonly ["--project", "--environment", "--endpoint", "--mcp-config"];
26
+ readonly pull: readonly ["--output", "--project", "--environment", "--endpoint"];
27
+ readonly diff: readonly ["--project", "--environment", "--endpoint"];
28
+ readonly help: readonly [];
29
+ readonly version: readonly [];
30
+ readonly telemetry: readonly [];
31
+ readonly unknown: readonly [];
32
+ };
33
+ export declare const GLOBAL_FLAGS: readonly ["--no-telemetry", "--help", "--version"];
34
+ /** Options that consume the next argument as their value; that value is never a flag. */
35
+ export declare const VALUE_FLAGS: {
36
+ readonly init: readonly ["--path", "--style", "--database", "--chdb-path", "--auth", "--tables", "--exclude-tables"];
37
+ readonly dev: readonly ["--port", "--hostname", "--cache", "--redis-url", "--path"];
38
+ readonly mcp: readonly ["--path", "--tenant", "--url"];
39
+ readonly generate: readonly ["--output", "--path", "--tables", "--database", "--chdb-path"];
40
+ readonly 'generate:types': readonly ["--output", "--path", "--tables", "--database", "--chdb-path"];
41
+ readonly 'generate:datasets': readonly ["--output", "--path", "--tables", "--exclude-tables", "--tenant-column"];
42
+ readonly 'generate:manifest': readonly ["--output"];
43
+ readonly login: readonly ["--cloud-url", "--environment"];
44
+ readonly logout: readonly [];
45
+ readonly deploy: readonly ["--bundle-output", "--release-output", "--project", "--environment", "--endpoint"];
46
+ readonly 'deployment:build': readonly ["--bundle-output"];
47
+ readonly 'deployment:validate': readonly [];
48
+ readonly 'deployment:release': readonly ["--project", "--environment", "--output"];
49
+ readonly 'deployment:submit': readonly ["--release", "--endpoint"];
50
+ readonly 'deployment:status': readonly ["--project", "--environment", "--endpoint"];
51
+ readonly pull: readonly ["--output", "--project", "--environment", "--endpoint"];
52
+ readonly diff: readonly ["--project", "--environment", "--endpoint"];
53
+ readonly help: readonly [];
54
+ readonly version: readonly [];
55
+ readonly telemetry: readonly [];
56
+ readonly unknown: readonly [];
57
+ };
58
+ export type TelemetryFlag = typeof COMMAND_FLAGS[TelemetryCommand][number] | typeof GLOBAL_FLAGS[number];
59
+ export declare const SHORT_FLAGS: {
60
+ readonly '-o': "--output";
61
+ readonly '-p': "--port";
62
+ readonly '-h': "--hostname";
63
+ readonly '-q': "--quiet";
64
+ readonly '-V': "--version";
65
+ };
66
+ export declare const HYPEQUERY_PACKAGES: readonly ["@hypequery/clickhouse", "@hypequery/datasets", "@hypequery/serve", "@hypequery/react", "@hypequery/cli", "@hypequery/mcp", "@hypequery/protocol", "@hypequery/protocol-conformance", "@hypequery/deployment"];
67
+ export declare const WARNING_CODES: readonly ["tenant-key-candidate", "tenant-column-missing"];
68
+ export declare const TYPE_FAMILIES: readonly ["AggregateFunction", "SimpleAggregateFunction", "Variant", "Dynamic", "Object", "JSON", "Nested", "Tuple", "Map", "Array", "Nullable", "LowCardinality", "Decimal", "Enum", "DateTime", "DateTime64", "unknown"];
69
+ //# sourceMappingURL=domains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domains.d.ts","sourceRoot":"","sources":["../../../src/utils/telemetry/domains.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,eAAO,MAAM,aAAa,sDAAuD,CAAC;AAClF,eAAO,MAAM,gBAAgB,gFAAiF,CAAC;AAC/G,eAAO,MAAM,WAAW,gWAKd,CAAC;AACX,eAAO,MAAM,QAAQ,6DAA8D,CAAC;AACpF,eAAO,MAAM,SAAS,wDAAyD,CAAC;AAChF,eAAO,MAAM,QAAQ,4SAKX,CAAC;AACX,MAAM,MAAM,gBAAgB,GAAG,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEvD,6FAA6F;AAC7F,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;CAmBsC,CAAC;AACjE,eAAO,MAAM,YAAY,oDAAqD,CAAC;AAC/E,yFAAyF;AACzF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;CAmBoE,CAAC;AAC7F,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,GAAG,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AACzG,eAAO,MAAM,WAAW;;;;;;CAAwG,CAAC;AACjI,eAAO,MAAM,kBAAkB,0NAA2N,CAAC;AAC3P,eAAO,MAAM,aAAa,4DAA6D,CAAC;AACxF,eAAO,MAAM,aAAa,4NAA6N,CAAC"}
@@ -0,0 +1,64 @@
1
+ /** Stable domains: never populate these from user-provided names or messages. */
2
+ export const COUNT_BUCKETS = ['0', '1', '2-5', '6-20', '21-100', '101+'];
3
+ export const DURATION_BUCKETS = ['<100ms', '100ms-1s', '1s-10s', '10s-1m', '1m-10m', '10m-1h', '1h+'];
4
+ export const ERROR_CODES = [
5
+ 'unknown', 'connection_failed', 'auth_failed', 'entrypoint_not_found', 'compile_error',
6
+ 'prompt_cancelled', 'validation_failed', 'cloud_network_error', 'cloud_rejected',
7
+ 'not_installed', 'engine_error', 'no_tables', 'no_datasets', 'tenant_required',
8
+ 'load_error', 'output_missing', 'output_out_of_date', 'unknown_command', 'unknown_option',
9
+ ];
10
+ export const OUTCOMES = ['success', 'failure', 'cancelled', 'interrupted'];
11
+ export const DATABASES = ['clickhouse', 'chdb', 'bigquery', 'unknown'];
12
+ export const COMMANDS = [
13
+ 'init', 'dev', 'mcp', 'generate', 'generate:types', 'generate:datasets',
14
+ 'generate:manifest', 'login', 'logout', 'deploy', 'deployment:build',
15
+ 'deployment:validate', 'deployment:release', 'deployment:submit', 'deployment:status',
16
+ 'pull', 'diff', 'help', 'version', 'telemetry', 'unknown',
17
+ ];
18
+ /** Canonical long names, including negated flags. Values and aliases never leave the CLI. */
19
+ export const COMMAND_FLAGS = {
20
+ init: ['--path', '--style', '--database', '--chdb-path', '--auth', '--all-tables', '--tables', '--exclude-tables', '--no-example', '--no-interactive', '--force', '--skip-connection'],
21
+ dev: ['--port', '--hostname', '--no-watch', '--no-cache', '--cache', '--redis-url', '--open', '--cors', '--path', '--quiet'],
22
+ mcp: ['--path', '--tenant', '--self-test', '--url'],
23
+ generate: ['--output', '--path', '--tables', '--database', '--chdb-path'],
24
+ 'generate:types': ['--output', '--path', '--tables', '--database', '--chdb-path'],
25
+ 'generate:datasets': ['--output', '--path', '--tables', '--exclude-tables', '--tenant-column', '--force', '--check', '--diff'],
26
+ 'generate:manifest': ['--output'],
27
+ login: ['--cloud-url', '--environment'],
28
+ logout: [],
29
+ deploy: ['--bundle-output', '--release-output', '--project', '--environment', '--no-source', '--endpoint', '--replace-restored', '--mcp-config'],
30
+ 'deployment:build': ['--bundle-output', '--no-source'],
31
+ 'deployment:validate': [],
32
+ 'deployment:release': ['--project', '--environment', '--output'],
33
+ 'deployment:submit': ['--release', '--endpoint', '--replace-restored'],
34
+ 'deployment:status': ['--project', '--environment', '--endpoint', '--mcp-config'],
35
+ pull: ['--output', '--project', '--environment', '--endpoint'],
36
+ diff: ['--project', '--environment', '--endpoint'],
37
+ help: [], version: [], telemetry: [], unknown: [],
38
+ };
39
+ export const GLOBAL_FLAGS = ['--no-telemetry', '--help', '--version'];
40
+ /** Options that consume the next argument as their value; that value is never a flag. */
41
+ export const VALUE_FLAGS = {
42
+ init: ['--path', '--style', '--database', '--chdb-path', '--auth', '--tables', '--exclude-tables'],
43
+ dev: ['--port', '--hostname', '--cache', '--redis-url', '--path'],
44
+ mcp: ['--path', '--tenant', '--url'],
45
+ generate: ['--output', '--path', '--tables', '--database', '--chdb-path'],
46
+ 'generate:types': ['--output', '--path', '--tables', '--database', '--chdb-path'],
47
+ 'generate:datasets': ['--output', '--path', '--tables', '--exclude-tables', '--tenant-column'],
48
+ 'generate:manifest': ['--output'],
49
+ login: ['--cloud-url', '--environment'],
50
+ logout: [],
51
+ deploy: ['--bundle-output', '--release-output', '--project', '--environment', '--endpoint'],
52
+ 'deployment:build': ['--bundle-output'],
53
+ 'deployment:validate': [],
54
+ 'deployment:release': ['--project', '--environment', '--output'],
55
+ 'deployment:submit': ['--release', '--endpoint'],
56
+ 'deployment:status': ['--project', '--environment', '--endpoint'],
57
+ pull: ['--output', '--project', '--environment', '--endpoint'],
58
+ diff: ['--project', '--environment', '--endpoint'],
59
+ help: [], version: [], telemetry: [], unknown: [],
60
+ };
61
+ export const SHORT_FLAGS = { '-o': '--output', '-p': '--port', '-h': '--hostname', '-q': '--quiet', '-V': '--version' };
62
+ export const HYPEQUERY_PACKAGES = ['@hypequery/clickhouse', '@hypequery/datasets', '@hypequery/serve', '@hypequery/react', '@hypequery/cli', '@hypequery/mcp', '@hypequery/protocol', '@hypequery/protocol-conformance', '@hypequery/deployment'];
63
+ export const WARNING_CODES = ['tenant-key-candidate', 'tenant-column-missing'];
64
+ export const TYPE_FAMILIES = ['AggregateFunction', 'SimpleAggregateFunction', 'Variant', 'Dynamic', 'Object', 'JSON', 'Nested', 'Tuple', 'Map', 'Array', 'Nullable', 'LowCardinality', 'Decimal', 'Enum', 'DateTime', 'DateTime64', 'unknown'];
@@ -0,0 +1,3 @@
1
+ /** HTTPS, or HTTP for loopback testing only; rejects credentials, query strings and fragments. */
2
+ export declare function telemetryEndpoint(raw: string | undefined): URL | null;
3
+ //# sourceMappingURL=endpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../../src/utils/telemetry/endpoint.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,GAAG,IAAI,CAQrE"}
@@ -0,0 +1,15 @@
1
+ /** HTTPS, or HTTP for loopback testing only; rejects credentials, query strings and fragments. */
2
+ export function telemetryEndpoint(raw) {
3
+ if (!raw)
4
+ return null;
5
+ try {
6
+ const url = new URL(raw);
7
+ const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
8
+ if ((url.protocol !== 'https:' && !(url.protocol === 'http:' && loopback)) || url.username || url.password || url.search || url.hash)
9
+ return null;
10
+ return url;
11
+ }
12
+ catch {
13
+ return null;
14
+ }
15
+ }
@@ -0,0 +1,27 @@
1
+ import { COMMON_PROPERTIES } from './catalog.js';
2
+ import type { Properties } from './schema.js';
3
+ import { type ProjectContext, type ReadLocalFile } from './project-context.js';
4
+ type Common = Properties<typeof COMMON_PROPERTIES>;
5
+ export declare const CI_SIGNALS: readonly [readonly ["GITHUB_ACTIONS", "github_actions"], readonly ["GITLAB_CI", "gitlab"], readonly ["CIRCLECI", "circleci"], readonly ["BUILDKITE", "buildkite"], readonly ["JENKINS_URL", "jenkins"], readonly ["VERCEL", "vercel"], readonly ["NETLIFY", "netlify"], readonly ["TF_BUILD", "azure"], readonly ["BITBUCKET_BUILD_NUMBER", "bitbucket"], readonly ["TEAMCITY_VERSION", "teamcity"], readonly ["TRAVIS", "travis"], readonly ["CODEBUILD_BUILD_ID", "codebuild"]];
6
+ export declare function ciContext(env: Readonly<Record<string, string | undefined>>): Pick<Common, 'is_ci' | 'ci_name'>;
7
+ export declare function packageManagerContext(env: Readonly<Record<string, string | undefined>>, executable: string): Pick<Common, 'package_manager' | 'package_manager_major' | 'invoked_via'>;
8
+ export declare function installedPackages(context: ProjectContext, read: ReadLocalFile): Common['hypequery_packages'];
9
+ export declare function environmentDatabase(env: Readonly<Record<string, string | undefined>>, context: ProjectContext): Common['database'];
10
+ export interface EnvironmentOptions {
11
+ readonly env?: Readonly<Record<string, string | undefined>>;
12
+ readonly read?: ReadLocalFile;
13
+ readonly platform?: string;
14
+ readonly arch?: string;
15
+ readonly nodeVersion?: string;
16
+ readonly cliVersion?: string;
17
+ readonly executable?: string;
18
+ readonly isTTY?: boolean;
19
+ readonly database?: string;
20
+ /** Monotonic clock for the local-read budget. Defaults to `performance.now`. */
21
+ readonly now?: () => number;
22
+ }
23
+ /** Total wall-clock budget for local file probes; telemetry must never slow the CLI. */
24
+ export declare const READ_BUDGET_MS = 5;
25
+ export declare function collectEnvironment(context: ProjectContext, options?: EnvironmentOptions): Omit<Common, 'install_id' | 'session_id' | 'project_id' | 'is_first_run'>;
26
+ export {};
27
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../src/utils/telemetry/environment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAwB,MAAM,cAAc,CAAC;AAEvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAkC,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAI/G,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AACnD,eAAO,MAAM,UAAU,mdAKb,CAAC;AAEX,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC,CAI9G;AAED,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EACjD,UAAU,EAAE,MAAM,GACjB,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,uBAAuB,GAAG,aAAa,CAAC,CAY3E;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAkB5G;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,CAMlI;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC5D,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,gFAAgF;IAChF,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAED,wFAAwF;AACxF,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,GAAE,kBAAuB,GAAG,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,GAAG,YAAY,GAAG,cAAc,CAAC,CAyBvK"}
@@ -0,0 +1,95 @@
1
+ import path from 'node:path';
2
+ import { COMMON_PROPERTIES, EVENT_SCHEMA_VERSION } from './catalog.js';
3
+ import { HYPEQUERY_PACKAGES, DATABASES } from './domains.js';
4
+ import { matchesTelemetryFormat } from './value-formats.js';
5
+ import { readPackage, readTelemetryFile } from './project-context.js';
6
+ import { detectDatabaseFromEnvironment } from '../detect-database-environment.js';
7
+ import { performance } from 'node:perf_hooks';
8
+ export const CI_SIGNALS = [
9
+ ['GITHUB_ACTIONS', 'github_actions'], ['GITLAB_CI', 'gitlab'], ['CIRCLECI', 'circleci'],
10
+ ['BUILDKITE', 'buildkite'], ['JENKINS_URL', 'jenkins'], ['VERCEL', 'vercel'],
11
+ ['NETLIFY', 'netlify'], ['TF_BUILD', 'azure'], ['BITBUCKET_BUILD_NUMBER', 'bitbucket'],
12
+ ['TEAMCITY_VERSION', 'teamcity'], ['TRAVIS', 'travis'], ['CODEBUILD_BUILD_ID', 'codebuild'],
13
+ ];
14
+ export function ciContext(env) {
15
+ const match = CI_SIGNALS.find(([key]) => env[key] && env[key] !== 'false' && env[key] !== '0');
16
+ const ci = !!match || !!(env.CI && env.CI !== 'false' && env.CI !== '0');
17
+ return { is_ci: ci, ci_name: match?.[1] ?? (ci ? 'unknown' : 'none') };
18
+ }
19
+ export function packageManagerContext(env, executable) {
20
+ const match = env.npm_config_user_agent?.match(/^(npm|pnpm|yarn|bun)\/(\d{1,3})(?:\.|\s|$)/);
21
+ const executableManager = env.npm_execpath?.replace(/\\/g, '/').split('/').pop()?.match(/^(npm-cli|pnpm|yarn|bun)(?:[-.].*)?$/)?.[1];
22
+ const manager = (match?.[1] ?? (executableManager === 'npm-cli' ? 'npm' : executableManager));
23
+ const script = executable.replace(/\\/g, '/');
24
+ const invoked = /\/_npx\//.test(script) ? 'npx'
25
+ : /(?:\/dlx\/|\/dlx-)/.test(script) && manager === 'pnpm' ? 'pnpm_dlx'
26
+ : env.npm_command === 'exec' && manager === 'npm' ? 'npx'
27
+ : manager === 'bun' && /(?:bunx|\.bun\/install\/cache)/.test(script) ? 'bunx'
28
+ : /(?:\/lib\/node_modules\/|\/bin\/hypequery(?:\.js)?$)/.test(script) ? 'global'
29
+ : /\/node_modules\/(?:\.bin\/|@hypequery\/cli\/)/.test(script) ? 'local_bin' : 'unknown';
30
+ return { package_manager: manager ?? 'unknown', ...(match ? { package_manager_major: match[2] } : {}), invoked_via: invoked };
31
+ }
32
+ export function installedPackages(context, read) {
33
+ const result = {};
34
+ const pkg = context.package;
35
+ if (!pkg || !context.directory)
36
+ return undefined;
37
+ for (const name of HYPEQUERY_PACKAGES) {
38
+ const declared = [pkg.dependencies, pkg.devDependencies, pkg.peerDependencies, pkg.optionalDependencies]
39
+ .some(section => !!section && typeof section === 'object' && Object.hasOwn(section, name));
40
+ if (!declared)
41
+ continue;
42
+ const locations = [...new Set([context.directory, context.rootDirectory].filter((directory) => !!directory))];
43
+ const resolved = locations.map(directory => readPackage(path.join(directory, 'node_modules', name, 'package.json'), read)?.version)
44
+ .find(version => matchesTelemetryFormat('version', version));
45
+ const sections = [pkg.dependencies, pkg.devDependencies, pkg.peerDependencies, pkg.optionalDependencies];
46
+ const spec = sections.map(section => section?.[name]).find(value => typeof value === 'string');
47
+ // Dependency specs are never forwarded. Only a validated exact release is eligible.
48
+ result[name] = matchesTelemetryFormat('version', resolved) ? resolved
49
+ : matchesTelemetryFormat('version', spec) ? spec : 'unknown';
50
+ }
51
+ return Object.keys(result).length ? result : undefined;
52
+ }
53
+ export function environmentDatabase(env, context) {
54
+ const detected = detectDatabaseFromEnvironment(env);
55
+ if (detected)
56
+ return detected;
57
+ const pkg = context.package;
58
+ if ([pkg?.dependencies, pkg?.devDependencies].some(section => !!section && typeof section === 'object' && Object.hasOwn(section, 'chdb')))
59
+ return 'chdb';
60
+ return 'unknown';
61
+ }
62
+ /** Total wall-clock budget for local file probes; telemetry must never slow the CLI. */
63
+ export const READ_BUDGET_MS = 5;
64
+ export function collectEnvironment(context, options = {}) {
65
+ const env = options.env ?? process.env;
66
+ const now = options.now ?? (() => performance.now());
67
+ const deadline = now() + READ_BUDGET_MS;
68
+ const read = file => {
69
+ if (now() >= deadline)
70
+ return undefined;
71
+ try {
72
+ return (options.read ?? readTelemetryFile)(file);
73
+ }
74
+ catch {
75
+ return undefined;
76
+ }
77
+ };
78
+ const os = options.platform ?? process.platform;
79
+ const arch = options.arch ?? process.arch;
80
+ const node = (options.nodeVersion ?? process.versions.node).split('.').slice(0, 2).join('.');
81
+ const packages = installedPackages(context, read);
82
+ const docker = read('/.dockerenv') !== undefined || /(?:docker|containerd|kubepods)/.test(read('/proc/1/cgroup') ?? '');
83
+ const wsl = !!env.WSL_DISTRO_NAME || /microsoft/i.test(read('/proc/sys/kernel/osrelease') ?? '');
84
+ return {
85
+ schema_version: EVENT_SCHEMA_VERSION,
86
+ cli_version: matchesTelemetryFormat('version', options.cliVersion) ? options.cliVersion : 'unknown',
87
+ node_version: matchesTelemetryFormat('node_version', node) ? node : 'unknown',
88
+ os: COMMON_PROPERTIES.os.values.includes(os) ? os : 'unknown',
89
+ arch: COMMON_PROPERTIES.arch.values.includes(arch) ? arch : 'unknown',
90
+ ...ciContext(env), is_tty: options.isTTY ?? !!process.stderr.isTTY, is_docker: docker, is_wsl: wsl,
91
+ ...packageManagerContext(env, options.executable ?? process.argv[1] ?? ''),
92
+ ...(packages ? { hypequery_packages: packages } : {}),
93
+ database: DATABASES.includes(options.database ?? '') ? options.database : environmentDatabase(env, context),
94
+ };
95
+ }
@@ -0,0 +1,4 @@
1
+ import { ERROR_CODES } from './domains.js';
2
+ export declare function telemetryErrorCode(error: unknown): typeof ERROR_CODES[number];
3
+ export declare function exceptionClass(error: unknown): 'Error' | 'TypeError' | 'RangeError' | 'SyntaxError' | 'ReferenceError' | 'URIError' | 'EvalError' | 'AggregateError' | 'unknown';
4
+ //# sourceMappingURL=error-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-code.d.ts","sourceRoot":"","sources":["../../../src/utils/telemetry/error-code.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,WAAW,CAAC,MAAM,CAAC,CAuB7E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,WAAW,GAAG,YAAY,GAAG,aAAa,GAAG,gBAAgB,GAAG,UAAU,GAAG,WAAW,GAAG,gBAAgB,GAAG,SAAS,CAShL"}
@@ -0,0 +1,57 @@
1
+ import { isPromptCancelled } from '../prompts.js';
2
+ import { CommandExit } from '../command-exit.js';
3
+ import { ERROR_CODES } from './domains.js';
4
+ export function telemetryErrorCode(error) {
5
+ if (error instanceof CommandExit)
6
+ return error.errorCode ?? 'unknown';
7
+ if (isPromptCancelled(error))
8
+ return 'prompt_cancelled';
9
+ if (!error || typeof error !== 'object')
10
+ return 'unknown';
11
+ try {
12
+ const code = error.code;
13
+ if (typeof code === 'string') {
14
+ if (ERROR_CODES.includes(code))
15
+ return code;
16
+ if (['ECONNREFUSED', 'ECONNRESET', 'ETIMEDOUT', 'ENOTFOUND', 'EAI_AGAIN'].includes(code))
17
+ return 'connection_failed';
18
+ if (['UNAUTHORIZED', 'FORBIDDEN', 'AUTHENTICATION_FAILED'].includes(code))
19
+ return 'auth_failed';
20
+ if (code === 'commander.unknownCommand')
21
+ return 'unknown_command';
22
+ if (code === 'commander.unknownOption')
23
+ return 'unknown_option';
24
+ if (code.startsWith('commander.'))
25
+ return 'validation_failed';
26
+ }
27
+ // Some existing libraries expose only messages. Classify locally and discard
28
+ // the text; the returned value is always from the closed catalog.
29
+ if (error instanceof Error) {
30
+ if (/authentication failed|unauthorized|forbidden/i.test(error.message))
31
+ return 'auth_failed';
32
+ if (/build failed|compilation failed|transform failed/i.test(error.message))
33
+ return 'compile_error';
34
+ if (/ECONNREFUSED|ECONNRESET|ENOTFOUND|ETIMEDOUT|fetch failed|network error/i.test(error.message))
35
+ return 'connection_failed';
36
+ }
37
+ }
38
+ catch { /* No error content is retained. */ }
39
+ return 'unknown';
40
+ }
41
+ export function exceptionClass(error) {
42
+ if (error instanceof TypeError)
43
+ return 'TypeError';
44
+ if (error instanceof RangeError)
45
+ return 'RangeError';
46
+ if (error instanceof SyntaxError)
47
+ return 'SyntaxError';
48
+ if (error instanceof ReferenceError)
49
+ return 'ReferenceError';
50
+ if (error instanceof URIError)
51
+ return 'URIError';
52
+ if (error instanceof EvalError)
53
+ return 'EvalError';
54
+ if (error instanceof AggregateError)
55
+ return 'AggregateError';
56
+ return error instanceof Error ? 'Error' : 'unknown';
57
+ }
@@ -0,0 +1,5 @@
1
+ import { type TelemetryCommand, type TelemetryFlag } from './domains.js';
2
+ export declare function knownCommand(input: string): TelemetryCommand;
3
+ /** Call with Commander's raw args for the selected command, never its option values. */
4
+ export declare function flagNames(command: TelemetryCommand, args: readonly string[]): TelemetryFlag[];
5
+ //# sourceMappingURL=flags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../../../src/utils/telemetry/flags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAE1I,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAE5D;AAED,wFAAwF;AACxF,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,EAAE,CA8B7F"}
@@ -0,0 +1,41 @@
1
+ import { COMMANDS, COMMAND_FLAGS, GLOBAL_FLAGS, SHORT_FLAGS, VALUE_FLAGS } from './domains.js';
2
+ export function knownCommand(input) {
3
+ return COMMANDS.includes(input) ? input : 'unknown';
4
+ }
5
+ /** Call with Commander's raw args for the selected command, never its option values. */
6
+ export function flagNames(command, args) {
7
+ const allowed = [...COMMAND_FLAGS[command], ...GLOBAL_FLAGS];
8
+ const takesValue = VALUE_FLAGS[command];
9
+ const flags = new Set();
10
+ for (let index = 0; index < args.length; index++) {
11
+ const arg = args[index];
12
+ if (arg === '--')
13
+ break;
14
+ if (/^-[^-].+/.test(arg)) {
15
+ for (const [position, letter] of [...arg.slice(1)].entries()) {
16
+ const short = `-${letter}`;
17
+ const canonical = short === '-h' && command !== 'dev' ? '--help' : SHORT_FLAGS[short];
18
+ if (!canonical || !allowed.includes(canonical))
19
+ break;
20
+ flags.add(canonical);
21
+ if (takesValue.includes(canonical)) {
22
+ // A value is either attached (-p4000) or the next argument (-p 4000).
23
+ if (position === arg.length - 2)
24
+ index++;
25
+ break;
26
+ }
27
+ }
28
+ continue;
29
+ }
30
+ const name = arg.split('=', 1)[0];
31
+ const canonical = name === '-h' && command !== 'dev'
32
+ ? '--help' : SHORT_FLAGS[name] ?? name;
33
+ if (allowed.includes(canonical))
34
+ flags.add(canonical);
35
+ // Commander takes the next argument as a required value even when it starts
36
+ // with "-", so it must not be read as flags (`--output -help.ts`).
37
+ if (takesValue.includes(canonical) && !arg.includes('='))
38
+ index++;
39
+ }
40
+ return [...flags].sort();
41
+ }
@@ -0,0 +1,15 @@
1
+ import type { DatasetGenerationWarning } from '../../generators/dataset-generator.js';
2
+ import type { CommandMetrics } from './command-context.js';
3
+ export declare function warningBuckets(warnings?: readonly DatasetGenerationWarning[]): NonNullable<CommandMetrics<'generate:datasets'>['warning_counts']>;
4
+ /** Only inspect already produced manifest data and the loaded registry. */
5
+ export declare function manifestMetrics(api: unknown, manifest: unknown): CommandMetrics<'generate:manifest'>;
6
+ /** Reduces fallback type expressions immediately to a closed family domain. */
7
+ export declare class TypeGenerationMetrics {
8
+ private columns;
9
+ private unsupported;
10
+ private families;
11
+ column(): void;
12
+ fallback(type: string): void;
13
+ snapshot(): CommandMetrics<'generate'>;
14
+ }
15
+ //# sourceMappingURL=generation-metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generation-metrics.d.ts","sourceRoot":"","sources":["../../../src/utils/telemetry/generation-metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AAGtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,wBAAgB,cAAc,CAAC,QAAQ,GAAE,SAAS,wBAAwB,EAAO,GAAG,WAAW,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAErJ;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,cAAc,CAAC,mBAAmB,CAAC,CAQpG;AAED,+EAA+E;AAC/E,qBAAa,qBAAqB;IAChC,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,QAAQ,CAA2C;IAE3D,MAAM,IAAI,IAAI;IAEd,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAO5B,QAAQ,IAAI,cAAc,CAAC,UAAU,CAAC;CAIvC"}
@@ -0,0 +1,35 @@
1
+ import { TYPE_FAMILIES, WARNING_CODES } from './domains.js';
2
+ import { countBucket } from './buckets.js';
3
+ export function warningBuckets(warnings = []) {
4
+ return Object.fromEntries(WARNING_CODES.map(code => [code, countBucket(warnings.filter(warning => warning.kind === code).length)]));
5
+ }
6
+ /** Only inspect already produced manifest data and the loaded registry. */
7
+ export function manifestMetrics(api, manifest) {
8
+ try {
9
+ const queries = Object.getOwnPropertyDescriptor(api, 'queries')?.value;
10
+ return {
11
+ ...(queries && typeof queries === 'object' ? { query_count_bucket: countBucket(Object.keys(queries).length) } : {}),
12
+ ...(manifest && typeof manifest === 'object' ? { endpoint_count_bucket: countBucket(Object.keys(manifest).length) } : {}),
13
+ };
14
+ }
15
+ catch {
16
+ return {};
17
+ }
18
+ }
19
+ /** Reduces fallback type expressions immediately to a closed family domain. */
20
+ export class TypeGenerationMetrics {
21
+ columns = 0;
22
+ unsupported = 0;
23
+ families = new Set();
24
+ column() { this.columns++; }
25
+ fallback(type) {
26
+ this.unsupported++;
27
+ const name = /^\s*([A-Za-z][A-Za-z0-9_]*)/.exec(type)?.[1];
28
+ const family = TYPE_FAMILIES.find(value => value === name) ?? 'unknown';
29
+ this.families.add(family);
30
+ }
31
+ snapshot() {
32
+ return { column_count_bucket: countBucket(this.columns), unsupported_type_count_bucket: countBucket(this.unsupported),
33
+ unsupported_type_families: TYPE_FAMILIES.filter(family => this.families.has(family)) };
34
+ }
35
+ }
@@ -0,0 +1,12 @@
1
+ import type { TelemetryConfig } from './config-schema.js';
2
+ import type { ProjectContext } from './project-context.js';
3
+ /** HQ-233: shared across installs; the proxy must re-key this digest before storage. */
4
+ export declare const PROJECT_HASH_SALT = "hypequery.cli.project.v1:";
5
+ export declare function normalizeProjectRemote(input: string): string | undefined;
6
+ export declare function projectId(context: ProjectContext): string | undefined;
7
+ export declare function invocationIdentity(config: TelemetryConfig, context: ProjectContext): {
8
+ project_id?: string | undefined;
9
+ install_id: string;
10
+ session_id: `${string}-${string}-${string}-${string}-${string}`;
11
+ };
12
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/utils/telemetry/identity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,wFAAwF;AACxF,eAAO,MAAM,iBAAiB,8BAA8B,CAAC;AAE7D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAoBxE;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAMrE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc;;;;EAGlF"}
@@ -0,0 +1,42 @@
1
+ import { createHash, randomUUID } from 'node:crypto';
2
+ /** HQ-233: shared across installs; the proxy must re-key this digest before storage. */
3
+ export const PROJECT_HASH_SALT = 'hypequery.cli.project.v1:';
4
+ export function normalizeProjectRemote(input) {
5
+ try {
6
+ const raw = input.trim();
7
+ let url;
8
+ // SCP-style SSH remotes have no URL scheme. Local file paths are not signals.
9
+ if (/^(?:[^/@\s]+@)?[^/:\s]+:[^\\\s]+$/.test(raw) && !raw.includes('://')) {
10
+ const match = raw.match(/^(?:[^/@\s]+@)?([^/:\s]+):(.+)$/);
11
+ if (match[1].length === 1)
12
+ return undefined; // Windows drive path.
13
+ url = new URL(`ssh://${match[1]}/${match[2]}`);
14
+ }
15
+ else {
16
+ url = new URL(raw);
17
+ }
18
+ if (!['https:', 'http:', 'ssh:', 'git:'].includes(url.protocol))
19
+ return undefined;
20
+ const repo = url.pathname.replace(/^\/+|\/+$/g, '').replace(/\.git$/i, '');
21
+ if (!url.hostname || !repo)
22
+ return undefined;
23
+ const standardPort = { 'ssh:': '22', 'git:': '9418', 'https:': '443', 'http:': '80' }[url.protocol];
24
+ const port = url.port && url.port !== standardPort ? `:${url.port}` : '';
25
+ // Credentials, query, fragment and transport are excluded before hashing.
26
+ return `${url.hostname.toLowerCase()}${port}/${repo}`;
27
+ }
28
+ catch {
29
+ return undefined;
30
+ }
31
+ }
32
+ export function projectId(context) {
33
+ const remote = context.remote ? normalizeProjectRemote(context.remote) : undefined;
34
+ const name = (context.rootPackage ?? context.package)?.name;
35
+ const signal = remote ? `remote:${remote}` : typeof name === 'string' && name.trim()
36
+ ? `package:${name.trim()}` : undefined;
37
+ return signal ? createHash('sha256').update(PROJECT_HASH_SALT).update(signal).digest('hex') : undefined;
38
+ }
39
+ export function invocationIdentity(config, context) {
40
+ const project = projectId(context);
41
+ return { install_id: config.install_id, session_id: randomUUID(), ...(project ? { project_id: project } : {}) };
42
+ }
@@ -0,0 +1,15 @@
1
+ import { type CommandMetrics } from './command-context.js';
2
+ type InitStage = NonNullable<CommandMetrics<'init'>['stage_reached']>;
3
+ /** Tracks actual progress even when embedded setup tests its connection later. */
4
+ export declare class InitFunnel {
5
+ private reached;
6
+ private attempted;
7
+ constructor(metrics: CommandMetrics<'init'>);
8
+ update(metrics: CommandMetrics<'init'>): void;
9
+ attempt(stage: InitStage): void;
10
+ reach(stage: InitStage): void;
11
+ cancel(): void;
12
+ fail(error: unknown): void;
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=init-funnel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-funnel.d.ts","sourceRoot":"","sources":["../../../src/utils/telemetry/init-funnel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkD,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3G,KAAK,SAAS,GAAG,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;AAGtE,kFAAkF;AAClF,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,SAAS,CAAwB;gBAE7B,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC;IAI3C,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,IAAI;IAE7C,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAE/B,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAK7B,MAAM,IAAI,IAAI;IAEd,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;CAI3B"}
@@ -0,0 +1,25 @@
1
+ import { CommandExit } from '../command-exit.js';
2
+ import { isPromptCancelled } from '../prompts.js';
3
+ import { cancelCommandTelemetry, updateCommandTelemetry } from './command-context.js';
4
+ const stages = ['started', 'database_selected', 'connection_tested', 'style_selected', 'files_written', 'dependencies_installed', 'completed'];
5
+ /** Tracks actual progress even when embedded setup tests its connection later. */
6
+ export class InitFunnel {
7
+ reached = 'started';
8
+ attempted = 'started';
9
+ constructor(metrics) {
10
+ this.update({ ...metrics, stage_reached: this.reached });
11
+ }
12
+ update(metrics) { updateCommandTelemetry('init', metrics); }
13
+ attempt(stage) { this.attempted = stage; }
14
+ reach(stage) {
15
+ if (stages.indexOf(stage) > stages.indexOf(this.reached))
16
+ this.reached = stage;
17
+ this.update({ stage_reached: this.reached });
18
+ }
19
+ cancel() { cancelCommandTelemetry(); }
20
+ fail(error) {
21
+ if (isPromptCancelled(error) || error instanceof CommandExit && error.outcome !== 'failure')
22
+ return;
23
+ this.update({ failed_stage: this.attempted });
24
+ }
25
+ }