@fungi.computer/braid 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtime/schedules.d.ts +15 -0
- package/dist/runtime/schedules.js +19 -1
- package/package.json +4 -4
|
@@ -35,6 +35,10 @@ export declare function createWorkflowSchedules(options: {
|
|
|
35
35
|
installationId: string;
|
|
36
36
|
workflowId: string;
|
|
37
37
|
triggerId: string;
|
|
38
|
+
cron: {
|
|
39
|
+
expression: string;
|
|
40
|
+
timeZone: string;
|
|
41
|
+
};
|
|
38
42
|
nextDueAt: number;
|
|
39
43
|
state: "active" | "finished" | "paused" | "cancelled";
|
|
40
44
|
lastError: string | null;
|
|
@@ -47,6 +51,17 @@ export declare function createWorkflowSchedules(options: {
|
|
|
47
51
|
} | {
|
|
48
52
|
kind: "paused";
|
|
49
53
|
}>;
|
|
54
|
+
/** Resume from the next occurrence; Almanac owns missed-run and retry semantics. */
|
|
55
|
+
resume(principal: WorkflowTriggerPrincipal, installationId: string, scheduleId: string): Promise<{
|
|
56
|
+
kind: "not_found";
|
|
57
|
+
reason?: never;
|
|
58
|
+
} | {
|
|
59
|
+
kind: "refused";
|
|
60
|
+
reason: string;
|
|
61
|
+
} | {
|
|
62
|
+
kind: "resumed";
|
|
63
|
+
reason?: never;
|
|
64
|
+
}>;
|
|
50
65
|
disarm(principal: WorkflowTriggerPrincipal, installationId: string, scheduleId: string): Promise<{
|
|
51
66
|
kind: "not_found";
|
|
52
67
|
} | {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
import * as Result from "effect/Result";
|
|
3
|
-
import { afterAdmitted, afterRefused, isDue, nextOccurrence, occurrenceKey, paused, cancelled, } from "@fungi.computer/almanac";
|
|
3
|
+
import { afterAdmitted, afterRefused, isDue, nextOccurrence, occurrenceKey, paused, resumed, cancelled, } from "@fungi.computer/almanac";
|
|
4
4
|
import { canonicalJson, contentDigest } from "../index.js";
|
|
5
5
|
import { armedWorkflowTriggerSchema, workflowArmerKey, workflowTriggerControlledBy, workflowTriggerPrincipalMember, } from "./trigger-owner.js";
|
|
6
6
|
import { storedTriggerRows } from "./stored-trigger-rows.js";
|
|
@@ -106,6 +106,7 @@ export function createWorkflowSchedules(options) {
|
|
|
106
106
|
installationId: record.installationId,
|
|
107
107
|
workflowId: record.workflowId,
|
|
108
108
|
triggerId: record.triggerId,
|
|
109
|
+
cron: record.cron,
|
|
109
110
|
nextDueAt: record.nextDueAt,
|
|
110
111
|
state: record.state,
|
|
111
112
|
lastError: record.lastError,
|
|
@@ -128,6 +129,23 @@ export function createWorkflowSchedules(options) {
|
|
|
128
129
|
await options.wake(nextWake());
|
|
129
130
|
return { kind: "paused" };
|
|
130
131
|
},
|
|
132
|
+
/** Resume from the next occurrence; Almanac owns missed-run and retry semantics. */
|
|
133
|
+
async resume(principal, installationId, scheduleId) {
|
|
134
|
+
await options.authorize(workflowTriggerPrincipalMember(principal), installationId);
|
|
135
|
+
const record = rows.read(scheduleId);
|
|
136
|
+
if (record?.installationId !== installationId ||
|
|
137
|
+
!workflowTriggerControlledBy(principal, record) ||
|
|
138
|
+
record.state !== "paused")
|
|
139
|
+
return { kind: "not_found" };
|
|
140
|
+
const next = resumed(record, options.now());
|
|
141
|
+
if (Result.isFailure(next))
|
|
142
|
+
return { kind: "refused", reason: next.failure.message };
|
|
143
|
+
await options.commit(() => {
|
|
144
|
+
store({ ...next.success, retryAt: null });
|
|
145
|
+
});
|
|
146
|
+
await options.wake(nextWake());
|
|
147
|
+
return { kind: "resumed" };
|
|
148
|
+
},
|
|
131
149
|
async disarm(principal, installationId, scheduleId) {
|
|
132
150
|
const memberId = workflowTriggerPrincipalMember(principal);
|
|
133
151
|
await options.authorize(memberId, installationId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/braid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Pure versioned Workflow graph validation and content-addressed compilation",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@cfworker/json-schema": "4.1.1",
|
|
32
32
|
"@fungi.computer/almanac": "0.2.0",
|
|
33
|
-
"@fungi.computer/mycelium": "0.3.
|
|
33
|
+
"@fungi.computer/mycelium": "0.3.2",
|
|
34
34
|
"effect": "4.0.2",
|
|
35
35
|
"jsonpointer": "5.0.1",
|
|
36
36
|
"mustache": "4.2.0",
|
|
37
37
|
"zod": "4.4.3",
|
|
38
|
-
"@fungi.computer/agar": "0.6.
|
|
38
|
+
"@fungi.computer/agar": "0.6.1",
|
|
39
39
|
"@fungi.computer/gills": "0.2.0",
|
|
40
40
|
"@fungi.computer/watchdog": "0.1.0",
|
|
41
|
-
"@fungi.computer/puffball": "0.
|
|
41
|
+
"@fungi.computer/puffball": "0.4.0",
|
|
42
42
|
"@fungi.computer/cairn": "0.1.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|