@payoutjp/core 0.1.0-alpha.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 (55) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +11 -0
  3. package/dist/aggregation.d.ts +10 -0
  4. package/dist/aggregation.d.ts.map +1 -0
  5. package/dist/aggregation.js +63 -0
  6. package/dist/aggregation.js.map +1 -0
  7. package/dist/engine.d.ts +12 -0
  8. package/dist/engine.d.ts.map +1 -0
  9. package/dist/engine.js +101 -0
  10. package/dist/engine.js.map +1 -0
  11. package/dist/errors.d.ts +33 -0
  12. package/dist/errors.d.ts.map +1 -0
  13. package/dist/errors.js +73 -0
  14. package/dist/errors.js.map +1 -0
  15. package/dist/finding.d.ts +76 -0
  16. package/dist/finding.d.ts.map +1 -0
  17. package/dist/finding.js +63 -0
  18. package/dist/finding.js.map +1 -0
  19. package/dist/identifier-schema.d.ts +7 -0
  20. package/dist/identifier-schema.d.ts.map +1 -0
  21. package/dist/identifier-schema.js +24 -0
  22. package/dist/identifier-schema.js.map +1 -0
  23. package/dist/identifiers.d.ts +38 -0
  24. package/dist/identifiers.d.ts.map +1 -0
  25. package/dist/identifiers.js +53 -0
  26. package/dist/identifiers.js.map +1 -0
  27. package/dist/index.d.ts +14 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +13 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/profile.d.ts +69 -0
  32. package/dist/profile.d.ts.map +1 -0
  33. package/dist/profile.js +89 -0
  34. package/dist/profile.js.map +1 -0
  35. package/dist/redaction.d.ts +14 -0
  36. package/dist/redaction.d.ts.map +1 -0
  37. package/dist/redaction.js +41 -0
  38. package/dist/redaction.js.map +1 -0
  39. package/dist/registry.d.ts +64 -0
  40. package/dist/registry.d.ts.map +1 -0
  41. package/dist/registry.js +131 -0
  42. package/dist/registry.js.map +1 -0
  43. package/dist/report.d.ts +209 -0
  44. package/dist/report.d.ts.map +1 -0
  45. package/dist/report.js +160 -0
  46. package/dist/report.js.map +1 -0
  47. package/dist/rule.d.ts +32 -0
  48. package/dist/rule.d.ts.map +1 -0
  49. package/dist/rule.js +2 -0
  50. package/dist/rule.js.map +1 -0
  51. package/dist/status.d.ts +19 -0
  52. package/dist/status.d.ts.map +1 -0
  53. package/dist/status.js +27 -0
  54. package/dist/status.js.map +1 -0
  55. package/package.json +43 -0
