@driveflux/api-functions 0.0.7-next.19 → 0.0.7-next.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/auth/confirm.js +325 -66
- package/dist/auth/emails.js +210 -42
- package/dist/auth/formatter.js +9 -9
- package/dist/auth/otp.js +374 -120
- package/dist/auth/register.js +383 -95
- package/dist/auth/register.js.map +1 -1
- package/dist/auth/tokens.d.ts +3 -3
- package/dist/auth/tokens.js +426 -114
- package/dist/auth/verifications.js +581 -176
- package/dist/constants.js +4 -4
- package/dist/mailjet/calls/manage-contacts-in-list.d.ts +2 -2
- package/dist/mailjet/calls/manage-contacts-in-list.d.ts.map +1 -1
- package/dist/mailjet/calls/manage-contacts-in-list.js +167 -22
- package/dist/mailjet/calls/manage-contacts-in-list.js.map +1 -1
- package/dist/mailjet/calls/manage-subscription-status.d.ts +2 -2
- package/dist/mailjet/calls/manage-subscription-status.d.ts.map +1 -1
- package/dist/mailjet/calls/manage-subscription-status.js +154 -13
- package/dist/mailjet/calls/manage-subscription-status.js.map +1 -1
- package/dist/mailjet/calls/request-service.js +182 -18
- package/dist/mailjet/refresh-email-preferences.js +221 -21
- package/dist/mailjet/set-contact.d.ts +2 -2
- package/dist/mailjet/set-contact.d.ts.map +1 -1
- package/dist/mailjet/set-contact.js +213 -21
- package/dist/mailjet/set-contact.js.map +1 -1
- package/dist/mailjet/types.d.ts +2 -2
- package/dist/mailjet/types.d.ts.map +1 -1
- package/dist/mailjet/utils/convert-to-array.d.ts +1 -1
- package/dist/mailjet/utils/convert-to-array.d.ts.map +1 -1
- package/dist/mailjet/utils/convert-to-array.js +56 -9
- package/dist/mailjet/utils/extract-email-preferences.d.ts +1 -1
- package/dist/mailjet/utils/extract-email-preferences.d.ts.map +1 -1
- package/dist/mailjet/utils/extract-email-preferences.js +214 -37
- package/dist/mailjet/utils/lists.js +248 -28
- package/dist/mailjet/utils/update-email-references.d.ts +2 -2
- package/dist/mailjet/utils/update-email-references.d.ts.map +1 -1
- package/dist/mailjet/utils/update-email-references.js +207 -27
- package/dist/mailjet/utils/update-email-references.js.map +1 -1
- package/dist/notion/client.js +196 -50
- package/dist/notion/helpful.js +169 -25
- package/dist/notion/schemas/block.js +1 -1
- package/dist/notion/schemas/common.js +9 -7
- package/dist/notion/schemas/database.d.ts +1 -1
- package/dist/notion/schemas/database.js +100 -68
- package/dist/notion/schemas/emoji.js +1 -1
- package/dist/notion/schemas/file.js +1 -1
- package/dist/notion/schemas/kb.js +3 -3
- package/dist/notion/schemas/page.d.ts +1 -1
- package/dist/notion/schemas/page.js +103 -69
- package/dist/notion/schemas/parent.js +4 -4
- package/dist/notion/schemas/user.js +2 -2
- package/dist/reservation/agree.d.ts +1 -1
- package/dist/reservation/agree.d.ts.map +1 -1
- package/dist/reservation/agree.js +157 -17
- package/dist/reservation/checks.d.ts +1 -1
- package/dist/reservation/checks.d.ts.map +1 -1
- package/dist/reservation/checks.js +177 -21
- package/dist/reservation/display-vehicle.d.ts +1 -1
- package/dist/reservation/display-vehicle.js +500 -122
- package/dist/reservation/display-vehicle.js.map +1 -1
- package/dist/reservation/fetch-or-create.d.ts +2 -2
- package/dist/reservation/fetch-or-create.d.ts.map +1 -1
- package/dist/reservation/fetch-or-create.js +478 -188
- package/dist/reservation/fetch-or-create.js.map +1 -1
- package/dist/reservation/invoice.d.ts +3 -3
- package/dist/reservation/invoice.d.ts.map +1 -1
- package/dist/reservation/invoice.js +492 -182
- package/dist/reservation/invoice.js.map +1 -1
- package/dist/reservation/payer.d.ts +1 -1
- package/dist/reservation/payer.d.ts.map +1 -1
- package/dist/reservation/payer.js +175 -25
- package/dist/reservation/reserve.d.ts +1 -1
- package/dist/reservation/reserve.d.ts.map +1 -1
- package/dist/reservation/reserve.js +196 -35
- package/dist/reservation/reserve.js.map +1 -1
- package/dist/reservation/types.d.ts +0 -1
- package/dist/reservation/types.d.ts.map +1 -1
- package/dist/reservation/vehicle.d.ts +1 -1
- package/dist/reservation/vehicle.d.ts.map +1 -1
- package/dist/reservation/vehicle.js +188 -23
- package/dist/reservation/vehicle.js.map +1 -1
- package/dist/slack.js +268 -57
- package/dist/validation.js +98 -38
- package/dist/vehicle/vehicle-pricing/constants.d.ts +1 -1
- package/dist/vehicle/vehicle-pricing/constants.d.ts.map +1 -1
- package/dist/vehicle/vehicle-pricing/constants.js +16 -16
- package/dist/vehicle/vehicle-pricing/index.d.ts +1 -1
- package/dist/vehicle/vehicle-pricing/index.d.ts.map +1 -1
- package/dist/vehicle/vehicle-pricing/index.js +259 -87
- package/dist/vehicle/vehicle-pricing/index.js.map +1 -1
- package/package.json +21 -21
|
@@ -1,3 +1,151 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _define_property(obj, key, value) {
|
|
31
|
+
if (key in obj) {
|
|
32
|
+
Object.defineProperty(obj, key, {
|
|
33
|
+
value: value,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
obj[key] = value;
|
|
40
|
+
}
|
|
41
|
+
return obj;
|
|
42
|
+
}
|
|
43
|
+
function _object_spread(target) {
|
|
44
|
+
for(var i = 1; i < arguments.length; i++){
|
|
45
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
46
|
+
var ownKeys = Object.keys(source);
|
|
47
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
48
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
49
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
ownKeys.forEach(function(key) {
|
|
53
|
+
_define_property(target, key, source[key]);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return target;
|
|
57
|
+
}
|
|
58
|
+
function _ts_generator(thisArg, body) {
|
|
59
|
+
var f, y, t, _ = {
|
|
60
|
+
label: 0,
|
|
61
|
+
sent: function() {
|
|
62
|
+
if (t[0] & 1) throw t[1];
|
|
63
|
+
return t[1];
|
|
64
|
+
},
|
|
65
|
+
trys: [],
|
|
66
|
+
ops: []
|
|
67
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
68
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
69
|
+
return this;
|
|
70
|
+
}), g;
|
|
71
|
+
function verb(n) {
|
|
72
|
+
return function(v) {
|
|
73
|
+
return step([
|
|
74
|
+
n,
|
|
75
|
+
v
|
|
76
|
+
]);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function step(op) {
|
|
80
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
81
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
82
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
83
|
+
if (y = 0, t) op = [
|
|
84
|
+
op[0] & 2,
|
|
85
|
+
t.value
|
|
86
|
+
];
|
|
87
|
+
switch(op[0]){
|
|
88
|
+
case 0:
|
|
89
|
+
case 1:
|
|
90
|
+
t = op;
|
|
91
|
+
break;
|
|
92
|
+
case 4:
|
|
93
|
+
_.label++;
|
|
94
|
+
return {
|
|
95
|
+
value: op[1],
|
|
96
|
+
done: false
|
|
97
|
+
};
|
|
98
|
+
case 5:
|
|
99
|
+
_.label++;
|
|
100
|
+
y = op[1];
|
|
101
|
+
op = [
|
|
102
|
+
0
|
|
103
|
+
];
|
|
104
|
+
continue;
|
|
105
|
+
case 7:
|
|
106
|
+
op = _.ops.pop();
|
|
107
|
+
_.trys.pop();
|
|
108
|
+
continue;
|
|
109
|
+
default:
|
|
110
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
111
|
+
_ = 0;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
115
|
+
_.label = op[1];
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
119
|
+
_.label = t[1];
|
|
120
|
+
t = op;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
if (t && _.label < t[2]) {
|
|
124
|
+
_.label = t[2];
|
|
125
|
+
_.ops.push(op);
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
if (t[2]) _.ops.pop();
|
|
129
|
+
_.trys.pop();
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
op = body.call(thisArg, _);
|
|
133
|
+
} catch (e) {
|
|
134
|
+
op = [
|
|
135
|
+
6,
|
|
136
|
+
e
|
|
137
|
+
];
|
|
138
|
+
y = 0;
|
|
139
|
+
} finally{
|
|
140
|
+
f = t = 0;
|
|
141
|
+
}
|
|
142
|
+
if (op[0] & 5) throw op[1];
|
|
143
|
+
return {
|
|
144
|
+
value: op[0] ? op[1] : void 0,
|
|
145
|
+
done: true
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
1
149
|
import { prisma } from '@driveflux/db';
|
|
2
150
|
import { makeProblem, PROBLEM_NOT_FOUND } from '@driveflux/problem';
|
|
3
151
|
import { Err } from '@driveflux/result';
|
|
@@ -5,7 +153,7 @@ import { manageSubscriptionStatus } from './calls/manage-subscription-status.js'
|
|
|
5
153
|
import { convertToArray } from './utils/convert-to-array.js';
|
|
6
154
|
import { extractUserEmailPreferences } from './utils/extract-email-preferences.js';
|
|
7
155
|
import { updateEmailPreferences } from './utils/update-email-references.js';
|
|
8
|
-
|
|
156
|
+
var userForRefreshEmailPreferencesQuery = {
|
|
9
157
|
select: {
|
|
10
158
|
id: true,
|
|
11
159
|
emailPreferences: true,
|
|
@@ -19,24 +167,76 @@ const userForRefreshEmailPreferencesQuery = {
|
|
|
19
167
|
}
|
|
20
168
|
}
|
|
21
169
|
};
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
170
|
+
export var refreshEmailPreferences = function(idOrUserForRefreshEmailPreferences) {
|
|
171
|
+
return _async_to_generator(function() {
|
|
172
|
+
var user, _tmp, preferences, updated, items;
|
|
173
|
+
return _ts_generator(this, function(_state) {
|
|
174
|
+
switch(_state.label){
|
|
175
|
+
case 0:
|
|
176
|
+
if (!(typeof idOrUserForRefreshEmailPreferences === 'string')) return [
|
|
177
|
+
3,
|
|
178
|
+
2
|
|
179
|
+
];
|
|
180
|
+
return [
|
|
181
|
+
4,
|
|
182
|
+
prisma.user.findUnique(_object_spread({
|
|
183
|
+
where: {
|
|
184
|
+
id: idOrUserForRefreshEmailPreferences
|
|
185
|
+
}
|
|
186
|
+
}, userForRefreshEmailPreferencesQuery))
|
|
187
|
+
];
|
|
188
|
+
case 1:
|
|
189
|
+
_tmp = _state.sent();
|
|
190
|
+
return [
|
|
191
|
+
3,
|
|
192
|
+
3
|
|
193
|
+
];
|
|
194
|
+
case 2:
|
|
195
|
+
_tmp = idOrUserForRefreshEmailPreferences;
|
|
196
|
+
_state.label = 3;
|
|
197
|
+
case 3:
|
|
198
|
+
user = _tmp;
|
|
199
|
+
if (!user) {
|
|
200
|
+
return [
|
|
201
|
+
2,
|
|
202
|
+
new Err(makeProblem(PROBLEM_NOT_FOUND, 'User not found'))
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
return [
|
|
206
|
+
4,
|
|
207
|
+
extractUserEmailPreferences(user)
|
|
208
|
+
];
|
|
209
|
+
case 4:
|
|
210
|
+
preferences = _state.sent();
|
|
211
|
+
if (!preferences) {
|
|
212
|
+
return [
|
|
213
|
+
2,
|
|
214
|
+
new Err(makeProblem(PROBLEM_NOT_FOUND, 'Preferences not found'))
|
|
215
|
+
];
|
|
216
|
+
}
|
|
217
|
+
return [
|
|
218
|
+
4,
|
|
219
|
+
updateEmailPreferences(user, preferences)
|
|
220
|
+
];
|
|
221
|
+
case 5:
|
|
222
|
+
updated = _state.sent();
|
|
223
|
+
if (!updated) {
|
|
224
|
+
return [
|
|
225
|
+
2,
|
|
226
|
+
new Err(makeProblem(PROBLEM_NOT_FOUND, 'User not updated'))
|
|
227
|
+
];
|
|
228
|
+
}
|
|
229
|
+
items = convertToArray(preferences, !!(updated === null || updated === void 0 ? void 0 : updated.businessId));
|
|
230
|
+
return [
|
|
231
|
+
4,
|
|
232
|
+
manageSubscriptionStatus(user.email, items)
|
|
233
|
+
];
|
|
234
|
+
case 6:
|
|
235
|
+
return [
|
|
236
|
+
2,
|
|
237
|
+
_state.sent()
|
|
238
|
+
];
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
})();
|
|
42
242
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Prisma } from '@driveflux/db';
|
|
2
2
|
import { Err, Ok } from '@driveflux/result';
|
|
3
|
-
import type { EmailPreferences } from './types
|
|
3
|
+
import type { EmailPreferences } from './types';
|
|
4
4
|
export type UserForSetInContactListlPreferences = Prisma.UserGetPayload<typeof userForSetInContactListlPreferencesQuery>;
|
|
5
5
|
declare const userForSetInContactListlPreferencesQuery: {
|
|
6
6
|
readonly select: {
|
|
@@ -16,6 +16,6 @@ declare const userForSetInContactListlPreferencesQuery: {
|
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
export declare const setContactInList: (idOrUserForSetInContactListlPreferences: string | UserForSetInContactListlPreferences, preferences: EmailPreferences) => Promise<Err<import("@driveflux/problem").Problem, unknown> | Ok<string, unknown> | Ok<import("@driveflux/result").StandardResult<import("./calls/manage-subscription-status
|
|
19
|
+
export declare const setContactInList: (idOrUserForSetInContactListlPreferences: string | UserForSetInContactListlPreferences, preferences: EmailPreferences) => Promise<Err<import("@driveflux/problem").Problem, unknown> | Ok<string, unknown> | Ok<import("@driveflux/result").StandardResult<import("./calls/manage-subscription-status").MailjetManageContactsListsResponse, unknown, unknown>, unknown>>;
|
|
20
20
|
export {};
|
|
21
21
|
//# sourceMappingURL=set-contact.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-contact.d.ts","sourceRoot":"","sources":["../../src/mailjet/set-contact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAU,MAAM,eAAe,CAAA;AAEnD,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAA;AAE3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"set-contact.d.ts","sourceRoot":"","sources":["../../src/mailjet/set-contact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAU,MAAM,eAAe,CAAA;AAEnD,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAA;AAE3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,MAAM,MAAM,mCAAmC,GAAG,MAAM,CAAC,cAAc,CACtE,OAAO,wCAAwC,CAC/C,CAAA;AAED,QAAA,MAAM,wCAAwC;;;;;;;;;;;;;CAaH,CAAA;AAE3C,eAAO,MAAM,gBAAgB,GAC5B,yCACG,MAAM,GACN,mCAAmC,EACtC,aAAa,gBAAgB,mPAyB7B,CAAA"}
|
|
@@ -1,10 +1,158 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _define_property(obj, key, value) {
|
|
31
|
+
if (key in obj) {
|
|
32
|
+
Object.defineProperty(obj, key, {
|
|
33
|
+
value: value,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
obj[key] = value;
|
|
40
|
+
}
|
|
41
|
+
return obj;
|
|
42
|
+
}
|
|
43
|
+
function _object_spread(target) {
|
|
44
|
+
for(var i = 1; i < arguments.length; i++){
|
|
45
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
46
|
+
var ownKeys = Object.keys(source);
|
|
47
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
48
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
49
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
ownKeys.forEach(function(key) {
|
|
53
|
+
_define_property(target, key, source[key]);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return target;
|
|
57
|
+
}
|
|
58
|
+
function _ts_generator(thisArg, body) {
|
|
59
|
+
var f, y, t, _ = {
|
|
60
|
+
label: 0,
|
|
61
|
+
sent: function() {
|
|
62
|
+
if (t[0] & 1) throw t[1];
|
|
63
|
+
return t[1];
|
|
64
|
+
},
|
|
65
|
+
trys: [],
|
|
66
|
+
ops: []
|
|
67
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
68
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
69
|
+
return this;
|
|
70
|
+
}), g;
|
|
71
|
+
function verb(n) {
|
|
72
|
+
return function(v) {
|
|
73
|
+
return step([
|
|
74
|
+
n,
|
|
75
|
+
v
|
|
76
|
+
]);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function step(op) {
|
|
80
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
81
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
82
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
83
|
+
if (y = 0, t) op = [
|
|
84
|
+
op[0] & 2,
|
|
85
|
+
t.value
|
|
86
|
+
];
|
|
87
|
+
switch(op[0]){
|
|
88
|
+
case 0:
|
|
89
|
+
case 1:
|
|
90
|
+
t = op;
|
|
91
|
+
break;
|
|
92
|
+
case 4:
|
|
93
|
+
_.label++;
|
|
94
|
+
return {
|
|
95
|
+
value: op[1],
|
|
96
|
+
done: false
|
|
97
|
+
};
|
|
98
|
+
case 5:
|
|
99
|
+
_.label++;
|
|
100
|
+
y = op[1];
|
|
101
|
+
op = [
|
|
102
|
+
0
|
|
103
|
+
];
|
|
104
|
+
continue;
|
|
105
|
+
case 7:
|
|
106
|
+
op = _.ops.pop();
|
|
107
|
+
_.trys.pop();
|
|
108
|
+
continue;
|
|
109
|
+
default:
|
|
110
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
111
|
+
_ = 0;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
115
|
+
_.label = op[1];
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
119
|
+
_.label = t[1];
|
|
120
|
+
t = op;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
if (t && _.label < t[2]) {
|
|
124
|
+
_.label = t[2];
|
|
125
|
+
_.ops.push(op);
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
if (t[2]) _.ops.pop();
|
|
129
|
+
_.trys.pop();
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
op = body.call(thisArg, _);
|
|
133
|
+
} catch (e) {
|
|
134
|
+
op = [
|
|
135
|
+
6,
|
|
136
|
+
e
|
|
137
|
+
];
|
|
138
|
+
y = 0;
|
|
139
|
+
} finally{
|
|
140
|
+
f = t = 0;
|
|
141
|
+
}
|
|
142
|
+
if (op[0] & 5) throw op[1];
|
|
143
|
+
return {
|
|
144
|
+
value: op[0] ? op[1] : void 0,
|
|
145
|
+
done: true
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
1
149
|
import { prisma } from '@driveflux/db';
|
|
2
150
|
import { makeProblem, PROBLEM_NOT_FOUND } from '@driveflux/problem';
|
|
3
151
|
import { Err, Ok } from '@driveflux/result';
|
|
4
|
-
import { manageSubscriptionStatus } from './calls/manage-subscription-status
|
|
5
|
-
import { convertToArray } from './utils/convert-to-array
|
|
6
|
-
import { updateEmailPreferences } from './utils/update-email-references
|
|
7
|
-
|
|
152
|
+
import { manageSubscriptionStatus } from './calls/manage-subscription-status';
|
|
153
|
+
import { convertToArray } from './utils/convert-to-array';
|
|
154
|
+
import { updateEmailPreferences } from './utils/update-email-references';
|
|
155
|
+
var userForSetInContactListlPreferencesQuery = {
|
|
8
156
|
select: {
|
|
9
157
|
id: true,
|
|
10
158
|
emailPreferences: true,
|
|
@@ -18,21 +166,65 @@ const userForSetInContactListlPreferencesQuery = {
|
|
|
18
166
|
}
|
|
19
167
|
}
|
|
20
168
|
};
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
169
|
+
export var setContactInList = function(idOrUserForSetInContactListlPreferences, preferences) {
|
|
170
|
+
return _async_to_generator(function() {
|
|
171
|
+
var user, _tmp, updated, items, results;
|
|
172
|
+
return _ts_generator(this, function(_state) {
|
|
173
|
+
switch(_state.label){
|
|
174
|
+
case 0:
|
|
175
|
+
if (!(typeof idOrUserForSetInContactListlPreferences === 'string')) return [
|
|
176
|
+
3,
|
|
177
|
+
2
|
|
178
|
+
];
|
|
179
|
+
return [
|
|
180
|
+
4,
|
|
181
|
+
prisma.user.findUnique(_object_spread({
|
|
182
|
+
where: {
|
|
183
|
+
id: idOrUserForSetInContactListlPreferences
|
|
184
|
+
}
|
|
185
|
+
}, userForSetInContactListlPreferencesQuery))
|
|
186
|
+
];
|
|
187
|
+
case 1:
|
|
188
|
+
_tmp = _state.sent();
|
|
189
|
+
return [
|
|
190
|
+
3,
|
|
191
|
+
3
|
|
192
|
+
];
|
|
193
|
+
case 2:
|
|
194
|
+
_tmp = idOrUserForSetInContactListlPreferences;
|
|
195
|
+
_state.label = 3;
|
|
196
|
+
case 3:
|
|
197
|
+
user = _tmp;
|
|
198
|
+
if (!user) {
|
|
199
|
+
return [
|
|
200
|
+
2,
|
|
201
|
+
new Err(makeProblem(PROBLEM_NOT_FOUND, 'User not found'))
|
|
202
|
+
];
|
|
203
|
+
}
|
|
204
|
+
return [
|
|
205
|
+
4,
|
|
206
|
+
updateEmailPreferences(user, preferences)
|
|
207
|
+
];
|
|
208
|
+
case 4:
|
|
209
|
+
updated = _state.sent();
|
|
210
|
+
if (!updated) {
|
|
211
|
+
return [
|
|
212
|
+
2,
|
|
213
|
+
new Ok('No new lists were provided')
|
|
214
|
+
];
|
|
215
|
+
}
|
|
216
|
+
items = convertToArray(preferences);
|
|
217
|
+
return [
|
|
218
|
+
4,
|
|
219
|
+
manageSubscriptionStatus(user.email, items)
|
|
220
|
+
];
|
|
221
|
+
case 5:
|
|
222
|
+
results = _state.sent();
|
|
223
|
+
return [
|
|
224
|
+
2,
|
|
225
|
+
new Ok(results)
|
|
226
|
+
];
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
})();
|
|
38
230
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-contact.js","sourceRoot":"","sources":["../../src/mailjet/set-contact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"set-contact.js","sourceRoot":"","sources":["../../src/mailjet/set-contact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAA;AAE7E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAA;AAMxE,MAAM,wCAAwC,GAAG;IAChD,MAAM,EAAE;QACP,EAAE,EAAE,IAAI;QACR,gBAAgB,EAAE,IAAI;QACtB,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,IAAI;QACX,aAAa,EAAE;YACd,MAAM,EAAE;gBACP,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,IAAI;aACZ;SACD;KACD;CACyC,CAAA;AAE3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACpC,uCAEsC,EACtC,WAA6B,EAC5B,EAAE;IACH,MAAM,IAAI,GACT,OAAO,uCAAuC,KAAK,QAAQ;QAC1D,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;YAC7B,KAAK,EAAE,EAAE,EAAE,EAAE,uCAAuC,EAAE;YACtD,GAAG,wCAAwC;SAC3C,CAAC;QACH,CAAC,CAAC,uCAAuC,CAAA;IAE3C,IAAI,CAAC,IAAI,EAAE,CAAC;QACX,OAAO,IAAI,GAAG,CAAC,WAAW,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC,CAAA;IACjE,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,sBAAsB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;IAE/D,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAO,IAAI,EAAE,CAAC,4BAA4B,CAAC,CAAA;IAC5C,CAAC;IAED,MAAM,KAAK,GAAG,cAAc,CAAC,WAAW,CAAC,CAAA;IAEzC,MAAM,OAAO,GAAG,MAAM,wBAAwB,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAEjE,OAAO,IAAI,EAAE,CAAC,OAAO,CAAC,CAAA;AACvB,CAAC,CAAA"}
|
package/dist/mailjet/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Subscription, User } from '@driveflux/db';
|
|
2
|
-
import type { ListName } from './utils/lists
|
|
2
|
+
import type { ListName } from './utils/lists';
|
|
3
3
|
export type UserWithSubscription = User & {
|
|
4
4
|
subscriptions: Subscription[];
|
|
5
5
|
};
|
|
@@ -26,6 +26,6 @@ export type MailjetOptions = {
|
|
|
26
26
|
list: ListName;
|
|
27
27
|
unsub?: boolean;
|
|
28
28
|
};
|
|
29
|
-
export type { ListName, MailjetLists } from './utils/lists
|
|
29
|
+
export type { ListName, MailjetLists } from './utils/lists';
|
|
30
30
|
export type StatusAction = 'addforce' | 'addnoforce' | 'remove' | 'unsub';
|
|
31
31
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/mailjet/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/mailjet/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,MAAM,oBAAoB,GAAG,IAAI,GAAG;IAAE,aAAa,EAAE,YAAY,EAAE,CAAA;CAAE,CAAA;AAE3E,MAAM,MAAM,OAAO,GAAG;IACrB,uBAAuB,EAAE,OAAO,CAAA;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,IAAI,GAAG,MAAM,CAAA;IACxB,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,+BAA+B,EAAE,IAAI,GAAG,MAAM,CAAA;IAC9C,EAAE,EAAE,MAAM,CAAA;IACV,cAAc,EAAE,MAAM,CAAA;IACtB,iBAAiB,EAAE,KAAK,CAAA;IACxB,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B,YAAY,EAAE,IAAI,GAAG,MAAM,CAAA;IAC3B,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;KAAG,GAAG,IAAI,QAAQ,CAAC,CAAC,EAAE,OAAO;CAAE,CAAA;AAE9D,MAAM,MAAM,cAAc,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,QAAQ,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAED,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE3D,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EmailPreferences } from '../types
|
|
1
|
+
import type { EmailPreferences } from '../types';
|
|
2
2
|
export declare const convertToArray: (preferences?: EmailPreferences, isBusiness?: boolean) => {
|
|
3
3
|
list: "generalMarketing" | "noActiveSubs" | "signUpOnly" | "signUpPaymentAdded" | "activeSub" | "expiredSub" | "activeSubBusiness" | "activeSubPersonal";
|
|
4
4
|
action: "addnoforce" | "unsub";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-to-array.d.ts","sourceRoot":"","sources":["../../../src/mailjet/utils/convert-to-array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAA0B,MAAM,
|
|
1
|
+
{"version":3,"file":"convert-to-array.d.ts","sourceRoot":"","sources":["../../../src/mailjet/utils/convert-to-array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAA0B,MAAM,UAAU,CAAA;AAExE,eAAO,MAAM,cAAc,GAC1B,cAAc,gBAAgB,EAC9B,aAAa,OAAO;;;GA0BpB,CAAA"}
|
|
@@ -1,24 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _iterable_to_array_limit(arr, i) {
|
|
10
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
11
|
+
if (_i == null) return;
|
|
12
|
+
var _arr = [];
|
|
13
|
+
var _n = true;
|
|
14
|
+
var _d = false;
|
|
15
|
+
var _s, _e;
|
|
16
|
+
try {
|
|
17
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
18
|
+
_arr.push(_s.value);
|
|
19
|
+
if (i && _arr.length === i) break;
|
|
20
|
+
}
|
|
21
|
+
} catch (err) {
|
|
22
|
+
_d = true;
|
|
23
|
+
_e = err;
|
|
24
|
+
} finally{
|
|
25
|
+
try {
|
|
26
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
27
|
+
} finally{
|
|
28
|
+
if (_d) throw _e;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return _arr;
|
|
32
|
+
}
|
|
33
|
+
function _non_iterable_rest() {
|
|
34
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
35
|
+
}
|
|
36
|
+
function _sliced_to_array(arr, i) {
|
|
37
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
38
|
+
}
|
|
39
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
40
|
+
if (!o) return;
|
|
41
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
42
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
43
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
44
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
45
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
46
|
+
}
|
|
47
|
+
export var convertToArray = function(preferences, isBusiness) {
|
|
2
48
|
if (!preferences) {
|
|
3
49
|
return [];
|
|
4
50
|
}
|
|
5
|
-
|
|
51
|
+
var preferencesArray = Object.entries(preferences);
|
|
6
52
|
if (typeof isBusiness === 'boolean') {
|
|
7
53
|
preferencesArray.push([
|
|
8
54
|
'activeSubBusiness',
|
|
9
|
-
!!preferences
|
|
55
|
+
!!(preferences === null || preferences === void 0 ? void 0 : preferences.activeSub) && isBusiness
|
|
10
56
|
]);
|
|
11
57
|
preferencesArray.push([
|
|
12
58
|
'activeSubPersonal',
|
|
13
|
-
!!preferences
|
|
59
|
+
!!(preferences === null || preferences === void 0 ? void 0 : preferences.activeSub) && !isBusiness
|
|
14
60
|
]);
|
|
15
61
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
62
|
+
var items = preferencesArray.map(function(param) {
|
|
63
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
64
|
+
var list = key;
|
|
65
|
+
var action = value ? 'addnoforce' : 'unsub';
|
|
19
66
|
return {
|
|
20
|
-
list,
|
|
21
|
-
action
|
|
67
|
+
list: list,
|
|
68
|
+
action: action
|
|
22
69
|
};
|
|
23
70
|
});
|
|
24
71
|
return items;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Prisma } from '@driveflux/db';
|
|
2
|
-
import type { EmailPreferences } from '../types
|
|
2
|
+
import type { EmailPreferences } from '../types';
|
|
3
3
|
export type UserForEmailPreferences = Prisma.UserGetPayload<typeof userForEmailPreferencesQuery>;
|
|
4
4
|
export declare const userForEmailPreferencesQuery: {
|
|
5
5
|
readonly select: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-email-preferences.d.ts","sourceRoot":"","sources":["../../../src/mailjet/utils/extract-email-preferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAU,MAAM,eAAe,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"extract-email-preferences.d.ts","sourceRoot":"","sources":["../../../src/mailjet/utils/extract-email-preferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAU,MAAM,eAAe,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAY,MAAM,UAAU,CAAA;AAE1D,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,cAAc,CAC1D,OAAO,4BAA4B,CACnC,CAAA;AAED,eAAO,MAAM,4BAA4B;;;;;;;;;;;CAWE,CAAA;AAE3C,eAAO,MAAM,2BAA2B,GACvC,6BAA6B,MAAM,GAAG,uBAAuB,0CA8C7D,CAAA"}
|