@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
package/dist/src/fx.d.ts CHANGED
@@ -1,37 +1,91 @@
1
- import type { BillableOperator, CallsOperator, NotificationsOperator, PreferencesOperator, TmpPhonesOperator, TmpUsernamesOperator, UsersOperator } from "@fabriktor/client";
1
+ import type { BillableOperator, CallsOperator, ChatOperator, ConnectionsOperator, ContactsOperator, FeedOperator, JobsOperator, MarketplaceOperator, NotificationsOperator, PaymentsOperator, PayrollsOperator, PreferencesOperator, PrivacyOperator, RoutesOperator, StorageOperator, TimesheetsOperator, TmpPhonesOperator, TmpUsernamesOperator, UsersOperator } from "@fabriktor/client";
2
2
  import type { AuthOperator } from "./auth/auth.js";
3
3
  import type { BillableFX, BillableFXOperator } from "./billable/billable.js";
4
4
  import type { CallsFX, CallsFXOperator } from "./calls/calls.js";
5
+ import type { ChatFX, ChatFXOperator } from "./chat/chat.js";
6
+ import type { ContactsFX, ContactsFXOperator } from "./contacts/contacts.js";
7
+ import type { FeedFX, FeedFXOperator } from "./feed/feed.js";
8
+ import type { JobsFX, JobsFXOperator } from "./jobs/jobs.js";
9
+ import type { MarketplaceFX, MarketplaceFXOperator } from "./marketplace/marketplace.js";
10
+ import type { DeviceTokenProvider, NotificationsFX, NotificationsFXOperator } from "./notifications/notifications.js";
11
+ import type { PaymentsFX, PaymentsFXOperator } from "./payments/payments.js";
12
+ import type { PayrollsFX, PayrollsFXOperator } from "./payrolls/payrolls.js";
5
13
  import type { PreferencesFX, PreferencesFXOperator } from "./preferences/preferences.js";
14
+ import type { PrivacyFX, PrivacyFXOperator } from "./privacy/privacy.js";
15
+ import type { RoutesFX, RoutesFXOperator } from "./routes/routes.js";
6
16
  import type { SessionFX, SessionFXOperator } from "./session/session.js";
17
+ import type { StorageFX, StorageFXOperator } from "./storage/storage.js";
18
+ import type { TimesheetsFX, TimesheetsFXOperator } from "./timesheets/timesheets.js";
7
19
  import type { UsersFX, UsersFXOperator } from "./users/users.js";
8
20
  export type FXOptions = {
9
21
  auth: AuthOperator;
10
22
  billable: BillableOperator;
11
23
  calls: CallsOperator;
24
+ chat: ChatOperator;
25
+ connections: ConnectionsOperator;
26
+ contacts: ContactsOperator;
27
+ feed: FeedOperator;
28
+ jobs: JobsOperator;
29
+ marketplace: MarketplaceOperator;
12
30
  notifications: NotificationsOperator;
13
- users: UsersOperator;
14
- tmp_usernames: TmpUsernamesOperator;
15
- tmp_phones: TmpPhonesOperator;
31
+ payments: PaymentsOperator;
32
+ payrolls: PayrollsOperator;
16
33
  preferences: PreferencesOperator;
34
+ privacy: PrivacyOperator;
35
+ routes: RoutesOperator;
36
+ storage: StorageOperator;
37
+ timesheets: TimesheetsOperator;
38
+ tmp_phones: TmpPhonesOperator;
39
+ tmp_usernames: TmpUsernamesOperator;
40
+ users: UsersOperator;
41
+ get_device_token: DeviceTokenProvider;
42
+ feed_keep_alive_interval_ms: number;
43
+ marketplace_keep_alive_interval_ms: number;
17
44
  };
18
45
  export type DefaultFXOptions = {
19
46
  base_url: string;
20
47
  auth: AuthOperator;
48
+ get_device_token: DeviceTokenProvider;
49
+ feed_keep_alive_interval_ms: number;
50
+ marketplace_keep_alive_interval_ms: number;
21
51
  };
