@lssm/lib.workflow-composer 0.1.0
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 +17 -0
- package/dist/composer.d.ts +13 -0
- package/dist/composer.d.ts.map +1 -0
- package/dist/composer.js +2 -0
- package/dist/composer.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -0
- package/dist/injector.d.ts +8 -0
- package/dist/injector.d.ts.map +1 -0
- package/dist/injector.js +2 -0
- package/dist/injector.js.map +1 -0
- package/dist/merger.d.ts +7 -0
- package/dist/merger.d.ts.map +1 -0
- package/dist/merger.js +2 -0
- package/dist/merger.js.map +1 -0
- package/dist/templates.d.ts +15 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +2 -0
- package/dist/templates.js.map +1 -0
- package/dist/types.d.ts +32 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/validator.d.ts +12 -0
- package/dist/validator.d.ts.map +1 -0
- package/dist/validator.js +2 -0
- package/dist/validator.js.map +1 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @lssm/lib.workflow-composer
|
|
2
|
+
|
|
3
|
+
Compose base WorkflowSpecs with tenant-, role-, or device-specific extensions. The composer lets teams inject steps, hide portions of a workflow, and attach tenant-scoped metadata without duplicating base definitions.
|
|
4
|
+
|
|
5
|
+
## Highlights
|
|
6
|
+
|
|
7
|
+
- Type-safe `extendWorkflow` helper.
|
|
8
|
+
- Registry for extension templates (tenant, role, device scopes).
|
|
9
|
+
- Validation to ensure injected steps reference valid anchors.
|
|
10
|
+
- Merge utilities to combine overlays coming from tenant + user.
|
|
11
|
+
|
|
12
|
+
Refer to `docs/tech/personalization/workflow-composition.md` for more.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComposeParams, WorkflowExtension } from "./types.js";
|
|
2
|
+
import { WorkflowSpec } from "@lssm/lib.contracts/workflow/spec";
|
|
3
|
+
|
|
4
|
+
//#region src/composer.d.ts
|
|
5
|
+
declare class WorkflowComposer {
|
|
6
|
+
private readonly extensions;
|
|
7
|
+
register(extension: WorkflowExtension): this;
|
|
8
|
+
registerMany(extensions: WorkflowExtension[]): this;
|
|
9
|
+
compose(params: ComposeParams): WorkflowSpec;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { WorkflowComposer };
|
|
13
|
+
//# sourceMappingURL=composer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composer.d.ts","names":[],"sources":["../src/composer.ts"],"sourcesContent":[],"mappings":";;;;cAIa,gBAAA;;EAAA,QAAA,CAAA,SAAA,EAGS,iBAHO,CAAA,EAAA,IAAA;EAGP,YAAA,CAAA,UAAA,EAKK,iBALL,EAAA,CAAA,EAAA,IAAA;EAKK,OAAA,CAAA,MAAA,EAKT,aALS,CAAA,EAKO,YALP"}
|
package/dist/composer.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{applyWorkflowExtension as e}from"./injector.js";var t=class{extensions=[];register(e){return this.extensions.push(e),this}registerMany(e){return e.forEach(e=>this.register(e)),this}compose(t){return this.extensions.filter(e=>n(t,e)).sort((e,t)=>(e.priority??0)-(t.priority??0)).reduce((t,n)=>e(t,n),t.base)}};function n(e,t){return!(t.workflow!==e.base.meta.name||t.baseVersion&&t.baseVersion!==e.base.meta.version||t.tenantId&&t.tenantId!==e.tenantId||t.role&&t.role!==e.role||t.device&&t.device!==e.device)}export{t as WorkflowComposer};
|
|
2
|
+
//# sourceMappingURL=composer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composer.js","names":[],"sources":["../src/composer.ts"],"sourcesContent":["import type { WorkflowSpec } from '@lssm/lib.contracts/workflow/spec';\nimport { applyWorkflowExtension } from './injector';\nimport type { ComposeParams, WorkflowExtension } from './types';\n\nexport class WorkflowComposer {\n private readonly extensions: WorkflowExtension[] = [];\n\n register(extension: WorkflowExtension): this {\n this.extensions.push(extension);\n return this;\n }\n\n registerMany(extensions: WorkflowExtension[]): this {\n extensions.forEach((extension) => this.register(extension));\n return this;\n }\n\n compose(params: ComposeParams): WorkflowSpec {\n const applicable = this.extensions\n .filter((extension) => matches(params, extension))\n .sort((a, b) => (a.priority ?? 0) - (b.priority ?? 0));\n\n return applicable.reduce(\n (acc, extension) => applyWorkflowExtension(acc, extension),\n params.base\n );\n }\n}\n\nfunction matches(params: ComposeParams, extension: WorkflowExtension) {\n if (extension.workflow !== params.base.meta.name) return false;\n if (\n extension.baseVersion &&\n extension.baseVersion !== params.base.meta.version\n ) {\n return false;\n }\n if (extension.tenantId && extension.tenantId !== params.tenantId) {\n return false;\n }\n if (extension.role && extension.role !== params.role) {\n return false;\n }\n if (extension.device && extension.device !== params.device) {\n return false;\n }\n return true;\n}\n"],"mappings":"uDAIA,IAAa,EAAb,KAA8B,CAC5B,WAAmD,EAAE,CAErD,SAAS,EAAoC,CAE3C,OADA,KAAK,WAAW,KAAK,EAAU,CACxB,KAGT,aAAa,EAAuC,CAElD,OADA,EAAW,QAAS,GAAc,KAAK,SAAS,EAAU,CAAC,CACpD,KAGT,QAAQ,EAAqC,CAK3C,OAJmB,KAAK,WACrB,OAAQ,GAAc,EAAQ,EAAQ,EAAU,CAAC,CACjD,MAAM,EAAG,KAAO,EAAE,UAAY,IAAM,EAAE,UAAY,GAAG,CAEtC,QACf,EAAK,IAAc,EAAuB,EAAK,EAAU,CAC1D,EAAO,KACR,GAIL,SAAS,EAAQ,EAAuB,EAA8B,CAiBpE,MAHA,EAbI,EAAU,WAAa,EAAO,KAAK,KAAK,MAE1C,EAAU,aACV,EAAU,cAAgB,EAAO,KAAK,KAAK,SAIzC,EAAU,UAAY,EAAU,WAAa,EAAO,UAGpD,EAAU,MAAQ,EAAU,OAAS,EAAO,MAG5C,EAAU,QAAU,EAAU,SAAW,EAAO"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComposeParams, StepInjection, WorkflowExtension, WorkflowExtensionScope } from "./types.js";
|
|
2
|
+
import { StepTemplateOptions, approvalStepTemplate } from "./templates.js";
|
|
3
|
+
import { applyWorkflowExtension } from "./injector.js";
|
|
4
|
+
import { WorkflowComposer } from "./composer.js";
|
|
5
|
+
import { WorkflowExtensionValidationIssue, validateExtension } from "./validator.js";
|
|
6
|
+
import { mergeExtensions } from "./merger.js";
|
|
7
|
+
export { ComposeParams, StepInjection, StepTemplateOptions, WorkflowComposer, WorkflowExtension, WorkflowExtensionScope, WorkflowExtensionValidationIssue, applyWorkflowExtension, approvalStepTemplate, mergeExtensions, validateExtension };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{approvalStepTemplate as e}from"./templates.js";import{validateExtension as t}from"./validator.js";import{applyWorkflowExtension as n}from"./injector.js";import{WorkflowComposer as r}from"./composer.js";import{mergeExtensions as i}from"./merger.js";export{r as WorkflowComposer,n as applyWorkflowExtension,e as approvalStepTemplate,i as mergeExtensions,t as validateExtension};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WorkflowExtension } from "./types.js";
|
|
2
|
+
import { WorkflowSpec } from "@lssm/lib.contracts/workflow/spec";
|
|
3
|
+
|
|
4
|
+
//#region src/injector.d.ts
|
|
5
|
+
declare function applyWorkflowExtension(base: WorkflowSpec, extension: WorkflowExtension): WorkflowSpec;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { applyWorkflowExtension };
|
|
8
|
+
//# sourceMappingURL=injector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injector.d.ts","names":[],"sources":["../src/injector.ts"],"sourcesContent":[],"mappings":";;;;iBAIgB,sBAAA,OACR,yBACK,oBACV"}
|
package/dist/injector.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{validateExtension as e}from"./validator.js";function t(t,r){e(r,t);let s=o(t),c=[...s.definition.steps],l=[...s.definition.transitions],u=new Set(r.hiddenSteps??[]);return u.forEach(e=>{let t=c.findIndex(t=>t.id===e);t!==-1&&c.splice(t,1)}),u.size&&(l=l.filter(e=>!u.has(e.from)&&!u.has(e.to))),r.customSteps?.forEach(e=>{n(c,e),i(l,e)}),s.definition.steps=c,s.definition.transitions=a(l),s.meta={...s.meta,version:s.meta.version},s}function n(e,t){let n=r(e,t);if(n===-1)throw Error(`Unable to place injected step "${t.inject.id}"`);e.splice(n,0,{...t.inject})}function r(e,t){if(t.after){let n=e.findIndex(e=>e.id===t.after);return n===-1?-1:n+1}if(t.before){let n=e.findIndex(e=>e.id===t.before);return n===-1?-1:n}return e.length}function i(e,t){t.inject.id&&(t.transitionFrom&&e.push({from:t.transitionFrom,to:t.inject.id,condition:t.when}),t.transitionTo&&e.push({from:t.inject.id,to:t.transitionTo,condition:t.when}))}function a(e){let t=new Set,n=[];return e.forEach(e=>{let r=`${e.from}->${e.to}:${e.condition??``}`;t.has(r)||(t.add(r),n.push(e))}),n}function o(e){return JSON.parse(JSON.stringify(e))}export{t as applyWorkflowExtension};
|
|
2
|
+
//# sourceMappingURL=injector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injector.js","names":["result: typeof transitions"],"sources":["../src/injector.ts"],"sourcesContent":["import type { WorkflowSpec } from '@lssm/lib.contracts/workflow/spec';\nimport type { WorkflowExtension, StepInjection } from './types';\nimport { validateExtension } from './validator';\n\nexport function applyWorkflowExtension(\n base: WorkflowSpec,\n extension: WorkflowExtension\n): WorkflowSpec {\n validateExtension(extension, base);\n const spec = cloneWorkflowSpec(base);\n\n const steps = [...spec.definition.steps];\n let transitions = [...spec.definition.transitions];\n\n const hiddenSet = new Set(extension.hiddenSteps ?? []);\n\n hiddenSet.forEach((stepId) => {\n const idx = steps.findIndex((step) => step.id === stepId);\n if (idx !== -1) {\n steps.splice(idx, 1);\n }\n });\n\n if (hiddenSet.size) {\n transitions = transitions.filter(\n (transition) =>\n !hiddenSet.has(transition.from) && !hiddenSet.has(transition.to)\n );\n }\n\n extension.customSteps?.forEach((injection) => {\n insertStep(steps, injection);\n wireTransitions(transitions, injection);\n });\n\n spec.definition.steps = steps;\n spec.definition.transitions = dedupeTransitions(transitions);\n spec.meta = {\n ...spec.meta,\n version: spec.meta.version,\n };\n return spec;\n}\n\nfunction insertStep(\n steps: WorkflowSpec['definition']['steps'],\n injection: StepInjection\n) {\n const anchorIndex = resolveAnchorIndex(steps, injection);\n if (anchorIndex === -1) {\n throw new Error(`Unable to place injected step \"${injection.inject.id}\"`);\n }\n steps.splice(anchorIndex, 0, { ...injection.inject });\n}\n\nfunction resolveAnchorIndex(\n steps: WorkflowSpec['definition']['steps'],\n injection: StepInjection\n) {\n if (injection.after) {\n const idx = steps.findIndex((step) => step.id === injection.after);\n return idx === -1 ? -1 : idx + 1;\n }\n if (injection.before) {\n const idx = steps.findIndex((step) => step.id === injection.before);\n return idx === -1 ? -1 : idx;\n }\n return steps.length;\n}\n\nfunction wireTransitions(\n transitions: WorkflowSpec['definition']['transitions'],\n injection: StepInjection\n) {\n if (!injection.inject.id) return;\n\n if (injection.transitionFrom) {\n transitions.push({\n from: injection.transitionFrom,\n to: injection.inject.id,\n condition: injection.when,\n });\n }\n\n if (injection.transitionTo) {\n transitions.push({\n from: injection.inject.id,\n to: injection.transitionTo,\n condition: injection.when,\n });\n }\n}\n\nfunction dedupeTransitions(\n transitions: WorkflowSpec['definition']['transitions']\n): WorkflowSpec['definition']['transitions'] {\n const seen = new Set<string>();\n const result: typeof transitions = [];\n transitions.forEach((transition) => {\n const key = `${transition.from}->${transition.to}:${transition.condition ?? ''}`;\n if (seen.has(key)) return;\n seen.add(key);\n result.push(transition);\n });\n return result;\n}\n\nfunction cloneWorkflowSpec(spec: WorkflowSpec): WorkflowSpec {\n return JSON.parse(JSON.stringify(spec));\n}\n"],"mappings":"mDAIA,SAAgB,EACd,EACA,EACc,CACd,EAAkB,EAAW,EAAK,CAClC,IAAM,EAAO,EAAkB,EAAK,CAE9B,EAAQ,CAAC,GAAG,EAAK,WAAW,MAAM,CACpC,EAAc,CAAC,GAAG,EAAK,WAAW,YAAY,CAE5C,EAAY,IAAI,IAAI,EAAU,aAAe,EAAE,CAAC,CA2BtD,OAzBA,EAAU,QAAS,GAAW,CAC5B,IAAM,EAAM,EAAM,UAAW,GAAS,EAAK,KAAO,EAAO,CACrD,IAAQ,IACV,EAAM,OAAO,EAAK,EAAE,EAEtB,CAEE,EAAU,OACZ,EAAc,EAAY,OACvB,GACC,CAAC,EAAU,IAAI,EAAW,KAAK,EAAI,CAAC,EAAU,IAAI,EAAW,GAAG,CACnE,EAGH,EAAU,aAAa,QAAS,GAAc,CAC5C,EAAW,EAAO,EAAU,CAC5B,EAAgB,EAAa,EAAU,EACvC,CAEF,EAAK,WAAW,MAAQ,EACxB,EAAK,WAAW,YAAc,EAAkB,EAAY,CAC5D,EAAK,KAAO,CACV,GAAG,EAAK,KACR,QAAS,EAAK,KAAK,QACpB,CACM,EAGT,SAAS,EACP,EACA,EACA,CACA,IAAM,EAAc,EAAmB,EAAO,EAAU,CACxD,GAAI,IAAgB,GAClB,MAAU,MAAM,kCAAkC,EAAU,OAAO,GAAG,GAAG,CAE3E,EAAM,OAAO,EAAa,EAAG,CAAE,GAAG,EAAU,OAAQ,CAAC,CAGvD,SAAS,EACP,EACA,EACA,CACA,GAAI,EAAU,MAAO,CACnB,IAAM,EAAM,EAAM,UAAW,GAAS,EAAK,KAAO,EAAU,MAAM,CAClE,OAAO,IAAQ,GAAK,GAAK,EAAM,EAEjC,GAAI,EAAU,OAAQ,CACpB,IAAM,EAAM,EAAM,UAAW,GAAS,EAAK,KAAO,EAAU,OAAO,CACnE,OAAO,IAAQ,GAAK,GAAK,EAE3B,OAAO,EAAM,OAGf,SAAS,EACP,EACA,EACA,CACK,EAAU,OAAO,KAElB,EAAU,gBACZ,EAAY,KAAK,CACf,KAAM,EAAU,eAChB,GAAI,EAAU,OAAO,GACrB,UAAW,EAAU,KACtB,CAAC,CAGA,EAAU,cACZ,EAAY,KAAK,CACf,KAAM,EAAU,OAAO,GACvB,GAAI,EAAU,aACd,UAAW,EAAU,KACtB,CAAC,EAIN,SAAS,EACP,EAC2C,CAC3C,IAAM,EAAO,IAAI,IACXA,EAA6B,EAAE,CAOrC,OANA,EAAY,QAAS,GAAe,CAClC,IAAM,EAAM,GAAG,EAAW,KAAK,IAAI,EAAW,GAAG,GAAG,EAAW,WAAa,KACxE,EAAK,IAAI,EAAI,GACjB,EAAK,IAAI,EAAI,CACb,EAAO,KAAK,EAAW,GACvB,CACK,EAGT,SAAS,EAAkB,EAAkC,CAC3D,OAAO,KAAK,MAAM,KAAK,UAAU,EAAK,CAAC"}
|
package/dist/merger.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merger.d.ts","names":[],"sources":["../src/merger.ts"],"sourcesContent":[],"mappings":";;;iBAEgB,eAAA,aACF,sBACX"}
|
package/dist/merger.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merger.js","names":[],"sources":["../src/merger.ts"],"sourcesContent":["import type { WorkflowExtension } from './types';\n\nexport function mergeExtensions(\n extensions: WorkflowExtension[]\n): WorkflowExtension[] {\n return extensions.sort((a, b) => (a.priority ?? 0) - (b.priority ?? 0));\n}\n"],"mappings":"AAEA,SAAgB,EACd,EACqB,CACrB,OAAO,EAAW,MAAM,EAAG,KAAO,EAAE,UAAY,IAAM,EAAE,UAAY,GAAG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Step, StepAction, StepType } from "@lssm/lib.contracts/workflow/spec";
|
|
2
|
+
|
|
3
|
+
//#region src/templates.d.ts
|
|
4
|
+
interface StepTemplateOptions {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
type?: StepType;
|
|
8
|
+
description?: string;
|
|
9
|
+
action?: StepAction;
|
|
10
|
+
guardExpression?: string;
|
|
11
|
+
}
|
|
12
|
+
declare function approvalStepTemplate(options: StepTemplateOptions): Step;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { StepTemplateOptions, approvalStepTemplate };
|
|
15
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","names":[],"sources":["../src/templates.ts"],"sourcesContent":[],"mappings":";;;UAMiB,mBAAA;;EAAA,KAAA,EAAA,MAAA;EASD,IAAA,CAAA,EANP,QAMO;;WAJL;;;iBAIK,oBAAA,UAA8B,sBAAsB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){return{id:e.id,label:e.label,type:e.type??`human`,description:e.description??`Tenant-specific approval`,action:e.action,guard:e.guardExpression?{type:`expression`,value:e.guardExpression}:void 0}}export{e as approvalStepTemplate};
|
|
2
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","names":[],"sources":["../src/templates.ts"],"sourcesContent":["import type {\n Step,\n StepAction,\n StepType,\n} from '@lssm/lib.contracts/workflow/spec';\n\nexport interface StepTemplateOptions {\n id: string;\n label: string;\n type?: StepType;\n description?: string;\n action?: StepAction;\n guardExpression?: string;\n}\n\nexport function approvalStepTemplate(options: StepTemplateOptions): Step {\n return {\n id: options.id,\n label: options.label,\n type: options.type ?? 'human',\n description: options.description ?? 'Tenant-specific approval',\n action: options.action,\n guard: options.guardExpression\n ? {\n type: 'expression',\n value: options.guardExpression,\n }\n : undefined,\n };\n}\n"],"mappings":"AAeA,SAAgB,EAAqB,EAAoC,CACvE,MAAO,CACL,GAAI,EAAQ,GACZ,MAAO,EAAQ,MACf,KAAM,EAAQ,MAAQ,QACtB,YAAa,EAAQ,aAAe,2BACpC,OAAQ,EAAQ,OAChB,MAAO,EAAQ,gBACX,CACE,KAAM,aACN,MAAO,EAAQ,gBAChB,CACD,IAAA,GACL"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Step, WorkflowSpec } from "@lssm/lib.contracts/workflow/spec";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
interface WorkflowExtensionScope {
|
|
5
|
+
tenantId?: string;
|
|
6
|
+
role?: string;
|
|
7
|
+
device?: string;
|
|
8
|
+
}
|
|
9
|
+
interface StepInjection {
|
|
10
|
+
id?: string;
|
|
11
|
+
after?: string;
|
|
12
|
+
before?: string;
|
|
13
|
+
inject: Step;
|
|
14
|
+
when?: string;
|
|
15
|
+
transitionTo?: string;
|
|
16
|
+
transitionFrom?: string;
|
|
17
|
+
}
|
|
18
|
+
interface WorkflowExtension extends WorkflowExtensionScope {
|
|
19
|
+
workflow: string;
|
|
20
|
+
baseVersion?: number;
|
|
21
|
+
priority?: number;
|
|
22
|
+
customSteps?: StepInjection[];
|
|
23
|
+
hiddenSteps?: string[];
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
annotations?: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
interface ComposeParams extends WorkflowExtensionScope {
|
|
28
|
+
base: WorkflowSpec;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { ComposeParams, StepInjection, WorkflowExtension, WorkflowExtensionScope };
|
|
32
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;UAEiB,sBAAA;;EAAA,IAAA,CAAA,EAAA,MAAA;EAMA,MAAA,CAAA,EAAA,MAAA;AAUjB;AAIgB,UAdC,aAAA,CAcD;EAEH,EAAA,CAAA,EAAA,MAAA;EACG,KAAA,CAAA,EAAA,MAAA;EAP2B,MAAA,CAAA,EAAA,MAAA;EAAsB,MAAA,EANvD,IAMuD;EAUhD,IAAA,CAAA,EAAA,MAAA;;;;UAVA,iBAAA,SAA0B;;;;gBAI3B;;aAEH;gBACG;;UAGC,aAAA,SAAsB;QAC/B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WorkflowExtension } from "./types.js";
|
|
2
|
+
import { WorkflowSpec } from "@lssm/lib.contracts/workflow/spec";
|
|
3
|
+
|
|
4
|
+
//#region src/validator.d.ts
|
|
5
|
+
interface WorkflowExtensionValidationIssue {
|
|
6
|
+
code: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
declare function validateExtension(extension: WorkflowExtension, base: WorkflowSpec): void;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { WorkflowExtensionValidationIssue, validateExtension };
|
|
12
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","names":[],"sources":["../src/validator.ts"],"sourcesContent":[],"mappings":";;;;UAGiB,gCAAA;;EAAA,OAAA,EAAA,MAAA;AAKjB;iBAAgB,iBAAA,YACH,yBACL"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,t){let n=[],r=new Set(t.definition.steps.map(e=>e.id));if(e.customSteps?.forEach((e,t)=>{e.inject.id||n.push({code:`workflow.extension.step.id`,message:`customSteps[${t}] is missing an id`}),!e.after&&!e.before&&n.push({code:`workflow.extension.step.anchor`,message:`customSteps[${t}] must set after or before`}),e.after&&!r.has(e.after)&&n.push({code:`workflow.extension.step.after`,message:`customSteps[${t}] references unknown step "${e.after}"`}),e.before&&!r.has(e.before)&&n.push({code:`workflow.extension.step.before`,message:`customSteps[${t}] references unknown step "${e.before}"`})}),e.hiddenSteps?.forEach(e=>{r.has(e)||n.push({code:`workflow.extension.hidden-step`,message:`hidden step "${e}" does not exist`})}),n.length){let t=n.map(e=>`${e.code}: ${e.message}`).join(`; `);throw Error(`Invalid workflow extension for ${e.workflow}: ${t}`)}}export{e as validateExtension};
|
|
2
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","names":["issues: WorkflowExtensionValidationIssue[]"],"sources":["../src/validator.ts"],"sourcesContent":["import type { WorkflowSpec } from '@lssm/lib.contracts/workflow/spec';\nimport type { WorkflowExtension } from './types';\n\nexport interface WorkflowExtensionValidationIssue {\n code: string;\n message: string;\n}\n\nexport function validateExtension(\n extension: WorkflowExtension,\n base: WorkflowSpec\n) {\n const issues: WorkflowExtensionValidationIssue[] = [];\n const stepIds = new Set(base.definition.steps.map((step) => step.id));\n\n extension.customSteps?.forEach((injection, idx) => {\n if (!injection.inject.id) {\n issues.push({\n code: 'workflow.extension.step.id',\n message: `customSteps[${idx}] is missing an id`,\n });\n }\n\n if (!injection.after && !injection.before) {\n issues.push({\n code: 'workflow.extension.step.anchor',\n message: `customSteps[${idx}] must set after or before`,\n });\n }\n\n if (injection.after && !stepIds.has(injection.after)) {\n issues.push({\n code: 'workflow.extension.step.after',\n message: `customSteps[${idx}] references unknown step \"${injection.after}\"`,\n });\n }\n\n if (injection.before && !stepIds.has(injection.before)) {\n issues.push({\n code: 'workflow.extension.step.before',\n message: `customSteps[${idx}] references unknown step \"${injection.before}\"`,\n });\n }\n });\n\n extension.hiddenSteps?.forEach((stepId) => {\n if (!stepIds.has(stepId)) {\n issues.push({\n code: 'workflow.extension.hidden-step',\n message: `hidden step \"${stepId}\" does not exist`,\n });\n }\n });\n\n if (issues.length) {\n const reason = issues\n .map((issue) => `${issue.code}: ${issue.message}`)\n .join('; ');\n throw new Error(\n `Invalid workflow extension for ${extension.workflow}: ${reason}`\n );\n }\n}\n"],"mappings":"AAQA,SAAgB,EACd,EACA,EACA,CACA,IAAMA,EAA6C,EAAE,CAC/C,EAAU,IAAI,IAAI,EAAK,WAAW,MAAM,IAAK,GAAS,EAAK,GAAG,CAAC,CAyCrE,GAvCA,EAAU,aAAa,SAAS,EAAW,IAAQ,CAC5C,EAAU,OAAO,IACpB,EAAO,KAAK,CACV,KAAM,6BACN,QAAS,eAAe,EAAI,oBAC7B,CAAC,CAGA,CAAC,EAAU,OAAS,CAAC,EAAU,QACjC,EAAO,KAAK,CACV,KAAM,iCACN,QAAS,eAAe,EAAI,4BAC7B,CAAC,CAGA,EAAU,OAAS,CAAC,EAAQ,IAAI,EAAU,MAAM,EAClD,EAAO,KAAK,CACV,KAAM,gCACN,QAAS,eAAe,EAAI,6BAA6B,EAAU,MAAM,GAC1E,CAAC,CAGA,EAAU,QAAU,CAAC,EAAQ,IAAI,EAAU,OAAO,EACpD,EAAO,KAAK,CACV,KAAM,iCACN,QAAS,eAAe,EAAI,6BAA6B,EAAU,OAAO,GAC3E,CAAC,EAEJ,CAEF,EAAU,aAAa,QAAS,GAAW,CACpC,EAAQ,IAAI,EAAO,EACtB,EAAO,KAAK,CACV,KAAM,iCACN,QAAS,gBAAgB,EAAO,kBACjC,CAAC,EAEJ,CAEE,EAAO,OAAQ,CACjB,IAAM,EAAS,EACZ,IAAK,GAAU,GAAG,EAAM,KAAK,IAAI,EAAM,UAAU,CACjD,KAAK,KAAK,CACb,MAAU,MACR,kCAAkC,EAAU,SAAS,IAAI,IAC1D"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lssm/lib.workflow-composer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Tenant-aware workflow composition helpers for ContractSpec.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "bun build:bundle && bun build:types",
|
|
15
|
+
"build:bundle": "tsdown",
|
|
16
|
+
"build:types": "tsc --noEmit",
|
|
17
|
+
"dev": "bun build:bundle --watch",
|
|
18
|
+
"clean": "rimraf dist .turbo",
|
|
19
|
+
"lint": "bun lint:fix",
|
|
20
|
+
"lint:fix": "eslint src --fix",
|
|
21
|
+
"lint:check": "eslint src",
|
|
22
|
+
"test": "vitest run"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@lssm/lib.contracts": "workspace:*"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@lssm/tool.tsdown": "workspace:*",
|
|
29
|
+
"@lssm/tool.typescript": "workspace:*",
|
|
30
|
+
"tsdown": "^0.16.6",
|
|
31
|
+
"typescript": "^5.9.3",
|
|
32
|
+
"vitest": "^1.6.0"
|
|
33
|
+
},
|
|
34
|
+
"exports": {
|
|
35
|
+
".": "./dist/index.js",
|
|
36
|
+
"./*": "./*"
|
|
37
|
+
}
|
|
38
|
+
}
|