@shware/workflow 3.2.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -29
- package/dist/apns.cjs +113 -26
- package/dist/apns.cjs.map +1 -1
- package/dist/apns.d.cts +52 -6
- package/dist/apns.d.cts.map +1 -1
- package/dist/apns.d.mts +52 -6
- package/dist/apns.d.mts.map +1 -1
- package/dist/apns.mjs +111 -27
- package/dist/apns.mjs.map +1 -1
- package/dist/aws/engine-step.cjs +5 -5
- package/dist/aws/engine-step.cjs.map +1 -1
- package/dist/aws/engine-step.d.cts +8 -2
- package/dist/aws/engine-step.d.cts.map +1 -1
- package/dist/aws/engine-step.d.mts +8 -2
- package/dist/aws/engine-step.d.mts.map +1 -1
- package/dist/aws/engine-step.mjs +5 -5
- package/dist/aws/engine-step.mjs.map +1 -1
- package/dist/aws/index.cjs +47 -6
- package/dist/aws/index.cjs.map +1 -1
- package/dist/aws/index.d.cts +2 -2
- package/dist/aws/index.d.cts.map +1 -1
- package/dist/aws/index.d.mts +2 -2
- package/dist/aws/index.d.mts.map +1 -1
- package/dist/aws/index.mjs +47 -6
- package/dist/aws/index.mjs.map +1 -1
- package/dist/aws/instances.cjs +29 -6
- package/dist/aws/instances.cjs.map +1 -1
- package/dist/aws/instances.d.cts +11 -1
- package/dist/aws/instances.d.cts.map +1 -1
- package/dist/aws/instances.d.mts +11 -1
- package/dist/aws/instances.d.mts.map +1 -1
- package/dist/aws/instances.mjs +27 -4
- package/dist/aws/instances.mjs.map +1 -1
- package/dist/client.cjs +4 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.mts +2 -2
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +4 -1
- package/dist/client.mjs.map +1 -1
- package/dist/cloudflare/bindings.cjs +28 -25
- package/dist/cloudflare/bindings.cjs.map +1 -1
- package/dist/cloudflare/bindings.d.cts +17 -129
- package/dist/cloudflare/bindings.d.cts.map +1 -1
- package/dist/cloudflare/bindings.d.mts +17 -129
- package/dist/cloudflare/bindings.d.mts.map +1 -1
- package/dist/cloudflare/bindings.mjs +28 -23
- package/dist/cloudflare/bindings.mjs.map +1 -1
- package/dist/cloudflare/d1-env.cjs +6 -6
- package/dist/cloudflare/d1-env.cjs.map +1 -1
- package/dist/cloudflare/d1-env.d.cts +5 -5
- package/dist/cloudflare/d1-env.d.mts +5 -5
- package/dist/cloudflare/d1-env.mjs +6 -6
- package/dist/cloudflare/d1-env.mjs.map +1 -1
- package/dist/cloudflare/index.cjs +28 -18
- package/dist/cloudflare/index.d.cts +8 -4
- package/dist/cloudflare/index.d.mts +8 -4
- package/dist/cloudflare/index.mjs +9 -5
- package/dist/cloudflare/runner.cjs +29 -14
- package/dist/cloudflare/runner.cjs.map +1 -1
- package/dist/cloudflare/runner.d.cts +9 -2
- package/dist/cloudflare/runner.d.cts.map +1 -1
- package/dist/cloudflare/runner.d.mts +9 -2
- package/dist/cloudflare/runner.d.mts.map +1 -1
- package/dist/cloudflare/runner.mjs +28 -13
- package/dist/cloudflare/runner.mjs.map +1 -1
- package/dist/cloudflare/schema.sql +27 -6
- package/dist/cloudflare/worker.cjs +19 -9
- package/dist/cloudflare/worker.cjs.map +1 -1
- package/dist/cloudflare/worker.d.cts +2 -2
- package/dist/cloudflare/worker.d.cts.map +1 -1
- package/dist/cloudflare/worker.d.mts +2 -2
- package/dist/cloudflare/worker.d.mts.map +1 -1
- package/dist/cloudflare/worker.mjs +19 -9
- package/dist/cloudflare/worker.mjs.map +1 -1
- package/dist/config.cjs +21 -5
- package/dist/config.cjs.map +1 -1
- package/dist/config.mjs +21 -5
- package/dist/config.mjs.map +1 -1
- package/dist/dsl/action.cjs +3 -6
- package/dist/dsl/action.cjs.map +1 -1
- package/dist/dsl/action.d.cts +12 -11
- package/dist/dsl/action.d.cts.map +1 -1
- package/dist/dsl/action.d.mts +12 -11
- package/dist/dsl/action.d.mts.map +1 -1
- package/dist/dsl/action.mjs +3 -6
- package/dist/dsl/action.mjs.map +1 -1
- package/dist/dsl/bundle.cjs +35 -31
- package/dist/dsl/bundle.cjs.map +1 -1
- package/dist/dsl/bundle.d.cts.map +1 -1
- package/dist/dsl/bundle.d.mts.map +1 -1
- package/dist/dsl/bundle.mjs +35 -31
- package/dist/dsl/bundle.mjs.map +1 -1
- package/dist/dsl/condition.cjs +13 -1
- package/dist/dsl/condition.cjs.map +1 -1
- package/dist/dsl/condition.d.cts +9 -1
- package/dist/dsl/condition.d.cts.map +1 -1
- package/dist/dsl/condition.d.mts +9 -1
- package/dist/dsl/condition.d.mts.map +1 -1
- package/dist/dsl/condition.mjs +13 -2
- package/dist/dsl/condition.mjs.map +1 -1
- package/dist/dsl/flow.cjs +33 -11
- package/dist/dsl/flow.cjs.map +1 -1
- package/dist/dsl/flow.d.cts +9 -1
- package/dist/dsl/flow.d.cts.map +1 -1
- package/dist/dsl/flow.d.mts +9 -1
- package/dist/dsl/flow.d.mts.map +1 -1
- package/dist/dsl/flow.mjs +34 -13
- package/dist/dsl/flow.mjs.map +1 -1
- package/dist/dsl/workflow.cjs +2 -3
- package/dist/dsl/workflow.cjs.map +1 -1
- package/dist/dsl/workflow.d.cts.map +1 -1
- package/dist/dsl/workflow.d.mts.map +1 -1
- package/dist/dsl/workflow.mjs +3 -4
- package/dist/dsl/workflow.mjs.map +1 -1
- package/dist/email-sender.cjs +24 -0
- package/dist/email-sender.cjs.map +1 -1
- package/dist/email-sender.d.cts +18 -0
- package/dist/email-sender.d.cts.map +1 -1
- package/dist/email-sender.d.mts +18 -0
- package/dist/email-sender.d.mts.map +1 -1
- package/dist/email-sender.mjs +24 -1
- package/dist/email-sender.mjs.map +1 -1
- package/dist/engine/actions.cjs +1 -8
- package/dist/engine/actions.cjs.map +1 -1
- package/dist/engine/actions.d.cts +1 -12
- package/dist/engine/actions.d.cts.map +1 -1
- package/dist/engine/actions.d.mts +1 -12
- package/dist/engine/actions.d.mts.map +1 -1
- package/dist/engine/actions.mjs +1 -8
- package/dist/engine/actions.mjs.map +1 -1
- package/dist/engine/condition.cjs +25 -5
- package/dist/engine/condition.cjs.map +1 -1
- package/dist/engine/condition.d.cts +12 -3
- package/dist/engine/condition.d.cts.map +1 -1
- package/dist/engine/condition.d.mts +12 -3
- package/dist/engine/condition.d.mts.map +1 -1
- package/dist/engine/condition.mjs +25 -6
- package/dist/engine/condition.mjs.map +1 -1
- package/dist/engine/index.cjs +3 -0
- package/dist/engine/index.d.cts +5 -5
- package/dist/engine/index.d.mts +5 -5
- package/dist/engine/index.mjs +4 -4
- package/dist/engine/interpreter.cjs +27 -20
- package/dist/engine/interpreter.cjs.map +1 -1
- package/dist/engine/interpreter.d.cts.map +1 -1
- package/dist/engine/interpreter.d.mts.map +1 -1
- package/dist/engine/interpreter.mjs +27 -20
- package/dist/engine/interpreter.mjs.map +1 -1
- package/dist/engine/ports.d.cts +21 -6
- package/dist/engine/ports.d.cts.map +1 -1
- package/dist/engine/ports.d.mts +21 -6
- package/dist/engine/ports.d.mts.map +1 -1
- package/dist/engine/retry.cjs +13 -0
- package/dist/engine/retry.cjs.map +1 -1
- package/dist/engine/retry.d.cts +12 -0
- package/dist/engine/retry.d.cts.map +1 -1
- package/dist/engine/retry.d.mts +12 -0
- package/dist/engine/retry.d.mts.map +1 -1
- package/dist/engine/retry.mjs +13 -1
- package/dist/engine/retry.mjs.map +1 -1
- package/dist/engine/time-scale.cjs +90 -15
- package/dist/engine/time-scale.cjs.map +1 -1
- package/dist/engine/time-scale.d.cts +9 -6
- package/dist/engine/time-scale.d.cts.map +1 -1
- package/dist/engine/time-scale.d.mts +9 -6
- package/dist/engine/time-scale.d.mts.map +1 -1
- package/dist/engine/time-scale.mjs +90 -16
- package/dist/engine/time-scale.mjs.map +1 -1
- package/dist/fcm.cjs +111 -38
- package/dist/fcm.cjs.map +1 -1
- package/dist/fcm.d.cts +45 -5
- package/dist/fcm.d.cts.map +1 -1
- package/dist/fcm.d.mts +45 -5
- package/dist/fcm.d.mts.map +1 -1
- package/dist/fcm.mjs +110 -39
- package/dist/fcm.mjs.map +1 -1
- package/dist/hash.cjs +6 -6
- package/dist/hash.cjs.map +1 -1
- package/dist/hash.mjs +6 -6
- package/dist/hash.mjs.map +1 -1
- package/dist/host/auth.cjs +49 -0
- package/dist/host/auth.cjs.map +1 -0
- package/dist/host/auth.d.cts +21 -0
- package/dist/host/auth.d.cts.map +1 -0
- package/dist/host/auth.d.mts +21 -0
- package/dist/host/auth.d.mts.map +1 -0
- package/dist/host/auth.mjs +47 -0
- package/dist/host/auth.mjs.map +1 -0
- package/dist/host/channels.cjs +118 -40
- package/dist/host/channels.cjs.map +1 -1
- package/dist/host/channels.d.cts +27 -1
- package/dist/host/channels.d.cts.map +1 -1
- package/dist/host/channels.d.mts +27 -1
- package/dist/host/channels.d.mts.map +1 -1
- package/dist/host/channels.mjs +121 -44
- package/dist/host/channels.mjs.map +1 -1
- package/dist/host/execute.cjs +14 -2
- package/dist/host/execute.cjs.map +1 -1
- package/dist/host/execute.d.cts +4 -4
- package/dist/host/execute.d.cts.map +1 -1
- package/dist/host/execute.d.mts +4 -4
- package/dist/host/execute.d.mts.map +1 -1
- package/dist/host/execute.mjs +13 -1
- package/dist/host/execute.mjs.map +1 -1
- package/dist/host/fresh-read.cjs +30 -0
- package/dist/host/fresh-read.cjs.map +1 -0
- package/dist/host/fresh-read.d.cts +18 -0
- package/dist/host/fresh-read.d.cts.map +1 -0
- package/dist/host/fresh-read.d.mts +18 -0
- package/dist/host/fresh-read.d.mts.map +1 -0
- package/dist/host/fresh-read.mjs +29 -0
- package/dist/host/fresh-read.mjs.map +1 -0
- package/dist/host/http.cjs +321 -0
- package/dist/host/http.cjs.map +1 -0
- package/dist/host/http.d.cts +54 -0
- package/dist/host/http.d.cts.map +1 -0
- package/dist/host/http.d.mts +54 -0
- package/dist/host/http.d.mts.map +1 -0
- package/dist/host/http.mjs +317 -0
- package/dist/host/http.mjs.map +1 -0
- package/dist/host/{router.cjs → ingest.cjs} +147 -175
- package/dist/host/ingest.cjs.map +1 -0
- package/dist/host/{router.d.cts → ingest.d.cts} +48 -30
- package/dist/host/ingest.d.cts.map +1 -0
- package/dist/host/{router.d.mts → ingest.d.mts} +48 -30
- package/dist/host/ingest.d.mts.map +1 -0
- package/dist/host/{router.mjs → ingest.mjs} +144 -173
- package/dist/host/ingest.mjs.map +1 -0
- package/dist/host/journey-host.cjs +65 -93
- package/dist/host/journey-host.cjs.map +1 -1
- package/dist/host/journey-host.d.cts +19 -26
- package/dist/host/journey-host.d.cts.map +1 -1
- package/dist/host/journey-host.d.mts +19 -26
- package/dist/host/journey-host.d.mts.map +1 -1
- package/dist/host/journey-host.mjs +65 -93
- package/dist/host/journey-host.mjs.map +1 -1
- package/dist/host/platform.cjs +21 -0
- package/dist/host/platform.cjs.map +1 -0
- package/dist/host/platform.d.cts +126 -0
- package/dist/host/platform.d.cts.map +1 -0
- package/dist/host/platform.d.mts +126 -0
- package/dist/host/platform.d.mts.map +1 -0
- package/dist/host/platform.mjs +19 -0
- package/dist/host/platform.mjs.map +1 -0
- package/dist/host/senders.cjs +18 -9
- package/dist/host/senders.cjs.map +1 -1
- package/dist/host/senders.d.cts +9 -4
- package/dist/host/senders.d.cts.map +1 -1
- package/dist/host/senders.d.mts +9 -4
- package/dist/host/senders.d.mts.map +1 -1
- package/dist/host/senders.mjs +18 -9
- package/dist/host/senders.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/ir.cjs +5 -7
- package/dist/ir.cjs.map +1 -1
- package/dist/ir.d.cts +3 -12
- package/dist/ir.d.cts.map +1 -1
- package/dist/ir.d.mts +3 -12
- package/dist/ir.d.mts.map +1 -1
- package/dist/ir.mjs +5 -7
- package/dist/ir.mjs.map +1 -1
- package/dist/plan.cjs +27 -33
- package/dist/plan.cjs.map +1 -1
- package/dist/plan.d.cts +1 -1
- package/dist/plan.d.cts.map +1 -1
- package/dist/plan.d.mts +1 -1
- package/dist/plan.d.mts.map +1 -1
- package/dist/plan.mjs +27 -33
- package/dist/plan.mjs.map +1 -1
- package/dist/reporting/observer.cjs +1 -0
- package/dist/reporting/observer.cjs.map +1 -1
- package/dist/reporting/observer.mjs +1 -0
- package/dist/reporting/observer.mjs.map +1 -1
- package/dist/reporting/tracking.cjs +19 -4
- package/dist/reporting/tracking.cjs.map +1 -1
- package/dist/reporting/tracking.d.cts +13 -11
- package/dist/reporting/tracking.d.cts.map +1 -1
- package/dist/reporting/tracking.d.mts +13 -11
- package/dist/reporting/tracking.d.mts.map +1 -1
- package/dist/reporting/tracking.mjs +19 -4
- package/dist/reporting/tracking.mjs.map +1 -1
- package/dist/store/d1.cjs +88 -29
- package/dist/store/d1.cjs.map +1 -1
- package/dist/store/d1.d.cts +29 -11
- package/dist/store/d1.d.cts.map +1 -1
- package/dist/store/d1.d.mts +29 -11
- package/dist/store/d1.d.mts.map +1 -1
- package/dist/store/d1.mjs +88 -29
- package/dist/store/d1.mjs.map +1 -1
- package/dist/store/erasure.cjs +22 -0
- package/dist/store/erasure.cjs.map +1 -0
- package/dist/store/erasure.d.cts +18 -0
- package/dist/store/erasure.d.cts.map +1 -0
- package/dist/store/erasure.d.mts +18 -0
- package/dist/store/erasure.d.mts.map +1 -0
- package/dist/store/erasure.mjs +21 -0
- package/dist/store/erasure.mjs.map +1 -0
- package/dist/store/index.cjs +2 -0
- package/dist/store/index.cjs.map +1 -1
- package/dist/store/index.d.cts +67 -13
- package/dist/store/index.d.cts.map +1 -1
- package/dist/store/index.d.mts +67 -13
- package/dist/store/index.d.mts.map +1 -1
- package/dist/store/index.mjs +2 -1
- package/dist/store/index.mjs.map +1 -1
- package/dist/store/postgres-reporting.cjs +125 -62
- package/dist/store/postgres-reporting.cjs.map +1 -1
- package/dist/store/postgres-reporting.d.cts +30 -2
- package/dist/store/postgres-reporting.d.cts.map +1 -1
- package/dist/store/postgres-reporting.d.mts +30 -2
- package/dist/store/postgres-reporting.d.mts.map +1 -1
- package/dist/store/postgres-reporting.mjs +125 -62
- package/dist/store/postgres-reporting.mjs.map +1 -1
- package/dist/store/postgres.cjs +179 -60
- package/dist/store/postgres.cjs.map +1 -1
- package/dist/store/postgres.d.cts +44 -7
- package/dist/store/postgres.d.cts.map +1 -1
- package/dist/store/postgres.d.mts +44 -7
- package/dist/store/postgres.d.mts.map +1 -1
- package/dist/store/postgres.mjs +179 -60
- package/dist/store/postgres.mjs.map +1 -1
- package/dist/store/tables.cjs +7 -5
- package/dist/store/tables.cjs.map +1 -1
- package/dist/store/tables.d.cts.map +1 -1
- package/dist/store/tables.d.mts.map +1 -1
- package/dist/store/tables.mjs +7 -5
- package/dist/store/tables.mjs.map +1 -1
- package/dist/store/user-lock.cjs +43 -0
- package/dist/store/user-lock.cjs.map +1 -0
- package/dist/store/user-lock.d.cts +32 -0
- package/dist/store/user-lock.d.cts.map +1 -0
- package/dist/store/user-lock.d.mts +32 -0
- package/dist/store/user-lock.d.mts.map +1 -0
- package/dist/store/user-lock.mjs +40 -0
- package/dist/store/user-lock.mjs.map +1 -0
- package/dist/transports/cloudflare-email.cjs +3 -2
- package/dist/transports/cloudflare-email.cjs.map +1 -1
- package/dist/transports/cloudflare-email.mjs +3 -2
- package/dist/transports/cloudflare-email.mjs.map +1 -1
- package/dist/transports/ses.cjs +52 -7
- package/dist/transports/ses.cjs.map +1 -1
- package/dist/transports/ses.d.cts +9 -1
- package/dist/transports/ses.d.cts.map +1 -1
- package/dist/transports/ses.d.mts +9 -1
- package/dist/transports/ses.d.mts.map +1 -1
- package/dist/transports/ses.mjs +52 -8
- package/dist/transports/ses.mjs.map +1 -1
- package/dist/webpush.cjs +133 -47
- package/dist/webpush.cjs.map +1 -1
- package/dist/webpush.d.cts +49 -8
- package/dist/webpush.d.cts.map +1 -1
- package/dist/webpush.d.mts +49 -8
- package/dist/webpush.d.mts.map +1 -1
- package/dist/webpush.mjs +130 -47
- package/dist/webpush.mjs.map +1 -1
- package/package.json +1 -1
- package/src/cloudflare/schema.sql +27 -6
- package/dist/host/router.cjs.map +0 -1
- package/dist/host/router.d.cts.map +0 -1
- package/dist/host/router.d.mts.map +0 -1
- package/dist/host/router.mjs.map +0 -1
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { TriggerIR } from "../ir.cjs";
|
|
2
|
-
import { JourneyEnv } from "
|
|
2
|
+
import { JourneyEnv } from "./platform.cjs";
|
|
3
3
|
import { BundleVersion, JourneyStore, ProfileProps } from "../store/index.cjs";
|
|
4
|
-
|
|
5
|
-
//#region src/host/router.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Ingest router. An incoming event does four things: it is stored, it wakes
|
|
8
|
-
* waiting instances, it is matched against event triggers, and it re-evaluates
|
|
9
|
-
* segment-trigger membership. Plus /deploy (persist a bundle) and /identify
|
|
10
|
-
* (merge a profile — which wakes property-condition waits via
|
|
11
|
-
* PROFILE_UPDATED_EVENT and re-evaluates segment triggers too).
|
|
12
|
-
*
|
|
13
|
-
* Storage goes through a JourneyStore; the `store` argument defaults to the
|
|
14
|
-
* D1 + KV store built from the env's bindings, so a Worker that only has those
|
|
15
|
-
* calls these functions exactly as before.
|
|
16
|
-
*/
|
|
4
|
+
//#region src/host/ingest.d.ts
|
|
17
5
|
export interface IngestInput {
|
|
18
6
|
userId: string;
|
|
19
7
|
event: string;
|
|
@@ -44,6 +32,12 @@ export interface IngestResult {
|
|
|
44
32
|
started: string[];
|
|
45
33
|
}
|
|
46
34
|
export declare function ingestEvent(env: JourneyEnv, input: IngestInput, store?: JourneyStore): Promise<IngestResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Wake every instance of the user waiting on any of `events`, once each: an instance subscribed
|
|
37
|
+
* to several of them (a wait on two profile properties, patched together) gets one wake-up, and
|
|
38
|
+
* the payload names the first event it matched.
|
|
39
|
+
*/
|
|
40
|
+
export declare function wakeSubscribers(env: JourneyEnv, store: JourneyStore, userId: string, events: readonly string[]): Promise<number>;
|
|
47
41
|
/**
|
|
48
42
|
* Segment-entry triggers, maintained lazily: on each ingest/identify for a
|
|
49
43
|
* user, re-evaluate every trigger-routed segment for that user and act on the
|
|
@@ -63,12 +57,43 @@ export interface SweepResult {
|
|
|
63
57
|
size: number;
|
|
64
58
|
}[];
|
|
65
59
|
}
|
|
60
|
+
/** How many users one sweep page evaluates: a unit of resumable work (AWS checkpoints each). */
|
|
61
|
+
export declare const SWEEP_PAGE_SIZE = 500;
|
|
62
|
+
/**
|
|
63
|
+
* What the sweep does before it looks at any user: the runtime's own upkeep (AWS: unconfirmed
|
|
64
|
+
* starts, executions that ended unseen) and the erasures left unfinished (an instance would not
|
|
65
|
+
* stop). A failure of either is logged, never fatal: the pages still run. Users whose erasure is
|
|
66
|
+
* still pending afterwards are skipped by every page (`sweepSegmentsPaged`).
|
|
67
|
+
*/
|
|
68
|
+
export declare function sweepMaintenance(env: JourneyEnv, store: JourneyStore): Promise<void>;
|
|
69
|
+
export interface SweepPage {
|
|
70
|
+
/** Users evaluated on this page (those being erased are listed but skipped). */
|
|
71
|
+
users: number;
|
|
72
|
+
/** Journeys the segments' entries started on this page. */
|
|
73
|
+
started: string[];
|
|
74
|
+
/** The last user id listed, to resume past (`after`); undefined when the page was empty. */
|
|
75
|
+
lastUserId?: string | undefined;
|
|
76
|
+
/** Whether the page was full, so another may follow. */
|
|
77
|
+
more: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* One page of the sweep: the users after `after` (ascending, at most `limit`), every deployed
|
|
81
|
+
* segment evaluated for each. The pages are what makes the sweep resumable — a host whose run
|
|
82
|
+
* can be cut short (a Lambda timeout) checkpoints each one and replays the checkpointed pages
|
|
83
|
+
* instead of starting over; `sweepSegments` is the plain loop over them.
|
|
84
|
+
*/
|
|
85
|
+
export declare function sweepSegmentsPaged(env: JourneyEnv, store: JourneyStore, page: {
|
|
86
|
+
after?: string | undefined;
|
|
87
|
+
limit?: number | undefined;
|
|
88
|
+
now?: number | undefined;
|
|
89
|
+
}): Promise<SweepPage>;
|
|
66
90
|
/**
|
|
67
91
|
* The scheduled sweep: every deployed segment evaluated for every known user — the evaluator a
|
|
68
92
|
* journey's conditions run on, so a member is exactly who a journey would see in it. Membership
|
|
69
93
|
* follows (joiners keep the time they joined, leavers are removed), segment triggers start the
|
|
70
94
|
* journeys of whoever entered by the clock alone, and the store records each segment's size.
|
|
71
|
-
* It walks users
|
|
95
|
+
* It walks users page by page (`sweepSegmentsPaged`): fine for thousands, a large audience wants
|
|
96
|
+
* SQL-side evaluation.
|
|
72
97
|
*/
|
|
73
98
|
export declare function sweepSegments(env: JourneyEnv, store: JourneyStore, now?: number): Promise<SweepResult>;
|
|
74
99
|
export interface IdentifyResult {
|
|
@@ -99,9 +124,13 @@ export declare function registerDevice(env: JourneyEnv, device: DeviceRegistrati
|
|
|
99
124
|
woke: number;
|
|
100
125
|
}>;
|
|
101
126
|
/**
|
|
102
|
-
* Forget a user (a deleted account): the
|
|
103
|
-
*
|
|
104
|
-
*
|
|
127
|
+
* Forget a user (a deleted account): the tombstone is committed first, then the erasure carried
|
|
128
|
+
* out. `erased: true` means every admitted runner of theirs was confirmed stopped, the entries
|
|
129
|
+
* never admitted can never run, and the data is deleted — for good, with no time window and no
|
|
130
|
+
* second pass: the tombstone commits under the user's lock, which every write about the user
|
|
131
|
+
* also takes, so nothing of theirs can land after it. An admitted instance that will not stop
|
|
132
|
+
* leaves it pending — nothing erased yet — and the scheduled sweep retries it; `erased: false`
|
|
133
|
+
* says so. A user already erased answers `erased: true` again, with nothing to do.
|
|
105
134
|
*/
|
|
106
135
|
export declare function forgetUser(env: JourneyEnv, userId: string, store?: JourneyStore, now?: number): Promise<{
|
|
107
136
|
ok: true;
|
|
@@ -157,16 +186,5 @@ export declare class BundleIntegrityError extends Error {
|
|
|
157
186
|
* compiled into it; without one it is forced, whatever is live.
|
|
158
187
|
*/
|
|
159
188
|
export declare function deployBundle(env: JourneyEnv, bundle: unknown, store?: JourneyStore, version?: BundleVersion): Promise<DeployResult>;
|
|
160
|
-
/**
|
|
161
|
-
* How the ingest API applies a contract: 'enforce' refuses an invalid event or
|
|
162
|
-
* patch with a 400 before anything is stored, woken or started; 'report' logs
|
|
163
|
-
* the issues (event id, name, field paths — never the payload) and accepts it,
|
|
164
|
-
* for checking real producers before turning enforcement on.
|
|
165
|
-
*/
|
|
166
|
-
export interface IngestValidation {
|
|
167
|
-
contract?: Contract | undefined;
|
|
168
|
-
mode?: 'enforce' | 'report' | undefined;
|
|
169
|
-
}
|
|
170
|
-
export declare function handleRequest(request: Request, env: JourneyEnv, store?: JourneyStore, validation?: IngestValidation): Promise<Response>;
|
|
171
189
|
//#endregion
|
|
172
|
-
//# sourceMappingURL=
|
|
190
|
+
//# sourceMappingURL=ingest.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingest.d.cts","names":[],"sources":["../../src/host/ingest.ts"],"mappings":";;;;iBA+CiB;EACf;EACA;EACA,UAAU;EACV;;;;;;;;;;;;;;;EAeA;;iBAGe;;EAEf;;EAEA;EACA;EACA;;wBAGoB,YACpB,KAAK,YACL,OAAO,aACP,QAAO,eACN,QAAQ;;;;;;wBAwCW,gBACpB,KAAK,YACL,OAAO,cACP,gBACA,4BACC;;;;;;;;;wBA0EmB,uBACpB,KAAK,YACL,OAAO,cACP,gBACA,aACC;iBA0Fc;EACf;;EAEA;;EAEA;IAAS;IAAiB;;;;qBAIf;;;;;;;wBAQS,iBAAiB,KAAK,YAAY,OAAO,eAAe;iBAkB7D;;EAEf;;EAEA;;EAEA;;EAEA;;;;;;;;wBASoB,mBACpB,KAAK,YACL,OAAO,cACP;EAAQ;EAA4B;EAA4B;IAC/D,QAAQ;;;;;;;;;wBAsCW,cACpB,KAAK,YACL,OAAO,cACP,eACC,QAAQ;iBAgFM;EACf;EACA,OAAO;EACP;EACA;;;;;;;wBAQoB,aACpB,KAAK,YACL,gBACA,OAAO,cACP,QAAO,eACN,QAAQ;iBAiBM;EACf;EACA;EACA;EACA;;;;;;;wBAQoB,eACpB,KAAK,YACL,QAAQ,oBACR,QAAO,eACN;EAAU;EAAU;;;;;;;;;;;wBA2FD,WACpB,KAAK,YACL,gBACA,QAAO,cACP,eACC;EAAU;EAAU;EAAiB;;;;;;;wBAUlB,aACpB,KAAK,YACL,eACA,QAAO,eACN;EAAU;EAAU;;;wBAQD,aACpB,KAAK,YACL,eACA,QAAO,eACN;EAAU;EAAU;;iBASN;EACf;;;;;;;;EAQA;IAAY;IAAkB,SAAS;;;;;;EAKvC;;;qBAIW,8BAA8B;WACvB;EAClB;;;qBAMW,6BAA6B;EACxC,YAAY;;;;;;;;wBA8CQ,aACpB,KAAK,YACL,iBACA,QAAO,cACP,UAAU,gBACT,QAAQ"}
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { TriggerIR } from "../ir.mjs";
|
|
2
|
-
import { JourneyEnv } from "
|
|
2
|
+
import { JourneyEnv } from "./platform.mjs";
|
|
3
3
|
import { BundleVersion, JourneyStore, ProfileProps } from "../store/index.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/host/router.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Ingest router. An incoming event does four things: it is stored, it wakes
|
|
8
|
-
* waiting instances, it is matched against event triggers, and it re-evaluates
|
|
9
|
-
* segment-trigger membership. Plus /deploy (persist a bundle) and /identify
|
|
10
|
-
* (merge a profile — which wakes property-condition waits via
|
|
11
|
-
* PROFILE_UPDATED_EVENT and re-evaluates segment triggers too).
|
|
12
|
-
*
|
|
13
|
-
* Storage goes through a JourneyStore; the `store` argument defaults to the
|
|
14
|
-
* D1 + KV store built from the env's bindings, so a Worker that only has those
|
|
15
|
-
* calls these functions exactly as before.
|
|
16
|
-
*/
|
|
4
|
+
//#region src/host/ingest.d.ts
|
|
17
5
|
export interface IngestInput {
|
|
18
6
|
userId: string;
|
|
19
7
|
event: string;
|
|
@@ -44,6 +32,12 @@ export interface IngestResult {
|
|
|
44
32
|
started: string[];
|
|
45
33
|
}
|
|
46
34
|
export declare function ingestEvent(env: JourneyEnv, input: IngestInput, store?: JourneyStore): Promise<IngestResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Wake every instance of the user waiting on any of `events`, once each: an instance subscribed
|
|
37
|
+
* to several of them (a wait on two profile properties, patched together) gets one wake-up, and
|
|
38
|
+
* the payload names the first event it matched.
|
|
39
|
+
*/
|
|
40
|
+
export declare function wakeSubscribers(env: JourneyEnv, store: JourneyStore, userId: string, events: readonly string[]): Promise<number>;
|
|
47
41
|
/**
|
|
48
42
|
* Segment-entry triggers, maintained lazily: on each ingest/identify for a
|
|
49
43
|
* user, re-evaluate every trigger-routed segment for that user and act on the
|
|
@@ -63,12 +57,43 @@ export interface SweepResult {
|
|
|
63
57
|
size: number;
|
|
64
58
|
}[];
|
|
65
59
|
}
|
|
60
|
+
/** How many users one sweep page evaluates: a unit of resumable work (AWS checkpoints each). */
|
|
61
|
+
export declare const SWEEP_PAGE_SIZE = 500;
|
|
62
|
+
/**
|
|
63
|
+
* What the sweep does before it looks at any user: the runtime's own upkeep (AWS: unconfirmed
|
|
64
|
+
* starts, executions that ended unseen) and the erasures left unfinished (an instance would not
|
|
65
|
+
* stop). A failure of either is logged, never fatal: the pages still run. Users whose erasure is
|
|
66
|
+
* still pending afterwards are skipped by every page (`sweepSegmentsPaged`).
|
|
67
|
+
*/
|
|
68
|
+
export declare function sweepMaintenance(env: JourneyEnv, store: JourneyStore): Promise<void>;
|
|
69
|
+
export interface SweepPage {
|
|
70
|
+
/** Users evaluated on this page (those being erased are listed but skipped). */
|
|
71
|
+
users: number;
|
|
72
|
+
/** Journeys the segments' entries started on this page. */
|
|
73
|
+
started: string[];
|
|
74
|
+
/** The last user id listed, to resume past (`after`); undefined when the page was empty. */
|
|
75
|
+
lastUserId?: string | undefined;
|
|
76
|
+
/** Whether the page was full, so another may follow. */
|
|
77
|
+
more: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* One page of the sweep: the users after `after` (ascending, at most `limit`), every deployed
|
|
81
|
+
* segment evaluated for each. The pages are what makes the sweep resumable — a host whose run
|
|
82
|
+
* can be cut short (a Lambda timeout) checkpoints each one and replays the checkpointed pages
|
|
83
|
+
* instead of starting over; `sweepSegments` is the plain loop over them.
|
|
84
|
+
*/
|
|
85
|
+
export declare function sweepSegmentsPaged(env: JourneyEnv, store: JourneyStore, page: {
|
|
86
|
+
after?: string | undefined;
|
|
87
|
+
limit?: number | undefined;
|
|
88
|
+
now?: number | undefined;
|
|
89
|
+
}): Promise<SweepPage>;
|
|
66
90
|
/**
|
|
67
91
|
* The scheduled sweep: every deployed segment evaluated for every known user — the evaluator a
|
|
68
92
|
* journey's conditions run on, so a member is exactly who a journey would see in it. Membership
|
|
69
93
|
* follows (joiners keep the time they joined, leavers are removed), segment triggers start the
|
|
70
94
|
* journeys of whoever entered by the clock alone, and the store records each segment's size.
|
|
71
|
-
* It walks users
|
|
95
|
+
* It walks users page by page (`sweepSegmentsPaged`): fine for thousands, a large audience wants
|
|
96
|
+
* SQL-side evaluation.
|
|
72
97
|
*/
|
|
73
98
|
export declare function sweepSegments(env: JourneyEnv, store: JourneyStore, now?: number): Promise<SweepResult>;
|
|
74
99
|
export interface IdentifyResult {
|
|
@@ -99,9 +124,13 @@ export declare function registerDevice(env: JourneyEnv, device: DeviceRegistrati
|
|
|
99
124
|
woke: number;
|
|
100
125
|
}>;
|
|
101
126
|
/**
|
|
102
|
-
* Forget a user (a deleted account): the
|
|
103
|
-
*
|
|
104
|
-
*
|
|
127
|
+
* Forget a user (a deleted account): the tombstone is committed first, then the erasure carried
|
|
128
|
+
* out. `erased: true` means every admitted runner of theirs was confirmed stopped, the entries
|
|
129
|
+
* never admitted can never run, and the data is deleted — for good, with no time window and no
|
|
130
|
+
* second pass: the tombstone commits under the user's lock, which every write about the user
|
|
131
|
+
* also takes, so nothing of theirs can land after it. An admitted instance that will not stop
|
|
132
|
+
* leaves it pending — nothing erased yet — and the scheduled sweep retries it; `erased: false`
|
|
133
|
+
* says so. A user already erased answers `erased: true` again, with nothing to do.
|
|
105
134
|
*/
|
|
106
135
|
export declare function forgetUser(env: JourneyEnv, userId: string, store?: JourneyStore, now?: number): Promise<{
|
|
107
136
|
ok: true;
|
|
@@ -157,16 +186,5 @@ export declare class BundleIntegrityError extends Error {
|
|
|
157
186
|
* compiled into it; without one it is forced, whatever is live.
|
|
158
187
|
*/
|
|
159
188
|
export declare function deployBundle(env: JourneyEnv, bundle: unknown, store?: JourneyStore, version?: BundleVersion): Promise<DeployResult>;
|
|
160
|
-
/**
|
|
161
|
-
* How the ingest API applies a contract: 'enforce' refuses an invalid event or
|
|
162
|
-
* patch with a 400 before anything is stored, woken or started; 'report' logs
|
|
163
|
-
* the issues (event id, name, field paths — never the payload) and accepts it,
|
|
164
|
-
* for checking real producers before turning enforcement on.
|
|
165
|
-
*/
|
|
166
|
-
export interface IngestValidation {
|
|
167
|
-
contract?: Contract | undefined;
|
|
168
|
-
mode?: 'enforce' | 'report' | undefined;
|
|
169
|
-
}
|
|
170
|
-
export declare function handleRequest(request: Request, env: JourneyEnv, store?: JourneyStore, validation?: IngestValidation): Promise<Response>;
|
|
171
189
|
//#endregion
|
|
172
|
-
//# sourceMappingURL=
|
|
190
|
+
//# sourceMappingURL=ingest.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingest.d.mts","names":[],"sources":["../../src/host/ingest.ts"],"mappings":";;;;iBA+CiB;EACf;EACA;EACA,UAAU;EACV;;;;;;;;;;;;;;;EAeA;;iBAGe;;EAEf;;EAEA;EACA;EACA;;wBAGoB,YACpB,KAAK,YACL,OAAO,aACP,QAAO,eACN,QAAQ;;;;;;wBAwCW,gBACpB,KAAK,YACL,OAAO,cACP,gBACA,4BACC;;;;;;;;;wBA0EmB,uBACpB,KAAK,YACL,OAAO,cACP,gBACA,aACC;iBA0Fc;EACf;;EAEA;;EAEA;IAAS;IAAiB;;;;qBAIf;;;;;;;wBAQS,iBAAiB,KAAK,YAAY,OAAO,eAAe;iBAkB7D;;EAEf;;EAEA;;EAEA;;EAEA;;;;;;;;wBASoB,mBACpB,KAAK,YACL,OAAO,cACP;EAAQ;EAA4B;EAA4B;IAC/D,QAAQ;;;;;;;;;wBAsCW,cACpB,KAAK,YACL,OAAO,cACP,eACC,QAAQ;iBAgFM;EACf;EACA,OAAO;EACP;EACA;;;;;;;wBAQoB,aACpB,KAAK,YACL,gBACA,OAAO,cACP,QAAO,eACN,QAAQ;iBAiBM;EACf;EACA;EACA;EACA;;;;;;;wBAQoB,eACpB,KAAK,YACL,QAAQ,oBACR,QAAO,eACN;EAAU;EAAU;;;;;;;;;;;wBA2FD,WACpB,KAAK,YACL,gBACA,QAAO,cACP,eACC;EAAU;EAAU;EAAiB;;;;;;;wBAUlB,aACpB,KAAK,YACL,eACA,QAAO,eACN;EAAU;EAAU;;;wBAQD,aACpB,KAAK,YACL,eACA,QAAO,eACN;EAAU;EAAU;;iBASN;EACf;;;;;;;;EAQA;IAAY;IAAkB,SAAS;;;;;;EAKvC;;;qBAIW,8BAA8B;WACvB;EAClB;;;qBAMW,6BAA6B;EACxC,YAAY;;;;;;;;wBA8CQ,aACpB,KAAK,YACL,iBACA,QAAO,cACP,UAAU,gBACT,QAAQ"}
|