@fabriktor/fx 0.0.31 → 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.
Files changed (41) hide show
  1. package/dist/src/billable/billable.d.ts +12 -10
  2. package/dist/src/billable/billable.js +1 -2
  3. package/dist/src/calls/calls.d.ts +5 -5
  4. package/dist/src/calls/calls.js +10 -4
  5. package/dist/src/chat/chat.d.ts +90 -0
  6. package/dist/src/chat/chat.js +194 -0
  7. package/dist/src/contacts/contacts.d.ts +67 -0
  8. package/dist/src/contacts/contacts.js +179 -0
  9. package/dist/src/core/err.d.ts +0 -10
  10. package/dist/src/core/err.js +0 -38
  11. package/dist/src/core/pull.d.ts +39 -0
  12. package/dist/src/core/pull.js +101 -0
  13. package/dist/src/feed/feed.d.ts +167 -0
  14. package/dist/src/feed/feed.js +642 -0
  15. package/dist/src/fx.d.ts +62 -8
  16. package/dist/src/fx.js +137 -9
  17. package/dist/src/index.d.ts +13 -0
  18. package/dist/src/index.js +13 -0
  19. package/dist/src/jobs/jobs.d.ts +74 -0
  20. package/dist/src/jobs/jobs.js +375 -0
  21. package/dist/src/marketplace/marketplace.d.ts +35 -0
  22. package/dist/src/marketplace/marketplace.js +159 -0
  23. package/dist/src/notifications/notifications.d.ts +20 -0
  24. package/dist/src/notifications/notifications.js +45 -0
  25. package/dist/src/payments/payments.d.ts +59 -0
  26. package/dist/src/payments/payments.js +266 -0
  27. package/dist/src/payrolls/payrolls.d.ts +52 -0
  28. package/dist/src/payrolls/payrolls.js +54 -0
  29. package/dist/src/privacy/privacy.d.ts +21 -0
  30. package/dist/src/privacy/privacy.js +78 -0
  31. package/dist/src/routes/routes.d.ts +22 -0
  32. package/dist/src/routes/routes.js +134 -0
  33. package/dist/src/session/session.d.ts +29 -13
  34. package/dist/src/session/session.js +21 -14
  35. package/dist/src/storage/storage.d.ts +79 -0
  36. package/dist/src/storage/storage.js +240 -0
  37. package/dist/src/timesheets/timesheets.d.ts +91 -0
  38. package/dist/src/timesheets/timesheets.js +407 -0
  39. package/dist/src/users/users.d.ts +15 -11
  40. package/dist/src/users/users.js +33 -7
  41. package/package.json +3 -3
@@ -1,18 +1,32 @@
1
- import type { InUser, PLUsersForgotPassword, PLUsersSignInLink, PLUsersVerifyEmail, UpsertResult } from "@fabriktor/schema";
2
- import type { BootstrapOptions, OperationResultOf, UsersOperator } from "@fabriktor/client";
1
+ import type { UpsertResult } from "@fabriktor/schema";
2
+ import type { BootstrapOptions, ConnectionsOperator, OperationResultOf, UsersOperator } from "@fabriktor/client";
3
3
  import type { AuthEmailOptions, AuthOperator } from "../auth/auth.js";
4
4
  import type { UsersFXOperator } from "../users/users.js";
5
- export type SignInMode = "email" | "username";
5
+ type ConnectionInsert = Parameters<ConnectionsOperator["insertOneConnection"]>[0]["in"];
6
+ type BootstrapInput = BootstrapOptions["in"];
7
+ export declare const SignInMode: {
8
+ readonly Email: "email";
9
+ readonly Username: "username";
10
+ };
11
+ export type SignInMode = (typeof SignInMode)[keyof typeof SignInMode];
6
12
  export type SignInOptions = {
7
13
  mode: SignInMode;
8
14
  identifier: string;
9
15
  password: string;
16
+ connection: ConnectionInsert;
17
+ };
18
+ export type SignInWithEmailOptions = AuthEmailOptions & {
19
+ connection: ConnectionInsert;
10
20
  };
