@openparser/lineage 1.0.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 (67) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/LICENSE +201 -0
  3. package/README.md +211 -0
  4. package/dist/activity.d.ts +74 -0
  5. package/dist/activity.d.ts.map +1 -0
  6. package/dist/approval.d.ts +24 -0
  7. package/dist/approval.d.ts.map +1 -0
  8. package/dist/builder.d.ts +48 -0
  9. package/dist/builder.d.ts.map +1 -0
  10. package/dist/common.d.ts +34 -0
  11. package/dist/common.d.ts.map +1 -0
  12. package/dist/confidence.d.ts +61 -0
  13. package/dist/confidence.d.ts.map +1 -0
  14. package/dist/derivation.d.ts +163 -0
  15. package/dist/derivation.d.ts.map +1 -0
  16. package/dist/document.d.ts +412 -0
  17. package/dist/document.d.ts.map +1 -0
  18. package/dist/entity.d.ts +126 -0
  19. package/dist/entity.d.ts.map +1 -0
  20. package/dist/fields.d.ts +76 -0
  21. package/dist/fields.d.ts.map +1 -0
  22. package/dist/index.d.ts +21 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +870 -0
  25. package/dist/labels.d.ts +11 -0
  26. package/dist/labels.d.ts.map +1 -0
  27. package/dist/profile/grounding.d.ts +34 -0
  28. package/dist/profile/grounding.d.ts.map +1 -0
  29. package/dist/profile/index.d.ts +14 -0
  30. package/dist/profile/index.d.ts.map +1 -0
  31. package/dist/profile/index.js +1298 -0
  32. package/dist/profile/labels.d.ts +10 -0
  33. package/dist/profile/labels.d.ts.map +1 -0
  34. package/dist/profile/recognition.d.ts +70 -0
  35. package/dist/profile/recognition.d.ts.map +1 -0
  36. package/dist/profile/transform-validation.d.ts +250 -0
  37. package/dist/profile/transform-validation.d.ts.map +1 -0
  38. package/dist/prov.d.ts +40 -0
  39. package/dist/prov.d.ts.map +1 -0
  40. package/dist/relation.d.ts +27 -0
  41. package/dist/relation.d.ts.map +1 -0
  42. package/dist/traverse.d.ts +12 -0
  43. package/dist/traverse.d.ts.map +1 -0
  44. package/dist/validate.d.ts +14 -0
  45. package/dist/validate.d.ts.map +1 -0
  46. package/lineage.schema.json +625 -0
  47. package/package.json +71 -0
  48. package/src/activity.ts +65 -0
  49. package/src/approval.ts +28 -0
  50. package/src/builder.ts +129 -0
  51. package/src/common.ts +58 -0
  52. package/src/confidence.ts +72 -0
  53. package/src/derivation.ts +81 -0
  54. package/src/document.ts +82 -0
  55. package/src/entity.ts +87 -0
  56. package/src/fields.ts +163 -0
  57. package/src/index.ts +123 -0
  58. package/src/labels.ts +13 -0
  59. package/src/profile/grounding.ts +74 -0
  60. package/src/profile/index.ts +67 -0
  61. package/src/profile/labels.ts +28 -0
  62. package/src/profile/recognition.ts +149 -0
  63. package/src/profile/transform-validation.ts +1379 -0
  64. package/src/prov.ts +205 -0
  65. package/src/relation.ts +32 -0
  66. package/src/traverse.ts +91 -0
  67. package/src/validate.ts +221 -0
