@actuarial-ts/interchange 0.5.0 → 0.6.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 (58) hide show
  1. package/README.md +36 -70
  2. package/dist/convert/diagnosticDefinition.d.ts +16 -0
  3. package/dist/convert/diagnosticDefinition.d.ts.map +1 -0
  4. package/dist/convert/diagnosticDefinition.js +82 -0
  5. package/dist/convert/diagnosticDefinition.js.map +1 -0
  6. package/dist/convert/result.d.ts.map +1 -1
  7. package/dist/convert/result.js +2 -2
  8. package/dist/convert/result.js.map +1 -1
  9. package/dist/envelope.d.ts +6 -6
  10. package/dist/envelope.d.ts.map +1 -1
  11. package/dist/envelope.js +13 -7
  12. package/dist/envelope.js.map +1 -1
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +2 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/json.d.ts +5 -0
  18. package/dist/json.d.ts.map +1 -0
  19. package/dist/json.js +13 -0
  20. package/dist/json.js.map +1 -0
  21. package/dist/parse.d.ts +2 -1
  22. package/dist/parse.d.ts.map +1 -1
  23. package/dist/parse.js +8 -2
  24. package/dist/parse.js.map +1 -1
  25. package/dist/schemas/bundle.d.ts +2 -0
  26. package/dist/schemas/bundle.d.ts.map +1 -1
  27. package/dist/schemas/bundle.js +2 -0
  28. package/dist/schemas/bundle.js.map +1 -1
  29. package/dist/schemas/crosscheck.d.ts +6 -6
  30. package/dist/schemas/diagnosticDefinition.d.ts +11572 -0
  31. package/dist/schemas/diagnosticDefinition.d.ts.map +1 -0
  32. package/dist/schemas/diagnosticDefinition.js +133 -0
  33. package/dist/schemas/diagnosticDefinition.js.map +1 -0
  34. package/dist/schemas/manifest.d.ts.map +1 -1
  35. package/dist/schemas/manifest.js +7 -1
  36. package/dist/schemas/manifest.js.map +1 -1
  37. package/dist/schemas/record.d.ts +5 -0
  38. package/dist/schemas/record.d.ts.map +1 -0
  39. package/dist/schemas/record.js +9 -0
  40. package/dist/schemas/record.js.map +1 -0
  41. package/dist/schemas/result.d.ts +12 -12
  42. package/dist/schemas/selection.d.ts +6 -6
  43. package/dist/schemas/triangle.d.ts +89 -89
  44. package/dist/schemas/triangle.d.ts.map +1 -1
  45. package/dist/schemas/triangle.js +20 -5
  46. package/dist/schemas/triangle.js.map +1 -1
  47. package/package.json +4 -3
  48. package/src/convert/diagnosticDefinition.ts +150 -0
  49. package/src/convert/result.ts +2 -1
  50. package/src/envelope.ts +28 -9
  51. package/src/index.ts +2 -0
  52. package/src/json.ts +17 -0
  53. package/src/parse.ts +11 -3
  54. package/src/schemas/bundle.ts +3 -0
  55. package/src/schemas/diagnosticDefinition.ts +172 -0
  56. package/src/schemas/manifest.ts +7 -1
  57. package/src/schemas/record.ts +16 -0
  58. package/src/schemas/triangle.ts +23 -5
@@ -1,3 +1,4 @@
1
+ import { isRealIsoDate } from "@actuarial-ts/core";
1
2
  import { z } from "zod";
2
3
  import { envelopeShape } from "../envelope.js";
3
4
 
@@ -29,7 +30,12 @@ export type CoreMeasure = (typeof CORE_MEASURES)[number];
29
30
 
30
31
  export const measureSchema = z.union([
31
32
  z.enum([...CORE_MEASURES, "earnedPremium"]),
32
- z.string().regex(/^custom:.+$/, 'custom measures must be namespaced as "custom:<label>"'),
33
+ z
34
+ .string()
35
+ .regex(
36
+ /^custom:.+$/,
37
+ 'custom measures must be namespaced as "custom:<label>"',
38
+ ),
33
39
  ]);
34
40
 
35
41
  export type Measure = z.infer<typeof measureSchema>;
@@ -43,7 +49,9 @@ export const originLengthMonthsSchema = z.union([
43
49
 
44
50
  export type OriginLengthMonths = z.infer<typeof originLengthMonthsSchema>;
45
51
 
46
- const isoDateSchema = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "expected an ISO yyyy-mm-dd date");
52
+ const isoDateSchema = z
53
+ .string()
54
+ .refine(isRealIsoDate, "expected a real ISO yyyy-mm-dd date");
47
55
 
48
56
  export const triangleOriginSchema = z
49
57
  .object({ label: z.string().min(1), start: isoDateSchema })
@@ -51,7 +59,11 @@ export const triangleOriginSchema = z
51
59
 
52
60
  /** Bulk-lane reference (spec 3.3). */
53
61
  export const valuesRefSchema = z
54
- .object({ format: z.literal("arrow"), path: z.string().min(1), sha256: z.string().min(1) })
62
+ .object({
63
+ format: z.literal("arrow"),
64
+ path: z.string().min(1),
65
+ sha256: z.string().min(1),
66
+ })
55
67
  .passthrough();
56
68
 
57
69
  export const triangleBodySchema = z
@@ -73,10 +85,16 @@ export const triangleBodySchema = z
73
85
  .passthrough()
74
86
  .optional(),
75
87
  units: z
76
- .object({ currency: z.string().optional(), scale: z.number().positive().optional() })
88
+ .object({
89
+ currency: z.string().optional(),
90
+ scale: z.number().positive().optional(),
91
+ })
92
+ .passthrough()
93
+ .optional(),
94
+ segment: z
95
+ .object({ labels: z.record(z.string()) })
77
96
  .passthrough()
78
97
  .optional(),
79
- segment: z.object({ labels: z.record(z.string()) }).passthrough().optional(),
80
98
  })
81
99
  .passthrough()
82
100
  .superRefine((body, ctx) => {