11
21
  export type SignUpAndBootstrapOptions = AuthEmailOptions & {
12
- in: InUser;
22
+ in: BootstrapInput;
13
23
  };
24
+ export type ForgotPasswordOptions = Parameters<UsersOperator["forgotPassword"]>[0];
25
+ export type SendSignInLinkOptions = Parameters<UsersOperator["sendSignInLink"]>[0];
26
+ export type SendEmailVerificationOptions = Parameters<UsersOperator["sendEmailVerification"]>[0];
14
27
  export type SessionFXOptions = {
15
28
  auth: AuthOperator;
29
+ connections: ConnectionsOperator;
16
30
  users: UsersOperator;
17
31
  users_fx: UsersFXOperator;
18
32
  };
@@ -21,27 +35,29 @@ export interface SessionFXOperator {
21
35
  finishSignUp(opts: BootstrapOptions): Promise<OperationResultOf<UpsertResult>>;
22
36
  signUpAndBootstrap(opts: SignUpAndBootstrapOptions): Promise<OperationResultOf<UpsertResult>>;
23
37
  signIn(opts: SignInOptions): Promise<void>;
24
- signInWithEmail(opts: AuthEmailOptions): Promise<void>;
38
+ signInWithEmail(opts: SignInWithEmailOptions): Promise<void>;
25
39
  signOut(): Promise<void>;
26
- forgotPassword(opts: PLUsersForgotPassword): Promise<void>;
27
- sendSignInLink(opts: PLUsersSignInLink): Promise<void>;
28
- sendEmailVerification(opts: PLUsersVerifyEmail): Promise<void>;
40
+ forgotPassword(opts: ForgotPasswordOptions): Promise<void>;
41
+ sendSignInLink(opts: SendSignInLinkOptions): Promise<void>;
42
+ sendEmailVerification(opts: SendEmailVerificationOptions): Promise<void>;
29
43
  checkEmailVerification(): Promise<boolean>;
30
44
  }
31
45
  export declare class SessionFX implements SessionFXOperator {
32
46
  private auth;
47
+ private connections;
33
48
  private users;
34
- private users_fx;
49
+ private usersFX;
35
50
  constructor(opts: SessionFXOptions);
36
51
  startSignUp(opts: AuthEmailOptions): Promise<void>;
37
52
  finishSignUp(opts: BootstrapOptions): Promise<OperationResultOf<UpsertResult>>;
38
53
  signUpAndBootstrap(opts: SignUpAndBootstrapOptions): Promise<OperationResultOf<UpsertResult>>;
39
54
  signIn(opts: SignInOptions): Promise<void>;
40
- signInWithEmail(opts: AuthEmailOptions): Promise<void>;
55
+ signInWithEmail(opts: SignInWithEmailOptions): Promise<void>;
41
56
  signOut(): Promise<void>;
42
- forgotPassword(opts: PLUsersForgotPassword): Promise<void>;
43
- sendSignInLink(opts: PLUsersSignInLink): Promise<void>;
44
- sendEmailVerification(opts: PLUsersVerifyEmail): Promise<void>;
57
+ forgotPassword(opts: ForgotPasswordOptions): Promise<void>;
58
+ sendSignInLink(opts: SendSignInLinkOptions): Promise<void>;
59
+ sendEmailVerification(opts: SendEmailVerificationOptions): Promise<void>;
45
60
  checkEmailVerification(): Promise<boolean>;
46
61
  }
47
62
  export declare function newSessionFX(opts: SessionFXOptions): SessionFX;
63
+ export {};
@@ -3,14 +3,20 @@
3
3
  // Licensed under the Apache License, Version 2.0 (the "License"); you may
4
4
  // not use this file except in compliance with the License. You may obtain
