@xemahq/decision-plane-nest 0.1.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/LICENSE +176 -0
- package/README.md +87 -0
- package/dist/decision-plane.client.d.ts +19 -0
- package/dist/decision-plane.client.d.ts.map +1 -0
- package/dist/decision-plane.client.js +156 -0
- package/dist/decision-plane.client.js.map +1 -0
- package/dist/decision-plane.module.d.ts +3 -0
- package/dist/decision-plane.module.d.ts.map +1 -0
- package/dist/decision-plane.module.js +21 -0
- package/dist/decision-plane.module.js.map +1 -0
- package/dist/errors.d.ts +21 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +48 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/registry.contract.d.ts +4 -0
- package/dist/registry.contract.d.ts.map +1 -0
- package/dist/registry.contract.js +3 -0
- package/dist/registry.contract.js.map +1 -0
- package/dist/wire.d.ts +111 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +62 -0
- package/dist/wire.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# @xemahq/decision-plane-nest
|
|
2
|
+
|
|
3
|
+
The **producer** side of the Xema human-decision primitive.
|
|
4
|
+
|
|
5
|
+
A service that needs a human to decide something opens an ask on `decision-api`
|
|
6
|
+
and acts when somebody answers. Every such service needs the same five calls,
|
|
7
|
+
the same envelope discipline, the same org header and the same "is a decision
|
|
8
|
+
plane even installed here" probe — and two of them had written all of it twice,
|
|
9
|
+
in two different transports.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
@Module({ imports: [DecisionPlaneModule], providers: [MyAskService] })
|
|
13
|
+
export class MyDecisionPlaneModule {}
|
|
14
|
+
|
|
15
|
+
const decision = await this.decisions.open(orgId, {
|
|
16
|
+
idempotencyKey: contentHashOfTheThing,
|
|
17
|
+
kind: DecisionKind.CONFIRM,
|
|
18
|
+
title: 'Send the drafted reply?',
|
|
19
|
+
subjectResourceRef: `resource:mailbox:${mailboxId}`,
|
|
20
|
+
subjectClassification: DecisionSubjectClassification.CONFIDENTIAL,
|
|
21
|
+
answerCapabilityRef: 'mailops:mail.dispatch@1',
|
|
22
|
+
producerRef: holdId,
|
|
23
|
+
recipients: [{ kind: RecipientKind.HUMAN, target: { userId: ownerId } }],
|
|
24
|
+
options: [ /* … */ ],
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## What it deliberately does NOT do
|
|
29
|
+
|
|
30
|
+
**The resume.** Reacting to a committed answer is safety-critical and genuinely
|
|
31
|
+
producer-specific: the capability gate replays an invocation under a
|
|
32
|
+
compare-and-set, mailops dispatches mail through the capability plane, the Store
|
|
33
|
+
flips a version lifecycle under its own claim. *Extract the ask; leave the
|
|
34
|
+
resume* is the program's rule, and an SDK that swallowed the resume would be
|
|
35
|
+
centralising the half that must not be.
|
|
36
|
+
|
|
37
|
+
**Delivery.** `decision-api` emits; `user-hub-api` owns materialisation,
|
|
38
|
+
per-category preferences, presence gating and every channel adapter. Nothing
|
|
39
|
+
here knows a recipient prefers email.
|
|
40
|
+
|
|
41
|
+
## Withdrawal, and why it exists
|
|
42
|
+
|
|
43
|
+
`decision-api` runs no sweeper — every terminal status is DERIVED, which only
|
|
44
|
+
ends an ask that has a DEADLINE — and producers routinely open asks without one,
|
|
45
|
+
for good reasons (a review nobody got to must not become un-approvable by the
|
|
46
|
+
passage of time). Together that makes an unanswered ask **immortal**.
|
|
47
|
+
|
|
48
|
+
So `withdraw()` is not a convenience. A producer that knows its subject is gone
|
|
49
|
+
must call it, and both live producers now do — from a mailbox disconnect and
|
|
50
|
+
from a listing archive. It is best-effort by design (its callers are mid-way
|
|
51
|
+
through something the user asked for) and never silent: 404/409 are the state it
|
|
52
|
+
exists to reach, everything else is logged, and
|
|
53
|
+
`GET /internal/decisions/abandoned` is what surfaces the remainder.
|
|
54
|
+
|
|
55
|
+
## The wire mirror, and when to delete it
|
|
56
|
+
|
|
57
|
+
`src/wire.ts` restates decision-api's vocabulary instead of importing
|
|
58
|
+
`@xemahq/kernel-contracts/decision`. That is not a preference:
|
|
59
|
+
|
|
60
|
+
> The two consumers sit in repositories pinned to kernel-contracts **14.1.0** and
|
|
61
|
+
> **13.0.0**. The `decision` subpath first ships in 15.0.0, and raising
|
|
62
|
+
> xema-store-api's pin is not a local edit — measured 2026-08-20, **nine**
|
|
63
|
+
> packages in that lockfile declare `peer @xemahq/kernel-contracts ^12.0.0`.
|
|
64
|
+
|
|
65
|
+
An SDK importing the kernel subpath would be unconsumable by the very producer
|
|
66
|
+
whose duplication it exists to delete. So it mirrors the wire ONCE, replacing
|
|
67
|
+
the two hand-written mirrors those producers carry today.
|
|
68
|
+
|
|
69
|
+
Two things keep that honest:
|
|
70
|
+
|
|
71
|
+
- it mirrors only what a **producer** sends or reads — the answerer surface, the
|
|
72
|
+
escalation vocabulary and `Recipient`'s five target variants are absent,
|
|
73
|
+
because a mirror of a field nobody uses is a field that drifts unnoticed;
|
|
74
|
+
- `test/wire-parity.spec.ts` asserts every value against decision-api's own
|
|
75
|
+
`prisma/schema.prisma`, in both directions, and is mutation-tested. It reads
|
|
76
|
+
the schema as TEXT so it needs nothing installed, and it SKIPS LOUDLY in a
|
|
77
|
+
standalone clone where decision-api does not exist rather than passing
|
|
78
|
+
vacuously.
|
|
79
|
+
|
|
80
|
+
**When the fleet upgrade happens, `wire.ts` collapses into an import and is
|
|
81
|
+
deleted.** It says so in the file, so nobody preserves it out of politeness.
|
|
82
|
+
|
|
83
|
+
`registry.contract.ts` is the same trade for a single method, and
|
|
84
|
+
`test/registry-assignability.spec.ts` pins it against the real signature — an
|
|
85
|
+
earlier draft declared an array and read `.length`, which compiles and is
|
|
86
|
+
`undefined` on the real `ResolvedService`, so "is a plane installed" would have
|
|
87
|
+
answered NO for one that was.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type TypedServiceClient } from '@xemahq/service-registry-nest';
|
|
2
|
+
import type { ServiceRegistry } from './registry.contract';
|
|
3
|
+
import type { CloseDecisionRequest, DecisionView, OpenDecisionRequest } from './wire';
|
|
4
|
+
export declare const DECISION_API_SERVICE = "decision-api";
|
|
5
|
+
export declare class DecisionPlaneClient {
|
|
6
|
+
private readonly decisions;
|
|
7
|
+
private readonly registry?;
|
|
8
|
+
private readonly logger;
|
|
9
|
+
constructor(decisions: TypedServiceClient, registry?: ServiceRegistry | undefined);
|
|
10
|
+
isAvailable(): Promise<boolean>;
|
|
11
|
+
open(orgId: string, request: OpenDecisionRequest): Promise<DecisionView>;
|
|
12
|
+
findByProducerRef(orgId: string, producerRef: string): Promise<DecisionView | null>;
|
|
13
|
+
read(orgId: string, decisionId: string): Promise<DecisionView>;
|
|
14
|
+
close(orgId: string, decisionId: string, request: CloseDecisionRequest): Promise<void>;
|
|
15
|
+
withdraw(orgId: string, decisionId: string, reason: string): Promise<boolean>;
|
|
16
|
+
private assertAvailable;
|
|
17
|
+
private translate;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=decision-plane.client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision-plane.client.d.ts","sourceRoot":"","sources":["../src/decision-plane.client.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,+BAA+B,CAAC;AAUvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACpB,MAAM,QAAQ,CAAC;AAWhB,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AAyDnD,qBACa,mBAAmB;IAK5B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAO1B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAX5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;gBAI5C,SAAS,EAAE,kBAAkB,EAO7B,QAAQ,CAAC,EAAE,eAAe,YAAA;IAWvC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IA6B/B,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC;IA2BxE,iBAAiB,CACrB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAwBzB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAqB9D,KAAK,CACT,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC;IAiCV,QAAQ,CACZ,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC;YAwBL,eAAe;IAgB7B,OAAO,CAAC,SAAS;CAiBlB"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var DecisionPlaneClient_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.DecisionPlaneClient = exports.DECISION_API_SERVICE = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const service_registry_nest_1 = require("@xemahq/service-registry-nest");
|
|
19
|
+
const errors_1 = require("./errors");
|
|
20
|
+
const wire_1 = require("./wire");
|
|
21
|
+
exports.DECISION_API_SERVICE = 'decision-api';
|
|
22
|
+
const ORG_HEADER = 'X-Xema-Org-Id';
|
|
23
|
+
function unwrap(body, operation) {
|
|
24
|
+
if (typeof body !== 'object' ||
|
|
25
|
+
body === null ||
|
|
26
|
+
!('data' in body) ||
|
|
27
|
+
body.data === null ||
|
|
28
|
+
body.data === undefined) {
|
|
29
|
+
throw new errors_1.DecisionEnvelopeError(operation);
|
|
30
|
+
}
|
|
31
|
+
return body.data;
|
|
32
|
+
}
|
|
33
|
+
function statusOf(err) {
|
|
34
|
+
const status = typeof err === 'object' && err !== null
|
|
35
|
+
? err.status
|
|
36
|
+
: undefined;
|
|
37
|
+
return typeof status === 'number' ? status : undefined;
|
|
38
|
+
}
|
|
39
|
+
function detailOf(err) {
|
|
40
|
+
return err instanceof Error ? err.message : String(err);
|
|
41
|
+
}
|
|
42
|
+
let DecisionPlaneClient = DecisionPlaneClient_1 = class DecisionPlaneClient {
|
|
43
|
+
decisions;
|
|
44
|
+
registry;
|
|
45
|
+
logger = new common_1.Logger(DecisionPlaneClient_1.name);
|
|
46
|
+
constructor(decisions, registry) {
|
|
47
|
+
this.decisions = decisions;
|
|
48
|
+
this.registry = registry;
|
|
49
|
+
}
|
|
50
|
+
async isAvailable() {
|
|
51
|
+
if (this.registry === undefined) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
await this.registry.resolve(exports.DECISION_API_SERVICE);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
this.logger.debug(`${exports.DECISION_API_SERVICE} is not resolvable from the service registry: ` +
|
|
60
|
+
detailOf(err));
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async open(orgId, request) {
|
|
65
|
+
await this.assertAvailable();
|
|
66
|
+
try {
|
|
67
|
+
const body = await this.decisions.post('/internal/decisions', request, { headers: { [ORG_HEADER]: orgId } });
|
|
68
|
+
const decision = unwrap(body, 'POST /internal/decisions');
|
|
69
|
+
this.logger.debug(`Opened decision ${decision.id} attempt=${decision.attempt} ` +
|
|
70
|
+
`producerRef=${decision.producerRef ?? '(none)'} org=${orgId}`);
|
|
71
|
+
return decision;
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
throw this.translate(err, 'POST /internal/decisions', request.subjectResourceRef);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async findByProducerRef(orgId, producerRef) {
|
|
78
|
+
await this.assertAvailable();
|
|
79
|
+
try {
|
|
80
|
+
const body = await this.decisions.get(`/internal/decisions/by-ref/${encodeURIComponent(producerRef)}`, { headers: { [ORG_HEADER]: orgId } });
|
|
81
|
+
return unwrap(body, 'GET /internal/decisions/by-ref');
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
if (statusOf(err) === 404) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
throw this.translate(err, 'GET /internal/decisions/by-ref');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async read(orgId, decisionId) {
|
|
91
|
+
await this.assertAvailable();
|
|
92
|
+
try {
|
|
93
|
+
const body = await this.decisions.get(`/internal/decisions/${encodeURIComponent(decisionId)}`, { headers: { [ORG_HEADER]: orgId } });
|
|
94
|
+
return unwrap(body, 'GET /internal/decisions/:id');
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
throw this.translate(err, 'GET /internal/decisions/:id');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async close(orgId, decisionId, request) {
|
|
101
|
+
await this.assertAvailable();
|
|
102
|
+
try {
|
|
103
|
+
await this.decisions.post(`/internal/decisions/${encodeURIComponent(decisionId)}/close`, request, { headers: { [ORG_HEADER]: orgId } });
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
throw this.translate(err, 'POST /internal/decisions/:id/close');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async withdraw(orgId, decisionId, reason) {
|
|
110
|
+
if (!(await this.isAvailable())) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
await this.close(orgId, decisionId, {
|
|
115
|
+
outcome: wire_1.DecisionOutcome.WITHDRAWN,
|
|
116
|
+
reason: reason.slice(0, 2000),
|
|
117
|
+
});
|
|
118
|
+
this.logger.log(`Withdrew decision ${decisionId} (org ${orgId}): ${reason}`);
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
const status = err instanceof errors_1.DecisionPlaneRequestError ? err.status : undefined;
|
|
123
|
+
if (status === 404 || status === 409) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
this.logger.error(`Could not withdraw decision ${decisionId} (org ${orgId}): ${detailOf(err)}. ` +
|
|
127
|
+
"The ask stays OPEN and will appear in decision-api's abandoned report.");
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async assertAvailable() {
|
|
132
|
+
if (!(await this.isAvailable())) {
|
|
133
|
+
throw new errors_1.DecisionPlaneAbsentError(`no healthy '${exports.DECISION_API_SERVICE}' instance is registered`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
translate(err, operation, subjectResourceRef) {
|
|
137
|
+
if (err instanceof errors_1.DecisionEnvelopeError || err instanceof errors_1.DecisionPlaneAbsentError) {
|
|
138
|
+
return err;
|
|
139
|
+
}
|
|
140
|
+
const detail = detailOf(err);
|
|
141
|
+
if (subjectResourceRef !== undefined &&
|
|
142
|
+
detail.includes('DECISION_SUBJECT_RESOURCE_UNREGISTERED')) {
|
|
143
|
+
return new errors_1.DecisionSubjectUnregisteredError(subjectResourceRef, detail);
|
|
144
|
+
}
|
|
145
|
+
return new errors_1.DecisionPlaneRequestError(operation, statusOf(err), detail, err);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
exports.DecisionPlaneClient = DecisionPlaneClient;
|
|
149
|
+
exports.DecisionPlaneClient = DecisionPlaneClient = DecisionPlaneClient_1 = __decorate([
|
|
150
|
+
(0, common_1.Injectable)(),
|
|
151
|
+
__param(0, (0, service_registry_nest_1.InjectService)(exports.DECISION_API_SERVICE)),
|
|
152
|
+
__param(1, (0, common_1.Optional)()),
|
|
153
|
+
__param(1, (0, common_1.Inject)(service_registry_nest_1.SERVICE_REGISTRY_TOKEN)),
|
|
154
|
+
__metadata("design:paramtypes", [Function, Object])
|
|
155
|
+
], DecisionPlaneClient);
|
|
156
|
+
//# sourceMappingURL=decision-plane.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision-plane.client.js","sourceRoot":"","sources":["../src/decision-plane.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAsE;AACtE,yEAIuC;AAEvC,qCAKkB;AAClB,iCAAyC;AAkB5B,QAAA,oBAAoB,GAAG,cAAc,CAAC;AAGnD,MAAM,UAAU,GAAG,eAAe,CAAC;AAEnC,SAAS,MAAM,CAAI,IAAa,EAAE,SAAiB;IACjD,IACE,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC;QAChB,IAA2B,CAAC,IAAI,KAAK,IAAI;QACzC,IAA2B,CAAC,IAAI,KAAK,SAAS,EAC/C,CAAC;QACD,MAAM,IAAI,8BAAqB,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IACD,OAAQ,IAAoB,CAAC,IAAI,CAAC;AACpC,CAAC;AAGD,SAAS,QAAQ,CAAC,GAAY;IAC5B,MAAM,MAAM,GACV,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QACrC,CAAC,CAAE,GAA4B,CAAC,MAAM;QACtC,CAAC,CAAC,SAAS,CAAC;IAChB,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC;AAED,SAAS,QAAQ,CAAC,GAAY;IAC5B,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oot":"","sources":["../src/decision-plane.module.ts"],"names":[],"mappings":"AAmBA,qBAIa,mBAAmB;CAAG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DecisionPlaneModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const decision_plane_client_1 = require("./decision-plane.client");
|
|
12
|
+
let DecisionPlaneModule = class DecisionPlaneModule {
|
|
13
|
+
};
|
|
14
|
+
exports.DecisionPlaneModule = DecisionPlaneModule;
|
|
15
|
+
exports.DecisionPlaneModule = DecisionPlaneModule = __decorate([
|
|
16
|
+
(0, common_1.Module)({
|
|
17
|
+
providers: [decision_plane_client_1.DecisionPlaneClient],
|
|
18
|
+
exports: [decision_plane_client_1.DecisionPlaneClient],
|
|
19
|
+
})
|
|
20
|
+
], DecisionPlaneModule);
|
|
21
|
+
//# sourceMappingURL=decision-plane.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision-plane.module.js","sourceRoot":"","sources":["../src/decision-plane.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AAExC,mEAA8D;AAqBvD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAAG,CAAA;AAAtB,kDAAmB;8BAAnB,mBAAmB;IAJ/B,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,2CAAmB,CAAC;QAChC,OAAO,EAAE,CAAC,2CAAmB,CAAC;KAC/B,CAAC;GACW,mBAAmB,CAAG"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare abstract class DecisionPlaneError extends Error {
|
|
2
|
+
protected constructor(message: string, options?: {
|
|
3
|
+
cause?: unknown;
|
|
4
|
+
});
|
|
5
|
+
}
|
|
6
|
+
export declare class DecisionPlaneAbsentError extends DecisionPlaneError {
|
|
7
|
+
constructor(reason: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class DecisionSubjectUnregisteredError extends DecisionPlaneError {
|
|
10
|
+
readonly subjectResourceRef: string;
|
|
11
|
+
constructor(subjectResourceRef: string, detail: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class DecisionPlaneRequestError extends DecisionPlaneError {
|
|
14
|
+
readonly operation: string;
|
|
15
|
+
readonly status: number | undefined;
|
|
16
|
+
constructor(operation: string, status: number | undefined, detail: string, cause?: unknown);
|
|
17
|
+
}
|
|
18
|
+
export declare class DecisionEnvelopeError extends DecisionPlaneError {
|
|
19
|
+
constructor(operation: string);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAWA,8BAAsB,kBAAmB,SAAQ,KAAK;IACpD,SAAS,aAAa,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAIrE;AAWD,qBAAa,wBAAyB,SAAQ,kBAAkB;gBAClD,MAAM,EAAE,MAAM;CAG3B;AAcD,qBAAa,gCAAiC,SAAQ,kBAAkB;IAEpE,QAAQ,CAAC,kBAAkB,EAAE,MAAM;gBAA1B,kBAAkB,EAAE,MAAM,EACnC,MAAM,EAAE,MAAM;CAQjB;AAGD,qBAAa,yBAA0B,SAAQ,kBAAkB;IAE7D,QAAQ,CAAC,SAAS,EAAE,MAAM;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;gBAD1B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GAAG,SAAS,EACnC,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,OAAO;CASlB;AAeD,qBAAa,qBAAsB,SAAQ,kBAAkB;gBAC/C,SAAS,EAAE,MAAM;CAQ9B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DecisionEnvelopeError = exports.DecisionPlaneRequestError = exports.DecisionSubjectUnregisteredError = exports.DecisionPlaneAbsentError = exports.DecisionPlaneError = void 0;
|
|
4
|
+
class DecisionPlaneError extends Error {
|
|
5
|
+
constructor(message, options) {
|
|
6
|
+
super(message, options);
|
|
7
|
+
this.name = new.target.name;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.DecisionPlaneError = DecisionPlaneError;
|
|
11
|
+
class DecisionPlaneAbsentError extends DecisionPlaneError {
|
|
12
|
+
constructor(reason) {
|
|
13
|
+
super(`The decision plane is not available: ${reason}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.DecisionPlaneAbsentError = DecisionPlaneAbsentError;
|
|
17
|
+
class DecisionSubjectUnregisteredError extends DecisionPlaneError {
|
|
18
|
+
subjectResourceRef;
|
|
19
|
+
constructor(subjectResourceRef, detail) {
|
|
20
|
+
super(`decision-api refused "${subjectResourceRef}" as an unregistered subject ` +
|
|
21
|
+
`resource: ${detail}. Answerability resolves against the INSTANCE, so ` +
|
|
22
|
+
'the resource must carry registered ownership before an ask can name it.');
|
|
23
|
+
this.subjectResourceRef = subjectResourceRef;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.DecisionSubjectUnregisteredError = DecisionSubjectUnregisteredError;
|
|
27
|
+
class DecisionPlaneRequestError extends DecisionPlaneError {
|
|
28
|
+
operation;
|
|
29
|
+
status;
|
|
30
|
+
constructor(operation, status, detail, cause) {
|
|
31
|
+
super(`decision-api ${operation} failed` +
|
|
32
|
+
(status === undefined ? '' : ` (HTTP ${status})`) +
|
|
33
|
+
`: ${detail}`, { cause });
|
|
34
|
+
this.operation = operation;
|
|
35
|
+
this.status = status;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.DecisionPlaneRequestError = DecisionPlaneRequestError;
|
|
39
|
+
class DecisionEnvelopeError extends DecisionPlaneError {
|
|
40
|
+
constructor(operation) {
|
|
41
|
+
super(`decision-api ${operation} returned a body with no \`data\` envelope. ` +
|
|
42
|
+
'Every route is wrapped by ResponseEnvelopeInterceptor, so this means ' +
|
|
43
|
+
'the contract changed or the response came from something else. ' +
|
|
44
|
+
'Refusing to read it as a bare payload.');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.DecisionEnvelopeError = DecisionEnvelopeError;
|
|
48
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAWA,MAAsB,kBAAmB,SAAQ,KAAK;IACpD,YAAsB,OAAe,EAAE,OAA6B;QAClE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AALD,gDAKC;AAWD,MAAa,wBAAyB,SAAQ,kBAAkB;IAC9D,YAAY,MAAc;QACxB,KAAK,CAAC,wCAAwC,MAAM,EAAE,CAAC,CAAC;IAC1D,CAAC;CACF;AAJD,4DAIC;AAcD,MAAa,gCAAiC,SAAQ,kBAAkB;IAE3D;IADX,YACW,kBAA0B,EACnC,MAAc;QAEd,KAAK,CACH,yBAAyB,kBAAkB,+BAA+B;YACxE,aAAa,MAAM,oDAAoD;YACvE,yEAAyE,CAC5E,CAAC;QAPO,uBAAkB,GAAlB,kBAAkB,CAAQ;IAQrC,CAAC;CACF;AAXD,4EAWC;AAGD,MAAa,yBAA0B,SAAQ,kBAAkB;IAEpD;IACA;IAFX,YACW,SAAiB,EACjB,MAA0B,EACnC,MAAc,EACd,KAAe;QAEf,KAAK,CACH,gBAAgB,SAAS,SAAS;YAChC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,MAAM,GAAG,CAAC;YACjD,KAAK,MAAM,EAAE,EACf,EAAE,KAAK,EAAE,CACV,CAAC;QAVO,cAAS,GAAT,SAAS,CAAQ;QACjB,WAAM,GAAN,MAAM,CAAoB;IAUrC,CAAC;CACF;AAdD,8DAcC;AAeD,MAAa,qBAAsB,SAAQ,kBAAkB;IAC3D,YAAY,SAAiB;QAC3B,KAAK,CACH,gBAAgB,SAAS,8CAA8C;YACrE,uEAAuE;YACvE,iEAAiE;YACjE,wCAAwC,CAC3C,CAAC;IACJ,CAAC;CACF;AATD,sDASC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DecisionPlaneClient, DECISION_API_SERVICE, } from './decision-plane.client';
|
|
2
|
+
export { DecisionPlaneModule } from './decision-plane.module';
|
|
3
|
+
export { DecisionEnvelopeError, DecisionPlaneAbsentError, DecisionPlaneError, DecisionPlaneRequestError, DecisionSubjectUnregisteredError, } from './errors';
|
|
4
|
+
export { DecisionAnswerRestriction, DecisionDeadlineEffect, DecisionKind, DecisionOptionEffect, DecisionOrgRole, DecisionOutcome, DecisionSettlement, DecisionSubjectClassification, RecipientKind, type CloseDecisionRequest, type DeclaredDecisionOption, type DecisionCommitView, type DecisionFact, type DecisionRecipient, type DecisionView, type OpenDecisionRequest, } from './wire';
|
|
5
|
+
export type { ServiceRegistry } from './registry.contract';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,yBAAyB,EACzB,gCAAgC,GACjC,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,6BAA6B,EAC7B,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,QAAQ,CAAC;AAChB,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecipientKind = exports.DecisionSubjectClassification = exports.DecisionSettlement = exports.DecisionOutcome = exports.DecisionOrgRole = exports.DecisionOptionEffect = exports.DecisionKind = exports.DecisionDeadlineEffect = exports.DecisionAnswerRestriction = exports.DecisionSubjectUnregisteredError = exports.DecisionPlaneRequestError = exports.DecisionPlaneError = exports.DecisionPlaneAbsentError = exports.DecisionEnvelopeError = exports.DecisionPlaneModule = exports.DECISION_API_SERVICE = exports.DecisionPlaneClient = void 0;
|
|
4
|
+
var decision_plane_client_1 = require("./decision-plane.client");
|
|
5
|
+
Object.defineProperty(exports, "DecisionPlaneClient", { enumerable: true, get: function () { return decision_plane_client_1.DecisionPlaneClient; } });
|
|
6
|
+
Object.defineProperty(exports, "DECISION_API_SERVICE", { enumerable: true, get: function () { return decision_plane_client_1.DECISION_API_SERVICE; } });
|
|
7
|
+
var decision_plane_module_1 = require("./decision-plane.module");
|
|
8
|
+
Object.defineProperty(exports, "DecisionPlaneModule", { enumerable: true, get: function () { return decision_plane_module_1.DecisionPlaneModule; } });
|
|
9
|
+
var errors_1 = require("./errors");
|
|
10
|
+
Object.defineProperty(exports, "DecisionEnvelopeError", { enumerable: true, get: function () { return errors_1.DecisionEnvelopeError; } });
|
|
11
|
+
Object.defineProperty(exports, "DecisionPlaneAbsentError", { enumerable: true, get: function () { return errors_1.DecisionPlaneAbsentError; } });
|
|
12
|
+
Object.defineProperty(exports, "DecisionPlaneError", { enumerable: true, get: function () { return errors_1.DecisionPlaneError; } });
|
|
13
|
+
Object.defineProperty(exports, "DecisionPlaneRequestError", { enumerable: true, get: function () { return errors_1.DecisionPlaneRequestError; } });
|
|
14
|
+
Object.defineProperty(exports, "DecisionSubjectUnregisteredError", { enumerable: true, get: function () { return errors_1.DecisionSubjectUnregisteredError; } });
|
|
15
|
+
var wire_1 = require("./wire");
|
|
16
|
+
Object.defineProperty(exports, "DecisionAnswerRestriction", { enumerable: true, get: function () { return wire_1.DecisionAnswerRestriction; } });
|
|
17
|
+
Object.defineProperty(exports, "DecisionDeadlineEffect", { enumerable: true, get: function () { return wire_1.DecisionDeadlineEffect; } });
|
|
18
|
+
Object.defineProperty(exports, "DecisionKind", { enumerable: true, get: function () { return wire_1.DecisionKind; } });
|
|
19
|
+
Object.defineProperty(exports, "DecisionOptionEffect", { enumerable: true, get: function () { return wire_1.DecisionOptionEffect; } });
|
|
20
|
+
Object.defineProperty(exports, "DecisionOrgRole", { enumerable: true, get: function () { return wire_1.DecisionOrgRole; } });
|
|
21
|
+
Object.defineProperty(exports, "DecisionOutcome", { enumerable: true, get: function () { return wire_1.DecisionOutcome; } });
|
|
22
|
+
Object.defineProperty(exports, "DecisionSettlement", { enumerable: true, get: function () { return wire_1.DecisionSettlement; } });
|
|
23
|
+
Object.defineProperty(exports, "DecisionSubjectClassification", { enumerable: true, get: function () { return wire_1.DecisionSubjectClassification; } });
|
|
24
|
+
Object.defineProperty(exports, "RecipientKind", { enumerable: true, get: function () { return wire_1.RecipientKind; } });
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iEAGiC;AAF/B,4HAAA,mBAAmB,OAAA;AACnB,6HAAA,oBAAoB,OAAA;AAEtB,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA;AAC5B,mCAMkB;AALhB,+GAAA,qBAAqB,OAAA;AACrB,kHAAA,wBAAwB,OAAA;AACxB,4GAAA,kBAAkB,OAAA;AAClB,mHAAA,yBAAyB,OAAA;AACzB,0HAAA,gCAAgC,OAAA;AAElC,+BAiBgB;AAhBd,iHAAA,yBAAyB,OAAA;AACzB,8GAAA,sBAAsB,OAAA;AACtB,oGAAA,YAAY,OAAA;AACZ,4GAAA,oBAAoB,OAAA;AACpB,uGAAA,eAAe,OAAA;AACf,uGAAA,eAAe,OAAA;AACf,0GAAA,kBAAkB,OAAA;AAClB,qHAAA,6BAA6B,OAAA;AAC7B,qGAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.contract.d.ts","sourceRoot":"","sources":["../src/registry.contract.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.contract.js","sourceRoot":"","sources":["../src/registry.contract.ts"],"names":[],"mappings":""}
|
package/dist/wire.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export declare enum DecisionKind {
|
|
2
|
+
CONFIRM = "CONFIRM",
|
|
3
|
+
VERDICT = "VERDICT",
|
|
4
|
+
PROPOSAL_SET = "PROPOSAL_SET",
|
|
5
|
+
OPEN = "OPEN"
|
|
6
|
+
}
|
|
7
|
+
export declare enum DecisionOptionEffect {
|
|
8
|
+
SETTLING_ACT = "SETTLING_ACT",
|
|
9
|
+
SETTLING_NO_ACT = "SETTLING_NO_ACT",
|
|
10
|
+
ADDITIVE = "ADDITIVE"
|
|
11
|
+
}
|
|
12
|
+
export declare enum DecisionSettlement {
|
|
13
|
+
BY_COMMIT = "BY_COMMIT",
|
|
14
|
+
BY_PRODUCER = "BY_PRODUCER"
|
|
15
|
+
}
|
|
16
|
+
export declare enum DecisionDeadlineEffect {
|
|
17
|
+
CLOSE = "CLOSE",
|
|
18
|
+
HIDE = "HIDE",
|
|
19
|
+
ESCALATE = "ESCALATE"
|
|
20
|
+
}
|
|
21
|
+
export declare enum DecisionAnswerRestriction {
|
|
22
|
+
ANY_PERMITTED = "ANY_PERMITTED",
|
|
23
|
+
ADDRESSED_ONLY = "ADDRESSED_ONLY"
|
|
24
|
+
}
|
|
25
|
+
export declare enum DecisionOrgRole {
|
|
26
|
+
MEMBER = "MEMBER",
|
|
27
|
+
ADMIN = "ADMIN",
|
|
28
|
+
OWNER = "OWNER"
|
|
29
|
+
}
|
|
30
|
+
export declare enum DecisionSubjectClassification {
|
|
31
|
+
PUBLIC = "PUBLIC",
|
|
32
|
+
INTERNAL = "INTERNAL",
|
|
33
|
+
CONFIDENTIAL = "CONFIDENTIAL",
|
|
34
|
+
SECRET = "SECRET",
|
|
35
|
+
REGULATED = "REGULATED"
|
|
36
|
+
}
|
|
37
|
+
export declare enum DecisionOutcome {
|
|
38
|
+
COMMITTED_ACTION = "COMMITTED_ACTION",
|
|
39
|
+
COMMITTED_NO_ACTION = "COMMITTED_NO_ACTION",
|
|
40
|
+
NO_JUDGEMENT = "NO_JUDGEMENT",
|
|
41
|
+
WITHDRAWN = "WITHDRAWN"
|
|
42
|
+
}
|
|
43
|
+
export declare enum RecipientKind {
|
|
44
|
+
HUMAN = "human",
|
|
45
|
+
AGENT = "agent",
|
|
46
|
+
ENDPOINT = "endpoint",
|
|
47
|
+
IDENTITY_GROUP = "identity_group",
|
|
48
|
+
WORKFLOW = "workflow"
|
|
49
|
+
}
|
|
50
|
+
export interface DecisionFact {
|
|
51
|
+
readonly label: string;
|
|
52
|
+
readonly value: string;
|
|
53
|
+
readonly href?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface DecisionRecipient {
|
|
56
|
+
readonly kind: RecipientKind;
|
|
57
|
+
readonly target: Readonly<Record<string, unknown>>;
|
|
58
|
+
readonly mandatory?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface DeclaredDecisionOption {
|
|
61
|
+
readonly key: string;
|
|
62
|
+
readonly label: string;
|
|
63
|
+
readonly description?: string;
|
|
64
|
+
readonly effect: DecisionOptionEffect;
|
|
65
|
+
readonly commitThreshold?: number;
|
|
66
|
+
readonly replySchema?: Readonly<Record<string, unknown>>;
|
|
67
|
+
readonly capabilityRef?: string;
|
|
68
|
+
readonly capabilityArguments?: Readonly<Record<string, unknown>>;
|
|
69
|
+
}
|
|
70
|
+
export interface OpenDecisionRequest {
|
|
71
|
+
readonly idempotencyKey: string;
|
|
72
|
+
readonly kind: DecisionKind;
|
|
73
|
+
readonly settlement?: DecisionSettlement;
|
|
74
|
+
readonly title: string;
|
|
75
|
+
readonly summary?: string;
|
|
76
|
+
readonly facts?: readonly DecisionFact[];
|
|
77
|
+
readonly deepLink?: string;
|
|
78
|
+
readonly subjectResourceRef: string;
|
|
79
|
+
readonly subjectClassification: DecisionSubjectClassification;
|
|
80
|
+
readonly answerCapabilityRef: string;
|
|
81
|
+
readonly producerRef?: string;
|
|
82
|
+
readonly recipients?: readonly DecisionRecipient[];
|
|
83
|
+
readonly answerRestriction?: DecisionAnswerRestriction;
|
|
84
|
+
readonly minimumOrgRole?: DecisionOrgRole;
|
|
85
|
+
readonly raisedByActorId?: string;
|
|
86
|
+
readonly selfAnswerAllowed?: boolean;
|
|
87
|
+
readonly deadlineAt?: string;
|
|
88
|
+
readonly deadlineEffect?: DecisionDeadlineEffect;
|
|
89
|
+
readonly options: readonly DeclaredDecisionOption[];
|
|
90
|
+
readonly openReplySchema?: Readonly<Record<string, unknown>>;
|
|
91
|
+
}
|
|
92
|
+
export interface DecisionCommitView {
|
|
93
|
+
readonly id: string;
|
|
94
|
+
readonly optionKey: string;
|
|
95
|
+
readonly committedBy: string;
|
|
96
|
+
readonly reply: Readonly<Record<string, unknown>> | null;
|
|
97
|
+
readonly note?: string | null;
|
|
98
|
+
}
|
|
99
|
+
export interface DecisionView {
|
|
100
|
+
readonly id: string;
|
|
101
|
+
readonly attempt: number;
|
|
102
|
+
readonly producerRef?: string | null;
|
|
103
|
+
readonly revision: number;
|
|
104
|
+
readonly commits?: readonly DecisionCommitView[];
|
|
105
|
+
}
|
|
106
|
+
export interface CloseDecisionRequest {
|
|
107
|
+
readonly outcome: DecisionOutcome;
|
|
108
|
+
readonly reason?: string;
|
|
109
|
+
readonly expectedRevision?: number;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAsCA,oBAAY,YAAY;IAEtB,OAAO,YAAY;IAEnB,OAAO,YAAY;IAEnB,YAAY,iBAAiB;IAE7B,IAAI,SAAS;CACd;AAGD,oBAAY,oBAAoB;IAE9B,YAAY,iBAAiB;IAE7B,eAAe,oBAAoB;IAEnC,QAAQ,aAAa;CACtB;AAGD,oBAAY,kBAAkB;IAE5B,SAAS,cAAc;IAEvB,WAAW,gBAAgB;CAC5B;AAGD,oBAAY,sBAAsB;IAEhC,KAAK,UAAU;IAEf,IAAI,SAAS;IAEb,QAAQ,aAAa;CACtB;AAGD,oBAAY,yBAAyB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AAC,CAAC,CAAC;CAC9D;AAGD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IACzD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAUD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;CAClD;AAGD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC"}
|
package/dist/wire.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecipientKind = exports.DecisionOutcome = exports.DecisionSubjectClassification = exports.DecisionOrgRole = exports.DecisionAnswerRestriction = exports.DecisionDeadlineEffect = exports.DecisionSettlement = exports.DecisionOptionEffect = exports.DecisionKind = void 0;
|
|
4
|
+
var DecisionKind;
|
|
5
|
+
(function (DecisionKind) {
|
|
6
|
+
DecisionKind["CONFIRM"] = "CONFIRM";
|
|
7
|
+
DecisionKind["VERDICT"] = "VERDICT";
|
|
8
|
+
DecisionKind["PROPOSAL_SET"] = "PROPOSAL_SET";
|
|
9
|
+
DecisionKind["OPEN"] = "OPEN";
|
|
10
|
+
})(DecisionKind || (exports.DecisionKind = DecisionKind = {}));
|
|
11
|
+
var DecisionOptionEffect;
|
|
12
|
+
(function (DecisionOptionEffect) {
|
|
13
|
+
DecisionOptionEffect["SETTLING_ACT"] = "SETTLING_ACT";
|
|
14
|
+
DecisionOptionEffect["SETTLING_NO_ACT"] = "SETTLING_NO_ACT";
|
|
15
|
+
DecisionOptionEffect["ADDITIVE"] = "ADDITIVE";
|
|
16
|
+
})(DecisionOptionEffect || (exports.DecisionOptionEffect = DecisionOptionEffect = {}));
|
|
17
|
+
var DecisionSettlement;
|
|
18
|
+
(function (DecisionSettlement) {
|
|
19
|
+
DecisionSettlement["BY_COMMIT"] = "BY_COMMIT";
|
|
20
|
+
DecisionSettlement["BY_PRODUCER"] = "BY_PRODUCER";
|
|
21
|
+
})(DecisionSettlement || (exports.DecisionSettlement = DecisionSettlement = {}));
|
|
22
|
+
var DecisionDeadlineEffect;
|
|
23
|
+
(function (DecisionDeadlineEffect) {
|
|
24
|
+
DecisionDeadlineEffect["CLOSE"] = "CLOSE";
|
|
25
|
+
DecisionDeadlineEffect["HIDE"] = "HIDE";
|
|
26
|
+
DecisionDeadlineEffect["ESCALATE"] = "ESCALATE";
|
|
27
|
+
})(DecisionDeadlineEffect || (exports.DecisionDeadlineEffect = DecisionDeadlineEffect = {}));
|
|
28
|
+
var DecisionAnswerRestriction;
|
|
29
|
+
(function (DecisionAnswerRestriction) {
|
|
30
|
+
DecisionAnswerRestriction["ANY_PERMITTED"] = "ANY_PERMITTED";
|
|
31
|
+
DecisionAnswerRestriction["ADDRESSED_ONLY"] = "ADDRESSED_ONLY";
|
|
32
|
+
})(DecisionAnswerRestriction || (exports.DecisionAnswerRestriction = DecisionAnswerRestriction = {}));
|
|
33
|
+
var DecisionOrgRole;
|
|
34
|
+
(function (DecisionOrgRole) {
|
|
35
|
+
DecisionOrgRole["MEMBER"] = "MEMBER";
|
|
36
|
+
DecisionOrgRole["ADMIN"] = "ADMIN";
|
|
37
|
+
DecisionOrgRole["OWNER"] = "OWNER";
|
|
38
|
+
})(DecisionOrgRole || (exports.DecisionOrgRole = DecisionOrgRole = {}));
|
|
39
|
+
var DecisionSubjectClassification;
|
|
40
|
+
(function (DecisionSubjectClassification) {
|
|
41
|
+
DecisionSubjectClassification["PUBLIC"] = "PUBLIC";
|
|
42
|
+
DecisionSubjectClassification["INTERNAL"] = "INTERNAL";
|
|
43
|
+
DecisionSubjectClassification["CONFIDENTIAL"] = "CONFIDENTIAL";
|
|
44
|
+
DecisionSubjectClassification["SECRET"] = "SECRET";
|
|
45
|
+
DecisionSubjectClassification["REGULATED"] = "REGULATED";
|
|
46
|
+
})(DecisionSubjectClassification || (exports.DecisionSubjectClassification = DecisionSubjectClassification = {}));
|
|
47
|
+
var DecisionOutcome;
|
|
48
|
+
(function (DecisionOutcome) {
|
|
49
|
+
DecisionOutcome["COMMITTED_ACTION"] = "COMMITTED_ACTION";
|
|
50
|
+
DecisionOutcome["COMMITTED_NO_ACTION"] = "COMMITTED_NO_ACTION";
|
|
51
|
+
DecisionOutcome["NO_JUDGEMENT"] = "NO_JUDGEMENT";
|
|
52
|
+
DecisionOutcome["WITHDRAWN"] = "WITHDRAWN";
|
|
53
|
+
})(DecisionOutcome || (exports.DecisionOutcome = DecisionOutcome = {}));
|
|
54
|
+
var RecipientKind;
|
|
55
|
+
(function (RecipientKind) {
|
|
56
|
+
RecipientKind["HUMAN"] = "human";
|
|
57
|
+
RecipientKind["AGENT"] = "agent";
|
|
58
|
+
RecipientKind["ENDPOINT"] = "endpoint";
|
|
59
|
+
RecipientKind["IDENTITY_GROUP"] = "identity_group";
|
|
60
|
+
RecipientKind["WORKFLOW"] = "workflow";
|
|
61
|
+
})(RecipientKind || (exports.RecipientKind = RecipientKind = {}));
|
|
62
|
+
//# sourceMappingURL=wire.js.map
|
package/dist/wire.js.map
ADDED
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AE3C,gDAA6B,CAAA;IAE7B,0CAAuB,CAAA;AACzB,CAAC,EATW,eAAe,+BAAf,eAAe,QAS1B;AAGD,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,gCAAe,CAAA;IACf,gCAAe,CAAA;IACf,sCAAqB,CAAA;IAErB,kDAAiC,CAAA;IACjC,sCAAqB,CAAA;AACvB,CAAC,EAPW,aAAa,6BAAb,aAAa,QAOxB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xemahq/decision-plane-nest",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Producer-side SDK for the Xema human-decision primitive. One transport, one wire mirror and one consumed-event contract for every service that opens an ask on decision-api — so a producer writes only the two things that are genuinely its own: what the ask SAYS, and what it does when a human answers.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"xema",
|
|
7
|
+
"xema-platform",
|
|
8
|
+
"nestjs",
|
|
9
|
+
"decision",
|
|
10
|
+
"human-in-the-loop"
|
|
11
|
+
],
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"author": "Neuralchowder Inc. <developer@xema.dev> (https://xema.dev)",
|
|
14
|
+
"homepage": "https://docs.xema.dev/decision-plane-nest",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/xema-dev/xema-kernel-sdk.git",
|
|
18
|
+
"directory": "packages/sdks/decision-plane-nest"
|
|
19
|
+
},
|
|
20
|
+
"bugs": "https://github.com/xema-dev/xema-kernel-sdk/issues",
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"registry": "https://registry.npmjs.org/"
|
|
24
|
+
},
|
|
25
|
+
"main": "dist/index.js",
|
|
26
|
+
"types": "dist/index.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@nestjs/common": "^10 || ^11",
|
|
33
|
+
"@xemahq/service-registry-nest": "^0.8.0",
|
|
34
|
+
"reflect-metadata": "^0.2"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@nestjs/common": "11.1.18",
|
|
38
|
+
"@nestjs/core": "11.1.18",
|
|
39
|
+
"@nestjs/testing": "11.1.18",
|
|
40
|
+
"@types/jest": "^30.0.0",
|
|
41
|
+
"@types/node": "25.2.3",
|
|
42
|
+
"jest": "^30.3.0",
|
|
43
|
+
"prettier": "3.6.2",
|
|
44
|
+
"reflect-metadata": "0.2.2",
|
|
45
|
+
"rxjs": "7.8.2",
|
|
46
|
+
"ts-jest": "^29.4.9",
|
|
47
|
+
"typescript": "5.9.3",
|
|
48
|
+
"@xemahq/service-registry-nest": "0.8.4"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"clean": "rm -rf dist",
|
|
52
|
+
"build": "tsc -p tsconfig.build.json",
|
|
53
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
54
|
+
"lint": "eslint .",
|
|
55
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
56
|
+
"test": "jest"
|
|
57
|
+
}
|
|
58
|
+
}
|