@medicine-wheel/consent-lifecycle 0.2.2
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/README.md +84 -0
- package/dist/alerts.d.ts +74 -0
- package/dist/alerts.d.ts.map +1 -0
- package/dist/alerts.js +152 -0
- package/dist/alerts.js.map +1 -0
- package/dist/cascade.d.ts +48 -0
- package/dist/cascade.d.ts.map +1 -0
- package/dist/cascade.js +97 -0
- package/dist/cascade.js.map +1 -0
- package/dist/ceremony.d.ts +26 -0
- package/dist/ceremony.d.ts.map +1 -0
- package/dist/ceremony.js +81 -0
- package/dist/ceremony.js.map +1 -0
- package/dist/community.d.ts +57 -0
- package/dist/community.d.ts.map +1 -0
- package/dist/community.js +99 -0
- package/dist/community.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle.d.ts +45 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +175 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/schemas.d.ts +298 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +66 -0
- package/dist/schemas.js.map +1 -0
- package/dist/scope.d.ts +56 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +114 -0
- package/dist/scope.js.map +1 -0
- package/dist/types.d.ts +97 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @medicine-wheel/consent-lifecycle — Zod Schemas
|
|
3
|
+
*
|
|
4
|
+
* Runtime validation schemas for consent lifecycle types.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export declare const ConsentStateSchema: z.ZodEnum<["pending", "granted", "active", "renewal-needed", "expired", "renegotiating", "withdrawn"]>;
|
|
8
|
+
export declare const ConsentScopeSchema: z.ZodObject<{
|
|
9
|
+
description: z.ZodString;
|
|
10
|
+
dataTypes: z.ZodArray<z.ZodString, "many">;
|
|
11
|
+
purposes: z.ZodArray<z.ZodString, "many">;
|
|
12
|
+
duration: z.ZodOptional<z.ZodString>;
|
|
13
|
+
geographic: z.ZodOptional<z.ZodString>;
|
|
14
|
+
restrictions: z.ZodArray<z.ZodString, "many">;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
description: string;
|
|
17
|
+
dataTypes: string[];
|
|
18
|
+
purposes: string[];
|
|
19
|
+
restrictions: string[];
|
|
20
|
+
duration?: string | undefined;
|
|
21
|
+
geographic?: string | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
description: string;
|
|
24
|
+
dataTypes: string[];
|
|
25
|
+
purposes: string[];
|
|
26
|
+
restrictions: string[];
|
|
27
|
+
duration?: string | undefined;
|
|
28
|
+
geographic?: string | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
export declare const ConsentCeremonySchema: z.ZodObject<{
|
|
31
|
+
type: z.ZodEnum<["initial", "renewal", "renegotiation", "withdrawal"]>;
|
|
32
|
+
timestamp: z.ZodString;
|
|
33
|
+
participants: z.ZodArray<z.ZodString, "many">;
|
|
34
|
+
witnessedBy: z.ZodArray<z.ZodString, "many">;
|
|
35
|
+
outcome: z.ZodEnum<["pending", "granted", "active", "renewal-needed", "expired", "renegotiating", "withdrawn"]>;
|
|
36
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
37
|
+
ceremonyId: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
type: "initial" | "renewal" | "renegotiation" | "withdrawal";
|
|
40
|
+
timestamp: string;
|
|
41
|
+
participants: string[];
|
|
42
|
+
witnessedBy: string[];
|
|
43
|
+
outcome: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
44
|
+
notes?: string | undefined;
|
|
45
|
+
ceremonyId?: string | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
type: "initial" | "renewal" | "renegotiation" | "withdrawal";
|
|
48
|
+
timestamp: string;
|
|
49
|
+
participants: string[];
|
|
50
|
+
witnessedBy: string[];
|
|
51
|
+
outcome: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
52
|
+
notes?: string | undefined;
|
|
53
|
+
ceremonyId?: string | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
export declare const ConsentStateChangeSchema: z.ZodObject<{
|
|
56
|
+
from: z.ZodEnum<["pending", "granted", "active", "renewal-needed", "expired", "renegotiating", "withdrawn"]>;
|
|
57
|
+
to: z.ZodEnum<["pending", "granted", "active", "renewal-needed", "expired", "renegotiating", "withdrawn"]>;
|
|
58
|
+
reason: z.ZodString;
|
|
59
|
+
timestamp: z.ZodString;
|
|
60
|
+
initiatedBy: z.ZodString;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
timestamp: string;
|
|
63
|
+
from: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
64
|
+
to: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
65
|
+
reason: string;
|
|
66
|
+
initiatedBy: string;
|
|
67
|
+
}, {
|
|
68
|
+
timestamp: string;
|
|
69
|
+
from: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
70
|
+
to: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
71
|
+
reason: string;
|
|
72
|
+
initiatedBy: string;
|
|
73
|
+
}>;
|
|
74
|
+
export declare const ConsentCascadeSchema: z.ZodObject<{
|
|
75
|
+
triggerId: z.ZodString;
|
|
76
|
+
affected: z.ZodArray<z.ZodString, "many">;
|
|
77
|
+
action: z.ZodEnum<["expire", "review", "withdraw", "narrow"]>;
|
|
78
|
+
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
triggerId: string;
|
|
80
|
+
affected: string[];
|
|
81
|
+
action: "expire" | "review" | "withdraw" | "narrow";
|
|
82
|
+
}, {
|
|
83
|
+
triggerId: string;
|
|
84
|
+
affected: string[];
|
|
85
|
+
action: "expire" | "review" | "withdraw" | "narrow";
|
|
86
|
+
}>;
|
|
87
|
+
export declare const ConsentRecordSchema: z.ZodObject<{
|
|
88
|
+
id: z.ZodString;
|
|
89
|
+
grantor: z.ZodString;
|
|
90
|
+
grantee: z.ZodString;
|
|
91
|
+
scope: z.ZodObject<{
|
|
92
|
+
description: z.ZodString;
|
|
93
|
+
dataTypes: z.ZodArray<z.ZodString, "many">;
|
|
94
|
+
purposes: z.ZodArray<z.ZodString, "many">;
|
|
95
|
+
duration: z.ZodOptional<z.ZodString>;
|
|
96
|
+
geographic: z.ZodOptional<z.ZodString>;
|
|
97
|
+
restrictions: z.ZodArray<z.ZodString, "many">;
|
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
description: string;
|
|
100
|
+
dataTypes: string[];
|
|
101
|
+
purposes: string[];
|
|
102
|
+
restrictions: string[];
|
|
103
|
+
duration?: string | undefined;
|
|
104
|
+
geographic?: string | undefined;
|
|
105
|
+
}, {
|
|
106
|
+
description: string;
|
|
107
|
+
dataTypes: string[];
|
|
108
|
+
purposes: string[];
|
|
109
|
+
restrictions: string[];
|
|
110
|
+
duration?: string | undefined;
|
|
111
|
+
geographic?: string | undefined;
|
|
112
|
+
}>;
|
|
113
|
+
state: z.ZodEnum<["pending", "granted", "active", "renewal-needed", "expired", "renegotiating", "withdrawn"]>;
|
|
114
|
+
grantedAt: z.ZodOptional<z.ZodString>;
|
|
115
|
+
renewedAt: z.ZodOptional<z.ZodString>;
|
|
116
|
+
expiresAt: z.ZodOptional<z.ZodString>;
|
|
117
|
+
renewalInterval: z.ZodOptional<z.ZodNumber>;
|
|
118
|
+
ceremonies: z.ZodArray<z.ZodObject<{
|
|
119
|
+
type: z.ZodEnum<["initial", "renewal", "renegotiation", "withdrawal"]>;
|
|
120
|
+
timestamp: z.ZodString;
|
|
121
|
+
participants: z.ZodArray<z.ZodString, "many">;
|
|
122
|
+
witnessedBy: z.ZodArray<z.ZodString, "many">;
|
|
123
|
+
outcome: z.ZodEnum<["pending", "granted", "active", "renewal-needed", "expired", "renegotiating", "withdrawn"]>;
|
|
124
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
125
|
+
ceremonyId: z.ZodOptional<z.ZodString>;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
type: "initial" | "renewal" | "renegotiation" | "withdrawal";
|
|
128
|
+
timestamp: string;
|
|
129
|
+
participants: string[];
|
|
130
|
+
witnessedBy: string[];
|
|
131
|
+
outcome: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
132
|
+
notes?: string | undefined;
|
|
133
|
+
ceremonyId?: string | undefined;
|
|
134
|
+
}, {
|
|
135
|
+
type: "initial" | "renewal" | "renegotiation" | "withdrawal";
|
|
136
|
+
timestamp: string;
|
|
137
|
+
participants: string[];
|
|
138
|
+
witnessedBy: string[];
|
|
139
|
+
outcome: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
140
|
+
notes?: string | undefined;
|
|
141
|
+
ceremonyId?: string | undefined;
|
|
142
|
+
}>, "many">;
|
|
143
|
+
history: z.ZodArray<z.ZodObject<{
|
|
144
|
+
from: z.ZodEnum<["pending", "granted", "active", "renewal-needed", "expired", "renegotiating", "withdrawn"]>;
|
|
145
|
+
to: z.ZodEnum<["pending", "granted", "active", "renewal-needed", "expired", "renegotiating", "withdrawn"]>;
|
|
146
|
+
reason: z.ZodString;
|
|
147
|
+
timestamp: z.ZodString;
|
|
148
|
+
initiatedBy: z.ZodString;
|
|
149
|
+
}, "strip", z.ZodTypeAny, {
|
|
150
|
+
timestamp: string;
|
|
151
|
+
from: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
152
|
+
to: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
153
|
+
reason: string;
|
|
154
|
+
initiatedBy: string;
|
|
155
|
+
}, {
|
|
156
|
+
timestamp: string;
|
|
157
|
+
from: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
158
|
+
to: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
159
|
+
reason: string;
|
|
160
|
+
initiatedBy: string;
|
|
161
|
+
}>, "many">;
|
|
162
|
+
communityLevel: z.ZodBoolean;
|
|
163
|
+
dependentRelations: z.ZodArray<z.ZodString, "many">;
|
|
164
|
+
ocapFlags: z.ZodObject<{
|
|
165
|
+
ownership: z.ZodString;
|
|
166
|
+
control: z.ZodString;
|
|
167
|
+
access: z.ZodEnum<["community", "researchers", "public", "restricted"]>;
|
|
168
|
+
possession: z.ZodEnum<["on-premise", "community-server", "cloud-sovereign", "cloud-shared"]>;
|
|
169
|
+
compliant: z.ZodBoolean;
|
|
170
|
+
steward: z.ZodOptional<z.ZodString>;
|
|
171
|
+
consent_given: z.ZodOptional<z.ZodBoolean>;
|
|
172
|
+
consent_scope: z.ZodOptional<z.ZodString>;
|
|
173
|
+
consent_state: z.ZodOptional<z.ZodEnum<["active", "withdrawn", "expired", "pending"]>>;
|
|
174
|
+
consent_last_affirmed: z.ZodOptional<z.ZodString>;
|
|
175
|
+
}, "strip", z.ZodTypeAny, {
|
|
176
|
+
ownership: string;
|
|
177
|
+
control: string;
|
|
178
|
+
access: "community" | "researchers" | "public" | "restricted";
|
|
179
|
+
possession: "on-premise" | "community-server" | "cloud-sovereign" | "cloud-shared";
|
|
180
|
+
compliant: boolean;
|
|
181
|
+
steward?: string | undefined;
|
|
182
|
+
consent_given?: boolean | undefined;
|
|
183
|
+
consent_scope?: string | undefined;
|
|
184
|
+
consent_state?: "active" | "withdrawn" | "expired" | "pending" | undefined;
|
|
185
|
+
consent_last_affirmed?: string | undefined;
|
|
186
|
+
}, {
|
|
187
|
+
ownership: string;
|
|
188
|
+
control: string;
|
|
189
|
+
access: "community" | "researchers" | "public" | "restricted";
|
|
190
|
+
possession: "on-premise" | "community-server" | "cloud-sovereign" | "cloud-shared";
|
|
191
|
+
compliant: boolean;
|
|
192
|
+
steward?: string | undefined;
|
|
193
|
+
consent_given?: boolean | undefined;
|
|
194
|
+
consent_scope?: string | undefined;
|
|
195
|
+
consent_state?: "active" | "withdrawn" | "expired" | "pending" | undefined;
|
|
196
|
+
consent_last_affirmed?: string | undefined;
|
|
197
|
+
}>;
|
|
198
|
+
}, "strip", z.ZodTypeAny, {
|
|
199
|
+
id: string;
|
|
200
|
+
grantor: string;
|
|
201
|
+
grantee: string;
|
|
202
|
+
scope: {
|
|
203
|
+
description: string;
|
|
204
|
+
dataTypes: string[];
|
|
205
|
+
purposes: string[];
|
|
206
|
+
restrictions: string[];
|
|
207
|
+
duration?: string | undefined;
|
|
208
|
+
geographic?: string | undefined;
|
|
209
|
+
};
|
|
210
|
+
state: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
211
|
+
ceremonies: {
|
|
212
|
+
type: "initial" | "renewal" | "renegotiation" | "withdrawal";
|
|
213
|
+
timestamp: string;
|
|
214
|
+
participants: string[];
|
|
215
|
+
witnessedBy: string[];
|
|
216
|
+
outcome: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
217
|
+
notes?: string | undefined;
|
|
218
|
+
ceremonyId?: string | undefined;
|
|
219
|
+
}[];
|
|
220
|
+
history: {
|
|
221
|
+
timestamp: string;
|
|
222
|
+
from: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
223
|
+
to: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
224
|
+
reason: string;
|
|
225
|
+
initiatedBy: string;
|
|
226
|
+
}[];
|
|
227
|
+
communityLevel: boolean;
|
|
228
|
+
dependentRelations: string[];
|
|
229
|
+
ocapFlags: {
|
|
230
|
+
ownership: string;
|
|
231
|
+
control: string;
|
|
232
|
+
access: "community" | "researchers" | "public" | "restricted";
|
|
233
|
+
possession: "on-premise" | "community-server" | "cloud-sovereign" | "cloud-shared";
|
|
234
|
+
compliant: boolean;
|
|
235
|
+
steward?: string | undefined;
|
|
236
|
+
consent_given?: boolean | undefined;
|
|
237
|
+
consent_scope?: string | undefined;
|
|
238
|
+
consent_state?: "active" | "withdrawn" | "expired" | "pending" | undefined;
|
|
239
|
+
consent_last_affirmed?: string | undefined;
|
|
240
|
+
};
|
|
241
|
+
grantedAt?: string | undefined;
|
|
242
|
+
renewedAt?: string | undefined;
|
|
243
|
+
expiresAt?: string | undefined;
|
|
244
|
+
renewalInterval?: number | undefined;
|
|
245
|
+
}, {
|
|
246
|
+
id: string;
|
|
247
|
+
grantor: string;
|
|
248
|
+
grantee: string;
|
|
249
|
+
scope: {
|
|
250
|
+
description: string;
|
|
251
|
+
dataTypes: string[];
|
|
252
|
+
purposes: string[];
|
|
253
|
+
restrictions: string[];
|
|
254
|
+
duration?: string | undefined;
|
|
255
|
+
geographic?: string | undefined;
|
|
256
|
+
};
|
|
257
|
+
state: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
258
|
+
ceremonies: {
|
|
259
|
+
type: "initial" | "renewal" | "renegotiation" | "withdrawal";
|
|
260
|
+
timestamp: string;
|
|
261
|
+
participants: string[];
|
|
262
|
+
witnessedBy: string[];
|
|
263
|
+
outcome: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
264
|
+
notes?: string | undefined;
|
|
265
|
+
ceremonyId?: string | undefined;
|
|
266
|
+
}[];
|
|
267
|
+
history: {
|
|
268
|
+
timestamp: string;
|
|
269
|
+
from: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
270
|
+
to: "pending" | "granted" | "active" | "renewal-needed" | "expired" | "renegotiating" | "withdrawn";
|
|
271
|
+
reason: string;
|
|
272
|
+
initiatedBy: string;
|
|
273
|
+
}[];
|
|
274
|
+
communityLevel: boolean;
|
|
275
|
+
dependentRelations: string[];
|
|
276
|
+
ocapFlags: {
|
|
277
|
+
ownership: string;
|
|
278
|
+
control: string;
|
|
279
|
+
access: "community" | "researchers" | "public" | "restricted";
|
|
280
|
+
possession: "on-premise" | "community-server" | "cloud-sovereign" | "cloud-shared";
|
|
281
|
+
compliant: boolean;
|
|
282
|
+
steward?: string | undefined;
|
|
283
|
+
consent_given?: boolean | undefined;
|
|
284
|
+
consent_scope?: string | undefined;
|
|
285
|
+
consent_state?: "active" | "withdrawn" | "expired" | "pending" | undefined;
|
|
286
|
+
consent_last_affirmed?: string | undefined;
|
|
287
|
+
};
|
|
288
|
+
grantedAt?: string | undefined;
|
|
289
|
+
renewedAt?: string | undefined;
|
|
290
|
+
expiresAt?: string | undefined;
|
|
291
|
+
renewalInterval?: number | undefined;
|
|
292
|
+
}>;
|
|
293
|
+
export type ValidatedConsentRecord = z.infer<typeof ConsentRecordSchema>;
|
|
294
|
+
export type ValidatedConsentScope = z.infer<typeof ConsentScopeSchema>;
|
|
295
|
+
export type ValidatedConsentCeremony = z.infer<typeof ConsentCeremonySchema>;
|
|
296
|
+
export type ValidatedConsentStateChange = z.infer<typeof ConsentStateChangeSchema>;
|
|
297
|
+
export type ValidatedConsentCascade = z.infer<typeof ConsentCascadeSchema>;
|
|
298
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,kBAAkB,wGAG7B,CAAC;AAIH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;EAO7B,CAAC;AAIH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;EAQhC,CAAC;AAIH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;EAMnC,CAAC;AAIH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;EAI/B,CAAC;AAIH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAe9B,CAAC;AAIH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACzE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACvE,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC7E,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AACnF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @medicine-wheel/consent-lifecycle — Zod Schemas
|
|
4
|
+
*
|
|
5
|
+
* Runtime validation schemas for consent lifecycle types.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ConsentRecordSchema = exports.ConsentCascadeSchema = exports.ConsentStateChangeSchema = exports.ConsentCeremonySchema = exports.ConsentScopeSchema = exports.ConsentStateSchema = void 0;
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
const ontology_core_1 = require("@medicine-wheel/ontology-core");
|
|
11
|
+
// ── Consent State Schema ────────────────────────────────────────────────────
|
|
12
|
+
exports.ConsentStateSchema = zod_1.z.enum([
|
|
13
|
+
'pending', 'granted', 'active', 'renewal-needed',
|
|
14
|
+
'expired', 'renegotiating', 'withdrawn',
|
|
15
|
+
]);
|
|
16
|
+
// ── Consent Scope Schema ────────────────────────────────────────────────────
|
|
17
|
+
exports.ConsentScopeSchema = zod_1.z.object({
|
|
18
|
+
description: zod_1.z.string(),
|
|
19
|
+
dataTypes: zod_1.z.array(zod_1.z.string()),
|
|
20
|
+
purposes: zod_1.z.array(zod_1.z.string()),
|
|
21
|
+
duration: zod_1.z.string().optional(),
|
|
22
|
+
geographic: zod_1.z.string().optional(),
|
|
23
|
+
restrictions: zod_1.z.array(zod_1.z.string()),
|
|
24
|
+
});
|
|
25
|
+
// ── Consent Ceremony Schema ─────────────────────────────────────────────────
|
|
26
|
+
exports.ConsentCeremonySchema = zod_1.z.object({
|
|
27
|
+
type: zod_1.z.enum(['initial', 'renewal', 'renegotiation', 'withdrawal']),
|
|
28
|
+
timestamp: zod_1.z.string(),
|
|
29
|
+
participants: zod_1.z.array(zod_1.z.string()),
|
|
30
|
+
witnessedBy: zod_1.z.array(zod_1.z.string()),
|
|
31
|
+
outcome: exports.ConsentStateSchema,
|
|
32
|
+
notes: zod_1.z.string().optional(),
|
|
33
|
+
ceremonyId: zod_1.z.string().optional(),
|
|
34
|
+
});
|
|
35
|
+
// ── Consent State Change Schema ─────────────────────────────────────────────
|
|
36
|
+
exports.ConsentStateChangeSchema = zod_1.z.object({
|
|
37
|
+
from: exports.ConsentStateSchema,
|
|
38
|
+
to: exports.ConsentStateSchema,
|
|
39
|
+
reason: zod_1.z.string(),
|
|
40
|
+
timestamp: zod_1.z.string(),
|
|
41
|
+
initiatedBy: zod_1.z.string(),
|
|
42
|
+
});
|
|
43
|
+
// ── Consent Cascade Schema ──────────────────────────────────────────────────
|
|
44
|
+
exports.ConsentCascadeSchema = zod_1.z.object({
|
|
45
|
+
triggerId: zod_1.z.string(),
|
|
46
|
+
affected: zod_1.z.array(zod_1.z.string()),
|
|
47
|
+
action: zod_1.z.enum(['expire', 'review', 'withdraw', 'narrow']),
|
|
48
|
+
});
|
|
49
|
+
// ── Consent Record Schema ───────────────────────────────────────────────────
|
|
50
|
+
exports.ConsentRecordSchema = zod_1.z.object({
|
|
51
|
+
id: zod_1.z.string(),
|
|
52
|
+
grantor: zod_1.z.string(),
|
|
53
|
+
grantee: zod_1.z.string(),
|
|
54
|
+
scope: exports.ConsentScopeSchema,
|
|
55
|
+
state: exports.ConsentStateSchema,
|
|
56
|
+
grantedAt: zod_1.z.string().optional(),
|
|
57
|
+
renewedAt: zod_1.z.string().optional(),
|
|
58
|
+
expiresAt: zod_1.z.string().optional(),
|
|
59
|
+
renewalInterval: zod_1.z.number().int().min(1).optional(),
|
|
60
|
+
ceremonies: zod_1.z.array(exports.ConsentCeremonySchema),
|
|
61
|
+
history: zod_1.z.array(exports.ConsentStateChangeSchema),
|
|
62
|
+
communityLevel: zod_1.z.boolean(),
|
|
63
|
+
dependentRelations: zod_1.z.array(zod_1.z.string()),
|
|
64
|
+
ocapFlags: ontology_core_1.OcapFlagsSchema,
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,6BAAwB;AACxB,iEAAgE;AAEhE,+EAA+E;AAElE,QAAA,kBAAkB,GAAG,OAAC,CAAC,IAAI,CAAC;IACvC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB;IAChD,SAAS,EAAE,eAAe,EAAE,WAAW;CACxC,CAAC,CAAC;AAEH,+EAA+E;AAElE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Scope Module
|
|
3
|
+
*
|
|
4
|
+
* Manages consent scope: defining, narrowing, widening,
|
|
5
|
+
* and checking whether actions fall within scope.
|
|
6
|
+
*/
|
|
7
|
+
import type { ConsentScope } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Create a new consent scope with the given parameters.
|
|
10
|
+
* A scope defines the boundaries of what is consented.
|
|
11
|
+
*/
|
|
12
|
+
export declare function defineScope(description: string, dataTypes: string[], purposes: string[]): ConsentScope;
|
|
13
|
+
/**
|
|
14
|
+
* Narrow an existing scope by adding restrictions.
|
|
15
|
+
* Narrowing does not require re-consent — it only limits scope.
|
|
16
|
+
*/
|
|
17
|
+
export declare function narrowScope(scope: ConsentScope, restrictions: string[]): ConsentScope;
|
|
18
|
+
/**
|
|
19
|
+
* Widen a scope by adding data types, purposes, or removing restrictions.
|
|
20
|
+
* IMPORTANT: Widening scope requires re-consent from the grantor.
|
|
21
|
+
* This function returns the proposed new scope; the caller must
|
|
22
|
+
* initiate a renegotiation process.
|
|
23
|
+
*/
|
|
24
|
+
export declare function widenScope(scope: ConsentScope, additions: ScopeAdditions): WidenScopeResult;
|
|
25
|
+
/**
|
|
26
|
+
* Check whether a specific action falls within the consent scope.
|
|
27
|
+
* Returns true if the action's data type and purpose are covered
|
|
28
|
+
* and not restricted.
|
|
29
|
+
*/
|
|
30
|
+
export declare function scopeIncludes(scope: ConsentScope, query: ScopeQuery): ScopeCheckResult;
|
|
31
|
+
/** Additions to propose when widening scope */
|
|
32
|
+
export interface ScopeAdditions {
|
|
33
|
+
dataTypes?: string[];
|
|
34
|
+
purposes?: string[];
|
|
35
|
+
removeRestrictions?: string[];
|
|
36
|
+
duration?: string;
|
|
37
|
+
geographic?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Result of a scope widening operation */
|
|
40
|
+
export interface WidenScopeResult {
|
|
41
|
+
proposedScope: ConsentScope;
|
|
42
|
+
requiresReconsent: boolean;
|
|
43
|
+
changes: string[];
|
|
44
|
+
}
|
|
45
|
+
/** Query to check against a consent scope */
|
|
46
|
+
export interface ScopeQuery {
|
|
47
|
+
dataType: string;
|
|
48
|
+
purpose: string;
|
|
49
|
+
geographic?: string;
|
|
50
|
+
}
|
|
51
|
+
/** Result of a scope inclusion check */
|
|
52
|
+
export interface ScopeCheckResult {
|
|
53
|
+
withinScope: boolean;
|
|
54
|
+
issues: string[];
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,WAAW,CACzB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EAAE,EACnB,QAAQ,EAAE,MAAM,EAAE,GACjB,YAAY,CAOd;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,YAAY,EACnB,YAAY,EAAE,MAAM,EAAE,GACrB,YAAY,CAKd;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,cAAc,GACxB,gBAAgB,CAqBlB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,UAAU,GAChB,gBAAgB,CAuClB;AAID,+CAA+C;AAC/C,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,2CAA2C;AAC3C,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,YAAY,CAAC;IAC5B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,6CAA6C;AAC7C,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wCAAwC;AACxC,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB"}
|
package/dist/scope.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @medicine-wheel/consent-lifecycle — Scope Module
|
|
4
|
+
*
|
|
5
|
+
* Manages consent scope: defining, narrowing, widening,
|
|
6
|
+
* and checking whether actions fall within scope.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.defineScope = defineScope;
|
|
10
|
+
exports.narrowScope = narrowScope;
|
|
11
|
+
exports.widenScope = widenScope;
|
|
12
|
+
exports.scopeIncludes = scopeIncludes;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new consent scope with the given parameters.
|
|
15
|
+
* A scope defines the boundaries of what is consented.
|
|
16
|
+
*/
|
|
17
|
+
function defineScope(description, dataTypes, purposes) {
|
|
18
|
+
return {
|
|
19
|
+
description,
|
|
20
|
+
dataTypes,
|
|
21
|
+
purposes,
|
|
22
|
+
restrictions: [],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Narrow an existing scope by adding restrictions.
|
|
27
|
+
* Narrowing does not require re-consent — it only limits scope.
|
|
28
|
+
*/
|
|
29
|
+
function narrowScope(scope, restrictions) {
|
|
30
|
+
return {
|
|
31
|
+
...scope,
|
|
32
|
+
restrictions: [...scope.restrictions, ...restrictions],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Widen a scope by adding data types, purposes, or removing restrictions.
|
|
37
|
+
* IMPORTANT: Widening scope requires re-consent from the grantor.
|
|
38
|
+
* This function returns the proposed new scope; the caller must
|
|
39
|
+
* initiate a renegotiation process.
|
|
40
|
+
*/
|
|
41
|
+
function widenScope(scope, additions) {
|
|
42
|
+
const newScope = {
|
|
43
|
+
...scope,
|
|
44
|
+
dataTypes: additions.dataTypes
|
|
45
|
+
? [...scope.dataTypes, ...additions.dataTypes]
|
|
46
|
+
: scope.dataTypes,
|
|
47
|
+
purposes: additions.purposes
|
|
48
|
+
? [...scope.purposes, ...additions.purposes]
|
|
49
|
+
: scope.purposes,
|
|
50
|
+
restrictions: additions.removeRestrictions
|
|
51
|
+
? scope.restrictions.filter((r) => !additions.removeRestrictions.includes(r))
|
|
52
|
+
: scope.restrictions,
|
|
53
|
+
duration: additions.duration ?? scope.duration,
|
|
54
|
+
geographic: additions.geographic ?? scope.geographic,
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
proposedScope: newScope,
|
|
58
|
+
requiresReconsent: true,
|
|
59
|
+
changes: describeChanges(scope, newScope),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check whether a specific action falls within the consent scope.
|
|
64
|
+
* Returns true if the action's data type and purpose are covered
|
|
65
|
+
* and not restricted.
|
|
66
|
+
*/
|
|
67
|
+
function scopeIncludes(scope, query) {
|
|
68
|
+
const issues = [];
|
|
69
|
+
// Check data type
|
|
70
|
+
const dataTypeMatch = scope.dataTypes.some((dt) => dt === query.dataType || dt === '*');
|
|
71
|
+
if (!dataTypeMatch) {
|
|
72
|
+
issues.push(`Data type '${query.dataType}' is not within consent scope.`);
|
|
73
|
+
}
|
|
74
|
+
// Check purpose
|
|
75
|
+
const purposeMatch = scope.purposes.some((p) => p === query.purpose || p === '*');
|
|
76
|
+
if (!purposeMatch) {
|
|
77
|
+
issues.push(`Purpose '${query.purpose}' is not within consent scope.`);
|
|
78
|
+
}
|
|
79
|
+
// Check restrictions
|
|
80
|
+
for (const restriction of scope.restrictions) {
|
|
81
|
+
const lower = restriction.toLowerCase();
|
|
82
|
+
if (lower.includes(query.dataType.toLowerCase()) ||
|
|
83
|
+
lower.includes(query.purpose.toLowerCase())) {
|
|
84
|
+
issues.push(`Action may violate restriction: '${restriction}'.`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Check geographic if specified
|
|
88
|
+
if (scope.geographic && query.geographic && scope.geographic !== query.geographic) {
|
|
89
|
+
issues.push(`Geographic scope mismatch: consented for '${scope.geographic}', action in '${query.geographic}'.`);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
withinScope: issues.length === 0,
|
|
93
|
+
issues,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// ── Internal Helpers ────────────────────────────────────────────────────────
|
|
97
|
+
function describeChanges(oldScope, newScope) {
|
|
98
|
+
const changes = [];
|
|
99
|
+
const addedTypes = newScope.dataTypes.filter((t) => !oldScope.dataTypes.includes(t));
|
|
100
|
+
const addedPurposes = newScope.purposes.filter((p) => !oldScope.purposes.includes(p));
|
|
101
|
+
const removedRestrictions = oldScope.restrictions.filter((r) => !newScope.restrictions.includes(r));
|
|
102
|
+
if (addedTypes.length > 0)
|
|
103
|
+
changes.push(`Added data types: ${addedTypes.join(', ')}`);
|
|
104
|
+
if (addedPurposes.length > 0)
|
|
105
|
+
changes.push(`Added purposes: ${addedPurposes.join(', ')}`);
|
|
106
|
+
if (removedRestrictions.length > 0)
|
|
107
|
+
changes.push(`Removed restrictions: ${removedRestrictions.join(', ')}`);
|
|
108
|
+
if (newScope.duration !== oldScope.duration)
|
|
109
|
+
changes.push(`Duration changed to: ${newScope.duration ?? 'unset'}`);
|
|
110
|
+
if (newScope.geographic !== oldScope.geographic)
|
|
111
|
+
changes.push(`Geographic scope changed to: ${newScope.geographic ?? 'unset'}`);
|
|
112
|
+
return changes;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=scope.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AE,CAAC,CAAC;IAC1F,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,CAAC,IAAI,CAAC,yBAAyB,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5G,IAAI,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ;QAAE,OAAO,CAAC,IAAI,CAAC,wBAAwB,QAAQ,CAAC,QAAQ,IAAI,OAAO,EAAE,CAAC,CAAC;IAClH,IAAI,QAAQ,CAAC,UAAU,KAAK,QAAQ,CAAC,UAAU;QAAE,OAAO,CAAC,IAAI,CAAC,gCAAgC,QAAQ,CAAC,UAAU,IAAI,OAAO,EAAE,CAAC,CAAC;IAEhI,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @medicine-wheel/consent-lifecycle — Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Types for managing consent as a living relational obligation.
|
|
5
|
+
* Wilson's relational accountability means consent is not an event —
|
|
6
|
+
* it's a relationship. "Once you are in relationship, you are
|
|
7
|
+
* responsible for that relationship's wellbeing."
|
|
8
|
+
*/
|
|
9
|
+
import type { OcapFlags } from '@medicine-wheel/ontology-core';
|
|
10
|
+
/** Consent lifecycle states — consent is never just "on" or "off" */
|
|
11
|
+
export type ConsentState = 'pending' | 'granted' | 'active' | 'renewal-needed' | 'expired' | 'renegotiating' | 'withdrawn';
|
|
12
|
+
/** A living consent record with full lifecycle tracking */
|
|
13
|
+
export interface ConsentRecord {
|
|
14
|
+
/** Unique consent identifier */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Who gave consent */
|
|
17
|
+
grantor: string;
|
|
18
|
+
/** Who received consent */
|
|
19
|
+
grantee: string;
|
|
20
|
+
/** Scope of the consent */
|
|
21
|
+
scope: ConsentScope;
|
|
22
|
+
/** Current consent state */
|
|
23
|
+
state: ConsentState;
|
|
24
|
+
/** When consent was first granted (ISO 8601) */
|
|
25
|
+
grantedAt?: string;
|
|
26
|
+
/** When consent was last renewed (ISO 8601) */
|
|
27
|
+
renewedAt?: string;
|
|
28
|
+
/** When consent expires (ISO 8601) */
|
|
29
|
+
expiresAt?: string;
|
|
30
|
+
/** Days between required renewals */
|
|
31
|
+
renewalInterval?: number;
|
|
32
|
+
/** Log of consent ceremonies */
|
|
33
|
+
ceremonies: ConsentCeremony[];
|
|
34
|
+
/** Full state change history */
|
|
35
|
+
history: ConsentStateChange[];
|
|
36
|
+
/** Whether this is community-wide consent */
|
|
37
|
+
communityLevel: boolean;
|
|
38
|
+
/** Relations that depend on this consent */
|
|
39
|
+
dependentRelations: string[];
|
|
40
|
+
/** OCAP® governance flags */
|
|
41
|
+
ocapFlags: OcapFlags;
|
|
42
|
+
}
|
|
43
|
+
/** Defines the boundaries of what is consented */
|
|
44
|
+
export interface ConsentScope {
|
|
45
|
+
/** Human-readable description of the consent scope */
|
|
46
|
+
description: string;
|
|
47
|
+
/** What types of data/knowledge are covered */
|
|
48
|
+
dataTypes: string[];
|
|
49
|
+
/** What purposes are consented */
|
|
50
|
+
purposes: string[];
|
|
51
|
+
/** How long the consent is valid */
|
|
52
|
+
duration?: string;
|
|
53
|
+
/** Geographic scope */
|
|
54
|
+
geographic?: string;
|
|
55
|
+
/** What is explicitly NOT consented */
|
|
56
|
+
restrictions: string[];
|
|
57
|
+
}
|
|
58
|
+
/** A ceremony associated with consent granting, renewal, or withdrawal */
|
|
59
|
+
export interface ConsentCeremony {
|
|
60
|
+
/** Type of consent ceremony */
|
|
61
|
+
type: 'initial' | 'renewal' | 'renegotiation' | 'withdrawal';
|
|
62
|
+
/** When the ceremony occurred (ISO 8601) */
|
|
63
|
+
timestamp: string;
|
|
64
|
+
/** Who participated in the ceremony */
|
|
65
|
+
participants: string[];
|
|
66
|
+
/** Who witnessed the ceremony */
|
|
67
|
+
witnessedBy: string[];
|
|
68
|
+
/** The consent state outcome */
|
|
69
|
+
outcome: ConsentState;
|
|
70
|
+
/** Additional notes */
|
|
71
|
+
notes?: string;
|
|
72
|
+
/** Link to ceremony-protocol ceremony */
|
|
73
|
+
ceremonyId?: string;
|
|
74
|
+
}
|
|
75
|
+
/** A recorded transition between consent states */
|
|
76
|
+
export interface ConsentStateChange {
|
|
77
|
+
/** Previous state */
|
|
78
|
+
from: ConsentState;
|
|
79
|
+
/** New state */
|
|
80
|
+
to: ConsentState;
|
|
81
|
+
/** Reason for the change */
|
|
82
|
+
reason: string;
|
|
83
|
+
/** When the change occurred (ISO 8601) */
|
|
84
|
+
timestamp: string;
|
|
85
|
+
/** Who initiated the change */
|
|
86
|
+
initiatedBy: string;
|
|
87
|
+
}
|
|
88
|
+
/** Describes cascading effects when consent changes */
|
|
89
|
+
export interface ConsentCascade {
|
|
90
|
+
/** The consent record that triggered the cascade */
|
|
91
|
+
triggerId: string;
|
|
92
|
+
/** Affected consent records or relation IDs */
|
|
93
|
+
affected: string[];
|
|
94
|
+
/** The action to take on affected records */
|
|
95
|
+
action: 'expire' | 'review' | 'withdraw' | 'narrow';
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI/D,qEAAqE;AACrE,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,SAAS,GACT,QAAQ,GACR,gBAAgB,GAChB,SAAS,GACT,eAAe,GACf,WAAW,CAAC;AAIhB,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,KAAK,E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