@opencrvs/toolkit 2.2.0-rc.3de6f63 → 2.2.0-rc.5bf5dfc
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/build.sh +7 -2
- package/dist/application-config/index.js +4 -4
- package/dist/authentication/index.d.ts +1 -1
- package/dist/authentication/index.js +4 -8
- package/dist/cli.js +48 -31
- package/dist/commons/api/router.d.ts +3 -3
- package/dist/commons/conditionals/conditionals.d.ts +4 -4
- package/dist/commons/conditionals/validate.d.ts +1 -1
- package/dist/commons/events/ActionStatus.d.ts +2 -2
- package/dist/commons/events/ActionType.d.ts +2 -0
- package/dist/commons/events/Draft.d.ts +34 -1
- package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
- package/dist/commons/events/locations.d.ts +1 -1
- package/dist/commons/events/scopes.d.ts +2 -1
- package/dist/commons/events/test.utils.d.ts +3 -3
- package/dist/commons/users/Role.d.ts +23 -0
- package/dist/commons/users/User.d.ts +263 -0
- package/dist/commons/users/authentication.d.ts +67 -0
- package/dist/commons/users/index.d.ts +5 -0
- package/dist/commons/users/roleValidations.d.ts +15 -0
- package/dist/commons/users/scopes.d.ts +1402 -0
- package/dist/commons/users/userReferences.d.ts +176 -0
- package/dist/conditionals/index.js +3 -3
- package/dist/environment/questions.d.ts +28 -7
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +32 -30
- package/dist/environment/setup-environment.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +9 -1
- package/dist/events/index.js +17 -9
- package/dist/notification/index.js +15 -9
- package/dist/roles/index.d.ts +2 -0
- package/dist/roles/index.d.ts.map +1 -0
- package/dist/roles/index.js +719 -0
- package/dist/scopes/index.d.ts +0 -10
- package/dist/scopes/index.js +3 -7
- package/opencrvs-toolkit-2.2.0-rc.5bf5dfc.tgz +0 -0
- package/package.json +3 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +3 -5
- package/opencrvs-toolkit-2.2.0-rc.3de6f63.tgz +0 -0
package/build.sh
CHANGED
|
@@ -25,6 +25,8 @@ mkdir -p ./dist/commons/events
|
|
|
25
25
|
cp -r ../commons/build/dist/common/events/*.d.ts ./dist/commons/events
|
|
26
26
|
mkdir -p ./dist/commons/events/state
|
|
27
27
|
cp -r ../commons/build/dist/common/events/state/*.d.ts ./dist/commons/events/state
|
|
28
|
+
mkdir -p ./dist/commons/users
|
|
29
|
+
cp -r ../commons/build/dist/common/users/*.d.ts ./dist/commons/users
|
|
28
30
|
|
|
29
31
|
# Build common conditionals
|
|
30
32
|
npx esbuild src/conditionals/index.ts --bundle --format=cjs --outdir=./dist/conditionals --allow-overwrite --packages=external
|
|
@@ -33,11 +35,14 @@ cp -r ../commons/build/dist/common/conditionals/*.d.ts ./dist/commons/conditiona
|
|
|
33
35
|
|
|
34
36
|
# Build common scopes
|
|
35
37
|
npx esbuild src/scopes/index.ts --bundle --format=cjs --outdir=./dist/scopes --allow-overwrite --packages=external
|
|
36
|
-
cp -r ../commons/build/dist/common/scopes.d.ts ./dist/scopes/index.d.ts
|
|
38
|
+
cp -r ../commons/build/dist/common/users/scopes.d.ts ./dist/scopes/index.d.ts
|
|
39
|
+
|
|
40
|
+
# Build common roles (.d.ts points at dist/commons/users, copied with the events types)
|
|
41
|
+
npx esbuild src/roles/index.ts --bundle --format=cjs --outdir=./dist/roles --allow-overwrite --packages=external
|
|
37
42
|
|
|
38
43
|
# Build common authentication
|
|
39
44
|
npx esbuild src/authentication/index.ts --bundle --format=cjs --outdir=./dist/authentication --allow-overwrite --packages=external
|
|
40
|
-
cp -r ../commons/build/dist/common/authentication.d.ts ./dist/authentication/index.d.ts
|
|
45
|
+
cp -r ../commons/build/dist/common/users/authentication.d.ts ./dist/authentication/index.d.ts
|
|
41
46
|
|
|
42
47
|
# Build api client
|
|
43
48
|
npx esbuild src/api/index.ts --bundle --format=cjs --outdir=./dist/api --allow-overwrite --packages=external
|
|
@@ -619,11 +619,11 @@ var META_ACTIONS = [
|
|
|
619
619
|
ActionType.READ
|
|
620
620
|
];
|
|
621
621
|
|
|
622
|
-
// ../commons/src/authentication.ts
|
|
622
|
+
// ../commons/src/users/authentication.ts
|
|
623
623
|
var import_jwt_decode = __toESM(require("jwt-decode"));
|
|
624
624
|
var z14 = __toESM(require("zod/v4"));
|
|
625
625
|
|
|
626
|
-
// ../commons/src/scopes.ts
|
|
626
|
+
// ../commons/src/users/scopes.ts
|
|
627
627
|
var z13 = __toESM(require("zod/v4"));
|
|
628
628
|
var qs = __toESM(require("qs"));
|
|
629
629
|
|
|
@@ -707,7 +707,7 @@ var EventStatus = z12.enum([
|
|
|
707
707
|
"ARCHIVED"
|
|
708
708
|
]);
|
|
709
709
|
|
|
710
|
-
// ../commons/src/scopes.ts
|
|
710
|
+
// ../commons/src/users/scopes.ts
|
|
711
711
|
var JurisdictionFilter = z13.enum(["administrativeArea", "location", "all"]).describe(
|
|
712
712
|
"Filters based on user jurisdiction relative to their office location in hierarchy."
|
|
713
713
|
);
|
|
@@ -980,7 +980,7 @@ var DEFAULT_SCOPE_OPTIONS = {
|
|
|
980
980
|
registeredIn: JurisdictionFilter.enum.all
|
|
981
981
|
};
|
|
982
982
|
|
|
983
|
-
// ../commons/src/authentication.ts
|
|
983
|
+
// ../commons/src/users/authentication.ts
|
|
984
984
|
var TokenUserType = z14.enum(["user", "system"]);
|
|
985
985
|
var TokenWithBearer = z14.string().regex(/^Bearer\s/);
|
|
986
986
|
|
|
@@ -50,7 +50,6 @@ __export(authentication_exports, {
|
|
|
50
50
|
canUserCreateEvent: () => canUserCreateEvent,
|
|
51
51
|
canUserNotifyEvent: () => canUserNotifyEvent,
|
|
52
52
|
decodeScope: () => decodeScope,
|
|
53
|
-
defineRoles: () => defineRoles,
|
|
54
53
|
defineScopes: () => defineScopes,
|
|
55
54
|
encodeScope: () => encodeScope,
|
|
56
55
|
getAcceptedScopesByType: () => getAcceptedScopesByType,
|
|
@@ -76,11 +75,11 @@ __export(authentication_exports, {
|
|
|
76
75
|
module.exports = __toCommonJS(authentication_exports);
|
|
77
76
|
var z9 = __toESM(require("zod/v4"));
|
|
78
77
|
|
|
79
|
-
// ../commons/src/authentication.ts
|
|
78
|
+
// ../commons/src/users/authentication.ts
|
|
80
79
|
var import_jwt_decode = __toESM(require("jwt-decode"));
|
|
81
80
|
var z8 = __toESM(require("zod/v4"));
|
|
82
81
|
|
|
83
|
-
// ../commons/src/scopes.ts
|
|
82
|
+
// ../commons/src/users/scopes.ts
|
|
84
83
|
var z7 = __toESM(require("zod/v4"));
|
|
85
84
|
var qs = __toESM(require("qs"));
|
|
86
85
|
|
|
@@ -352,7 +351,7 @@ var EventStatus = z6.enum([
|
|
|
352
351
|
"ARCHIVED"
|
|
353
352
|
]);
|
|
354
353
|
|
|
355
|
-
// ../commons/src/scopes.ts
|
|
354
|
+
// ../commons/src/users/scopes.ts
|
|
356
355
|
var JurisdictionFilter = z7.enum(["administrativeArea", "location", "all"]).describe(
|
|
357
356
|
"Filters based on user jurisdiction relative to their office location in hierarchy."
|
|
358
357
|
);
|
|
@@ -727,11 +726,8 @@ function canUserNotifyEvent(userScopes, eventType) {
|
|
|
727
726
|
function defineScopes(scopes) {
|
|
728
727
|
return scopes.map((scope) => Scope.parse(scope)).map(encodeScope);
|
|
729
728
|
}
|
|
730
|
-
function defineRoles(roles) {
|
|
731
|
-
return roles;
|
|
732
|
-
}
|
|
733
729
|
|
|
734
|
-
// ../commons/src/authentication.ts
|
|
730
|
+
// ../commons/src/users/authentication.ts
|
|
735
731
|
function getAcceptedScopesFromToken(token, acceptedScopes) {
|
|
736
732
|
const tokenScopes = getScopes(token);
|
|
737
733
|
return tokenScopes.map((scope) => {
|
package/dist/cli.js
CHANGED
|
@@ -877,7 +877,7 @@ function validateCIDRs(input4) {
|
|
|
877
877
|
function validateRegistryHost(input4) {
|
|
878
878
|
return /^[a-z0-9]([a-z0-9.-]*[a-z0-9])?(:[0-9]+)?$/i.test(input4) ? true : "Please enter a registry host without protocol or path (e.g. docker.io, ghcr.io)";
|
|
879
879
|
}
|
|
880
|
-
var import_kleur2, notEmpty, registryQuestions, githubQuestions, githubOtherQuestions, githubTokenQuestion, countryQuestions, infrastructureQuestions, staticSSLCertQuestions, backupQuestions, diskQuestions, databaseAndMonitoringQuestions, emailQuestions, sentryQuestions, metabaseAdminQuestions;
|
|
880
|
+
var import_kleur2, notEmpty, registryQuestions, githubQuestions, githubApprovalRequiredQuestion, githubApproversQuestion, githubOtherQuestions, githubTokenQuestion, countryQuestions, infrastructureQuestions, staticSSLCertQuestions, backupQuestions, diskQuestions, databaseAndMonitoringQuestions, emailQuestions, sentryQuestions, metabaseAdminQuestions;
|
|
881
881
|
var init_questions = __esm({
|
|
882
882
|
"src/environment/questions.ts"() {
|
|
883
883
|
"use strict";
|
|
@@ -959,36 +959,38 @@ var init_questions = __esm({
|
|
|
959
959
|
scope: "REPOSITORY"
|
|
960
960
|
}
|
|
961
961
|
];
|
|
962
|
+
githubApprovalRequiredQuestion = {
|
|
963
|
+
name: "approvalRequired",
|
|
964
|
+
type: "select",
|
|
965
|
+
message: "Would you like to enable approvals process for GitHub action workflows?",
|
|
966
|
+
choices: [
|
|
967
|
+
{
|
|
968
|
+
title: "True",
|
|
969
|
+
value: "true"
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
title: "False",
|
|
973
|
+
value: "false"
|
|
974
|
+
}
|
|
975
|
+
],
|
|
976
|
+
valueType: "VARIABLE",
|
|
977
|
+
validate: notEmpty,
|
|
978
|
+
valueLabel: "APPROVAL_REQUIRED",
|
|
979
|
+
initial: process.env.APPROVAL_REQUIRED,
|
|
980
|
+
scope: "ENVIRONMENT"
|
|
981
|
+
};
|
|
982
|
+
githubApproversQuestion = {
|
|
983
|
+
name: "githubApprovers",
|
|
984
|
+
type: "text",
|
|
985
|
+
message: "Please provide/update list of approvers?",
|
|
986
|
+
initial: process.env.GH_APPROVERS,
|
|
987
|
+
valueType: "VARIABLE",
|
|
988
|
+
valueLabel: "GH_APPROVERS",
|
|
989
|
+
scope: "REPOSITORY"
|
|
990
|
+
};
|
|
962
991
|
githubOtherQuestions = [
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
type: "text",
|
|
966
|
-
message: "Please provide/update list of production approvers?",
|
|
967
|
-
initial: process.env.GH_APPROVERS,
|
|
968
|
-
valueType: "VARIABLE",
|
|
969
|
-
valueLabel: "GH_APPROVERS",
|
|
970
|
-
scope: "REPOSITORY"
|
|
971
|
-
},
|
|
972
|
-
{
|
|
973
|
-
name: "approvalRequired",
|
|
974
|
-
type: "select",
|
|
975
|
-
message: "Would you like to enable approvals process for GitHub action workflows?",
|
|
976
|
-
choices: [
|
|
977
|
-
{
|
|
978
|
-
title: "True",
|
|
979
|
-
value: "true"
|
|
980
|
-
},
|
|
981
|
-
{
|
|
982
|
-
title: "False",
|
|
983
|
-
value: "false"
|
|
984
|
-
}
|
|
985
|
-
],
|
|
986
|
-
valueType: "VARIABLE",
|
|
987
|
-
validate: notEmpty,
|
|
988
|
-
valueLabel: "APPROVAL_REQUIRED",
|
|
989
|
-
initial: process.env.APPROVAL_REQUIRED,
|
|
990
|
-
scope: "ENVIRONMENT"
|
|
991
|
-
}
|
|
992
|
+
githubApprovalRequiredQuestion,
|
|
993
|
+
githubApproversQuestion
|
|
992
994
|
];
|
|
993
995
|
githubTokenQuestion = [
|
|
994
996
|
{
|
|
@@ -2253,7 +2255,22 @@ async function runSetupEnvironment() {
|
|
|
2253
2255
|
"WARNING! You are setting up a production environment.\n Make sure you have read the deployment guide carefully before proceeding.\n"
|
|
2254
2256
|
)
|
|
2255
2257
|
);
|
|
2256
|
-
|
|
2258
|
+
}
|
|
2259
|
+
log("\n", import_kleur4.default.bold().underline("Workflow approvals"));
|
|
2260
|
+
const { approvalRequired } = await promptAndStoreAnswer(
|
|
2261
|
+
[
|
|
2262
|
+
{
|
|
2263
|
+
...githubApprovalRequiredQuestion,
|
|
2264
|
+
initial: getIndexFromChoices(
|
|
2265
|
+
githubApprovalRequiredQuestion.choices,
|
|
2266
|
+
process.env.APPROVAL_REQUIRED || (environment_type === "production" ? "true" : "false")
|
|
2267
|
+
)
|
|
2268
|
+
}
|
|
2269
|
+
],
|
|
2270
|
+
existingValues
|
|
2271
|
+
);
|
|
2272
|
+
if (approvalRequired !== "false") {
|
|
2273
|
+
await promptAndStoreAnswer([githubApproversQuestion], existingValues);
|
|
2257
2274
|
}
|
|
2258
2275
|
log("\n", import_kleur4.default.bold().underline("Two-factor authentication (2FA)"));
|
|
2259
2276
|
const existingTwoFaEnabled = findExistingValue(
|
|
@@ -1227,7 +1227,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
1227
1227
|
annotation?: Record<string, import("../commons").FieldUpdateValue> | null | undefined;
|
|
1228
1228
|
status: "Accepted" | "Rejected" | "Requested";
|
|
1229
1229
|
originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
|
|
1230
|
-
type: "
|
|
1230
|
+
type: "DECLARE" | "NOTIFY";
|
|
1231
1231
|
};
|
|
1232
1232
|
}[];
|
|
1233
1233
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
@@ -1243,7 +1243,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
1243
1243
|
keepAssignmentIfAccepted?: boolean | undefined;
|
|
1244
1244
|
keepAssignmentIfRejected?: boolean | undefined;
|
|
1245
1245
|
createdAtLocation?: string | null | undefined;
|
|
1246
|
-
type: "DECLARE";
|
|
1246
|
+
type: "DECLARE" | "NOTIFY";
|
|
1247
1247
|
status: "Accepted" | "Rejected" | "Requested";
|
|
1248
1248
|
};
|
|
1249
1249
|
output: {
|
|
@@ -1262,7 +1262,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
1262
1262
|
annotation?: Record<string, import("../commons").FieldUpdateValue> | null | undefined;
|
|
1263
1263
|
status: "Accepted" | "Rejected" | "Requested";
|
|
1264
1264
|
originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
|
|
1265
|
-
type: "
|
|
1265
|
+
type: "DECLARE" | "NOTIFY";
|
|
1266
1266
|
};
|
|
1267
1267
|
};
|
|
1268
1268
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventDocument } from '../events/EventDocument';
|
|
2
2
|
import { ActionUpdate, EventState } from '../events/ActionDocument';
|
|
3
|
-
import { ITokenPayload as TokenPayload } from '../authentication';
|
|
3
|
+
import { ITokenPayload as TokenPayload } from '../users/authentication';
|
|
4
4
|
import { PartialSchema as AjvJSONSchemaType } from 'ajv/dist/types/json-schema';
|
|
5
5
|
import { userSerializer } from '../events/serializers/user/serializer';
|
|
6
6
|
import { UUID } from '../uuid';
|
|
@@ -83,13 +83,13 @@ export declare const now: typeof todayDateTimeValueSerializer;
|
|
|
83
83
|
* Generate conditional rules for user.
|
|
84
84
|
*/
|
|
85
85
|
export declare const user: typeof userSerializer & {
|
|
86
|
-
scope: (scope: import("../scopes").ScopeType) => {
|
|
87
|
-
attribute: (option: import("../scopes").ScopeOptionKey) => {
|
|
86
|
+
scope: (scope: import("../users/scopes").ScopeType) => {
|
|
87
|
+
attribute: (option: import("../users/scopes").ScopeOptionKey) => {
|
|
88
88
|
$scope: "attachment.upload" | "bypassratelimit" | "config.update-all" | "dashboard.view" | "integration.audit.read" | "integration.create" | "location.edit" | "organisation.read-locations" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.action.accept" | "record.action.reject" | "record.archive" | "record.correct" | "record.create" | "record.custom-action" | "record.declare" | "record.edit" | "record.import" | "record.notify" | "record.print-certified-copies" | "record.read" | "record.register" | "record.reindex" | "record.reinstate-registration" | "record.reject" | "record.request-correction" | "record.review-duplicates" | "record.revoke-registration" | "record.search" | "record.unarchive" | "record.unassign-others" | "user.create" | "user.data-seeding" | "user.edit" | "user.read" | "user.read-only-my-audit" | "user.search" | "workqueue";
|
|
89
89
|
$option: "accessLevel" | "createdBy" | "createdIn" | "declaredBy" | "declaredIn" | "event" | "flags" | "ids" | "notifiedBy" | "notifiedIn" | "placeOfEvent" | "registeredBy" | "registeredIn" | "role" | "status";
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
|
-
jurisdiction: (jurisdiction: import("../scopes").JurisdictionFilter | {
|
|
92
|
+
jurisdiction: (jurisdiction: import("../users/scopes").JurisdictionFilter | {
|
|
93
93
|
$scope: "attachment.upload" | "bypassratelimit" | "config.update-all" | "dashboard.view" | "integration.audit.read" | "integration.create" | "location.edit" | "organisation.read-locations" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.action.accept" | "record.action.reject" | "record.archive" | "record.correct" | "record.create" | "record.custom-action" | "record.declare" | "record.edit" | "record.import" | "record.notify" | "record.print-certified-copies" | "record.read" | "record.register" | "record.reindex" | "record.reinstate-registration" | "record.reject" | "record.request-correction" | "record.review-duplicates" | "record.revoke-registration" | "record.search" | "record.unarchive" | "record.unassign-others" | "user.create" | "user.data-seeding" | "user.edit" | "user.read" | "user.read-only-my-audit" | "user.search" | "workqueue";
|
|
94
94
|
$option: "accessLevel" | "createdBy" | "createdIn" | "declaredBy" | "declaredIn" | "event" | "flags" | "ids" | "notifiedBy" | "notifiedIn" | "placeOfEvent" | "registeredBy" | "registeredIn" | "role" | "status";
|
|
95
95
|
}) => {
|
|
@@ -4,7 +4,7 @@ import { FieldConditional } from '../events/Conditional';
|
|
|
4
4
|
import { FieldConfig } from '../events/FieldConfig';
|
|
5
5
|
import { PlainDate, FieldUpdateValue, FieldValue } from '../events/FieldValue';
|
|
6
6
|
import { TranslationConfig } from '../events/TranslationConfig';
|
|
7
|
-
import { EncodedScope, TokenUserType } from '../authentication';
|
|
7
|
+
import { EncodedScope, TokenUserType } from '../users/authentication';
|
|
8
8
|
import { UUID } from '../uuid';
|
|
9
9
|
import { FormState } from '../events/utils';
|
|
10
10
|
import { ActionConfig } from '../events/ActionConfig';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Deliberately dependency-free (aside from language builtins) so that files
|
|
3
3
|
* like Flag.ts can depend on ActionStatus without being pulled into the
|
|
4
|
-
* commons/scopes.ts <-> commons/authentication.ts import cycle that
|
|
4
|
+
* commons/users/scopes.ts <-> commons/users/authentication.ts import cycle that
|
|
5
5
|
* ActionDocument.ts participates in (it imports TokenUserType from
|
|
6
|
-
* '../authentication').
|
|
6
|
+
* '../users/authentication').
|
|
7
7
|
*/
|
|
8
8
|
export declare const ActionStatus: {
|
|
9
9
|
readonly Requested: 'Requested';
|
|
@@ -59,6 +59,8 @@ export type ActionTypes = z.infer<typeof ActionTypes>;
|
|
|
59
59
|
*/
|
|
60
60
|
export declare const ClientSpecificAction: {
|
|
61
61
|
readonly REVIEW_CORRECTION_REQUEST: 'REVIEW_CORRECTION_REQUEST';
|
|
62
|
+
/** Opens the user's declare or notify draft of the event in its own flow */
|
|
63
|
+
readonly CONTINUE_DRAFT: 'CONTINUE_DRAFT';
|
|
62
64
|
};
|
|
63
65
|
export type ClientSpecificAction = (typeof ClientSpecificAction)[keyof typeof ClientSpecificAction];
|
|
64
66
|
/** Actions which change event data (declaration) before registration / during declaration. */
|
|
@@ -57,13 +57,46 @@ export declare const DraftInput: z.ZodObject<{
|
|
|
57
57
|
keepAssignmentIfAccepted: z.ZodOptional<z.ZodBoolean>;
|
|
58
58
|
keepAssignmentIfRejected: z.ZodOptional<z.ZodBoolean>;
|
|
59
59
|
createdAtLocation: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
|
|
60
|
-
type: z.
|
|
60
|
+
type: z.ZodEnum<{
|
|
61
|
+
DECLARE: "DECLARE";
|
|
62
|
+
NOTIFY: "NOTIFY";
|
|
63
|
+
}>;
|
|
61
64
|
status: z.ZodEnum<{
|
|
62
65
|
Accepted: "Accepted";
|
|
63
66
|
Rejected: "Rejected";
|
|
64
67
|
Requested: "Requested";
|
|
65
68
|
}>;
|
|
66
69
|
}, z.core.$strip>;
|
|
70
|
+
export declare const RemoteDraft: z.ZodObject<{
|
|
71
|
+
id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
|
|
72
|
+
eventId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
|
|
73
|
+
transactionId: z.ZodString;
|
|
74
|
+
createdAt: z.ZodString;
|
|
75
|
+
action: z.ZodObject<{
|
|
76
|
+
transactionId: z.ZodString;
|
|
77
|
+
createdByUserType: z.ZodEnum<{
|
|
78
|
+
system: "system";
|
|
79
|
+
user: "user";
|
|
80
|
+
}>;
|
|
81
|
+
createdAt: z.ZodString;
|
|
82
|
+
createdBy: z.ZodString;
|
|
83
|
+
createdByRole: z.ZodOptional<z.ZodString>;
|
|
84
|
+
createdBySignature: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">>>;
|
|
85
|
+
declaration: z.ZodRecord<z.ZodString, z.ZodType<import("./FieldValue").FieldUpdateValue, unknown, z.core.$ZodTypeInternals<import("./FieldValue").FieldUpdateValue, unknown>>>;
|
|
86
|
+
annotation: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./FieldValue").FieldUpdateValue, unknown, z.core.$ZodTypeInternals<import("./FieldValue").FieldUpdateValue, unknown>>>>>;
|
|
87
|
+
status: z.ZodEnum<{
|
|
88
|
+
Accepted: "Accepted";
|
|
89
|
+
Rejected: "Rejected";
|
|
90
|
+
Requested: "Requested";
|
|
91
|
+
}>;
|
|
92
|
+
originalActionId: z.ZodNullable<z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
|
|
93
|
+
type: z.ZodEnum<{
|
|
94
|
+
DECLARE: "DECLARE";
|
|
95
|
+
NOTIFY: "NOTIFY";
|
|
96
|
+
}>;
|
|
97
|
+
}, z.core.$strip>;
|
|
98
|
+
}, z.core.$strip>;
|
|
67
99
|
export type Draft = z.infer<typeof Draft>;
|
|
68
100
|
export type DraftInput = z.infer<typeof DraftInput>;
|
|
101
|
+
export type RemoteDraft = z.infer<typeof RemoteDraft>;
|
|
69
102
|
//# sourceMappingURL=Draft.d.ts.map
|
|
@@ -32,8 +32,8 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
32
32
|
age: z.ZodNumber;
|
|
33
33
|
asOfDateRef: z.ZodString;
|
|
34
34
|
}, z.core.$strip> | z.ZodObject<{
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
numericValue: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
37
37
|
}, z.core.$strip> | z.ZodObject<{
|
|
38
38
|
path: z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">;
|
|
39
39
|
originalFilename: z.ZodString;
|
|
@@ -44,8 +44,8 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
44
44
|
numericValue: z.ZodNumber;
|
|
45
45
|
unit: z.ZodString;
|
|
46
46
|
}, z.core.$strip> | z.ZodObject<{
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
label: z.ZodString;
|
|
48
|
+
value: z.ZodString;
|
|
49
49
|
}, z.core.$strip> | z.ZodObject<{
|
|
50
50
|
data: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
51
51
|
}, z.core.$strip> | z.ZodObject<{
|
|
@@ -68,8 +68,8 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
68
68
|
age: z.ZodNumber;
|
|
69
69
|
asOfDateRef: z.ZodString;
|
|
70
70
|
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
numericValue: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
73
73
|
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
74
74
|
path: z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">;
|
|
75
75
|
originalFilename: z.ZodString;
|
|
@@ -80,8 +80,8 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
80
80
|
numericValue: z.ZodNumber;
|
|
81
81
|
unit: z.ZodString;
|
|
82
82
|
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
label: z.ZodString;
|
|
84
|
+
value: z.ZodString;
|
|
85
85
|
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
86
86
|
data: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
87
87
|
country: z.ZodString;
|
|
@@ -243,15 +243,6 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
243
243
|
}, z.core.$strip>>>;
|
|
244
244
|
data: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
|
|
245
245
|
}, z.core.$strip>, z.ZodNull]>, z.ZodUndefined]>>> | z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUnknown, "CustomFieldValue", "out">>> | z.ZodString | z.ZodType<{
|
|
246
|
-
country: string;
|
|
247
|
-
streetLevelDetails?: Record<string, string> | undefined;
|
|
248
|
-
addressType: "DOMESTIC";
|
|
249
|
-
administrativeArea: string;
|
|
250
|
-
} | {
|
|
251
|
-
country: string;
|
|
252
|
-
streetLevelDetails?: Record<string, string> | undefined;
|
|
253
|
-
addressType: "INTERNATIONAL";
|
|
254
|
-
} | {
|
|
255
246
|
country?: string | null | undefined;
|
|
256
247
|
streetLevelDetails?: Record<string, string | null> | null | undefined;
|
|
257
248
|
addressType: "DOMESTIC";
|
|
@@ -260,7 +251,7 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
260
251
|
country?: string | null | undefined;
|
|
261
252
|
streetLevelDetails?: Record<string, string | null> | null | undefined;
|
|
262
253
|
addressType: "INTERNATIONAL";
|
|
263
|
-
} |
|
|
254
|
+
} | {
|
|
264
255
|
country: string;
|
|
265
256
|
streetLevelDetails?: Record<string, string> | undefined;
|
|
266
257
|
addressType: "DOMESTIC";
|
|
@@ -269,7 +260,7 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
269
260
|
country: string;
|
|
270
261
|
streetLevelDetails?: Record<string, string> | undefined;
|
|
271
262
|
addressType: "INTERNATIONAL";
|
|
272
|
-
} | {
|
|
263
|
+
} | null | undefined, unknown, z.core.$ZodTypeInternals<{
|
|
273
264
|
country?: string | null | undefined;
|
|
274
265
|
streetLevelDetails?: Record<string, string | null> | null | undefined;
|
|
275
266
|
addressType: "DOMESTIC";
|
|
@@ -278,6 +269,15 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
278
269
|
country?: string | null | undefined;
|
|
279
270
|
streetLevelDetails?: Record<string, string | null> | null | undefined;
|
|
280
271
|
addressType: "INTERNATIONAL";
|
|
272
|
+
} | {
|
|
273
|
+
country: string;
|
|
274
|
+
streetLevelDetails?: Record<string, string> | undefined;
|
|
275
|
+
addressType: "DOMESTIC";
|
|
276
|
+
administrativeArea: string;
|
|
277
|
+
} | {
|
|
278
|
+
country: string;
|
|
279
|
+
streetLevelDetails?: Record<string, string> | undefined;
|
|
280
|
+
addressType: "INTERNATIONAL";
|
|
281
281
|
} | null | undefined, unknown>> | z.ZodUnion<[z.ZodObject<{
|
|
282
282
|
start: z.core.$ZodBranded<z.ZodString, "PlainDate", "out">;
|
|
283
283
|
end: z.core.$ZodBranded<z.ZodString, "PlainDate", "out">;
|
|
@@ -3,7 +3,7 @@ import * as z from 'zod/v4';
|
|
|
3
3
|
import { PlainDate } from './PlainDate';
|
|
4
4
|
import { EventIndex } from './EventIndex';
|
|
5
5
|
import { ActionCreationMetadata, RegistrationCreationMetadata } from './EventMetadata';
|
|
6
|
-
import { RecordScopeV2, UserScopeV2 } from '../scopes';
|
|
6
|
+
import { RecordScopeV2, UserScopeV2 } from '../users/scopes';
|
|
7
7
|
import { SystemContext, UserContext } from '../users/User';
|
|
8
8
|
/** @deprecated Moving on, location types are arbitrary and defined by the country config. */
|
|
9
9
|
export declare const LocationTypeV1: z.ZodEnum<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DisplayableAction } from './ActionType';
|
|
2
|
-
import { EncodedScope, RecordScopeTypeV2, ScopeType, UserScopeV2 } from '../scopes';
|
|
2
|
+
import { EncodedScope, RecordScopeTypeV2, ScopeType, UserScopeV2 } from '../users/scopes';
|
|
3
3
|
import { EventIndexWithAdministrativeHierarchy } from './locations';
|
|
4
4
|
import { UserContext } from '../users/User';
|
|
5
5
|
import { EventIndex } from './EventIndex';
|
|
@@ -15,6 +15,7 @@ export declare const ACTION_SCOPE_MAP: {
|
|
|
15
15
|
PRINT_CERTIFICATE: "record.print-certified-copies"[];
|
|
16
16
|
REQUEST_CORRECTION: ("record.correct" | "record.request-correction")[];
|
|
17
17
|
REVIEW_CORRECTION_REQUEST: "record.correct"[];
|
|
18
|
+
CONTINUE_DRAFT: never[];
|
|
18
19
|
REJECT_CORRECTION: "record.correct"[];
|
|
19
20
|
APPROVE_CORRECTION: "record.correct"[];
|
|
20
21
|
REVOKE_REGISTRATION: "record.revoke-registration"[];
|
|
@@ -3,7 +3,7 @@ import { ActionDocument, ActionUpdate } from './ActionDocument';
|
|
|
3
3
|
import { ValidatorContext } from '../conditionals/validate';
|
|
4
4
|
import { ApproveCorrectionActionInput, ArchiveActionInput, AssignActionInput, DeclareActionInput, EditActionInput, MarkAsDuplicateActionInput, MarkNotDuplicateActionInput, NotifyActionInput, RegisterActionInput, RejectCorrectionActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, UnarchiveActionInput, UnassignActionInput, RevokeRegistrationActionInput, ReinstateRegistrationActionInput } from './ActionInput';
|
|
5
5
|
import { ActionType } from './ActionType';
|
|
6
|
-
import { Draft } from './Draft';
|
|
6
|
+
import { Draft, DraftInput, RemoteDraft } from './Draft';
|
|
7
7
|
import { EventConfig, EventConfigInput } from './EventConfig';
|
|
8
8
|
import { EventDocument } from './EventDocument';
|
|
9
9
|
import { EventIndex } from './EventIndex';
|
|
@@ -310,11 +310,11 @@ export declare function generateEventDocument({ configuration, actions, rng, def
|
|
|
310
310
|
}): EventDocument;
|
|
311
311
|
export declare function generateEventDraftDocument({ eventId, actionType, rng, declaration }: {
|
|
312
312
|
eventId: UUID;
|
|
313
|
-
actionType:
|
|
313
|
+
actionType: DraftInput['type'];
|
|
314
314
|
rng?: () => number;
|
|
315
315
|
declaration?: ActionUpdate;
|
|
316
316
|
annotation?: ActionUpdate;
|
|
317
|
-
}):
|
|
317
|
+
}): RemoteDraft;
|
|
318
318
|
/**
|
|
319
319
|
* Useful for testing when we need deterministic outcome.
|
|
320
320
|
* @param seed - Seed value for the pseudo-random number generator
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EventConfig } from '../events/EventConfig';
|
|
3
|
+
export declare const Role: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
scopes: z.ZodArray<z.core.$ZodBranded<z.ZodString, "EncodedScope", "out">>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export type Role = z.infer<typeof Role>;
|
|
8
|
+
export declare const Roles: z.ZodArray<z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
scopes: z.ZodArray<z.core.$ZodBranded<z.ZodString, "EncodedScope", "out">>;
|
|
11
|
+
}, z.core.$strip>>;
|
|
12
|
+
export type Roles = z.infer<typeof Roles>;
|
|
13
|
+
/**
|
|
14
|
+
* Helper for defining user roles. Should be used in country config.
|
|
15
|
+
*
|
|
16
|
+
* @param roles Array of roles in object format.
|
|
17
|
+
* @param eventConfigs Array of event configurations, which are needed to run validations for scopes.
|
|
18
|
+
*/
|
|
19
|
+
export declare function defineRoles(roles: Roles, eventConfigs: EventConfig[]): {
|
|
20
|
+
id: string;
|
|
21
|
+
scopes: (string & z.$brand<"EncodedScope">)[];
|
|
22
|
+
}[];
|
|
23
|
+
//# sourceMappingURL=Role.d.ts.map
|