@stacksjs/defaults 0.75.660 → 0.75.663

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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: stacks-actions
3
- description: Use when working with Stacks server actions - creating actions in app/Actions/, auto-generated API actions from the useApi model trait, the 780 default framework actions (auth, dashboard, commerce, content, deployment, jobs), action request/response handling, or action registration. Covers @stacksjs/actions and storage/framework/defaults/app/Actions/.
3
+ description: Use when working with Stacks server actions - creating actions in app/Actions/, auto-generated API actions from the useApi model trait, the 781 default framework actions (auth, dashboard, commerce, content, deployment, jobs), action request/response handling, or action registration. Covers @stacksjs/actions and storage/framework/defaults/app/Actions/.
4
4
  license: MIT
5
5
  compatibility: Bun >= 1.3.0, TypeScript
6
6
  allowed-tools: Read Edit Write Bash Grep Glob
@@ -275,6 +275,7 @@ the operation must do both separately.
275
275
  - `Auth.revokeOtherTokens(userId?: number, { exceptTokenId? }): Promise<{ keptTokenId: number | null }>` - keeps `exceptTokenId`, else the request's own token; when neither resolves it revokes every token (fail closed)
276
276
  - `Auth.pruneExpiredTokens(): Promise<number>`
277
277
  - `Auth.pruneRevokedTokens(): Promise<number>`
278
+ - The scheduler runs `auth/prune` daily by default (expired tokens, revoked ones older than 7 days); `pruneTokens: false` in config/auth.ts turns it off. `tokenRotation` is read by nothing, and the scheduler warns when it is set.
278
279
  - `Auth.rotateToken(oldToken: string): Promise<AuthToken | null>`
279
280
  - `Auth.findToken(tokenId: number): Promise<PersonalAccessToken | null>`
280
281
 
@@ -31,11 +31,12 @@ compiler-delivered client surface.
31
31
  `browser-auto-imports.json`: that manifest is compile-time only, and 22 of
32
32
  the 27 `use*` it declares are absent from the runtime. -->
33
33
 
34
- `useAsync`, `useClickOutside`, `useColorMode`, `useCounter`, `useDark`,
35
- `useDebounce`, `useDebouncedValue`, `useEventListener`, `useFetch`, `useFocus`,
36
- `useHead`, `useInterval`, `useLocalStorage`, `useMutation`, `useQuery`,
37
- `useRef`, `useRoute`, `useSearchParams`, `useSeoMeta`, `useSessionStorage`,
38
- `useStore`, `useThrottle`, `useTimeout`, `useToggle`, `useWebSocket`.
34
+ `useAsync`, `useAsyncData`, `useClickOutside`, `useColorMode`, `useCounter`,
35
+ `useDark`, `useDebounce`, `useDebouncedValue`, `useEventListener`, `useFetch`,
36
+ `useFocus`, `useHead`, `useInterval`, `useLocalStorage`, `useMutation`,
37
+ `useQuery`, `useRef`, `useRoute`, `useSearchParams`, `useSeoMeta`,
38
+ `useSessionStorage`, `useStore`, `useThrottle`, `useTimeout`, `useToggle`,
39
+ `useWebSocket`.
39
40
 
40
41
  <!-- auto-imported:end -->
41
42
 
@@ -53,7 +53,11 @@ format/file-writing options. Read config/logging.ts rather than inventing a
53
53
  separate severity vocabulary from another logger.
54
54
 
55
55
  Default local logs live under storage/logs; selected file paths and runtime
56
- fallbacks come from the logger/config. The Log model does not automatically make
56
+ fallbacks come from the logger/config. Daily files (`stacks-YYYY-MM-DD.log`)
57
+ are kept for `retentionDays` in config/logging.ts (default 14, `0` keeps every
58
+ file, LOG_RETENTION_DAYS overrides it); older ones are deleted when the logger
59
+ starts and once a day after, and `stacks.log` and other files there are left
60
+ alone. `pruneDailyLogs(directory, days)` runs the same pass on demand. The Log model does not automatically make
57
61
  every log call a database insert. normalizeError/normalizeContext retain embedded
58
62
  Error detail and bound cause traversal; they are not secret redaction policies.
59
63
 
@@ -104,6 +104,13 @@ of forcing a cast. See `orm/tests/inference-attributes.test-d.ts`.
104
104
  | `validation` | `{ rule, message? }` - declared rules are enforced on direct ORM writes and generated CRUD |
105
105
  | `encrypted` | Encrypt persisted values and decrypt model reads; raw queries still see stored ciphertext |
106
106
 
107
+ `encrypted` applies to the model's own writes and reads only. A write through the
108
+ query builder (`db.insertInto(table).values(row)`) is not encrypted on its own: wrap
109
+ the row with `encryptRow(table, row)`, and decrypt query-builder reads with
110
+ `decryptRow(table, row)` / `decryptRows(table, rows)`, all from `@stacksjs/orm`.
111
+ They take column or attribute names, are idempotent, and throw for a table no loaded
112
+ model defines; `encryptedColumns(table)` lists a table's encrypted columns.
113
+
107
114
  ### Traits
108
115
 
109
116
  | Trait | What it adds |
@@ -21,7 +21,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
21
21
  | `@stacksjs/auth` | [`stacks-auth`](../stacks-auth/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/auth/src/index.ts) | 136 |
22
22
  | `@stacksjs/browser` | [`stacks-browser`](../stacks-browser/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/browser/src/index.ts) | 10 |
23
23
  | `@stacksjs/browser-extension` | [`stacks-browser-extension`](../stacks-browser-extension/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/browser-extension/src/index.ts) | 9 |
24
- | `@stacksjs/buddy` | [`stacks-buddy`](../stacks-buddy/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/src/index.ts) | 219 |
24
+ | `@stacksjs/buddy` | [`stacks-buddy`](../stacks-buddy/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/src/index.ts) | 220 |
25
25
  | `@stacksjs/build` | [`stacks-build`](../stacks-build/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/build/src/index.ts) | 7 |
26
26
  | `@stacksjs/cache` | [`stacks-cache`](../stacks-cache/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/cache/src/index.ts) | 24 |
27
27
  | `@stacksjs/calendar-api` | [`stacks-calendar`](../stacks-calendar/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/calendar-api/src/index.ts) | 5 |
@@ -35,11 +35,11 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
35
35
  | `@stacksjs/composables` | [`stacks-composables`](../stacks-composables/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/composables/src/index.ts) | 18 |
36
36
  | `@stacksjs/config` | [`stacks-config`](../stacks-config/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/config/src/index.ts) | 18 |
37
37
  | `@stacksjs/cron` | [`stacks-cron`](../stacks-cron/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/cron/src/index.ts) | 6 |
38
- | `@stacksjs/database` | [`stacks-database`](../stacks-database/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/index.ts) | 149 |
38
+ | `@stacksjs/database` | [`stacks-database`](../stacks-database/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/index.ts) | 151 |
39
39
  | `@stacksjs/datetime` | [`stacks-datetime`](../stacks-datetime/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/datetime/src/index.ts) | 22 |
40
40
  | `@stacksjs/defaults` | [`stacks-build`](../stacks-build/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/defaults/package.json) | 3 |
41
41
  | `@stacksjs/deploy` | [`stacks-deploy`](../stacks-deploy/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/deploy/package.json) | 1 |
42
- | `@stacksjs/desktop-build` | [`stacks-desktop`](../stacks-desktop/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/index.ts) | 23 |
42
+ | `@stacksjs/desktop-build` | [`stacks-desktop`](../stacks-desktop/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/index.ts) | 24 |
43
43
  | `@stacksjs/development` | [`stacks-development`](../stacks-development/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/development/package.json) | 1 |
