@c4a/extract-contract 0.7.10-alpha.1 → 0.7.10

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 (3) hide show
  1. package/index.d.ts +584 -0
  2. package/index.js +1 -1
  3. package/package.json +5 -3
package/index.d.ts ADDED
@@ -0,0 +1,584 @@
1
+ import { z } from 'zod';
2
+
3
+ export interface ContractLocator {
4
+ path: string;
5
+ line: number;
6
+ column: number;
7
+ qualified_item_path: string;
8
+ }
9
+ export interface ContractEndpoint {
10
+ endpoint_ref: string;
11
+ protocol: "openapi" | "graphql";
12
+ path_or_type: string;
13
+ locator: ContractLocator;
14
+ }
15
+ export interface ContractOperation {
16
+ operation_ref: string;
17
+ protocol: "openapi" | "graphql";
18
+ operation_kind: string;
19
+ name: string;
20
+ parent: string;
21
+ deprecated: boolean;
22
+ fields?: ContractField[];
23
+ locator: ContractLocator;
24
+ }
25
+ export interface ContractType {
26
+ type_ref: string;
27
+ protocol: "openapi" | "graphql";
28
+ kind: string;
29
+ name: string;
30
+ extension: boolean;
31
+ field_names: string[];
32
+ fields?: ContractField[];
33
+ locator: ContractLocator;
34
+ }
35
+ interface ContractField {
36
+ name: string;
37
+ type: string;
38
+ optional: boolean;
39
+ location?: string;
40
+ defaultValue?: string;
41
+ description?: string;
42
+ fields?: ContractField[];
43
+ constraints?: Record<string, unknown>;
44
+ }
45
+ export interface ContractReference {
46
+ reference_ref: string;
47
+ protocol: "openapi" | "graphql";
48
+ target_path: string;
49
+ target_item_path: string;
50
+ locator: ContractLocator;
51
+ }
52
+ export interface ContractDiagnostic {
53
+ code: "contract-source-unsupported" | "graphql-extension-base-ambiguous" | "graphql-extension-base-missing" | "graphql-schema-definition-ambiguous" | "graphql-type-definition-ambiguous" | "openapi-external-ref-cycle" | "openapi-ref-base-uri-unsupported" | "openapi-ref-missing" | "openapi-ref-out-of-scope" | "openapi-ref-pointer-missing" | "openapi-ref-target-unsupported";
54
+ severity: "warning" | "error";
55
+ locator: ContractLocator;
56
+ detail: string;
57
+ }
58
+ export interface ContractDocumentCatalog {
59
+ path: string;
60
+ format: "openapi" | "openapi-fragment" | "graphql" | "excluded";
61
+ version: string | null;
62
+ disposition: "analyzed" | "unsupported" | "excluded";
63
+ endpoints: ContractEndpoint[];
64
+ operations: ContractOperation[];
65
+ types: ContractType[];
66
+ references: ContractReference[];
67
+ diagnostics: ContractDiagnostic[];
68
+ }
69
+ /**
70
+ * Parses one registered contract scope. GraphQL files in one invocation are
71
+ * treated as one schema scope so extensions can resolve to an exact base.
72
+ */
73
+ export declare function parseContractSources(files: Readonly<Record<string, string>>): ContractDocumentCatalog[];
74
+ /** Discover local dependencies with the same syntax and scope rules as parsing.
75
+ * The caller supplies captured file access; this helper never reads or fetches. */
76
+ export declare function openApiSourceDependencies(path: string, source: string): string[];
77
+ declare const indexerEvidenceAdapterResultSchema: z.ZodEffects<z.ZodObject<{
78
+ protocol: z.ZodLiteral<"context.indexer.evidence-adapter-result/v1">;
79
+ adapter: z.ZodObject<{
80
+ id: z.ZodEffects<z.ZodString, string, string>;
81
+ package: z.ZodString;
82
+ export: z.ZodString;
83
+ version: z.ZodString;
84
+ digest: z.ZodString;
85
+ }, "strict", z.ZodTypeAny, {
86
+ version: string;
87
+ package: string;
88
+ id: string;
89
+ digest: string;
90
+ export: string;
91
+ }, {
92
+ version: string;
93
+ package: string;
94
+ id: string;
95
+ digest: string;
96
+ export: string;
97
+ }>;
98
+ authorized_scope: z.ZodObject<{
99
+ source_ref: z.ZodString;
100
+ module_refs: z.ZodArray<z.ZodString, "many">;
101
+ scope_digest: z.ZodString;
102
+ }, "strict", z.ZodTypeAny, {
103
+ source_ref: string;
104
+ module_refs: string[];
105
+ scope_digest: string;
106
+ }, {
107
+ source_ref: string;
108
+ module_refs: string[];
109
+ scope_digest: string;
110
+ }>;
111
+ input_digest: z.ZodString;
112
+ precedence: z.ZodNumber;
113
+ files: z.ZodArray<z.ZodEffects<z.ZodObject<{
114
+ file_ref: z.ZodString;
115
+ source_ref: z.ZodString;
116
+ module_ref: z.ZodNullable<z.ZodString>;
117
+ normalized_path: z.ZodEffects<z.ZodString, string, string>;
118
+ role: z.ZodEnum<[
119
+ "primary-owner",
120
+ "enricher"
121
+ ]>;
122
+ coverage_tier: z.ZodEnum<[
123
+ "ast-catalog",
124
+ "lightweight-evidence"
125
+ ]>;
126
+ disposition: z.ZodEnum<[
127
+ "analyzed",
128
+ "unsupported",
129
+ "excluded"
130
+ ]>;
131
+ facts: z.ZodArray<z.ZodObject<{
132
+ fact_ref: z.ZodString;
133
+ kind: z.ZodEffects<z.ZodString, string, string>;
134
+ locator: z.ZodObject<{
135
+ source_ref: z.ZodString;
136
+ module_ref: z.ZodNullable<z.ZodString>;
137
+ normalized_path: z.ZodEffects<z.ZodString, string, string>;
138
+ qualified_item_path: z.ZodString;
139
+ signature_digest: z.ZodString;
140
+ }, "strict", z.ZodTypeAny, {
141
+ source_ref: string;
142
+ module_ref: string | null;
143
+ normalized_path: string;
144
+ qualified_item_path: string;
145
+ signature_digest: string;
146
+ }, {
147
+ source_ref: string;
148
+ module_ref: string | null;
149
+ normalized_path: string;
150
+ qualified_item_path: string;
151
+ signature_digest: string;
152
+ }>;
153
+ payload_digest: z.ZodString;
154
+ denominator: z.ZodEnum<[
155
+ "none",
156
+ "eligible-file",
157
+ "loc",
158
+ "symbol",
159
+ "protocol-item"
160
+ ]>;
161
+ }, "strict", z.ZodTypeAny, {
162
+ kind: string;
163
+ fact_ref: string;
164
+ locator: {
165
+ source_ref: string;
166
+ module_ref: string | null;
167
+ normalized_path: string;
168
+ qualified_item_path: string;
169
+ signature_digest: string;
170
+ };
171
+ payload_digest: string;
172
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
173
+ }, {
174
+ kind: string;
175
+ fact_ref: string;
176
+ locator: {
177
+ source_ref: string;
178
+ module_ref: string | null;
179
+ normalized_path: string;
180
+ qualified_item_path: string;
181
+ signature_digest: string;
182
+ };
183
+ payload_digest: string;
184
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
185
+ }>, "many">;
186
+ }, "strict", z.ZodTypeAny, {
187
+ disposition: "excluded" | "analyzed" | "unsupported";
188
+ source_ref: string;
189
+ module_ref: string | null;
190
+ normalized_path: string;
191
+ file_ref: string;
192
+ role: "primary-owner" | "enricher";
193
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
194
+ facts: {
195
+ kind: string;
196
+ fact_ref: string;
197
+ locator: {
198
+ source_ref: string;
199
+ module_ref: string | null;
200
+ normalized_path: string;
201
+ qualified_item_path: string;
202
+ signature_digest: string;
203
+ };
204
+ payload_digest: string;
205
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
206
+ }[];
207
+ }, {
208
+ disposition: "excluded" | "analyzed" | "unsupported";
209
+ source_ref: string;
210
+ module_ref: string | null;
211
+ normalized_path: string;
212
+ file_ref: string;
213
+ role: "primary-owner" | "enricher";
214
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
215
+ facts: {
216
+ kind: string;
217
+ fact_ref: string;
218
+ locator: {
219
+ source_ref: string;
220
+ module_ref: string | null;
221
+ normalized_path: string;
222
+ qualified_item_path: string;
223
+ signature_digest: string;
224
+ };
225
+ payload_digest: string;
226
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
227
+ }[];
228
+ }>, {
229
+ disposition: "excluded" | "analyzed" | "unsupported";
230
+ source_ref: string;
231
+ module_ref: string | null;
232
+ normalized_path: string;
233
+ file_ref: string;
234
+ role: "primary-owner" | "enricher";
235
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
236
+ facts: {
237
+ kind: string;
238
+ fact_ref: string;
239
+ locator: {
240
+ source_ref: string;
241
+ module_ref: string | null;
242
+ normalized_path: string;
243
+ qualified_item_path: string;
244
+ signature_digest: string;
245
+ };
246
+ payload_digest: string;
247
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
248
+ }[];
249
+ }, {
250
+ disposition: "excluded" | "analyzed" | "unsupported";
251
+ source_ref: string;
252
+ module_ref: string | null;
253
+ normalized_path: string;
254
+ file_ref: string;
255
+ role: "primary-owner" | "enricher";
256
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
257
+ facts: {
258
+ kind: string;
259
+ fact_ref: string;
260
+ locator: {
261
+ source_ref: string;
262
+ module_ref: string | null;
263
+ normalized_path: string;
264
+ qualified_item_path: string;
265
+ signature_digest: string;
266
+ };
267
+ payload_digest: string;
268
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
269
+ }[];
270
+ }>, "many">;
271
+ diagnostics: z.ZodArray<z.ZodObject<{
272
+ code: z.ZodEffects<z.ZodString, string, string>;
273
+ fact_ref: z.ZodOptional<z.ZodString>;
274
+ severity: z.ZodEnum<[
275
+ "info",
276
+ "warning",
277
+ "error"
278
+ ]>;
279
+ detail_digest: z.ZodString;
280
+ }, "strict", z.ZodTypeAny, {
281
+ code: string;
282
+ severity: "warning" | "error" | "info";
283
+ detail_digest: string;
284
+ fact_ref?: string | undefined;
285
+ }, {
286
+ code: string;
287
+ severity: "warning" | "error" | "info";
288
+ detail_digest: string;
289
+ fact_ref?: string | undefined;
290
+ }>, "many">;
291
+ toolchain: z.ZodArray<z.ZodEffects<z.ZodObject<{
292
+ step: z.ZodEffects<z.ZodString, string, string>;
293
+ package: z.ZodString;
294
+ export: z.ZodString;
295
+ version: z.ZodString;
296
+ digest: z.ZodString;
297
+ capabilities: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
298
+ input_digest: z.ZodString;
299
+ output_digest: z.ZodString;
300
+ }, "strict", z.ZodTypeAny, {
301
+ version: string;
302
+ package: string;
303
+ digest: string;
304
+ export: string;
305
+ step: string;
306
+ capabilities: string[];
307
+ input_digest: string;
308
+ output_digest: string;
309
+ }, {
310
+ version: string;
311
+ package: string;
312
+ digest: string;
313
+ export: string;
314
+ step: string;
315
+ capabilities: string[];
316
+ input_digest: string;
317
+ output_digest: string;
318
+ }>, {
319
+ version: string;
320
+ package: string;
321
+ digest: string;
322
+ export: string;
323
+ step: string;
324
+ capabilities: string[];
325
+ input_digest: string;
326
+ output_digest: string;
327
+ }, {
328
+ version: string;
329
+ package: string;
330
+ digest: string;
331
+ export: string;
332
+ step: string;
333
+ capabilities: string[];
334
+ input_digest: string;
335
+ output_digest: string;
336
+ }>, "many">;
337
+ output_digest: z.ZodString;
338
+ }, "strict", z.ZodTypeAny, {
339
+ input_digest: string;
340
+ output_digest: string;
341
+ protocol: "context.indexer.evidence-adapter-result/v1";
342
+ adapter: {
343
+ version: string;
344
+ package: string;
345
+ id: string;
346
+ digest: string;
347
+ export: string;
348
+ };
349
+ authorized_scope: {
350
+ source_ref: string;
351
+ module_refs: string[];
352
+ scope_digest: string;
353
+ };
354
+ precedence: number;
355
+ files: {
356
+ disposition: "excluded" | "analyzed" | "unsupported";
357
+ source_ref: string;
358
+ module_ref: string | null;
359
+ normalized_path: string;
360
+ file_ref: string;
361
+ role: "primary-owner" | "enricher";
362
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
363
+ facts: {
364
+ kind: string;
365
+ fact_ref: string;
366
+ locator: {
367
+ source_ref: string;
368
+ module_ref: string | null;
369
+ normalized_path: string;
370
+ qualified_item_path: string;
371
+ signature_digest: string;
372
+ };
373
+ payload_digest: string;
374
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
375
+ }[];
376
+ }[];
377
+ diagnostics: {
378
+ code: string;
379
+ severity: "warning" | "error" | "info";
380
+ detail_digest: string;
381
+ fact_ref?: string | undefined;
382
+ }[];
383
+ toolchain: {
384
+ version: string;
385
+ package: string;
386
+ digest: string;
387
+ export: string;
388
+ step: string;
389
+ capabilities: string[];
390
+ input_digest: string;
391
+ output_digest: string;
392
+ }[];
393
+ }, {
394
+ input_digest: string;
395
+ output_digest: string;
396
+ protocol: "context.indexer.evidence-adapter-result/v1";
397
+ adapter: {
398
+ version: string;
399
+ package: string;
400
+ id: string;
401
+ digest: string;
402
+ export: string;
403
+ };
404
+ authorized_scope: {
405
+ source_ref: string;
406
+ module_refs: string[];
407
+ scope_digest: string;
408
+ };
409
+ precedence: number;
410
+ files: {
411
+ disposition: "excluded" | "analyzed" | "unsupported";
412
+ source_ref: string;
413
+ module_ref: string | null;
414
+ normalized_path: string;
415
+ file_ref: string;
416
+ role: "primary-owner" | "enricher";
417
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
418
+ facts: {
419
+ kind: string;
420
+ fact_ref: string;
421
+ locator: {
422
+ source_ref: string;
423
+ module_ref: string | null;
424
+ normalized_path: string;
425
+ qualified_item_path: string;
426
+ signature_digest: string;
427
+ };
428
+ payload_digest: string;
429
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
430
+ }[];
431
+ }[];
432
+ diagnostics: {
433
+ code: string;
434
+ severity: "warning" | "error" | "info";
435
+ detail_digest: string;
436
+ fact_ref?: string | undefined;
437
+ }[];
438
+ toolchain: {
439
+ version: string;
440
+ package: string;
441
+ digest: string;
442
+ export: string;
443
+ step: string;
444
+ capabilities: string[];
445
+ input_digest: string;
446
+ output_digest: string;
447
+ }[];
448
+ }>, {
449
+ input_digest: string;
450
+ output_digest: string;
451
+ protocol: "context.indexer.evidence-adapter-result/v1";
452
+ adapter: {
453
+ version: string;
454
+ package: string;
455
+ id: string;
456
+ digest: string;
457
+ export: string;
458
+ };
459
+ authorized_scope: {
460
+ source_ref: string;
461
+ module_refs: string[];
462
+ scope_digest: string;
463
+ };
464
+ precedence: number;
465
+ files: {
466
+ disposition: "excluded" | "analyzed" | "unsupported";
467
+ source_ref: string;
468
+ module_ref: string | null;
469
+ normalized_path: string;
470
+ file_ref: string;
471
+ role: "primary-owner" | "enricher";
472
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
473
+ facts: {
474
+ kind: string;
475
+ fact_ref: string;
476
+ locator: {
477
+ source_ref: string;
478
+ module_ref: string | null;
479
+ normalized_path: string;
480
+ qualified_item_path: string;
481
+ signature_digest: string;
482
+ };
483
+ payload_digest: string;
484
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
485
+ }[];
486
+ }[];
487
+ diagnostics: {
488
+ code: string;
489
+ severity: "warning" | "error" | "info";
490
+ detail_digest: string;
491
+ fact_ref?: string | undefined;
492
+ }[];
493
+ toolchain: {
494
+ version: string;
495
+ package: string;
496
+ digest: string;
497
+ export: string;
498
+ step: string;
499
+ capabilities: string[];
500
+ input_digest: string;
501
+ output_digest: string;
502
+ }[];
503
+ }, {
504
+ input_digest: string;
505
+ output_digest: string;
506
+ protocol: "context.indexer.evidence-adapter-result/v1";
507
+ adapter: {
508
+ version: string;
509
+ package: string;
510
+ id: string;
511
+ digest: string;
512
+ export: string;
513
+ };
514
+ authorized_scope: {
515
+ source_ref: string;
516
+ module_refs: string[];
517
+ scope_digest: string;
518
+ };
519
+ precedence: number;
520
+ files: {
521
+ disposition: "excluded" | "analyzed" | "unsupported";
522
+ source_ref: string;
523
+ module_ref: string | null;
524
+ normalized_path: string;
525
+ file_ref: string;
526
+ role: "primary-owner" | "enricher";
527
+ coverage_tier: "ast-catalog" | "lightweight-evidence";
528
+ facts: {
529
+ kind: string;
530
+ fact_ref: string;
531
+ locator: {
532
+ source_ref: string;
533
+ module_ref: string | null;
534
+ normalized_path: string;
535
+ qualified_item_path: string;
536
+ signature_digest: string;
537
+ };
538
+ payload_digest: string;
539
+ denominator: "symbol" | "none" | "eligible-file" | "loc" | "protocol-item";
540
+ }[];
541
+ }[];
542
+ diagnostics: {
543
+ code: string;
544
+ severity: "warning" | "error" | "info";
545
+ detail_digest: string;
546
+ fact_ref?: string | undefined;
547
+ }[];
548
+ toolchain: {
549
+ version: string;
550
+ package: string;
551
+ digest: string;
552
+ export: string;
553
+ step: string;
554
+ capabilities: string[];
555
+ input_digest: string;
556
+ output_digest: string;
557
+ }[];
558
+ }>;
559
+ type IndexerEvidenceAdapterResult = z.infer<typeof indexerEvidenceAdapterResultSchema>;
560
+ type IndexerEvidenceAdapterFactPayloadValue = null | boolean | number | string | IndexerEvidenceAdapterFactPayloadValue[] | {
561
+ [key: string]: IndexerEvidenceAdapterFactPayloadValue;
562
+ };
563
+ interface IndexerEvidenceAdapterFactPayload {
564
+ fact_ref: string;
565
+ payload: IndexerEvidenceAdapterFactPayloadValue;
566
+ }
567
+ interface IndexerEvidenceAdapterMaterialization {
568
+ result: IndexerEvidenceAdapterResult;
569
+ fact_payloads: IndexerEvidenceAdapterFactPayload[];
570
+ }
571
+ export interface ContractEvidenceAdapterInvocation {
572
+ adapter: IndexerEvidenceAdapterResult["adapter"];
573
+ authorized_scope: IndexerEvidenceAdapterResult["authorized_scope"];
574
+ input_digest: string;
575
+ precedence: number;
576
+ module_refs?: Readonly<Record<string, string | null>>;
577
+ role?: "primary-owner" | "enricher";
578
+ }
579
+ /** Parses caller-registered contract text and emits only the common Evidence ABI. */
580
+ export declare function contractSourcesToEvidenceAdapterResult(files: Readonly<Record<string, string>>, invocation: ContractEvidenceAdapterInvocation): IndexerEvidenceAdapterResult;
581
+ export declare function contractSourcesToEvidenceAdapterMaterialization(files: Readonly<Record<string, string>>, invocation: ContractEvidenceAdapterInvocation): IndexerEvidenceAdapterMaterialization;
582
+ export declare const CONTRACT_EVIDENCE_ADAPTER_EXPORT = "contractSourcesToEvidenceAdapterMaterialization";
583
+
584
+ export {};
package/index.js CHANGED
@@ -21820,7 +21820,7 @@ function refTarget(importer, raw) {
21820
21820
  const pointer = fragment === undefined ? "" : `#${fragment}`;
21821
21821
  if (rawPath === "")
21822
21822
  return { targetPath: importer, pointer, external: false };
21823
- if (!portablePath(rawPath))
21823
+ if (rawPath.includes("\\") || rawPath.split("/").some((part) => part === ""))
21824
21824
  return null;
21825
21825
  const targetPath = posix.normalize(posix.join(posix.dirname(importer), rawPath));
21826
21826
  return portablePath(targetPath) ? { targetPath, pointer, external: true } : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/extract-contract",
3
- "version": "0.7.10-alpha.1",
3
+ "version": "0.7.10",
4
4
  "type": "module",
5
5
  "description": "OpenAPI and GraphQL contract catalog adapter for Context",
6
6
  "license": "MIT",
@@ -20,7 +20,9 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "graphql": "^16.14.2",
23
- "yaml": "^2.8.2"
23
+ "yaml": "^2.8.2",
24
+ "zod": "^3.23.8"
24
25
  },
25
- "main": "./index.js"
26
+ "main": "./index.js",
27
+ "types": "./index.d.ts"
26
28
  }