@opencrvs/toolkit 1.8.0-rc.f7a451a → 1.8.0-rc.f7bcb31
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/dist/commons/api/router.d.ts +4206 -8342
- package/dist/commons/conditionals/conditionals.d.ts +7 -11
- package/dist/commons/conditionals/validate.d.ts +6 -4
- package/dist/commons/events/ActionConfig.d.ts +1727 -97087
- package/dist/commons/events/ActionDocument.d.ts +211 -542
- package/dist/commons/events/ActionInput.d.ts +240 -248
- package/dist/commons/events/AdvancedSearchConfig.d.ts +22 -957
- package/dist/commons/events/CompositeFieldValue.d.ts +0 -3
- package/dist/commons/events/Draft.d.ts +20 -33
- package/dist/commons/events/EventConfig.d.ts +1350 -46327
- package/dist/commons/events/EventDocument.d.ts +156 -324
- package/dist/commons/events/EventIndex.d.ts +13 -1821
- package/dist/commons/events/EventMetadata.d.ts +11 -277
- package/dist/commons/events/FieldConfig.d.ts +754 -4280
- package/dist/commons/events/FieldType.d.ts +3 -3
- package/dist/commons/events/FieldTypeMapping.d.ts +4 -11
- package/dist/commons/events/FieldValue.d.ts +4 -7
- package/dist/commons/events/FormConfig.d.ts +441 -43593
- package/dist/commons/events/PageConfig.d.ts +208 -10864
- package/dist/commons/events/SummaryConfig.d.ts +39 -95
- package/dist/commons/events/User.d.ts +2 -31
- package/dist/commons/events/WorkqueueConfig.d.ts +20 -5341
- package/dist/commons/events/defineConfig.d.ts +35 -7218
- package/dist/commons/events/index.d.ts +0 -6
- package/dist/commons/events/test.utils.d.ts +46 -10
- package/dist/commons/events/utils.d.ts +67 -3665
- package/dist/conditionals/index.js +35 -55
- package/dist/events/index.js +1075 -2461
- package/dist/scopes/index.d.ts +4 -91
- package/dist/scopes/index.js +21 -39
- package/package.json +2 -3
- package/dist/commons/events/CountryConfigQueryInput.d.ts +0 -3008
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +0 -42
- package/dist/commons/events/event.d.ts +0 -54
- package/dist/commons/events/field.d.ts +0 -82
- package/dist/commons/events/scopes.d.ts +0 -45
- package/dist/commons/events/serializer.d.ts +0 -2
- package/dist/commons/events/workqueueDefaultColumns.d.ts +0 -3
package/dist/scopes/index.d.ts
CHANGED
@@ -123,84 +123,19 @@ declare const ConfigurableScopes: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
123
123
|
options: {
|
124
124
|
role: string[];
|
125
125
|
};
|
126
|
-
}>, z.ZodObject<{
|
127
|
-
type: z.ZodLiteral<"workqueue">;
|
128
|
-
options: z.ZodObject<{
|
129
|
-
id: z.ZodArray<z.ZodString, "many">;
|
130
|
-
}, "strip", z.ZodTypeAny, {
|
131
|
-
id: string[];
|
132
|
-
}, {
|
133
|
-
id: string[];
|
134
|
-
}>;
|
135
|
-
}, "strip", z.ZodTypeAny, {
|
136
|
-
type: "workqueue";
|
137
|
-
options: {
|
138
|
-
id: string[];
|
139
|
-
};
|
140
|
-
}, {
|
141
|
-
type: "workqueue";
|
142
|
-
options: {
|
143
|
-
id: string[];
|
144
|
-
};
|
145
|
-
}>, z.ZodObject<{
|
146
|
-
type: z.ZodLiteral<"record.notify">;
|
147
|
-
options: z.ZodObject<{
|
148
|
-
event: z.ZodArray<z.ZodString, "many">;
|
149
|
-
}, "strip", z.ZodTypeAny, {
|
150
|
-
event: string[];
|
151
|
-
}, {
|
152
|
-
event: string[];
|
153
|
-
}>;
|
154
|
-
}, "strip", z.ZodTypeAny, {
|
155
|
-
type: "record.notify";
|
156
|
-
options: {
|
157
|
-
event: string[];
|
158
|
-
};
|
159
|
-
}, {
|
160
|
-
type: "record.notify";
|
161
|
-
options: {
|
162
|
-
event: string[];
|
163
|
-
};
|
164
126
|
}>]>;
|
165
|
-
|
166
|
-
export
|
167
|
-
export declare function findScope<T extends ConfigurableScopeType>(scopes: string[], scopeType: T): Extract<{
|
127
|
+
type ConfigurableScopes = z.infer<typeof ConfigurableScopes>;
|
128
|
+
export declare function findScope(scopes: string[], scopeType: ConfigurableScopes['type']): {
|
168
129
|
type: "user.create";
|
169
130
|
options: {
|
170
131
|
role: string[];
|
171
132
|
};
|
172
|
-
}
|
173
|
-
type: T;
|
174
|
-
}> | Extract<{
|
133
|
+
} | {
|
175
134
|
type: "user.edit";
|
176
135
|
options: {
|
177
136
|
role: string[];
|
178
137
|
};
|
179
|
-
}
|
180
|
-
type: T;
|
181
|
-
}> | Extract<{
|
182
|
-
type: "workqueue";
|
183
|
-
options: {
|
184
|
-
id: string[];
|
185
|
-
};
|
186
|
-
}, {
|
187
|
-
type: T;
|
188
|
-
}> | Extract<{
|
189
|
-
type: "record.notify";
|
190
|
-
options: {
|
191
|
-
event: string[];
|
192
|
-
};
|
193
|
-
}, {
|
194
|
-
type: T;
|
195
|
-
}> | undefined;
|
196
|
-
/**
|
197
|
-
* Parses a configurable scope string into a ConfigurableScopes object.
|
198
|
-
* @param {string} scope - The scope string to parse
|
199
|
-
* @returns {ConfigurableScopes | undefined} The parsed scope object if valid, undefined otherwise
|
200
|
-
* @example
|
201
|
-
* parseScope("user.create[role=field-agent|registration-agent]")
|
202
|
-
* // Returns: { type: "user.create", options: { role: ["field-agent", "registration-agent"] } }
|
203
|
-
*/
|
138
|
+
} | undefined;
|
204
139
|
export declare function parseScope(scope: string): {
|
205
140
|
type: "user.create";
|
206
141
|
options: {
|
@@ -211,31 +146,9 @@ export declare function parseScope(scope: string): {
|
|
211
146
|
options: {
|
212
147
|
role: string[];
|
213
148
|
};
|
214
|
-
} | {
|
215
|
-
type: "workqueue";
|
216
|
-
options: {
|
217
|
-
id: string[];
|
218
|
-
};
|
219
|
-
} | {
|
220
|
-
type: "record.notify";
|
221
|
-
options: {
|
222
|
-
event: string[];
|
223
|
-
};
|
224
149
|
} | {
|
225
150
|
type: "natlsysadmin" | "bypassratelimit" | "declare" | "register" | "validate" | "demo" | "certify" | "performance" | "sysadmin" | "teams" | "config" | "webhook" | "nationalId" | "notification-api" | "recordsearch" | "record.declare-birth" | "record.declare-birth:my-jurisdiction" | "record.declare-death" | "record.declare-death:my-jurisdiction" | "record.declare-marriage" | "record.declare-marriage:my-jurisdiction" | "record.declaration-submit-incomplete" | "record.declaration-submit-for-review" | "record.unassign-others" | "record.declaration-submit-for-approval" | "record.declaration-submit-for-updates" | "record.declaration-edit" | "record.review-duplicates" | "record.declaration-archive" | "record.declaration-reinstate" | "record.register" | "record.export-records" | "record.declaration-print" | "record.declaration-print-supporting-documents" | "record.registration-print" | "record.registration-print&issue-certified-copies" | "record.registration-print-certified-copies" | "record.registration-bulk-print-certified-copies" | "record.registration-verify-certified-copies" | "record.registration-request-correction" | "record.registration-correct" | "record.registration-request-revocation" | "record.registration-revoke" | "record.registration-request-reinstatement" | "record.registration-reinstate" | "record.confirm-registration" | "record.reject-registration" | "search.birth:my-jurisdiction" | "search.birth" | "search.death:my-jurisdiction" | "search.death" | "search.marriage:my-jurisdiction" | "search.marriage" | "record.read" | "record.read-audit" | "record.read-comments" | "record.create-comments" | "profile.update" | "profile.electronic-signature" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "organisation.read-locations:all" | "organisation.read-locations:my-office" | "organisation.read-locations:my-jurisdiction" | "user.read:all" | "user.read:my-office" | "user.read:my-jurisdiction" | "user.read:only-my-audit" | "user.create:all" | "user.create:my-jurisdiction" | "user.update:all" | "user.update:my-jurisdiction" | "config.update:all" | "user.data-seeding";
|
226
151
|
} | undefined;
|
227
|
-
/**
|
228
|
-
* Stringifies a ConfigurableScopes object into a scope string.
|
229
|
-
* @param {ConfigurableScopes} scope - The scope object to stringify
|
230
|
-
* @returns {string} The stringified scope in format "type[key1=value1|value2,key2=value3|value4]"
|
231
|
-
* @example
|
232
|
-
* stringifyScope({
|
233
|
-
* type: "record.notify",
|
234
|
-
* options: { event: ["v2.birth", "tennis-club-membership"] }
|
235
|
-
* })
|
236
|
-
* // Returns: "record.notify[event=v2.birth|tennis-club-membership]"
|
237
|
-
*/
|
238
|
-
export declare function stringifyScope(scope: ConfigurableScopes): string;
|
239
152
|
export declare const scopes: Scope[];
|
240
153
|
export type ParsedScopes = NonNullable<ReturnType<typeof parseScope>>;
|
241
154
|
export type RawScopes = z.infer<typeof LiteralScopes> | (string & {});
|
package/dist/scopes/index.js
CHANGED
@@ -23,8 +23,7 @@ __export(scopes_exports, {
|
|
23
23
|
SCOPES: () => SCOPES,
|
24
24
|
findScope: () => findScope,
|
25
25
|
parseScope: () => parseScope,
|
26
|
-
scopes: () => scopes
|
27
|
-
stringifyScope: () => stringifyScope
|
26
|
+
scopes: () => scopes
|
28
27
|
});
|
29
28
|
module.exports = __toCommonJS(scopes_exports);
|
30
29
|
|
@@ -217,7 +216,7 @@ var LiteralScopes = import_zod.z.union([
|
|
217
216
|
import_zod.z.literal(SCOPES.CONFIG_UPDATE_ALL),
|
218
217
|
import_zod.z.literal(SCOPES.USER_DATA_SEEDING)
|
219
218
|
]);
|
220
|
-
var rawConfigurableScopeRegex = /^([a-zA-Z
|
219
|
+
var rawConfigurableScopeRegex = /^([a-zA-Z]+\.[a-zA-Z]+)\[((?:\w+=\w+(?:\|\w+)*)(:?,\w+=\w+(?:\|\w+)*)*)\]$/;
|
221
220
|
var rawConfigurableScope = import_zod.z.string().regex(rawConfigurableScopeRegex);
|
222
221
|
var CreateUserScope = import_zod.z.object({
|
223
222
|
type: import_zod.z.literal("user.create"),
|
@@ -231,27 +230,12 @@ var EditUserScope = import_zod.z.object({
|
|
231
230
|
role: import_zod.z.array(import_zod.z.string())
|
232
231
|
})
|
233
232
|
});
|
234
|
-
var WorkqueueScope = import_zod.z.object({
|
235
|
-
type: import_zod.z.literal("workqueue"),
|
236
|
-
options: import_zod.z.object({
|
237
|
-
id: import_zod.z.array(import_zod.z.string())
|
238
|
-
})
|
239
|
-
});
|
240
|
-
var NotifyRecordScope = import_zod.z.object({
|
241
|
-
type: import_zod.z.literal("record.notify"),
|
242
|
-
options: import_zod.z.object({
|
243
|
-
event: import_zod.z.array(import_zod.z.string())
|
244
|
-
})
|
245
|
-
});
|
246
233
|
var ConfigurableScopes = import_zod.z.discriminatedUnion("type", [
|
247
234
|
CreateUserScope,
|
248
|
-
EditUserScope
|
249
|
-
WorkqueueScope,
|
250
|
-
NotifyRecordScope
|
235
|
+
EditUserScope
|
251
236
|
]);
|
252
237
|
function findScope(scopes2, scopeType) {
|
253
|
-
|
254
|
-
return parsedScopes.find(
|
238
|
+
return scopes2.map((rawScope) => parseScope(rawScope)).find(
|
255
239
|
(parsedScope) => parsedScope?.type === scopeType
|
256
240
|
);
|
257
241
|
}
|
@@ -263,25 +247,23 @@ function parseScope(scope) {
|
|
263
247
|
};
|
264
248
|
}
|
265
249
|
const maybeConfigurableScope = rawConfigurableScope.safeParse(scope);
|
266
|
-
if (
|
267
|
-
|
250
|
+
if (maybeConfigurableScope.success) {
|
251
|
+
const rawScope = maybeConfigurableScope.data;
|
252
|
+
const [, type, rawOptions] = rawScope.match(rawConfigurableScopeRegex) ?? [];
|
253
|
+
const options = rawOptions.split(",").reduce((acc, option) => {
|
254
|
+
const [key, value] = option.split("=");
|
255
|
+
acc[key] = value.split("|");
|
256
|
+
return acc;
|
257
|
+
}, {});
|
258
|
+
const parsedScope = {
|
259
|
+
type,
|
260
|
+
options
|
261
|
+
};
|
262
|
+
const result = ConfigurableScopes.safeParse(parsedScope);
|
263
|
+
if (result.success) {
|
264
|
+
return result.data;
|
265
|
+
}
|
268
266
|
}
|
269
|
-
|
270
|
-
const [, type, rawOptions] = rawScope.match(rawConfigurableScopeRegex) ?? [];
|
271
|
-
const options = rawOptions.split(",").reduce((acc, option) => {
|
272
|
-
const [key, value] = option.split("=");
|
273
|
-
acc[key] = value.split("|");
|
274
|
-
return acc;
|
275
|
-
}, {});
|
276
|
-
const parsedScope = {
|
277
|
-
type,
|
278
|
-
options
|
279
|
-
};
|
280
|
-
const result = ConfigurableScopes.safeParse(parsedScope);
|
281
|
-
return result.success ? result.data : void 0;
|
282
|
-
}
|
283
|
-
function stringifyScope(scope) {
|
284
|
-
const options = Object.entries(scope.options).map(([key, value]) => `${key}=${value.join("|")}`).join(",");
|
285
|
-
return `${scope.type}[${options}]`;
|
267
|
+
return void 0;
|
286
268
|
}
|
287
269
|
var scopes = Object.values(SCOPES);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@opencrvs/toolkit",
|
3
|
-
"version": "1.8.0-rc.
|
3
|
+
"version": "1.8.0-rc.f7bcb31",
|
4
4
|
"description": "OpenCRVS toolkit for building country configurations",
|
5
5
|
"license": "MPL-2.0",
|
6
6
|
"exports": {
|
@@ -20,8 +20,7 @@
|
|
20
20
|
"ajv-formats": "^3.0.1",
|
21
21
|
"superjson": "1.9.0-0",
|
22
22
|
"@trpc/client": "^11.0.0-rc.648",
|
23
|
-
"@trpc/server": "^11.0.0-rc.532"
|
24
|
-
"zod-openapi": "^4.2.4"
|
23
|
+
"@trpc/server": "^11.0.0-rc.532"
|
25
24
|
},
|
26
25
|
"devDependencies": {
|
27
26
|
"@types/uuid": "^9.0.3",
|