@growth-labs/mailer 0.4.4 → 0.4.6
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/index.d.ts.map +1 -1
- package/dist/index.js +20 -8
- package/dist/index.js.map +1 -1
- package/package.json +10 -6
- package/src/index.ts +24 -8
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAyB,MAAM,cAAc,CAAA;AAmBxE,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,WAAW,EAAE,aAAa,GAAG,gBAAgB,CA0D3E;AAED,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAExE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,YAAY,EACX,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACZ,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EACN,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,kBAAkB,GAClB,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAC7E,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,GACjB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
1
2
|
import { mailerOptionsSchema } from './options.js';
|
|
2
3
|
import { growthLabsMailerPlugin } from './vite-plugin.js';
|
|
4
|
+
function isSourceEntrypoint() {
|
|
5
|
+
return typeof import.meta.url === 'string' && import.meta.url.endsWith('.ts');
|
|
6
|
+
}
|
|
7
|
+
const ENTRYPOINT_EXTENSION = isSourceEntrypoint() ? '.ts' : '.js';
|
|
8
|
+
function resolveEntrypoint(path) {
|
|
9
|
+
if (path.endsWith('.astro')) {
|
|
10
|
+
const sourcePath = isSourceEntrypoint() ? path : `../src/${path.replace(/^\.\//, '')}`;
|
|
11
|
+
return fileURLToPath(new URL(sourcePath, import.meta.url));
|
|
12
|
+
}
|
|
13
|
+
return fileURLToPath(new URL(`${path}${ENTRYPOINT_EXTENSION}`, import.meta.url));
|
|
14
|
+
}
|
|
3
15
|
export default function mailer(userOptions) {
|
|
4
16
|
const options = mailerOptionsSchema.parse(userOptions);
|
|
5
17
|
return {
|
|
@@ -19,35 +31,35 @@ export default function mailer(userOptions) {
|
|
|
19
31
|
// Inject routes
|
|
20
32
|
injectRoute({
|
|
21
33
|
pattern: options.subscribePath,
|
|
22
|
-
entrypoint: '
|
|
34
|
+
entrypoint: resolveEntrypoint('./routes/subscribe'),
|
|
23
35
|
});
|
|
24
36
|
injectRoute({
|
|
25
37
|
pattern: options.confirmPath,
|
|
26
|
-
entrypoint: '
|
|
38
|
+
entrypoint: resolveEntrypoint('./routes/confirm'),
|
|
27
39
|
});
|
|
28
40
|
injectRoute({
|
|
29
41
|
pattern: options.unsubscribePath,
|
|
30
|
-
entrypoint: '
|
|
42
|
+
entrypoint: resolveEntrypoint('./routes/unsubscribe'),
|
|
31
43
|
});
|
|
32
44
|
injectRoute({
|
|
33
45
|
pattern: options.preferencesPath,
|
|
34
|
-
entrypoint: '
|
|
46
|
+
entrypoint: resolveEntrypoint('./routes/preferences.astro'),
|
|
35
47
|
});
|
|
36
48
|
injectRoute({
|
|
37
49
|
pattern: options.webhookPath,
|
|
38
|
-
entrypoint: '
|
|
50
|
+
entrypoint: resolveEntrypoint('./routes/webhook'),
|
|
39
51
|
});
|
|
40
52
|
injectRoute({
|
|
41
53
|
pattern: `${options.trackOpenPath}/[trackingId]`,
|
|
42
|
-
entrypoint: '
|
|
54
|
+
entrypoint: resolveEntrypoint('./routes/track-open'),
|
|
43
55
|
});
|
|
44
56
|
injectRoute({
|
|
45
57
|
pattern: `${options.trackClickPath}/[trackingId]`,
|
|
46
|
-
entrypoint: '
|
|
58
|
+
entrypoint: resolveEntrypoint('./routes/track-click'),
|
|
47
59
|
});
|
|
48
60
|
// Add tracking middleware
|
|
49
61
|
addMiddleware({
|
|
50
|
-
entrypoint: '
|
|
62
|
+
entrypoint: resolveEntrypoint('./middleware/tracking'),
|
|
51
63
|
order: 'post',
|
|
52
64
|
});
|
|
53
65
|
},
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAGxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAEzD,SAAS,kBAAkB;IAC1B,OAAO,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC9E,CAAC;AA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kB,GAClB,MAAM,uBAAuB,CAAA;AAE9B,yCAAyC;AACzC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAC7E,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,GACjB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@growth-labs/mailer",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -58,8 +58,12 @@
|
|
|
58
58
|
},
|
|
59
59
|
"files": [
|
|
60
60
|
"dist",
|
|
61
|
+
"src/**/*.ts",
|
|
62
|
+
"src/**/*.astro",
|
|
63
|
+
"src/**/*.css",
|
|
64
|
+
"src/**/*.md",
|
|
65
|
+
"src/**/*.sql",
|
|
61
66
|
"migrations",
|
|
62
|
-
"src",
|
|
63
67
|
"README.md"
|
|
64
68
|
],
|
|
65
69
|
"publishConfig": {
|
|
@@ -67,7 +71,7 @@
|
|
|
67
71
|
"registry": "https://registry.npmjs.org/"
|
|
68
72
|
},
|
|
69
73
|
"peerDependencies": {
|
|
70
|
-
"astro": "^6.
|
|
74
|
+
"astro": "^6.1.10"
|
|
71
75
|
},
|
|
72
76
|
"peerDependenciesMeta": {
|
|
73
77
|
"@growth-labs/analytics": {
|
|
@@ -75,16 +79,16 @@
|
|
|
75
79
|
}
|
|
76
80
|
},
|
|
77
81
|
"dependencies": {
|
|
78
|
-
"drizzle-orm": "^0.
|
|
82
|
+
"drizzle-orm": "^0.45.2",
|
|
79
83
|
"ulidx": "^2.4.0",
|
|
80
84
|
"zod": "^3.23.0"
|
|
81
85
|
},
|
|
82
86
|
"devDependencies": {
|
|
83
87
|
"@cloudflare/workers-types": "^4.20260402.1",
|
|
84
|
-
"astro": "^6.
|
|
88
|
+
"astro": "^6.1.10",
|
|
85
89
|
"drizzle-kit": "^0.30.0",
|
|
86
90
|
"typescript": "^5.7.0",
|
|
87
|
-
"vite": "^7.
|
|
91
|
+
"vite": "^7.3.2",
|
|
88
92
|
"vitest": "^3.0.0"
|
|
89
93
|
},
|
|
90
94
|
"scripts": {
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
1
2
|
import type { AstroIntegration } from 'astro'
|
|
2
3
|
import type { MailerOptions, ResolvedMailerOptions } from './options.js'
|
|
3
4
|
import { mailerOptionsSchema } from './options.js'
|
|
4
5
|
import { growthLabsMailerPlugin } from './vite-plugin.js'
|
|
5
6
|
|
|
7
|
+
function isSourceEntrypoint(): boolean {
|
|
8
|
+
return typeof import.meta.url === 'string' && import.meta.url.endsWith('.ts')
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const ENTRYPOINT_EXTENSION = isSourceEntrypoint() ? '.ts' : '.js'
|
|
12
|
+
|
|
13
|
+
function resolveEntrypoint(path: string): string {
|
|
14
|
+
if (path.endsWith('.astro')) {
|
|
15
|
+
const sourcePath = isSourceEntrypoint() ? path : `../src/${path.replace(/^\.\//, '')}`
|
|
16
|
+
return fileURLToPath(new URL(sourcePath, import.meta.url))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return fileURLToPath(new URL(`${path}${ENTRYPOINT_EXTENSION}`, import.meta.url))
|
|
20
|
+
}
|
|
21
|
+
|
|
6
22
|
export default function mailer(userOptions: MailerOptions): AstroIntegration {
|
|
7
23
|
const options = mailerOptionsSchema.parse(userOptions) as ResolvedMailerOptions
|
|
8
24
|
|
|
@@ -26,36 +42,36 @@ export default function mailer(userOptions: MailerOptions): AstroIntegration {
|
|
|
26
42
|
// Inject routes
|
|
27
43
|
injectRoute({
|
|
28
44
|
pattern: options.subscribePath,
|
|
29
|
-
entrypoint: '
|
|
45
|
+
entrypoint: resolveEntrypoint('./routes/subscribe'),
|
|
30
46
|
})
|
|
31
47
|
injectRoute({
|
|
32
48
|
pattern: options.confirmPath,
|
|
33
|
-
entrypoint: '
|
|
49
|
+
entrypoint: resolveEntrypoint('./routes/confirm'),
|
|
34
50
|
})
|
|
35
51
|
injectRoute({
|
|
36
52
|
pattern: options.unsubscribePath,
|
|
37
|
-
entrypoint: '
|
|
53
|
+
entrypoint: resolveEntrypoint('./routes/unsubscribe'),
|
|
38
54
|
})
|
|
39
55
|
injectRoute({
|
|
40
56
|
pattern: options.preferencesPath,
|
|
41
|
-
entrypoint: '
|
|
57
|
+
entrypoint: resolveEntrypoint('./routes/preferences.astro'),
|
|
42
58
|
})
|
|
43
59
|
injectRoute({
|
|
44
60
|
pattern: options.webhookPath,
|
|
45
|
-
entrypoint: '
|
|
61
|
+
entrypoint: resolveEntrypoint('./routes/webhook'),
|
|
46
62
|
})
|
|
47
63
|
injectRoute({
|
|
48
64
|
pattern: `${options.trackOpenPath}/[trackingId]`,
|
|
49
|
-
entrypoint: '
|
|
65
|
+
entrypoint: resolveEntrypoint('./routes/track-open'),
|
|
50
66
|
})
|
|
51
67
|
injectRoute({
|
|
52
68
|
pattern: `${options.trackClickPath}/[trackingId]`,
|
|
53
|
-
entrypoint: '
|
|
69
|
+
entrypoint: resolveEntrypoint('./routes/track-click'),
|
|
54
70
|
})
|
|
55
71
|
|
|
56
72
|
// Add tracking middleware
|
|
57
73
|
addMiddleware({
|
|
58
|
-
entrypoint: '
|
|
74
|
+
entrypoint: resolveEntrypoint('./middleware/tracking'),
|
|
59
75
|
order: 'post',
|
|
60
76
|
})
|
|
61
77
|
},
|