@oxyhq/crowdsource-contracts 0.3.0 → 0.4.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 (81) hide show
  1. package/dist/appeals.d.ts +323 -0
  2. package/dist/appeals.d.ts.map +1 -0
  3. package/dist/appeals.js +203 -0
  4. package/dist/appeals.js.map +1 -0
  5. package/dist/case-envelope.d.ts +3 -3
  6. package/dist/case-envelope.d.ts.map +1 -1
  7. package/dist/case-envelope.js +32 -32
  8. package/dist/case-envelope.js.map +1 -1
  9. package/dist/decisions.d.ts +1 -1
  10. package/dist/decisions.d.ts.map +1 -1
  11. package/dist/decisions.js +28 -28
  12. package/dist/decisions.js.map +1 -1
  13. package/dist/esm/appeals.js +200 -0
  14. package/dist/esm/appeals.js.map +1 -0
  15. package/dist/esm/case-envelope.js +380 -0
  16. package/dist/esm/case-envelope.js.map +1 -0
  17. package/dist/esm/closed.js +32 -0
  18. package/dist/esm/closed.js.map +1 -0
  19. package/dist/esm/decisions.js +195 -0
  20. package/dist/esm/decisions.js.map +1 -0
  21. package/dist/esm/index.js +48 -0
  22. package/dist/esm/index.js.map +1 -0
  23. package/dist/esm/json-schema.js +84 -0
  24. package/dist/esm/json-schema.js.map +1 -0
  25. package/dist/esm/package.json +1 -0
  26. package/dist/esm/policies.js +175 -0
  27. package/dist/esm/policies.js.map +1 -0
  28. package/dist/esm/primitives.js +249 -0
  29. package/dist/esm/primitives.js.map +1 -0
  30. package/dist/esm/reputation-events.js +125 -0
  31. package/dist/esm/reputation-events.js.map +1 -0
  32. package/dist/esm/resources.js +455 -0
  33. package/dist/esm/resources.js.map +1 -0
  34. package/dist/esm/reviewer-surface.js +612 -0
  35. package/dist/esm/reviewer-surface.js.map +1 -0
  36. package/dist/esm/reviews.js +141 -0
  37. package/dist/esm/reviews.js.map +1 -0
  38. package/dist/esm/taxonomy.js +278 -0
  39. package/dist/esm/taxonomy.js.map +1 -0
  40. package/dist/esm/webhooks.js +188 -0
  41. package/dist/esm/webhooks.js.map +1 -0
  42. package/dist/index.d.ts +13 -11
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +13 -11
  45. package/dist/index.js.map +1 -1
  46. package/dist/json-schema.d.ts +1 -1
  47. package/dist/json-schema.d.ts.map +1 -1
  48. package/dist/json-schema.js +25 -20
  49. package/dist/json-schema.js.map +1 -1
  50. package/dist/policies.d.ts +1 -1
  51. package/dist/policies.d.ts.map +1 -1
  52. package/dist/policies.js +14 -14
  53. package/dist/policies.js.map +1 -1
  54. package/dist/reputation-events.js +19 -19
  55. package/dist/reputation-events.js.map +1 -1
  56. package/dist/resources.d.ts +60 -2
  57. package/dist/resources.d.ts.map +1 -1
  58. package/dist/resources.js +116 -103
  59. package/dist/resources.js.map +1 -1
  60. package/dist/reviewer-surface.d.ts +1956 -0
  61. package/dist/reviewer-surface.d.ts.map +1 -0
  62. package/dist/reviewer-surface.js +615 -0
  63. package/dist/reviewer-surface.js.map +1 -0
  64. package/dist/reviews.js +15 -15
  65. package/dist/reviews.js.map +1 -1
  66. package/dist/webhooks.d.ts +1 -1
  67. package/dist/webhooks.d.ts.map +1 -1
  68. package/dist/webhooks.js +18 -18
  69. package/dist/webhooks.js.map +1 -1
  70. package/package.json +4 -4
  71. package/src/appeals.ts +229 -0
  72. package/src/case-envelope.ts +5 -5
  73. package/src/decisions.ts +6 -6
  74. package/src/index.ts +13 -11
  75. package/src/json-schema.ts +12 -7
  76. package/src/policies.ts +3 -3
  77. package/src/reputation-events.ts +4 -4
  78. package/src/resources.ts +99 -73
  79. package/src/reviewer-surface.ts +715 -0
  80. package/src/reviews.ts +4 -4
  81. package/src/webhooks.ts +4 -4
package/dist/reviews.js CHANGED
@@ -22,10 +22,10 @@
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.RecusalSubmissionSchema = exports.RecusalReasonSchema = exports.RECUSAL_REASONS = exports.ReviewSubmissionSchema = exports.ReviewFindingSchema = exports.ContextSufficiencySchema = exports.CONTEXT_SUFFICIENCIES = exports.ReviewOutcomeSchema = exports.REVIEW_OUTCOMES = void 0;
24
24
  const zod_1 = require("zod");
