@opencrvs/toolkit 1.9.13-rc.72233cd → 1.9.13-rc.76fce04
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 +0 -13
- package/dist/api/index.d.ts.map +1 -1
- package/dist/commons/api/router.d.ts +4561 -3370
- package/dist/commons/conditionals/conditionals.d.ts +3 -27
- package/dist/commons/conditionals/validate.d.ts +3 -13
- package/dist/commons/events/ActionConfig.d.ts +1555 -415
- package/dist/commons/events/ActionDocument.d.ts +1941 -888
- package/dist/commons/events/ActionInput.d.ts +1277 -277
- package/dist/commons/events/ActionType.d.ts +11 -91
- package/dist/commons/events/AdvancedSearchConfig.d.ts +1496 -294
- package/dist/commons/events/CompositeFieldValue.d.ts +190 -30
- package/dist/commons/events/Conditional.d.ts +38 -26
- package/dist/commons/events/Constants.d.ts +1 -1
- package/dist/commons/events/CountryConfigQueryInput.d.ts +4471 -1592
- package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
- package/dist/commons/events/DeduplicationConfig.d.ts +171 -15
- package/dist/commons/events/Draft.d.ts +113 -72
- package/dist/commons/events/DynamicFieldValue.d.ts +78 -12
- package/dist/commons/events/EventConfig.d.ts +2420 -35
- package/dist/commons/events/EventConfigInput.d.ts +3 -0
- package/dist/commons/events/EventDocument.d.ts +1366 -354
- package/dist/commons/events/EventIndex.d.ts +1010 -212
- package/dist/commons/events/EventInput.d.ts +8 -3
- package/dist/commons/events/EventMetadata.d.ts +357 -130
- package/dist/commons/events/FieldConfig.d.ts +12890 -2890
- package/dist/commons/events/FieldType.d.ts +4 -26
- package/dist/commons/events/FieldTypeMapping.d.ts +906 -314
- package/dist/commons/events/FieldValue.d.ts +527 -149
- package/dist/commons/events/FileUtils.d.ts +2 -2
- package/dist/commons/events/FormConfig.d.ts +721 -54
- package/dist/commons/events/PageConfig.d.ts +320 -58
- package/dist/commons/events/PlainDate.d.ts +1 -1
- package/dist/commons/events/SummaryConfig.d.ts +161 -14
- package/dist/commons/events/TemplateConfig.d.ts +3 -2
- package/dist/commons/events/TranslationConfig.d.ts +2 -2
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +37 -74
- package/dist/commons/events/WorkqueueConfig.d.ts +7480 -2135
- package/dist/commons/events/deduplication.d.ts +3 -3
- package/dist/commons/events/defineConfig.d.ts +247 -2
- package/dist/commons/events/index.d.ts +0 -3
- package/dist/commons/events/locations.d.ts +20 -57
- package/dist/commons/events/scopes.d.ts +34 -35
- package/dist/commons/events/state/availableActions.d.ts +2 -7
- package/dist/commons/events/state/flags.d.ts +3 -21
- package/dist/commons/events/state/index.d.ts +27 -30
- package/dist/commons/events/state/utils.d.ts +172 -190
- package/dist/commons/events/test.utils.d.ts +11 -52
- package/dist/commons/events/transactions.d.ts +1 -1
- package/dist/commons/events/utils.d.ts +274 -374
- package/dist/commons/notification/UserNotifications.d.ts +637 -61
- package/dist/conditionals/index.d.ts.map +1 -1
- package/dist/conditionals/index.js +14 -302
- package/dist/events/deduplication.d.ts +3 -3
- package/dist/events/index.js +2113 -2847
- package/dist/notification/index.d.ts.map +1 -1
- package/dist/notification/index.js +1769 -2073
- package/dist/scopes/index.d.ts +353 -640
- package/dist/scopes/index.d.ts.map +1 -1
- package/dist/scopes/index.js +300 -340
- package/package.json +3 -13
- package/tsconfig.json +2 -12
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/application-config/index.d.ts +0 -2
- package/dist/application-config/index.d.ts.map +0 -1
- package/dist/application-config/index.js +0 -2128
- package/dist/cli.d.ts +0 -2
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -3237
- package/dist/commons/application-config/index.d.ts +0 -84
- package/dist/commons/events/AuditLog.d.ts +0 -405
- package/dist/commons/events/Flag.d.ts +0 -67
- package/dist/commons/events/eventConfigValidation.d.ts +0 -8
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +0 -3
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +0 -405
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +0 -2
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +0 -1
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +0 -829
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +0 -3
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +0 -1
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +0 -159
- package/dist/migrations/v2.0/index.d.ts +0 -7
- package/dist/migrations/v2.0/index.d.ts.map +0 -1
- package/dist/migrations/v2.0/index.js +0 -3176
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +0 -3
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +0 -1
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +0 -344
- package/dist/migrations/v2.0/migrate-scopes.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-scopes.js +0 -282
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +0 -268
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +0 -237
- package/dist/migrations/v2.0/remove-delete-actions.d.ts +0 -3
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-delete-actions.js +0 -157
- package/dist/migrations/v2.0/remove-demo-scope.d.ts +0 -3
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-demo-scope.js +0 -75
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +0 -3
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-deprecated-imports.js +0 -97
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +0 -3
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-hearth-migrations.js +0 -78
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +0 -3
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +0 -110
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +0 -3
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-review-from-register-action.js +0 -164
- package/dist/migrations/v2.0/rename-api-paths.d.ts +0 -3
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +0 -1
- package/dist/migrations/v2.0/rename-api-paths.js +0 -188
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts +0 -3
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +0 -1
- package/dist/migrations/v2.0/rename-location-parent-id.js +0 -181
- package/opencrvs-toolkit-1.9.13-rc.72233cd.tgz +0 -0
package/dist/scopes/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,373 +15,335 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/scopes/index.ts
|
|
31
21
|
var scopes_exports = {};
|
|
32
22
|
__export(scopes_exports, {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
UserFilter: () => UserFilter,
|
|
45
|
-
canUserCreateEvent: () => canUserCreateEvent,
|
|
46
|
-
decodeScope: () => decodeScope,
|
|
47
|
-
defineRoles: () => defineRoles,
|
|
48
|
-
defineScopes: () => defineScopes,
|
|
49
|
-
encodeScope: () => encodeScope,
|
|
50
|
-
getAcceptedScopesByType: () => getAcceptedScopesByType,
|
|
51
|
-
getScopeOptionValue: () => getScopeOptionValue,
|
|
52
|
-
hasAnyScope: () => hasAnyScope,
|
|
53
|
-
hasScope: () => hasScope,
|
|
54
|
-
isCustomActionScope: () => isCustomActionScope,
|
|
55
|
-
scopeUsesDeclaredOptions: () => scopeUsesDeclaredOptions,
|
|
56
|
-
scopeUsesFullOptions: () => scopeUsesFullOptions,
|
|
57
|
-
scopeUsesPrintCertifiedCopiesOptions: () => scopeUsesPrintCertifiedCopiesOptions
|
|
23
|
+
ActionScopes: () => ActionScopes,
|
|
24
|
+
RecordScope: () => RecordScope,
|
|
25
|
+
RecordScopeType: () => RecordScopeType,
|
|
26
|
+
SCOPES: () => SCOPES,
|
|
27
|
+
SearchScopes: () => SearchScopes,
|
|
28
|
+
findScope: () => findScope,
|
|
29
|
+
getAuthorizedEventsFromScopes: () => getAuthorizedEventsFromScopes,
|
|
30
|
+
parseConfigurableScope: () => parseConfigurableScope,
|
|
31
|
+
parseLiteralScope: () => parseLiteralScope,
|
|
32
|
+
scopes: () => scopes,
|
|
33
|
+
stringifyScope: () => stringifyScope
|
|
58
34
|
});
|
|
59
35
|
module.exports = __toCommonJS(scopes_exports);
|
|
60
|
-
var z4 = __toESM(require("zod/v4"));
|
|
61
36
|
|
|
62
37
|
// ../commons/src/scopes.ts
|
|
63
|
-
var
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
38
|
+
var import_zod = require("zod");
|
|
39
|
+
var SCOPES = {
|
|
40
|
+
// TODO v1.8 legacy scopes
|
|
41
|
+
BYPASSRATELIMIT: "bypassratelimit",
|
|
42
|
+
REGISTER: "register",
|
|
43
|
+
DEMO: "demo",
|
|
44
|
+
CONFIG: "config",
|
|
45
|
+
// systems / integrations
|
|
46
|
+
WEBHOOK: "webhook",
|
|
47
|
+
NATIONALID: "nationalId",
|
|
48
|
+
NOTIFICATION_API: "notification-api",
|
|
49
|
+
RECORDSEARCH: "recordsearch",
|
|
50
|
+
RECORD_IMPORT: "record.import",
|
|
51
|
+
RECORD_EXPORT: "record.export",
|
|
52
|
+
RECORD_REINDEX: "record.reindex",
|
|
53
|
+
// declare
|
|
54
|
+
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
|
55
|
+
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
|
56
|
+
RECORD_DECLARE_DEATH: "record.declare-death",
|
|
57
|
+
RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
|
|
58
|
+
RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
|
|
59
|
+
RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
|
|
60
|
+
RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
|
|
61
|
+
// @todo: should this record be removed from events v2?
|
|
62
|
+
RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
|
|
63
|
+
RECORD_UNASSIGN_OTHERS: "record.unassign-others",
|
|
64
|
+
// validate
|
|
65
|
+
RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
|
|
66
|
+
RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
|
|
67
|
+
RECORD_DECLARATION_EDIT: "record.declaration-edit",
|
|
68
|
+
RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
|
|
69
|
+
RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
|
|
70
|
+
RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
|
|
71
|
+
// register
|
|
72
|
+
RECORD_REGISTER: "record.register",
|
|
73
|
+
/**
|
|
74
|
+
* This scope is used to **print and **issue certified copies of a record
|
|
75
|
+
* after it has been registered. Previously Registrars had this permission.
|
|
76
|
+
*/
|
|
77
|
+
RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
|
|
78
|
+
// correct
|
|
79
|
+
RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
|
|
80
|
+
RECORD_REGISTRATION_CORRECT: "record.registration-correct",
|
|
81
|
+
RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
|
|
82
|
+
RECORD_REJECT_REGISTRATION: "record.reject-registration",
|
|
83
|
+
// search
|
|
84
|
+
SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
|
|
85
|
+
SEARCH_BIRTH: "search.birth",
|
|
86
|
+
SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
|
|
87
|
+
SEARCH_DEATH: "search.death",
|
|
88
|
+
SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
|
|
89
|
+
SEARCH_MARRIAGE: "search.marriage",
|
|
90
|
+
// audit v1.8
|
|
91
|
+
RECORD_READ: "record.read",
|
|
92
|
+
// profile
|
|
93
|
+
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
|
94
|
+
// performance
|
|
95
|
+
PERFORMANCE_READ: "performance.read",
|
|
96
|
+
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
|
97
|
+
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
|
98
|
+
// organisation
|
|
99
|
+
ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
|
|
100
|
+
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
|
101
|
+
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
|
102
|
+
// user
|
|
103
|
+
USER_READ: "user.read:all",
|
|
104
|
+
USER_READ_MY_OFFICE: "user.read:my-office",
|
|
105
|
+
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
|
106
|
+
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
|
107
|
+
//v1.8
|
|
108
|
+
USER_CREATE: "user.create:all",
|
|
109
|
+
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
|
110
|
+
USER_UPDATE: "user.update:all",
|
|
111
|
+
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
|
|
112
|
+
// config
|
|
113
|
+
CONFIG_UPDATE_ALL: "config.update:all",
|
|
114
|
+
// data seeding
|
|
115
|
+
USER_DATA_SEEDING: "user.data-seeding"
|
|
94
116
|
};
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
);
|
|
101
|
-
var UserFilter = z3.enum(["user"]).describe("Filters based on the user. Limits to self.");
|
|
102
|
-
var RecordScopeTypeV2 = z3.enum([
|
|
103
|
-
"record.search",
|
|
104
|
-
"record.create",
|
|
105
|
-
"record.read",
|
|
106
|
-
"record.declare",
|
|
107
|
-
"record.notify",
|
|
108
|
-
"record.edit",
|
|
109
|
-
"record.reject",
|
|
110
|
-
"record.archive",
|
|
111
|
-
"record.review-duplicates",
|
|
112
|
-
"record.register",
|
|
113
|
-
"record.print-certified-copies",
|
|
114
|
-
"record.request-correction",
|
|
115
|
-
"record.correct",
|
|
116
|
-
"record.unassign-others",
|
|
117
|
-
"record.custom-action"
|
|
117
|
+
var LegacyScopes = import_zod.z.union([
|
|
118
|
+
import_zod.z.literal(SCOPES.BYPASSRATELIMIT),
|
|
119
|
+
import_zod.z.literal(SCOPES.REGISTER),
|
|
120
|
+
import_zod.z.literal(SCOPES.DEMO),
|
|
121
|
+
import_zod.z.literal(SCOPES.CONFIG)
|
|
118
122
|
]);
|
|
119
|
-
var
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"integration.create",
|
|
125
|
-
"record.import",
|
|
126
|
-
"config.update-all",
|
|
127
|
-
"attachment.upload",
|
|
128
|
-
"profile.electronic-signature",
|
|
129
|
-
"user.read-only-my-audit",
|
|
130
|
-
// Performance dashboard
|
|
131
|
-
"performance.read",
|
|
132
|
-
"performance.read-dashboards",
|
|
133
|
-
"performance.vital-statistics-export",
|
|
134
|
-
// Scopes used exclusively by countryconfig integration token
|
|
135
|
-
"record.confirm-registration",
|
|
136
|
-
"record.reject-registration"
|
|
123
|
+
var IntegrationScopes = import_zod.z.union([
|
|
124
|
+
import_zod.z.literal(SCOPES.WEBHOOK),
|
|
125
|
+
import_zod.z.literal(SCOPES.NATIONALID),
|
|
126
|
+
import_zod.z.literal(SCOPES.NOTIFICATION_API),
|
|
127
|
+
import_zod.z.literal(SCOPES.RECORDSEARCH)
|
|
137
128
|
]);
|
|
138
|
-
var
|
|
139
|
-
(
|
|
140
|
-
|
|
141
|
-
)
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
129
|
+
var InternalOperationsScopes = import_zod.z.union([
|
|
130
|
+
import_zod.z.literal(SCOPES.RECORD_REINDEX),
|
|
131
|
+
import_zod.z.literal(SCOPES.RECORD_IMPORT)
|
|
132
|
+
]);
|
|
133
|
+
var DeclareScopes = import_zod.z.union([
|
|
134
|
+
import_zod.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
|
|
135
|
+
import_zod.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
|
|
136
|
+
import_zod.z.literal(SCOPES.RECORD_DECLARE_DEATH),
|
|
137
|
+
import_zod.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
|
|
138
|
+
import_zod.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
|
|
139
|
+
import_zod.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
|
|
140
|
+
import_zod.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
|
|
141
|
+
import_zod.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW)
|
|
142
|
+
]);
|
|
143
|
+
var UnassignScope = import_zod.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS);
|
|
144
|
+
var ValidateScopes = import_zod.z.union([
|
|
145
|
+
import_zod.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
|
|
146
|
+
import_zod.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
|
|
147
|
+
import_zod.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
|
|
148
|
+
import_zod.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
|
|
149
|
+
import_zod.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
|
|
150
|
+
import_zod.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE)
|
|
151
|
+
]);
|
|
152
|
+
var RegisterScope = import_zod.z.literal(SCOPES.RECORD_REGISTER);
|
|
153
|
+
var CorrectionScopes = import_zod.z.union([
|
|
154
|
+
import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
|
|
155
|
+
import_zod.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
|
|
156
|
+
import_zod.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
|
|
157
|
+
import_zod.z.literal(SCOPES.RECORD_REJECT_REGISTRATION)
|
|
158
|
+
]);
|
|
159
|
+
var SearchScopes = import_zod.z.union([
|
|
160
|
+
import_zod.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
|
|
161
|
+
import_zod.z.literal(SCOPES.SEARCH_BIRTH),
|
|
162
|
+
import_zod.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
|
|
163
|
+
import_zod.z.literal(SCOPES.SEARCH_DEATH),
|
|
164
|
+
import_zod.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
|
|
165
|
+
import_zod.z.literal(SCOPES.SEARCH_MARRIAGE)
|
|
166
|
+
]);
|
|
167
|
+
var AuditScopes = import_zod.z.literal(SCOPES.RECORD_READ);
|
|
168
|
+
var PerformanceScopes = import_zod.z.union([
|
|
169
|
+
import_zod.z.literal(SCOPES.PERFORMANCE_READ),
|
|
170
|
+
import_zod.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
|
|
171
|
+
import_zod.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS)
|
|
172
|
+
]);
|
|
173
|
+
var OrganisationScopes = import_zod.z.union([
|
|
174
|
+
import_zod.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
|
|
175
|
+
import_zod.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
|
|
176
|
+
import_zod.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION)
|
|
177
|
+
]);
|
|
178
|
+
var UserScopes = import_zod.z.union([
|
|
179
|
+
import_zod.z.literal(SCOPES.USER_READ),
|
|
180
|
+
import_zod.z.literal(SCOPES.USER_READ_MY_OFFICE),
|
|
181
|
+
import_zod.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
|
|
182
|
+
import_zod.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
|
|
183
|
+
import_zod.z.literal(SCOPES.USER_CREATE),
|
|
184
|
+
import_zod.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
|
|
185
|
+
import_zod.z.literal(SCOPES.USER_UPDATE),
|
|
186
|
+
import_zod.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION)
|
|
187
|
+
]);
|
|
188
|
+
var ConfigScope = import_zod.z.literal(SCOPES.CONFIG_UPDATE_ALL);
|
|
189
|
+
var DataSeedingScope = import_zod.z.literal(SCOPES.USER_DATA_SEEDING);
|
|
190
|
+
var LiteralScopes = import_zod.z.union([
|
|
191
|
+
LegacyScopes,
|
|
192
|
+
IntegrationScopes,
|
|
193
|
+
UnassignScope,
|
|
194
|
+
DeclareScopes,
|
|
195
|
+
ValidateScopes,
|
|
196
|
+
RegisterScope,
|
|
197
|
+
import_zod.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
|
|
198
|
+
CorrectionScopes,
|
|
199
|
+
SearchScopes,
|
|
200
|
+
AuditScopes,
|
|
201
|
+
import_zod.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
|
|
202
|
+
PerformanceScopes,
|
|
203
|
+
OrganisationScopes,
|
|
204
|
+
UserScopes,
|
|
205
|
+
ConfigScope,
|
|
206
|
+
DataSeedingScope,
|
|
207
|
+
InternalOperationsScopes
|
|
208
|
+
]);
|
|
209
|
+
var rawConfigurableScopeRegex = /^([a-zA-Z][a-zA-Z0-9.-]*(?:\.[a-zA-Z0-9.-]+)*)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
|
|
210
|
+
var rawConfigurableScope = import_zod.z.string().regex(rawConfigurableScopeRegex);
|
|
211
|
+
var CreateUserScope = import_zod.z.object({
|
|
212
|
+
type: import_zod.z.literal("user.create"),
|
|
213
|
+
options: import_zod.z.object({
|
|
214
|
+
role: import_zod.z.array(import_zod.z.string())
|
|
215
|
+
})
|
|
161
216
|
});
|
|
162
|
-
var
|
|
163
|
-
|
|
217
|
+
var EditUserScope = import_zod.z.object({
|
|
218
|
+
type: import_zod.z.literal("user.edit"),
|
|
219
|
+
options: import_zod.z.object({
|
|
220
|
+
role: import_zod.z.array(import_zod.z.string())
|
|
221
|
+
})
|
|
164
222
|
});
|
|
165
|
-
var
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
)
|
|
223
|
+
var WorkqueueScope = import_zod.z.object({
|
|
224
|
+
type: import_zod.z.literal("workqueue"),
|
|
225
|
+
options: import_zod.z.object({
|
|
226
|
+
id: import_zod.z.array(import_zod.z.string())
|
|
227
|
+
})
|
|
170
228
|
});
|
|
171
|
-
var
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
229
|
+
var SearchScope = import_zod.z.object({
|
|
230
|
+
type: import_zod.z.literal("search"),
|
|
231
|
+
options: import_zod.z.object({
|
|
232
|
+
event: import_zod.z.array(import_zod.z.string()).length(1),
|
|
233
|
+
access: import_zod.z.array(import_zod.z.enum(["my-jurisdiction", "all"])).length(1)
|
|
234
|
+
})
|
|
175
235
|
});
|
|
176
|
-
var
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}).describe(
|
|
187
|
-
"Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
|
|
188
|
-
);
|
|
189
|
-
var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
|
|
190
|
-
registeredIn: UUID.nullish(),
|
|
191
|
-
registeredBy: z3.string().optional()
|
|
192
|
-
}).describe(
|
|
193
|
-
"Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
|
|
194
|
-
);
|
|
195
|
-
var ScopesWithPlaceEventOptions = RecordScopeTypeV2.extract([
|
|
236
|
+
var PrintCertifiedCopiesScope = import_zod.z.object({
|
|
237
|
+
type: import_zod.z.literal("record.registered.print-certified-copies"),
|
|
238
|
+
options: import_zod.z.object({
|
|
239
|
+
event: import_zod.z.array(import_zod.z.string()).describe("Event type, e.g. birth, death"),
|
|
240
|
+
templates: import_zod.z.array(import_zod.z.string()).optional().describe(
|
|
241
|
+
"Template IDs for certified copies. If not provided, all templates will be used."
|
|
242
|
+
)
|
|
243
|
+
})
|
|
244
|
+
});
|
|
245
|
+
var RecordScopeType = import_zod.z.enum([
|
|
196
246
|
"record.create",
|
|
197
|
-
"record.declare",
|
|
198
|
-
"record.notify"
|
|
199
|
-
]);
|
|
200
|
-
var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
|
|
201
|
-
"record.edit",
|
|
202
|
-
"record.reject",
|
|
203
|
-
"record.archive",
|
|
204
|
-
"record.review-duplicates",
|
|
205
|
-
"record.register"
|
|
206
|
-
]);
|
|
207
|
-
var ScopesWithFullOptions = RecordScopeTypeV2.extract([
|
|
208
|
-
"record.search",
|
|
209
247
|
"record.read",
|
|
210
|
-
"record.
|
|
211
|
-
"record.
|
|
248
|
+
"record.declare",
|
|
249
|
+
"record.notify",
|
|
250
|
+
"record.declared.validate",
|
|
251
|
+
"record.declared.reject",
|
|
252
|
+
"record.declared.archive",
|
|
253
|
+
"record.declared.review-duplicates",
|
|
254
|
+
"record.register",
|
|
255
|
+
"record.registered.request-correction",
|
|
256
|
+
"record.registered.correct",
|
|
212
257
|
"record.unassign-others"
|
|
213
258
|
]);
|
|
214
|
-
var
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
).describe(
|
|
219
|
-
"Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
|
|
220
|
-
)
|
|
221
|
-
});
|
|
222
|
-
var RecordScopeV2 = z3.discriminatedUnion("type", [
|
|
223
|
-
z3.object({
|
|
224
|
-
type: ScopesWithPlaceEventOptions,
|
|
225
|
-
options: scopeOptionsPlaceEvent.optional()
|
|
226
|
-
}),
|
|
227
|
-
z3.object({
|
|
228
|
-
type: ScopesWithDeclaredOptions,
|
|
229
|
-
options: scopeOptionsDeclared.optional()
|
|
230
|
-
}),
|
|
231
|
-
z3.object({
|
|
232
|
-
type: ScopesWithFullOptions,
|
|
233
|
-
options: AllRecordScopeOptions.optional()
|
|
234
|
-
}),
|
|
235
|
-
z3.object({
|
|
236
|
-
type: z3.literal("record.custom-action"),
|
|
237
|
-
options: CustomActionScopeOptions.optional()
|
|
238
|
-
}),
|
|
239
|
-
z3.object({
|
|
240
|
-
type: z3.literal("record.print-certified-copies"),
|
|
241
|
-
options: ScopeOptionsPrintCertifiedCopies.optional()
|
|
259
|
+
var RecordScope = import_zod.z.object({
|
|
260
|
+
type: RecordScopeType,
|
|
261
|
+
options: import_zod.z.object({
|
|
262
|
+
event: import_zod.z.array(import_zod.z.string()).describe("Event type, e.g. birth, death")
|
|
242
263
|
})
|
|
243
|
-
|
|
264
|
+
}).describe(
|
|
244
265
|
"Scopes used to check user's permission to perform actions on a record."
|
|
245
266
|
);
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
return scope.type === "record.print-certified-copies";
|
|
254
|
-
}
|
|
255
|
-
function isCustomActionScope(scope) {
|
|
256
|
-
return scope.type === "record.custom-action";
|
|
257
|
-
}
|
|
258
|
-
var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
259
|
-
z3.object({
|
|
260
|
-
type: ScopesWithPlaceEventOptions,
|
|
261
|
-
options: ResolvedScopeOptionsPlaceEvent.optional()
|
|
262
|
-
}),
|
|
263
|
-
z3.object({
|
|
264
|
-
type: ScopesWithDeclaredOptions,
|
|
265
|
-
options: ResolvedScopeOptionsDeclared.optional()
|
|
266
|
-
}),
|
|
267
|
-
z3.object({
|
|
268
|
-
type: ScopesWithFullOptions,
|
|
269
|
-
options: ResolvedScopeOptionsFull.optional()
|
|
270
|
-
}),
|
|
271
|
-
z3.object({
|
|
272
|
-
type: z3.literal("record.print-certified-copies"),
|
|
273
|
-
options: ResolvedScopeOptionsFull.extend({
|
|
274
|
-
templates: z3.array(z3.string()).optional()
|
|
275
|
-
}).optional()
|
|
276
|
-
})
|
|
277
|
-
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
278
|
-
var SystemScopeType = z3.enum([
|
|
279
|
-
"organisation.read-locations",
|
|
280
|
-
"user.read",
|
|
281
|
-
"user.create",
|
|
282
|
-
"user.edit"
|
|
267
|
+
var ConfigurableRawScopes = import_zod.z.discriminatedUnion("type", [
|
|
268
|
+
SearchScope,
|
|
269
|
+
PrintCertifiedCopiesScope,
|
|
270
|
+
CreateUserScope,
|
|
271
|
+
EditUserScope,
|
|
272
|
+
WorkqueueScope,
|
|
273
|
+
RecordScope
|
|
283
274
|
]);
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
...SystemScopeType.options,
|
|
299
|
-
...RecordScopeTypeV2.options,
|
|
300
|
-
...PlainScopeType.options,
|
|
301
|
-
"workqueue",
|
|
302
|
-
"dashboard.view"
|
|
303
|
-
]);
|
|
304
|
-
var flattenScope = (scope) => ({
|
|
305
|
-
type: scope.type,
|
|
306
|
-
..."options" in scope ? scope.options : {}
|
|
307
|
-
});
|
|
308
|
-
var unflattenScope = (input) => {
|
|
309
|
-
const { type, ...options } = input;
|
|
310
|
-
return { type, options };
|
|
311
|
-
};
|
|
312
|
-
var EncodedScope2 = z3.string().brand("EncodedScope");
|
|
313
|
-
var encodeScope = (scope) => {
|
|
314
|
-
const flattened = flattenScope(scope);
|
|
315
|
-
return qs.stringify(flattened, {
|
|
316
|
-
arrayFormat: "comma",
|
|
317
|
-
allowDots: true,
|
|
318
|
-
addQueryPrefix: false,
|
|
319
|
-
encode: false
|
|
320
|
-
});
|
|
321
|
-
};
|
|
322
|
-
var decodeScope = (query) => {
|
|
323
|
-
const scope = qs.parse(query, {
|
|
324
|
-
ignoreQueryPrefix: true,
|
|
325
|
-
comma: true,
|
|
326
|
-
allowDots: true
|
|
327
|
-
});
|
|
328
|
-
const unflattenedScope = unflattenScope(scope);
|
|
329
|
-
return Scope2.safeParse(unflattenedScope)?.data;
|
|
330
|
-
};
|
|
331
|
-
var DEFAULT_SCOPE_OPTIONS = {
|
|
332
|
-
placeOfEvent: JurisdictionFilter.enum.all,
|
|
333
|
-
accessLevel: JurisdictionFilter.enum.all
|
|
334
|
-
};
|
|
335
|
-
function getScopeOptionValue(scope, option) {
|
|
336
|
-
const options = "options" in scope ? scope.options : void 0;
|
|
337
|
-
const value = options?.[option];
|
|
338
|
-
const defaultValue = option in DEFAULT_SCOPE_OPTIONS ? DEFAULT_SCOPE_OPTIONS[option] : void 0;
|
|
339
|
-
return value ?? defaultValue;
|
|
275
|
+
function flattenAndMergeScopes(scopes2) {
|
|
276
|
+
if (scopes2.length === 0) return null;
|
|
277
|
+
const type = scopes2[0].type;
|
|
278
|
+
const mergedOptions = {};
|
|
279
|
+
for (const scope of scopes2) {
|
|
280
|
+
const entries = Object.entries(scope.options);
|
|
281
|
+
if (entries.length < 2) continue;
|
|
282
|
+
const sourceValues = entries[0][1];
|
|
283
|
+
const targetValues = entries[1][1];
|
|
284
|
+
for (let i = 0; i < sourceValues.length; i++) {
|
|
285
|
+
mergedOptions[sourceValues[i]] = targetValues[i];
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return { type, options: mergedOptions };
|
|
340
289
|
}
|
|
341
|
-
function
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
) ? parsedScope : null;
|
|
350
|
-
}).filter((scope) => scope !== null);
|
|
290
|
+
function findScope(scopes2, scopeType) {
|
|
291
|
+
const parsedScopes = scopes2.map(parseConfigurableScope);
|
|
292
|
+
const searchScopes = parsedScopes.filter((scope) => scope?.type === "search");
|
|
293
|
+
const otherScopes = parsedScopes.filter((scope) => scope?.type !== "search");
|
|
294
|
+
const mergedSearchScope = flattenAndMergeScopes(searchScopes);
|
|
295
|
+
return [...otherScopes, mergedSearchScope].find(
|
|
296
|
+
(scope) => scope?.type === scopeType
|
|
297
|
+
);
|
|
351
298
|
}
|
|
352
|
-
function
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
});
|
|
358
|
-
return foundScopes.length > 0;
|
|
299
|
+
function getScopeOptions(rawOptions) {
|
|
300
|
+
return rawOptions.split(",").reduce((acc, option) => {
|
|
301
|
+
const [key, value] = option.split("=");
|
|
302
|
+
acc[key] = value.split("|");
|
|
303
|
+
return acc;
|
|
304
|
+
}, {});
|
|
359
305
|
}
|
|
360
|
-
function
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
scopes: tokenOrScopes
|
|
365
|
-
}).length > 0;
|
|
306
|
+
function parseConfigurableScope(scope) {
|
|
307
|
+
const maybeConfigurableScope = rawConfigurableScope.safeParse(scope);
|
|
308
|
+
if (!maybeConfigurableScope.success) {
|
|
309
|
+
return;
|
|
366
310
|
}
|
|
367
|
-
|
|
311
|
+
const rawScope = maybeConfigurableScope.data;
|
|
312
|
+
const [, type, rawOptions] = rawScope.match(rawConfigurableScopeRegex) ?? [];
|
|
313
|
+
const options = getScopeOptions(rawOptions);
|
|
314
|
+
const parsedScope = {
|
|
315
|
+
type,
|
|
316
|
+
options
|
|
317
|
+
};
|
|
318
|
+
const result = ConfigurableRawScopes.safeParse(parsedScope);
|
|
319
|
+
return result.success ? result.data : void 0;
|
|
368
320
|
}
|
|
369
|
-
function
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
378
|
-
return scope.options?.event?.includes(eventType);
|
|
379
|
-
});
|
|
321
|
+
function parseLiteralScope(scope) {
|
|
322
|
+
const maybeLiteralScope = LiteralScopes.safeParse(scope);
|
|
323
|
+
if (maybeLiteralScope.success) {
|
|
324
|
+
return {
|
|
325
|
+
type: maybeLiteralScope.data
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
return;
|
|
380
329
|
}
|
|
381
|
-
function
|
|
382
|
-
|
|
330
|
+
function stringifyScope(scope) {
|
|
331
|
+
const options = Object.entries(scope.options).map(([key, value]) => `${key}=${value.join("|")}`).join(",");
|
|
332
|
+
return `${scope.type}[${options}]`;
|
|
383
333
|
}
|
|
384
|
-
function
|
|
385
|
-
return
|
|
334
|
+
function getAuthorizedEventsFromScopes(scopes2) {
|
|
335
|
+
return scopes2.flatMap(({ options }) => {
|
|
336
|
+
if (options && "event" in options) {
|
|
337
|
+
return options.event;
|
|
338
|
+
}
|
|
339
|
+
return void 0;
|
|
340
|
+
}).filter((event) => event !== void 0).filter((event, index, self) => self.indexOf(event) === index);
|
|
386
341
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
342
|
+
var scopes = Object.values(SCOPES);
|
|
343
|
+
var ActionScopes = import_zod.z.union([
|
|
344
|
+
DeclareScopes,
|
|
345
|
+
ValidateScopes,
|
|
346
|
+
RegisterScope,
|
|
347
|
+
import_zod.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
|
|
348
|
+
CorrectionScopes
|
|
349
|
+
]);
|