@aglyn/plugins-workflows 1.0.0-beta.218 → 1.0.0-beta.220

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.
Files changed (85) hide show
  1. package/README.md +33 -4
  2. package/package.json +13 -13
  3. package/src/index.d.ts +1 -0
  4. package/src/index.js.map +1 -1
  5. package/src/lib/components/host-actions-card.component.js +3 -2
  6. package/src/lib/components/host-actions-card.component.js.map +1 -1
  7. package/src/lib/components/host-run-history-card.component.d.ts +2 -2
  8. package/src/lib/components/host-run-history-card.component.js +3 -2
  9. package/src/lib/components/host-run-history-card.component.js.map +1 -1
  10. package/src/lib/components/host-webhooks-card.component.js +2 -1
  11. package/src/lib/components/host-webhooks-card.component.js.map +1 -1
  12. package/src/lib/components/host-workflows-card.component.js +4 -3
  13. package/src/lib/components/host-workflows-card.component.js.map +1 -1
  14. package/src/lib/components/use-automation-step-pickers.js +50 -42
  15. package/src/lib/components/use-automation-step-pickers.js.map +1 -1
  16. package/src/lib/components/use-org-automation-step-pickers.js +23 -11
  17. package/src/lib/components/use-org-automation-step-pickers.js.map +1 -1
  18. package/src/lib/components/workflow-zones.d.ts +49 -0
  19. package/src/lib/components/workflow-zones.js +3 -0
  20. package/src/lib/components/workflow-zones.js.map +1 -1
  21. package/src/lib/declarations.server.d.ts +6 -0
  22. package/src/lib/declarations.server.js +39 -0
  23. package/src/lib/declarations.server.js.map +1 -1
  24. package/src/lib/engine/crm-action-steps.d.ts +14 -1
  25. package/src/lib/engine/crm-action-steps.js +15 -0
  26. package/src/lib/engine/crm-action-steps.js.map +1 -1
  27. package/src/lib/engine/run-event-actions.d.ts +2 -1
  28. package/src/lib/engine/run-event-actions.js +66 -25
  29. package/src/lib/engine/run-event-actions.js.map +1 -1
  30. package/src/lib/engine/run-event-workflows.js +2 -1
  31. package/src/lib/engine/run-event-workflows.js.map +1 -1
  32. package/src/lib/engine/workflow-steps.d.ts +1 -1
  33. package/src/lib/engine/workflow-steps.js +1 -1
  34. package/src/lib/engine/workflow-steps.js.map +1 -1
  35. package/src/lib/model/automation-record.d.ts +47 -0
  36. package/src/lib/model/automation-record.js +79 -0
  37. package/src/lib/model/automation-record.js.map +1 -0
  38. package/src/lib/model/org-automations.js.map +1 -1
  39. package/src/lib/model/step-outcomes.d.ts +42 -0
  40. package/src/lib/model/step-outcomes.js +70 -0
  41. package/src/lib/model/step-outcomes.js.map +1 -0
  42. package/src/lib/model/webhooks.d.ts +36 -0
  43. package/src/lib/model/webhooks.js +24 -0
  44. package/src/lib/model/webhooks.js.map +1 -0
  45. package/src/lib/model/workflows-record-lists.d.ts +18 -0
  46. package/src/lib/model/workflows-record-lists.js +45 -0
  47. package/src/lib/model/workflows-record-lists.js.map +1 -0
  48. package/src/lib/model/workflows-record-routes.d.ts +22 -0
  49. package/src/lib/model/workflows-record-routes.js +73 -0
  50. package/src/lib/model/workflows-record-routes.js.map +1 -0
  51. package/src/lib/model/workflows-search-sources.d.ts +20 -0
  52. package/src/lib/model/workflows-search-sources.js +35 -0
  53. package/src/lib/model/workflows-search-sources.js.map +1 -0
  54. package/src/lib/model/workflows.d.ts +102 -0
  55. package/src/lib/model/workflows.js +167 -0
  56. package/src/lib/model/workflows.js.map +1 -0
  57. package/src/lib/plan-entitlements.d.ts +36 -0
  58. package/src/lib/plan-entitlements.js +44 -0
  59. package/src/lib/plan-entitlements.js.map +1 -0
  60. package/src/lib/plugin.js +37 -2
  61. package/src/lib/plugin.js.map +1 -1
  62. package/src/lib/server/automation-record-index.d.ts +20 -0
  63. package/src/lib/server/automation-record-index.js +59 -0
  64. package/src/lib/server/automation-record-index.js.map +1 -0
  65. package/src/lib/server/workflow-dependents.d.ts +28 -0
  66. package/src/lib/server/workflow-dependents.js +61 -0
  67. package/src/lib/server/workflow-dependents.js.map +1 -0
  68. package/src/lib/server/workflow-variables.d.ts +20 -0
  69. package/src/lib/server/workflow-variables.js +75 -0
  70. package/src/lib/server/workflow-variables.js.map +1 -0
  71. package/src/lib/server.d.ts +1 -0
  72. package/src/lib/server.js +2 -1
  73. package/src/lib/server.js.map +1 -1
  74. package/src/lib/tenant-emails.d.ts +29 -0
  75. package/src/lib/tenant-emails.js +41 -0
  76. package/src/lib/tenant-emails.js.map +1 -0
  77. package/src/lib/testing/stand-in-dataset-list.d.ts +28 -0
  78. package/src/lib/testing/stand-in-dataset-list.js +55 -0
  79. package/src/lib/testing/stand-in-dataset-list.js.map +1 -0
  80. package/src/lib/testing/stand-in-overlay-list.d.ts +26 -0
  81. package/src/lib/testing/stand-in-overlay-list.js +53 -0
  82. package/src/lib/testing/stand-in-overlay-list.js.map +1 -0
  83. package/src/lib/usage-axes.d.ts +28 -0
  84. package/src/lib/usage-axes.js +72 -0
  85. package/src/lib/usage-axes.js.map +1 -0
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /**
17
+ * Past-tense phrases for a run summary (AGL-2171).
18
+ *
19
+ * `HOST_ACTION_STEP_LABELS` (core `actions.ts`) names what a step WILL do, in the
20
+ * imperative, for a `Do` select — "Send an email". A run history is the
21
+ * opposite tense and a different audience: it says what already happened,
22
+ * on one line, several steps at a time. `/product/workflows` advertises
23
+ * exactly that shape — `Sent email · saved to Leads · webhook 200`.
24
+ *
25
+ * Two maps rather than one derived from the other, because "Send a webhook
26
+ * (Business)" cannot be mechanically turned into "webhook" — the plan
27
+ * suffix is part of the picker's label and has no business in a log line.
28
+ * Only the steps a SERVER run can perform appear here; the client-side
29
+ * steps run in the visitor's browser and never reach the activity write.
30
+ */ export const HOST_ACTION_STEP_OUTCOMES = {
31
+ runWorkflow: 'ran workflow',
32
+ siteAlert: 'showed an alert',
33
+ customEvent: 'fired an event',
34
+ datasetAppend: 'saved to dataset',
35
+ updateDataset: 'updated dataset',
36
+ webhookPost: 'webhook',
37
+ sendEmail: 'sent email',
38
+ notifyAdmins: 'notified admins',
39
+ enrollList: 'enrolled in list',
40
+ assignCampaign: 'assigned to campaign',
41
+ wait: 'waiting',
42
+ waitForEvent: 'waiting for',
43
+ exitFlow: 'ended the flow',
44
+ setContactStage: 'set stage',
45
+ addContactTag: 'tagged',
46
+ assignContactOwner: 'assigned owner',
47
+ createCrmTask: 'created task',
48
+ logCrmActivity: 'logged activity'
49
+ };
50
+ /**
51
+ * One step's line in a run summary, with the detail that makes it useful.
52
+ *
53
+ * `saved to Leads` beats `saved to dataset`, and `webhook 200` beats
54
+ * `webhook` — the status code is the entire reason anyone opens a run
55
+ * history after a webhook, and it was being discarded on the line it
56
+ * arrived.
57
+ */ export function describeStepOutcome(type, detail) {
58
+ var _HOST_ACTION_STEP_OUTCOMES_type;
59
+ const base = (_HOST_ACTION_STEP_OUTCOMES_type = HOST_ACTION_STEP_OUTCOMES[type]) != null ? _HOST_ACTION_STEP_OUTCOMES_type : String(type);
60
+ const trimmed = detail == null ? void 0 : detail.trim();
61
+ if (!trimmed) return base;
62
+ if (type === 'datasetAppend' || type === 'updateDataset') {
63
+ // `saved to dataset` + `Leads` reads as `saved to Leads`, not
64
+ // `saved to dataset Leads`.
65
+ return `${base.replace(/ dataset$/, '')} ${trimmed}`;
66
+ }
67
+ return `${base} ${trimmed}`;
68
+ }
69
+
70
+ //# sourceMappingURL=step-outcomes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/workflows/src/lib/model/step-outcomes.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { HostActionStepType } from '@aglyn/aglyn/app-utils/actions'\n\n/**\n * Past-tense phrases for a run summary (AGL-2171).\n *\n * `HOST_ACTION_STEP_LABELS` (core `actions.ts`) names what a step WILL do, in the\n * imperative, for a `Do` select — \"Send an email\". A run history is the\n * opposite tense and a different audience: it says what already happened,\n * on one line, several steps at a time. `/product/workflows` advertises\n * exactly that shape — `Sent email · saved to Leads · webhook 200`.\n *\n * Two maps rather than one derived from the other, because \"Send a webhook\n * (Business)\" cannot be mechanically turned into \"webhook\" — the plan\n * suffix is part of the picker's label and has no business in a log line.\n * Only the steps a SERVER run can perform appear here; the client-side\n * steps run in the visitor's browser and never reach the activity write.\n */\nexport const HOST_ACTION_STEP_OUTCOMES: Partial<\n Record<HostActionStepType, string>\n> = {\n runWorkflow: 'ran workflow',\n siteAlert: 'showed an alert',\n customEvent: 'fired an event',\n datasetAppend: 'saved to dataset',\n updateDataset: 'updated dataset',\n webhookPost: 'webhook',\n sendEmail: 'sent email',\n notifyAdmins: 'notified admins',\n enrollList: 'enrolled in list',\n assignCampaign: 'assigned to campaign',\n wait: 'waiting',\n waitForEvent: 'waiting for',\n exitFlow: 'ended the flow',\n setContactStage: 'set stage',\n addContactTag: 'tagged',\n assignContactOwner: 'assigned owner',\n createCrmTask: 'created task',\n logCrmActivity: 'logged activity',\n}\n\n/**\n * One step's line in a run summary, with the detail that makes it useful.\n *\n * `saved to Leads` beats `saved to dataset`, and `webhook 200` beats\n * `webhook` — the status code is the entire reason anyone opens a run\n * history after a webhook, and it was being discarded on the line it\n * arrived.\n */\nexport function describeStepOutcome(\n type: HostActionStepType,\n detail?: string,\n): string {\n const base = HOST_ACTION_STEP_OUTCOMES[type] ?? String(type)\n const trimmed = detail?.trim()\n if (!trimmed) return base\n if (type === 'datasetAppend' || type === 'updateDataset') {\n // `saved to dataset` + `Leads` reads as `saved to Leads`, not\n // `saved to dataset Leads`.\n return `${base.replace(/ dataset$/, '')} ${trimmed}`\n }\n return `${base} ${trimmed}`\n}\n"],"names":["HOST_ACTION_STEP_OUTCOMES","runWorkflow","siteAlert","customEvent","datasetAppend","updateDataset","webhookPost","sendEmail","notifyAdmins","enrollList","assignCampaign","wait","waitForEvent","exitFlow","setContactStage","addContactTag","assignContactOwner","createCrmTask","logCrmActivity","describeStepOutcome","type","detail","base","String","trimmed","trim","replace"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID;;;;;;;;;;;;;;CAcC,GACD,OAAO,MAAMA,4BAET;IACFC,aAAa;IACbC,WAAW;IACXC,aAAa;IACbC,eAAe;IACfC,eAAe;IACfC,aAAa;IACbC,WAAW;IACXC,cAAc;IACdC,YAAY;IACZC,gBAAgB;IAChBC,MAAM;IACNC,cAAc;IACdC,UAAU;IACVC,iBAAiB;IACjBC,eAAe;IACfC,oBAAoB;IACpBC,eAAe;IACfC,gBAAgB;AAClB,EAAC;AAED;;;;;;;CAOC,GACD,OAAO,SAASC,oBACdC,IAAwB,EACxBC,MAAe;QAEFrB;IAAb,MAAMsB,QAAOtB,kCAAAA,yBAAyB,CAACoB,KAAK,YAA/BpB,kCAAmCuB,OAAOH;IACvD,MAAMI,UAAUH,0BAAAA,OAAQI,IAAI;IAC5B,IAAI,CAACD,SAAS,OAAOF;IACrB,IAAIF,SAAS,mBAAmBA,SAAS,iBAAiB;QACxD,8DAA8D;QAC9D,4BAA4B;QAC5B,OAAO,GAAGE,KAAKI,OAAO,CAAC,aAAa,IAAI,CAAC,EAAEF,SAAS;IACtD;IACA,OAAO,GAAGF,KAAK,CAAC,EAAEE,SAAS;AAC7B"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Webhooks (AGL-149) at `hosts/{hostId}/webhooks/{id}`. Outbound entries
19
+ * are targets a `webhookPost` action step delivers to (HMAC-signed);
20
+ * inbound entries mint `/api/hooks/{hostId}/{hookId}` endpoints that run
21
+ * a workflow with the posted JSON in scope. Business tier (`webhooks`
22
+ * flag); Pro can be enabled per-tenant via entitlement overrides.
23
+ */
24
+ export interface HostWebhook {
25
+ name: string;
26
+ direction: 'outbound' | 'inbound';
27
+ /** Outbound delivery URL (https only; checked again at send time). */
28
+ url?: string;
29
+ /** Shared secret: signs outbound bodies, verifies inbound callers. */
30
+ secret?: string;
31
+ /** Inbound: workflow (by name) enrolled with the payload in scope. */
32
+ workflowName?: string;
33
+ enabled?: boolean;
34
+ }
35
+ /** Outbound URLs must be public https — first-line SSRF guard. */
36
+ export declare const WEBHOOK_URL_PATTERN: RegExp;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /**
17
+ * Webhooks (AGL-149) at `hosts/{hostId}/webhooks/{id}`. Outbound entries
18
+ * are targets a `webhookPost` action step delivers to (HMAC-signed);
19
+ * inbound entries mint `/api/hooks/{hostId}/{hookId}` endpoints that run
20
+ * a workflow with the posted JSON in scope. Business tier (`webhooks`
21
+ * flag); Pro can be enabled per-tenant via entitlement overrides.
22
+ */ /** Outbound URLs must be public https — first-line SSRF guard. */ export const WEBHOOK_URL_PATTERN = /^https:\/\/(?!localhost)(?!127\.)(?!0\.)(?!10\.)(?!172\.(1[6-9]|2\d|3[01])\.)(?!192\.168\.)(?!169\.254\.)[^\s]+$/i;
23
+
24
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/workflows/src/lib/model/webhooks.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Webhooks (AGL-149) at `hosts/{hostId}/webhooks/{id}`. Outbound entries\n * are targets a `webhookPost` action step delivers to (HMAC-signed);\n * inbound entries mint `/api/hooks/{hostId}/{hookId}` endpoints that run\n * a workflow with the posted JSON in scope. Business tier (`webhooks`\n * flag); Pro can be enabled per-tenant via entitlement overrides.\n */\nexport interface HostWebhook {\n name: string\n direction: 'outbound' | 'inbound'\n /** Outbound delivery URL (https only; checked again at send time). */\n url?: string\n /** Shared secret: signs outbound bodies, verifies inbound callers. */\n secret?: string\n /** Inbound: workflow (by name) enrolled with the payload in scope. */\n workflowName?: string\n enabled?: boolean\n}\n\n/** Outbound URLs must be public https — first-line SSRF guard. */\nexport const WEBHOOK_URL_PATTERN =\n /^https:\\/\\/(?!localhost)(?!127\\.)(?!0\\.)(?!10\\.)(?!172\\.(1[6-9]|2\\d|3[01])\\.)(?!192\\.168\\.)(?!169\\.254\\.)[^\\s]+$/i\n"],"names":["WEBHOOK_URL_PATTERN"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;CAMC,GAaD,gEAAgE,GAChE,OAAO,MAAMA,sBACX,oHAAmH"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /** Called from the console registrar, owner named for a spec that calls it directly. */
18
+ export declare function registerWorkflowsRecordLists(): void;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ import { registerPluginRecordListSource } from "@aglyn/aglyn/plugin-manager/plugin-record-lists";
17
+ import { collection, documentId, limit, orderBy, query } from "firebase/firestore";
18
+ import { BUNDLE_ID } from "../constants/bundle-common.js";
19
+ import { AUTOMATION_COLLECTIONS, automationIndexedRecord } from "./automation-record.js";
20
+ /**
21
+ * A site's workflows, webhooks and actions, listed in the console for another
22
+ * plugin's picker or check (AGL-3080) — a computed variable choosing the
23
+ * workflow that fills it, a reference check confirming one still exists.
24
+ *
25
+ * All three are a site's: asked at the organization, a source answers none,
26
+ * and none is ever installed from a listing. Ordered by document id, so the
27
+ * window is the same one every bounded list reads. Each record is
28
+ * `automationIndexedRecord`'s, the server indexes' shape.
29
+ */ function automationListSource(kind) {
30
+ return {
31
+ query (firestore, request) {
32
+ return request.hostId && !request.installedFrom ? query(collection(firestore, 'hosts', request.hostId, AUTOMATION_COLLECTIONS[kind]), orderBy(documentId()), limit(request.limit)) : null;
33
+ },
34
+ record: (id, data)=>automationIndexedRecord(kind, id, data)
35
+ };
36
+ }
37
+ /** Called from the console registrar, owner named for a spec that calls it directly. */ export function registerWorkflowsRecordLists() {
38
+ for (const kind of Object.keys(AUTOMATION_COLLECTIONS)){
39
+ registerPluginRecordListSource(kind, automationListSource(kind), {
40
+ pluginId: BUNDLE_ID
41
+ });
42
+ }
43
+ }
44
+
45
+ //# sourceMappingURL=workflows-record-lists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/workflows/src/lib/model/workflows-record-lists.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n registerPluginRecordListSource,\n type PluginRecordListSource,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-lists'\nimport { collection, documentId, limit, orderBy, query } from 'firebase/firestore'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport {\n AUTOMATION_COLLECTIONS,\n automationIndexedRecord,\n type AutomationRecordKind,\n} from './automation-record'\n\n/**\n * A site's workflows, webhooks and actions, listed in the console for another\n * plugin's picker or check (AGL-3080) — a computed variable choosing the\n * workflow that fills it, a reference check confirming one still exists.\n *\n * All three are a site's: asked at the organization, a source answers none,\n * and none is ever installed from a listing. Ordered by document id, so the\n * window is the same one every bounded list reads. Each record is\n * `automationIndexedRecord`'s, the server indexes' shape.\n */\nfunction automationListSource(kind: AutomationRecordKind): PluginRecordListSource {\n return {\n query(firestore, request) {\n return request.hostId && !request.installedFrom\n ? query(\n collection(firestore, 'hosts', request.hostId, AUTOMATION_COLLECTIONS[kind]),\n orderBy(documentId()),\n limit(request.limit),\n )\n : null\n },\n record: (id, data) => automationIndexedRecord(kind, id, data),\n }\n}\n\n/** Called from the console registrar, owner named for a spec that calls it directly. */\nexport function registerWorkflowsRecordLists(): void {\n for (const kind of Object.keys(AUTOMATION_COLLECTIONS) as AutomationRecordKind[]) {\n registerPluginRecordListSource(kind, automationListSource(kind), { pluginId: BUNDLE_ID })\n }\n}\n"],"names":["registerPluginRecordListSource","collection","documentId","limit","orderBy","query","BUNDLE_ID","AUTOMATION_COLLECTIONS","automationIndexedRecord","automationListSource","kind","firestore","request","hostId","installedFrom","record","id","data","registerWorkflowsRecordLists","Object","keys","pluginId"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,8BAA8B,QAEzB,kDAAiD;AACxD,SAASC,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,EAAEC,KAAK,QAAQ,qBAAoB;AAClF,SAASC,SAAS,QAAQ,gCAA4B;AACtD,SACEC,sBAAsB,EACtBC,uBAAuB,QAElB,yBAAqB;AAE5B;;;;;;;;;CASC,GACD,SAASC,qBAAqBC,IAA0B;IACtD,OAAO;QACLL,OAAMM,SAAS,EAAEC,OAAO;YACtB,OAAOA,QAAQC,MAAM,IAAI,CAACD,QAAQE,aAAa,GAC3CT,MACEJ,WAAWU,WAAW,SAASC,QAAQC,MAAM,EAAEN,sBAAsB,CAACG,KAAK,GAC3EN,QAAQF,eACRC,MAAMS,QAAQT,KAAK,KAErB;QACN;QACAY,QAAQ,CAACC,IAAIC,OAAST,wBAAwBE,MAAMM,IAAIC;IAC1D;AACF;AAEA,sFAAsF,GACtF,OAAO,SAASC;IACd,KAAK,MAAMR,QAAQS,OAAOC,IAAI,CAACb,wBAAmD;QAChFP,+BAA+BU,MAAMD,qBAAqBC,OAAO;YAAEW,UAAUf;QAAU;IACzF;AACF"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Called from the console registrar. The owner is named rather than read off
19
+ * the loader's marker, so the routes register the same way under a spec that
20
+ * calls the registrar directly.
21
+ */
22
+ export declare function registerWorkflowsRecordRoutes(): void;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ import { buildRoute, Route } from "@aglyn/aglyn/app-utils/console-routes";
17
+ import { registerPluginRecordRoute } from "@aglyn/aglyn/plugin-manager/plugin-record-routes";
18
+ import { BUNDLE_ID } from "../constants/bundle-common.js";
19
+ /**
20
+ * Where a site's workflows, actions and webhooks are read, published for
21
+ * every other surface — the same three kinds this plugin indexes.
22
+ *
23
+ * The CRM installs an action recipe and names where it landed; an assistant
24
+ * job opens the actions list its drafted automation was saved to. Each asks
25
+ * the record-route registry for the kind rather than spelling this plugin's
26
+ * nav slug, and gets `null` (text instead of a link) where it is not loaded.
27
+ *
28
+ * None of the three has a page of its own: each is edited in its section of
29
+ * the Automation page, so a record's address is its section. The
30
+ * organization's hub lists every site's records under the same section ids,
31
+ * so both levels answer.
32
+ */ /** The nav slug the shell resolves this plugin's hub by, at either level. */ const AUTOMATION_SLUG = 'automation';
33
+ function section({ orgSlug, host }, id) {
34
+ const hub = host ? buildRoute(Route.HOST_PLUGIN, {
35
+ orgSlug,
36
+ host,
37
+ pluginSlug: AUTOMATION_SLUG
38
+ }) : buildRoute(Route.ORG_PLUGIN, {
39
+ orgSlug,
40
+ pluginSlug: AUTOMATION_SLUG
41
+ });
42
+ return `${hub}/${id}`;
43
+ }
44
+ /**
45
+ * Called from the console registrar. The owner is named rather than read off
46
+ * the loader's marker, so the routes register the same way under a spec that
47
+ * calls the registrar directly.
48
+ */ export function registerWorkflowsRecordRoutes() {
49
+ const owner = {
50
+ pluginId: BUNDLE_ID
51
+ };
52
+ for (const [kind, id] of [
53
+ [
54
+ 'workflow',
55
+ 'workflows'
56
+ ],
57
+ [
58
+ 'action',
59
+ 'actions'
60
+ ],
61
+ [
62
+ 'webhook',
63
+ 'webhooks'
64
+ ]
65
+ ]){
66
+ registerPluginRecordRoute(kind, {
67
+ list: (context)=>section(context, id),
68
+ record: (context)=>section(context, id)
69
+ }, owner);
70
+ }
71
+ }
72
+
73
+ //# sourceMappingURL=workflows-record-routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/workflows/src/lib/model/workflows-record-routes.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { buildRoute, Route } from '@aglyn/aglyn/app-utils/console-routes'\nimport {\n registerPluginRecordRoute,\n type PluginRecordRouteContext,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport type { WorkflowsConsoleSectionId } from '../components/workflows-console-sections'\n\n/**\n * Where a site's workflows, actions and webhooks are read, published for\n * every other surface — the same three kinds this plugin indexes.\n *\n * The CRM installs an action recipe and names where it landed; an assistant\n * job opens the actions list its drafted automation was saved to. Each asks\n * the record-route registry for the kind rather than spelling this plugin's\n * nav slug, and gets `null` (text instead of a link) where it is not loaded.\n *\n * None of the three has a page of its own: each is edited in its section of\n * the Automation page, so a record's address is its section. The\n * organization's hub lists every site's records under the same section ids,\n * so both levels answer.\n */\n\n/** The nav slug the shell resolves this plugin's hub by, at either level. */\nconst AUTOMATION_SLUG = 'automation'\n\nfunction section(\n { orgSlug, host }: PluginRecordRouteContext,\n id: WorkflowsConsoleSectionId,\n): string {\n const hub = host\n ? buildRoute(Route.HOST_PLUGIN, { orgSlug, host, pluginSlug: AUTOMATION_SLUG })\n : buildRoute(Route.ORG_PLUGIN, { orgSlug, pluginSlug: AUTOMATION_SLUG })\n return `${hub}/${id}`\n}\n\n/**\n * Called from the console registrar. The owner is named rather than read off\n * the loader's marker, so the routes register the same way under a spec that\n * calls the registrar directly.\n */\nexport function registerWorkflowsRecordRoutes(): void {\n const owner = { pluginId: BUNDLE_ID }\n for (const [kind, id] of [\n ['workflow', 'workflows'],\n ['action', 'actions'],\n ['webhook', 'webhooks'],\n ] as const) {\n registerPluginRecordRoute(\n kind,\n { list: (context) => section(context, id), record: (context) => section(context, id) },\n owner,\n )\n }\n}\n"],"names":["buildRoute","Route","registerPluginRecordRoute","BUNDLE_ID","AUTOMATION_SLUG","section","orgSlug","host","id","hub","HOST_PLUGIN","pluginSlug","ORG_PLUGIN","registerWorkflowsRecordRoutes","owner","pluginId","kind","list","context","record"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,UAAU,EAAEC,KAAK,QAAQ,wCAAuC;AACzE,SACEC,yBAAyB,QAEpB,mDAAkD;AACzD,SAASC,SAAS,QAAQ,gCAA4B;AAGtD;;;;;;;;;;;;;CAaC,GAED,2EAA2E,GAC3E,MAAMC,kBAAkB;AAExB,SAASC,QACP,EAAEC,OAAO,EAAEC,IAAI,EAA4B,EAC3CC,EAA6B;IAE7B,MAAMC,MAAMF,OACRP,WAAWC,MAAMS,WAAW,EAAE;QAAEJ;QAASC;QAAMI,YAAYP;IAAgB,KAC3EJ,WAAWC,MAAMW,UAAU,EAAE;QAAEN;QAASK,YAAYP;IAAgB;IACxE,OAAO,GAAGK,IAAI,CAAC,EAAED,IAAI;AACvB;AAEA;;;;CAIC,GACD,OAAO,SAASK;IACd,MAAMC,QAAQ;QAAEC,UAAUZ;IAAU;IACpC,KAAK,MAAM,CAACa,MAAMR,GAAG,IAAI;QACvB;YAAC;YAAY;SAAY;QACzB;YAAC;YAAU;SAAU;QACrB;YAAC;YAAW;SAAW;KACxB,CAAW;QACVN,0BACEc,MACA;YAAEC,MAAM,CAACC,UAAYb,QAAQa,SAASV;YAAKW,QAAQ,CAACD,UAAYb,QAAQa,SAASV;QAAI,GACrFM;IAEJ;AACF"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ */
14
+ import type { ConsoleSearchSource } from '@aglyn/aglyn';
15
+ /**
16
+ * What the console's search finds in a site's automation (AGL-3080): its
17
+ * workflows, by name, opening on the site's Automation page — the address,
18
+ * never the `/workflows` one it redirects from.
19
+ */
20
+ export declare const WORKFLOWS_SEARCH_SOURCES: readonly ConsoleSearchSource[];
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ */ import { buildRoute, Route } from "@aglyn/aglyn/app-utils/console-routes";
14
+ /**
15
+ * What the console's search finds in a site's automation (AGL-3080): its
16
+ * workflows, by name, opening on the site's Automation page — the address,
17
+ * never the `/workflows` one it redirects from.
18
+ */ export const WORKFLOWS_SEARCH_SOURCES = [
19
+ {
20
+ id: 'workflows',
21
+ group: 'Workflows',
22
+ noun: 'workflows',
23
+ scope: 'host',
24
+ collection: 'workflows',
25
+ nameField: 'name',
26
+ entitlementKey: 'workflowsPerHost',
27
+ order: 150,
28
+ href: (_row, { orgSlug, host })=>host ? buildRoute(Route.HOST_AUTOMATION, {
29
+ orgSlug,
30
+ host
31
+ }) : null
32
+ }
33
+ ];
34
+
35
+ //# sourceMappingURL=workflows-search-sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/workflows/src/lib/model/workflows-search-sources.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ConsoleSearchSource } from '@aglyn/aglyn'\nimport { buildRoute, Route } from '@aglyn/aglyn/app-utils/console-routes'\n\n/**\n * What the console's search finds in a site's automation (AGL-3080): its\n * workflows, by name, opening on the site's Automation page — the address,\n * never the `/workflows` one it redirects from.\n */\nexport const WORKFLOWS_SEARCH_SOURCES: readonly ConsoleSearchSource[] = [\n {\n id: 'workflows',\n group: 'Workflows',\n noun: 'workflows',\n scope: 'host',\n collection: 'workflows',\n nameField: 'name',\n entitlementKey: 'workflowsPerHost',\n order: 150,\n href: (_row, { orgSlug, host }) =>\n host ? buildRoute(Route.HOST_AUTOMATION, { orgSlug, host }) : null,\n },\n]\n"],"names":["buildRoute","Route","WORKFLOWS_SEARCH_SOURCES","id","group","noun","scope","collection","nameField","entitlementKey","order","href","_row","orgSlug","host","HOST_AUTOMATION"],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAGD,SAASA,UAAU,EAAEC,KAAK,QAAQ,wCAAuC;AAEzE;;;;CAIC,GACD,OAAO,MAAMC,2BAA2D;IACtE;QACEC,IAAI;QACJC,OAAO;QACPC,MAAM;QACNC,OAAO;QACPC,YAAY;QACZC,WAAW;QACXC,gBAAgB;QAChBC,OAAO;QACPC,MAAM,CAACC,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAC5BA,OAAOd,WAAWC,MAAMc,eAAe,EAAE;gBAAEF;gBAASC;YAAK,KAAK;IAClE;CACD,CAAA"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { type HostFunction } from '@aglyn/aglyn/app-utils/functions';
18
+ import type { HostEventType } from '@aglyn/aglyn/app-utils/host-events';
19
+ import type { HostVariable } from '@aglyn/aglyn/app-utils/variables';
20
+ /**
21
+ * Workflows (Workflow Builder, AGL-101): named pipelines of host-function
22
+ * calls. Each step evaluates its argument expressions over host variables
23
+ * and previous step results, runs the function through the safe evaluator,
24
+ * and stores the result under its name for later steps. Pure and bounded —
25
+ * no I/O, no loops. Site-event triggers arrive in v2.
26
+ */
27
+ export interface HostWorkflowTrigger {
28
+ event: HostEventType;
29
+ /**
30
+ * Optional expression over the event payload (plus variables); the
31
+ * workflow only runs when it evaluates truthy (e.g. `path == "/pricing"`).
32
+ */
33
+ filter?: string;
34
+ }
35
+ export interface HostWorkflowStep {
36
+ /**
37
+ * Host function to run — by doc id (AGL-261), rename-safe. Steps saved
38
+ * before AGL-261 carry only `functionName`; executors resolve id first.
39
+ */
40
+ functionId?: string;
41
+ /** Legacy name reference, kept as the display hint; `functionId` wins. */
42
+ functionName: string;
43
+ /**
44
+ * One expression per function parameter, evaluated over variables and
45
+ * previous step results (e.g. `price * qty`, `step1 + 10`).
46
+ */
47
+ args: string[];
48
+ /** Scope name the step's result binds to; defaults to `step<N>`. */
49
+ resultName?: string;
50
+ }
51
+ /** `hosts/{hostId}/workflows/{id}` doc. */
52
+ export interface HostWorkflow {
53
+ name: string;
54
+ steps: HostWorkflowStep[];
55
+ /** Scope name whose final value the workflow returns. */
56
+ returnValue?: string;
57
+ /** Event trigger (AGL-128); absent means manual/embedded use only. */
58
+ trigger?: HostWorkflowTrigger | null;
59
+ }
60
+ export declare const WORKFLOW_MAX_STEPS = 25;
61
+ /** Max nesting across workflow→function→workflow cross-calls (AGL-129). */
62
+ export declare const CROSS_MAX_DEPTH = 3;
63
+ /** How deep one custom event may chain into another automation's run. */
64
+ export declare const ACTION_MAX_EVENT_DEPTH = 3;
65
+ export type WorkflowRunResult = {
66
+ ok: true;
67
+ value: number | string | boolean;
68
+ results: Record<string, number | string | boolean>;
69
+ } | {
70
+ ok: false;
71
+ error: string;
72
+ step?: number;
73
+ };
74
+ export interface WorkflowRunContext {
75
+ /** All host workflows by name, enabling function→workflow calls. */
76
+ workflows?: Record<string, HostWorkflow>;
77
+ /** Cross-call nesting depth; internal — callers omit it. */
78
+ depth?: number;
79
+ }
80
+ export declare function runWorkflow(workflow: HostWorkflow, functions: Record<string, HostFunction>, variables?: Record<string, HostVariable>,
81
+ /**
82
+ * Extra scope entries seeded ahead of the steps — event payloads (path,
83
+ * formName, field values) land here (AGL-128). Wins over variables.
84
+ */
85
+ extraScope?: Record<string, number | string | boolean>, context?: WorkflowRunContext): WorkflowRunResult;
86
+ /**
87
+ * The reference a computed site variable carries to the workflow that
88
+ * computes it: the workflow's document id (AGL-261), and the name it had when
89
+ * it was picked, which a variable computed before ids existed carries alone.
90
+ * Written by the variables editor; read here.
91
+ */
92
+ export interface WorkflowComputedVariable extends HostVariable {
93
+ workflowId?: string;
94
+ workflowName?: string;
95
+ }
96
+ /**
97
+ * Computed variables (AGL-129): a variable naming a workflow takes that
98
+ * workflow's result as its value at compose time — by id first, then by
99
+ * name; failures keep the stored fallback value. Each computed variable
100
+ * evaluates once, bounded by the shared depth guard.
101
+ */
102
+ export declare function resolveComputedVariables(variables: Record<string, HostVariable>, functions: Record<string, HostFunction>, workflows: Record<string, HostWorkflow>): Record<string, HostVariable>;