@flaks/onerecord 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/MIGRATING.md +114 -0
  3. package/README.md +42 -34
  4. package/dist/classes/account-number/schema.d.ts +2 -7
  5. package/dist/classes/account-number/schema.d.ts.map +1 -1
  6. package/dist/classes/account-number/schema.js +7 -4
  7. package/dist/classes/account-number/schema.js.map +1 -1
  8. package/dist/classes/co2-emissions/codec.d.ts +4 -0
  9. package/dist/classes/co2-emissions/codec.d.ts.map +1 -0
  10. package/dist/classes/co2-emissions/codec.js +11 -0
  11. package/dist/classes/co2-emissions/codec.js.map +1 -0
  12. package/dist/classes/co2-emissions/deserialize.d.ts +5 -0
  13. package/dist/classes/co2-emissions/deserialize.d.ts.map +1 -0
  14. package/dist/classes/co2-emissions/deserialize.js +64 -0
  15. package/dist/classes/co2-emissions/deserialize.js.map +1 -0
  16. package/dist/classes/co2-emissions/index.d.ts +6 -0
  17. package/dist/classes/co2-emissions/index.d.ts.map +1 -0
  18. package/dist/classes/co2-emissions/index.js +5 -0
  19. package/dist/classes/co2-emissions/index.js.map +1 -0
  20. package/dist/classes/co2-emissions/schema.d.ts +18 -0
  21. package/dist/classes/co2-emissions/schema.d.ts.map +1 -0
  22. package/dist/classes/co2-emissions/schema.js +12 -0
  23. package/dist/classes/co2-emissions/schema.js.map +1 -0
  24. package/dist/classes/co2-emissions/serialize.d.ts +6 -0
  25. package/dist/classes/co2-emissions/serialize.d.ts.map +1 -0
  26. package/dist/classes/co2-emissions/serialize.js +28 -0
  27. package/dist/classes/co2-emissions/serialize.js.map +1 -0
  28. package/dist/classes/company/codec.d.ts +4 -0
  29. package/dist/classes/company/codec.d.ts.map +1 -0
  30. package/dist/classes/company/codec.js +11 -0
  31. package/dist/classes/company/codec.js.map +1 -0
  32. package/dist/classes/company/deserialize.d.ts +5 -0
  33. package/dist/classes/company/deserialize.d.ts.map +1 -0
  34. package/dist/classes/company/deserialize.js +64 -0
  35. package/dist/classes/company/deserialize.js.map +1 -0
  36. package/dist/classes/company/index.d.ts +6 -0
  37. package/dist/classes/company/index.d.ts.map +1 -0
  38. package/dist/classes/company/index.js +5 -0
  39. package/dist/classes/company/index.js.map +1 -0
  40. package/dist/classes/company/schema.d.ts +23 -0
  41. package/dist/classes/company/schema.d.ts.map +1 -0
  42. package/dist/classes/company/schema.js +23 -0
  43. package/dist/classes/company/schema.js.map +1 -0
  44. package/dist/classes/company/serialize.d.ts +6 -0
  45. package/dist/classes/company/serialize.d.ts.map +1 -0
  46. package/dist/classes/company/serialize.js +28 -0
  47. package/dist/classes/company/serialize.js.map +1 -0
  48. package/dist/classes/customs-information/codec.d.ts +4 -0
  49. package/dist/classes/customs-information/codec.d.ts.map +1 -0
  50. package/dist/classes/customs-information/codec.js +11 -0
  51. package/dist/classes/customs-information/codec.js.map +1 -0
  52. package/dist/classes/customs-information/deserialize.d.ts +5 -0
  53. package/dist/classes/customs-information/deserialize.d.ts.map +1 -0
  54. package/dist/classes/customs-information/deserialize.js +64 -0
  55. package/dist/classes/customs-information/deserialize.js.map +1 -0
  56. package/dist/classes/customs-information/index.d.ts +6 -0
  57. package/dist/classes/customs-information/index.d.ts.map +1 -0
  58. package/dist/classes/customs-information/index.js +5 -0
  59. package/dist/classes/customs-information/index.js.map +1 -0
  60. package/dist/classes/customs-information/schema.d.ts +18 -0
  61. package/dist/classes/customs-information/schema.d.ts.map +1 -0
  62. package/dist/classes/customs-information/schema.js +17 -0
  63. package/dist/classes/customs-information/schema.js.map +1 -0
  64. package/dist/classes/customs-information/serialize.d.ts +6 -0
  65. package/dist/classes/customs-information/serialize.d.ts.map +1 -0
  66. package/dist/classes/customs-information/serialize.js +28 -0
  67. package/dist/classes/customs-information/serialize.js.map +1 -0
  68. package/dist/classes/insurance/codec.d.ts +4 -0
  69. package/dist/classes/insurance/codec.d.ts.map +1 -0
  70. package/dist/classes/insurance/codec.js +11 -0
  71. package/dist/classes/insurance/codec.js.map +1 -0
  72. package/dist/classes/insurance/deserialize.d.ts +5 -0
  73. package/dist/classes/insurance/deserialize.d.ts.map +1 -0
  74. package/dist/classes/insurance/deserialize.js +64 -0
  75. package/dist/classes/insurance/deserialize.js.map +1 -0
  76. package/dist/classes/insurance/index.d.ts +6 -0
  77. package/dist/classes/insurance/index.d.ts.map +1 -0
  78. package/dist/classes/insurance/index.js +5 -0
  79. package/dist/classes/insurance/index.js.map +1 -0
  80. package/dist/classes/insurance/schema.d.ts +17 -0
  81. package/dist/classes/insurance/schema.d.ts.map +1 -0
  82. package/dist/classes/insurance/schema.js +11 -0
  83. package/dist/classes/insurance/schema.js.map +1 -0
  84. package/dist/classes/insurance/serialize.d.ts +6 -0
  85. package/dist/classes/insurance/serialize.d.ts.map +1 -0
  86. package/dist/classes/insurance/serialize.js +28 -0
  87. package/dist/classes/insurance/serialize.js.map +1 -0
  88. package/dist/classes/line-item-package/codec.d.ts +4 -0
  89. package/dist/classes/line-item-package/codec.d.ts.map +1 -0
  90. package/dist/classes/line-item-package/codec.js +11 -0
  91. package/dist/classes/line-item-package/codec.js.map +1 -0
  92. package/dist/classes/line-item-package/deserialize.d.ts +5 -0
  93. package/dist/classes/line-item-package/deserialize.d.ts.map +1 -0
  94. package/dist/classes/line-item-package/deserialize.js +64 -0
  95. package/dist/classes/line-item-package/deserialize.js.map +1 -0
  96. package/dist/classes/line-item-package/index.d.ts +6 -0
  97. package/dist/classes/line-item-package/index.d.ts.map +1 -0
  98. package/dist/classes/line-item-package/index.js +5 -0
  99. package/dist/classes/line-item-package/index.js.map +1 -0
  100. package/dist/classes/line-item-package/schema.d.ts +22 -0
  101. package/dist/classes/line-item-package/schema.d.ts.map +1 -0
  102. package/dist/classes/line-item-package/schema.js +12 -0
  103. package/dist/classes/line-item-package/schema.js.map +1 -0
  104. package/dist/classes/line-item-package/serialize.d.ts +6 -0
  105. package/dist/classes/line-item-package/serialize.d.ts.map +1 -0
  106. package/dist/classes/line-item-package/serialize.js +28 -0
  107. package/dist/classes/line-item-package/serialize.js.map +1 -0
  108. package/dist/classes/other-charge/codec.d.ts +4 -0
  109. package/dist/classes/other-charge/codec.d.ts.map +1 -0
  110. package/dist/classes/other-charge/codec.js +11 -0
  111. package/dist/classes/other-charge/codec.js.map +1 -0
  112. package/dist/classes/other-charge/deserialize.d.ts +5 -0
  113. package/dist/classes/other-charge/deserialize.d.ts.map +1 -0
  114. package/dist/classes/other-charge/deserialize.js +64 -0
  115. package/dist/classes/other-charge/deserialize.js.map +1 -0
  116. package/dist/classes/other-charge/index.d.ts +6 -0
  117. package/dist/classes/other-charge/index.d.ts.map +1 -0
  118. package/dist/classes/other-charge/index.js +5 -0
  119. package/dist/classes/other-charge/index.js.map +1 -0
  120. package/dist/classes/other-charge/schema.d.ts +27 -0
  121. package/dist/classes/other-charge/schema.d.ts.map +1 -0
  122. package/dist/classes/other-charge/schema.js +14 -0
  123. package/dist/classes/other-charge/schema.js.map +1 -0
  124. package/dist/classes/other-charge/serialize.d.ts +6 -0
  125. package/dist/classes/other-charge/serialize.d.ts.map +1 -0
  126. package/dist/classes/other-charge/serialize.js +28 -0
  127. package/dist/classes/other-charge/serialize.js.map +1 -0
  128. package/dist/classes/party/schema.d.ts +9 -1
  129. package/dist/classes/party/schema.d.ts.map +1 -1
  130. package/dist/classes/party/schema.js +5 -2
  131. package/dist/classes/party/schema.js.map +1 -1
  132. package/dist/classes/piece/schema.d.ts +11 -0
  133. package/dist/classes/piece/schema.d.ts.map +1 -1
  134. package/dist/classes/piece/schema.js +10 -0
  135. package/dist/classes/piece/schema.js.map +1 -1
  136. package/dist/classes/regulated-entity/codec.d.ts +4 -0
  137. package/dist/classes/regulated-entity/codec.d.ts.map +1 -0
  138. package/dist/classes/regulated-entity/codec.js +11 -0
  139. package/dist/classes/regulated-entity/codec.js.map +1 -0
  140. package/dist/classes/regulated-entity/deserialize.d.ts +5 -0
  141. package/dist/classes/regulated-entity/deserialize.d.ts.map +1 -0
  142. package/dist/classes/regulated-entity/deserialize.js +64 -0
  143. package/dist/classes/regulated-entity/deserialize.js.map +1 -0
  144. package/dist/classes/regulated-entity/index.d.ts +6 -0
  145. package/dist/classes/regulated-entity/index.d.ts.map +1 -0
  146. package/dist/classes/regulated-entity/index.js +5 -0
  147. package/dist/classes/regulated-entity/index.js.map +1 -0
  148. package/dist/classes/regulated-entity/schema.d.ts +19 -0
  149. package/dist/classes/regulated-entity/schema.d.ts.map +1 -0
  150. package/dist/classes/regulated-entity/schema.js +12 -0
  151. package/dist/classes/regulated-entity/schema.js.map +1 -0
  152. package/dist/classes/regulated-entity/serialize.d.ts +6 -0
  153. package/dist/classes/regulated-entity/serialize.d.ts.map +1 -0
  154. package/dist/classes/regulated-entity/serialize.js +28 -0
  155. package/dist/classes/regulated-entity/serialize.js.map +1 -0
  156. package/dist/classes/security-declaration/codec.d.ts +4 -0
  157. package/dist/classes/security-declaration/codec.d.ts.map +1 -0
  158. package/dist/classes/security-declaration/codec.js +11 -0
  159. package/dist/classes/security-declaration/codec.js.map +1 -0
  160. package/dist/classes/security-declaration/deserialize.d.ts +5 -0
  161. package/dist/classes/security-declaration/deserialize.d.ts.map +1 -0
  162. package/dist/classes/security-declaration/deserialize.js +64 -0
  163. package/dist/classes/security-declaration/deserialize.js.map +1 -0
  164. package/dist/classes/security-declaration/index.d.ts +6 -0
  165. package/dist/classes/security-declaration/index.d.ts.map +1 -0
  166. package/dist/classes/security-declaration/index.js +5 -0
  167. package/dist/classes/security-declaration/index.js.map +1 -0
  168. package/dist/classes/security-declaration/schema.d.ts +44 -0
  169. package/dist/classes/security-declaration/schema.d.ts.map +1 -0
  170. package/dist/classes/security-declaration/schema.js +21 -0
  171. package/dist/classes/security-declaration/schema.js.map +1 -0
  172. package/dist/classes/security-declaration/serialize.d.ts +6 -0
  173. package/dist/classes/security-declaration/serialize.d.ts.map +1 -0
  174. package/dist/classes/security-declaration/serialize.js +28 -0
  175. package/dist/classes/security-declaration/serialize.js.map +1 -0
  176. package/dist/classes/shared/value.d.ts +44 -0
  177. package/dist/classes/shared/value.d.ts.map +1 -0
  178. package/dist/classes/shared/value.js +39 -0
  179. package/dist/classes/shared/value.js.map +1 -0
  180. package/dist/classes/shipment/schema.d.ts +31 -8
  181. package/dist/classes/shipment/schema.d.ts.map +1 -1
  182. package/dist/classes/shipment/schema.js +15 -5
  183. package/dist/classes/shipment/schema.js.map +1 -1
  184. package/dist/classes/transport-movement/schema.d.ts +22 -0
  185. package/dist/classes/transport-movement/schema.d.ts.map +1 -1
  186. package/dist/classes/transport-movement/schema.js +7 -0
  187. package/dist/classes/transport-movement/schema.js.map +1 -1
  188. package/dist/classes/uld/codec.d.ts +4 -0
  189. package/dist/classes/uld/codec.d.ts.map +1 -0
  190. package/dist/classes/uld/codec.js +11 -0
  191. package/dist/classes/uld/codec.js.map +1 -0
  192. package/dist/classes/uld/deserialize.d.ts +5 -0
  193. package/dist/classes/uld/deserialize.d.ts.map +1 -0
  194. package/dist/classes/uld/deserialize.js +64 -0
  195. package/dist/classes/uld/deserialize.js.map +1 -0
  196. package/dist/classes/uld/index.d.ts +6 -0
  197. package/dist/classes/uld/index.d.ts.map +1 -0
  198. package/dist/classes/uld/index.js +5 -0
  199. package/dist/classes/uld/index.js.map +1 -0
  200. package/dist/classes/uld/schema.d.ts +31 -0
  201. package/dist/classes/uld/schema.d.ts.map +1 -0
  202. package/dist/classes/uld/schema.js +29 -0
  203. package/dist/classes/uld/schema.js.map +1 -0
  204. package/dist/classes/uld/serialize.d.ts +6 -0
  205. package/dist/classes/uld/serialize.d.ts.map +1 -0
  206. package/dist/classes/uld/serialize.js +28 -0
  207. package/dist/classes/uld/serialize.js.map +1 -0
  208. package/dist/classes/waybill/schema.d.ts +45 -5
  209. package/dist/classes/waybill/schema.d.ts.map +1 -1
  210. package/dist/classes/waybill/schema.js +28 -7
  211. package/dist/classes/waybill/schema.js.map +1 -1
  212. package/dist/classes/waybill-line-item/codec.d.ts +4 -0
  213. package/dist/classes/waybill-line-item/codec.d.ts.map +1 -0
  214. package/dist/classes/waybill-line-item/codec.js +11 -0
  215. package/dist/classes/waybill-line-item/codec.js.map +1 -0
  216. package/dist/classes/waybill-line-item/deserialize.d.ts +5 -0
  217. package/dist/classes/waybill-line-item/deserialize.d.ts.map +1 -0
  218. package/dist/classes/waybill-line-item/deserialize.js +64 -0
  219. package/dist/classes/waybill-line-item/deserialize.js.map +1 -0
  220. package/dist/classes/waybill-line-item/index.d.ts +6 -0
  221. package/dist/classes/waybill-line-item/index.d.ts.map +1 -0
  222. package/dist/classes/waybill-line-item/index.js +5 -0
  223. package/dist/classes/waybill-line-item/index.js.map +1 -0
  224. package/dist/classes/waybill-line-item/schema.d.ts +44 -0
  225. package/dist/classes/waybill-line-item/schema.d.ts.map +1 -0
  226. package/dist/classes/waybill-line-item/schema.js +22 -0
  227. package/dist/classes/waybill-line-item/schema.js.map +1 -0
  228. package/dist/classes/waybill-line-item/serialize.d.ts +6 -0
  229. package/dist/classes/waybill-line-item/serialize.d.ts.map +1 -0
  230. package/dist/classes/waybill-line-item/serialize.js +28 -0
  231. package/dist/classes/waybill-line-item/serialize.js.map +1 -0
  232. package/dist/codecs.d.ts +10 -1
  233. package/dist/codecs.d.ts.map +1 -1
  234. package/dist/codecs.js +10 -1
  235. package/dist/codecs.js.map +1 -1
  236. package/dist/codes/enums.d.ts +35 -0
  237. package/dist/codes/enums.d.ts.map +1 -1
  238. package/dist/codes/enums.js +4 -0
  239. package/dist/codes/enums.js.map +1 -1
  240. package/dist/codes/index.d.ts +1 -1
  241. package/dist/codes/index.d.ts.map +1 -1
  242. package/dist/codes/index.js +1 -1
  243. package/dist/codes/index.js.map +1 -1
  244. package/dist/dispatch/domain-constraints.d.ts +13 -8
  245. package/dist/dispatch/domain-constraints.d.ts.map +1 -1
  246. package/dist/dispatch/domain-constraints.js +14 -24
  247. package/dist/dispatch/domain-constraints.js.map +1 -1
  248. package/dist/dispatch/field-types.d.ts +2 -3
  249. package/dist/dispatch/field-types.d.ts.map +1 -1
  250. package/dist/dispatch/field-types.js +60 -13
  251. package/dist/dispatch/field-types.js.map +1 -1
  252. package/dist/dispatch/graph-walk.d.ts.map +1 -1
  253. package/dist/dispatch/graph-walk.js +9 -8
  254. package/dist/dispatch/graph-walk.js.map +1 -1
  255. package/dist/facade.d.ts +12 -3
  256. package/dist/facade.d.ts.map +1 -1
  257. package/dist/factory-classes.d.ts +27 -6
  258. package/dist/factory-classes.d.ts.map +1 -1
  259. package/dist/factory-classes.js +27 -6
  260. package/dist/factory-classes.js.map +1 -1
  261. package/dist/index.d.ts +20 -2
  262. package/dist/index.d.ts.map +1 -1
  263. package/dist/index.js +20 -2
  264. package/dist/index.js.map +1 -1
  265. package/dist/iri/zod-safe-iri.d.ts +18 -2
  266. package/dist/iri/zod-safe-iri.d.ts.map +1 -1
  267. package/dist/iri/zod-safe-iri.js +14 -2
  268. package/dist/iri/zod-safe-iri.js.map +1 -1
  269. package/dist/types/index.d.ts +10 -1
  270. package/dist/types/index.d.ts.map +1 -1
  271. package/dist/version.d.ts +9 -4
  272. package/dist/version.d.ts.map +1 -1
  273. package/dist/version.js +18 -6
  274. package/dist/version.js.map +1 -1
  275. package/package.json +7 -6
