@bsv/dpp-profiles 0.3.0-beta.1

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 (96) hide show
  1. package/LICENSE +58 -0
  2. package/README.md +64 -0
  3. package/dist/applicability.d.ts +96 -0
  4. package/dist/applicability.d.ts.map +1 -0
  5. package/dist/applicability.js +181 -0
  6. package/dist/applicability.js.map +1 -0
  7. package/dist/combinations.d.ts +30 -0
  8. package/dist/combinations.d.ts.map +1 -0
  9. package/dist/combinations.js +103 -0
  10. package/dist/combinations.js.map +1 -0
  11. package/dist/evidence-shapes.d.ts +198 -0
  12. package/dist/evidence-shapes.d.ts.map +1 -0
  13. package/dist/evidence-shapes.js +123 -0
  14. package/dist/evidence-shapes.js.map +1 -0
  15. package/dist/gs1-epc-binary.d.ts +81 -0
  16. package/dist/gs1-epc-binary.d.ts.map +1 -0
  17. package/dist/gs1-epc-binary.js +252 -0
  18. package/dist/gs1-epc-binary.js.map +1 -0
  19. package/dist/gs1-resolution.d.ts +392 -0
  20. package/dist/gs1-resolution.d.ts.map +1 -0
  21. package/dist/gs1-resolution.js +696 -0
  22. package/dist/gs1-resolution.js.map +1 -0
  23. package/dist/identifiers.d.ts +57 -0
  24. package/dist/identifiers.d.ts.map +1 -0
  25. package/dist/identifiers.js +117 -0
  26. package/dist/identifiers.js.map +1 -0
  27. package/dist/index.d.ts +235 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +124 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/manifest-v2.d.ts +87 -0
  32. package/dist/manifest-v2.d.ts.map +1 -0
  33. package/dist/manifest-v2.js +31 -0
  34. package/dist/manifest-v2.js.map +1 -0
  35. package/dist/mapping.d.ts +84 -0
  36. package/dist/mapping.d.ts.map +1 -0
  37. package/dist/mapping.js +88 -0
  38. package/dist/mapping.js.map +1 -0
  39. package/dist/projections.d.ts +233 -0
  40. package/dist/projections.d.ts.map +1 -0
  41. package/dist/projections.js +466 -0
  42. package/dist/projections.js.map +1 -0
  43. package/frozen.json +42 -0
  44. package/generated/consumer/battery-v2.json +2248 -0
  45. package/generated/consumer/battery-v3.json +4354 -0
  46. package/generated/consumer/general-v1.json +9 -0
  47. package/generated/consumer/general-v2.json +714 -0
  48. package/generated/consumer/textile-v1.json +101 -0
  49. package/generated/consumer/textile-v2.json +1033 -0
  50. package/generated/consumer/textile-v3.json +2011 -0
  51. package/generated/index.json +86 -0
  52. package/generated/mapping/battery@2.md +116 -0
  53. package/generated/mapping/battery@3.md +130 -0
  54. package/generated/mapping/general@2.md +50 -0
  55. package/generated/mapping/textile@2.md +61 -0
  56. package/generated/mapping/textile@3.md +73 -0
  57. package/generated/payload-schema/battery@2.public.schema.json +609 -0
  58. package/generated/payload-schema/battery@2.restricted.schema.json +377 -0
  59. package/generated/payload-schema/battery@3.public.schema.json +1364 -0
  60. package/generated/payload-schema/battery@3.restricted.schema.json +1097 -0
  61. package/generated/payload-schema/general@1.public.schema.json +37 -0
  62. package/generated/payload-schema/general@1.restricted.schema.json +9 -0
  63. package/generated/payload-schema/general@2.public.schema.json +352 -0
  64. package/generated/payload-schema/general@2.restricted.schema.json +52 -0
  65. package/generated/payload-schema/textile@1.public.schema.json +82 -0
  66. package/generated/payload-schema/textile@1.restricted.schema.json +22 -0
  67. package/generated/payload-schema/textile@2.public.schema.json +464 -0
  68. package/generated/payload-schema/textile@2.restricted.schema.json +78 -0
  69. package/generated/payload-schema/textile@3.public.schema.json +1299 -0
  70. package/generated/payload-schema/textile@3.restricted.schema.json +78 -0
  71. package/manifests/battery@2.json +4047 -0
  72. package/manifests/battery@3.json +6164 -0
  73. package/manifests/exchange/untp-0.7.0-jose@1.json +191 -0
  74. package/manifests/exchange/vc-di-ecdsa-rdfc-2019@1.json +74 -0
  75. package/manifests/exchange/vsc-draft-compat@0.1.0.json +64 -0
  76. package/manifests/general@1.json +148 -0
  77. package/manifests/general@2.json +1266 -0
  78. package/manifests/interoperability/epcis-json@1.json +69 -0
  79. package/manifests/interoperability/epcis-vsc@1.json +64 -0
  80. package/manifests/interoperability/gs1-digital-link@1.json +71 -0
  81. package/manifests/operator/federated-operators@1.json +54 -0
  82. package/manifests/operator/single-operator@1.json +52 -0
  83. package/manifests/textile@1.json +383 -0
  84. package/manifests/textile@2.json +1682 -0
  85. package/manifests/textile@3.json +2763 -0
  86. package/package.json +59 -0
  87. package/schemas/exchange-profile.schema.json +134 -0
  88. package/schemas/gs1/NOTICE.md +11 -0
  89. package/schemas/gs1/resolver-description-file-schema-1.2.0.json +124 -0
  90. package/schemas/gs1/resolver-linkset-context-1.2.1.jsonld +39 -0
  91. package/schemas/gs1/resolver-linkset-schema-1.2.1.json +96 -0
  92. package/schemas/interoperability-profile.schema.json +347 -0
  93. package/schemas/operator-profile.schema.json +108 -0
  94. package/schemas/product-identity.schema.json +45 -0
  95. package/schemas/profile-manifest-v2.schema.json +1087 -0
  96. package/schemas/profile-manifest.schema.json +291 -0