5
5
  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ export const SignInMode = {
7
+ Email: "email",
8
+ Username: "username",
9
+ };
6
10
  export class SessionFX {
7
11
  auth;
12
+ connections;
8
13
  users;
9
- users_fx;
14
+ usersFX;
10
15
  constructor(opts) {
11
16
  this.auth = opts.auth;
17
+ this.connections = opts.connections;
12
18
  this.users = opts.users;
13
- this.users_fx = opts.users_fx;
19
+ this.usersFX = opts.users_fx;
14
20
  }
15
21
  async startSignUp(opts) {
16
22
  await this.auth.signUp({
@@ -33,37 +39,38 @@ export class SessionFX {
33
39
  });
34
40
  }
35
41
  async signIn(opts) {
36
- const email = opts.mode === "email"
42
+ const email = opts.mode === SignInMode.Email
37
43
  ? opts.identifier
38
- : await this.users_fx.resolveUsername({
44
+ : await this.usersFX.resolveUsername({
39
45
  username: opts.identifier,
40
46
  });
41
47
  await this.signInWithEmail({
42
48
  email,
43
49
  password: opts.password,
50
+ connection: opts.connection,
44
51
  });
45
52
  }
46
53
  async signInWithEmail(opts) {
47
- await this.auth.signIn(opts);
54
+ await this.auth.signIn({
55
+ email: opts.email,
56
+ password: opts.password,
57
+ });
58
+ await this.connections.insertOneConnection({
59
+ in: opts.connection,
60
+ });
48
61
  await this.users.sync();
49
62
  }
50
63
  async signOut() {
51
64
  await this.auth.signOut();
52
65
  }
53
66
  async forgotPassword(opts) {
54
- await this.users.forgotPassword({
55
- email: opts.email,
56
- });
67
+ await this.users.forgotPassword(opts);
57
68
  }
58
69
  async sendSignInLink(opts) {
59
- await this.users.sendSignInLink({
60
- email: opts.email,
61
- });
70
+ await this.users.sendSignInLink(opts);
62
71
  }
63
72
  async sendEmailVerification(opts) {
64
- await this.users.sendEmailVerification({
65
- language: opts.language,
66
- });
73
+ await this.users.sendEmailVerification(opts);
67
74
  }
68
75
  async checkEmailVerification() {
69
76
  await this.auth.reloadUser();
@@ -0,0 +1,79 @@
1
+ import { type Object as StorageObject, type RPStorageUpload } from "@fabriktor/schema";
2
+ import type { OperationResultOf, OptionalField, StorageCollection, StorageOperator, StorageUploadFile, UploadStorageOptions } from "@fabriktor/client";
3
+ type StorageDownloadOptions = Parameters<StorageOperator["download"]>[1];
4
+ export declare const StorageUploadModeration: {
5
+ readonly Clean: "clean";
6
+ readonly ContainsForbidden: "contains_forbidden";
7
+ readonly AllForbidden: "all_forbidden";
8
+ };
9
+ export type StorageUploadModeration = (typeof StorageUploadModeration)[keyof typeof StorageUploadModeration];
10
+ export declare const StoragePersonalBoxUploadStatus: {
11
+ readonly PrimaryOnly: "primary_only";
12
+ readonly Complete: "complete";
13
+ readonly Partial: "partial";
14
+ };
15
+ export type StoragePersonalBoxUploadStatus = (typeof StoragePersonalBoxUploadStatus)[keyof typeof StoragePersonalBoxUploadStatus];
16
+ export type StorageFXOptions = {
17
+ storage: StorageOperator;
18
+ };
19
+ export type UploadObjectsOptions = UploadStorageOptions & {
20
+ col: StorageCollection;
21
+ };
22
+ export type UploadObjectsWithPersonalBoxOptions = UploadObjectsOptions & {
23
+ user_id?: string;
24
+ save_to_personal_box?: boolean;
25
+ };
26
+ export type DownloadObjectsOptions = OptionalField<StorageDownloadOptions, "mime_prefix"> & {
27
+ col: StorageCollection;
28
+ };
29
+ export type UploadUserObjectsOptions = {
30
+ user_id: string;
31
+ uploader_id?: string;
32
+ full_quality?: boolean;
33
+ files: StorageUploadFile[];
34
+ };
35
+ export type UploadChatObjectsOptions = {
36
+ chat_id: string;
37
+ user_id?: string;
38
+ uploader_id?: string;
39
+ full_quality?: boolean;
40
+ files: StorageUploadFile[];
41
+ save_to_personal_box?: boolean;
42
+ };
43
+ export type StorageUploadResult = {
44
+ raw: OperationResultOf<RPStorageUpload>;
45
+ moderation: StorageUploadModeration;
46
+ contains_forbidden: boolean;
47
+ all_forbidden: boolean;
48
+ };
49
+ export type StoragePersonalBoxUploadResult = {
50
+ status: typeof StoragePersonalBoxUploadStatus.PrimaryOnly;
51
+ primary: StorageUploadResult;
52
+ } | {
53
+ status: typeof StoragePersonalBoxUploadStatus.Complete;
54
+ primary: StorageUploadResult;
55
+ personal_box: StorageUploadResult;
56
+ } | {
57
+ status: typeof StoragePersonalBoxUploadStatus.Partial;
58
+ primary: StorageUploadResult;
59
+ personal_box_error: unknown;
60
+ };
61
+ export type UploadChatObjectsResult = StoragePersonalBoxUploadResult;
62
+ export interface StorageFXOperator {
63
+ uploadObjects(opts: UploadObjectsOptions): Promise<StorageUploadResult>;
64
+ uploadObjectsWithPersonalBox(opts: UploadObjectsWithPersonalBoxOptions): Promise<StoragePersonalBoxUploadResult>;
65
+ downloadObjects(opts: DownloadObjectsOptions): Promise<OperationResultOf<StorageObject[]>>;
66
+ uploadUserObjects(opts: UploadUserObjectsOptions): Promise<StorageUploadResult>;
67
+ uploadChatObjects(opts: UploadChatObjectsOptions): Promise<UploadChatObjectsResult>;
68
+ }
69
+ export declare class StorageFX implements StorageFXOperator {
70
+ private storage;
71
+ constructor(opts: StorageFXOptions);
72
+ uploadObjects(opts: UploadObjectsOptions): Promise<StorageUploadResult>;
73
+ uploadObjectsWithPersonalBox(opts: UploadObjectsWithPersonalBoxOptions): Promise<StoragePersonalBoxUploadResult>;
74
+ downloadObjects(opts: DownloadObjectsOptions): Promise<OperationResultOf<StorageObject[]>>;
75
+ uploadUserObjects(opts: UploadUserObjectsOptions): Promise<StorageUploadResult>;
76
+ uploadChatObjects(opts: UploadChatObjectsOptions): Promise<UploadChatObjectsResult>;
77
+ }
78
+ export declare function newStorageFX(opts: StorageFXOptions): StorageFX;
79
+ export {};
@@ -0,0 +1,240 @@
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 { ColStorageChat, ColStorageUsers, } from "@fabriktor/schema";
7
+ import { errRequired, errValidation } from "../core/err.js";
8
+ const maxUploadFiles = 20;
9
+ const maxUploadBytes = 1024 * 1024 * 1024;
10
+ const mimePrefixAll = "";
11
+ const extensionHEIC = ".heic";
12
+ const extensionHEIF = ".heif";
13
+ const mimeImageHEIC = "image/heic";
14
+ const mimeImageHEIF = "image/heif";
15
+ const mimeImageHEICSequence = "image/heic-sequence";
16
+ const mimeImageHEIFSequence = "image/heif-sequence";
17
+ const msgOwnerIDRequired = "Owner ID is required.";
18
+ const msgChatIDRequired = "Chat ID is required.";
19
+ const msgUserIDRequired = "User ID is required.";
20
+ const msgUploadFilesRequired = "At least one file is required.";
21
+ const msgUploadTooManyFiles = "Upload supports at most 20 files.";
22
+ const msgUploadTooLarge = "Combined upload size cannot exceed 1 GB.";
23
+ const msgHEICUnsupported = "HEIC and HEIF files must be converted to JPEG or PNG before upload.";
24
+ export const StorageUploadModeration = {
25
+ Clean: "clean",
26
+ ContainsForbidden: "contains_forbidden",
27
+ AllForbidden: "all_forbidden",
28
+ };
29
+ export const StoragePersonalBoxUploadStatus = {
30
+ PrimaryOnly: "primary_only",
31
+ Complete: "complete",
32
+ Partial: "partial",
33
+ };
34
+ export class StorageFX {
35
+ storage;
36
+ constructor(opts) {
37
+ this.storage = opts.storage;
38
+ }
39
+ async uploadObjects(opts) {
40
+ validateUpload(opts);
41
+ const owner_id = opts.owner_id.trim();
42
+ const out = await this.storage.upload(opts.col, {
43
+ owner_id,
44
+ uploader_id: opts.uploader_id,
45
+ full_quality: opts.full_quality,
46
+ files: opts.files,
47
+ });
48
+ return uploadResult(out);
49
+ }
50
+ async uploadObjectsWithPersonalBox(opts) {
51
+ const personal_box_user_id = personalBoxUserID(opts);
52
+ const primary = await this.uploadObjects({
53
+ col: opts.col,
54
+ owner_id: opts.owner_id,
55
+ uploader_id: opts.uploader_id,
56
+ full_quality: opts.full_quality,
57
+ files: opts.files,
58
+ });
59
+ if (personal_box_user_id === undefined) {
60
+ return {
61
+ status: StoragePersonalBoxUploadStatus.PrimaryOnly,
62
+ primary,
63
+ };
64
+ }
65
+ try {
66
+ const personal_box = await this.uploadUserObjects({
67
+ user_id: personal_box_user_id,
68
+ uploader_id: opts.uploader_id,
69
+ full_quality: opts.full_quality,
70
+ files: opts.files,
71
+ });
72
+ return {
73
+ status: StoragePersonalBoxUploadStatus.Complete,
74
+ primary,
75
+ personal_box,
76
+ };
77
+ }
78
+ catch (err) {
79
+ return {
80
+ status: StoragePersonalBoxUploadStatus.Partial,
81
+ primary,
82
+ personal_box_error: err,
83
+ };
84
+ }
85
+ }
86
+ async downloadObjects(opts) {
87
+ const owner_id = opts.owner_id.trim();
88
+ if (owner_id === "") {
89
+ throw errRequired({
90
+ field: "owner_id",
91
+ msg: msgOwnerIDRequired,
92
+ });
93
+ }
94
+ const { col, mime_prefix, ...input } = opts;
95
+ return await this.storage.download(col, {
96
+ ...input,
97
+ owner_id,
98
+ mime_prefix: mime_prefix?.trim() ?? mimePrefixAll,
99
+ });
100
+ }
101
+ async uploadUserObjects(opts) {
102
+ const user_id = opts.user_id.trim();
103
+ if (user_id === "") {
104
+ throw errRequired({
105
+ field: "user_id",
106
+ msg: msgUserIDRequired,
107
+ });
108
+ }
109
+ return await this.uploadObjects({
110
+ col: ColStorageUsers,
111
+ owner_id: user_id,
112
+ uploader_id: opts.uploader_id,
113
+ full_quality: opts.full_quality,
114
+ files: opts.files,
115
+ });
116
+ }
117
+ async uploadChatObjects(opts) {
118
+ const chat_id = opts.chat_id.trim();
119
+ if (chat_id === "") {
120
+ throw errRequired({
121
+ field: "chat_id",
122
+ msg: msgChatIDRequired,
123
+ });
124
+ }
125
+ return await this.uploadObjectsWithPersonalBox({
126
+ col: ColStorageChat,
127
+ owner_id: chat_id,
128
+ user_id: opts.user_id,
129
+ uploader_id: opts.uploader_id,
130
+ full_quality: opts.full_quality,
131
+ files: opts.files,
132
+ save_to_personal_box: opts.save_to_personal_box,
133
+ });
134
+ }
135
+ }
136
+ export function newStorageFX(opts) {
137
+ return new StorageFX(opts);
138
+ }
139
+ function personalBoxUserID(opts) {
140
+ if (!opts.save_to_personal_box) {
141
+ return undefined;
142
+ }
143
+ const user_id = opts.user_id?.trim();
144
+ if (user_id === undefined || user_id === "") {
145
+ throw errRequired({
146
+ field: "user_id",
147
+ msg: msgUserIDRequired,
148
+ });
149
+ }
150
+ return user_id;
151
+ }
152
+ function validateUpload(opts) {
153
+ if (opts.owner_id.trim() === "") {
154
+ throw errRequired({
155
+ field: "owner_id",
156
+ msg: msgOwnerIDRequired,
157
+ });
158
+ }
159
+ if (opts.files.length === 0) {
160
+ throw errRequired({
161
+ field: "files",
162
+ msg: msgUploadFilesRequired,
163
+ });
164
+ }
165
+ if (opts.files.length > maxUploadFiles) {
166
+ throw errValidation({
167
+ field: "files",
168
+ msg: msgUploadTooManyFiles,
169
+ });
170
+ }
171
+ if (uploadSize(opts.files) > maxUploadBytes) {
172
+ throw errValidation({
173
+ field: "files",
174
+ msg: msgUploadTooLarge,
175
+ });
176
+ }
177
+ if (opts.files.some(isHEIC)) {
178
+ throw errValidation({
179
+ field: "files",
180
+ msg: msgHEICUnsupported,
181
+ });
182
+ }
183
+ }
184
+ function uploadSize(files) {
185
+ let out = 0;
186
+ for (const f of files) {
187
+ out += fileSize(f);
188
+ }
189
+ return out;
190
+ }
191
+ function fileSize(f) {
192
+ if ("blob" in f) {
193
+ return f.blob.size;
194
+ }
195
+ return f.size;
196
+ }
197
+ function isHEIC(f) {
198
+ const name = fileName(f).toLowerCase();
199
+ const mime = fileMIME(f).toLowerCase();
200
+ return (name.endsWith(extensionHEIC) ||
201
+ name.endsWith(extensionHEIF) ||
202
+ mime === mimeImageHEIC ||
203
+ mime === mimeImageHEIF ||
204
+ mime === mimeImageHEICSequence ||
205
+ mime === mimeImageHEIFSequence);
206
+ }
207
+ function fileName(f) {
208
+ if ("blob" in f) {
209
+ return f.filename;
210
+ }
211
+ return f.name;
212
+ }
213
+ function fileMIME(f) {
214
+ if ("blob" in f) {
215
+ return f.blob.type;
216
+ }
217
+ return f.type;
218
+ }
219
+ function uploadResult(raw) {
220
+ const contains_forbidden = raw.value?.contains_forbidden ?? false;
221
+ const all_forbidden = raw.value?.all_forbidden ?? false;
222
+ return {
223
+ raw,
224
+ moderation: uploadModeration({
225
+ contains_forbidden,
226
+ all_forbidden,
227
+ }),
228
+ contains_forbidden,
229
+ all_forbidden,
230
+ };
231
+ }
232
+ function uploadModeration(opts) {
233
+ if (opts.all_forbidden) {
234
+ return StorageUploadModeration.AllForbidden;
235
+ }
236
+ if (opts.contains_forbidden) {
237
+ return StorageUploadModeration.ContainsForbidden;
238
+ }
239
+ return StorageUploadModeration.Clean;
240
+ }
@@ -0,0 +1,91 @@
1
+ import { type Date as SchemaDate, type OperationResult, type WeekSheet } from "@fabriktor/schema";
2
+ import type { TimesheetsOperator } from "@fabriktor/client";
3
+ type PunchPayload = Parameters<TimesheetsOperator["punch"]>[0];
4
+ export type TimesheetsFXOptions = {
5
+ timesheets: TimesheetsOperator;
6
+ };
7
+ export type PunchContext = Pick<PunchPayload, "timezone" | "location_id" | "employer_id">;
8
+ export type PunchInOptions = PunchContext & {
9
+ explicit_date?: SchemaDate;
10
+ };
11
+ export type PunchOutOptions = PunchContext & {
12
+ total_pause_minutes: number;
13
+ total_meal_minutes: number;
14
+ explicit_date?: SchemaDate;
15
+ };
16
+ export type RideInOptions = PunchContext & {
17
+ explicit_date?: SchemaDate;
18
+ };
19
+ export type RideOutOptions = PunchContext & {
20
+ explicit_date?: SchemaDate;
21
+ };
22
+ export type ReplaceDayOptions = PunchContext & {
23
+ punch_in_date: SchemaDate;
24
+ punch_out_date: SchemaDate;
25
+ total_pause_minutes: number;
26
+ total_meal_minutes: number;
27
+ };
28
+ export type ReplaceDayResult = {
29
+ punch_in: OperationResult;
30
+ punch_out: OperationResult;
31
+ };
32
+ export type DeleteDayOptions = PunchContext & {
33
+ explicit_date?: SchemaDate;
34
+ };
35
+ export type CreateBlankWeekSheetOptions = PunchContext & {
36
+ explicit_date?: SchemaDate;
37
+ };
38
+ export type PunchControlsOptions = {
39
+ week_sheet?: WeekSheet;
40
+ week_day: number;
41
+ };
42
+ export type PunchControls = {
43
+ can_punch_in: boolean;
44
+ can_punch_out: boolean;
45
+ can_ride_in: boolean;
46
+ can_ride_out: boolean;
47
+ };
48
+ export type SyncWeekOptions = {
49
+ from: WeekSheet;
50
+ to: WeekSheet[];
51
+ };
52
+ export type SyncDaysOptions = SyncWeekOptions & {
53
+ days: number[];
54
+ };
55
+ export type ApproveWeekSheetsOptions = {
56
+ employer_id: string;
57
+ week_sheets: WeekSheet[];
58
+ };
59
+ export interface TimesheetsFXOperator {
60
+ punchControls(opts: PunchControlsOptions): PunchControls;
61
+ punchIn(opts: PunchInOptions): Promise<OperationResult>;
62
+ punchOut(opts: PunchOutOptions): Promise<OperationResult>;
63
+ rideIn(opts: RideInOptions): Promise<OperationResult>;
64
+ rideOut(opts: RideOutOptions): Promise<OperationResult>;
65
+ replaceDay(opts: ReplaceDayOptions): Promise<ReplaceDayResult>;
66
+ deleteDay(opts: DeleteDayOptions): Promise<OperationResult>;
67
+ createBlankWeekSheet(opts: CreateBlankWeekSheetOptions): Promise<OperationResult>;
68
+ syncWeek(opts: SyncWeekOptions): Promise<void>;
69
+ syncDays(opts: SyncDaysOptions): Promise<void>;
70
+ approveWeekSheets(opts: ApproveWeekSheetsOptions): Promise<void>;
71
+ }
72
+ export declare class TimesheetsFX implements TimesheetsFXOperator {
73
+ private timesheets;
74
+ private punch_in_progress;
75
+ constructor(opts: TimesheetsFXOptions);
76
+ punchControls(opts: PunchControlsOptions): PunchControls;
77
+ punchIn(opts: PunchInOptions): Promise<OperationResult>;
78
+ punchOut(opts: PunchOutOptions): Promise<OperationResult>;
79
+ rideIn(opts: RideInOptions): Promise<OperationResult>;
80
+ rideOut(opts: RideOutOptions): Promise<OperationResult>;
81
+ replaceDay(opts: ReplaceDayOptions): Promise<ReplaceDayResult>;
82
+ deleteDay(opts: DeleteDayOptions): Promise<OperationResult>;
83
+ createBlankWeekSheet(opts: CreateBlankWeekSheetOptions): Promise<OperationResult>;
84
+ syncWeek(opts: SyncWeekOptions): Promise<void>;
85
+ syncDays(opts: SyncDaysOptions): Promise<void>;
86
+ approveWeekSheets(opts: ApproveWeekSheetsOptions): Promise<void>;
87
+ private syncSheets;
88
+ private runPunch;
89
+ }
90
+ export declare function newTimesheetsFX(opts: TimesheetsFXOptions): TimesheetsFX;
91
+ export {};