44
44
  | `@stacksjs/dns` | [`stacks-dns`](../stacks-dns/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/dns/src/index.ts) | 4 |
45
45
  | `@stacksjs/docs` | [`stacks-docs`](../stacks-docs/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/docs/src/index.ts) | 8 |
@@ -60,13 +60,13 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
60
60
  | `@stacksjs/i18n` | [`stacks-i18n`](../stacks-i18n/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/index.ts) | 7 |
61
61
  | `@stacksjs/image` | [`stacks-image`](../stacks-image/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/image/src/index.ts) | 5 |
62
62
  | `@stacksjs/lint` | [`stacks-lint`](../stacks-lint/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/lint/src/index.ts) | 3 |
63
- | `@stacksjs/logging` | [`stacks-logging`](../stacks-logging/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/logging/src/index.ts) | 14 |
63
+ | `@stacksjs/logging` | [`stacks-logging`](../stacks-logging/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/logging/src/index.ts) | 15 |
64
64
  | `@stacksjs/mobile` | [`stacks-mobile`](../stacks-mobile/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/mobile/src/index.ts) | 23 |
65
65
  | `@stacksjs/model-meta` | [`stacks-models`](../stacks-models/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/model-meta/src/index.ts) | 1 |
66
66
  | `@stacksjs/newsletter` | [`stacks-newsletter`](../stacks-newsletter/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/newsletter/src/index.ts) | 10 |
67
67
  | `@stacksjs/notifications` | [`stacks-notifications`](../stacks-notifications/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/notifications/src/index.ts) | 18 |
68
68
  | `@stacksjs/objects` | [`stacks-objects`](../stacks-objects/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/objects/src/index.ts) | 10 |
69
- | `@stacksjs/orm` | [`stacks-orm`](../stacks-orm/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/index.ts) | 80 |
69
+ | `@stacksjs/orm` | [`stacks-orm`](../stacks-orm/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/index.ts) | 81 |
70
70
  | `@stacksjs/pagination` | [`stacks-pagination`](../stacks-pagination/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/pagination/src/index.ts) | 1 |
71
71
  | `@stacksjs/path` | [`stacks-path`](../stacks-path/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/path/src/index.ts) | 14 |
72
72
  | `@stacksjs/payments` | [`stacks-payments`](../stacks-payments/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/payments/src/index.ts) | 40 |
@@ -77,7 +77,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
77
77
  | `@stacksjs/registry` | [`stacks-registry`](../stacks-registry/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/registry/src/index.ts) | 1 |
78
78
  | `@stacksjs/repl` | [`stacks-repl`](../stacks-repl/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/repl/src/index.ts) | 2 |
79
79
  | `@stacksjs/router` | [`stacks-router`](../stacks-router/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/index.ts) | 114 |
80
- | `@stacksjs/scheduler` | [`stacks-scheduler`](../stacks-scheduler/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/scheduler/src/index.ts) | 19 |
80
+ | `@stacksjs/scheduler` | [`stacks-scheduler`](../stacks-scheduler/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/scheduler/src/index.ts) | 21 |
81
81
  | `@stacksjs/search-engine` | [`stacks-search-engine`](../stacks-search-engine/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/search-engine/src/index.ts) | 11 |
82
82
  | `@stacksjs/security` | [`stacks-security`](../stacks-security/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/security/src/index.ts) | 12 |
83
83
  | `@stacksjs/server` | [`stacks-server`](../stacks-server/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/server/src/index.ts) | 30 |
@@ -91,7 +91,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
91
91
  | `@stacksjs/strings` | [`stacks-strings`](../stacks-strings/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/strings/src/index.ts) | 12 |
92
92
  | `@stacksjs/support` | [`stacks-support`](../stacks-support/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/support/src/index.ts) | 6 |
93
93
  | `@stacksjs/telephony` | [`stacks-telephony`](../stacks-telephony/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/telephony/src/index.ts) | 5 |
94
- | `@stacksjs/testing` | [`stacks-testing`](../stacks-testing/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/index.ts) | 27 |
94
+ | `@stacksjs/testing` | [`stacks-testing`](../stacks-testing/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/index.ts) | 28 |
95
95
  | `@stacksjs/tinker` | [`stacks-repl`](../stacks-repl/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/index.ts) | 4 |
96
96
  | `@stacksjs/tunnel` | [`stacks-tunnel`](../stacks-tunnel/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tunnel/src/index.ts) | 1 |
97
97
  | `@stacksjs/types` | [`stacks-types`](../stacks-types/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/index.ts) | 3 |
@@ -223,7 +223,7 @@ Read the entrypoint and package export map for re-exported or type-only surfaces
223
223
 
224
224
  Local source modules: [src/commands/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/src/commands/index.ts).
225
225
 
