@lssm/lib.workflow-composer 0.3.0 → 1.41.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 CHANGED
@@ -25,4 +25,9 @@ Refer to `docs/tech/personalization/workflow-composition.md` for more.
25
25
 
26
26
 
27
27
 
28
+
29
+
30
+
31
+
32
+
28
33
 
package/dist/composer.js CHANGED
@@ -1,2 +1 @@
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
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};
package/dist/injector.js CHANGED
@@ -1,2 +1 @@
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
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};
package/dist/merger.js CHANGED
@@ -1,2 +1 @@
1
- function e(e){return e.sort((e,t)=>(e.priority??0)-(t.priority??0))}export{e as mergeExtensions};
2
- //# sourceMappingURL=merger.js.map
1
+ function e(e){return e.sort((e,t)=>(e.priority??0)-(t.priority??0))}export{e as mergeExtensions};
package/dist/templates.js CHANGED
@@ -1,2 +1 @@
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
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};
package/dist/validator.js CHANGED
@@ -1,2 +1 @@
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
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lssm/lib.workflow-composer",
3
- "version": "0.3.0",
3
+ "version": "1.41.0",
4
4
  "description": "Tenant-aware workflow composition helpers for ContractSpec.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -23,19 +23,23 @@
23
23
  "test": "bun run"
24
24
  },
25
25
  "dependencies": {
26
- "@lssm/lib.contracts": "1.11.0"
26
+ "@lssm/lib.contracts": "workspace:*"
27
27
  },
28
28
  "devDependencies": {
29
- "@lssm/tool.tsdown": "0.12.0",
30
- "@lssm/tool.typescript": "0.11.0",
31
- "tsdown": "^0.16.6",
29
+ "@lssm/tool.tsdown": "workspace:*",
30
+ "@lssm/tool.typescript": "workspace:*",
31
+ "tsdown": "^0.17.4",
32
32
  "typescript": "^5.9.3"
33
33
  },
34
34
  "exports": {
35
- ".": "./dist/index.js",
35
+ ".": "./src/index.ts",
36
36
  "./*": "./*"
37
37
  },
38
38
  "publishConfig": {
39
- "access": "public"
39
+ "access": "public",
40
+ "exports": {
41
+ ".": "./dist/index.js",
42
+ "./*": "./*"
43
+ }
40
44
  }
41
45
  }
@@ -1,13 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
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 DELETED
@@ -1,7 +0,0 @@
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 };
@@ -1,8 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"injector.d.ts","names":[],"sources":["../src/injector.ts"],"sourcesContent":[],"mappings":";;;;iBAIgB,sBAAA,OACR,yBACK,oBACV"}
@@ -1 +0,0 @@
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 DELETED
@@ -1,7 +0,0 @@
1
- import { WorkflowExtension } from "./types.js";
2
-
3
- //#region src/merger.d.ts
4
- declare function mergeExtensions(extensions: WorkflowExtension[]): WorkflowExtension[];
5
- //#endregion
6
- export { mergeExtensions };
7
- //# sourceMappingURL=merger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"merger.d.ts","names":[],"sources":["../src/merger.ts"],"sourcesContent":[],"mappings":";;;iBAEgB,eAAA,aACF,sBACX"}
@@ -1 +0,0 @@
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"}
@@ -1,15 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
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 DELETED
@@ -1,32 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,12 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
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"}