@company-semantics/contracts 62.1.0 → 62.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@company-semantics/contracts",
3
- "version": "62.1.0",
3
+ "version": "62.2.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
package/src/org/README.md CHANGED
@@ -335,6 +335,8 @@ Shared type vocabulary for organization ownership, type classification, and tran
335
335
  - `RemoveMemberRequest` _(type)_ — Request payload for removing a member from the workspace.
336
336
  - `RemoveMemberResponse` _(type)_
337
337
  - `RemoveMemberResponseSchema`
338
+ - `ReportingErrorCode` _(type)_
339
+ - `ReportingErrorCodeSchema` — Structured codes for reporting-line mutation rejections, surfaced as `ErrorResponse.meta.reportingCode` by…
338
340
  - `ResolveOrgDivergenceResult` _(type)_
339
341
  - `ResolveOrgDivergenceResultSchema`
340
342
  - `RoleCatalogEntry` _(type)_ — Entry in the RBAC roles catalog (GET /api/rbac/roles).
@@ -2,6 +2,7 @@ import { describe, it, expect } from "vitest";
2
2
  import {
3
3
  PositionReportingSchema,
4
4
  PositionReportingRelationshipTypeSchema,
5
+ ReportingErrorCodeSchema,
5
6
  } from "../position-reporting.js";
6
7
 
7
8
  const validEdge = {
@@ -86,3 +87,17 @@ describe("PositionReportingRelationshipTypeSchema", () => {
86
87
  ).toBe(false);
87
88
  });
88
89
  });
90
+
91
+ describe("Enum exhaustiveness", () => {
92
+ it("ReportingErrorCodeSchema enumerates all 3 known codes", () => {
93
+ const codes = [
94
+ "REPORTING_CYCLE_BLOCKED",
95
+ "ENDPOINT_NOT_ON_CHART",
96
+ "SELF_REPORT_BLOCKED",
97
+ ];
98
+ for (const code of codes) {
99
+ expect(() => ReportingErrorCodeSchema.parse(code)).not.toThrow();
100
+ }
101
+ expect(() => ReportingErrorCodeSchema.parse("OTHER")).toThrow();
102
+ });
103
+ });
package/src/org/index.ts CHANGED
@@ -115,10 +115,12 @@ export type { PositionStatus, Position } from "./positions";
115
115
  export {
116
116
  PositionReportingRelationshipTypeSchema,
117
117
  PositionReportingSchema,
118
+ ReportingErrorCodeSchema,
118
119
  } from "./position-reporting";
119
120
  export type {
120
121
  PositionReportingRelationshipType,
121
122
  PositionReporting,
123
+ ReportingErrorCode,
122
124
  } from "./position-reporting";
123
125
 
124
126
  // Source authority: per-field ownership — who may WRITE a given entity field.
@@ -61,3 +61,27 @@ export const PositionReportingSchema = z.object({
61
61
  provenance: FactProvenanceSchema.optional(),
62
62
  });
63
63
  export type PositionReporting = z.infer<typeof PositionReportingSchema>;
64
+
65
+ // ---------------------------------------------------------------------------
66
+ // ReportingErrorCode — structured rejection codes for reporting-line mutations
67
+ // ---------------------------------------------------------------------------
68
+
69
+ /**
70
+ * Structured codes for reporting-line mutation rejections, surfaced as
71
+ * `ErrorResponse.meta.reportingCode` by `PUT /api/reporting/positions/{id}/manager`
72
+ * and its preview twin. The top-level `error` field only carries the error
73
+ * class (`CONFLICT`, `VALIDATION_ERROR`), so this code is the one channel that
74
+ * lets a client tell a cycle 409 from a not-on-chart 409 and key per-code copy
75
+ * off it (the `OrgUnitErrorCode` lesson). The closed set ships all known codes
76
+ * at once: adding a member later is a breaking change for consumers holding an
77
+ * exhaustive `Record<ReportingErrorCode, …>`.
78
+ */
79
+ export const ReportingErrorCodeSchema = z.enum([
80
+ // 409 — the edge would close a reporting cycle on the position graph.
81
+ "REPORTING_CYCLE_BLOCKED",
82
+ // 409 — an endpoint of the edge has no seat on the org chart yet.
83
+ "ENDPOINT_NOT_ON_CHART",
84
+ // 400 — a seat (or member) cannot report to itself.
85
+ "SELF_REPORT_BLOCKED",
86
+ ]);
87
+ export type ReportingErrorCode = z.infer<typeof ReportingErrorCodeSchema>;