22
52
  export interface FXOperator {
23
53
  billable: BillableFXOperator;
24
54
  calls: CallsFXOperator;
25
- users: UsersFXOperator;
26
- session: SessionFXOperator;
55
+ chat: ChatFXOperator;
56
+ contacts: ContactsFXOperator;
57
+ feed: FeedFXOperator;
58
+ jobs: JobsFXOperator;
59
+ marketplace: MarketplaceFXOperator;
60
+ notifications: NotificationsFXOperator;
61
+ payments: PaymentsFXOperator;
62
+ payrolls: PayrollsFXOperator;
27
63
  preferences: PreferencesFXOperator;
64
+ privacy: PrivacyFXOperator;
65
+ routes: RoutesFXOperator;
66
+ session: SessionFXOperator;
67
+ storage: StorageFXOperator;
68
+ timesheets: TimesheetsFXOperator;
69
+ users: UsersFXOperator;
28
70
  }
29
71
  export declare class FX implements FXOperator {
30
72
  billable: BillableFX;
31
73
  calls: CallsFX;
32
- users: UsersFX;
33
- session: SessionFX;
74
+ chat: ChatFX;
75
+ contacts: ContactsFX;
76
+ feed: FeedFX;
77
+ jobs: JobsFX;
78
+ marketplace: MarketplaceFX;
79
+ notifications: NotificationsFX;
80
+ payments: PaymentsFX;
81
+ payrolls: PayrollsFX;
34
82
  preferences: PreferencesFX;
83
+ privacy: PrivacyFX;
84
+ routes: RoutesFX;
85
+ session: SessionFX;
86
+ storage: StorageFX;
87
+ timesheets: TimesheetsFX;
88
+ users: UsersFX;
35
89
  constructor(opts: FXOptions);
36
90
  }
37
91
  export declare function newFX(opts: FXOptions): FX;
package/dist/src/fx.js CHANGED
@@ -3,18 +3,42 @@
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
- import { newBillableClient, newCallsClient, newHTTPClient, newNotificationsClient, newPreferencesClient, newTmpPhonesClient, newTmpUsernamesClient, newUsersClient, } from "@fabriktor/client";
6
+ import { newBillableClient, newCallsClient, newChatClient, newConnectionsClient, newContactsClient, newFeedClient, newHTTPClient, newJobsClient, newMarketplaceClient, newNotificationsClient, newPaymentsClient, newPayrollsClient, newPreferencesClient, newPrivacyClient, newRoutesClient, newStorageClient, newTimesheetsClient, newTmpPhonesClient, newTmpUsernamesClient, newUsersClient, } from "@fabriktor/client";
7
7
  import { newBillableFX } from "./billable/billable.js";
8
8
  import { newCallsFX } from "./calls/calls.js";
9
+ import { newChatFX } from "./chat/chat.js";
10
+ import { newContactsFX } from "./contacts/contacts.js";
11
+ import { newFeedFX } from "./feed/feed.js";
12
+ import { newJobsFX } from "./jobs/jobs.js";
13
+ import { newMarketplaceFX } from "./marketplace/marketplace.js";
14
+ import { newNotificationsFX } from "./notifications/notifications.js";
15
+ import { newPaymentsFX } from "./payments/payments.js";
16
+ import { newPayrollsFX } from "./payrolls/payrolls.js";
9
17
  import { newPreferencesFX } from "./preferences/preferences.js";
18
+ import { newPrivacyFX } from "./privacy/privacy.js";
19
+ import { newRoutesFX } from "./routes/routes.js";
10
20
  import { newSessionFX } from "./session/session.js";
21
+ import { newStorageFX } from "./storage/storage.js";
22
+ import { newTimesheetsFX } from "./timesheets/timesheets.js";
11
23
  import { newUsersFX } from "./users/users.js";