25
- const primitives_1 = require("./primitives");
26
- const policies_1 = require("./policies");
27
- const resources_1 = require("./resources");
28
- const taxonomy_1 = require("./taxonomy");
25
+ const primitives_js_1 = require("./primitives.js");
26
+ const policies_js_1 = require("./policies.js");
27
+ const resources_js_1 = require("./resources.js");
28
+ const taxonomy_js_1 = require("./taxonomy.js");
29
29
  /**
30
30
  * What a single reviewer can conclude.
31
31
  *
@@ -68,12 +68,12 @@ exports.ContextSufficiencySchema = zod_1.z.enum(exports.CONTEXT_SUFFICIENCIES);
68
68
  * weights the vote.
69
69
  */
70
70
  exports.ReviewFindingSchema = zod_1.z.strictObject({
71
- code: taxonomy_1.TaxonomyCodeSchema,
72
- resourceIds: zod_1.z.array(resources_1.ResourceIdSchema).min(1).max(primitives_1.CONTRACT_LIMITS.RESOURCE_REFS_PER_FINDING_MAX),
73
- severity: taxonomy_1.SeveritySchema,
74
- context: taxonomy_1.FindingContextSchema.optional(),
75
- confidence: primitives_1.UnitIntervalSchema,
76
- policyRuleIds: zod_1.z.array(policies_1.PolicyRuleIdSchema).max(primitives_1.CONTRACT_LIMITS.POLICY_RULE_IDS_MAX).optional(),
71
+ code: taxonomy_js_1.TaxonomyCodeSchema,
72
+ resourceIds: zod_1.z.array(resources_js_1.ResourceIdSchema).min(1).max(primitives_js_1.CONTRACT_LIMITS.RESOURCE_REFS_PER_FINDING_MAX),
73
+ severity: taxonomy_js_1.SeveritySchema,
74
+ context: taxonomy_js_1.FindingContextSchema.optional(),
75
+ confidence: primitives_js_1.UnitIntervalSchema,
76
+ policyRuleIds: zod_1.z.array(policies_js_1.PolicyRuleIdSchema).max(primitives_js_1.CONTRACT_LIMITS.POLICY_RULE_IDS_MAX).optional(),
77
77
  });
78
78
  /**
79
79
  * The body of `POST /v1/reviewer/assignments/{id}/reviews` — §9.3's "result of
@@ -89,17 +89,17 @@ exports.ReviewSubmissionSchema = zod_1.z
89
89
  .strictObject({
90
90
  outcome: exports.ReviewOutcomeSchema,
91
91
  contextSufficiency: exports.ContextSufficiencySchema,
92
- findings: zod_1.z.array(exports.ReviewFindingSchema).max(primitives_1.CONTRACT_LIMITS.FINDINGS_MAX),
92
+ findings: zod_1.z.array(exports.ReviewFindingSchema).max(primitives_js_1.CONTRACT_LIMITS.FINDINGS_MAX),
93
93
  recommendedActions: zod_1.z
94
- .array(taxonomy_1.RecommendedActionSchema)
95
- .max(primitives_1.CONTRACT_LIMITS.RECOMMENDED_ACTIONS_MAX),
94
+ .array(taxonomy_js_1.RecommendedActionSchema)
95
+ .max(primitives_js_1.CONTRACT_LIMITS.RECOMMENDED_ACTIONS_MAX),
96
96
  /**
97
97
  * §13.5 and the "sensitive content never reaches logs" invariant apply to
98
98
  * this field as much as to the evidence: a note is free text a human wrote
99
99
  * while looking at the material, so it is bounded here and must be treated
100
100
  * as case content everywhere downstream — never logged, never attested.
101
101
  */
102
- notes: zod_1.z.string().max(primitives_1.CONTRACT_LIMITS.LONG_TEXT_MAX_LENGTH).optional(),
102
+ notes: zod_1.z.string().max(primitives_js_1.CONTRACT_LIMITS.LONG_TEXT_MAX_LENGTH).optional(),
103
103
  })