226
- Evidence directory: [219 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
226
+ Evidence directory: [220 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
227
227
 
228
228
  ### @stacksjs/build
229
229
 
@@ -361,7 +361,7 @@ Declared runtime exports: `Database`, `EntityQueryBuilder`, `__flushAfterCommitN
361
361
 
362
362
  Local source modules: [src/affected-rows.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/affected-rows.ts), [src/auth-tables.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/auth-tables.ts), [src/custom/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/custom/index.ts), [src/database.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/database.ts), [src/datetime-columns.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/datetime-columns.ts), [src/ddl-constraints.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/ddl-constraints.ts), [src/defaults.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/defaults.ts), [src/dialect.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/dialect.ts), [src/driver-config.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/driver-config.ts), [src/drivers/dynamodb.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/drivers/dynamodb.ts), [src/drivers/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/drivers/index.ts), [src/ensure-database.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/ensure-database.ts), [src/erd.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/erd.ts), [src/fk-audit.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/fk-audit.ts), [src/framework-renames.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/framework-renames.ts), [src/framework-route-admission.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/framework-route-admission.ts), [src/hand-written-migrations.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/hand-written-migrations.ts), [src/held-back-changes.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/held-back-changes.ts), [src/ignored-migrations.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/ignored-migrations.ts), [src/index-shape.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/index-shape.ts), [src/managed-columns.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/managed-columns.ts), [src/migration-dialect.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/migration-dialect.ts), [src/migration-ledger.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/migration-ledger.ts), [src/migration-names.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/migration-names.ts), [src/migration-path.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/migration-path.ts), [src/migrations.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/migrations.ts), [src/model-sources.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/model-sources.ts), [src/notification-tables.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/notification-tables.ts), [src/package-migrations.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/package-migrations.ts), [src/package-models.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/package-models.ts), [src/query-logger.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/query-logger.ts), [src/rbac-tables.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/rbac-tables.ts), [src/relation-columns.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/relation-columns.ts), [src/replicas.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/replicas.ts), [src/row-lease.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/row-lease.ts), [src/row-lock.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/row-lock.ts), [src/safe-migrations.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/safe-migrations.ts), [src/schema-align.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/schema-align.ts), [src/schema-drift.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/schema-drift.ts), [src/seeder.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/seeder.ts), [src/shadowed-models.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/shadowed-models.ts), [src/sql-helpers.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/sql-helpers.ts), [src/table-exists.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/table-exists.ts), [src/trait-tables.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/trait-tables.ts), [src/transaction-context.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/transaction-context.ts), [src/transaction-options.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/transaction-options.ts), [src/types.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/types.ts), [src/unique-audit.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/unique-audit.ts), [src/utc-defaults.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/utc-defaults.ts), [src/utils.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/utils.ts), [src/uuid-columns.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/uuid-columns.ts), [src/vschema.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/vschema.ts).
363
363
 
364
- Evidence directory: [149 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
364
+ Evidence directory: [151 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
365
365
 
366
366
  ### @stacksjs/datetime
367
367
 
@@ -397,7 +397,7 @@ Declared runtime exports: `BUN_EXECUTABLE_MARKER`, `RESERVED_PLIST_KEYS`, `USERL
397
397
 
398
398
  Local source modules: [src/agent-launcher.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/agent-launcher.ts), [src/agent.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/agent.ts), [src/craft-runtime.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/craft-runtime.ts), [src/invites.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/invites.ts), [src/macos-app.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/macos-app.ts), [src/macos-bundle.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/macos-bundle.ts), [src/macos-release.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/macos-release.ts), [src/support.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/support.ts), [src/update-feed.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/update-feed.ts), [src/update-install.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/update-install.ts), [src/update-signing.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/update-signing.ts), [src/updater.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/updater.ts), [src/webview-agent.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/webview-agent.ts), [src/webview-app.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/webview-app.ts), [src/webview-build-record.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/webview-build-record.ts), [src/webview-launcher.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/webview-launcher.ts).
399
399
 
400
- Evidence directory: [23 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
400
+ Evidence directory: [24 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
401
401
 
402
402
  ### @stacksjs/development
403
403
 
@@ -595,9 +595,11 @@ Evidence directory: [3 retained tests](https://github.com/stacksjs/stacks/blob/m
595
595
 
596
596
  Guidance: [`stacks-logging`](../stacks-logging/SKILL.md). Source: [storage/framework/core/logging/src/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/logging/src/index.ts).
597
597
 
598
- Declared runtime exports: `currentLevel`, `dd`, `defaultLogDirectory`, `dump`, `echo`, `formatMessage`, `getLogContext`, `log`, `logger`, `normalizeContext`, `normalizeError`, `parseLogFormat`, `parseLogLevel`, `registerTransport`, `renderNormalizedError`, `report`, `resolveLogSettings`, `struct`, `suppressedAtCurrentLevel`, `transports`, `withLogContext`.
598
+ Declared runtime exports: `DEFAULT_LOG_RETENTION_DAYS`, `currentLevel`, `dd`, `defaultLogDirectory`, `dump`, `echo`, `formatMessage`, `getLogContext`, `log`, `logger`, `normalizeContext`, `normalizeError`, `parseLogFormat`, `parseLogLevel`, `pruneDailyLogs`, `registerTransport`, `renderNormalizedError`, `report`, `resolveLogSettings`, `struct`, `suppressedAtCurrentLevel`, `transports`, `withLogContext`.
599
599
 
600
- Evidence directory: [14 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/logging/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
600
+ Local source modules: [src/retention.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/logging/src/retention.ts).
601
+
602
+ Evidence directory: [15 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/logging/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
601
603
 
602
604
  ### @stacksjs/mobile
603
605
 
@@ -651,11 +653,11 @@ Evidence directory: [10 retained tests](https://github.com/stacksjs/stacks/blob/
651
653
 
652
654
  Guidance: [`stacks-orm`](../stacks-orm/SKILL.md). Source: [storage/framework/core/orm/src/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/index.ts).
653
655
 
654
- Declared runtime exports: `Activity`, `AnalyticsEvent`, `Auction`, `AuctionItem`, `Author`, `Automation`, `AutomationRun`, `BILLABLE_INSTANCE_METHODS`, `Bid`, `Board`, `BoardColumn`, `Campaign`, `CampaignSend`, `CampaignVariant`, `Card`, `CardAttachment`, `CardComment`, `Cart`, `CartItem`, `Categorizable`, `Category`, `Comment`, `CommunicationSuppression`, `ConsentEvent`, `Coupon`, `Courier`, `CourierPing`, `Customer`, `DeliveryRoute`, `DeliveryStop`, `Deployment`, `DigitalDelivery`, `Discount`, `EmailIdempotency`, `EmailList`, `EmailListSubscriber`, `EmailSuppression`, `EmailWebhookEvent`, `ErrorModel`, `FailedJob`, `FeedbackToken`, `Form`, `FormField`, `FormSubmission`, `GdprRequest`, `GiftCard`, `Job`, `Label`, `LicenseActivation`, `LicenseKey`, `LicenseSeat`, `Log`, `LoyaltyPoint`, `LoyaltyReward`, `MagicLinkToken`, `MailPreference`, `Manufacturer`, `Menu`, `MenuItem`, `ModelUnavailableError`, `Notification`, `NotificationDelivery`, `Order`, `OrderIdempotency`, `OrderItem`, `Page`, `PageRevision`, `Payment`, `PaymentMethod`, `PaymentProduct`, `PaymentTransaction`, `PaymentWebhookEvent`, `PersonalAccessToken`, `Pledge`, `Post`, `PostPurchaseOffer`, `PostPurchaseOfferResponse`, `PrintDevice`, `Product`, `ProductUnit`, `ProductVariant`, `QueryLog`, `QueueWorker`, `Receipt`, `Redirect`, `Referral`, `ReferralCode`, `Release`, `Request`, `Review`, `SenderDomain`, `ShippingMethod`, `ShippingRate`, `ShippingZone`, `Site`, `SiteDomain`, `SmsOptOut`, `SocialAccount`, `SocialPost`, `StorageItem`, `StorageItemTask`, `Subscriber`, `SubscriberEmail`, `Subscription`, `SubscriptionNotOwnedError`, `Tag`, `TaxRate`, `Team`, `TeamInvitation`, `TeamMember`, `Transaction`, `UsageEvent`, `User`, `WaitlistProduct`, `WaitlistRestaurant`, `Websocket`, `buildDatabaseSchema`, `collectEncryptedAttributes`, `createAuditMethods`, `createCategorizableMethods`, `createCommentableMethods`, `createLikeableMethods`, `createTaggableMethods`, `customerOwnership`, `decryptValue`, `decryptValueInPlace`, `encryptValue`, `enrichPaginatorUrls`, `filterFillable`, `frameworkModelFeature`, `getWritableFields`, `isBillable`, `isCursorPaginator`, `isEncrypted`, `isPaginator`, `isSimplePaginator`, `isUniqueViolation`, `mapWriteError`, `modelGlobalNames`, `ormReady`, `parentOwnership`, `parseCursor`, `renderDatabaseTypeFile`, `resolveCursorArgs`, `resolvePageArgs`, `selfOwnership`, `setAuditUser`, `siteOwnership`, `teamMembershipOwnership`, `toCursorPaginator`, `toPaginator`, `toSimplePaginator`, `toSnakeCaseKeys`.
656
+ Declared runtime exports: `Activity`, `AnalyticsEvent`, `Auction`, `AuctionItem`, `Author`, `Automation`, `AutomationRun`, `BILLABLE_INSTANCE_METHODS`, `Bid`, `Board`, `BoardColumn`, `Campaign`, `CampaignSend`, `CampaignVariant`, `Card`, `CardAttachment`, `CardComment`, `Cart`, `CartItem`, `Categorizable`, `Category`, `Comment`, `CommunicationSuppression`, `ConsentEvent`, `Coupon`, `Courier`, `CourierPing`, `Customer`, `DeliveryRoute`, `DeliveryStop`, `Deployment`, `DigitalDelivery`, `Discount`, `EmailIdempotency`, `EmailList`, `EmailListSubscriber`, `EmailSuppression`, `EmailWebhookEvent`, `ErrorModel`, `FailedJob`, `FeedbackToken`, `Form`, `FormField`, `FormSubmission`, `GdprRequest`, `GiftCard`, `Job`, `Label`, `LicenseActivation`, `LicenseKey`, `LicenseSeat`, `Log`, `LoyaltyPoint`, `LoyaltyReward`, `MagicLinkToken`, `MailPreference`, `Manufacturer`, `Menu`, `MenuItem`, `ModelUnavailableError`, `Notification`, `NotificationDelivery`, `Order`, `OrderIdempotency`, `OrderItem`, `Page`, `PageRevision`, `Payment`, `PaymentMethod`, `PaymentProduct`, `PaymentTransaction`, `PaymentWebhookEvent`, `PersonalAccessToken`, `Pledge`, `Post`, `PostPurchaseOffer`, `PostPurchaseOfferResponse`, `PrintDevice`, `Product`, `ProductUnit`, `ProductVariant`, `QueryLog`, `QueueWorker`, `Receipt`, `Redirect`, `Referral`, `ReferralCode`, `Release`, `Request`, `Review`, `SenderDomain`, `ShippingMethod`, `ShippingRate`, `ShippingZone`, `Site`, `SiteDomain`, `SmsOptOut`, `SocialAccount`, `SocialPost`, `StorageItem`, `StorageItemTask`, `Subscriber`, `SubscriberEmail`, `Subscription`, `SubscriptionNotOwnedError`, `Tag`, `TaxRate`, `Team`, `TeamInvitation`, `TeamMember`, `Transaction`, `UsageEvent`, `User`, `WaitlistProduct`, `WaitlistRestaurant`, `Websocket`, `buildDatabaseSchema`, `collectEncryptedAttributes`, `createAuditMethods`, `createCategorizableMethods`, `createCommentableMethods`, `createLikeableMethods`, `createTaggableMethods`, `customerOwnership`, `decryptRow`, `decryptRows`, `decryptValue`, `decryptValueInPlace`, `encryptRow`, `encryptValue`, `encryptedColumns`, `enrichPaginatorUrls`, `filterFillable`, `frameworkModelFeature`, `getWritableFields`, `isBillable`, `isCursorPaginator`, `isEncrypted`, `isPaginator`, `isSimplePaginator`, `isUniqueViolation`, `mapWriteError`, `modelGlobalNames`, `ormReady`, `parentOwnership`, `parseCursor`, `renderDatabaseTypeFile`, `resolveCursorArgs`, `resolvePageArgs`, `selfOwnership`, `setAuditUser`, `siteOwnership`, `teamMembershipOwnership`, `toCursorPaginator`, `toPaginator`, `toSimplePaginator`, `toSnakeCaseKeys`.
655
657
 
656
658
  Local source modules: [src/auto-crud.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/auto-crud.ts), [src/batch-loader.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/batch-loader.ts), [src/db.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/db.ts), [src/define-model.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/define-model.ts), [src/extend-model.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/extend-model.ts), [src/gdpr/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/gdpr/index.ts), [src/generate-database-schema.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/generate-database-schema.ts), [src/locked-row.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/locked-row.ts), [src/messaging.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/messaging.ts), [src/model-types.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/model-types.ts), [src/ownership.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/ownership.ts), [src/paginator-request.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/paginator-request.ts), [src/row-token.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/row-token.ts), [src/subquery.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/subquery.ts), [src/traits/audit.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/traits/audit.ts), [src/traits/billable.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/traits/billable.ts), [src/traits/categorizable.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/traits/categorizable.ts), [src/traits/commentable.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/traits/commentable.ts), [src/traits/likeable.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/traits/likeable.ts), [src/traits/taggable.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/traits/taggable.ts), [src/transaction.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/transaction.ts), [src/types.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/types.ts), [src/utils/encrypted.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/utils/encrypted.ts), [src/utils/prunable.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/src/utils/prunable.ts).
657
659
 
658
- Evidence directory: [80 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
660
+ Evidence directory: [81 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/orm/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
659
661
 
660
662
  ### @stacksjs/pagination
661
663
 
@@ -759,7 +761,7 @@ Read the entrypoint and package export map for re-exported or type-only surfaces
759
761
 
760
762
  Local source modules: [src/run.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/scheduler/src/run.ts), [src/schedule.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/scheduler/src/schedule.ts), [src/types.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/scheduler/src/types.ts).
761
763
 
762
- Evidence directory: [19 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/scheduler/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
764
+ Evidence directory: [21 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/scheduler/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
763
765
 
764
766
  ### @stacksjs/search-engine
765
767
 
@@ -897,7 +899,7 @@ Read the entrypoint and package export map for re-exported or type-only surfaces
897
899
 
898
900
  Local source modules: [src/console.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/console.ts), [src/disposable-database.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/disposable-database.ts), [src/events.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/events.ts), [src/feature.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/feature.ts), [src/isolated.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/isolated.ts), [src/mail.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/mail.ts), [src/schema.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/schema.ts), [src/service.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/service.ts), [src/time.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/time.ts).
899
901
 
900
- Evidence directory: [27 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
902
+ Evidence directory: [28 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
901
903
 
902
904
  ### @stacksjs/tinker
903
905
 
@@ -252,6 +252,14 @@ import { runScheduler } from '@stacksjs/scheduler'
252
252
  const result = await runScheduler()
253
253
  ```
254
254
 
255
+ Last, `runScheduler()` adds the framework's own housekeeping (`maintenance.ts`):
256
+ `auth/prune` (what `buddy auth:prune` does: expired tokens, and revoked ones
257
+ older than 7 days) daily at 03:15, unless the app already schedules
258
+ `auth/prune` itself or `config/auth.ts` sets `pruneTokens: false`. It also warns
259
+ when `config/auth.ts` still sets the dead `tokenRotation`. `buddy dev` starts
260
+ the scheduler only for an app with an app/Scheduler.ts or a job, so an app
261
+ with neither prunes only where `schedule:run` runs.
262
+
255
263
  ## Queue-Level Scheduler (queue/src/scheduler.ts)
256
264
 
257
265
  A separate, queue-integrated scheduler that discovers jobs and dispatches them to the queue system:
@@ -302,6 +310,8 @@ process.on('SIGINT', () => {
302
310
 
303
311
  - `buddy schedule:run` -- Runs `Action.ScheduleRun`, which calls `runScheduler()`
304
312
  - Options: `-p, --project [project]`, `--verbose`
313
+ - `buddy dev` -- Runs the same `Action.ScheduleRun` beside the dev servers whenever the app has an `app/Scheduler.ts` or a job in `app/Jobs/`, and says so in the ready banner. `--no-schedule` or `STACKS_DEV_SCHEDULE=0` turns it off, for an app whose tasks send email or post for real.
314
+ - A process whose only tasks are sub-minute (`everySecond()`) does not stay up: those interval timers are `unref()`'d. A minute-or-longer task keeps it running.
305
315
 
306
316
  ## Code Examples
307
317
 
@@ -37,6 +37,17 @@ auto-imported names exist in a test. Without it, loading an action written
37
37
  without imports throws "Action is not defined". `setupTestEnvironment()` still
38
38
  exists and only sets the env.
39
39
 
40
+ For an app suite, `bootTestEnvironment()` also gives the run a throwaway SQLite
41
+ database: a `stacks_test_*.sqlite` file in a temporary directory, set as
42
+ `DB_DATABASE_PATH` before the app's config loads and removed when the run ends.
43
+ `refreshDatabase()` migrates it the first time a test asks. The suite used to run
44
+ against whatever `.env` named, which on a developer's machine is their real data.
45
+ A Postgres or MySQL run keeps its configured database (the reset refuses one whose
46
+ name doesn't say it's for tests), and `STACKS_TEST_DATABASE=configured` keeps a
47
+ configured SQLite file too. The SQLite reset now acts on the connection's own file
48
+ and refuses one the run didn't create, unless it's under the temporary directory or
49
+ named for tests (`app_test.sqlite`).
50
+
40
51
  ```typescript
41
52
  import { refreshDatabase, setupDatabase, truncateMysql, truncatePostgres, truncateSqlite } from '@stacksjs/testing/database'
42
53
 
@@ -2,6 +2,19 @@ import { Action } from '@stacksjs/actions/runtime'
2
2
  import { isUniqueViolation, Subscriber, SubscriberEmail } from '@stacksjs/orm'
3
3
  import { rateLimit } from '@stacksjs/router'
4
4
  import { sendSubscriptionConfirmation } from '../Mail/SubscriptionConfirmation'
5
+ import { formReturnLocation, normalizeEmail, wantsFormRedirect } from './form-return'
6
+
7
+ /**
8
+ * What a signup came to. A plain form gets it back as `?subscribe=<outcome>`;
9
+ * a script gets the JSON beside it.
10
+ *
11
+ * - `subscribed`: a new address, or one that had unsubscribed and came back.
12
+ * - `already`: the address is on the list.
13
+ * - `invalid`: not an email address.
14
+ * - `busy`: too many attempts from this visitor in a minute.
15
+ * - `error`: anything else. Logged here; the visitor is asked to try again.
16
+ */
17
+ type Outcome = 'subscribed' | 'already' | 'invalid' | 'busy' | 'error'
5
18
 
6
19
  export default new Action({
7
20
  name: 'SubscriberEmailAction',
@@ -9,52 +22,84 @@ export default new Action({
9
22
  method: 'POST',
10
23
 
11
24
  async handle(request: RequestInstance) {
12
- // Per-IP throttle. The endpoint is unauthenticated and skipCsrf'd so
13
- // bots will find it; without this they can flood the subscribers
14
- // table within minutes and burn through SES/SendGrid quota. 10/min
15
- // is generous for a real human filling the same form repeatedly.
16
- await rateLimit('email-subscribe', 10).per('minute')
17
-
18
- const email = request.get('email')
19
- const source = request.get('source') || 'homepage'
25
+ // A plain <form> post goes back to its page with the outcome in the query
26
+ // string (see ./form-return.ts), so a visitor never lands on raw JSON or
27
+ // an error screen. A script keeps getting JSON, and errors, as before.
28
+ const backToForm = wantsFormRedirect(request.headers)
29
+ const answer = (outcome: Outcome, json: Record<string, unknown>) => backToForm
30
+ ? response.redirect(formReturnLocation({ target: request.get('return'), referer: request.headers.get('referer'), param: 'subscribe', outcome }), 303)
31
+ : json
20
32
 
21
- if (!email || !email.includes('@')) {
22
- return { success: false, message: 'A valid email is required' }
23
- }
24
-
25
- // Check if subscriber already exists
26
- const existingSubscriber = await Subscriber.where('email', email).first()
27
- if (existingSubscriber) {
28
- return { success: true, message: 'Already subscribed' }
29
- }
30
-
31
- // Create subscriber record. The check above is a fast path; two requests
32
- // for the same email can still both pass it and race into the
33
- // subscribers.email unique index (#1957). Treat the loser's unique
34
- // violation as the same "already subscribed" success — the response
35
- // contract (and its enumeration semantics) is unchanged.
36
- let subscriber: any
37
33
  try {
38
- subscriber = await Subscriber.create({ email, status: 'subscribed', source })
34
+ // Per-IP throttle. The endpoint is unauthenticated and skipCsrf'd so
35
+ // bots will find it; without this they can flood the subscribers
36
+ // table within minutes and burn through SES/SendGrid quota. 10/min
37
+ // is generous for a real human filling the same form repeatedly.
38
+ await rateLimit('email-subscribe', 10).per('minute')
39
39
  }
40
40
  catch (err) {
41
- if (isUniqueViolation(err))
42
- return { success: true, message: 'Already subscribed' }
41
+ if (backToForm && (err as { status?: number })?.status === 429)
42
+ return answer('busy', {})
43
43
  throw err
44
44
  }
45
45
 
46
- // Log the email event
47
- await SubscriberEmail.create({ email, source })
46
+ const email = normalizeEmail(request.get('email'))
47
+ const source = String(request.get('source') || 'homepage').slice(0, 120)
48
+
49
+ if (!email)
50
+ return answer('invalid', { success: false, message: 'A valid email is required' })
51
+
52
+ try {
53
+ const existing = await Subscriber.where('email', email).first()
54
+
55
+ if (existing) {
56
+ if (existing.status !== 'unsubscribed')
57
+ return answer('already', { success: true, message: 'Already subscribed' })
58
+
59
+ // They left and came back. Telling them "already subscribed" while
60
+ // the row still says unsubscribed would keep them off every send.
61
+ await existing.update({ status: 'subscribed', unsubscribed_at: null, source })
62
+ await SubscriberEmail.create({ email, source })
63
+ welcome(email, existing.uuid)
64
+ return answer('subscribed', { success: true, message: 'Subscribed' })
65
+ }
66
+
67
+ // Create subscriber record. The check above is a fast path; two requests
68
+ // for the same email can still both pass it and race into the
69
+ // subscribers.email unique index (#1957). Treat the loser's unique
70
+ // violation as the same "already subscribed" success — the response
71
+ // contract (and its enumeration semantics) is unchanged.
72
+ let subscriber: any
73
+ try {
74
+ subscriber = await Subscriber.create({ email, status: 'subscribed', source })
75
+ }
76
+ catch (err) {
77
+ if (isUniqueViolation(err))
78
+ return answer('already', { success: true, message: 'Already subscribed' })
79
+ throw err
80
+ }
48
81
 
49
- // Send subscription confirmation email asynchronously (do not block the response)
50
- sendSubscriptionConfirmation({
51
- to: email,
52
- subscriberUuid: subscriber.uuid,
53
- }).catch((err: unknown) => {
54
- const message = err instanceof Error ? err.message : String(err)
55
- console.error(`Failed to send confirmation email to ${email}:`, message)
56
- })
82
+ // Log the email event
83
+ await SubscriberEmail.create({ email, source })
57
84
 
58
- return { success: true, subscriber }
85
+ welcome(email, subscriber.uuid)
86
+
87
+ return answer('subscribed', { success: true, subscriber })
88
+ }
89
+ catch (err) {
90
+ if (!backToForm)
91
+ throw err
92
+
93
+ console.error('[subscribe] signup failed:', err instanceof Error ? err.message : String(err))
94
+ return answer('error', {})
95
+ }
59
96
  },
60
97
  })
98
+
99
+ /** Send the welcome email without holding up the response; a failure is logged. */
100
+ function welcome(to: string, subscriberUuid: string): void {
101
+ sendSubscriptionConfirmation({ to, subscriberUuid }).catch((err: unknown) => {
102
+ const message = err instanceof Error ? err.message : String(err)
103
+ console.error(`Failed to send confirmation email to ${to}:`, message)
104
+ })
105
+ }
@@ -1,5 +1,6 @@
1
1
  import type { RequestInstance } from '@stacksjs/types'
2
2
  import { Action } from '@stacksjs/actions/runtime'
3
+ import { config } from '@stacksjs/config'
3
4
  import { EmailList, EmailListSubscriber, Subscriber } from '@stacksjs/orm'
4
5
 
5
6
  export default new Action({
@@ -83,26 +84,51 @@ export default new Action({
83
84
  },
84
85
  })
85
86
 
87
+ function escapeHtml(value: string): string {
88
+ return value.replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', '\'': '&#39;' }[c]!))
89
+ }
90
+
91
+ /**
92
+ * The page an unsubscribe link lands on.
93
+ *
94
+ * It names the app the visitor subscribed to, from config, rather than
95
+ * stacksjs.com, which every app using this default used to print. The
96
+ * message carries the subscriber's stored address, so everything is escaped.
97
+ */
86
98
  function unsubscribePage(title: string, message: string, success: boolean): string {
87
- const icon = success ? '&#10003;' : '&#10007;'
88
- const iconColor = success ? '#22c55e' : '#ef4444'
99
+ const appName = escapeHtml(config.app?.name || 'Home')
100
+ const rawUrl = String(config.app?.url || '/')
101
+ const appUrl = escapeHtml(/^https?:\/\//.test(rawUrl) || rawUrl.startsWith('/') ? rawUrl : `https://${rawUrl}`)
102
+ const accent = success ? '#1747c9' : '#dc2626'
103
+ const icon = success ? '&#10003;' : '&#33;'
89
104
 
90
105
  return `<!DOCTYPE html>
91
106
  <html lang="en">
92
107
  <head>
93
108
  <meta charset="UTF-8">
94
109
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
95
- <title>${title}</title>
110
+ <meta name="robots" content="noindex">
111
+ <meta name="color-scheme" content="light dark">
112
+ <title>${escapeHtml(title)} - ${appName}</title>
113
+ <style>
114
+ :root { --bg: #f6f7f9; --card: #ffffff; --text: #0b1220; --muted: #4a5468; --line: rgba(11, 18, 32, 0.1); }
115
+ @media (prefers-color-scheme: dark) { :root { --bg: #070b14; --card: #0d1322; --text: #e8edf7; --muted: #9ba7be; --line: rgba(232, 237, 247, 0.1); } }
116
+ * { box-sizing: border-box; }
117
+ body { margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }
118
+ main { width: min(440px, 100%); padding: 40px 32px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); text-align: center; }
119
+ .icon { display: inline-grid; place-items: center; width: 56px; height: 56px; margin-bottom: 20px; border-radius: 50%; color: ${accent}; font-size: 24px; font-weight: 700; background: ${accent}1a; }
120
+ h1 { margin: 0 0 10px; font-size: 22px; letter-spacing: -0.01em; }
121
+ p { margin: 0 0 28px; color: var(--muted); font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
122
+ a { display: inline-block; padding: 11px 20px; border-radius: 10px; color: #fff; font-size: 14px; font-weight: 600; text-decoration: none; background: #1747c9; }
123
+ </style>
96
124
  </head>
97
- <body style="margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #0e0e0e; color: #d4d4d4; display: flex; align-items: center; justify-content: center; min-height: 100vh;">
98
- <div style="max-width: 480px; margin: 0 auto; padding: 40px 20px; text-align: center;">
99
- <div style="width: 64px; height: 64px; border-radius: 50%; background-color: ${iconColor}20; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 24px;">
100
- <span style="font-size: 28px; color: ${iconColor};">${icon}</span>
101
- </div>
102
- <h1 style="color: #ececec; font-size: 24px; font-weight: 600; margin: 0 0 12px;">${title}</h1>
103
- <p style="color: #a0a0a0; font-size: 16px; line-height: 1.6; margin: 0 0 32px;">${message}</p>
104
- <a href="https://stacksjs.com" style="color: #888; font-size: 13px; text-decoration: none;">stacksjs.com</a>
105
- </div>
125
+ <body>
126
+ <main>
127
+ <div class="icon" aria-hidden="true">${icon}</div>
128
+ <h1>${escapeHtml(title)}</h1>
129
+ <p>${escapeHtml(message)}</p>
130
+ <a href="${appUrl}">Back to ${appName}</a>
131
+ </main>
106
132
  </body>
107
133
  </html>`
108
134
  }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Sending a plain HTML form back to the page it came from.
3
+ *
4
+ * The public forms (newsletter signup, contact) post straight to the API with
5
+ * no JavaScript in between. Answered with JSON, a visitor who submits one is
6
+ * left on a page of raw `{"success":true,...}` with no way back but the back
7
+ * button. A browser form post asks for HTML, so it gets a 303 back to the page
8
+ * instead, with the outcome in the query string for that page to render. A
9
+ * `fetch()` asks for anything (`Accept: *\/*`) and keeps getting JSON.
10
+ */
11
+
12
+ /**
13
+ * An email address as a public form should store it, or null.
14
+ *
15
+ * Trimmed and lowercased, so `Ada@Example.com ` and `ada@example.com` are one
16
+ * subscriber, and held to the shape every mail system accepts: one `@`, a
17
+ * dot in the domain, no spaces or angle brackets, at most 254 characters.
18
+ * Checking only for an `@` let `<b>@x` into the list and onto every page
19
+ * that prints an address.
20
+ */
21
+ export function normalizeEmail(value: unknown): string | null {
22
+ if (typeof value !== 'string')
23
+ return null
24
+
25
+ const email = value.trim().toLowerCase()
26
+ if (email.length > 254)
27
+ return null
28
+
29
+ return /^[^\s@<>"'(),;:]+@[^\s@<>"'(),;:]+\.[^\s@<>"'(),;:]{2,}$/.test(email) ? email : null
30
+ }
31
+
32
+ /** Whether the request is a browser submitting a `<form>`, rather than a script. */
33
+ export function wantsFormRedirect(headers: Headers): boolean {
34
+ const accept = headers.get('accept') || ''
35
+ const type = headers.get('content-type') || ''
36
+ const isForm = type.includes('application/x-www-form-urlencoded') || type.includes('multipart/form-data')
37
+ return isForm && accept.includes('text/html')
38
+ }
39
+
40
+ /**
41
+ * A same-site path, or null. Only a path is ever accepted, never a host: a
42
+ * return address that could name another site would make this endpoint an
43
+ * open redirect for anyone who can link to it.
44
+ */
45
+ function sitePath(value: unknown): string | null {
46
+ if (typeof value !== 'string')
47
+ return null
48
+
49
+ const path = value.trim()
50
+ // `//host` and `/\host` are both read as another origin by browsers.
51
+ if (!path.startsWith('/') || path.startsWith('//') || path.includes('\\'))
52
+ return null
53
+ // eslint-disable-next-line no-control-regex
54
+ if (/[\u0000-\u001F\u007F]/.test(path))
55
+ return null
56
+
57
+ return path
58
+ }
59
+
60
+ /** The path, query and fragment of a Referer, or null when there is none. */
61
+ function refererPath(referer: string | null): string | null {
62
+ if (!referer)
63
+ return null
64
+
65
+ try {
66
+ const url = new URL(referer)
67
+ return `${url.pathname}${url.search}${url.hash}`
68
+ }
69
+ catch {
70
+ return null
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Where to send the browser: the form's own `return` field when it names a
76
+ * path on this site, else the page in the Referer, else the home page, with
77
+ * `?<param>=<outcome>` set on it. A fragment in `return` is kept, so a page
78
+ * with two forms can bring the reader back to the one they used.
79
+ */
80
+ export function formReturnLocation(options: { target?: unknown, referer?: string | null, param: string, outcome: string }): string {
81
+ const path = sitePath(options.target) ?? sitePath(refererPath(options.referer ?? null)) ?? '/'
82
+ const url = new URL(path, 'http://return.invalid')
83
+ url.searchParams.set(options.param, options.outcome)
84
+ return `${url.pathname}${url.search}${url.hash}`
85
+ }
@@ -1,5 +1,6 @@
1
1
  import { config } from '@stacksjs/config'
2
2
  import { mail, template } from '@stacksjs/email'
3
+ import { buildUnsubscribeHeaders } from '@stacksjs/newsletter'
3
4
  import { url } from '@stacksjs/router'
4
5
 
5
6
  export interface SubscriptionConfirmationOptions {
@@ -7,23 +8,51 @@ export interface SubscriptionConfirmationOptions {
7
8
  subscriberUuid: string
8
9
  }
9
10
 
11
+ /** The app's own address, with a scheme, for links in the email. */
12
+ function appUrl(): string {
13
+ const raw = String(config.app.url || '').trim().replace(/\/+$/, '')
14
+ if (!raw)
15
+ return ''
16
+ return /^https?:\/\//.test(raw) ? raw : `https://${raw}`
17
+ }
18
+
19
+ /**
20
+ * The RFC 8058 `List-Unsubscribe` headers, so the inbox's own unsubscribe
21
+ * button works (POST `/api/email/unsubscribe`). They need an absolute URL;
22
+ * without one the email still goes, with only the link in its body.
23
+ */
24
+ function unsubscribeHeaders(unsubscribeUrl: string): Record<string, string> | undefined {
25
+ try {
26
+ return buildUnsubscribeHeaders({ url: unsubscribeUrl })
27
+ }
28
+ catch {
29
+ return undefined
30
+ }
31
+ }
32
+
10
33
  /**
11
34
  * Send a subscription confirmation email with an unsubscribe link.
12
35
  *
13
- * Uses the `resources/emails/subscription-confirmation.stx` template.
36
+ * Uses the `resources/emails/subscription-confirmation.stx` template, and
37
+ * passes it the app's name and address so a template never has to fall back
38
+ * to the framework's.
14
39
  */
15
40
  export async function sendSubscriptionConfirmation(options: SubscriptionConfirmationOptions): Promise<void> {
16
41
  const { to, subscriberUuid } = options
17
42
 
18
43
  const appName = config.app.name || 'Stacks'
19
44
  const unsubscribeUrl = url('email.unsubscribe', { token: subscriberUuid })
45
+ const subject = `You are on the ${appName} list`
20
46
 
21
47
  const { html, text } = await template('subscription-confirmation', {
22
48
  variables: {
23
49
  email: to,
24
50
  unsubscribeUrl,
51
+ appName,
52
+ appUrl: appUrl(),
53
+ year: new Date().getFullYear(),
25
54
  },
26
- subject: `Welcome to ${appName}!`,
55
+ subject,
27
56
  })
28
57
 
29
58
  await mail.sendOrFail({
@@ -32,9 +61,10 @@ export async function sendSubscriptionConfirmation(options: SubscriptionConfirma
32
61
  name: config.email.from?.name || appName,
33
62
  address: config.email.from?.address || 'hello@stacksjs.com',
34
63
  },
35
- subject: `Welcome to ${appName}!`,
64
+ subject,
36
65
  html,
37
66
  text,
67
+ headers: unsubscribeHeaders(unsubscribeUrl),
38
68
  })
39
69
  }
40
70
 
@@ -81,7 +81,7 @@ export default defineModel({
81
81
  failed_at: {
82
82
  fillable: true,
83
83
  validation: {
84
- rule: schema.date(),
84
+ rule: schema.timestamp(),
85
85
  },
86
86
  factory: () => '2024-12-23 13:32:19',
87
87
  },
@@ -14,7 +14,7 @@ export default defineModel({
14
14
  referredUserId: { required: true, unique: true, validation: { rule: schema.number().integer().min(1) } },
15
15
  code: { required: true, validation: { rule: schema.string().max(24) } },
16
16
  status: { required: true, default: 'registered', validation: { rule: schema.enum(['registered', 'qualified']) } },
17
- qualifiedAt: { nullable: true, validation: { rule: schema.date() } },
17
+ qualifiedAt: { nullable: true, validation: { rule: schema.timestamp() } },
18
18
  },
19
19
 
20
20
  dashboard: {
@@ -122,7 +122,7 @@ export default defineModel({
122
122
  order: 7,
123
123
  fillable: true,
124
124
  validation: {
125
- rule: schema.date().required(),
125
+ rule: schema.timestamp().required(),
126
126
  },
127
127
  factory: faker => faker.date.soon().toISOString(),
128
128
  },
@@ -131,7 +131,7 @@ export default defineModel({
131
131
  order: 8,
132
132
  fillable: true,
133
133
  validation: {
134
- rule: schema.date().required(),
134
+ rule: schema.timestamp().required(),
135
135
  },
136
136
  factory: faker => faker.date.future().toISOString(),
137
137
  },
@@ -187,7 +187,7 @@ export default defineModel({
187
187
  order: 13,
188
188
  fillable: true,
189
189
  validation: {
190
- rule: schema.date(),
190
+ rule: schema.timestamp(),
191
191
  },
192
192
  factory: () => null,
193
193
  },
@@ -119,7 +119,7 @@ export default defineModel({
119
119
  order: 6,
120
120
  fillable: true,
121
121
  validation: {
122
- rule: schema.date().required(),
122
+ rule: schema.timestamp().required(),
123
123
  },
124
124
  factory: faker => faker.date.recent().toISOString(),
125
125
  },
@@ -133,7 +133,7 @@ export default defineModel({
133
133
  order: 9,
134
134
  fillable: true,
135
135
  validation: {
136
- rule: schema.date(),
136
+ rule: schema.timestamp(),
137
137
  },
138
138
  factory: faker => faker.date.future().toISOString().slice(0, 19).replace('T', ' '),
139
139
  },
@@ -141,7 +141,7 @@ export default defineModel({
141
141
  order: 10,
142
142
  fillable: true,
143
143
  validation: {
144
- rule: schema.date(),
144
+ rule: schema.timestamp(),
145
145
  },
146
146
  factory: faker => faker.date.future().toISOString().slice(0, 19).replace('T', ' '),
147
147
  },
@@ -149,7 +149,7 @@ export default defineModel({
149
149
  order: 11,
150
150
  fillable: true,
151
151
  validation: {
152
- rule: schema.date(),
152
+ rule: schema.timestamp(),
153
153
  },
154
154
  factory: faker => faker.date.future().toISOString().slice(0, 19).replace('T', ' '),
155
155
  },
@@ -2,7 +2,7 @@
2
2
  "publisher": "Stacks",
3
3
  "name": "vscode-stacks",
4
4
  "displayName": "Stacks",
5
- "version": "0.75.660",
5
+ "version": "0.75.663",
6
6
  "description": "Stacks, built into VS Code: stx templates, pickier linting and formatting, encrypted env files, the dev server preview and every buddy command. No other extensions required.",
7
7
  "license": "MIT",
8
8
  "funding": "https://github.com/sponsors/chrisbbreuer",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/defaults",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.660",
5
+ "version": "0.75.663",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/stacksjs/stacks.git",
@@ -45,14 +45,14 @@
45
45
  "dependencies": {
46
46
  "@iconify-json/f7": "^1.2.2",
47
47
  "@iconify-json/hugeicons": "^1.2.35",
48
- "@stacksjs/mobile": "0.75.660",
49
- "@stacksjs/sanitizer": "^0.2.908",
50
- "@stacksjs/stx": "^0.2.908",
51
- "@stacksjs/strings": "0.75.660",
48
+ "@stacksjs/mobile": "0.75.663",
49
+ "@stacksjs/sanitizer": "^0.2.927",
50
+ "@stacksjs/stx": "^0.2.927",
51
+ "@stacksjs/strings": "0.75.663",
52
52
  "@xterm/addon-fit": "^0.11.0",
53
53
  "@xterm/xterm": "^6.0.0",
54
54
  "ts-qr-codes": "^0.1.8",
55
- "@stacksjs/support": "0.75.660",
56
- "@stacksjs/browser": "0.75.660"
55
+ "@stacksjs/support": "0.75.663",
56
+ "@stacksjs/browser": "0.75.663"
57
57
  }
58
58
  }
@@ -19,8 +19,10 @@ export interface AuthConfig {
19
19
  username: string
20
20
  password: string
21
21
  tokenExpiry: number
22
- /** @deprecated Use explicit bearer rotation or a refresh-token exchange. */
22
+ /** @deprecated Read by nothing. Use explicit bearer rotation or a refresh-token exchange. */
23
23
  tokenRotation?: number
24
+ /** Whether the scheduler prunes expired and old revoked tokens daily. Default `true`. */
25
+ pruneTokens?: boolean
24
26
  defaultAbilities: string[]
25
27
  defaultTokenName: string
26
28
  }
@@ -1,99 +1,34 @@
1
1
  <script server>
2
+ // The default welcome for a newsletter signup, sent by SubscriptionConfirmation
3
+ // (defaults/app/Mail) when someone subscribes through /api/email/subscribe.
4
+ //
5
+ // It speaks for the app, not for Stacks: the name and address come from the
6
+ // app's config. It used to describe Stacks as "a rapid application development
7
+ // framework" in every app's welcome email. An app overrides it with its own
8
+ // resources/emails/subscription-confirmation.stx.
2
9
  const email = props.email || ''
3
10
  const unsubscribeUrl = props.unsubscribeUrl || '#'
4
- const appName = props.appName || 'Stacks'
5
- const appUrl = props.appUrl || 'https://stacksjs.com'
11
+ const appName = props.appName || 'our newsletter'
12
+ const appUrl = props.appUrl || ''
6
13
  const primaryColor = props.primaryColor || '#3451b2'
7
14
  const year = props.year || new Date().getFullYear()
15
+ const subject = `You are on the ${appName} list`
8
16
  </script>
9
17
 
10
- <!DOCTYPE html>
11
- <html lang="en">
12
- <head>
13
- <meta charset="UTF-8">
14
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
15
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
16
- <title>Welcome to {{ appName }}</title>
17
- </head>
18
- <body style="margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #0e0e0e; line-height: 1.6; color: #d4d4d4;">
19
- <table role="presentation" cellpadding="0" cellspacing="0" style="width: 100%; border-collapse: collapse;">
20
- <tr>
21
- <td style="padding: 40px 20px;">
22
- <table role="presentation" cellpadding="0" cellspacing="0" style="max-width: 600px; margin: 0 auto;">
23
-
24
- <!-- Logo -->
25
- <tr>
26
- <td style="text-align: center; padding-bottom: 32px;">
27
- <h1 style="color: #ececec; font-size: 28px; font-weight: 600; margin: 0;">{{ appName }}</h1>
28
- </td>
29
- </tr>
30
-
31
- <!-- Main Content -->
32
- <tr>
33
- <td style="background-color: #1a1a1a; border-radius: 12px; padding: 40px;">
34
-
35
- <h2 style="color: #ececec; font-size: 22px; font-weight: 600; margin: 0 0 16px;">Thanks for subscribing!</h2>
36
-
37
- <p style="color: #a0a0a0; font-size: 16px; line-height: 1.6; margin: 0 0 16px;">
38
- You're now on the list. We'll keep you in the loop on new releases, features, and framework updates.
39
- </p>
18
+ <EmailLayout title="{{ subject }}" preheader="Thanks for subscribing to {{ appName }}." brand="{{ appName }}" brandUrl="{{ appUrl }}" accent="{{ primaryColor }}">
19
+ <EmailText size="heading">Thanks for subscribing.</EmailText>
20
+ <EmailText>You are on the {{ appName }} list. We will write when there is something worth reading, and never more than that.</EmailText>
40
21
 
41
- <p style="color: #a0a0a0; font-size: 16px; line-height: 1.6; margin: 0 0 24px;">
42
- {{ appName }} is a rapid application development framework that helps you build type-safe web apps, APIs, and cloud infrastructure with ease.
43
- </p>
22
+ @if (appUrl)
23
+ <EmailButton href="{{ appUrl }}" bg="{{ primaryColor }}">Visit {{ appName }}</EmailButton>
24
+ @endif
44
25
 
45
- <!-- CTA Button -->
46
- <table role="presentation" cellpadding="0" cellspacing="0" style="margin: 0 0 24px;">
47
- <tr>
48
- <td>
49
- <a href="{{ appUrl }}" style="display: inline-block; background-color: {{ primaryColor }}; color: #ffffff; text-decoration: none; padding: 12px 24px; border-radius: 8px; font-size: 14px; font-weight: 500;">
50
- Visit {{ appName }}
51
- </a>
52
- </td>
53
- </tr>
54
- </table>
26
+ <EmailDivider />
27
+ <EmailText size="sm" spacing="0">You are getting this because {{ email }} subscribed. Changed your mind? <a href="{{ unsubscribeUrl }}" style="color:#71717a;text-decoration:underline;">Unsubscribe</a> in one click.</EmailText>
55
28
 
56
- <!-- Divider -->
57
- <table role="presentation" cellpadding="0" cellspacing="0" style="width: 100%; margin: 8px 0 24px;">
58
- <tr>
59
- <td style="border-top: 1px solid #2a2a2a;"></td>
60
- </tr>
61
- </table>
62
-
63
- <!-- Links -->
64
- <table role="presentation" cellpadding="0" cellspacing="0" style="width: 100%;">
65
- <tr>
66
- <td style="color: #666; font-size: 13px;">
67
- <a href="https://docs.stacksjs.com" style="color: #888; text-decoration: none;">Docs</a>
68
- &nbsp;&middot;&nbsp;
69
- <a href="https://github.com/stacksjs/stacks" style="color: #888; text-decoration: none;">GitHub</a>
70
- &nbsp;&middot;&nbsp;
71
- <a href="https://stacksjs.com/discord" style="color: #888; text-decoration: none;">Discord</a>
72
- </td>
73
- </tr>
74
- </table>
75
-
76
- </td>
77
- </tr>
78
-
79
- <!-- Footer -->
80
- <tr>
81
- <td style="text-align: center; padding-top: 32px;">
82
- <p style="color: #555; font-size: 13px; margin: 0 0 8px;">
83
- You received this email because {{ email }} subscribed at {{ appUrl }}.
84
- </p>
85
- <p style="margin: 0;">
86
- <a href="{{ unsubscribeUrl }}" style="color: #666; font-size: 12px; text-decoration: underline;">Unsubscribe</a>
87
- </p>
88
- <p style="color: #444; font-size: 11px; margin: 12px 0 0;">
89
- &copy; {{ year }} {{ appName }}. All rights reserved.
90
- </p>
91
- </td>
92
- </tr>
93
-
94
- </table>
95
- </td>
29
+ <template #footer>
30
+ <tr>
31
+ <td class="email-muted" style="padding:16px 40px 20px;border-top:1px solid #e4e4e7;color:#a1a1aa;font-size:11px;text-align:center;">&copy; {{ year }} {{ appName }}</td>
96
32
  </tr>
97
- </table>
98
- </body>
99
- </html>
33
+ </template>
34
+ </EmailLayout>