@superxd-studio/adptr 0.5.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/GENERATIVE.md +101 -0
- package/INTERACTIONS.md +51 -0
- package/LICENSE +21 -0
- package/README.md +57 -0
- package/REUSE.md +170 -0
- package/REVIEW.md +68 -0
- package/THIRD-PARTY-NOTICES.md +28 -0
- package/ai-sdk/index.js +96 -0
- package/assets/ibm-plex-mono-cyrillic-400-normal.woff2 +0 -0
- package/assets/ibm-plex-mono-cyrillic-500-normal.woff2 +0 -0
- package/assets/ibm-plex-mono-cyrillic-ext-400-normal.woff2 +0 -0
- package/assets/ibm-plex-mono-cyrillic-ext-500-normal.woff2 +0 -0
- package/assets/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- package/assets/ibm-plex-mono-latin-500-normal.woff2 +0 -0
- package/assets/ibm-plex-mono-latin-ext-400-normal.woff2 +0 -0
- package/assets/ibm-plex-mono-latin-ext-500-normal.woff2 +0 -0
- package/assets/ibm-plex-mono-vietnamese-400-normal.woff2 +0 -0
- package/assets/ibm-plex-mono-vietnamese-500-normal.woff2 +0 -0
- package/assets/instrument-sans-latin-ext-wght-normal.woff2 +0 -0
- package/assets/instrument-sans-latin-wght-normal.woff2 +0 -0
- package/assistant-ui/index.js +139 -0
- package/chunks/callout-DKMHSnjc.js +342 -0
- package/chunks/canvas-BJ15-XxE.js +598 -0
- package/chunks/controller-Cfpg0C7v.js +180 -0
- package/chunks/core-BCqVRLUy.js +312 -0
- package/chunks/text-field-BLtoaZFn.js +41 -0
- package/chunks/types-BGF7r1my.js +115 -0
- package/chunks/ui-9DyNsYXY.js +967 -0
- package/core/index.js +4 -0
- package/custom/index.js +64 -0
- package/examples/ai-sdk-backend/package.json +11 -0
- package/examples/ai-sdk-backend/server.mjs +316 -0
- package/examples/custom-backend/copy.mjs +7 -0
- package/examples/custom-backend/server.mjs +118 -0
- package/examples/generative/specs.json +2094 -0
- package/examples/review-backend/copy.mjs +27 -0
- package/examples/review-backend/package.json +11 -0
- package/examples/review-backend/server.mjs +276 -0
- package/examples/web-ai-sdk/index.html +12 -0
- package/examples/web-ai-sdk/package.json +21 -0
- package/examples/web-ai-sdk/src/copy.ts +1 -0
- package/examples/web-ai-sdk/src/main.tsx +64 -0
- package/examples/web-ai-sdk/tsconfig.json +13 -0
- package/examples/web-generative/index.html +12 -0
- package/examples/web-generative/package.json +23 -0
- package/examples/web-generative/src/copy.ts +42 -0
- package/examples/web-generative/src/main.tsx +74 -0
- package/examples/web-generative/tsconfig.json +14 -0
- package/examples/web-independent/index.html +12 -0
- package/examples/web-independent/package.json +20 -0
- package/examples/web-independent/src/main.tsx +32 -0
- package/examples/web-independent/tsconfig.json +14 -0
- package/examples/web-interactions/index.html +12 -0
- package/examples/web-interactions/package.json +21 -0
- package/examples/web-interactions/src/copy.ts +215 -0
- package/examples/web-interactions/src/examples.tsx +628 -0
- package/examples/web-interactions/src/main.tsx +116 -0
- package/examples/web-interactions/tsconfig.json +14 -0
- package/examples/web-review/index.html +12 -0
- package/examples/web-review/package.json +20 -0
- package/examples/web-review/src/main.tsx +59 -0
- package/examples/web-review/tsconfig.json +14 -0
- package/fonts.css +117 -0
- package/generative/index.js +1560 -0
- package/interactions/index.js +1591 -0
- package/langgraph-review/index.js +36 -0
- package/licenses/ai-sdk.txt +13 -0
- package/licenses/assistant-ui-generative.txt +21 -0
- package/licenses/assistant-ui.txt +23 -0
- package/licenses/ibm-plex-mono.txt +93 -0
- package/licenses/instrument-sans.txt +93 -0
- package/licenses/internationalized-date.txt +201 -0
- package/licenses/langgraph.txt +21 -0
- package/licenses/lucide.txt +43 -0
- package/licenses/react-markdown.txt +21 -0
- package/licenses/remark-gfm.txt +22 -0
- package/licenses/zod.txt +21 -0
- package/package.json +138 -0
- package/review/index.js +31 -0
- package/source/components/avatar.tsx +50 -0
- package/source/components/button.tsx +155 -0
- package/source/components/callout.tsx +65 -0
- package/source/components/canvas/connector.tsx +14 -0
- package/source/components/canvas/copy.ts +34 -0
- package/source/components/canvas/index.tsx +257 -0
- package/source/components/canvas/recorder.ts +36 -0
- package/source/components/date-time-field.tsx +77 -0
- package/source/components/flow-motion.tsx +109 -0
- package/source/components/icons.tsx +275 -0
- package/source/components/responsive-overlay.tsx +91 -0
- package/source/components/scenario-picker/copy.ts +5 -0
- package/source/components/scenario-picker/index.tsx +142 -0
- package/source/components/scroll-area.tsx +59 -0
- package/source/components/search-picker.tsx +127 -0
- package/source/components/segmented-control.tsx +123 -0
- package/source/components/skeleton.tsx +11 -0
- package/source/components/spinner.tsx +19 -0
- package/source/components/superxd-arrow.tsx +22 -0
- package/source/components/switch.tsx +45 -0
- package/source/components/text-field.tsx +81 -0
- package/source/components/thinking.tsx +16 -0
- package/source/components/ui/copy.ts +12 -0
- package/source/components/ui/display.tsx +276 -0
- package/source/components/ui/navigation.tsx +346 -0
- package/source/components/ui/portal-theme.tsx +28 -0
- package/source/components/ui/selection.tsx +336 -0
- package/source/lib/cn.ts +23 -0
- package/source/reusable/ai-sdk/index.ts +114 -0
- package/source/reusable/assistant-ui/index.tsx +266 -0
- package/source/reusable/core/attachments.ts +163 -0
- package/source/reusable/core/index.ts +417 -0
- package/source/reusable/custom/index.ts +90 -0
- package/source/reusable/generative/actions.ts +188 -0
- package/source/reusable/generative/copy.ts +47 -0
- package/source/reusable/generative/data.tsx +126 -0
- package/source/reusable/generative/index.tsx +517 -0
- package/source/reusable/generative/schema.ts +327 -0
- package/source/reusable/generative/timeline.tsx +214 -0
- package/source/reusable/generative/vocabulary.tsx +847 -0
- package/source/reusable/interactions/agent.ts +259 -0
- package/source/reusable/interactions/artifact.ts +236 -0
- package/source/reusable/interactions/context.tsx +38 -0
- package/source/reusable/interactions/copy.ts +117 -0
- package/source/reusable/interactions/feedback.ts +73 -0
- package/source/reusable/interactions/index.ts +11 -0
- package/source/reusable/interactions/presentation.tsx +483 -0
- package/source/reusable/interactions/store.ts +74 -0
- package/source/reusable/interactions/threads.ts +126 -0
- package/source/reusable/interactions/web.tsx +574 -0
- package/source/reusable/langgraph-review/index.ts +73 -0
- package/source/reusable/review/controller.ts +263 -0
- package/source/reusable/review/index.ts +47 -0
- package/source/reusable/review/types.ts +189 -0
- package/source/reusable/ui/index.ts +25 -0
- package/source/reusable/uploads/index.ts +48 -0
- package/source/reusable/web/attachments/copy.ts +23 -0
- package/source/reusable/web/attachments/index.tsx +233 -0
- package/source/reusable/web/copy.ts +22 -0
- package/source/reusable/web/index.tsx +470 -0
- package/source/reusable/web/message/copy.ts +26 -0
- package/source/reusable/web/message/index.tsx +388 -0
- package/source/reusable/web/message/streaming.ts +64 -0
- package/source/reusable/web/message/styles.css +21 -0
- package/source/reusable/web/review/copy.ts +78 -0
- package/source/reusable/web/review/flow.ts +24 -0
- package/source/reusable/web/review/index.tsx +506 -0
- package/source/reusable/web/styles.ts +2 -0
- package/source/styles/library.css +612 -0
- package/source/styles/theme.css +228 -0
- package/styles.css +3 -0
- package/styles.d.ts +1 -0
- package/types/components/avatar.d.ts +14 -0
- package/types/components/button.d.ts +36 -0
- package/types/components/callout.d.ts +19 -0
- package/types/components/canvas/connector.d.ts +2 -0
- package/types/components/canvas/copy.d.ts +34 -0
- package/types/components/canvas/index.d.ts +33 -0
- package/types/components/canvas/recorder.d.ts +10 -0
- package/types/components/date-time-field.d.ts +11 -0
- package/types/components/flow-motion.d.ts +38 -0
- package/types/components/icons.d.ts +138 -0
- package/types/components/responsive-overlay.d.ts +15 -0
- package/types/components/scenario-picker/copy.d.ts +5 -0
- package/types/components/scenario-picker/index.d.ts +14 -0
- package/types/components/scroll-area.d.ts +14 -0
- package/types/components/search-picker.d.ts +27 -0
- package/types/components/segmented-control.d.ts +23 -0
- package/types/components/skeleton.d.ts +4 -0
- package/types/components/spinner.d.ts +4 -0
- package/types/components/superxd-arrow.d.ts +5 -0
- package/types/components/switch.d.ts +8 -0
- package/types/components/text-field.d.ts +19 -0
- package/types/components/thinking.d.ts +8 -0
- package/types/components/ui/copy.d.ts +12 -0
- package/types/components/ui/display.d.ts +50 -0
- package/types/components/ui/navigation.d.ts +63 -0
- package/types/components/ui/portal-theme.d.ts +8 -0
- package/types/components/ui/selection.d.ts +37 -0
- package/types/lib/cn.d.ts +3 -0
- package/types/reusable/ai-sdk/index.d.ts +15 -0
- package/types/reusable/assistant-ui/index.d.ts +12 -0
- package/types/reusable/core/attachments.d.ts +54 -0
- package/types/reusable/core/index.d.ts +107 -0
- package/types/reusable/custom/index.d.ts +14 -0
- package/types/reusable/generative/actions.d.ts +45 -0
- package/types/reusable/generative/copy.d.ts +48 -0
- package/types/reusable/generative/data.d.ts +4 -0
- package/types/reusable/generative/index.d.ts +30 -0
- package/types/reusable/generative/schema.d.ts +303 -0
- package/types/reusable/generative/timeline.d.ts +21 -0
- package/types/reusable/generative/vocabulary.d.ts +34 -0
- package/types/reusable/interactions/agent.d.ts +98 -0
- package/types/reusable/interactions/artifact.d.ts +118 -0
- package/types/reusable/interactions/context.d.ts +130 -0
- package/types/reusable/interactions/copy.d.ts +115 -0
- package/types/reusable/interactions/feedback.d.ts +34 -0
- package/types/reusable/interactions/index.d.ts +10 -0
- package/types/reusable/interactions/presentation.d.ts +97 -0
- package/types/reusable/interactions/store.d.ts +29 -0
- package/types/reusable/interactions/threads.d.ts +38 -0
- package/types/reusable/interactions/web.d.ts +22 -0
- package/types/reusable/langgraph-review/index.d.ts +5 -0
- package/types/reusable/review/controller.d.ts +52 -0
- package/types/reusable/review/index.d.ts +12 -0
- package/types/reusable/review/types.d.ts +61 -0
- package/types/reusable/ui/index.d.ts +19 -0
- package/types/reusable/uploads/index.d.ts +11 -0
- package/types/reusable/web/attachments/copy.d.ts +25 -0
- package/types/reusable/web/attachments/index.d.ts +24 -0
- package/types/reusable/web/copy.d.ts +24 -0
- package/types/reusable/web/index.d.ts +41 -0
- package/types/reusable/web/message/copy.d.ts +27 -0
- package/types/reusable/web/message/index.d.ts +56 -0
- package/types/reusable/web/message/streaming.d.ts +27 -0
- package/types/reusable/web/review/copy.d.ts +72 -0
- package/types/reusable/web/review/flow.d.ts +3 -0
- package/types/reusable/web/review/index.d.ts +38 -0
- package/types/reusable/web/styles.d.ts +2 -0
- package/ui/index.js +4 -0
- package/uploads/index.js +34 -0
- package/web/index.js +931 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { a as e, i as t, o as n, t as r } from "./types-BGF7r1my.js";
|
|
2
|
+
//#region src/reusable/review/controller.ts
|
|
3
|
+
function i(e) {
|
|
4
|
+
return e.record && (e.record.proposal.changes.forEach(Object.freeze), Object.freeze(e.record.proposal.changes), Object.freeze(e.record.proposal), Object.freeze(e.record.appliedIds), Object.freeze(e.record.remainingIds), Object.freeze(e.record)), e.decision && (Object.freeze(e.decision.changeIds), Object.freeze(e.decision)), Object.freeze(e.selectedIds), Object.freeze(e);
|
|
5
|
+
}
|
|
6
|
+
var a = i({
|
|
7
|
+
status: "idle",
|
|
8
|
+
record: null,
|
|
9
|
+
selectedIds: [],
|
|
10
|
+
decision: null,
|
|
11
|
+
issue: null
|
|
12
|
+
});
|
|
13
|
+
function o(e) {
|
|
14
|
+
return e.outcome === "complete" || e.outcome === "denied" ? e.outcome : e.proposal.canDecide ? e.outcome === "partial" ? "partial" : "ready" : "blocked";
|
|
15
|
+
}
|
|
16
|
+
function s(e, t) {
|
|
17
|
+
switch (t.type) {
|
|
18
|
+
case "loading": return {
|
|
19
|
+
...e,
|
|
20
|
+
status: "loading",
|
|
21
|
+
decision: null,
|
|
22
|
+
issue: null
|
|
23
|
+
};
|
|
24
|
+
case "loaded": return {
|
|
25
|
+
...a,
|
|
26
|
+
status: o(t.record),
|
|
27
|
+
record: t.record
|
|
28
|
+
};
|
|
29
|
+
case "selected": return {
|
|
30
|
+
...e,
|
|
31
|
+
selectedIds: t.ids,
|
|
32
|
+
issue: null
|
|
33
|
+
};
|
|
34
|
+
case "prepared": return {
|
|
35
|
+
...e,
|
|
36
|
+
status: "confirming",
|
|
37
|
+
decision: t.decision,
|
|
38
|
+
issue: null
|
|
39
|
+
};
|
|
40
|
+
case "back": return {
|
|
41
|
+
...e,
|
|
42
|
+
status: e.record?.outcome === "partial" ? "partial" : "ready",
|
|
43
|
+
decision: null,
|
|
44
|
+
issue: null
|
|
45
|
+
};
|
|
46
|
+
case "sending": return {
|
|
47
|
+
...e,
|
|
48
|
+
status: "submitting",
|
|
49
|
+
issue: null
|
|
50
|
+
};
|
|
51
|
+
case "checking": return {
|
|
52
|
+
...e,
|
|
53
|
+
status: "checking",
|
|
54
|
+
issue: null
|
|
55
|
+
};
|
|
56
|
+
case "settled": return {
|
|
57
|
+
...a,
|
|
58
|
+
record: t.receipt.record,
|
|
59
|
+
status: o(t.receipt.record),
|
|
60
|
+
selectedIds: t.receipt.record.outcome === "partial" ? t.receipt.record.remainingIds : []
|
|
61
|
+
};
|
|
62
|
+
case "unapplied": return {
|
|
63
|
+
...e,
|
|
64
|
+
status: "confirming",
|
|
65
|
+
issue: "not-applied"
|
|
66
|
+
};
|
|
67
|
+
case "failed": return {
|
|
68
|
+
...e,
|
|
69
|
+
status: t.status,
|
|
70
|
+
decision: t.status === "conflict" || t.status === "blocked" ? null : e.decision
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
var c = class {
|
|
75
|
+
adapter;
|
|
76
|
+
newId;
|
|
77
|
+
state = a;
|
|
78
|
+
listeners = /* @__PURE__ */ new Set();
|
|
79
|
+
operation = null;
|
|
80
|
+
generation = 0;
|
|
81
|
+
constructor(e, t = () => crypto.randomUUID()) {
|
|
82
|
+
this.adapter = e, this.newId = t;
|
|
83
|
+
}
|
|
84
|
+
getSnapshot = () => this.state;
|
|
85
|
+
subscribe = (e) => (this.listeners.add(e), () => this.listeners.delete(e));
|
|
86
|
+
dispatch(e) {
|
|
87
|
+
this.state = i(s(this.state, e)), this.listeners.forEach((e) => e());
|
|
88
|
+
}
|
|
89
|
+
async run(e, t) {
|
|
90
|
+
let n = ++this.generation;
|
|
91
|
+
this.operation?.abort();
|
|
92
|
+
let i = new AbortController();
|
|
93
|
+
this.operation = i;
|
|
94
|
+
try {
|
|
95
|
+
await e(i.signal);
|
|
96
|
+
} catch (e) {
|
|
97
|
+
n === this.generation && !i.signal.aborted && this.dispatch({
|
|
98
|
+
type: "failed",
|
|
99
|
+
status: e instanceof r ? e.kind : t
|
|
100
|
+
});
|
|
101
|
+
} finally {
|
|
102
|
+
n === this.generation && (this.operation = null);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
load = () => this.operation || this.state.decision || ![
|
|
106
|
+
"idle",
|
|
107
|
+
"load-error",
|
|
108
|
+
"conflict",
|
|
109
|
+
"blocked"
|
|
110
|
+
].includes(this.state.status) ? !1 : (this.dispatch({ type: "loading" }), this.run(async (t) => {
|
|
111
|
+
let n = e(await this.adapter.load(t));
|
|
112
|
+
t.aborted || this.dispatch({
|
|
113
|
+
type: "loaded",
|
|
114
|
+
record: n
|
|
115
|
+
});
|
|
116
|
+
}, "load-error"), !0);
|
|
117
|
+
select = (e, t) => {
|
|
118
|
+
if (!["ready", "partial"].includes(this.state.status) || !this.state.record?.proposal.canDecide || !this.state.record.remainingIds.includes(e)) return !1;
|
|
119
|
+
let n = new Set(this.state.selectedIds);
|
|
120
|
+
return t ? n.add(e) : n.delete(e), this.dispatch({
|
|
121
|
+
type: "selected",
|
|
122
|
+
ids: [...n]
|
|
123
|
+
}), !0;
|
|
124
|
+
};
|
|
125
|
+
prepare = (e) => {
|
|
126
|
+
let { record: t, status: n, selectedIds: r } = this.state;
|
|
127
|
+
return !t?.proposal.canDecide || !["ready", "partial"].includes(n) || e === "approve" && !r.length ? !1 : (this.dispatch({
|
|
128
|
+
type: "prepared",
|
|
129
|
+
decision: {
|
|
130
|
+
requestId: this.newId(),
|
|
131
|
+
proposalId: t.proposal.id,
|
|
132
|
+
revision: t.proposal.revision,
|
|
133
|
+
choice: e,
|
|
134
|
+
changeIds: e === "approve" ? [...r].sort() : []
|
|
135
|
+
}
|
|
136
|
+
}), !0);
|
|
137
|
+
};
|
|
138
|
+
back = () => this.state.status !== "confirming" || this.state.issue === "not-applied" ? !1 : (this.dispatch({ type: "back" }), !0);
|
|
139
|
+
verifyReceipt(e, t) {
|
|
140
|
+
if (e.requestId !== t.requestId || e.choice !== t.choice || e.record.proposal.id !== t.proposalId || e.appliedIds.some((e) => !t.changeIds.includes(e)) || e.record.proposal.revision <= t.revision) throw Error("Receipt does not match decision");
|
|
141
|
+
let n = this.state.record?.appliedIds ?? [], r = e.record.appliedIds.filter((e) => !n.includes(e));
|
|
142
|
+
if (n.some((t) => !e.record.appliedIds.includes(t)) || r.length !== e.appliedIds.length || r.some((t) => !e.appliedIds.includes(t)) || e.record.remainingIds.some((e) => !t.changeIds.includes(e)) || t.choice === "approve" && t.changeIds.some((t) => !e.appliedIds.includes(t) && !e.record.remainingIds.includes(t))) throw Error("Receipt has an unexpected scope");
|
|
143
|
+
}
|
|
144
|
+
submit = () => {
|
|
145
|
+
let e = this.state.decision;
|
|
146
|
+
return this.state.status !== "confirming" || !e || this.operation ? !1 : (this.dispatch({ type: "sending" }), this.run(async (n) => {
|
|
147
|
+
let r = t(await this.adapter.decide(e, n));
|
|
148
|
+
this.verifyReceipt(r, e), n.aborted || this.dispatch({
|
|
149
|
+
type: "settled",
|
|
150
|
+
receipt: r
|
|
151
|
+
});
|
|
152
|
+
}, "uncertain"), !0);
|
|
153
|
+
};
|
|
154
|
+
recover = () => {
|
|
155
|
+
let e = this.state.decision;
|
|
156
|
+
return !(this.state.status === "uncertain" || this.state.status === "confirming" && this.state.issue === "not-applied") || !e || this.operation ? !1 : (this.dispatch({ type: "checking" }), this.run(async (t) => {
|
|
157
|
+
let r = n(await this.adapter.recover(e.requestId, t));
|
|
158
|
+
t.aborted || (r.receipt ? (this.verifyReceipt(r.receipt, e), this.dispatch({
|
|
159
|
+
type: "settled",
|
|
160
|
+
receipt: r.receipt
|
|
161
|
+
})) : r.record.proposal.id !== e.proposalId || r.record.proposal.revision !== e.revision || r.record.outcome === "complete" || r.record.outcome === "denied" ? this.dispatch({
|
|
162
|
+
type: "failed",
|
|
163
|
+
status: "conflict"
|
|
164
|
+
}) : r.record.proposal.canDecide ? this.dispatch({ type: "unapplied" }) : this.dispatch({
|
|
165
|
+
type: "failed",
|
|
166
|
+
status: "blocked"
|
|
167
|
+
}));
|
|
168
|
+
}, "uncertain"), !0);
|
|
169
|
+
};
|
|
170
|
+
disconnect = () => {
|
|
171
|
+
++this.generation, this.operation?.abort(), this.operation = null;
|
|
172
|
+
let e = ["submitting", "checking"].includes(this.state.status) ? "uncertain" : this.state.status === "loading" ? "idle" : this.state.status;
|
|
173
|
+
e !== this.state.status && (this.state = i({
|
|
174
|
+
...this.state,
|
|
175
|
+
status: e
|
|
176
|
+
}), this.listeners.forEach((e) => e()));
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
//#endregion
|
|
180
|
+
export { s as n, c as t };
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import "./controller-Cfpg0C7v.js";
|
|
2
|
+
//#region src/reusable/core/attachments.ts
|
|
3
|
+
var e = class {
|
|
4
|
+
adapter;
|
|
5
|
+
policy;
|
|
6
|
+
id;
|
|
7
|
+
snapshot = { items: [] };
|
|
8
|
+
listeners = /* @__PURE__ */ new Set();
|
|
9
|
+
sources = /* @__PURE__ */ new Map();
|
|
10
|
+
active = /* @__PURE__ */ new Map();
|
|
11
|
+
constructor(e, t, n) {
|
|
12
|
+
this.adapter = e, this.policy = t, this.id = n;
|
|
13
|
+
}
|
|
14
|
+
getSnapshot = () => this.snapshot;
|
|
15
|
+
subscribe = (e) => (this.listeners.add(e), () => this.listeners.delete(e));
|
|
16
|
+
publish(e, t) {
|
|
17
|
+
this.snapshot = {
|
|
18
|
+
items: e,
|
|
19
|
+
...t ? { issue: t } : {}
|
|
20
|
+
};
|
|
21
|
+
for (let e of this.listeners) e();
|
|
22
|
+
}
|
|
23
|
+
add = (e) => {
|
|
24
|
+
let t;
|
|
25
|
+
for (let n of e) {
|
|
26
|
+
if (this.snapshot.items.length >= this.policy.maxFiles) {
|
|
27
|
+
t = "count";
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
let e = this.id(), r = this.policy.mediaTypes.includes(n.mediaType) ? !Number.isSafeInteger(n.size) || n.size < 1 || n.size > this.policy.maxBytes ? "size" : void 0 : "type", i = {
|
|
31
|
+
...n,
|
|
32
|
+
id: e
|
|
33
|
+
};
|
|
34
|
+
this.sources.set(e, i);
|
|
35
|
+
let a = {
|
|
36
|
+
id: e,
|
|
37
|
+
name: n.name,
|
|
38
|
+
mediaType: n.mediaType,
|
|
39
|
+
size: n.size,
|
|
40
|
+
status: r ? "rejected" : "uploading",
|
|
41
|
+
...r ? { issue: r } : {}
|
|
42
|
+
};
|
|
43
|
+
this.publish([...this.snapshot.items, a]), r || this.begin(e, i);
|
|
44
|
+
}
|
|
45
|
+
t && this.publish(this.snapshot.items, t);
|
|
46
|
+
};
|
|
47
|
+
cancel = (e) => {
|
|
48
|
+
this.active.has(e) && (this.active.get(e)?.abort(), this.active.delete(e), this.publish(this.snapshot.items.map((t) => t.id === e ? {
|
|
49
|
+
...t,
|
|
50
|
+
status: "cancelled"
|
|
51
|
+
} : t)));
|
|
52
|
+
};
|
|
53
|
+
remove = (e) => {
|
|
54
|
+
let t = this.snapshot.items.find((t) => t.id === e);
|
|
55
|
+
this.active.get(e)?.abort(), this.active.delete(e), this.sources.delete(e), t?.file && this.adapter.release?.(t.file).catch(() => {}), this.publish(this.snapshot.items.filter((t) => t.id !== e));
|
|
56
|
+
};
|
|
57
|
+
retry = (e) => {
|
|
58
|
+
let t = this.snapshot.items.find((t) => t.id === e), n = this.sources.get(e);
|
|
59
|
+
n && t && ["error", "cancelled"].includes(t.status) && (this.publish(this.snapshot.items.map((t) => t.id === e ? {
|
|
60
|
+
...t,
|
|
61
|
+
status: "uploading",
|
|
62
|
+
issue: void 0
|
|
63
|
+
} : t)), this.begin(e, n));
|
|
64
|
+
};
|
|
65
|
+
transfer = () => {
|
|
66
|
+
let e = this.snapshot.items.filter((e) => e.status === "ready");
|
|
67
|
+
for (let t of e) this.sources.delete(t.id);
|
|
68
|
+
this.publish(this.snapshot.items.filter((e) => e.status !== "ready"));
|
|
69
|
+
};
|
|
70
|
+
dispose = () => {
|
|
71
|
+
for (let e of this.active.values()) e.abort();
|
|
72
|
+
this.active.clear();
|
|
73
|
+
for (let e of this.snapshot.items) e.file && this.adapter.release?.(e.file).catch(() => {});
|
|
74
|
+
this.sources.clear(), this.snapshot = { items: [] }, this.listeners.clear();
|
|
75
|
+
};
|
|
76
|
+
begin(e, t) {
|
|
77
|
+
let r = new AbortController();
|
|
78
|
+
this.active.set(e, r), Promise.resolve().then(() => {
|
|
79
|
+
if (r.signal.aborted) throw Error("Upload cancelled before start");
|
|
80
|
+
return this.adapter.upload(t, r.signal);
|
|
81
|
+
}).then((i) => {
|
|
82
|
+
let a = n(i);
|
|
83
|
+
if (a.name !== t.name || a.mediaType !== t.mediaType || a.size !== t.size) throw Error("Upload reference mismatch");
|
|
84
|
+
if (this.active.get(e) !== r || r.signal.aborted) {
|
|
85
|
+
this.adapter.release?.(a).catch(() => {});
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.active.delete(e), this.publish(this.snapshot.items.map((t) => t.id === e ? {
|
|
89
|
+
...t,
|
|
90
|
+
status: "ready",
|
|
91
|
+
file: a
|
|
92
|
+
} : t));
|
|
93
|
+
}).catch(() => {
|
|
94
|
+
this.active.get(e) === r && (this.active.delete(e), this.publish(this.snapshot.items.map((t) => t.id === e ? {
|
|
95
|
+
...t,
|
|
96
|
+
status: "error",
|
|
97
|
+
issue: "failed"
|
|
98
|
+
} : t)));
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}, t = class extends Error {
|
|
102
|
+
constructor() {
|
|
103
|
+
super("The stream ended before its finish event.");
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
function n(e) {
|
|
107
|
+
if (typeof e != "object" || !e) throw Error("Invalid file");
|
|
108
|
+
let t = e;
|
|
109
|
+
if (typeof t.id != "string" || !/^[\w-]{1,100}$/.test(t.id) || typeof t.name != "string" || !t.name.trim() || t.name.length > 255 || typeof t.mediaType != "string" || !/^[\w.+-]+\/[\w.+-]+$/.test(t.mediaType) || typeof t.size != "number" || !Number.isSafeInteger(t.size) || t.size < 1 || t.size > 1e7 || typeof t.url != "string" || t.url.length > 2e3) throw Error("Invalid file");
|
|
110
|
+
let n = new URL(t.url);
|
|
111
|
+
if (!["http:", "https:"].includes(n.protocol) || n.username || n.password) throw Error("Invalid file URL");
|
|
112
|
+
return {
|
|
113
|
+
id: t.id,
|
|
114
|
+
name: t.name,
|
|
115
|
+
mediaType: t.mediaType,
|
|
116
|
+
size: t.size,
|
|
117
|
+
url: t.url
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function r(e) {
|
|
121
|
+
if (typeof e != "object" || !e || !("type" in e)) throw Error("Invalid chat event");
|
|
122
|
+
if ((e.type === "text" || e.type === "replace-text") && "text" in e && typeof e.text == "string" && e.text.length <= 1e5) return {
|
|
123
|
+
type: e.type,
|
|
124
|
+
text: e.text
|
|
125
|
+
};
|
|
126
|
+
if (e.type === "metadata" && "metadata" in e && typeof e.metadata == "object" && e.metadata !== null && !Array.isArray(e.metadata) && JSON.stringify(e.metadata).length <= 2e5) return {
|
|
127
|
+
type: "metadata",
|
|
128
|
+
metadata: e.metadata
|
|
129
|
+
};
|
|
130
|
+
if (e.type === "finish" || e.type === "error") return { type: e.type };
|
|
131
|
+
throw Error("Unsupported chat event");
|
|
132
|
+
}
|
|
133
|
+
function i(e) {
|
|
134
|
+
if (typeof e != "object" || !e || !("requestId" in e) || typeof e.requestId != "string" || !/^[\w-]{1,100}$/.test(e.requestId) || !("messages" in e) || !Array.isArray(e.messages) || e.messages.length < 1 || e.messages.length > 100) throw Error("Invalid chat request");
|
|
135
|
+
let t = e.messages.map((e) => {
|
|
136
|
+
if (typeof e != "object" || !e || !("id" in e) || typeof e.id != "string" || e.id.length > 100 || !("role" in e) || e.role !== "user" && e.role !== "assistant" || !("text" in e) || typeof e.text != "string" || e.text.length > (e.role === "user" ? 2e4 : 1e5)) throw Error("Invalid message");
|
|
137
|
+
let t = "files" in e && e.files !== void 0 ? Array.isArray(e.files) && e.files.length <= 4 ? e.files.map(n) : (() => {
|
|
138
|
+
throw Error("Invalid files");
|
|
139
|
+
})() : void 0;
|
|
140
|
+
return {
|
|
141
|
+
id: e.id,
|
|
142
|
+
role: e.role,
|
|
143
|
+
text: e.text,
|
|
144
|
+
...t?.length ? { files: t } : {}
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
|
+
if (t.at(-1)?.role !== "user" || new Set(t.map((e) => e.id)).size !== t.length) throw Error("Invalid message order");
|
|
148
|
+
return {
|
|
149
|
+
requestId: e.requestId,
|
|
150
|
+
messages: t
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
var a = class {
|
|
154
|
+
adapter;
|
|
155
|
+
id;
|
|
156
|
+
snapshot;
|
|
157
|
+
listeners = /* @__PURE__ */ new Set();
|
|
158
|
+
nodes = /* @__PURE__ */ new Map();
|
|
159
|
+
children = /* @__PURE__ */ new Map();
|
|
160
|
+
selected = /* @__PURE__ */ new Map();
|
|
161
|
+
active;
|
|
162
|
+
generation = 0;
|
|
163
|
+
constructor(e, t) {
|
|
164
|
+
this.adapter = e, this.id = t, this.snapshot = {
|
|
165
|
+
messages: [],
|
|
166
|
+
status: "idle",
|
|
167
|
+
capabilities: e.capabilities
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
getSnapshot = () => this.snapshot;
|
|
171
|
+
subscribe = (e) => (this.listeners.add(e), () => this.listeners.delete(e));
|
|
172
|
+
path() {
|
|
173
|
+
let e = [], t = this.selected.get(null);
|
|
174
|
+
for (; t;) {
|
|
175
|
+
let n = this.nodes.get(t);
|
|
176
|
+
if (!n) break;
|
|
177
|
+
e.push(n), t = this.selected.get(t);
|
|
178
|
+
}
|
|
179
|
+
return e;
|
|
180
|
+
}
|
|
181
|
+
publish() {
|
|
182
|
+
let e = this.path(), t = {};
|
|
183
|
+
for (let n of e) {
|
|
184
|
+
let e = this.children.get(n.parent) ?? [];
|
|
185
|
+
e.length > 1 && (t[n.message.id] = {
|
|
186
|
+
index: e.indexOf(n.message.id),
|
|
187
|
+
count: e.length
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
this.snapshot = {
|
|
191
|
+
...this.snapshot,
|
|
192
|
+
messages: e.map((e) => e.message),
|
|
193
|
+
status: e.at(-1)?.status ?? "idle",
|
|
194
|
+
branches: t
|
|
195
|
+
};
|
|
196
|
+
for (let e of this.listeners) e();
|
|
197
|
+
}
|
|
198
|
+
add(e, t, n) {
|
|
199
|
+
let r = {
|
|
200
|
+
message: e,
|
|
201
|
+
parent: t,
|
|
202
|
+
status: n
|
|
203
|
+
};
|
|
204
|
+
return this.nodes.set(e.id, r), this.children.set(t, [...this.children.get(t) ?? [], e.id]), this.selected.set(t, e.id), r;
|
|
205
|
+
}
|
|
206
|
+
room(e, t = 1) {
|
|
207
|
+
return this.nodes.size + t <= 500 && (this.children.get(e)?.length ?? 0) < 20;
|
|
208
|
+
}
|
|
209
|
+
send = (e, t = []) => {
|
|
210
|
+
let r = this.snapshot.messages.at(-1)?.id ?? null;
|
|
211
|
+
if (this.active || !this.adapter.capabilities.send || !e.trim() && !t.length || t.length > 0 && !this.adapter.capabilities.attachments || t.length > 4 || e.length > 2e4 || this.snapshot.messages.length >= 98 || !this.room(r, 2)) return !1;
|
|
212
|
+
let i;
|
|
213
|
+
try {
|
|
214
|
+
i = t.map(n);
|
|
215
|
+
} catch {
|
|
216
|
+
return !1;
|
|
217
|
+
}
|
|
218
|
+
let a = this.add({
|
|
219
|
+
id: this.id(),
|
|
220
|
+
role: "user",
|
|
221
|
+
text: e,
|
|
222
|
+
...i.length ? { files: i } : {}
|
|
223
|
+
}, r, "idle");
|
|
224
|
+
return this.begin(a), !0;
|
|
225
|
+
};
|
|
226
|
+
edit = (e, t) => {
|
|
227
|
+
let n = this.snapshot.messages.findIndex((t) => t.id === e && t.role === "user"), r = this.nodes.get(e);
|
|
228
|
+
if (this.active || !this.adapter.capabilities.send || !this.adapter.capabilities.edit || !r || n < 0 || t.length > 2e4 || !t.trim() && !r.message.files?.length || t === r.message.text || !this.room(r.parent, 2)) return !1;
|
|
229
|
+
let i = this.add({
|
|
230
|
+
...r.message,
|
|
231
|
+
id: this.id(),
|
|
232
|
+
text: t
|
|
233
|
+
}, r.parent, "idle");
|
|
234
|
+
return this.begin(i), !0;
|
|
235
|
+
};
|
|
236
|
+
regenerate = (e) => {
|
|
237
|
+
let t = this.nodes.get(e), n = this.snapshot.messages.findIndex((t) => t.id === e && t.role === "assistant"), r = t?.parent ? this.nodes.get(t.parent) : void 0;
|
|
238
|
+
return this.active || !this.adapter.capabilities.send || !this.adapter.capabilities.regenerate || n < 0 || r?.message.role !== "user" || !this.room(r.message.id) ? !1 : (this.begin(r), !0);
|
|
239
|
+
};
|
|
240
|
+
selectBranch = (e, t) => {
|
|
241
|
+
let n = this.nodes.get(e);
|
|
242
|
+
if (this.active || !this.adapter.capabilities.branches || !n || !this.snapshot.messages.some((t) => t.id === e)) return !1;
|
|
243
|
+
let r = this.children.get(n.parent) ?? [], i = r[r.indexOf(e) + (t === "previous" ? -1 : 1)];
|
|
244
|
+
return i ? (this.selected.set(n.parent, i), this.publish(), !0) : !1;
|
|
245
|
+
};
|
|
246
|
+
retry = () => {
|
|
247
|
+
let e = this.nodes.get(this.snapshot.messages.at(-1)?.id ?? ""), t = e?.parent ? this.nodes.get(e.parent) : void 0;
|
|
248
|
+
return this.active || !this.adapter.capabilities.retry || t?.message.role !== "user" || ![
|
|
249
|
+
"error",
|
|
250
|
+
"interrupted",
|
|
251
|
+
"cancelled"
|
|
252
|
+
].includes(this.snapshot.status) || !this.room(t.message.id) ? !1 : (this.begin(t), !0);
|
|
253
|
+
};
|
|
254
|
+
cancel = () => {
|
|
255
|
+
if (!this.active || !this.adapter.capabilities.cancel) return;
|
|
256
|
+
++this.generation, this.active.abort(), this.active = void 0;
|
|
257
|
+
let e = this.nodes.get(this.snapshot.messages.at(-1)?.id ?? "");
|
|
258
|
+
e && (e.status = "cancelled"), this.publish();
|
|
259
|
+
};
|
|
260
|
+
dispose = () => {
|
|
261
|
+
++this.generation, this.active?.abort(), this.active = void 0, this.listeners.clear();
|
|
262
|
+
};
|
|
263
|
+
begin(e) {
|
|
264
|
+
let t = ++this.generation, n = new AbortController();
|
|
265
|
+
this.active = n;
|
|
266
|
+
let r = this.add({
|
|
267
|
+
id: this.id(),
|
|
268
|
+
role: "assistant",
|
|
269
|
+
text: ""
|
|
270
|
+
}, e.message.id, "waiting");
|
|
271
|
+
this.publish();
|
|
272
|
+
let i = this.snapshot.messages.slice(0, -1);
|
|
273
|
+
this.consume(i, r, t, n);
|
|
274
|
+
}
|
|
275
|
+
async consume(e, n, r, i) {
|
|
276
|
+
try {
|
|
277
|
+
let a = !1;
|
|
278
|
+
for await (let t of this.adapter.run({
|
|
279
|
+
requestId: this.id(),
|
|
280
|
+
messages: e
|
|
281
|
+
}, i.signal)) {
|
|
282
|
+
if (r !== this.generation || i.signal.aborted) return;
|
|
283
|
+
if (t.type === "error") throw Error("Response failed");
|
|
284
|
+
if (t.type === "finish") {
|
|
285
|
+
a = !0;
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
if (t.type === "metadata") n.message = {
|
|
289
|
+
...n.message,
|
|
290
|
+
metadata: t.metadata
|
|
291
|
+
};
|
|
292
|
+
else {
|
|
293
|
+
let e = t.type === "replace-text" ? t.text : n.message.text + t.text;
|
|
294
|
+
if (e.length > 1e5) throw Error("Response too large");
|
|
295
|
+
n.message = {
|
|
296
|
+
...n.message,
|
|
297
|
+
text: e
|
|
298
|
+
}, n.status = "streaming";
|
|
299
|
+
}
|
|
300
|
+
this.publish();
|
|
301
|
+
}
|
|
302
|
+
if (r !== this.generation) return;
|
|
303
|
+
if (!a) throw new t();
|
|
304
|
+
this.active = void 0, n.status = "complete", this.publish();
|
|
305
|
+
} catch (e) {
|
|
306
|
+
if (r !== this.generation) return;
|
|
307
|
+
this.active = void 0, n.status = e instanceof t ? "interrupted" : "error", this.publish();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
//#endregion
|
|
312
|
+
export { i as a, n as i, t as n, e as o, r, a as t };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { O as e, m as t } from "./callout-DKMHSnjc.js";
|
|
2
|
+
import { FieldError as n, Input as r, Label as i, Text as a, TextArea as o, TextField as s } from "react-aria-components";
|
|
3
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/text-field.tsx
|
|
5
|
+
var d = "w-full rounded-control border border-line-input bg-surface px-control-md-x text-sm text-fg-emphasis shadow-control outline-none transition-[border-color,box-shadow] duration-(--duration-snap) ease-snap placeholder:text-fg-subtle data-hovered:border-line-emphasis data-focused:border-focus data-focused:ring-2 data-focused:ring-focus/15 data-invalid:border-error data-invalid:data-focused:ring-error/15 data-disabled:cursor-not-allowed data-disabled:bg-surface-muted data-disabled:text-fg-muted";
|
|
6
|
+
function f({ label: f, description: p, error: m, placeholder: h, optional: g, multiline: _, rows: v = 3, className: y, inputClassName: b, ...x }) {
|
|
7
|
+
return /* @__PURE__ */ u(s, {
|
|
8
|
+
...x,
|
|
9
|
+
isInvalid: !!m || x.isInvalid,
|
|
10
|
+
validationBehavior: x.validationBehavior ?? "aria",
|
|
11
|
+
className: e("flex flex-col gap-1.5", typeof y == "string" ? y : void 0),
|
|
12
|
+
children: [
|
|
13
|
+
/* @__PURE__ */ u(i, {
|
|
14
|
+
className: "type-label text-fg-emphasis",
|
|
15
|
+
children: [f, g ? /* @__PURE__ */ l("span", {
|
|
16
|
+
className: "font-normal text-fg-subtle",
|
|
17
|
+
children: " (optional)"
|
|
18
|
+
}) : null]
|
|
19
|
+
}),
|
|
20
|
+
_ ? /* @__PURE__ */ l(o, {
|
|
21
|
+
rows: v,
|
|
22
|
+
placeholder: h,
|
|
23
|
+
className: e(d, "min-h-24 resize-y py-control-y leading-5", b)
|
|
24
|
+
}) : /* @__PURE__ */ l(r, {
|
|
25
|
+
placeholder: h,
|
|
26
|
+
className: e(d, "h-control-md", b)
|
|
27
|
+
}),
|
|
28
|
+
p && !m ? /* @__PURE__ */ l(a, {
|
|
29
|
+
slot: "description",
|
|
30
|
+
className: "type-caption font-normal text-fg-subtle",
|
|
31
|
+
children: p
|
|
32
|
+
}) : null,
|
|
33
|
+
/* @__PURE__ */ l(n, {
|
|
34
|
+
className: "flex animate-reveal-in items-start gap-1.5 type-caption text-error",
|
|
35
|
+
children: ({ validationErrors: e }) => /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(t, { className: "mt-px size-3.5" }), /* @__PURE__ */ l("span", { children: m ?? e.join(" ") })] })
|
|
36
|
+
})
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { f as t };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
//#region src/reusable/review/types.ts
|
|
2
|
+
var e = class extends Error {
|
|
3
|
+
kind;
|
|
4
|
+
constructor(e) {
|
|
5
|
+
super(e), this.kind = e;
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
function t(e) {
|
|
9
|
+
if (!e || typeof e != "object" || Array.isArray(e)) throw Error("Invalid review data");
|
|
10
|
+
return e;
|
|
11
|
+
}
|
|
12
|
+
function n(e, t = 6e3) {
|
|
13
|
+
if (typeof e != "string" || !e.trim() || e.length > t) throw Error("Invalid review text");
|
|
14
|
+
return e;
|
|
15
|
+
}
|
|
16
|
+
function r(e) {
|
|
17
|
+
let t = n(e, 100);
|
|
18
|
+
if (!/^[\w-]+$/.test(t)) throw Error("Invalid review id");
|
|
19
|
+
return t;
|
|
20
|
+
}
|
|
21
|
+
function i(e) {
|
|
22
|
+
if (!Array.isArray(e) || e.length > 32) throw Error("Invalid review selection");
|
|
23
|
+
let t = e.map(r);
|
|
24
|
+
if (new Set(t).size !== t.length) throw Error("Duplicate review ids");
|
|
25
|
+
return t;
|
|
26
|
+
}
|
|
27
|
+
function a(e) {
|
|
28
|
+
if (typeof e != "number" || !Number.isSafeInteger(e) || e < 1) throw Error("Invalid review revision");
|
|
29
|
+
return e;
|
|
30
|
+
}
|
|
31
|
+
function o(e) {
|
|
32
|
+
let i = t(e);
|
|
33
|
+
if (!Array.isArray(i.changes) || i.changes.length > 32 || typeof i.canDecide != "boolean") throw Error("Invalid proposal");
|
|
34
|
+
let o = i.changes.map((e) => {
|
|
35
|
+
let i = t(e);
|
|
36
|
+
return {
|
|
37
|
+
id: r(i.id),
|
|
38
|
+
title: n(i.title, 200),
|
|
39
|
+
before: n(i.before),
|
|
40
|
+
after: n(i.after),
|
|
41
|
+
reason: n(i.reason, 1e3)
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
if (new Set(o.map((e) => e.id)).size !== o.length) throw Error("Duplicate changes");
|
|
45
|
+
return {
|
|
46
|
+
id: r(i.id),
|
|
47
|
+
revision: a(i.revision),
|
|
48
|
+
title: n(i.title, 200),
|
|
49
|
+
destination: n(i.destination, 200),
|
|
50
|
+
changes: o,
|
|
51
|
+
canDecide: i.canDecide
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function s(e) {
|
|
55
|
+
let n = t(e);
|
|
56
|
+
if (Object.keys(n).sort().join() !== [
|
|
57
|
+
"changeIds",
|
|
58
|
+
"choice",
|
|
59
|
+
"proposalId",
|
|
60
|
+
"requestId",
|
|
61
|
+
"revision"
|
|
62
|
+
].sort().join()) throw Error("Invalid decision fields");
|
|
63
|
+
if (n.choice !== "approve" && n.choice !== "deny") throw Error("Invalid decision");
|
|
64
|
+
let o = i(n.changeIds).sort();
|
|
65
|
+
if (n.choice === "approve" && !o.length || n.choice === "deny" && o.length) throw Error("Invalid decision selection");
|
|
66
|
+
return {
|
|
67
|
+
requestId: r(n.requestId),
|
|
68
|
+
proposalId: r(n.proposalId),
|
|
69
|
+
revision: a(n.revision),
|
|
70
|
+
choice: n.choice,
|
|
71
|
+
changeIds: o
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function c(e) {
|
|
75
|
+
let n = t(e), r = o(n.proposal);
|
|
76
|
+
if (![
|
|
77
|
+
"pending",
|
|
78
|
+
"partial",
|
|
79
|
+
"complete",
|
|
80
|
+
"denied"
|
|
81
|
+
].includes(String(n.outcome))) throw Error("Invalid review outcome");
|
|
82
|
+
let a = i(n.appliedIds), s = i(n.remainingIds), c = new Set(r.changes.map((e) => e.id));
|
|
83
|
+
if ([...a, ...s].some((e) => !c.has(e)) || s.some((e) => a.includes(e))) throw Error("Invalid review scope");
|
|
84
|
+
if ((n.outcome === "complete" || n.outcome === "denied") && s.length) throw Error("Closed review still has pending changes");
|
|
85
|
+
if (n.outcome === "denied" && a.length) throw Error("Denied review has applied changes");
|
|
86
|
+
if (n.outcome === "pending" && a.length) throw Error("Pending review has applied changes");
|
|
87
|
+
if (n.outcome === "partial" && (!a.length || !s.length)) throw Error("Invalid partial result");
|
|
88
|
+
return {
|
|
89
|
+
proposal: r,
|
|
90
|
+
appliedIds: a,
|
|
91
|
+
remainingIds: s,
|
|
92
|
+
outcome: n.outcome
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function l(e) {
|
|
96
|
+
let n = t(e), a = c(n.record);
|
|
97
|
+
if (n.choice !== "approve" && n.choice !== "deny") throw Error("Invalid receipt");
|
|
98
|
+
let o = i(n.appliedIds);
|
|
99
|
+
if (o.some((e) => !a.appliedIds.includes(e)) || n.choice === "deny" && (o.length || !(a.outcome === "denied" || a.outcome === "complete" && a.appliedIds.length > 0)) || n.choice === "approve" && !["complete", "partial"].includes(a.outcome)) throw Error("Invalid receipt outcome");
|
|
100
|
+
return {
|
|
101
|
+
requestId: r(n.requestId),
|
|
102
|
+
choice: n.choice,
|
|
103
|
+
appliedIds: o,
|
|
104
|
+
record: a
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function u(e) {
|
|
108
|
+
let n = t(e);
|
|
109
|
+
return {
|
|
110
|
+
record: c(n.record),
|
|
111
|
+
receipt: n.receipt === null ? null : l(n.receipt)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
export { c as a, l as i, s as n, u as o, o as r, e as t };
|