@lssm/example.workflow-system 0.0.0-canary-20251217060834 → 0.0.0-canary-20251217072406
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/approval/approval.contracts.d.ts +134 -134
- package/dist/approval/approval.contracts.js +250 -1
- package/dist/approval/approval.enum.d.ts +3 -3
- package/dist/approval/approval.enum.js +29 -1
- package/dist/approval/approval.event.d.ts +32 -32
- package/dist/approval/approval.event.js +186 -1
- package/dist/approval/approval.handler.js +71 -1
- package/dist/approval/approval.schema.d.ts +24 -24
- package/dist/approval/approval.schema.js +111 -1
- package/dist/approval/index.js +6 -1
- package/dist/docs/index.js +1 -1
- package/dist/docs/workflow-system.docblock.js +61 -5
- package/dist/entities/approval.d.ts +36 -36
- package/dist/entities/approval.js +128 -1
- package/dist/entities/index.d.ts +127 -127
- package/dist/entities/index.js +31 -1
- package/dist/entities/instance.d.ts +47 -47
- package/dist/entities/instance.js +168 -1
- package/dist/entities/step.d.ts +32 -32
- package/dist/entities/step.js +135 -1
- package/dist/entities/workflow.d.ts +23 -23
- package/dist/entities/workflow.js +102 -1
- package/dist/example.js +50 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +19 -1
- package/dist/instance/index.js +6 -1
- package/dist/instance/instance.contracts.d.ts +256 -256
- package/dist/instance/instance.contracts.js +334 -1
- package/dist/instance/instance.enum.d.ts +2 -2
- package/dist/instance/instance.enum.js +20 -1
- package/dist/instance/instance.event.d.ts +87 -87
- package/dist/instance/instance.event.js +214 -1
- package/dist/instance/instance.handler.js +93 -1
- package/dist/instance/instance.schema.d.ts +54 -54
- package/dist/instance/instance.schema.js +173 -1
- package/dist/libs/contracts/dist/capabilities/openbanking.js +88 -0
- package/dist/libs/contracts/dist/client/index.js +5 -0
- package/dist/libs/contracts/dist/client/react/feature-render.js +2 -0
- package/dist/libs/contracts/dist/client/react/form-render.js +4 -0
- package/dist/libs/contracts/dist/client/react/index.js +4 -0
- package/dist/libs/contracts/dist/contract-registry/index.js +1 -0
- package/dist/libs/contracts/dist/contract-registry/schemas.js +60 -0
- package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/index.js +29 -0
- package/dist/libs/contracts/dist/docs/presentations.js +71 -0
- package/dist/libs/contracts/dist/docs/registry.js +44 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +80 -0
- package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +57 -0
- package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +357 -0
- package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +37 -0
- package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +20 -0
- package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +48 -0
- package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +79 -0
- package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +84 -0
- package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +45 -0
- package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +67 -0
- package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +40 -0
- package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +69 -0
- package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +47 -0
- package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +62 -0
- package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +155 -0
- package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +20 -0
- package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +101 -0
- package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +20 -0
- package/dist/libs/contracts/dist/events.js +10 -0
- package/dist/libs/contracts/dist/experiments/evaluator.js +1 -0
- package/dist/libs/contracts/dist/index.js +71 -0
- package/dist/libs/contracts/dist/install.js +2 -0
- package/dist/libs/contracts/dist/integrations/contracts.js +377 -0
- package/dist/libs/contracts/dist/integrations/index.js +18 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +228 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +159 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +3 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +210 -0
- package/dist/libs/contracts/dist/integrations/openbanking/models.js +242 -0
- package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +13 -0
- package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +52 -0
- package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +75 -0
- package/dist/libs/contracts/dist/integrations/providers/gmail.js +87 -0
- package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +66 -0
- package/dist/libs/contracts/dist/integrations/providers/index.js +11 -0
- package/dist/libs/contracts/dist/integrations/providers/mistral.js +68 -0
- package/dist/libs/contracts/dist/integrations/providers/postmark.js +68 -0
- package/dist/libs/contracts/dist/integrations/providers/powens.js +116 -0
- package/dist/libs/contracts/dist/integrations/providers/qdrant.js +73 -0
- package/dist/libs/contracts/dist/integrations/providers/registry.js +10 -0
- package/dist/libs/contracts/dist/integrations/providers/stripe.js +83 -0
- package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +61 -0
- package/dist/libs/contracts/dist/jsonschema.js +1 -0
- package/dist/libs/contracts/dist/knowledge/contracts.js +306 -0
- package/dist/libs/contracts/dist/knowledge/index.js +7 -0
- package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +34 -0
- package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +34 -0
- package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +38 -0
- package/dist/libs/contracts/dist/knowledge/spaces/index.js +6 -0
- package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +34 -0
- package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +37 -0
- package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +34 -0
- package/dist/libs/contracts/dist/llm/exporters.js +19 -0
- package/dist/libs/contracts/dist/llm/index.js +2 -0
- package/dist/libs/contracts/dist/llm/prompts.js +1 -0
- package/dist/libs/contracts/dist/onboarding-base.js +196 -0
- package/dist/libs/contracts/dist/openapi.js +1 -0
- package/dist/libs/contracts/dist/ownership.js +21 -0
- package/dist/libs/contracts/dist/presentations.js +1 -0
- package/dist/libs/contracts/dist/presentations.v2.js +11 -0
- package/dist/libs/contracts/dist/prompt.js +1 -0
- package/dist/libs/contracts/dist/promptRegistry.js +1 -0
- package/dist/libs/contracts/dist/regenerator/index.js +1 -0
- package/dist/libs/contracts/dist/regenerator/service.js +6 -0
- package/dist/libs/contracts/dist/registry.js +2 -0
- package/dist/libs/contracts/dist/resources.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/EnumType.js +2 -0
- package/dist/libs/contracts/dist/schema/dist/FieldType.js +49 -0
- package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +236 -0
- package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +39 -0
- package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/entity/index.js +2 -0
- package/dist/libs/contracts/dist/schema/dist/entity/types.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/index.js +6 -0
- package/dist/libs/contracts/dist/server/graphql-pothos.js +6 -0
- package/dist/libs/contracts/dist/server/index.js +8 -0
- package/dist/libs/contracts/dist/server/mcp/createMcpServer.js +4 -0
- package/dist/libs/contracts/dist/server/mcp/registerPresentations.js +2 -0
- package/dist/libs/contracts/dist/server/mcp/registerPrompts.js +1 -0
- package/dist/libs/contracts/dist/server/mcp/registerResources.js +2 -0
- package/dist/libs/contracts/dist/server/mcp/registerTools.js +1 -0
- package/dist/libs/contracts/dist/server/provider-mcp.js +1 -0
- package/dist/libs/contracts/dist/server/rest-elysia.js +1 -0
- package/dist/libs/contracts/dist/server/rest-express.js +1 -0
- package/dist/libs/contracts/dist/server/rest-generic.js +1 -0
- package/dist/libs/contracts/dist/server/rest-next-app.js +1 -0
- package/dist/libs/contracts/dist/server/rest-next-pages.js +1 -0
- package/dist/libs/contracts/dist/spec.js +34 -0
- package/dist/libs/contracts/dist/telemetry/index.js +1 -0
- package/dist/libs/contracts/dist/telemetry/tracker.js +1 -0
- package/dist/libs/contracts/dist/tests/index.js +1 -0
- package/dist/libs/contracts/dist/tests/runner.js +2 -0
- package/dist/libs/contracts/dist/workflow/index.js +1 -0
- package/dist/libs/contracts/dist/workflow/runner.js +1 -0
- package/dist/libs/schema/dist/EnumType.js +56 -0
- package/dist/libs/schema/dist/FieldType.js +49 -0
- package/dist/libs/schema/dist/ScalarTypeEnum.js +236 -0
- package/dist/libs/schema/dist/SchemaModel.js +39 -0
- package/dist/libs/schema/dist/entity/defineEntity.js +236 -0
- package/dist/libs/schema/dist/entity/index.js +2 -0
- package/dist/libs/schema/dist/entity/types.js +1 -0
- package/dist/libs/schema/dist/index.js +6 -0
- package/dist/presentations/index.js +291 -1
- package/dist/shared/index.js +3 -1
- package/dist/shared/mock-data.js +11 -1
- package/dist/state-machine/index.js +157 -1
- package/dist/workflow/index.js +6 -1
- package/dist/workflow/workflow.contracts.d.ts +245 -245
- package/dist/workflow/workflow.contracts.js +239 -1
- package/dist/workflow/workflow.enum.js +47 -1
- package/dist/workflow/workflow.event.d.ts +32 -32
- package/dist/workflow/workflow.event.js +116 -1
- package/dist/workflow/workflow.handler.js +65 -1
- package/dist/workflow/workflow.schema.js +250 -1
- package/dist/workflow-system.feature.js +337 -1
- package/package.json +11 -11
|
@@ -1 +1,71 @@
|
|
|
1
|
-
import{mockDataStore
|
|
1
|
+
import { mockDataStore } from "../shared/mock-data.js";
|
|
2
|
+
import { handleTransitionWorkflow } from "../instance/instance.handler.js";
|
|
3
|
+
|
|
4
|
+
//#region src/approval/approval.handler.ts
|
|
5
|
+
async function createApprovalRequests(instance, step, _context) {
|
|
6
|
+
const now = /* @__PURE__ */ new Date();
|
|
7
|
+
for (let i = 0; i < step.approverRoles.length; i++) {
|
|
8
|
+
const role = step.approverRoles[i];
|
|
9
|
+
const id = `approval_${Date.now()}_${i}`;
|
|
10
|
+
const request = {
|
|
11
|
+
id,
|
|
12
|
+
workflowInstanceId: instance.id,
|
|
13
|
+
stepExecutionId: `exec_${instance.id}_${step.id}`,
|
|
14
|
+
approverId: `user_${role}`,
|
|
15
|
+
approverRole: role,
|
|
16
|
+
title: `Approval required for ${step.name}`,
|
|
17
|
+
description: step.description,
|
|
18
|
+
status: "PENDING",
|
|
19
|
+
contextSnapshot: instance.contextData,
|
|
20
|
+
sequenceOrder: i,
|
|
21
|
+
createdAt: now,
|
|
22
|
+
updatedAt: now
|
|
23
|
+
};
|
|
24
|
+
mockDataStore.approvals.set(id, request);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function handleSubmitDecision(input, context) {
|
|
28
|
+
const request = mockDataStore.approvals.get(input.requestId);
|
|
29
|
+
if (!request) throw new Error(`Approval request ${input.requestId} not found`);
|
|
30
|
+
if (request.approverId !== context.userId && !context.userRoles.includes(request.approverRole ?? "")) throw new Error("User is not authorized to make this decision");
|
|
31
|
+
const now = /* @__PURE__ */ new Date();
|
|
32
|
+
request.decision = input.decision;
|
|
33
|
+
request.decisionComment = input.comment;
|
|
34
|
+
request.decidedAt = now;
|
|
35
|
+
request.updatedAt = now;
|
|
36
|
+
if (input.decision === "APPROVE") {
|
|
37
|
+
request.status = "APPROVED";
|
|
38
|
+
await handleTransitionWorkflow({
|
|
39
|
+
instanceId: request.workflowInstanceId,
|
|
40
|
+
action: "approve",
|
|
41
|
+
data: input.data,
|
|
42
|
+
comment: input.comment
|
|
43
|
+
}, context);
|
|
44
|
+
} else if (input.decision === "REJECT") {
|
|
45
|
+
request.status = "REJECTED";
|
|
46
|
+
await handleTransitionWorkflow({
|
|
47
|
+
instanceId: request.workflowInstanceId,
|
|
48
|
+
action: "reject",
|
|
49
|
+
data: input.data,
|
|
50
|
+
comment: input.comment
|
|
51
|
+
}, context);
|
|
52
|
+
}
|
|
53
|
+
return request;
|
|
54
|
+
}
|
|
55
|
+
async function handleListMyApprovals(input, context) {
|
|
56
|
+
let requests = Array.from(mockDataStore.approvals.values()).filter((r) => r.approverId === context.userId || context.userRoles.includes(r.approverRole ?? ""));
|
|
57
|
+
const pendingCount = requests.filter((r) => r.status === "PENDING").length;
|
|
58
|
+
if (input.status) requests = requests.filter((r) => r.status === input.status);
|
|
59
|
+
const total = requests.length;
|
|
60
|
+
const offset = input.offset ?? 0;
|
|
61
|
+
const limit = input.limit ?? 20;
|
|
62
|
+
requests = requests.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime()).slice(offset, offset + limit);
|
|
63
|
+
return {
|
|
64
|
+
requests,
|
|
65
|
+
total,
|
|
66
|
+
pendingCount
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { createApprovalRequests, handleListMyApprovals, handleSubmitDecision };
|
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _lssm_lib_schema260 from "@lssm/lib.schema";
|
|
2
2
|
|
|
3
3
|
//#region src/approval/approval.schema.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* An approval request.
|
|
6
6
|
*/
|
|
7
|
-
declare const ApprovalRequestModel:
|
|
7
|
+
declare const ApprovalRequestModel: _lssm_lib_schema260.SchemaModel<{
|
|
8
8
|
id: {
|
|
9
|
-
type:
|
|
9
|
+
type: _lssm_lib_schema260.FieldType<string, string>;
|
|
10
10
|
isOptional: false;
|
|
11
11
|
};
|
|
12
12
|
workflowInstanceId: {
|
|
13
|
-
type:
|
|
13
|
+
type: _lssm_lib_schema260.FieldType<string, string>;
|
|
14
14
|
isOptional: false;
|
|
15
15
|
};
|
|
16
16
|
stepExecutionId: {
|
|
17
|
-
type:
|
|
17
|
+
type: _lssm_lib_schema260.FieldType<string, string>;
|
|
18
18
|
isOptional: false;
|
|
19
19
|
};
|
|
20
20
|
approverId: {
|
|
21
|
-
type:
|
|
21
|
+
type: _lssm_lib_schema260.FieldType<string, string>;
|
|
22
22
|
isOptional: false;
|
|
23
23
|
};
|
|
24
24
|
approverRole: {
|
|
25
|
-
type:
|
|
25
|
+
type: _lssm_lib_schema260.FieldType<string, string>;
|
|
26
26
|
isOptional: true;
|
|
27
27
|
};
|
|
28
28
|
title: {
|
|
29
|
-
type:
|
|
29
|
+
type: _lssm_lib_schema260.FieldType<string, string>;
|
|
30
30
|
isOptional: false;
|
|
31
31
|
};
|
|
32
32
|
description: {
|
|
33
|
-
type:
|
|
33
|
+
type: _lssm_lib_schema260.FieldType<string, string>;
|
|
34
34
|
isOptional: true;
|
|
35
35
|
};
|
|
36
36
|
status: {
|
|
37
|
-
type:
|
|
37
|
+
type: _lssm_lib_schema260.EnumType<[string, string, string, string, string, string, string]>;
|
|
38
38
|
isOptional: false;
|
|
39
39
|
};
|
|
40
40
|
decision: {
|
|
41
|
-
type:
|
|
41
|
+
type: _lssm_lib_schema260.EnumType<[string, string, string, string, string]>;
|
|
42
42
|
isOptional: true;
|
|
43
43
|
};
|
|
44
44
|
decisionComment: {
|
|
45
|
-
type:
|
|
45
|
+
type: _lssm_lib_schema260.FieldType<string, string>;
|
|
46
46
|
isOptional: true;
|
|
47
47
|
};
|
|
48
48
|
decidedAt: {
|
|
49
|
-
type:
|
|
49
|
+
type: _lssm_lib_schema260.FieldType<Date, string>;
|
|
50
50
|
isOptional: true;
|
|
51
51
|
};
|
|
52
52
|
dueAt: {
|
|
53
|
-
type:
|
|
53
|
+
type: _lssm_lib_schema260.FieldType<Date, string>;
|
|
54
54
|
isOptional: true;
|
|
55
55
|
};
|
|
56
56
|
contextSnapshot: {
|
|
57
|
-
type:
|
|
57
|
+
type: _lssm_lib_schema260.FieldType<unknown, unknown>;
|
|
58
58
|
isOptional: true;
|
|
59
59
|
};
|
|
60
60
|
sequenceOrder: {
|
|
61
|
-
type:
|
|
61
|
+
type: _lssm_lib_schema260.FieldType<number, number>;
|
|
62
62
|
isOptional: false;
|
|
63
63
|
};
|
|
64
64
|
createdAt: {
|
|
65
|
-
type:
|
|
65
|
+
type: _lssm_lib_schema260.FieldType<Date, string>;
|
|
66
66
|
isOptional: false;
|
|
67
67
|
};
|
|
68
68
|
}>;
|
|
69
69
|
/**
|
|
70
70
|
* A comment on an approval.
|
|
71
71
|
*/
|
|
72
|
-
declare const ApprovalCommentModel:
|
|
72
|
+
declare const ApprovalCommentModel: _lssm_lib_schema260.SchemaModel<{
|
|
73
73
|
id: {
|
|
74
|
-
type:
|
|
74
|
+
type: _lssm_lib_schema260.FieldType<string, string>;
|
|
75
75
|
isOptional: false;
|
|
76
76
|
};
|
|
77
77
|
approvalRequestId: {
|
|
78
|
-
type:
|
|
78
|
+
type: _lssm_lib_schema260.FieldType<string, string>;
|
|
79
79
|
isOptional: false;
|
|
80
80
|
};
|
|
81
81
|
authorId: {
|
|
82
|
-
type:
|
|
82
|
+
type: _lssm_lib_schema260.FieldType<string, string>;
|
|
83
83
|
isOptional: false;
|
|
84
84
|
};
|
|
85
85
|
content: {
|
|
86
|
-
type:
|
|
86
|
+
type: _lssm_lib_schema260.FieldType<string, string>;
|
|
87
87
|
isOptional: false;
|
|
88
88
|
};
|
|
89
89
|
isInternal: {
|
|
90
|
-
type:
|
|
90
|
+
type: _lssm_lib_schema260.FieldType<boolean, boolean>;
|
|
91
91
|
isOptional: false;
|
|
92
92
|
};
|
|
93
93
|
createdAt: {
|
|
94
|
-
type:
|
|
94
|
+
type: _lssm_lib_schema260.FieldType<Date, string>;
|
|
95
95
|
isOptional: false;
|
|
96
96
|
};
|
|
97
97
|
}>;
|
|
@@ -1 +1,111 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { ScalarTypeEnum } from "../libs/schema/dist/ScalarTypeEnum.js";
|
|
2
|
+
import { defineSchemaModel } from "../libs/schema/dist/SchemaModel.js";
|
|
3
|
+
import "../libs/schema/dist/index.js";
|
|
4
|
+
import { ApprovalDecisionEnum, ApprovalStatusEnum } from "./approval.enum.js";
|
|
5
|
+
|
|
6
|
+
//#region src/approval/approval.schema.ts
|
|
7
|
+
/**
|
|
8
|
+
* An approval request.
|
|
9
|
+
*/
|
|
10
|
+
const ApprovalRequestModel = defineSchemaModel({
|
|
11
|
+
name: "ApprovalRequestModel",
|
|
12
|
+
description: "An approval request",
|
|
13
|
+
fields: {
|
|
14
|
+
id: {
|
|
15
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
16
|
+
isOptional: false
|
|
17
|
+
},
|
|
18
|
+
workflowInstanceId: {
|
|
19
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
20
|
+
isOptional: false
|
|
21
|
+
},
|
|
22
|
+
stepExecutionId: {
|
|
23
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
24
|
+
isOptional: false
|
|
25
|
+
},
|
|
26
|
+
approverId: {
|
|
27
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
28
|
+
isOptional: false
|
|
29
|
+
},
|
|
30
|
+
approverRole: {
|
|
31
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
32
|
+
isOptional: true
|
|
33
|
+
},
|
|
34
|
+
title: {
|
|
35
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
36
|
+
isOptional: false
|
|
37
|
+
},
|
|
38
|
+
description: {
|
|
39
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
40
|
+
isOptional: true
|
|
41
|
+
},
|
|
42
|
+
status: {
|
|
43
|
+
type: ApprovalStatusEnum,
|
|
44
|
+
isOptional: false
|
|
45
|
+
},
|
|
46
|
+
decision: {
|
|
47
|
+
type: ApprovalDecisionEnum,
|
|
48
|
+
isOptional: true
|
|
49
|
+
},
|
|
50
|
+
decisionComment: {
|
|
51
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
52
|
+
isOptional: true
|
|
53
|
+
},
|
|
54
|
+
decidedAt: {
|
|
55
|
+
type: ScalarTypeEnum.DateTime(),
|
|
56
|
+
isOptional: true
|
|
57
|
+
},
|
|
58
|
+
dueAt: {
|
|
59
|
+
type: ScalarTypeEnum.DateTime(),
|
|
60
|
+
isOptional: true
|
|
61
|
+
},
|
|
62
|
+
contextSnapshot: {
|
|
63
|
+
type: ScalarTypeEnum.JSON(),
|
|
64
|
+
isOptional: true
|
|
65
|
+
},
|
|
66
|
+
sequenceOrder: {
|
|
67
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
68
|
+
isOptional: false
|
|
69
|
+
},
|
|
70
|
+
createdAt: {
|
|
71
|
+
type: ScalarTypeEnum.DateTime(),
|
|
72
|
+
isOptional: false
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* A comment on an approval.
|
|
78
|
+
*/
|
|
79
|
+
const ApprovalCommentModel = defineSchemaModel({
|
|
80
|
+
name: "ApprovalCommentModel",
|
|
81
|
+
description: "A comment on an approval",
|
|
82
|
+
fields: {
|
|
83
|
+
id: {
|
|
84
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
85
|
+
isOptional: false
|
|
86
|
+
},
|
|
87
|
+
approvalRequestId: {
|
|
88
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
89
|
+
isOptional: false
|
|
90
|
+
},
|
|
91
|
+
authorId: {
|
|
92
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
93
|
+
isOptional: false
|
|
94
|
+
},
|
|
95
|
+
content: {
|
|
96
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
97
|
+
isOptional: false
|
|
98
|
+
},
|
|
99
|
+
isInternal: {
|
|
100
|
+
type: ScalarTypeEnum.Boolean(),
|
|
101
|
+
isOptional: false
|
|
102
|
+
},
|
|
103
|
+
createdAt: {
|
|
104
|
+
type: ScalarTypeEnum.DateTime(),
|
|
105
|
+
isOptional: false
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
//#endregion
|
|
111
|
+
export { ApprovalCommentModel, ApprovalRequestModel };
|
package/dist/approval/index.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ApprovalDecisionEnum, ApprovalStatusEnum } from "./approval.enum.js";
|
|
2
|
+
import { ApprovalCommentModel, ApprovalRequestModel } from "./approval.schema.js";
|
|
3
|
+
import { AddApprovalCommentContract, DelegateApprovalContract, GetApprovalContract, ListMyApprovalsContract, SubmitDecisionContract } from "./approval.contracts.js";
|
|
4
|
+
import { ApprovalDecidedEvent, ApprovalDelegatedEvent, ApprovalEscalatedEvent, ApprovalRequestedEvent } from "./approval.event.js";
|
|
5
|
+
|
|
6
|
+
export { AddApprovalCommentContract, ApprovalCommentModel, ApprovalDecidedEvent, ApprovalDecisionEnum, ApprovalDelegatedEvent, ApprovalEscalatedEvent, ApprovalRequestModel, ApprovalRequestedEvent, ApprovalStatusEnum, DelegateApprovalContract, GetApprovalContract, ListMyApprovalsContract, SubmitDecisionContract };
|
package/dist/docs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./workflow-system.docblock.js";
|
|
1
|
+
import "./workflow-system.docblock.js";
|
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
import{registerDocBlocks
|
|
1
|
+
import { registerDocBlocks } from "../libs/contracts/dist/docs/registry.js";
|
|
2
|
+
import "../libs/contracts/dist/docs/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/docs/workflow-system.docblock.ts
|
|
5
|
+
registerDocBlocks([
|
|
6
|
+
{
|
|
7
|
+
id: "docs.examples.workflow-system",
|
|
8
|
+
title: "Workflow / Approval System",
|
|
9
|
+
summary: "Reference app showing state-machine driven approvals with RBAC, audit trail, notifications, and jobs.",
|
|
10
|
+
kind: "reference",
|
|
11
|
+
visibility: "public",
|
|
12
|
+
route: "/docs/examples/workflow-system",
|
|
13
|
+
tags: [
|
|
14
|
+
"workflow",
|
|
15
|
+
"approval",
|
|
16
|
+
"state-machine",
|
|
17
|
+
"rbac"
|
|
18
|
+
],
|
|
19
|
+
body: `## Entities
|
|
2
20
|
|
|
3
21
|
- WorkflowDefinition, WorkflowStep, WorkflowInstance, Approval.
|
|
4
22
|
- State machine expressed in \`src/state-machine\` with allowed transitions and role gates.
|
|
@@ -22,7 +40,17 @@ import{registerDocBlocks as e}from"@lssm/lib.contracts/docs";e([{id:`docs.exampl
|
|
|
22
40
|
|
|
23
41
|
- Keep transitions declarative to enable safe regeneration; role guards live in spec.
|
|
24
42
|
- Use Notification Center for approval requests and outcomes; attach files via Files module if needed.
|
|
25
|
-
`
|
|
43
|
+
`
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "docs.examples.workflow-system.goal",
|
|
47
|
+
title: "Workflow System — Goal",
|
|
48
|
+
summary: "Why the workflow/approval template exists and outcomes it targets.",
|
|
49
|
+
kind: "goal",
|
|
50
|
+
visibility: "public",
|
|
51
|
+
route: "/docs/examples/workflow-system/goal",
|
|
52
|
+
tags: ["workflow", "goal"],
|
|
53
|
+
body: `## Why it matters
|
|
26
54
|
- Provides a regenerable, role-gated approval engine using declarative state machines.
|
|
27
55
|
- Keeps workflow rules consistent across UI/API/events with auditability.
|
|
28
56
|
|
|
@@ -32,7 +60,17 @@ import{registerDocBlocks as e}from"@lssm/lib.contracts/docs";e([{id:`docs.exampl
|
|
|
32
60
|
|
|
33
61
|
## Success criteria
|
|
34
62
|
- State changes are declarative and regenerate cleanly.
|
|
35
|
-
- Every transition emits auditable events and respects RBAC guards.`
|
|
63
|
+
- Every transition emits auditable events and respects RBAC guards.`
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "docs.examples.workflow-system.usage",
|
|
67
|
+
title: "Workflow System — Usage",
|
|
68
|
+
summary: "How to configure workflows, transitions, and regenerate safely.",
|
|
69
|
+
kind: "usage",
|
|
70
|
+
visibility: "public",
|
|
71
|
+
route: "/docs/examples/workflow-system/usage",
|
|
72
|
+
tags: ["workflow", "usage"],
|
|
73
|
+
body: `## Setup
|
|
36
74
|
1) Define WorkflowDefinition steps and allowed transitions with role gates in spec.
|
|
37
75
|
2) Seed sample workflows/instances (if provided) or create via UI; enable reminders via Jobs.
|
|
38
76
|
|
|
@@ -44,7 +82,21 @@ import{registerDocBlocks as e}from"@lssm/lib.contracts/docs";e([{id:`docs.exampl
|
|
|
44
82
|
## Guardrails
|
|
45
83
|
- Emit events for every transition; log to Audit Trail.
|
|
46
84
|
- Use Notifications for approvals/rejections; schedule reminders for pending steps.
|
|
47
|
-
- Keep transitions declarative; avoid imperative branching in handlers.`
|
|
85
|
+
- Keep transitions declarative; avoid imperative branching in handlers.`
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: "docs.examples.workflow-system.constraints",
|
|
89
|
+
title: "Workflow System — Constraints & Safety",
|
|
90
|
+
summary: "Internal guardrails for state machines, RBAC, and regeneration semantics.",
|
|
91
|
+
kind: "reference",
|
|
92
|
+
visibility: "internal",
|
|
93
|
+
route: "/docs/examples/workflow-system/constraints",
|
|
94
|
+
tags: [
|
|
95
|
+
"workflow",
|
|
96
|
+
"constraints",
|
|
97
|
+
"internal"
|
|
98
|
+
],
|
|
99
|
+
body: `## Constraints
|
|
48
100
|
- State machine (steps/transitions) must stay declarative in spec; no hidden code paths.
|
|
49
101
|
- Events to emit: instance.started, step.completed/rejected, instance.finished.
|
|
50
102
|
- Regeneration must not change approval logic without explicit spec diff.
|
|
@@ -56,4 +108,8 @@ import{registerDocBlocks as e}from"@lssm/lib.contracts/docs";e([{id:`docs.exampl
|
|
|
56
108
|
## Verification
|
|
57
109
|
- Add fixtures for transition changes and role gates.
|
|
58
110
|
- Validate reminders (Jobs) stay aligned with pending states after regeneration.
|
|
59
|
-
- Use Feature Flags for new transitions/escalation rules; default safe/off.`
|
|
111
|
+
- Use Feature Flags for new transitions/escalation rules; default safe/off.`
|
|
112
|
+
}
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _lssm_lib_schema61 from "@lssm/lib.schema";
|
|
2
2
|
|
|
3
3
|
//#region src/entities/approval.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Approval status enum.
|
|
6
6
|
*/
|
|
7
|
-
declare const ApprovalStatusEnum:
|
|
7
|
+
declare const ApprovalStatusEnum: _lssm_lib_schema61.EntityEnumDef;
|
|
8
8
|
/**
|
|
9
9
|
* Approval decision enum.
|
|
10
10
|
*/
|
|
11
|
-
declare const ApprovalDecisionEnum:
|
|
11
|
+
declare const ApprovalDecisionEnum: _lssm_lib_schema61.EntityEnumDef;
|
|
12
12
|
/**
|
|
13
13
|
* ApprovalRequest entity - a request for approval from a user.
|
|
14
14
|
*
|
|
15
15
|
* Created when a workflow reaches an APPROVAL step. Multiple requests
|
|
16
16
|
* may be created depending on the approval mode.
|
|
17
17
|
*/
|
|
18
|
-
declare const ApprovalRequestEntity:
|
|
19
|
-
id:
|
|
20
|
-
workflowInstanceId:
|
|
21
|
-
stepExecutionId:
|
|
22
|
-
approverId:
|
|
23
|
-
approverRole:
|
|
24
|
-
title:
|
|
25
|
-
description:
|
|
26
|
-
status:
|
|
27
|
-
decision:
|
|
28
|
-
decisionComment:
|
|
29
|
-
decidedAt:
|
|
30
|
-
delegatedTo:
|
|
31
|
-
delegationReason:
|
|
32
|
-
escalationLevel:
|
|
33
|
-
escalatedAt:
|
|
34
|
-
dueAt:
|
|
35
|
-
reminderSentAt:
|
|
36
|
-
contextSnapshot:
|
|
37
|
-
sequenceOrder:
|
|
38
|
-
createdAt:
|
|
39
|
-
updatedAt:
|
|
40
|
-
workflowInstance:
|
|
41
|
-
stepExecution:
|
|
18
|
+
declare const ApprovalRequestEntity: _lssm_lib_schema61.EntitySpec<{
|
|
19
|
+
id: _lssm_lib_schema61.EntityScalarField;
|
|
20
|
+
workflowInstanceId: _lssm_lib_schema61.EntityScalarField;
|
|
21
|
+
stepExecutionId: _lssm_lib_schema61.EntityScalarField;
|
|
22
|
+
approverId: _lssm_lib_schema61.EntityScalarField;
|
|
23
|
+
approverRole: _lssm_lib_schema61.EntityScalarField;
|
|
24
|
+
title: _lssm_lib_schema61.EntityScalarField;
|
|
25
|
+
description: _lssm_lib_schema61.EntityScalarField;
|
|
26
|
+
status: _lssm_lib_schema61.EntityEnumField;
|
|
27
|
+
decision: _lssm_lib_schema61.EntityEnumField;
|
|
28
|
+
decisionComment: _lssm_lib_schema61.EntityScalarField;
|
|
29
|
+
decidedAt: _lssm_lib_schema61.EntityScalarField;
|
|
30
|
+
delegatedTo: _lssm_lib_schema61.EntityScalarField;
|
|
31
|
+
delegationReason: _lssm_lib_schema61.EntityScalarField;
|
|
32
|
+
escalationLevel: _lssm_lib_schema61.EntityScalarField;
|
|
33
|
+
escalatedAt: _lssm_lib_schema61.EntityScalarField;
|
|
34
|
+
dueAt: _lssm_lib_schema61.EntityScalarField;
|
|
35
|
+
reminderSentAt: _lssm_lib_schema61.EntityScalarField;
|
|
36
|
+
contextSnapshot: _lssm_lib_schema61.EntityScalarField;
|
|
37
|
+
sequenceOrder: _lssm_lib_schema61.EntityScalarField;
|
|
38
|
+
createdAt: _lssm_lib_schema61.EntityScalarField;
|
|
39
|
+
updatedAt: _lssm_lib_schema61.EntityScalarField;
|
|
40
|
+
workflowInstance: _lssm_lib_schema61.EntityRelationField;
|
|
41
|
+
stepExecution: _lssm_lib_schema61.EntityRelationField;
|
|
42
42
|
}>;
|
|
43
43
|
/**
|
|
44
44
|
* ApprovalComment entity - comments on approval requests.
|
|
45
45
|
*/
|
|
46
|
-
declare const ApprovalCommentEntity:
|
|
47
|
-
id:
|
|
48
|
-
approvalRequestId:
|
|
49
|
-
authorId:
|
|
50
|
-
content:
|
|
51
|
-
isInternal:
|
|
52
|
-
createdAt:
|
|
53
|
-
updatedAt:
|
|
54
|
-
approvalRequest:
|
|
46
|
+
declare const ApprovalCommentEntity: _lssm_lib_schema61.EntitySpec<{
|
|
47
|
+
id: _lssm_lib_schema61.EntityScalarField;
|
|
48
|
+
approvalRequestId: _lssm_lib_schema61.EntityScalarField;
|
|
49
|
+
authorId: _lssm_lib_schema61.EntityScalarField;
|
|
50
|
+
content: _lssm_lib_schema61.EntityScalarField;
|
|
51
|
+
isInternal: _lssm_lib_schema61.EntityScalarField;
|
|
52
|
+
createdAt: _lssm_lib_schema61.EntityScalarField;
|
|
53
|
+
updatedAt: _lssm_lib_schema61.EntityScalarField;
|
|
54
|
+
approvalRequest: _lssm_lib_schema61.EntityRelationField;
|
|
55
55
|
}>;
|
|
56
56
|
//#endregion
|
|
57
57
|
export { ApprovalCommentEntity, ApprovalDecisionEnum, ApprovalRequestEntity, ApprovalStatusEnum };
|
|
@@ -1 +1,128 @@
|
|
|
1
|
-
import{defineEntity
|
|
1
|
+
import { defineEntity, defineEntityEnum, field, index } from "../libs/schema/dist/entity/defineEntity.js";
|
|
2
|
+
import "../libs/schema/dist/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/entities/approval.ts
|
|
5
|
+
/**
|
|
6
|
+
* Approval status enum.
|
|
7
|
+
*/
|
|
8
|
+
const ApprovalStatusEnum = defineEntityEnum({
|
|
9
|
+
name: "ApprovalStatus",
|
|
10
|
+
values: [
|
|
11
|
+
"PENDING",
|
|
12
|
+
"APPROVED",
|
|
13
|
+
"REJECTED",
|
|
14
|
+
"DELEGATED",
|
|
15
|
+
"ESCALATED",
|
|
16
|
+
"WITHDRAWN",
|
|
17
|
+
"EXPIRED"
|
|
18
|
+
],
|
|
19
|
+
schema: "workflow",
|
|
20
|
+
description: "Status of an approval request."
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Approval decision enum.
|
|
24
|
+
*/
|
|
25
|
+
const ApprovalDecisionEnum = defineEntityEnum({
|
|
26
|
+
name: "ApprovalDecision",
|
|
27
|
+
values: [
|
|
28
|
+
"APPROVE",
|
|
29
|
+
"REJECT",
|
|
30
|
+
"REQUEST_CHANGES",
|
|
31
|
+
"DELEGATE",
|
|
32
|
+
"ABSTAIN"
|
|
33
|
+
],
|
|
34
|
+
schema: "workflow",
|
|
35
|
+
description: "Possible approval decisions."
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* ApprovalRequest entity - a request for approval from a user.
|
|
39
|
+
*
|
|
40
|
+
* Created when a workflow reaches an APPROVAL step. Multiple requests
|
|
41
|
+
* may be created depending on the approval mode.
|
|
42
|
+
*/
|
|
43
|
+
const ApprovalRequestEntity = defineEntity({
|
|
44
|
+
name: "ApprovalRequest",
|
|
45
|
+
description: "A pending approval request for a workflow step.",
|
|
46
|
+
schema: "workflow",
|
|
47
|
+
map: "approval_request",
|
|
48
|
+
fields: {
|
|
49
|
+
id: field.id({ description: "Unique approval request ID" }),
|
|
50
|
+
workflowInstanceId: field.foreignKey(),
|
|
51
|
+
stepExecutionId: field.foreignKey(),
|
|
52
|
+
approverId: field.foreignKey({ description: "User requested to approve" }),
|
|
53
|
+
approverRole: field.string({
|
|
54
|
+
isOptional: true,
|
|
55
|
+
description: "Role of the approver"
|
|
56
|
+
}),
|
|
57
|
+
title: field.string({ description: "Approval request title" }),
|
|
58
|
+
description: field.string({ isOptional: true }),
|
|
59
|
+
status: field.enum("ApprovalStatus", { default: "PENDING" }),
|
|
60
|
+
decision: field.enum("ApprovalDecision", { isOptional: true }),
|
|
61
|
+
decisionComment: field.string({
|
|
62
|
+
isOptional: true,
|
|
63
|
+
description: "Comment explaining decision"
|
|
64
|
+
}),
|
|
65
|
+
decidedAt: field.dateTime({ isOptional: true }),
|
|
66
|
+
delegatedTo: field.string({
|
|
67
|
+
isOptional: true,
|
|
68
|
+
description: "User delegated to"
|
|
69
|
+
}),
|
|
70
|
+
delegationReason: field.string({ isOptional: true }),
|
|
71
|
+
escalationLevel: field.int({
|
|
72
|
+
default: 0,
|
|
73
|
+
description: "Current escalation level"
|
|
74
|
+
}),
|
|
75
|
+
escalatedAt: field.dateTime({ isOptional: true }),
|
|
76
|
+
dueAt: field.dateTime({
|
|
77
|
+
isOptional: true,
|
|
78
|
+
description: "When approval is due"
|
|
79
|
+
}),
|
|
80
|
+
reminderSentAt: field.dateTime({ isOptional: true }),
|
|
81
|
+
contextSnapshot: field.json({
|
|
82
|
+
isOptional: true,
|
|
83
|
+
description: "Snapshot of relevant data for review"
|
|
84
|
+
}),
|
|
85
|
+
sequenceOrder: field.int({
|
|
86
|
+
default: 0,
|
|
87
|
+
description: "Order in approval chain"
|
|
88
|
+
}),
|
|
89
|
+
createdAt: field.createdAt(),
|
|
90
|
+
updatedAt: field.updatedAt(),
|
|
91
|
+
workflowInstance: field.belongsTo("WorkflowInstance", ["workflowInstanceId"], ["id"], { onDelete: "Cascade" }),
|
|
92
|
+
stepExecution: field.belongsTo("StepExecution", ["stepExecutionId"], ["id"])
|
|
93
|
+
},
|
|
94
|
+
indexes: [
|
|
95
|
+
index.on(["approverId", "status"]),
|
|
96
|
+
index.on(["workflowInstanceId", "status"]),
|
|
97
|
+
index.on(["stepExecutionId"]),
|
|
98
|
+
index.on(["status", "dueAt"]),
|
|
99
|
+
index.on(["createdAt"])
|
|
100
|
+
],
|
|
101
|
+
enums: [ApprovalStatusEnum, ApprovalDecisionEnum]
|
|
102
|
+
});
|
|
103
|
+
/**
|
|
104
|
+
* ApprovalComment entity - comments on approval requests.
|
|
105
|
+
*/
|
|
106
|
+
const ApprovalCommentEntity = defineEntity({
|
|
107
|
+
name: "ApprovalComment",
|
|
108
|
+
description: "A comment on an approval request.",
|
|
109
|
+
schema: "workflow",
|
|
110
|
+
map: "approval_comment",
|
|
111
|
+
fields: {
|
|
112
|
+
id: field.id(),
|
|
113
|
+
approvalRequestId: field.foreignKey(),
|
|
114
|
+
authorId: field.foreignKey(),
|
|
115
|
+
content: field.string({ description: "Comment text" }),
|
|
116
|
+
isInternal: field.boolean({
|
|
117
|
+
default: false,
|
|
118
|
+
description: "Internal note vs public comment"
|
|
119
|
+
}),
|
|
120
|
+
createdAt: field.createdAt(),
|
|
121
|
+
updatedAt: field.updatedAt(),
|
|
122
|
+
approvalRequest: field.belongsTo("ApprovalRequest", ["approvalRequestId"], ["id"], { onDelete: "Cascade" })
|
|
123
|
+
},
|
|
124
|
+
indexes: [index.on(["approvalRequestId", "createdAt"])]
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
export { ApprovalCommentEntity, ApprovalDecisionEnum, ApprovalRequestEntity, ApprovalStatusEnum };
|