@wix/email-subscriptions 1.0.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.
Files changed (31) hide show
  1. package/build/cjs/index.d.ts +1 -0
  2. package/build/cjs/index.js +24 -0
  3. package/build/cjs/index.js.map +1 -0
  4. package/build/cjs/src/emailsubscriptions-v1-emailsubscription.http.d.ts +40 -0
  5. package/build/cjs/src/emailsubscriptions-v1-emailsubscription.http.js +204 -0
  6. package/build/cjs/src/emailsubscriptions-v1-emailsubscription.http.js.map +1 -0
  7. package/build/cjs/src/emailsubscriptions-v1-emailsubscription.public.d.ts +11 -0
  8. package/build/cjs/src/emailsubscriptions-v1-emailsubscription.public.js +33 -0
  9. package/build/cjs/src/emailsubscriptions-v1-emailsubscription.public.js.map +1 -0
  10. package/build/cjs/src/emailsubscriptions-v1-emailsubscription.types.d.ts +258 -0
  11. package/build/cjs/src/emailsubscriptions-v1-emailsubscription.types.js +28 -0
  12. package/build/cjs/src/emailsubscriptions-v1-emailsubscription.types.js.map +1 -0
  13. package/build/cjs/src/emailsubscriptions-v1-emailsubscription.universal.d.ts +338 -0
  14. package/build/cjs/src/emailsubscriptions-v1-emailsubscription.universal.js +316 -0
  15. package/build/cjs/src/emailsubscriptions-v1-emailsubscription.universal.js.map +1 -0
  16. package/build/es/index.d.ts +1 -0
  17. package/build/es/index.js +2 -0
  18. package/build/es/index.js.map +1 -0
  19. package/build/es/src/emailsubscriptions-v1-emailsubscription.http.d.ts +40 -0
  20. package/build/es/src/emailsubscriptions-v1-emailsubscription.http.js +197 -0
  21. package/build/es/src/emailsubscriptions-v1-emailsubscription.http.js.map +1 -0
  22. package/build/es/src/emailsubscriptions-v1-emailsubscription.public.d.ts +11 -0
  23. package/build/es/src/emailsubscriptions-v1-emailsubscription.public.js +24 -0
  24. package/build/es/src/emailsubscriptions-v1-emailsubscription.public.js.map +1 -0
  25. package/build/es/src/emailsubscriptions-v1-emailsubscription.types.d.ts +258 -0
  26. package/build/es/src/emailsubscriptions-v1-emailsubscription.types.js +25 -0
  27. package/build/es/src/emailsubscriptions-v1-emailsubscription.types.js.map +1 -0
  28. package/build/es/src/emailsubscriptions-v1-emailsubscription.universal.d.ts +338 -0
  29. package/build/es/src/emailsubscriptions-v1-emailsubscription.universal.js +290 -0
  30. package/build/es/src/emailsubscriptions-v1-emailsubscription.universal.js.map +1 -0
  31. package/package.json +37 -0
