@pithy-sh/email 0.4.0 → 0.6.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/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +15 -0
- package/dist/crypto/signingKey.d.ts +4 -0
- package/dist/crypto/signingKey.d.ts.map +1 -1
- package/dist/crypto/signingKey.js +5 -1
- package/dist/data/emailJob.d.ts +1 -1
- package/dist/data/tables.d.ts +1 -1
- package/dist/error/errors.d.ts +4 -3
- package/dist/error/errors.d.ts.map +1 -1
- package/dist/provision/provisionEmail.d.ts +9 -1
- package/dist/provision/provisionEmail.d.ts.map +1 -1
- package/dist/provision/provisionEmail.js +5 -1
- package/dist/provision/resolveEmailConfig.d.ts +7 -0
- package/dist/provision/resolveEmailConfig.d.ts.map +1 -1
- package/dist/provision/resolveEmailConfig.js +14 -1
- package/dist/send/enqueue.d.ts +16 -0
- package/dist/send/enqueue.d.ts.map +1 -1
- package/dist/send/enqueue.js +14 -0
- package/dist/templates/messages.d.ts.map +1 -1
- package/dist/templates/messages.es.d.ts.map +1 -1
- package/dist/templates/messages.es.js +26 -0
- package/dist/templates/messages.js +28 -2
- package/dist/templates/precompiled.generated.d.ts +86 -0
- package/dist/templates/precompiled.generated.d.ts.map +1 -1
- package/dist/templates/precompiled.generated.js +1234 -0
- package/dist/templates/registry.d.ts.map +1 -1
- package/dist/templates/registry.js +67 -0
- package/dist/templates/samples.d.ts.map +1 -1
- package/dist/templates/samples.js +15 -0
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/package.json +4 -4
- package/src/capability.ts +16 -0
- package/src/crypto/signingKey.ts +6 -0
- package/src/error/errors.ts +4 -3
- package/src/provision/provisionEmail.ts +10 -1
- package/src/provision/resolveEmailConfig.ts +12 -0
- package/src/send/enqueue.ts +28 -0
- package/src/templates/messages.es.ts +36 -0
- package/src/templates/messages.ts +36 -2
- package/src/templates/precompiled.generated.ts +417 -0
- package/src/templates/registry.ts +105 -0
- package/src/templates/samples.ts +4 -0
- package/src/version.generated.ts +1 -1
package/dist/capability.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,0CAA0C,CAAC;AAI7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EACL,KAAK,wBAAwB,EAM9B,MAAM,eAAe,CAAC;AAMvB,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAgB,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,KAAK,cAAc,EAAsB,MAAM,sBAAsB,CAAC;AAE/E,OAAO,EAAe,KAAK,UAAU,EAAgB,MAAM,mBAAmB,CAAC;AAI/E;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACrD,EAAE,EAAE,UAAU,CAAC;IACf;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,UAAU,CAAC;CACjC;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,kGAAkG;AAClG,eAAO,MAAM,kCAAkC,MAAM,CAAC;AAEtD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiC8B,CAAC;AACvD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AACvD,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE3D,2FAA2F;AAC3F,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,WAAW,EAAE,eAAe,CAAC;IAC7B,KAAK,EAAE,UAAU,CAAC;CACnB;AAED,wFAAwF;AACxF,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD,WAAW,EAAE,mBAAmB,CAAC;IACjC;;;;;OAKG;IACH,OAAO,EAAE,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/E;;;;;;;;;;;;;OAaG;IACH,YAAY,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,wBAAwB,CAAC;IACjE;;;;;;;;;;;OAWG;IACH,YAAY,EAAE,MAAM,cAAc,CAAC;CACpC;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,gBAAgB,GAAG,eAAe,CAoO/D;AAED,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,IAAI,eAAe,CAEvF"}
|
package/dist/capability.js
CHANGED
|
@@ -20,6 +20,7 @@ import { EmailScheduleParams, EmailSendParams } from "./workflows/params.js";
|
|
|
20
20
|
import { z } from "zod";
|
|
21
21
|
import { defineCapability } from "@pithy-sh/core/src/capability/capability";
|
|
22
22
|
import { pithyCommandOf } from "@pithy-sh/core/src/cli/command";
|
|
23
|
+
import { composedUsageMeter } from "@pithy-sh/core/src/entitlement/meter";
|
|
23
24
|
import { InternalError } from "@pithy-sh/core/src/error/pithyError";
|
|
24
25
|
//#region src/capability.ts
|
|
25
26
|
/**
|
|
@@ -80,6 +81,12 @@ function email(config) {
|
|
|
80
81
|
* capability's own config, and this is the only thing that knows it.
|
|
81
82
|
*/
|
|
82
83
|
let supportedLocales = [];
|
|
84
|
+
/**
|
|
85
|
+
* The usage meter a composed provider exposes — `@pithy-sh/payments`, when it is composed — found in
|
|
86
|
+
* `compose` by core's structural predicate. Undefined with no provider, which is the email capability
|
|
87
|
+
* exactly as it always was: nothing is counted and nothing is refused.
|
|
88
|
+
*/
|
|
89
|
+
let meter;
|
|
83
90
|
const capability = defineCapability({
|
|
84
91
|
name: "email",
|
|
85
92
|
version: PACKAGE_VERSION,
|
|
@@ -114,6 +121,7 @@ function email(config) {
|
|
|
114
121
|
* project sends what it always sent.
|
|
115
122
|
*/
|
|
116
123
|
compose: ({ capabilities }) => {
|
|
124
|
+
meter = composedUsageMeter(capabilities);
|
|
117
125
|
for (const composed of capabilities) {
|
|
118
126
|
if (composed.name !== "i18n") continue;
|
|
119
127
|
const candidate = composed.layersFor;
|
|
@@ -230,6 +238,12 @@ function email(config) {
|
|
|
230
238
|
});
|
|
231
239
|
return emailSuppressionDatabase(binding);
|
|
232
240
|
};
|
|
241
|
+
/** The meter charge for one env, or undefined when no provider is composed. */
|
|
242
|
+
const chargeFor = (env) => {
|
|
243
|
+
const composed = meter;
|
|
244
|
+
if (composed === void 0) return void 0;
|
|
245
|
+
return (charge) => composed.charge(env, charge);
|
|
246
|
+
};
|
|
233
247
|
const enqueue = (env, input) => enqueueEmail({
|
|
234
248
|
db: emailDatabase(env.DB),
|
|
235
249
|
fromAddress: resolved.fromAddress,
|
|
@@ -238,6 +252,7 @@ function email(config) {
|
|
|
238
252
|
layersFor: (locale) => layersFor(locale),
|
|
239
253
|
sender: emailSenderBinding(env),
|
|
240
254
|
suppressionDb: env.EMAIL_SUPPRESSIONS ? emailSuppressionDatabase(env.EMAIL_SUPPRESSIONS) : void 0,
|
|
255
|
+
meter: chargeFor(env),
|
|
241
256
|
now: /* @__PURE__ */ new Date(),
|
|
242
257
|
newId: () => crypto.randomUUID()
|
|
243
258
|
}, input);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signingKey.d.ts","sourceRoot":"","sources":["../../src/crypto/signingKey.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAG1E;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,0BAA4C,CAAC;AAExF,gHAAgH;AAChH,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"signingKey.d.ts","sourceRoot":"","sources":["../../src/crypto/signingKey.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAG1E;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,0BAA4C,CAAC;AAExF,gHAAgH;AAChH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;CAqC/B,CAAC;AAEH;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,eAAe,CAAC,CAAC,OAAO,oBAAoB,CAAC,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAGxF"}
|
|
@@ -31,7 +31,11 @@ const emailSigningRegistry = defineSecretRegistry({ [EMAIL_LINK_SIGNING_KEY]: {
|
|
|
31
31
|
encoding: "base64url"
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
-
rotation: { kind: "local" }
|
|
34
|
+
rotation: { kind: "local" },
|
|
35
|
+
overlap: {
|
|
36
|
+
days: 90,
|
|
37
|
+
minimumDays: 90
|
|
38
|
+
}
|
|
35
39
|
} });
|
|
36
40
|
/**
|
|
37
41
|
* Resolve the current signing key plus every still-valid prior version. The current version is the
|
package/dist/data/emailJob.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare const EmailJob: z.ZodObject<{
|
|
|
35
35
|
marketing: "marketing";
|
|
36
36
|
transactional: "transactional";
|
|
37
37
|
}>;
|
|
38
|
-
payload:
|
|
38
|
+
payload: import("@pithy-sh/core/src/data/codecs").SqliteJson<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
39
39
|
payloadRedactedAt: z.ZodOptional<z.ZodNullable<z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>>>;
|
|
40
40
|
status: z.ZodEnum<{
|
|
41
41
|
bounced: "bounced";
|
package/dist/data/tables.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare const emailTables: {
|
|
|
25
25
|
marketing: "marketing";
|
|
26
26
|
transactional: "transactional";
|
|
27
27
|
}>;
|
|
28
|
-
payload: import("
|
|
28
|
+
payload: import("@pithy-sh/core/src/data/codecs").SqliteJson<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
29
29
|
payloadRedactedAt: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>>>;
|
|
30
30
|
status: import("zod").ZodEnum<{
|
|
31
31
|
bounced: "bounced";
|
package/dist/error/errors.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
import { PithyError } from "@pithy-sh/core/src/error/pithyError";
|
|
4
4
|
import type { MessageParams } from "@pithy-sh/core/src/i18n/catalog";
|
|
5
|
+
import type { UnmarkedString } from "@pithy-sh/core/src/privacy/types";
|
|
5
6
|
/**
|
|
6
7
|
* `@pithy-sh/email` throw sugar. The `email/*` codes live in core's closed `KitErrorPayload` union
|
|
7
8
|
* (CLAUDE.md §Errors: capabilities add their codes to the one union); these subclasses are the
|
|
@@ -11,11 +12,11 @@ import type { MessageParams } from "@pithy-sh/core/src/i18n/catalog";
|
|
|
11
12
|
/** Variable parts each subclass accepts; `code`/`status` are fixed by the subclass. */
|
|
12
13
|
interface EmailErrorArgs {
|
|
13
14
|
/** Override the public, safe-to-expose message. */
|
|
14
|
-
message?:
|
|
15
|
+
message?: UnmarkedString;
|
|
15
16
|
/** A remediation hint (CLI action line). */
|
|
16
|
-
action?:
|
|
17
|
+
action?: UnmarkedString;
|
|
17
18
|
/** Internal context for logs + audit. Never serialized to clients. */
|
|
18
|
-
detail?:
|
|
19
|
+
detail?: UnmarkedString;
|
|
19
20
|
/**
|
|
20
21
|
* Values a translating client interpolates into its own wording for this code. Client-facing, so —
|
|
21
22
|
* unlike `action` and `detail` — these cross the boundary with `message`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/error/errors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/error/errors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAEvE;;;;;GAKG;AAEH,uFAAuF;AACvF,UAAU,cAAc;IACtB,mDAAmD;IACnD,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,sEAAsE;IACtE,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,mDAAmD;AACnD,qBAAa,0BAA2B,SAAQ,UAAU;IACxD,YAAY,IAAI,GAAE,cAAmB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAYnE;CACF;AAED,iFAAiF;AACjF,qBAAa,wBAAyB,SAAQ,UAAU;IACtD,YAAY,IAAI,GAAE,cAAmB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAYnE;CACF;AAED,4GAA4G;AAC5G,qBAAa,sBAAuB,SAAQ,UAAU;IACpD,YAAY,IAAI,GAAE,cAAmB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAYnE;CACF;AAED,8EAA8E;AAC9E,qBAAa,oBAAqB,SAAQ,UAAU;IAClD,YAAY,IAAI,GAAE,cAAmB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAYnE;CACF;AAED,kGAAkG;AAClG,qBAAa,qBAAsB,SAAQ,UAAU;IACnD,YAAY,IAAI,GAAE,cAAmB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAYnE;CACF;AAED,kFAAkF;AAClF,qBAAa,oBAAqB,SAAQ,UAAU;IAClD,YAAY,IAAI,GAAE,cAAmB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAYnE;CACF"}
|
|
@@ -153,6 +153,11 @@ export interface EmailDeprovisioner {
|
|
|
153
153
|
* before it deletes the list they share (#591).
|
|
154
154
|
*/
|
|
155
155
|
hasWorker(env: ManagedEnvironment): Promise<boolean>;
|
|
156
|
+
/**
|
|
157
|
+
* Delete the env's send and schedule Workflows, by `emailWorkflowNames`. Idempotent (a Workflow already gone is
|
|
158
|
+
* a no-op). Deleting the worker leaves them registered, so they go first (#789).
|
|
159
|
+
*/
|
|
160
|
+
deleteWorkflows(env: ManagedEnvironment): Promise<void>;
|
|
156
161
|
/** Delete the env's email worker. Idempotent (a missing worker is a no-op). */
|
|
157
162
|
deleteWorker(env: ManagedEnvironment): Promise<void>;
|
|
158
163
|
/**
|
|
@@ -184,7 +189,10 @@ export interface EmailDeprovisionOptions {
|
|
|
184
189
|
* 2. With `deleteSuppression` only: refuse while any other declared environment still runs an email worker
|
|
185
190
|
* (`assertSharedLeavesLast`). The list is one per project, and a staging teardown must not take production's.
|
|
186
191
|
* 3. Count the list, and refuse unless the operator counted the same (`assertRetainedAgreed`, #588's guard).
|
|
187
|
-
* 4. Delete the environment's worker (it binds the list), then — only when asked — the list.
|
|
192
|
+
* 4. Delete the environment's Workflows (#789), then its worker (it binds the list), then — only when asked — the list.
|
|
193
|
+
*
|
|
194
|
+
* It never deletes the environment's link-signing key. `pithy secrets provision` creates that entry and binds it
|
|
195
|
+
* into the app Worker, which is still deployed, and every link already sent is signed with it (#596).
|
|
188
196
|
*
|
|
189
197
|
* Idempotent end to end: a missing worker or database is a no-op.
|
|
190
198
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provisionEmail.d.ts","sourceRoot":"","sources":["../../src/provision/provisionEmail.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,KAAK,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACjG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAKlF,OAAO,EAEL,KAAK,iBAAiB,EAEtB,KAAK,kBAAkB,EAExB,MAAM,6BAA6B,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,4GAA4G;AAC5G,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,kGAAkG;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AAC,YAAY,EAAE,CAAC,CAAC;IACpD;;;OAGG;IACH,SAAS,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD;;;OAGG;IACH,eAAe,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,+EAA+E;IAC/E,YAAY,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD;;;;;OAKG;IACH,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAED,+GAA+G;AAC/G,MAAM,WAAW,uBAAuB;IACtC,gGAAgG;IAChG,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,gBAAgB,CACpC,aAAa,EAAE,kBAAkB,EACjC,MAAM,EAAE,iBAAiB,EACzB,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC;IAAE,GAAG,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAiBtC"}
|
|
@@ -146,7 +146,10 @@ async function provisionEmail(provisioner, environments) {
|
|
|
146
146
|
* 2. With `deleteSuppression` only: refuse while any other declared environment still runs an email worker
|
|
147
147
|
* (`assertSharedLeavesLast`). The list is one per project, and a staging teardown must not take production's.
|
|
148
148
|
* 3. Count the list, and refuse unless the operator counted the same (`assertRetainedAgreed`, #588's guard).
|
|
149
|
-
* 4. Delete the environment's worker (it binds the list), then — only when asked — the list.
|
|
149
|
+
* 4. Delete the environment's Workflows (#789), then its worker (it binds the list), then — only when asked — the list.
|
|
150
|
+
*
|
|
151
|
+
* It never deletes the environment's link-signing key. `pithy secrets provision` creates that entry and binds it
|
|
152
|
+
* into the app Worker, which is still deployed, and every link already sent is signed with it (#596).
|
|
150
153
|
*
|
|
151
154
|
* Idempotent end to end: a missing worker or database is a no-op.
|
|
152
155
|
*/
|
|
@@ -159,6 +162,7 @@ async function deprovisionEmail(deprovisioner, target, options = {}) {
|
|
|
159
162
|
}]);
|
|
160
163
|
assertRetainedAgreed(await deprovisioner.countSuppressionRetained(), options.destroyRetained, "anything was deleted");
|
|
161
164
|
}
|
|
165
|
+
await deprovisioner.deleteWorkflows(env);
|
|
162
166
|
await deprovisioner.deleteWorker(env);
|
|
163
167
|
if (options.deleteSuppression) await deprovisioner.deleteSuppressionDatabase();
|
|
164
168
|
return { env };
|
|
@@ -29,6 +29,13 @@ export interface EmailWorkerWranglerTemplate extends WorkflowHostTemplate {
|
|
|
29
29
|
}
|
|
30
30
|
/** The registry the host resolver derives its `workflows` array from, and the host's app dispatches on. */
|
|
31
31
|
export declare const emailWorkflowRegistry: WorkflowRegistry;
|
|
32
|
+
/**
|
|
33
|
+
* The Workflows one environment's email worker is deployed with — `<project>-<env>-email-send` and
|
|
34
|
+
* `<project>-<env>-email-schedule`. Derived by the call {@link resolveEmailConfig} deploys with, so teardown
|
|
35
|
+
* deletes the names provision created and no others (#789). Deleting a Worker does not delete the Workflows
|
|
36
|
+
* registered against it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function emailWorkflowNames(project: string, env: ManagedEnvironment): string[];
|
|
32
39
|
/**
|
|
33
40
|
* The most one Cloudflare Worker variable holds. **Per variable, and that is the whole design.**
|
|
34
41
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveEmailConfig.d.ts","sourceRoot":"","sources":["../../src/provision/resolveEmailConfig.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEzE,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,kCAAkC,CAAC;AAG1C,OAAO,KAAK,EAAE,gBAAg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AAE,2BAA2B,EACrC,MAAM,EAAE,iBAAiB,GACxB,2BAA2B,CAwD7B"}
|
|
@@ -34,6 +34,19 @@ const emailWorkflowRegistry = Object.fromEntries(Object.entries({
|
|
|
34
34
|
}];
|
|
35
35
|
}));
|
|
36
36
|
/**
|
|
37
|
+
* The Workflows one environment's email worker is deployed with — `<project>-<env>-email-send` and
|
|
38
|
+
* `<project>-<env>-email-schedule`. Derived by the call {@link resolveEmailConfig} deploys with, so teardown
|
|
39
|
+
* deletes the names provision created and no others (#789). Deleting a Worker does not delete the Workflows
|
|
40
|
+
* registered against it.
|
|
41
|
+
*/
|
|
42
|
+
function emailWorkflowNames(project, env) {
|
|
43
|
+
return hostWorkflowsFor(emailWorkflowRegistry, {
|
|
44
|
+
project,
|
|
45
|
+
capability: EMAIL_CAPABILITY,
|
|
46
|
+
env
|
|
47
|
+
}).workflows.map((workflow) => workflow.name);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
37
50
|
* The most one Cloudflare Worker variable holds. **Per variable, and that is the whole design.**
|
|
38
51
|
*
|
|
39
52
|
* Cloudflare's documented limit is 5 KB per variable, on Free and Paid alike, and a Worker carries 64
|
|
@@ -131,4 +144,4 @@ function resolveEmailConfig(template, params) {
|
|
|
131
144
|
});
|
|
132
145
|
}
|
|
133
146
|
//#endregion
|
|
134
|
-
export { MAX_WORKER_VAR_BYTES, emailMessagesVars, emailWorkflowRegistry, resolveEmailConfig };
|
|
147
|
+
export { MAX_WORKER_VAR_BYTES, emailMessagesVars, emailWorkflowNames, emailWorkflowRegistry, resolveEmailConfig };
|
package/dist/send/enqueue.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
+
import type { MeterCharge, MeterSubject } from "@pithy-sh/core/src/entitlement/meter";
|
|
3
4
|
import type { EmailJobStatus, SendMode, SuppressionReason } from "../data/enums";
|
|
4
5
|
import type { EmailDatabase, EmailSuppressionDatabase } from "../data/tables";
|
|
5
6
|
import { type EmailMessageLayers } from "../templates/messages";
|
|
@@ -112,6 +113,16 @@ export interface EnqueueInput {
|
|
|
112
113
|
inReplyTo?: string;
|
|
113
114
|
/** The `References` chain, angle-bracketed and space-separated. Built by the caller from the parent. */
|
|
114
115
|
references?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Who this message is sent on behalf of, for the `emails` meter — the holder pair `@pithy-sh/payments`
|
|
118
|
+
* bills, `{ subjectType: "organization", subjectId }`.
|
|
119
|
+
*
|
|
120
|
+
* **Omit it and nothing is counted**, which is right for every message the kit sends on its own account: a
|
|
121
|
+
* magic link to somebody who has not signed up is not a tenant's usage. Name it on mail a customer's plan
|
|
122
|
+
* pays for — a campaign, a notification their workspace triggers — and, where the meter is enforced, an
|
|
123
|
+
* enqueue past the period's quota throws `payments/quota_exceeded` and writes no job.
|
|
124
|
+
*/
|
|
125
|
+
subject?: MeterSubject;
|
|
115
126
|
}
|
|
116
127
|
/** Dependencies enqueue needs: the database, the from identity, optional send-Workflow binding, time, ids. */
|
|
117
128
|
export interface EnqueueDeps {
|
|
@@ -139,6 +150,11 @@ export interface EnqueueDeps {
|
|
|
139
150
|
* goes could not be consulted yet, which is strictly worse than queueing it.
|
|
140
151
|
*/
|
|
141
152
|
suppressionDb?: EmailSuppressionDatabase;
|
|
153
|
+
/**
|
|
154
|
+
* Charge one email against the `emails` meter, or refuse — the composed provider's seam, closed over this
|
|
155
|
+
* request's env. Absent when no provider is composed, and then nothing is counted.
|
|
156
|
+
*/
|
|
157
|
+
meter?: (charge: MeterCharge) => Promise<void>;
|
|
142
158
|
now: Date;
|
|
143
159
|
/** Generate a job id (a UUID in production). */
|
|
144
160
|
newId: () => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enqueue.d.ts","sourceRoot":"","sources":["../../src/send/enqueue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enqueue.d.ts","sourceR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CAAC,CAgKjG"}
|
package/dist/send/enqueue.js
CHANGED
|
@@ -89,6 +89,20 @@ async function enqueueEmail(deps, input) {
|
|
|
89
89
|
* exist.
|
|
90
90
|
*/
|
|
91
91
|
const batchId = sender ? (deps.newBatchId ?? mintBatchId)() : null;
|
|
92
|
+
/**
|
|
93
|
+
* Charge the `emails` meter **before the row exists**, so a refusal writes no job — and only for a message
|
|
94
|
+
* that is going to be sent. A withheld recipient costs the customer nothing, and a message the kit sends
|
|
95
|
+
* on nobody's account names no subject and is never counted.
|
|
96
|
+
*
|
|
97
|
+
* Before the insert rather than after it, and the cost is the right way round: an insert that fails after
|
|
98
|
+
* a charge over-counts by one, and over-counting briefly is recoverable where under-counting is not.
|
|
99
|
+
*/
|
|
100
|
+
if (!blocked && input.subject !== void 0 && deps.meter !== void 0) await deps.meter({
|
|
101
|
+
subject: input.subject,
|
|
102
|
+
meter: "emails",
|
|
103
|
+
amount: 1,
|
|
104
|
+
now: deps.now
|
|
105
|
+
});
|
|
92
106
|
const marketing = template.category === "marketing";
|
|
93
107
|
const job = {
|
|
94
108
|
id: deps.newId(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/templates/messages.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtF,OAAO,EAAoC,KAAK,UAAU,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/templates/messages.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtF,OAAO,EAAoC,KAAK,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAoKvG;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,EAAE,cAA+C,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,SAAS,CAAC,cAAc,GAAG,SAAS,CAAC,EAAE,CAAC;AAE7F,iHAAiH;AACjH,eAAO,MAAM,cAAc,EAAE,kBAA+D,CAAC;AAsB7F;;;;;;;GAOG;AACH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAE1D;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKhE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc,CAa5E;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,cAAc,GAAG,kBAAkB,CAa1E;AA2BD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,SAAS,EAAE,kBAAkB,GAAG,UAAU,CAG5G"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.es.d.ts","sourceRoot":"","sources":["../../src/templates/messages.es.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"messages.es.d.ts","sourceRoot":"","sources":["../../src/templates/messages.es.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,QAAQ,EAAE,cA+GtB,CAAC"}
|
|
@@ -74,6 +74,32 @@ const EMAIL_ES = {
|
|
|
74
74
|
"email/password_changed.warn": "Si no fuiste tú, contacta con soporte de inmediato.",
|
|
75
75
|
"email/password_changed.cta": "Contactar con soporte",
|
|
76
76
|
"email/password_changed.text_body": "Las credenciales de tu cuenta cambiaron el {when}. Si no fuiste tú, contacta con soporte:",
|
|
77
|
+
"email/account_suspended.subject": "Tu cuenta de {app} está suspendida",
|
|
78
|
+
"email/account_suspended.heading": "Tu cuenta está suspendida",
|
|
79
|
+
"email/account_suspended.body": "tu cuenta de {app} está suspendida. No puedes iniciar sesión hasta que se levante la suspensión.",
|
|
80
|
+
"email/account_suspended.text_body": "Tu cuenta de {app} está suspendida. No puedes iniciar sesión hasta que se levante la suspensión.",
|
|
81
|
+
"email/account_suspended.reason": "El motivo indicado: {reason}",
|
|
82
|
+
"email/account_suspended.until": "Termina el {until}.",
|
|
83
|
+
"email/account_suspended.contact": "Si crees que es un error, responde a este correo.",
|
|
84
|
+
"email/account_suspended.text_contact": "Si crees que es un error, responde a este correo.",
|
|
85
|
+
"email/account_reinstated.subject": "Tu cuenta de {app} vuelve a estar activa",
|
|
86
|
+
"email/account_reinstated.heading": "Tu cuenta vuelve a estar activa",
|
|
87
|
+
"email/account_reinstated.body": "se ha levantado la suspensión de tu cuenta de {app}. Ya puedes volver a iniciar sesión.",
|
|
88
|
+
"email/account_reinstated.text_body": "Se ha levantado la suspensión de tu cuenta de {app}. Ya puedes volver a iniciar sesión.",
|
|
89
|
+
"email/deletion_scheduled.subject": "Tu cuenta de {app} se ha eliminado",
|
|
90
|
+
"email/deletion_scheduled.heading": "Tu cuenta se ha eliminado",
|
|
91
|
+
"email/deletion_scheduled.body": "tu cuenta de {app} se ha eliminado y ya no puedes iniciar sesión.",
|
|
92
|
+
"email/deletion_scheduled.text_body": "Tu cuenta de {app} se ha eliminado y ya no puedes iniciar sesión.",
|
|
93
|
+
"email/deletion_scheduled.purge": "Tus datos se borrarán el {purgeOn}. Hasta entonces, la cuenta se puede recuperar.",
|
|
94
|
+
"email/deletion_scheduled.cta": "Recuperar mi cuenta",
|
|
95
|
+
"email/deletion_scheduled.text_restore": "Recupérala:",
|
|
96
|
+
"email/deletion_scheduled.contact": "Si no lo pediste tú, responde a este correo antes del {purgeOn}.",
|
|
97
|
+
"email/deletion_scheduled.text_contact": "Si no lo pediste tú, responde a este correo antes del {purgeOn}.",
|
|
98
|
+
"email/deletion_complete.subject": "Tus datos de {app} se han borrado",
|
|
99
|
+
"email/deletion_complete.heading": "Tus datos se han borrado",
|
|
100
|
+
"email/deletion_complete.body": "tu cuenta de {app} y sus datos se borraron el {purgedOn}. No se puede deshacer.",
|
|
101
|
+
"email/deletion_complete.text_body": "Tu cuenta de {app} y sus datos se borraron el {purgedOn}. No se puede deshacer.",
|
|
102
|
+
"email/deletion_complete.last": "Es el último correo que recibirá esta cuenta.",
|
|
77
103
|
"email/lead_capture.subject": "Tu descarga: {asset}",
|
|
78
104
|
"email/lead_capture.heading": "Tu descarga está lista",
|
|
79
105
|
"email/lead_capture.ready": "Tu copia de {asset} ya está lista.",
|
|
@@ -43,13 +43,13 @@ import { DEFAULT_LOCALE, createTranslator } from "@pithy-sh/core/src/i18n/transl
|
|
|
43
43
|
*
|
|
44
44
|
* ## Only the kit's own copy
|
|
45
45
|
*
|
|
46
|
-
*
|
|
46
|
+
* Eleven templates are here. The five whose words arrive as payload — `testerNudge`, `supportReply`,
|
|
47
47
|
* `operationalNotice`, `newsletter`, `marketingCampaign` — are the adopter's copy, chosen by a human
|
|
48
48
|
* for one message, and a catalog cannot translate a sentence it has never seen. Their **shell** still
|
|
49
49
|
* follows the job's locale (the severity word, the footer, the document's `lang` and `dir`), so a
|
|
50
50
|
* notice at locale `es` reads its severity in Spanish and its summary in whatever the caller wrote.
|
|
51
51
|
*/
|
|
52
|
-
/** The kit's English for every string the
|
|
52
|
+
/** The kit's English for every string the eleven kit-authored templates and the shared shell render. */
|
|
53
53
|
const EMAIL_EN = {
|
|
54
54
|
"email/shell.greeting": "Hi,",
|
|
55
55
|
"email/shell.greeting_named": "Hi {name},",
|
|
@@ -97,6 +97,32 @@ const EMAIL_EN = {
|
|
|
97
97
|
"email/password_changed.warn": "If this wasn't you, contact support immediately.",
|
|
98
98
|
"email/password_changed.cta": "Contact support",
|
|
99
99
|
"email/password_changed.text_body": "Your account credentials were changed on {when}. If this wasn't you, contact support:",
|
|
100
|
+
"email/account_suspended.subject": "Your {app} account is suspended",
|
|
101
|
+
"email/account_suspended.heading": "Your account is suspended",
|
|
102
|
+
"email/account_suspended.body": "your {app} account is suspended. You cannot sign in until it is lifted.",
|
|
103
|
+
"email/account_suspended.text_body": "Your {app} account is suspended. You cannot sign in until it is lifted.",
|
|
104
|
+
"email/account_suspended.reason": "The reason given: {reason}",
|
|
105
|
+
"email/account_suspended.until": "It ends on {until}.",
|
|
106
|
+
"email/account_suspended.contact": "If you think this is a mistake, reply to this email.",
|
|
107
|
+
"email/account_suspended.text_contact": "If you think this is a mistake, reply to this email.",
|
|
108
|
+
"email/account_reinstated.subject": "Your {app} account is back",
|
|
109
|
+
"email/account_reinstated.heading": "Your account is back",
|
|
110
|
+
"email/account_reinstated.body": "the suspension on your {app} account is lifted. You can sign in again.",
|
|
111
|
+
"email/account_reinstated.text_body": "The suspension on your {app} account is lifted. You can sign in again.",
|
|
112
|
+
"email/deletion_scheduled.subject": "Your {app} account is deleted",
|
|
113
|
+
"email/deletion_scheduled.heading": "Your account is deleted",
|
|
114
|
+
"email/deletion_scheduled.body": "your {app} account is deleted, and you can no longer sign in.",
|
|
115
|
+
"email/deletion_scheduled.text_body": "Your {app} account is deleted, and you can no longer sign in.",
|
|
116
|
+
"email/deletion_scheduled.purge": "Your data will be erased on {purgeOn}. Until then, the account can be restored.",
|
|
117
|
+
"email/deletion_scheduled.cta": "Restore my account",
|
|
118
|
+
"email/deletion_scheduled.text_restore": "Restore it:",
|
|
119
|
+
"email/deletion_scheduled.contact": "If you did not ask for this, reply to this email before {purgeOn}.",
|
|
120
|
+
"email/deletion_scheduled.text_contact": "If you did not ask for this, reply to this email before {purgeOn}.",
|
|
121
|
+
"email/deletion_complete.subject": "Your {app} data is erased",
|
|
122
|
+
"email/deletion_complete.heading": "Your data is erased",
|
|
123
|
+
"email/deletion_complete.body": "your {app} account and its data were erased on {purgedOn}. This cannot be undone.",
|
|
124
|
+
"email/deletion_complete.text_body": "Your {app} account and its data were erased on {purgedOn}. This cannot be undone.",
|
|
125
|
+
"email/deletion_complete.last": "This is the last email this account will receive.",
|
|
100
126
|
"email/lead_capture.subject": "Your download: {asset}",
|
|
101
127
|
"email/lead_capture.heading": "Your download is ready",
|
|
102
128
|
"email/lead_capture.ready": "Your copy of {asset} is ready.",
|
|
@@ -162,6 +162,92 @@ export declare const precompiledTemplates: {
|
|
|
162
162
|
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
163
163
|
useData: boolean;
|
|
164
164
|
};
|
|
165
|
+
"accountSuspended:subject": {
|
|
166
|
+
compiler: (string | number)[];
|
|
167
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
168
|
+
useData: boolean;
|
|
169
|
+
};
|
|
170
|
+
"accountSuspended:html": {
|
|
171
|
+
"0": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
172
|
+
"1": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
173
|
+
"2": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
174
|
+
"3": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
175
|
+
compiler: (string | number)[];
|
|
176
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
177
|
+
usePartial: boolean;
|
|
178
|
+
useData: boolean;
|
|
179
|
+
};
|
|
180
|
+
"accountSuspended:text": {
|
|
181
|
+
"0": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
182
|
+
"1": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
183
|
+
"2": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
184
|
+
"3": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
185
|
+
compiler: (string | number)[];
|
|
186
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
187
|
+
useData: boolean;
|
|
188
|
+
};
|
|
189
|
+
"accountReinstated:subject": {
|
|
190
|
+
compiler: (string | number)[];
|
|
191
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
192
|
+
useData: boolean;
|
|
193
|
+
};
|
|
194
|
+
"accountReinstated:html": {
|
|
195
|
+
"0": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
196
|
+
"1": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
197
|
+
compiler: (string | number)[];
|
|
198
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
199
|
+
usePartial: boolean;
|
|
200
|
+
useData: boolean;
|
|
201
|
+
};
|
|
202
|
+
"accountReinstated:text": {
|
|
203
|
+
"0": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
204
|
+
"1": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
205
|
+
compiler: (string | number)[];
|
|
206
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
207
|
+
useData: boolean;
|
|
208
|
+
};
|
|
209
|
+
"deletionScheduled:subject": {
|
|
210
|
+
compiler: (string | number)[];
|
|
211
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
212
|
+
useData: boolean;
|
|
213
|
+
};
|
|
214
|
+
"deletionScheduled:html": {
|
|
215
|
+
"0": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
216
|
+
"1": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
217
|
+
"2": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
218
|
+
compiler: (string | number)[];
|
|
219
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
220
|
+
usePartial: boolean;
|
|
221
|
+
useData: boolean;
|
|
222
|
+
};
|
|
223
|
+
"deletionScheduled:text": {
|
|
224
|
+
"0": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
225
|
+
"1": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
226
|
+
"2": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
227
|
+
compiler: (string | number)[];
|
|
228
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
229
|
+
useData: boolean;
|
|
230
|
+
};
|
|
231
|
+
"deletionComplete:subject": {
|
|
232
|
+
compiler: (string | number)[];
|
|
233
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
234
|
+
useData: boolean;
|
|
235
|
+
};
|
|
236
|
+
"deletionComplete:html": {
|
|
237
|
+
"0": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
238
|
+
"1": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
239
|
+
compiler: (string | number)[];
|
|
240
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
241
|
+
usePartial: boolean;
|
|
242
|
+
useData: boolean;
|
|
243
|
+
};
|
|
244
|
+
"deletionComplete:text": {
|
|
245
|
+
"0": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
246
|
+
"1": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
|
|
247
|
+
compiler: (string | number)[];
|
|
248
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
249
|
+
useData: boolean;
|
|
250
|
+
};
|
|
165
251
|
"operationalNotice:subject": {
|
|
166
252
|
compiler: (string | number)[];
|
|
167
253
|
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"precompiled.generated.d.ts","sourceRoot":"","sources":["../../src/templates/precompiled.generated.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;CAmL/B,CAAC;AAEF,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"precompiled.generated.d.ts","sourceRoot":"","sources":["../../src/templates/precompiled.generated.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;CAmL/B,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkiDhC,CAAC"}
|