package/CHANGELOG.md CHANGED
@@ -4,6 +4,115 @@ All notable changes are documented here. Format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/), versioning follows
5
5
  [SemVer](https://semver.org/) per the policy in `MIGRATING.md`.
6
6
 
7
+ ## [0.3.0] - 2026-05-17
8
+
9
+ FWB-equivalence Path A: 10 new classes, schema rewrites for the core FWB
10
+ classes, full IATA 3.2.0 conformance for the covered class set with documented
11
+ deviations and 3.2.1-forward extensions. See `MIGRATING.md` for per-breaking-
12
+ change migration guidance.
13
+
14
+ ### Added
15
+
16
+ - **`Company`** class — concrete `:Organization` subtype; retires the abstract
17
+ `Organization` class. `Party.partyDetails` and all Organization-range fields
18
+ now point to `Company`.
19
+ - **`WaybillLineItem`** class — FWB rate/charge line item.
20
+ - **`OtherCharge`** class — FWB OCI/other-charge block.
21
+ - **`CustomsInformation`** class — FWB customs information block.
22
+ - **`Insurance`** class — FWB insurance details.
23
+ - **`LineItemPackage`** class — FWB package-level line item.
24
+ - **`ULD`** class — unit load device reference.
25
+ - **`CO2Emissions`** class — carbon emissions per spec §D6.
26
+ - **`RegulatedEntity`** class — security regulated entity (shipper/handler).
27
+ - **`SecurityDeclaration`** class — security declaration per spec §8.
28
+ - **Shared value sub-schemas**: `ValueSchema`, `CurrencyValueSchema`,
29
+ `DimensionsSchema` — used by all NEW value-typed properties in v0.3.0.
30
+ - **FWB properties** on `Waybill`: `shipment`, `involvedParties`,
31
+ `waybillLineItems`, `otherCharges`, `carrierDeclarationPlace`,
32
+ `departureLocation`, `arrivalLocation`, `houseWaybills`, `masterWaybill`,
33
+ `billingDetails` (IRI ref only; `:BillingDetails` class not modelled — deviation #16).
34
+ `accountingInformation` — deprecated upstream (owl:deprecated true in
35
+ 3.2-rc2 ~2861) — **deviation #15**.
36
+ - **FWB properties** on `Shipment`: `pieces`, `waybill`, `involvedParties`,
37
+ `customsInformation`, `insurance`, `securityDeclarations` (accepted as
38
+ optional 3.2.1-forward extension — deviation #12).
39
+ - **FWB properties** on `Piece`: `ofShipment`, `containedPieces`,
40
+ `securityDeclarations` (3.2.0-conformant via Piece restriction ~8260).
41
+ - `CARGO_ONTOLOGY_VERSION` bumped from `'3.2'` to `'3.2.0'` (exact endorsed
42
+ version string). Legacy alias `'3.2'` remains accepted by
43
+ `assertOntologyVersion` and `checkServerInformation`.
44
+
45
+ ### Changed
46
+
47
+ - **`Organization` class retired** — replaced by `Company`
48
+ (`:Company rdfs:subClassOf :Organization`; the only concrete org type shipped).
49
+ `Party.partyDetails` widened to accept `IRI | {@id}` (Person or Company).
50
+ `NI` added as accepted `Party.partyRole` value.
51
+ - **`Waybill`**: dropped `shipmentInformation` (renamed to `shipment`);
52
+ dropped `totalGrossWeight` (the field already exists on `Shipment` — use that).
53
+ - **`Shipment`**: dropped `pieceCount`, `totalVolume`, `containedPieces`
54
+ (renamed to `pieces`), `shipper`, `consignee` (moved to `involvedParties`).
55
+ - **`waybillType` enum**: `DIRECT` added.
56
+ - **`waybillPrefix`**: now accepts `[A-Z0-9]{1,3}` (editorial policy relaxation
57
+ — NOT a spec pattern; the ontology has only `xsd:string maxLength 3`).
58
+ - **`waybillNumber`**: now accepts `[A-Z0-9]+` per 3.2-rc2 ontology pattern.
59
+ - **`AccountNumber`**: `accountNumber`/`issuedBy`/`accountType` renamed to
60
+ `accountNumberType`/`textualValue`; `issuedBy` removed (wrong domain — belongs
61
+ to `:SecurityDeclaration`, not `:AccountNumber`).
62
+ - **`CARGO_ONTOLOGY_VERSION`**: `'3.2'` → `'3.2.0'`. `assertOntologyVersion`
63
+ and `checkServerInformation` now use an exact-alias accepted set
64
+ (`'3.2'` ≡ `'3.2.0'`, `'3.2.1'` rejected — NOT prefix-tolerant).
65
+ - **`FIELD_TYPES` map**: stale v0.2 entries removed (`Waybill.shipmentInformation`,
66
+ `Shipment.containedPieces`, `Shipment.consignee`, `Shipment.shipper`,
67
+ `Organization.address`, `Organization.contactPersons`,
68
+ `AccountNumber.issuedBy`); ~40 new entries added for v0.3.0 classes.
69
+ - **Domain constraints** (`domain-constraints.ts`): stale v0.2 constraints
70
+ on `Waybill.shipmentInformation` and `Shipment.containedPieces` removed.
71
+ No spec basis post-Path-A; the corrected cross-node check
72
+ (Waybill↔Shipment inverse-property consistency) is deferred.
73
+
74
+ ### BREAKING CHANGES
75
+
76
+ Consumers upgrading from v0.2.x must audit the following:
77
+
78
+ 1. **`Organization` class removed** — import `Company` instead. Any code
79
+ referencing `OrganizationSchema`, `OrganizationCodec`, `serializeOrganization`,
80
+ or `deserializeOrganization` will break.
81
+ 2. **`Waybill.shipmentInformation` removed** — use `Waybill.shipment`.
82
+ 3. **`Waybill.totalGrossWeight` removed** — field moved to `Shipment`.
83
+ 4. **`Shipment.pieceCount` removed** — no direct replacement (compute from `pieces.length`).
84
+ 5. **`Shipment.totalVolume` removed** — no direct replacement in v0.3.0.
85
+ 6. **`Shipment.containedPieces` removed** — use `Shipment.pieces`.
86
+ 7. **`Shipment.shipper` / `Shipment.consignee` removed** — use `Shipment.involvedParties`
87
+ filtered by `partyRole`.
88
+ 8. **`waybillType` enum**: `DIRECT` is now a valid value — exhaustive switches
89
+ must handle it.
90
+ 9. **`waybillPrefix`**: now accepts alphanumeric `[A-Z0-9]{1,3}` — do not
91
+ assume numeric-only downstream.
92
+ 10. **`waybillNumber`**: now accepts `[A-Z0-9]+` — do not assume numeric-only.
93
+ 11. **`AccountNumber` fields renamed**: `accountNumber` → `textualValue`,
94
+ `accountType` → `accountNumberType`; `issuedBy` removed.
95
+ 12. **`Party.partyDetails`** widened (additive for accept — a bare IRI still
96
+ validates; see MIGRATING.md for detail).
97
+ 13. **`CARGO_ONTOLOGY_VERSION`** changed from `'3.2'` to `'3.2.0'`. Any code
98
+ doing `=== '3.2'` on the constant will need updating.
99
+ 14. **`assertOntologyVersion('3.2.1')`** now throws (previously any mismatch
100
+ with `'3.2'` would throw; now the exact-alias set `{'3.2.0','3.2'}` is
101
+ accepted and everything else including `'3.2.1'` is rejected).
102
+ 15. **`domain_constraint_violation`** for `Waybill.shipmentInformation` /
103
+ `Shipment.containedPieces` no longer fires (those fields no longer exist).
104
+ 16. **`Party.partyRole`**: `'NI'` (also-notify, AWB box 7) is now an accepted
105
+ value — exhaustive `switch` statements over `partyRole` must handle it
106
+ (same migration class as `waybillType` `DIRECT`).
107
+
108
+ ### Spec deviations
109
+
110
+ - **#12 (reworded)**: `Shipment.securityDeclarations` is a documented
111
+ 3.2.1-forward extension — see `docs/spec-deviations.md#12`.
112
+ - **#14 (new)**: Legacy `{unit,value}` shape on 3 pre-existing fields.
113
+ - **#15 (new)**: `Waybill.accountingInformation` is `owl:deprecated` in 3.2-rc2.
114
+ - **#16 (new)**: `BillingDetails` class not modelled in v0.3.0.
115
+
7
116
  ## [0.2.0] - 2026-04-28
8
117
 
9
118
  First publicly verifiable release. Closes 3 of 5 v0.1.x spec
package/MIGRATING.md CHANGED
@@ -2,6 +2,120 @@
2
2
 
3
3
  This file documents one entry per minor release.
4
4
 
5
+ ## Migrating from v0.2.x to v0.3.0
6
+
7
+ v0.3.0 is a **breaking release**. Review every item below before upgrading.
8
+
9
+ ### 1. `Organization` class retired → use `Company`
10
+
11
+ `Organization` is removed. Import and use `Company` instead. Update all
12
+ references to `OrganizationSchema`, `OrganizationCodec`, `serializeOrganization`,
13
+ `deserializeOrganization`.
14
+
15
+ ```typescript
16
+ // Before (v0.2.x)
17
+ import { OrganizationCodec } from '@flaks/onerecord'
18
+ // After (v0.3.0)
19
+ import { CompanyCodec } from '@flaks/onerecord'
20
+ ```
21
+
22
+ ### 2. `Waybill.shipmentInformation` → `Waybill.shipment`
23
+
24
+ ```typescript
25
+ // Before
26
+ waybill.shipmentInformation = 'https://example/sh'
27
+ // After
28
+ waybill.shipment = 'https://example/sh'
29
+ ```
30
+
31
+ ### 3. `Shipment.containedPieces` → `Shipment.pieces`
32
+
33
+ ```typescript
34
+ // Before
35
+ shipment.containedPieces = ['https://example/p1']
36
+ // After
37
+ shipment.pieces = ['https://example/p1']
38
+ ```
39
+
40
+ ### 4. `Shipment.shipper` / `Shipment.consignee` → `Shipment.involvedParties`
41
+
42
+ The `shipper` and `consignee` top-level fields on `Shipment` are removed.
43
+ Use `Shipment.involvedParties` filtered by `partyRole`:
44
+
45
+ ```typescript
46
+ const shipper = shipment.involvedParties?.find(p => p.partyRole === 'SHP')
47
+ const consignee = shipment.involvedParties?.find(p => p.partyRole === 'CNE')
48
+ ```
49
+
50
+ ### 5. `Shipment.pieceCount` / `Shipment.totalVolume` removed
51
+
52
+ No direct replacement in v0.3.0. Compute `pieceCount` from `pieces.length`
53
+ if needed. `totalVolume` is deferred (no spec-correct successor in scope).
54
+
55
+ ### 6. `AccountNumber` field renames
56
+
57
+ | v0.2.x field | v0.3.0 field | Notes |
58
+ |---|---|---|
59
+ | `accountNumber` | `textualValue` | String value of the account number |
60
+ | `accountType` | `accountNumberType` | IRI ref to code value |
61
+ | `issuedBy` | removed | Wrong domain; belongs to `:SecurityDeclaration` |
62
+
63
+ ### 7. `Party.partyDetails` widening — additive for accept
64
+
65
+ `partyDetails` now accepts `Person | Company` (not `Person | Organization`).
66
+ **This is additive for deserializing**: a bare IRI still validates. Code
67
+ that checks `partyDetails['@type'] === 'Organization'` must be updated to
68
+ `'Company'`. The new `NI` value is accepted for `partyRole`.
69
+
70
+ ### 8. `waybillNumber` and `waybillPrefix` regex relaxation
71
+
72
+ - **`waybillNumber`**: now accepts `[A-Z0-9]+` **per the 3.2-rc2 ontology
73
+ pattern**. Do not assume numeric-only (`[0-9]+`) downstream.
74
+ - **`waybillPrefix`**: now accepts up to 3 alphanumeric characters (`[A-Z0-9]{1,3}`)
75
+ as the library's **EDITORIAL policy** — the ontology only specifies
76
+ `xsd:string maxLength 3` with no character-class restriction. Do not assume
77
+ numeric-only downstream.
78
+
79
+ ### 9. `CARGO_ONTOLOGY_VERSION` constant changed
80
+
81
+ The exported constant changed from `'3.2'` to `'3.2.0'`:
82
+
83
+ ```typescript
84
+ // Before: CARGO_ONTOLOGY_VERSION === '3.2'
85
+ // After: CARGO_ONTOLOGY_VERSION === '3.2.0'
86
+ ```
87
+
88
+ Any code doing `=== '3.2'` on the constant must be updated to `=== '3.2.0'`
89
+ (or use `CARGO_ONTOLOGY_VERSION` indirectly).
90
+
91
+ ### 10. `assertOntologyVersion` + `checkServerInformation` — exact-alias peer-compat policy
92
+
93
+ Both functions now use an **exact-alias accepted set**: `{'3.2.0', '3.2'}`.
94
+
95
+ - `assertOntologyVersion('3.2.0')` — does NOT throw (canonical pin)
96
+ - `assertOntologyVersion('3.2')` — does NOT throw (legacy alias ≡ 3.2.0)
97
+ - `assertOntologyVersion('3.2.1')` — THROWS `incompatible_ontology_version`
98
+ - `assertOntologyVersion('4.0')` — THROWS `incompatible_ontology_version`
99
+
100
+ The accepted set is **NOT** prefix-tolerant (`'3.2.1'` is master-only and
101
+ intentionally rejected). `checkServerInformation` follows the same rule:
102
+ a server advertising `cargoOntologyVersion: '3.2.1'` will return
103
+ `compatible: false`.
104
+
105
+ ### 11. `waybillType` enum: `DIRECT` added
106
+
107
+ If your code has an exhaustive `switch` on `waybillType`, add a `'DIRECT'`
108
+ case. TypeScript will surface this at compile time.
109
+
110
+ ### 12. `domain_constraint_violation` for stale fields no longer fires
111
+
112
+ If your code expected `domain_constraint_violation` for a Waybill missing
113
+ `shipmentInformation` or a Shipment missing `containedPieces`, those errors
114
+ no longer fire — those fields don't exist in v0.3.0. Update your error
115
+ handling to match the new field names (`shipment`, `pieces`).
116
+
117
+ ---
118
+
5
119
  ## Migrating from v0.1.x to v0.2.0
6
120
 
7
121
  v0.2.0 is **non-breaking at the call-site level** for v0.1.x consumers.
package/README.md CHANGED
@@ -1,18 +1,19 @@
1
1
  # @flaks/onerecord
2
2
 
3
- Zero-dependency Zod-first TypeScript mapper for the IATA OneRecord cargo data model 3.2 and API spec 2.2.0.
3
+ Zero-dependency Zod-first TypeScript mapper for the IATA OneRecord cargo data model 3.2.0 and API spec 2.2.0.
4
4
 
5
5
  ## What it is
6
6
 
7
7
  `@flaks/onerecord` provides round-trip-safe serialization and deserialization for
8
- 32 OneRecord cargo data model classes. Each class ships with a Zod schema, an
9
- application-layer TypeScript type, a `JsonLd<T>` brand, `serialize` / `serializeStrict`
10
- / `deserialize` functions, and a `Codec` bundle. A factory (`createMapper`) and a
11
- namespaced facade (`onerecord`) cover the two main consumption patterns. Safety
12
- primitives (depth, node, string, array, payload limits; prototype-pollution defense;
13
- IRI validation) run before Zod so that invalid JSON-LD graphs never reach schema
14
- evaluation. All 22 parse-error variants are typed as a discriminated union (`ParseError`)
15
- so callers handle every failure mode exhaustively.
8
+ the OneRecord cargo data model class set (Ring 1–5, booking-flow, and FWB-equivalence
9
+ classes added in v0.3.0). Each class ships with a Zod schema, an application-layer
10
+ TypeScript type, a `JsonLd<T>` brand, `serialize` / `serializeStrict` / `deserialize`
11
+ functions, and a `Codec` bundle. A factory (`createMapper`) and a namespaced facade
12
+ (`onerecord`) cover the two main consumption patterns. Safety primitives (depth, node,
13
+ string, array, payload limits; prototype-pollution defense; IRI validation) run before
14
+ Zod so that invalid JSON-LD graphs never reach schema evaluation. All parse-error
15
+ variants are typed as a discriminated union (`ParseError`) so callers handle every
16
+ failure mode exhaustively.
16
17
 
17
18
  ## Why use this library?
18
19
 
@@ -36,14 +37,20 @@ Use this library if you're building cargo software that needs to:
36
37
  `missing_type`, all surfaced as typed `ParseError` variants. Default
37
38
  per-class deserializers stay structural-only for v0.1.x compatibility;
38
39
  graph-walk is opt-in.
39
- - **Type-check** every parse-failure path: `ParseError` is a 22-variant
40
- discriminated union, so the compiler tells you when you've forgotten a
41
- failure mode.
40
+ - **Type-check** every parse-failure path: `ParseError` is a discriminated
41
+ union, so the compiler tells you when you've forgotten a failure mode.
42
42
 
43
43
  Skip it if you want a generic JSON-LD or RDF toolkit; this is purpose-built
44
44
  for the IATA cargo ontology and the ONE Record API spec 2.2.0.
45
45
 
46
- ### Publicly verifiable
46
+ ### Conformance and verifiability
47
+
48
+ This library is **3.2.0-conformant for the covered class set, with documented
49
+ deviations and 3.2.1-forward extensions**. Specifically:
50
+ `Shipment.securityDeclarations` is accepted as a documented 3.2.1-forward
51
+ extension (deviation #12). Every deviation is recorded in
52
+ [`docs/spec-deviations.md`](docs/spec-deviations.md) — read that before
53
+ adopting if your integration must match the spec verbatim.
47
54
 
48
55
  This library publishes verifiable artifacts so consumers can audit the
49
56
  conformance claim independently:
@@ -51,12 +58,13 @@ conformance claim independently:
51
58
  - All releases are GPG-signed git tags + signed npm tarballs (per
52
59
  [`MAINTENANCE.md`](MAINTENANCE.md)).
53
60
  - Every spec deviation is documented in [`docs/spec-deviations.md`](docs/spec-deviations.md)
54
- with status banners (CLOSED, PARTIAL, deferred-to-v0.3) and explicit
55
- guidance on what consumers should do today.
56
- - Property-based round-trip tests for the eight Ring 1+2 classes
57
- (Waybill, Shipment, Piece, Address, Person, Organization, Party,
58
- AccountNumber) — `serialize(deserialize(x))` is field-equivalent for
59
- any value an `Arbitrary` produces.
61
+ with status banners (CLOSED, PARTIAL, deferred) and explicit guidance
62
+ on what consumers should do today.
63
+ - A [`docs/conformance-matrix.md`](docs/conformance-matrix.md) maps each
64
+ class and field to its binding authority in `IATA-1R-DM-Ontology.ttl`.
65
+ - Property-based round-trip tests for the Ring 1+2 classes
66
+ — `serialize(deserialize(x))` is field-equivalent for any value an
67
+ `Arbitrary` produces.
60
68
  - Contract tests at `test/contract/` exercise the wire format
61
69
  end-to-end against the OLF-hosted reference NE:ONE Server (the IATA
62
70
  OneRecord reference implementation). See [`CONTRIBUTING.md`](CONTRIBUTING.md)
@@ -64,11 +72,11 @@ conformance claim independently:
64
72
 
65
73
  ## Status
66
74
 
67
- `v0.2.0` ships:
75
+ `v0.3.0` ships:
68
76
 
69
- - The 32 canonical cargo data model classes (Ring 1–5 plus booking-flow)
70
- with full round-trip codecs, Zod schemas, snapshot tests, and pre-Zod
71
- safety primitives.
77
+ - The canonical cargo data model class set (Ring 1–5, booking-flow, plus
78
+ 10 new FWB-equivalence classes in v0.3.0) with full round-trip codecs,
79
+ Zod schemas, snapshot tests, and pre-Zod safety primitives.
72
80
  - Opt-in **graph-walk dispatcher** (`createMapper({ graphWalk: true })` or
73
81
  `onerecord.dispatch.deserialize.<Class>`) emitting all four cross-node
74
82
  integrity ParseError kinds.
@@ -87,11 +95,11 @@ conformance claim independently:
87
95
  The library is Apache-2.0 and ready for use within the v0.x stability
88
96
  policy described in [`MIGRATING.md`](MIGRATING.md).
89
97
 
90
- Spec compliance: cargo data model **3.2 (2025-07 endorsed standard)**, API
91
- spec **2.2.0**. A small number of deliberate divergences from canonical
92
- spec behavior are documented in
93
- [`docs/spec-deviations.md`](docs/spec-deviations.md); read that before
94
- adopting if your integration must match the spec verbatim.
98
+ Spec compliance: cargo data model **3.2.0 (2025-07 endorsed standard, 3.2-rc2 file)**,
99
+ API spec **2.2.0**. The library is 3.2.0-conformant for the covered class set,
100
+ with documented deviations and 3.2.1-forward extensions. See
101
+ [`docs/spec-deviations.md`](docs/spec-deviations.md) and
102
+ [`docs/conformance-matrix.md`](docs/conformance-matrix.md) for the full picture.
95
103
 
96
104
  ## Install
97
105
 
@@ -163,7 +171,7 @@ const jsonLd = onerecord.serialize.Piece(piece)
163
171
 
164
172
  ### Per-class exports
165
173
 
166
- Each of the 32 classes exposes:
174
+ Each registered class exposes:
167
175
 
168
176
  | Export | Description |
169
177
  |---|---|
@@ -196,9 +204,9 @@ No bound state; suitable for one-off operations and tree-shake-friendly imports.
196
204
 
197
205
  ### Errors
198
206
 
199
- - `ParseError` — 22-variant discriminated union (`kind` field); covers
200
- `zod_validation`, `cardinality_violation`, `invalid_iri`, `depth_limit_exceeded`,
201
- `prototype_pollution_attempt`, `invalid_pointer`, and 16 more
207
+ - `ParseError` — discriminated union on `kind`; covers `zod_validation`,
208
+ `cardinality_violation`, `invalid_iri`, `depth_limit_exceeded`,
209
+ `prototype_pollution_attempt`, `invalid_pointer`, and more
202
210
  - `SerializationError` — `code: 'invalid_application_object' | 'iri_construction_failed'`
203
211
  - `formatError(e: ParseError): string` — human-readable message
204
212
  - `redactError(e: ParseError): ParseError` — strips PII from error payloads before logging
@@ -288,14 +296,14 @@ import type { Waybill, ParseError } from '@flaks/onerecord/types'
288
296
 
289
297
  | Spec | Version |
290
298
  |---|---|
291
- | Cargo data model | 3.2 (2025-07 endorsed standard) |
299
+ | Cargo data model | 3.2.0 (2025-07 endorsed standard, 3.2-rc2 ontology file) |
292
300
  | API spec | 2.2.0 |
293
301
 
294
302
  ## Development
295
303
 
296
304
  ```bash
297
305
  bun install
298
- bun run test # 518 passing + 10 skipped = 528 total
306
+ bun run test # see CI for current count
299
307
  bun run lint # Biome
300
308
  bun run typecheck # tsc --noEmit
301
309
  ```
@@ -4,13 +4,8 @@ export declare const AccountNumberSchema: z.ZodObject<{
4
4
  '@context': z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
5
5
  '@id': z.ZodString;
6
6
  '@type': z.ZodLiteral<"AccountNumber">;
7
- accountNumber: z.ZodString;
8
- issuedBy: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("../../index.js").SafeIri, string>>>;
9
- accountType: z.ZodOptional<z.ZodEnum<{
10
- IATA_CASS: "IATA_CASS";
11
- INTERNAL: "INTERNAL";
12
- OTHER: "OTHER";
13
- }>>;
7
+ accountNumberType: z.ZodOptional<z.ZodString>;
8
+ textualValue: z.ZodOptional<z.ZodString>;
14
9
  }, z.core.$strict>;
15
10
  export type AccountNumber = z.infer<typeof AccountNumberSchema>;
16
11
  export type JsonLdAccountNumber = JsonLd<'AccountNumber'>;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/classes/account-number/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAGvD,eAAO,MAAM,mBAAmB;;;;;;;;;;;kBAKrB,CAAA;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAC/D,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,eAAe,CAAC,CAAA"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/classes/account-number/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAGvD,eAAO,MAAM,mBAAmB;;;;;;kBASrB,CAAA;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAC/D,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,eAAe,CAAC,CAAA"}
@@ -1,10 +1,13 @@
1
1
  import { z } from 'zod';
2
- import { safeIri } from '../../iri/zod-safe-iri.js';
3
2
  import { LogisticsObjectSchema } from '../shared/logistics-object.js';
4
3
  export const AccountNumberSchema = LogisticsObjectSchema.extend({
5
4
  '@type': z.literal('AccountNumber'),
6
- accountNumber: z.string().max(35),
7
- issuedBy: safeIri().optional(),
8
- accountType: z.enum(['IATA_CASS', 'INTERNAL', 'OTHER']).optional(),
5
+ // :accountNumberType → :AccountType, owl:maxCardinality 1 (TTL DM 4780/4784-4785).
6
+ // String per open-codelist idiom — :AccountType is rdfs:subClassOf :CodeListElement,
7
+ // no owl:oneOf in DM or CL ontology (DM TTL 4801-4805).
8
+ accountNumberType: z.string().min(1).max(16).optional(),
9
+ // :textualValue → xsd:string, owl:maxCardinality 1 (TTL DM 4788/4791-4793). .max(35) = FWB account
10
+ // field width (editorial — the ontology has no length facet).
11
+ textualValue: z.string().min(1).max(35).optional(),
9
12
  }).strict();
10
13
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/classes/account-number/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAEnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAErE,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,MAAM,CAAC;IAC9D,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;IACnC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IACjC,QAAQ,EAAE,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC9B,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE;CACnE,CAAC,CAAC,MAAM,EAAE,CAAA"}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/classes/account-number/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAErE,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,MAAM,CAAC;IAC9D,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;IACnC,mFAAmF;IACnF,qFAAqF;IACrF,wDAAwD;IACxD,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IACvD,mGAAmG;IACnG,8DAA8D;IAC9D,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;CACnD,CAAC,CAAC,MAAM,EAAE,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { Codec } from '../shared/codec.js';
2
+ import type { CO2Emissions, JsonLdCO2Emissions } from './schema.js';
3
+ export declare const CO2EmissionsCodec: Codec<CO2Emissions, JsonLdCO2Emissions, 'CO2Emissions'>;
4
+ //# sourceMappingURL=codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../../src/classes/co2-emissions/codec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAInE,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,YAAY,EAAE,kBAAkB,EAAE,cAAc,CAOzE,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { deserializeCO2Emissions } from './deserialize.js';
2
+ import { CO2EmissionsSchema } from './schema.js';
3
+ import { serializeCO2Emissions, serializeCO2EmissionsStrict } from './serialize.js';
4
+ export const CO2EmissionsCodec = Object.freeze({
5
+ schema: CO2EmissionsSchema,
6
+ serialize: serializeCO2Emissions,
7
+ serializeStrict: serializeCO2EmissionsStrict,
8
+ deserialize: deserializeCO2Emissions,
9
+ type: 'CO2Emissions',
10
+ });
11
+ //# sourceMappingURL=codec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../../src/classes/co2-emissions/codec.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAA;AAEnF,MAAM,CAAC,MAAM,iBAAiB,GAC5B,MAAM,CAAC,MAAM,CAAC;IACZ,MAAM,EAAE,kBAAkB;IAC1B,SAAS,EAAE,qBAAqB;IAChC,eAAe,EAAE,2BAA2B;IAC5C,WAAW,EAAE,uBAAuB;IACpC,IAAI,EAAE,cAAc;CACZ,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { ParseResult } from '../../result.js';
2
+ import type { DeserializeOpts } from '../../safety/limits.js';
3
+ import type { CO2Emissions } from './schema.js';
4
+ export declare function deserializeCO2Emissions(input: unknown, opts?: DeserializeOpts): ParseResult<CO2Emissions>;
5
+ //# sourceMappingURL=deserialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deserialize.d.ts","sourceRoot":"","sources":["../../../src/classes/co2-emissions/deserialize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG/C,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EACd,IAAI,GAAE,eAAoB,GACzB,WAAW,CAAC,YAAY,CAAC,CA2D3B"}
@@ -0,0 +1,64 @@
1
+ import { assertContextAllowed } from '../../context.js';
2
+ import { findInvalidIriInIssues } from '../../iri/zod-safe-iri.js';
3
+ import { preValidate } from '../../safety/pre-validate.js';
4
+ import { findFirstEmptyArray, nullProtoClone, withMeta } from '../shared/parse-utils.js';
5
+ import { CO2EmissionsSchema } from './schema.js';
6
+ export function deserializeCO2Emissions(input, opts = {}) {
7
+ // 1. Pre-Zod sanity (depth/nodes/string/array/payload/pollution/cycle)
8
+ const preOpts = {};
9
+ if (opts.limits !== undefined)
10
+ preOpts.limits = opts.limits;
11
+ if (opts.payloadByteLength !== undefined)
12
+ preOpts.payloadByteLength = opts.payloadByteLength;
13
+ if (opts.meta !== undefined)
14
+ preOpts.meta = opts.meta;
15
+ const pre = preValidate(input, preOpts);
16
+ if (!pre.ok)
17
+ return pre;
18
+ // 2. v2 (A3-B2, A1-M4): @context allowlist enforced before Zod
19
+ if (pre.value && typeof pre.value === 'object' && '@context' in pre.value) {
20
+ const ctxOpts = {};
21
+ if (opts.allowedContexts !== undefined)
22
+ ctxOpts.allowedContexts = opts.allowedContexts;
23
+ if (opts.meta !== undefined)
24
+ ctxOpts.meta = opts.meta;
25
+ const ctxR = assertContextAllowed(pre.value['@context'], ctxOpts);
26
+ if (!ctxR.ok)
27
+ return ctxR;
28
+ }
29
+ // 3. v3 plan correction: empty-array rejection BEFORE Zod
30
+ const empty = findFirstEmptyArray(pre.value, '$');
31
+ if (empty) {
32
+ return {
33
+ ok: false,
34
+ error: withMeta({
35
+ kind: 'cardinality_violation',
36
+ field: empty.field,
37
+ expected: '>=1 or omit',
38
+ got: 0,
39
+ path: empty.path,
40
+ }, opts.meta),
41
+ };
42
+ }
43
+ // 4. Zod parse — lift safeIri-tagged issues to invalid_iri
44
+ const r = CO2EmissionsSchema.safeParse(pre.value);
45
+ if (!r.success) {
46
+ const iriErr = findInvalidIriInIssues(r.error.issues, '$');
47
+ if (iriErr)
48
+ return { ok: false, error: withMeta(iriErr, opts.meta) };
49
+ return {
50
+ ok: false,
51
+ error: withMeta({
52
+ kind: 'zod_validation',
53
+ issues: r.error.issues.map((i) => ({
54
+ path: i.path.length === 0 ? '$' : i.path.join('.'),
55
+ message: i.message,
56
+ code: i.code,
57
+ })),
58
+ }, opts.meta),
59
+ };
60
+ }
61
+ // 5. v2 (A1-M5, A3-M4): null-prototype clone the output graph
62
+ return { ok: true, value: nullProtoClone(r.data) };
63
+ }
64
+ //# sourceMappingURL=deserialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deserialize.js","sourceRoot":"","sources":["../../../src/classes/co2-emissions/deserialize.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,6 @@
1
+ export { CO2EmissionsCodec } from './codec.js';
2
+ export { deserializeCO2Emissions } from './deserialize.js';
3
+ export { CO2EmissionsSchema } from './schema.js';
4
+ export type { CO2Emissions, JsonLdCO2Emissions } from './schema.js';
5
+ export { serializeCO2Emissions, serializeCO2EmissionsStrict } from './serialize.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/classes/co2-emissions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,5 @@
1
+ export { CO2EmissionsCodec } from './codec.js';
2
+ export { deserializeCO2Emissions } from './deserialize.js';
3
+ export { CO2EmissionsSchema } from './schema.js';
4
+ export { serializeCO2Emissions, serializeCO2EmissionsStrict } from './serialize.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/classes/co2-emissions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import type { JsonLd } from '../shared/jsonld-brand.js';
3
+ export declare const CO2EmissionsSchema: z.ZodObject<{
4
+ '@context': z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
5
+ '@id': z.ZodString;
6
+ '@type': z.ZodLiteral<"CO2Emissions">;
7
+ calculatedEmissions: z.ZodOptional<z.ZodObject<{
8
+ '@type': z.ZodOptional<z.ZodLiteral<"Value">>;
9
+ numericalValue: z.ZodNumber;
10
+ unit: z.ZodString;
11
+ }, z.core.$strict>>;
12
+ calculationFor: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("../../index.js").SafeIri, string>>>;
13
+ methodName: z.ZodOptional<z.ZodString>;
14
+ methodVersion: z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strict>;
16
+ export type CO2Emissions = z.infer<typeof CO2EmissionsSchema>;
17
+ export type JsonLdCO2Emissions = JsonLd<'CO2Emissions'>;
18
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/classes/co2-emissions/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAIvD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;kBAMpB,CAAA;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAC7D,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,cAAc,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { z } from 'zod';
2
+ import { safeIri } from '../../iri/zod-safe-iri.js';
3
+ import { LogisticsObjectSchema } from '../shared/logistics-object.js';
4
+ import { ValueSchema } from '../shared/value.js';
5
+ export const CO2EmissionsSchema = LogisticsObjectSchema.extend({
6
+ '@type': z.literal('CO2Emissions'),
7
+ calculatedEmissions: ValueSchema.optional(),
8
+ calculationFor: safeIri().optional(),
9
+ methodName: z.string().min(1).max(128).optional(),
10
+ methodVersion: z.string().min(1).max(64).optional(),
11
+ }).strict();
12
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/classes/co2-emissions/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAEnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,MAAM,CAAC,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,MAAM,CAAC;IAC7D,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;IAClC,mBAAmB,EAAE,WAAW,CAAC,QAAQ,EAAE;IAC3C,cAAc,EAAE,OAAO,EAAE,CAAC,QAAQ,EAAE;IACpC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IACjD,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;CACpD,CAAC,CAAC,MAAM,EAAE,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { ParseResult } from '../../result.js';
2
+ import type { SerializeOpts } from '../../safety/limits.js';
3
+ import type { CO2Emissions, JsonLdCO2Emissions } from './schema.js';
4
+ export declare function serializeCO2Emissions(input: CO2Emissions, _opts?: SerializeOpts): JsonLdCO2Emissions;
5
+ export declare function serializeCO2EmissionsStrict(input: CO2Emissions, _opts?: SerializeOpts): ParseResult<JsonLdCO2Emissions>;
6
+ //# sourceMappingURL=serialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/classes/co2-emissions/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAGnE,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,YAAY,EACnB,KAAK,CAAC,EAAE,aAAa,GACpB,kBAAkB,CAUpB;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,YAAY,EACnB,KAAK,CAAC,EAAE,aAAa,GACpB,WAAW,CAAC,kBAAkB,CAAC,CAgBjC"}