12
24
  export class FX {
13
25
  billable;
14
26
  calls;
15
- users;
16
- session;
27
+ chat;
28
+ contacts;
29
+ feed;
30
+ jobs;
31
+ marketplace;
32
+ notifications;
33
+ payments;
34
+ payrolls;
17
35
  preferences;
36
+ privacy;
37
+ routes;
38
+ session;
39
+ storage;
40
+ timesheets;
41
+ users;
18
42
  constructor(opts) {
19
43
  this.billable = newBillableFX({
20
44
  billable: opts.billable,
@@ -23,16 +47,57 @@ export class FX {
23
47
  calls: opts.calls,
24
48
  notifications: opts.notifications,
25
49
  });
50
+ this.chat = newChatFX({
51
+ chat: opts.chat,
52
+ });
53
+ this.contacts = newContactsFX({
54
+ contacts: opts.contacts,
55
+ });
56
+ this.jobs = newJobsFX({
57
+ jobs: opts.jobs,
58
+ });
59
+ this.notifications = newNotificationsFX({
60
+ notifications: opts.notifications,
61
+ get_device_token: opts.get_device_token,
62
+ });
63
+ this.payments = newPaymentsFX({
64
+ payments: opts.payments,
65
+ });
66
+ this.payrolls = newPayrollsFX({
67
+ payrolls: opts.payrolls,
68
+ });
69
+ this.preferences = newPreferencesFX({
70
+ preferences: opts.preferences,
71
+ });
72
+ this.privacy = newPrivacyFX({
73
+ privacy: opts.privacy,
74
+ });
75
+ this.routes = newRoutesFX({
76
+ routes: opts.routes,
77
+ });
78
+ this.storage = newStorageFX({
79
+ storage: opts.storage,
80
+ });
81
+ this.feed = newFeedFX({
82
+ feed: opts.feed,
83
+ storage_fx: this.storage,
84
+ keep_alive_interval_ms: opts.feed_keep_alive_interval_ms,
85
+ });
86
+ this.marketplace = newMarketplaceFX({
87
+ marketplace: opts.marketplace,
88
+ keep_alive_interval_ms: opts.marketplace_keep_alive_interval_ms,
89
+ });
90
+ this.timesheets = newTimesheetsFX({
91
+ timesheets: opts.timesheets,
92
+ });
26
93
  this.users = newUsersFX({
27
94
  users: opts.users,
28
95
  tmp_usernames: opts.tmp_usernames,
29
96
  tmp_phones: opts.tmp_phones,
30
97
  });
31
- this.preferences = newPreferencesFX({
32
- preferences: opts.preferences,
33
- });
34
98
  this.session = newSessionFX({
35
99
  auth: opts.auth,
100
+ connections: opts.connections,
36
101
  users: opts.users,
37
102
  users_fx: this.users,
38
103
  });
@@ -56,17 +121,72 @@ export function newDefaultFX(opts) {
56
121
  base_url: opts.base_url,
57
122
  get_token,
58
123
  }),
124
+ chat: newChatClient({
125
+ http,
126
+ base_url: opts.base_url,
127
+ get_token,
128
+ }),
129
+ connections: newConnectionsClient({
130
+ http,
131
+ base_url: opts.base_url,
132
+ get_token,
133
+ }),
134
+ contacts: newContactsClient({
135
+ http,
136
+ base_url: opts.base_url,
137
+ get_token,
138
+ }),
139
+ feed: newFeedClient({
140
+ http,
141
+ base_url: opts.base_url,
142
+ get_token,
143
+ }),
144
+ jobs: newJobsClient({
145
+ http,
146
+ base_url: opts.base_url,
147
+ get_token,
148
+ }),
149
+ marketplace: newMarketplaceClient({
150
+ http,
151
+ base_url: opts.base_url,
152
+ get_token,
153
+ }),
59
154
  notifications: newNotificationsClient({
60
155
  http,
61
156
  base_url: opts.base_url,
62
157
  get_token,
63
158
  }),
64
- users: newUsersClient({
159
+ payments: newPaymentsClient({
65
160
  http,
66
161
  base_url: opts.base_url,
67
162
  get_token,
68
163
  }),
69
- tmp_usernames: newTmpUsernamesClient({
164
+ payrolls: newPayrollsClient({
165
+ http,
166
+ base_url: opts.base_url,
167
+ get_token,
168
+ }),
169
+ preferences: newPreferencesClient({
170
+ http,
171
+ base_url: opts.base_url,
172
+ get_token,
173
+ }),
174
+ privacy: newPrivacyClient({
175
+ http,
176
+ base_url: opts.base_url,
177
+ get_token,
178
+ }),
179
+ routes: newRoutesClient({
180
+ http,
181
+ base_url: opts.base_url,
182
+ get_token,
183
+ }),
184
+ storage: newStorageClient({
185
+ http,
186
+ base_url: opts.base_url,
187
+ get_token,
188
+ }),
189
+ timesheets: newTimesheetsClient({
70
190
  http,
71
191
  base_url: opts.base_url,
72
192
  get_token,
@@ -76,10 +196,18 @@ export function newDefaultFX(opts) {
76
196
  base_url: opts.base_url,
77
197
  get_token,
78
198
  }),
79
- preferences: newPreferencesClient({
199
+ tmp_usernames: newTmpUsernamesClient({
200
+ http,
201
+ base_url: opts.base_url,
202
+ get_token,
203
+ }),
204
+ users: newUsersClient({
80
205
  http,
81
206
  base_url: opts.base_url,
82
207
  get_token,
83
208
  }),
209
+ get_device_token: opts.get_device_token,
210
+ feed_keep_alive_interval_ms: opts.feed_keep_alive_interval_ms,
211
+ marketplace_keep_alive_interval_ms: opts.marketplace_keep_alive_interval_ms,
84
212
  });
85
213
  }
@@ -1,10 +1,23 @@
1
1
  export * from "./auth/auth.js";
2
2
  export * from "./billable/billable.js";
3
3
  export * from "./calls/calls.js";
4
+ export * from "./chat/chat.js";
5
+ export * from "./contacts/contacts.js";
4
6
  export * from "./core/err.js";
7
+ export * from "./core/pull.js";
8
+ export * from "./feed/feed.js";
5
9
  export * from "./fx.js";
10
+ export * from "./jobs/jobs.js";
11
+ export * from "./marketplace/marketplace.js";
12
+ export * from "./notifications/notifications.js";
13
+ export * from "./payments/payments.js";
14
+ export * from "./payrolls/payrolls.js";
6
15
  export * from "./preferences/preferences.js";
16
+ export * from "./privacy/privacy.js";
17
+ export * from "./routes/routes.js";
7
18
  export * from "./session/session.js";
19
+ export * from "./storage/storage.js";
20
+ export * from "./timesheets/timesheets.js";
8
21
  export * from "./users/phone.js";
9
22
  export * from "./users/username.js";
10
23
  export * from "./users/users.js";
package/dist/src/index.js CHANGED
@@ -1,10 +1,23 @@
1
1
  export * from "./auth/auth.js";
2
2
  export * from "./billable/billable.js";
3
3
  export * from "./calls/calls.js";
4
+ export * from "./chat/chat.js";
5
+ export * from "./contacts/contacts.js";
4
6
  export * from "./core/err.js";
7
+ export * from "./core/pull.js";
8
+ export * from "./feed/feed.js";
5
9
  export * from "./fx.js";
10
+ export * from "./jobs/jobs.js";
11
+ export * from "./marketplace/marketplace.js";
12
+ export * from "./notifications/notifications.js";
13
+ export * from "./payments/payments.js";
14
+ export * from "./payrolls/payrolls.js";
6
15
  export * from "./preferences/preferences.js";
16
+ export * from "./privacy/privacy.js";
17
+ export * from "./routes/routes.js";
7
18
  export * from "./session/session.js";
19
+ export * from "./storage/storage.js";
20
+ export * from "./timesheets/timesheets.js";
8
21
  export * from "./users/phone.js";
9
22
  export * from "./users/username.js";
10
23
  export * from "./users/users.js";
@@ -0,0 +1,74 @@
1
+ import { type Job, type Location, type OperationResult, type RPJobsFindOverlaps } from "@fabriktor/schema";
2
+ import type { JobsOperator, OperationResultOf } from "@fabriktor/client";
3
+ type JobInsert = Parameters<JobsOperator["insertOneJob"]>[0]["in"];
4
+ type JobProgramInsert = Parameters<JobsOperator["insertOneJobProgram"]>[0]["in"];
5
+ type LocationInsert = Parameters<JobsOperator["insertOneLocation"]>[0]["in"];
6
+ export declare const JobProgramCreateMode: {
7
+ readonly Scheduled: "scheduled";
8
+ readonly Immediate: "immediate";
9
+ };
10
+ export type JobProgramCreateMode = (typeof JobProgramCreateMode)[keyof typeof JobProgramCreateMode];
11
+ export type JobsFXOptions = {
12
+ jobs: JobsOperator;
13
+ now?: () => globalThis.Date;
14
+ };
15
+ export type CreateJobInput = Omit<JobInsert, "status" | "is_active" | "auto_start" | "all_members" | "location_id" | "recurrent">;
16
+ export type CreateJobOptions = {
17
+ in: CreateJobInput;
18
+ location: Location;
19
+ auto_start: boolean;
20
+ start_immediately: boolean;
21
+ };
22
+ export type CreateJobProgramInput = Omit<JobProgramInsert, "job_location_id" | "current_occurrences">;
23
+ export type CreateJobProgramOptions = {
24
+ in: CreateJobProgramInput;
25
+ location: Location;
26
+ };
27
+ export type CreateJobProgramResult = {
28
+ mode: typeof JobProgramCreateMode.Scheduled;
29
+ create: OperationResult;
30
+ } | {
31
+ mode: typeof JobProgramCreateMode.Immediate;
32
+ };
33
+ export type FindLocationOverlapsInput = Pick<LocationInsert, "y" | "m" | "d" | "h" | "min" | "tz" | "end_date">;
34
+ export type FindLocationOverlapsOptions = {
35
+ in: FindLocationOverlapsInput;
36
+ source_id?: string;
37
+ exclude_pending?: boolean;
38
+ exclude_started?: boolean;
39
+ exclude_terminated?: boolean;
40
+ };
41
+ export type AddJobForemanOptions = {
42
+ job: Job;
43
+ location: Location;
44
+ member_id: string;
45
+ };
46
+ export type RemoveJobMemberOptions = {
47
+ job: Job;
48
+ member_id: string;
49
+ };
50
+ export type SetLocationMembersOptions = {
51
+ location: Location;
52
+ current_members: string[];
53
+ };
54
+ export interface JobsFXOperator {
55
+ createJob(opts: CreateJobOptions): Promise<OperationResult>;
56
+ createJobProgram(opts: CreateJobProgramOptions): Promise<CreateJobProgramResult>;
57
+ findLocationOverlaps(opts: FindLocationOverlapsOptions): Promise<OperationResultOf<RPJobsFindOverlaps>>;
58
+ addJobForeman(opts: AddJobForemanOptions): Promise<OperationResult>;
59
+ removeJobMember(opts: RemoveJobMemberOptions): Promise<OperationResult>;
60
+ setLocationMembers(opts: SetLocationMembersOptions): Promise<OperationResult>;
61
+ }
62
+ export declare class JobsFX implements JobsFXOperator {
63
+ private jobs;
64
+ private now;
65
+ constructor(opts: JobsFXOptions);
66
+ createJob(opts: CreateJobOptions): Promise<OperationResult>;
67
+ createJobProgram(opts: CreateJobProgramOptions): Promise<CreateJobProgramResult>;
68
+ findLocationOverlaps(opts: FindLocationOverlapsOptions): Promise<OperationResultOf<RPJobsFindOverlaps>>;
69
+ addJobForeman(opts: AddJobForemanOptions): Promise<OperationResult>;
70
+ removeJobMember(opts: RemoveJobMemberOptions): Promise<OperationResult>;
71
+ setLocationMembers(opts: SetLocationMembersOptions): Promise<OperationResult>;
72
+ }
73
+ export declare function newJobsFX(opts: JobsFXOptions): JobsFX;
74
+ export {};