@@ -0,0 +1,131 @@
1
+ import { createHash } from "node:crypto";
2
+ import { z } from "zod";
3
+ import { PayoutJpIntegrityError } from "./errors.js";
4
+ import { RegistryIdSchema } from "./identifier-schema.js";
5
+ const NonEmptyStringSchema = z.string().min(1);
6
+ const Sha256Schema = z.string().regex(/^[a-f0-9]{64}$/u, "Expected a lowercase SHA-256 digest");
7
+ const IsoDateOrDateTimeSchema = z.union([z.iso.date(), z.iso.datetime({ offset: true })]);
8
+ /** Runtime schema for provenance attached to a Registry snapshot. */
9
+ export const SourceMetadataV1Schema = z.strictObject({
10
+ publisher: NonEmptyStringSchema,
11
+ uri: NonEmptyStringSchema,
12
+ retrievedAt: IsoDateOrDateTimeSchema,
13
+ effectiveAsOf: IsoDateOrDateTimeSchema.optional(),
14
+ license: NonEmptyStringSchema.optional(),
15
+ notes: z.array(NonEmptyStringSchema).optional(),
16
+ });
17
+ /** Creates a strict Registry envelope schema for one payload contract. */
18
+ export function createRegistryEnvelopeV1Schema(payloadSchema) {
19
+ return z.strictObject({
20
+ schemaVersion: z.literal("1"),
21
+ id: RegistryIdSchema,
22
+ version: NonEmptyStringSchema,
23
+ kind: NonEmptyStringSchema,
24
+ sha256: Sha256Schema,
25
+ source: SourceMetadataV1Schema,
26
+ payload: payloadSchema,
27
+ });
28
+ }
29
+ /** Runtime schema for a Registry envelope whose payload contract is not yet selected. */
30
+ export const RegistryEnvelopeV1Schema = createRegistryEnvelopeV1Schema(z.unknown());
31
+ const RegistryEnvelopeDigestInputV1Schema = z.strictObject({
32
+ schemaVersion: z.literal("1"),
33
+ id: RegistryIdSchema,
34
+ version: NonEmptyStringSchema,
35
+ kind: NonEmptyStringSchema,
36
+ sha256: Sha256Schema.optional(),
37
+ source: SourceMetadataV1Schema,
38
+ payload: z.unknown(),
39
+ });
40
+ function canonicalizeJsonValue(value, ancestors) {
41
+ if (value === null || typeof value === "boolean" || typeof value === "string") {
42
+ return JSON.stringify(value);
43
+ }
44
+ if (typeof value === "number") {
45
+ if (!Number.isFinite(value)) {
46
+ throw new TypeError("Canonical JSON accepts only finite numbers");
47
+ }
48
+ return JSON.stringify(value);
49
+ }
50
+ if (typeof value !== "object") {
51
+ throw new TypeError("Canonical JSON accepts only JSON values");
52
+ }
53
+ if (ancestors.has(value)) {
54
+ throw new TypeError("Canonical JSON does not accept cyclic values");
55
+ }
56
+ ancestors.add(value);
57
+ try {
58
+ if (Array.isArray(value)) {
59
+ if (Object.getOwnPropertySymbols(value).length > 0 ||
60
+ Object.keys(value).length !== value.length) {
61
+ throw new TypeError("Canonical JSON accepts only dense arrays");
62
+ }
63
+ const entries = [];
64
+ for (let index = 0; index < value.length; index += 1) {
65
+ const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
66
+ if (descriptor === undefined || !("value" in descriptor)) {
67
+ throw new TypeError("Canonical JSON accepts only dense data arrays");
68
+ }
69
+ entries.push(canonicalizeJsonValue(descriptor.value, ancestors));
70
+ }
71
+ return `[${entries.join(",")}]`;
72
+ }
73
+ const prototype = Object.getPrototypeOf(value);
74
+ if (prototype !== Object.prototype && prototype !== null) {
75
+ throw new TypeError("Canonical JSON accepts only plain objects");
76
+ }
77
+ if (Object.getOwnPropertySymbols(value).length > 0) {
78
+ throw new TypeError("Canonical JSON accepts only string object keys");
79
+ }
80
+ const entries = Object.keys(value)
81
+ .sort()
82
+ .map((key) => {
83
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
84
+ if (descriptor === undefined || !("value" in descriptor)) {
85
+ throw new TypeError("Canonical JSON does not accept accessor properties");
86
+ }
87
+ return `${JSON.stringify(key)}:${canonicalizeJsonValue(descriptor.value, ancestors)}`;
88
+ });
89
+ return `{${entries.join(",")}}`;
90
+ }
91
+ finally {
92
+ ancestors.delete(value);
93
+ }
94
+ }
95
+ /** Serializes finite JSON data with recursively sorted object keys and preserved array order. */
96
+ export function canonicalizeJson(value) {
97
+ return canonicalizeJsonValue(value, new Set());
98
+ }
99
+ /** Calculates the lowercase SHA-256 for a Registry envelope with its digest field omitted. */
100
+ export function calculateRegistryEnvelopeSha256(input) {
101
+ const envelope = RegistryEnvelopeDigestInputV1Schema.parse(input);
102
+ const content = {
103
+ schemaVersion: envelope.schemaVersion,
104
+ id: envelope.id,
105
+ version: envelope.version,
106
+ kind: envelope.kind,
107
+ source: envelope.source,
108
+ payload: envelope.payload,
109
+ };
110
+ return createHash("sha256").update(canonicalizeJson(content), "utf8").digest("hex");
111
+ }
112
+ /** Loads a decoded local Registry and verifies its payload contract and content digest. */
113
+ export function loadRegistryEnvelopeV1(input, payloadSchema = z.unknown()) {
114
+ const parsed = createRegistryEnvelopeV1Schema(payloadSchema).safeParse(input);
115
+ if (!parsed.success) {
116
+ throw new PayoutJpIntegrityError("PJP_REGISTRY_INVALID");
117
+ }
118
+ const envelope = parsed.data;
119
+ let actualDigest;
120
+ try {
121
+ actualDigest = calculateRegistryEnvelopeSha256(envelope);
122
+ }
123
+ catch {
124
+ throw new PayoutJpIntegrityError("PJP_REGISTRY_INVALID");
125
+ }
126
+ if (envelope.sha256 !== actualDigest) {
127
+ throw new PayoutJpIntegrityError("PJP_REGISTRY_DIGEST_MISMATCH");
128
+ }
129
+ return envelope;
130
+ }
131
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,C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AO,EAAyB;IAEvE,MAAM,MAAM,GAAG,8BAA8B,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9E,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,sBAAsB,CAAC,sBAAsB,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC;IAE7B,IAAI,YAAoB,CAAC;IACzB,IAAI,CAAC;QACH,YAAY,GAAG,+BAA+B,CAAC,QAAQ,CAAC,CAAC;IAC3D,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,sBAAsB,CAAC,sBAAsB,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;QACrC,MAAM,IAAI,sBAAsB,CAAC,8BAA8B,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,209 @@
1
+ import { z } from "zod";
2
+ import { type FindingV1 } from "./finding.js";
3
+ /** Canonical payout rails represented in a validation report. */
4
+ export declare const railValues: readonly ["bank_transfer", "jpyc"];
5
+ /** Payout destination rail represented in a validation report. */
6
+ export type Rail = (typeof railValues)[number];
7
+ /** Runtime schema for one validated item and its findings. */
8
+ export declare const ValidationItemReportV1Schema: z.ZodObject<{
9
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").ItemId, string>>;
10
+ index: z.ZodNumber;
11
+ rail: z.ZodEnum<{
12
+ bank_transfer: "bank_transfer";
13
+ jpyc: "jpyc";
14
+ }>;
15
+ status: z.ZodEnum<{
16
+ FAIL: "FAIL";
17
+ PASS: "PASS";
18
+ WARNING: "WARNING";
19
+ }>;
20
+ findings: z.ZodArray<z.ZodObject<{
21
+ schemaVersion: z.ZodLiteral<"1">;
22
+ ruleId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").RuleId, string>>;
23
+ severity: z.ZodEnum<{
24
+ error: "error";
25
+ info: "info";
26
+ warning: "warning";
27
+ }>;
28
+ messageKey: z.ZodString;
29
+ message: z.ZodString;
30
+ path: z.ZodString;
31
+ location: z.ZodOptional<z.ZodObject<{
32
+ file: z.ZodOptional<z.ZodString>;
33
+ line: z.ZodOptional<z.ZodNumber>;
34
+ column: z.ZodOptional<z.ZodNumber>;
35
+ itemIndex: z.ZodOptional<z.ZodNumber>;
36
+ jsonPointer: z.ZodOptional<z.ZodString>;
37
+ }, z.core.$strict>>;
38
+ actual: z.ZodOptional<z.ZodObject<{
39
+ classification: z.ZodEnum<{
40
+ "masked-bank-account": "masked-bank-account";
41
+ "metadata-only": "metadata-only";
42
+ public: "public";
43
+ "redacted-account-holder": "redacted-account-holder";
44
+ "short-wallet-address": "short-wallet-address";
45
+ }>;
46
+ display: z.ZodString;
47
+ }, z.core.$strict>>;
48
+ expected: z.ZodOptional<z.ZodString>;
49
+ remediation: z.ZodOptional<z.ZodObject<{
50
+ code: z.ZodString;
51
+ message: z.ZodString;
52
+ }, z.core.$strict>>;
53
+ profileId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").ProfileId, string>>;
54
+ profileVersion: z.ZodString;
55
+ }, z.core.$strict>>;
56
+ }, z.core.$strict>;
57
+ /** One validated item and its findings. */
58
+ export type ValidationItemReportV1 = z.infer<typeof ValidationItemReportV1Schema>;
59
+ /** Runtime schema for report summary counts before semantic aggregation checks. */
60
+ export declare const ValidationSummaryV1Schema: z.ZodObject<{
61
+ totalItems: z.ZodNumber;
62
+ passedItems: z.ZodNumber;
63
+ warningItems: z.ZodNumber;
64
+ failedItems: z.ZodNumber;
65
+ errors: z.ZodNumber;
66
+ warnings: z.ZodNumber;
67
+ infos: z.ZodNumber;
68
+ }, z.core.$strict>;
69
+ /** Summary counts for a validation report. */
70
+ export type ValidationSummaryV1 = z.infer<typeof ValidationSummaryV1Schema>;
71
+ /** Runtime schema for the tool identity embedded in canonical reports. */
72
+ export declare const ToolReferenceV1Schema: z.ZodObject<{
73
+ name: z.ZodLiteral<"payoutjp">;
74
+ version: z.ZodString;
75
+ }, z.core.$strict>;
76
+ /** Tool identity embedded in a canonical report. */
77
+ export type ToolReferenceV1 = z.infer<typeof ToolReferenceV1Schema>;
78
+ /** Runtime schema for a compatibility profile reference. */
79
+ export declare const ProfileReferenceV1Schema: z.ZodObject<{
80
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").ProfileId, string>>;
81
+ version: z.ZodString;
82
+ status: z.ZodEnum<{
83
+ deprecated: "deprecated";
84
+ experimental: "experimental";
85
+ retired: "retired";
86
+ verified: "verified";
87
+ }>;
88
+ }, z.core.$strict>;
89
+ /** Compatibility profile reference embedded in a report. */
90
+ export type ProfileReferenceV1 = z.infer<typeof ProfileReferenceV1Schema>;
91
+ /** Runtime schema for a content-addressed registry reference. */
92
+ export declare const RegistryReferenceV1Schema: z.ZodObject<{
93
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").RegistryId, string>>;
94
+ version: z.ZodString;
95
+ sha256: z.ZodString;
96
+ }, z.core.$strict>;
97
+ /** Content-addressed registry reference embedded in a report. */
98
+ export type RegistryReferenceV1 = z.infer<typeof RegistryReferenceV1Schema>;
99
+ /** Runtime schema for a structurally and semantically consistent version 1 validation report. */
100
+ export declare const ValidationReportV1Schema: z.ZodObject<{
101
+ schemaVersion: z.ZodLiteral<"1">;
102
+ tool: z.ZodObject<{
103
+ name: z.ZodLiteral<"payoutjp">;
104
+ version: z.ZodString;
105
+ }, z.core.$strict>;
106
+ notices: z.ZodArray<z.ZodString>;
107
+ status: z.ZodEnum<{
108
+ FAIL: "FAIL";
109
+ PASS: "PASS";
110
+ WARNING: "WARNING";
111
+ }>;
112
+ profiles: z.ZodArray<z.ZodObject<{
113
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").ProfileId, string>>;
114
+ version: z.ZodString;
115
+ status: z.ZodEnum<{
116
+ deprecated: "deprecated";
117
+ experimental: "experimental";
118
+ retired: "retired";
119
+ verified: "verified";
120
+ }>;
121
+ }, z.core.$strict>>;
122
+ registries: z.ZodArray<z.ZodObject<{
123
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").RegistryId, string>>;
124
+ version: z.ZodString;
125
+ sha256: z.ZodString;
126
+ }, z.core.$strict>>;
127
+ summary: z.ZodObject<{
128
+ totalItems: z.ZodNumber;
129
+ passedItems: z.ZodNumber;
130
+ warningItems: z.ZodNumber;
131
+ failedItems: z.ZodNumber;
132
+ errors: z.ZodNumber;
133
+ warnings: z.ZodNumber;
134
+ infos: z.ZodNumber;
135
+ }, z.core.$strict>;
136
+ items: z.ZodArray<z.ZodObject<{
137
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").ItemId, string>>;
138
+ index: z.ZodNumber;
139
+ rail: z.ZodEnum<{
140
+ bank_transfer: "bank_transfer";
141
+ jpyc: "jpyc";
142
+ }>;
143
+ status: z.ZodEnum<{
144
+ FAIL: "FAIL";
145
+ PASS: "PASS";
146
+ WARNING: "WARNING";
147
+ }>;
148
+ findings: z.ZodArray<z.ZodObject<{
149
+ schemaVersion: z.ZodLiteral<"1">;
150
+ ruleId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").RuleId, string>>;
151
+ severity: z.ZodEnum<{
152
+ error: "error";
153
+ info: "info";
154
+ warning: "warning";
155
+ }>;
156
+ messageKey: z.ZodString;
157
+ message: z.ZodString;
158
+ path: z.ZodString;
159
+ location: z.ZodOptional<z.ZodObject<{
160
+ file: z.ZodOptional<z.ZodString>;
161
+ line: z.ZodOptional<z.ZodNumber>;
162
+ column: z.ZodOptional<z.ZodNumber>;
163
+ itemIndex: z.ZodOptional<z.ZodNumber>;
164
+ jsonPointer: z.ZodOptional<z.ZodString>;
165
+ }, z.core.$strict>>;
166
+ actual: z.ZodOptional<z.ZodObject<{
167
+ classification: z.ZodEnum<{
168
+ "masked-bank-account": "masked-bank-account";
169
+ "metadata-only": "metadata-only";
170
+ public: "public";
171
+ "redacted-account-holder": "redacted-account-holder";
172
+ "short-wallet-address": "short-wallet-address";
173
+ }>;
174
+ display: z.ZodString;
175
+ }, z.core.$strict>>;
176
+ expected: z.ZodOptional<z.ZodString>;
177
+ remediation: z.ZodOptional<z.ZodObject<{
178
+ code: z.ZodString;
179
+ message: z.ZodString;
180
+ }, z.core.$strict>>;
181
+ profileId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").ProfileId, string>>;
182
+ profileVersion: z.ZodString;
183
+ }, z.core.$strict>>;
184
+ }, z.core.$strict>>;
185
+ }, z.core.$strict>;
186
+ /** Canonical version 1 validation report inferred from {@link ValidationReportV1Schema}. */
187
+ export type ValidationReportV1 = z.infer<typeof ValidationReportV1Schema>;
188
+ /** Item input for canonical report construction; status is always derived. */
189
+ export interface ValidationItemInputV1 {
190
+ readonly id: ValidationItemReportV1["id"];
191
+ readonly index: number;
192
+ readonly rail: Rail;
193
+ readonly findings: readonly FindingV1[];
194
+ }
195
+ /** Inputs whose ordering and aggregate fields are normalized by the report builder. */
196
+ export interface CreateValidationReportV1Input {
197
+ readonly tool: ToolReferenceV1;
198
+ readonly notices?: readonly string[];
199
+ readonly profiles: readonly ProfileReferenceV1[];
200
+ readonly registries: readonly RegistryReferenceV1[];
201
+ readonly items: readonly ValidationItemInputV1[];
202
+ }
203
+ /** Returns Profile references sorted by ID and then version. */
204
+ export declare function sortProfileReferences(profiles: readonly ProfileReferenceV1[]): readonly ProfileReferenceV1[];
205
+ /** Returns Registry references sorted by ID and then version. */
206
+ export declare function sortRegistryReferences(registries: readonly RegistryReferenceV1[]): readonly RegistryReferenceV1[];
207
+ /** Builds a validated canonical report with stable ordering and derived aggregate fields. */
208
+ export declare function createValidationReportV1(input: CreateValidationReportV1Input): ValidationReportV1;
209
+ //# sourceMappingURL=report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2CjC,CAAC;AAEL,4FAA4F;AAC5F,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,8EAA8E;AAC9E,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,SAAS,SAAS,EAAE,CAAC;CACzC;AAED,uFAAuF;AACvF,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACjD,QAAQ,CAAC,UAAU,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACpD,QAAQ,CAAC,KAAK,EAAE,SAAS,qBAAqB,EAAE,CAAC;CAClD;AAaD,gEAAgE;AAChE,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,GACtC,SAAS,kBAAkB,EAAE,CAE/B;AAED,iEAAiE;AACjE,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,SAAS,mBAAmB,EAAE,GACzC,SAAS,mBAAmB,EAAE,CAEhC;AAED,6FAA6F;AAC7F,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,GAAG,kBAAkB,CAyBjG"}
package/dist/report.js ADDED
@@ -0,0 +1,160 @@
1
+ import { z } from "zod";
2
+ import { aggregateItemStatus, aggregateReportStatus, summarizeValidationItems, } from "./aggregation.js";
3
+ import { sortFindings } from "./engine.js";
4
+ import { FindingV1Schema } from "./finding.js";
5
+ import { ItemIdSchema, ProfileIdSchema, RegistryIdSchema } from "./identifier-schema.js";
6
+ import { itemStatusValues, profileStatusValues } from "./status.js";
7
+ /** Canonical payout rails represented in a validation report. */
8
+ export const railValues = Object.freeze(["bank_transfer", "jpyc"]);
9
+ const NonNegativeIntegerSchema = z.number().int().nonnegative();
10
+ const NonEmptyStringSchema = z.string().min(1);
11
+ const Sha256Schema = z.string().regex(/^[a-f0-9]{64}$/u, "Expected a lowercase SHA-256 digest");
12
+ /** Runtime schema for one validated item and its findings. */
13
+ export const ValidationItemReportV1Schema = z.strictObject({
14
+ id: ItemIdSchema,
15
+ index: NonNegativeIntegerSchema,
16
+ rail: z.enum(railValues),
17
+ status: z.enum(itemStatusValues),
18
+ findings: z.array(FindingV1Schema),
19
+ });
20
+ /** Runtime schema for report summary counts before semantic aggregation checks. */
21
+ export const ValidationSummaryV1Schema = z.strictObject({
22
+ totalItems: NonNegativeIntegerSchema,
23
+ passedItems: NonNegativeIntegerSchema,
24
+ warningItems: NonNegativeIntegerSchema,
25
+ failedItems: NonNegativeIntegerSchema,
26
+ errors: NonNegativeIntegerSchema,
27
+ warnings: NonNegativeIntegerSchema,
28
+ infos: NonNegativeIntegerSchema,
29
+ });
30
+ /** Runtime schema for the tool identity embedded in canonical reports. */
31
+ export const ToolReferenceV1Schema = z.strictObject({
32
+ name: z.literal("payoutjp"),
33
+ version: NonEmptyStringSchema,
34
+ });
35
+ /** Runtime schema for a compatibility profile reference. */
36
+ export const ProfileReferenceV1Schema = z.strictObject({
37
+ id: ProfileIdSchema,
38
+ version: NonEmptyStringSchema,
39
+ status: z.enum(profileStatusValues),
40
+ });
41
+ /** Runtime schema for a content-addressed registry reference. */
42
+ export const RegistryReferenceV1Schema = z.strictObject({
43
+ id: RegistryIdSchema,
44
+ version: NonEmptyStringSchema,
45
+ sha256: Sha256Schema,
46
+ });
47
+ function rejectDuplicateReferences(references, context, kind) {
48
+ const seen = new Set();
49
+ references.forEach((reference, index) => {
50
+ const key = `${reference.id}\0${reference.version}`;
51
+ if (seen.has(key)) {
52
+ context.addIssue({
53
+ code: "custom",
54
+ message: `Duplicate ${kind} reference`,
55
+ path: [index],
56
+ });
57
+ }
58
+ seen.add(key);
59
+ });
60
+ }
61
+ const ProfileReferencesSchema = z
62
+ .array(ProfileReferenceV1Schema)
63
+ .superRefine((references, context) => rejectDuplicateReferences(references, context, "profile"));
64
+ const RegistryReferencesSchema = z
65
+ .array(RegistryReferenceV1Schema)
66
+ .superRefine((references, context) => rejectDuplicateReferences(references, context, "registry"));
67
+ /** Runtime schema for the canonical version 1 validation report contract. */
68
+ const summaryFields = Object.freeze([
69
+ "totalItems",
70
+ "passedItems",
71
+ "warningItems",
72
+ "failedItems",
73
+ "errors",
74
+ "warnings",
75
+ "infos",
76
+ ]);
77
+ /** Runtime schema for a structurally and semantically consistent version 1 validation report. */
78
+ export const ValidationReportV1Schema = z
79
+ .strictObject({
80
+ schemaVersion: z.literal("1"),
81
+ tool: ToolReferenceV1Schema,
82
+ notices: z.array(NonEmptyStringSchema),
83
+ status: z.enum(itemStatusValues),
84
+ profiles: ProfileReferencesSchema,
85
+ registries: RegistryReferencesSchema,
86
+ summary: ValidationSummaryV1Schema,
87
+ items: z.array(ValidationItemReportV1Schema),
88
+ })
89
+ .superRefine((report, context) => {
90
+ const itemStatuses = report.items.map((item, index) => {
91
+ const expected = aggregateItemStatus(item.findings);
92
+ if (item.status !== expected) {
93
+ context.addIssue({
94
+ code: "custom",
95
+ message: "Item status does not match its findings",
96
+ path: ["items", index, "status"],
97
+ });
98
+ }
99
+ return expected;
100
+ });
101
+ const expectedStatus = aggregateReportStatus(itemStatuses);
102
+ if (report.status !== expectedStatus) {
103
+ context.addIssue({
104
+ code: "custom",
105
+ message: "Report status does not match its items",
106
+ path: ["status"],
107
+ });
108
+ }
109
+ const expectedSummary = summarizeValidationItems(report.items);
110
+ for (const field of summaryFields) {
111
+ if (report.summary[field] !== expectedSummary[field]) {
112
+ context.addIssue({
113
+ code: "custom",
114
+ message: "Report summary does not match its items",
115
+ path: ["summary", field],
116
+ });
117
+ }
118
+ }
119
+ });
120
+ function compareStrings(left, right) {
121
+ return left < right ? -1 : left > right ? 1 : 0;
122
+ }
123
+ function compareVersionedReferences(left, right) {
124
+ return compareStrings(left.id, right.id) || compareStrings(left.version, right.version);
125
+ }
126
+ /** Returns Profile references sorted by ID and then version. */
127
+ export function sortProfileReferences(profiles) {
128
+ return [...profiles].sort(compareVersionedReferences);
129
+ }
130
+ /** Returns Registry references sorted by ID and then version. */
131
+ export function sortRegistryReferences(registries) {
132
+ return [...registries].sort(compareVersionedReferences);
133
+ }
134
+ /** Builds a validated canonical report with stable ordering and derived aggregate fields. */
135
+ export function createValidationReportV1(input) {
136
+ const items = input.items
137
+ .map((item) => {
138
+ const findings = [...sortFindings(item.findings)];
139
+ return {
140
+ id: item.id,
141
+ index: item.index,
142
+ rail: item.rail,
143
+ status: aggregateItemStatus(findings),
144
+ findings,
145
+ };
146
+ })
147
+ .sort((left, right) => left.index - right.index || compareStrings(left.id, right.id));
148
+ const itemStatuses = items.map((item) => item.status);
149
+ return ValidationReportV1Schema.parse({
150
+ schemaVersion: "1",
151
+ tool: input.tool,
152
+ notices: [...(input.notices ?? [])],
153
+ status: aggregateReportStatus(itemStatuses),
154
+ profiles: sortProfileReferences(input.profiles),
155
+ registries: sortRegistryReferences(input.registries),
156
+ summary: summarizeValidationItems(items),
157
+ items,
158
+ });
159
+ }
160
+ //# sourceMappingURL=report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAkB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAA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AAC;QACxC,KAAK;KACN,CAAC,CAAC;AACL,CAAC"}
package/dist/rule.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ import type { FindingV1 } from "./finding.js";
2
+ import type { ItemId, RuleId } from "./identifiers.js";
3
+ import type { CompatibilityProfileV1 } from "./profile.js";
4
+ import type { RegistryEnvelopeV1 } from "./registry.js";
5
+ import type { Severity } from "./status.js";
6
+ /**
7
+ * Immutable input shared with a rule during applicability checks and evaluation.
8
+ *
9
+ * Destination, params, Registry payload, and optional application configuration
10
+ * remain generic while Profile and Registry envelopes use their runtime contracts.
11
+ */
12
+ export interface RuleContextV1<TDestination = unknown, TParams = unknown, TRegistryPayload = unknown, TApplicationConfig = unknown> {
13
+ readonly destination: TDestination;
14
+ readonly applicationConfig?: TApplicationConfig;
15
+ readonly profile: CompatibilityProfileV1;
16
+ readonly params: TParams;
17
+ readonly registries: ReadonlyMap<string, RegistryEnvelopeV1<TRegistryPayload>>;
18
+ readonly itemIndex: number;
19
+ readonly itemId: ItemId;
20
+ }
21
+ /** A pure, synchronous validation rule specialized for one context shape. */
22
+ export interface Rule<TContext extends RuleContextV1 = RuleContextV1> {
23
+ readonly id: RuleId;
24
+ readonly defaultSeverity: Severity;
25
+ /** Parses and validates the rule-specific params supplied by a Profile. */
26
+ parseParams(input: unknown): TContext["params"];
27
+ /** Determines whether the rule applies without mutating the context. */
28
+ applies(context: Readonly<TContext>): boolean;
29
+ /** Evaluates the context without I/O or mutation and returns report-ready findings. */
30
+ evaluate(context: Readonly<TContext>): readonly FindingV1[];
31
+ }
32
+ //# sourceMappingURL=rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule.d.ts","sourceRoot":"","sources":["../src/rule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB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sourceRoot":"","sources":["../src/rule.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ /** Canonical finding severities. */
2
+ export declare const severityValues: readonly ["error", "warning", "info"];
3
+ /** Severity assigned to a validation finding. */
4
+ export type Severity = (typeof severityValues)[number];
5
+ /** Canonical validation item and report statuses. */
6
+ export declare const itemStatusValues: readonly ["PASS", "WARNING", "FAIL"];
7
+ /** Aggregated status shared by validation items and reports. */
8
+ export type ItemStatus = (typeof itemStatusValues)[number];
9
+ /** Canonical lifecycle statuses for compatibility profiles. */
10
+ export declare const profileStatusValues: readonly ["verified", "experimental", "deprecated", "retired"];
11
+ /** Lifecycle status of a compatibility profile. */
12
+ export type ProfileStatus = (typeof profileStatusValues)[number];
13
+ /** Returns whether an unknown value is a canonical finding severity. */
14
+ export declare function isSeverity(value: unknown): value is Severity;
15
+ /** Returns whether an unknown value is a canonical validation item/report status. */
16
+ export declare function isItemStatus(value: unknown): value is ItemStatus;
17
+ /** Returns whether an unknown value is a canonical compatibility profile status. */
18
+ export declare function isProfileStatus(value: unknown): value is ProfileStatus;
19
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,eAAO,MAAM,cAAc,uCAAuD,CAAC;AAEnF,iDAAiD;AACjD,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,qDAAqD;AACrD,eAAO,MAAM,gBAAgB,sCAAsD,CAAC;AAEpF,gEAAgE;AAChE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D,+DAA+D;AAC/D,eAAO,MAAM,mBAAmB,gEAKrB,CAAC;AAEZ,mDAAmD;AACnD,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AASjE,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAED,qFAAqF;AACrF,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE"}
package/dist/status.js ADDED
@@ -0,0 +1,27 @@
1
+ /** Canonical finding severities. */
2
+ export const severityValues = Object.freeze(["error", "warning", "info"]);
3
+ /** Canonical validation item and report statuses. */
4
+ export const itemStatusValues = Object.freeze(["PASS", "WARNING", "FAIL"]);
5
+ /** Canonical lifecycle statuses for compatibility profiles. */
6
+ export const profileStatusValues = Object.freeze([
7
+ "verified",
8
+ "experimental",
9
+ "deprecated",
10
+ "retired",
11
+ ]);
12
+ function isStringMember(values, value) {
13
+ return typeof value === "string" && values.some((candidate) => candidate === value);
14
+ }
15
+ /** Returns whether an unknown value is a canonical finding severity. */
16
+ export function isSeverity(value) {
17
+ return isStringMember(severityValues, value);
18
+ }
19
+ /** Returns whether an unknown value is a canonical validation item/report status. */
20
+ export function isItemStatus(value) {
21
+ return isStringMember(itemStatusValues, value);
22
+ }
23
+ /** Returns whether an unknown value is a canonical compatibility profile status. */
24
+ export function isProfileStatus(value) {
25
+ return isStringMember(profileStatusValues, value);
26
+ }
27
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAU,CAAC,CAAC;AAKnF,qDAAqD;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAU,CAAC,CAAC;AAKpF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC/C,UAAU;IACV,cAAc;IACd,YAAY;IACZ,SAAS;CACD,CAAC,CAAC;AAKZ,SAAS,cAAc,CACrB,MAAc,EACd,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC;AACtF,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,cAAc,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,cAAc,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,cAAc,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC"}