@fabriktor/fx 0.0.32 → 0.0.33
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/src/billable/billable.d.ts +12 -10
- package/dist/src/billable/billable.js +1 -2
- package/dist/src/calls/calls.d.ts +5 -5
- package/dist/src/chat/chat.d.ts +3 -2
- package/dist/src/core/pull.d.ts +39 -0
- package/dist/src/core/pull.js +101 -0
- package/dist/src/feed/feed.d.ts +167 -0
- package/dist/src/feed/feed.js +642 -0
- package/dist/src/fx.d.ts +42 -1
- package/dist/src/fx.js +94 -2
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.js +10 -0
- package/dist/src/jobs/jobs.d.ts +74 -0
- package/dist/src/jobs/jobs.js +375 -0
- package/dist/src/marketplace/marketplace.d.ts +35 -0
- package/dist/src/marketplace/marketplace.js +159 -0
- package/dist/src/notifications/notifications.d.ts +20 -0
- package/dist/src/notifications/notifications.js +45 -0
- package/dist/src/payments/payments.d.ts +59 -0
- package/dist/src/payments/payments.js +266 -0
- package/dist/src/payrolls/payrolls.d.ts +52 -0
- package/dist/src/payrolls/payrolls.js +54 -0
- package/dist/src/privacy/privacy.d.ts +21 -0
- package/dist/src/privacy/privacy.js +78 -0
- package/dist/src/routes/routes.d.ts +22 -0
- package/dist/src/routes/routes.js +134 -0
- package/dist/src/session/session.d.ts +17 -11
- package/dist/src/session/session.js +6 -12
- package/dist/src/storage/storage.d.ts +22 -13
- package/dist/src/storage/storage.js +56 -41
- package/dist/src/timesheets/timesheets.d.ts +91 -0
- package/dist/src/timesheets/timesheets.js +407 -0
- package/dist/src/users/users.d.ts +15 -11
- package/dist/src/users/users.js +2 -2
- package/package.json +3 -3
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
// Copyright (C) Fabriktor, Inc. 2025-present.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
4
|
+
// not use this file except in compliance with the License. You may obtain
|
|
5
|
+
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
import { PunchModeDefault, PunchModeDelete, PunchModeReplace, PunchModeWeekSheet, PunchStatusPending, PunchStatusWorking, PunchTypeIn, PunchTypeOut, PunchTypeRideIn, PunchTypeRideOut, ZeroID, } from "@fabriktor/schema";
|
|
7
|
+
import { errRequired, errValidation } from "../core/err.js";
|
|
8
|
+
const allWeekDays = [0, 1, 2, 3, 4, 5, 6];
|
|
9
|
+
const minuteStep = 15;
|
|
10
|
+
const msgPunchInProgress = "A punch action is already in progress.";
|
|
11
|
+
const msgTimezoneRequired = "Timezone is required.";
|
|
12
|
+
const msgLocationIDRequired = "Location ID is required.";
|
|
13
|
+
const msgEmployerIDRequired = "Employer ID is required.";
|
|
14
|
+
const msgWeekSheetIDRequired = "Week sheet ID is required.";
|
|
15
|
+
const msgWeekSheetsRequired = "At least one week sheet is required.";
|
|
16
|
+
const msgDestinationWeekSheetsRequired = "At least one destination week sheet is required.";
|
|
17
|
+
const msgDaysRequired = "At least one week day is required.";
|
|
18
|
+
const msgWeekDayInvalid = "Week day must be an integer between 0 and 6.";
|
|
19
|
+
const msgMinutesInvalid = "Pause and meal minutes must be non-negative 15-minute increments.";
|
|
20
|
+
const msgWeekSheetArchived = "Archived week sheets cannot be modified or approved.";
|
|
21
|
+
const msgWeekSheetEmployerMismatch = "Week sheet employer does not match the requested employer.";
|
|
22
|
+
const msgPunchNotPending = "All punches must be pending before the week sheet can be approved.";
|
|
23
|
+
const msgSyncEmployerMismatch = "Source and destination week sheets must belong to the same employer.";
|
|
24
|
+
export class TimesheetsFX {
|
|
25
|
+
timesheets;
|
|
26
|
+
punch_in_progress;
|
|
27
|
+
constructor(opts) {
|
|
28
|
+
this.timesheets = opts.timesheets;
|
|
29
|
+
this.punch_in_progress = false;
|
|
30
|
+
}
|
|
31
|
+
punchControls(opts) {
|
|
32
|
+
validateWeekDay(opts.week_day, "week_day");
|
|
33
|
+
if (opts.week_sheet?.is_archived) {
|
|
34
|
+
return disabledPunchControls();
|
|
35
|
+
}
|
|
36
|
+
const day = opts.week_sheet?.sheets.find((sheet) => sheet.week_day === opts.week_day);
|
|
37
|
+
const latest_punch = day?.punches.at(-1);
|
|
38
|
+
if (latest_punch === undefined) {
|
|
39
|
+
return readyToPunchInControls();
|
|
40
|
+
}
|
|
41
|
+
if (latest_punch.punch_status !== PunchStatusWorking) {
|
|
42
|
+
return readyToPunchInControls();
|
|
43
|
+
}
|
|
44
|
+
const latest_ride = latest_punch.rides.at(-1);
|
|
45
|
+
const ride_active = latest_ride?.is_active === true;
|
|
46
|
+
return {
|
|
47
|
+
can_punch_in: false,
|
|
48
|
+
can_punch_out: true,
|
|
49
|
+
can_ride_in: !ride_active,
|
|
50
|
+
can_ride_out: ride_active,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
async punchIn(opts) {
|
|
54
|
+
return await this.runPunch(async () => {
|
|
55
|
+
const input = buildPunch({
|
|
56
|
+
context: opts,
|
|
57
|
+
punch_type: PunchTypeIn,
|
|
58
|
+
punch_mode: PunchModeDefault,
|
|
59
|
+
punch_status: PunchStatusWorking,
|
|
60
|
+
total_pause_minutes: 0,
|
|
61
|
+
total_meal_minutes: 0,
|
|
62
|
+
explicit_date: opts.explicit_date,
|
|
63
|
+
});
|
|
64
|
+
return await this.timesheets.punch(input);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async punchOut(opts) {
|
|
68
|
+
validateMinutes(opts.total_pause_minutes, "total_pause_minutes");
|
|
69
|
+
validateMinutes(opts.total_meal_minutes, "total_meal_minutes");
|
|
70
|
+
return await this.runPunch(async () => {
|
|
71
|
+
const input = buildPunch({
|
|
72
|
+
context: opts,
|
|
73
|
+
punch_type: PunchTypeOut,
|
|
74
|
+
punch_mode: PunchModeDefault,
|
|
75
|
+
punch_status: PunchStatusPending,
|
|
76
|
+
total_pause_minutes: opts.total_pause_minutes,
|
|
77
|
+
total_meal_minutes: opts.total_meal_minutes,
|
|
78
|
+
explicit_date: opts.explicit_date,
|
|
79
|
+
});
|
|
80
|
+
return await this.timesheets.punch(input);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async rideIn(opts) {
|
|
84
|
+
return await this.runPunch(async () => {
|
|
85
|
+
const input = buildPunch({
|
|
86
|
+
context: opts,
|
|
87
|
+
punch_type: PunchTypeRideIn,
|
|
88
|
+
punch_mode: PunchModeDefault,
|
|
89
|
+
punch_status: PunchStatusWorking,
|
|
90
|
+
total_pause_minutes: 0,
|
|
91
|
+
total_meal_minutes: 0,
|
|
92
|
+
explicit_date: opts.explicit_date,
|
|
93
|
+
});
|
|
94
|
+
return await this.timesheets.punch(input);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async rideOut(opts) {
|
|
98
|
+
return await this.runPunch(async () => {
|
|
99
|
+
const input = buildPunch({
|
|
100
|
+
context: opts,
|
|
101
|
+
punch_type: PunchTypeRideOut,
|
|
102
|
+
punch_mode: PunchModeDefault,
|
|
103
|
+
punch_status: PunchStatusWorking,
|
|
104
|
+
total_pause_minutes: 0,
|
|
105
|
+
total_meal_minutes: 0,
|
|
106
|
+
explicit_date: opts.explicit_date,
|
|
107
|
+
});
|
|
108
|
+
return await this.timesheets.punch(input);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
async replaceDay(opts) {
|
|
112
|
+
validateMinutes(opts.total_pause_minutes, "total_pause_minutes");
|
|
113
|
+
validateMinutes(opts.total_meal_minutes, "total_meal_minutes");
|
|
114
|
+
return await this.runPunch(async () => {
|
|
115
|
+
const punch_in = await this.timesheets.punch(buildPunch({
|
|
116
|
+
context: opts,
|
|
117
|
+
punch_type: PunchTypeIn,
|
|
118
|
+
punch_mode: PunchModeReplace,
|
|
119
|
+
punch_status: PunchStatusWorking,
|
|
120
|
+
total_pause_minutes: 0,
|
|
121
|
+
total_meal_minutes: 0,
|
|
122
|
+
explicit_date: opts.punch_in_date,
|
|
123
|
+
}));
|
|
124
|
+
const punch_out = await this.timesheets.punch(buildPunch({
|
|
125
|
+
context: opts,
|
|
126
|
+
punch_type: PunchTypeOut,
|
|
127
|
+
punch_mode: PunchModeDefault,
|
|
128
|
+
punch_status: PunchStatusPending,
|
|
129
|
+
total_pause_minutes: opts.total_pause_minutes,
|
|
130
|
+
total_meal_minutes: opts.total_meal_minutes,
|
|
131
|
+
explicit_date: opts.punch_out_date,
|
|
132
|
+
}));
|
|
133
|
+
return {
|
|
134
|
+
punch_in,
|
|
135
|
+
punch_out,
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
async deleteDay(opts) {
|
|
140
|
+
return await this.runPunch(async () => {
|
|
141
|
+
const input = buildPunch({
|
|
142
|
+
context: opts,
|
|
143
|
+
punch_type: PunchTypeIn,
|
|
144
|
+
punch_mode: PunchModeDelete,
|
|
145
|
+
punch_status: PunchStatusWorking,
|
|
146
|
+
total_pause_minutes: 0,
|
|
147
|
+
total_meal_minutes: 0,
|
|
148
|
+
explicit_date: opts.explicit_date,
|
|
149
|
+
});
|
|
150
|
+
return await this.timesheets.punch(input);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
async createBlankWeekSheet(opts) {
|
|
154
|
+
return await this.runPunch(async () => {
|
|
155
|
+
const input = buildPunch({
|
|
156
|
+
context: opts,
|
|
157
|
+
punch_type: PunchTypeIn,
|
|
158
|
+
punch_mode: PunchModeWeekSheet,
|
|
159
|
+
punch_status: PunchStatusWorking,
|
|
160
|
+
total_pause_minutes: 0,
|
|
161
|
+
total_meal_minutes: 0,
|
|
162
|
+
explicit_date: opts.explicit_date,
|
|
163
|
+
});
|
|
164
|
+
return await this.timesheets.punch(input);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
async syncWeek(opts) {
|
|
168
|
+
await this.syncSheets({
|
|
169
|
+
from: opts.from,
|
|
170
|
+
to: opts.to,
|
|
171
|
+
days: [...allWeekDays],
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async syncDays(opts) {
|
|
175
|
+
const days = normalizeDays(opts.days);
|
|
176
|
+
if (days.length === 0) {
|
|
177
|
+
throw errRequired({
|
|
178
|
+
field: "days",
|
|
179
|
+
msg: msgDaysRequired,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
await this.syncSheets({
|
|
183
|
+
from: opts.from,
|
|
184
|
+
to: opts.to,
|
|
185
|
+
days,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
async approveWeekSheets(opts) {
|
|
189
|
+
const employer_id = requiredID(opts.employer_id, "employer_id", msgEmployerIDRequired);
|
|
190
|
+
if (opts.week_sheets.length === 0) {
|
|
191
|
+
throw errRequired({
|
|
192
|
+
field: "week_sheets",
|
|
193
|
+
msg: msgWeekSheetsRequired,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const ids = [];
|
|
197
|
+
for (const week_sheet of opts.week_sheets) {
|
|
198
|
+
const id = requiredID(week_sheet.id, "week_sheets", msgWeekSheetIDRequired);
|
|
199
|
+
if (week_sheet.employer_id !== employer_id) {
|
|
200
|
+
throw errValidation({
|
|
201
|
+
field: "week_sheets",
|
|
202
|
+
msg: msgWeekSheetEmployerMismatch,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
if (week_sheet.is_archived) {
|
|
206
|
+
throw errValidation({
|
|
207
|
+
field: "week_sheets",
|
|
208
|
+
msg: msgWeekSheetArchived,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
for (const sheet of week_sheet.sheets) {
|
|
212
|
+
for (const punch of sheet.punches) {
|
|
213
|
+
if (punch.punch_status !== PunchStatusPending) {
|
|
214
|
+
throw errValidation({
|
|
215
|
+
field: "week_sheets",
|
|
216
|
+
msg: msgPunchNotPending,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
ids.push(id);
|
|
222
|
+
}
|
|
223
|
+
const input = {
|
|
224
|
+
ids: normalizeIDs(ids),
|
|
225
|
+
employer_id,
|
|
226
|
+
};
|
|
227
|
+
await this.timesheets.approve(input);
|
|
228
|
+
}
|
|
229
|
+
async syncSheets(opts) {
|
|
230
|
+
const from_id = requiredID(opts.from.id, "from", msgWeekSheetIDRequired);
|
|
231
|
+
if (opts.to.length === 0) {
|
|
232
|
+
throw errRequired({
|
|
233
|
+
field: "to",
|
|
234
|
+
msg: msgDestinationWeekSheetsRequired,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
const to_ids = [];
|
|
238
|
+
for (const week_sheet of opts.to) {
|
|
239
|
+
const id = requiredID(week_sheet.id, "to", msgWeekSheetIDRequired);
|
|
240
|
+
if (week_sheet.is_archived) {
|
|
241
|
+
throw errValidation({
|
|
242
|
+
field: "to",
|
|
243
|
+
msg: msgWeekSheetArchived,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
if (week_sheet.employer_id !== opts.from.employer_id) {
|
|
247
|
+
throw errValidation({
|
|
248
|
+
field: "to",
|
|
249
|
+
msg: msgSyncEmployerMismatch,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
to_ids.push(id);
|
|
253
|
+
}
|
|
254
|
+
const input = {
|
|
255
|
+
from_id,
|
|
256
|
+
to_ids: normalizeIDs(to_ids),
|
|
257
|
+
days: normalizeDays(opts.days),
|
|
258
|
+
};
|
|
259
|
+
await this.timesheets.sync(input);
|
|
260
|
+
}
|
|
261
|
+
async runPunch(fn) {
|
|
262
|
+
if (this.punch_in_progress) {
|
|
263
|
+
throw errValidation({
|
|
264
|
+
field: "punch_in_progress",
|
|
265
|
+
msg: msgPunchInProgress,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
this.punch_in_progress = true;
|
|
269
|
+
try {
|
|
270
|
+
return await fn();
|
|
271
|
+
}
|
|
272
|
+
finally {
|
|
273
|
+
this.punch_in_progress = false;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
export function newTimesheetsFX(opts) {
|
|
278
|
+
return new TimesheetsFX(opts);
|
|
279
|
+
}
|
|
280
|
+
function buildPunch(opts) {
|
|
281
|
+
const context = normalizePunchContext(opts.context);
|
|
282
|
+
return {
|
|
283
|
+
punch_in_time: zeroDate(),
|
|
284
|
+
punch_out_time: zeroDate(),
|
|
285
|
+
rides: [],
|
|
286
|
+
punch_status: opts.punch_status,
|
|
287
|
+
work_hours: 0,
|
|
288
|
+
ride_hours: 0,
|
|
289
|
+
owner_id: ZeroID,
|
|
290
|
+
timezone: context.timezone,
|
|
291
|
+
punch_type: opts.punch_type,
|
|
292
|
+
punch_mode: opts.punch_mode,
|
|
293
|
+
location_id: context.location_id,
|
|
294
|
+
employer_id: context.employer_id,
|
|
295
|
+
total_pause_minutes: opts.total_pause_minutes,
|
|
296
|
+
total_meal_minutes: opts.total_meal_minutes,
|
|
297
|
+
is_explicit: opts.explicit_date !== undefined,
|
|
298
|
+
explicit_date: opts.explicit_date === undefined
|
|
299
|
+
? zeroDate()
|
|
300
|
+
: cloneDate(opts.explicit_date),
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function normalizePunchContext(opts) {
|
|
304
|
+
return {
|
|
305
|
+
timezone: requiredText(opts.timezone, "timezone", msgTimezoneRequired),
|
|
306
|
+
location_id: requiredID(opts.location_id, "location_id", msgLocationIDRequired),
|
|
307
|
+
employer_id: requiredID(opts.employer_id, "employer_id", msgEmployerIDRequired),
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function disabledPunchControls() {
|
|
311
|
+
return {
|
|
312
|
+
can_punch_in: false,
|
|
313
|
+
can_punch_out: false,
|
|
314
|
+
can_ride_in: false,
|
|
315
|
+
can_ride_out: false,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function readyToPunchInControls() {
|
|
319
|
+
return {
|
|
320
|
+
can_punch_in: true,
|
|
321
|
+
can_punch_out: false,
|
|
322
|
+
can_ride_in: false,
|
|
323
|
+
can_ride_out: false,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
function zeroDate() {
|
|
327
|
+
return {
|
|
328
|
+
utc: "",
|
|
329
|
+
y: 0,
|
|
330
|
+
m: 0,
|
|
331
|
+
d: 0,
|
|
332
|
+
h: 0,
|
|
333
|
+
min: 0,
|
|
334
|
+
tz: "",
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function cloneDate(v) {
|
|
338
|
+
return {
|
|
339
|
+
utc: v.utc,
|
|
340
|
+
y: v.y,
|
|
341
|
+
m: v.m,
|
|
342
|
+
d: v.d,
|
|
343
|
+
h: v.h,
|
|
344
|
+
min: v.min,
|
|
345
|
+
tz: v.tz,
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function validateMinutes(v, field) {
|
|
349
|
+
if (!Number.isFinite(v) ||
|
|
350
|
+
v < 0 ||
|
|
351
|
+
!Number.isInteger(v) ||
|
|
352
|
+
v % minuteStep !== 0) {
|
|
353
|
+
throw errValidation({
|
|
354
|
+
field,
|
|
355
|
+
msg: msgMinutesInvalid,
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
function validateWeekDay(v, field) {
|
|
360
|
+
if (!Number.isInteger(v) || v < 0 || v > 6) {
|
|
361
|
+
throw errValidation({
|
|
362
|
+
field,
|
|
363
|
+
msg: msgWeekDayInvalid,
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function normalizeDays(days) {
|
|
368
|
+
const out = new Set();
|
|
369
|
+
for (const day of days) {
|
|
370
|
+
validateWeekDay(day, "days");
|
|
371
|
+
out.add(day);
|
|
372
|
+
}
|
|
373
|
+
return [...out].sort((a, b) => a - b);
|
|
374
|
+
}
|
|
375
|
+
function requiredID(v, field, msg) {
|
|
376
|
+
const out = v?.trim();
|
|
377
|
+
if (out === undefined || out === "" || out === ZeroID) {
|
|
378
|
+
throw errRequired({
|
|
379
|
+
field,
|
|
380
|
+
msg,
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
return out;
|
|
384
|
+
}
|
|
385
|
+
function requiredText(v, field, msg) {
|
|
386
|
+
const out = v?.trim();
|
|
387
|
+
if (out === undefined || out === "") {
|
|
388
|
+
throw errRequired({
|
|
389
|
+
field,
|
|
390
|
+
msg,
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
return out;
|
|
394
|
+
}
|
|
395
|
+
function normalizeIDs(ids) {
|
|
396
|
+
const seen = new Set();
|
|
397
|
+
const out = [];
|
|
398
|
+
for (const raw of ids) {
|
|
399
|
+
const id = raw.trim();
|
|
400
|
+
if (id === "" || id === ZeroID || seen.has(id)) {
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
seen.add(id);
|
|
404
|
+
out.push(id);
|
|
405
|
+
}
|
|
406
|
+
return out;
|
|
407
|
+
}
|
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import type { PLUsersResolveUsername, PLUsersSendCode, PLUsersUsername, PLUsersVerifyCode } from "@fabriktor/schema";
|
|
2
1
|
import type { OperationResultOf, TmpPhonesOperator, TmpUsernamesOperator, UsernameVerification, UsersOperator } from "@fabriktor/client";
|
|
2
|
+
export type ResolveUsernameOptions = Parameters<UsersOperator["resolveUsername"]>[0];
|
|
3
|
+
export type VerifyUsernameOptions = Parameters<TmpUsernamesOperator["verify"]>[0];
|
|
4
|
+
export type GenerateUsernamesOptions = VerifyUsernameOptions;
|
|
5
|
+
export type SendPhoneCodeOptions = Parameters<TmpPhonesOperator["send"]>[0];
|
|
6
|
+
export type VerifyPhoneCodeOptions = Parameters<TmpPhonesOperator["verify"]>[0];
|
|
3
7
|
export type UsersFXOptions = {
|
|
4
8
|
users: UsersOperator;
|
|
5
9
|
tmp_usernames: TmpUsernamesOperator;
|
|
6
10
|
tmp_phones: TmpPhonesOperator;
|
|
7
11
|
};
|
|
8
12
|
export interface UsersFXOperator {
|
|
9
|
-
resolveUsername(opts:
|
|
10
|
-
verifyUsername(opts:
|
|
11
|
-
generateUsernames(opts:
|
|
12
|
-
sendPhoneCode(opts:
|
|
13
|
-
verifyPhoneCode(opts:
|
|
13
|
+
resolveUsername(opts: ResolveUsernameOptions): Promise<string>;
|
|
14
|
+
verifyUsername(opts: VerifyUsernameOptions): Promise<OperationResultOf<UsernameVerification>>;
|
|
15
|
+
generateUsernames(opts: GenerateUsernamesOptions): Promise<OperationResultOf<UsernameVerification>>;
|
|
16
|
+
sendPhoneCode(opts: SendPhoneCodeOptions): Promise<void>;
|
|
17
|
+
verifyPhoneCode(opts: VerifyPhoneCodeOptions): Promise<void>;
|
|
14
18
|
}
|
|
15
19
|
export declare class UsersFX implements UsersFXOperator {
|
|
16
20
|
private users;
|
|
17
21
|
private tmp_usernames;
|
|
18
22
|
private tmp_phones;
|
|
19
23
|
constructor(opts: UsersFXOptions);
|
|
20
|
-
resolveUsername(opts:
|
|
21
|
-
verifyUsername(opts:
|
|
22
|
-
generateUsernames(opts:
|
|
23
|
-
sendPhoneCode(opts:
|
|
24
|
-
verifyPhoneCode(opts:
|
|
24
|
+
resolveUsername(opts: ResolveUsernameOptions): Promise<string>;
|
|
25
|
+
verifyUsername(opts: VerifyUsernameOptions): Promise<OperationResultOf<UsernameVerification>>;
|
|
26
|
+
generateUsernames(opts: GenerateUsernamesOptions): Promise<OperationResultOf<UsernameVerification>>;
|
|
27
|
+
sendPhoneCode(opts: SendPhoneCodeOptions): Promise<void>;
|
|
28
|
+
verifyPhoneCode(opts: VerifyPhoneCodeOptions): Promise<void>;
|
|
25
29
|
}
|
|
26
30
|
export declare function newUsersFX(opts: UsersFXOptions): UsersFX;
|
package/dist/src/users/users.js
CHANGED
|
@@ -52,7 +52,7 @@ export class UsersFX {
|
|
|
52
52
|
if (!validatePhone(phone)) {
|
|
53
53
|
throw errPhoneRequired("phone");
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
await this.tmp_phones.send({
|
|
56
56
|
phone,
|
|
57
57
|
});
|
|
58
58
|
}
|
|
@@ -65,7 +65,7 @@ export class UsersFX {
|
|
|
65
65
|
if (!validatePhoneCode(code)) {
|
|
66
66
|
throw errPhoneCodeRequired("code");
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
await this.tmp_phones.verify({
|
|
69
69
|
phone,
|
|
70
70
|
code,
|
|
71
71
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabriktor/fx",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.33",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"typescript": "^6.0.3"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@fabriktor/client": "0.0.
|
|
21
|
-
"@fabriktor/schema": "0.0.
|
|
20
|
+
"@fabriktor/client": "0.0.42",
|
|
21
|
+
"@fabriktor/schema": "0.0.31"
|
|
22
22
|
}
|
|
23
23
|
}
|