@rytass/bpm-core-shared 0.1.3 → 0.1.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rytass
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rytass/bpm-core-shared",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Shared TypeScript contracts for the Rytass BPM approval workflow stack (workflow, form, condition, identity, organization, status types).",
5
5
  "keywords": [
6
6
  "bpm",
@@ -75,4 +75,4 @@
75
75
  "dependencies": {
76
76
  "tslib": "^2.3.0"
77
77
  }
78
- }
78
+ }
package/src/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./lib/condition"), exports);
5
+ tslib_1.__exportStar(require("./lib/form"), exports);
6
+ tslib_1.__exportStar(require("./lib/identity"), exports);
7
+ tslib_1.__exportStar(require("./lib/organization"), exports);
8
+ tslib_1.__exportStar(require("./lib/status"), exports);
9
+ tslib_1.__exportStar(require("./lib/workflow"), exports);
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/shared/src/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,qDAA2B;AAC3B,yDAA+B;AAC/B,6DAAmC;AACnC,uDAA6B;AAC7B,yDAA+B"}
@@ -0,0 +1,43 @@
1
+ export type ConditionContextType = 'INITIATOR_POLICY' | 'ENTRY_CONDITION' | 'FLOW_CONDITION' | 'APPROVER_RESOLVER' | 'FORM_FIELD_CONDITION' | 'DELEGATION_CONDITION';
2
+ export interface SubjectContext {
3
+ readonly customFields: Readonly<Record<string, unknown>>;
4
+ readonly email: string;
5
+ readonly memberId: string;
6
+ readonly name: string;
7
+ readonly org: OrgContext;
8
+ readonly position: PositionContext;
9
+ readonly roles: readonly string[];
10
+ }
11
+ export interface OrgContext {
12
+ readonly code: string;
13
+ readonly costCenter?: string;
14
+ readonly id: string;
15
+ readonly location?: string;
16
+ readonly name: string;
17
+ readonly parentId: string | null;
18
+ readonly path: readonly string[];
19
+ readonly type: string;
20
+ }
21
+ export interface PositionContext {
22
+ readonly code: string;
23
+ readonly id: string;
24
+ readonly level: number;
25
+ readonly name: string;
26
+ }
27
+ export interface EnvContext {
28
+ readonly now: string;
29
+ }
30
+ export interface InstanceContext {
31
+ readonly id: string;
32
+ readonly startedAt: string;
33
+ readonly templateId: string;
34
+ readonly templateVersion: number;
35
+ }
36
+ export interface LastDecisionContext {
37
+ readonly action: 'approved' | 'rejected' | 'returned';
38
+ readonly comment: string;
39
+ readonly decidedAt: string;
40
+ readonly decidedBy: SubjectContext;
41
+ readonly nodeId: string;
42
+ readonly taskId: string;
43
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=condition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../../../libs/shared/src/lib/condition.ts"],"names":[],"mappings":""}
@@ -0,0 +1,48 @@
1
+ export interface FormDefinitionSchema {
2
+ readonly fields: readonly FormFieldDefinition[];
3
+ readonly schemaVersion: 1;
4
+ }
5
+ export type FormFieldDefinition = TextFieldDefinition | NumberFieldDefinition | DateFieldDefinition | SelectFieldDefinition | BooleanFieldDefinition | FileUploadFieldDefinition;
6
+ interface BaseFormFieldDefinition<TType extends string> {
7
+ readonly defaultValue?: FormFieldValue;
8
+ readonly description?: string;
9
+ readonly fieldKey: string;
10
+ readonly label: string;
11
+ readonly placeholder?: string;
12
+ readonly readonlyWhen?: string;
13
+ readonly required: boolean;
14
+ readonly requiredWhen?: string;
15
+ readonly type: TType;
16
+ readonly visibleWhen?: string;
17
+ }
18
+ export type FormFieldValue = boolean | number | string | readonly string[] | null;
19
+ export type TextFieldDefinition = BaseFormFieldDefinition<'text' | 'textarea'> & {
20
+ readonly maxLength?: number;
21
+ readonly minLength?: number;
22
+ };
23
+ export type NumberFieldDefinition = BaseFormFieldDefinition<'number' | 'money'> & {
24
+ readonly maximum?: number;
25
+ readonly minimum?: number;
26
+ };
27
+ export type DateFieldDefinition = BaseFormFieldDefinition<'date' | 'datetime'>;
28
+ export type SelectFieldDefinition = BaseFormFieldDefinition<'select' | 'radio' | 'checkbox'> & {
29
+ readonly options: readonly FormFieldOption[];
30
+ };
31
+ export interface FormFieldOption {
32
+ readonly label: string;
33
+ readonly value: string;
34
+ }
35
+ export type BooleanFieldDefinition = BaseFormFieldDefinition<'boolean'>;
36
+ export type FileUploadFieldDefinition = BaseFormFieldDefinition<'file_upload'> & {
37
+ readonly acceptedMimeTypes?: readonly string[];
38
+ readonly maxFiles?: number;
39
+ };
40
+ export interface FormUiSchema {
41
+ readonly layout: readonly FormLayoutItem[];
42
+ readonly schemaVersion: 1;
43
+ }
44
+ export interface FormLayoutItem {
45
+ readonly fieldKey: string;
46
+ readonly width: 'FULL' | 'HALF' | 'THIRD';
47
+ }
48
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.js","sourceRoot":"","sources":["../../../../../libs/shared/src/lib/form.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ export interface MemberMetadata {
2
+ readonly memberId: string;
3
+ readonly name: string;
4
+ readonly email: string;
5
+ readonly customFields: Readonly<Record<string, unknown>>;
6
+ }
7
+ export interface MemberMetadataCacheEntry {
8
+ readonly id: string;
9
+ readonly memberId: string;
10
+ readonly metadata: MemberMetadata;
11
+ readonly fetchedAt: string;
12
+ readonly expiresAt: string;
13
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../../../libs/shared/src/lib/identity.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ export type OrgUnitType = 'company' | 'division' | 'department' | 'team';
2
+ export type ManagerResolutionScopeType = 'MEMBER' | 'ORG_UNIT' | 'POSITION';
3
+ export interface OrgUnit {
4
+ readonly id: string;
5
+ readonly parentId: string | null;
6
+ readonly code: string;
7
+ readonly name: string;
8
+ readonly type: OrgUnitType;
9
+ readonly path: string;
10
+ readonly metadata: Readonly<Record<string, unknown>>;
11
+ }
12
+ export interface Position {
13
+ readonly id: string;
14
+ readonly code: string;
15
+ readonly name: string;
16
+ readonly level: number;
17
+ readonly metadata: Readonly<Record<string, unknown>>;
18
+ }
19
+ export interface Membership {
20
+ readonly id: string;
21
+ readonly memberId: string;
22
+ readonly orgUnitId: string;
23
+ readonly positionId: string | null;
24
+ readonly isPrimary: boolean;
25
+ readonly effectiveFrom: string;
26
+ readonly effectiveTo: string | null;
27
+ }
28
+ export interface ManagerResolution {
29
+ readonly id: string;
30
+ readonly scopeType: ManagerResolutionScopeType;
31
+ readonly scopeId: string;
32
+ readonly managerMemberId: string;
33
+ readonly priority: number;
34
+ readonly effectiveFrom: string;
35
+ readonly effectiveTo: string | null;
36
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=organization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.js","sourceRoot":"","sources":["../../../../../libs/shared/src/lib/organization.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export type VersionStatus = 'DRAFT' | 'PUBLISHED' | 'ARCHIVED';
2
+ export type ApprovalInstanceState = 'DRAFT' | 'RUNNING' | 'APPROVED' | 'REJECTED' | 'RETURNED' | 'CANCELLED' | 'EXPIRED';
3
+ export type WorkflowTokenStatus = 'ACTIVE' | 'WAITING' | 'CONSUMED';
4
+ export type TaskStatus = 'PENDING' | 'IN_PROGRESS' | 'COMPLETED' | 'TRANSFERRED' | 'CANCELLED';
5
+ export type TaskDecisionAction = 'APPROVED' | 'REJECTED' | 'RETURNED' | 'TRANSFERRED';
6
+ export type DelegationRuleStatus = 'ACTIVE' | 'REVOKED' | 'EXPIRED';
7
+ export type DelegationScopeType = 'ALL' | 'TEMPLATE_LIST' | 'CONDITION_BASED';
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../../../libs/shared/src/lib/status.ts"],"names":[],"mappings":""}
@@ -0,0 +1,160 @@
1
+ export interface WorkflowDefinition {
2
+ readonly edges: readonly WorkflowEdge[];
3
+ readonly meta: WorkflowDefinitionMeta;
4
+ readonly nodes: readonly WorkflowNode[];
5
+ }
6
+ export interface WorkflowDefinitionMeta {
7
+ readonly diagramVersion?: string;
8
+ readonly schemaVersion: 1;
9
+ }
10
+ export type WorkflowNode = StartEventNode | EndEventNode | UserTaskNode | ServiceTaskNode | ExclusiveGatewayNode | ParallelGatewayNode;
11
+ export interface NodePosition {
12
+ readonly x: number;
13
+ readonly y: number;
14
+ }
15
+ export interface BaseNodeData {
16
+ readonly label: string;
17
+ readonly triggerMode?: WorkflowNodeTriggerMode;
18
+ }
19
+ export type WorkflowNodeTriggerMode = 'AND' | 'OR';
20
+ export interface BaseWorkflowNode<TType extends string, TData extends BaseNodeData> {
21
+ readonly data: TData;
22
+ readonly id: string;
23
+ readonly position: NodePosition;
24
+ readonly type: TType;
25
+ }
26
+ export type StartEventNode = BaseWorkflowNode<'startEvent', BaseNodeData>;
27
+ export type EndEventNode = BaseWorkflowNode<'endEvent', BaseNodeData & {
28
+ readonly endState?: 'APPROVED' | 'REJECTED';
29
+ }>;
30
+ export type UserTaskNode = BaseWorkflowNode<'userTask', UserTaskNodeData>;
31
+ export interface UserTaskNodeData extends BaseNodeData {
32
+ readonly allowAddSigner: boolean;
33
+ readonly allowReject: boolean;
34
+ readonly allowTransfer: boolean;
35
+ readonly approverResolver: ApproverResolver;
36
+ readonly decisionPolicy: DecisionPolicy;
37
+ readonly description?: string;
38
+ readonly entryCondition?: string;
39
+ readonly fieldPermissions?: readonly FieldPermission[];
40
+ readonly notification?: NotificationOverride;
41
+ readonly returnBehavior: ReturnBehavior;
42
+ readonly sla?: SlaConfig;
43
+ }
44
+ export type ApproverResolver = {
45
+ readonly memberIds: readonly string[];
46
+ readonly type: 'DIRECT';
47
+ } | {
48
+ readonly positionId: string;
49
+ readonly type: 'POSITION';
50
+ } | {
51
+ readonly includeDescendants?: boolean;
52
+ readonly orgUnitId: string;
53
+ readonly type: 'ORG_UNIT_MEMBER';
54
+ } | {
55
+ readonly includeDescendants?: boolean;
56
+ readonly orgUnitId: string;
57
+ readonly positionId: string;
58
+ readonly type: 'ORG_UNIT_POSITION';
59
+ } | {
60
+ readonly baseFromInitiator: boolean;
61
+ readonly fallback?: ApproverResolverFallback;
62
+ readonly levelsUp: number;
63
+ readonly type: 'ORG_MANAGER';
64
+ } | {
65
+ readonly fallback?: ApproverResolverFallback;
66
+ readonly orgUnitId: string;
67
+ readonly type: 'ORG_UNIT_MANAGER';
68
+ } | {
69
+ readonly formPath: string;
70
+ readonly type: 'DYNAMIC_FORM';
71
+ } | {
72
+ readonly expression: string;
73
+ readonly type: 'EXPRESSION';
74
+ };
75
+ export type ApproverResolverFallback = {
76
+ readonly type: 'NONE';
77
+ } | {
78
+ readonly allowInitiatorSelfApproval?: boolean;
79
+ readonly memberId: string;
80
+ readonly type: 'DIRECT';
81
+ };
82
+ export type DecisionPolicy = {
83
+ readonly type: 'SINGLE';
84
+ } | {
85
+ readonly type: 'SEQUENTIAL';
86
+ } | {
87
+ readonly type: 'PARALLEL_ALL';
88
+ } | {
89
+ readonly type: 'PARALLEL_ANY';
90
+ } | {
91
+ readonly threshold: number;
92
+ readonly thresholdType: 'COUNT' | 'PERCENTAGE';
93
+ readonly type: 'QUORUM';
94
+ };
95
+ export interface ReturnBehavior {
96
+ readonly allowReturn: boolean;
97
+ readonly allowedTargets: 'PREVIOUS' | 'INITIATOR' | 'ANY';
98
+ readonly resubmitStrategy?: ReturnResubmitStrategy;
99
+ }
100
+ export type ReturnResubmitStrategy = 'FROM_RETURN_POINT' | 'RESTART';
101
+ export interface SlaConfig {
102
+ readonly duration: string;
103
+ readonly escalateLevelsUp?: number;
104
+ readonly onTimeout: 'REMIND' | 'AUTO_APPROVE' | 'ESCALATE' | 'TERMINATE_INSTANCE';
105
+ readonly warningAt?: number;
106
+ }
107
+ export interface FieldPermission {
108
+ readonly editable: boolean;
109
+ readonly fieldPath: string;
110
+ readonly visible: boolean;
111
+ }
112
+ export interface NotificationOverride {
113
+ readonly channels?: readonly NotificationChannel[];
114
+ readonly customTemplate?: string;
115
+ }
116
+ export type NotificationChannel = 'IN_APP' | 'EMAIL' | 'WEBHOOK';
117
+ export type ServiceTaskNode = BaseWorkflowNode<'serviceTask', BaseNodeData & {
118
+ readonly action: ServiceAction;
119
+ readonly entryCondition?: string;
120
+ }>;
121
+ export type ServiceAction = {
122
+ readonly channels: readonly Exclude<NotificationChannel, 'WEBHOOK'>[];
123
+ readonly recipients: ApproverResolver;
124
+ readonly template?: string;
125
+ readonly type: 'NOTIFY';
126
+ } | {
127
+ readonly headers?: Readonly<Record<string, string>>;
128
+ readonly payload?: string;
129
+ readonly type: 'WEBHOOK';
130
+ readonly url: string;
131
+ } | {
132
+ readonly fieldPath: string;
133
+ readonly type: 'SET_FORM_FIELD';
134
+ readonly value: string;
135
+ };
136
+ export type ExclusiveGatewayNode = BaseWorkflowNode<'exclusiveGateway', BaseNodeData & {
137
+ readonly direction: GatewayDirection;
138
+ }>;
139
+ export type ParallelGatewayNode = BaseWorkflowNode<'parallelGateway', BaseNodeData & {
140
+ readonly direction: GatewayDirection;
141
+ }>;
142
+ export type GatewayDirection = 'split' | 'join';
143
+ export interface WorkflowEdge {
144
+ readonly data: WorkflowEdgeData;
145
+ readonly id: string;
146
+ readonly source: string;
147
+ readonly sourceHandle?: string | null;
148
+ readonly target: string;
149
+ readonly targetHandle?: string | null;
150
+ readonly type?: 'smoothstep';
151
+ }
152
+ export interface WorkflowEdgeData {
153
+ readonly condition?: string;
154
+ readonly conditionFieldKey?: string;
155
+ readonly conditionOperator?: WorkflowEdgeConditionOperator;
156
+ readonly conditionValue?: string;
157
+ readonly isDefault?: boolean;
158
+ readonly label?: string;
159
+ }
160
+ export type WorkflowEdgeConditionOperator = 'EQUALS' | 'GREATER_THAN' | 'GREATER_THAN_OR_EQUALS' | 'IS_EMPTY' | 'IS_FILLED' | 'LESS_THAN' | 'LESS_THAN_OR_EQUALS' | 'NOT_EQUALS';
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../../../../libs/shared/src/lib/workflow.ts"],"names":[],"mappings":""}
package/eslint.config.mjs DELETED
@@ -1,19 +0,0 @@
1
- import baseConfig from '../../eslint.config.mjs';
2
-
3
- export default [
4
- ...baseConfig,
5
- {
6
- files: ['**/*.json'],
7
- rules: {
8
- '@nx/dependency-checks': [
9
- 'error',
10
- {
11
- ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}'],
12
- },
13
- ],
14
- },
15
- languageOptions: {
16
- parser: await import('jsonc-eslint-parser'),
17
- },
18
- },
19
- ];
package/jest.config.cts DELETED
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- displayName: 'shared',
3
- preset: '../../jest.preset.js',
4
- testEnvironment: 'node',
5
- transform: {
6
- '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
7
- },
8
- moduleFileExtensions: ['ts', 'js', 'html'],
9
- coverageDirectory: '../../coverage/libs/shared',
10
- };
package/project.json DELETED
@@ -1,49 +0,0 @@
1
- {
2
- "name": "shared",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "libs/shared/src",
5
- "projectType": "library",
6
- "tags": [],
7
- "targets": {
8
- "build": {
9
- "executor": "@nx/js:tsc",
10
- "outputs": ["{options.outputPath}"],
11
- "options": {
12
- "outputPath": "dist/libs/shared",
13
- "main": "libs/shared/src/index.ts",
14
- "tsConfig": "libs/shared/tsconfig.lib.json",
15
- "assets": [
16
- "libs/shared/*.md",
17
- { "input": ".", "glob": "LICENSE", "output": "." }
18
- ]
19
- }
20
- },
21
- "typecheck": {
22
- "executor": "nx:run-commands",
23
- "options": {
24
- "command": "tsc --noEmit -p libs/shared/tsconfig.lib.json"
25
- }
26
- },
27
- "pkg-quality": {
28
- "executor": "nx:run-commands",
29
- "dependsOn": ["build"],
30
- "options": {
31
- "commands": [
32
- "pnpm exec publint dist/libs/shared"
33
- ],
34
- "parallel": false
35
- }
36
- },
37
- "pkg-quality-attw": {
38
- "executor": "nx:run-commands",
39
- "dependsOn": ["build"],
40
- "options": {
41
- "command": "pnpm exec attw --pack dist/libs/shared"
42
- }
43
- },
44
- "prepublish-check": {
45
- "executor": "nx:noop",
46
- "dependsOn": ["typecheck", "lint", "build", "pkg-quality"]
47
- }
48
- }
49
- }
@@ -1,55 +0,0 @@
1
- export type ConditionContextType =
2
- | 'INITIATOR_POLICY'
3
- | 'ENTRY_CONDITION'
4
- | 'FLOW_CONDITION'
5
- | 'APPROVER_RESOLVER'
6
- | 'FORM_FIELD_CONDITION'
7
- | 'DELEGATION_CONDITION';
8
-
9
- export interface SubjectContext {
10
- readonly customFields: Readonly<Record<string, unknown>>;
11
- readonly email: string;
12
- readonly memberId: string;
13
- readonly name: string;
14
- readonly org: OrgContext;
15
- readonly position: PositionContext;
16
- readonly roles: readonly string[];
17
- }
18
-
19
- export interface OrgContext {
20
- readonly code: string;
21
- readonly costCenter?: string;
22
- readonly id: string;
23
- readonly location?: string;
24
- readonly name: string;
25
- readonly parentId: string | null;
26
- readonly path: readonly string[];
27
- readonly type: string;
28
- }
29
-
30
- export interface PositionContext {
31
- readonly code: string;
32
- readonly id: string;
33
- readonly level: number;
34
- readonly name: string;
35
- }
36
-
37
- export interface EnvContext {
38
- readonly now: string;
39
- }
40
-
41
- export interface InstanceContext {
42
- readonly id: string;
43
- readonly startedAt: string;
44
- readonly templateId: string;
45
- readonly templateVersion: number;
46
- }
47
-
48
- export interface LastDecisionContext {
49
- readonly action: 'approved' | 'rejected' | 'returned';
50
- readonly comment: string;
51
- readonly decidedAt: string;
52
- readonly decidedBy: SubjectContext;
53
- readonly nodeId: string;
54
- readonly taskId: string;
55
- }
package/src/lib/form.ts DELETED
@@ -1,77 +0,0 @@
1
- export interface FormDefinitionSchema {
2
- readonly fields: readonly FormFieldDefinition[];
3
- readonly schemaVersion: 1;
4
- }
5
-
6
- export type FormFieldDefinition =
7
- | TextFieldDefinition
8
- | NumberFieldDefinition
9
- | DateFieldDefinition
10
- | SelectFieldDefinition
11
- | BooleanFieldDefinition
12
- | FileUploadFieldDefinition;
13
-
14
- interface BaseFormFieldDefinition<TType extends string> {
15
- readonly defaultValue?: FormFieldValue;
16
- readonly description?: string;
17
- readonly fieldKey: string;
18
- readonly label: string;
19
- readonly placeholder?: string;
20
- readonly readonlyWhen?: string;
21
- readonly required: boolean;
22
- readonly requiredWhen?: string;
23
- readonly type: TType;
24
- readonly visibleWhen?: string;
25
- }
26
-
27
- export type FormFieldValue =
28
- | boolean
29
- | number
30
- | string
31
- | readonly string[]
32
- | null;
33
-
34
- export type TextFieldDefinition = BaseFormFieldDefinition<
35
- 'text' | 'textarea'
36
- > & {
37
- readonly maxLength?: number;
38
- readonly minLength?: number;
39
- };
40
-
41
- export type NumberFieldDefinition = BaseFormFieldDefinition<
42
- 'number' | 'money'
43
- > & {
44
- readonly maximum?: number;
45
- readonly minimum?: number;
46
- };
47
-
48
- export type DateFieldDefinition = BaseFormFieldDefinition<'date' | 'datetime'>;
49
-
50
- export type SelectFieldDefinition = BaseFormFieldDefinition<
51
- 'select' | 'radio' | 'checkbox'
52
- > & {
53
- readonly options: readonly FormFieldOption[];
54
- };
55
-
56
- export interface FormFieldOption {
57
- readonly label: string;
58
- readonly value: string;
59
- }
60
-
61
- export type BooleanFieldDefinition = BaseFormFieldDefinition<'boolean'>;
62
-
63
- export type FileUploadFieldDefinition =
64
- BaseFormFieldDefinition<'file_upload'> & {
65
- readonly acceptedMimeTypes?: readonly string[];
66
- readonly maxFiles?: number;
67
- };
68
-
69
- export interface FormUiSchema {
70
- readonly layout: readonly FormLayoutItem[];
71
- readonly schemaVersion: 1;
72
- }
73
-
74
- export interface FormLayoutItem {
75
- readonly fieldKey: string;
76
- readonly width: 'FULL' | 'HALF' | 'THIRD';
77
- }
@@ -1,14 +0,0 @@
1
- export interface MemberMetadata {
2
- readonly memberId: string;
3
- readonly name: string;
4
- readonly email: string;
5
- readonly customFields: Readonly<Record<string, unknown>>;
6
- }
7
-
8
- export interface MemberMetadataCacheEntry {
9
- readonly id: string;
10
- readonly memberId: string;
11
- readonly metadata: MemberMetadata;
12
- readonly fetchedAt: string;
13
- readonly expiresAt: string;
14
- }
@@ -1,41 +0,0 @@
1
- export type OrgUnitType = 'company' | 'division' | 'department' | 'team';
2
-
3
- export type ManagerResolutionScopeType = 'MEMBER' | 'ORG_UNIT' | 'POSITION';
4
-
5
- export interface OrgUnit {
6
- readonly id: string;
7
- readonly parentId: string | null;
8
- readonly code: string;
9
- readonly name: string;
10
- readonly type: OrgUnitType;
11
- readonly path: string;
12
- readonly metadata: Readonly<Record<string, unknown>>;
13
- }
14
-
15
- export interface Position {
16
- readonly id: string;
17
- readonly code: string;
18
- readonly name: string;
19
- readonly level: number;
20
- readonly metadata: Readonly<Record<string, unknown>>;
21
- }
22
-
23
- export interface Membership {
24
- readonly id: string;
25
- readonly memberId: string;
26
- readonly orgUnitId: string;
27
- readonly positionId: string | null;
28
- readonly isPrimary: boolean;
29
- readonly effectiveFrom: string;
30
- readonly effectiveTo: string | null;
31
- }
32
-
33
- export interface ManagerResolution {
34
- readonly id: string;
35
- readonly scopeType: ManagerResolutionScopeType;
36
- readonly scopeId: string;
37
- readonly managerMemberId: string;
38
- readonly priority: number;
39
- readonly effectiveFrom: string;
40
- readonly effectiveTo: string | null;
41
- }
@@ -1,13 +0,0 @@
1
- import { WorkflowDefinition } from './workflow';
2
-
3
- describe('shared', () => {
4
- it('exports workflow definition types', () => {
5
- const workflow: WorkflowDefinition = {
6
- edges: [],
7
- meta: { schemaVersion: 1 },
8
- nodes: [],
9
- };
10
-
11
- expect(workflow.meta.schemaVersion).toBe(1);
12
- });
13
- });
package/src/lib/status.ts DELETED
@@ -1,29 +0,0 @@
1
- export type VersionStatus = 'DRAFT' | 'PUBLISHED' | 'ARCHIVED';
2
-
3
- export type ApprovalInstanceState =
4
- | 'DRAFT'
5
- | 'RUNNING'
6
- | 'APPROVED'
7
- | 'REJECTED'
8
- | 'RETURNED'
9
- | 'CANCELLED'
10
- | 'EXPIRED';
11
-
12
- export type WorkflowTokenStatus = 'ACTIVE' | 'WAITING' | 'CONSUMED';
13
-
14
- export type TaskStatus =
15
- | 'PENDING'
16
- | 'IN_PROGRESS'
17
- | 'COMPLETED'
18
- | 'TRANSFERRED'
19
- | 'CANCELLED';
20
-
21
- export type TaskDecisionAction =
22
- | 'APPROVED'
23
- | 'REJECTED'
24
- | 'RETURNED'
25
- | 'TRANSFERRED';
26
-
27
- export type DelegationRuleStatus = 'ACTIVE' | 'REVOKED' | 'EXPIRED';
28
-
29
- export type DelegationScopeType = 'ALL' | 'TEMPLATE_LIST' | 'CONDITION_BASED';
@@ -1,216 +0,0 @@
1
- export interface WorkflowDefinition {
2
- readonly edges: readonly WorkflowEdge[];
3
- readonly meta: WorkflowDefinitionMeta;
4
- readonly nodes: readonly WorkflowNode[];
5
- }
6
-
7
- export interface WorkflowDefinitionMeta {
8
- readonly diagramVersion?: string;
9
- readonly schemaVersion: 1;
10
- }
11
-
12
- export type WorkflowNode =
13
- | StartEventNode
14
- | EndEventNode
15
- | UserTaskNode
16
- | ServiceTaskNode
17
- | ExclusiveGatewayNode
18
- | ParallelGatewayNode;
19
-
20
- export interface NodePosition {
21
- readonly x: number;
22
- readonly y: number;
23
- }
24
-
25
- export interface BaseNodeData {
26
- readonly label: string;
27
- readonly triggerMode?: WorkflowNodeTriggerMode;
28
- }
29
-
30
- export type WorkflowNodeTriggerMode = 'AND' | 'OR';
31
-
32
- export interface BaseWorkflowNode<
33
- TType extends string,
34
- TData extends BaseNodeData,
35
- > {
36
- readonly data: TData;
37
- readonly id: string;
38
- readonly position: NodePosition;
39
- readonly type: TType;
40
- }
41
-
42
- export type StartEventNode = BaseWorkflowNode<'startEvent', BaseNodeData>;
43
-
44
- export type EndEventNode = BaseWorkflowNode<
45
- 'endEvent',
46
- BaseNodeData & {
47
- readonly endState?: 'APPROVED' | 'REJECTED';
48
- }
49
- >;
50
-
51
- export type UserTaskNode = BaseWorkflowNode<'userTask', UserTaskNodeData>;
52
-
53
- export interface UserTaskNodeData extends BaseNodeData {
54
- readonly allowAddSigner: boolean;
55
- readonly allowReject: boolean;
56
- readonly allowTransfer: boolean;
57
- readonly approverResolver: ApproverResolver;
58
- readonly decisionPolicy: DecisionPolicy;
59
- readonly description?: string;
60
- readonly entryCondition?: string;
61
- readonly fieldPermissions?: readonly FieldPermission[];
62
- readonly notification?: NotificationOverride;
63
- readonly returnBehavior: ReturnBehavior;
64
- readonly sla?: SlaConfig;
65
- }
66
-
67
- export type ApproverResolver =
68
- | { readonly memberIds: readonly string[]; readonly type: 'DIRECT' }
69
- | { readonly positionId: string; readonly type: 'POSITION' }
70
- | {
71
- readonly includeDescendants?: boolean;
72
- readonly orgUnitId: string;
73
- readonly type: 'ORG_UNIT_MEMBER';
74
- }
75
- | {
76
- readonly includeDescendants?: boolean;
77
- readonly orgUnitId: string;
78
- readonly positionId: string;
79
- readonly type: 'ORG_UNIT_POSITION';
80
- }
81
- | {
82
- readonly baseFromInitiator: boolean;
83
- readonly fallback?: ApproverResolverFallback;
84
- readonly levelsUp: number;
85
- readonly type: 'ORG_MANAGER';
86
- }
87
- | {
88
- readonly fallback?: ApproverResolverFallback;
89
- readonly orgUnitId: string;
90
- readonly type: 'ORG_UNIT_MANAGER';
91
- }
92
- | { readonly formPath: string; readonly type: 'DYNAMIC_FORM' }
93
- | { readonly expression: string; readonly type: 'EXPRESSION' };
94
-
95
- export type ApproverResolverFallback =
96
- | { readonly type: 'NONE' }
97
- | {
98
- readonly allowInitiatorSelfApproval?: boolean;
99
- readonly memberId: string;
100
- readonly type: 'DIRECT';
101
- };
102
-
103
- export type DecisionPolicy =
104
- | { readonly type: 'SINGLE' }
105
- | { readonly type: 'SEQUENTIAL' }
106
- | { readonly type: 'PARALLEL_ALL' }
107
- | { readonly type: 'PARALLEL_ANY' }
108
- | {
109
- readonly threshold: number;
110
- readonly thresholdType: 'COUNT' | 'PERCENTAGE';
111
- readonly type: 'QUORUM';
112
- };
113
-
114
- export interface ReturnBehavior {
115
- readonly allowReturn: boolean;
116
- readonly allowedTargets: 'PREVIOUS' | 'INITIATOR' | 'ANY';
117
- readonly resubmitStrategy?: ReturnResubmitStrategy;
118
- }
119
-
120
- export type ReturnResubmitStrategy = 'FROM_RETURN_POINT' | 'RESTART';
121
-
122
- export interface SlaConfig {
123
- readonly duration: string;
124
- readonly escalateLevelsUp?: number;
125
- readonly onTimeout:
126
- | 'REMIND'
127
- | 'AUTO_APPROVE'
128
- | 'ESCALATE'
129
- | 'TERMINATE_INSTANCE';
130
- readonly warningAt?: number;
131
- }
132
-
133
- export interface FieldPermission {
134
- readonly editable: boolean;
135
- readonly fieldPath: string;
136
- readonly visible: boolean;
137
- }
138
-
139
- export interface NotificationOverride {
140
- readonly channels?: readonly NotificationChannel[];
141
- readonly customTemplate?: string;
142
- }
143
-
144
- export type NotificationChannel = 'IN_APP' | 'EMAIL' | 'WEBHOOK';
145
-
146
- export type ServiceTaskNode = BaseWorkflowNode<
147
- 'serviceTask',
148
- BaseNodeData & {
149
- readonly action: ServiceAction;
150
- readonly entryCondition?: string;
151
- }
152
- >;
153
-
154
- export type ServiceAction =
155
- | {
156
- readonly channels: readonly Exclude<NotificationChannel, 'WEBHOOK'>[];
157
- readonly recipients: ApproverResolver;
158
- readonly template?: string;
159
- readonly type: 'NOTIFY';
160
- }
161
- | {
162
- readonly headers?: Readonly<Record<string, string>>;
163
- readonly payload?: string;
164
- readonly type: 'WEBHOOK';
165
- readonly url: string;
166
- }
167
- | {
168
- readonly fieldPath: string;
169
- readonly type: 'SET_FORM_FIELD';
170
- readonly value: string;
171
- };
172
-
173
- export type ExclusiveGatewayNode = BaseWorkflowNode<
174
- 'exclusiveGateway',
175
- BaseNodeData & {
176
- readonly direction: GatewayDirection;
177
- }
178
- >;
179
-
180
- export type ParallelGatewayNode = BaseWorkflowNode<
181
- 'parallelGateway',
182
- BaseNodeData & {
183
- readonly direction: GatewayDirection;
184
- }
185
- >;
186
-
187
- export type GatewayDirection = 'split' | 'join';
188
-
189
- export interface WorkflowEdge {
190
- readonly data: WorkflowEdgeData;
191
- readonly id: string;
192
- readonly source: string;
193
- readonly sourceHandle?: string | null;
194
- readonly target: string;
195
- readonly targetHandle?: string | null;
196
- readonly type?: 'smoothstep';
197
- }
198
-
199
- export interface WorkflowEdgeData {
200
- readonly condition?: string;
201
- readonly conditionFieldKey?: string;
202
- readonly conditionOperator?: WorkflowEdgeConditionOperator;
203
- readonly conditionValue?: string;
204
- readonly isDefault?: boolean;
205
- readonly label?: string;
206
- }
207
-
208
- export type WorkflowEdgeConditionOperator =
209
- | 'EQUALS'
210
- | 'GREATER_THAN'
211
- | 'GREATER_THAN_OR_EQUALS'
212
- | 'IS_EMPTY'
213
- | 'IS_FILLED'
214
- | 'LESS_THAN'
215
- | 'LESS_THAN_OR_EQUALS'
216
- | 'NOT_EQUALS';
package/tsconfig.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "module": "commonjs",
5
- "forceConsistentCasingInFileNames": true,
6
- "strict": true,
7
- "importHelpers": true,
8
- "noImplicitOverride": true,
9
- "noImplicitReturns": true,
10
- "noFallthroughCasesInSwitch": true,
11
- "noPropertyAccessFromIndexSignature": true
12
- },
13
- "files": [],
14
- "include": [],
15
- "references": [
16
- {
17
- "path": "./tsconfig.lib.json"
18
- },
19
- {
20
- "path": "./tsconfig.spec.json"
21
- }
22
- ]
23
- }
package/tsconfig.lib.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "module": "commonjs",
5
- "outDir": "../../dist/out-tsc",
6
- "declaration": true,
7
- "types": ["node"]
8
- },
9
- "include": ["src/**/*.ts"],
10
- "exclude": [
11
- "jest.config.ts",
12
- "jest.config.cts",
13
- "src/**/*.spec.ts",
14
- "src/**/*.test.ts"
15
- ]
16
- }
@@ -1,16 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "module": "commonjs",
6
- "moduleResolution": "node10",
7
- "types": ["jest", "node"]
8
- },
9
- "include": [
10
- "jest.config.ts",
11
- "jest.config.cts",
12
- "src/**/*.test.ts",
13
- "src/**/*.spec.ts",
14
- "src/**/*.d.ts"
15
- ]
16
- }
File without changes