@processfocus/runtime-local 0.1.0-next.3 → 0.1.0-next.4
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 +3 -0
- package/dist/authentication-server.mjs +3 -3
- package/dist/{chunk-bg5r4wpv.js → chunk-3wzp2sax.js} +168 -117
- package/dist/{chunk-cbd36jq1.js → chunk-5kjvzbwr.js} +1 -1
- package/dist/{chunk-727y6qkb.js → chunk-egeb4821.js} +2 -2
- package/dist/{chunk-d4ctj079.js → chunk-q5v72erd.js} +2 -2
- package/dist/{chunk-04r0t2mb.js → chunk-wvbz0nmd.js} +97 -49
- package/dist/{chunk-r5s2v669.js → chunk-y8fnwbx0.js} +512 -480
- package/dist/dashboard-source/apps/frontend/app/(protected)/connected-apps/disconnect-form.tsx +57 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/connected-apps/page.tsx +97 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/list-page-client.tsx +26 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/page.tsx +11 -12
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-create-form.tsx +7 -5
- package/dist/dashboard-source/apps/frontend/app/api/dev/import-events/route.ts +69 -1
- package/dist/dashboard-source/apps/frontend/app/app-shell.tsx +4 -3
- package/dist/dashboard-source/apps/frontend/app/mcp/[[...endpoint]]/route.ts +0 -3
- package/dist/dashboard-source/apps/frontend/components/Header.tsx +10 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-factory.tsx +3 -2
- package/dist/dashboard-source/apps/frontend/lib/collections/graphql-stream.ts +21 -1
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-query-invalidation.tsx +66 -9
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-refresh.ts +10 -6
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/gql.ts +3 -3
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/graphql.ts +2 -3
- package/dist/dashboard-source/apps/frontend/lib/mcp/oauth.ts +61 -72
- package/dist/dashboard-source/apps/frontend/lib/mcp/origin.ts +20 -12
- package/dist/dashboard-source/apps/frontend/lib/mcp/store.ts +80 -166
- package/dist/dashboard-source/apps/frontend/lib/mcp/todos.ts +42 -19
- package/dist/dashboard-source/apps/frontend/package.json +2 -3
- package/dist/dashboard-source/modules/shadcn-components/src/lib/date-time-display.tsx +3 -2
- package/dist/dashboard-source.json +2 -3
- package/dist/graphql-server.mjs +34 -7
- package/dist/job-worker-supervisor.mjs +3 -3
- package/dist/job-worker.mjs +5 -5
- package/dist/main.mjs +7 -2
- package/dist/resources/graphql-schema/system.graphql +1 -0
- package/package.json +3 -4
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
calculateFieldCompletion,
|
|
29
29
|
FormRequestData,
|
|
30
30
|
publicCompletionCorrectionForm
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-5kjvzbwr.js";
|
|
32
32
|
import {
|
|
33
33
|
RUNTIME_ARTIFACT_FORMAT,
|
|
34
34
|
RUNTIME_ARTIFACT_VERSION,
|
|
@@ -137,6 +137,8 @@ import {
|
|
|
137
137
|
RegistrationLinkStatus,
|
|
138
138
|
SettingsQueries,
|
|
139
139
|
FlowExecutionOperations,
|
|
140
|
+
McpOAuthOperation,
|
|
141
|
+
McpOAuthRecords,
|
|
140
142
|
ProcessExecutionOperations,
|
|
141
143
|
OAuthClientQueries,
|
|
142
144
|
OrgQueries,
|
|
@@ -164,12 +166,12 @@ import {
|
|
|
164
166
|
UserDetails,
|
|
165
167
|
getUserDetails,
|
|
166
168
|
withUserDetailsScope
|
|
167
|
-
} from "./chunk-
|
|
169
|
+
} from "./chunk-wvbz0nmd.js";
|
|
168
170
|
import {
|
|
169
171
|
RequestTime,
|
|
170
172
|
getRequestTime,
|
|
171
173
|
SqliteQueueServiceLive
|
|
172
|
-
} from "./chunk-
|
|
174
|
+
} from "./chunk-3wzp2sax.js";
|
|
173
175
|
import {
|
|
174
176
|
__toESM,
|
|
175
177
|
__commonJS,
|
|
@@ -62975,11 +62977,12 @@ var projectProcessStartForm = ({
|
|
|
62975
62977
|
|
|
62976
62978
|
import { Effect as Effect72 } from "effect";
|
|
62977
62979
|
var STATUS_PREDICATES = {
|
|
62980
|
+
Actionable: { kind: "open" },
|
|
62978
62981
|
Active: { kind: "correction-free", deleted: false },
|
|
62979
62982
|
Completed: { kind: "correction-free", deleted: true },
|
|
62980
62983
|
"Correction Required": { kind: "correction-required" }
|
|
62981
62984
|
};
|
|
62982
|
-
var isTodoListStatus = (status) => status === "Active" || status === "Completed" || status === "Correction Required";
|
|
62985
|
+
var isTodoListStatus = (status) => status === "Actionable" || status === "Active" || status === "Completed" || status === "Correction Required";
|
|
62983
62986
|
var parseTodoListStatusPredicate = (status) => Effect72.gen(function* () {
|
|
62984
62987
|
if (status == null)
|
|
62985
62988
|
return;
|
|
@@ -62988,7 +62991,7 @@ var parseTodoListStatusPredicate = (status) => Effect72.gen(function* () {
|
|
|
62988
62991
|
errors: [
|
|
62989
62992
|
{
|
|
62990
62993
|
field: "status",
|
|
62991
|
-
message: 'Status must be "Active", "Completed", or "Correction Required".'
|
|
62994
|
+
message: 'Status must be "Actionable", "Active", "Completed", or "Correction Required".'
|
|
62992
62995
|
}
|
|
62993
62996
|
]
|
|
62994
62997
|
});
|
|
@@ -65941,9 +65944,38 @@ var dynamicSchema = Effect75.gen(function* () {
|
|
|
65941
65944
|
import { Data as Data33, Effect as Effect76 } from "effect";
|
|
65942
65945
|
class SerializationError extends Data33.TaggedError("SerializationError") {
|
|
65943
65946
|
}
|
|
65947
|
+
|
|
65948
|
+
import { createHmac as createHmac2, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
65949
|
+
import { DateTime as DateTime24, Effect as Effect77, Option as Option32, Schema as Schema33 } from "effect";
|
|
65950
|
+
var path5 = "/internal/mcp-oauth";
|
|
65951
|
+
var decode = Schema33.decodeUnknownOption(McpOAuthOperation);
|
|
65952
|
+
var headers = { "Cache-Control": "no-store" };
|
|
65953
|
+
var makeMcpOAuthStorageRoute = (secret) => Effect77.gen(function* () {
|
|
65954
|
+
const store = yield* McpOAuthRecords;
|
|
65955
|
+
const expected = secret ? createHmac2("sha256", secret).update(path5).digest("base64url") : undefined;
|
|
65956
|
+
return (request) => {
|
|
65957
|
+
if (new URL(request.url).pathname !== path5)
|
|
65958
|
+
return;
|
|
65959
|
+
return Effect77.gen(function* () {
|
|
65960
|
+
const authorization = request.headers.get("authorization");
|
|
65961
|
+
const match = /^Bearer ([A-Za-z0-9_-]{43})$/.exec(authorization ?? "");
|
|
65962
|
+
const token = match?.[1];
|
|
65963
|
+
if (!expected || !token || !timingSafeEqual2(Buffer.from(token), Buffer.from(expected)))
|
|
65964
|
+
return new Response(null, { status: 401, headers });
|
|
65965
|
+
if (request.method !== "POST")
|
|
65966
|
+
return new Response(null, { status: 405, headers });
|
|
65967
|
+
const operation = decode(yield* Effect77.promise(() => request.json().catch(() => {
|
|
65968
|
+
return;
|
|
65969
|
+
})));
|
|
65970
|
+
if (Option32.isNone(operation))
|
|
65971
|
+
return new Response(null, { status: 400, headers });
|
|
65972
|
+
return yield* store.operate(operation.value, yield* DateTime24.now).pipe(Effect77.withTracerEnabled(false), Effect77.map((result) => Response.json(result, { headers })), Effect77.catchCause(() => Effect77.logError("MCP OAuth storage failed").pipe(Effect77.as(new Response(null, { status: 503, headers })))));
|
|
65973
|
+
});
|
|
65974
|
+
};
|
|
65975
|
+
});
|
|
65944
65976
|
// src/cron-warnings.ts
|
|
65945
|
-
import { Effect as
|
|
65946
|
-
var warnIgnoredCronDeclarations = (org, runtimeName) =>
|
|
65977
|
+
import { Effect as Effect78 } from "effect";
|
|
65978
|
+
var warnIgnoredCronDeclarations = (org, runtimeName) => Effect78.forEach(org.processes().filter((process2) => process2.props.cron !== undefined), (process2) => Effect78.logWarning(`Ignoring cron for ${process2.node.path} in ${runtimeName}. Local cron execution is not supported.`), { discard: true });
|
|
65947
65979
|
|
|
65948
65980
|
|
|
65949
65981
|
import { readFileSync } from "fs";
|
|
@@ -66007,7 +66039,7 @@ var getEffectiveFrontendBaseUrl = () => {
|
|
|
66007
66039
|
};
|
|
66008
66040
|
|
|
66009
66041
|
// src/services/local-document-store.ts
|
|
66010
|
-
import { createHmac as
|
|
66042
|
+
import { createHmac as createHmac3 } from "crypto";
|
|
66011
66043
|
import {
|
|
66012
66044
|
existsSync,
|
|
66013
66045
|
mkdirSync,
|
|
@@ -66017,16 +66049,16 @@ import {
|
|
|
66017
66049
|
writeFileSync
|
|
66018
66050
|
} from "fs";
|
|
66019
66051
|
import { join as join11 } from "path";
|
|
66020
|
-
import { Context as Context34, Effect as
|
|
66052
|
+
import { Context as Context34, Effect as Effect79, Layer as Layer23, Stream as Stream5 } from "effect";
|
|
66021
66053
|
var URL_EXPIRY_SECONDS = 3600;
|
|
66022
66054
|
|
|
66023
66055
|
class LocalDocumentStoreConfig extends Context34.Service()("processfocus:internal-tag/runtime-local/LocalDocumentStoreConfig") {
|
|
66024
66056
|
}
|
|
66025
66057
|
var generateLocalDocumentStoreToken = (storePrefix, fileId, expires, secret, filename) => {
|
|
66026
66058
|
const message = filename ? `${storePrefix}/${fileId}:${expires}:${filename}` : `${storePrefix}/${fileId}:${expires}`;
|
|
66027
|
-
return
|
|
66059
|
+
return createHmac3("sha256", secret).update(message).digest("hex");
|
|
66028
66060
|
};
|
|
66029
|
-
var ensureDirectory = (dir, failureMessage) =>
|
|
66061
|
+
var ensureDirectory = (dir, failureMessage) => Effect79.try({
|
|
66030
66062
|
try: () => {
|
|
66031
66063
|
if (!existsSync(dir)) {
|
|
66032
66064
|
mkdirSync(dir, { recursive: true });
|
|
@@ -66037,20 +66069,20 @@ var ensureDirectory = (dir, failureMessage) => Effect78.try({
|
|
|
66037
66069
|
cause
|
|
66038
66070
|
})
|
|
66039
66071
|
});
|
|
66040
|
-
var pathExists = (filePath, failureMessage) =>
|
|
66072
|
+
var pathExists = (filePath, failureMessage) => Effect79.try({
|
|
66041
66073
|
try: () => existsSync(filePath),
|
|
66042
66074
|
catch: (cause) => new DocumentStoreError({
|
|
66043
66075
|
message: `${failureMessage}: ${String(cause)}`,
|
|
66044
66076
|
cause
|
|
66045
66077
|
})
|
|
66046
66078
|
});
|
|
66047
|
-
var LocalDocumentStoreServiceLive = Layer23.effect(DocumentStoreService,
|
|
66079
|
+
var LocalDocumentStoreServiceLive = Layer23.effect(DocumentStoreService, Effect79.gen(function* () {
|
|
66048
66080
|
const config = yield* LocalDocumentStoreConfig;
|
|
66049
66081
|
if (!existsSync(config.storagePath)) {
|
|
66050
66082
|
mkdirSync(config.storagePath, { recursive: true });
|
|
66051
66083
|
}
|
|
66052
66084
|
return {
|
|
66053
|
-
requestUploadUrl: (opts) =>
|
|
66085
|
+
requestUploadUrl: (opts) => Effect79.gen(function* () {
|
|
66054
66086
|
const { fileId, storePrefix } = opts;
|
|
66055
66087
|
const now = Date.now();
|
|
66056
66088
|
const expires = Math.floor(Math.min(now + URL_EXPIRY_SECONDS * 1000, opts.expiresAt ?? Infinity) / 1000);
|
|
@@ -66064,14 +66096,14 @@ var LocalDocumentStoreServiceLive = Layer23.effect(DocumentStoreService, Effect7
|
|
|
66064
66096
|
yield* ensureDirectory(storeDir, "Failed to ensure upload store directory");
|
|
66065
66097
|
const uploadUrl = `${config.baseUrl()}/files/${storePrefix}/${fileId}?token=${token}&expires=${expiresStr}`;
|
|
66066
66098
|
const expiresAt = new Date(expires * 1000).toISOString();
|
|
66067
|
-
yield*
|
|
66099
|
+
yield* Effect79.log("Generated upload URL").pipe(Effect79.annotateLogs({
|
|
66068
66100
|
fileId,
|
|
66069
66101
|
storePrefix,
|
|
66070
66102
|
contentType: opts.contentType
|
|
66071
66103
|
}));
|
|
66072
66104
|
return { fileId, uploadUrl, expiresAt };
|
|
66073
66105
|
}),
|
|
66074
|
-
requestDownloadUrl: (fileId, storePrefix, filename) =>
|
|
66106
|
+
requestDownloadUrl: (fileId, storePrefix, filename) => Effect79.gen(function* () {
|
|
66075
66107
|
const filePath = join11(config.storagePath, storePrefix, fileId);
|
|
66076
66108
|
const exists = yield* pathExists(filePath, "Failed to check file existence for download URL");
|
|
66077
66109
|
if (!exists) {
|
|
@@ -66086,17 +66118,17 @@ var LocalDocumentStoreServiceLive = Layer23.effect(DocumentStoreService, Effect7
|
|
|
66086
66118
|
downloadUrl += `&filename=${encodeURIComponent(signedFilename)}`;
|
|
66087
66119
|
}
|
|
66088
66120
|
const expiresAt = new Date(expires * 1000).toISOString();
|
|
66089
|
-
yield*
|
|
66121
|
+
yield* Effect79.log("Generated download URL").pipe(Effect79.annotateLogs({ fileId, storePrefix }));
|
|
66090
66122
|
return { downloadUrl, expiresAt };
|
|
66091
66123
|
}),
|
|
66092
|
-
storeFile: (opts) =>
|
|
66124
|
+
storeFile: (opts) => Effect79.gen(function* () {
|
|
66093
66125
|
const { fileId, storePrefix } = opts;
|
|
66094
66126
|
const storeDir = join11(config.storagePath, storePrefix);
|
|
66095
66127
|
yield* ensureDirectory(storeDir, "Failed to ensure store directory for write");
|
|
66096
66128
|
const parts = yield* Stream5.runFold(opts.content, () => [], (acc, chunk) => {
|
|
66097
66129
|
acc.push(chunk);
|
|
66098
66130
|
return acc;
|
|
66099
|
-
}).pipe(
|
|
66131
|
+
}).pipe(Effect79.mapError((error) => new DocumentStoreError({
|
|
66100
66132
|
message: `Failed to collect stream: ${String(error)}`,
|
|
66101
66133
|
cause: error
|
|
66102
66134
|
})));
|
|
@@ -66108,7 +66140,7 @@ var LocalDocumentStoreServiceLive = Layer23.effect(DocumentStoreService, Effect7
|
|
|
66108
66140
|
offset += arr.length;
|
|
66109
66141
|
}
|
|
66110
66142
|
const filePath = join11(storeDir, fileId);
|
|
66111
|
-
yield*
|
|
66143
|
+
yield* Effect79.try({
|
|
66112
66144
|
try: () => {
|
|
66113
66145
|
writeFileSync(filePath, body);
|
|
66114
66146
|
},
|
|
@@ -66117,7 +66149,7 @@ var LocalDocumentStoreServiceLive = Layer23.effect(DocumentStoreService, Effect7
|
|
|
66117
66149
|
cause
|
|
66118
66150
|
})
|
|
66119
66151
|
});
|
|
66120
|
-
yield*
|
|
66152
|
+
yield* Effect79.log("Stored file locally").pipe(Effect79.annotateLogs({
|
|
66121
66153
|
fileId,
|
|
66122
66154
|
storePrefix,
|
|
66123
66155
|
path: filePath,
|
|
@@ -66125,13 +66157,13 @@ var LocalDocumentStoreServiceLive = Layer23.effect(DocumentStoreService, Effect7
|
|
|
66125
66157
|
}));
|
|
66126
66158
|
return { fileId };
|
|
66127
66159
|
}),
|
|
66128
|
-
getFileContent: (fileId, storePrefix) =>
|
|
66160
|
+
getFileContent: (fileId, storePrefix) => Effect79.gen(function* () {
|
|
66129
66161
|
const filePath = join11(config.storagePath, storePrefix, fileId);
|
|
66130
66162
|
const exists = yield* pathExists(filePath, "Failed to check file existence for read");
|
|
66131
66163
|
if (!exists) {
|
|
66132
66164
|
return yield* new FileNotFoundError({ fileId });
|
|
66133
66165
|
}
|
|
66134
|
-
const content = yield*
|
|
66166
|
+
const content = yield* Effect79.try({
|
|
66135
66167
|
try: () => readFileSync2(filePath),
|
|
66136
66168
|
catch: (cause) => {
|
|
66137
66169
|
const nodeError = cause;
|
|
@@ -66144,15 +66176,15 @@ var LocalDocumentStoreServiceLive = Layer23.effect(DocumentStoreService, Effect7
|
|
|
66144
66176
|
});
|
|
66145
66177
|
}
|
|
66146
66178
|
});
|
|
66147
|
-
yield*
|
|
66179
|
+
yield* Effect79.log("Retrieved file content locally").pipe(Effect79.annotateLogs({ fileId, storePrefix, path: filePath }));
|
|
66148
66180
|
return {
|
|
66149
66181
|
content: new Uint8Array(content),
|
|
66150
66182
|
contentType: "application/octet-stream"
|
|
66151
66183
|
};
|
|
66152
66184
|
}),
|
|
66153
|
-
getFileMetadata: (fileId, storePrefix) =>
|
|
66185
|
+
getFileMetadata: (fileId, storePrefix) => Effect79.gen(function* () {
|
|
66154
66186
|
const filePath = join11(config.storagePath, storePrefix, fileId);
|
|
66155
|
-
const metadata = yield*
|
|
66187
|
+
const metadata = yield* Effect79.try({
|
|
66156
66188
|
try: () => statSync(filePath),
|
|
66157
66189
|
catch: (cause) => {
|
|
66158
66190
|
const nodeError = cause;
|
|
@@ -66170,29 +66202,29 @@ var LocalDocumentStoreServiceLive = Layer23.effect(DocumentStoreService, Effect7
|
|
|
66170
66202
|
contentType: "application/octet-stream"
|
|
66171
66203
|
};
|
|
66172
66204
|
}),
|
|
66173
|
-
deleteFile: (fileId, storePrefix) =>
|
|
66205
|
+
deleteFile: (fileId, storePrefix) => Effect79.gen(function* () {
|
|
66174
66206
|
const filePath = join11(config.storagePath, storePrefix, fileId);
|
|
66175
|
-
yield*
|
|
66207
|
+
yield* Effect79.try({
|
|
66176
66208
|
try: () => unlinkSync(filePath),
|
|
66177
66209
|
catch: (error) => new DocumentStoreError({
|
|
66178
66210
|
message: `Failed to delete file: ${String(error)}`,
|
|
66179
66211
|
cause: error
|
|
66180
66212
|
})
|
|
66181
|
-
}).pipe(
|
|
66213
|
+
}).pipe(Effect79.catch((error) => {
|
|
66182
66214
|
const nodeError = error.cause;
|
|
66183
66215
|
if (nodeError.code === "ENOENT")
|
|
66184
|
-
return
|
|
66185
|
-
return
|
|
66216
|
+
return Effect79.void;
|
|
66217
|
+
return Effect79.fail(error);
|
|
66186
66218
|
}));
|
|
66187
|
-
yield*
|
|
66219
|
+
yield* Effect79.log("Deleted local file").pipe(Effect79.annotateLogs({ fileId, storePrefix, path: filePath }));
|
|
66188
66220
|
})
|
|
66189
66221
|
};
|
|
66190
66222
|
}));
|
|
66191
66223
|
|
|
66192
66224
|
// src/services/local-queue-service.ts
|
|
66193
|
-
import { Effect as
|
|
66225
|
+
import { Effect as Effect95, Layer as Layer27 } from "effect";
|
|
66194
66226
|
|
|
66195
|
-
import { Effect as
|
|
66227
|
+
import { Effect as Effect80, Schema as Schema34 } from "effect";
|
|
66196
66228
|
import { SqlClient as SqlClient10 } from "effect/sql";
|
|
66197
66229
|
|
|
66198
66230
|
|
|
@@ -66205,31 +66237,31 @@ class ExecutionFromJobPublisher extends Context35.Service()("processfocus:intern
|
|
|
66205
66237
|
}
|
|
66206
66238
|
|
|
66207
66239
|
|
|
66208
|
-
var ExecutionEventPayloadSchema =
|
|
66209
|
-
executionId:
|
|
66240
|
+
var ExecutionEventPayloadSchema = Schema34.Struct({
|
|
66241
|
+
executionId: Schema34.String
|
|
66210
66242
|
});
|
|
66211
|
-
var handleExecutionEvent =
|
|
66243
|
+
var handleExecutionEvent = Effect80.fn("execution-event")((job) => Effect80.gen(function* () {
|
|
66212
66244
|
const { executionId } = job.payload;
|
|
66213
66245
|
const completedJobOps = yield* CompletedJobOperations;
|
|
66214
66246
|
const executionPublisher = yield* ExecutionFromJobPublisher;
|
|
66215
66247
|
const alreadyCompleted = yield* completedJobOps.isJobCompleted(EXECUTION_EVENT_QUEUE, job.jobId);
|
|
66216
66248
|
if (alreadyCompleted) {
|
|
66217
|
-
yield*
|
|
66249
|
+
yield* Effect80.log("Job already completed, skipping", {
|
|
66218
66250
|
jobId: job.jobId,
|
|
66219
66251
|
executionId
|
|
66220
66252
|
});
|
|
66221
66253
|
return;
|
|
66222
66254
|
}
|
|
66223
|
-
yield*
|
|
66255
|
+
yield* Effect80.log("Processing execution-event job", {
|
|
66224
66256
|
jobId: job.jobId,
|
|
66225
66257
|
executionId
|
|
66226
66258
|
});
|
|
66227
66259
|
const sqlClient = yield* SqlClient10.SqlClient;
|
|
66228
66260
|
const outcome = yield* executionPublisher.publishExecutionChanged(executionId);
|
|
66229
66261
|
if (outcome === "skipped-not-found") {
|
|
66230
|
-
yield*
|
|
66262
|
+
yield* Effect80.logWarning("No execution found for ID - flow-execution may have rolled back", { executionId });
|
|
66231
66263
|
} else {
|
|
66232
|
-
yield*
|
|
66264
|
+
yield* Effect80.log("Published execution changed event", { executionId });
|
|
66233
66265
|
}
|
|
66234
66266
|
yield* sqlClient.withTransaction(completedJobOps.markJobCompleted(EXECUTION_EVENT_QUEUE, job.jobId));
|
|
66235
66267
|
}));
|
|
@@ -66238,7 +66270,7 @@ var executionEventHandler = {
|
|
|
66238
66270
|
handle: handleExecutionEvent
|
|
66239
66271
|
};
|
|
66240
66272
|
|
|
66241
|
-
import { Effect as
|
|
66273
|
+
import { Effect as Effect83, Option as Option34, Schema as Schema35 } from "effect";
|
|
66242
66274
|
import { SqlClient as SqlClient11 } from "effect/sql";
|
|
66243
66275
|
|
|
66244
66276
|
|
|
@@ -66272,7 +66304,7 @@ class DirectAssigneeResolutionError extends Data35.TaggedError("DirectAssigneeRe
|
|
|
66272
66304
|
}
|
|
66273
66305
|
|
|
66274
66306
|
|
|
66275
|
-
import { DateTime as
|
|
66307
|
+
import { DateTime as DateTime25, Duration as Duration8, Effect as Effect82 } from "effect";
|
|
66276
66308
|
|
|
66277
66309
|
|
|
66278
66310
|
var selectMatchingOnErrorFlows = (flows, errorTag) => {
|
|
@@ -66289,23 +66321,23 @@ var selectMatchingOnErrorFlows = (flows, errorTag) => {
|
|
|
66289
66321
|
var hasMatchingOnErrorFlow = (flows, errorTag) => selectMatchingOnErrorFlows(flows, errorTag).length > 0;
|
|
66290
66322
|
|
|
66291
66323
|
|
|
66292
|
-
import { Effect as
|
|
66293
|
-
var reportSystemStepCompletion = (sqlClient, message, fields) =>
|
|
66294
|
-
const committed =
|
|
66295
|
-
const transaction = yield*
|
|
66296
|
-
if (
|
|
66324
|
+
import { Effect as Effect81, Option as Option33 } from "effect";
|
|
66325
|
+
var reportSystemStepCompletion = (sqlClient, message, fields) => Effect81.gen(function* () {
|
|
66326
|
+
const committed = Effect81.logInfo(message, fields);
|
|
66327
|
+
const transaction = yield* Effect81.serviceOption(sqlClient.transactionService);
|
|
66328
|
+
if (Option33.isNone(transaction)) {
|
|
66297
66329
|
yield* committed;
|
|
66298
66330
|
return;
|
|
66299
66331
|
}
|
|
66300
|
-
const callbacks = yield*
|
|
66301
|
-
if (
|
|
66302
|
-
const context = yield*
|
|
66303
|
-
callbacks.value.callbacks.push(committed.pipe(
|
|
66332
|
+
const callbacks = yield* Effect81.serviceOption(TransactionCommitCallbacks);
|
|
66333
|
+
if (Option33.isSome(callbacks) && callbacks.value.transactionKey === sqlClient.transactionService.key) {
|
|
66334
|
+
const context = yield* Effect81.context();
|
|
66335
|
+
callbacks.value.callbacks.push(committed.pipe(Effect81.provide(context)));
|
|
66304
66336
|
}
|
|
66305
66337
|
});
|
|
66306
66338
|
|
|
66307
66339
|
|
|
66308
|
-
var calculateStepBusinessDuration2 = (sqlClient, calendarQueries, createdAtMs, completedAtMs, orgUnitId) =>
|
|
66340
|
+
var calculateStepBusinessDuration2 = (sqlClient, calendarQueries, createdAtMs, completedAtMs, orgUnitId) => Effect82.gen(function* () {
|
|
66309
66341
|
const calendarDataMap = yield* withReadSnapshot(sqlClient, calendarQueries.getCalendarData([orgUnitId]));
|
|
66310
66342
|
const calendarData = calendarDataMap.get(orgUnitId);
|
|
66311
66343
|
if (calendarData && hasCalendarConfigured(calendarData)) {
|
|
@@ -66317,7 +66349,7 @@ var calculateStepBusinessDuration2 = (sqlClient, calendarQueries, createdAtMs, c
|
|
|
66317
66349
|
return completedAtMs - createdAtMs;
|
|
66318
66350
|
});
|
|
66319
66351
|
var getForEachStepKey = (stepPath) => toCamelCase(getStepIdFromPath(stepPath));
|
|
66320
|
-
var enqueueTodoProcessExecutionEvents = (params) =>
|
|
66352
|
+
var enqueueTodoProcessExecutionEvents = (params) => Effect82.gen(function* () {
|
|
66321
66353
|
const { todoId, processExecutionId, queueService, flowExecutionOps } = params;
|
|
66322
66354
|
yield* queueService.enqueue(TODO_EVENT_QUEUE, {
|
|
66323
66355
|
todoIds: [todoId]
|
|
@@ -66330,7 +66362,7 @@ var enqueueTodoProcessExecutionEvents = (params) => Effect81.gen(function* () {
|
|
|
66330
66362
|
executionId: processExecutionId
|
|
66331
66363
|
});
|
|
66332
66364
|
});
|
|
66333
|
-
var completeSystemStep = (params) =>
|
|
66365
|
+
var completeSystemStep = (params) => Effect82.gen(function* () {
|
|
66334
66366
|
const {
|
|
66335
66367
|
todoId,
|
|
66336
66368
|
stepPath,
|
|
@@ -66355,11 +66387,11 @@ var completeSystemStep = (params) => Effect81.gen(function* () {
|
|
|
66355
66387
|
return;
|
|
66356
66388
|
}
|
|
66357
66389
|
const requestTime = yield* getRequestTime();
|
|
66358
|
-
const completedAtMs =
|
|
66390
|
+
const completedAtMs = DateTime25.toEpochMillis(requestTime);
|
|
66359
66391
|
const businessDurationMs = yield* calculateStepBusinessDuration2(sqlClient, calendarQueries, todoInfo.createdAtMs, completedAtMs, todoInfo.orgUnitId);
|
|
66360
66392
|
const stateUpdate = isForEach ? null : output;
|
|
66361
66393
|
const forEachStepKey = isForEach ? getForEachStepKey(stepPath) : null;
|
|
66362
|
-
const scheduledFlowId = yield* sqlClient.withTransaction(
|
|
66394
|
+
const scheduledFlowId = yield* sqlClient.withTransaction(Effect82.gen(function* () {
|
|
66363
66395
|
if (!(yield* isJobAttemptCurrent))
|
|
66364
66396
|
return;
|
|
66365
66397
|
if (forEachStepKey) {
|
|
@@ -66373,7 +66405,7 @@ var completeSystemStep = (params) => Effect81.gen(function* () {
|
|
|
66373
66405
|
yield* queueService.enqueue(FLOW_EXECUTION_QUEUE, {
|
|
66374
66406
|
scheduledFlowId
|
|
66375
66407
|
});
|
|
66376
|
-
yield*
|
|
66408
|
+
yield* Effect82.log("Staged flow after system step completion (provisional until outer commit)", {
|
|
66377
66409
|
scheduledFlowId
|
|
66378
66410
|
});
|
|
66379
66411
|
} else {
|
|
@@ -66403,7 +66435,7 @@ var completeSystemStep = (params) => Effect81.gen(function* () {
|
|
|
66403
66435
|
queueService,
|
|
66404
66436
|
flowExecutionOps
|
|
66405
66437
|
});
|
|
66406
|
-
yield*
|
|
66438
|
+
yield* Effect82.log("Flow scheduled after system step completion", {
|
|
66407
66439
|
scheduledFlowId
|
|
66408
66440
|
});
|
|
66409
66441
|
}
|
|
@@ -66414,7 +66446,7 @@ var completeSystemStep = (params) => Effect81.gen(function* () {
|
|
|
66414
66446
|
flowExecutionOps
|
|
66415
66447
|
});
|
|
66416
66448
|
});
|
|
66417
|
-
var completeAsyncSystemStep = (params) =>
|
|
66449
|
+
var completeAsyncSystemStep = (params) => Effect82.gen(function* () {
|
|
66418
66450
|
const {
|
|
66419
66451
|
todoId,
|
|
66420
66452
|
stepPath,
|
|
@@ -66437,11 +66469,11 @@ var completeAsyncSystemStep = (params) => Effect81.gen(function* () {
|
|
|
66437
66469
|
return true;
|
|
66438
66470
|
}
|
|
66439
66471
|
const requestTime = yield* getRequestTime();
|
|
66440
|
-
const completedAtMs =
|
|
66472
|
+
const completedAtMs = DateTime25.toEpochMillis(requestTime);
|
|
66441
66473
|
const businessDurationMs = yield* calculateStepBusinessDuration2(sqlClient, calendarQueries, todoInfo.createdAtMs, completedAtMs, todoInfo.orgUnitId);
|
|
66442
66474
|
const stateUpdate = isForEach ? null : output;
|
|
66443
66475
|
const forEachStepKey = isForEach ? getForEachStepKey(stepPath) : null;
|
|
66444
|
-
const scheduledFlowId = yield* sqlClient.withTransaction(
|
|
66476
|
+
const scheduledFlowId = yield* sqlClient.withTransaction(Effect82.gen(function* () {
|
|
66445
66477
|
const transitioned = yield* stepCompletionOps.completeAsyncToDo(todoId, null, businessDurationMs);
|
|
66446
66478
|
if (!transitioned) {
|
|
66447
66479
|
return null;
|
|
@@ -66456,7 +66488,7 @@ var completeAsyncSystemStep = (params) => Effect81.gen(function* () {
|
|
|
66456
66488
|
yield* queueService.enqueue(FLOW_EXECUTION_QUEUE, {
|
|
66457
66489
|
scheduledFlowId
|
|
66458
66490
|
});
|
|
66459
|
-
yield*
|
|
66491
|
+
yield* Effect82.log("Staged flow after async system step completion (provisional until outer commit)", {
|
|
66460
66492
|
scheduledFlowId
|
|
66461
66493
|
});
|
|
66462
66494
|
} else {
|
|
@@ -66479,7 +66511,7 @@ var completeAsyncSystemStep = (params) => Effect81.gen(function* () {
|
|
|
66479
66511
|
queueService,
|
|
66480
66512
|
flowExecutionOps
|
|
66481
66513
|
});
|
|
66482
|
-
yield*
|
|
66514
|
+
yield* Effect82.log("Flow scheduled after async system step completion", {
|
|
66483
66515
|
scheduledFlowId
|
|
66484
66516
|
});
|
|
66485
66517
|
}
|
|
@@ -66491,7 +66523,7 @@ var completeAsyncSystemStep = (params) => Effect81.gen(function* () {
|
|
|
66491
66523
|
});
|
|
66492
66524
|
return true;
|
|
66493
66525
|
});
|
|
66494
|
-
var failAsyncSystemStep = (params) =>
|
|
66526
|
+
var failAsyncSystemStep = (params) => Effect82.gen(function* () {
|
|
66495
66527
|
const {
|
|
66496
66528
|
todoId,
|
|
66497
66529
|
processExecutionId,
|
|
@@ -66522,7 +66554,7 @@ var failAsyncSystemStep = (params) => Effect81.gen(function* () {
|
|
|
66522
66554
|
return { didFail: false };
|
|
66523
66555
|
}
|
|
66524
66556
|
const hasMatchingOnError = hasMatchingOnErrorFlow(yield* flowExecutionOps.queryFlowsBySourceStepId(todoInfo.targetStepId), errorTag);
|
|
66525
|
-
const didFail = yield* sqlClient.withTransaction(
|
|
66557
|
+
const didFail = yield* sqlClient.withTransaction(Effect82.gen(function* () {
|
|
66526
66558
|
const didFail = yield* stepCompletionOps.failAsyncToDo(todoId, failureReason);
|
|
66527
66559
|
if (!didFail) {
|
|
66528
66560
|
return { didFail: false };
|
|
@@ -66569,7 +66601,7 @@ var failAsyncSystemStep = (params) => Effect81.gen(function* () {
|
|
|
66569
66601
|
});
|
|
66570
66602
|
|
|
66571
66603
|
|
|
66572
|
-
var collaborators =
|
|
66604
|
+
var collaborators = Effect83.gen(function* () {
|
|
66573
66605
|
return {
|
|
66574
66606
|
queueService: yield* QueueService,
|
|
66575
66607
|
stepCompletionOps: yield* StepCompletionOperations,
|
|
@@ -66578,7 +66610,7 @@ var collaborators = Effect82.gen(function* () {
|
|
|
66578
66610
|
sqlClient: yield* SqlClient11.SqlClient
|
|
66579
66611
|
};
|
|
66580
66612
|
});
|
|
66581
|
-
var completeAsyncSystemStep2 = (command) =>
|
|
66613
|
+
var completeAsyncSystemStep2 = (command) => Effect83.gen(function* () {
|
|
66582
66614
|
if (yield* recoverTodoSystemStepFlowDispatch(command.todoId))
|
|
66583
66615
|
return true;
|
|
66584
66616
|
const services = yield* collaborators;
|
|
@@ -66586,7 +66618,7 @@ var completeAsyncSystemStep2 = (command) => Effect82.gen(function* () {
|
|
|
66586
66618
|
const todo = yield* services.stepCompletionOps.queryTodoById(command.todoId);
|
|
66587
66619
|
if (!todo)
|
|
66588
66620
|
return false;
|
|
66589
|
-
const identity = todo.createdBy &&
|
|
66621
|
+
const identity = todo.createdBy && Option34.isSome(decodeDelegationAudit(todo.createdBy)) ? { by: todo.createdBy, id: null } : yield* UserDetails;
|
|
66590
66622
|
return yield* completeAsyncSystemStep({
|
|
66591
66623
|
...services,
|
|
66592
66624
|
calendarQueries,
|
|
@@ -66595,32 +66627,32 @@ var completeAsyncSystemStep2 = (command) => Effect82.gen(function* () {
|
|
|
66595
66627
|
output: command.output,
|
|
66596
66628
|
todoInfo: todo,
|
|
66597
66629
|
isForEach: todo.hasForEach
|
|
66598
|
-
}).pipe(
|
|
66630
|
+
}).pipe(Effect83.provideService(UserDetails, identity));
|
|
66599
66631
|
});
|
|
66600
|
-
var failAsyncSystemStep2 = (command) =>
|
|
66632
|
+
var failAsyncSystemStep2 = (command) => Effect83.gen(function* () {
|
|
66601
66633
|
const services = yield* collaborators;
|
|
66602
66634
|
const todo = yield* services.stepCompletionOps.queryTodoById(command.todoId);
|
|
66603
66635
|
if (!todo)
|
|
66604
66636
|
return { didFail: false };
|
|
66605
|
-
const identity = todo.createdBy &&
|
|
66637
|
+
const identity = todo.createdBy && Option34.isSome(decodeDelegationAudit(todo.createdBy)) ? { by: todo.createdBy, id: null } : yield* UserDetails;
|
|
66606
66638
|
return yield* failAsyncSystemStep({
|
|
66607
66639
|
...services,
|
|
66608
66640
|
...command,
|
|
66609
66641
|
processExecutionId: todo.processExecutionId
|
|
66610
|
-
}).pipe(
|
|
66642
|
+
}).pipe(Effect83.provideService(UserDetails, identity));
|
|
66611
66643
|
});
|
|
66612
66644
|
|
|
66613
|
-
import { Effect as
|
|
66645
|
+
import { Effect as Effect84 } from "effect";
|
|
66614
66646
|
|
|
66615
66647
|
import {
|
|
66616
66648
|
Cause as Cause5,
|
|
66617
|
-
DateTime as
|
|
66649
|
+
DateTime as DateTime26,
|
|
66618
66650
|
Duration as Duration9,
|
|
66619
|
-
Effect as
|
|
66651
|
+
Effect as Effect85,
|
|
66620
66652
|
Metric as Metric2,
|
|
66621
|
-
Option as
|
|
66653
|
+
Option as Option35,
|
|
66622
66654
|
Result as Result13,
|
|
66623
|
-
Schema as
|
|
66655
|
+
Schema as Schema36
|
|
66624
66656
|
} from "effect";
|
|
66625
66657
|
import { SqlClient as SqlClient12 } from "effect/sql";
|
|
66626
66658
|
var flowsScheduled = Metric2.counter("flows.scheduled", {
|
|
@@ -66629,47 +66661,47 @@ var flowsScheduled = Metric2.counter("flows.scheduled", {
|
|
|
66629
66661
|
var flowsDeferred = Metric2.counter("flows.deferred", {
|
|
66630
66662
|
description: "Number of flows deferred for later execution"
|
|
66631
66663
|
});
|
|
66632
|
-
var FlowExecutionPayloadSchema =
|
|
66633
|
-
scheduledFlowId:
|
|
66634
|
-
onError:
|
|
66635
|
-
errorTag:
|
|
66664
|
+
var FlowExecutionPayloadSchema = Schema36.Struct({
|
|
66665
|
+
scheduledFlowId: Schema36.String,
|
|
66666
|
+
onError: Schema36.optional(Schema36.Boolean),
|
|
66667
|
+
errorTag: Schema36.optional(Schema36.String)
|
|
66636
66668
|
});
|
|
66637
|
-
var ProcessStateSchema2 =
|
|
66669
|
+
var ProcessStateSchema2 = Schema36.Unknown.check(Schema36.makeFilter((value) => typeof value === "object" && value !== null && !Array.isArray(value))).pipe(Schema36.decodeTo(Schema36.Record(Schema36.String, Schema36.Unknown)));
|
|
66638
66670
|
var resolveBusinessTimeAsClockTime = (scheduledTime) => {
|
|
66639
66671
|
switch (scheduledTime._tag) {
|
|
66640
66672
|
case "BusinessMinutes":
|
|
66641
|
-
return
|
|
66673
|
+
return DateTime26.add(scheduledTime.from, {
|
|
66642
66674
|
minutes: Math.floor(scheduledTime.minutes)
|
|
66643
66675
|
});
|
|
66644
66676
|
case "BusinessHours":
|
|
66645
|
-
return
|
|
66677
|
+
return DateTime26.add(scheduledTime.from, {
|
|
66646
66678
|
minutes: Math.floor(scheduledTime.hours * 60)
|
|
66647
66679
|
});
|
|
66648
66680
|
case "BusinessDays":
|
|
66649
|
-
return
|
|
66681
|
+
return DateTime26.add(scheduledTime.from, {
|
|
66650
66682
|
hours: Math.floor(scheduledTime.days * 24)
|
|
66651
66683
|
});
|
|
66652
66684
|
case "FromPoint":
|
|
66653
|
-
return
|
|
66685
|
+
return DateTime26.add(scheduledTime.from, scheduledTime.offset);
|
|
66654
66686
|
}
|
|
66655
66687
|
};
|
|
66656
|
-
var resolveFromPointSchedule = (marker, calendarData) =>
|
|
66688
|
+
var resolveFromPointSchedule = (marker, calendarData) => Effect85.gen(function* () {
|
|
66657
66689
|
if (!marker.from || !marker.offset) {
|
|
66658
66690
|
return yield* new InvalidScheduleMarkerError({
|
|
66659
66691
|
marker,
|
|
66660
66692
|
reason: "Missing required fields: from date or offset"
|
|
66661
66693
|
});
|
|
66662
66694
|
}
|
|
66663
|
-
const target =
|
|
66695
|
+
const target = DateTime26.add(marker.from, marker.offset);
|
|
66664
66696
|
if (!calendarData || !hasCalendarConfigured(calendarData)) {
|
|
66665
|
-
yield*
|
|
66697
|
+
yield* Effect85.logDebug("No calendar configured, falling back to clock time for FromPoint schedule");
|
|
66666
66698
|
return target;
|
|
66667
66699
|
}
|
|
66668
|
-
return yield* buildCalendarConfig(calendarData).pipe(
|
|
66700
|
+
return yield* buildCalendarConfig(calendarData).pipe(Effect85.flatMap((config) => Effect85.gen(function* () {
|
|
66669
66701
|
const calendarService = yield* makeBusinessCalendarService(config);
|
|
66670
|
-
const targetUtc =
|
|
66671
|
-
const fromUtc =
|
|
66672
|
-
const isBackward =
|
|
66702
|
+
const targetUtc = DateTime26.toUtc(target);
|
|
66703
|
+
const fromUtc = DateTime26.toUtc(marker.from);
|
|
66704
|
+
const isBackward = DateTime26.isLessThan(targetUtc, fromUtc);
|
|
66673
66705
|
const isBusinessDay = yield* calendarService.isBusinessDay(targetUtc);
|
|
66674
66706
|
let resolvedDay;
|
|
66675
66707
|
if (isBusinessDay) {
|
|
@@ -66680,39 +66712,39 @@ var resolveFromPointSchedule = (marker, calendarData) => Effect84.gen(function*
|
|
|
66680
66712
|
resolvedDay = yield* calendarService.nextBusinessDay(targetUtc);
|
|
66681
66713
|
}
|
|
66682
66714
|
const startOpt = yield* calendarService.businessDayStart(resolvedDay);
|
|
66683
|
-
if (
|
|
66715
|
+
if (Option35.isSome(startOpt)) {
|
|
66684
66716
|
return startOpt.value;
|
|
66685
66717
|
}
|
|
66686
66718
|
return resolvedDay;
|
|
66687
|
-
})),
|
|
66688
|
-
yield*
|
|
66719
|
+
})), Effect85.catch((error) => Effect85.gen(function* () {
|
|
66720
|
+
yield* Effect85.logWarning("Invalid calendar config, falling back to clock time for FromPoint schedule", { error });
|
|
66689
66721
|
return target;
|
|
66690
66722
|
})));
|
|
66691
66723
|
});
|
|
66692
|
-
var resolveScheduledTime = (scheduledTime, calendarData) =>
|
|
66724
|
+
var resolveScheduledTime = (scheduledTime, calendarData) => Effect85.gen(function* () {
|
|
66693
66725
|
if (!Schedule.isScheduleMarker(scheduledTime)) {
|
|
66694
66726
|
return scheduledTime;
|
|
66695
66727
|
}
|
|
66696
66728
|
return yield* Schedule.match(scheduledTime, {
|
|
66697
|
-
onClockTime: (marker) =>
|
|
66729
|
+
onClockTime: (marker) => Effect85.succeed(DateTime26.add(marker.from, {
|
|
66698
66730
|
milliseconds: Duration9.toMillis(marker.duration)
|
|
66699
66731
|
})),
|
|
66700
|
-
onBusinessMinutes: (marker) => resolveBusinessTimeMarker(marker, calendarData, (svc) => svc.addBusinessHours(
|
|
66701
|
-
onBusinessHours: (marker) => resolveBusinessTimeMarker(marker, calendarData, (svc) => svc.addBusinessHours(
|
|
66702
|
-
onBusinessDays: (marker) => resolveBusinessTimeMarker(marker, calendarData, (svc) => svc.addBusinessDays(
|
|
66732
|
+
onBusinessMinutes: (marker) => resolveBusinessTimeMarker(marker, calendarData, (svc) => svc.addBusinessHours(DateTime26.toUtc(marker.from), marker.minutes / 60), () => resolveBusinessTimeAsClockTime(marker)),
|
|
66733
|
+
onBusinessHours: (marker) => resolveBusinessTimeMarker(marker, calendarData, (svc) => svc.addBusinessHours(DateTime26.toUtc(marker.from), marker.hours), () => resolveBusinessTimeAsClockTime(marker)),
|
|
66734
|
+
onBusinessDays: (marker) => resolveBusinessTimeMarker(marker, calendarData, (svc) => svc.addBusinessDays(DateTime26.toUtc(marker.from), marker.days), () => resolveBusinessTimeAsClockTime(marker)),
|
|
66703
66735
|
onFromPoint: (marker) => resolveFromPointSchedule(marker, calendarData)
|
|
66704
66736
|
});
|
|
66705
66737
|
});
|
|
66706
|
-
var resolveBusinessTimeMarker = (marker, calendarData, resolve, fallback) =>
|
|
66738
|
+
var resolveBusinessTimeMarker = (marker, calendarData, resolve, fallback) => Effect85.gen(function* () {
|
|
66707
66739
|
if (!calendarData || !hasCalendarConfigured(calendarData)) {
|
|
66708
|
-
yield*
|
|
66740
|
+
yield* Effect85.logDebug("No calendar configured, falling back to clock time for business schedule", { tag: marker._tag });
|
|
66709
66741
|
return fallback();
|
|
66710
66742
|
}
|
|
66711
|
-
return yield* buildCalendarConfig(calendarData).pipe(
|
|
66743
|
+
return yield* buildCalendarConfig(calendarData).pipe(Effect85.flatMap((config) => Effect85.gen(function* () {
|
|
66712
66744
|
const calendarService = yield* makeBusinessCalendarService(config);
|
|
66713
66745
|
return yield* resolve(calendarService);
|
|
66714
|
-
})),
|
|
66715
|
-
yield*
|
|
66746
|
+
})), Effect85.catch((error) => Effect85.gen(function* () {
|
|
66747
|
+
yield* Effect85.logWarning("Invalid calendar config, falling back to clock time for business schedule", { error });
|
|
66716
66748
|
return fallback();
|
|
66717
66749
|
})));
|
|
66718
66750
|
});
|
|
@@ -66731,9 +66763,9 @@ var resolveDirectRecipient = ({
|
|
|
66731
66763
|
}) => {
|
|
66732
66764
|
const cachedRecipient = directRecipientCache.get(providerUserId);
|
|
66733
66765
|
if (cachedRecipient !== undefined) {
|
|
66734
|
-
return
|
|
66766
|
+
return Effect85.succeed(cachedRecipient === null ? [] : [cachedRecipient]);
|
|
66735
66767
|
}
|
|
66736
|
-
return flowExecutionOps.queryNotificationRecipientByProviderUserId(providerUserId).pipe(
|
|
66768
|
+
return flowExecutionOps.queryNotificationRecipientByProviderUserId(providerUserId).pipe(Effect85.tap((recipient) => Effect85.sync(() => directRecipientCache.set(providerUserId, recipient))), Effect85.map((recipient) => recipient === null ? [] : [recipient]));
|
|
66737
66769
|
};
|
|
66738
66770
|
var resolveRoleRecipients = ({
|
|
66739
66771
|
roleId,
|
|
@@ -66742,18 +66774,18 @@ var resolveRoleRecipients = ({
|
|
|
66742
66774
|
}) => {
|
|
66743
66775
|
const cachedRecipients = roleRecipientCache.get(roleId);
|
|
66744
66776
|
if (cachedRecipients !== undefined) {
|
|
66745
|
-
return
|
|
66777
|
+
return Effect85.succeed(cachedRecipients);
|
|
66746
66778
|
}
|
|
66747
|
-
return flowExecutionOps.queryNotificationRecipientsByRoleId(roleId).pipe(
|
|
66779
|
+
return flowExecutionOps.queryNotificationRecipientsByRoleId(roleId).pipe(Effect85.tap((recipients) => Effect85.sync(() => roleRecipientCache.set(roleId, recipients))));
|
|
66748
66780
|
};
|
|
66749
|
-
var resolveMaybeEffect4 = (value) =>
|
|
66781
|
+
var resolveMaybeEffect4 = (value) => Effect85.isEffect(value) ? value : Effect85.succeed(value);
|
|
66750
66782
|
var normalizePublicRecipient2 = (recipient) => typeof recipient === "string" ? { email: recipient } : {
|
|
66751
66783
|
email: recipient.email,
|
|
66752
66784
|
...recipient.displayName ? { displayName: recipient.displayName } : {}
|
|
66753
66785
|
};
|
|
66754
|
-
var preparePublicCompletionPayloadWithAttempt = (todoInfo) =>
|
|
66755
|
-
const organisationProvider = yield*
|
|
66756
|
-
if (
|
|
66786
|
+
var preparePublicCompletionPayloadWithAttempt = (todoInfo) => Effect85.gen(function* () {
|
|
66787
|
+
const organisationProvider = yield* Effect85.serviceOption(OrganisationProvider);
|
|
66788
|
+
if (Option35.isNone(organisationProvider)) {
|
|
66757
66789
|
return;
|
|
66758
66790
|
}
|
|
66759
66791
|
const { organisation } = organisationProvider.value;
|
|
@@ -66775,12 +66807,12 @@ var preparePublicCompletionPayloadWithAttempt = (todoInfo) => Effect84.gen(funct
|
|
|
66775
66807
|
processExecutionId: todoInfo.processExecutionId
|
|
66776
66808
|
});
|
|
66777
66809
|
}
|
|
66778
|
-
const state = yield*
|
|
66810
|
+
const state = yield* Schema36.decodeUnknownEffect(ProcessStateSchema2)(processStateRaw.state ?? {}).pipe(Effect85.mapError(() => new InvalidProcessStateError({
|
|
66779
66811
|
processExecutionId: todoInfo.processExecutionId,
|
|
66780
66812
|
reason: "State is not a valid record"
|
|
66781
66813
|
})));
|
|
66782
66814
|
const completedSteps = yield* stepCompletionOps.getCompletedStepsForExecution(todoInfo.processExecutionId);
|
|
66783
|
-
const processStartedAt = completedSteps.length > 0 ? completedSteps.reduce((earliest, step) =>
|
|
66815
|
+
const processStartedAt = completedSteps.length > 0 ? completedSteps.reduce((earliest, step) => DateTime26.isLessThan(step.completedAt, earliest.completedAt) ? step : earliest).completedAt : yield* DateTime26.now;
|
|
66784
66816
|
const ctx = buildFlowContext(todoInfo.processExecutionId, processStartedAt, completedSteps);
|
|
66785
66817
|
const item = todoInfo.itemData ?? undefined;
|
|
66786
66818
|
const recipient = normalizePublicRecipient2(yield* resolveMaybeEffect4(publicCompletion.recipient(state, ctx, item)));
|
|
@@ -66790,8 +66822,8 @@ var preparePublicCompletionPayloadWithAttempt = (todoInfo) => Effect84.gen(funct
|
|
|
66790
66822
|
recipientEmail: recipient.email
|
|
66791
66823
|
});
|
|
66792
66824
|
const issuedAtSeconds = Math.floor(Date.now() / 1000);
|
|
66793
|
-
const expiresAtIso =
|
|
66794
|
-
const expiresAtSeconds = Math.floor(
|
|
66825
|
+
const expiresAtIso = DateTime26.formatIso(expiresAt);
|
|
66826
|
+
const expiresAtSeconds = Math.floor(DateTime26.toEpochMillis(expiresAt) / 1000);
|
|
66795
66827
|
const token = yield* encryptPublicTodoToken({
|
|
66796
66828
|
v: 1,
|
|
66797
66829
|
tid: todoInfo.todoId,
|
|
@@ -66826,20 +66858,20 @@ var preparePublicCompletionPayloadWithAttempt = (todoInfo) => Effect84.gen(funct
|
|
|
66826
66858
|
}
|
|
66827
66859
|
};
|
|
66828
66860
|
});
|
|
66829
|
-
var shouldAlwaysNotifyTodoAssignment = (stepPath) =>
|
|
66830
|
-
const organisationProvider = yield*
|
|
66831
|
-
if (
|
|
66832
|
-
yield*
|
|
66861
|
+
var shouldAlwaysNotifyTodoAssignment = (stepPath) => Effect85.gen(function* () {
|
|
66862
|
+
const organisationProvider = yield* Effect85.serviceOption(OrganisationProvider);
|
|
66863
|
+
if (Option35.isNone(organisationProvider)) {
|
|
66864
|
+
yield* Effect85.logWarning("Could not resolve organisation for todo notification settings", { stepPath });
|
|
66833
66865
|
return false;
|
|
66834
66866
|
}
|
|
66835
66867
|
const step = organisationProvider.value.organisation.stepByPath(stepPath);
|
|
66836
66868
|
if (!step) {
|
|
66837
|
-
yield*
|
|
66869
|
+
yield* Effect85.logWarning("Could not resolve step for todo notification settings", { stepPath });
|
|
66838
66870
|
return false;
|
|
66839
66871
|
}
|
|
66840
66872
|
return step.props.alwaysNotify === true;
|
|
66841
66873
|
});
|
|
66842
|
-
var resolveNotificationDeliveryPayloads = (todoIds) =>
|
|
66874
|
+
var resolveNotificationDeliveryPayloads = (todoIds) => Effect85.gen(function* () {
|
|
66843
66875
|
if (todoIds.length === 0) {
|
|
66844
66876
|
return [];
|
|
66845
66877
|
}
|
|
@@ -66855,7 +66887,7 @@ var resolveNotificationDeliveryPayloads = (todoIds) => Effect84.gen(function* ()
|
|
|
66855
66887
|
const publicCompletionPayload = yield* preparePublicCompletionPayloadWithAttempt(todoInfo);
|
|
66856
66888
|
if (publicCompletionPayload) {
|
|
66857
66889
|
payloads.push(publicCompletionPayload);
|
|
66858
|
-
yield*
|
|
66890
|
+
yield* Effect85.log("Skipped internal todo assignment notifications for public-completion todo", {
|
|
66859
66891
|
todoId: todoInfo.todoId,
|
|
66860
66892
|
stepPath: todoInfo.stepPath,
|
|
66861
66893
|
processName: todoInfo.processName,
|
|
@@ -66879,7 +66911,7 @@ var resolveNotificationDeliveryPayloads = (todoIds) => Effect84.gen(function* ()
|
|
|
66879
66911
|
...new Map(eligibleRecipients.map((recipient) => [recipient.userId, recipient])).values()
|
|
66880
66912
|
];
|
|
66881
66913
|
if (dedupedRecipients.length === 0) {
|
|
66882
|
-
yield*
|
|
66914
|
+
yield* Effect85.log("Created todo produced zero notification-delivery jobs", {
|
|
66883
66915
|
todoId: todoInfo.todoId,
|
|
66884
66916
|
stepPath: todoInfo.stepPath,
|
|
66885
66917
|
processName: todoInfo.processName,
|
|
@@ -66913,7 +66945,7 @@ var resolveNotificationDeliveryPayloads = (todoIds) => Effect84.gen(function* ()
|
|
|
66913
66945
|
};
|
|
66914
66946
|
payloads.push(payload);
|
|
66915
66947
|
}
|
|
66916
|
-
yield*
|
|
66948
|
+
yield* Effect85.log("Prepared notification-delivery jobs", {
|
|
66917
66949
|
todoId: todoInfo.todoId,
|
|
66918
66950
|
recipientResolution: directAssigneePresent ? "direct" : "role",
|
|
66919
66951
|
alwaysNotify,
|
|
@@ -66923,7 +66955,7 @@ var resolveNotificationDeliveryPayloads = (todoIds) => Effect84.gen(function* ()
|
|
|
66923
66955
|
}
|
|
66924
66956
|
return payloads;
|
|
66925
66957
|
});
|
|
66926
|
-
var enqueueNotificationDeliveryJobs = (payloads) =>
|
|
66958
|
+
var enqueueNotificationDeliveryJobs = (payloads) => Effect85.gen(function* () {
|
|
66927
66959
|
if (payloads.length === 0) {
|
|
66928
66960
|
return;
|
|
66929
66961
|
}
|
|
@@ -66932,10 +66964,10 @@ var enqueueNotificationDeliveryJobs = (payloads) => Effect84.gen(function* () {
|
|
|
66932
66964
|
yield* queueService.enqueue(NOTIFICATION_DELIVERY_QUEUE, payload);
|
|
66933
66965
|
}
|
|
66934
66966
|
});
|
|
66935
|
-
var armTaskDeadlines = (todoIds, activatedAt) =>
|
|
66936
|
-
const provider = yield*
|
|
66967
|
+
var armTaskDeadlines = (todoIds, activatedAt) => Effect85.gen(function* () {
|
|
66968
|
+
const provider = yield* Effect85.serviceOption(OrganisationProvider);
|
|
66937
66969
|
const dispatch = [];
|
|
66938
|
-
if (
|
|
66970
|
+
if (Option35.isNone(provider))
|
|
66939
66971
|
return dispatch;
|
|
66940
66972
|
const completions = yield* StepCompletionOperations;
|
|
66941
66973
|
const flows = yield* FlowExecutionOperations;
|
|
@@ -66949,20 +66981,20 @@ var armTaskDeadlines = (todoIds, activatedAt) => Effect84.gen(function* () {
|
|
|
66949
66981
|
if (!step?.isForm || !attachments?.length)
|
|
66950
66982
|
continue;
|
|
66951
66983
|
const state = yield* flows.getProcessStateByExecutionId(todo.processExecutionId);
|
|
66952
|
-
const activationState = yield*
|
|
66984
|
+
const activationState = yield* Schema36.decodeUnknownEffect(ProcessStateSchema2)(state?.state ?? {});
|
|
66953
66985
|
const candidates = yield* flows.queryFlowsBySourceStepId(todo.targetStepId);
|
|
66954
66986
|
for (const attachment of attachments) {
|
|
66955
66987
|
const flow = candidates.find((candidate) => candidate.deadlineName === attachment.name);
|
|
66956
|
-
const evaluation = yield* decodeTimingState(provider.value.organisation, todo.targetStepPath, activationState).pipe(
|
|
66988
|
+
const evaluation = yield* decodeTimingState(provider.value.organisation, todo.targetStepPath, activationState).pipe(Effect85.flatMap((decodedState) => Effect85.try(() => {
|
|
66957
66989
|
const timing = attachment.timing;
|
|
66958
|
-
const dueAt = "at" in timing ? timing.at(decodedState) :
|
|
66990
|
+
const dueAt = "at" in timing ? timing.at(decodedState) : DateTime26.add(activatedAt, {
|
|
66959
66991
|
milliseconds: Duration9.toMillis(timing.after)
|
|
66960
66992
|
});
|
|
66961
|
-
if (!flow || !
|
|
66993
|
+
if (!flow || !DateTime26.isDateTime(dueAt) || !Number.isFinite(DateTime26.toEpochMillis(dueAt))) {
|
|
66962
66994
|
throw new Error("Deadline must resolve to a finite timestamp and an attached flow");
|
|
66963
66995
|
}
|
|
66964
|
-
return
|
|
66965
|
-
})),
|
|
66996
|
+
return DateTime26.toUtc(dueAt);
|
|
66997
|
+
})), Effect85.result);
|
|
66966
66998
|
if (Result13.isFailure(evaluation)) {
|
|
66967
66999
|
const reason = `Invalid deadline "${attachment.name}" on ${todo.targetStepPath}: ${String(evaluation.failure)}`;
|
|
66968
67000
|
yield* completions.failToDo(todoId, reason);
|
|
@@ -66990,24 +67022,24 @@ var armTaskDeadlines = (todoIds, activatedAt) => Effect84.gen(function* () {
|
|
|
66990
67022
|
}
|
|
66991
67023
|
return dispatch;
|
|
66992
67024
|
});
|
|
66993
|
-
var resolveProviderUserId = (stepPath, assignee) =>
|
|
67025
|
+
var resolveProviderUserId = (stepPath, assignee) => Effect85.gen(function* () {
|
|
66994
67026
|
const providerUserQueries = yield* ProviderUserQueries;
|
|
66995
67027
|
const trimmed = assignee.trim();
|
|
66996
67028
|
if (trimmed.length === 0) {
|
|
66997
|
-
return yield*
|
|
67029
|
+
return yield* Effect85.fail(new DirectAssigneeResolutionError({
|
|
66998
67030
|
stepPath,
|
|
66999
67031
|
assignee,
|
|
67000
67032
|
message: `Direct assignee for step "${stepPath}" resolved to an empty value`
|
|
67001
67033
|
}));
|
|
67002
67034
|
}
|
|
67003
67035
|
const result = trimmed.includes("@") ? yield* providerUserQueries.queryProviderUserByEmail(trimmed) : yield* providerUserQueries.queryProviderUserByProviderUserId(trimmed);
|
|
67004
|
-
return yield*
|
|
67005
|
-
onNone: () =>
|
|
67036
|
+
return yield* Option35.match(result, {
|
|
67037
|
+
onNone: () => Effect85.fail(new DirectAssigneeResolutionError({
|
|
67006
67038
|
stepPath,
|
|
67007
67039
|
assignee: trimmed,
|
|
67008
67040
|
message: `Could not resolve direct assignee "${trimmed}" for step "${stepPath}"`
|
|
67009
67041
|
})),
|
|
67010
|
-
onSome: (providerUser) =>
|
|
67042
|
+
onSome: (providerUser) => Effect85.succeed(providerUser.id)
|
|
67011
67043
|
});
|
|
67012
67044
|
});
|
|
67013
67045
|
var resolveTodoAssignee = ({
|
|
@@ -67015,7 +67047,7 @@ var resolveTodoAssignee = ({
|
|
|
67015
67047
|
state,
|
|
67016
67048
|
ctx,
|
|
67017
67049
|
item
|
|
67018
|
-
}) =>
|
|
67050
|
+
}) => Effect85.gen(function* () {
|
|
67019
67051
|
const organisationProvider = yield* OrganisationProvider;
|
|
67020
67052
|
const step = organisationProvider.organisation.stepByPath(stepPath);
|
|
67021
67053
|
if (!step?.isForm) {
|
|
@@ -67031,9 +67063,9 @@ var resolveTodoAssignee = ({
|
|
|
67031
67063
|
}
|
|
67032
67064
|
return yield* resolveProviderUserId(stepPath, assignee);
|
|
67033
67065
|
});
|
|
67034
|
-
var targetStepHasAssignee = (stepPath) =>
|
|
67035
|
-
const organisationProvider = yield*
|
|
67036
|
-
if (
|
|
67066
|
+
var targetStepHasAssignee = (stepPath) => Effect85.gen(function* () {
|
|
67067
|
+
const organisationProvider = yield* Effect85.serviceOption(OrganisationProvider);
|
|
67068
|
+
if (Option35.isNone(organisationProvider)) {
|
|
67037
67069
|
return false;
|
|
67038
67070
|
}
|
|
67039
67071
|
const step = organisationProvider.value.organisation.stepByPath(stepPath);
|
|
@@ -67042,7 +67074,7 @@ var targetStepHasAssignee = (stepPath) => Effect84.gen(function* () {
|
|
|
67042
67074
|
}
|
|
67043
67075
|
return step.hasAssigneeFunction;
|
|
67044
67076
|
});
|
|
67045
|
-
var enqueueFlowExecutionJobs = (params) =>
|
|
67077
|
+
var enqueueFlowExecutionJobs = (params) => Effect85.gen(function* () {
|
|
67046
67078
|
const {
|
|
67047
67079
|
todoIds,
|
|
67048
67080
|
notificationDeliveryPayloads,
|
|
@@ -67057,12 +67089,12 @@ var enqueueFlowExecutionJobs = (params) => Effect84.gen(function* () {
|
|
|
67057
67089
|
const scheduledFlowOps = yield* ScheduledFlowOperations;
|
|
67058
67090
|
const flowExecutionOps = yield* FlowExecutionOperations;
|
|
67059
67091
|
for (const deadline of params.deadlineFlows ?? []) {
|
|
67060
|
-
const delay =
|
|
67092
|
+
const delay = DateTime26.isLessThanOrEqualTo(deadline.dispatchAt, now) ? Duration9.zero : Duration9.abs(DateTime26.distance(now, deadline.dispatchAt));
|
|
67061
67093
|
yield* queueService.enqueueWithDelay(FLOW_EXECUTION_QUEUE, { scheduledFlowId: deadline.id }, delay);
|
|
67062
67094
|
}
|
|
67063
67095
|
if (todoIds.length > 0) {
|
|
67064
67096
|
yield* queueService.enqueue(TODO_EVENT_QUEUE, { todoIds });
|
|
67065
|
-
yield*
|
|
67097
|
+
yield* Effect85.log(queueService.queueInTransaction ? "Staged todo-event job (provisional until outer commit)" : "Enqueued todo-event job", {
|
|
67066
67098
|
todoCount: todoIds.length
|
|
67067
67099
|
});
|
|
67068
67100
|
yield* enqueueNotificationDeliveryJobs(notificationDeliveryPayloads);
|
|
@@ -67070,24 +67102,24 @@ var enqueueFlowExecutionJobs = (params) => Effect84.gen(function* () {
|
|
|
67070
67102
|
for (const { todoId, stepPath } of systemStepTodos) {
|
|
67071
67103
|
const retryLimit = yield* flowExecutionOps.getStepRetryLimitByPath(stepPath);
|
|
67072
67104
|
yield* queueService.enqueue(SYSTEM_STEP_EXECUTION_QUEUE, { todoId, stepPath }, retryLimit !== null ? { retryLimit } : undefined);
|
|
67073
|
-
yield*
|
|
67105
|
+
yield* Effect85.log(queueService.queueInTransaction ? "Staged system-step-execution job (provisional until outer commit)" : "Enqueued system-step-execution job", {
|
|
67074
67106
|
todoId,
|
|
67075
67107
|
stepPath,
|
|
67076
67108
|
retryLimit: retryLimit ?? "default"
|
|
67077
67109
|
});
|
|
67078
67110
|
}
|
|
67079
67111
|
for (const { flow, scheduledAt } of deferredFlows) {
|
|
67080
|
-
const scheduledAtUtc =
|
|
67112
|
+
const scheduledAtUtc = DateTime26.toUtc(scheduledAt);
|
|
67081
67113
|
const newScheduledFlowId = yield* scheduledFlowOps.insertScheduledFlow(processExecutionId, sourceStepId, {
|
|
67082
67114
|
targetStepId: flow.targetStepId,
|
|
67083
67115
|
scheduledAt: scheduledAtUtc
|
|
67084
67116
|
});
|
|
67085
|
-
const delay = Duration9.abs(
|
|
67117
|
+
const delay = Duration9.abs(DateTime26.distance(now, scheduledAt));
|
|
67086
67118
|
yield* queueService.enqueueWithDelay(FLOW_EXECUTION_QUEUE, { scheduledFlowId: newScheduledFlowId }, delay);
|
|
67087
|
-
yield*
|
|
67119
|
+
yield* Effect85.log(queueService.queueInTransaction ? "Staged deferred flow (provisional until outer commit)" : "Deferred flow scheduled", {
|
|
67088
67120
|
flowId: flow.id,
|
|
67089
67121
|
newScheduledFlowId,
|
|
67090
|
-
scheduledAt:
|
|
67122
|
+
scheduledAt: DateTime26.formatIso(scheduledAt),
|
|
67091
67123
|
delayMs: Duration9.toMillis(delay)
|
|
67092
67124
|
});
|
|
67093
67125
|
}
|
|
@@ -67096,12 +67128,12 @@ var enqueueFlowExecutionJobs = (params) => Effect84.gen(function* () {
|
|
|
67096
67128
|
const processId = yield* flowExecutionOps.getProcessIdForExecution(processExecutionId);
|
|
67097
67129
|
if (processId) {
|
|
67098
67130
|
yield* queueService.enqueue(PROCESS_EVENT_QUEUE, { processId });
|
|
67099
|
-
yield*
|
|
67131
|
+
yield* Effect85.log(queueService.queueInTransaction ? "Staged process-event job (provisional until outer commit)" : "Enqueued process-event job", { processId });
|
|
67100
67132
|
}
|
|
67101
67133
|
yield* queueService.enqueue(EXECUTION_EVENT_QUEUE, {
|
|
67102
67134
|
executionId: processExecutionId
|
|
67103
67135
|
});
|
|
67104
|
-
yield*
|
|
67136
|
+
yield* Effect85.log(queueService.queueInTransaction ? "Staged execution-event job (provisional until outer commit)" : "Enqueued execution-event job", {
|
|
67105
67137
|
executionId: processExecutionId
|
|
67106
67138
|
});
|
|
67107
67139
|
}
|
|
@@ -67115,7 +67147,7 @@ var persistExternalFlowDispatch = ({
|
|
|
67115
67147
|
params,
|
|
67116
67148
|
passThroughFlowIds,
|
|
67117
67149
|
sourceScheduledFlowId
|
|
67118
|
-
}) =>
|
|
67150
|
+
}) => Effect85.gen(function* () {
|
|
67119
67151
|
const flowExecutionOps = yield* FlowExecutionOperations;
|
|
67120
67152
|
const scheduledFlowOps = yield* ScheduledFlowOperations;
|
|
67121
67153
|
const jobs = [];
|
|
@@ -67140,7 +67172,7 @@ var persistExternalFlowDispatch = ({
|
|
|
67140
67172
|
}
|
|
67141
67173
|
}
|
|
67142
67174
|
for (const deadline of params.deadlineFlows ?? []) {
|
|
67143
|
-
add(`${sourceScheduledFlowId}:deadline:${deadline.id}`, FLOW_EXECUTION_QUEUE, { scheduledFlowId: deadline.id }, { scheduledAt:
|
|
67175
|
+
add(`${sourceScheduledFlowId}:deadline:${deadline.id}`, FLOW_EXECUTION_QUEUE, { scheduledFlowId: deadline.id }, { scheduledAt: DateTime26.formatIso(deadline.dispatchAt) });
|
|
67144
67176
|
}
|
|
67145
67177
|
for (const { todoId, stepPath } of params.systemStepTodos) {
|
|
67146
67178
|
const retryLimit = yield* flowExecutionOps.getStepRetryLimitByPath(stepPath);
|
|
@@ -67149,9 +67181,9 @@ var persistExternalFlowDispatch = ({
|
|
|
67149
67181
|
for (const { flow, scheduledAt } of params.deferredFlows) {
|
|
67150
67182
|
const deferredScheduledFlowId = yield* scheduledFlowOps.insertScheduledFlow(params.processExecutionId, params.sourceStepId, {
|
|
67151
67183
|
targetStepId: flow.targetStepId,
|
|
67152
|
-
scheduledAt:
|
|
67184
|
+
scheduledAt: DateTime26.toUtc(scheduledAt)
|
|
67153
67185
|
});
|
|
67154
|
-
add(`${sourceScheduledFlowId}:deferred-flow:${flow.id}`, FLOW_EXECUTION_QUEUE, { scheduledFlowId: deferredScheduledFlowId }, { scheduledAt:
|
|
67186
|
+
add(`${sourceScheduledFlowId}:deferred-flow:${flow.id}`, FLOW_EXECUTION_QUEUE, { scheduledFlowId: deferredScheduledFlowId }, { scheduledAt: DateTime26.formatIso(scheduledAt) });
|
|
67155
67187
|
}
|
|
67156
67188
|
const stateChanged = params.todoIds.length > 0 || params.processWasFinished;
|
|
67157
67189
|
if (stateChanged) {
|
|
@@ -67170,7 +67202,7 @@ var persistExternalFlowDispatch = ({
|
|
|
67170
67202
|
}
|
|
67171
67203
|
yield* flowExecutionOps.insertFlowDispatchJobs(jobs);
|
|
67172
67204
|
});
|
|
67173
|
-
var drainExternalFlowDispatch = (sourceScheduledFlowId) =>
|
|
67205
|
+
var drainExternalFlowDispatch = (sourceScheduledFlowId) => Effect85.gen(function* () {
|
|
67174
67206
|
const flowExecutionOps = yield* FlowExecutionOperations;
|
|
67175
67207
|
const queueService = yield* QueueService;
|
|
67176
67208
|
const jobs = yield* flowExecutionOps.queryFlowDispatchJobs(sourceScheduledFlowId);
|
|
@@ -67182,16 +67214,16 @@ var drainExternalFlowDispatch = (sourceScheduledFlowId) => Effect84.gen(function
|
|
|
67182
67214
|
if (job.scheduledAt === null) {
|
|
67183
67215
|
yield* queueService.enqueue(job.queue, job.payload, options);
|
|
67184
67216
|
} else {
|
|
67185
|
-
const now = yield*
|
|
67186
|
-
const scheduledAt =
|
|
67187
|
-
const delay =
|
|
67217
|
+
const now = yield* DateTime26.now;
|
|
67218
|
+
const scheduledAt = DateTime26.makeUnsafe(job.scheduledAt);
|
|
67219
|
+
const delay = DateTime26.isLessThanOrEqualTo(scheduledAt, now) ? Duration9.zero : Duration9.abs(DateTime26.distance(now, scheduledAt));
|
|
67188
67220
|
yield* queueService.enqueueWithDelay(job.queue, job.payload, delay, options);
|
|
67189
67221
|
}
|
|
67190
67222
|
yield* flowExecutionOps.deleteFlowDispatchJob(job.id);
|
|
67191
67223
|
}
|
|
67192
67224
|
return jobs.length;
|
|
67193
67225
|
});
|
|
67194
|
-
var recordFlowExecutionFailure = (job, errorDescription) =>
|
|
67226
|
+
var recordFlowExecutionFailure = (job, errorDescription) => Effect85.gen(function* () {
|
|
67195
67227
|
const { scheduledFlowId } = job.payload;
|
|
67196
67228
|
const completedJobOps = yield* CompletedJobOperations;
|
|
67197
67229
|
const scheduledFlowOps = yield* ScheduledFlowOperations;
|
|
@@ -67199,16 +67231,16 @@ var recordFlowExecutionFailure = (job, errorDescription) => Effect84.gen(functio
|
|
|
67199
67231
|
const calendarQueries = yield* BusinessCalendarQueries;
|
|
67200
67232
|
const queueService = yield* QueueService;
|
|
67201
67233
|
const sqlClient = yield* SqlClient12.SqlClient;
|
|
67202
|
-
yield*
|
|
67234
|
+
yield* Effect85.logError("Infrastructure error on last attempt of flow-execution, cleaning up", {
|
|
67203
67235
|
scheduledFlowId,
|
|
67204
67236
|
jobId: job.jobId,
|
|
67205
67237
|
attempts: job.attempts,
|
|
67206
67238
|
maxAttempts: job.maxAttempts,
|
|
67207
67239
|
error: errorDescription
|
|
67208
67240
|
});
|
|
67209
|
-
const cleanupResult = yield* sqlClient.withTransaction(
|
|
67241
|
+
const cleanupResult = yield* sqlClient.withTransaction(Effect85.gen(function* () {
|
|
67210
67242
|
const scheduledFlowOption = yield* scheduledFlowOps.getScheduledFlow(scheduledFlowId);
|
|
67211
|
-
if (
|
|
67243
|
+
if (Option35.isNone(scheduledFlowOption)) {
|
|
67212
67244
|
yield* completedJobOps.markJobCompleted(FLOW_EXECUTION_QUEUE, job.jobId);
|
|
67213
67245
|
return { shouldPublish: false, processExecutionId: null };
|
|
67214
67246
|
}
|
|
@@ -67252,36 +67284,36 @@ var describeFlowExecutionError = (error) => {
|
|
|
67252
67284
|
}
|
|
67253
67285
|
return String(error);
|
|
67254
67286
|
};
|
|
67255
|
-
var handleFlowExecution =
|
|
67287
|
+
var handleFlowExecution = Effect85.fn("flow-execution")((job) => handleFlowExecutionInner(job).pipe(Effect85.catch((error) => {
|
|
67256
67288
|
if (job.attempts < job.maxAttempts)
|
|
67257
|
-
return
|
|
67258
|
-
return
|
|
67289
|
+
return Effect85.fail(error);
|
|
67290
|
+
return Effect85.gen(function* () {
|
|
67259
67291
|
const flowExecutionOps = yield* FlowExecutionOperations;
|
|
67260
67292
|
const pending = yield* flowExecutionOps.queryFlowDispatchJobs(job.payload.scheduledFlowId);
|
|
67261
67293
|
if (pending.length > 0)
|
|
67262
|
-
return yield*
|
|
67294
|
+
return yield* Effect85.fail(error);
|
|
67263
67295
|
const description = `Exhausted ${job.maxAttempts} retries: ${describeFlowExecutionError(error)}`;
|
|
67264
|
-
return yield* recordFlowExecutionFailure(job, description).pipe(
|
|
67296
|
+
return yield* recordFlowExecutionFailure(job, description).pipe(Effect85.catchCause((recordingCause) => Effect85.logError("Failed to record flow-execution infrastructure failure", {
|
|
67265
67297
|
scheduledFlowId: job.payload.scheduledFlowId,
|
|
67266
67298
|
recordingError: Cause5.pretty(recordingCause)
|
|
67267
67299
|
})));
|
|
67268
67300
|
});
|
|
67269
|
-
}),
|
|
67301
|
+
}), Effect85.catchDefect((defect) => {
|
|
67270
67302
|
if (job.attempts < job.maxAttempts)
|
|
67271
|
-
return
|
|
67303
|
+
return Effect85.die(defect);
|
|
67272
67304
|
const description = `Exhausted ${job.maxAttempts} retries (defect): ${String(defect)}`;
|
|
67273
|
-
return recordFlowExecutionFailure(job, description).pipe(
|
|
67305
|
+
return recordFlowExecutionFailure(job, description).pipe(Effect85.catchCause((recordingCause) => Effect85.logError("Failed to record flow-execution infrastructure defect", {
|
|
67274
67306
|
scheduledFlowId: job.payload.scheduledFlowId,
|
|
67275
67307
|
recordingError: Cause5.pretty(recordingCause)
|
|
67276
67308
|
})));
|
|
67277
67309
|
})));
|
|
67278
|
-
var handleFlowExecutionInner = (job) =>
|
|
67310
|
+
var handleFlowExecutionInner = (job) => Effect85.gen(function* () {
|
|
67279
67311
|
const { errorTag, onError, scheduledFlowId } = job.payload;
|
|
67280
67312
|
const queueService = yield* QueueService;
|
|
67281
67313
|
if (!queueService.queueInTransaction) {
|
|
67282
67314
|
const resumedCount = yield* drainExternalFlowDispatch(scheduledFlowId);
|
|
67283
67315
|
if (resumedCount > 0) {
|
|
67284
|
-
yield*
|
|
67316
|
+
yield* Effect85.log("Resumed external flow dispatch", {
|
|
67285
67317
|
scheduledFlowId,
|
|
67286
67318
|
dispatchedJobs: resumedCount
|
|
67287
67319
|
});
|
|
@@ -67307,21 +67339,21 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67307
67339
|
const deadline = yield* scheduledFlowOps.getTaskDeadline(scheduledFlowId);
|
|
67308
67340
|
if (deadline && (deadline.triggeredAt || deadline.disarmedAt))
|
|
67309
67341
|
return;
|
|
67310
|
-
const staleBarrierCompletion = alreadyCompleted &&
|
|
67342
|
+
const staleBarrierCompletion = alreadyCompleted && Option35.isSome(scheduledFlowOption) && scheduledFlowOption.value.forEachBarrier;
|
|
67311
67343
|
if (alreadyCompleted && !staleBarrierCompletion) {
|
|
67312
|
-
yield*
|
|
67344
|
+
yield* Effect85.log("Job already completed, skipping", {
|
|
67313
67345
|
jobId: job.jobId,
|
|
67314
67346
|
scheduledFlowId
|
|
67315
67347
|
});
|
|
67316
67348
|
return;
|
|
67317
67349
|
}
|
|
67318
67350
|
if (staleBarrierCompletion) {
|
|
67319
|
-
yield*
|
|
67351
|
+
yield* Effect85.logWarning("Rechecking live forEach barrier with stale completion marker", { jobId: job.jobId, scheduledFlowId });
|
|
67320
67352
|
}
|
|
67321
|
-
if (
|
|
67353
|
+
if (Option35.isNone(scheduledFlowOption)) {
|
|
67322
67354
|
const wasBarrier = yield* scheduledFlowOps.wasBarrierScheduledFlow(scheduledFlowId);
|
|
67323
67355
|
if (wasBarrier) {
|
|
67324
|
-
yield*
|
|
67356
|
+
yield* Effect85.log("Barrier scheduled flow already claimed, skipping", {
|
|
67325
67357
|
scheduledFlowId
|
|
67326
67358
|
});
|
|
67327
67359
|
return;
|
|
@@ -67329,7 +67361,7 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67329
67361
|
if (job.attempts < job.maxAttempts) {
|
|
67330
67362
|
return yield* new ScheduledFlowNotFoundError({ scheduledFlowId });
|
|
67331
67363
|
}
|
|
67332
|
-
yield*
|
|
67364
|
+
yield* Effect85.logWarning("Scheduled flow not found after max retries, skipping as spurious job", {
|
|
67333
67365
|
scheduledFlowId,
|
|
67334
67366
|
attempts: job.attempts,
|
|
67335
67367
|
maxAttempts: job.maxAttempts
|
|
@@ -67343,12 +67375,12 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67343
67375
|
forEachBarrier
|
|
67344
67376
|
} = scheduledFlowOption.value;
|
|
67345
67377
|
const initiatingAudit = scheduledFlowOption.value.createdBy;
|
|
67346
|
-
const actor = initiatingAudit === undefined ?
|
|
67347
|
-
const scopedUserDetails = initiatingAudit !== undefined &&
|
|
67348
|
-
return yield*
|
|
67378
|
+
const actor = initiatingAudit === undefined ? Option35.none() : decodeDelegationAudit(initiatingAudit);
|
|
67379
|
+
const scopedUserDetails = initiatingAudit !== undefined && Option35.isSome(actor) ? { by: initiatingAudit, id: actor.value.ownerUserId } : yield* UserDetails;
|
|
67380
|
+
return yield* Effect85.gen(function* () {
|
|
67349
67381
|
if (forEachBarrier) {
|
|
67350
67382
|
const activeSiblings = yield* flowExecutionOps.countActiveTodosForStep(processExecutionId, sourceStepId);
|
|
67351
|
-
yield*
|
|
67383
|
+
yield* Effect85.log("forEach barrier check", {
|
|
67352
67384
|
scheduledFlowId,
|
|
67353
67385
|
sourceStepId,
|
|
67354
67386
|
activeSiblings
|
|
@@ -67357,15 +67389,15 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67357
67389
|
return AwaitingJobTrigger;
|
|
67358
67390
|
}
|
|
67359
67391
|
}
|
|
67360
|
-
const now = yield*
|
|
67361
|
-
if (deadline &&
|
|
67392
|
+
const now = yield* DateTime26.now;
|
|
67393
|
+
if (deadline && DateTime26.isGreaterThan(deadline.dueAt, now)) {
|
|
67362
67394
|
const state = yield* flowExecutionOps.getProcessStateByExecutionId(processExecutionId);
|
|
67363
67395
|
if (!state?.withoutWaiting) {
|
|
67364
|
-
yield* queueService.enqueueWithDelay(FLOW_EXECUTION_QUEUE, { scheduledFlowId }, Duration9.abs(
|
|
67396
|
+
yield* queueService.enqueueWithDelay(FLOW_EXECUTION_QUEUE, { scheduledFlowId }, Duration9.abs(DateTime26.distance(now, deadline.dueAt)));
|
|
67365
67397
|
return;
|
|
67366
67398
|
}
|
|
67367
67399
|
}
|
|
67368
|
-
yield*
|
|
67400
|
+
yield* Effect85.log("Executing flows for process from source step", {
|
|
67369
67401
|
sourceStepId,
|
|
67370
67402
|
processExecutionId,
|
|
67371
67403
|
scheduledFlowId,
|
|
@@ -67379,7 +67411,7 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67379
67411
|
processWasFinished: false,
|
|
67380
67412
|
passThroughFlowIds: []
|
|
67381
67413
|
});
|
|
67382
|
-
const transactionResult = yield* sqlClient.withTransaction(
|
|
67414
|
+
const transactionResult = yield* sqlClient.withTransaction(Effect85.gen(function* () {
|
|
67383
67415
|
if (deadline && !(yield* flowExecutionOps.isProcessExecutionOpen(processExecutionId))) {
|
|
67384
67416
|
return makeSkippedTransactionResult();
|
|
67385
67417
|
}
|
|
@@ -67388,7 +67420,7 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67388
67420
|
}
|
|
67389
67421
|
const claimed = yield* scheduledFlowOps.deleteScheduledFlow(scheduledFlowId);
|
|
67390
67422
|
if (!claimed) {
|
|
67391
|
-
yield*
|
|
67423
|
+
yield* Effect85.log(forEachBarrier ? "forEach barrier already claimed by another handler, skipping" : "Scheduled flow already claimed or cancelled, skipping", { scheduledFlowId });
|
|
67392
67424
|
if (!staleBarrierCompletion) {
|
|
67393
67425
|
yield* completedJobOps.markJobCompleted(FLOW_EXECUTION_QUEUE, job.jobId);
|
|
67394
67426
|
}
|
|
@@ -67402,14 +67434,14 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67402
67434
|
yield* scheduledFlowOps.disarmTaskDeadlines(deadline.ownerTodoId);
|
|
67403
67435
|
}
|
|
67404
67436
|
if (forEachBarrier) {
|
|
67405
|
-
yield*
|
|
67437
|
+
yield* Effect85.log("forEach barrier claimed, proceeding with flow", {
|
|
67406
67438
|
scheduledFlowId,
|
|
67407
67439
|
sourceStepId
|
|
67408
67440
|
});
|
|
67409
67441
|
}
|
|
67410
67442
|
const executionOpen = yield* flowExecutionOps.isProcessExecutionOpen(processExecutionId);
|
|
67411
67443
|
if (!executionOpen) {
|
|
67412
|
-
yield*
|
|
67444
|
+
yield* Effect85.log("Process execution is closed, skipping flow", {
|
|
67413
67445
|
processExecutionId,
|
|
67414
67446
|
scheduledFlowId
|
|
67415
67447
|
});
|
|
@@ -67418,14 +67450,14 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67418
67450
|
}
|
|
67419
67451
|
const allFlows = yield* flowExecutionOps.queryFlowsBySourceStepId(sourceStepId);
|
|
67420
67452
|
const sourceStepPath = allFlows[0]?.sourceStepPath;
|
|
67421
|
-
yield*
|
|
67453
|
+
yield* Effect85.annotateCurrentSpan("step.id", sourceStepId);
|
|
67422
67454
|
if (sourceStepPath) {
|
|
67423
|
-
yield*
|
|
67455
|
+
yield* Effect85.annotateCurrentSpan("step.path", sourceStepPath);
|
|
67424
67456
|
}
|
|
67425
67457
|
const filteredFlows = storedTargetStepId ? allFlows.filter((f) => f.targetStepId === storedTargetStepId) : allFlows;
|
|
67426
67458
|
const flows = onError ? selectMatchingOnErrorFlows(filteredFlows, errorTag) : deadline ? filteredFlows.filter((flow) => flow.id === deadline.flowId) : filteredFlows.filter((flow) => !flow.isOnError && !flow.deadlineName);
|
|
67427
67459
|
if (flows.length === 0) {
|
|
67428
|
-
yield*
|
|
67460
|
+
yield* Effect85.log("No outgoing flows from source step", {
|
|
67429
67461
|
sourceStepId,
|
|
67430
67462
|
targetStepId: storedTargetStepId,
|
|
67431
67463
|
onError: onError ?? false,
|
|
@@ -67468,7 +67500,7 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67468
67500
|
processWasFinished
|
|
67469
67501
|
};
|
|
67470
67502
|
}
|
|
67471
|
-
yield*
|
|
67503
|
+
yield* Effect85.logDebug("Found outgoing flows", {
|
|
67472
67504
|
sourceStepId,
|
|
67473
67505
|
flowCount: flows.length,
|
|
67474
67506
|
targetStepId: storedTargetStepId
|
|
@@ -67488,7 +67520,7 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67488
67520
|
unconditionalFlows.push(flow);
|
|
67489
67521
|
}
|
|
67490
67522
|
}
|
|
67491
|
-
yield*
|
|
67523
|
+
yield* Effect85.logDebug("Categorized flows", {
|
|
67492
67524
|
unconditional: unconditionalFlows.length,
|
|
67493
67525
|
conditional: conditionalFlows.length,
|
|
67494
67526
|
scheduled: scheduledFlows.length,
|
|
@@ -67496,7 +67528,7 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67496
67528
|
});
|
|
67497
67529
|
const flowsToExecute = [...unconditionalFlows];
|
|
67498
67530
|
const deferredFlows = [];
|
|
67499
|
-
const loadStateAndContext =
|
|
67531
|
+
const loadStateAndContext = Effect85.gen(function* () {
|
|
67500
67532
|
const stepCompletionOps = yield* StepCompletionOperations;
|
|
67501
67533
|
const processStateRaw = yield* flowExecutionOps.getProcessStateByExecutionId(processExecutionId);
|
|
67502
67534
|
if (!processStateRaw) {
|
|
@@ -67504,12 +67536,12 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67504
67536
|
processExecutionId
|
|
67505
67537
|
});
|
|
67506
67538
|
}
|
|
67507
|
-
const state = yield*
|
|
67539
|
+
const state = yield* Schema36.decodeUnknownEffect(ProcessStateSchema2)(processStateRaw.state ?? {}).pipe(Effect85.mapError(() => new InvalidProcessStateError({
|
|
67508
67540
|
processExecutionId,
|
|
67509
67541
|
reason: "State is not a valid record"
|
|
67510
67542
|
})));
|
|
67511
67543
|
const completedSteps = yield* stepCompletionOps.getCompletedStepsForExecution(processExecutionId);
|
|
67512
|
-
const processStartedAt = completedSteps.length > 0 ? completedSteps.reduce((earliest, step) =>
|
|
67544
|
+
const processStartedAt = completedSteps.length > 0 ? completedSteps.reduce((earliest, step) => DateTime26.isLessThan(step.completedAt, earliest.completedAt) ? step : earliest).completedAt : yield* DateTime26.now;
|
|
67513
67545
|
const ctx = buildFlowContext(processExecutionId, processStartedAt, completedSteps);
|
|
67514
67546
|
return {
|
|
67515
67547
|
state,
|
|
@@ -67524,35 +67556,35 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67524
67556
|
for (const flow of scheduledFlows) {
|
|
67525
67557
|
const rawScheduledTime = yield* scheduleEvaluator.evaluate(flow.sourceStepPath, flow.targetStepPath, state, ctx);
|
|
67526
67558
|
const scheduledAt = yield* resolveScheduledTime(rawScheduledTime, scheduleCalendarData);
|
|
67527
|
-
if (!
|
|
67559
|
+
if (!DateTime26.isDateTime(scheduledAt) || !Number.isFinite(DateTime26.toEpochMillis(scheduledAt))) {
|
|
67528
67560
|
return yield* new InvalidScheduleMarkerError({
|
|
67529
67561
|
marker: rawScheduledTime,
|
|
67530
67562
|
reason: "Schedule did not resolve to a valid date"
|
|
67531
67563
|
});
|
|
67532
67564
|
}
|
|
67533
|
-
if (withoutWaiting ||
|
|
67565
|
+
if (withoutWaiting || DateTime26.isLessThanOrEqualTo(scheduledAt, now)) {
|
|
67534
67566
|
if (flow.condition !== null) {
|
|
67535
|
-
const conditionResult = yield* conditionEvaluator.evaluate(flow.sourceStepPath, flow.targetStepPath, state, ctx).pipe(
|
|
67536
|
-
yield*
|
|
67567
|
+
const conditionResult = yield* conditionEvaluator.evaluate(flow.sourceStepPath, flow.targetStepPath, state, ctx).pipe(Effect85.catchTag("ConditionEvaluationError", (error) => Effect85.gen(function* () {
|
|
67568
|
+
yield* Effect85.logWarning("Condition evaluation failed for scheduled flow, treating as false", { flowId: flow.id, error: error.error });
|
|
67537
67569
|
return false;
|
|
67538
67570
|
})));
|
|
67539
67571
|
if (conditionResult) {
|
|
67540
|
-
yield*
|
|
67572
|
+
yield* Effect85.logDebug("Scheduled flow ready and condition satisfied", { flowId: flow.id });
|
|
67541
67573
|
flowsToExecute.push(flow);
|
|
67542
67574
|
} else {
|
|
67543
|
-
yield*
|
|
67575
|
+
yield* Effect85.logDebug("Scheduled flow ready but condition not satisfied", { flowId: flow.id });
|
|
67544
67576
|
}
|
|
67545
67577
|
} else {
|
|
67546
|
-
yield*
|
|
67578
|
+
yield* Effect85.logDebug("Scheduled flow ready, proceeding", {
|
|
67547
67579
|
flowId: flow.id,
|
|
67548
67580
|
scheduledAt
|
|
67549
67581
|
});
|
|
67550
67582
|
flowsToExecute.push(flow);
|
|
67551
67583
|
}
|
|
67552
67584
|
} else {
|
|
67553
|
-
yield*
|
|
67585
|
+
yield* Effect85.logDebug("Scheduled flow deferred", {
|
|
67554
67586
|
flowId: flow.id,
|
|
67555
|
-
scheduledAt:
|
|
67587
|
+
scheduledAt: DateTime26.formatIso(scheduledAt)
|
|
67556
67588
|
});
|
|
67557
67589
|
deferredFlows.push({ flow, scheduledAt });
|
|
67558
67590
|
}
|
|
@@ -67561,24 +67593,24 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67561
67593
|
if (conditionalFlows.length > 0) {
|
|
67562
67594
|
const { state, ctx } = yield* loadStateAndContext;
|
|
67563
67595
|
for (const flow of conditionalFlows) {
|
|
67564
|
-
const conditionResult = yield* conditionEvaluator.evaluate(flow.sourceStepPath, flow.targetStepPath, state, ctx).pipe(
|
|
67565
|
-
yield*
|
|
67596
|
+
const conditionResult = yield* conditionEvaluator.evaluate(flow.sourceStepPath, flow.targetStepPath, state, ctx).pipe(Effect85.catchTag("ConditionEvaluationError", (error) => Effect85.gen(function* () {
|
|
67597
|
+
yield* Effect85.logWarning("Condition evaluation failed for flow, treating as false", { flowId: flow.id, error: error.error });
|
|
67566
67598
|
return false;
|
|
67567
67599
|
})));
|
|
67568
67600
|
if (conditionResult) {
|
|
67569
|
-
yield*
|
|
67601
|
+
yield* Effect85.logDebug("Flow condition satisfied, proceeding", {
|
|
67570
67602
|
flowId: flow.id
|
|
67571
67603
|
});
|
|
67572
67604
|
flowsToExecute.push(flow);
|
|
67573
67605
|
} else {
|
|
67574
|
-
yield*
|
|
67606
|
+
yield* Effect85.logDebug("Flow condition not satisfied, skipping ToDo creation", { flowId: flow.id });
|
|
67575
67607
|
}
|
|
67576
67608
|
}
|
|
67577
67609
|
}
|
|
67578
67610
|
if (conditionalFlows.length > 0) {
|
|
67579
67611
|
const anyConditionalMatched = flowsToExecute.some((f) => conditionalFlows.includes(f));
|
|
67580
67612
|
if (!anyConditionalMatched && elseBranches.length > 0) {
|
|
67581
|
-
yield*
|
|
67613
|
+
yield* Effect85.log("No conditional flows matched, taking else branch", { elseBranchCount: elseBranches.length });
|
|
67582
67614
|
flowsToExecute.push(...elseBranches);
|
|
67583
67615
|
}
|
|
67584
67616
|
}
|
|
@@ -67626,7 +67658,7 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67626
67658
|
let slaWarningAt = null;
|
|
67627
67659
|
if (slaInfo && slaInfo.slaValue != null && slaInfo.slaUnit != null) {
|
|
67628
67660
|
if (slaInfo.slaValue <= 0) {
|
|
67629
|
-
yield*
|
|
67661
|
+
yield* Effect85.logWarning("Invalid SLA value, skipping calculation", {
|
|
67630
67662
|
flowId: flow.id,
|
|
67631
67663
|
slaValue: slaInfo.slaValue
|
|
67632
67664
|
});
|
|
@@ -67643,24 +67675,24 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67643
67675
|
const { state, ctx } = yield* loadStateAndContext;
|
|
67644
67676
|
const items = yield* forEachResolver.resolve(flow.targetStepPath, state, ctx);
|
|
67645
67677
|
if (items.length === 0) {
|
|
67646
|
-
yield*
|
|
67678
|
+
yield* Effect85.log("ForEach step has 0 items, scheduling downstream flow", { flowId: flow.id, stepPath: flow.targetStepPath });
|
|
67647
67679
|
const emptyScheduledFlowId = yield* scheduledFlowOps.insertScheduledFlow(processExecutionId, flow.targetStepId);
|
|
67648
67680
|
passThroughFlowIds.push(emptyScheduledFlowId);
|
|
67649
67681
|
continue;
|
|
67650
67682
|
}
|
|
67651
|
-
yield*
|
|
67683
|
+
yield* Effect85.log("Creating forEach todos", {
|
|
67652
67684
|
flowId: flow.id,
|
|
67653
67685
|
stepPath: flow.targetStepPath,
|
|
67654
67686
|
itemCount: items.length
|
|
67655
67687
|
});
|
|
67656
67688
|
const hasRole = yield* flowExecutionOps.targetStepHasRole(flow.id);
|
|
67657
67689
|
const barrierScheduledFlowId = yield* scheduledFlowOps.insertScheduledFlow(processExecutionId, flow.targetStepId, { forEachBarrier: true });
|
|
67658
|
-
yield*
|
|
67690
|
+
yield* Effect85.log("Created forEach barrier scheduled_flow", {
|
|
67659
67691
|
barrierScheduledFlowId,
|
|
67660
67692
|
stepPath: flow.targetStepPath
|
|
67661
67693
|
});
|
|
67662
67694
|
const hasAssignee = yield* targetStepHasAssignee(flow.targetStepPath);
|
|
67663
|
-
const newTodoIds = hasAssignee ? yield*
|
|
67695
|
+
const newTodoIds = hasAssignee ? yield* Effect85.forEach(items, (item) => Effect85.gen(function* () {
|
|
67664
67696
|
const itemData = item;
|
|
67665
67697
|
const assignedToProviderUserId = yield* resolveTodoAssignee({
|
|
67666
67698
|
stepPath: flow.targetStepPath,
|
|
@@ -67694,14 +67726,14 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67694
67726
|
});
|
|
67695
67727
|
}
|
|
67696
67728
|
}
|
|
67697
|
-
yield*
|
|
67729
|
+
yield* Effect85.log("ForEach todos created", {
|
|
67698
67730
|
flowId: flow.id,
|
|
67699
67731
|
todoCount: items.length,
|
|
67700
67732
|
isSystemStep: hasRole === false
|
|
67701
67733
|
});
|
|
67702
67734
|
} else {
|
|
67703
67735
|
const hasAssignee = yield* targetStepHasAssignee(flow.targetStepPath);
|
|
67704
|
-
const assignedToProviderUserId = hasAssignee ? yield*
|
|
67736
|
+
const assignedToProviderUserId = hasAssignee ? yield* Effect85.gen(function* () {
|
|
67705
67737
|
const assigneeContext = yield* loadStateAndContext;
|
|
67706
67738
|
return yield* resolveTodoAssignee({
|
|
67707
67739
|
stepPath: flow.targetStepPath,
|
|
@@ -67722,17 +67754,17 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67722
67754
|
todoId,
|
|
67723
67755
|
stepPath: flow.targetStepPath
|
|
67724
67756
|
});
|
|
67725
|
-
yield*
|
|
67757
|
+
yield* Effect85.log("Flow executed, created ToDo for system step", {
|
|
67726
67758
|
flowId: flow.id,
|
|
67727
67759
|
todoId,
|
|
67728
67760
|
stepPath: flow.targetStepPath
|
|
67729
67761
|
});
|
|
67730
67762
|
} else {
|
|
67731
|
-
yield*
|
|
67763
|
+
yield* Effect85.log("Flow executed, created ToDo", {
|
|
67732
67764
|
flowId: flow.id,
|
|
67733
67765
|
todoId,
|
|
67734
|
-
slaTargetAt: slaTargetAt ?
|
|
67735
|
-
slaWarningAt: slaWarningAt ?
|
|
67766
|
+
slaTargetAt: slaTargetAt ? DateTime26.formatIso(slaTargetAt) : null,
|
|
67767
|
+
slaWarningAt: slaWarningAt ? DateTime26.formatIso(slaWarningAt) : null
|
|
67736
67768
|
});
|
|
67737
67769
|
}
|
|
67738
67770
|
}
|
|
@@ -67761,7 +67793,7 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67761
67793
|
yield* queueService.enqueue(FLOW_EXECUTION_QUEUE, {
|
|
67762
67794
|
scheduledFlowId
|
|
67763
67795
|
});
|
|
67764
|
-
yield*
|
|
67796
|
+
yield* Effect85.log("Staged pass-through flow for empty forEach (provisional until outer commit)", {
|
|
67765
67797
|
scheduledFlowId
|
|
67766
67798
|
});
|
|
67767
67799
|
}
|
|
@@ -67805,20 +67837,20 @@ var handleFlowExecutionInner = (job) => Effect84.gen(function* () {
|
|
|
67805
67837
|
}
|
|
67806
67838
|
if (transactionDeferredFlows.length > 0) {
|
|
67807
67839
|
yield* Metric2.update(flowsDeferred, transactionDeferredFlows.length);
|
|
67808
|
-
yield*
|
|
67840
|
+
yield* Effect85.annotateCurrentSpan("flows.deferred", transactionDeferredFlows.length);
|
|
67809
67841
|
}
|
|
67810
67842
|
yield* Metric2.update(flowsScheduled, createdTodoIds.length);
|
|
67811
|
-
yield*
|
|
67812
|
-
return yield*
|
|
67843
|
+
yield* Effect85.annotateCurrentSpan("flows.scheduled", createdTodoIds.length);
|
|
67844
|
+
return yield* Effect85.log("Completed flow execution for source step", {
|
|
67813
67845
|
sourceStepId,
|
|
67814
67846
|
scheduledFlowId,
|
|
67815
67847
|
todosCreated: createdTodoIds.length,
|
|
67816
67848
|
flowsDeferred: transactionDeferredFlows.length
|
|
67817
67849
|
});
|
|
67818
|
-
}).pipe(
|
|
67850
|
+
}).pipe(Effect85.provideService(UserDetails, scopedUserDetails));
|
|
67819
67851
|
});
|
|
67820
67852
|
var advanceScheduledFlow = (job) => withUserDetailsScope(handleFlowExecution(job));
|
|
67821
|
-
var calculateExecutionBusinessDuration = (calendarQueries, createdAtMs, finishedAtMs, orgUnitId) =>
|
|
67853
|
+
var calculateExecutionBusinessDuration = (calendarQueries, createdAtMs, finishedAtMs, orgUnitId) => Effect85.gen(function* () {
|
|
67822
67854
|
const calendarDataMap = yield* calendarQueries.getCalendarData([orgUnitId]);
|
|
67823
67855
|
const calendarData = calendarDataMap.get(orgUnitId);
|
|
67824
67856
|
if (calendarData && hasCalendarConfigured(calendarData)) {
|
|
@@ -67849,16 +67881,16 @@ var addBusinessTime2 = (calendarService, startedAt, value, unit, workingDaysPerW
|
|
|
67849
67881
|
var addClockTime2 = (startedAt, value, unit) => {
|
|
67850
67882
|
switch (unit) {
|
|
67851
67883
|
case "minutes":
|
|
67852
|
-
return
|
|
67884
|
+
return DateTime26.add(startedAt, { minutes: Math.round(value) });
|
|
67853
67885
|
case "businessHours":
|
|
67854
|
-
return
|
|
67886
|
+
return DateTime26.add(startedAt, { minutes: Math.round(value * 60) });
|
|
67855
67887
|
case "businessDays":
|
|
67856
|
-
return
|
|
67888
|
+
return DateTime26.add(startedAt, { hours: Math.round(value * 24) });
|
|
67857
67889
|
case "businessWeeks":
|
|
67858
|
-
return
|
|
67890
|
+
return DateTime26.add(startedAt, { hours: Math.round(value * 7 * 24) });
|
|
67859
67891
|
}
|
|
67860
67892
|
};
|
|
67861
|
-
var calculateSlaWithCalendar = (calendarService, startedAt, slaValue, slaUnit, slaWarning, workingDaysPerWeek) =>
|
|
67893
|
+
var calculateSlaWithCalendar = (calendarService, startedAt, slaValue, slaUnit, slaWarning, workingDaysPerWeek) => Effect85.gen(function* () {
|
|
67862
67894
|
const slaTargetAt = yield* addBusinessTime2(calendarService, startedAt, slaValue, slaUnit, workingDaysPerWeek);
|
|
67863
67895
|
let slaWarningAt = null;
|
|
67864
67896
|
if (slaWarning != null) {
|
|
@@ -67868,7 +67900,7 @@ var calculateSlaWithCalendar = (calendarService, startedAt, slaValue, slaUnit, s
|
|
|
67868
67900
|
}
|
|
67869
67901
|
return { slaTargetAt, slaWarningAt };
|
|
67870
67902
|
});
|
|
67871
|
-
var calculateTodoSlaTimes = (calendarData, slaValue, slaUnit, slaWarning, startedAt, flowId) =>
|
|
67903
|
+
var calculateTodoSlaTimes = (calendarData, slaValue, slaUnit, slaWarning, startedAt, flowId) => Effect85.gen(function* () {
|
|
67872
67904
|
if (slaValue == null || slaUnit == null) {
|
|
67873
67905
|
return { slaTargetAt: null, slaWarningAt: null };
|
|
67874
67906
|
}
|
|
@@ -67891,7 +67923,7 @@ var calculateTodoSlaTimes = (calendarData, slaValue, slaUnit, slaWarning, starte
|
|
|
67891
67923
|
const workingDaysPerWeek = getWorkingDaysPerWeek2(config);
|
|
67892
67924
|
return yield* calculateSlaWithCalendar(calendarService, startedAt, slaValue, unit, slaWarning, workingDaysPerWeek);
|
|
67893
67925
|
});
|
|
67894
|
-
var checkAndMarkProcessFinished = (flowExecutionOps, calendarQueries, processExecutionId, queueInTransaction) =>
|
|
67926
|
+
var checkAndMarkProcessFinished = (flowExecutionOps, calendarQueries, processExecutionId, queueInTransaction) => Effect85.gen(function* () {
|
|
67895
67927
|
const activeTodos = yield* flowExecutionOps.countActiveTodos(processExecutionId);
|
|
67896
67928
|
const scheduledFlowOps = yield* ScheduledFlowOperations;
|
|
67897
67929
|
const hasTaskDeadlines = yield* scheduledFlowOps.hasTaskDeadlines(processExecutionId);
|
|
@@ -67903,11 +67935,11 @@ var checkAndMarkProcessFinished = (flowExecutionOps, calendarQueries, processExe
|
|
|
67903
67935
|
let businessDurationMs = null;
|
|
67904
67936
|
if (details) {
|
|
67905
67937
|
const requestTime = yield* getRequestTime();
|
|
67906
|
-
const finishedAtMs =
|
|
67938
|
+
const finishedAtMs = DateTime26.toEpochMillis(requestTime);
|
|
67907
67939
|
businessDurationMs = yield* calculateExecutionBusinessDuration(calendarQueries, details.createdAtMs, finishedAtMs, details.orgUnitId);
|
|
67908
67940
|
}
|
|
67909
67941
|
yield* flowExecutionOps.setProcessExecutionFinished(processExecutionId, businessDurationMs);
|
|
67910
|
-
yield*
|
|
67942
|
+
yield* Effect85.log("Process execution marked as finished", {
|
|
67911
67943
|
processExecutionId,
|
|
67912
67944
|
businessDurationMs
|
|
67913
67945
|
});
|
|
@@ -67916,11 +67948,11 @@ var checkAndMarkProcessFinished = (flowExecutionOps, calendarQueries, processExe
|
|
|
67916
67948
|
return false;
|
|
67917
67949
|
});
|
|
67918
67950
|
|
|
67919
|
-
import { Effect as
|
|
67951
|
+
import { Effect as Effect87, Option as Option37 } from "effect";
|
|
67920
67952
|
import { SqlClient as SqlClient13 } from "effect/sql";
|
|
67921
67953
|
|
|
67922
67954
|
|
|
67923
|
-
import { Config as Config5, Effect as
|
|
67955
|
+
import { Config as Config5, Effect as Effect86, Option as Option36 } from "effect";
|
|
67924
67956
|
var formatNotificationRecipientDisplayName2 = (recipient) => {
|
|
67925
67957
|
const fullName = recipient.name.trim();
|
|
67926
67958
|
if (fullName.length > 0) {
|
|
@@ -67953,14 +67985,14 @@ var addRecipient = (recipients, recipient) => {
|
|
|
67953
67985
|
}
|
|
67954
67986
|
recipients.set(email.toLowerCase(), recipient);
|
|
67955
67987
|
};
|
|
67956
|
-
var resolveExecutionFailureNotificationPayloads = (params) =>
|
|
67957
|
-
const organisationProvider = yield*
|
|
67988
|
+
var resolveExecutionFailureNotificationPayloads = (params) => Effect86.gen(function* () {
|
|
67989
|
+
const organisationProvider = yield* Effect86.serviceOption(OrganisationProvider);
|
|
67958
67990
|
const recipients = new Map;
|
|
67959
67991
|
for (const recipient of params.additionalRecipients ?? []) {
|
|
67960
67992
|
addRecipient(recipients, recipient);
|
|
67961
67993
|
}
|
|
67962
67994
|
let processName = params.processName ?? params.stepPath;
|
|
67963
|
-
if (
|
|
67995
|
+
if (Option36.isSome(organisationProvider)) {
|
|
67964
67996
|
const flowExecutionOps = yield* FlowExecutionOperations;
|
|
67965
67997
|
const { organisation } = organisationProvider.value;
|
|
67966
67998
|
const step = organisation.stepByPath(params.stepPath);
|
|
@@ -67972,7 +68004,7 @@ var resolveExecutionFailureNotificationPayloads = (params) => Effect85.gen(funct
|
|
|
67972
68004
|
}
|
|
67973
68005
|
}
|
|
67974
68006
|
}
|
|
67975
|
-
const { project, environment } = yield*
|
|
68007
|
+
const { project, environment } = yield* Effect86.all({
|
|
67976
68008
|
project: Config5.withDefault(Config5.String("PF_PROJECT"), "local"),
|
|
67977
68009
|
environment: Config5.withDefault(Config5.String("PF_ENV"), "local")
|
|
67978
68010
|
});
|
|
@@ -67996,7 +68028,7 @@ var resolveExecutionFailureNotificationPayloads = (params) => Effect85.gen(funct
|
|
|
67996
68028
|
return payload;
|
|
67997
68029
|
});
|
|
67998
68030
|
});
|
|
67999
|
-
var enqueueExecutionFailureNotificationJobs = (params) =>
|
|
68031
|
+
var enqueueExecutionFailureNotificationJobs = (params) => Effect86.gen(function* () {
|
|
68000
68032
|
const queueService = yield* QueueService;
|
|
68001
68033
|
const payloads = yield* resolveExecutionFailureNotificationPayloads(params);
|
|
68002
68034
|
for (const payload of payloads) {
|
|
@@ -68010,7 +68042,7 @@ var formatFailureReason = (callback) => {
|
|
|
68010
68042
|
const reason = details.length > 0 ? `${callback.failureReason} (${details})` : callback.failureReason;
|
|
68011
68043
|
return reason.length > 500 ? `${reason.slice(0, 497)}...` : reason;
|
|
68012
68044
|
};
|
|
68013
|
-
var enqueueTodoProcessExecutionEvents2 = (params) =>
|
|
68045
|
+
var enqueueTodoProcessExecutionEvents2 = (params) => Effect87.gen(function* () {
|
|
68014
68046
|
const queueService = yield* QueueService;
|
|
68015
68047
|
const flowExecutionOps = yield* FlowExecutionOperations;
|
|
68016
68048
|
yield* queueService.enqueue(TODO_EVENT_QUEUE, { todoIds: [params.todoId] });
|
|
@@ -68024,7 +68056,7 @@ var enqueueTodoProcessExecutionEvents2 = (params) => Effect86.gen(function* () {
|
|
|
68024
68056
|
});
|
|
68025
68057
|
var callbackDispatchId = (callback, result) => `public-completion:${callback.invitationAttemptId}:${callback.deliveryId}:${result}`;
|
|
68026
68058
|
var notificationLogicalId2 = (dispatchId, payload) => `${dispatchId}:notification:${payload.recipient.userId ?? payload.recipient.email.trim().toLowerCase()}`;
|
|
68027
|
-
var persistExternalDispatch = (params) =>
|
|
68059
|
+
var persistExternalDispatch = (params) => Effect87.gen(function* () {
|
|
68028
68060
|
const flowExecutionOps = yield* FlowExecutionOperations;
|
|
68029
68061
|
const jobs = [];
|
|
68030
68062
|
let sequence = 0;
|
|
@@ -68060,7 +68092,7 @@ var persistExternalDispatch = (params) => Effect86.gen(function* () {
|
|
|
68060
68092
|
}
|
|
68061
68093
|
yield* flowExecutionOps.insertFlowDispatchJobs(jobs);
|
|
68062
68094
|
});
|
|
68063
|
-
var drainExternalDispatch = (dispatchId) =>
|
|
68095
|
+
var drainExternalDispatch = (dispatchId) => Effect87.gen(function* () {
|
|
68064
68096
|
const flowExecutionOps = yield* FlowExecutionOperations;
|
|
68065
68097
|
const queueService = yield* QueueService;
|
|
68066
68098
|
const jobs = yield* flowExecutionOps.queryFlowDispatchJobs(dispatchId);
|
|
@@ -68072,7 +68104,7 @@ var drainExternalDispatch = (dispatchId) => Effect86.gen(function* () {
|
|
|
68072
68104
|
}
|
|
68073
68105
|
return jobs.length > 0;
|
|
68074
68106
|
});
|
|
68075
|
-
var resolveResponsibleProviderRecipients = (target) =>
|
|
68107
|
+
var resolveResponsibleProviderRecipients = (target) => Effect87.gen(function* () {
|
|
68076
68108
|
const flowExecutionOps = yield* FlowExecutionOperations;
|
|
68077
68109
|
if (target.assignedToProviderUserId !== null) {
|
|
68078
68110
|
const recipient = yield* flowExecutionOps.queryNotificationRecipientByProviderUserId(target.assignedToProviderUserId);
|
|
@@ -68090,20 +68122,20 @@ var formatNotificationRecipientDisplayName3 = (recipient) => {
|
|
|
68090
68122
|
const fallbackName = `${recipient.firstName} ${recipient.lastName}`.trim();
|
|
68091
68123
|
return fallbackName.length > 0 ? fallbackName : undefined;
|
|
68092
68124
|
};
|
|
68093
|
-
var hasEnabledCorrectionConfig = (stepPath) =>
|
|
68094
|
-
const organisationProvider = yield*
|
|
68095
|
-
if (
|
|
68125
|
+
var hasEnabledCorrectionConfig = (stepPath) => Effect87.gen(function* () {
|
|
68126
|
+
const organisationProvider = yield* Effect87.serviceOption(OrganisationProvider);
|
|
68127
|
+
if (Option37.isNone(organisationProvider))
|
|
68096
68128
|
return false;
|
|
68097
68129
|
let step;
|
|
68098
68130
|
try {
|
|
68099
68131
|
step = organisationProvider.value.organisation.stepByPath(stepPath);
|
|
68100
68132
|
} catch (error) {
|
|
68101
|
-
yield*
|
|
68133
|
+
yield* Effect87.logWarning("Public-completion correction config lookup failed", { stepPath, error: String(error) });
|
|
68102
68134
|
return false;
|
|
68103
68135
|
}
|
|
68104
68136
|
return step?.isForm === true && step.publicCompletion?.correction?.enabled === true;
|
|
68105
68137
|
});
|
|
68106
|
-
var resolveCorrectionRequiredNotificationPayloads = (params) =>
|
|
68138
|
+
var resolveCorrectionRequiredNotificationPayloads = (params) => Effect87.gen(function* () {
|
|
68107
68139
|
const dedupedRecipients = [
|
|
68108
68140
|
...new Map(params.recipients.filter((recipient) => recipient.email.trim().length > 0).map((recipient) => [
|
|
68109
68141
|
recipient.email.trim().toLowerCase(),
|
|
@@ -68129,18 +68161,18 @@ var resolveCorrectionRequiredNotificationPayloads = (params) => Effect86.gen(fun
|
|
|
68129
68161
|
return payload;
|
|
68130
68162
|
});
|
|
68131
68163
|
});
|
|
68132
|
-
var enqueueNotificationPayloads = (payloads) =>
|
|
68164
|
+
var enqueueNotificationPayloads = (payloads) => Effect87.gen(function* () {
|
|
68133
68165
|
const queueService = yield* QueueService;
|
|
68134
68166
|
for (const payload of payloads) {
|
|
68135
68167
|
yield* queueService.enqueue(NOTIFICATION_DELIVERY_QUEUE, payload);
|
|
68136
68168
|
}
|
|
68137
68169
|
});
|
|
68138
|
-
var applyPublicCompletionDeliveryCallback = (callback) =>
|
|
68170
|
+
var applyPublicCompletionDeliveryCallback = (callback) => Effect87.gen(function* () {
|
|
68139
68171
|
const stepCompletionOps = yield* StepCompletionOperations;
|
|
68140
68172
|
const sqlClient = yield* SqlClient13.SqlClient;
|
|
68141
68173
|
const queueService = yield* QueueService;
|
|
68142
68174
|
if (callback.status === "delivered") {
|
|
68143
|
-
const deliveryResult = yield* withImmediateTransaction(sqlClient,
|
|
68175
|
+
const deliveryResult = yield* withImmediateTransaction(sqlClient, Effect87.gen(function* () {
|
|
68144
68176
|
const target = yield* stepCompletionOps.queryPublicCompletionInvitationAttemptCallbackTarget(callback.todoId, callback.invitationAttemptId);
|
|
68145
68177
|
if (!target) {
|
|
68146
68178
|
return { _tag: "Ignored" };
|
|
@@ -68155,7 +68187,7 @@ var applyPublicCompletionDeliveryCallback = (callback) => Effect86.gen(function*
|
|
|
68155
68187
|
return recorded ? { _tag: "Delivered" } : { _tag: "Ignored" };
|
|
68156
68188
|
}));
|
|
68157
68189
|
if (deliveryResult._tag === "Ignored") {
|
|
68158
|
-
yield*
|
|
68190
|
+
yield* Effect87.logInfo("Ignoring public-completion delivery callback for a stale or non-waiting attempt", {
|
|
68159
68191
|
todoId: callback.todoId,
|
|
68160
68192
|
invitationAttemptId: callback.invitationAttemptId,
|
|
68161
68193
|
deliveryId: callback.deliveryId
|
|
@@ -68174,7 +68206,7 @@ var applyPublicCompletionDeliveryCallback = (callback) => Effect86.gen(function*
|
|
|
68174
68206
|
return { _tag: "Failed" };
|
|
68175
68207
|
}
|
|
68176
68208
|
}
|
|
68177
|
-
const failResult = yield* withImmediateTransaction(sqlClient,
|
|
68209
|
+
const failResult = yield* withImmediateTransaction(sqlClient, Effect87.gen(function* () {
|
|
68178
68210
|
const target = yield* stepCompletionOps.queryPublicCompletionInvitationAttemptCallbackTarget(callback.todoId, callback.invitationAttemptId);
|
|
68179
68211
|
if (!target) {
|
|
68180
68212
|
return { _tag: "Ignored" };
|
|
@@ -68255,7 +68287,7 @@ var applyPublicCompletionDeliveryCallback = (callback) => Effect86.gen(function*
|
|
|
68255
68287
|
yield* drainExternalDispatch(callbackDispatchId(callback, failResult._tag === "CorrectionRequired" ? "correction" : "failed"));
|
|
68256
68288
|
}
|
|
68257
68289
|
if (failResult._tag === "DeliveryRecordedTodoNotCorrected") {
|
|
68258
|
-
yield*
|
|
68290
|
+
yield* Effect87.logInfo("Public-completion failure callback recorded but todo could not enter correction", {
|
|
68259
68291
|
todoId: callback.todoId,
|
|
68260
68292
|
invitationAttemptId: callback.invitationAttemptId,
|
|
68261
68293
|
deliveryId: callback.deliveryId,
|
|
@@ -68264,7 +68296,7 @@ var applyPublicCompletionDeliveryCallback = (callback) => Effect86.gen(function*
|
|
|
68264
68296
|
return { _tag: "Ignored" };
|
|
68265
68297
|
}
|
|
68266
68298
|
if (failResult._tag === "DeliveryRecordedTodoNotFailed") {
|
|
68267
|
-
yield*
|
|
68299
|
+
yield* Effect87.logInfo("Public-completion failure callback recorded but todo was already resolved", {
|
|
68268
68300
|
todoId: callback.todoId,
|
|
68269
68301
|
invitationAttemptId: callback.invitationAttemptId,
|
|
68270
68302
|
deliveryId: callback.deliveryId,
|
|
@@ -68273,7 +68305,7 @@ var applyPublicCompletionDeliveryCallback = (callback) => Effect86.gen(function*
|
|
|
68273
68305
|
return { _tag: "Ignored" };
|
|
68274
68306
|
}
|
|
68275
68307
|
if (failResult._tag === "Ignored") {
|
|
68276
|
-
yield*
|
|
68308
|
+
yield* Effect87.logInfo("Ignoring public-completion failure callback for a stale or non-waiting attempt", {
|
|
68277
68309
|
todoId: callback.todoId,
|
|
68278
68310
|
invitationAttemptId: callback.invitationAttemptId,
|
|
68279
68311
|
deliveryId: callback.deliveryId,
|
|
@@ -68289,33 +68321,33 @@ import {
|
|
|
68289
68321
|
Cause as Cause6,
|
|
68290
68322
|
Config as Config6,
|
|
68291
68323
|
Data as Data36,
|
|
68292
|
-
DateTime as
|
|
68324
|
+
DateTime as DateTime27,
|
|
68293
68325
|
Duration as Duration10,
|
|
68294
|
-
Effect as
|
|
68326
|
+
Effect as Effect88,
|
|
68295
68327
|
Exit as Exit3,
|
|
68296
|
-
Option as
|
|
68297
|
-
Schema as
|
|
68328
|
+
Option as Option38,
|
|
68329
|
+
Schema as Schema37
|
|
68298
68330
|
} from "effect";
|
|
68299
68331
|
import { SqlClient as SqlClient14 } from "effect/sql";
|
|
68300
68332
|
var SYSTEM_STEP_EXECUTION_TIMEOUT_SECONDS_ENV = "SYSTEM_STEP_EXECUTION_TIMEOUT_SECONDS";
|
|
68301
68333
|
|
|
68302
68334
|
class SystemStepExecutionTimeoutError extends Data36.TaggedError("SystemStepExecutionTimeoutError") {
|
|
68303
68335
|
}
|
|
68304
|
-
var SystemStepTodoPayloadSchema =
|
|
68305
|
-
todoId:
|
|
68306
|
-
stepPath:
|
|
68336
|
+
var SystemStepTodoPayloadSchema = Schema37.Struct({
|
|
68337
|
+
todoId: Schema37.String,
|
|
68338
|
+
stepPath: Schema37.String
|
|
68307
68339
|
});
|
|
68308
|
-
var StartSystemStepExecutionPayloadSchema =
|
|
68309
|
-
startsProcess:
|
|
68310
|
-
processExecutionId:
|
|
68311
|
-
stepId:
|
|
68312
|
-
stepPath:
|
|
68340
|
+
var StartSystemStepExecutionPayloadSchema = Schema37.Struct({
|
|
68341
|
+
startsProcess: Schema37.Literal(true),
|
|
68342
|
+
processExecutionId: Schema37.String,
|
|
68343
|
+
stepId: Schema37.String,
|
|
68344
|
+
stepPath: Schema37.String
|
|
68313
68345
|
});
|
|
68314
|
-
var SystemStepExecutionPayloadSchema =
|
|
68346
|
+
var SystemStepExecutionPayloadSchema = Schema37.Union([
|
|
68315
68347
|
SystemStepTodoPayloadSchema,
|
|
68316
68348
|
StartSystemStepExecutionPayloadSchema
|
|
68317
68349
|
]);
|
|
68318
|
-
var ProcessStateSchema3 =
|
|
68350
|
+
var ProcessStateSchema3 = Schema37.Unknown.check(Schema37.makeFilter((value) => typeof value === "object" && value !== null && !Array.isArray(value))).pipe(Schema37.decodeTo(Schema37.Record(Schema37.String, Schema37.Unknown)));
|
|
68319
68351
|
var isTodoPayload = (payload) => ("todoId" in payload);
|
|
68320
68352
|
var getPayloadContext = (payload) => isTodoPayload(payload) ? { todoId: payload.todoId } : {
|
|
68321
68353
|
processExecutionId: payload.processExecutionId,
|
|
@@ -68323,7 +68355,7 @@ var getPayloadContext = (payload) => isTodoPayload(payload) ? { todoId: payload.
|
|
|
68323
68355
|
};
|
|
68324
68356
|
var isSystemStepExecutionFailure = (error) => typeof error === "object" && error !== null && ("_tag" in error) && error._tag === "SystemStepExecutionError";
|
|
68325
68357
|
var authorFacingFailure = (cause) => {
|
|
68326
|
-
const failureValue =
|
|
68358
|
+
const failureValue = Option38.getOrUndefined(Cause6.findErrorOption(cause));
|
|
68327
68359
|
return isSystemStepExecutionFailure(failureValue) ? failureValue.error : failureValue;
|
|
68328
68360
|
};
|
|
68329
68361
|
var isTerminalStepFailure = (cause) => {
|
|
@@ -68334,7 +68366,7 @@ var isTerminalStepFailure = (cause) => {
|
|
|
68334
68366
|
};
|
|
68335
68367
|
var formatExecutionFailure = (cause) => {
|
|
68336
68368
|
const fullFailureReason = Cause6.pretty(cause);
|
|
68337
|
-
const failureValue =
|
|
68369
|
+
const failureValue = Option38.getOrUndefined(Cause6.findErrorOption(cause));
|
|
68338
68370
|
const innerError = isSystemStepExecutionFailure(failureValue) ? failureValue.error : undefined;
|
|
68339
68371
|
const innerErrorText = (() => {
|
|
68340
68372
|
if (innerError == null)
|
|
@@ -68373,31 +68405,31 @@ var getTaggedFailureTag = (candidate) => {
|
|
|
68373
68405
|
return;
|
|
68374
68406
|
};
|
|
68375
68407
|
var extractOutermostErrorTag = (cause) => {
|
|
68376
|
-
const failureValue =
|
|
68408
|
+
const failureValue = Option38.getOrUndefined(Cause6.findErrorOption(cause));
|
|
68377
68409
|
const failureTag = getTaggedFailureTag(failureValue);
|
|
68378
68410
|
if (failureTag !== undefined) {
|
|
68379
68411
|
return failureTag;
|
|
68380
68412
|
}
|
|
68381
68413
|
return cause.reasons.filter(Cause6.isDieReason).map((reason) => reason.defect).map(getTaggedFailureTag).find((tag) => tag !== undefined);
|
|
68382
68414
|
};
|
|
68383
|
-
var withConfiguredSystemStepTimeout = (stepPath, effect) => Config6.option(Config6.Number(SYSTEM_STEP_EXECUTION_TIMEOUT_SECONDS_ENV)).pipe(
|
|
68384
|
-
if (
|
|
68415
|
+
var withConfiguredSystemStepTimeout = (stepPath, effect) => Config6.option(Config6.Number(SYSTEM_STEP_EXECUTION_TIMEOUT_SECONDS_ENV)).pipe(Effect88.flatMap((timeoutSecondsOption) => {
|
|
68416
|
+
if (Option38.isNone(timeoutSecondsOption)) {
|
|
68385
68417
|
return effect;
|
|
68386
68418
|
}
|
|
68387
68419
|
const timeoutSeconds = timeoutSecondsOption.value;
|
|
68388
68420
|
if (!Number.isFinite(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
68389
68421
|
return effect;
|
|
68390
68422
|
}
|
|
68391
|
-
return effect.pipe(
|
|
68423
|
+
return effect.pipe(Effect88.timeoutOrElse({
|
|
68392
68424
|
duration: Duration10.seconds(timeoutSeconds),
|
|
68393
|
-
orElse: () =>
|
|
68425
|
+
orElse: () => Effect88.fail(new SystemStepExecutionTimeoutError({
|
|
68394
68426
|
message: `System step execution exceeded configured timeout of ${timeoutSeconds} seconds`,
|
|
68395
68427
|
stepPath,
|
|
68396
68428
|
timeoutSeconds
|
|
68397
68429
|
}))
|
|
68398
68430
|
}));
|
|
68399
68431
|
}));
|
|
68400
|
-
var recordInfrastructureFailure = (job, errorDescription) =>
|
|
68432
|
+
var recordInfrastructureFailure = (job, errorDescription) => Effect88.gen(function* () {
|
|
68401
68433
|
if (!isTodoPayload(job.payload)) {
|
|
68402
68434
|
return yield* recordStartedSystemStepFailure(job, errorDescription);
|
|
68403
68435
|
}
|
|
@@ -68408,7 +68440,7 @@ var recordInfrastructureFailure = (job, errorDescription) => Effect87.gen(functi
|
|
|
68408
68440
|
const queueService = yield* QueueService;
|
|
68409
68441
|
const sqlClient = yield* SqlClient14.SqlClient;
|
|
68410
68442
|
const failureReason = errorDescription.length > 500 ? `${errorDescription.slice(0, 497)}...` : errorDescription;
|
|
68411
|
-
yield*
|
|
68443
|
+
yield* Effect88.logError("Infrastructure error on last attempt, recording todo failure", {
|
|
68412
68444
|
todoId,
|
|
68413
68445
|
jobId: job.jobId,
|
|
68414
68446
|
attempts: job.attempts,
|
|
@@ -68416,7 +68448,7 @@ var recordInfrastructureFailure = (job, errorDescription) => Effect87.gen(functi
|
|
|
68416
68448
|
isTerminal: true,
|
|
68417
68449
|
failureReason
|
|
68418
68450
|
});
|
|
68419
|
-
const failedExecutionId = yield* sqlClient.withTransaction(
|
|
68451
|
+
const failedExecutionId = yield* sqlClient.withTransaction(Effect88.gen(function* () {
|
|
68420
68452
|
if (!(yield* isJobAttemptCurrent))
|
|
68421
68453
|
return;
|
|
68422
68454
|
yield* stepCompletionOps.failToDo(todoId, failureReason);
|
|
@@ -68449,7 +68481,7 @@ var recordInfrastructureFailure = (job, errorDescription) => Effect87.gen(functi
|
|
|
68449
68481
|
});
|
|
68450
68482
|
}
|
|
68451
68483
|
});
|
|
68452
|
-
var recordStartedSystemStepFailure = (job, errorDescription) =>
|
|
68484
|
+
var recordStartedSystemStepFailure = (job, errorDescription) => Effect88.gen(function* () {
|
|
68453
68485
|
const { processExecutionId, stepPath } = job.payload;
|
|
68454
68486
|
const completedJobId = getStartedSystemStepCompletedJobId(processExecutionId);
|
|
68455
68487
|
const completedJobOps = yield* CompletedJobOperations;
|
|
@@ -68457,7 +68489,7 @@ var recordStartedSystemStepFailure = (job, errorDescription) => Effect87.gen(fun
|
|
|
68457
68489
|
const queueService = yield* QueueService;
|
|
68458
68490
|
const sqlClient = yield* SqlClient14.SqlClient;
|
|
68459
68491
|
const failureReason = errorDescription.length > 500 ? `${errorDescription.slice(0, 497)}...` : errorDescription;
|
|
68460
|
-
yield*
|
|
68492
|
+
yield* Effect88.logError("Start system step failed on last attempt, finishing execution", {
|
|
68461
68493
|
processExecutionId,
|
|
68462
68494
|
stepPath,
|
|
68463
68495
|
jobId: job.jobId,
|
|
@@ -68466,7 +68498,7 @@ var recordStartedSystemStepFailure = (job, errorDescription) => Effect87.gen(fun
|
|
|
68466
68498
|
isTerminal: true,
|
|
68467
68499
|
failureReason
|
|
68468
68500
|
});
|
|
68469
|
-
yield* sqlClient.withTransaction(
|
|
68501
|
+
yield* sqlClient.withTransaction(Effect88.gen(function* () {
|
|
68470
68502
|
if (!(yield* isJobAttemptCurrent))
|
|
68471
68503
|
return;
|
|
68472
68504
|
yield* completedJobOps.markJobCompleted(SYSTEM_STEP_EXECUTION_QUEUE, completedJobId);
|
|
@@ -68480,29 +68512,29 @@ var recordStartedSystemStepFailure = (job, errorDescription) => Effect87.gen(fun
|
|
|
68480
68512
|
executionId: processExecutionId
|
|
68481
68513
|
});
|
|
68482
68514
|
});
|
|
68483
|
-
var handleSystemStepExecution =
|
|
68515
|
+
var handleSystemStepExecution = Effect88.fn("system-step-execution")((job) => handleSystemStepExecutionInner(job).pipe(Effect88.catch((error) => Effect88.gen(function* () {
|
|
68484
68516
|
if (isSystemStepFlowDispatchError(error)) {
|
|
68485
|
-
return yield*
|
|
68517
|
+
return yield* Effect88.fail(error);
|
|
68486
68518
|
}
|
|
68487
68519
|
if (job.attempts < job.maxAttempts) {
|
|
68488
|
-
return yield*
|
|
68520
|
+
return yield* Effect88.fail(error);
|
|
68489
68521
|
}
|
|
68490
68522
|
const description = `Exhausted ${job.maxAttempts} retries: ${String(error)}`;
|
|
68491
|
-
yield* recordInfrastructureFailure(job, description).pipe(
|
|
68523
|
+
yield* recordInfrastructureFailure(job, description).pipe(Effect88.catchCause((recordingCause) => Effect88.logError("Failed to record infrastructure failure on system step", {
|
|
68492
68524
|
...getPayloadContext(job.payload),
|
|
68493
68525
|
recordingError: Cause6.pretty(recordingCause)
|
|
68494
68526
|
})));
|
|
68495
|
-
})),
|
|
68527
|
+
})), Effect88.catchDefect((defect) => Effect88.gen(function* () {
|
|
68496
68528
|
if (job.attempts < job.maxAttempts) {
|
|
68497
|
-
return yield*
|
|
68529
|
+
return yield* Effect88.die(defect);
|
|
68498
68530
|
}
|
|
68499
68531
|
const description = `Exhausted ${job.maxAttempts} retries (defect): ${String(defect)}`;
|
|
68500
|
-
yield* recordInfrastructureFailure(job, description).pipe(
|
|
68532
|
+
yield* recordInfrastructureFailure(job, description).pipe(Effect88.catchCause((recordingCause) => Effect88.logError("Failed to record infrastructure defect on system step", {
|
|
68501
68533
|
...getPayloadContext(job.payload),
|
|
68502
68534
|
recordingError: Cause6.pretty(recordingCause)
|
|
68503
68535
|
})));
|
|
68504
68536
|
}))));
|
|
68505
|
-
var handleTodoSystemStepExecution = (job) =>
|
|
68537
|
+
var handleTodoSystemStepExecution = (job) => Effect88.gen(function* () {
|
|
68506
68538
|
const { todoId, stepPath } = job.payload;
|
|
68507
68539
|
const queueService = yield* QueueService;
|
|
68508
68540
|
const flowExecutionOps = yield* FlowExecutionOperations;
|
|
@@ -68530,23 +68562,23 @@ var handleTodoSystemStepExecution = (job) => Effect87.gen(function* () {
|
|
|
68530
68562
|
const sqlClient = yield* SqlClient14.SqlClient;
|
|
68531
68563
|
const alreadyCompleted = yield* completedJobOps.isJobCompleted(SYSTEM_STEP_EXECUTION_QUEUE, job.jobId);
|
|
68532
68564
|
if (alreadyCompleted) {
|
|
68533
|
-
yield*
|
|
68565
|
+
yield* Effect88.log("Job already completed, skipping", {
|
|
68534
68566
|
jobId: job.jobId,
|
|
68535
68567
|
todoId,
|
|
68536
68568
|
stepPath
|
|
68537
68569
|
});
|
|
68538
68570
|
return;
|
|
68539
68571
|
}
|
|
68540
|
-
yield*
|
|
68572
|
+
yield* Effect88.log("Processing system-step-execution job", {
|
|
68541
68573
|
jobId: job.jobId,
|
|
68542
68574
|
todoId,
|
|
68543
68575
|
stepPath
|
|
68544
68576
|
});
|
|
68545
|
-
const inputs = yield* withReadSnapshot(sqlClient,
|
|
68577
|
+
const inputs = yield* withReadSnapshot(sqlClient, Effect88.gen(function* () {
|
|
68546
68578
|
const todoInfo = yield* stepCompletionOps.queryTodoById(todoId);
|
|
68547
68579
|
if (!todoInfo)
|
|
68548
68580
|
return null;
|
|
68549
|
-
yield*
|
|
68581
|
+
yield* Effect88.logInfo("System-step-execution job resolved execution", {
|
|
68550
68582
|
jobId: job.jobId,
|
|
68551
68583
|
todoId,
|
|
68552
68584
|
stepPath,
|
|
@@ -68562,13 +68594,13 @@ var handleTodoSystemStepExecution = (job) => Effect87.gen(function* () {
|
|
|
68562
68594
|
return { todoInfo, processState, completedSteps };
|
|
68563
68595
|
}));
|
|
68564
68596
|
if (!inputs) {
|
|
68565
|
-
yield*
|
|
68597
|
+
yield* Effect88.logWarning("Todo not found - flow-execution may have rolled back", { todoId });
|
|
68566
68598
|
yield* completedJobOps.markJobCompleted(SYSTEM_STEP_EXECUTION_QUEUE, job.jobId);
|
|
68567
68599
|
return;
|
|
68568
68600
|
}
|
|
68569
68601
|
const { todoInfo, processState, completedSteps } = inputs;
|
|
68570
68602
|
if (todoInfo.failureReason != null) {
|
|
68571
|
-
yield*
|
|
68603
|
+
yield* Effect88.log("Skipping delivery for a failed system-step Todo", {
|
|
68572
68604
|
todoId,
|
|
68573
68605
|
stepPath
|
|
68574
68606
|
});
|
|
@@ -68576,18 +68608,18 @@ var handleTodoSystemStepExecution = (job) => Effect87.gen(function* () {
|
|
|
68576
68608
|
return;
|
|
68577
68609
|
}
|
|
68578
68610
|
const initiatingAudit = todoInfo.createdBy;
|
|
68579
|
-
const scopedUserDetails = initiatingAudit !== undefined &&
|
|
68580
|
-
return yield*
|
|
68611
|
+
const scopedUserDetails = initiatingAudit !== undefined && Option38.isSome(decodeDelegationAudit(initiatingAudit)) ? { by: initiatingAudit, id: null } : yield* UserDetails;
|
|
68612
|
+
return yield* Effect88.gen(function* () {
|
|
68581
68613
|
const ctx = buildFlowContext(todoInfo.processExecutionId, processState.processStartedAt, completedSteps);
|
|
68582
68614
|
const isForEach = todoInfo.hasForEach;
|
|
68583
|
-
yield*
|
|
68615
|
+
yield* Effect88.logDebug("Executing system step", {
|
|
68584
68616
|
stepPath,
|
|
68585
68617
|
processExecutionId: todoInfo.processExecutionId,
|
|
68586
68618
|
isForEach,
|
|
68587
68619
|
hasItemData: todoInfo.itemData !== null
|
|
68588
68620
|
});
|
|
68589
68621
|
const forEachInput = isForEach && todoInfo.itemData !== null ? todoInfo.itemData : undefined;
|
|
68590
|
-
const exit = yield*
|
|
68622
|
+
const exit = yield* Effect88.exit(withConfiguredSystemStepTimeout(stepPath, systemStepExecutor.execute(stepPath, processState.state, ctx, todoId, forEachInput, completedSteps.map((step) => step.stepPath), todoInfo.externalWriteAttemptId ?? undefined)));
|
|
68591
68623
|
if (Exit3.isFailure(exit)) {
|
|
68592
68624
|
const errorTag = extractOutermostErrorTag(exit.cause);
|
|
68593
68625
|
const {
|
|
@@ -68599,7 +68631,7 @@ var handleTodoSystemStepExecution = (job) => Effect87.gen(function* () {
|
|
|
68599
68631
|
const failureReason = displayFailureReason.length > 500 ? `${displayFailureReason.slice(0, 497)}...` : displayFailureReason;
|
|
68600
68632
|
const isTerminal = isNonRetryable || job.attempts >= job.maxAttempts;
|
|
68601
68633
|
const hasMatchingOnError = isTerminal && hasMatchingOnErrorFlow(yield* flowExecutionOps.queryFlowsBySourceStepId(todoInfo.targetStepId), errorTag);
|
|
68602
|
-
const logFailure = isTerminal && !hasMatchingOnError ?
|
|
68634
|
+
const logFailure = isTerminal && !hasMatchingOnError ? Effect88.logError : Effect88.logWarning;
|
|
68603
68635
|
yield* logFailure("System step execution failed", {
|
|
68604
68636
|
stepPath,
|
|
68605
68637
|
processExecutionId: todoInfo.processExecutionId,
|
|
@@ -68613,7 +68645,7 @@ var handleTodoSystemStepExecution = (job) => Effect87.gen(function* () {
|
|
|
68613
68645
|
innerError: innerErrorText
|
|
68614
68646
|
});
|
|
68615
68647
|
if (isTerminal) {
|
|
68616
|
-
const outcome = yield* sqlClient.withTransaction(
|
|
68648
|
+
const outcome = yield* sqlClient.withTransaction(Effect88.gen(function* () {
|
|
68617
68649
|
if (!(yield* isJobAttemptCurrent))
|
|
68618
68650
|
return { recorded: false };
|
|
68619
68651
|
const failure = authorFacingFailure(exit.cause);
|
|
@@ -68685,11 +68717,11 @@ var handleTodoSystemStepExecution = (job) => Effect87.gen(function* () {
|
|
|
68685
68717
|
});
|
|
68686
68718
|
return;
|
|
68687
68719
|
}
|
|
68688
|
-
return yield*
|
|
68720
|
+
return yield* Effect88.failCause(exit.cause);
|
|
68689
68721
|
}
|
|
68690
68722
|
const result = exit.value;
|
|
68691
68723
|
if (result._tag === "Deferred") {
|
|
68692
|
-
yield* sqlClient.withTransaction(
|
|
68724
|
+
yield* sqlClient.withTransaction(Effect88.gen(function* () {
|
|
68693
68725
|
if (!(yield* isJobAttemptCurrent))
|
|
68694
68726
|
return;
|
|
68695
68727
|
if (result.stateUpdate && Object.keys(result.stateUpdate).length > 0) {
|
|
@@ -68697,14 +68729,14 @@ var handleTodoSystemStepExecution = (job) => Effect87.gen(function* () {
|
|
|
68697
68729
|
}
|
|
68698
68730
|
yield* completedJobOps.markJobCompleted(SYSTEM_STEP_EXECUTION_QUEUE, job.jobId);
|
|
68699
68731
|
}));
|
|
68700
|
-
yield*
|
|
68732
|
+
yield* Effect88.log("System step deferred to external executor", {
|
|
68701
68733
|
stepPath,
|
|
68702
68734
|
todoId
|
|
68703
68735
|
});
|
|
68704
68736
|
return;
|
|
68705
68737
|
}
|
|
68706
68738
|
const output = result.output;
|
|
68707
|
-
yield*
|
|
68739
|
+
yield* Effect88.logInfo("System step execution returned; completion pending", {
|
|
68708
68740
|
jobId: job.jobId,
|
|
68709
68741
|
todoId,
|
|
68710
68742
|
processExecutionId: todoInfo.processExecutionId,
|
|
@@ -68726,9 +68758,9 @@ var handleTodoSystemStepExecution = (job) => Effect87.gen(function* () {
|
|
|
68726
68758
|
calendarQueries,
|
|
68727
68759
|
sqlClient
|
|
68728
68760
|
});
|
|
68729
|
-
}).pipe(
|
|
68761
|
+
}).pipe(Effect88.provideService(UserDetails, scopedUserDetails));
|
|
68730
68762
|
});
|
|
68731
|
-
var completeStartedSystemStep = (params) =>
|
|
68763
|
+
var completeStartedSystemStep = (params) => Effect88.gen(function* () {
|
|
68732
68764
|
const {
|
|
68733
68765
|
processExecutionId,
|
|
68734
68766
|
processStateId,
|
|
@@ -68743,7 +68775,7 @@ var completeStartedSystemStep = (params) => Effect87.gen(function* () {
|
|
|
68743
68775
|
const flowExecutionOps = yield* FlowExecutionOperations;
|
|
68744
68776
|
const sqlClient = yield* SqlClient14.SqlClient;
|
|
68745
68777
|
const dispatchId = startedSystemStepDispatchId(processExecutionId);
|
|
68746
|
-
const scheduledFlowId = yield* sqlClient.withTransaction(
|
|
68778
|
+
const scheduledFlowId = yield* sqlClient.withTransaction(Effect88.gen(function* () {
|
|
68747
68779
|
if (!(yield* isJobAttemptCurrent))
|
|
68748
68780
|
return;
|
|
68749
68781
|
if (Object.keys(output).length > 0) {
|
|
@@ -68752,7 +68784,7 @@ var completeStartedSystemStep = (params) => Effect87.gen(function* () {
|
|
|
68752
68784
|
const scheduledFlowId = yield* scheduledFlowOps.insertScheduledFlow(processExecutionId, stepId);
|
|
68753
68785
|
if (queueService.queueInTransaction) {
|
|
68754
68786
|
yield* queueService.enqueue(FLOW_EXECUTION_QUEUE, { scheduledFlowId });
|
|
68755
|
-
yield*
|
|
68787
|
+
yield* Effect88.log("Staged flow after start system step completion (provisional until outer commit)", {
|
|
68756
68788
|
scheduledFlowId
|
|
68757
68789
|
});
|
|
68758
68790
|
} else {
|
|
@@ -68782,7 +68814,7 @@ var completeStartedSystemStep = (params) => Effect87.gen(function* () {
|
|
|
68782
68814
|
queueService,
|
|
68783
68815
|
flowExecutionOps
|
|
68784
68816
|
});
|
|
68785
|
-
yield*
|
|
68817
|
+
yield* Effect88.log("Flow scheduled after start system step completion", {
|
|
68786
68818
|
scheduledFlowId
|
|
68787
68819
|
});
|
|
68788
68820
|
}
|
|
@@ -68794,7 +68826,7 @@ var completeStartedSystemStep = (params) => Effect87.gen(function* () {
|
|
|
68794
68826
|
executionId: processExecutionId
|
|
68795
68827
|
});
|
|
68796
68828
|
});
|
|
68797
|
-
var handleStartedSystemStepExecution = (job) =>
|
|
68829
|
+
var handleStartedSystemStepExecution = (job) => Effect88.gen(function* () {
|
|
68798
68830
|
const { processExecutionId, stepId, stepPath } = job.payload;
|
|
68799
68831
|
const completedJobId = getStartedSystemStepCompletedJobId(processExecutionId);
|
|
68800
68832
|
const queueService = yield* QueueService;
|
|
@@ -68818,21 +68850,21 @@ var handleStartedSystemStepExecution = (job) => Effect87.gen(function* () {
|
|
|
68818
68850
|
const systemStepExecutor = yield* SystemStepExecutor;
|
|
68819
68851
|
const alreadyCompleted = yield* completedJobOps.isJobCompleted(SYSTEM_STEP_EXECUTION_QUEUE, completedJobId);
|
|
68820
68852
|
if (alreadyCompleted) {
|
|
68821
|
-
yield*
|
|
68853
|
+
yield* Effect88.log("Job already completed, skipping", {
|
|
68822
68854
|
jobId: job.jobId,
|
|
68823
68855
|
processExecutionId,
|
|
68824
68856
|
stepPath
|
|
68825
68857
|
});
|
|
68826
68858
|
return;
|
|
68827
68859
|
}
|
|
68828
|
-
yield*
|
|
68860
|
+
yield* Effect88.log("Processing start system-step-execution job", {
|
|
68829
68861
|
jobId: job.jobId,
|
|
68830
68862
|
processExecutionId,
|
|
68831
68863
|
stepId,
|
|
68832
68864
|
stepPath
|
|
68833
68865
|
});
|
|
68834
68866
|
const sqlClient = yield* SqlClient14.SqlClient;
|
|
68835
|
-
const { processStateRaw, executionDetails, completedSteps } = yield* withReadSnapshot(sqlClient,
|
|
68867
|
+
const { processStateRaw, executionDetails, completedSteps } = yield* withReadSnapshot(sqlClient, Effect88.gen(function* () {
|
|
68836
68868
|
const processStateRaw = yield* flowExecutionOps.getProcessStateByExecutionId(processExecutionId);
|
|
68837
68869
|
if (!processStateRaw) {
|
|
68838
68870
|
return yield* new ProcessStateNotFoundError({ processExecutionId });
|
|
@@ -68847,14 +68879,14 @@ var handleStartedSystemStepExecution = (job) => Effect87.gen(function* () {
|
|
|
68847
68879
|
return { processStateRaw, executionDetails, completedSteps };
|
|
68848
68880
|
}));
|
|
68849
68881
|
const initiatingAudit = processStateRaw.createdBy;
|
|
68850
|
-
const scopedUserDetails = initiatingAudit !== undefined &&
|
|
68851
|
-
return yield*
|
|
68852
|
-
const processState = yield*
|
|
68882
|
+
const scopedUserDetails = initiatingAudit !== undefined && Option38.isSome(decodeDelegationAudit(initiatingAudit)) ? { by: initiatingAudit, id: null } : yield* UserDetails;
|
|
68883
|
+
return yield* Effect88.gen(function* () {
|
|
68884
|
+
const processState = yield* Schema37.decodeUnknownEffect(ProcessStateSchema3)(processStateRaw.state ?? {}).pipe(Effect88.mapError(() => new InvalidProcessStateError({
|
|
68853
68885
|
processExecutionId,
|
|
68854
68886
|
reason: "State is not a valid record"
|
|
68855
68887
|
})));
|
|
68856
|
-
const ctx = buildFlowContext(processExecutionId,
|
|
68857
|
-
const exit = yield*
|
|
68888
|
+
const ctx = buildFlowContext(processExecutionId, DateTime27.makeUnsafe(executionDetails.createdAtMs), completedSteps);
|
|
68889
|
+
const exit = yield* Effect88.exit(withConfiguredSystemStepTimeout(stepPath, systemStepExecutor.execute(stepPath, processState, ctx, completedJobId, undefined, completedSteps.map((step) => step.stepPath))));
|
|
68858
68890
|
if (Exit3.isFailure(exit)) {
|
|
68859
68891
|
const errorTag = extractOutermostErrorTag(exit.cause);
|
|
68860
68892
|
const {
|
|
@@ -68864,7 +68896,7 @@ var handleStartedSystemStepExecution = (job) => Effect87.gen(function* () {
|
|
|
68864
68896
|
isTerminal: isNonRetryable
|
|
68865
68897
|
} = formatExecutionFailure(exit.cause);
|
|
68866
68898
|
const isTerminal = isNonRetryable || job.attempts >= job.maxAttempts;
|
|
68867
|
-
const logFailure = isTerminal ?
|
|
68899
|
+
const logFailure = isTerminal ? Effect88.logError : Effect88.logWarning;
|
|
68868
68900
|
yield* logFailure("Start system step execution failed", {
|
|
68869
68901
|
processExecutionId,
|
|
68870
68902
|
stepPath,
|
|
@@ -68880,11 +68912,11 @@ var handleStartedSystemStepExecution = (job) => Effect87.gen(function* () {
|
|
|
68880
68912
|
yield* recordStartedSystemStepFailure(job, displayFailureReason);
|
|
68881
68913
|
return;
|
|
68882
68914
|
}
|
|
68883
|
-
return yield*
|
|
68915
|
+
return yield* Effect88.failCause(exit.cause);
|
|
68884
68916
|
}
|
|
68885
68917
|
const result = exit.value;
|
|
68886
68918
|
if (result._tag === "Deferred") {
|
|
68887
|
-
yield*
|
|
68919
|
+
yield* Effect88.log("Start system step deferred to external executor", {
|
|
68888
68920
|
processExecutionId,
|
|
68889
68921
|
stepPath
|
|
68890
68922
|
});
|
|
@@ -68892,7 +68924,7 @@ var handleStartedSystemStepExecution = (job) => Effect87.gen(function* () {
|
|
|
68892
68924
|
return;
|
|
68893
68925
|
}
|
|
68894
68926
|
const output = result.output;
|
|
68895
|
-
yield*
|
|
68927
|
+
yield* Effect88.logInfo("Start system step execution returned; completion pending", {
|
|
68896
68928
|
jobId: job.jobId,
|
|
68897
68929
|
processExecutionId,
|
|
68898
68930
|
stepPath,
|
|
@@ -68907,7 +68939,7 @@ var handleStartedSystemStepExecution = (job) => Effect87.gen(function* () {
|
|
|
68907
68939
|
output,
|
|
68908
68940
|
completedJobId
|
|
68909
68941
|
});
|
|
68910
|
-
}).pipe(
|
|
68942
|
+
}).pipe(Effect88.provideService(UserDetails, scopedUserDetails));
|
|
68911
68943
|
});
|
|
68912
68944
|
var handleSystemStepExecutionInner = (job) => isTodoPayload(job.payload) ? handleTodoSystemStepExecution(job) : handleStartedSystemStepExecution(job);
|
|
68913
68945
|
var executeSystemStep = (job) => withUserDetailsScope(handleSystemStepExecution(job));
|
|
@@ -68922,93 +68954,93 @@ var flowExecutionHandler = {
|
|
|
68922
68954
|
})
|
|
68923
68955
|
};
|
|
68924
68956
|
|
|
68925
|
-
import { Effect as
|
|
68926
|
-
|
|
68927
|
-
|
|
68928
|
-
import { Schema as
|
|
68929
|
-
var NotificationRecipientSchema =
|
|
68930
|
-
userId:
|
|
68931
|
-
email:
|
|
68932
|
-
displayName:
|
|
68933
|
-
});
|
|
68934
|
-
var NotificationTodoSchema =
|
|
68935
|
-
todoId:
|
|
68936
|
-
stepPath:
|
|
68937
|
-
processName:
|
|
68938
|
-
stepName:
|
|
68939
|
-
});
|
|
68940
|
-
var CorrectionRequiredNotificationSchema =
|
|
68941
|
-
todoId:
|
|
68942
|
-
processName:
|
|
68943
|
-
stepName:
|
|
68944
|
-
failureReason:
|
|
68945
|
-
});
|
|
68946
|
-
var StoredEmailAttachmentSchema =
|
|
68947
|
-
filename:
|
|
68948
|
-
storePrefix:
|
|
68949
|
-
fileId:
|
|
68950
|
-
});
|
|
68951
|
-
var PublicTodoNotificationSchema =
|
|
68952
|
-
todoId:
|
|
68953
|
-
processName:
|
|
68954
|
-
stepName:
|
|
68955
|
-
token:
|
|
68956
|
-
expiresAt:
|
|
68957
|
-
publicCompletionInvitationAttemptId:
|
|
68958
|
-
from:
|
|
68959
|
-
subject:
|
|
68960
|
-
body:
|
|
68961
|
-
template:
|
|
68962
|
-
id:
|
|
68963
|
-
variables:
|
|
68957
|
+
import { Effect as Effect89 } from "effect";
|
|
68958
|
+
|
|
68959
|
+
|
|
68960
|
+
import { Schema as Schema38 } from "effect";
|
|
68961
|
+
var NotificationRecipientSchema = Schema38.Struct({
|
|
68962
|
+
userId: Schema38.optional(Schema38.String),
|
|
68963
|
+
email: Schema38.String,
|
|
68964
|
+
displayName: Schema38.optional(Schema38.String)
|
|
68965
|
+
});
|
|
68966
|
+
var NotificationTodoSchema = Schema38.Struct({
|
|
68967
|
+
todoId: Schema38.String,
|
|
68968
|
+
stepPath: Schema38.String,
|
|
68969
|
+
processName: Schema38.String,
|
|
68970
|
+
stepName: Schema38.String
|
|
68971
|
+
});
|
|
68972
|
+
var CorrectionRequiredNotificationSchema = Schema38.Struct({
|
|
68973
|
+
todoId: Schema38.String,
|
|
68974
|
+
processName: Schema38.String,
|
|
68975
|
+
stepName: Schema38.String,
|
|
68976
|
+
failureReason: Schema38.String
|
|
68977
|
+
});
|
|
68978
|
+
var StoredEmailAttachmentSchema = Schema38.Struct({
|
|
68979
|
+
filename: Schema38.String,
|
|
68980
|
+
storePrefix: Schema38.String,
|
|
68981
|
+
fileId: Schema38.String
|
|
68982
|
+
});
|
|
68983
|
+
var PublicTodoNotificationSchema = Schema38.Struct({
|
|
68984
|
+
todoId: Schema38.String,
|
|
68985
|
+
processName: Schema38.String,
|
|
68986
|
+
stepName: Schema38.String,
|
|
68987
|
+
token: Schema38.String,
|
|
68988
|
+
expiresAt: Schema38.String,
|
|
68989
|
+
publicCompletionInvitationAttemptId: Schema38.optional(Schema38.String),
|
|
68990
|
+
from: Schema38.optional(Schema38.String),
|
|
68991
|
+
subject: Schema38.optional(Schema38.String),
|
|
68992
|
+
body: Schema38.optional(Schema38.String),
|
|
68993
|
+
template: Schema38.optional(Schema38.Struct({
|
|
68994
|
+
id: Schema38.String,
|
|
68995
|
+
variables: Schema38.optional(Schema38.Record(Schema38.String, Schema38.Union([Schema38.String, Schema38.Number])))
|
|
68964
68996
|
})),
|
|
68965
|
-
attachments:
|
|
68997
|
+
attachments: Schema38.optional(Schema38.Array(StoredEmailAttachmentSchema))
|
|
68966
68998
|
});
|
|
68967
|
-
var ExecutionFailureNotificationSchema =
|
|
68968
|
-
executionId:
|
|
68969
|
-
processName:
|
|
68970
|
-
failureReason:
|
|
68971
|
-
project:
|
|
68972
|
-
environment:
|
|
68999
|
+
var ExecutionFailureNotificationSchema = Schema38.Struct({
|
|
69000
|
+
executionId: Schema38.String,
|
|
69001
|
+
processName: Schema38.String,
|
|
69002
|
+
failureReason: Schema38.String,
|
|
69003
|
+
project: Schema38.String,
|
|
69004
|
+
environment: Schema38.String
|
|
68973
69005
|
});
|
|
68974
|
-
var AccessReviewControlNotificationSchema =
|
|
68975
|
-
failureCategory:
|
|
69006
|
+
var AccessReviewControlNotificationSchema = Schema38.Struct({
|
|
69007
|
+
failureCategory: Schema38.Literals([
|
|
68976
69008
|
"missed-scheduled-start",
|
|
68977
69009
|
"review-sla-overdue",
|
|
68978
69010
|
"remediation-sla-overdue"
|
|
68979
69011
|
]),
|
|
68980
|
-
project:
|
|
68981
|
-
environment:
|
|
68982
|
-
processPath:
|
|
68983
|
-
investigationReference:
|
|
68984
|
-
scheduledFor:
|
|
68985
|
-
executionId:
|
|
68986
|
-
todoId:
|
|
68987
|
-
dueAt:
|
|
68988
|
-
});
|
|
68989
|
-
var NotificationDeliveryBase =
|
|
68990
|
-
channel:
|
|
68991
|
-
idempotencyKey:
|
|
69012
|
+
project: Schema38.String,
|
|
69013
|
+
environment: Schema38.String,
|
|
69014
|
+
processPath: Schema38.String,
|
|
69015
|
+
investigationReference: Schema38.String,
|
|
69016
|
+
scheduledFor: Schema38.optional(Schema38.String),
|
|
69017
|
+
executionId: Schema38.optional(Schema38.String),
|
|
69018
|
+
todoId: Schema38.optional(Schema38.String),
|
|
69019
|
+
dueAt: Schema38.optional(Schema38.String)
|
|
69020
|
+
});
|
|
69021
|
+
var NotificationDeliveryBase = Schema38.Struct({
|
|
69022
|
+
channel: Schema38.Literal("email"),
|
|
69023
|
+
idempotencyKey: Schema38.optional(Schema38.String),
|
|
68992
69024
|
recipient: NotificationRecipientSchema
|
|
68993
69025
|
});
|
|
68994
|
-
var NotificationDeliveryPayloadSchema =
|
|
68995
|
-
|
|
69026
|
+
var NotificationDeliveryPayloadSchema = Schema38.Union([
|
|
69027
|
+
Schema38.Struct({
|
|
68996
69028
|
...NotificationDeliveryBase.fields,
|
|
68997
69029
|
todo: NotificationTodoSchema
|
|
68998
69030
|
}),
|
|
68999
|
-
|
|
69031
|
+
Schema38.Struct({
|
|
69000
69032
|
...NotificationDeliveryBase.fields,
|
|
69001
69033
|
correctionRequired: CorrectionRequiredNotificationSchema
|
|
69002
69034
|
}),
|
|
69003
|
-
|
|
69035
|
+
Schema38.Struct({
|
|
69004
69036
|
...NotificationDeliveryBase.fields,
|
|
69005
69037
|
publicTodo: PublicTodoNotificationSchema
|
|
69006
69038
|
}),
|
|
69007
|
-
|
|
69039
|
+
Schema38.Struct({
|
|
69008
69040
|
...NotificationDeliveryBase.fields,
|
|
69009
69041
|
executionFailure: ExecutionFailureNotificationSchema
|
|
69010
69042
|
}),
|
|
69011
|
-
|
|
69043
|
+
Schema38.Struct({
|
|
69012
69044
|
...NotificationDeliveryBase.fields,
|
|
69013
69045
|
accessReviewControl: AccessReviewControlNotificationSchema
|
|
69014
69046
|
})
|
|
@@ -69210,23 +69242,23 @@ var buildPublicTodoEmail = (payload, frontendBaseUrl, sender, environment) => {
|
|
|
69210
69242
|
var recordPublicCompletionInvitationReceipt = (payload, receipt) => {
|
|
69211
69243
|
const attemptId = payload.publicTodo.publicCompletionInvitationAttemptId;
|
|
69212
69244
|
if (attemptId === undefined || receipt === undefined) {
|
|
69213
|
-
return
|
|
69245
|
+
return Effect89.void;
|
|
69214
69246
|
}
|
|
69215
|
-
return
|
|
69247
|
+
return Effect89.gen(function* () {
|
|
69216
69248
|
const stepCompletionOps = yield* StepCompletionOperations;
|
|
69217
69249
|
const recorded = yield* stepCompletionOps.recordPublicCompletionInvitationAttemptReceipt(attemptId, {
|
|
69218
69250
|
providerMessageId: receipt.providerMessageId,
|
|
69219
69251
|
providerSentTo: receipt.providerSentTo
|
|
69220
69252
|
});
|
|
69221
69253
|
if (!recorded) {
|
|
69222
|
-
yield*
|
|
69254
|
+
yield* Effect89.logWarning("Public-completion delivery receipt did not match an invitation attempt", { attemptId });
|
|
69223
69255
|
}
|
|
69224
|
-
}).pipe(
|
|
69256
|
+
}).pipe(Effect89.catch((error) => Effect89.logWarning("Failed to record public-completion delivery receipt", {
|
|
69225
69257
|
attemptId,
|
|
69226
69258
|
error: String(error)
|
|
69227
69259
|
})));
|
|
69228
69260
|
};
|
|
69229
|
-
var handleNotificationDelivery =
|
|
69261
|
+
var handleNotificationDelivery = Effect89.fn("notification-delivery")((job) => Effect89.gen(function* () {
|
|
69230
69262
|
const emailSender = yield* EmailSender;
|
|
69231
69263
|
const config = yield* NotificationDeliveryConfig;
|
|
69232
69264
|
const frontendBaseUrl = config.getFrontendBaseUrl();
|
|
@@ -69243,7 +69275,7 @@ var handleNotificationDelivery = Effect88.fn("notification-delivery")((job) => E
|
|
|
69243
69275
|
...job.payload.accessReviewControl.todoId !== undefined ? { todoId: job.payload.accessReviewControl.todoId } : {}
|
|
69244
69276
|
} : isExecutionFailurePayload(job.payload) ? { executionId: job.payload.executionFailure.executionId } : {};
|
|
69245
69277
|
if (senderIdentity === undefined) {
|
|
69246
|
-
yield*
|
|
69278
|
+
yield* Effect89.logWarning("Skipping notification email because sender identity is not configured. Configure NotificationDeliveryConfig.getSenderIdentity() in your org/job worker runtime.", {
|
|
69247
69279
|
jobId: job.jobId,
|
|
69248
69280
|
channel: job.payload.channel,
|
|
69249
69281
|
userId: job.payload.recipient.userId,
|
|
@@ -69253,13 +69285,13 @@ var handleNotificationDelivery = Effect88.fn("notification-delivery")((job) => E
|
|
|
69253
69285
|
return;
|
|
69254
69286
|
}
|
|
69255
69287
|
if (isTaskAssignmentPayload(job.payload) && emailSender.loggingOnly) {
|
|
69256
|
-
yield*
|
|
69288
|
+
yield* Effect89.logWarning("Skipping task-assignment email because no delivery transport is configured", { jobId: job.jobId, ...payloadContext });
|
|
69257
69289
|
return;
|
|
69258
69290
|
}
|
|
69259
69291
|
const email = isTaskAssignmentPayload(job.payload) ? buildTaskAssignmentEmail(job.payload, frontendBaseUrl, senderIdentity) : isCorrectionRequiredPayload(job.payload) ? buildCorrectionRequiredEmail(job.payload, frontendBaseUrl, senderIdentity) : isPublicTodoPayload(job.payload) ? buildPublicTodoEmail(job.payload, frontendBaseUrl, senderIdentity, environment) : isAccessReviewControlPayload(job.payload) ? buildAccessReviewControlEmail(job.payload, frontendBaseUrl, senderIdentity) : isExecutionFailurePayload(job.payload) ? buildExecutionFailureEmail(job.payload, frontendBaseUrl, senderIdentity) : (() => {
|
|
69260
69292
|
throw new Error("Unsupported notification-delivery payload variant");
|
|
69261
69293
|
})();
|
|
69262
|
-
yield*
|
|
69294
|
+
yield* Effect89.log("Processing notification-delivery job", {
|
|
69263
69295
|
jobId: job.jobId,
|
|
69264
69296
|
channel: job.payload.channel,
|
|
69265
69297
|
userId: job.payload.recipient.userId,
|
|
@@ -69269,7 +69301,7 @@ var handleNotificationDelivery = Effect88.fn("notification-delivery")((job) => E
|
|
|
69269
69301
|
if (isPublicTodoPayload(job.payload)) {
|
|
69270
69302
|
yield* recordPublicCompletionInvitationReceipt(job.payload, receipt);
|
|
69271
69303
|
}
|
|
69272
|
-
yield*
|
|
69304
|
+
yield* Effect89.log("Delivered notification email", {
|
|
69273
69305
|
jobId: job.jobId,
|
|
69274
69306
|
channel: job.payload.channel,
|
|
69275
69307
|
userId: job.payload.recipient.userId,
|
|
@@ -69288,7 +69320,7 @@ var notificationDeliveryHandler = {
|
|
|
69288
69320
|
handle: handleNotificationDelivery
|
|
69289
69321
|
};
|
|
69290
69322
|
|
|
69291
|
-
import { Effect as
|
|
69323
|
+
import { Effect as Effect90, Schema as Schema39 } from "effect";
|
|
69292
69324
|
import { SqlClient as SqlClient15 } from "effect/sql";
|
|
69293
69325
|
|
|
69294
69326
|
|
|
@@ -69301,22 +69333,22 @@ class ProcessFromJobPublisher extends Context36.Service()("processfocus:internal
|
|
|
69301
69333
|
}
|
|
69302
69334
|
|
|
69303
69335
|
|
|
69304
|
-
var ProcessEventPayloadSchema =
|
|
69305
|
-
processId:
|
|
69336
|
+
var ProcessEventPayloadSchema = Schema39.Struct({
|
|
69337
|
+
processId: Schema39.String
|
|
69306
69338
|
});
|
|
69307
|
-
var handleProcessEvent =
|
|
69339
|
+
var handleProcessEvent = Effect90.fn("process-event")((job) => Effect90.gen(function* () {
|
|
69308
69340
|
const { processId } = job.payload;
|
|
69309
69341
|
const completedJobOps = yield* CompletedJobOperations;
|
|
69310
69342
|
const processPublisher = yield* ProcessFromJobPublisher;
|
|
69311
69343
|
const alreadyCompleted = yield* completedJobOps.isJobCompleted(PROCESS_EVENT_QUEUE, job.jobId);
|
|
69312
69344
|
if (alreadyCompleted) {
|
|
69313
|
-
yield*
|
|
69345
|
+
yield* Effect90.log("Job already completed, skipping", {
|
|
69314
69346
|
jobId: job.jobId,
|
|
69315
69347
|
processId
|
|
69316
69348
|
});
|
|
69317
69349
|
return;
|
|
69318
69350
|
}
|
|
69319
|
-
yield*
|
|
69351
|
+
yield* Effect90.log("Processing process-event job", {
|
|
69320
69352
|
jobId: job.jobId,
|
|
69321
69353
|
processId
|
|
69322
69354
|
});
|
|
@@ -69325,9 +69357,9 @@ var handleProcessEvent = Effect89.fn("process-event")((job) => Effect89.gen(func
|
|
|
69325
69357
|
yield* sqlClient.withTransaction(processes.advanceProcessRevision(processId));
|
|
69326
69358
|
const outcome = yield* processPublisher.publishProcessChanged(processId);
|
|
69327
69359
|
if (outcome === "skipped-not-found") {
|
|
69328
|
-
yield*
|
|
69360
|
+
yield* Effect90.logWarning("No process found for ID - flow-execution may have rolled back", { processId });
|
|
69329
69361
|
} else {
|
|
69330
|
-
yield*
|
|
69362
|
+
yield* Effect90.log("Published process changed event", { processId });
|
|
69331
69363
|
}
|
|
69332
69364
|
yield* sqlClient.withTransaction(completedJobOps.markJobCompleted(PROCESS_EVENT_QUEUE, job.jobId));
|
|
69333
69365
|
}));
|
|
@@ -69346,7 +69378,7 @@ var systemStepExecutionHandler = {
|
|
|
69346
69378
|
})
|
|
69347
69379
|
};
|
|
69348
69380
|
|
|
69349
|
-
import { Effect as
|
|
69381
|
+
import { Effect as Effect91, Schema as Schema40 } from "effect";
|
|
69350
69382
|
import { SqlClient as SqlClient16 } from "effect/sql";
|
|
69351
69383
|
|
|
69352
69384
|
|
|
@@ -69359,35 +69391,35 @@ class TodoFromJobPublisher extends Context37.Service()("processfocus:internal-ta
|
|
|
69359
69391
|
}
|
|
69360
69392
|
|
|
69361
69393
|
|
|
69362
|
-
var TodoEventPayloadSchema =
|
|
69363
|
-
todoIds:
|
|
69394
|
+
var TodoEventPayloadSchema = Schema40.Struct({
|
|
69395
|
+
todoIds: Schema40.Array(Schema40.String)
|
|
69364
69396
|
});
|
|
69365
|
-
var handleTodoEvent =
|
|
69397
|
+
var handleTodoEvent = Effect91.fn("todo-event")((job) => Effect91.gen(function* () {
|
|
69366
69398
|
const { todoIds } = job.payload;
|
|
69367
69399
|
const completedJobOps = yield* CompletedJobOperations;
|
|
69368
69400
|
const todoQueries = yield* TodoQueries;
|
|
69369
69401
|
const todoPublisher = yield* TodoFromJobPublisher;
|
|
69370
69402
|
const alreadyCompleted = yield* completedJobOps.isJobCompleted(TODO_EVENT_QUEUE, job.jobId);
|
|
69371
69403
|
if (alreadyCompleted) {
|
|
69372
|
-
yield*
|
|
69404
|
+
yield* Effect91.log("Job already completed, skipping", {
|
|
69373
69405
|
jobId: job.jobId,
|
|
69374
69406
|
todoIds
|
|
69375
69407
|
});
|
|
69376
69408
|
return;
|
|
69377
69409
|
}
|
|
69378
|
-
yield*
|
|
69410
|
+
yield* Effect91.log("Processing todo-event job", {
|
|
69379
69411
|
jobId: job.jobId,
|
|
69380
69412
|
todoCount: todoIds.length
|
|
69381
69413
|
});
|
|
69382
69414
|
const sqlClient = yield* SqlClient16.SqlClient;
|
|
69383
|
-
const todosWithSummary = yield* sqlClient.withTransaction(
|
|
69415
|
+
const todosWithSummary = yield* sqlClient.withTransaction(Effect91.gen(function* () {
|
|
69384
69416
|
const todos = yield* todoQueries.getTodos(todoIds);
|
|
69385
69417
|
if (todos.length === 0) {
|
|
69386
|
-
yield*
|
|
69418
|
+
yield* Effect91.logWarning("No todos found for IDs - flow-execution may have rolled back", { todoIds });
|
|
69387
69419
|
return [];
|
|
69388
69420
|
}
|
|
69389
69421
|
if (todos.length !== todoIds.length) {
|
|
69390
|
-
yield*
|
|
69422
|
+
yield* Effect91.logWarning("Some todos not found - possible partial rollback", {
|
|
69391
69423
|
expectedCount: todoIds.length,
|
|
69392
69424
|
foundCount: todos.length,
|
|
69393
69425
|
todoIds
|
|
@@ -69398,7 +69430,7 @@ var handleTodoEvent = Effect90.fn("todo-event")((job) => Effect90.gen(function*
|
|
|
69398
69430
|
}));
|
|
69399
69431
|
if (todosWithSummary.length > 0) {
|
|
69400
69432
|
yield* todoPublisher.publishTodosCreated(todosWithSummary);
|
|
69401
|
-
yield*
|
|
69433
|
+
yield* Effect91.log("Published todo changed events", {
|
|
69402
69434
|
count: todosWithSummary.length
|
|
69403
69435
|
});
|
|
69404
69436
|
}
|
|
@@ -69409,27 +69441,27 @@ var todoEventHandler = {
|
|
|
69409
69441
|
handle: handleTodoEvent
|
|
69410
69442
|
};
|
|
69411
69443
|
|
|
69412
|
-
import { Effect as
|
|
69444
|
+
import { Effect as Effect92, Schema as Schema41 } from "effect";
|
|
69413
69445
|
import { SqlClient as SqlClient17 } from "effect/sql";
|
|
69414
|
-
var UploadCompletePayloadSchema =
|
|
69415
|
-
fileId:
|
|
69416
|
-
storePrefix:
|
|
69417
|
-
fileSize:
|
|
69418
|
-
mimeType:
|
|
69446
|
+
var UploadCompletePayloadSchema = Schema41.Struct({
|
|
69447
|
+
fileId: Schema41.String,
|
|
69448
|
+
storePrefix: Schema41.String,
|
|
69449
|
+
fileSize: Schema41.Number,
|
|
69450
|
+
mimeType: Schema41.optional(Schema41.String)
|
|
69419
69451
|
});
|
|
69420
|
-
var handleUploadComplete =
|
|
69452
|
+
var handleUploadComplete = Effect92.fn("upload-complete")((job) => Effect92.gen(function* () {
|
|
69421
69453
|
const { fileId, storePrefix, fileSize, mimeType } = job.payload;
|
|
69422
69454
|
const completedJobOps = yield* CompletedJobOperations;
|
|
69423
69455
|
const fileOps = yield* FileOperations;
|
|
69424
69456
|
const alreadyCompleted = yield* completedJobOps.isJobCompleted(UPLOAD_COMPLETE_QUEUE, job.jobId);
|
|
69425
69457
|
if (alreadyCompleted) {
|
|
69426
|
-
yield*
|
|
69458
|
+
yield* Effect92.log("Job already completed, skipping", {
|
|
69427
69459
|
jobId: job.jobId,
|
|
69428
69460
|
fileId
|
|
69429
69461
|
});
|
|
69430
69462
|
return;
|
|
69431
69463
|
}
|
|
69432
|
-
yield*
|
|
69464
|
+
yield* Effect92.log("Processing upload-complete job", {
|
|
69433
69465
|
jobId: job.jobId,
|
|
69434
69466
|
fileId,
|
|
69435
69467
|
storePrefix,
|
|
@@ -69437,12 +69469,12 @@ var handleUploadComplete = Effect91.fn("upload-complete")((job) => Effect91.gen(
|
|
|
69437
69469
|
mimeType
|
|
69438
69470
|
});
|
|
69439
69471
|
const sqlClient = yield* SqlClient17.SqlClient;
|
|
69440
|
-
yield* sqlClient.withTransaction(
|
|
69472
|
+
yield* sqlClient.withTransaction(Effect92.gen(function* () {
|
|
69441
69473
|
const fileRecord = yield* fileOps.getFileWithStore(fileId);
|
|
69442
69474
|
if (!fileRecord) {
|
|
69443
|
-
yield*
|
|
69475
|
+
yield* Effect92.log("File record not found, deleting orphaned S3 object", { fileId, jobId: job.jobId });
|
|
69444
69476
|
const docStore = yield* DocumentStoreService;
|
|
69445
|
-
yield* docStore.deleteFile(fileId, storePrefix).pipe(
|
|
69477
|
+
yield* docStore.deleteFile(fileId, storePrefix).pipe(Effect92.catch((error) => Effect92.log("Failed to delete S3 object (best-effort)", {
|
|
69446
69478
|
fileId,
|
|
69447
69479
|
error: String(error)
|
|
69448
69480
|
})));
|
|
@@ -69450,7 +69482,7 @@ var handleUploadComplete = Effect91.fn("upload-complete")((job) => Effect91.gen(
|
|
|
69450
69482
|
return;
|
|
69451
69483
|
}
|
|
69452
69484
|
yield* fileOps.markFileUploaded(fileId, fileSize, mimeType);
|
|
69453
|
-
yield*
|
|
69485
|
+
yield* Effect92.log("File marked as uploaded", {
|
|
69454
69486
|
fileId,
|
|
69455
69487
|
fileSize,
|
|
69456
69488
|
mimeType
|
|
@@ -69459,26 +69491,26 @@ var handleUploadComplete = Effect91.fn("upload-complete")((job) => Effect91.gen(
|
|
|
69459
69491
|
}));
|
|
69460
69492
|
}));
|
|
69461
69493
|
|
|
69462
|
-
import { DateTime as
|
|
69463
|
-
var makeWebhookCallbackHost =
|
|
69464
|
-
const services = yield*
|
|
69494
|
+
import { DateTime as DateTime28, Effect as Effect93, Layer as Layer24 } from "effect";
|
|
69495
|
+
var makeWebhookCallbackHost = Effect93.gen(function* () {
|
|
69496
|
+
const services = yield* Effect93.context();
|
|
69465
69497
|
const stepCompletionOps = yield* StepCompletionOperations;
|
|
69466
|
-
const run = (message, effect) =>
|
|
69498
|
+
const run = (message, effect) => Effect93.flatMap(DateTime28.now, (now) => effect.pipe(Effect93.provideService(RequestTime, now), Effect93.provideService(UserDetails, { by: "SYSTEM", id: null }), Effect93.provide(services), Effect93.mapError((cause) => new WebhookCallbackError({ message, cause }))));
|
|
69467
69499
|
const outcome = (applied) => applied ? { _tag: "Applied" } : { _tag: "Ignored" };
|
|
69468
69500
|
return {
|
|
69469
|
-
lookupDeferredTodo: (todoId) => run(`Failed to look up deferred Todo ${todoId}`,
|
|
69501
|
+
lookupDeferredTodo: (todoId) => run(`Failed to look up deferred Todo ${todoId}`, Effect93.gen(function* () {
|
|
69470
69502
|
const todo = yield* stepCompletionOps.queryTodoById(todoId);
|
|
69471
69503
|
if (!todo)
|
|
69472
69504
|
return null;
|
|
69473
69505
|
const state = yield* stepCompletionOps.getProcessStateByTodoId(todoId);
|
|
69474
69506
|
return state ? { state: state.state } : null;
|
|
69475
69507
|
})),
|
|
69476
|
-
completeDeferredTodo: (input) => run(`Failed to complete deferred Todo ${input.todoId}`, completeAsyncSystemStep2(input).pipe(
|
|
69477
|
-
failDeferredTodo: (input) => run(`Failed to fail deferred Todo ${input.todoId}`, failAsyncSystemStep2(input).pipe(
|
|
69478
|
-
applyPublicCompletionCallback: (callback) => run(`Failed to apply public-completion callback ${callback.deliveryId}`, applyPublicCompletionDeliveryCallback(callback).pipe(
|
|
69508
|
+
completeDeferredTodo: (input) => run(`Failed to complete deferred Todo ${input.todoId}`, completeAsyncSystemStep2(input).pipe(Effect93.map(outcome))),
|
|
69509
|
+
failDeferredTodo: (input) => run(`Failed to fail deferred Todo ${input.todoId}`, failAsyncSystemStep2(input).pipe(Effect93.map((result) => outcome(result.didFail)))),
|
|
69510
|
+
applyPublicCompletionCallback: (callback) => run(`Failed to apply public-completion callback ${callback.deliveryId}`, applyPublicCompletionDeliveryCallback(callback).pipe(Effect93.map((result) => outcome(result._tag !== "Ignored"))))
|
|
69479
69511
|
};
|
|
69480
69512
|
});
|
|
69481
|
-
var makeServerPluginWebhookRouter =
|
|
69513
|
+
var makeServerPluginWebhookRouter = Effect93.gen(function* () {
|
|
69482
69514
|
const organisationProvider = yield* OrganisationProvider;
|
|
69483
69515
|
const callbackHost = yield* makeWebhookCallbackHost;
|
|
69484
69516
|
return (request) => {
|
|
@@ -69502,10 +69534,10 @@ var makeNotificationDeliveryConfig = (getFrontendBaseUrl, getEnvironment = () =>
|
|
|
69502
69534
|
getEnvironment
|
|
69503
69535
|
});
|
|
69504
69536
|
|
|
69505
|
-
import { Effect as
|
|
69537
|
+
import { Effect as Effect94, Layer as Layer26 } from "effect";
|
|
69506
69538
|
var LoggingEmailSenderLive = Layer26.succeed(EmailSender, {
|
|
69507
69539
|
loggingOnly: true,
|
|
69508
|
-
send: (message) =>
|
|
69540
|
+
send: (message) => Effect94.logWarning("No EmailSender configured for notification delivery", {
|
|
69509
69541
|
to: message.to,
|
|
69510
69542
|
from: message.from,
|
|
69511
69543
|
subject: message.subject,
|
|
@@ -69516,7 +69548,7 @@ var LoggingEmailSenderLive = Layer26.succeed(EmailSender, {
|
|
|
69516
69548
|
attachmentCount: message.attachments.length
|
|
69517
69549
|
},
|
|
69518
69550
|
...message.tags !== undefined && { tagCount: message.tags.length }
|
|
69519
|
-
}).pipe(
|
|
69551
|
+
}).pipe(Effect94.as(undefined))
|
|
69520
69552
|
});
|
|
69521
69553
|
|
|
69522
69554
|
var mapTodoRowToGraphql2 = (row) => ({
|
|
@@ -69553,7 +69585,7 @@ var buildTodoChangeEvent = (todos) => {
|
|
|
69553
69585
|
};
|
|
69554
69586
|
};
|
|
69555
69587
|
|
|
69556
|
-
import { Context as Context38, Schema as
|
|
69588
|
+
import { Context as Context38, Schema as Schema42 } from "effect";
|
|
69557
69589
|
var labels = {
|
|
69558
69590
|
setup: ["Setting up deployment..."],
|
|
69559
69591
|
runner: ["Starting deployment runner..."],
|
|
@@ -69573,30 +69605,30 @@ var labels = {
|
|
|
69573
69605
|
],
|
|
69574
69606
|
promote: ["Activating new deployment", "Promoting new deployment"]
|
|
69575
69607
|
};
|
|
69576
|
-
var DeploymentPhaseObservation =
|
|
69577
|
-
label:
|
|
69578
|
-
occurredAt:
|
|
69579
|
-
sequence:
|
|
69608
|
+
var DeploymentPhaseObservation = Schema42.Struct({
|
|
69609
|
+
label: Schema42.Literals(Object.values(labels).flat()),
|
|
69610
|
+
occurredAt: Schema42.Int,
|
|
69611
|
+
sequence: Schema42.Int
|
|
69580
69612
|
});
|
|
69581
|
-
var DeploymentPhaseDelivery =
|
|
69613
|
+
var DeploymentPhaseDelivery = Schema42.Struct({
|
|
69582
69614
|
...DeploymentPhaseObservation.fields,
|
|
69583
|
-
todoId:
|
|
69584
|
-
restartAttemptId:
|
|
69615
|
+
todoId: Schema42.String,
|
|
69616
|
+
restartAttemptId: Schema42.NullOr(Schema42.String)
|
|
69585
69617
|
});
|
|
69586
69618
|
class DeploymentPhaseWriter extends Context38.Service()("processfocus:internal-tag/project-accounting/DeploymentPhaseWriter") {
|
|
69587
69619
|
}
|
|
69588
69620
|
|
|
69589
|
-
import { Context as Context39, Schema as
|
|
69621
|
+
import { Context as Context39, Schema as Schema43 } from "effect";
|
|
69590
69622
|
var PROJECT_ACCOUNTING_QUEUE = "project-accounting-event";
|
|
69591
|
-
var DeploymentChange =
|
|
69592
|
-
deployment:
|
|
69593
|
-
projectId:
|
|
69594
|
-
environmentId:
|
|
69623
|
+
var DeploymentChange = Schema43.Struct({
|
|
69624
|
+
deployment: Schema43.Struct({
|
|
69625
|
+
projectId: Schema43.String,
|
|
69626
|
+
environmentId: Schema43.String
|
|
69595
69627
|
})
|
|
69596
69628
|
});
|
|
69597
|
-
var ProjectAccountingChange =
|
|
69598
|
-
|
|
69599
|
-
|
|
69629
|
+
var ProjectAccountingChange = Schema43.Union([
|
|
69630
|
+
Schema43.Struct({ projectId: Schema43.String }),
|
|
69631
|
+
Schema43.Struct({ recipientPrincipalId: Schema43.String }),
|
|
69600
69632
|
DeploymentChange
|
|
69601
69633
|
]);
|
|
69602
69634
|
|
|
@@ -69616,7 +69648,7 @@ var builtInConsumers = {
|
|
|
69616
69648
|
[NOTIFICATION_DELIVERY_QUEUE]: "local job worker",
|
|
69617
69649
|
[PROJECT_ACCOUNTING_QUEUE]: "local GraphQL accounting event publisher"
|
|
69618
69650
|
};
|
|
69619
|
-
var makeLocalQueueServiceLayer = (additionalConsumers) => Layer27.effect(QueueService,
|
|
69651
|
+
var makeLocalQueueServiceLayer = (additionalConsumers) => Layer27.effect(QueueService, Effect95.gen(function* () {
|
|
69620
69652
|
const queue = yield* QueueService;
|
|
69621
69653
|
const consumers = new Map(Object.entries(builtInConsumers));
|
|
69622
69654
|
if (typeof additionalConsumers !== "object" || additionalConsumers === null || Array.isArray(additionalConsumers)) {
|
|
@@ -69635,7 +69667,7 @@ var makeLocalQueueServiceLayer = (additionalConsumers) => Layer27.effect(QueueSe
|
|
|
69635
69667
|
}
|
|
69636
69668
|
consumers.set(name, owner);
|
|
69637
69669
|
}
|
|
69638
|
-
const admit = (name) =>
|
|
69670
|
+
const admit = (name) => Effect95.gen(function* () {
|
|
69639
69671
|
yield* validateQueueName(name);
|
|
69640
69672
|
if (!consumers.has(name)) {
|
|
69641
69673
|
return yield* new EnqueueError({
|
|
@@ -69646,16 +69678,16 @@ var makeLocalQueueServiceLayer = (additionalConsumers) => Layer27.effect(QueueSe
|
|
|
69646
69678
|
});
|
|
69647
69679
|
return QueueService.of({
|
|
69648
69680
|
...queue,
|
|
69649
|
-
enqueue: (name, payload, options) => admit(name).pipe(
|
|
69650
|
-
enqueueWithDelay: (name, payload, delay, options) => admit(name).pipe(
|
|
69681
|
+
enqueue: (name, payload, options) => admit(name).pipe(Effect95.andThen(queue.enqueue(name, payload, options))),
|
|
69682
|
+
enqueueWithDelay: (name, payload, delay, options) => admit(name).pipe(Effect95.andThen(queue.enqueueWithDelay(name, payload, delay, options)))
|
|
69651
69683
|
});
|
|
69652
69684
|
})).pipe(Layer27.provideMerge(SqliteQueueServiceLive));
|
|
69653
|
-
var LocalQueueServiceLive = Layer27.unwrap(
|
|
69685
|
+
var LocalQueueServiceLive = Layer27.unwrap(Effect95.try({
|
|
69654
69686
|
try: () => JSON.parse(process.env["PF_LOCAL_QUEUE_CONSUMERS"] ?? "{}"),
|
|
69655
69687
|
catch: () => new EnqueueError({
|
|
69656
69688
|
queue: "configuration",
|
|
69657
69689
|
message: "PF_LOCAL_QUEUE_CONSUMERS must contain valid JSON mapping queue names to consumer owners"
|
|
69658
69690
|
})
|
|
69659
|
-
}).pipe(
|
|
69691
|
+
}).pipe(Effect95.map(makeLocalQueueServiceLayer)));
|
|
69660
69692
|
|
|
69661
|
-
export { layer, ConditionEvaluator, makeConditionEvaluator, ForEachItemsResolver, makeForEachItemsResolver, OrganisationProvider, OrganisationProviderFromPath, OrganisationProviderFromPathDev, ScheduleEvaluator, makeScheduleEvaluator, SystemStepExecutor, makeSystemStepExecutor, CedarPoliciesProvider, OrgCedarPoliciesProvider, CedarReloadNotifierService, LocalCedarConfigStatic, LocalCedarConfigHotReload, LocalCedarAuthorizationLive, DelegationSessionServiceIsolated, resolveBusinessMetricDimensions, BusinessMetricDimensions, versionInfo, GraphQLError, parse, validate, getOperationAST, execute, subscribe, LocalDelegatedRealtime, AuthConfig, AuthConfigLive, makeDashboardActivityLayer, DraftProcessEvents, TodoSummaryComputation, TodoSummaryComputationLive, ExecutionEvents, ProcessDurationServiceLive, ProcessEvents, DraftProcessExecutionCollectionOpsLive, SlaCalculationServiceLive, ExecutionCollectionOps, ExecutionCollectionOpsLive, ProcessCollectionOps, ProcessCollectionOpsLive, TodoCollectionOps, TodoCollectionOpsLive, TodoEvents, ListExportServiceLive, DynamicSchemaConfig, AppSchemaBuilderLive, Yoga, ResolverRuntime, YogaLive, warnIgnoredCronDeclarations, getEffectiveFrontendBaseUrl, LocalDocumentStoreConfig, generateLocalDocumentStoreToken, LocalDocumentStoreServiceLive, ExecutionFromJobPublishError, ExecutionFromJobPublisher, executionEventHandler, ScheduledFlowNotFoundError, flowExecutionHandler, notificationDeliveryHandler, ProcessFromJobPublishError, ProcessFromJobPublisher, processEventHandler, systemStepExecutionHandler, TodoFromJobPublishError, TodoFromJobPublisher, todoEventHandler, makeServerPluginWebhookRouter, makeNotificationDeliveryConfig, LoggingEmailSenderLive, buildTodoChangeEvent, PROJECT_ACCOUNTING_QUEUE, ProjectAccountingChange, ProjectAccountingEvents, LocalQueueServiceLive };
|
|
69693
|
+
export { layer, normalizePath, ConditionEvaluator, makeConditionEvaluator, ForEachItemsResolver, makeForEachItemsResolver, OrganisationProvider, OrganisationProviderFromPath, OrganisationProviderFromPathDev, ScheduleEvaluator, makeScheduleEvaluator, SystemStepExecutor, makeSystemStepExecutor, CedarPoliciesProvider, OrgCedarPoliciesProvider, CedarReloadNotifierService, LocalCedarConfigStatic, LocalCedarConfigHotReload, LocalCedarAuthorizationLive, DelegationSessionServiceIsolated, resolveBusinessMetricDimensions, BusinessMetricDimensions, versionInfo, GraphQLError, parse, validate, getOperationAST, execute, subscribe, LocalDelegatedRealtime, AuthConfig, AuthConfigLive, makeDashboardActivityLayer, DraftProcessEvents, TodoSummaryComputation, TodoSummaryComputationLive, ExecutionEvents, ProcessDurationServiceLive, ProcessEvents, DraftProcessExecutionCollectionOpsLive, SlaCalculationServiceLive, ExecutionCollectionOps, ExecutionCollectionOpsLive, ProcessCollectionOps, ProcessCollectionOpsLive, TodoCollectionOps, TodoCollectionOpsLive, TodoEvents, ListExportServiceLive, DynamicSchemaConfig, AppSchemaBuilderLive, Yoga, ResolverRuntime, YogaLive, makeMcpOAuthStorageRoute, warnIgnoredCronDeclarations, getEffectiveFrontendBaseUrl, LocalDocumentStoreConfig, generateLocalDocumentStoreToken, LocalDocumentStoreServiceLive, ExecutionFromJobPublishError, ExecutionFromJobPublisher, executionEventHandler, ScheduledFlowNotFoundError, flowExecutionHandler, notificationDeliveryHandler, ProcessFromJobPublishError, ProcessFromJobPublisher, processEventHandler, systemStepExecutionHandler, TodoFromJobPublishError, TodoFromJobPublisher, todoEventHandler, makeServerPluginWebhookRouter, makeNotificationDeliveryConfig, LoggingEmailSenderLive, buildTodoChangeEvent, PROJECT_ACCOUNTING_QUEUE, ProjectAccountingChange, ProjectAccountingEvents, LocalQueueServiceLive };
|