@xemahq/contracts 0.84.0 → 0.85.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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "algorithm": "sha256/len-framed-v1",
3
- "hash": "d6fec904ae98561d04f66eed70ff50044ab0868581eb875fd8a14365a85d56c1",
4
- "fileCount": 752
3
+ "hash": "21d9afeed6e60ee8bd9a14986b4191328662c3c1c2db85332b9085f490ce9afb",
4
+ "fileCount": 757
5
5
  }
@@ -0,0 +1,5 @@
1
+ export * from './lib/org-erasure-outcome';
2
+ export * from './lib/org-erasure-outcome-violation';
3
+ export * from './lib/org-erasure-pending';
4
+ export * from './lib/parse-org-erasure-outcome';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/org-erasure/index.ts"],"names":[],"mappings":"AAOA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qCAAqC,CAAC;AACpD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./lib/org-erasure-outcome"), exports);
18
+ __exportStar(require("./lib/org-erasure-outcome-violation"), exports);
19
+ __exportStar(require("./lib/org-erasure-pending"), exports);
20
+ __exportStar(require("./lib/parse-org-erasure-outcome"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/org-erasure/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAOA,4DAA0C;AAC1C,sEAAoD;AACpD,4DAA0C;AAC1C,kEAAgD"}
@@ -0,0 +1,8 @@
1
+ export declare const ORG_ERASURE_OUTCOME_VIOLATION = "ORG_ERASURE_OUTCOME_VIOLATION";
2
+ export declare class OrgErasureOutcomeViolationError extends Error {
3
+ readonly orgId: string;
4
+ readonly detail: string;
5
+ readonly code = "ORG_ERASURE_OUTCOME_VIOLATION";
6
+ constructor(orgId: string, detail: string);
7
+ }
8
+ //# sourceMappingURL=org-erasure-outcome-violation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-erasure-outcome-violation.d.ts","sourceRoot":"","sources":["../../../src/org-erasure/lib/org-erasure-outcome-violation.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,6BAA6B,kCAAkC,CAAC;AAO7E,qBAAa,+BAAgC,SAAQ,KAAK;IAGtD,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM;IAHzB,QAAQ,CAAC,IAAI,mCAAiC;gBAEnC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM;CAK1B"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrgErasureOutcomeViolationError = exports.ORG_ERASURE_OUTCOME_VIOLATION = void 0;
4
+ exports.ORG_ERASURE_OUTCOME_VIOLATION = 'ORG_ERASURE_OUTCOME_VIOLATION';
5
+ class OrgErasureOutcomeViolationError extends Error {
6
+ orgId;
7
+ detail;
8
+ code = exports.ORG_ERASURE_OUTCOME_VIOLATION;
9
+ constructor(orgId, detail) {
10
+ super(`Org-erasure answer for org ${JSON.stringify(orgId)} violates the outcome contract: ${detail}`);
11
+ this.orgId = orgId;
12
+ this.detail = detail;
13
+ this.name = 'OrgErasureOutcomeViolationError';
14
+ }
15
+ }
16
+ exports.OrgErasureOutcomeViolationError = OrgErasureOutcomeViolationError;
17
+ //# sourceMappingURL=org-erasure-outcome-violation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-erasure-outcome-violation.js","sourceRoot":"","sources":["../../../src/org-erasure/lib/org-erasure-outcome-violation.ts"],"names":[],"mappings":";;;AACa,QAAA,6BAA6B,GAAG,+BAA+B,CAAC;AAO7E,MAAa,+BAAgC,SAAQ,KAAK;IAG7C;IACA;IAHF,IAAI,GAAG,qCAA6B,CAAC;IAC9C,YACW,KAAa,EACb,MAAc;QAEvB,KAAK,CAAC,8BAA8B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,mCAAmC,MAAM,EAAE,CAAC,CAAC;QAH7F,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAAQ;QAGvB,IAAI,CAAC,IAAI,GAAG,iCAAiC,CAAC;IAChD,CAAC;CACF;AATD,0EASC"}
@@ -0,0 +1,28 @@
1
+ export declare enum OrgErasureOutcomeState {
2
+ Erased = "erased",
3
+ Pending = "pending"
4
+ }
5
+ export declare const ORG_ERASURE_PENDING_HTTP_STATUS = 202;
6
+ export declare const ORG_ERASURE_ERASED_HTTP_STATUSES: readonly number[];
7
+ export declare const ORG_ERASURE_RETRY_AFTER_SECONDS_MIN = 5;
8
+ export declare const ORG_ERASURE_RETRY_AFTER_SECONDS_MAX = 3600;
9
+ export interface OrgErasureReport {
10
+ readonly orgId: string;
11
+ readonly deletedByModel: Readonly<Record<string, number>>;
12
+ readonly totalDeleted: number;
13
+ readonly passes: number;
14
+ }
15
+ export interface OrgErasurePending {
16
+ readonly state: OrgErasureOutcomeState.Pending;
17
+ readonly orgId: string;
18
+ readonly pendingUnits: number;
19
+ readonly pendingSince: string;
20
+ readonly retryAfterSeconds: number;
21
+ }
22
+ export type OrgErasureAnswer = OrgErasureReport | OrgErasurePending;
23
+ export interface OrgErasureErased extends OrgErasureReport {
24
+ readonly state: OrgErasureOutcomeState.Erased;
25
+ }
26
+ export type OrgErasureOutcome = OrgErasureErased | OrgErasurePending;
27
+ export declare function isOrgErasurePending(answer: OrgErasureAnswer): answer is OrgErasurePending;
28
+ //# sourceMappingURL=org-erasure-outcome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-erasure-outcome.d.ts","sourceRoot":"","sources":["../../../src/org-erasure/lib/org-erasure-outcome.ts"],"names":[],"mappings":"AA4BA,oBAAY,sBAAsB;IAEhC,MAAM,WAAW;IAEjB,OAAO,YAAY;CACpB;AAGD,eAAO,MAAM,+BAA+B,MAAM,CAAC;AAMnD,eAAO,MAAM,gCAAgC,EAAE,SAAS,MAAM,EAA8B,CAAC;AAW7F,eAAO,MAAM,mCAAmC,IAAI,CAAC;AACrD,eAAO,MAAM,mCAAmC,OAAO,CAAC;AASxD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAMD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,sBAAsB,CAAC,OAAO,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAKvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAM9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAO9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACpC;AAGD,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAGpE,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,QAAQ,CAAC,KAAK,EAAE,sBAAsB,CAAC,MAAM,CAAC;CAC/C;AAGD,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAGrE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,IAAI,iBAAiB,CAEzF"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ORG_ERASURE_RETRY_AFTER_SECONDS_MAX = exports.ORG_ERASURE_RETRY_AFTER_SECONDS_MIN = exports.ORG_ERASURE_ERASED_HTTP_STATUSES = exports.ORG_ERASURE_PENDING_HTTP_STATUS = exports.OrgErasureOutcomeState = void 0;
4
+ exports.isOrgErasurePending = isOrgErasurePending;
5
+ var OrgErasureOutcomeState;
6
+ (function (OrgErasureOutcomeState) {
7
+ OrgErasureOutcomeState["Erased"] = "erased";
8
+ OrgErasureOutcomeState["Pending"] = "pending";
9
+ })(OrgErasureOutcomeState || (exports.OrgErasureOutcomeState = OrgErasureOutcomeState = {}));
10
+ exports.ORG_ERASURE_PENDING_HTTP_STATUS = 202;
11
+ exports.ORG_ERASURE_ERASED_HTTP_STATUSES = Object.freeze([200, 201]);
12
+ exports.ORG_ERASURE_RETRY_AFTER_SECONDS_MIN = 5;
13
+ exports.ORG_ERASURE_RETRY_AFTER_SECONDS_MAX = 3600;
14
+ function isOrgErasurePending(answer) {
15
+ return answer.state === OrgErasureOutcomeState.Pending;
16
+ }
17
+ //# sourceMappingURL=org-erasure-outcome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-erasure-outcome.js","sourceRoot":"","sources":["../../../src/org-erasure/lib/org-erasure-outcome.ts"],"names":[],"mappings":";;;AA+GA,kDAEC;AArFD,IAAY,sBAKX;AALD,WAAY,sBAAsB;IAEhC,2CAAiB,CAAA;IAEjB,6CAAmB,CAAA;AACrB,CAAC,EALW,sBAAsB,sCAAtB,sBAAsB,QAKjC;AAGY,QAAA,+BAA+B,GAAG,GAAG,CAAC;AAMtC,QAAA,gCAAgC,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAWhF,QAAA,mCAAmC,GAAG,CAAC,CAAC;AACxC,QAAA,mCAAmC,GAAG,IAAI,CAAC;AAyDxD,SAAgB,mBAAmB,CAAC,MAAwB;IAC1D,OAAQ,MAA8B,CAAC,KAAK,KAAK,sBAAsB,CAAC,OAAO,CAAC;AAClF,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type OrgErasurePending } from './org-erasure-outcome';
2
+ export interface OrgErasurePendingInput {
3
+ readonly orgId: string;
4
+ readonly pendingUnits: number;
5
+ readonly pendingSince: Date;
6
+ readonly retryAfterSeconds: number;
7
+ }
8
+ export declare function orgErasurePending(input: OrgErasurePendingInput): OrgErasurePending;
9
+ export declare function assertOrgErasurePendingFields(candidate: object, orgId: string): asserts candidate is OrgErasurePending;
10
+ //# sourceMappingURL=org-erasure-pending.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-erasure-pending.d.ts","sourceRoot":"","sources":["../../../src/org-erasure/lib/org-erasure-pending.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAI/B,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC;IAE5B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACpC;AAOD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,iBAAiB,CAalF;AAMD,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,SAAS,IAAI,iBAAiB,CAgCxC"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.orgErasurePending = orgErasurePending;
4
+ exports.assertOrgErasurePendingFields = assertOrgErasurePendingFields;
5
+ const org_erasure_outcome_1 = require("./org-erasure-outcome");
6
+ const org_erasure_outcome_violation_1 = require("./org-erasure-outcome-violation");
7
+ function orgErasurePending(input) {
8
+ if (!(input.pendingSince instanceof Date) || Number.isNaN(input.pendingSince.getTime())) {
9
+ throw new org_erasure_outcome_violation_1.OrgErasureOutcomeViolationError(input.orgId, 'pendingSince must be a valid Date.');
10
+ }
11
+ const pending = {
12
+ state: org_erasure_outcome_1.OrgErasureOutcomeState.Pending,
13
+ orgId: input.orgId,
14
+ pendingUnits: input.pendingUnits,
15
+ pendingSince: input.pendingSince.toISOString(),
16
+ retryAfterSeconds: input.retryAfterSeconds,
17
+ };
18
+ assertOrgErasurePendingFields(pending, input.orgId);
19
+ return pending;
20
+ }
21
+ function assertOrgErasurePendingFields(candidate, orgId) {
22
+ const fields = candidate;
23
+ const refuse = (detail) => {
24
+ throw new org_erasure_outcome_violation_1.OrgErasureOutcomeViolationError(orgId, detail);
25
+ };
26
+ if (typeof orgId !== 'string' || orgId.trim() === '') {
27
+ refuse('the org id must be a non-empty string.');
28
+ }
29
+ if (fields.state !== org_erasure_outcome_1.OrgErasureOutcomeState.Pending) {
30
+ refuse(`a pending answer must carry state '${org_erasure_outcome_1.OrgErasureOutcomeState.Pending}', got ${JSON.stringify(fields.state)}.`);
31
+ }
32
+ if (fields.orgId !== orgId) {
33
+ refuse(`the answer names org ${JSON.stringify(fields.orgId)}, not the org asked for.`);
34
+ }
35
+ const { pendingUnits, pendingSince, retryAfterSeconds } = fields;
36
+ if (typeof pendingUnits !== 'number' || !Number.isSafeInteger(pendingUnits) || pendingUnits < 1) {
37
+ refuse(`pendingUnits must be an integer ≥ 1, got ${JSON.stringify(pendingUnits)}.`);
38
+ }
39
+ if (typeof pendingSince !== 'string' || !isCanonicalIsoInstant(pendingSince)) {
40
+ refuse(`pendingSince must be an ISO-8601 UTC instant (Date#toISOString), got ${JSON.stringify(pendingSince)}.`);
41
+ }
42
+ if (typeof retryAfterSeconds !== 'number' ||
43
+ !Number.isSafeInteger(retryAfterSeconds) ||
44
+ retryAfterSeconds < org_erasure_outcome_1.ORG_ERASURE_RETRY_AFTER_SECONDS_MIN ||
45
+ retryAfterSeconds > org_erasure_outcome_1.ORG_ERASURE_RETRY_AFTER_SECONDS_MAX) {
46
+ refuse(`retryAfterSeconds must be an integer in [${org_erasure_outcome_1.ORG_ERASURE_RETRY_AFTER_SECONDS_MIN}, ` +
47
+ `${org_erasure_outcome_1.ORG_ERASURE_RETRY_AFTER_SECONDS_MAX}], got ${JSON.stringify(retryAfterSeconds)}.`);
48
+ }
49
+ }
50
+ function isCanonicalIsoInstant(value) {
51
+ const parsed = new Date(value);
52
+ return !Number.isNaN(parsed.getTime()) && parsed.toISOString() === value;
53
+ }
54
+ //# sourceMappingURL=org-erasure-pending.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-erasure-pending.js","sourceRoot":"","sources":["../../../src/org-erasure/lib/org-erasure-pending.ts"],"names":[],"mappings":";;AAwBA,8CAaC;AAMD,sEAmCC;AA9ED,+DAK+B;AAC/B,mFAAkF;AAkBlF,SAAgB,iBAAiB,CAAC,KAA6B;IAC7D,IAAI,CAAC,CAAC,KAAK,CAAC,YAAY,YAAY,IAAI,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QACxF,MAAM,IAAI,+DAA+B,CAAC,KAAK,CAAC,KAAK,EAAE,oCAAoC,CAAC,CAAC;IAC/F,CAAC;IACD,MAAM,OAAO,GAAsB;QACjC,KAAK,EAAE,4CAAsB,CAAC,OAAO;QACrC,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB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ACtF,CAAC;IACD,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,EAAE,CAAC;QAC7E,MAAM,CAAC,wEAAwE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAClH,CAAC;IACD,IACE,OAAO,iBAAiB,KAAK,QAAQ;QACrC,CAAC,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC;QACxC,iBAAiB,GAAG,yDAAmC;QACvD,iBAAiB,GAAG,yDAAmC,EACvD,CAAC;QACD,MAAM,CACJ,4CAA4C,yDAAmC,IAAI;YACjF,GAAG,yDAAmC,UAAU,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,GAAG,CACvF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAa;IAC1C,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type OrgErasureOutcome } from './org-erasure-outcome';
2
+ export interface OrgErasureHttpAnswer {
3
+ readonly status: number;
4
+ readonly payload: unknown;
5
+ readonly orgId: string;
6
+ }
7
+ export declare function parseOrgErasureOutcome(answer: OrgErasureHttpAnswer): OrgErasureOutcome;
8
+ //# sourceMappingURL=parse-org-erasure-outcome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-org-erasure-outcome.d.ts","sourceRoot":"","sources":["../../../src/org-erasure/lib/parse-org-erasure-outcome.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAK/B,MAAM,WAAW,oBAAoB;IAEnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAYD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,oBAAoB,GAAG,iBAAiB,CA2DtF"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseOrgErasureOutcome = parseOrgErasureOutcome;
4
+ const org_erasure_outcome_1 = require("./org-erasure-outcome");
5
+ const org_erasure_outcome_violation_1 = require("./org-erasure-outcome-violation");
6
+ const org_erasure_pending_1 = require("./org-erasure-pending");
7
+ function parseOrgErasureOutcome(answer) {
8
+ const { status, payload, orgId } = answer;
9
+ const refuse = (detail) => {
10
+ throw new org_erasure_outcome_violation_1.OrgErasureOutcomeViolationError(orgId, detail);
11
+ };
12
+ if (payload === null || typeof payload !== 'object' || Array.isArray(payload)) {
13
+ return refuse(`the answer must be an object, got ${describe(payload)}.`);
14
+ }
15
+ const body = payload;
16
+ if (status === org_erasure_outcome_1.ORG_ERASURE_PENDING_HTTP_STATUS) {
17
+ const pending = body;
18
+ (0, org_erasure_pending_1.assertOrgErasurePendingFields)(pending, orgId);
19
+ return {
20
+ state: org_erasure_outcome_1.OrgErasureOutcomeState.Pending,
21
+ orgId,
22
+ pendingUnits: pending.pendingUnits,
23
+ pendingSince: pending.pendingSince,
24
+ retryAfterSeconds: pending.retryAfterSeconds,
25
+ };
26
+ }
27
+ if (!org_erasure_outcome_1.ORG_ERASURE_ERASED_HTTP_STATUSES.includes(status)) {
28
+ return refuse(`status ${status} is neither a pending answer (${org_erasure_outcome_1.ORG_ERASURE_PENDING_HTTP_STATUS}) ` +
29
+ `nor an erased one (${org_erasure_outcome_1.ORG_ERASURE_ERASED_HTTP_STATUSES.join(', ')}).`);
30
+ }
31
+ if ('state' in body) {
32
+ return refuse(`an erased answer (status ${status}) must not carry a state; got ${JSON.stringify(body.state)}. ` +
33
+ `A pending answer is answered with ${org_erasure_outcome_1.ORG_ERASURE_PENDING_HTTP_STATUS}.`);
34
+ }
35
+ if (body.orgId !== orgId) {
36
+ return refuse(`the report names org ${JSON.stringify(body.orgId)}, not the org asked for.`);
37
+ }
38
+ const { deletedByModel, totalDeleted, passes } = body;
39
+ if (!isCount(totalDeleted)) {
40
+ return refuse(`totalDeleted must be a non-negative integer, got ${JSON.stringify(totalDeleted)}.`);
41
+ }
42
+ if (!isCount(passes)) {
43
+ return refuse(`passes must be a non-negative integer, got ${JSON.stringify(passes)}.`);
44
+ }
45
+ if (deletedByModel === null || typeof deletedByModel !== 'object' || Array.isArray(deletedByModel)) {
46
+ return refuse(`deletedByModel must be an object of counts, got ${describe(deletedByModel)}.`);
47
+ }
48
+ const counts = deletedByModel;
49
+ for (const [unit, count] of Object.entries(counts)) {
50
+ if (!isCount(count)) {
51
+ return refuse(`deletedByModel[${JSON.stringify(unit)}] must be a non-negative integer, got ${JSON.stringify(count)}.`);
52
+ }
53
+ }
54
+ return {
55
+ state: org_erasure_outcome_1.OrgErasureOutcomeState.Erased,
56
+ orgId,
57
+ deletedByModel: counts,
58
+ totalDeleted,
59
+ passes,
60
+ };
61
+ }
62
+ function isCount(value) {
63
+ return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
64
+ }
65
+ function describe(value) {
66
+ if (value === null) {
67
+ return 'null';
68
+ }
69
+ return Array.isArray(value) ? 'an array' : `a ${typeof value}`;
70
+ }
71
+ //# sourceMappingURL=parse-org-erasure-outcome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-org-erasure-outcome.js","sourceRoot":"","sources":["../../../src/org-erasure/lib/parse-org-erasure-outcome.ts"],"names":[],"mappings":";;AA6BA,wDA2DC;AAxFD,+DAK+B;AAC/B,mFAAkF;AAClF,+DAAsE;AAsBtE,SAAgB,sBAAsB,CAAC,MAA4B;IACjE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAC1C,MAAM,MAAM,GAAG,C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AC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,OAAO,KAAK,EAAE,CAAC;AACjE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xemahq/contracts",
3
- "version": "0.84.0",
3
+ "version": "0.85.0",
4
4
  "description": "Consolidated Xema kernel wire contracts — pure types + zod schemas for the kernel protocol surfaces. One package, one npm scope, wildcard per-surface subpath exports. No framework deps; the one runtime dependency beside zod is the OpenFGA syntax transformer the authorization-module composer runs.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Neuralchowder Inc. <developer@xema.dev> (https://xema.dev)",
@@ -68,6 +68,6 @@
68
68
  "test:authorization-models": "node scripts/run-authorization-model-tests.mjs"
69
69
  },
70
70
  "xemaRelease": {
71
- "sourceDigest": "sha256:60dbdb033c85aecbf9dee30ad95b8400795b434d1d72c654d1c229e1b3ba896c"
71
+ "sourceDigest": "sha256:45fe45b618d8fed4e119bd3aa69aaea32d4f3b670f769a59b2aae6e6756f9dfd"
72
72
  }
73
73
  }