@driveflux/api-functions 0.0.7-next.2 → 0.0.7-next.21
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 +73 -327
- package/dist/auth/emails.js +43 -210
- package/dist/auth/formatter.js +11 -11
- package/dist/auth/otp.js +122 -392
- package/dist/auth/register.d.ts +1 -1
- package/dist/auth/register.js +102 -398
- package/dist/auth/register.js.map +1 -1
- package/dist/auth/tokens.js +115 -430
- package/dist/auth/verifications.js +177 -583
- package/dist/constants.js +5 -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 +24 -168
- 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 +14 -154
- package/dist/mailjet/calls/manage-subscription-status.js.map +1 -1
- package/dist/mailjet/calls/request-service.d.ts +1 -1
- package/dist/mailjet/calls/request-service.d.ts.map +1 -1
- package/dist/mailjet/calls/request-service.js +18 -183
- package/dist/mailjet/refresh-email-preferences.js +26 -225
- 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 +26 -217
- 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/types.js +2 -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 +9 -58
- 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 +41 -217
- package/dist/mailjet/utils/lists.js +30 -249
- 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 +27 -208
- package/dist/mailjet/utils/update-email-references.js.map +1 -1
- package/dist/notion/client.js +48 -197
- package/dist/notion/helpful.js +29 -170
- package/dist/notion/schemas/block.js +49 -43
- package/dist/notion/schemas/common.js +17 -14
- package/dist/notion/schemas/database.js +125 -159
- package/dist/notion/schemas/emoji.js +3 -2
- package/dist/notion/schemas/file.js +10 -10
- package/dist/notion/schemas/kb.js +9 -8
- package/dist/notion/schemas/page.js +126 -171
- package/dist/notion/schemas/parent.js +9 -8
- package/dist/notion/schemas/user.js +21 -20
- package/dist/reservation/agree.d.ts +1 -1
- package/dist/reservation/agree.d.ts.map +1 -1
- package/dist/reservation/agree.js +19 -158
- package/dist/reservation/checks.d.ts +1 -1
- package/dist/reservation/checks.d.ts.map +1 -1
- package/dist/reservation/checks.js +23 -178
- package/dist/reservation/display-vehicle.d.ts +17 -17
- package/dist/reservation/display-vehicle.js +142 -514
- 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 +199 -482
- 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 +198 -496
- 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 +28 -177
- package/dist/reservation/reserve.d.ts +1 -1
- package/dist/reservation/reserve.d.ts.map +1 -1
- package/dist/reservation/reserve.js +36 -196
- package/dist/reservation/reserve.js.map +1 -1
- package/dist/reservation/types.d.ts +1 -0
- package/dist/reservation/types.d.ts.map +1 -1
- package/dist/reservation/types.js +2 -1
- package/dist/reservation/vehicle.d.ts +1 -1
- package/dist/reservation/vehicle.d.ts.map +1 -1
- package/dist/reservation/vehicle.js +26 -188
- package/dist/reservation/vehicle.js.map +1 -1
- package/dist/slack.d.ts +2 -2
- package/dist/slack.d.ts.map +1 -1
- package/dist/slack.js +67 -273
- package/dist/validation.d.ts +4 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +89 -139
- package/dist/validation.js.map +1 -1
- 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 +33 -36
- 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 +101 -259
- package/dist/vehicle/vehicle-pricing/index.js.map +1 -1
- package/dist/vehicle/vehicle-pricing/types.js +2 -1
- package/package.json +21 -21
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export const TASK_PIPELINE_SLACK = 'slack-pipeline';
|
|
2
|
+
export const TASK_COMMIT_SLACK_CHANNEL = 'commit-slack-channel';
|
|
3
|
+
export const TASK_PIPELINE_SLACK_CRON = '* * * * *';
|
|
4
|
+
export const SALT_ROUNDS = 12;
|
|
5
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { User } from '@driveflux/db';
|
|
2
2
|
import { Err } from '@driveflux/result';
|
|
3
|
-
import type { MailjetLists, StatusAction } from '../types';
|
|
4
|
-
import { type ResponseBase } from './request-service';
|
|
3
|
+
import type { MailjetLists, StatusAction } from '../types.js';
|
|
4
|
+
import { type ResponseBase } from './request-service.js';
|
|
5
5
|
type Params = {
|
|
6
6
|
users: User[];
|
|
7
7
|
list: keyof MailjetLists;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manage-contacts-in-list.d.ts","sourceRoot":"","sources":["../../../src/mailjet/calls/manage-contacts-in-list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AACvC,OAAO,KAAK,EAAW,YAAY,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"manage-contacts-in-list.d.ts","sourceRoot":"","sources":["../../../src/mailjet/calls/manage-contacts-in-list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AACvC,OAAO,KAAK,EAAW,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEtE,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAErE,KAAK,MAAM,GAAG;IACb,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,IAAI,EAAE,MAAM,YAAY,CAAA;IACxB,MAAM,CAAC,EAAE,YAAY,CAAA;CACrB,CAAA;AAED,KAAK,QAAQ,GAAG,YAAY,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAA;CACb,CAAC,CAAA;AAGF,eAAO,MAAM,oBAAoB,GAAU,0BAIxC,MAAM;;;;;;GA6BR,CAAA"}
|
|
@@ -1,172 +1,28 @@
|
|
|
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 _ts_generator(thisArg, body) {
|
|
31
|
-
var f, y, t, _ = {
|
|
32
|
-
label: 0,
|
|
33
|
-
sent: function() {
|
|
34
|
-
if (t[0] & 1) throw t[1];
|
|
35
|
-
return t[1];
|
|
36
|
-
},
|
|
37
|
-
trys: [],
|
|
38
|
-
ops: []
|
|
39
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
40
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
41
|
-
return this;
|
|
42
|
-
}), g;
|
|
43
|
-
function verb(n) {
|
|
44
|
-
return function(v) {
|
|
45
|
-
return step([
|
|
46
|
-
n,
|
|
47
|
-
v
|
|
48
|
-
]);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function step(op) {
|
|
52
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
53
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
54
|
-
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;
|
|
55
|
-
if (y = 0, t) op = [
|
|
56
|
-
op[0] & 2,
|
|
57
|
-
t.value
|
|
58
|
-
];
|
|
59
|
-
switch(op[0]){
|
|
60
|
-
case 0:
|
|
61
|
-
case 1:
|
|
62
|
-
t = op;
|
|
63
|
-
break;
|
|
64
|
-
case 4:
|
|
65
|
-
_.label++;
|
|
66
|
-
return {
|
|
67
|
-
value: op[1],
|
|
68
|
-
done: false
|
|
69
|
-
};
|
|
70
|
-
case 5:
|
|
71
|
-
_.label++;
|
|
72
|
-
y = op[1];
|
|
73
|
-
op = [
|
|
74
|
-
0
|
|
75
|
-
];
|
|
76
|
-
continue;
|
|
77
|
-
case 7:
|
|
78
|
-
op = _.ops.pop();
|
|
79
|
-
_.trys.pop();
|
|
80
|
-
continue;
|
|
81
|
-
default:
|
|
82
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
-
_ = 0;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
-
_.label = op[1];
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
-
_.label = t[1];
|
|
92
|
-
t = op;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
if (t && _.label < t[2]) {
|
|
96
|
-
_.label = t[2];
|
|
97
|
-
_.ops.push(op);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
if (t[2]) _.ops.pop();
|
|
101
|
-
_.trys.pop();
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
op = body.call(thisArg, _);
|
|
105
|
-
} catch (e) {
|
|
106
|
-
op = [
|
|
107
|
-
6,
|
|
108
|
-
e
|
|
109
|
-
];
|
|
110
|
-
y = 0;
|
|
111
|
-
} finally{
|
|
112
|
-
f = t = 0;
|
|
113
|
-
}
|
|
114
|
-
if (op[0] & 5) throw op[1];
|
|
115
|
-
return {
|
|
116
|
-
value: op[0] ? op[1] : void 0,
|
|
117
|
-
done: true
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
1
|
import { makeProblem, PROBLEM_INVALID_DATA } from '@driveflux/problem';
|
|
122
2
|
import { Err } from '@driveflux/result';
|
|
123
|
-
import { getListByRef } from '../utils/lists';
|
|
124
|
-
import { callMailjet } from './request-service';
|
|
3
|
+
import { getListByRef } from '../utils/lists.js';
|
|
4
|
+
import { callMailjet } from './request-service.js';
|
|
125
5
|
// Add a contact to a contact list in Mailjet
|
|
126
|
-
export
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
];
|
|
148
|
-
case 1:
|
|
149
|
-
listOjbect = _state.sent();
|
|
150
|
-
if (!(listOjbect === null || listOjbect === void 0 ? void 0 : listOjbect.id)) {
|
|
151
|
-
return [
|
|
152
|
-
2,
|
|
153
|
-
new Err(makeProblem(PROBLEM_INVALID_DATA, "List '".concat(list, "' is not valid")))
|
|
154
|
-
];
|
|
155
|
-
}
|
|
156
|
-
return [
|
|
157
|
-
4,
|
|
158
|
-
callMailjet("contactslist/".concat(listOjbect.id, "/managemanycontacts"), {
|
|
159
|
-
Action: action,
|
|
160
|
-
Contacts: contacts
|
|
161
|
-
})
|
|
162
|
-
];
|
|
163
|
-
case 2:
|
|
164
|
-
result = _state.sent();
|
|
165
|
-
return [
|
|
166
|
-
2,
|
|
167
|
-
result
|
|
168
|
-
];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
})();
|
|
6
|
+
export const manageContactsInList = async ({ users, list, action = 'addnoforce', }) => {
|
|
7
|
+
const contacts = users.map((u) => {
|
|
8
|
+
return {
|
|
9
|
+
Email: u.email,
|
|
10
|
+
IsExcludedFromCampaigns: false,
|
|
11
|
+
Name: `${u.firstName} ${u.lastName}`,
|
|
12
|
+
Properties: {
|
|
13
|
+
FirstName: u.firstName,
|
|
14
|
+
LastName: u.lastName,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
const listOjbect = await getListByRef(list);
|
|
19
|
+
if (!listOjbect?.id) {
|
|
20
|
+
return new Err(makeProblem(PROBLEM_INVALID_DATA, `List '${list}' is not valid`));
|
|
21
|
+
}
|
|
22
|
+
const result = await callMailjet(`contactslist/${listOjbect.id}/managemanycontacts`, {
|
|
23
|
+
Action: action,
|
|
24
|
+
Contacts: contacts,
|
|
25
|
+
});
|
|
26
|
+
return result;
|
|
172
27
|
};
|
|
28
|
+
//# sourceMappingURL=manage-contacts-in-list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manage-contacts-in-list.js","sourceRoot":"","sources":["../../../src/mailjet/calls/manage-contacts-in-list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"manage-contacts-in-list.js","sourceRoot":"","sources":["../../../src/mailjet/calls/manage-contacts-in-list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAqB,MAAM,sBAAsB,CAAA;AAYrE,6CAA6C;AAC7C,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAAE,EAC1C,KAAK,EACL,IAAI,EACJ,MAAM,GAAG,YAAY,GACb,EAAE,EAAE;IACZ,MAAM,QAAQ,GAAuB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACpD,OAAO;YACN,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,uBAAuB,EAAE,KAAK;YAC9B,IAAI,EAAE,GAAG,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,EAAE;YACpC,UAAU,EAAE;gBACX,SAAS,EAAE,CAAC,CAAC,SAAS;gBACtB,QAAQ,EAAE,CAAC,CAAC,QAAQ;aACpB;SACD,CAAA;IACF,CAAC,CAAC,CAAA;IAEF,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,CAAA;IAE3C,IAAI,CAAC,UAAU,EAAE,EAAE,EAAE,CAAC;QACrB,OAAO,IAAI,GAAG,CACb,WAAW,CAAC,oBAAoB,EAAE,SAAS,IAAI,gBAAgB,CAAC,CAChE,CAAA;IACF,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,WAAW,CAC/B,gBAAgB,UAAU,CAAC,EAAE,qBAAqB,EAClD;QACC,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,QAAQ;KAClB,CACD,CAAA;IACD,OAAO,MAAM,CAAA;AACd,CAAC,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PromisedResult } from '@driveflux/result';
|
|
2
|
-
import type { ListName, StatusAction } from '../types';
|
|
3
|
-
import { type ResponseBase } from './request-service';
|
|
2
|
+
import type { ListName, StatusAction } from '../types.js';
|
|
3
|
+
import { type ResponseBase } from './request-service.js';
|
|
4
4
|
export type Item = {
|
|
5
5
|
list: ListName;
|
|
6
6
|
action?: StatusAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manage-subscription-status.d.ts","sourceRoot":"","sources":["../../../src/mailjet/calls/manage-subscription-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"manage-subscription-status.d.ts","sourceRoot":"","sources":["../../../src/mailjet/calls/manage-subscription-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEzD,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAErE,MAAM,MAAM,IAAI,GAAG;IAClB,IAAI,EAAE,QAAQ,CAAA;IACd,MAAM,CAAC,EAAE,YAAY,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,kCAAkC,GAAG,YAAY,CAAC;IAC7D,aAAa,EAAE;QACd,MAAM,EAAE,MAAM,CAAA;QACd,MAAM,EAAE,YAAY,CAAA;KACpB,EAAE,CAAA;CACH,CAAC,CAAA;AAEF,eAAO,MAAM,wBAAwB,GACpC,OAAO,MAAM,EACb,cAAc,IAAI,EAAE,KAClB,cAAc,CAAC,kCAAkC,CAkBnD,CAAA"}
|
|
@@ -1,156 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
});
|
|
1
|
+
import { getLists } from '../utils/lists.js';
|
|
2
|
+
import { callMailjet } from './request-service.js';
|
|
3
|
+
export const manageSubscriptionStatus = async (email, updatedLists) => {
|
|
4
|
+
const lists = await getLists();
|
|
5
|
+
const data = {
|
|
6
|
+
ContactsLists: updatedLists.map((item) => {
|
|
7
|
+
return {
|
|
8
|
+
Action: item.action,
|
|
9
|
+
ListID: lists[item.list],
|
|
10
|
+
};
|
|
11
|
+
}),
|
|
28
12
|
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
var f, y, t, _ = {
|
|
32
|
-
label: 0,
|
|
33
|
-
sent: function() {
|
|
34
|
-
if (t[0] & 1) throw t[1];
|
|
35
|
-
return t[1];
|
|
36
|
-
},
|
|
37
|
-
trys: [],
|
|
38
|
-
ops: []
|
|
39
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
40
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
41
|
-
return this;
|
|
42
|
-
}), g;
|
|
43
|
-
function verb(n) {
|
|
44
|
-
return function(v) {
|
|
45
|
-
return step([
|
|
46
|
-
n,
|
|
47
|
-
v
|
|
48
|
-
]);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function step(op) {
|
|
52
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
53
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
54
|
-
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;
|
|
55
|
-
if (y = 0, t) op = [
|
|
56
|
-
op[0] & 2,
|
|
57
|
-
t.value
|
|
58
|
-
];
|
|
59
|
-
switch(op[0]){
|
|
60
|
-
case 0:
|
|
61
|
-
case 1:
|
|
62
|
-
t = op;
|
|
63
|
-
break;
|
|
64
|
-
case 4:
|
|
65
|
-
_.label++;
|
|
66
|
-
return {
|
|
67
|
-
value: op[1],
|
|
68
|
-
done: false
|
|
69
|
-
};
|
|
70
|
-
case 5:
|
|
71
|
-
_.label++;
|
|
72
|
-
y = op[1];
|
|
73
|
-
op = [
|
|
74
|
-
0
|
|
75
|
-
];
|
|
76
|
-
continue;
|
|
77
|
-
case 7:
|
|
78
|
-
op = _.ops.pop();
|
|
79
|
-
_.trys.pop();
|
|
80
|
-
continue;
|
|
81
|
-
default:
|
|
82
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
-
_ = 0;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
-
_.label = op[1];
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
-
_.label = t[1];
|
|
92
|
-
t = op;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
if (t && _.label < t[2]) {
|
|
96
|
-
_.label = t[2];
|
|
97
|
-
_.ops.push(op);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
if (t[2]) _.ops.pop();
|
|
101
|
-
_.trys.pop();
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
op = body.call(thisArg, _);
|
|
105
|
-
} catch (e) {
|
|
106
|
-
op = [
|
|
107
|
-
6,
|
|
108
|
-
e
|
|
109
|
-
];
|
|
110
|
-
y = 0;
|
|
111
|
-
} finally{
|
|
112
|
-
f = t = 0;
|
|
113
|
-
}
|
|
114
|
-
if (op[0] & 5) throw op[1];
|
|
115
|
-
return {
|
|
116
|
-
value: op[0] ? op[1] : void 0,
|
|
117
|
-
done: true
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
import { getLists } from '../utils/lists';
|
|
122
|
-
import { callMailjet } from './request-service';
|
|
123
|
-
export var manageSubscriptionStatus = function(email, updatedLists) {
|
|
124
|
-
return _async_to_generator(function() {
|
|
125
|
-
var lists, data, result;
|
|
126
|
-
return _ts_generator(this, function(_state) {
|
|
127
|
-
switch(_state.label){
|
|
128
|
-
case 0:
|
|
129
|
-
return [
|
|
130
|
-
4,
|
|
131
|
-
getLists()
|
|
132
|
-
];
|
|
133
|
-
case 1:
|
|
134
|
-
lists = _state.sent();
|
|
135
|
-
data = {
|
|
136
|
-
ContactsLists: updatedLists.map(function(item) {
|
|
137
|
-
return {
|
|
138
|
-
Action: item.action,
|
|
139
|
-
ListID: lists[item.list]
|
|
140
|
-
};
|
|
141
|
-
})
|
|
142
|
-
};
|
|
143
|
-
return [
|
|
144
|
-
4,
|
|
145
|
-
callMailjet("/contact/".concat(email, "/managecontactslists"), data)
|
|
146
|
-
];
|
|
147
|
-
case 2:
|
|
148
|
-
result = _state.sent();
|
|
149
|
-
return [
|
|
150
|
-
2,
|
|
151
|
-
result
|
|
152
|
-
];
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
})();
|
|
13
|
+
const result = await callMailjet(`/contact/${email}/managecontactslists`, data);
|
|
14
|
+
return result;
|
|
156
15
|
};
|
|
16
|
+
//# sourceMappingURL=manage-subscription-status.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manage-subscription-status.js","sourceRoot":"","sources":["../../../src/mailjet/calls/manage-subscription-status.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"manage-subscription-status.js","sourceRoot":"","sources":["../../../src/mailjet/calls/manage-subscription-status.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAqB,MAAM,sBAAsB,CAAA;AAcrE,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAC5C,KAAa,EACb,YAAoB,EACiC,EAAE;IACvD,MAAM,KAAK,GAAG,MAAM,QAAQ,EAAE,CAAA;IAE9B,MAAM,IAAI,GAAG;QACZ,aAAa,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACxC,OAAO;gBACN,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;aACxB,CAAA;QACF,CAAC,CAAC;KACF,CAAA;IAED,MAAM,MAAM,GAAG,MAAM,WAAW,CAC/B,YAAY,KAAK,sBAAsB,EACvC,IAAI,CACJ,CAAA;IAED,OAAO,MAAM,CAAA;AACd,CAAC,CAAA"}
|
|
@@ -3,5 +3,5 @@ export type ResponseBase<T> = {
|
|
|
3
3
|
Data?: T[];
|
|
4
4
|
Total?: number;
|
|
5
5
|
};
|
|
6
|
-
export declare const callMailjet: <T>(path: string, data: any, method?: string) => Promise<import("@driveflux/fetch").EnhandedFetchResult<T, import("
|
|
6
|
+
export declare const callMailjet: <T>(path: string, data: any, method?: string) => Promise<import("@driveflux/fetch").EnhandedFetchResult<T, import("@driveflux/problem").Problem>>;
|
|
7
7
|
//# sourceMappingURL=request-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-service.d.ts","sourceRoot":"","sources":["../../../src/mailjet/calls/request-service.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,CAAC,EAAE,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAgBD,eAAO,MAAM,WAAW,GAAU,CAAC,EAClC,MAAM,MAAM,EACZ,MAAM,GAAG,EACT,eAAe,
|
|
1
|
+
{"version":3,"file":"request-service.d.ts","sourceRoot":"","sources":["../../../src/mailjet/calls/request-service.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,CAAC,EAAE,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAgBD,eAAO,MAAM,WAAW,GAAU,CAAC,EAClC,MAAM,MAAM,EACZ,MAAM,GAAG,EACT,eAAe,qGAaf,CAAA"}
|
|
@@ -1,189 +1,24 @@
|
|
|
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
|
-
}
|
|
149
1
|
import { config } from '@driveflux/email';
|
|
150
2
|
import { enhancedFetch } from '@driveflux/fetch';
|
|
151
|
-
|
|
152
|
-
|
|
3
|
+
const getAuth = () => {
|
|
4
|
+
const authData = {
|
|
153
5
|
publicKey: config.mailjet.apiKeyPublic || process.env.MAILJET_API_KEY_PUBLIC,
|
|
154
|
-
privateKey: config.mailjet.apiKeyPrivate || process.env.MAILJET_API_KEY_PRIVATE
|
|
6
|
+
privateKey: config.mailjet.apiKeyPrivate || process.env.MAILJET_API_KEY_PRIVATE,
|
|
155
7
|
};
|
|
156
|
-
|
|
157
|
-
return
|
|
8
|
+
const authLine = `${authData.publicKey}:${authData.privateKey}`;
|
|
9
|
+
return `Basic ${Buffer.from(authLine).toString('base64')}`;
|
|
158
10
|
};
|
|
159
|
-
|
|
160
|
-
export
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
method: method,
|
|
172
|
-
headers: {
|
|
173
|
-
'Content-Type': 'application/json',
|
|
174
|
-
Authorization: getAuth()
|
|
175
|
-
}
|
|
176
|
-
}, method !== 'GET' ? {
|
|
177
|
-
body: JSON.stringify(data)
|
|
178
|
-
} : {}))
|
|
179
|
-
];
|
|
180
|
-
case 1:
|
|
181
|
-
result = _state.sent();
|
|
182
|
-
return [
|
|
183
|
-
2,
|
|
184
|
-
result
|
|
185
|
-
];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
})();
|
|
11
|
+
const baseUrl = 'https://api.mailjet.com/v3/REST';
|
|
12
|
+
export const callMailjet = async (path, data, method = 'POST') => {
|
|
13
|
+
const url = `${baseUrl}${path}`;
|
|
14
|
+
const result = await enhancedFetch(url, {
|
|
15
|
+
method,
|
|
16
|
+
headers: {
|
|
17
|
+
'Content-Type': 'application/json',
|
|
18
|
+
Authorization: getAuth(),
|
|
19
|
+
},
|
|
20
|
+
...(method !== 'GET' ? { body: JSON.stringify(data) } : {}),
|
|
21
|
+
});
|
|
22
|
+
return result;
|
|
189
23
|
};
|
|
24
|
+
//# sourceMappingURL=request-service.js.map
|