@optizio/merchant-identity 0.1.0 → 0.2.0
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 +22 -0
- package/dist/index.js +7 -0
- package/package.json +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -59,7 +59,12 @@ export interface StoredMerchant {
|
|
|
59
59
|
shopDomain: string;
|
|
60
60
|
shopGid: string | null;
|
|
61
61
|
name: string | null;
|
|
62
|
+
/** Snapshot of the shop's Shopify email, refreshed by every identify capture. */
|
|
62
63
|
email: string | null;
|
|
64
|
+
/** Merchant-set recipients for billing/account mail; empty means "use `email`". */
|
|
65
|
+
transactionalEmails: string[];
|
|
66
|
+
/** Merchant-set recipients for product news; empty means "use `email`". */
|
|
67
|
+
newsletterEmails: string[];
|
|
63
68
|
planName: string | null;
|
|
64
69
|
shopifyPlus: boolean | null;
|
|
65
70
|
partnerDevelopment: boolean | null;
|
|
@@ -109,11 +114,22 @@ export interface StoreDetails {
|
|
|
109
114
|
apps: StoredMerchantApp[];
|
|
110
115
|
subscriptions: StoredMerchantSubscription[];
|
|
111
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* The two streams a merchant can address separately. This service only stores
|
|
119
|
+
* the split — it has no send path, so gating is the calling app's job:
|
|
120
|
+
* transactional mail (billing, security, account notices) always sends, while
|
|
121
|
+
* newsletter mail should be checked against
|
|
122
|
+
* `isSubscribed(shop, { topic: SUBSCRIPTION_TOPIC_NEWSLETTER })` first.
|
|
123
|
+
*/
|
|
124
|
+
export type ContactEmailType = 'transactional' | 'newsletter';
|
|
125
|
+
export declare const CONTACT_EMAIL_TYPES: readonly ContactEmailType[];
|
|
112
126
|
/** Sentinel stored for the `app_id` / `user_id` columns when a row applies to
|
|
113
127
|
* every app / every user of a store. */
|
|
114
128
|
export declare const SUBSCRIPTION_ALL_SCOPES = "*";
|
|
115
129
|
/** Sentinel stored for the `topic` column when a row applies to all topics. */
|
|
116
130
|
export declare const SUBSCRIPTION_ALL_TOPICS = "all";
|
|
131
|
+
/** Topic for opt-out of product news. Transactional mail is never gated on it. */
|
|
132
|
+
export declare const SUBSCRIPTION_TOPIC_NEWSLETTER = "newsletter";
|
|
117
133
|
export interface SubscriptionScope {
|
|
118
134
|
appId?: string;
|
|
119
135
|
topic?: string;
|
|
@@ -137,6 +153,12 @@ export interface IdentityClient {
|
|
|
137
153
|
captureMerchantUser(input: MerchantUserRecord): Promise<void>;
|
|
138
154
|
touchMerchantApp(input: MerchantAppRecord): Promise<void>;
|
|
139
155
|
markAppUninstalled(shopDomain: string, appId: string): Promise<void>;
|
|
156
|
+
/**
|
|
157
|
+
* Replace the merchant's recipients for one stream. Pass an empty array to
|
|
158
|
+
* clear the override so comms fall back to the captured Shopify shop email.
|
|
159
|
+
* Rejects a malformed address or an unknown type.
|
|
160
|
+
*/
|
|
161
|
+
setContactEmails(shopDomain: string, type: ContactEmailType, emails: string[]): Promise<void>;
|
|
140
162
|
setSubscription(input: MerchantSubscriptionRecord): Promise<void>;
|
|
141
163
|
isSubscribed(shopDomain: string, scope?: SubscriptionScope): Promise<boolean>;
|
|
142
164
|
getStoreDetails(shopDomain: string): Promise<StoreDetails>;
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
* This package holds only types + pure helpers, so it has no Cloudflare or
|
|
11
11
|
* runtime dependencies and is safe to import anywhere.
|
|
12
12
|
*/
|
|
13
|
+
export const CONTACT_EMAIL_TYPES = [
|
|
14
|
+
'transactional',
|
|
15
|
+
'newsletter',
|
|
16
|
+
];
|
|
13
17
|
/* -------------------------------------------------------------------------- */
|
|
14
18
|
/* Subscriptions */
|
|
15
19
|
/* -------------------------------------------------------------------------- */
|
|
@@ -18,6 +22,8 @@
|
|
|
18
22
|
export const SUBSCRIPTION_ALL_SCOPES = '*';
|
|
19
23
|
/** Sentinel stored for the `topic` column when a row applies to all topics. */
|
|
20
24
|
export const SUBSCRIPTION_ALL_TOPICS = 'all';
|
|
25
|
+
/** Topic for opt-out of product news. Transactional mail is never gated on it. */
|
|
26
|
+
export const SUBSCRIPTION_TOPIC_NEWSLETTER = 'newsletter';
|
|
21
27
|
/**
|
|
22
28
|
* Resolve the effective subscribed state for a scope from a store's rows.
|
|
23
29
|
* Most-specific match wins (user > app > topic); returns `null` when nothing
|
|
@@ -50,6 +56,7 @@ export const NOOP_IDENTITY = {
|
|
|
50
56
|
async captureMerchantUser() { },
|
|
51
57
|
async touchMerchantApp() { },
|
|
52
58
|
async markAppUninstalled() { },
|
|
59
|
+
async setContactEmails() { },
|
|
53
60
|
async setSubscription() { },
|
|
54
61
|
async isSubscribed() {
|
|
55
62
|
return true;
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optizio/merchant-identity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Shared merchant/user identity types + RPC client contract for the merchant-hub portfolio.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/optizio/merchant-hub.git",
|
|
8
|
+
"directory": "packages/types"
|
|
9
|
+
},
|
|
5
10
|
"type": "module",
|
|
6
11
|
"main": "dist/index.js",
|
|
7
12
|
"types": "dist/index.d.ts",
|