@redeemid/emdash 0.0.9 → 0.0.11

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.
Files changed (42) hide show
  1. package/README.md +138 -2
  2. package/bin/redeemid-emdash.mjs +144 -0
  3. package/docs/shopify-setup.md +4 -2
  4. package/package.json +8 -2
  5. package/src/access.ts +2 -2
  6. package/src/agents.ts +179 -0
  7. package/src/blocks/ContributionBlock.astro +1 -1
  8. package/src/blocks/PlanBlock.astro +1 -1
  9. package/src/blocks/PreferencesBlock.astro +12 -0
  10. package/src/blocks/index.ts +3 -0
  11. package/src/blocks-names.ts +27 -0
  12. package/src/components/AccessBadge.astro +10 -6
  13. package/src/components/Account.astro +5 -4
  14. package/src/components/Cart.astro +4 -1
  15. package/src/components/CartView.astro +14 -13
  16. package/src/components/Collection.astro +2 -1
  17. package/src/components/Content.astro +25 -10
  18. package/src/components/Contribution.astro +4 -3
  19. package/src/components/LockedPanel.astro +35 -9
  20. package/src/components/MemberCard.astro +15 -14
  21. package/src/components/Notices.astro +12 -2
  22. package/src/components/Plan.astro +3 -2
  23. package/src/components/Preferences.astro +102 -0
  24. package/src/components/Product.astro +6 -5
  25. package/src/components/YourData.astro +42 -0
  26. package/src/config.ts +38 -1
  27. package/src/descriptor.ts +1 -0
  28. package/src/events.ts +3 -2
  29. package/src/files.ts +196 -0
  30. package/src/guard.ts +43 -2
  31. package/src/index.ts +2 -0
  32. package/src/plugin.ts +169 -4
  33. package/src/preferences.ts +298 -0
  34. package/src/privacy.ts +148 -0
  35. package/src/routes/preferences.ts +82 -0
  36. package/src/routes/privacy.ts +59 -0
  37. package/src/routes/webhook.ts +1 -1
  38. package/src/staff.ts +92 -0
  39. package/src/storage.ts +17 -0
  40. package/src/text.ts +185 -0
  41. package/src/version.ts +1 -1
  42. package/src/webhooks.ts +17 -4
package/src/webhooks.ts CHANGED
@@ -7,6 +7,8 @@
7
7
  */
8
8
 
9
9
  import { cleanTags, emptyMember, numericId, stampTags, type MemberRecord, type Stores } from "./storage.js";
10
+ import type { RedeemIDConfig } from "./config.js";
11
+ import { eraseAll, eraseMember, shopifyDataRequest } from "./privacy.js";
10
12
 
11
13
  export type Kind = "profile" | "delete" | "status" | "tags" | "merge" | "compliance" | "ignored";
12
14
 
@@ -94,16 +96,27 @@ export async function apply(
94
96
  payload: Record<string, unknown>,
95
97
  /** Called after a member is written, with their tags before (null when new). */
96
98
  onWrite?: (beforeTags: string[] | null, after: MemberRecord) => Promise<void> | void,
99
+ /** For the member.erased event on customers/redact. */
100
+ config?: RedeemIDConfig | null,
97
101
  ): Promise<Outcome> {
98
102
  const kind = kindOf(topic);
99
103
  if (!kind || kind === "ignored") return "ignored";
100
104
 
101
105
  if (kind === "compliance") {
102
- // customers/redact: drop the mirror for that customer. data_request and
103
- // shop/redact need staff action (or are covered by deleting the app).
106
+ // Every compliance topic is logged as a privacy request (see privacy.ts).
107
+ const id = customerOf(payload);
104
108
  if (topic === "customers/redact") {
105
- const id = customerOf(payload);
106
- if (id) await s.members.delete(id);
109
+ if (id) await eraseMember(config ?? null, s, id, "shopify");
110
+ return id ? "processed" : "skipped";
111
+ }
112
+ if (topic === "customers/data_request") {
113
+ if (!id) return "skipped";
114
+ const req = (payload.data_request as { id?: unknown } | undefined)?.id;
115
+ await shopifyDataRequest(s, id, req === undefined || req === null ? null : String(req));
116
+ return "processed";
117
+ }
118
+ if (topic === "shop/redact") {
119
+ await eraseAll(config ?? null, s);
107
120
  return "processed";
108
121
  }
109
122
  return "skipped";