@approvio/api 0.0.29 → 0.0.31
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 +12 -1
- package/dist/mocks/index.cjs +137 -0
- package/dist/mocks/index.d.cts +44 -0
- package/dist/mocks/index.d.mts +44 -0
- package/dist/mocks/index.mjs +118 -0
- package/dist/src/index.cjs +1494 -0
- package/dist/src/index.d.cts +1434 -0
- package/dist/src/index.d.mts +1434 -0
- package/dist/src/index.mjs +1356 -0
- package/dist/workflow-create-DVgNnx0X.d.mts +506 -0
- package/dist/workflow-create-Dgj7wWZs.d.cts +506 -0
- package/package.json +54 -13
- package/dist/add-group-entities-request.d.ts +0 -21
- package/dist/add-group-entities-request.js +0 -3
- package/dist/add-group-entities-request.js.map +0 -1
- package/dist/agent-challenge-request.d.ts +0 -17
- package/dist/agent-challenge-request.js +0 -14
- package/dist/agent-challenge-request.js.map +0 -1
- package/dist/agent-challenge-response.d.ts +0 -17
- package/dist/agent-challenge-response.js +0 -14
- package/dist/agent-challenge-response.js.map +0 -1
- package/dist/agent-get200-response.d.ts +0 -29
- package/dist/agent-get200-response.js +0 -14
- package/dist/agent-get200-response.js.map +0 -1
- package/dist/agent-public-details.d.ts +0 -29
- package/dist/agent-public-details.js +0 -14
- package/dist/agent-public-details.js.map +0 -1
- package/dist/agent-registration-request.d.ts +0 -17
- package/dist/agent-registration-request.js +0 -14
- package/dist/agent-registration-request.js.map +0 -1
- package/dist/agent-registration-response.d.ts +0 -33
- package/dist/agent-registration-response.js +0 -14
- package/dist/agent-registration-response.js.map +0 -1
- package/dist/agent-summary.d.ts +0 -21
- package/dist/agent-summary.js +0 -14
- package/dist/agent-summary.js.map +0 -1
- package/dist/agent-token-request.d.ts +0 -35
- package/dist/agent-token-request.js +0 -24
- package/dist/agent-token-request.js.map +0 -1
- package/dist/agent-token-response.d.ts +0 -21
- package/dist/agent-token-response.js +0 -14
- package/dist/agent-token-response.js.map +0 -1
- package/dist/and-rule.d.ts +0 -31
- package/dist/and-rule.js +0 -10
- package/dist/and-rule.js.map +0 -1
- package/dist/api-error-details-inner.d.ts +0 -15
- package/dist/api-error-details-inner.js +0 -14
- package/dist/api-error-details-inner.js.map +0 -1
- package/dist/api-error.d.ts +0 -23
- package/dist/api-error.js +0 -3
- package/dist/api-error.js.map +0 -1
- package/dist/approval-rule.d.ts +0 -23
- package/dist/approval-rule.js +0 -3
- package/dist/approval-rule.js.map +0 -1
- package/dist/auth-message-response.d.ts +0 -29
- package/dist/auth-message-response.js +0 -14
- package/dist/auth-message-response.js.map +0 -1
- package/dist/bound-role.d.ts +0 -34
- package/dist/bound-role.js +0 -3
- package/dist/bound-role.js.map +0 -1
- package/dist/can-vote-response.d.ts +0 -29
- package/dist/can-vote-response.js +0 -14
- package/dist/can-vote-response.js.map +0 -1
- package/dist/email-action.d.ts +0 -30
- package/dist/email-action.js +0 -21
- package/dist/email-action.js.map +0 -1
- package/dist/entity-membership-add.d.ts +0 -15
- package/dist/entity-membership-add.js +0 -3
- package/dist/entity-membership-add.js.map +0 -1
- package/dist/entity-membership-remove.d.ts +0 -15
- package/dist/entity-membership-remove.js +0 -3
- package/dist/entity-membership-remove.js.map +0 -1
- package/dist/entity-reference.d.ts +0 -21
- package/dist/entity-reference.js +0 -14
- package/dist/entity-reference.js.map +0 -1
- package/dist/failed-auth-response.d.ts +0 -17
- package/dist/failed-auth-response.js +0 -14
- package/dist/failed-auth-response.js.map +0 -1
- package/dist/get-entity-info-200-response.d.ts +0 -19
- package/dist/get-entity-info-200-response.js +0 -3
- package/dist/get-entity-info-200-response.js.map +0 -1
- package/dist/get-user-info-200-response.d.ts +0 -19
- package/dist/get-user-info-200-response.js +0 -3
- package/dist/get-user-info-200-response.js.map +0 -1
- package/dist/get-workflow-params.d.ts +0 -17
- package/dist/get-workflow-params.js +0 -14
- package/dist/get-workflow-params.js.map +0 -1
- package/dist/get-workflow-votes-200-response.d.ts +0 -15
- package/dist/get-workflow-votes-200-response.js +0 -3
- package/dist/get-workflow-votes-200-response.js.map +0 -1
- package/dist/group-create.d.ts +0 -21
- package/dist/group-create.js +0 -14
- package/dist/group-create.js.map +0 -1
- package/dist/group-info.d.ts +0 -15
- package/dist/group-info.js +0 -14
- package/dist/group-info.js.map +0 -1
- package/dist/group-membership.d.ts +0 -19
- package/dist/group-membership.js +0 -3
- package/dist/group-membership.js.map +0 -1
- package/dist/group-requirement-rule.d.ts +0 -38
- package/dist/group-requirement-rule.js +0 -21
- package/dist/group-requirement-rule.js.map +0 -1
- package/dist/group-scope.d.ts +0 -30
- package/dist/group-scope.js +0 -21
- package/dist/group-scope.js.map +0 -1
- package/dist/group.d.ts +0 -37
- package/dist/group.js +0 -14
- package/dist/group.js.map +0 -1
- package/dist/health-response.d.ts +0 -21
- package/dist/health-response.js +0 -14
- package/dist/health-response.js.map +0 -1
- package/dist/index.d.ts +0 -99
- package/dist/index.html +0 -1274
- package/dist/index.js +0 -117
- package/dist/index.js.map +0 -1
- package/dist/initiate-cli-login-200-response.d.ts +0 -14
- package/dist/initiate-cli-login-200-response.js +0 -14
- package/dist/initiate-cli-login-200-response.js.map +0 -1
- package/dist/initiate-cli-login-request.d.ts +0 -17
- package/dist/initiate-cli-login-request.js +0 -14
- package/dist/initiate-cli-login-request.js.map +0 -1
- package/dist/list-agents-200-response.d.ts +0 -17
- package/dist/list-agents-200-response.js +0 -3
- package/dist/list-agents-200-response.js.map +0 -1
- package/dist/list-agents-params.d.ts +0 -21
- package/dist/list-agents-params.js +0 -14
- package/dist/list-agents-params.js.map +0 -1
- package/dist/list-group-entities-200-response.d.ts +0 -17
- package/dist/list-group-entities-200-response.js +0 -3
- package/dist/list-group-entities-200-response.js.map +0 -1
- package/dist/list-groups-200-response.d.ts +0 -17
- package/dist/list-groups-200-response.js +0 -3
- package/dist/list-groups-200-response.js.map +0 -1
- package/dist/list-organization-admins-200-response.d.ts +0 -17
- package/dist/list-organization-admins-200-response.js +0 -3
- package/dist/list-organization-admins-200-response.js.map +0 -1
- package/dist/list-organization-admins-for-org-200-response.d.ts +0 -17
- package/dist/list-organization-admins-for-org-200-response.js +0 -3
- package/dist/list-organization-admins-for-org-200-response.js.map +0 -1
- package/dist/list-role-templates-200-response.d.ts +0 -15
- package/dist/list-role-templates-200-response.js +0 -3
- package/dist/list-role-templates-200-response.js.map +0 -1
- package/dist/list-spaces-200-response.d.ts +0 -17
- package/dist/list-spaces-200-response.js +0 -3
- package/dist/list-spaces-200-response.js.map +0 -1
- package/dist/list-users-200-response.d.ts +0 -17
- package/dist/list-users-200-response.js +0 -3
- package/dist/list-users-200-response.js.map +0 -1
- package/dist/list-workflow-templates-200-response.d.ts +0 -17
- package/dist/list-workflow-templates-200-response.js +0 -3
- package/dist/list-workflow-templates-200-response.js.map +0 -1
- package/dist/list-workflow-templates-params.d.ts +0 -25
- package/dist/list-workflow-templates-params.js +0 -14
- package/dist/list-workflow-templates-params.js.map +0 -1
- package/dist/list-workflows-200-response.d.ts +0 -17
- package/dist/list-workflows-200-response.js +0 -3
- package/dist/list-workflows-200-response.js.map +0 -1
- package/dist/list-workflows-params.d.ts +0 -33
- package/dist/list-workflows-params.js +0 -14
- package/dist/list-workflows-params.js.map +0 -1
- package/dist/models.d.ts +0 -86
- package/dist/models.js +0 -103
- package/dist/models.js.map +0 -1
- package/dist/oidc-callback-request.d.ts +0 -21
- package/dist/oidc-callback-request.js +0 -14
- package/dist/oidc-callback-request.js.map +0 -1
- package/dist/or-rule.d.ts +0 -31
- package/dist/or-rule.js +0 -10
- package/dist/or-rule.js.map +0 -1
- package/dist/org-scope.d.ts +0 -26
- package/dist/org-scope.js +0 -21
- package/dist/org-scope.js.map +0 -1
- package/dist/organization-admin-create.d.ts +0 -17
- package/dist/organization-admin-create.js +0 -14
- package/dist/organization-admin-create.js.map +0 -1
- package/dist/organization-admin-remove.d.ts +0 -17
- package/dist/organization-admin-remove.js +0 -14
- package/dist/organization-admin-remove.js.map +0 -1
- package/dist/organization-admin.d.ts +0 -25
- package/dist/organization-admin.js +0 -14
- package/dist/organization-admin.js.map +0 -1
- package/dist/pagination.d.ts +0 -25
- package/dist/pagination.js +0 -14
- package/dist/pagination.js.map +0 -1
- package/dist/privileged-token-exchange-request.d.ts +0 -29
- package/dist/privileged-token-exchange-request.js +0 -14
- package/dist/privileged-token-exchange-request.js.map +0 -1
- package/dist/privileged-token-response.d.ts +0 -17
- package/dist/privileged-token-response.js +0 -14
- package/dist/privileged-token-response.js.map +0 -1
- package/dist/refresh-token-request.d.ts +0 -17
- package/dist/refresh-token-request.js +0 -14
- package/dist/refresh-token-request.js.map +0 -1
- package/dist/remove-group-entities-request.d.ts +0 -21
- package/dist/remove-group-entities-request.js +0 -3
- package/dist/remove-group-entities-request.js.map +0 -1
- package/dist/role-assignment-item.d.ts +0 -22
- package/dist/role-assignment-item.js +0 -3
- package/dist/role-assignment-item.js.map +0 -1
- package/dist/role-assignment-request.d.ts +0 -21
- package/dist/role-assignment-request.js +0 -3
- package/dist/role-assignment-request.js.map +0 -1
- package/dist/role-operation-item.d.ts +0 -22
- package/dist/role-operation-item.js +0 -3
- package/dist/role-operation-item.js.map +0 -1
- package/dist/role-operation-request.d.ts +0 -21
- package/dist/role-operation-request.js +0 -3
- package/dist/role-operation-request.js.map +0 -1
- package/dist/role-removal-request.d.ts +0 -21
- package/dist/role-removal-request.js +0 -3
- package/dist/role-removal-request.js.map +0 -1
- package/dist/role-scope.d.ts +0 -24
- package/dist/role-scope.js +0 -3
- package/dist/role-scope.js.map +0 -1
- package/dist/role-template.d.ts +0 -25
- package/dist/role-template.js +0 -14
- package/dist/role-template.js.map +0 -1
- package/dist/role.d.ts +0 -26
- package/dist/role.js +0 -3
- package/dist/role.js.map +0 -1
- package/dist/space-create.d.ts +0 -21
- package/dist/space-create.js +0 -14
- package/dist/space-create.js.map +0 -1
- package/dist/space-scope.d.ts +0 -30
- package/dist/space-scope.js +0 -21
- package/dist/space-scope.js.map +0 -1
- package/dist/space.d.ts +0 -33
- package/dist/space.js +0 -14
- package/dist/space.js.map +0 -1
- package/dist/step-up-operation.d.ts +0 -19
- package/dist/step-up-operation.js +0 -19
- package/dist/step-up-operation.js.map +0 -1
- package/dist/step-up-token-request.d.ts +0 -25
- package/dist/step-up-token-request.js +0 -3
- package/dist/step-up-token-request.js.map +0 -1
- package/dist/successful-auth-response.d.ts +0 -29
- package/dist/successful-auth-response.js +0 -14
- package/dist/successful-auth-response.js.map +0 -1
- package/dist/token-request.d.ts +0 -21
- package/dist/token-request.js +0 -14
- package/dist/token-request.js.map +0 -1
- package/dist/token-response.d.ts +0 -21
- package/dist/token-response.js +0 -14
- package/dist/token-response.js.map +0 -1
- package/dist/user-create.d.ts +0 -25
- package/dist/user-create.js +0 -14
- package/dist/user-create.js.map +0 -1
- package/dist/user-summary.d.ts +0 -25
- package/dist/user-summary.js +0 -14
- package/dist/user-summary.js.map +0 -1
- package/dist/user.d.ts +0 -33
- package/dist/user.js +0 -14
- package/dist/user.js.map +0 -1
- package/dist/vote-approve.d.ts +0 -27
- package/dist/vote-approve.js +0 -21
- package/dist/vote-approve.js.map +0 -1
- package/dist/vote-mode.d.ts +0 -17
- package/dist/vote-mode.js +0 -14
- package/dist/vote-mode.js.map +0 -1
- package/dist/vote-veto.d.ts +0 -23
- package/dist/vote-veto.js +0 -21
- package/dist/vote-veto.js.map +0 -1
- package/dist/vote-withdraw.d.ts +0 -23
- package/dist/vote-withdraw.js +0 -21
- package/dist/vote-withdraw.js.map +0 -1
- package/dist/webhook-action.d.ts +0 -46
- package/dist/webhook-action.js +0 -26
- package/dist/webhook-action.js.map +0 -1
- package/dist/workflow-action.d.ts +0 -22
- package/dist/workflow-action.js +0 -3
- package/dist/workflow-action.js.map +0 -1
- package/dist/workflow-create.d.ts +0 -29
- package/dist/workflow-create.js +0 -14
- package/dist/workflow-create.js.map +0 -1
- package/dist/workflow-include.d.ts +0 -18
- package/dist/workflow-include.js +0 -18
- package/dist/workflow-include.js.map +0 -1
- package/dist/workflow-ref.d.ts +0 -18
- package/dist/workflow-ref.js +0 -3
- package/dist/workflow-ref.js.map +0 -1
- package/dist/workflow-template-create.d.ts +0 -40
- package/dist/workflow-template-create.js +0 -3
- package/dist/workflow-template-create.js.map +0 -1
- package/dist/workflow-template-delete.d.ts +0 -17
- package/dist/workflow-template-delete.js +0 -14
- package/dist/workflow-template-delete.js.map +0 -1
- package/dist/workflow-template-deprecate.d.ts +0 -17
- package/dist/workflow-template-deprecate.js +0 -14
- package/dist/workflow-template-deprecate.js.map +0 -1
- package/dist/workflow-template-scope.d.ts +0 -30
- package/dist/workflow-template-scope.js +0 -21
- package/dist/workflow-template-scope.js.map +0 -1
- package/dist/workflow-template-summary.d.ts +0 -37
- package/dist/workflow-template-summary.js +0 -14
- package/dist/workflow-template-summary.js.map +0 -1
- package/dist/workflow-template-update.d.ts +0 -36
- package/dist/workflow-template-update.js +0 -3
- package/dist/workflow-template-update.js.map +0 -1
- package/dist/workflow-template.d.ts +0 -72
- package/dist/workflow-template.js +0 -12
- package/dist/workflow-template.js.map +0 -1
- package/dist/workflow-vote-request-vote-type.d.ts +0 -19
- package/dist/workflow-vote-request-vote-type.js +0 -3
- package/dist/workflow-vote-request-vote-type.js.map +0 -1
- package/dist/workflow-vote-request.d.ts +0 -19
- package/dist/workflow-vote-request.js +0 -3
- package/dist/workflow-vote-request.js.map +0 -1
- package/dist/workflow-vote.d.ts +0 -37
- package/dist/workflow-vote.js +0 -14
- package/dist/workflow-vote.js.map +0 -1
- package/dist/workflow.d.ts +0 -51
- package/dist/workflow.js +0 -3
- package/dist/workflow.js.map +0 -1
|
@@ -0,0 +1,1356 @@
|
|
|
1
|
+
import { isLeft, isRight, left, right } from "fp-ts/Either";
|
|
2
|
+
//#region generated/openapi/model/agent-token-request.ts
|
|
3
|
+
let AgentTokenRequest;
|
|
4
|
+
(function(_AgentTokenRequest) {
|
|
5
|
+
_AgentTokenRequest.GrantTypeEnum = { UrnietfparamsoauthgrantTypejwtBearer: "urn:ietf:params:oauth:grant-type:jwt-bearer" };
|
|
6
|
+
_AgentTokenRequest.ClientAssertionTypeEnum = { UrnietfparamsoauthclientAssertionTypejwtBearer: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" };
|
|
7
|
+
})(AgentTokenRequest || (AgentTokenRequest = {}));
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region generated/openapi/model/and-rule.ts
|
|
10
|
+
let AndRule;
|
|
11
|
+
(function(_AndRule) {
|
|
12
|
+
_AndRule.TypeEnum = { And: "AND" };
|
|
13
|
+
})(AndRule || (AndRule = {}));
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region generated/openapi/model/email-action.ts
|
|
16
|
+
let EmailAction;
|
|
17
|
+
(function(_EmailAction) {
|
|
18
|
+
_EmailAction.TypeEnum = { Email: "EMAIL" };
|
|
19
|
+
})(EmailAction || (EmailAction = {}));
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region generated/openapi/model/group-requirement-rule.ts
|
|
22
|
+
let GroupRequirementRule;
|
|
23
|
+
(function(_GroupRequirementRule) {
|
|
24
|
+
_GroupRequirementRule.TypeEnum = { GroupRequirement: "GROUP_REQUIREMENT" };
|
|
25
|
+
})(GroupRequirementRule || (GroupRequirementRule = {}));
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region generated/openapi/model/group-scope.ts
|
|
28
|
+
let GroupScope;
|
|
29
|
+
(function(_GroupScope) {
|
|
30
|
+
_GroupScope.TypeEnum = { Group: "group" };
|
|
31
|
+
})(GroupScope || (GroupScope = {}));
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region generated/openapi/model/or-rule.ts
|
|
34
|
+
let OrRule;
|
|
35
|
+
(function(_OrRule) {
|
|
36
|
+
_OrRule.TypeEnum = { Or: "OR" };
|
|
37
|
+
})(OrRule || (OrRule = {}));
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region generated/openapi/model/org-scope.ts
|
|
40
|
+
let OrgScope;
|
|
41
|
+
(function(_OrgScope) {
|
|
42
|
+
_OrgScope.TypeEnum = { Org: "org" };
|
|
43
|
+
})(OrgScope || (OrgScope = {}));
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region generated/openapi/model/space-scope.ts
|
|
46
|
+
let SpaceScope;
|
|
47
|
+
(function(_SpaceScope) {
|
|
48
|
+
_SpaceScope.TypeEnum = { Space: "space" };
|
|
49
|
+
})(SpaceScope || (SpaceScope = {}));
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region generated/openapi/model/vote-approve.ts
|
|
52
|
+
let VoteApprove;
|
|
53
|
+
(function(_VoteApprove) {
|
|
54
|
+
_VoteApprove.TypeEnum = { Approve: "APPROVE" };
|
|
55
|
+
})(VoteApprove || (VoteApprove = {}));
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region generated/openapi/model/vote-veto.ts
|
|
58
|
+
let VoteVeto;
|
|
59
|
+
(function(_VoteVeto) {
|
|
60
|
+
_VoteVeto.TypeEnum = { Veto: "VETO" };
|
|
61
|
+
})(VoteVeto || (VoteVeto = {}));
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region generated/openapi/model/vote-withdraw.ts
|
|
64
|
+
let VoteWithdraw;
|
|
65
|
+
(function(_VoteWithdraw) {
|
|
66
|
+
_VoteWithdraw.TypeEnum = { Withdraw: "WITHDRAW" };
|
|
67
|
+
})(VoteWithdraw || (VoteWithdraw = {}));
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region generated/openapi/model/webhook-action.ts
|
|
70
|
+
let WebhookAction;
|
|
71
|
+
(function(_WebhookAction) {
|
|
72
|
+
_WebhookAction.TypeEnum = { Webhook: "WEBHOOK" };
|
|
73
|
+
_WebhookAction.MethodEnum = {
|
|
74
|
+
Post: "POST",
|
|
75
|
+
Put: "PUT",
|
|
76
|
+
Get: "GET"
|
|
77
|
+
};
|
|
78
|
+
})(WebhookAction || (WebhookAction = {}));
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region generated/openapi/model/workflow-template.ts
|
|
81
|
+
let WorkflowTemplate;
|
|
82
|
+
(function(_WorkflowTemplate) {
|
|
83
|
+
_WorkflowTemplate.StatusEnum = {
|
|
84
|
+
Active: "ACTIVE",
|
|
85
|
+
PendingDeprecation: "PENDING_DEPRECATION",
|
|
86
|
+
Deprecated: "DEPRECATED"
|
|
87
|
+
};
|
|
88
|
+
})(WorkflowTemplate || (WorkflowTemplate = {}));
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region generated/openapi/model/workflow-template-scope.ts
|
|
91
|
+
let WorkflowTemplateScope;
|
|
92
|
+
(function(_WorkflowTemplateScope) {
|
|
93
|
+
_WorkflowTemplateScope.TypeEnum = { WorkflowTemplate: "workflow_template" };
|
|
94
|
+
})(WorkflowTemplateScope || (WorkflowTemplateScope = {}));
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/utils/validation.utils.ts
|
|
97
|
+
function hasOwnProperty(obj, prop) {
|
|
98
|
+
return Object.hasOwn(obj, prop);
|
|
99
|
+
}
|
|
100
|
+
function isNonEmptyString(value) {
|
|
101
|
+
return typeof value === "string" && value.length > 0;
|
|
102
|
+
}
|
|
103
|
+
function isNumber(value) {
|
|
104
|
+
return typeof value === "number" && !isNaN(value);
|
|
105
|
+
}
|
|
106
|
+
function isArray(value) {
|
|
107
|
+
return Array.isArray(value);
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/validators/auth.validators.ts
|
|
111
|
+
function validateTokenResponse(object) {
|
|
112
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
113
|
+
if (!hasOwnProperty(object, "accessToken")) return left("missing_access_token");
|
|
114
|
+
if (!isNonEmptyString(object.accessToken)) return left("invalid_access_token");
|
|
115
|
+
if (!hasOwnProperty(object, "refreshToken")) return left("missing_refresh_token");
|
|
116
|
+
if (!isNonEmptyString(object.refreshToken)) return left("invalid_refresh_token");
|
|
117
|
+
return right({
|
|
118
|
+
accessToken: object.accessToken,
|
|
119
|
+
refreshToken: object.refreshToken
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function validateAgentRegistrationResponse(object) {
|
|
123
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
124
|
+
if (!hasOwnProperty(object, "agentId")) return left("missing_agent_id");
|
|
125
|
+
if (!isNonEmptyString(object.agentId)) return left("invalid_agent_id");
|
|
126
|
+
if (!hasOwnProperty(object, "agentName")) return left("missing_agent_name");
|
|
127
|
+
if (!isNonEmptyString(object.agentName)) return left("invalid_agent_name");
|
|
128
|
+
if (!hasOwnProperty(object, "publicKey")) return left("missing_public_key");
|
|
129
|
+
if (!isNonEmptyString(object.publicKey)) return left("invalid_public_key");
|
|
130
|
+
if (!hasOwnProperty(object, "privateKey")) return left("missing_private_key");
|
|
131
|
+
if (!isNonEmptyString(object.privateKey)) return left("invalid_private_key");
|
|
132
|
+
if (!hasOwnProperty(object, "createdAt")) return left("missing_created_at");
|
|
133
|
+
if (!isNonEmptyString(object.createdAt)) return left("invalid_created_at");
|
|
134
|
+
return right({
|
|
135
|
+
agentId: object.agentId,
|
|
136
|
+
agentName: object.agentName,
|
|
137
|
+
publicKey: object.publicKey,
|
|
138
|
+
privateKey: object.privateKey,
|
|
139
|
+
createdAt: object.createdAt
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function validateTokenRequest(object) {
|
|
143
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
144
|
+
if (!hasOwnProperty(object, "code") || !isNonEmptyString(object.code)) return left(hasOwnProperty(object, "code") ? "invalid_code" : "missing_code");
|
|
145
|
+
if (!hasOwnProperty(object, "state") || !isNonEmptyString(object.state)) return left(hasOwnProperty(object, "state") ? "invalid_state" : "missing_state");
|
|
146
|
+
return right({
|
|
147
|
+
code: object.code,
|
|
148
|
+
state: object.state
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function validateRefreshTokenRequest(object) {
|
|
152
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
153
|
+
if (!hasOwnProperty(object, "refreshToken") || !isNonEmptyString(object.refreshToken)) return left(hasOwnProperty(object, "refreshToken") ? "invalid_refresh_token" : "missing_refresh_token");
|
|
154
|
+
return right({ refreshToken: object.refreshToken });
|
|
155
|
+
}
|
|
156
|
+
function validatePrivilegedTokenExchangeRequest(object) {
|
|
157
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
158
|
+
if (!hasOwnProperty(object, "code") || !isNonEmptyString(object.code)) return left(hasOwnProperty(object, "code") ? "invalid_code" : "missing_code");
|
|
159
|
+
if (!hasOwnProperty(object, "state") || !isNonEmptyString(object.state)) return left(hasOwnProperty(object, "state") ? "invalid_state" : "missing_state");
|
|
160
|
+
if (!hasOwnProperty(object, "operation") || !isNonEmptyString(object.operation)) return left(hasOwnProperty(object, "operation") ? "invalid_operation" : "missing_operation");
|
|
161
|
+
const result = {
|
|
162
|
+
code: object.code,
|
|
163
|
+
state: object.state,
|
|
164
|
+
operation: object.operation
|
|
165
|
+
};
|
|
166
|
+
if (hasOwnProperty(object, "resourceId") && object.resourceId !== void 0) {
|
|
167
|
+
if (typeof object.resourceId !== "string") return left("invalid_resource_id");
|
|
168
|
+
result.resourceId = object.resourceId;
|
|
169
|
+
}
|
|
170
|
+
return right(result);
|
|
171
|
+
}
|
|
172
|
+
function validatePrivilegedTokenResponse(object) {
|
|
173
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
174
|
+
if (!hasOwnProperty(object, "accessToken") || !isNonEmptyString(object.accessToken)) return left(hasOwnProperty(object, "accessToken") ? "invalid_access_token" : "missing_access_token");
|
|
175
|
+
return right({ accessToken: object.accessToken });
|
|
176
|
+
}
|
|
177
|
+
function validateInitiateCliLoginRequest(object) {
|
|
178
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
179
|
+
if (!hasOwnProperty(object, "redirectUri") || !isNonEmptyString(object.redirectUri)) return left(hasOwnProperty(object, "redirectUri") ? "invalid_redirect_uri" : "missing_redirect_uri");
|
|
180
|
+
return right({ redirectUri: object.redirectUri });
|
|
181
|
+
}
|
|
182
|
+
function validateInitiateCliLogin200Response(object) {
|
|
183
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
184
|
+
if (!hasOwnProperty(object, "authorizationUrl") || !isNonEmptyString(object.authorizationUrl)) return left(hasOwnProperty(object, "authorizationUrl") ? "invalid_authorization_url" : "missing_authorization_url");
|
|
185
|
+
return right({ authorizationUrl: object.authorizationUrl });
|
|
186
|
+
}
|
|
187
|
+
function validateOidcCallbackRequest(object) {
|
|
188
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
189
|
+
if (!hasOwnProperty(object, "code") || !isNonEmptyString(object.code)) return left(hasOwnProperty(object, "code") ? "invalid_code" : "missing_code");
|
|
190
|
+
if (!hasOwnProperty(object, "state") || !isNonEmptyString(object.state)) return left(hasOwnProperty(object, "state") ? "invalid_state" : "missing_state");
|
|
191
|
+
return right({
|
|
192
|
+
code: object.code,
|
|
193
|
+
state: object.state
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/validators/groups.validators.ts
|
|
198
|
+
function validateGroup(object) {
|
|
199
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
200
|
+
if (!hasOwnProperty(object, "id") || !isNonEmptyString(object.id)) return left(hasOwnProperty(object, "id") ? "invalid_id" : "missing_id");
|
|
201
|
+
if (!hasOwnProperty(object, "name") || !isNonEmptyString(object.name)) return left(hasOwnProperty(object, "name") ? "invalid_name" : "missing_name");
|
|
202
|
+
if (!hasOwnProperty(object, "entitiesCount") || typeof object.entitiesCount !== "number") return left(hasOwnProperty(object, "entitiesCount") ? "invalid_entities_count" : "missing_entities_count");
|
|
203
|
+
if (!hasOwnProperty(object, "createdAt") || !isNonEmptyString(object.createdAt)) return left(hasOwnProperty(object, "createdAt") ? "invalid_created_at" : "missing_created_at");
|
|
204
|
+
if (!hasOwnProperty(object, "updatedAt") || !isNonEmptyString(object.updatedAt)) return left(hasOwnProperty(object, "updatedAt") ? "invalid_updated_at" : "missing_updated_at");
|
|
205
|
+
const result = {
|
|
206
|
+
id: object.id,
|
|
207
|
+
name: object.name,
|
|
208
|
+
entitiesCount: object.entitiesCount,
|
|
209
|
+
createdAt: object.createdAt,
|
|
210
|
+
updatedAt: object.updatedAt
|
|
211
|
+
};
|
|
212
|
+
if (hasOwnProperty(object, "description") && object.description !== void 0) {
|
|
213
|
+
if (typeof object.description !== "string") return left("invalid_description");
|
|
214
|
+
result.description = object.description;
|
|
215
|
+
}
|
|
216
|
+
return right(result);
|
|
217
|
+
}
|
|
218
|
+
function validateGroupCreate(object) {
|
|
219
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
220
|
+
if (!hasOwnProperty(object, "name") || !isNonEmptyString(object.name)) return left(hasOwnProperty(object, "name") ? "invalid_name" : "missing_name");
|
|
221
|
+
const result = { name: object.name };
|
|
222
|
+
if (hasOwnProperty(object, "description") && object.description !== void 0) {
|
|
223
|
+
if (typeof object.description !== "string") return left("invalid_description");
|
|
224
|
+
result.description = object.description;
|
|
225
|
+
}
|
|
226
|
+
return right(result);
|
|
227
|
+
}
|
|
228
|
+
function validateListGroups200Response(object) {
|
|
229
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
230
|
+
if (!hasOwnProperty(object, "groups") || !isArray(object.groups)) return left(hasOwnProperty(object, "groups") ? "invalid_groups" : "missing_groups");
|
|
231
|
+
const groups = [];
|
|
232
|
+
for (const item of object.groups) {
|
|
233
|
+
const validatedItem = validateGroup(item);
|
|
234
|
+
if (isLeft(validatedItem)) return left("invalid_groups");
|
|
235
|
+
groups.push(validatedItem.right);
|
|
236
|
+
}
|
|
237
|
+
if (!hasOwnProperty(object, "pagination")) return left("missing_pagination");
|
|
238
|
+
const paginationValidation = validatePagination(object.pagination);
|
|
239
|
+
if (isLeft(paginationValidation)) return left("invalid_pagination");
|
|
240
|
+
return right({
|
|
241
|
+
groups,
|
|
242
|
+
pagination: paginationValidation.right
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
function validateGroupScope(object) {
|
|
246
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
247
|
+
if (!hasOwnProperty(object, "type")) return left("missing_type");
|
|
248
|
+
if (object.type !== "group") return left("invalid_type");
|
|
249
|
+
if (!hasOwnProperty(object, "groupId") || !isNonEmptyString(object.groupId)) return left(hasOwnProperty(object, "groupId") ? "invalid_group_id" : "missing_group_id");
|
|
250
|
+
return right({
|
|
251
|
+
type: "group",
|
|
252
|
+
groupId: object.groupId
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
function validateGroupInfo(object) {
|
|
256
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
257
|
+
if (!hasOwnProperty(object, "groupId") || !isNonEmptyString(object.groupId)) return left(hasOwnProperty(object, "groupId") ? "invalid_group_id" : "missing_group_id");
|
|
258
|
+
if (!hasOwnProperty(object, "groupName") || !isNonEmptyString(object.groupName)) return left(hasOwnProperty(object, "groupName") ? "invalid_group_name" : "missing_group_name");
|
|
259
|
+
return right({
|
|
260
|
+
groupId: object.groupId,
|
|
261
|
+
groupName: object.groupName
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
function validateEntityReference(object) {
|
|
265
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
266
|
+
if (!hasOwnProperty(object, "entityType") || !isNonEmptyString(object.entityType)) return left(hasOwnProperty(object, "entityType") ? "invalid_entity_type" : "missing_entity_type");
|
|
267
|
+
if (!hasOwnProperty(object, "entityId") || !isNonEmptyString(object.entityId)) return left(hasOwnProperty(object, "entityId") ? "invalid_entity_id" : "missing_entity_id");
|
|
268
|
+
return right({
|
|
269
|
+
entityType: object.entityType,
|
|
270
|
+
entityId: object.entityId
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
function validateGroupMembership(object) {
|
|
274
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
275
|
+
if (!hasOwnProperty(object, "entity")) return left("missing_entity");
|
|
276
|
+
const entityValidation = validateEntityReference(object.entity);
|
|
277
|
+
if (isLeft(entityValidation)) return left("invalid_entity");
|
|
278
|
+
if (!hasOwnProperty(object, "addedAt") || !isNonEmptyString(object.addedAt)) return left(hasOwnProperty(object, "addedAt") ? "invalid_added_at" : "missing_added_at");
|
|
279
|
+
return right({
|
|
280
|
+
entity: entityValidation.right,
|
|
281
|
+
addedAt: object.addedAt
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
function validateEntityMembershipAdd(object) {
|
|
285
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
286
|
+
if (!hasOwnProperty(object, "entity")) return left("missing_entity");
|
|
287
|
+
const entityValidation = validateEntityReference(object.entity);
|
|
288
|
+
if (isLeft(entityValidation)) return left("invalid_entity");
|
|
289
|
+
return right({ entity: entityValidation.right });
|
|
290
|
+
}
|
|
291
|
+
function validateEntityMembershipRemove(object) {
|
|
292
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
293
|
+
if (!hasOwnProperty(object, "entity")) return left("missing_entity");
|
|
294
|
+
const entityValidation = validateEntityReference(object.entity);
|
|
295
|
+
if (isLeft(entityValidation)) return left("invalid_entity");
|
|
296
|
+
return right({ entity: entityValidation.right });
|
|
297
|
+
}
|
|
298
|
+
function validateAddGroupEntitiesRequest(object) {
|
|
299
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
300
|
+
if (!hasOwnProperty(object, "entities") || !isArray(object.entities)) return left(hasOwnProperty(object, "entities") ? "invalid_entities" : "missing_entities");
|
|
301
|
+
const entities = [];
|
|
302
|
+
for (const item of object.entities) {
|
|
303
|
+
const validatedItem = validateEntityMembershipAdd(item);
|
|
304
|
+
if (isLeft(validatedItem)) return left("invalid_entities");
|
|
305
|
+
entities.push(validatedItem.right);
|
|
306
|
+
}
|
|
307
|
+
return right({ entities });
|
|
308
|
+
}
|
|
309
|
+
function validateRemoveGroupEntitiesRequest(object) {
|
|
310
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
311
|
+
if (!hasOwnProperty(object, "entities") || !isArray(object.entities)) return left(hasOwnProperty(object, "entities") ? "invalid_entities" : "missing_entities");
|
|
312
|
+
const entities = [];
|
|
313
|
+
for (const item of object.entities) {
|
|
314
|
+
const validatedItem = validateEntityMembershipRemove(item);
|
|
315
|
+
if (isLeft(validatedItem)) return left("invalid_entities");
|
|
316
|
+
entities.push(validatedItem.right);
|
|
317
|
+
}
|
|
318
|
+
return right({ entities });
|
|
319
|
+
}
|
|
320
|
+
function validateListGroupEntities200Response(object) {
|
|
321
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
322
|
+
if (!hasOwnProperty(object, "entities") || !isArray(object.entities)) return left(hasOwnProperty(object, "entities") ? "invalid_entities" : "missing_entities");
|
|
323
|
+
const entities = [];
|
|
324
|
+
for (const item of object.entities) {
|
|
325
|
+
const validatedItem = validateGroupMembership(item);
|
|
326
|
+
if (isLeft(validatedItem)) return left("invalid_entities");
|
|
327
|
+
entities.push(validatedItem.right);
|
|
328
|
+
}
|
|
329
|
+
if (!hasOwnProperty(object, "pagination")) return left("missing_pagination");
|
|
330
|
+
const paginationValidation = validatePagination(object.pagination);
|
|
331
|
+
if (isLeft(paginationValidation)) return left("invalid_pagination");
|
|
332
|
+
return right({
|
|
333
|
+
entities,
|
|
334
|
+
pagination: paginationValidation.right
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region src/validators/common.validators.ts
|
|
339
|
+
function validatePagination(object) {
|
|
340
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
341
|
+
if (!hasOwnProperty(object, "total")) return left("missing_total");
|
|
342
|
+
if (!isNumber(object.total) || object.total < 0) return left("invalid_total");
|
|
343
|
+
if (!hasOwnProperty(object, "page")) return left("missing_page");
|
|
344
|
+
if (!isNumber(object.page) || object.page < 0) return left("invalid_page");
|
|
345
|
+
if (!hasOwnProperty(object, "limit")) return left("missing_limit");
|
|
346
|
+
if (!isNumber(object.limit) || object.limit < 1) return left("invalid_limit");
|
|
347
|
+
return right({
|
|
348
|
+
total: object.total,
|
|
349
|
+
page: object.page,
|
|
350
|
+
limit: object.limit
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
function validateAPIErrorDetailsInner(object) {
|
|
354
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
355
|
+
const result = {};
|
|
356
|
+
if (hasOwnProperty(object, "field") && object.field !== void 0) {
|
|
357
|
+
if (typeof object.field !== "string") return left("invalid_field");
|
|
358
|
+
result.field = object.field;
|
|
359
|
+
}
|
|
360
|
+
if (hasOwnProperty(object, "message") && object.message !== void 0) {
|
|
361
|
+
if (typeof object.message !== "string") return left("invalid_message");
|
|
362
|
+
result.message = object.message;
|
|
363
|
+
}
|
|
364
|
+
return right(result);
|
|
365
|
+
}
|
|
366
|
+
function validateAPIError(object) {
|
|
367
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
368
|
+
const result = {};
|
|
369
|
+
if (hasOwnProperty(object, "code") && object.code !== void 0) {
|
|
370
|
+
if (typeof object.code !== "string") return left("invalid_code");
|
|
371
|
+
result.code = object.code;
|
|
372
|
+
}
|
|
373
|
+
if (hasOwnProperty(object, "message") && object.message !== void 0) {
|
|
374
|
+
if (typeof object.message !== "string") return left("invalid_message");
|
|
375
|
+
result.message = object.message;
|
|
376
|
+
}
|
|
377
|
+
if (hasOwnProperty(object, "details") && object.details !== void 0) {
|
|
378
|
+
if (!isArray(object.details)) return left("invalid_details");
|
|
379
|
+
const details = [];
|
|
380
|
+
for (const item of object.details) {
|
|
381
|
+
const validatedItem = validateAPIErrorDetailsInner(item);
|
|
382
|
+
if (isLeft(validatedItem)) return left("invalid_details");
|
|
383
|
+
details.push(validatedItem.right);
|
|
384
|
+
}
|
|
385
|
+
result.details = details;
|
|
386
|
+
}
|
|
387
|
+
return right(result);
|
|
388
|
+
}
|
|
389
|
+
function validateHealthResponse(object) {
|
|
390
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
391
|
+
if (!hasOwnProperty(object, "status") || !isNonEmptyString(object.status)) return left(hasOwnProperty(object, "status") ? "invalid_status" : "missing_status");
|
|
392
|
+
const result = { status: object.status };
|
|
393
|
+
if (hasOwnProperty(object, "message") && object.message !== void 0) {
|
|
394
|
+
if (typeof object.message !== "string") return left("invalid_message");
|
|
395
|
+
result.message = object.message;
|
|
396
|
+
}
|
|
397
|
+
return right(result);
|
|
398
|
+
}
|
|
399
|
+
function validateGetEntityInfo200Response(object) {
|
|
400
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
401
|
+
if (!hasOwnProperty(object, "entityType") || !isNonEmptyString(object.entityType)) return left(hasOwnProperty(object, "entityType") ? "invalid_entity_type" : "missing_entity_type");
|
|
402
|
+
if (!hasOwnProperty(object, "groups") || !isArray(object.groups)) return left(hasOwnProperty(object, "groups") ? "invalid_groups" : "missing_groups");
|
|
403
|
+
const groups = [];
|
|
404
|
+
for (const item of object.groups) {
|
|
405
|
+
const validatedItem = validateGroupInfo(item);
|
|
406
|
+
if (isLeft(validatedItem)) return left("invalid_groups");
|
|
407
|
+
groups.push(validatedItem.right);
|
|
408
|
+
}
|
|
409
|
+
return right({
|
|
410
|
+
entityType: object.entityType,
|
|
411
|
+
groups
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region src/utils/enum.ts
|
|
416
|
+
function getStringAsEnum(str, enumType) {
|
|
417
|
+
if (Object.values(enumType).includes(str)) return str;
|
|
418
|
+
}
|
|
419
|
+
//#endregion
|
|
420
|
+
//#region src/validators/workflow-templates.validators.ts
|
|
421
|
+
function validateEmailAction(object) {
|
|
422
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
423
|
+
if (!hasOwnProperty(object, "type") || object.type !== "EMAIL") return left("invalid_type");
|
|
424
|
+
if (!hasOwnProperty(object, "recipients") || !Array.isArray(object.recipients)) return left("invalid_recipients");
|
|
425
|
+
for (const recipient of object.recipients) if (!isNonEmptyString(recipient)) return left("invalid_recipients_element");
|
|
426
|
+
const type = getStringAsEnum(object.type, EmailAction.TypeEnum);
|
|
427
|
+
if (!type) return left("invalid_type");
|
|
428
|
+
return right({
|
|
429
|
+
type,
|
|
430
|
+
recipients: object.recipients
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
function validateWebhookAction(object) {
|
|
434
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
435
|
+
if (!hasOwnProperty(object, "type") || object.type !== "WEBHOOK") return left("invalid_type");
|
|
436
|
+
if (!hasOwnProperty(object, "url") || !isNonEmptyString(object.url)) return left("invalid_url");
|
|
437
|
+
const type = getStringAsEnum(object.type, WebhookAction.TypeEnum);
|
|
438
|
+
if (!type) return left("invalid_type");
|
|
439
|
+
const result = {
|
|
440
|
+
type,
|
|
441
|
+
url: object.url
|
|
442
|
+
};
|
|
443
|
+
if (hasOwnProperty(object, "method") && object.method !== void 0) {
|
|
444
|
+
if (typeof object.method !== "string") return left("invalid_method");
|
|
445
|
+
const method = getStringAsEnum(object.method, WebhookAction.MethodEnum);
|
|
446
|
+
if (!method) return left("invalid_method");
|
|
447
|
+
result.method = method;
|
|
448
|
+
}
|
|
449
|
+
if (hasOwnProperty(object, "headers") && object.headers !== void 0) {
|
|
450
|
+
if (typeof object.headers !== "object" || object.headers === null || Array.isArray(object.headers)) return left("invalid_headers");
|
|
451
|
+
const headers = {};
|
|
452
|
+
for (const [key, value] of Object.entries(object.headers)) {
|
|
453
|
+
if (typeof value !== "string") return left("invalid_headers_element");
|
|
454
|
+
headers[key] = value;
|
|
455
|
+
}
|
|
456
|
+
result.headers = headers;
|
|
457
|
+
}
|
|
458
|
+
return right(result);
|
|
459
|
+
}
|
|
460
|
+
function validateWorkflowAction(object) {
|
|
461
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
462
|
+
if (hasOwnProperty(object, "type")) {
|
|
463
|
+
if (object.type === "EMAIL") return validateEmailAction(object);
|
|
464
|
+
if (object.type === "WEBHOOK") return validateWebhookAction(object);
|
|
465
|
+
}
|
|
466
|
+
return left("invalid_workflow_action_type");
|
|
467
|
+
}
|
|
468
|
+
function validateGroupRequirementRule(object) {
|
|
469
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
470
|
+
if (!hasOwnProperty(object, "type") || object.type !== "GROUP_REQUIREMENT") return left("invalid_type");
|
|
471
|
+
if (!hasOwnProperty(object, "groupId") || !isNonEmptyString(object.groupId)) return left("invalid_group_id");
|
|
472
|
+
if (!hasOwnProperty(object, "minCount") || typeof object.minCount !== "number" || object.minCount < 1) return left("invalid_min_count");
|
|
473
|
+
const type = getStringAsEnum(object.type, GroupRequirementRule.TypeEnum);
|
|
474
|
+
if (!type) return left("invalid_type");
|
|
475
|
+
const result = {
|
|
476
|
+
type,
|
|
477
|
+
groupId: object.groupId,
|
|
478
|
+
minCount: object.minCount
|
|
479
|
+
};
|
|
480
|
+
if (hasOwnProperty(object, "requireHighPrivilege") && object.requireHighPrivilege !== void 0) {
|
|
481
|
+
if (typeof object.requireHighPrivilege !== "boolean") return left("invalid_require_high_privilege");
|
|
482
|
+
result.requireHighPrivilege = object.requireHighPrivilege;
|
|
483
|
+
}
|
|
484
|
+
return right(result);
|
|
485
|
+
}
|
|
486
|
+
function validateAndRule(object) {
|
|
487
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
488
|
+
if (!hasOwnProperty(object, "type") || object.type !== "AND") return left("invalid_type");
|
|
489
|
+
if (!hasOwnProperty(object, "rules") || !Array.isArray(object.rules) || object.rules.length === 0) return left("invalid_rules");
|
|
490
|
+
const rules = [];
|
|
491
|
+
for (const rule of object.rules) {
|
|
492
|
+
const validatedRule = validateApprovalRule(rule);
|
|
493
|
+
if (isLeft(validatedRule)) return left("invalid_rules_element");
|
|
494
|
+
rules.push(validatedRule.right);
|
|
495
|
+
}
|
|
496
|
+
const type = getStringAsEnum(object.type, AndRule.TypeEnum);
|
|
497
|
+
if (!type) return left("invalid_type");
|
|
498
|
+
return right({
|
|
499
|
+
type,
|
|
500
|
+
rules
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
function validateOrRule(object) {
|
|
504
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
505
|
+
if (!hasOwnProperty(object, "type") || object.type !== "OR") return left("invalid_type");
|
|
506
|
+
if (!hasOwnProperty(object, "rules") || !Array.isArray(object.rules) || object.rules.length === 0) return left("invalid_rules");
|
|
507
|
+
const rules = [];
|
|
508
|
+
for (const rule of object.rules) {
|
|
509
|
+
const validatedRule = validateApprovalRule(rule);
|
|
510
|
+
if (isLeft(validatedRule)) return left("invalid_rules_element");
|
|
511
|
+
rules.push(validatedRule.right);
|
|
512
|
+
}
|
|
513
|
+
const type = getStringAsEnum(object.type, OrRule.TypeEnum);
|
|
514
|
+
if (!type) return left("invalid_type");
|
|
515
|
+
return right({
|
|
516
|
+
type,
|
|
517
|
+
rules
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
function validateApprovalRule(object) {
|
|
521
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
522
|
+
if (hasOwnProperty(object, "type")) {
|
|
523
|
+
if (object.type === "GROUP_REQUIREMENT") return validateGroupRequirementRule(object);
|
|
524
|
+
if (object.type === "AND") return validateAndRule(object);
|
|
525
|
+
if (object.type === "OR") return validateOrRule(object);
|
|
526
|
+
}
|
|
527
|
+
return left("invalid_approval_rule_type");
|
|
528
|
+
}
|
|
529
|
+
function validateWorkflowTemplate(object) {
|
|
530
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
531
|
+
if (!hasOwnProperty(object, "id") || !isNonEmptyString(object.id)) return left("invalid_id");
|
|
532
|
+
if (!hasOwnProperty(object, "name") || !isNonEmptyString(object.name)) return left("invalid_name");
|
|
533
|
+
if (!hasOwnProperty(object, "version") || !isNonEmptyString(object.version)) return left("invalid_version");
|
|
534
|
+
if (!hasOwnProperty(object, "status") || typeof object.status !== "string") return left("invalid_status");
|
|
535
|
+
const status = getStringAsEnum(object.status, WorkflowTemplate.StatusEnum);
|
|
536
|
+
if (!status) return left("invalid_status");
|
|
537
|
+
if (!hasOwnProperty(object, "allowVotingOnDeprecatedTemplate") || typeof object.allowVotingOnDeprecatedTemplate !== "boolean") return left("invalid_allow_voting");
|
|
538
|
+
if (!hasOwnProperty(object, "approvalRule")) return left("missing_approval_rule");
|
|
539
|
+
const approvalRuleValidation = validateApprovalRule(object.approvalRule);
|
|
540
|
+
if (isLeft(approvalRuleValidation)) return left("invalid_approval_rule");
|
|
541
|
+
if (!hasOwnProperty(object, "spaceId") || !isNonEmptyString(object.spaceId)) return left("invalid_space_id");
|
|
542
|
+
if (!hasOwnProperty(object, "createdAt") || !isNonEmptyString(object.createdAt)) return left("invalid_created_at");
|
|
543
|
+
if (!hasOwnProperty(object, "updatedAt") || !isNonEmptyString(object.updatedAt)) return left("invalid_updated_at");
|
|
544
|
+
const result = {
|
|
545
|
+
id: object.id,
|
|
546
|
+
name: object.name,
|
|
547
|
+
version: object.version,
|
|
548
|
+
status,
|
|
549
|
+
allowVotingOnDeprecatedTemplate: object.allowVotingOnDeprecatedTemplate,
|
|
550
|
+
approvalRule: approvalRuleValidation.right,
|
|
551
|
+
spaceId: object.spaceId,
|
|
552
|
+
createdAt: object.createdAt,
|
|
553
|
+
updatedAt: object.updatedAt
|
|
554
|
+
};
|
|
555
|
+
if (hasOwnProperty(object, "description") && object.description !== void 0) {
|
|
556
|
+
if (typeof object.description !== "string") return left("invalid_description");
|
|
557
|
+
result.description = object.description;
|
|
558
|
+
}
|
|
559
|
+
if (hasOwnProperty(object, "metadata") && object.metadata !== void 0) {
|
|
560
|
+
const metadata = object.metadata;
|
|
561
|
+
if (typeof metadata !== "object" || metadata === null || Array.isArray(metadata)) return left("invalid_metadata");
|
|
562
|
+
result.metadata = metadata;
|
|
563
|
+
}
|
|
564
|
+
if (hasOwnProperty(object, "actions") && object.actions !== void 0) {
|
|
565
|
+
if (!Array.isArray(object.actions)) return left("invalid_actions");
|
|
566
|
+
const actions = [];
|
|
567
|
+
for (const action of object.actions) {
|
|
568
|
+
const validatedAction = validateWorkflowAction(action);
|
|
569
|
+
if (isLeft(validatedAction)) return left("invalid_actions_element");
|
|
570
|
+
actions.push(validatedAction.right);
|
|
571
|
+
}
|
|
572
|
+
result.actions = actions;
|
|
573
|
+
}
|
|
574
|
+
if (hasOwnProperty(object, "defaultExpiresInHours") && object.defaultExpiresInHours !== void 0) {
|
|
575
|
+
if (typeof object.defaultExpiresInHours !== "number") return left("invalid_default_expires_in_hours");
|
|
576
|
+
result.defaultExpiresInHours = object.defaultExpiresInHours;
|
|
577
|
+
}
|
|
578
|
+
return right(result);
|
|
579
|
+
}
|
|
580
|
+
function validateWorkflowTemplateCreate(object) {
|
|
581
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
582
|
+
if (!hasOwnProperty(object, "name") || !isNonEmptyString(object.name)) return left("invalid_name");
|
|
583
|
+
if (!hasOwnProperty(object, "approvalRule")) return left("missing_approval_rule");
|
|
584
|
+
const approvalRuleValidation = validateApprovalRule(object.approvalRule);
|
|
585
|
+
if (isLeft(approvalRuleValidation)) return left("invalid_approval_rule");
|
|
586
|
+
if (!hasOwnProperty(object, "spaceId") || !isNonEmptyString(object.spaceId)) return left("invalid_space_id");
|
|
587
|
+
const result = {
|
|
588
|
+
name: object.name,
|
|
589
|
+
approvalRule: approvalRuleValidation.right,
|
|
590
|
+
spaceId: object.spaceId
|
|
591
|
+
};
|
|
592
|
+
if (hasOwnProperty(object, "description") && object.description !== void 0) {
|
|
593
|
+
if (typeof object.description !== "string") return left("invalid_description");
|
|
594
|
+
result.description = object.description;
|
|
595
|
+
}
|
|
596
|
+
if (hasOwnProperty(object, "metadata") && object.metadata !== void 0) {
|
|
597
|
+
const metadata = object.metadata;
|
|
598
|
+
if (typeof metadata !== "object" || metadata === null || Array.isArray(metadata)) return left("invalid_metadata");
|
|
599
|
+
result.metadata = metadata;
|
|
600
|
+
}
|
|
601
|
+
if (hasOwnProperty(object, "actions") && object.actions !== void 0) {
|
|
602
|
+
if (!Array.isArray(object.actions)) return left("invalid_actions");
|
|
603
|
+
const actions = [];
|
|
604
|
+
for (const action of object.actions) {
|
|
605
|
+
const validatedAction = validateWorkflowAction(action);
|
|
606
|
+
if (isLeft(validatedAction)) return left("invalid_actions_element");
|
|
607
|
+
actions.push(validatedAction.right);
|
|
608
|
+
}
|
|
609
|
+
result.actions = actions;
|
|
610
|
+
}
|
|
611
|
+
if (hasOwnProperty(object, "defaultExpiresInHours") && object.defaultExpiresInHours !== void 0) {
|
|
612
|
+
if (typeof object.defaultExpiresInHours !== "number") return left("invalid_default_expires_in_hours");
|
|
613
|
+
result.defaultExpiresInHours = object.defaultExpiresInHours;
|
|
614
|
+
}
|
|
615
|
+
return right(result);
|
|
616
|
+
}
|
|
617
|
+
function validateWorkflowTemplateUpdate(object) {
|
|
618
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
619
|
+
const result = {};
|
|
620
|
+
if (hasOwnProperty(object, "description") && object.description !== void 0) {
|
|
621
|
+
if (typeof object.description !== "string") return left("invalid_description");
|
|
622
|
+
result.description = object.description;
|
|
623
|
+
}
|
|
624
|
+
if (hasOwnProperty(object, "metadata") && object.metadata !== void 0) {
|
|
625
|
+
const metadata = object.metadata;
|
|
626
|
+
if (typeof metadata !== "object" || metadata === null || Array.isArray(metadata)) return left("invalid_metadata");
|
|
627
|
+
result.metadata = metadata;
|
|
628
|
+
}
|
|
629
|
+
if (hasOwnProperty(object, "approvalRule") && object.approvalRule !== void 0) {
|
|
630
|
+
const approvalRuleValidation = validateApprovalRule(object.approvalRule);
|
|
631
|
+
if (isLeft(approvalRuleValidation)) return left("invalid_approval_rule");
|
|
632
|
+
result.approvalRule = approvalRuleValidation.right;
|
|
633
|
+
}
|
|
634
|
+
if (hasOwnProperty(object, "actions") && object.actions !== void 0) {
|
|
635
|
+
if (!Array.isArray(object.actions)) return left("invalid_actions");
|
|
636
|
+
const actions = [];
|
|
637
|
+
for (const action of object.actions) {
|
|
638
|
+
const validatedAction = validateWorkflowAction(action);
|
|
639
|
+
if (isLeft(validatedAction)) return left("invalid_actions_element");
|
|
640
|
+
actions.push(validatedAction.right);
|
|
641
|
+
}
|
|
642
|
+
result.actions = actions;
|
|
643
|
+
}
|
|
644
|
+
if (hasOwnProperty(object, "defaultExpiresInHours") && object.defaultExpiresInHours !== void 0) {
|
|
645
|
+
if (typeof object.defaultExpiresInHours !== "number") return left("invalid_default_expires_in_hours");
|
|
646
|
+
result.defaultExpiresInHours = object.defaultExpiresInHours;
|
|
647
|
+
}
|
|
648
|
+
if (hasOwnProperty(object, "cancelWorkflows") && object.cancelWorkflows !== void 0) {
|
|
649
|
+
if (typeof object.cancelWorkflows !== "boolean") return left("invalid_cancel_workflows");
|
|
650
|
+
result.cancelWorkflows = object.cancelWorkflows;
|
|
651
|
+
}
|
|
652
|
+
return right(result);
|
|
653
|
+
}
|
|
654
|
+
function validateWorkflowTemplateDeprecate(object) {
|
|
655
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
656
|
+
const result = {};
|
|
657
|
+
if (hasOwnProperty(object, "cancelWorkflows") && object.cancelWorkflows !== void 0) {
|
|
658
|
+
if (typeof object.cancelWorkflows !== "boolean") return left("invalid_cancel_workflows");
|
|
659
|
+
result.cancelWorkflows = object.cancelWorkflows;
|
|
660
|
+
}
|
|
661
|
+
return right(result);
|
|
662
|
+
}
|
|
663
|
+
function validateWorkflowTemplateScope(object) {
|
|
664
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
665
|
+
if (!hasOwnProperty(object, "type") || object.type !== "workflow_template") return left("invalid_type");
|
|
666
|
+
if (!hasOwnProperty(object, "workflowTemplateId") || !isNonEmptyString(object.workflowTemplateId)) return left("invalid_workflow_template_id");
|
|
667
|
+
if (!hasOwnProperty(object, "type") || typeof object.type !== "string") return left("invalid_type");
|
|
668
|
+
const type = getStringAsEnum(object.type, WorkflowTemplateScope.TypeEnum);
|
|
669
|
+
if (!type) return left("invalid_type");
|
|
670
|
+
return right({
|
|
671
|
+
type,
|
|
672
|
+
workflowTemplateId: object.workflowTemplateId
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
function validateWorkflowTemplateSummary(object) {
|
|
676
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
677
|
+
if (!hasOwnProperty(object, "id") || !isNonEmptyString(object.id)) return left("invalid_id");
|
|
678
|
+
if (!hasOwnProperty(object, "name") || !isNonEmptyString(object.name)) return left("invalid_name");
|
|
679
|
+
if (!hasOwnProperty(object, "version") || !isNonEmptyString(object.version)) return left("invalid_version");
|
|
680
|
+
if (!hasOwnProperty(object, "createdAt") || !isNonEmptyString(object.createdAt)) return left("invalid_created_at");
|
|
681
|
+
if (!hasOwnProperty(object, "updatedAt") || !isNonEmptyString(object.updatedAt)) return left("invalid_updated_at");
|
|
682
|
+
const result = {
|
|
683
|
+
id: object.id,
|
|
684
|
+
name: object.name,
|
|
685
|
+
version: object.version,
|
|
686
|
+
createdAt: object.createdAt,
|
|
687
|
+
updatedAt: object.updatedAt
|
|
688
|
+
};
|
|
689
|
+
if (hasOwnProperty(object, "description") && object.description !== void 0) {
|
|
690
|
+
if (typeof object.description !== "string") return left("invalid_description");
|
|
691
|
+
result.description = object.description;
|
|
692
|
+
}
|
|
693
|
+
return right(result);
|
|
694
|
+
}
|
|
695
|
+
function validateListWorkflowTemplates200Response(object) {
|
|
696
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
697
|
+
if (!hasOwnProperty(object, "data") || !Array.isArray(object.data)) return left("invalid_data");
|
|
698
|
+
const data = [];
|
|
699
|
+
for (const item of object.data) {
|
|
700
|
+
const validatedItem = validateWorkflowTemplateSummary(item);
|
|
701
|
+
if (isLeft(validatedItem)) return left("invalid_data_element");
|
|
702
|
+
data.push(validatedItem.right);
|
|
703
|
+
}
|
|
704
|
+
if (!hasOwnProperty(object, "pagination")) return left("missing_pagination");
|
|
705
|
+
const paginationValidation = validatePagination(object.pagination);
|
|
706
|
+
if (isLeft(paginationValidation)) return left("invalid_pagination");
|
|
707
|
+
return right({
|
|
708
|
+
data,
|
|
709
|
+
pagination: paginationValidation.right
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
function validateListWorkflowTemplatesParams(object) {
|
|
713
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
714
|
+
const result = {};
|
|
715
|
+
if (hasOwnProperty(object, "page") && object.page !== void 0) {
|
|
716
|
+
if (typeof object.page !== "number") return left("invalid_page");
|
|
717
|
+
result.page = object.page;
|
|
718
|
+
}
|
|
719
|
+
if (hasOwnProperty(object, "limit") && object.limit !== void 0) {
|
|
720
|
+
if (typeof object.limit !== "number") return left("invalid_limit");
|
|
721
|
+
result.limit = object.limit;
|
|
722
|
+
}
|
|
723
|
+
if (hasOwnProperty(object, "spaceIdentifier") && object.spaceIdentifier !== void 0) {
|
|
724
|
+
if (!isNonEmptyString(object.spaceIdentifier)) return left("invalid_space_identifier");
|
|
725
|
+
result.spaceIdentifier = object.spaceIdentifier;
|
|
726
|
+
}
|
|
727
|
+
return right(result);
|
|
728
|
+
}
|
|
729
|
+
//#endregion
|
|
730
|
+
//#region src/validators/workflow.validators.ts
|
|
731
|
+
function validateWorkflowCreate(object) {
|
|
732
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
733
|
+
if (!hasOwnProperty(object, "name") || !isNonEmptyString(object["name"])) return left("missing_name");
|
|
734
|
+
if (!hasOwnProperty(object, "workflowTemplateId") || !isNonEmptyString(object["workflowTemplateId"])) return left("missing_workflow_template_id");
|
|
735
|
+
let description = void 0;
|
|
736
|
+
if (hasOwnProperty(object, "description")) {
|
|
737
|
+
if (typeof object["description"] !== "string") return left("invalid_description");
|
|
738
|
+
description = object["description"];
|
|
739
|
+
}
|
|
740
|
+
let metadata = void 0;
|
|
741
|
+
if (hasOwnProperty(object, "metadata")) {
|
|
742
|
+
if (typeof object["metadata"] !== "object" || object["metadata"] === null) return left("invalid_metadata");
|
|
743
|
+
metadata = object["metadata"];
|
|
744
|
+
}
|
|
745
|
+
return right({
|
|
746
|
+
name: object["name"],
|
|
747
|
+
workflowTemplateId: object["workflowTemplateId"],
|
|
748
|
+
description,
|
|
749
|
+
metadata
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
function validateWorkflowRef(object) {
|
|
753
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
754
|
+
let workflowTemplate = void 0;
|
|
755
|
+
if (hasOwnProperty(object, "workflowTemplate")) {
|
|
756
|
+
const templateRes = validateWorkflowTemplate(object["workflowTemplate"]);
|
|
757
|
+
if (isLeft(templateRes)) return left("invalid_workflow_template");
|
|
758
|
+
workflowTemplate = templateRes.right;
|
|
759
|
+
}
|
|
760
|
+
return right({ workflowTemplate });
|
|
761
|
+
}
|
|
762
|
+
function validateWorkflow(object) {
|
|
763
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
764
|
+
if (!hasOwnProperty(object, "id") || !isNonEmptyString(object["id"])) return left(hasOwnProperty(object, "id") ? "invalid_id" : "missing_id");
|
|
765
|
+
if (!hasOwnProperty(object, "name") || !isNonEmptyString(object["name"])) return left(hasOwnProperty(object, "name") ? "invalid_name" : "missing_name");
|
|
766
|
+
if (!hasOwnProperty(object, "status") || !isNonEmptyString(object["status"])) return left(hasOwnProperty(object, "status") ? "invalid_status" : "missing_status");
|
|
767
|
+
if (!hasOwnProperty(object, "workflowTemplateId") || !isNonEmptyString(object["workflowTemplateId"])) return left(hasOwnProperty(object, "workflowTemplateId") ? "invalid_workflow_template_id" : "missing_workflow_template_id");
|
|
768
|
+
if (!hasOwnProperty(object, "metadata") || typeof object["metadata"] !== "object" || object["metadata"] === null) return left(hasOwnProperty(object, "metadata") ? "invalid_metadata" : "missing_metadata");
|
|
769
|
+
if (!hasOwnProperty(object, "createdAt") || !isNonEmptyString(object["createdAt"])) return left(hasOwnProperty(object, "createdAt") ? "invalid_created_at" : "missing_created_at");
|
|
770
|
+
if (!hasOwnProperty(object, "updatedAt") || !isNonEmptyString(object["updatedAt"])) return left(hasOwnProperty(object, "updatedAt") ? "invalid_updated_at" : "missing_updated_at");
|
|
771
|
+
let description = void 0;
|
|
772
|
+
if (hasOwnProperty(object, "description")) {
|
|
773
|
+
if (typeof object["description"] !== "string") return left("invalid_description");
|
|
774
|
+
description = object["description"];
|
|
775
|
+
}
|
|
776
|
+
let expiresAt = void 0;
|
|
777
|
+
if (hasOwnProperty(object, "expiresAt")) {
|
|
778
|
+
if (typeof object["expiresAt"] !== "string") return left("invalid_expires_at");
|
|
779
|
+
expiresAt = object["expiresAt"];
|
|
780
|
+
}
|
|
781
|
+
let ref = void 0;
|
|
782
|
+
if (hasOwnProperty(object, "ref")) {
|
|
783
|
+
const refRes = validateWorkflowRef(object["ref"]);
|
|
784
|
+
if (isLeft(refRes)) return left("invalid_ref");
|
|
785
|
+
ref = refRes.right;
|
|
786
|
+
}
|
|
787
|
+
return right({
|
|
788
|
+
id: object["id"],
|
|
789
|
+
name: object["name"],
|
|
790
|
+
status: object["status"],
|
|
791
|
+
workflowTemplateId: object["workflowTemplateId"],
|
|
792
|
+
metadata: object["metadata"],
|
|
793
|
+
createdAt: object["createdAt"],
|
|
794
|
+
updatedAt: object["updatedAt"],
|
|
795
|
+
description,
|
|
796
|
+
expiresAt,
|
|
797
|
+
ref
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
function validateGetWorkflowParams(object) {
|
|
801
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
802
|
+
let include = void 0;
|
|
803
|
+
if (hasOwnProperty(object, "include")) {
|
|
804
|
+
const includeVal = object["include"];
|
|
805
|
+
if (!isArray(includeVal)) return left("invalid_include");
|
|
806
|
+
const validatedInclude = [];
|
|
807
|
+
for (const item of includeVal) {
|
|
808
|
+
if (typeof item !== "string") return left("invalid_include");
|
|
809
|
+
validatedInclude.push(item);
|
|
810
|
+
}
|
|
811
|
+
include = validatedInclude;
|
|
812
|
+
}
|
|
813
|
+
return right({ include });
|
|
814
|
+
}
|
|
815
|
+
function validateListWorkflowsParams(object) {
|
|
816
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
817
|
+
let page = void 0;
|
|
818
|
+
if (hasOwnProperty(object, "page")) {
|
|
819
|
+
const val = object["page"];
|
|
820
|
+
if (typeof val !== "number") return left("invalid_page");
|
|
821
|
+
page = val;
|
|
822
|
+
}
|
|
823
|
+
let limit = void 0;
|
|
824
|
+
if (hasOwnProperty(object, "limit")) {
|
|
825
|
+
const val = object["limit"];
|
|
826
|
+
if (typeof val !== "number") return left("invalid_limit");
|
|
827
|
+
limit = val;
|
|
828
|
+
}
|
|
829
|
+
let include = void 0;
|
|
830
|
+
if (hasOwnProperty(object, "include")) {
|
|
831
|
+
const includeVal = object["include"];
|
|
832
|
+
if (!isArray(includeVal)) return left("invalid_include");
|
|
833
|
+
const validatedInclude = [];
|
|
834
|
+
for (const item of includeVal) {
|
|
835
|
+
if (typeof item !== "string") return left("invalid_include");
|
|
836
|
+
validatedInclude.push(item);
|
|
837
|
+
}
|
|
838
|
+
include = validatedInclude;
|
|
839
|
+
}
|
|
840
|
+
let includeOnlyNonTerminalState = void 0;
|
|
841
|
+
if (hasOwnProperty(object, "includeOnlyNonTerminalState")) {
|
|
842
|
+
const val = object["includeOnlyNonTerminalState"];
|
|
843
|
+
if (typeof val !== "boolean") return left("invalid_include_only_non_terminal_state");
|
|
844
|
+
includeOnlyNonTerminalState = val;
|
|
845
|
+
}
|
|
846
|
+
let workflowTemplateIdentifier = void 0;
|
|
847
|
+
if (hasOwnProperty(object, "workflowTemplateIdentifier")) {
|
|
848
|
+
const val = object["workflowTemplateIdentifier"];
|
|
849
|
+
if (typeof val !== "string") return left("invalid_workflow_template_identifier");
|
|
850
|
+
workflowTemplateIdentifier = val;
|
|
851
|
+
}
|
|
852
|
+
return right({
|
|
853
|
+
page,
|
|
854
|
+
limit,
|
|
855
|
+
include,
|
|
856
|
+
includeOnlyNonTerminalState,
|
|
857
|
+
workflowTemplateIdentifier
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
function validateListWorkflows200Response(object) {
|
|
861
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
862
|
+
if (!hasOwnProperty(object, "data") || !isArray(object["data"])) return left("missing_data");
|
|
863
|
+
const data = [];
|
|
864
|
+
for (const item of object["data"]) {
|
|
865
|
+
const itemRes = validateWorkflow(item);
|
|
866
|
+
if (isLeft(itemRes)) return left("invalid_data");
|
|
867
|
+
data.push(itemRes.right);
|
|
868
|
+
}
|
|
869
|
+
if (!hasOwnProperty(object, "pagination")) return left("missing_pagination");
|
|
870
|
+
const pageRes = validatePagination(object["pagination"]);
|
|
871
|
+
if (isLeft(pageRes)) return left("invalid_pagination");
|
|
872
|
+
return right({
|
|
873
|
+
data,
|
|
874
|
+
pagination: pageRes.right
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
function validateVoteApprove(object) {
|
|
878
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
879
|
+
if (!hasOwnProperty(object, "type") || object["type"] !== "APPROVE") return left(hasOwnProperty(object, "type") ? "invalid_type" : "missing_type");
|
|
880
|
+
if (!hasOwnProperty(object, "votedForGroups")) return left("missing_voted_for_groups");
|
|
881
|
+
const votedForGroupsVal = object["votedForGroups"];
|
|
882
|
+
if (!isArray(votedForGroupsVal)) return left("invalid_voted_for_groups");
|
|
883
|
+
const validatedGroups = [];
|
|
884
|
+
for (const v of votedForGroupsVal) {
|
|
885
|
+
if (typeof v !== "string") return left("invalid_voted_for_groups");
|
|
886
|
+
validatedGroups.push(v);
|
|
887
|
+
}
|
|
888
|
+
return right({
|
|
889
|
+
type: "APPROVE",
|
|
890
|
+
votedForGroups: validatedGroups
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
function validateVoteVeto(object) {
|
|
894
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
895
|
+
if (!hasOwnProperty(object, "type") || object["type"] !== "VETO") return left(hasOwnProperty(object, "type") ? "invalid_type" : "missing_type");
|
|
896
|
+
return right({ type: "VETO" });
|
|
897
|
+
}
|
|
898
|
+
function validateVoteWithdraw(object) {
|
|
899
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
900
|
+
if (!hasOwnProperty(object, "type") || object["type"] !== "WITHDRAW") return left(hasOwnProperty(object, "type") ? "invalid_type" : "missing_type");
|
|
901
|
+
return right({ type: "WITHDRAW" });
|
|
902
|
+
}
|
|
903
|
+
function validateWorkflowVoteRequestVoteType(object) {
|
|
904
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
905
|
+
if (!hasOwnProperty(object, "type")) return left("invalid_vote_type");
|
|
906
|
+
if (object["type"] === "APPROVE") {
|
|
907
|
+
const res = validateVoteApprove(object);
|
|
908
|
+
if (isLeft(res)) return left("invalid_vote_type");
|
|
909
|
+
return right(res.right);
|
|
910
|
+
} else if (object["type"] === "VETO") {
|
|
911
|
+
const res = validateVoteVeto(object);
|
|
912
|
+
if (isLeft(res)) return left("invalid_vote_type");
|
|
913
|
+
return right(res.right);
|
|
914
|
+
} else if (object["type"] === "WITHDRAW") {
|
|
915
|
+
const res = validateVoteWithdraw(object);
|
|
916
|
+
if (isLeft(res)) return left("invalid_vote_type");
|
|
917
|
+
return right(res.right);
|
|
918
|
+
}
|
|
919
|
+
return left("invalid_vote_type");
|
|
920
|
+
}
|
|
921
|
+
function validateWorkflowVoteRequest(object) {
|
|
922
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
923
|
+
let reason = void 0;
|
|
924
|
+
if (hasOwnProperty(object, "reason")) {
|
|
925
|
+
if (typeof object["reason"] !== "string") return left("invalid_reason");
|
|
926
|
+
reason = object["reason"];
|
|
927
|
+
}
|
|
928
|
+
if (!hasOwnProperty(object, "voteType")) return left("missing_vote_type");
|
|
929
|
+
const voteTypeRes = validateWorkflowVoteRequestVoteType(object["voteType"]);
|
|
930
|
+
if (isLeft(voteTypeRes)) return left("invalid_vote_type");
|
|
931
|
+
return right({
|
|
932
|
+
reason,
|
|
933
|
+
voteType: voteTypeRes.right
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
function validateWorkflowVote(object) {
|
|
937
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
938
|
+
if (!hasOwnProperty(object, "voterId") || !isNonEmptyString(object["voterId"])) return left(hasOwnProperty(object, "voterId") ? "invalid_voter_id" : "missing_voter_id");
|
|
939
|
+
if (!hasOwnProperty(object, "voterType") || !isNonEmptyString(object["voterType"])) return left(hasOwnProperty(object, "voterType") ? "invalid_voter_type" : "missing_voter_type");
|
|
940
|
+
if (!hasOwnProperty(object, "voteType") || !isNonEmptyString(object["voteType"])) return left(hasOwnProperty(object, "voteType") ? "invalid_vote_type" : "missing_vote_type");
|
|
941
|
+
if (!hasOwnProperty(object, "timestamp") || !isNonEmptyString(object["timestamp"])) return left(hasOwnProperty(object, "timestamp") ? "invalid_timestamp" : "missing_timestamp");
|
|
942
|
+
let reason = void 0;
|
|
943
|
+
if (hasOwnProperty(object, "reason")) {
|
|
944
|
+
const val = object["reason"];
|
|
945
|
+
if (typeof val !== "string") return left("invalid_reason");
|
|
946
|
+
reason = val;
|
|
947
|
+
}
|
|
948
|
+
let votedForGroups = void 0;
|
|
949
|
+
if (hasOwnProperty(object, "votedForGroups")) {
|
|
950
|
+
const votedForGroupsVal = object["votedForGroups"];
|
|
951
|
+
if (!isArray(votedForGroupsVal)) return left("invalid_voted_for_groups");
|
|
952
|
+
const validatedGroups = [];
|
|
953
|
+
for (const v of votedForGroupsVal) {
|
|
954
|
+
if (typeof v !== "string") return left("invalid_voted_for_groups");
|
|
955
|
+
validatedGroups.push(v);
|
|
956
|
+
}
|
|
957
|
+
votedForGroups = validatedGroups;
|
|
958
|
+
}
|
|
959
|
+
return right({
|
|
960
|
+
voterId: object["voterId"],
|
|
961
|
+
voterType: object["voterType"],
|
|
962
|
+
voteType: object["voteType"],
|
|
963
|
+
timestamp: object["timestamp"],
|
|
964
|
+
reason,
|
|
965
|
+
votedForGroups
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
function validateCanVoteResponse(object) {
|
|
969
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
970
|
+
if (!hasOwnProperty(object, "canVote") || typeof object["canVote"] !== "boolean") return left(hasOwnProperty(object, "canVote") ? "invalid_can_vote" : "missing_can_vote");
|
|
971
|
+
if (!hasOwnProperty(object, "voteStatus") || !isNonEmptyString(object["voteStatus"])) return left(hasOwnProperty(object, "voteStatus") ? "invalid_vote_status" : "missing_vote_status");
|
|
972
|
+
let cantVoteReason = void 0;
|
|
973
|
+
if (hasOwnProperty(object, "cantVoteReason")) {
|
|
974
|
+
if (typeof object["cantVoteReason"] !== "string") return left("invalid_cant_vote_reason");
|
|
975
|
+
cantVoteReason = object["cantVoteReason"];
|
|
976
|
+
}
|
|
977
|
+
let requireHighPrivilege = void 0;
|
|
978
|
+
if (hasOwnProperty(object, "requireHighPrivilege")) {
|
|
979
|
+
if (typeof object["requireHighPrivilege"] !== "boolean") return left("invalid_require_high_privilege");
|
|
980
|
+
requireHighPrivilege = object["requireHighPrivilege"];
|
|
981
|
+
}
|
|
982
|
+
return right({
|
|
983
|
+
canVote: object["canVote"],
|
|
984
|
+
voteStatus: object["voteStatus"],
|
|
985
|
+
cantVoteReason,
|
|
986
|
+
requireHighPrivilege
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
function validateGetWorkflowVotes200Response(object) {
|
|
990
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
991
|
+
if (!hasOwnProperty(object, "votes") || !isArray(object["votes"])) return left("missing_votes");
|
|
992
|
+
const votes = [];
|
|
993
|
+
for (const vote of object["votes"]) {
|
|
994
|
+
const voteRes = validateWorkflowVote(vote);
|
|
995
|
+
if (isLeft(voteRes)) return left("invalid_votes");
|
|
996
|
+
votes.push(voteRes.right);
|
|
997
|
+
}
|
|
998
|
+
return right({ votes });
|
|
999
|
+
}
|
|
1000
|
+
//#endregion
|
|
1001
|
+
//#region src/validators/users.validators.ts
|
|
1002
|
+
function validateUser(object) {
|
|
1003
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1004
|
+
if (!hasOwnProperty(object, "id")) return left("missing_id");
|
|
1005
|
+
if (!isNonEmptyString(object.id)) return left("invalid_id");
|
|
1006
|
+
if (!hasOwnProperty(object, "displayName")) return left("missing_display_name");
|
|
1007
|
+
if (!isNonEmptyString(object.displayName)) return left("invalid_display_name");
|
|
1008
|
+
if (!hasOwnProperty(object, "email")) return left("missing_email");
|
|
1009
|
+
if (!isNonEmptyString(object.email)) return left("invalid_email");
|
|
1010
|
+
if (!hasOwnProperty(object, "orgRole")) return left("missing_org_role");
|
|
1011
|
+
if (!isNonEmptyString(object.orgRole)) return left("invalid_org_role");
|
|
1012
|
+
if (!hasOwnProperty(object, "createdAt")) return left("missing_created_at");
|
|
1013
|
+
if (!isNonEmptyString(object.createdAt)) return left("invalid_created_at");
|
|
1014
|
+
return right({
|
|
1015
|
+
id: object.id,
|
|
1016
|
+
displayName: object.displayName,
|
|
1017
|
+
email: object.email,
|
|
1018
|
+
orgRole: object.orgRole,
|
|
1019
|
+
createdAt: object.createdAt
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
function validateUserCreate(object) {
|
|
1023
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1024
|
+
if (!hasOwnProperty(object, "displayName")) return left("missing_display_name");
|
|
1025
|
+
if (!isNonEmptyString(object.displayName)) return left("invalid_display_name");
|
|
1026
|
+
if (!hasOwnProperty(object, "email")) return left("missing_email");
|
|
1027
|
+
if (!isNonEmptyString(object.email)) return left("invalid_email");
|
|
1028
|
+
if (!hasOwnProperty(object, "orgRole")) return left("missing_org_role");
|
|
1029
|
+
if (!isNonEmptyString(object.orgRole)) return left("invalid_org_role");
|
|
1030
|
+
return right({
|
|
1031
|
+
displayName: object.displayName,
|
|
1032
|
+
email: object.email,
|
|
1033
|
+
orgRole: object.orgRole
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
function validateUserSummary(object) {
|
|
1037
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1038
|
+
if (!hasOwnProperty(object, "id")) return left("missing_id");
|
|
1039
|
+
if (!isNonEmptyString(object.id)) return left("invalid_id");
|
|
1040
|
+
if (!hasOwnProperty(object, "displayName")) return left("missing_display_name");
|
|
1041
|
+
if (!isNonEmptyString(object.displayName)) return left("invalid_display_name");
|
|
1042
|
+
if (!hasOwnProperty(object, "email")) return left("missing_email");
|
|
1043
|
+
if (!isNonEmptyString(object.email)) return left("invalid_email");
|
|
1044
|
+
return right({
|
|
1045
|
+
id: object.id,
|
|
1046
|
+
displayName: object.displayName,
|
|
1047
|
+
email: object.email
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
function validateListUsers200Response(object) {
|
|
1051
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1052
|
+
if (!hasOwnProperty(object, "users")) return left("missing_users");
|
|
1053
|
+
if (!isArray(object.users)) return left("invalid_users");
|
|
1054
|
+
for (const user of object.users) if (isLeft(validateUserSummary(user))) return left("invalid_users");
|
|
1055
|
+
if (!hasOwnProperty(object, "pagination")) return left("missing_pagination");
|
|
1056
|
+
const paginationValidation = validatePagination(object.pagination);
|
|
1057
|
+
if (isLeft(paginationValidation)) return left("invalid_pagination");
|
|
1058
|
+
const users = [];
|
|
1059
|
+
for (const user of object.users) {
|
|
1060
|
+
const validatedUser = validateUserSummary(user);
|
|
1061
|
+
if (isRight(validatedUser)) users.push(validatedUser.right);
|
|
1062
|
+
}
|
|
1063
|
+
return right({
|
|
1064
|
+
users,
|
|
1065
|
+
pagination: paginationValidation.right
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
function validateRoleScope(object) {
|
|
1069
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1070
|
+
if (!hasOwnProperty(object, "type")) return left("missing_type");
|
|
1071
|
+
if (object.type === "org") return right({ type: "org" });
|
|
1072
|
+
else if (object.type === "space") {
|
|
1073
|
+
if (!hasOwnProperty(object, "spaceId")) return left("missing_space_id");
|
|
1074
|
+
if (!isNonEmptyString(object.spaceId)) return left("invalid_space_id");
|
|
1075
|
+
return right({
|
|
1076
|
+
type: "space",
|
|
1077
|
+
spaceId: object.spaceId
|
|
1078
|
+
});
|
|
1079
|
+
} else if (object.type === "group") {
|
|
1080
|
+
if (!hasOwnProperty(object, "groupId")) return left("missing_group_id");
|
|
1081
|
+
if (!isNonEmptyString(object.groupId)) return left("invalid_group_id");
|
|
1082
|
+
return right({
|
|
1083
|
+
type: "group",
|
|
1084
|
+
groupId: object.groupId
|
|
1085
|
+
});
|
|
1086
|
+
} else if (object.type === "workflow_template") {
|
|
1087
|
+
if (!hasOwnProperty(object, "workflowTemplateId")) return left("missing_workflow_template_id");
|
|
1088
|
+
if (!isNonEmptyString(object.workflowTemplateId)) return left("invalid_workflow_template_id");
|
|
1089
|
+
return right({
|
|
1090
|
+
type: "workflow_template",
|
|
1091
|
+
workflowTemplateId: object.workflowTemplateId
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
return left("invalid_type");
|
|
1095
|
+
}
|
|
1096
|
+
function validateRoleOperationItem(object) {
|
|
1097
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1098
|
+
if (!hasOwnProperty(object, "roleName")) return left("missing_role_name");
|
|
1099
|
+
if (!isNonEmptyString(object.roleName)) return left("invalid_role_name");
|
|
1100
|
+
if (!hasOwnProperty(object, "scope")) return left("missing_scope");
|
|
1101
|
+
const scopeValidation = validateRoleScope(object.scope);
|
|
1102
|
+
if (isLeft(scopeValidation)) return left("invalid_scope");
|
|
1103
|
+
return right({
|
|
1104
|
+
roleName: object.roleName,
|
|
1105
|
+
scope: scopeValidation.right
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
function validateRoleAssignmentRequest(object) {
|
|
1109
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1110
|
+
if (!hasOwnProperty(object, "roles")) return left("missing_roles");
|
|
1111
|
+
if (!isArray(object.roles)) return left("invalid_roles");
|
|
1112
|
+
const roles = [];
|
|
1113
|
+
for (const role of object.roles) {
|
|
1114
|
+
const roleValidation = validateRoleOperationItem(role);
|
|
1115
|
+
if (isLeft(roleValidation)) return left("invalid_roles");
|
|
1116
|
+
roles.push(roleValidation.right);
|
|
1117
|
+
}
|
|
1118
|
+
return right({ roles });
|
|
1119
|
+
}
|
|
1120
|
+
function validateRoleRemovalRequest(object) {
|
|
1121
|
+
return validateRoleAssignmentRequest(object);
|
|
1122
|
+
}
|
|
1123
|
+
//#endregion
|
|
1124
|
+
//#region src/validators/spaces.validators.ts
|
|
1125
|
+
function validateSpace(object) {
|
|
1126
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1127
|
+
if (!hasOwnProperty(object, "id")) return left("missing_id");
|
|
1128
|
+
if (!isNonEmptyString(object.id)) return left("invalid_id");
|
|
1129
|
+
if (!hasOwnProperty(object, "name")) return left("missing_name");
|
|
1130
|
+
if (!isNonEmptyString(object.name)) return left("invalid_name");
|
|
1131
|
+
if (!hasOwnProperty(object, "createdAt")) return left("missing_created_at");
|
|
1132
|
+
if (!isNonEmptyString(object.createdAt)) return left("invalid_created_at");
|
|
1133
|
+
if (!hasOwnProperty(object, "updatedAt")) return left("missing_updated_at");
|
|
1134
|
+
if (!isNonEmptyString(object.updatedAt)) return left("invalid_updated_at");
|
|
1135
|
+
const result = {
|
|
1136
|
+
id: object.id,
|
|
1137
|
+
name: object.name,
|
|
1138
|
+
createdAt: object.createdAt,
|
|
1139
|
+
updatedAt: object.updatedAt
|
|
1140
|
+
};
|
|
1141
|
+
if (hasOwnProperty(object, "description") && object.description !== void 0) {
|
|
1142
|
+
if (typeof object.description !== "string") return left("invalid_description");
|
|
1143
|
+
result.description = object.description;
|
|
1144
|
+
}
|
|
1145
|
+
return right(result);
|
|
1146
|
+
}
|
|
1147
|
+
function validateSpaceCreate(object) {
|
|
1148
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1149
|
+
if (!hasOwnProperty(object, "name")) return left("missing_name");
|
|
1150
|
+
if (!isNonEmptyString(object.name)) return left("invalid_name");
|
|
1151
|
+
const result = { name: object.name };
|
|
1152
|
+
if (hasOwnProperty(object, "description") && object.description !== void 0) {
|
|
1153
|
+
if (typeof object.description !== "string") return left("invalid_description");
|
|
1154
|
+
result.description = object.description;
|
|
1155
|
+
}
|
|
1156
|
+
return right(result);
|
|
1157
|
+
}
|
|
1158
|
+
function validateListSpaces200Response(object) {
|
|
1159
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1160
|
+
if (!hasOwnProperty(object, "data")) return left("missing_data");
|
|
1161
|
+
if (!isArray(object.data)) return left("invalid_data");
|
|
1162
|
+
const data = [];
|
|
1163
|
+
for (const item of object.data) {
|
|
1164
|
+
const validatedItem = validateSpace(item);
|
|
1165
|
+
if (isLeft(validatedItem)) return left("invalid_data");
|
|
1166
|
+
data.push(validatedItem.right);
|
|
1167
|
+
}
|
|
1168
|
+
if (!hasOwnProperty(object, "pagination")) return left("missing_pagination");
|
|
1169
|
+
const paginationValidation = validatePagination(object.pagination);
|
|
1170
|
+
if (isLeft(paginationValidation)) return left("invalid_pagination");
|
|
1171
|
+
return right({
|
|
1172
|
+
data,
|
|
1173
|
+
pagination: paginationValidation.right
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
function validateSpaceScope(object) {
|
|
1177
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1178
|
+
if (!hasOwnProperty(object, "type")) return left("missing_type");
|
|
1179
|
+
if (object.type !== "space") return left("invalid_type");
|
|
1180
|
+
if (!hasOwnProperty(object, "spaceId")) return left("missing_space_id");
|
|
1181
|
+
if (!isNonEmptyString(object.spaceId)) return left("invalid_space_id");
|
|
1182
|
+
return right({
|
|
1183
|
+
type: "space",
|
|
1184
|
+
spaceId: object.spaceId
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
//#endregion
|
|
1188
|
+
//#region src/validators/agents.validators.ts
|
|
1189
|
+
function validateAgentSummary(object) {
|
|
1190
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1191
|
+
if (!hasOwnProperty(object, "id") || !isNonEmptyString(object.id)) return left(hasOwnProperty(object, "id") ? "invalid_id" : "missing_id");
|
|
1192
|
+
if (!hasOwnProperty(object, "name") || !isNonEmptyString(object.name)) return left(hasOwnProperty(object, "name") ? "invalid_name" : "missing_name");
|
|
1193
|
+
return right({
|
|
1194
|
+
id: object.id,
|
|
1195
|
+
name: object.name
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
function validateAgentRegistrationRequest(object) {
|
|
1199
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1200
|
+
if (!hasOwnProperty(object, "agentName") || !isNonEmptyString(object.agentName)) return left(hasOwnProperty(object, "agentName") ? "invalid_agent_name" : "missing_agent_name");
|
|
1201
|
+
return right({ agentName: object.agentName });
|
|
1202
|
+
}
|
|
1203
|
+
function validateAgentChallengeRequest(object) {
|
|
1204
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1205
|
+
if (!hasOwnProperty(object, "agentName") || !isNonEmptyString(object.agentName)) return left(hasOwnProperty(object, "agentName") ? "invalid_agent_name" : "missing_agent_name");
|
|
1206
|
+
return right({ agentName: object.agentName });
|
|
1207
|
+
}
|
|
1208
|
+
function validateAgentChallengeResponse(object) {
|
|
1209
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1210
|
+
if (!hasOwnProperty(object, "challenge") || !isNonEmptyString(object.challenge)) return left(hasOwnProperty(object, "challenge") ? "invalid_challenge" : "missing_challenge");
|
|
1211
|
+
return right({ challenge: object.challenge });
|
|
1212
|
+
}
|
|
1213
|
+
function validateAgentTokenRequest(object) {
|
|
1214
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1215
|
+
if (!hasOwnProperty(object, "grantType")) return left("missing_grant_type");
|
|
1216
|
+
if (typeof object.grantType !== "string") return left("invalid_grant_type");
|
|
1217
|
+
const grantType = getStringAsEnum(object.grantType, AgentTokenRequest.GrantTypeEnum);
|
|
1218
|
+
if (!grantType) return left("invalid_grant_type");
|
|
1219
|
+
if (!hasOwnProperty(object, "clientAssertionType")) return left("missing_client_assertion_type");
|
|
1220
|
+
if (typeof object.clientAssertionType !== "string") return left("invalid_client_assertion_type");
|
|
1221
|
+
const clientAssertionType = getStringAsEnum(object.clientAssertionType, AgentTokenRequest.ClientAssertionTypeEnum);
|
|
1222
|
+
if (!clientAssertionType) return left("invalid_client_assertion_type");
|
|
1223
|
+
if (!hasOwnProperty(object, "clientAssertion") || !isNonEmptyString(object.clientAssertion)) return left(hasOwnProperty(object, "clientAssertion") ? "invalid_client_assertion" : "missing_client_assertion");
|
|
1224
|
+
return right({
|
|
1225
|
+
grantType,
|
|
1226
|
+
clientAssertionType,
|
|
1227
|
+
clientAssertion: object.clientAssertion
|
|
1228
|
+
});
|
|
1229
|
+
}
|
|
1230
|
+
function validateAgentTokenResponse(object) {
|
|
1231
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1232
|
+
if (!hasOwnProperty(object, "accessToken") || !isNonEmptyString(object.accessToken)) return left(hasOwnProperty(object, "accessToken") ? "invalid_access_token" : "missing_access_token");
|
|
1233
|
+
if (!hasOwnProperty(object, "refreshToken") || !isNonEmptyString(object.refreshToken)) return left(hasOwnProperty(object, "refreshToken") ? "invalid_refresh_token" : "missing_refresh_token");
|
|
1234
|
+
return right({
|
|
1235
|
+
accessToken: object.accessToken,
|
|
1236
|
+
refreshToken: object.refreshToken
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
function validateListAgentsParams(object) {
|
|
1240
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1241
|
+
let page = void 0;
|
|
1242
|
+
if (hasOwnProperty(object, "page") && object.page !== void 0) {
|
|
1243
|
+
if (typeof object.page !== "number") return left("invalid_page");
|
|
1244
|
+
page = object.page;
|
|
1245
|
+
}
|
|
1246
|
+
let limit = void 0;
|
|
1247
|
+
if (hasOwnProperty(object, "limit") && object.limit !== void 0) {
|
|
1248
|
+
if (typeof object.limit !== "number") return left("invalid_limit");
|
|
1249
|
+
limit = object.limit;
|
|
1250
|
+
}
|
|
1251
|
+
return right({
|
|
1252
|
+
page,
|
|
1253
|
+
limit
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
function validateListAgents200Response(object) {
|
|
1257
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1258
|
+
if (!hasOwnProperty(object, "agents") || !isArray(object.agents)) return left(hasOwnProperty(object, "agents") ? "invalid_agents" : "missing_agents");
|
|
1259
|
+
const agents = [];
|
|
1260
|
+
for (const item of object.agents) {
|
|
1261
|
+
const validatedItem = validateAgentSummary(item);
|
|
1262
|
+
if (isLeft(validatedItem)) return left("invalid_agents");
|
|
1263
|
+
agents.push(validatedItem.right);
|
|
1264
|
+
}
|
|
1265
|
+
if (!hasOwnProperty(object, "pagination")) return left("missing_pagination");
|
|
1266
|
+
const paginationValidation = validatePagination(object.pagination);
|
|
1267
|
+
if (isLeft(paginationValidation)) return left("invalid_pagination");
|
|
1268
|
+
return right({
|
|
1269
|
+
agents,
|
|
1270
|
+
pagination: paginationValidation.right
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
function validateAgentGet200Response(object) {
|
|
1274
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1275
|
+
if (!hasOwnProperty(object, "id") || !isNonEmptyString(object.id)) return left(hasOwnProperty(object, "id") ? "invalid_id" : "missing_id");
|
|
1276
|
+
if (!hasOwnProperty(object, "agentName") || !isNonEmptyString(object.agentName)) return left(hasOwnProperty(object, "agentName") ? "invalid_agent_name" : "missing_agent_name");
|
|
1277
|
+
if (!hasOwnProperty(object, "publicKey") || !isNonEmptyString(object.publicKey)) return left(hasOwnProperty(object, "publicKey") ? "invalid_public_key" : "missing_public_key");
|
|
1278
|
+
if (!hasOwnProperty(object, "createdAt") || !isNonEmptyString(object.createdAt)) return left(hasOwnProperty(object, "createdAt") ? "invalid_created_at" : "missing_created_at");
|
|
1279
|
+
return right({
|
|
1280
|
+
id: object.id,
|
|
1281
|
+
agentName: object.agentName,
|
|
1282
|
+
publicKey: object.publicKey,
|
|
1283
|
+
createdAt: object.createdAt
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
//#endregion
|
|
1287
|
+
//#region src/validators/organization-admins.validators.ts
|
|
1288
|
+
function validateOrganizationAdmin(object) {
|
|
1289
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1290
|
+
if (!hasOwnProperty(object, "userId") || !isNonEmptyString(object.userId)) return left(hasOwnProperty(object, "userId") ? "invalid_user_id" : "missing_user_id");
|
|
1291
|
+
if (!hasOwnProperty(object, "email") || !isNonEmptyString(object.email)) return left(hasOwnProperty(object, "email") ? "invalid_email" : "missing_email");
|
|
1292
|
+
if (!hasOwnProperty(object, "createdAt") || !isNonEmptyString(object.createdAt)) return left(hasOwnProperty(object, "createdAt") ? "invalid_created_at" : "missing_created_at");
|
|
1293
|
+
return right({
|
|
1294
|
+
userId: object.userId,
|
|
1295
|
+
email: object.email,
|
|
1296
|
+
createdAt: object.createdAt
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
function validateOrganizationAdminCreate(object) {
|
|
1300
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1301
|
+
if (!hasOwnProperty(object, "email") || !isNonEmptyString(object.email)) return left(hasOwnProperty(object, "email") ? "invalid_email" : "missing_email");
|
|
1302
|
+
return right({ email: object.email });
|
|
1303
|
+
}
|
|
1304
|
+
function validateOrganizationAdminRemove(object) {
|
|
1305
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1306
|
+
if (!hasOwnProperty(object, "userId") || !isNonEmptyString(object.userId)) return left(hasOwnProperty(object, "userId") ? "invalid_user_id" : "missing_user_id");
|
|
1307
|
+
return right({ userId: object.userId });
|
|
1308
|
+
}
|
|
1309
|
+
function validateListOrganizationAdminsForOrg200Response(object) {
|
|
1310
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1311
|
+
if (!hasOwnProperty(object, "data") || !isArray(object.data)) return left(hasOwnProperty(object, "data") ? "invalid_data" : "missing_data");
|
|
1312
|
+
const data = [];
|
|
1313
|
+
for (const item of object.data) {
|
|
1314
|
+
const validatedItem = validateOrganizationAdmin(item);
|
|
1315
|
+
if (isLeft(validatedItem)) return left("invalid_data");
|
|
1316
|
+
data.push(validatedItem.right);
|
|
1317
|
+
}
|
|
1318
|
+
if (!hasOwnProperty(object, "pagination")) return left("missing_pagination");
|
|
1319
|
+
const paginationValidation = validatePagination(object.pagination);
|
|
1320
|
+
if (isLeft(paginationValidation)) return left("invalid_pagination");
|
|
1321
|
+
return right({
|
|
1322
|
+
data,
|
|
1323
|
+
pagination: paginationValidation.right
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
//#endregion
|
|
1327
|
+
//#region src/validators/roles.validators.ts
|
|
1328
|
+
function validateRoleTemplate(object) {
|
|
1329
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1330
|
+
if (!hasOwnProperty(object, "name") || !isNonEmptyString(object.name)) return left(hasOwnProperty(object, "name") ? "invalid_name" : "missing_name");
|
|
1331
|
+
if (!hasOwnProperty(object, "scope") || !isNonEmptyString(object.scope)) return left(hasOwnProperty(object, "scope") ? "invalid_scope" : "missing_scope");
|
|
1332
|
+
if (!hasOwnProperty(object, "permissions") || !isArray(object.permissions)) return left(hasOwnProperty(object, "permissions") ? "invalid_permissions" : "missing_permissions");
|
|
1333
|
+
const permissions = [];
|
|
1334
|
+
for (const perm of object.permissions) {
|
|
1335
|
+
if (!isNonEmptyString(perm)) return left("invalid_permissions");
|
|
1336
|
+
permissions.push(perm);
|
|
1337
|
+
}
|
|
1338
|
+
return right({
|
|
1339
|
+
name: object.name,
|
|
1340
|
+
permissions,
|
|
1341
|
+
scope: object.scope
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
function validateListRoleTemplates200Response(object) {
|
|
1345
|
+
if (typeof object !== "object" || object === null) return left("malformed_object");
|
|
1346
|
+
if (!hasOwnProperty(object, "roles") || !isArray(object.roles)) return left(hasOwnProperty(object, "roles") ? "invalid_roles" : "missing_roles");
|
|
1347
|
+
const roles = [];
|
|
1348
|
+
for (const item of object.roles) {
|
|
1349
|
+
const validatedItem = validateRoleTemplate(item);
|
|
1350
|
+
if (isLeft(validatedItem)) return left("invalid_roles");
|
|
1351
|
+
roles.push(validatedItem.right);
|
|
1352
|
+
}
|
|
1353
|
+
return right({ roles });
|
|
1354
|
+
}
|
|
1355
|
+
//#endregion
|
|
1356
|
+
export { AgentTokenRequest, AndRule, EmailAction, GroupRequirementRule, GroupScope, OrRule, OrgScope, SpaceScope, VoteApprove, VoteVeto, VoteWithdraw, WebhookAction, WorkflowTemplate, WorkflowTemplateScope, validateAPIError, validateAddGroupEntitiesRequest, validateAgentChallengeRequest, validateAgentChallengeResponse, validateAgentGet200Response, validateAgentRegistrationRequest, validateAgentRegistrationResponse, validateAgentTokenRequest, validateAgentTokenResponse, validateCanVoteResponse, validateGetEntityInfo200Response, validateGetWorkflowParams, validateGetWorkflowVotes200Response, validateGroupCreate, validateGroupInfo, validateGroupScope, validateHealthResponse, validateInitiateCliLogin200Response, validateInitiateCliLoginRequest, validateListAgents200Response, validateListAgentsParams, validateListGroupEntities200Response, validateListGroups200Response, validateListOrganizationAdminsForOrg200Response, validateListRoleTemplates200Response, validateListSpaces200Response, validateListUsers200Response, validateListWorkflowTemplates200Response, validateListWorkflowTemplatesParams, validateListWorkflows200Response, validateListWorkflowsParams, validateOidcCallbackRequest, validateOrganizationAdminCreate, validateOrganizationAdminRemove, validatePagination, validatePrivilegedTokenExchangeRequest, validatePrivilegedTokenResponse, validateRefreshTokenRequest, validateRemoveGroupEntitiesRequest, validateRoleAssignmentRequest, validateRoleRemovalRequest, validateSpaceCreate, validateSpaceScope, validateTokenRequest, validateTokenResponse, validateUser, validateUserCreate, validateWorkflowCreate, validateWorkflowTemplate, validateWorkflowTemplateCreate, validateWorkflowTemplateDeprecate, validateWorkflowTemplateScope, validateWorkflowTemplateUpdate, validateWorkflowVoteRequest };
|