@c4a/extract-sql 0.7.9 → 0.7.10-alpha.2

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 (2) hide show
  1. package/index.d.ts +568 -0
  2. package/package.json +5 -3
package/index.d.ts ADDED
@@ -0,0 +1,568 @@
1
+ import { z } from 'zod';
2
+
3
+ export type SqlDialect = "mysql" | "postgresql" | "sqlite";
4
+ export interface SqlLocator {
5
+ path: string;
6
+ line: number;
7
+ column: number;
8
+ qualified_item_path: string;
9
+ }
10
+ export interface SqlStatement {
11
+ statement_ref: string;
12
+ dialect: SqlDialect;
13
+ statement_type: string;
14
+ category: "read" | "write" | "ddl" | "control";
15
+ statement_digest: string;
16
+ locator: SqlLocator;
17
+ }
18
+ export interface SqlObjectEvidence {
19
+ object_ref: string;
20
+ object_kind: "table" | "view" | "index";
21
+ name: string;
22
+ operation: "read" | "write" | "ddl";
23
+ ddl_action: string | null;
24
+ statement_ref: string;
25
+ locator: SqlLocator;
26
+ }
27
+ export interface SqlMigrationCandidate {
28
+ migration_ref: string;
29
+ direction: "up" | "down" | "unknown";
30
+ sequence: string | null;
31
+ basis: "path-convention";
32
+ locator: SqlLocator;
33
+ }
34
+ export interface SqlDiagnostic {
35
+ code: "sql-dialect-required" | "sql-dialect-unsupported" | "sql-source-unsupported" | "sql-statement-unsupported";
36
+ severity: "error";
37
+ locator: SqlLocator;
38
+ detail: string;
39
+ }
40
+ export interface SqlDocumentCatalog {
41
+ path: string;
42
+ dialect: SqlDialect | null;
43
+ disposition: "analyzed" | "unsupported" | "excluded";
44
+ statements: SqlStatement[];
45
+ objects: SqlObjectEvidence[];
46
+ migrations: SqlMigrationCandidate[];
47
+ diagnostics: SqlDiagnostic[];
48
+ }
49
+ export interface SqlParseOptions {
50
+ dialects: Readonly<Record<string, string>>;
51
+ }
52
+ /** Parses registered `.sql` files only when the caller supplies an explicit supported dialect. */
53
+ export declare function parseSqlSources(files: Readonly<Record<string, string>>, options: SqlParseOptions): SqlDocumentCatalog[];
54
+ interface SqlSourceStatement {
55
+ text: string;
56
+ startOffset: number;
57
+ line: number;
58
+ column: number;
59
+ }
60
+ /** Splits top-level SQL semicolons while preserving quoted/commented bodies. */
61
+ export declare function splitSqlStatements(source: string): SqlSourceStatement[];
62
+ declare const indexerEvidenceAdapterResultSchema: z.ZodEffects<z.ZodObject<{
63
+ protocol: z.ZodLiteral<"context.indexer.evidence-adapter-result/v1">;
64
+ adapter: z.ZodObject<{
65
+ id: z.ZodEffects<z.ZodString, string, string>;
66
+ package: z.ZodString;
67
+ export: z.ZodString;
68
+ version: z.ZodString;
69
+ digest: z.ZodString;
70
+ }, "strict", z.ZodTypeAny, {
71
+ package: string;
72
+ id: string;
73
+ version: string;
74
+ digest: string;
75
+ export: string;
76
+ }, {
77
+ package: string;
78
+ id: string;
79
+ version: string;
80
+ digest: string;
81
+ export: string;
82
+ }>;
83
+ authorized_scope: z.ZodObject<{
84
+ source_ref: z.ZodString;
85
+ module_refs: z.ZodArray<z.ZodString, "many">;
86
+ scope_digest: z.ZodString;
87
+ }, "strict", z.ZodTypeAny, {
88
+ source_ref: string;
89
+ module_refs: string[];
90
+ scope_digest: string;
91
+ }, {
92
+ source_ref: string;
93
+ module_refs: string[];
94
+ scope_digest: string;
95
+ }>;
96
+ input_digest: z.ZodString;
97
+ precedence: z.ZodNumber;
98
+ files: z.ZodArray<z.ZodEffects<z.ZodObject<{
99
+ file_ref: z.ZodString;
100
+ source_ref: z.ZodString;
101
+ module_ref: z.ZodNullable<z.ZodString>;
102
+ normalized_path: z.ZodEffects<z.ZodString, string, string>;
103
+ role: z.ZodEnum<[
104
+ "primary-owner",
105
+ "enricher"
106
+ ]>;
107
+ coverage_tier: z.ZodEnum<[
108
+ "ast-catalog",
109
+ "lightweight-evidence"
110
+ ]>;
111
+ disposition: z.ZodEnum<[
112
+ "analyzed",
113
+ "unsupported",
114
+ "excluded"
115
+ ]>;
116
+ facts: z.ZodArray<z.ZodObject<{
117
+ fact_ref: z.ZodString;
118
+ kind: z.ZodEffects<z.ZodString, string, string>;
119
+ locator: z.ZodObject<{
120
+ source_ref: z.ZodString;
121
+ module_ref: z.ZodNullable<z.ZodString>;
122
+ normalized_path: z.ZodEffects<z.ZodString, string, string>;
123
+ qualified_item_path: z.ZodString;
124
+ signature_digest: z.ZodString;
125
+ }, "strict", z.ZodTypeAny, {
126
+ source_ref: string;
127
+ module_ref: string | null;
128
+ normalized_path: string;
129
+ qualified_item_path: string;
130
+ signature_digest: string;
131
+ }, {
132
+ source_ref: string;
133
+ module_ref: string | null;
134
+ normalized_path: string;
135
+ qualified_item_path: string;
136
+ signature_digest: string;
137
+ }>;
138
+ payload_digest: z.ZodString;
139
+ denominator: z.ZodEnum<[
140
+ "none",
141
+ "eligible-file",
142
+ "loc",
143
+ "symbol",
144
+ "protocol-item"
145
+ ]>;
146
+ }, "strict", z.ZodTypeAny, {
147
+ kind: string;
148
+ fact_ref: string;
149
+ locator: {
150
+ source_ref: string;
151
+ module_ref: string | null;
152
+ normalized_path: string;
153
+ qualified_item_path: string;
154
+ signature_digest: string;
155
+ };
156
+ payload_digest: string;
157
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
158
+ }, {
159
+ kind: string;
160
+ fact_ref: string;
161
+ locator: {
162
+ source_ref: string;
163
+ module_ref: string | null;
164
+ normalized_path: string;
165
+ qualified_item_path: string;
166
+ signature_digest: string;
167
+ };
168
+ payload_digest: string;
169
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
170
+ }>, "many">;
171
+ }, "strict", z.ZodTypeAny, {
172
+ source_ref: string;
173
+ module_ref: string | null;
174
+ normalized_path: string;
175
+ file_ref: string;
176
+ role: "primary-owner" | "enricher";
177
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
178
+ disposition: "analyzed" | "unsupported" | "excluded";
179
+ facts: {
180
+ kind: string;
181
+ fact_ref: string;
182
+ locator: {
183
+ source_ref: string;
184
+ module_ref: string | null;
185
+ normalized_path: string;
186
+ qualified_item_path: string;
187
+ signature_digest: string;
188
+ };
189
+ payload_digest: string;
190
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
191
+ }[];
192
+ }, {
193
+ source_ref: string;
194
+ module_ref: string | null;
195
+ normalized_path: string;
196
+ file_ref: string;
197
+ role: "primary-owner" | "enricher";
198
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
199
+ disposition: "analyzed" | "unsupported" | "excluded";
200
+ facts: {
201
+ kind: string;
202
+ fact_ref: string;
203
+ locator: {
204
+ source_ref: string;
205
+ module_ref: string | null;
206
+ normalized_path: string;
207
+ qualified_item_path: string;
208
+ signature_digest: string;
209
+ };
210
+ payload_digest: string;
211
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
212
+ }[];
213
+ }>, {
214
+ source_ref: string;
215
+ module_ref: string | null;
216
+ normalized_path: string;
217
+ file_ref: string;
218
+ role: "primary-owner" | "enricher";
219
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
220
+ disposition: "analyzed" | "unsupported" | "excluded";
221
+ facts: {
222
+ kind: string;
223
+ fact_ref: string;
224
+ locator: {
225
+ source_ref: string;
226
+ module_ref: string | null;
227
+ normalized_path: string;
228
+ qualified_item_path: string;
229
+ signature_digest: string;
230
+ };
231
+ payload_digest: string;
232
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
233
+ }[];
234
+ }, {
235
+ source_ref: string;
236
+ module_ref: string | null;
237
+ normalized_path: string;
238
+ file_ref: string;
239
+ role: "primary-owner" | "enricher";
240
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
241
+ disposition: "analyzed" | "unsupported" | "excluded";
242
+ facts: {
243
+ kind: string;
244
+ fact_ref: string;
245
+ locator: {
246
+ source_ref: string;
247
+ module_ref: string | null;
248
+ normalized_path: string;
249
+ qualified_item_path: string;
250
+ signature_digest: string;
251
+ };
252
+ payload_digest: string;
253
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
254
+ }[];
255
+ }>, "many">;
256
+ diagnostics: z.ZodArray<z.ZodObject<{
257
+ code: z.ZodEffects<z.ZodString, string, string>;
258
+ fact_ref: z.ZodOptional<z.ZodString>;
259
+ severity: z.ZodEnum<[
260
+ "info",
261
+ "warning",
262
+ "error"
263
+ ]>;
264
+ detail_digest: z.ZodString;
265
+ }, "strict", z.ZodTypeAny, {
266
+ code: string;
267
+ severity: "warning" | "info" | "error";
268
+ detail_digest: string;
269
+ fact_ref?: string | undefined;
270
+ }, {
271
+ code: string;
272
+ severity: "warning" | "info" | "error";
273
+ detail_digest: string;
274
+ fact_ref?: string | undefined;
275
+ }>, "many">;
276
+ toolchain: z.ZodArray<z.ZodEffects<z.ZodObject<{
277
+ step: z.ZodEffects<z.ZodString, string, string>;
278
+ package: z.ZodString;
279
+ export: z.ZodString;
280
+ version: z.ZodString;
281
+ digest: z.ZodString;
282
+ capabilities: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
283
+ input_digest: z.ZodString;
284
+ output_digest: z.ZodString;
285
+ }, "strict", z.ZodTypeAny, {
286
+ package: string;
287
+ version: string;
288
+ digest: string;
289
+ export: string;
290
+ step: string;
291
+ capabilities: string[];
292
+ input_digest: string;
293
+ output_digest: string;
294
+ }, {
295
+ package: string;
296
+ version: string;
297
+ digest: string;
298
+ export: string;
299
+ step: string;
300
+ capabilities: string[];
301
+ input_digest: string;
302
+ output_digest: string;
303
+ }>, {
304
+ package: string;
305
+ version: string;
306
+ digest: string;
307
+ export: string;
308
+ step: string;
309
+ capabilities: string[];
310
+ input_digest: string;
311
+ output_digest: string;
312
+ }, {
313
+ package: string;
314
+ version: string;
315
+ digest: string;
316
+ export: string;
317
+ step: string;
318
+ capabilities: string[];
319
+ input_digest: string;
320
+ output_digest: string;
321
+ }>, "many">;
322
+ output_digest: z.ZodString;
323
+ }, "strict", z.ZodTypeAny, {
324
+ input_digest: string;
325
+ output_digest: string;
326
+ protocol: "context.indexer.evidence-adapter-result/v1";
327
+ adapter: {
328
+ package: string;
329
+ id: string;
330
+ version: string;
331
+ digest: string;
332
+ export: string;
333
+ };
334
+ authorized_scope: {
335
+ source_ref: string;
336
+ module_refs: string[];
337
+ scope_digest: string;
338
+ };
339
+ precedence: number;
340
+ files: {
341
+ source_ref: string;
342
+ module_ref: string | null;
343
+ normalized_path: string;
344
+ file_ref: string;
345
+ role: "primary-owner" | "enricher";
346
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
347
+ disposition: "analyzed" | "unsupported" | "excluded";
348
+ facts: {
349
+ kind: string;
350
+ fact_ref: string;
351
+ locator: {
352
+ source_ref: string;
353
+ module_ref: string | null;
354
+ normalized_path: string;
355
+ qualified_item_path: string;
356
+ signature_digest: string;
357
+ };
358
+ payload_digest: string;
359
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
360
+ }[];
361
+ }[];
362
+ diagnostics: {
363
+ code: string;
364
+ severity: "warning" | "info" | "error";
365
+ detail_digest: string;
366
+ fact_ref?: string | undefined;
367
+ }[];
368
+ toolchain: {
369
+ package: string;
370
+ version: string;
371
+ digest: string;
372
+ export: string;
373
+ step: string;
374
+ capabilities: string[];
375
+ input_digest: string;
376
+ output_digest: string;
377
+ }[];
378
+ }, {
379
+ input_digest: string;
380
+ output_digest: string;
381
+ protocol: "context.indexer.evidence-adapter-result/v1";
382
+ adapter: {
383
+ package: string;
384
+ id: string;
385
+ version: string;
386
+ digest: string;
387
+ export: string;
388
+ };
389
+ authorized_scope: {
390
+ source_ref: string;
391
+ module_refs: string[];
392
+ scope_digest: string;
393
+ };
394
+ precedence: number;
395
+ files: {
396
+ source_ref: string;
397
+ module_ref: string | null;
398
+ normalized_path: string;
399
+ file_ref: string;
400
+ role: "primary-owner" | "enricher";
401
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
402
+ disposition: "analyzed" | "unsupported" | "excluded";
403
+ facts: {
404
+ kind: string;
405
+ fact_ref: string;
406
+ locator: {
407
+ source_ref: string;
408
+ module_ref: string | null;
409
+ normalized_path: string;
410
+ qualified_item_path: string;
411
+ signature_digest: string;
412
+ };
413
+ payload_digest: string;
414
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
415
+ }[];
416
+ }[];
417
+ diagnostics: {
418
+ code: string;
419
+ severity: "warning" | "info" | "error";
420
+ detail_digest: string;
421
+ fact_ref?: string | undefined;
422
+ }[];
423
+ toolchain: {
424
+ package: string;
425
+ version: string;
426
+ digest: string;
427
+ export: string;
428
+ step: string;
429
+ capabilities: string[];
430
+ input_digest: string;
431
+ output_digest: string;
432
+ }[];
433
+ }>, {
434
+ input_digest: string;
435
+ output_digest: string;
436
+ protocol: "context.indexer.evidence-adapter-result/v1";
437
+ adapter: {
438
+ package: string;
439
+ id: string;
440
+ version: string;
441
+ digest: string;
442
+ export: string;
443
+ };
444
+ authorized_scope: {
445
+ source_ref: string;
446
+ module_refs: string[];
447
+ scope_digest: string;
448
+ };
449
+ precedence: number;
450
+ files: {
451
+ source_ref: string;
452
+ module_ref: string | null;
453
+ normalized_path: string;
454
+ file_ref: string;
455
+ role: "primary-owner" | "enricher";
456
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
457
+ disposition: "analyzed" | "unsupported" | "excluded";
458
+ facts: {
459
+ kind: string;
460
+ fact_ref: string;
461
+ locator: {
462
+ source_ref: string;
463
+ module_ref: string | null;
464
+ normalized_path: string;
465
+ qualified_item_path: string;
466
+ signature_digest: string;
467
+ };
468
+ payload_digest: string;
469
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
470
+ }[];
471
+ }[];
472
+ diagnostics: {
473
+ code: string;
474
+ severity: "warning" | "info" | "error";
475
+ detail_digest: string;
476
+ fact_ref?: string | undefined;
477
+ }[];
478
+ toolchain: {
479
+ package: string;
480
+ version: string;
481
+ digest: string;
482
+ export: string;
483
+ step: string;
484
+ capabilities: string[];
485
+ input_digest: string;
486
+ output_digest: string;
487
+ }[];
488
+ }, {
489
+ input_digest: string;
490
+ output_digest: string;
491
+ protocol: "context.indexer.evidence-adapter-result/v1";
492
+ adapter: {
493
+ package: string;
494
+ id: string;
495
+ version: string;
496
+ digest: string;
497
+ export: string;
498
+ };
499
+ authorized_scope: {
500
+ source_ref: string;
501
+ module_refs: string[];
502
+ scope_digest: string;
503
+ };
504
+ precedence: number;
505
+ files: {
506
+ source_ref: string;
507
+ module_ref: string | null;
508
+ normalized_path: string;
509
+ file_ref: string;
510
+ role: "primary-owner" | "enricher";
511
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
512
+ disposition: "analyzed" | "unsupported" | "excluded";
513
+ facts: {
514
+ kind: string;
515
+ fact_ref: string;
516
+ locator: {
517
+ source_ref: string;
518
+ module_ref: string | null;
519
+ normalized_path: string;
520
+ qualified_item_path: string;
521
+ signature_digest: string;
522
+ };
523
+ payload_digest: string;
524
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
525
+ }[];
526
+ }[];
527
+ diagnostics: {
528
+ code: string;
529
+ severity: "warning" | "info" | "error";
530
+ detail_digest: string;
531
+ fact_ref?: string | undefined;
532
+ }[];
533
+ toolchain: {
534
+ package: string;
535
+ version: string;
536
+ digest: string;
537
+ export: string;
538
+ step: string;
539
+ capabilities: string[];
540
+ input_digest: string;
541
+ output_digest: string;
542
+ }[];
543
+ }>;
544
+ type IndexerEvidenceAdapterResult = z.infer<typeof indexerEvidenceAdapterResultSchema>;
545
+ type IndexerEvidenceAdapterFactPayloadValue = null | boolean | number | string | IndexerEvidenceAdapterFactPayloadValue[] | {
546
+ [key: string]: IndexerEvidenceAdapterFactPayloadValue;
547
+ };
548
+ interface IndexerEvidenceAdapterFactPayload {
549
+ fact_ref: string;
550
+ payload: IndexerEvidenceAdapterFactPayloadValue;
551
+ }
552
+ interface IndexerEvidenceAdapterMaterialization {
553
+ result: IndexerEvidenceAdapterResult;
554
+ fact_payloads: IndexerEvidenceAdapterFactPayload[];
555
+ }
556
+ export interface SqlEvidenceAdapterInvocation extends SqlParseOptions {
557
+ adapter: IndexerEvidenceAdapterResult["adapter"];
558
+ authorized_scope: IndexerEvidenceAdapterResult["authorized_scope"];
559
+ input_digest: string;
560
+ precedence: number;
561
+ module_refs?: Readonly<Record<string, string | null>>;
562
+ role?: "primary-owner" | "enricher";
563
+ }
564
+ export declare function sqlSourcesToEvidenceAdapterResult(files: Readonly<Record<string, string>>, invocation: SqlEvidenceAdapterInvocation): IndexerEvidenceAdapterResult;
565
+ export declare function sqlSourcesToEvidenceAdapterMaterialization(files: Readonly<Record<string, string>>, invocation: SqlEvidenceAdapterInvocation): IndexerEvidenceAdapterMaterialization;
566
+ export declare const SQL_EVIDENCE_ADAPTER_EXPORT = "sqlSourcesToEvidenceAdapterMaterialization";
567
+
568
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/extract-sql",
3
- "version": "0.7.9",
3
+ "version": "0.7.10-alpha.2",
4
4
  "type": "module",
5
5
  "description": "Dialect-bound lightweight SQL evidence adapter for Context",
6
6
  "license": "MIT",
@@ -19,7 +19,9 @@
19
19
  "node": ">=20"
20
20
  },
21
21
  "dependencies": {
22
- "node-sql-parser": "^5.4.0"
22
+ "node-sql-parser": "^5.4.0",
23
+ "zod": "^3.23.8"
23
24
  },
24
- "main": "./index.js"
25
+ "main": "./index.js",
26
+ "types": "./index.d.ts"
25
27
  }