@driveflux/api-functions 0.0.3 → 0.0.4
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 +100 -396
- package/dist/auth/tokens.js +115 -430
- package/dist/auth/verifications.js +154 -512
- package/dist/constants.js +5 -4
- package/dist/mailjet/calls/manage-contacts-in-list.js +22 -166
- package/dist/mailjet/calls/manage-subscription-status.js +13 -153
- package/dist/mailjet/calls/request-service.js +18 -183
- package/dist/mailjet/refresh-email-preferences.js +26 -225
- package/dist/mailjet/set-contact.js +23 -214
- package/dist/mailjet/types.js +2 -1
- package/dist/mailjet/utils/convert-to-array.js +9 -58
- 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.js +27 -208
- 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.js +19 -158
- package/dist/reservation/checks.js +23 -178
- package/dist/reservation/display-vehicle.js +142 -514
- package/dist/reservation/fetch-or-create.js +197 -482
- package/dist/reservation/invoice.d.ts.map +1 -1
- package/dist/reservation/invoice.js +199 -501
- package/dist/reservation/invoice.js.map +1 -1
- package/dist/reservation/payer.js +28 -177
- package/dist/reservation/reserve.js +31 -191
- package/dist/reservation/types.js +2 -1
- package/dist/reservation/vehicle.js +24 -186
- package/dist/slack.js +67 -273
- package/dist/validation.d.ts +11 -11
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +63 -96
- package/dist/validation.js.map +1 -1
- package/dist/vehicle/vehicle-pricing/constants.js +33 -36
- package/dist/vehicle/vehicle-pricing/index.js +99 -257
- package/dist/vehicle/vehicle-pricing/types.js +2 -1
- package/package.json +10 -10
|
@@ -1,194 +1,32 @@
|
|
|
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 { subject } from '@casl/ability';
|
|
122
2
|
import { prisma } from '@driveflux/db';
|
|
123
3
|
import { makeProblem, PROBLEM_NOT_FOUND } from '@driveflux/problem';
|
|
124
4
|
import { Err, Ok } from '@driveflux/result';
|
|
125
5
|
import { checkIfVehicleIsAvailableForReservation } from './checks';
|
|
126
6
|
import { createVehicleFromDisplayVehicle } from './display-vehicle';
|
|
127
|
-
export
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
];
|
|
142
|
-
case 1:
|
|
143
|
-
_tmp = _state.sent();
|
|
144
|
-
return [
|
|
145
|
-
3,
|
|
146
|
-
4
|
|
147
|
-
];
|
|
148
|
-
case 2:
|
|
149
|
-
return [
|
|
150
|
-
4,
|
|
151
|
-
prisma.vehicle.findUnique({
|
|
152
|
-
where: {
|
|
153
|
-
id: id
|
|
154
|
-
},
|
|
155
|
-
include: {
|
|
156
|
-
host: {
|
|
157
|
-
select: {
|
|
158
|
-
id: true
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
})
|
|
163
|
-
];
|
|
164
|
-
case 3:
|
|
165
|
-
_tmp = _state.sent();
|
|
166
|
-
_state.label = 4;
|
|
167
|
-
case 4:
|
|
168
|
-
vehicle = _tmp;
|
|
169
|
-
if (!vehicle) {
|
|
170
|
-
return [
|
|
171
|
-
2,
|
|
172
|
-
new Err(makeProblem(PROBLEM_NOT_FOUND, 'Vehicle not found'))
|
|
173
|
-
];
|
|
174
|
-
}
|
|
175
|
-
return [
|
|
176
|
-
4,
|
|
177
|
-
checkIfVehicleIsAvailableForReservation(vehicle, plan, requesterAbility.can('reserveDelistedVehicle', subject('User', requestUser)))
|
|
178
|
-
];
|
|
179
|
-
case 5:
|
|
180
|
-
vehicleResult = _state.sent();
|
|
181
|
-
if (vehicleResult.err) {
|
|
182
|
-
return [
|
|
183
|
-
2,
|
|
184
|
-
vehicleResult
|
|
185
|
-
];
|
|
186
|
-
}
|
|
187
|
-
return [
|
|
188
|
-
2,
|
|
189
|
-
new Ok(vehicle)
|
|
190
|
-
];
|
|
191
|
-
}
|
|
7
|
+
export const getVehicle = async (id, { selectedColor, plan, requestUser, }, requesterAbility) => {
|
|
8
|
+
const vehicle = id.startsWith('DV_')
|
|
9
|
+
? await createVehicleFromDisplayVehicle(id, selectedColor || undefined)
|
|
10
|
+
: await prisma.vehicle.findUnique({
|
|
11
|
+
where: {
|
|
12
|
+
id,
|
|
13
|
+
},
|
|
14
|
+
include: {
|
|
15
|
+
host: {
|
|
16
|
+
select: {
|
|
17
|
+
id: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
192
21
|
});
|
|
193
|
-
|
|
22
|
+
if (!vehicle) {
|
|
23
|
+
return new Err(makeProblem(PROBLEM_NOT_FOUND, 'Vehicle not found'));
|
|
24
|
+
}
|
|
25
|
+
// Check if the vehicle can be reserved
|
|
26
|
+
const vehicleResult = await checkIfVehicleIsAvailableForReservation(vehicle, plan, requesterAbility.can('reserveDelistedVehicle', subject('User', requestUser)));
|
|
27
|
+
if (vehicleResult.err) {
|
|
28
|
+
return vehicleResult;
|
|
29
|
+
}
|
|
30
|
+
return new Ok(vehicle);
|
|
194
31
|
};
|
|
32
|
+
//# sourceMappingURL=vehicle.js.map
|
package/dist/slack.js
CHANGED
|
@@ -1,148 +1,3 @@
|
|
|
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_without_holes(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
8
|
-
}
|
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
|
-
try {
|
|
11
|
-
var info = gen[key](arg);
|
|
12
|
-
var value = info.value;
|
|
13
|
-
} catch (error) {
|
|
14
|
-
reject(error);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (info.done) {
|
|
18
|
-
resolve(value);
|
|
19
|
-
} else {
|
|
20
|
-
Promise.resolve(value).then(_next, _throw);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function _async_to_generator(fn) {
|
|
24
|
-
return function() {
|
|
25
|
-
var self = this, args = arguments;
|
|
26
|
-
return new Promise(function(resolve, reject) {
|
|
27
|
-
var gen = fn.apply(self, args);
|
|
28
|
-
function _next(value) {
|
|
29
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
30
|
-
}
|
|
31
|
-
function _throw(err) {
|
|
32
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
33
|
-
}
|
|
34
|
-
_next(undefined);
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function _iterable_to_array(iter) {
|
|
39
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
40
|
-
}
|
|
41
|
-
function _non_iterable_spread() {
|
|
42
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
43
|
-
}
|
|
44
|
-
function _to_consumable_array(arr) {
|
|
45
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
46
|
-
}
|
|
47
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
48
|
-
if (!o) return;
|
|
49
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
50
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
51
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
52
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
53
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
54
|
-
}
|
|
55
|
-
function _ts_generator(thisArg, body) {
|
|
56
|
-
var f, y, t, _ = {
|
|
57
|
-
label: 0,
|
|
58
|
-
sent: function() {
|
|
59
|
-
if (t[0] & 1) throw t[1];
|
|
60
|
-
return t[1];
|
|
61
|
-
},
|
|
62
|
-
trys: [],
|
|
63
|
-
ops: []
|
|
64
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
65
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
66
|
-
return this;
|
|
67
|
-
}), g;
|
|
68
|
-
function verb(n) {
|
|
69
|
-
return function(v) {
|
|
70
|
-
return step([
|
|
71
|
-
n,
|
|
72
|
-
v
|
|
73
|
-
]);
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
function step(op) {
|
|
77
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
78
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
79
|
-
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;
|
|
80
|
-
if (y = 0, t) op = [
|
|
81
|
-
op[0] & 2,
|
|
82
|
-
t.value
|
|
83
|
-
];
|
|
84
|
-
switch(op[0]){
|
|
85
|
-
case 0:
|
|
86
|
-
case 1:
|
|
87
|
-
t = op;
|
|
88
|
-
break;
|
|
89
|
-
case 4:
|
|
90
|
-
_.label++;
|
|
91
|
-
return {
|
|
92
|
-
value: op[1],
|
|
93
|
-
done: false
|
|
94
|
-
};
|
|
95
|
-
case 5:
|
|
96
|
-
_.label++;
|
|
97
|
-
y = op[1];
|
|
98
|
-
op = [
|
|
99
|
-
0
|
|
100
|
-
];
|
|
101
|
-
continue;
|
|
102
|
-
case 7:
|
|
103
|
-
op = _.ops.pop();
|
|
104
|
-
_.trys.pop();
|
|
105
|
-
continue;
|
|
106
|
-
default:
|
|
107
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
108
|
-
_ = 0;
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
112
|
-
_.label = op[1];
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
116
|
-
_.label = t[1];
|
|
117
|
-
t = op;
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
if (t && _.label < t[2]) {
|
|
121
|
-
_.label = t[2];
|
|
122
|
-
_.ops.push(op);
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
if (t[2]) _.ops.pop();
|
|
126
|
-
_.trys.pop();
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
op = body.call(thisArg, _);
|
|
130
|
-
} catch (e) {
|
|
131
|
-
op = [
|
|
132
|
-
6,
|
|
133
|
-
e
|
|
134
|
-
];
|
|
135
|
-
y = 0;
|
|
136
|
-
} finally{
|
|
137
|
-
f = t = 0;
|
|
138
|
-
}
|
|
139
|
-
if (op[0] & 5) throw op[1];
|
|
140
|
-
return {
|
|
141
|
-
value: op[0] ? op[1] : void 0,
|
|
142
|
-
done: true
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
1
|
import { config } from '@driveflux/config/backend';
|
|
147
2
|
import { enhancedFetch } from '@driveflux/fetch';
|
|
148
3
|
import { createTaskLater } from '@driveflux/scheduler';
|
|
@@ -151,161 +6,100 @@ import { TASK_COMMIT_SLACK_CHANNEL, TASK_PIPELINE_SLACK } from './constants.js';
|
|
|
151
6
|
if (!global.__slackBlocks) {
|
|
152
7
|
global.__slackBlocks = new Map();
|
|
153
8
|
}
|
|
154
|
-
|
|
9
|
+
const slackBlocks = global.__slackBlocks;
|
|
155
10
|
/**
|
|
156
11
|
*
|
|
157
12
|
* @deprecated Use slackLater instead and commitSlack to commit
|
|
158
|
-
*/
|
|
159
|
-
|
|
160
|
-
return
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
text: message
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
]
|
|
182
|
-
})
|
|
183
|
-
})
|
|
184
|
-
];
|
|
185
|
-
case 1:
|
|
186
|
-
return [
|
|
187
|
-
2,
|
|
188
|
-
_state.sent()
|
|
189
|
-
];
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
})();
|
|
193
|
-
};
|
|
194
|
-
export var getSlackBlocks = function(channel) {
|
|
195
|
-
return channel ? slackBlocks.get(channel) : slackBlocks;
|
|
13
|
+
*/
|
|
14
|
+
export const slack = async (message, channel = config.slack.defaultChannelId) => {
|
|
15
|
+
return await enhancedFetch('https://slack.com/api/chat.postMessage', {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: `Bearer ${config.slack.token}`,
|
|
19
|
+
},
|
|
20
|
+
body: JSON.stringify({
|
|
21
|
+
channel,
|
|
22
|
+
blocks: [
|
|
23
|
+
{
|
|
24
|
+
type: 'section',
|
|
25
|
+
text: {
|
|
26
|
+
type: 'mrkdwn',
|
|
27
|
+
text: message,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
196
33
|
};
|
|
34
|
+
export const getSlackBlocks = (channel) => channel ? slackBlocks.get(channel) : slackBlocks;
|
|
197
35
|
/**
|
|
198
36
|
* Naive implementation, however, for now (uncrowded serverless env), this works
|
|
199
37
|
* @param blocks
|
|
200
38
|
* @param channel
|
|
201
|
-
*/
|
|
202
|
-
|
|
39
|
+
*/
|
|
40
|
+
export function slackLater(blocks, channel) {
|
|
41
|
+
const targetChannel = (config.appEnv === 'production'
|
|
42
|
+
? channel
|
|
43
|
+
: config.slack.defaultChannelId) || config.slack.defaultChannelId;
|
|
203
44
|
if (!targetChannel || !blocks) {
|
|
204
45
|
return;
|
|
205
46
|
}
|
|
206
|
-
|
|
47
|
+
const messages = slackBlocks.get(targetChannel) || new Set();
|
|
207
48
|
if (typeof blocks === 'string') {
|
|
208
49
|
messages.add({
|
|
209
50
|
type: 'section',
|
|
210
51
|
text: {
|
|
211
52
|
type: 'mrkdwn',
|
|
212
|
-
text: blocks
|
|
213
|
-
}
|
|
53
|
+
text: blocks,
|
|
54
|
+
},
|
|
214
55
|
});
|
|
215
|
-
}
|
|
56
|
+
}
|
|
57
|
+
else if (!Array.isArray(blocks)) {
|
|
216
58
|
messages.add(blocks);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
var b = _step.value;
|
|
222
|
-
messages.add(b);
|
|
223
|
-
}
|
|
224
|
-
} catch (err) {
|
|
225
|
-
_didIteratorError = true;
|
|
226
|
-
_iteratorError = err;
|
|
227
|
-
} finally{
|
|
228
|
-
try {
|
|
229
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
230
|
-
_iterator.return();
|
|
231
|
-
}
|
|
232
|
-
} finally{
|
|
233
|
-
if (_didIteratorError) {
|
|
234
|
-
throw _iteratorError;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
for (const b of blocks) {
|
|
62
|
+
messages.add(b);
|
|
237
63
|
}
|
|
238
64
|
}
|
|
239
65
|
slackBlocks.set(targetChannel, messages);
|
|
240
66
|
}
|
|
241
|
-
export function sendSlackMessages(channel, blocks) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
Authorization: "Bearer ".concat(config.slack.token)
|
|
254
|
-
},
|
|
255
|
-
body: JSON.stringify({
|
|
256
|
-
channel: targetChannel,
|
|
257
|
-
blocks: Array.from(blocks)
|
|
258
|
-
})
|
|
259
|
-
})
|
|
260
|
-
];
|
|
261
|
-
case 1:
|
|
262
|
-
return [
|
|
263
|
-
2,
|
|
264
|
-
_state.sent()
|
|
265
|
-
];
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
})();
|
|
67
|
+
export async function sendSlackMessages(channel, blocks) {
|
|
68
|
+
const targetChannel = config.appEnv === 'production' ? channel : config.slack.defaultChannelId;
|
|
69
|
+
return await enhancedFetch('https://slack.com/api/chat.postMessage', {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers: {
|
|
72
|
+
Authorization: `Bearer ${config.slack.token}`,
|
|
73
|
+
},
|
|
74
|
+
body: JSON.stringify({
|
|
75
|
+
channel: targetChannel,
|
|
76
|
+
blocks: Array.from(blocks),
|
|
77
|
+
}),
|
|
78
|
+
});
|
|
269
79
|
}
|
|
270
|
-
export
|
|
80
|
+
export const commitSlack = () => {
|
|
271
81
|
if (!slackBlocks.size) {
|
|
272
82
|
return;
|
|
273
83
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
var blocks = slackBlocks.get(channel);
|
|
282
|
-
if (!(blocks === null || blocks === void 0 ? void 0 : blocks.size)) {
|
|
283
|
-
continue;
|
|
284
|
-
}
|
|
285
|
-
createTaskLater({
|
|
286
|
-
pipeline: TASK_PIPELINE_SLACK,
|
|
287
|
-
name: TASK_COMMIT_SLACK_CHANNEL,
|
|
288
|
-
metadata: {
|
|
289
|
-
channel: channel,
|
|
290
|
-
blocks: _to_consumable_array(blocks)
|
|
291
|
-
},
|
|
292
|
-
taskHandlerUrl: "".concat(baseUrl || config.appUrl, "/api/hooks/slack-pipeline"),
|
|
293
|
-
scheduledAt: addSeconds(new Date(), i++)
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
} catch (err) {
|
|
297
|
-
_didIteratorError = true;
|
|
298
|
-
_iteratorError = err;
|
|
299
|
-
} finally{
|
|
300
|
-
try {
|
|
301
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
302
|
-
_iterator.return();
|
|
303
|
-
}
|
|
304
|
-
} finally{
|
|
305
|
-
if (_didIteratorError) {
|
|
306
|
-
throw _iteratorError;
|
|
307
|
-
}
|
|
84
|
+
const channels = slackBlocks.keys();
|
|
85
|
+
let i = 1;
|
|
86
|
+
const baseUrl = config.appEnv === 'development' ? config.tunnelUrl : config.appUrl;
|
|
87
|
+
for (const channel of channels) {
|
|
88
|
+
const blocks = slackBlocks.get(channel);
|
|
89
|
+
if (!blocks?.size) {
|
|
90
|
+
continue;
|
|
308
91
|
}
|
|
92
|
+
createTaskLater({
|
|
93
|
+
pipeline: TASK_PIPELINE_SLACK,
|
|
94
|
+
name: TASK_COMMIT_SLACK_CHANNEL,
|
|
95
|
+
metadata: {
|
|
96
|
+
channel,
|
|
97
|
+
blocks: [...blocks],
|
|
98
|
+
},
|
|
99
|
+
taskHandlerUrl: `${baseUrl || config.appUrl}/api/hooks/slack-pipeline`,
|
|
100
|
+
scheduledAt: addSeconds(new Date(), i++),
|
|
101
|
+
});
|
|
309
102
|
}
|
|
310
103
|
slackBlocks.clear();
|
|
311
104
|
};
|
|
105
|
+
//# sourceMappingURL=slack.js.map
|
package/dist/validation.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { type StandardResult } from '@driveflux/result';
|
|
2
|
-
import { type ZodError, z } from 'zod';
|
|
2
|
+
import { type ZodDate, type ZodError, type ZodNumber, z } from 'zod';
|
|
3
3
|
export declare const makeValidationErrorResult: (zodError: ZodError<any>) => StandardResult<never>;
|
|
4
4
|
export declare const getIdOrObjectValidation: <ObjectName extends string, ExtendObjectValidation extends z.ZodRawShape>(object: ObjectName, extendObjectValidation?: ExtendObjectValidation) => z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
5
5
|
object: z.ZodLiteral<ObjectName>;
|
|
6
6
|
}, z.core.$catchall<z.ZodAny>>]>;
|
|
7
7
|
export declare const nonEmptyStringValidator: z.ZodString;
|
|
8
|
-
export declare const metadataValidation: z.ZodObject<{}, z.core.$catchall<z.ZodUnion<readonly [z.ZodString,
|
|
8
|
+
export declare const metadataValidation: z.ZodObject<{}, z.core.$catchall<z.ZodUnion<readonly [z.ZodString, ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<ZodNumber>, z.ZodArray<z.ZodBoolean>, z.ZodNull, z.ZodUndefined]>>>;
|
|
9
9
|
export declare const addressValidation: z.ZodObject<{
|
|
10
10
|
name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
11
11
|
coordinates: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
12
|
-
lat:
|
|
13
|
-
lng:
|
|
12
|
+
lat: ZodNumber;
|
|
13
|
+
lng: ZodNumber;
|
|
14
14
|
}, z.core.$strip>>>;
|
|
15
15
|
street1: z.ZodString;
|
|
16
16
|
street2: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -18,9 +18,9 @@ export declare const addressValidation: z.ZodObject<{
|
|
|
18
18
|
state: z.ZodString;
|
|
19
19
|
postalCode: z.ZodString;
|
|
20
20
|
country: z.ZodString;
|
|
21
|
-
metadata: z.ZodNullable<z.ZodOptional<z.ZodObject<{}, z.core.$catchall<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodNumber>, z.ZodArray<z.ZodBoolean>, z.ZodNull, z.ZodUndefined]>>>>>;
|
|
22
21
|
}, z.core.$strip>;
|
|
23
|
-
export declare const
|
|
22
|
+
export declare const getIsoDatetimeToDate: (dateValidation?: ZodDate) => z.ZodCodec<z.ZodISODateTime, ZodDate>;
|
|
23
|
+
export declare const dateValidation: z.ZodCodec<z.ZodISODateTime, ZodDate>;
|
|
24
24
|
export declare const enhancedImageValidation: z.ZodObject<{
|
|
25
25
|
default: z.ZodString;
|
|
26
26
|
blurBase64: z.ZodOptional<z.ZodString>;
|
|
@@ -54,10 +54,10 @@ export declare const documentFileValidation: z.ZodObject<{
|
|
|
54
54
|
}>>>;
|
|
55
55
|
mimeType: z.ZodOptional<z.ZodString>;
|
|
56
56
|
uploaded: z.ZodDefault<z.ZodBoolean>;
|
|
57
|
-
createdAt: z.ZodOptional<z.ZodNullable<z.ZodDate
|
|
58
|
-
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodDate
|
|
59
|
-
metadata: z.ZodOptional<z.ZodNullable<z.ZodObject<{}, z.core.$catchall<z.ZodUnion<readonly [z.ZodString,
|
|
57
|
+
createdAt: z.ZodOptional<z.ZodNullable<z.ZodCodec<z.ZodISODateTime, ZodDate>>>;
|
|
58
|
+
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodCodec<z.ZodISODateTime, ZodDate>>>;
|
|
59
|
+
metadata: z.ZodOptional<z.ZodNullable<z.ZodObject<{}, z.core.$catchall<z.ZodUnion<readonly [z.ZodString, ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodArray<ZodNumber>, z.ZodArray<z.ZodBoolean>, z.ZodNull, z.ZodUndefined]>>>>>;
|
|
60
60
|
}, z.core.$strip>;
|
|
61
|
-
export declare const queryBooleanValidator: z.
|
|
62
|
-
export declare const queryNumberValidator: z.
|
|
61
|
+
export declare const queryBooleanValidator: z.ZodCodec<z.ZodString, z.ZodBoolean>;
|
|
62
|
+
export declare const queryNumberValidator: z.ZodCodec<z.ZodString, ZodNumber>;
|
|
63
63
|
//# sourceMappingURL=validation.d.ts.map
|
package/dist/validation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,QAAQ,EAEb,KAAK,SAAS,EACd,CAAC,EACD,MAAM,KAAK,CAAA;AAEZ,eAAO,MAAM,yBAAyB,GACrC,UAAU,QAAQ,CAAC,GAAG,CAAC,KACrB,cAAc,CAAC,KAAK,CAatB,CAAA;AAED,eAAO,MAAM,uBAAuB,GACnC,UAAU,SAAS,MAAM,EACzB,sBAAsB,SAAS,CAAC,CAAC,WAAW,EAE5C,QAAQ,UAAU,EAClB,yBAAyB,sBAAsB;;gCAiB9C,CAAA;AAEF,eAAO,MAAM,uBAAuB,aAAoB,CAAA;AAExD,eAAO,MAAM,kBAAkB,qMAa7B,CAAA;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;iBAe5B,CAAA;AAEF,eAAO,MAAM,oBAAoB,GAAI,iBAAiB,OAAO,0CAI1D,CAAA;AAEH,eAAO,MAAM,cAAc,uCAAyB,CAAA;AAEpD,eAAO,MAAM,uBAAuB;;;;;;;;iBAQlC,CAAA;AAEF,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,MAAM,EAAE,GAAG,CAAC,6GACnC,CAAA;AAEvB,eAAO,MAAM,iBAAiB;QACW,CAAC,CAAC,SAAS;;;;;;;iBAWlD,CAAA;AAEF,eAAO,MAAM,sBAAsB;QACM,CAAC,CAAC,SAAS;;;;;;;;;;;;;;;;iBAalD,CAAA;AAEF,eAAO,MAAM,qBAAqB,uCAGhC,CAAA;AAOF,eAAO,MAAM,oBAAoB,oCAAsB,CAAA"}
|