@redeemid/emdash 0.0.7 → 0.0.9
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/README.md +84 -2
- package/docs/shopify-setup.md +5 -1
- package/package.json +3 -1
- package/src/access.ts +7 -1
- package/src/admin-api.ts +191 -0
- package/src/blocks/CollectionBlock.astro +22 -0
- package/src/blocks/ContributionBlock.astro +24 -0
- package/src/blocks/ProductBlock.astro +12 -0
- package/src/blocks/index.ts +6 -0
- package/src/blocks-names.ts +3 -0
- package/src/components/CartView.astro +97 -0
- package/src/components/Collection.astro +55 -0
- package/src/components/Contribution.astro +74 -0
- package/src/components/Feature.astro +20 -0
- package/src/components/MemberCard.astro +8 -0
- package/src/components/Notices.astro +4 -0
- package/src/components/Product.astro +78 -0
- package/src/config.ts +21 -0
- package/src/descriptor.ts +1 -0
- package/src/events.ts +74 -0
- package/src/features.ts +39 -0
- package/src/index.ts +1 -0
- package/src/plugin.ts +150 -4
- package/src/routes/buy.ts +1 -1
- package/src/routes/callback.ts +8 -1
- package/src/routes/cart-edit.ts +97 -0
- package/src/routes/webhook.ts +5 -3
- package/src/staff.ts +220 -0
- package/src/storage.ts +1 -1
- package/src/storefront.ts +290 -3
- package/src/version.ts +1 -1
- package/src/webhooks.ts +11 -2
package/src/webhooks.ts
CHANGED
|
@@ -88,7 +88,13 @@ export type Outcome = "processed" | "skipped" | "stale" | "ignored";
|
|
|
88
88
|
* Apply one webhook to the mirror. Throws on storage errors so the caller can
|
|
89
89
|
* answer 500 and let Shopify retry.
|
|
90
90
|
*/
|
|
91
|
-
export async function apply(
|
|
91
|
+
export async function apply(
|
|
92
|
+
s: Stores,
|
|
93
|
+
topic: string,
|
|
94
|
+
payload: Record<string, unknown>,
|
|
95
|
+
/** Called after a member is written, with their tags before (null when new). */
|
|
96
|
+
onWrite?: (beforeTags: string[] | null, after: MemberRecord) => Promise<void> | void,
|
|
97
|
+
): Promise<Outcome> {
|
|
92
98
|
const kind = kindOf(topic);
|
|
93
99
|
if (!kind || kind === "ignored") return "ignored";
|
|
94
100
|
|
|
@@ -128,7 +134,9 @@ export async function apply(s: Stores, topic: string, payload: Record<string, un
|
|
|
128
134
|
return "processed";
|
|
129
135
|
}
|
|
130
136
|
|
|
131
|
-
const
|
|
137
|
+
const existing = await s.members.get(id);
|
|
138
|
+
const beforeTags = existing ? [...existing.tags] : null;
|
|
139
|
+
const current: MemberRecord = existing ?? emptyMember(id);
|
|
132
140
|
const updatedAt = time(payload.updated_at);
|
|
133
141
|
|
|
134
142
|
if (kind === "profile") {
|
|
@@ -157,5 +165,6 @@ export async function apply(s: Stores, topic: string, payload: Record<string, un
|
|
|
157
165
|
current.syncedAt = new Date().toISOString();
|
|
158
166
|
current.source = topic;
|
|
159
167
|
await s.members.put(id, stampTags(current));
|
|
168
|
+
await onWrite?.(beforeTags, current);
|
|
160
169
|
return "processed";
|
|
161
170
|
}
|