@@ -0,0 +1,10 @@
1
+ import type { Activity } from '../activity.js';
2
+ /**
3
+ * Display label for an OpenParser activity: an explicit `name` when a producer
4
+ * set one, otherwise a label for known types, otherwise the raw type.
5
+ *
6
+ * `type` is an open string, so unknown types render as themselves rather than
7
+ * being hidden behind a placeholder.
8
+ */
9
+ export declare function activityLabel(activity: Activity): string;
10
+ //# sourceMappingURL=labels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/profile/labels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAkB5C;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAExD"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * How a value's recognition score is derived from the OCR words behind it.
3
+ *
4
+ * This is a profile rule, not part of `lineage@1`: the protocol says a score has
5
+ * a scale, a scope, and a named method, and stays silent on what any particular
6
+ * method computes. It ships beside the protocol because a producer and a consumer
7
+ * that disagree here disagree about what a number means. A region cited by two
8
+ * fields is read once but quoted differently by each, so scoring the region and
9
+ * scoring a value are different questions — and answering the second with the
10
+ * first is how a crisply scanned number ends up wearing its neighbor's bad
11
+ * handwriting.
12
+ */
13
+ /** An OCR token with its recognition score, and whether a value was read from it. */
14
+ export type ScoredWord = {
15
+ id?: string;
16
+ text: string;
17
+ confidence: number;
18
+ cited?: boolean;
19
+ };
20
+ export declare const CITED_RECOGNITION_METHOD = "cited_minimum_context_downblend";
21
+ /** Scoring a whole region, because no word within it could be narrowed to. */
22
+ export declare const REGION_RECOGNITION_METHOD = "region_word_minimum";
23
+ /** How far the surrounding text may pull a cited score down. */
24
+ export declare const CONTEXT_BLEND_WEIGHT = 0.15;
25
+ /**
26
+ * Blend a cited-word minimum with the surrounding context: weaker context may
27
+ * only pull the score down, and never below what the blend allows. A noisy
28
+ * neighborhood is evidence that a value might be misread, not a verdict that it
29
+ * was.
30
+ */
31
+ export declare function downwardBlendCitedMinimum(citedMin: number, contextMean: number | undefined): number;
32
+ export type CitedWordAggregate = {
33
+ score: number;
34
+ minimum: number;
35
+ maximum: number;
36
+ sampleCount: number;
37
+ method: typeof CITED_RECOGNITION_METHOD | typeof REGION_RECOGNITION_METHOD;
38
+ contextMean?: number;
39
+ contextSampleCount?: number;
40
+ };
41
+ /**
42
+ * Score one value from the words it was read from, discounted by the words
43
+ * around it. With nothing marked cited there is nothing to narrow to, so every
44
+ * word counts, the result is the region's own weakest token, and `method` says
45
+ * so — a score over the whole region must not claim to have narrowed to a value.
46
+ */
47
+ export declare function aggregateCitedWordConfidences(words: readonly ScoredWord[]): CitedWordAggregate | undefined;
48
+ /** First candidate found in the text wins; pass candidates in priority order. */
49
+ export declare function citedSpanInText(regionText: string, candidates: ReadonlyArray<string | undefined>): {
50
+ start: number;
51
+ end: number;
52
+ };
53
+ /**
54
+ * Mark the words a value was read from within a region.
55
+ *
56
+ * `extractedText` is what the extraction produced, which is always text present
57
+ * in the document: for a value returned as-is it is the value itself, and for one
58
+ * the model went on to rewrite — `2024-05-30` from `MAY 30, 2024` — it is the text
59
+ * that was actually read. Searching for the value instead would find nothing in
60
+ * the second case. `lineageWordTexts`/`lineageWordIds` name words a lineage
61
+ * document already attributes to the value, used when no span matches.
62
+ */
63
+ export declare function annotateWordsWithCitation<T extends ScoredWord>(regionText: string, words: readonly T[], options?: {
64
+ extractedText?: string;
65
+ lineageWordTexts?: ReadonlySet<string>;
66
+ lineageWordIds?: ReadonlySet<string>;
67
+ }): Array<T & {
68
+ cited: boolean;
69
+ }>;
70
+ //# sourceMappingURL=recognition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recognition.d.ts","sourceRoot":"","sources":["../../src/profile/recognition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,qFAAqF;AACrF,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,wBAAwB,oCAAoC,CAAC;AAE1E,8EAA8E;AAC9E,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D,gEAAgE;AAChE,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,MAAM,CAIR;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,wBAAwB,GAAG,OAAO,yBAAyB,CAAC;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,SAAS,UAAU,EAAE,GAC3B,kBAAkB,GAAG,SAAS,CAoBhC;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC,GAC5C;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAUhC;AAkBD;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,UAAU,EAC5D,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,OAAO,CAAC,EAAE;IACR,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACtC,GACA,KAAK,CAAC,CAAC,GAAG;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAc/B"}
@@ -0,0 +1,250 @@
1
+ import { z } from 'zod';
2
+ export declare const TRANSFORM_VERIFICATION_DOCS = "https://docs.openparser.dev/lineage/openparser/transform-verification";
3
+ export declare const TRANSFORM_PROOF_ATTRIBUTE = "openparser:transformProof";
4
+ export declare const MAX_TRANSFORM_PROOF_BYTES = 2048;
5
+ /** Admission budget so a newly accepted policy can always serialize inside a 2 KiB proof. */
6
+ export declare const MAX_TRANSFORM_INTENT_PARAMETER_BYTES = 1024;
7
+ export declare const TRANSFORM_DOCS_ANCHORS: readonly ["date-time-format", "numeric-format", "quantity-magnitude", "unit-conversion", "currency-code", "boolean-alias", "text-normalization", "enum-alias"];
8
+ export type TransformDocsAnchor = (typeof TRANSFORM_DOCS_ANCHORS)[number];
9
+ export declare const TransformProofClassSchema: z.ZodEnum<{
10
+ safe_equivalence: "safe_equivalence";
11
+ exact_conversion: "exact_conversion";
12
+ policy_application: "policy_application";
13
+ }>;
14
+ export type TransformProofClass = z.infer<typeof TransformProofClassSchema>;
15
+ export type DateTimeKind = 'date' | 'date-time' | 'time';
16
+ export declare function dateTimeFormatIssue(kind: DateTimeKind, sourceFormats: string[], targetFormat: string): string | undefined;
17
+ /**
18
+ * Built-in Luxon source formats for format-only JSON Schema `date` / `date-time` /
19
+ * `time` intent. Versioned independently of `openparser.transform.date-time-format.v1`
20
+ * so accepted sources can grow without rewriting already-emitted proofs.
21
+ *
22
+ * v1 selection is conservative and not demo-specific:
23
+ * - ISO 8601 calendar date and the matching offset-bearing ISO date-time/time forms
24
+ * - Unambiguous year-first numeric calendar dates
25
+ * - Explicit English civil date families (day-first and US month-first, full or
26
+ * abbreviated month names, and "N day of Month Year")
27
+ *
28
+ * Locale-ambiguous numeric day/month orders (`MM/dd/yyyy`, `dd/MM/yyyy`, …),
29
+ * two-digit years, weekday-prefixed forms, and natural-language parsers are
30
+ * omitted. A claim `source_format` may only prioritize a catalog member; it
31
+ * cannot add omitted forms or shrink the candidate set.
32
+ */
33
+ export declare const DATE_SOURCE_CATALOG_ID: "openparser.transform.date-source-catalog";
34
+ export declare const DATE_SOURCE_CATALOG_VERSION: 1;
35
+ export declare const FORMAT_ONLY_DATE_TARGETS: {
36
+ readonly date: "yyyy-MM-dd";
37
+ readonly 'date-time': "yyyy-MM-dd'T'HH:mm:ssZZ";
38
+ readonly time: "HH:mm:ssZZ";
39
+ };
40
+ export declare const DATE_SOURCE_CATALOG_V1: Record<DateTimeKind, readonly string[]>;
41
+ export declare function trustedDateSourceFormats(kind: DateTimeKind, targetFormat?: string): string[];
42
+ export declare function formatOnlyDateTimeParameters(kind: DateTimeKind): {
43
+ kind: DateTimeKind;
44
+ sourceFormats: string[];
45
+ targetFormat: "yyyy-MM-dd" | "yyyy-MM-dd'T'HH:mm:ssZZ" | "HH:mm:ssZZ";
46
+ locale: string;
47
+ zonePolicy: "civil" | "preserve";
48
+ sourceCatalog: {
49
+ id: "openparser.transform.date-source-catalog";
50
+ version: 1;
51
+ };
52
+ };
53
+ export declare const TransformIntentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
54
+ operation: z.ZodLiteral<"date_time_format">;
55
+ parameters: z.ZodObject<{
56
+ kind: z.ZodEnum<{
57
+ date: "date";
58
+ time: "time";
59
+ "date-time": "date-time";
60
+ }>;
61
+ sourceFormats: z.ZodDefault<z.ZodArray<z.ZodString>>;
62
+ targetFormat: z.ZodString;
63
+ locale: z.ZodDefault<z.ZodString>;
64
+ zonePolicy: z.ZodDefault<z.ZodEnum<{
65
+ civil: "civil";
66
+ preserve: "preserve";
67
+ utc: "utc";
68
+ named: "named";
69
+ }>>;
70
+ zone: z.ZodOptional<z.ZodString>;
71
+ sourceCatalog: z.ZodOptional<z.ZodObject<{
72
+ id: z.ZodLiteral<"openparser.transform.date-source-catalog">;
73
+ version: z.ZodLiteral<1>;
74
+ }, z.core.$strict>>;
75
+ }, z.core.$strict>;
76
+ }, z.core.$strict>, z.ZodObject<{
77
+ operation: z.ZodLiteral<"numeric_format">;
78
+ parameters: z.ZodObject<{
79
+ decimalSeparator: z.ZodDefault<z.ZodEnum<{
80
+ ",": ",";
81
+ ".": ".";
82
+ }>>;
83
+ groupingSeparator: z.ZodOptional<z.ZodEnum<{
84
+ ",": ",";
85
+ ".": ".";
86
+ " ": " ";
87
+ "\u00A0": " ";
88
+ }>>;
89
+ prefixes: z.ZodDefault<z.ZodArray<z.ZodString>>;
90
+ suffixes: z.ZodDefault<z.ZodArray<z.ZodString>>;
91
+ accountingParentheses: z.ZodDefault<z.ZodBoolean>;
92
+ }, z.core.$strict>;
93
+ }, z.core.$strict>, z.ZodObject<{
94
+ operation: z.ZodLiteral<"quantity_magnitude">;
95
+ parameters: z.ZodObject<{
96
+ allowedUnits: z.ZodRecord<z.ZodString, z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>>;
97
+ targetUnit: z.ZodString;
98
+ }, z.core.$strict>;
99
+ }, z.core.$strict>, z.ZodObject<{
100
+ operation: z.ZodLiteral<"unit_conversion">;
101
+ parameters: z.ZodObject<{
102
+ sourceUnits: z.ZodArray<z.ZodString>;
103
+ targetUnit: z.ZodString;
104
+ }, z.core.$strict>;
105
+ }, z.core.$strict>, z.ZodObject<{
106
+ operation: z.ZodLiteral<"currency_code">;
107
+ parameters: z.ZodObject<{
108
+ acceptedCodes: z.ZodArray<z.ZodString>;
109
+ aliases: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>>>;
110
+ symbolMap: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>>>;
111
+ }, z.core.$strict>;
112
+ }, z.core.$strict>, z.ZodObject<{
113
+ operation: z.ZodLiteral<"boolean_alias">;
114
+ parameters: z.ZodObject<{
115
+ aliases: z.ZodRecord<z.ZodString, z.ZodType<boolean, unknown, z.core.$ZodTypeInternals<boolean, unknown>>>;
116
+ caseSensitive: z.ZodDefault<z.ZodBoolean>;
117
+ }, z.core.$strict>;
118
+ }, z.core.$strict>, z.ZodObject<{
119
+ operation: z.ZodLiteral<"text_normalization">;
120
+ parameters: z.ZodObject<{
121
+ operations: z.ZodArray<z.ZodEnum<{
122
+ trim: "trim";
123
+ lowercase: "lowercase";
124
+ uppercase: "uppercase";
125
+ collapse_whitespace: "collapse_whitespace";
126
+ nfkc: "nfkc";
127
+ }>>;
128
+ locale: z.ZodDefault<z.ZodString>;
129
+ }, z.core.$strict>;
130
+ }, z.core.$strict>, z.ZodObject<{
131
+ operation: z.ZodLiteral<"enum_alias">;
132
+ parameters: z.ZodObject<{
133
+ aliases: z.ZodRecord<z.ZodString, z.ZodType<string | number, unknown, z.core.$ZodTypeInternals<string | number, unknown>>>;
134
+ caseSensitive: z.ZodDefault<z.ZodBoolean>;
135
+ }, z.core.$strict>;
136
+ }, z.core.$strict>], "operation">;
137
+ export type TransformIntent = z.infer<typeof TransformIntentSchema>;
138
+ export type TransformOperation = TransformIntent['operation'];
139
+ export declare const TRANSFORM_OPERATIONS: readonly ["date_time_format", "numeric_format", "quantity_magnitude", "unit_conversion", "currency_code", "boolean_alias", "text_normalization", "enum_alias"];
140
+ export declare const TransformClaimSchema: z.ZodObject<{
141
+ operation: z.ZodEnum<{
142
+ "": "";
143
+ date_time_format: "date_time_format";
144
+ numeric_format: "numeric_format";
145
+ quantity_magnitude: "quantity_magnitude";
146
+ unit_conversion: "unit_conversion";
147
+ currency_code: "currency_code";
148
+ boolean_alias: "boolean_alias";
149
+ text_normalization: "text_normalization";
150
+ enum_alias: "enum_alias";
151
+ }>;
152
+ parameters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
153
+ reason: z.ZodString;
154
+ confidence: z.ZodEnum<{
155
+ "": "";
156
+ low: "low";
157
+ medium: "medium";
158
+ high: "high";
159
+ }>;
160
+ }, z.core.$strict>;
161
+ export type TransformClaim = z.infer<typeof TransformClaimSchema>;
162
+ export declare const TRANSFORM_PROOF_OPERAND_KEYS: readonly ["bounded", "canonical", "magnitude", "mappedValue", "matchedSourceFormat", "output", "outputCode", "outputDecimal", "outputHash", "policyHash", "resolvedCode", "sourceDecimal", "sourceHash", "sourceMagnitude", "sourceUnit", "targetMagnitude", "targetUnit"];
163
+ export declare const TransformProofHashSchema: z.ZodObject<{
164
+ algorithm: z.ZodLiteral<"sha256">;
165
+ digest: z.ZodString;
166
+ }, z.core.$strict>;
167
+ export declare const TransformProofOperandValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodObject<{
168
+ algorithm: z.ZodLiteral<"sha256">;
169
+ digest: z.ZodString;
170
+ }, z.core.$strict>]>;
171
+ export declare function isTrustedTransformDocsHref(href: string): boolean;
172
+ export declare function trustedTransformDocsHref(methodId?: string): string;
173
+ export declare function trustedIntentParametersFitProof(parameters: unknown): boolean;
174
+ export declare const TransformProofSchema: z.ZodObject<{
175
+ methodId: z.ZodString;
176
+ methodVersion: z.ZodNumber;
177
+ result: z.ZodEnum<{
178
+ verified: "verified";
179
+ contradicted: "contradicted";
180
+ not_applicable: "not_applicable";
181
+ }>;
182
+ proofClass: z.ZodEnum<{
183
+ safe_equivalence: "safe_equivalence";
184
+ exact_conversion: "exact_conversion";
185
+ policy_application: "policy_application";
186
+ }>;
187
+ scope: z.ZodString;
188
+ trustedParameters: z.ZodRecord<z.ZodString, z.ZodType<string | number | boolean | z.core.util.JSONType[] | {
189
+ [key: string]: z.core.util.JSONType;
190
+ } | null, unknown, z.core.$ZodTypeInternals<string | number | boolean | z.core.util.JSONType[] | {
191
+ [key: string]: z.core.util.JSONType;
192
+ } | null, unknown>>>;
193
+ operands: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<string | number | boolean | {
194
+ algorithm: "sha256";
195
+ digest: string;
196
+ }, unknown, z.core.$ZodTypeInternals<string | number | boolean | {
197
+ algorithm: "sha256";
198
+ digest: string;
199
+ }, unknown>>>>;
200
+ checks: z.ZodRecord<z.ZodString, z.ZodType<boolean, unknown, z.core.$ZodTypeInternals<boolean, unknown>>>;
201
+ implementation: z.ZodObject<{
202
+ library: z.ZodString;
203
+ version: z.ZodString;
204
+ runtime: z.ZodOptional<z.ZodString>;
205
+ locale: z.ZodOptional<z.ZodString>;
206
+ zone: z.ZodOptional<z.ZodString>;
207
+ }, z.core.$strict>;
208
+ limitations: z.ZodString;
209
+ docsHref: z.ZodString;
210
+ }, z.core.$strict>;
211
+ export type TransformProof = z.infer<typeof TransformProofSchema>;
212
+ export declare function parseTransformProof(value: unknown): TransformProof | undefined;
213
+ export type TransformVerificationResult = {
214
+ result: TransformProof['result'];
215
+ proof: TransformProof;
216
+ };
217
+ export type TransformValidatorDescriptor = {
218
+ operation: TransformOperation;
219
+ methodId: string;
220
+ version: number;
221
+ label: string;
222
+ summary: string;
223
+ docsAnchor: TransformDocsAnchor;
224
+ acceptedSourceTypes: readonly string[];
225
+ acceptedOutputTypes: readonly string[];
226
+ proofClass: TransformProofClass;
227
+ parameterSchema: z.ZodType;
228
+ parameterJsonSchema: Record<string, unknown>;
229
+ library: {
230
+ name: string;
231
+ version: string;
232
+ };
233
+ limitations: string;
234
+ verify(input: {
235
+ quote: string;
236
+ output: unknown;
237
+ parameters: unknown;
238
+ preferredSourceFormat?: string;
239
+ }): TransformVerificationResult;
240
+ };
241
+ export declare const TRANSFORM_VALIDATORS: readonly [TransformValidatorDescriptor, TransformValidatorDescriptor, TransformValidatorDescriptor, TransformValidatorDescriptor, TransformValidatorDescriptor, TransformValidatorDescriptor, TransformValidatorDescriptor, TransformValidatorDescriptor];
242
+ export declare function transformValidatorDescriptor(operation: TransformOperation): TransformValidatorDescriptor;
243
+ /** Verify only the validator selected by trusted request intent. Model claims never authorize it. */
244
+ export declare function verifyTransform(input: {
245
+ quote: string;
246
+ output: unknown;
247
+ intent: TransformIntent;
248
+ claim?: TransformClaim;
249
+ }): TransformVerificationResult;
250
+ //# sourceMappingURL=transform-validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-validation.d.ts","sourceRoot":"","sources":["../../src/profile/transform-validation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,2BAA2B,0EACiC,CAAC;AAC1E,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AACrE,eAAO,MAAM,yBAAyB,OAAQ,CAAC;AAC/C,6FAA6F;AAC7F,eAAO,MAAM,oCAAoC,OAAQ,CAAC;AAE1D,eAAO,MAAM,sBAAsB,gKASzB,CAAC;AACX,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1E,eAAO,MAAM,yBAAyB;;;;EAIpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC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M,EAAE,OAAO,CAAC;QAChB,UAAU,EAAE,OAAO,CAAC;QACpB,qBAAqB,CAAC,EAAE,MAAM,CAAC;KAChC,GAAG,2BAA2B,CAAC;CACjC,CAAC;AA2sBF,eAAO,MAAM,oBAAoB,2PAS2B,CAAC;AAM7D,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,kBAAkB,GAC5B,4BAA4B,CAE9B;AAQD,qGAAqG;AACrG,wBAAgB,eAAe,CAAC,KAAK,EAAE;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB,GAAG,2BAA2B,CAU9B"}
package/dist/prov.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ import type { LineageDocument } from './document.js';
2
+ /**
3
+ * Subset of W3C PROV-JSON used for interoperability export.
4
+ *
5
+ * Note: PROV-JSON itself is a W3C Member Submission
6
+ * (https://www.w3.org/Submission/2013/SUBM-prov-json-20130424/).
7
+ * The conceptual model is PROV-DM, a W3C Recommendation
8
+ * (https://www.w3.org/TR/prov-dm/).
9
+ */
10
+ export type ProvJsonDocument = {
11
+ prefix?: Record<string, string>;
12
+ entity?: Record<string, Record<string, unknown>>;
13
+ activity?: Record<string, Record<string, unknown>>;
14
+ agent?: Record<string, Record<string, unknown>>;
15
+ wasDerivedFrom?: Record<string, Record<string, unknown>>;
16
+ wasGeneratedBy?: Record<string, Record<string, unknown>>;
17
+ used?: Record<string, Record<string, unknown>>;
18
+ wasAssociatedWith?: Record<string, Record<string, unknown>>;
19
+ wasAttributedTo?: Record<string, Record<string, unknown>>;
20
+ hadMember?: Record<string, Record<string, unknown>>;
21
+ specializationOf?: Record<string, Record<string, unknown>>;
22
+ alternateOf?: Record<string, Record<string, unknown>>;
23
+ };
24
+ /**
25
+ * Where the `lineage@1` vocabulary is published, so PROV consumers can resolve
26
+ * the `lineage:` prefix. It names the format, not a producer — a document emitted
27
+ * by anyone binds the same prefix. Moving it breaks every consumer that has
28
+ * already resolved a term against it, so it is versioned with the format itself.
29
+ */
30
+ export declare const LINEAGE_PROV_NAMESPACE = "https://openparser.dev/ns/lineage#";
31
+ export declare function lineageIdToProvQualifiedName(id: string): string;
32
+ /**
33
+ * Map a validated `lineage@1` document to W3C PROV-JSON concepts.
34
+ *
35
+ * Derivations expand to `wasDerivedFrom` (per input), `wasGeneratedBy`
36
+ * (output ← activity), and `used` (activity ← input). Associations,
37
+ * attributions, and membership follow PROV relations.
38
+ */
39
+ export declare function toProvJson(doc: LineageDocument): ProvJsonDocument;
40
+ //# sourceMappingURL=prov.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prov.d.ts","sourceRoot":"","sources":["../src/prov.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACzD,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5D,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpD,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,uCAAuC,CAAC;AAE3E,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAK/D;AAGD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,eAAe,GAAG,gBAAgB,CA0IjE"}
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ export declare const RELATION_TYPES: readonly ["member_of", "specialization_of", "alternate_of"];
3
+ export declare const RelationTypeSchema: z.ZodEnum<{
4
+ member_of: "member_of";
5
+ specialization_of: "specialization_of";
6
+ alternate_of: "alternate_of";
7
+ }>;
8
+ export type RelationType = z.infer<typeof RelationTypeSchema>;
9
+ /**
10
+ * Semantic entity–entity relations outside the derivation DAG.
11
+ *
12
+ * - `member_of`: `source` is a member; `target` must be a `collection` entity
13
+ * - `specialization_of`: `source` specializes `target` (PROV specializationOf)
14
+ * - `alternate_of`: `source` and `target` are alternate of each other
15
+ */
16
+ export declare const RelationSchema: z.ZodObject<{
17
+ type: z.ZodEnum<{
18
+ member_of: "member_of";
19
+ specialization_of: "specialization_of";
20
+ alternate_of: "alternate_of";
21
+ }>;
22
+ source: z.ZodString;
23
+ target: z.ZodString;
24
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
25
+ }, z.core.$strict>;
26
+ export type Relation = z.infer<typeof RelationSchema>;
27
+ //# sourceMappingURL=relation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relation.d.ts","sourceRoot":"","sources":["../src/relation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,cAAc,6DAA8D,CAAC;AAC1F,eAAO,MAAM,kBAAkB;;;;EAAyB,CAAC;AACzD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;;;kBAgBvB,CAAC;AACL,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { LineageDocument } from './document.js';
2
+ /**
3
+ * Topological order of entity ids following derivation dependencies
4
+ * (inputs before outputs). Stable for disconnected nodes by insertion order
5
+ * of `Object.keys(entities)`.
6
+ */
7
+ export declare function topologicalEntityOrder(doc: LineageDocument): string[];
8
+ /** All entities reachable upstream via derivation inputs (transitive). */
9
+ export declare function entityAncestors(doc: LineageDocument, entityId: string): string[];
10
+ /** All entities reachable downstream via derivation outputs (transitive). */
11
+ export declare function entityDescendants(doc: LineageDocument, entityId: string): string[];
12
+ //# sourceMappingURL=traverse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traverse.d.ts","sourceRoot":"","sources":["../src/traverse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA8BlD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,EAAE,CA8BrE;AAiBD,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAEhF;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAElF"}
@@ -0,0 +1,14 @@
1
+ import type { LineageDocument } from './document.js';
2
+ export declare class LineageValidationError extends Error {
3
+ readonly issues: string[];
4
+ constructor(issues: string[]);
5
+ }
6
+ /**
7
+ * Strict graph validation beyond Zod shape checks.
8
+ *
9
+ * Ensures globally distinct ids, resolvable references, unique derivation
10
+ * outputs (one producer), no self-inputs, acyclic entity dependencies,
11
+ * valid collection membership, and coherent activity timestamps.
12
+ */
13
+ export declare function validateLineageGraph(doc: LineageDocument): void;
14
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;gBAEd,MAAM,EAAE,MAAM,EAAE;CAK7B;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI,CAwM/D"}