@codemation/host 0.1.7 → 0.2.1
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/CHANGELOG.md +23 -0
- package/dist/{AppConfigFactory-ByT1D8dM.js → AppConfigFactory-CqKWXqOm.js} +2 -2
- package/dist/{AppConfigFactory-ByT1D8dM.js.map → AppConfigFactory-CqKWXqOm.js.map} +1 -1
- package/dist/{AppConfigFactory-BBEn2B-i.d.ts → AppConfigFactory-j1Mc-dIX.d.ts} +3 -3
- package/dist/{AppContainerFactory-CeKsjo8L.js → AppContainerFactory-CcSGFNLW.js} +53 -16
- package/dist/AppContainerFactory-CcSGFNLW.js.map +1 -0
- package/dist/{CodemationConfig-9PkOBCh-.d.ts → CodemationAppContext-Vtn0U2Ga.d.ts} +80 -80
- package/dist/CodemationAuthoring.types-CXubuYvd.d.ts +196 -0
- package/dist/CodemationAuthoring.types-SxVJ1qu5.js +86 -0
- package/dist/CodemationAuthoring.types-SxVJ1qu5.js.map +1 -0
- package/dist/{CodemationConfigNormalizer-DIc-LYqW.d.ts → CodemationConfigNormalizer-kJmyHNDp.d.ts} +2 -2
- package/dist/{CodemationConsumerConfigLoader-CeW4bnOg.d.ts → CodemationConsumerConfigLoader-BvTE-7tX.d.ts} +2 -2
- package/dist/{CodemationConsumerConfigLoader-D6LFSlp5.js → CodemationConsumerConfigLoader-DovlxZNb.js} +2 -2
- package/dist/{CodemationConsumerConfigLoader-D6LFSlp5.js.map → CodemationConsumerConfigLoader-DovlxZNb.js.map} +1 -1
- package/dist/{CodemationPluginListMerger-Cv7CaM5_.d.ts → CodemationPluginListMerger-DegwsxrS.d.ts} +6 -6
- package/dist/{CodemationPluginListMerger-CGwOTdZ7.js → CodemationPluginListMerger-_lZaa6gO.js} +1 -1
- package/dist/{CodemationPluginListMerger-CGwOTdZ7.js.map → CodemationPluginListMerger-_lZaa6gO.js.map} +1 -1
- package/dist/{CodemationAuthConfig-7hEfICPf.d.ts → CodemationWhitelabelConfig-D5rYcLlj.d.ts} +33 -33
- package/dist/{ConsoleLogger-ClPU7jtc.js → ConsoleLogger-DuStfHe0.js} +1 -1
- package/dist/{ConsoleLogger-ClPU7jtc.js.map → ConsoleLogger-DuStfHe0.js.map} +1 -1
- package/dist/{CredentialServices-xVxVA9Tq.js → CredentialServices-BPKUF8Xs.js} +42 -8
- package/dist/CredentialServices-BPKUF8Xs.js.map +1 -0
- package/dist/{CredentialServices-Dp_jXTJo.d.ts → CredentialServices-GlBk2nL7.d.ts} +14 -5
- package/dist/{LogLevelPolicy-9IcPGZFk.d.ts → LogLevelPolicy-CkiJAH75.d.ts} +2 -2
- package/dist/{PublicFrontendBootstrap-DCniMBGu.d.ts → PublicFrontendBootstrap-ci0Vwxrb.d.ts} +2 -2
- package/dist/{PublicFrontendBootstrapFactory-SQVHMxLg.d.ts → PublicFrontendBootstrapFactory-r61MeSpZ.d.ts} +4 -4
- package/dist/{PublicFrontendBootstrapJsonCodec-BdiVGG5R.js → PublicFrontendBootstrapJsonCodec-BZgQ_FnW.js} +1 -1
- package/dist/{PublicFrontendBootstrapJsonCodec-BdiVGG5R.js.map → PublicFrontendBootstrapJsonCodec-BZgQ_FnW.js.map} +1 -1
- package/dist/{PublicFrontendBootstrapJsonCodec-BE0mhe1v.d.ts → PublicFrontendBootstrapJsonCodec-Ja0GQgpp.d.ts} +2 -2
- package/dist/{ServerLoggerFactory-BltIIDfQ.js → ServerLoggerFactory-CsNW5qhz.js} +4 -4
- package/dist/{ServerLoggerFactory-BltIIDfQ.js.map → ServerLoggerFactory-CsNW5qhz.js.map} +1 -1
- package/dist/authoring.d.ts +5 -0
- package/dist/authoring.js +4 -0
- package/dist/client.d.ts +4 -4
- package/dist/client.js +2 -2
- package/dist/consumer.d.ts +5 -5
- package/dist/consumer.js +5 -5
- package/dist/credentials.d.ts +4 -4
- package/dist/credentials.js +3 -3
- package/dist/devServerSidecar.d.ts +1 -1
- package/dist/{index-CLRTQLAp.d.ts → index-SKC6oys-.d.ts} +9 -1
- package/dist/index.d.ts +14 -203
- package/dist/index.js +14 -98
- package/dist/nextServer.d.ts +12 -11
- package/dist/nextServer.js +8 -8
- package/dist/{persistenceServer-Dv7fg_Jf.d.ts → persistenceServer-D89nDslh.d.ts} +2 -2
- package/dist/{persistenceServer-DMvIOGW8.js → persistenceServer-DKbFDxoS.js} +2 -2
- package/dist/{persistenceServer-DMvIOGW8.js.map → persistenceServer-DKbFDxoS.js.map} +1 -1
- package/dist/persistenceServer.d.ts +6 -6
- package/dist/persistenceServer.js +3 -3
- package/dist/{server-CioY8PP3.js → server-CFpgKuVE.js} +5 -5
- package/dist/{server-CioY8PP3.js.map → server-CFpgKuVE.js.map} +1 -1
- package/dist/{server-C5oqDnZQ.d.ts → server-CUo7My6x.d.ts} +5 -5
- package/dist/server.d.ts +11 -11
- package/dist/server.js +11 -11
- package/package.json +14 -7
- package/src/application/commands/StartWorkflowRunCommandHandler.ts +64 -2
- package/src/authoring.ts +31 -0
- package/src/domain/credentials/CredentialInstanceService.ts +8 -1
- package/src/domain/credentials/CredentialOAuth2ScopeResolver.ts +61 -0
- package/src/domain/credentials/CredentialServices.ts +1 -0
- package/src/domain/credentials/OAuth2ConnectServiceFactory.ts +9 -2
- package/dist/AppContainerFactory-CeKsjo8L.js.map +0 -1
- package/dist/CredentialServices-xVxVA9Tq.js.map +0 -1
- package/dist/index.js.map +0 -1
- /package/dist/{decorate-B0PP651O.js → decorate-Dq0XLibd.js} +0 -0
- /package/dist/{decorateParam-DrsXNPuw.js → decorateParam-D7WPDFAf.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-
|
|
3
|
-
import { t as AppConfigFactory } from "./AppConfigFactory-
|
|
4
|
-
import { a as WorkflowDto, o as WorkflowSummary } from "./PublicFrontendBootstrapFactory-
|
|
1
|
+
import { m as CodemationConfig, o as CodemationPlugin, r as AppConfig } from "./CodemationAppContext-Vtn0U2Ga.js";
|
|
2
|
+
import { t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-BvTE-7tX.js";
|
|
3
|
+
import { t as AppConfigFactory } from "./AppConfigFactory-j1Mc-dIX.js";
|
|
4
|
+
import { a as WorkflowDto, o as WorkflowSummary } from "./PublicFrontendBootstrapFactory-r61MeSpZ.js";
|
|
5
5
|
|
|
6
6
|
//#region src/presentation/http/ApiPaths.d.ts
|
|
7
7
|
declare class ApiPaths {
|
|
@@ -150,4 +150,4 @@ declare class WorkflowDiscoveryPathSegmentsComputer {
|
|
|
150
150
|
}
|
|
151
151
|
//#endregion
|
|
152
152
|
export { CodemationResolvedPluginPackage as a, CodemationServerGateway as c, CodemationPluginDiscovery as i, ApiPaths as l, WorkflowModulePathFinder as n, AppConfigLoadResult as o, CodemationDiscoveredPluginPackage as r, AppConfigLoader as s, WorkflowDiscoveryPathSegmentsComputer as t };
|
|
153
|
-
//# sourceMappingURL=server-
|
|
153
|
+
//# sourceMappingURL=server-CUo7My6x.d.ts.map
|
package/dist/server.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import "./
|
|
5
|
-
import "./
|
|
6
|
-
import "./CodemationConfigNormalizer-
|
|
7
|
-
import { i as CodemationConsumerAppResolver, n as CodemationConsumerConfigResolution, r as CodemationConsumerApp, t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-
|
|
8
|
-
import { r as PrismaDatabaseClient } from "./AppConfigFactory-
|
|
9
|
-
import { t as CodemationPostgresPrismaClientFactory } from "./persistenceServer-
|
|
10
|
-
import { a as CodemationResolvedPluginPackage, c as CodemationServerGateway, i as CodemationPluginDiscovery, l as ApiPaths, n as WorkflowModulePathFinder, o as AppConfigLoadResult, r as CodemationDiscoveredPluginPackage, s as AppConfigLoader, t as WorkflowDiscoveryPathSegmentsComputer } from "./server-
|
|
11
|
-
import { i as CodemationFrontendAuthSnapshotFactory, n as InternalAuthBootstrapFactory, r as FrontendAppConfigFactory, t as PublicFrontendBootstrapFactory } from "./PublicFrontendBootstrapFactory-
|
|
1
|
+
import "./index-SKC6oys-.js";
|
|
2
|
+
import "./CodemationAppContext-Vtn0U2Ga.js";
|
|
3
|
+
import "./CodemationWhitelabelConfig-D5rYcLlj.js";
|
|
4
|
+
import { n as InternalAuthBootstrap, r as FrontendAppConfig, t as PublicFrontendBootstrap } from "./PublicFrontendBootstrap-ci0Vwxrb.js";
|
|
5
|
+
import { i as CodemationFrontendAuthSnapshotJsonCodec, n as InternalAuthBootstrapJsonCodec, r as FrontendAppConfigJsonCodec, t as PublicFrontendBootstrapJsonCodec } from "./PublicFrontendBootstrapJsonCodec-Ja0GQgpp.js";
|
|
6
|
+
import "./CodemationConfigNormalizer-kJmyHNDp.js";
|
|
7
|
+
import { i as CodemationConsumerAppResolver, n as CodemationConsumerConfigResolution, r as CodemationConsumerApp, t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-BvTE-7tX.js";
|
|
8
|
+
import { r as PrismaDatabaseClient } from "./AppConfigFactory-j1Mc-dIX.js";
|
|
9
|
+
import { t as CodemationPostgresPrismaClientFactory } from "./persistenceServer-D89nDslh.js";
|
|
10
|
+
import { a as CodemationResolvedPluginPackage, c as CodemationServerGateway, i as CodemationPluginDiscovery, l as ApiPaths, n as WorkflowModulePathFinder, o as AppConfigLoadResult, r as CodemationDiscoveredPluginPackage, s as AppConfigLoader, t as WorkflowDiscoveryPathSegmentsComputer } from "./server-CUo7My6x.js";
|
|
11
|
+
import { i as CodemationFrontendAuthSnapshotFactory, n as InternalAuthBootstrapFactory, r as FrontendAppConfigFactory, t as PublicFrontendBootstrapFactory } from "./PublicFrontendBootstrapFactory-r61MeSpZ.js";
|
|
12
12
|
export { ApiPaths, AppConfigLoadResult, AppConfigLoader, CodemationConsumerApp, CodemationConsumerAppResolver, CodemationConsumerConfigLoader, CodemationConsumerConfigResolution, CodemationDiscoveredPluginPackage, CodemationFrontendAuthSnapshotFactory, CodemationFrontendAuthSnapshotJsonCodec, CodemationPluginDiscovery, CodemationPostgresPrismaClientFactory, CodemationResolvedPluginPackage, CodemationServerGateway, FrontendAppConfig, FrontendAppConfigFactory, FrontendAppConfigJsonCodec, InternalAuthBootstrap, InternalAuthBootstrapFactory, InternalAuthBootstrapJsonCodec, PrismaDatabaseClient as PrismaClient, PublicFrontendBootstrap, PublicFrontendBootstrapFactory, PublicFrontendBootstrapJsonCodec, WorkflowDiscoveryPathSegmentsComputer, WorkflowModulePathFinder };
|
package/dist/server.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import "./ConsoleLogger-
|
|
2
|
-
import { i as CodemationFrontendAuthSnapshotJsonCodec, n as InternalAuthBootstrapJsonCodec, r as FrontendAppConfigJsonCodec, t as PublicFrontendBootstrapJsonCodec } from "./PublicFrontendBootstrapJsonCodec-
|
|
3
|
-
import { i as CodemationConsumerAppResolver, n as WorkflowDiscoveryPathSegmentsComputer, r as WorkflowModulePathFinder, t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-
|
|
4
|
-
import "./ServerLoggerFactory-
|
|
5
|
-
import "./decorateParam-
|
|
6
|
-
import "./decorate-
|
|
7
|
-
import "./CredentialServices-
|
|
8
|
-
import { _ as CodemationFrontendAuthSnapshotFactory, g as FrontendAppConfigFactory, h as InternalAuthBootstrapFactory, m as PublicFrontendBootstrapFactory, y as ApiPaths } from "./AppContainerFactory-
|
|
9
|
-
import "./AppConfigFactory-
|
|
10
|
-
import { t as CodemationPostgresPrismaClientFactory } from "./persistenceServer-
|
|
11
|
-
import { n as AppConfigLoader, r as CodemationServerGateway, t as CodemationPluginDiscovery } from "./server-
|
|
1
|
+
import "./ConsoleLogger-DuStfHe0.js";
|
|
2
|
+
import { i as CodemationFrontendAuthSnapshotJsonCodec, n as InternalAuthBootstrapJsonCodec, r as FrontendAppConfigJsonCodec, t as PublicFrontendBootstrapJsonCodec } from "./PublicFrontendBootstrapJsonCodec-BZgQ_FnW.js";
|
|
3
|
+
import { i as CodemationConsumerAppResolver, n as WorkflowDiscoveryPathSegmentsComputer, r as WorkflowModulePathFinder, t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-DovlxZNb.js";
|
|
4
|
+
import "./ServerLoggerFactory-CsNW5qhz.js";
|
|
5
|
+
import "./decorateParam-D7WPDFAf.js";
|
|
6
|
+
import "./decorate-Dq0XLibd.js";
|
|
7
|
+
import "./CredentialServices-BPKUF8Xs.js";
|
|
8
|
+
import { _ as CodemationFrontendAuthSnapshotFactory, g as FrontendAppConfigFactory, h as InternalAuthBootstrapFactory, m as PublicFrontendBootstrapFactory, y as ApiPaths } from "./AppContainerFactory-CcSGFNLW.js";
|
|
9
|
+
import "./AppConfigFactory-CqKWXqOm.js";
|
|
10
|
+
import { t as CodemationPostgresPrismaClientFactory } from "./persistenceServer-DKbFDxoS.js";
|
|
11
|
+
import { n as AppConfigLoader, r as CodemationServerGateway, t as CodemationPluginDiscovery } from "./server-CFpgKuVE.js";
|
|
12
12
|
|
|
13
13
|
export { ApiPaths, AppConfigLoader, CodemationConsumerAppResolver, CodemationConsumerConfigLoader, CodemationFrontendAuthSnapshotFactory, CodemationFrontendAuthSnapshotJsonCodec, CodemationPluginDiscovery, CodemationPostgresPrismaClientFactory, CodemationServerGateway, FrontendAppConfigFactory, FrontendAppConfigJsonCodec, InternalAuthBootstrapFactory, InternalAuthBootstrapJsonCodec, PublicFrontendBootstrapFactory, PublicFrontendBootstrapJsonCodec, WorkflowDiscoveryPathSegmentsComputer, WorkflowModulePathFinder };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemation/host",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -24,6 +24,13 @@
|
|
|
24
24
|
},
|
|
25
25
|
"import": "./dist/index.js"
|
|
26
26
|
},
|
|
27
|
+
"./authoring": {
|
|
28
|
+
"types": "./dist/authoring.d.ts",
|
|
29
|
+
"development": {
|
|
30
|
+
"import": "./src/authoring.ts"
|
|
31
|
+
},
|
|
32
|
+
"import": "./dist/authoring.js"
|
|
33
|
+
},
|
|
27
34
|
"./client": {
|
|
28
35
|
"types": "./dist/client.d.ts",
|
|
29
36
|
"development": {
|
|
@@ -112,9 +119,9 @@
|
|
|
112
119
|
"tsx": "^4.21.0",
|
|
113
120
|
"ws": "^8.19.0",
|
|
114
121
|
"zxcvbn": "^4.4.2",
|
|
115
|
-
"@codemation/core
|
|
116
|
-
"@codemation/
|
|
117
|
-
"@codemation/
|
|
122
|
+
"@codemation/core": "0.5.0",
|
|
123
|
+
"@codemation/core-nodes": "0.1.1",
|
|
124
|
+
"@codemation/eventbus-redis": "0.0.27"
|
|
118
125
|
},
|
|
119
126
|
"devDependencies": {
|
|
120
127
|
"@playwright/test": "^1.58.2",
|
|
@@ -139,13 +146,13 @@
|
|
|
139
146
|
"tsdown": "^0.15.5",
|
|
140
147
|
"typescript": "^5.9.3",
|
|
141
148
|
"vitest": "^4.0.18",
|
|
142
|
-
"@codemation/core-nodes-gmail": "0.
|
|
149
|
+
"@codemation/core-nodes-gmail": "0.1.1"
|
|
143
150
|
},
|
|
144
151
|
"scripts": {
|
|
145
152
|
"changeset:verify": "pnpm --workspace-root run changeset:verify",
|
|
146
153
|
"prisma:generate": "node ./scripts/generate-prisma-clients.mjs && node ./scripts/ensure-prisma-runtime-sourcemaps.mjs",
|
|
147
|
-
"build": "tsdown src/index.ts src/client.ts src/credentials.ts src/consumer.ts src/nextServer.ts src/server.ts src/devServerSidecar.ts src/persistenceServer.ts --out-dir dist --sourcemap",
|
|
148
|
-
"dev": "tsdown src/index.ts src/client.ts src/credentials.ts src/consumer.ts src/nextServer.ts src/server.ts src/devServerSidecar.ts src/persistenceServer.ts --out-dir dist --sourcemap --watch",
|
|
154
|
+
"build": "tsdown src/index.ts src/authoring.ts src/client.ts src/credentials.ts src/consumer.ts src/nextServer.ts src/server.ts src/devServerSidecar.ts src/persistenceServer.ts --out-dir dist --sourcemap",
|
|
155
|
+
"dev": "tsdown src/index.ts src/authoring.ts src/client.ts src/credentials.ts src/consumer.ts src/nextServer.ts src/server.ts src/devServerSidecar.ts src/persistenceServer.ts --out-dir dist --sourcemap --watch",
|
|
149
156
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
150
157
|
"lint": "eslint .",
|
|
151
158
|
"test": "pnpm -w exec concurrently -m 5 -c auto -n unit,integration,ui,browser,e2e \"pnpm run test:unit\" \"pnpm run test:integration\" \"pnpm run test:ui\" \"pnpm run test:browser\" \"pnpm run test:e2e\"",
|
|
@@ -76,6 +76,13 @@ export class StartWorkflowRunCommandHandler extends CommandHandler<StartWorkflow
|
|
|
76
76
|
sourceState,
|
|
77
77
|
debuggerOverlay,
|
|
78
78
|
});
|
|
79
|
+
const synthesizeTriggerItems = this.resolveSynthesizeTriggerItems({
|
|
80
|
+
workflow,
|
|
81
|
+
mode: body.mode,
|
|
82
|
+
requestedItems,
|
|
83
|
+
requestedSynthesizeTriggerItems: body.synthesizeTriggerItems,
|
|
84
|
+
currentState,
|
|
85
|
+
});
|
|
79
86
|
const result =
|
|
80
87
|
legacyStartNodeId && this.hasReusableCurrentState(currentState) && !clearFromNodeId
|
|
81
88
|
? await this.runIntentService.rerunFromNode({
|
|
@@ -83,7 +90,7 @@ export class StartWorkflowRunCommandHandler extends CommandHandler<StartWorkflow
|
|
|
83
90
|
nodeId: legacyStartNodeId,
|
|
84
91
|
currentState,
|
|
85
92
|
items: requestedItems,
|
|
86
|
-
synthesizeTriggerItems
|
|
93
|
+
synthesizeTriggerItems,
|
|
87
94
|
executionOptions,
|
|
88
95
|
workflowSnapshot: sourceState?.workflowSnapshot,
|
|
89
96
|
mutableState: this.cloneMutableState(currentState.mutableState),
|
|
@@ -92,7 +99,7 @@ export class StartWorkflowRunCommandHandler extends CommandHandler<StartWorkflow
|
|
|
92
99
|
workflow,
|
|
93
100
|
startAt: legacyStartNodeId && !body.sourceRunId && !body.stopAt ? legacyStartNodeId : undefined,
|
|
94
101
|
items,
|
|
95
|
-
synthesizeTriggerItems
|
|
102
|
+
synthesizeTriggerItems,
|
|
96
103
|
executionOptions,
|
|
97
104
|
workflowSnapshot: sourceState?.workflowSnapshot,
|
|
98
105
|
mutableState: this.cloneMutableState(currentState.mutableState),
|
|
@@ -226,4 +233,59 @@ export class StartWorkflowRunCommandHandler extends CommandHandler<StartWorkflow
|
|
|
226
233
|
Object.keys(currentState.mutableState?.nodesById ?? {}).length > 0
|
|
227
234
|
);
|
|
228
235
|
}
|
|
236
|
+
|
|
237
|
+
private resolveSynthesizeTriggerItems(
|
|
238
|
+
args: Readonly<{
|
|
239
|
+
workflow: WorkflowDefinition;
|
|
240
|
+
mode: CreateRunRequest["mode"];
|
|
241
|
+
requestedItems: Items | undefined;
|
|
242
|
+
requestedSynthesizeTriggerItems: boolean | undefined;
|
|
243
|
+
currentState: RunCurrentState;
|
|
244
|
+
}>,
|
|
245
|
+
): boolean {
|
|
246
|
+
if (this.hasNonEmptyItems(args.requestedItems)) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
if (args.requestedSynthesizeTriggerItems === true) {
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
if (args.mode !== "manual") {
|
|
253
|
+
return args.requestedSynthesizeTriggerItems ?? false;
|
|
254
|
+
}
|
|
255
|
+
if (!this.workflowHasTrigger(args.workflow)) {
|
|
256
|
+
return args.requestedSynthesizeTriggerItems ?? false;
|
|
257
|
+
}
|
|
258
|
+
if (this.currentStateHasTriggerData(args.workflow, args.currentState)) {
|
|
259
|
+
return args.requestedSynthesizeTriggerItems ?? false;
|
|
260
|
+
}
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
private workflowHasTrigger(workflow: WorkflowDefinition): boolean {
|
|
265
|
+
return workflow.nodes.some((node) => node.kind === "trigger");
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
private currentStateHasTriggerData(workflow: WorkflowDefinition, currentState: RunCurrentState): boolean {
|
|
269
|
+
const triggerNodeIds = workflow.nodes.filter((node) => node.kind === "trigger").map((node) => node.id);
|
|
270
|
+
for (const triggerNodeId of triggerNodeIds) {
|
|
271
|
+
if (this.hasOutputItems(currentState.outputsByNode[triggerNodeId])) {
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
if (this.hasOutputItems(currentState.mutableState?.nodesById?.[triggerNodeId]?.pinnedOutputsByPort)) {
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private hasOutputItems(outputsByPort: Readonly<Partial<Record<string, Items>>> | undefined): boolean {
|
|
282
|
+
if (!outputsByPort) {
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
return Object.values(outputsByPort).some((items) => this.hasNonEmptyItems(items));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
private hasNonEmptyItems(items: Items | undefined): boolean {
|
|
289
|
+
return (items?.length ?? 0) > 0;
|
|
290
|
+
}
|
|
229
291
|
}
|
package/src/authoring.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { workflow } from "@codemation/core-nodes";
|
|
2
|
+
export { defineCodemationApp, definePlugin } from "./presentation/config/CodemationAuthoring.types";
|
|
3
|
+
export type {
|
|
4
|
+
DefineCodemationAppOptions,
|
|
5
|
+
DefinePluginOptions,
|
|
6
|
+
FriendlyCodemationDatabaseConfig,
|
|
7
|
+
FriendlyCodemationExecutionConfig,
|
|
8
|
+
} from "./presentation/config/CodemationAuthoring.types";
|
|
9
|
+
export type {
|
|
10
|
+
CodemationAppDefinition,
|
|
11
|
+
CodemationAppSchedulerConfig,
|
|
12
|
+
CodemationAppSchedulerKind,
|
|
13
|
+
CodemationApplicationRuntimeConfig,
|
|
14
|
+
CodemationConfig,
|
|
15
|
+
CodemationDatabaseConfig,
|
|
16
|
+
CodemationDatabaseKind,
|
|
17
|
+
CodemationEngineExecutionLimitsConfig,
|
|
18
|
+
CodemationEventBusConfig,
|
|
19
|
+
CodemationEventBusKind,
|
|
20
|
+
CodemationSchedulerConfig,
|
|
21
|
+
CodemationSchedulerKind,
|
|
22
|
+
} from "./presentation/config/CodemationConfig";
|
|
23
|
+
export type {
|
|
24
|
+
CodemationAppContext,
|
|
25
|
+
CodemationRegistrationContextBase,
|
|
26
|
+
} from "./presentation/config/CodemationAppContext";
|
|
27
|
+
export type {
|
|
28
|
+
CodemationPlugin,
|
|
29
|
+
CodemationPluginConfig,
|
|
30
|
+
CodemationPluginContext,
|
|
31
|
+
} from "./presentation/config/CodemationPlugin";
|
|
@@ -23,6 +23,7 @@ import { ApplicationTokens } from "../../applicationTokens";
|
|
|
23
23
|
|
|
24
24
|
import { CredentialFieldEnvOverlayService } from "./CredentialFieldEnvOverlayService";
|
|
25
25
|
import { CredentialMaterialResolver } from "./CredentialMaterialResolver";
|
|
26
|
+
import { CredentialOAuth2ScopeResolver } from "./CredentialOAuth2ScopeResolver";
|
|
26
27
|
import { CredentialSecretCipher } from "./CredentialSecretCipher";
|
|
27
28
|
import type {
|
|
28
29
|
CredentialInstanceRecord,
|
|
@@ -49,6 +50,8 @@ export class CredentialInstanceService {
|
|
|
49
50
|
private readonly credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService,
|
|
50
51
|
@inject(CredentialMaterialResolver)
|
|
51
52
|
private readonly credentialMaterialResolver: CredentialMaterialResolver,
|
|
53
|
+
@inject(CredentialOAuth2ScopeResolver)
|
|
54
|
+
private readonly credentialOAuth2ScopeResolver: CredentialOAuth2ScopeResolver,
|
|
52
55
|
@inject(CoreTokens.CredentialSessionService)
|
|
53
56
|
private readonly credentialSessionService: MutableCredentialSessionService,
|
|
54
57
|
) {}
|
|
@@ -373,10 +376,14 @@ export class CredentialInstanceService {
|
|
|
373
376
|
"providerId" in credentialType.definition.auth ? credentialType.definition.auth.providerId : "custom";
|
|
374
377
|
const material = await this.credentialStore.getOAuth2Material(instance.instanceId);
|
|
375
378
|
if (!material) {
|
|
379
|
+
const requestedScopes = this.credentialOAuth2ScopeResolver.resolveRequestedScopes(
|
|
380
|
+
credentialType.definition.auth,
|
|
381
|
+
instance.publicConfig,
|
|
382
|
+
);
|
|
376
383
|
return {
|
|
377
384
|
status: "disconnected",
|
|
378
385
|
providerId,
|
|
379
|
-
scopes: [...
|
|
386
|
+
scopes: [...requestedScopes],
|
|
380
387
|
};
|
|
381
388
|
}
|
|
382
389
|
return {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { CredentialOAuth2AuthDefinition } from "@codemation/core";
|
|
2
|
+
import { injectable } from "@codemation/core";
|
|
3
|
+
import type { JsonRecord } from "./CredentialServices";
|
|
4
|
+
|
|
5
|
+
@injectable()
|
|
6
|
+
export class CredentialOAuth2ScopeResolver {
|
|
7
|
+
resolveRequestedScopes(auth: CredentialOAuth2AuthDefinition, publicConfig: JsonRecord): ReadonlyArray<string> {
|
|
8
|
+
const scopesFromPublicConfig = auth.scopesFromPublicConfig;
|
|
9
|
+
if (!scopesFromPublicConfig) {
|
|
10
|
+
return [...auth.scopes];
|
|
11
|
+
}
|
|
12
|
+
const preset = this.resolveString(publicConfig[scopesFromPublicConfig.presetFieldKey]);
|
|
13
|
+
if (!preset) {
|
|
14
|
+
return [...auth.scopes];
|
|
15
|
+
}
|
|
16
|
+
const presetScopes = scopesFromPublicConfig.presetScopes[preset];
|
|
17
|
+
if (presetScopes) {
|
|
18
|
+
return [...presetScopes];
|
|
19
|
+
}
|
|
20
|
+
const customPresetKey = scopesFromPublicConfig.customPresetKey ?? "custom";
|
|
21
|
+
if (preset !== customPresetKey) {
|
|
22
|
+
return [...auth.scopes];
|
|
23
|
+
}
|
|
24
|
+
const customScopes = this.resolveScopeList(
|
|
25
|
+
publicConfig[scopesFromPublicConfig.customScopesFieldKey ?? "customScopes"],
|
|
26
|
+
);
|
|
27
|
+
if (customScopes.length > 0) {
|
|
28
|
+
return customScopes;
|
|
29
|
+
}
|
|
30
|
+
return [...auth.scopes];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private resolveString(value: unknown): string | undefined {
|
|
34
|
+
if (typeof value !== "string") {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
const normalized = value.trim();
|
|
38
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private resolveScopeList(value: unknown): ReadonlyArray<string> {
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
return this.dedupe(
|
|
44
|
+
value.map((entry) => (typeof entry === "string" ? entry.trim() : "")).filter((entry) => entry.length > 0),
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if (typeof value !== "string") {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
return this.dedupe(
|
|
51
|
+
value
|
|
52
|
+
.split(/[\s,]+/)
|
|
53
|
+
.map((entry) => entry.trim())
|
|
54
|
+
.filter((entry) => entry.length > 0),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private dedupe(entries: ReadonlyArray<string>): ReadonlyArray<string> {
|
|
59
|
+
return [...new Set(entries)];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -138,6 +138,7 @@ export { CredentialTypeRegistryImpl } from "./CredentialTypeRegistryImpl";
|
|
|
138
138
|
export { CredentialBindingService } from "./CredentialBindingService";
|
|
139
139
|
export { CredentialInstanceService } from "./CredentialInstanceService";
|
|
140
140
|
export { CredentialMaterialResolver } from "./CredentialMaterialResolver";
|
|
141
|
+
export { CredentialOAuth2ScopeResolver } from "./CredentialOAuth2ScopeResolver";
|
|
141
142
|
export { CredentialRuntimeMaterialService } from "./CredentialRuntimeMaterialService";
|
|
142
143
|
export { CredentialFieldEnvOverlayService } from "./CredentialFieldEnvOverlayService";
|
|
143
144
|
export { CredentialSecretCipher } from "./CredentialSecretCipher";
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
CredentialFieldEnvOverlayService,
|
|
10
10
|
CredentialInstanceService,
|
|
11
11
|
CredentialMaterialResolver,
|
|
12
|
+
CredentialOAuth2ScopeResolver,
|
|
12
13
|
CredentialRuntimeMaterialService,
|
|
13
14
|
CredentialSecretCipher,
|
|
14
15
|
CredentialTypeRegistryImpl,
|
|
@@ -47,6 +48,8 @@ export class OAuth2ConnectService {
|
|
|
47
48
|
private readonly credentialMaterialResolver: CredentialMaterialResolver,
|
|
48
49
|
@inject(CredentialSecretCipher)
|
|
49
50
|
private readonly credentialSecretCipher: CredentialSecretCipher,
|
|
51
|
+
@inject(CredentialOAuth2ScopeResolver)
|
|
52
|
+
private readonly credentialOAuth2ScopeResolver: CredentialOAuth2ScopeResolver,
|
|
50
53
|
@inject(OAuth2ProviderRegistry)
|
|
51
54
|
private readonly oauth2ProviderRegistry: OAuth2ProviderRegistry,
|
|
52
55
|
@inject(ApplicationTokens.AppConfig)
|
|
@@ -63,6 +66,10 @@ export class OAuth2ConnectService {
|
|
|
63
66
|
material: emptyMaterial,
|
|
64
67
|
});
|
|
65
68
|
const provider = this.oauth2ProviderRegistry.resolve(credentialType.definition, resolvedPublicConfig);
|
|
69
|
+
const requestedScopes = this.credentialOAuth2ScopeResolver.resolveRequestedScopes(
|
|
70
|
+
credentialType.definition.auth!,
|
|
71
|
+
resolvedPublicConfig,
|
|
72
|
+
);
|
|
66
73
|
const redirectUri = this.getRedirectUri(requestOrigin);
|
|
67
74
|
const state = this.createOpaqueValue();
|
|
68
75
|
const codeVerifier = this.createOpaqueValue();
|
|
@@ -74,7 +81,7 @@ export class OAuth2ConnectService {
|
|
|
74
81
|
instanceId,
|
|
75
82
|
codeVerifier,
|
|
76
83
|
providerId: provider.providerId,
|
|
77
|
-
requestedScopes
|
|
84
|
+
requestedScopes,
|
|
78
85
|
createdAt: createdAt.toISOString(),
|
|
79
86
|
expiresAt: expiresAt.toISOString(),
|
|
80
87
|
});
|
|
@@ -85,7 +92,7 @@ export class OAuth2ConnectService {
|
|
|
85
92
|
this.oauth2ProviderRegistry.resolveClientId(credentialType.definition.auth!, resolvedPublicConfig),
|
|
86
93
|
);
|
|
87
94
|
authorizeUrl.searchParams.set("redirect_uri", redirectUri);
|
|
88
|
-
authorizeUrl.searchParams.set("scope",
|
|
95
|
+
authorizeUrl.searchParams.set("scope", requestedScopes.join(" "));
|
|
89
96
|
authorizeUrl.searchParams.set("state", state);
|
|
90
97
|
authorizeUrl.searchParams.set("code_challenge", codeChallenge);
|
|
91
98
|
authorizeUrl.searchParams.set("code_challenge_method", "S256");
|