@pilely/simple-email 0.3.0 → 0.4.2

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/types.d.ts CHANGED
@@ -1,14 +1,34 @@
1
1
  /** Every `code` the simple_email service can put in a `{ok:false, code, reason}`
2
- * refusal. Exhaustive as of the 2026-09 review, checked against the service's
3
- * `response_json.rs` and `render.rs`.
2
+ * refusal, including the two `idempotency_key_*` conflicts, checked
3
+ * against the service's `response_json.rs` and `render.rs`.
4
4
  *
5
- * This is the union that most earns its keep: `daily_cap_exceeded` and
6
- * `rate_limited` BOTH answer 429, so a consumer cannot tell a burst limit
7
- * (retry shortly) from the per-app daily send cap (retry tomorrow) by status
8
- * alone — only by matching this code. */
5
+ * This is the union that most earns its keep: `out_of_traffic_credits` and
6
+ * `phone_verification_unavailable` BOTH answer 503, so a consumer cannot tell
7
+ * a used-up owner balance (the owner must top up) from a transient outage
8
+ * (retry shortly) by status alone — only by matching this code. */
9
9
  export type SimpleEmailErrorCode = "unauthenticated" | "bad_forwarded_identity" | "bad_request" | "not_found" | "account_exists" | "account_limit_reached" | "template_limit_reached"
10
- /** 429, same status as `rate_limited` — the per-app UTC-day send cap. */
11
- | "daily_cap_exceeded" | "phone_verification_required" | "phone_verification_unavailable" | "out_of_traffic_credits" | "rate_limited" | "internal";
10
+ /** 409 — this `idempotency_key` already belongs to a different request
11
+ * (another body or another caller) on this app in the last 24 hours;
12
+ * nothing was sent. Use a new key for a different email. */
13
+ | "idempotency_key_reused"
14
+ /** 409 — an earlier request with this `idempotency_key` is still being
15
+ * handed to the provider; retry in a few seconds. */
16
+ | "idempotency_key_in_progress"
17
+ /** 429 — the per-app UTC-day send cap. */
18
+ | "daily_cap_exceeded" | "phone_verification_required" | "phone_verification_unavailable" | "out_of_traffic_credits"
19
+ /** 429 — over a `@simple_limiter` policy the app's owner set on this
20
+ * app's sends; root answers it with a `Retry-After` header. */
21
+ | "rate_limited" | "internal";
22
+ /** Who besides the owner may make account sends (`to_account`):
23
+ * `"send_group"` (the default) keeps them to the owner and the send group's
24
+ * members; `"app_users"` also lets every signed-in user arriving through the
25
+ * account's own app send a template to their own or the owner's account
26
+ * email. It never opens raw sends (`to`). */
27
+ export type AccountSenders = "send_group" | "app_users";
28
+ /** The recipient of an account send, resolved by the service: the caller's
29
+ * own Pilely account email (`"self"`) or the account owner's (`"owner"`).
30
+ * The caller never supplies or sees the address. */
31
+ export type ToAccount = "self" | "owner";
12
32
  /** `address` is derived at read time, never stored, and `null` when the
13
33
  * app it names is gone. */
14
34
  export interface Account {
@@ -18,6 +38,7 @@ export interface Account {
18
38
  /** `null` means owner-only — the opposite polarity from simple_db's
19
39
  * `read_group`/`write_group`, where `null` means everyone. */
20
40
  send_group: string | null;
41
+ account_senders: AccountSenders;
21
42
  created_time_stamp: number;
22
43
  }
23
44
  /** `daily_cap`'s three siblings are nullable and sit BESIDE `account`, not
@@ -50,6 +71,10 @@ export interface TemplateMeta {
50
71
  export interface Template extends TemplateMeta {
51
72
  html?: string;
52
73
  }
74
+ /** One send-log row. An account send's row carries its `to_account`: for
75
+ * `"self"`, `recipients` is `[]` and `recipient_count` is `1` — the owner
76
+ * never sees a user's account email through this service; for `"owner"`,
77
+ * `recipients` holds the owner's own address. */
53
78
  export interface SendRow {
54
79
  send_id: string;
55
80
  requester_user_id: string;
@@ -61,6 +86,10 @@ export interface SendRow {
61
86
  recipient_count: number;
62
87
  outcome: string;
63
88
  outcome_reason: string | null;
89
+ /** `null` for a raw send. */
90
+ to_account: ToAccount | null;
91
+ /** The caller's `idempotency_key`, or `null` when the send had none. */
92
+ idempotency_key: string | null;
64
93
  fired_at: number;
65
94
  }
66
95
  export interface SendCursor {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pilely/simple-email",
3
- "version": "0.3.0",
4
- "description": "A typed client for the simple_email service.",
3
+ "version": "0.4.2",
4
+ "description": "React hooks for the simple_email service.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -21,7 +21,9 @@
21
21
  "directory": "npm/simple-email"
22
22
  },
23
23
  "peerDependencies": {
24
- "@pilely/core": "^0.3.0"
24
+ "@pilely/core": "^0.4.0",
25
+ "@tanstack/react-query": "^5.0.0",
26
+ "react": "^18.3.0 || ^19.0.0"
25
27
  },
26
28
  "scripts": {
27
29
  "build": "tsc -p tsconfig.json",