@stacksjs/newsletter 0.75.519 → 0.75.522
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/campaigns.d.ts +3 -50
- package/dist/sync.d.ts +0 -9
- package/package.json +9 -9
package/dist/campaigns.d.ts
CHANGED
|
@@ -1,55 +1,7 @@
|
|
|
1
1
|
import type { CampaignStatus, CreateCampaignInput, SendCampaignOptions } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Campaign CRUD + dispatch.
|
|
4
|
-
*
|
|
5
|
-
* `sendNow()` and `schedule()` both end up dispatching the
|
|
6
|
-
* `SendCampaignJob` queue handler — `schedule()` just adds a `delay()`
|
|
7
|
-
* computed against the campaign's `scheduled_at`. The job is the one
|
|
8
|
-
* source of truth for actually fanning out emails so that a manual
|
|
9
|
-
* `sendNow()` from the dashboard and a cron-fired scheduled run go
|
|
10
|
-
* through identical machinery.
|
|
11
|
-
*/
|
|
12
|
-
declare function resolveListId(input: CreateCampaignInput): Promise<number>;
|
|
13
2
|
export declare function campaignDeliverySnapshot(campaign: CampaignLike | null | undefined): CampaignDeliverySnapshot;
|
|
14
3
|
export declare function campaignDeliveryDispatchKey(id: number, mode: 'immediate' | 'scheduled', attempt: string, scheduledAt?: string): string;
|
|
15
4
|
export declare function canQueueCampaignStatus(status: unknown): boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Move a campaign from the state the caller read to `target`, or refuse.
|
|
18
|
-
*
|
|
19
|
-
* A compare-and-set against the caller's snapshot: the write only lands if
|
|
20
|
-
* status, scheduled_at and updated_at still hold what the caller read.
|
|
21
|
-
*
|
|
22
|
-
* On PostgreSQL and SQLite that is one atomic UPDATE whose affected-row count
|
|
23
|
-
* is the verdict, because both count the rows an UPDATE MATCHED. MySQL counts
|
|
24
|
-
* the rows it CHANGED, so there the same count cannot carry the decision: a
|
|
25
|
-
* transition whose target is the state the campaign is already in reported 0.
|
|
26
|
-
* `sqlDateTime` has second precision, so `updated_at` does not save it, and
|
|
27
|
-
* cancelling a cancelled campaign - a double click - threw
|
|
28
|
-
* CampaignStateConflictError for a campaign nobody else had touched
|
|
29
|
-
* (stacksjs/stacks#2639).
|
|
30
|
-
*
|
|
31
|
-
* The obvious repair is the dangerous one. Re-reading after a zero and
|
|
32
|
-
* accepting "the row already holds the target" cannot tell our no-op from a
|
|
33
|
-
* concurrent caller that got there first: two `sendNow()` calls in the same
|
|
34
|
-
* second both target `sending`, the loser's re-read finds exactly its target,
|
|
35
|
-
* and it would report success and dispatch a second SendCampaignJob. The
|
|
36
|
-
* campaign would go out twice.
|
|
37
|
-
*
|
|
38
|
-
* So on MySQL the comparison moves in front of the write, under a row lock,
|
|
39
|
-
* and is made by the database with the same predicate the UPDATE uses, which
|
|
40
|
-
* keeps the stored-format question out of JavaScript. A caller that loses a
|
|
41
|
-
* race waits for the winner, finds the snapshot no longer matches, and gets
|
|
42
|
-
* the conflict; with the row locked and matched, the UPDATE cannot miss, so
|
|
43
|
-
* its count is not read.
|
|
44
|
-
*
|
|
45
|
-
* The other dialects keep the single statement on purpose, not as a fallback.
|
|
46
|
-
* Opening a transaction there would make SQLite worse: its SELECT pins a read
|
|
47
|
-
* snapshot, and when a competing writer commits first the UPDATE fails to
|
|
48
|
-
* upgrade the transaction with a raw SQLITE_BUSY instead of re-checking its
|
|
49
|
-
* WHERE and reporting the conflict the caller can act on.
|
|
50
|
-
*/
|
|
51
|
-
declare function transitionCampaignDelivery(id: number, expected: CampaignDeliverySnapshot, target: CampaignDeliveryTarget): Promise<void>;
|
|
52
|
-
declare function dispatchCampaign(id: number, target: CampaignDeliveryTarget, previous: CampaignDeliverySnapshot, options: SendCampaignOptions, scheduledAt?: string, delaySeconds?: number): Promise<void>;
|
|
53
5
|
export declare function shouldRunScheduledCampaign(campaign: ScheduledCampaignState, expectedScheduledAt?: string): boolean;
|
|
54
6
|
export declare function campaignCreateData(input: CreateCampaignInput, emailListId: number): Record<string, CampaignWriteValue>;
|
|
55
7
|
export declare function campaignUpdateData(patch: Partial<CreateCampaignInput>, emailListId?: number): Record<string, CampaignWriteValue>;
|
|
@@ -62,7 +14,7 @@ export declare function campaignUpdateData(patch: Partial<CreateCampaignInput>,
|
|
|
62
14
|
* update: (id: number, patch: Partial<CreateCampaignInput>) => Promise<unknown>,
|
|
63
15
|
* sendNow: (id: number, options?: SendCampaignOptions) => Promise<{ ok: boolean; campaignId: number }>,
|
|
64
16
|
* schedule: (id: number, scheduledAt: Date | string, options?: SendCampaignOptions) => Promise<{ ok: boolean; campaignId: number; scheduledAt: unknown }>,
|
|
65
|
-
* cancel: (id: number) => Promise<
|
|
17
|
+
* cancel: (id: number) => Promise<unknown>
|
|
66
18
|
* }
|
|
67
19
|
* ```
|
|
68
20
|
*/
|
|
@@ -84,7 +36,7 @@ export declare const campaigns: {
|
|
|
84
36
|
campaignId: number;
|
|
85
37
|
scheduledAt: unknown
|
|
86
38
|
}>;
|
|
87
|
-
cancel: (id: number) => Promise<
|
|
39
|
+
cancel: (id: number) => Promise<unknown>
|
|
88
40
|
};
|
|
89
41
|
declare interface ScheduledCampaignState {
|
|
90
42
|
status?: unknown
|
|
@@ -135,3 +87,4 @@ declare type StoredCampaignStatus = CampaignStatus | 'active' | 'completed' | 'a
|
|
|
135
87
|
export declare class CampaignStateConflictError extends Error {
|
|
136
88
|
constructor(id: number);
|
|
137
89
|
}
|
|
90
|
+
export {};
|
package/dist/sync.d.ts
CHANGED
|
@@ -9,15 +9,6 @@ export declare function looksLikeEmail(value: string): boolean;
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function syncDecision(email: string, state: SyncContactState): SyncDecision;
|
|
11
11
|
export declare function syncListSubscribers(list: string | number, contacts: readonly SyncContact[], options?: { source?: string }): Promise<SyncListResult>;
|
|
12
|
-
/**
|
|
13
|
-
* Whether an address is suppressed.
|
|
14
|
-
*
|
|
15
|
-
* `@stacksjs/email` is imported lazily and its absence is not fatal: this
|
|
16
|
-
* package does not depend on it (nothing here sends), and an app running the
|
|
17
|
-
* newsletter tables without the email package should still be able to sync a
|
|
18
|
-
* list - it simply has no suppression list to consult.
|
|
19
|
-
*/
|
|
20
|
-
declare function suppressed(email: string): Promise<boolean>;
|
|
21
12
|
/**
|
|
22
13
|
* Putting an audience you already have onto a list.
|
|
23
14
|
*
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/newsletter",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.522",
|
|
6
6
|
"description": "Promotional email & newsletter primitives for Stacks. Lists, campaigns, subscribers, and one-click unsubscribe — sent through @stacksjs/email.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -61,16 +61,16 @@
|
|
|
61
61
|
"prepublishOnly": "bun run build"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@stacksjs/database": "0.75.
|
|
65
|
-
"@stacksjs/email": "0.75.
|
|
66
|
-
"@stacksjs/orm": "0.75.
|
|
67
|
-
"@stacksjs/queue": "0.75.
|
|
64
|
+
"@stacksjs/database": "0.75.522",
|
|
65
|
+
"@stacksjs/email": "0.75.522",
|
|
66
|
+
"@stacksjs/orm": "0.75.522",
|
|
67
|
+
"@stacksjs/queue": "0.75.522"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@stacksjs/cli": "0.75.
|
|
71
|
-
"@stacksjs/config": "0.75.
|
|
72
|
-
"@stacksjs/error-handling": "0.75.
|
|
73
|
-
"@stacksjs/types": "0.75.
|
|
70
|
+
"@stacksjs/cli": "0.75.522",
|
|
71
|
+
"@stacksjs/config": "0.75.522",
|
|
72
|
+
"@stacksjs/error-handling": "0.75.522",
|
|
73
|
+
"@stacksjs/types": "0.75.522",
|
|
74
74
|
"better-dx": "^0.2.24"
|
|
75
75
|
}
|
|
76
76
|
}
|