@actuarial-ts/interchange 0.2.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 (64) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +52 -0
  4. package/dist/convert/result.d.ts +45 -0
  5. package/dist/convert/result.d.ts.map +1 -0
  6. package/dist/convert/result.js +122 -0
  7. package/dist/convert/result.js.map +1 -0
  8. package/dist/convert/selection.d.ts +114 -0
  9. package/dist/convert/selection.d.ts.map +1 -0
  10. package/dist/convert/selection.js +383 -0
  11. package/dist/convert/selection.js.map +1 -0
  12. package/dist/convert/triangle.d.ts +49 -0
  13. package/dist/convert/triangle.d.ts.map +1 -0
  14. package/dist/convert/triangle.js +111 -0
  15. package/dist/convert/triangle.js.map +1 -0
  16. package/dist/envelope.d.ts +113 -0
  17. package/dist/envelope.d.ts.map +1 -0
  18. package/dist/envelope.js +139 -0
  19. package/dist/envelope.js.map +1 -0
  20. package/dist/index.d.ts +15 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +15 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/parse.d.ts +38 -0
  25. package/dist/parse.d.ts.map +1 -0
  26. package/dist/parse.js +48 -0
  27. package/dist/parse.js.map +1 -0
  28. package/dist/referee/crosscheck.d.ts +38 -0
  29. package/dist/referee/crosscheck.d.ts.map +1 -0
  30. package/dist/referee/crosscheck.js +212 -0
  31. package/dist/referee/crosscheck.js.map +1 -0
  32. package/dist/referee/profiles.d.ts +36 -0
  33. package/dist/referee/profiles.d.ts.map +1 -0
  34. package/dist/referee/profiles.js +80 -0
  35. package/dist/referee/profiles.js.map +1 -0
  36. package/dist/schemas/bundle.d.ts +45 -0
  37. package/dist/schemas/bundle.d.ts.map +1 -0
  38. package/dist/schemas/bundle.js +20 -0
  39. package/dist/schemas/bundle.js.map +1 -0
  40. package/dist/schemas/crosscheck.d.ts +3567 -0
  41. package/dist/schemas/crosscheck.d.ts.map +1 -0
  42. package/dist/schemas/crosscheck.js +72 -0
  43. package/dist/schemas/crosscheck.js.map +1 -0
  44. package/dist/schemas/manifest.d.ts +43 -0
  45. package/dist/schemas/manifest.d.ts.map +1 -0
  46. package/dist/schemas/manifest.js +39 -0
  47. package/dist/schemas/manifest.js.map +1 -0
  48. package/dist/schemas/result.d.ts +2163 -0
  49. package/dist/schemas/result.d.ts.map +1 -0
  50. package/dist/schemas/result.js +95 -0
  51. package/dist/schemas/result.js.map +1 -0
  52. package/dist/schemas/selection.d.ts +10388 -0
  53. package/dist/schemas/selection.d.ts.map +1 -0
  54. package/dist/schemas/selection.js +138 -0
  55. package/dist/schemas/selection.js.map +1 -0
  56. package/dist/schemas/study.d.ts +62 -0
  57. package/dist/schemas/study.d.ts.map +1 -0
  58. package/dist/schemas/study.js +35 -0
  59. package/dist/schemas/study.js.map +1 -0
  60. package/dist/schemas/triangle.d.ts +1260 -0
  61. package/dist/schemas/triangle.d.ts.map +1 -0
  62. package/dist/schemas/triangle.js +120 -0
  63. package/dist/schemas/triangle.js.map +1 -0
  64. package/package.json +66 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/schemas/result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;gCAKlB,CAAC;AAEjB,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;gCAEd,CAAC;AAEjB,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;gCAOlB,CAAC;AAEjB,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAA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;YAbzE,gEAAgE;;;;;;YAAhE,gEAAgE;;;;;;YAAhE,gEAAgE;;;;;;;;;;;;;;;;;;;;;;;QAahE,yEAAyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAa7D,CAAC;AAEjB,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