@@ -0,0 +1,338 @@
1
+ export declare const __debug: {
2
+ verboseLogging: {
3
+ on: () => boolean;
4
+ off: () => boolean;
5
+ };
6
+ };
7
+ export interface EmailSubscription {
8
+ /** @readonly */
9
+ _id?: string | null;
10
+ /** Email address. */
11
+ email?: string;
12
+ /**
13
+ * Indicates the recipient's opt-in or opt-out status
14
+ * for marketing emails.
15
+ *
16
+ * - `NOT_SET`: No status specified.
17
+ * - `PENDING`: Subscription confirmation was requested,
18
+ * but recipient hasn't confirmed yet.
19
+ * - `SUBSCRIBED`: Recipient has opted in to marketing emails.
20
+ * - `UNSUBSCRIBED`: Recipient has opted out of marketing emails.
21
+ *
22
+ * Defaults to `NOT_SET`.
23
+ */
24
+ subscriptionStatus?: SubscriptionEnumStatus;
25
+ /**
26
+ * Indicates last reported status of sent emails.
27
+ *
28
+ * - `NOT_SET`: No status specified.
29
+ * - `VALID`: Emails haven't bounced,
30
+ * but the recipient hasn't actively subscribed or unsubscribed.
31
+ * - `BOUNCED`: The last email to the recipient bounced or was rejected.
32
+ * - `SPAM_COMPLAINT`: Recipient registered a spam complaint
33
+ * with their email provider.
34
+ * - `INACTIVE`: No activity has been reported.
35
+ *
36
+ * Defaults to `NOT_SET`.
37
+ */
38
+ deliverabilityStatus?: Status;
39
+ /** @readonly */
40
+ _createdDate?: Date;
41
+ /** @readonly */
42
+ _updatedDate?: Date;
43
+ }
44
+ export declare enum SubscriptionEnumStatus {
45
+ UNKNOWN = "UNKNOWN",
46
+ /** No Subscription exists */
47
+ NOT_SET = "NOT_SET",
48
+ /** Pending Subscription */
49
+ PENDING = "PENDING",
50
+ /** Subscribed */
51
+ SUBSCRIBED = "SUBSCRIBED",
52
+ /** UnSubscribed */
53
+ UNSUBSCRIBED = "UNSUBSCRIBED"
54
+ }
55
+ export declare enum Status {
56
+ NOT_SET = "NOT_SET",
57
+ /** valid/deferral */
58
+ VALID = "VALID",
59
+ /** bounced/rejected/invalid */
60
+ BOUNCED = "BOUNCED",
61
+ /** spam/complaint */
62
+ SPAM_COMPLAINT = "SPAM_COMPLAINT",
63
+ /** valid, but no activity reported */
64
+ INACTIVE = "INACTIVE"
65
+ }
66
+ export interface EmailSubscriptionChanged {
67
+ /** subscription */
68
+ subscription?: EmailSubscription;
69
+ }
70
+ export interface GetEmailSubscriptionRequest {
71
+ _id?: string;
72
+ }
73
+ export interface GetEmailSubscriptionResponse {
74
+ /** Returned email subscription */
75
+ emailSubscription?: EmailSubscription;
76
+ }
77
+ export interface UpdateEmailSubscriptionRequest {
78
+ /** Email subscription to update */
79
+ subscription?: EmailSubscription;
80
+ }
81
+ export interface UpdateEmailSubscriptionResponse {
82
+ /** Updated email subscription */
83
+ subscription?: EmailSubscription;
84
+ }
85
+ export interface QueryEmailSubscriptionsRequest {
86
+ /**
87
+ * Filter options.
88
+ * Currently, querying is supported on the `email` field
89
+ * with the `$in` array filter.
90
+ */
91
+ filter: Record<string, any> | null;
92
+ /**
93
+ * Pagination options. For more information, see
94
+ * [Pagination](https://dev.wix.com/api/rest/getting-started/pagination).
95
+ */
96
+ paging?: Paging;
97
+ }
98
+ export interface Paging {
99
+ /** Number of items to load. */
100
+ limit?: number | null;
101
+ /** Number of items to skip in the current sort order. */
102
+ offset?: number | null;
103
+ }
104
+ export interface QueryEmailSubscriptionsResponse {
105
+ /** List of subscribed emails that matched the query options. */
106
+ subscriptions?: EmailSubscription[];
107
+ /** Metadata for the paginated results. */
108
+ metadata?: PagingMetadata;
109
+ }
110
+ export interface PagingMetadata {
111
+ /** Number of items returned in the response. */
112
+ count?: number | null;
113
+ /** Offset that was requested. */
114
+ offset?: number | null;
115
+ /** Total number of items that match the query. */
116
+ total?: number | null;
117
+ /** Flag that indicates the server failed to calculate the `total` field. */
118
+ tooManyToCount?: boolean | null;
119
+ }
120
+ export interface UpsertEmailSubscriptionRequest {
121
+ /** Email subscription to update or create. */
122
+ subscription?: EmailSubscription;
123
+ }
124
+ export interface UpsertEmailSubscriptionResponse {
125
+ /** Updated or created email subscription. */
126
+ subscription?: EmailSubscription;
127
+ }
128
+ export interface BulkUpsertEmailSubscriptionRequest {
129
+ /** List of email subscriptions to update or create. */
130
+ subscriptions: EmailSubscription[];
131
+ }
132
+ export interface BulkUpsertEmailSubscriptionResponse {
133
+ /** List of updated or created email subscriptions. */
134
+ results?: BulkUpsertEmailSubscriptionResult[];
135
+ /** Numbers of successful and failed actions. */
136
+ metadata?: Metadata;
137
+ }
138
+ export interface BulkUpsertEmailSubscriptionResult {
139
+ /** Position of the requested email subscription in the bulk array. */
140
+ originalIndex?: number;
141
+ /** New or updated email subscription. */
142
+ emailSubscription?: EmailSubscription;
143
+ /**
144
+ * Error information if the action failed.
145
+ * Omitted from successful actions.
146
+ */
147
+ error?: Error;
148
+ }
149
+ export interface Error {
150
+ /** Error code. */
151
+ errorCode?: string;
152
+ /** Message that contains details about the error. */
153
+ message?: string;
154
+ }
155
+ export interface Metadata {
156
+ /** Number of successful actions. */
157
+ totalSuccess?: number;
158
+ /** Number of failed actions. */
159
+ totalFailure?: number;
160
+ }
161
+ export interface GenerateUnsubscribeLinkRequest {
162
+ /** Email address the unsubscribe link is for. */
163
+ emailAddress: string;
164
+ /** Arbitrary parameters for closing-the-loop. */
165
+ metadata?: Record<string, string>;
166
+ /** Language for displaying unsubscribe confirmation page (optional - default EN). */
167
+ language?: string | null;
168
+ }
169
+ export interface GenerateUnsubscribeLinkResponse {
170
+ /** The unsubscribe link. */
171
+ link?: string;
172
+ }
173
+ export interface RenderUnsubscribePageRequest {
174
+ /** Payload */
175
+ payload?: string;
176
+ /** Language */
177
+ language?: string | null;
178
+ }
179
+ export interface RawHttpResponse {
180
+ body?: Uint8Array;
181
+ statusCode?: number | null;
182
+ headers?: HeadersEntry[];
183
+ }
184
+ export interface HeadersEntry {
185
+ key?: string;
186
+ value?: string;
187
+ }
188
+ export interface ConfirmUnsubscribeActionRequest {
189
+ /** Payload */
190
+ payload?: string;
191
+ }
192
+ export interface Empty {
193
+ }
194
+ export interface DomainEvent extends DomainEventBodyOneOf {
195
+ createdEvent?: EntityCreatedEvent;
196
+ updatedEvent?: EntityUpdatedEvent;
197
+ deletedEvent?: EntityDeletedEvent;
198
+ actionEvent?: ActionEvent;
199
+ extendedFieldsUpdatedEvent?: ExtendedFieldsUpdatedEvent;
200
+ /** random GUID so clients can tell if event was already handled */
201
+ _id?: string;
202
+ /**
203
+ * Assumes actions are also always typed to an entity_type
204
+ * Example: wix.stores.catalog.product, wix.bookings.session, wix.payments.transaction
205
+ */
206
+ entityFqdn?: string;
207
+ /**
208
+ * This is top level to ease client code dispatching of messages (switch on entity_fqdn+slug)
209
+ * This is although the created/updated/deleted notion is duplication of the oneof types
210
+ * Example: created/updated/deleted/started/completed/email_opened
211
+ */
212
+ slug?: string;
213
+ /**
214
+ * Assuming that all messages including Actions have id
215
+ * Example: The id of the specific order, the id of a specific campaign
216
+ */
217
+ entityId?: string;
218
+ /** The time of the event. Useful if there was a delay in dispatching */
219
+ eventTime?: Date;
220
+ /**
221
+ * A field that should be set if this event was triggered by an anonymize request.
222
+ * For example you must set it to true when sending an event as a result of a GDPR right to be forgotten request.
223
+ * NOTE: This field is not relevant for `EntityCreatedEvent` but is located here for better ergonomics of consumers.
224
+ */
225
+ triggeredByAnonymizeRequest?: boolean | null;
226
+ /** If present, indicates the action that triggered the event. */
227
+ originatedFrom?: string | null;
228
+ /**
229
+ * A sequence number defining the order of updates to the underlying entity.
230
+ * For example, given that some entity was updated at 16:00 and than again at 16:01,
231
+ * it is guaranteed that the sequence number of the second update is strictly higher than the first.
232
+ * As the consumer, you can use this value to ensure that you handle messages in the correct order.
233
+ * To do so, you will need to persist this number on your end, and compare the sequence number from the
234
+ * message against the one you have stored. Given that the stored number is higher, you should ignore the message.
235
+ */
236
+ entityEventSequence?: string | null;
237
+ }
238
+ /** @oneof */
239
+ export interface DomainEventBodyOneOf {
240
+ createdEvent?: EntityCreatedEvent;
241
+ updatedEvent?: EntityUpdatedEvent;
242
+ deletedEvent?: EntityDeletedEvent;
243
+ actionEvent?: ActionEvent;
244
+ extendedFieldsUpdatedEvent?: ExtendedFieldsUpdatedEvent;
245
+ }
246
+ export interface EntityCreatedEvent {
247
+ entityAsJson?: string;
248
+ }
249
+ export interface EntityUpdatedEvent {
250
+ /**
251
+ * Since platformized APIs only expose PATCH and not PUT we can't assume that the fields sent from the client are the actual diff.
252
+ * This means that to generate a list of changed fields (as opposed to sent fields) one needs to traverse both objects.
253
+ * We don't want to impose this on all developers and so we leave this traversal to the notification recipients which need it.
254
+ */
255
+ currentEntityAsJson?: string;
256
+ }
257
+ export interface EntityDeletedEvent {
258
+ }
259
+ export interface ActionEvent {
260
+ bodyAsJson?: string;
261
+ }
262
+ export interface ExtendedFieldsUpdatedEvent {
263
+ currentEntityAsJson?: string;
264
+ }
265
+ /**
266
+ * Retrieves email subscriptions,
267
+ * given the provided paging, filtering, and sorting.
268
+ *
269
+ * Currently, querying is supported on the `email` field
270
+ * with the `$in` array filter.
271
+ * For example, to query for emails "me@my.com" and "you@your.org",
272
+ * the filter should be formed like this:
273
+ *
274
+ * ```json
275
+ * { "filter": {
276
+ * "email": {
277
+ * "$in": ["me@my.com", "you@your.org"]
278
+ * }
279
+ * }
280
+ * }
281
+ * ```
282
+ *
283
+ * To learn how to query email subscriptions, see
284
+ * [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language).
285
+ * @param filter - Filter options.
286
+ * Currently, querying is supported on the `email` field
287
+ * with the `$in` array filter.
288
+ * @public
289
+ * @documentationMaturity preview
290
+ * @requiredField filter
291
+ */
292
+ export declare function queryEmailSubscriptions(filter: Record<string, any> | null, options?: QueryEmailSubscriptionsOptions): Promise<QueryEmailSubscriptionsResponse>;
293
+ export interface QueryEmailSubscriptionsOptions {
294
+ /**
295
+ * Pagination options. For more information, see
296
+ * [Pagination](https://dev.wix.com/api/rest/getting-started/pagination).
297
+ */
298
+ paging?: Paging;
299
+ }
300
+ /**
301
+ * Updates or creates an email subscription for the requested email.
302
+ *
303
+ * An email subscription is always returned in the response,
304
+ * regardless of whether it was updated or created.
305
+ * @public
306
+ * @documentationMaturity preview
307
+ * @requiredField options.subscription.email
308
+ */
309
+ export declare function upsertEmailSubscription(options?: UpsertEmailSubscriptionOptions): Promise<UpsertEmailSubscriptionResponse>;
310
+ export interface UpsertEmailSubscriptionOptions {
311
+ /** Email subscription to update or create. */
312
+ subscription?: EmailSubscription;
313
+ }
314
+ /**
315
+ * Updates or creates multiple email subscriptions.
316
+ * @param subscriptions - List of email subscriptions to update or create.
317
+ * @public
318
+ * @documentationMaturity preview
319
+ * @requiredField subscriptions
320
+ */
321
+ export declare function bulkUpsertEmailSubscription(subscriptions: EmailSubscription[]): Promise<BulkUpsertEmailSubscriptionResponse>;
322
+ /**
323
+ * Creates an unsubscribe link to be shared with the relevant recipient.
324
+ *
325
+ * If someone clicks the **Unsubscribe** button on the confirmation page,
326
+ * the recipient's `subscriptionStatus` is changed to `UNSUBSCRIBED`.
327
+ * @param emailAddress - Email address the unsubscribe link is for.
328
+ * @public
329
+ * @documentationMaturity preview
330
+ * @requiredField emailAddress
331
+ */
332
+ export declare function generateUnsubscribeLink(emailAddress: string, options?: GenerateUnsubscribeLinkOptions): Promise<GenerateUnsubscribeLinkResponse>;
333
+ export interface GenerateUnsubscribeLinkOptions {
334
+ /** Arbitrary parameters for closing-the-loop. */
335
+ metadata?: Record<string, string>;
336
+ /** Language for displaying unsubscribe confirmation page (optional - default EN). */
337
+ language?: string | null;
338
+ }
@@ -0,0 +1,290 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { serializer, transformError } from '@wix/metro-runtime/velo';
11
+ import * as ambassadorWixEmailsubscriptionsV1Emailsubscription from './emailsubscriptions-v1-emailsubscription.http';
12
+ let __verbose = false;
13
+ function __log(...args) {
14
+ __verbose && console.log(...args);
15
+ }
16
+ function __inspect(obj) {
17
+ return obj;
18
+ }
19
+ export const __debug = {
20
+ verboseLogging: {
21
+ on: () => (__verbose = true),
22
+ off: () => (__verbose = false),
23
+ },
24
+ };
25
+ const _toVeloEntity = '$';
26
+ const _fromVeloEntity = '$';
27
+ export var SubscriptionEnumStatus;
28
+ (function (SubscriptionEnumStatus) {
29
+ SubscriptionEnumStatus["UNKNOWN"] = "UNKNOWN";
30
+ /** No Subscription exists */
31
+ SubscriptionEnumStatus["NOT_SET"] = "NOT_SET";
32
+ /** Pending Subscription */
33
+ SubscriptionEnumStatus["PENDING"] = "PENDING";
34
+ /** Subscribed */
35
+ SubscriptionEnumStatus["SUBSCRIBED"] = "SUBSCRIBED";
36
+ /** UnSubscribed */
37
+ SubscriptionEnumStatus["UNSUBSCRIBED"] = "UNSUBSCRIBED";
38
+ })(SubscriptionEnumStatus || (SubscriptionEnumStatus = {}));
39
+ export var Status;
40
+ (function (Status) {
41
+ Status["NOT_SET"] = "NOT_SET";
42
+ /** valid/deferral */
43
+ Status["VALID"] = "VALID";
44
+ /** bounced/rejected/invalid */
45
+ Status["BOUNCED"] = "BOUNCED";
46
+ /** spam/complaint */
47
+ Status["SPAM_COMPLAINT"] = "SPAM_COMPLAINT";
48
+ /** valid, but no activity reported */
49
+ Status["INACTIVE"] = "INACTIVE";
50
+ })(Status || (Status = {}));
51
+ const _bulkUpsertEmailSubscriptionRequest = {};
52
+ const _bulkUpsertEmailSubscriptionResponse = {};
53
+ const _generateUnsubscribeLinkRequest = {};
54
+ const _generateUnsubscribeLinkResponse = {};
55
+ const _queryEmailSubscriptionsRequest = {};
56
+ const _queryEmailSubscriptionsResponse = {};
57
+ const _upsertEmailSubscriptionRequest = {};
58
+ const _upsertEmailSubscriptionResponse = {};
59
+ /**
60
+ * Retrieves email subscriptions,
61
+ * given the provided paging, filtering, and sorting.
62
+ *
63
+ * Currently, querying is supported on the `email` field
64
+ * with the `$in` array filter.
65
+ * For example, to query for emails "me@my.com" and "you@your.org",
66
+ * the filter should be formed like this:
67
+ *
68
+ * ```json
69
+ * { "filter": {
70
+ * "email": {
71
+ * "$in": ["me@my.com", "you@your.org"]
72
+ * }
73
+ * }
74
+ * }
75
+ * ```
76
+ *
77
+ * To learn how to query email subscriptions, see
78
+ * [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language).
79
+ * @param filter - Filter options.
80
+ * Currently, querying is supported on the `email` field
81
+ * with the `$in` array filter.
82
+ * @public
83
+ * @documentationMaturity preview
84
+ * @requiredField filter
85
+ */
86
+ export function queryEmailSubscriptions(filter, options) {
87
+ var _a, _b, _c;
88
+ return __awaiter(this, arguments, void 0, function* () {
89
+ const requestTransformation = { filter: '$[0]', paging: '$[1].paging' };
90
+ const responseTransformation = '$';
91
+ // @ts-ignore
92
+ const { httpClient, sideEffects } = arguments[2];
93
+ const { toAmbassadorRequest } = serializer({
94
+ rootSchema: _queryEmailSubscriptionsRequest,
95
+ depSchemas: {},
96
+ fqdnTransformation: {
97
+ paths: [],
98
+ transformation: _fromVeloEntity,
99
+ },
100
+ customTransformation: requestTransformation,
101
+ });
102
+ const { fromJSON } = serializer({
103
+ rootSchema: _queryEmailSubscriptionsResponse,
104
+ depSchemas: {},
105
+ fqdnTransformation: {
106
+ paths: [...['Array#subscriptions']],
107
+ transformation: _toVeloEntity,
108
+ },
109
+ customTransformation: responseTransformation,
110
+ });
111
+ const payload = toAmbassadorRequest([filter, options]);
112
+ const reqOpts = ambassadorWixEmailsubscriptionsV1Emailsubscription.queryEmailSubscriptions(payload);
113
+ __log(`"QueryEmailSubscriptions" sending request with: ${__inspect(reqOpts)}`);
114
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
115
+ try {
116
+ const result = yield httpClient.request(reqOpts);
117
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
118
+ return fromJSON(result.data);
119
+ }
120
+ catch (err) {
121
+ const transformedError = transformError(err, requestTransformation, [
122
+ 'filter',
123
+ 'options',
124
+ ]);
125
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
126
+ throw transformedError;
127
+ }
128
+ });
129
+ }
130
+ /**
131
+ * Updates or creates an email subscription for the requested email.
132
+ *
133
+ * An email subscription is always returned in the response,
134
+ * regardless of whether it was updated or created.
135
+ * @public
136
+ * @documentationMaturity preview
137
+ * @requiredField options.subscription.email
138
+ */
139
+ export function upsertEmailSubscription(options) {
140
+ var _a, _b, _c;
141
+ return __awaiter(this, arguments, void 0, function* () {
142
+ const requestTransformation = { subscription: '$[0].subscription' };
143
+ const responseTransformation = '$';
144
+ // @ts-ignore
145
+ const { httpClient, sideEffects } = arguments[1];
146
+ const { toAmbassadorRequest } = serializer({
147
+ rootSchema: _upsertEmailSubscriptionRequest,
148
+ depSchemas: {},
149
+ fqdnTransformation: {
150
+ paths: [...['subscription']],
151
+ transformation: _fromVeloEntity,
152
+ },
153
+ customTransformation: requestTransformation,
154
+ });
155
+ const { fromJSON } = serializer({
156
+ rootSchema: _upsertEmailSubscriptionResponse,
157
+ depSchemas: {},
158
+ fqdnTransformation: {
159
+ paths: [...['subscription']],
160
+ transformation: _toVeloEntity,
161
+ },
162
+ customTransformation: responseTransformation,
163
+ });
164
+ const payload = toAmbassadorRequest([options]);
165
+ const reqOpts = ambassadorWixEmailsubscriptionsV1Emailsubscription.upsertEmailSubscription(payload);
166
+ __log(`"UpsertEmailSubscription" sending request with: ${__inspect(reqOpts)}`);
167
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
168
+ try {
169
+ const result = yield httpClient.request(reqOpts);
170
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
171
+ return fromJSON(result.data);
172
+ }
173
+ catch (err) {
174
+ const transformedError = transformError(err, requestTransformation, [
175
+ 'options',
176
+ ]);
177
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
178
+ throw transformedError;
179
+ }
180
+ });
181
+ }
182
+ /**
183
+ * Updates or creates multiple email subscriptions.
184
+ * @param subscriptions - List of email subscriptions to update or create.
185
+ * @public
186
+ * @documentationMaturity preview
187
+ * @requiredField subscriptions
188
+ */
189
+ export function bulkUpsertEmailSubscription(subscriptions) {
190
+ var _a, _b, _c;
191
+ return __awaiter(this, arguments, void 0, function* () {
192
+ const requestTransformation = { subscriptions: '$[0]' };
193
+ const responseTransformation = '$';
194
+ // @ts-ignore
195
+ const { httpClient, sideEffects } = arguments[1];
196
+ const { toAmbassadorRequest } = serializer({
197
+ rootSchema: _bulkUpsertEmailSubscriptionRequest,
198
+ depSchemas: {},
199
+ fqdnTransformation: {
200
+ paths: [...['Array#subscriptions']],
201
+ transformation: _fromVeloEntity,
202
+ },
203
+ customTransformation: requestTransformation,
204
+ });
205
+ const { fromJSON } = serializer({
206
+ rootSchema: _bulkUpsertEmailSubscriptionResponse,
207
+ depSchemas: {},
208
+ fqdnTransformation: {
209
+ paths: [...['Array#results.emailSubscription']],
210
+ transformation: _toVeloEntity,
211
+ },
212
+ customTransformation: responseTransformation,
213
+ });
214
+ const payload = toAmbassadorRequest([subscriptions]);
215
+ const reqOpts = ambassadorWixEmailsubscriptionsV1Emailsubscription.bulkUpsertEmailSubscription(payload);
216
+ __log(`"BulkUpsertEmailSubscription" sending request with: ${__inspect(reqOpts)}`);
217
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
218
+ try {
219
+ const result = yield httpClient.request(reqOpts);
220
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
221
+ return fromJSON(result.data);
222
+ }
223
+ catch (err) {
224
+ const transformedError = transformError(err, requestTransformation, [
225
+ 'subscriptions',
226
+ ]);
227
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
228
+ throw transformedError;
229
+ }
230
+ });
231
+ }
232
+ /**
233
+ * Creates an unsubscribe link to be shared with the relevant recipient.
234
+ *
235
+ * If someone clicks the **Unsubscribe** button on the confirmation page,
236
+ * the recipient's `subscriptionStatus` is changed to `UNSUBSCRIBED`.
237
+ * @param emailAddress - Email address the unsubscribe link is for.
238
+ * @public
239
+ * @documentationMaturity preview
240
+ * @requiredField emailAddress
241
+ */
242
+ export function generateUnsubscribeLink(emailAddress, options) {
243
+ var _a, _b, _c;
244
+ return __awaiter(this, arguments, void 0, function* () {
245
+ const requestTransformation = {
246
+ emailAddress: '$[0]',
247
+ metadata: '$[1].metadata',
248
+ language: '$[1].language',
249
+ };
250
+ const responseTransformation = '$';
251
+ // @ts-ignore
252
+ const { httpClient, sideEffects } = arguments[2];
253
+ const { toAmbassadorRequest } = serializer({
254
+ rootSchema: _generateUnsubscribeLinkRequest,
255
+ depSchemas: {},
256
+ fqdnTransformation: {
257
+ paths: [],
258
+ transformation: _fromVeloEntity,
259
+ },
260
+ customTransformation: requestTransformation,
261
+ });
262
+ const { fromJSON } = serializer({
263
+ rootSchema: _generateUnsubscribeLinkResponse,
264
+ depSchemas: {},
265
+ fqdnTransformation: {
266
+ paths: [],
267
+ transformation: _toVeloEntity,
268
+ },
269
+ customTransformation: responseTransformation,
270
+ });
271
+ const payload = toAmbassadorRequest([emailAddress, options]);
272
+ const reqOpts = ambassadorWixEmailsubscriptionsV1Emailsubscription.generateUnsubscribeLink(payload);
273
+ __log(`"GenerateUnsubscribeLink" sending request with: ${__inspect(reqOpts)}`);
274
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
275
+ try {
276
+ const result = yield httpClient.request(reqOpts);
277
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
278
+ return fromJSON(result.data);
279
+ }
280
+ catch (err) {
281
+ const transformedError = transformError(err, requestTransformation, [
282
+ 'emailAddress',
283
+ 'options',
284
+ ]);
285
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
286
+ throw transformedError;
287
+ }
288
+ });
289
+ }
290
+ //# sourceMappingURL=emailsubscriptions-v1-emailsubscription.universal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emailsubscriptions-v1-emailsubscription.universal.js","sourceRoot":"","sources":["../../../src/emailsubscriptions-v1-emailsubscription.universal.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAErE,OAAO,KAAK,kDAAkD,MAAM,gDAAgD,CAAC;AAErH,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,SAAS,KAAK,CAAC,GAAG,IAAW;IAC3B,SAAS,IAAI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,CAAC;YACH,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,+CAApB,WAAW,EAAY,GAAG,CAAC,CAAC;YAE5B,MAAM,gBAAgB,CAAC;SACxB;;CACF"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@wix/email-subscriptions",
3
+ "version": "1.0.0",
4
+ "publishConfig": {
5
+ "registry": "https://registry.npmjs.org/",
6
+ "access": "public"
7
+ },
8
+ "sideEffects": false,
9
+ "module": "build/es/index.js",
10
+ "main": "build/cjs/index.js",
11
+ "typings": "./build/cjs/index.d.ts",
12
+ "files": [
13
+ "build",
14
+ "frontend/package.json"
15
+ ],
16
+ "dependencies": {
17
+ "@wix/metro-runtime": "^1.0.0",
18
+ "@wix/sdk-types": "^1.0.0",
19
+ "@wix/motion-edm-autogen-query-wrapper": "^1.0.0"
20
+ },
21
+ "devDependencies": {
22
+ "@wix/typescript-to-service-json": "^1.0.0"
23
+ },
24
+ "scripts": {
25
+ "build": "tsc -b tsconfig.json tsconfig.esm.json",
26
+ "autodocs": "ts-to-sj",
27
+ "posttest": "npm run autodocs",
28
+ "test": ":"
29
+ },
30
+ "wix": {
31
+ "artifact": {
32
+ "artifactId": "email-subscriptions-public-sdk-autogen",
33
+ "groupId": "com.wixpress.public-sdk-autogen"
34
+ }
35
+ },
36
+ "falconPackageHash": "5ee359e72ac0c3c4354575842ad7097c93ac7f8031b96ce1b35a782d"
37
+ }