@@ -0,0 +1,87 @@
1
+ import type { Granularity, ProfileField, ProfileManifest, ValueType } from './index.js';
2
+ import type { DatePrecision } from './evidence-shapes.js';
3
+ /** The applicability rule of a version 2 field. `always`, `category-in` and `needs-review` keep their version 1 meaning. */
4
+ export type ApplicabilityRuleV2 = {
5
+ rule: 'always';
6
+ } | {
7
+ rule: 'category-in';
8
+ categories: string[];
9
+ } | {
10
+ rule: 'needs-review';
11
+ condition: string;
12
+ categories?: string[];
13
+ } | {
14
+ rule: 'all' | 'any';
15
+ rules: ApplicabilityRuleV2[];
16
+ } | {
17
+ rule: 'jurisdiction-in';
18
+ jurisdictions: string[];
19
+ } | {
20
+ rule: 'effective';
21
+ from?: string;
22
+ until?: string;
23
+ } | {
24
+ rule: 'threshold';
25
+ field: string;
26
+ operator: 'gt' | 'gte' | 'lt' | 'lte' | 'eq';
27
+ value: number;
28
+ unit?: string;
29
+ } | {
30
+ rule: 'unresolved';
31
+ reason: string;
32
+ source?: string;
33
+ };
34
+ export type ValueTypeV2 = ValueType | 'measurement' | 'certification' | 'claimEvidence' | 'localisedText' | 'relatedDocument' | 'warrantyTerms';
35
+ /**
36
+ * What asks for a field's value and how settled that is; separate from the
37
+ * profile's own `obligation` and from the instrument `legalBasis` names.
38
+ * `not-to-be-displayed` is a positive statement from guidance that the value
39
+ * is not to be filled or shown as of the effective date; a consumer never
40
+ * shows such a field as required.
41
+ */
42
+ export interface RequirementStatus {
43
+ /** `none`: no instrument or guidance asks for the value; the obligation is the profile's own. */
44
+ status: 'enacted' | 'guidance' | 'anticipated' | 'needs-review' | 'not-to-be-displayed' | 'none';
45
+ source: string;
46
+ clause?: string;
47
+ effectiveDate?: string;
48
+ note?: string;
49
+ }
50
+ export interface ProfileFieldV2 extends Omit<ProfileField, 'valueType' | 'applicability'> {
51
+ valueType: ValueTypeV2;
52
+ applicability: ApplicabilityRuleV2;
53
+ requirement: RequirementStatus;
54
+ precision?: DatePrecision;
55
+ scope?: Granularity | 'component';
56
+ componentScoped?: boolean;
57
+ /** A batch or item source may carry a value that takes precedence over the model's, under the named policy. Absent means a conflict, never an override. */
58
+ overridable?: {
59
+ at: 'batch' | 'item';
60
+ policy: string;
61
+ };
62
+ }
63
+ export type MigrationOutcome = 'unchanged' | 'renamed' | 'retyped' | 'split' | 'new' | 'withdrawn' | 'relabelled';
64
+ export interface ProfileManifestV2 extends Omit<ProfileManifest, 'manifestVersion' | 'fields'> {
65
+ manifestVersion: '2';
66
+ fields: ProfileFieldV2[];
67
+ succession?: {
68
+ of: string;
69
+ migration: Array<{
70
+ from: string;
71
+ to?: string;
72
+ outcome: MigrationOutcome;
73
+ note: string;
74
+ }>;
75
+ };
76
+ }
77
+ export type AnyProfileManifest = ProfileManifest | ProfileManifestV2;
78
+ export type AnyProfileField = ProfileField | ProfileFieldV2;
79
+ export declare function isManifestV2(manifest: AnyProfileManifest): manifest is ProfileManifestV2;
80
+ export declare function isFieldV2(field: AnyProfileField): field is ProfileFieldV2;
81
+ /**
82
+ * The manifest of any published profile, version 1 or 2, by its `id@version`.
83
+ * The identifier is checked against the manifest grammar before it names a
84
+ * file, so nothing outside `manifests/` can be read through it.
85
+ */
86
+ export declare function readManifestAny(profile: string): AnyProfileManifest;
87
+ //# sourceMappingURL=manifest-v2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-v2.d.ts","sourceRoot":"","sources":["../src/manifest-v2.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEzD,4HAA4H;AAC5H,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAClE;IAAE,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;IAAC,KAAK,EAAE,mBAAmB,EAAE,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAChH;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,E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AS,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,EAAE,CAAC,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,gBAAgB,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAA;CACtH;AAED,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG,iBAAiB,CAAA;AACpE,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,cAAc,CAAA;AAE3D,wBAAgB,YAAY,CAAC,QAAQ,EAAE,kBAAkB,GAAG,QAAQ,IAAI,iBAAiB,CAExF;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK,IAAI,cAAc,CAEzE;AAID;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAKnE"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Manifest version 2 (`schemas/profile-manifest-v2.schema.json`,
3
+ * `spec/passport-projections.md` §6): everything version 1 declares, plus a
4
+ * requirement status per field, a composable applicability rule that can say
5
+ * `unresolved`, date precision, subject scope, override declarations, the
6
+ * shared evidence value types and a succession record. A version 1 manifest
7
+ * is read as it always was; `readManifestAny` returns whichever version a
8
+ * published manifest declares, and a reader branches on `manifestVersion`.
9
+ */
10
+ import { readFileSync } from 'node:fs';
11
+ export function isManifestV2(manifest) {
12
+ return manifest.manifestVersion === '2';
13
+ }
14
+ export function isFieldV2(field) {
15
+ return field.requirement != null;
16
+ }
17
+ const packageRoot = new URL('../', import.meta.url);
18
+ /**
19
+ * The manifest of any published profile, version 1 or 2, by its `id@version`.
20
+ * The identifier is checked against the manifest grammar before it names a
21
+ * file, so nothing outside `manifests/` can be read through it.
22
+ */
23
+ export function readManifestAny(profile) {
24
+ if (!/^[a-z][a-z0-9-]*@[0-9]+$/.test(profile))
25
+ throw new Error(`${profile} is not a profile identifier of the form id@version`);
26
+ const manifest = JSON.parse(readFileSync(new URL(`manifests/${profile}.json`, packageRoot), 'utf8'));
27
+ if (manifest.manifestVersion !== '1' && manifest.manifestVersion !== '2')
28
+ throw new Error(`${profile} declares manifest version ${String(manifest.manifestVersion)}, which this reader does not implement`);
29
+ return manifest;
30
+ }
31
+ //# sourceMappingURL=manifest-v2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-v2.js","sourceRoot":"","sources":["../src/manifest-v2.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAuDtC,MAAM,UAAU,YAAY,CAAC,QAA4B;IACvD,OAAO,QAAQ,CAAC,eAAe,KAAK,GAAG,CAAA;AACzC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAsB;IAC9C,OAAQ,KAAwB,CAAC,WAAW,IAAI,IAAI,CAAA;AACtD,CAAC;AAED,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAEnD;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,qDAAqD,CAAC,CAAA;IAC/H,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,aAAa,OAAO,OAAO,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,CAAuB,CAAA;IAC1H,IAAI,QAAQ,CAAC,eAAe,KAAK,GAAG,IAAI,QAAQ,CAAC,eAAe,KAAK,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,8BAA8B,MAAM,CAAE,QAAyC,CAAC,eAAe,CAAC,wCAAwC,CAAC,CAAA;IAC7O,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Conditional lifecycle mapping (`spec/rules.md` §2, `spec/profiles.md` §2).
3
+ *
4
+ * A native operation maps to an external lifecycle semantics only when the
5
+ * evidence the profile's `eventMappings` entry requires is actually present,
6
+ * and the result is exactly one of four words. `lossless` means every native
7
+ * fact the state carries has an external counterpart of equal meaning;
8
+ * `transformed` means the mapping was made but something has no home and is
9
+ * listed; `unsupported` means the profile declares no mapping for the
10
+ * operation; `insufficient-data` means the evidence condition is not met. No
11
+ * result other than `lossless` comes without its list of what was lost or is
12
+ * missing, and nothing is dropped silently.
13
+ */
14
+ import type { ProfileManifest } from './index.js';
15
+ export type NativeOperationV1 = 'ACTIVATE' | 'SOLD' | 'RESOLD' | 'REPAIRED' | 'RECYCLED' | 'EDIT' | 'TRANSFER';
16
+ /** The four record-version-2 capabilities (`spec/record-model-v2.md` §4). */
17
+ export type NativeOperationV2 = 'ISSUE' | 'UPDATE' | 'RETIRE';
18
+ export type NativeOperation = NativeOperationV1 | NativeOperationV2;
19
+ /**
20
+ * Which version 1 mapping a version 2 operation is read under
21
+ * (`spec/rules.md` §2): ISSUE is the genesis as ACTIVATE was, UPDATE a
22
+ * metadata revision as EDIT was, RETIRE a disposition as RECYCLED was, and
23
+ * TRANSFER is TRANSFER. The evidence conditions are the same, so an ISSUE is
24
+ * no more a manufacture than an ACTIVATE was, and a RETIRE is a disposition
25
+ * only with its disposition evidence. A manifest declares its mappings under
26
+ * the version 1 names; a version 2 operation is mapped through this table
27
+ * and the result names the operation that was actually written.
28
+ */
29
+ export declare const VERSION_2_OPERATION_MAPPING: Record<NativeOperationV2 | 'TRANSFER', NativeOperationV1>;
30
+ export type MappingOutcome = 'lossless' | 'transformed' | 'unsupported' | 'insufficient-data';
31
+ /**
32
+ * The evidence a caller can actually put forward, each item a reference to a
33
+ * record (a claim digest, an outpoint, a document digest), never a bare flag:
34
+ * the mapping asks whether the fact is evidenced, not whether it is asserted.
35
+ */
36
+ export interface LifecycleEvidence {
37
+ /** Origin: where, when and by whom the item was made or commissioned. */
38
+ facility?: string;
39
+ time?: string;
40
+ responsibleParty?: string;
41
+ /** Transfer: the physical move, or the custody record that changed hands. */
42
+ source?: string;
43
+ destination?: string;
44
+ custodyRecord?: string;
45
+ /** Transformation (repair): what was done, by whom, when. */
46
+ workDone?: string;
47
+ performedBy?: string;
48
+ performedAt?: string;
49
+ /** Disposition: whether this item was disposed of, or fed a process whose outputs carry new identities. */
50
+ dispositionKind?: 'disposal' | 'process-with-outputs';
51
+ outputs?: string[];
52
+ }
53
+ export interface MappingRequest {
54
+ nativeOperation: NativeOperation;
55
+ /** The payload keys the native state carries (public and restricted), so unmapped facts can be listed. */
56
+ payloadKeys?: string[];
57
+ evidence?: LifecycleEvidence;
58
+ }
59
+ export interface MappingResult {
60
+ nativeOperation: NativeOperation;
61
+ outcome: MappingOutcome;
62
+ /** The external semantics the mapping targets, when the profile declares one. */
63
+ eventType?: string;
64
+ externalEvent?: string;
65
+ /** The evidence facets the mapping requires and did not receive. */
66
+ missingEvidence: string[];
67
+ /** Everything lost or missing, in words; empty only when the outcome is lossless. */
68
+ losses: string[];
69
+ /** Payload keys with an external semantic field, and those without. */
70
+ mappedFields: Array<{
71
+ key: string;
72
+ semanticUri: string;
73
+ }>;
74
+ unmappedFields: string[];
75
+ }
76
+ type Facet = keyof LifecycleEvidence;
77
+ /**
78
+ * The structured form of each mapping's `requires` prose: which evidence
79
+ * facets must be present, as alternatives (any one group satisfies).
80
+ */
81
+ export declare const EVIDENCE_FACETS: Record<NativeOperation, Facet[][]>;
82
+ export declare function mapNativeOperation(manifest: ProfileManifest, request: MappingRequest): MappingResult;
83
+ export {};
84
+ //# sourceMappingURL=mapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../src/mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,M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AA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,oEAAoE;IACpE,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,qFAAqF;IACrF,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,uEAAuE;IACvE,YAAY,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACzD,cAAc,EAAE,MAAM,EAAE,CAAA;CACzB;AAED,KAAK,KAAK,GAAG,MAAM,iBAAiB,CAAA;AAEpC;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,eAAe,EAAE,KAAK,EAAE,EAAE,CAW9D,CAAA;AAOD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,GAAG,aAAa,CAoDpG"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Which version 1 mapping a version 2 operation is read under
3
+ * (`spec/rules.md` §2): ISSUE is the genesis as ACTIVATE was, UPDATE a
4
+ * metadata revision as EDIT was, RETIRE a disposition as RECYCLED was, and
5
+ * TRANSFER is TRANSFER. The evidence conditions are the same, so an ISSUE is
6
+ * no more a manufacture than an ACTIVATE was, and a RETIRE is a disposition
7
+ * only with its disposition evidence. A manifest declares its mappings under
8
+ * the version 1 names; a version 2 operation is mapped through this table
9
+ * and the result names the operation that was actually written.
10
+ */
11
+ export const VERSION_2_OPERATION_MAPPING = {
12
+ ISSUE: 'ACTIVATE',
13
+ UPDATE: 'EDIT',
14
+ TRANSFER: 'TRANSFER',
15
+ RETIRE: 'RECYCLED',
16
+ };
17
+ /**
18
+ * The structured form of each mapping's `requires` prose: which evidence
19
+ * facets must be present, as alternatives (any one group satisfies).
20
+ */
21
+ export const EVIDENCE_FACETS = {
22
+ ACTIVATE: [['facility', 'time', 'responsibleParty']],
23
+ SOLD: [['source', 'destination'], ['custodyRecord']],
24
+ RESOLD: [['source', 'destination'], ['custodyRecord']],
25
+ TRANSFER: [['custodyRecord']],
26
+ REPAIRED: [['workDone', 'performedBy', 'performedAt']],
27
+ EDIT: [[]],
28
+ RECYCLED: [['dispositionKind']],
29
+ ISSUE: [['facility', 'time', 'responsibleParty']],
30
+ UPDATE: [[]],
31
+ RETIRE: [['dispositionKind']],
32
+ };
33
+ const present = (evidence, facet) => {
34
+ const value = evidence[facet];
35
+ return Array.isArray(value) ? value.length > 0 : typeof value === 'string' && value.trim().length > 0;
36
+ };
37
+ export function mapNativeOperation(manifest, request) {
38
+ const { nativeOperation } = request;
39
+ const evidence = request.evidence ?? {};
40
+ const keys = [...new Set(request.payloadKeys ?? [])];
41
+ const byKey = new Map(manifest.fields.map((f) => [f.key, f]));
42
+ const mappedFields = keys.flatMap((key) => {
43
+ const uri = byKey.get(key)?.semanticUri;
44
+ return uri ? [{ key, semanticUri: uri }] : [];
45
+ });
46
+ const unmappedFields = keys.filter((key) => !byKey.get(key)?.semanticUri);
47
+ const base = { nativeOperation, missingEvidence: [], losses: [], mappedFields, unmappedFields };
48
+ // A version 2 operation is mapped under the version 1 name the manifest declares.
49
+ const declared = nativeOperation in VERSION_2_OPERATION_MAPPING ? VERSION_2_OPERATION_MAPPING[nativeOperation] : nativeOperation;
50
+ const mapping = manifest.eventMappings.find((m) => m.nativeOperation === declared);
51
+ if (mapping == null) {
52
+ return { ...base, outcome: 'unsupported', losses: [`${manifest.profile} declares no external mapping for ${nativeOperation}; the native operation stays native`] };
53
+ }
54
+ const target = { eventType: mapping.eventType, externalEvent: mapping.externalEvent };
55
+ // The evidence condition: any one alternative group fully present satisfies it.
56
+ const groups = EVIDENCE_FACETS[nativeOperation];
57
+ const satisfied = groups.some((group) => group.every((facet) => present(evidence, facet)));
58
+ if (!satisfied) {
59
+ const shortest = [...groups].sort((a, b) => a.filter((f) => !present(evidence, f)).length - b.filter((f) => !present(evidence, f)).length)[0];
60
+ const missingEvidence = shortest.filter((facet) => !present(evidence, facet));
61
+ return {
62
+ ...base,
63
+ ...target,
64
+ outcome: mapping.withoutEvidence,
65
+ missingEvidence,
66
+ losses: [
67
+ `${nativeOperation} is not mapped to ${mapping.externalEvent}: ${mapping.requires}`,
68
+ ...missingEvidence.map((facet) => `missing evidence: ${facet}`),
69
+ ...unmappedFields.map((key) => `no external semantic field for ${key}`),
70
+ ],
71
+ };
72
+ }
73
+ const losses = [];
74
+ if (declared === 'EDIT')
75
+ losses.push(`${nativeOperation === 'EDIT' ? 'an EDIT' : 'an UPDATE'} is a metadata revision; no physical transformation is implied and none is mapped`);
76
+ if (declared === 'RECYCLED' && evidence.dispositionKind === 'process-with-outputs' && !present(evidence, 'outputs')) {
77
+ return {
78
+ ...base,
79
+ ...target,
80
+ outcome: 'insufficient-data',
81
+ missingEvidence: ['outputs'],
82
+ losses: ['a recycling process creating new products or materials must name the outputs that carry new identities', ...unmappedFields.map((key) => `no external semantic field for ${key}`)],
83
+ };
84
+ }
85
+ losses.push(...unmappedFields.map((key) => `no external semantic field for ${key}`));
86
+ return { ...base, ...target, outcome: losses.length === 0 ? 'lossless' : 'transformed', losses };
87
+ }
88
+ //# sourceMappingURL=mapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.js","sourceRoot":"","sources":["../src/mapping.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAA8D;IACpG,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,UAAU;CACnB,CAAA;AAkDD;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAuC;IACjE,QAAQ,EAAE,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACpD,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,aAAa,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;IACpD,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,aAAa,CAAC,EAAE,CA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mFAAmF,CAAC,CAAA;IAChL,IAAI,QAAQ,KAAK,UAAU,IAAI,QAAQ,CAAC,eAAe,KAAK,sBAAsB,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC;QACpH,OAAO;YACL,GAAG,IAAI;YACP,GAAG,MAAM;YACT,OAAO,EAAE,mBAAmB;YAC5B,eAAe,EAAE,CAAC,SAAS,CAAC;YAC5B,MAAM,EAAE,CAAC,wGAAwG,EAAE,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,kCAAkC,GAAG,EAAE,CAAC,CAAC;SAC5L,CAAA;IACH,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,kCAAkC,GAAG,EAAE,CAAC,CAAC,CAAA;IACpF,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,EAAE,MAAM,EAAE,CAAA;AAClG,CAAC"}
@@ -0,0 +1,233 @@
1
+ import { type AnyProfileManifest } from './manifest-v2.js';
2
+ import { type ApplicabilityOutcome } from './applicability.js';
3
+ import { type LanguageSelection, type MeasurementConversion } from './evidence-shapes.js';
4
+ export declare const PROJECTION_VERSION: "1";
5
+ export declare const PROJECTION_ID_PREFIX = "urn:bsv:dpp:projection:sha256:";
6
+ export declare const DEFAULT_PROJECTION_LIMITS: {
7
+ readonly maxDepth: 8;
8
+ readonly maxRefs: 100;
9
+ };
10
+ export type ProjectionGranularity = 'model' | 'batch' | 'item' | 'component';
11
+ export type DisclosureScope = 'public' | 'owner' | 'legitimate' | 'authority';
12
+ export type RelationshipKind = 'instance-of-model' | 'member-of-batch' | 'component-of' | 'successor-of';
13
+ /** A source revision as the caller resolved it: exact identity, the payload it carried and the digest of its retained bytes. */
14
+ export interface ResolvedSource {
15
+ recordId: string;
16
+ revisionId: string;
17
+ subject: {
18
+ id: string;
19
+ granularity: ProjectionGranularity;
20
+ };
21
+ profileRef: {
22
+ id: string;
23
+ version: number;
24
+ };
25
+ payload: Record<string, unknown>;
26
+ digest: string;
27
+ recordedAt: string;
28
+ effective?: {
29
+ from?: string;
30
+ until?: string;
31
+ };
32
+ disclosure: {
33
+ policyId?: string;
34
+ scope: DisclosureScope;
35
+ };
36
+ authorisation: {
37
+ kind: string;
38
+ policyId: string;
39
+ principal?: string;
40
+ evidenceRef?: string;
41
+ };
42
+ }
43
+ export interface ProjectionRelationship {
44
+ relationshipId: string;
45
+ kind: RelationshipKind;
46
+ source: {
47
+ id: string;
48
+ granularity: ProjectionGranularity;
49
+ };
50
+ target: {
51
+ id: string;
52
+ granularity: ProjectionGranularity;
53
+ };
54
+ evidence: {
55
+ sourceRevision?: {
56
+ recordId: string;
57
+ revisionId: string;
58
+ };
59
+ credentialRef?: {
60
+ id: string;
61
+ digest?: string;
62
+ };
63
+ eventRef?: {
64
+ importId: string;
65
+ eventRef: string;
66
+ };
67
+ };
68
+ effective?: {
69
+ from?: string;
70
+ until?: string;
71
+ };
72
+ policyRef: string;
73
+ }
74
+ export type MeasurementStatus = 'accepted' | 'invalid' | 'revoked' | 'unresolved-correction';
75
+ /** A dynamic observation of one property of one subject, with the exact scope a projection matches on. */
76
+ export interface ProjectionMeasurement {
77
+ property: string;
78
+ subject: {
79
+ id: string;
80
+ granularity: ProjectionGranularity;
81
+ };
82
+ value: number | string | boolean;
83
+ unit: string;
84
+ method: string;
85
+ observedAt: string;
86
+ effectiveAt?: string;
87
+ source: {
88
+ recordId: string;
89
+ revisionId: string;
90
+ };
91
+ status?: MeasurementStatus;
92
+ }
93
+ export interface ProjectionPolicy {
94
+ id: string;
95
+ /** The field keys a batch or item source may override the model's value for. */
96
+ precedence: {
97
+ batchOverrides: string[];
98
+ itemOverrides: string[];
99
+ };
100
+ measurementSelection: 'latest-observed' | 'latest-effective';
101
+ tie: 'conflict';
102
+ }
103
+ export interface ProjectionInput {
104
+ passportId: string;
105
+ subject: {
106
+ id: string;
107
+ granularity: 'model' | 'batch' | 'item';
108
+ };
109
+ profile: AnyProfileManifest;
110
+ sources: ResolvedSource[];
111
+ relationships: ProjectionRelationship[];
112
+ measurements?: ProjectionMeasurement[];
113
+ policy: ProjectionPolicy;
114
+ /** The historical cutoff: sources recorded and measurements observed after it are excluded. Absent means no cutoff, recorded as null. */
115
+ asOf?: string;
116
+ disclosureScope: DisclosureScope;
117
+ locale?: {
118
+ exact?: string;
119
+ base?: string;
120
+ default: string;
121
+ };
122
+ jurisdiction?: string;
123
+ /** Overrides the category read from the sources' payload, when the caller knows it independently. */
124
+ category?: string;
125
+ validationRefs?: string[];
126
+ limits?: {
127
+ maxDepth?: number;
128
+ maxRefs?: number;
129
+ };
130
+ }
131
+ export type FieldAvailability = 'present' | 'missing' | 'unknown' | 'withheld';
132
+ export type FieldFinding = 'conflict' | 'unsupported' | 'limit' | 'cycle' | 'missing-source';
133
+ export interface ProjectedValue {
134
+ value: unknown;
135
+ source: {
136
+ recordId: string;
137
+ revisionId: string;
138
+ pointer: string;
139
+ };
140
+ granularity: ProjectionGranularity;
141
+ language?: string;
142
+ selection?: LanguageSelection;
143
+ conversion?: MeasurementConversion;
144
+ observedAt?: string;
145
+ method?: string;
146
+ }
147
+ export interface FieldResult {
148
+ availability: FieldAvailability;
149
+ applicability: ApplicabilityOutcome;
150
+ finding?: FieldFinding;
151
+ conflicts?: Array<{
152
+ recordId: string;
153
+ revisionId: string;
154
+ value: unknown;
155
+ }>;
156
+ reason?: string;
157
+ excluded?: Array<{
158
+ recordId: string;
159
+ revisionId: string;
160
+ reason: string;
161
+ }>;
162
+ }
163
+ export interface ProjectionFinding {
164
+ code: string;
165
+ field?: string;
166
+ detail: string;
167
+ }
168
+ export interface PassportProjection {
169
+ projectionId: string;
170
+ projectionVersion: typeof PROJECTION_VERSION;
171
+ projectionDigest: string;
172
+ passportId: string;
173
+ subjectId: string;
174
+ granularity: 'model' | 'batch' | 'item';
175
+ profileRef: {
176
+ id: string;
177
+ version: number;
178
+ };
179
+ sourceRefs: Array<{
180
+ recordId: string;
181
+ revisionId: string;
182
+ digest: string;
183
+ subjectId: string;
184
+ granularity: ProjectionGranularity;
185
+ }>;
186
+ relationshipRefs: Array<{
187
+ relationshipId: string;
188
+ kind: RelationshipKind;
189
+ sourceId: string;
190
+ targetId: string;
191
+ policyRef: string;
192
+ }>;
193
+ policyRef: string;
194
+ asOf: string | null;
195
+ disclosureScope: DisclosureScope;
196
+ values: Record<string, ProjectedValue>;
197
+ fieldResults: Record<string, FieldResult>;
198
+ evidenceRefs: string[];
199
+ validationRefs: string[];
200
+ diagnostics?: {
201
+ truncated: boolean;
202
+ limits: Record<string, number>;
203
+ findings: ProjectionFinding[];
204
+ };
205
+ template?: string;
206
+ }
207
+ export interface ProjectionOutput {
208
+ projection: PassportProjection;
209
+ /** `ok` is complete: no source was missing, no limit or cycle was hit and no record had competing revisions. Conflicts between sources are field results, not validation failures. */
210
+ validation: {
211
+ ok: boolean;
212
+ findings: ProjectionFinding[];
213
+ };
214
+ }
215
+ /** SHA-256 of the RFC 8785 canonical JSON of an inline payload. A retained source's digest is over its exact retained bytes; this is the digest of a payload carried inline. */
216
+ export declare function payloadDigest(payload: unknown): string;
217
+ /** The commitment body: every committed property, none of the derived or diagnostic ones (`spec/passport-projections.md` §4). */
218
+ export declare function projectionCommitmentBody(projection: PassportProjection): Record<string, unknown>;
219
+ /** The canonical bytes of the commitment body, as a UTF-8 string. */
220
+ export declare function projectionCommitment(projection: PassportProjection): string;
221
+ export declare function projectionDigest(projection: PassportProjection): string;
222
+ /** Whether a projection's recorded identity and digest are the ones its committed body yields. */
223
+ export declare function verifyProjectionCommitment(projection: PassportProjection): {
224
+ digestValid: boolean;
225
+ idValid: boolean;
226
+ };
227
+ /**
228
+ * Derive one passport's projection. Throws only for a caller error: a
229
+ * non-finite number in a payload or a measurement, or a date that is not one.
230
+ * Every other difficulty is a finding in the output.
231
+ */
232
+ export declare function projectPassport(input: ProjectionInput): ProjectionOutput;
233
+ //# sourceMappingURL=projections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projections.d.ts","sourceRoot":"","sources":["../src/projections.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAiD,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACzG,OAAO,EAA2F,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACvJ,OAAO,EAAkB,KAAK,iBAAiB,EAAuB,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAE9H,eAAO,MAAM,kBAAkB,EAAG,GAAY,CAAA;AAC9C,eAAO,MAAM,oBAAoB,mCAAmC,CAAA;AACpE,eAAO,MAAM,yBAAyB;;;CAAyC,CAAA;AAE/E,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,WAAW,CAAA;AAC5E,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,WAAW,CAAA;AAC7E,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,GAAG,iBAAiB,GAAG,cAAc,GAAG,cAAc,CAAA;AAExG,gIAAgI;AAChI,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,qBAAqB,CAAA;KAAE,CAAA;IAC3D,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE;QAAE,IAAI,CAAC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