104
104
  .superRefine((review, ctx) => {
105
105
  if (review.outcome === 'insufficient_context' && review.contextSufficiency !== 'insufficient') {
@@ -139,6 +139,6 @@ exports.RecusalReasonSchema = zod_1.z.enum(exports.RECUSAL_REASONS);
139
139
  */
140
140
  exports.RecusalSubmissionSchema = zod_1.z.strictObject({
141
141
  reason: exports.RecusalReasonSchema,
142
- note: zod_1.z.string().max(primitives_1.CONTRACT_LIMITS.SHORT_TEXT_MAX_LENGTH).optional(),
142
+ note: zod_1.z.string().max(primitives_js_1.CONTRACT_LIMITS.SHORT_TEXT_MAX_LENGTH).optional(),
143
143
  });
144
144
  //# sourceMappingURL=reviews.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reviews.js","sourceRoot":"","sources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uBAAuB,CAAC;IAC/C;;;;;OAKG;IACH,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,+BAAe,CAAC,oBAAoB,CAAC,CAAC,QAAQ,EAAE;CACvE,CAAC;KACD,WAAW,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;IAC3B,IAAI,MAAM,CAAC,OAAO,KAAK,sBAAsB,IAAI,MAAM,CAAC,kBAAkB,KAAK,cAAc,EAAE,CAAC;QAC9F,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,oBAAoB,CAAC;YAC5B,OAAO,EAAE,+EAA+E;SACzF,CAAC,CAAC;IACL,CAAC;IACD,IAAI,MAAM,CAAC,OAAO,KAAK,WAAW,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnE,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,UAAU,CAAC;YAClB,OAAO,EAAE,mDAAmD;SAC7D,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC;AAGL;;;;GAIG;AACU,QAAA,eAAe,GAAG;IAC7B,sBAAsB;IACtB,UAAU;IACV,eAAe;IACf,sBAAsB;CACd,CAAC;AACE,QAAA,mBAAmB,GAAG,OAAC,CAAC,IAAI,CAAC,uBAAe,CAAC,CAAC;AAG3D;;;;;;;GAOG;AACU,QAAA,uBAAuB,GAAG,OAAC,CAAC,YAAY,CAAC;IACpD,MAAM,EAAE,2BAAmB;IAC3B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,+BAAe,CAAC,qBAAqB,CAAC,CAAC,QAAQ,EAAE;CACvE,CAAC,CAAC"}
@@ -20,7 +20,7 @@
20
20
  * queue the processing" tells receivers to do.
21
21
  */
22
22
  import { z } from 'zod';
23
- import type { Closed } from './closed';
23
+ import type { Closed } from './closed.js';
24
24
  /** §10.6. */
25
25
  export declare const WEBHOOK_EVENT_TYPES: readonly ["report.received", "case.created", "case.escalated", "case.decided", "decision.corrected", "appeal.created", "appeal.decided", "case.closed"];
26
26
  export declare const WebhookEventTypeSchema: z.ZodEnum<{
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../src/webhooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,aAAa;AACb,eAAO,MAAM,mBAAmB,yJAStB,CAAC;AACX,eAAO,MAAM,sBAAsB;;;;;;;;;EAA8B,CAAC;AAClE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,aAI+C,CAAC;AAStF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B;;;;;;;iBAIrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC;AAoEtF;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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mCAAmC,MAAM,CAAC;AAEvD,gDAAgD;AAChD,eAAO,MAAM,4BAA4B,aAEQ,CAAC;AAElD,mEAAmE;AACnE,eAAO,MAAM,4BAA4B,aAE6C,CAAC;AAEvF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpF;AAED;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,EAAE,SAAS,MAAM,EAO1D,CAAC"}
package/dist/webhooks.js CHANGED
@@ -24,9 +24,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.WEBHOOK_RETRY_SCHEDULE_SECONDS = exports.WebhookSignatureHeaderSchema = exports.WebhookTimestampHeaderSchema = exports.WEBHOOK_TIMESTAMP_TOLERANCE_SECONDS = exports.WEBHOOK_SIGNATURE_VERSION = exports.WEBHOOK_SIGNATURE_HEADER = exports.WEBHOOK_TIMESTAMP_HEADER = exports.WEBHOOK_EVENT_ID_HEADER = exports.KnownWebhookEventSchema = exports.WebhookEventEnvelopeSchema = exports.AnyWebhookEventTypeSchema = exports.WebhookEventTypeSchema = exports.WEBHOOK_EVENT_TYPES = void 0;
25
25
  exports.buildWebhookSignedPayload = buildWebhookSignedPayload;
26
26
  const zod_1 = require("zod");
27
- const case_envelope_1 = require("./case-envelope");
28
- const decisions_1 = require("./decisions");
29
- const primitives_1 = require("./primitives");
27
+ const case_envelope_js_1 = require("./case-envelope.js");
28
+ const decisions_js_1 = require("./decisions.js");
29
+ const primitives_js_1 = require("./primitives.js");
30
30
  /** §10.6. */
31
31
  exports.WEBHOOK_EVENT_TYPES = [
32
32
  'report.received',
@@ -52,10 +52,10 @@ exports.AnyWebhookEventTypeSchema = zod_1.z
52
52
  .max(64)
53
53
  .regex(/^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+$/, 'must be a dotted lowercase event type');
54
54
  const webhookEnvelopeShape = {
55
- id: primitives_1.IdentifierSchema,
56
- createdAt: primitives_1.TimestampSchema,
57
- organizationId: primitives_1.IdentifierSchema,
58
- applicationId: primitives_1.IdentifierSchema,
55
+ id: primitives_js_1.IdentifierSchema,
56
+ createdAt: primitives_js_1.TimestampSchema,
57
+ organizationId: primitives_js_1.IdentifierSchema,
58
+ applicationId: primitives_js_1.IdentifierSchema,
59
59
  };
60
60
  /**
61
61
  * The envelope every delivery shares (§10.7), with `data` left opaque.
@@ -72,22 +72,22 @@ const ReportReceivedEventSchema = zod_1.z.looseObject({
72
72
  ...webhookEnvelopeShape,
73
73
  type: zod_1.z.literal('report.received'),
74
74
  /** §10.6: "optional confirmation of receipt and merge" — §10.4's response. */
75
- data: case_envelope_1.CreateReportResponseSchema,
75
+ data: case_envelope_js_1.CreateReportResponseSchema,
76
76
  });
77
77
  const CaseCreatedEventSchema = zod_1.z.looseObject({
78
78
  ...webhookEnvelopeShape,
79
79
  type: zod_1.z.literal('case.created'),
80
- data: zod_1.z.looseObject({ caseId: primitives_1.IdentifierSchema }),
80
+ data: zod_1.z.looseObject({ caseId: primitives_js_1.IdentifierSchema }),
81
81
  });
82
82
  const CaseEscalatedEventSchema = zod_1.z.looseObject({
83
83
  ...webhookEnvelopeShape,
84
84
  type: zod_1.z.literal('case.escalated'),
85
- data: zod_1.z.looseObject({ caseId: primitives_1.IdentifierSchema }),
85
+ data: zod_1.z.looseObject({ caseId: primitives_js_1.IdentifierSchema }),
86
86
  });
87
87
  const CaseDecidedEventSchema = zod_1.z.looseObject({
88
88
  ...webhookEnvelopeShape,
89
89
  type: zod_1.z.literal('case.decided'),
90
- data: zod_1.z.looseObject({ caseId: primitives_1.IdentifierSchema, decision: decisions_1.DecisionSchema }),
90
+ data: zod_1.z.looseObject({ caseId: primitives_js_1.IdentifierSchema, decision: decisions_js_1.DecisionSchema }),
91
91
  });
92
92
  /**
93
93
  * §10.6: "a later revision replaces the previous decision".
@@ -100,28 +100,28 @@ const DecisionCorrectedEventSchema = zod_1.z.looseObject({
100
100
  ...webhookEnvelopeShape,
101
101
  type: zod_1.z.literal('decision.corrected'),
102
102
  data: zod_1.z.looseObject({
103
- caseId: primitives_1.IdentifierSchema,
104
- decision: decisions_1.DecisionSchema.refine((decision) => decision.supersedesDecisionId !== undefined, { message: 'a corrected decision must supersede the decision it replaces' }),
103
+ caseId: primitives_js_1.IdentifierSchema,
104
+ decision: decisions_js_1.DecisionSchema.refine((decision) => decision.supersedesDecisionId !== undefined, { message: 'a corrected decision must supersede the decision it replaces' }),
105
105
  }),
106
106
  });
107
107
  const AppealCreatedEventSchema = zod_1.z.looseObject({
108
108
  ...webhookEnvelopeShape,
109
109
  type: zod_1.z.literal('appeal.created'),
110
- data: zod_1.z.looseObject({ caseId: primitives_1.IdentifierSchema, appealId: primitives_1.IdentifierSchema }),
110
+ data: zod_1.z.looseObject({ caseId: primitives_js_1.IdentifierSchema, appealId: primitives_js_1.IdentifierSchema }),
111
111
  });
112
112
  const AppealDecidedEventSchema = zod_1.z.looseObject({
113
113
  ...webhookEnvelopeShape,
114
114
  type: zod_1.z.literal('appeal.decided'),
115
115
  data: zod_1.z.looseObject({
116
- caseId: primitives_1.IdentifierSchema,
117
- appealId: primitives_1.IdentifierSchema,
118
- decision: decisions_1.DecisionSchema,
116
+ caseId: primitives_js_1.IdentifierSchema,
117
+ appealId: primitives_js_1.IdentifierSchema,
118
+ decision: decisions_js_1.DecisionSchema,
119
119
  }),
120
120
  });
121
121
  const CaseClosedEventSchema = zod_1.z.looseObject({
122
122
  ...webhookEnvelopeShape,
123
123
  type: zod_1.z.literal('case.closed'),
124
- data: zod_1.z.looseObject({ caseId: primitives_1.IdentifierSchema }),
124
+ data: zod_1.z.looseObject({ caseId: primitives_js_1.IdentifierSchema }),
125
125
  });
126
126
  /**
127
127
  * The eight events of §10.6, discriminated on `type`.
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../src/webhooks.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAi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DAAgD;AACnC,QAAA,4BAA4B,GAAG,OAAC;KAC1C,MAAM,EAAE;KACR,KAAK,CAAC,eAAe,EAAE,sBAAsB,CAAC,CAAC;AAElD,mEAAmE;AACtD,QAAA,4BAA4B,GAAG,OAAC;KAC1C,MAAM,EAAE;KACR,KAAK,CAAC,mBAAmB,EAAE,uDAAuD,CAAC,CAAC;AAEvF;;;;;;;;;;;;;GAaG;AACH,SAAgB,yBAAyB,CAAC,SAAiB,EAAE,OAAe;IAC1E,OAAO,GAAG,SAAS,IAAI,OAAO,EAAE,CAAC;AACnC,CAAC;AAED;;;;;;GAMG;AACU,QAAA,8BAA8B,GAAsB,MAAM,CAAC,MAAM,CAAC;IAC7E,EAAE;IACF,GAAG;IACH,GAAG;IACH,IAAK;IACL,KAAM;IACN,KAAM;CACP,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/crowdsource-contracts",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Versioned CrowdSource contracts: case envelope, resources, taxonomy, policies, reviews, decisions, webhooks and reputation events",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",
@@ -8,16 +8,16 @@
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js",
11
+ "import": "./dist/esm/index.js",
12
12
  "require": "./dist/index.js",
13
13
  "default": "./dist/index.js"
14
14
  },
15
15
  "./package.json": "./package.json"
16
16
  },
17
17
  "scripts": {
18
- "build": "tsc",
18
+ "build": "tsc && tsc -p tsconfig.esm.json && bun ../../scripts/write-esm-marker.mjs",
19
19
  "dev": "tsc --watch",
20
- "clean": "rm -rf dist",
20
+ "clean": "rm -rf dist *.tsbuildinfo",
21
21
  "lint": "tsc --noEmit --noUnusedLocals --noUnusedParameters && tsc -p tsconfig.test.json",
22
22
  "test": "node ../../node_modules/vitest/vitest.mjs run",
23
23
  "test:watch": "node ../../node_modules/vitest/vitest.mjs",
package/src/appeals.ts ADDED
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Appeals (§9.8, §9.9, §10.2).
3
+ *
4
+ * §9.8 opens with the rule the rest of this module serves: "la apelación no
5
+ * edita la decisión original. Crea una nueva revisión del caso con un jurado
6
+ * distinto y una nueva Decision revision." So an appeal is not a mutation and it
7
+ * is not a request to reconsider — it is an OBJECT: a requester, a reason, the
8
+ * author's structured additional context, and the pair of revisions it sits
9
+ * between. Everything about the outcome belongs to the decision it opens.
10
+ *
11
+ * Two strictness directions meet here, and they are the same two the package
12
+ * uses everywhere else:
13
+ *
14
+ * * **`AppealSubmissionSchema` is strict.** It arrives from a tenant, over the
15
+ * application API, carrying text the SUBJECT of a moderation case wrote —
16
+ * which is to say attacker-controlled text, filed by somebody with a motive.
17
+ * A field this schema tolerated is a field nobody validated.
18
+ * * **`AppealSchema` is loose.** It travels outbound, in the response and in
19
+ * §10.6's `appeal.created` and `appeal.decided`, so §10.11's "unknown fields
20
+ * must not break clients" applies.
21
+ *
22
+ * What is deliberately NOT here: the appeal's outcome, the new jury, the votes,
23
+ * anything about the panel. An appeal that carried its own verdict would be a
24
+ * second place the outcome of a case is written down, and §9.9 is explicit that
25
+ * there is exactly one — the decision revision.
26
+ */
27
+
28
+ import { z } from 'zod';
29
+
30
+ import type { Closed } from './closed.js';
31
+ import { DecisionSchema } from './decisions.js';
32
+ import {
33
+ CONTRACT_LIMITS,
34
+ ExternalIdSchema,
35
+ IdentifierSchema,
36
+ MetadataBagSchema,
37
+ TimestampSchema,
38
+ } from './primitives.js';
39
+ import { ResourceIdSchema } from './resources.js';
40
+
41
+ /**
42
+ * Why an appeal was filed.
43
+ *
44
+ * §9.8 requires a reason but never enumerates one, and a closed list is the only
45
+ * shape that works: the reason is carried into the appeal record, read by an
46
+ * operator, and counted in §15.9's overturn-rate metrics, so a free-text field
47
+ * would be both a channel for case content and a dimension nobody can aggregate.
48
+ *
49
+ * The six are derived from what the plan already says an appeal can be about.
50
+ * `context_missing` is §9.8's own "el autor puede aportar una explicación" and
51
+ * the remedy §9.6's `insufficient_context` asks for. `policy_misapplied` and
52
+ * `finding_incorrect` split §6.2's two layers — the rule that was applied
53
+ * against the classification of the material — because they want different
54
+ * remedies and conflating them would lose that. `exception_applies` is §6.2's
55
+ * `context` qualifier (artistic, documentary, satire) asserted by the person who
56
+ * made the material. `not_responsible` is §11.7.4's attribution being wrong,
57
+ * which matters most: an effect landing on the wrong principal is the one error
58
+ * a reversal cannot fully undo. `procedural_error` covers the process itself.
59
+ */
60
+ export const APPEAL_REASONS = [
61
+ 'context_missing',
62
+ 'policy_misapplied',
63
+ 'finding_incorrect',
64
+ 'exception_applies',
65
+ 'not_responsible',
66
+ 'procedural_error',
67
+ ] as const;
68
+ export const AppealReasonSchema = z.enum(APPEAL_REASONS);
69
+ export type AppealReason = z.infer<typeof AppealReasonSchema>;
70
+
71
+ /**
72
+ * The lifecycle of an appeal, which has exactly two states and no third.
73
+ *
74
+ * `open` from the moment it creates a revision until that revision publishes a
75
+ * decision, `decided` afterwards. There is no `rejected` state: an appeal that
76
+ * is not eligible is REFUSED at the boundary and never becomes an object at all
77
+ * (§10.5's 403 and 409), because an appeal row that exists without having opened
78
+ * a revision would be a case in `appealed` status with no jury owed to it — the
79
+ * one failure mode §9.8 cannot tolerate, since the author has been told their
80
+ * case is being looked at again.
81
+ *
82
+ * There is also no `upheld`/`overturned` pair, and that is the same rule as
83
+ * above: whether the outcome changed is a property of the two decisions, and
84
+ * `decision.corrected` (§10.6) is what says so.
85
+ */
86
+ export const APPEAL_STATUSES = ['open', 'decided'] as const;
87
+ export const AppealStatusSchema = z.enum(APPEAL_STATUSES);
88
+ export type AppealStatus = z.infer<typeof AppealStatusSchema>;
89
+
90
+ /**
91
+ * §9.8's "contexto adicional": what the author may add, "sujeta a validación y
92
+ * redacción".
93
+ *
94
+ * Three shapes, and each is bounded for a different reason. `statement` is the
95
+ * explanation in the author's own words and is the field the redaction in the
96
+ * backend's `appealContext.ts` exists for. `resourceIds` point at material
97
+ * ALREADY in the case snapshot — an appeal cannot introduce new evidence through
98
+ * this field, because evidence enters through §10.2's upload endpoints where it
99
+ * is hashed and scanned, and a URL or a blob here would be an unvalidated
100
+ * resource reaching a reviewer's screen. `fields` is §9.8's "evidencia
101
+ * estructurada" in the one shape the contract already trusts: a flat bag of
102
+ * scalars, key-restricted and prototype-safe.
103
+ */
104
+ export const AppealAuthorContextSchema = z.strictObject({
105
+ /**
106
+ * Free text from the author. Case content everywhere downstream: never logged,
107
+ * never attested, redacted before a reviewer sees it (§9.8, §13.4, §13.5).
108
+ */
109
+ statement: z.string().min(1).max(CONTRACT_LIMITS.LONG_TEXT_MAX_LENGTH),
110
+ /** Resources of the case this context is about. Validated against the case. */
111
+ resourceIds: z
112
+ .array(ResourceIdSchema)
113
+ .max(CONTRACT_LIMITS.RESOURCE_REFS_PER_FINDING_MAX)
114
+ .optional(),
115
+ /** §9.8's structured evidence: flat, scalar, bounded — never a document tree. */
116
+ fields: MetadataBagSchema.optional(),
117
+ });
118
+ export type AppealAuthorContext = z.infer<typeof AppealAuthorContextSchema>;
119
+
120
+ /**
121
+ * The body of `POST /v1/cases/{id}/appeals` (§10.2).
122
+ *
123
+ * Strict, and with no `caseId`, no `decisionId` and no `applicationId` — the
124
+ * case comes from the route, the revision under appeal is whichever one the case
125
+ * has decided, and the application comes from the credential. A schema that
126
+ * tolerated any of the three would let a caller appeal a decision of a case it
127
+ * was not handed, which is the same class of hole as a review submission that
128
+ * accepted a case id.
129
+ *
130
+ * `appellantExternalPrincipalId` is the application's own id for the person
131
+ * appealing, and the server checks it against the principals the CASE MATERIAL
132
+ * points at. That is what makes §9.8's "el autor" enforceable rather than
133
+ * declarative: a reporter is referenced by an allegation and never by the
134
+ * material, so a reporter's id is not in that set and cannot appeal a decision
135
+ * that went against somebody else.
136
+ */
137
+ export const AppealSubmissionSchema = z.strictObject({
138
+ appellantExternalPrincipalId: ExternalIdSchema,
139
+ reason: AppealReasonSchema,
140
+ authorContext: AppealAuthorContextSchema.optional(),
141
+ });
142
+ export type AppealSubmission = z.infer<typeof AppealSubmissionSchema>;
143
+
144
+ /**
145
+ * One appeal, as it travels back to the application (§10.2, §10.6).
146
+ *
147
+ * `supersededRevision` and `openedRevision` are both here because an appeal is
148
+ * exactly the link between them, and reading it is how an integrator follows
149
+ * §9.9's history: the decision it appealed is the one at `supersededRevision`,
150
+ * and the decision that answers it is the one at `openedRevision`.
151
+ *
152
+ * `requiredAgreeingVotes` is the bar the new panel must clear — §9.4's "umbral
153
+ * superior al de la primera decisión cuando la acción sea grave" — recorded on
154
+ * the appeal so it is auditable and fixed at filing time rather than recomputed
155
+ * later from a ladder that may have changed.
156
+ *
157
+ * The author's context is deliberately absent. The application supplied it, so
158
+ * echoing it back tells the tenant nothing it does not have, and §13.5's
159
+ * minimisation applies to every copy of case content — including the ones in a
160
+ * webhook body that will be retried, stored and logged by a receiver.
161
+ */
162
+ export const AppealSchema = z
163
+ .looseObject({
164
+ id: IdentifierSchema,
165
+ caseId: IdentifierSchema,
166
+ status: AppealStatusSchema,
167
+ reason: AppealReasonSchema,
168
+ /** The revision whose decision was appealed, and which is now superseded. */
169
+ supersededRevision: z.number().int().positive(),
170
+ supersededDecisionId: IdentifierSchema,
171
+ /** The revision this appeal opened. Always `supersededRevision + 1` (§9.9). */
172
+ openedRevision: z.number().int().positive(),
173
+ requiredAgreeingVotes: z.number().int().positive().max(CONTRACT_LIMITS.JURY_SIZE_MAX),
174
+ filedAt: TimestampSchema,
175
+ /** The decision that answered the appeal, once one exists. */
176
+ decision: DecisionSchema.optional(),
177
+ })
178
+ .superRefine((appeal, ctx) => {
179
+ /**
180
+ * §9.9's chain, checked rather than described: an appeal opens the revision
181
+ * immediately after the one it superseded. A gap would mean a revision
182
+ * nobody appealed and nobody decided.
183
+ */
184
+ if (appeal.openedRevision !== appeal.supersededRevision + 1) {
185
+ ctx.addIssue({
186
+ code: 'custom',
187
+ path: ['openedRevision'],
188
+ message: 'an appeal opens the revision immediately after the one it superseded',
189
+ });
190
+ }
191
+ /**
192
+ * The status is DERIVED from whether the revision it opened has published a
193
+ * decision, so the two cannot disagree — and asserting it here is what
194
+ * catches a serializer that started storing the status separately.
195
+ */
196
+ if (appeal.status === 'decided' && appeal.decision === undefined) {
197
+ ctx.addIssue({
198
+ code: 'custom',
199
+ path: ['decision'],
200
+ message: 'a decided appeal must carry the decision that answered it',
201
+ });
202
+ }
203
+ if (appeal.status === 'open' && appeal.decision !== undefined) {
204
+ ctx.addIssue({
205
+ code: 'custom',
206
+ path: ['status'],
207
+ message: 'an appeal that carries a decision is decided, not open',
208
+ });
209
+ }
210
+ if (appeal.decision !== undefined && appeal.decision.revision !== appeal.openedRevision) {
211
+ ctx.addIssue({
212
+ code: 'custom',
213
+ path: ['decision', 'revision'],
214
+ message: 'the decision answering an appeal is the one at the revision it opened',
215
+ });
216
+ }
217
+ });
218
+ /**
219
+ * `Closed`, like every other outbound type in this package.
220
+ *
221
+ * The schema stays loose — §10.11 requires unknown fields to pass through — and
222
+ * the exported type drops the index signature that looseness contributes. This
223
+ * DTO is the one in the package most likely to be misnamed by an integrator:
224
+ * `appeal.appealId` reads naturally and the field is `id`, and the webhook
225
+ * payload carries `data.appealId` beside `data.appeal.id`, so the two spellings
226
+ * sit next to each other in the same body. With an index signature both compile
227
+ * and one is `undefined` at runtime; closed, only the real one does.
228
+ */
229
+ export type Appeal = Closed<z.infer<typeof AppealSchema>>;
@@ -35,17 +35,17 @@ import {
35
35
  IdentifierSchema,
36
36
  MetadataBagSchema,
37
37
  TimestampSchema,
38
- } from './primitives';
39
- import { CasePolicyRefSchema } from './policies';
38
+ } from './primitives.js';
39
+ import { CasePolicyRefSchema } from './policies.js';
40
40
  import {
41
41
  PRINCIPAL_TARGETED_RELATION_TYPES,
42
42
  PrincipalRefSchema,
43
43
  RelationSchema,
44
44
  ResourceIdSchema,
45
45
  ResourceSchema,
46
- } from './resources';
47
- import { SensitivityHintSchema, TaxonomyCodeSchema } from './taxonomy';
48
- import type { Closed } from './closed';
46
+ } from './resources.js';
47
+ import { SensitivityHintSchema, TaxonomyCodeSchema } from './taxonomy.js';
48
+ import type { Closed } from './closed.js';
49
49
 
50
50
  /**
51
51
  * The contract version carried inside the payload.
package/src/decisions.ts CHANGED
@@ -21,10 +21,10 @@
21
21
 
22
22
  import { z } from 'zod';
23
23
 
24
- import { CONTRACT_LIMITS, IdentifierSchema, TimestampSchema, UnitIntervalSchema } from './primitives';
25
- import { DecisionPolicyVersionsSchema, PolicyRuleIdSchema } from './policies';
26
- import { ResourceIdSchema } from './resources';
27
- import { ContextSufficiencySchema } from './reviews';
24
+ import { CONTRACT_LIMITS, IdentifierSchema, TimestampSchema, UnitIntervalSchema } from './primitives.js';
25
+ import { DecisionPolicyVersionsSchema, PolicyRuleIdSchema } from './policies.js';
26
+ import { ResourceIdSchema } from './resources.js';
27
+ import { ContextSufficiencySchema } from './reviews.js';
28
28
  import {
29
29
  FindingAttributionSchema,
30
30
  FindingContextSchema,
@@ -32,8 +32,8 @@ import {
32
32
  RecommendedActionSchema,
33
33
  SeveritySchema,
34
34
  TaxonomyCodeSchema,
35
- } from './taxonomy';
36
- import type { Closed } from './closed';
35
+ } from './taxonomy.js';
36
+ import type { Closed } from './closed.js';
37
37
 
38
38
  /** §3.2 decision states. */
39
39
  export const DECISION_STATUSES = ['provisional', 'final', 'superseded', 'corrected'] as const;
package/src/index.ts CHANGED
@@ -33,14 +33,16 @@
33
33
  * names.
34
34
  */
35
35
 
36
- export * from './closed';
37
- export * from './primitives';
38
- export * from './taxonomy';
39
- export * from './policies';
40
- export * from './resources';
41
- export * from './case-envelope';
42
- export * from './reviews';
43
- export * from './decisions';
44
- export * from './webhooks';
45
- export * from './reputation-events';
46
- export * from './json-schema';
36
+ export * from './closed.js';
37
+ export * from './primitives.js';
38
+ export * from './taxonomy.js';
39
+ export * from './policies.js';
40
+ export * from './resources.js';
41
+ export * from './case-envelope.js';
42
+ export * from './reviews.js';
43
+ export * from './reviewer-surface.js';
44
+ export * from './decisions.js';
45
+ export * from './appeals.js';
46
+ export * from './webhooks.js';
47
+ export * from './reputation-events.js';
48
+ export * from './json-schema.js';
@@ -28,13 +28,14 @@
28
28
 
29
29
  import { z } from 'zod';
30
30
 
31
- import { CaseEnvelopeSchema, CreateReportRequestSchema, CreateReportResponseSchema } from './case-envelope';
32
- import { DecisionSchema } from './decisions';
33
- import { PolicySetVersionSchema } from './policies';
34
- import { ReputationEventSchema } from './reputation-events';
35
- import { RelationSchema, ResourceSchema, ResourceSchemaRegistrationSchema } from './resources';
36
- import { RecusalSubmissionSchema, ReviewSubmissionSchema } from './reviews';
37
- import { KnownWebhookEventSchema, WebhookEventEnvelopeSchema } from './webhooks';
31
+ import { AppealSchema, AppealSubmissionSchema } from './appeals.js';
32
+ import { CaseEnvelopeSchema, CreateReportRequestSchema, CreateReportResponseSchema } from './case-envelope.js';
33
+ import { DecisionSchema } from './decisions.js';
34
+ import { PolicySetVersionSchema } from './policies.js';
35
+ import { ReputationEventSchema } from './reputation-events.js';
36
+ import { RelationSchema, ResourceSchema, ResourceSchemaRegistrationSchema } from './resources.js';
37
+ import { RecusalSubmissionSchema, ReviewSubmissionSchema } from './reviews.js';
38
+ import { KnownWebhookEventSchema, WebhookEventEnvelopeSchema } from './webhooks.js';
38
39
 
39
40
  /** A JSON Schema document, as produced by the conversion. */
40
41
  export type JsonSchemaDocument = z.core.JSONSchema.BaseSchema;
@@ -50,6 +51,8 @@ export const CONTRACT_JSON_SCHEMA_NAMES = [
50
51
  'review-submission',
51
52
  'recusal-submission',
52
53
  'decision',
54
+ 'appeal-submission',
55
+ 'appeal',
53
56
  'webhook-event-envelope',
54
57
  'known-webhook-event',
55
58
  'reputation-event',
@@ -75,6 +78,8 @@ export const CONTRACT_SCHEMAS: Record<ContractJsonSchemaName, z.ZodType> = {
75
78
  'review-submission': ReviewSubmissionSchema,
76
79
  'recusal-submission': RecusalSubmissionSchema,
77
80
  decision: DecisionSchema,
81
+ 'appeal-submission': AppealSubmissionSchema,
82
+ appeal: AppealSchema,
78
83
  'webhook-event-envelope': WebhookEventEnvelopeSchema,
79
84
  'known-webhook-event': KnownWebhookEventSchema,
80
85
  'reputation-event': ReputationEventSchema,
package/src/policies.ts CHANGED
@@ -20,9 +20,9 @@
20
20
 
21
21
  import { z } from 'zod';
22
22
 
23
- import { CONTRACT_LIMITS, LanguageTagSchema, TimestampSchema } from './primitives';
24
- import { RecommendedActionSchema, SeveritySchema, TaxonomyCodeSchema } from './taxonomy';
25
- import type { Closed } from './closed';
23
+ import { CONTRACT_LIMITS, LanguageTagSchema, TimestampSchema } from './primitives.js';
24
+ import { RecommendedActionSchema, SeveritySchema, TaxonomyCodeSchema } from './taxonomy.js';
25
+ import type { Closed } from './closed.js';
26
26
 
27
27
  /** A namespaced policy set id, e.g. `mention.community`. */
28
28
  export const PolicySetIdSchema = z
@@ -36,15 +36,15 @@
36
36
 
37
37
  import { z } from 'zod';
38
38
 
39
- import { CONTRACT_LIMITS, IdentifierSchema, Sha256DigestSchema } from './primitives';
40
- import { PrincipalTypeSchema } from './case-envelope';
41
- import { ReputationPolicyVersionsSchema } from './policies';
39
+ import { CONTRACT_LIMITS, IdentifierSchema, Sha256DigestSchema } from './primitives.js';
40
+ import { PrincipalTypeSchema } from './case-envelope.js';
41
+ import { ReputationPolicyVersionsSchema } from './policies.js';
42
42
  import {
43
43
  FindingAttributionSchema,
44
44
  ReputationEligibleFindingScopeSchema,
45
45
  SeveritySchema,
46
46
  TaxonomyCodeSchema,
47
- } from './taxonomy';
47
+ } from './taxonomy.js';
48
48
 
49
49
  /**
50
50
  * §11.6 names one event type. §11.5 names four bridge operations — apply,