@@ -0,0 +1,95 @@
1
+ import { z } from "zod";
2
+ import { envelopeShape, generatorSchema, integritySchema } from "../envelope.js";
3
+ /**
4
+ * MethodResultDoc / StochasticResultDoc (spec 3.2).
5
+ *
6
+ * - `appliesTo` links results to their inputs by integrity tag;
7
+ * `selectionIntegrity` is null for runs with no selection document.
8
+ * - Method namespaces: actuarial-ts discriminants unprefixed, `clpy:` for
9
+ * chainladder-python, `rcl:` for R ChainLadder.
10
+ * - `effectiveParameters` records what the engine ACTUALLY did when it
11
+ * deviated from what was requested (R's est.sigma auto-fallback);
12
+ * absent = as requested. The referee downgrades requested≠effective
13
+ * comparisons with a comparability warning.
14
+ * - StochasticResultDoc adds seed/nSims/summary/byOrigin; samples travel
15
+ * only via `samplesRef` in the bulk lane. Cross-engine stochastic
16
+ * comparison is distribution-level only.
17
+ */
18
+ export const resultAppliesToSchema = z
19
+ .object({
20
+ triangleIntegrity: integritySchema,
21
+ selectionIntegrity: integritySchema.nullable(),
22
+ })
23
+ .passthrough();
24
+ export const engineStampSchema = generatorSchema
25
+ .extend({ conventionProfile: z.string().optional() })
26
+ .passthrough();
27
+ export const methodResultRowSchema = z
28
+ .object({
29
+ origin: z.string().min(1),
30
+ ultimate: z.number().finite(),
31
+ unpaid: z.number().finite(),
32
+ standardError: z.number().finite().optional(),
33
+ })
34
+ .passthrough();
35
+ export const methodResultTotalsSchema = z
36
+ .object({
37
+ ultimate: z.number().finite(),
38
+ unpaid: z.number().finite(),
39
+ standardError: z.number().finite().optional(),
40
+ })
41
+ .passthrough();
42
+ const resultCommonShape = {
43
+ appliesTo: resultAppliesToSchema,
44
+ engine: engineStampSchema,
45
+ method: z.string().min(1),
46
+ parameters: z.record(z.unknown()),
47
+ effectiveParameters: z.record(z.unknown()).optional(),
48
+ warnings: z.array(z.string()).optional(),
49
+ };
50
+ export const methodResultBodySchema = z
51
+ .object({
52
+ ...resultCommonShape,
53
+ rows: z.array(methodResultRowSchema),
54
+ totals: methodResultTotalsSchema,
55
+ })
56
+ .passthrough();
57
+ export const methodResultDocSchema = z
58
+ .object({
59
+ ...envelopeShape("method-result"),
60
+ result: methodResultBodySchema,
61
+ })
62
+ .passthrough();
63
+ /** Bulk-lane reference for raw simulation output (spec 3.3). */
64
+ export const samplesRefSchema = z
65
+ .object({ format: z.literal("arrow"), path: z.string().min(1), sha256: z.string().min(1) })
66
+ .passthrough();
67
+ export const stochasticSummarySchema = z
68
+ .object({
69
+ mean: z.number().finite(),
70
+ sd: z.number().finite(),
71
+ cv: z.number().finite().nullable(),
72
+ /** e.g. { "75": ..., "95": ... } — percentile label → value. */
73
+ percentiles: z.record(z.number().finite()),
74
+ })
75
+ .passthrough();
76
+ export const stochasticResultBodySchema = z
77
+ .object({
78
+ ...resultCommonShape,
79
+ seed: z.number().int().optional(),
80
+ nSims: z.number().int().positive(),
81
+ summary: stochasticSummarySchema,
82
+ byOrigin: z.array(z.object({ origin: z.string().min(1) }).passthrough()),
83
+ samplesRef: samplesRefSchema.optional(),
84
+ /** Point-estimate rows/totals may accompany the distribution summary. */
85
+ rows: z.array(methodResultRowSchema).optional(),
86
+ totals: methodResultTotalsSchema.optional(),
87
+ })
88
+ .passthrough();
89
+ export const stochasticResultDocSchema = z
90
+ .object({
91
+ ...envelopeShape("stochastic-result"),
92
+ result: stochasticResultBodySchema,
93
+ })
94
+ .passthrough();
95
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/schemas/result.ts"],"names":[],"mappings":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