@fabriktor/fx 0.0.39 → 0.0.40
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 +164 -1
- package/dist/src/billable/billable.js +436 -0
- package/dist/src/calls/calls.d.ts +11 -0
- package/dist/src/calls/calls.js +26 -0
- package/dist/src/chat/chat.d.ts +22 -1
- package/dist/src/chat/chat.js +33 -25
- package/dist/src/contacts/contacts.d.ts +12 -2
- package/dist/src/contacts/contacts.js +33 -7
- package/dist/src/core/id.d.ts +3 -0
- package/dist/src/core/id.js +24 -0
- package/dist/src/feed/feed.d.ts +39 -3
- package/dist/src/feed/feed.js +85 -7
- package/dist/src/fulfillments/fulfillments.d.ts +32 -0
- package/dist/src/fulfillments/fulfillments.js +54 -0
- package/dist/src/fx.d.ts +5 -1
- package/dist/src/fx.js +11 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/jobs/jobs.d.ts +52 -4
- package/dist/src/jobs/jobs.js +120 -9
- package/dist/src/marketplace/marketplace.d.ts +29 -1
- package/dist/src/marketplace/marketplace.js +64 -1
- package/dist/src/memos/memos.js +4 -28
- package/dist/src/payments/payments.d.ts +112 -1
- package/dist/src/payments/payments.js +291 -15
- package/dist/src/payrolls/payrolls.d.ts +134 -1
- package/dist/src/payrolls/payrolls.js +364 -0
- package/dist/src/preferences/preferences.d.ts +83 -1
- package/dist/src/preferences/preferences.js +227 -0
- package/dist/src/privacy/privacy.d.ts +21 -2
- package/dist/src/privacy/privacy.js +56 -5
- package/dist/src/routes/routes.d.ts +63 -3
- package/dist/src/routes/routes.js +151 -1
- package/dist/src/timesheets/timesheets.d.ts +11 -1
- package/dist/src/timesheets/timesheets.js +39 -1
- package/package.json +2 -2
package/dist/src/fx.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { BillableOperator, CallsOperator, ChatOperator, ConnectionsOperator, ContactsOperator, FeedOperator, JobsOperator, MarketplaceOperator, MemosOperator, NotificationsOperator, PaymentsOperator, PayrollsOperator, PreferencesOperator, PrivacyOperator, RoutesOperator, StorageOperator, TimesheetsOperator, TmpPhonesOperator, TmpUsernamesOperator, UsersOperator } from "@fabriktor/client";
|
|
1
|
+
import type { BillableOperator, CallsOperator, ChatOperator, ConnectionsOperator, ContactsOperator, FeedOperator, FulfillmentsOperator, JobsOperator, MarketplaceOperator, MemosOperator, 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
5
|
import type { ChatFX, ChatFXOperator } from "./chat/chat.js";
|
|
6
6
|
import type { ContactsFX, ContactsFXOperator } from "./contacts/contacts.js";
|
|
7
7
|
import type { FeedFX, FeedFXOperator } from "./feed/feed.js";
|
|
8
|
+
import type { FulfillmentsFX, FulfillmentsFXOperator } from "./fulfillments/fulfillments.js";
|
|
8
9
|
import type { JobsFX, JobsFXOperator } from "./jobs/jobs.js";
|
|
9
10
|
import type { MarketplaceFX, MarketplaceFXOperator } from "./marketplace/marketplace.js";
|
|
10
11
|
import type { MemosFX, MemosFXOperator } from "./memos/memos.js";
|
|
@@ -26,6 +27,7 @@ export type FXOptions = {
|
|
|
26
27
|
connections: ConnectionsOperator;
|
|
27
28
|
contacts: ContactsOperator;
|
|
28
29
|
feed: FeedOperator;
|
|
30
|
+
fulfillments: FulfillmentsOperator;
|
|
29
31
|
jobs: JobsOperator;
|
|
30
32
|
marketplace: MarketplaceOperator;
|
|
31
33
|
memos: MemosOperator;
|
|
@@ -57,6 +59,7 @@ export interface FXOperator {
|
|
|
57
59
|
chat: ChatFXOperator;
|
|
58
60
|
contacts: ContactsFXOperator;
|
|
59
61
|
feed: FeedFXOperator;
|
|
62
|
+
fulfillments: FulfillmentsFXOperator;
|
|
60
63
|
jobs: JobsFXOperator;
|
|
61
64
|
marketplace: MarketplaceFXOperator;
|
|
62
65
|
memos: MemosFXOperator;
|
|
@@ -77,6 +80,7 @@ export declare class FX implements FXOperator {
|
|
|
77
80
|
chat: ChatFX;
|
|
78
81
|
contacts: ContactsFX;
|
|
79
82
|
feed: FeedFX;
|
|
83
|
+
fulfillments: FulfillmentsFX;
|
|
80
84
|
jobs: JobsFX;
|
|
81
85
|
marketplace: MarketplaceFX;
|
|
82
86
|
memos: MemosFX;
|
package/dist/src/fx.js
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
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, newChatClient, newConnectionsClient, newContactsClient, newFeedClient, newHTTPClient, newJobsClient, newMarketplaceClient, newMemosClient, newNotificationsClient, newPaymentsClient, newPayrollsClient, newPreferencesClient, newPrivacyClient, newRoutesClient, newStorageClient, newTimesheetsClient, newTmpPhonesClient, newTmpUsernamesClient, newUsersClient, } from "@fabriktor/client";
|
|
6
|
+
import { newBillableClient, newCallsClient, newChatClient, newConnectionsClient, newContactsClient, newFeedClient, newFulfillmentsClient, newHTTPClient, newJobsClient, newMarketplaceClient, newMemosClient, 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
9
|
import { newChatFX } from "./chat/chat.js";
|
|
10
10
|
import { newContactsFX } from "./contacts/contacts.js";
|
|
11
11
|
import { newFeedFX } from "./feed/feed.js";
|
|
12
|
+
import { newFulfillmentsFX } from "./fulfillments/fulfillments.js";
|
|
12
13
|
import { newJobsFX } from "./jobs/jobs.js";
|
|
13
14
|
import { newMarketplaceFX } from "./marketplace/marketplace.js";
|
|
14
15
|
import { newMemosFX } from "./memos/memos.js";
|
|
@@ -28,6 +29,7 @@ export class FX {
|
|
|
28
29
|
chat;
|
|
29
30
|
contacts;
|
|
30
31
|
feed;
|
|
32
|
+
fulfillments;
|
|
31
33
|
jobs;
|
|
32
34
|
marketplace;
|
|
33
35
|
memos;
|
|
@@ -55,6 +57,9 @@ export class FX {
|
|
|
55
57
|
this.contacts = newContactsFX({
|
|
56
58
|
contacts: opts.contacts,
|
|
57
59
|
});
|
|
60
|
+
this.fulfillments = newFulfillmentsFX({
|
|
61
|
+
fulfillments: opts.fulfillments,
|
|
62
|
+
});
|
|
58
63
|
this.jobs = newJobsFX({
|
|
59
64
|
jobs: opts.jobs,
|
|
60
65
|
});
|
|
@@ -146,6 +151,11 @@ export function newDefaultFX(opts) {
|
|
|
146
151
|
base_url: opts.base_url,
|
|
147
152
|
get_token,
|
|
148
153
|
}),
|
|
154
|
+
fulfillments: newFulfillmentsClient({
|
|
155
|
+
http,
|
|
156
|
+
base_url: opts.base_url,
|
|
157
|
+
get_token,
|
|
158
|
+
}),
|
|
149
159
|
jobs: newJobsClient({
|
|
150
160
|
http,
|
|
151
161
|
base_url: opts.base_url,
|
package/dist/src/index.d.ts
CHANGED
|
@@ -4,9 +4,11 @@ export * from "./calls/calls.js";
|
|
|
4
4
|
export * from "./chat/chat.js";
|
|
5
5
|
export * from "./contacts/contacts.js";
|
|
6
6
|
export * from "./core/err.js";
|
|
7
|
+
export * from "./core/id.js";
|
|
7
8
|
export * from "./core/pull.js";
|
|
8
9
|
export * from "./core/search.js";
|
|
9
10
|
export * from "./feed/feed.js";
|
|
11
|
+
export * from "./fulfillments/fulfillments.js";
|
|
10
12
|
export * from "./fx.js";
|
|
11
13
|
export * from "./jobs/jobs.js";
|
|
12
14
|
export * from "./marketplace/marketplace.js";
|
package/dist/src/index.js
CHANGED
|
@@ -4,9 +4,11 @@ export * from "./calls/calls.js";
|
|
|
4
4
|
export * from "./chat/chat.js";
|
|
5
5
|
export * from "./contacts/contacts.js";
|
|
6
6
|
export * from "./core/err.js";
|
|
7
|
+
export * from "./core/id.js";
|
|
7
8
|
export * from "./core/pull.js";
|
|
8
9
|
export * from "./core/search.js";
|
|
9
10
|
export * from "./feed/feed.js";
|
|
11
|
+
export * from "./fulfillments/fulfillments.js";
|
|
10
12
|
export * from "./fx.js";
|
|
11
13
|
export * from "./jobs/jobs.js";
|
|
12
14
|
export * from "./marketplace/marketplace.js";
|
package/dist/src/jobs/jobs.d.ts
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
|
-
import { type Job, type Location, type OperationResult, type RPJobsFindOverlaps } from "@fabriktor/schema";
|
|
1
|
+
import { type Job, type JobProgram, type Location, type OperationResult, type RPJobsFindOverlaps } from "@fabriktor/schema";
|
|
2
2
|
import type { JobsOperator, OperationResultOf } from "@fabriktor/client";
|
|
3
|
+
import { type SearchPage } from "../core/search.js";
|
|
3
4
|
type JobInsert = Parameters<JobsOperator["insertOneJob"]>[0]["in"];
|
|
4
5
|
type JobProgramInsert = Parameters<JobsOperator["insertOneJobProgram"]>[0]["in"];
|
|
5
6
|
type LocationInsert = Parameters<JobsOperator["insertOneLocation"]>[0]["in"];
|
|
7
|
+
type LocationInsertOptions = Parameters<JobsOperator["insertOneLocation"]>[0];
|
|
8
|
+
type LocationReplaceOptions = Parameters<JobsOperator["replaceOneLocation"]>[0];
|
|
9
|
+
type JobProgramReplaceOptions = Parameters<JobsOperator["replaceOneJobProgram"]>[0];
|
|
10
|
+
type JobReplaceOptions = Parameters<JobsOperator["replaceOneJob"]>[0];
|
|
11
|
+
type SearchJobRecordsOptions = {
|
|
12
|
+
owner_id: string;
|
|
13
|
+
q?: string;
|
|
14
|
+
page?: number;
|
|
15
|
+
per_page?: number;
|
|
16
|
+
};
|
|
6
17
|
export declare const JobProgramCreateMode: {
|
|
7
18
|
readonly Scheduled: "scheduled";
|
|
8
19
|
readonly Immediate: "immediate";
|
|
9
20
|
};
|
|
10
21
|
export type JobProgramCreateMode = (typeof JobProgramCreateMode)[keyof typeof JobProgramCreateMode];
|
|
22
|
+
export type CreateLocationOptions = LocationInsertOptions;
|
|
23
|
+
export type ReplaceLocationOptions = LocationReplaceOptions;
|
|
24
|
+
export type ReplaceJobProgramOptions = JobProgramReplaceOptions;
|
|
25
|
+
export type ReplaceJobOptions = JobReplaceOptions;
|
|
26
|
+
export type SearchLocationsOptions = SearchJobRecordsOptions;
|
|
27
|
+
export type SearchJobProgramsOptions = SearchJobRecordsOptions;
|
|
28
|
+
export type SearchJobsOptions = SearchJobRecordsOptions;
|
|
29
|
+
export type SearchLocationsPage = SearchPage<Location>;
|
|
30
|
+
export type SearchJobProgramsPage = SearchPage<JobProgram>;
|
|
31
|
+
export type SearchJobsPage = SearchPage<Job>;
|
|
11
32
|
export type JobsFXOptions = {
|
|
12
33
|
jobs: JobsOperator;
|
|
13
34
|
now?: () => globalThis.Date;
|
|
@@ -24,12 +45,18 @@ export type CreateJobProgramOptions = {
|
|
|
24
45
|
in: CreateJobProgramInput;
|
|
25
46
|
location: Location;
|
|
26
47
|
};
|
|
27
|
-
export type
|
|
48
|
+
export type CreateLocationJobProgramResult = {
|
|
28
49
|
mode: typeof JobProgramCreateMode.Scheduled;
|
|
29
50
|
create: OperationResult;
|
|
30
51
|
} | {
|
|
31
52
|
mode: typeof JobProgramCreateMode.Immediate;
|
|
32
53
|
};
|
|
54
|
+
export type CreateJobProgramResult = {
|
|
55
|
+
mode: typeof JobProgramCreateMode.Scheduled;
|
|
56
|
+
job_program: JobProgram;
|
|
57
|
+
} | {
|
|
58
|
+
mode: typeof JobProgramCreateMode.Immediate;
|
|
59
|
+
};
|
|
33
60
|
export type FindLocationOverlapsInput = Pick<LocationInsert, "y" | "m" | "d" | "h" | "min" | "tz" | "end_date">;
|
|
34
61
|
export type FindLocationOverlapsOptions = {
|
|
35
62
|
in: FindLocationOverlapsInput;
|
|
@@ -52,8 +79,17 @@ export type SetLocationMembersOptions = {
|
|
|
52
79
|
current_members: string[];
|
|
53
80
|
};
|
|
54
81
|
export interface JobsFXOperator {
|
|
55
|
-
|
|
82
|
+
createLocation(opts: CreateLocationOptions): Promise<Location>;
|
|
83
|
+
replaceLocation(opts: ReplaceLocationOptions): Promise<Location>;
|
|
84
|
+
searchLocations(opts: SearchLocationsOptions): Promise<SearchLocationsPage>;
|
|
85
|
+
replaceJobProgram(opts: ReplaceJobProgramOptions): Promise<JobProgram>;
|
|
86
|
+
searchJobPrograms(opts: SearchJobProgramsOptions): Promise<SearchJobProgramsPage>;
|
|
87
|
+
replaceJob(opts: ReplaceJobOptions): Promise<Job>;
|
|
88
|
+
searchJobs(opts: SearchJobsOptions): Promise<SearchJobsPage>;
|
|
89
|
+
createJob(opts: CreateJobOptions): Promise<Job>;
|
|
90
|
+
createLocationJob(opts: CreateJobOptions): Promise<OperationResult>;
|
|
56
91
|
createJobProgram(opts: CreateJobProgramOptions): Promise<CreateJobProgramResult>;
|
|
92
|
+
createLocationJobProgram(opts: CreateJobProgramOptions): Promise<CreateLocationJobProgramResult>;
|
|
57
93
|
findLocationOverlaps(opts: FindLocationOverlapsOptions): Promise<OperationResultOf<RPJobsFindOverlaps>>;
|
|
58
94
|
addJobForeman(opts: AddJobForemanOptions): Promise<OperationResult>;
|
|
59
95
|
removeJobMember(opts: RemoveJobMemberOptions): Promise<OperationResult>;
|
|
@@ -63,12 +99,24 @@ export declare class JobsFX implements JobsFXOperator {
|
|
|
63
99
|
private jobs;
|
|
64
100
|
private now;
|
|
65
101
|
constructor(opts: JobsFXOptions);
|
|
66
|
-
|
|
102
|
+
createLocation(opts: CreateLocationOptions): Promise<Location>;
|
|
103
|
+
replaceLocation(opts: ReplaceLocationOptions): Promise<Location>;
|
|
104
|
+
searchLocations(opts: SearchLocationsOptions): Promise<SearchLocationsPage>;
|
|
105
|
+
replaceJobProgram(opts: ReplaceJobProgramOptions): Promise<JobProgram>;
|
|
106
|
+
searchJobPrograms(opts: SearchJobProgramsOptions): Promise<SearchJobProgramsPage>;
|
|
107
|
+
replaceJob(opts: ReplaceJobOptions): Promise<Job>;
|
|
108
|
+
searchJobs(opts: SearchJobsOptions): Promise<SearchJobsPage>;
|
|
109
|
+
createJob(opts: CreateJobOptions): Promise<Job>;
|
|
110
|
+
createLocationJob(opts: CreateJobOptions): Promise<OperationResult>;
|
|
67
111
|
createJobProgram(opts: CreateJobProgramOptions): Promise<CreateJobProgramResult>;
|
|
112
|
+
createLocationJobProgram(opts: CreateJobProgramOptions): Promise<CreateLocationJobProgramResult>;
|
|
68
113
|
findLocationOverlaps(opts: FindLocationOverlapsOptions): Promise<OperationResultOf<RPJobsFindOverlaps>>;
|
|
69
114
|
addJobForeman(opts: AddJobForemanOptions): Promise<OperationResult>;
|
|
70
115
|
removeJobMember(opts: RemoveJobMemberOptions): Promise<OperationResult>;
|
|
71
116
|
setLocationMembers(opts: SetLocationMembersOptions): Promise<OperationResult>;
|
|
117
|
+
private findLocation;
|
|
118
|
+
private findJobProgram;
|
|
119
|
+
private findJob;
|
|
72
120
|
}
|
|
73
121
|
export declare function newJobsFX(opts: JobsFXOptions): JobsFX;
|
|
74
122
|
export {};
|
package/dist/src/jobs/jobs.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
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 { LocationTypePersistent, Pending, Started, Terminated, ZeroID, } from "@fabriktor/schema";
|
|
7
|
-
import { errRequired, errValidation } from "../core/err.js";
|
|
6
|
+
import { LocationTypePersistent, Pending, Started, OwnerIDKey, Terminated, ZeroID, } from "@fabriktor/schema";
|
|
7
|
+
import { errRequired, errResolveFailed, errValidation, } from "../core/err.js";
|
|
8
|
+
import { requiredOperationID, resolvedID } from "../core/id.js";
|
|
9
|
+
import { runSearch } from "../core/search.js";
|
|
8
10
|
const msgJobIDRequired = "Job ID is required.";
|
|
9
11
|
const msgLocationIDRequired = "Location ID is required.";
|
|
10
12
|
const msgMemberIDRequired = "Member ID is required.";
|
|
@@ -20,6 +22,15 @@ const msgLocationMemberAssigned = "Cannot remove a location member while they ar
|
|
|
20
22
|
const msgDateInvalid = "Date contains an invalid UTC value.";
|
|
21
23
|
const msgLocationRangeInvalid = "Location contains an invalid scheduled time span.";
|
|
22
24
|
const msgTimezoneInvalid = "Program timezone is invalid.";
|
|
25
|
+
const resourceLocation = "location";
|
|
26
|
+
const resourceJobProgram = "job_program";
|
|
27
|
+
const resourceJob = "job";
|
|
28
|
+
const msgCreatedLocationIDMissing = "Created location response did not contain an ID.";
|
|
29
|
+
const msgCreatedJobProgramIDMissing = "Created job program response did not contain an ID.";
|
|
30
|
+
const msgCreatedJobIDMissing = "Created job response did not contain an ID.";
|
|
31
|
+
const msgLocationMissing = "Location could not be resolved after the mutation.";
|
|
32
|
+
const msgJobProgramMissing = "Job program could not be resolved after the mutation.";
|
|
33
|
+
const msgJobMissing = "Job could not be resolved after the mutation.";
|
|
23
34
|
export const JobProgramCreateMode = {
|
|
24
35
|
Scheduled: "scheduled",
|
|
25
36
|
Immediate: "immediate",
|
|
@@ -31,7 +42,62 @@ export class JobsFX {
|
|
|
31
42
|
this.jobs = opts.jobs;
|
|
32
43
|
this.now = opts.now ?? (() => new globalThis.Date());
|
|
33
44
|
}
|
|
45
|
+
async createLocation(opts) {
|
|
46
|
+
const out = await this.jobs.insertOneLocation(opts);
|
|
47
|
+
const id = requiredOperationID(out, msgCreatedLocationIDMissing);
|
|
48
|
+
return await this.findLocation(id);
|
|
49
|
+
}
|
|
50
|
+
async replaceLocation(opts) {
|
|
51
|
+
await this.jobs.replaceOneLocation(opts);
|
|
52
|
+
return await this.findLocation(opts.id);
|
|
53
|
+
}
|
|
54
|
+
async searchLocations(opts) {
|
|
55
|
+
return await runSearch({
|
|
56
|
+
search: (searchOpts) => this.jobs.searchManyLocations(searchOpts),
|
|
57
|
+
query: {
|
|
58
|
+
[OwnerIDKey]: opts.owner_id,
|
|
59
|
+
},
|
|
60
|
+
q: opts.q,
|
|
61
|
+
page: opts.page,
|
|
62
|
+
per_page: opts.per_page,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
async replaceJobProgram(opts) {
|
|
66
|
+
await this.jobs.replaceOneJobProgram(opts);
|
|
67
|
+
return await this.findJobProgram(opts.id);
|
|
68
|
+
}
|
|
69
|
+
async searchJobPrograms(opts) {
|
|
70
|
+
return await runSearch({
|
|
71
|
+
search: (searchOpts) => this.jobs.searchManyJobPrograms(searchOpts),
|
|
72
|
+
query: {
|
|
73
|
+
[OwnerIDKey]: opts.owner_id,
|
|
74
|
+
},
|
|
75
|
+
q: opts.q,
|
|
76
|
+
page: opts.page,
|
|
77
|
+
per_page: opts.per_page,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
async replaceJob(opts) {
|
|
81
|
+
await this.jobs.replaceOneJob(opts);
|
|
82
|
+
return await this.findJob(opts.id);
|
|
83
|
+
}
|
|
84
|
+
async searchJobs(opts) {
|
|
85
|
+
return await runSearch({
|
|
86
|
+
search: (searchOpts) => this.jobs.searchManyJobs(searchOpts),
|
|
87
|
+
query: {
|
|
88
|
+
[OwnerIDKey]: opts.owner_id,
|
|
89
|
+
},
|
|
90
|
+
q: opts.q,
|
|
91
|
+
page: opts.page,
|
|
92
|
+
per_page: opts.per_page,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
34
95
|
async createJob(opts) {
|
|
96
|
+
const out = await this.createLocationJob(opts);
|
|
97
|
+
const id = requiredOperationID(out, msgCreatedJobIDMissing);
|
|
98
|
+
return await this.findJob(id);
|
|
99
|
+
}
|
|
100
|
+
async createLocationJob(opts) {
|
|
35
101
|
const location_id = requiredID(opts.location.id, "location", msgLocationIDRequired);
|
|
36
102
|
const foremen = normalizeIDs(opts.in.foremen);
|
|
37
103
|
const current_members = unionIDs(opts.in.current_members, foremen);
|
|
@@ -58,6 +124,19 @@ export class JobsFX {
|
|
|
58
124
|
});
|
|
59
125
|
}
|
|
60
126
|
async createJobProgram(opts) {
|
|
127
|
+
const out = await this.createLocationJobProgram(opts);
|
|
128
|
+
if (out.mode === JobProgramCreateMode.Immediate) {
|
|
129
|
+
return {
|
|
130
|
+
mode: JobProgramCreateMode.Immediate,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
const id = requiredOperationID(out.create, msgCreatedJobProgramIDMissing);
|
|
134
|
+
return {
|
|
135
|
+
mode: JobProgramCreateMode.Scheduled,
|
|
136
|
+
job_program: await this.findJobProgram(id),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
async createLocationJobProgram(opts) {
|
|
61
140
|
const job_location_id = requiredID(opts.location.id, "location", msgLocationIDRequired);
|
|
62
141
|
const job_foremen = normalizeIDs(opts.in.job_foremen);
|
|
63
142
|
const job_current_members = unionIDs(opts.in.job_current_members, job_foremen);
|
|
@@ -200,6 +279,45 @@ export class JobsFX {
|
|
|
200
279
|
},
|
|
201
280
|
});
|
|
202
281
|
}
|
|
282
|
+
async findLocation(id) {
|
|
283
|
+
const out = await this.jobs.findOneLocation({
|
|
284
|
+
id,
|
|
285
|
+
});
|
|
286
|
+
const location = out.value;
|
|
287
|
+
if (location === undefined) {
|
|
288
|
+
throw errResolveFailed({
|
|
289
|
+
resource: resourceLocation,
|
|
290
|
+
msg: msgLocationMissing,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return location;
|
|
294
|
+
}
|
|
295
|
+
async findJobProgram(id) {
|
|
296
|
+
const out = await this.jobs.findOneJobProgram({
|
|
297
|
+
id,
|
|
298
|
+
});
|
|
299
|
+
const job_program = out.value;
|
|
300
|
+
if (job_program === undefined) {
|
|
301
|
+
throw errResolveFailed({
|
|
302
|
+
resource: resourceJobProgram,
|
|
303
|
+
msg: msgJobProgramMissing,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
return job_program;
|
|
307
|
+
}
|
|
308
|
+
async findJob(id) {
|
|
309
|
+
const out = await this.jobs.findOneJob({
|
|
310
|
+
id,
|
|
311
|
+
});
|
|
312
|
+
const job = out.value;
|
|
313
|
+
if (job === undefined) {
|
|
314
|
+
throw errResolveFailed({
|
|
315
|
+
resource: resourceJob,
|
|
316
|
+
msg: msgJobMissing,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
return job;
|
|
320
|
+
}
|
|
203
321
|
}
|
|
204
322
|
export function newJobsFX(opts) {
|
|
205
323
|
return new JobsFX(opts);
|
|
@@ -347,13 +465,6 @@ function requiredID(v, field, msg) {
|
|
|
347
465
|
}
|
|
348
466
|
return out;
|
|
349
467
|
}
|
|
350
|
-
function resolvedID(v) {
|
|
351
|
-
const out = v?.trim();
|
|
352
|
-
if (out === undefined || out === "" || out === ZeroID) {
|
|
353
|
-
return undefined;
|
|
354
|
-
}
|
|
355
|
-
return out;
|
|
356
|
-
}
|
|
357
468
|
function normalizeIDs(ids) {
|
|
358
469
|
const seen = new Set();
|
|
359
470
|
const out = [];
|
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
import { type RPMarketplacePull } from "@fabriktor/schema";
|
|
2
1
|
import type { MarketplaceOperator, OperationResultOf } from "@fabriktor/client";
|
|
2
|
+
import { type MarketplaceFavorite, type MarketplacePost, type RPMarketplacePull } from "@fabriktor/schema";
|
|
3
3
|
import { type PullSession, type PullSessionErrorHandler } from "../core/pull.js";
|
|
4
|
+
import { type SearchPage } from "../core/search.js";
|
|
5
|
+
type MarketplacePostInsertOptions = Parameters<MarketplaceOperator["insertOneMarketplacePost"]>[0];
|
|
6
|
+
type MarketplacePostReplaceOptions = Parameters<MarketplaceOperator["replaceOneMarketplacePost"]>[0];
|
|
7
|
+
type MarketplaceFavoriteInsertOptions = Parameters<MarketplaceOperator["insertOneMarketplaceFavorite"]>[0];
|
|
8
|
+
type MarketplaceFavoriteReplaceOptions = Parameters<MarketplaceOperator["replaceOneMarketplaceFavorite"]>[0];
|
|
4
9
|
type MarketplacePullOptions = Parameters<MarketplaceOperator["pull"]>[0];
|
|
10
|
+
export type CreateMarketplacePostOptions = MarketplacePostInsertOptions;
|
|
11
|
+
export type ReplaceMarketplacePostOptions = MarketplacePostReplaceOptions;
|
|
12
|
+
export type CreateMarketplaceFavoriteOptions = MarketplaceFavoriteInsertOptions;
|
|
13
|
+
export type ReplaceMarketplaceFavoriteOptions = MarketplaceFavoriteReplaceOptions;
|
|
14
|
+
export type SearchMarketplacePostsOptions = {
|
|
15
|
+
owner_id: string;
|
|
16
|
+
q?: string;
|
|
17
|
+
page?: number;
|
|
18
|
+
per_page?: number;
|
|
19
|
+
};
|
|
20
|
+
export type SearchMarketplacePostsPage = SearchPage<MarketplacePost>;
|
|
5
21
|
export type MarketplacePullContext = Pick<MarketplacePullOptions, "pull_type" | "entity_id" | "research" | "research_user_type">;
|
|
6
22
|
export type MarketplacePullResult = OperationResultOf<RPMarketplacePull>;
|
|
7
23
|
export type MarketplaceResearchUserType = MarketplacePullOptions["research_user_type"];
|
|
@@ -21,6 +37,11 @@ export type StartMarketplaceWelcomeSessionOptions = {
|
|
|
21
37
|
on_error?: MarketplaceSessionErrorHandler;
|
|
22
38
|
};
|
|
23
39
|
export interface MarketplaceFXOperator {
|
|
40
|
+
createMarketplacePost(opts: CreateMarketplacePostOptions): Promise<MarketplacePost>;
|
|
41
|
+
replaceMarketplacePost(opts: ReplaceMarketplacePostOptions): Promise<MarketplacePost>;
|
|
42
|
+
searchMarketplacePosts(opts: SearchMarketplacePostsOptions): Promise<SearchMarketplacePostsPage>;
|
|
43
|
+
createMarketplaceFavorite(opts: CreateMarketplaceFavoriteOptions): Promise<MarketplaceFavorite>;
|
|
44
|
+
replaceMarketplaceFavorite(opts: ReplaceMarketplaceFavoriteOptions): Promise<MarketplaceFavorite>;
|
|
24
45
|
startSession(opts: StartMarketplaceSessionOptions): Promise<MarketplaceSession>;
|
|
25
46
|
startWelcomeSession(opts: StartMarketplaceWelcomeSessionOptions): Promise<MarketplaceSession>;
|
|
26
47
|
}
|
|
@@ -28,8 +49,15 @@ export declare class MarketplaceFX implements MarketplaceFXOperator {
|
|
|
28
49
|
private marketplace;
|
|
29
50
|
private keep_alive_interval_ms;
|
|
30
51
|
constructor(opts: MarketplaceFXOptions);
|
|
52
|
+
createMarketplacePost(opts: CreateMarketplacePostOptions): Promise<MarketplacePost>;
|
|
53
|
+
replaceMarketplacePost(opts: ReplaceMarketplacePostOptions): Promise<MarketplacePost>;
|
|
54
|
+
searchMarketplacePosts(opts: SearchMarketplacePostsOptions): Promise<SearchMarketplacePostsPage>;
|
|
55
|
+
createMarketplaceFavorite(opts: CreateMarketplaceFavoriteOptions): Promise<MarketplaceFavorite>;
|
|
56
|
+
replaceMarketplaceFavorite(opts: ReplaceMarketplaceFavoriteOptions): Promise<MarketplaceFavorite>;
|
|
31
57
|
startSession(opts: StartMarketplaceSessionOptions): Promise<MarketplaceSession>;
|
|
32
58
|
startWelcomeSession(opts: StartMarketplaceWelcomeSessionOptions): Promise<MarketplaceSession>;
|
|
59
|
+
private findMarketplacePost;
|
|
60
|
+
private findMarketplaceFavorite;
|
|
33
61
|
}
|
|
34
62
|
export declare function newMarketplaceFX(opts: MarketplaceFXOptions): MarketplaceFX;
|
|
35
63
|
export {};
|
|
@@ -3,11 +3,19 @@
|
|
|
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 { PullTypeBatch, PullTypeKeepAlive, PullTypeResearch, } from "@fabriktor/schema";
|
|
6
|
+
import { OwnerIDKey, PullTypeBatch, PullTypeKeepAlive, PullTypeResearch, } from "@fabriktor/schema";
|
|
7
7
|
import { errRequired, errResolveFailed, errValidation } from "../core/err.js";
|
|
8
|
+
import { requiredOperationID } from "../core/id.js";
|
|
8
9
|
import { newPullSession, } from "../core/pull.js";
|
|
10
|
+
import { runSearch } from "../core/search.js";
|
|
9
11
|
const newMarketplaceSessionToken = "";
|
|
10
12
|
const resourceMarketplaceSessionToken = "marketplace_session_token";
|
|
13
|
+
const resourceMarketplacePost = "marketplace_post";
|
|
14
|
+
const resourceMarketplaceFavorite = "marketplace_favorite";
|
|
15
|
+
const msgCreatedMarketplacePostIDMissing = "Created marketplace post response did not contain an ID.";
|
|
16
|
+
const msgMarketplacePostMissing = "Marketplace post could not be resolved after the mutation.";
|
|
17
|
+
const msgCreatedMarketplaceFavoriteIDMissing = "Created marketplace favorite response did not contain an ID.";
|
|
18
|
+
const msgMarketplaceFavoriteMissing = "Marketplace favorite could not be resolved after the mutation.";
|
|
11
19
|
const msgKeepAliveIntervalInvalid = "Keep-alive interval must be a finite number greater than zero.";
|
|
12
20
|
const msgMarketplaceSessionClosed = "Marketplace session is closed.";
|
|
13
21
|
const msgMarketplacePullInProgress = "A marketplace pull is already in progress.";
|
|
@@ -24,6 +32,35 @@ export class MarketplaceFX {
|
|
|
24
32
|
this.marketplace = opts.marketplace;
|
|
25
33
|
this.keep_alive_interval_ms = opts.keep_alive_interval_ms;
|
|
26
34
|
}
|
|
35
|
+
async createMarketplacePost(opts) {
|
|
36
|
+
const out = await this.marketplace.insertOneMarketplacePost(opts);
|
|
37
|
+
const id = requiredOperationID(out, msgCreatedMarketplacePostIDMissing);
|
|
38
|
+
return await this.findMarketplacePost(id);
|
|
39
|
+
}
|
|
40
|
+
async replaceMarketplacePost(opts) {
|
|
41
|
+
await this.marketplace.replaceOneMarketplacePost(opts);
|
|
42
|
+
return await this.findMarketplacePost(opts.id);
|
|
43
|
+
}
|
|
44
|
+
async searchMarketplacePosts(opts) {
|
|
45
|
+
return await runSearch({
|
|
46
|
+
search: (searchOpts) => this.marketplace.searchManyMarketplacePosts(searchOpts),
|
|
47
|
+
query: {
|
|
48
|
+
[OwnerIDKey]: opts.owner_id,
|
|
49
|
+
},
|
|
50
|
+
q: opts.q,
|
|
51
|
+
page: opts.page,
|
|
52
|
+
per_page: opts.per_page,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async createMarketplaceFavorite(opts) {
|
|
56
|
+
const out = await this.marketplace.insertOneMarketplaceFavorite(opts);
|
|
57
|
+
const id = requiredOperationID(out, msgCreatedMarketplaceFavoriteIDMissing);
|
|
58
|
+
return await this.findMarketplaceFavorite(id);
|
|
59
|
+
}
|
|
60
|
+
async replaceMarketplaceFavorite(opts) {
|
|
61
|
+
await this.marketplace.replaceOneMarketplaceFavorite(opts);
|
|
62
|
+
return await this.findMarketplaceFavorite(opts.id);
|
|
63
|
+
}
|
|
27
64
|
async startSession(opts) {
|
|
28
65
|
const { on_error, ...input } = opts;
|
|
29
66
|
const context = marketplaceSessionContext(input);
|
|
@@ -74,6 +111,32 @@ export class MarketplaceFX {
|
|
|
74
111
|
on_error: opts.on_error,
|
|
75
112
|
});
|
|
76
113
|
}
|
|
114
|
+
async findMarketplacePost(id) {
|
|
115
|
+
const out = await this.marketplace.findOneMarketplacePost({
|
|
116
|
+
id,
|
|
117
|
+
});
|
|
118
|
+
const post = out.value;
|
|
119
|
+
if (post === undefined) {
|
|
120
|
+
throw errResolveFailed({
|
|
121
|
+
resource: resourceMarketplacePost,
|
|
122
|
+
msg: msgMarketplacePostMissing,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return post;
|
|
126
|
+
}
|
|
127
|
+
async findMarketplaceFavorite(id) {
|
|
128
|
+
const out = await this.marketplace.findOneMarketplaceFavorite({
|
|
129
|
+
id,
|
|
130
|
+
});
|
|
131
|
+
const favorite = out.value;
|
|
132
|
+
if (favorite === undefined) {
|
|
133
|
+
throw errResolveFailed({
|
|
134
|
+
resource: resourceMarketplaceFavorite,
|
|
135
|
+
msg: msgMarketplaceFavoriteMissing,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return favorite;
|
|
139
|
+
}
|
|
77
140
|
}
|
|
78
141
|
export function newMarketplaceFX(opts) {
|
|
79
142
|
return new MarketplaceFX(opts);
|
package/dist/src/memos/memos.js
CHANGED
|
@@ -3,12 +3,11 @@
|
|
|
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 { OwnerIDKey
|
|
6
|
+
import { OwnerIDKey } from "@fabriktor/schema";
|
|
7
7
|
import { errResolveFailed } from "../core/err.js";
|
|
8
|
+
import { requiredOperationID } from "../core/id.js";
|
|
8
9
|
import { runSearch } from "../core/search.js";
|
|
9
|
-
const resourceMemoID = "memo_id";
|
|
10
10
|
const resourceMemo = "memo";
|
|
11
|
-
const resourceMemoFolderID = "memo_folder_id";
|
|
12
11
|
const resourceMemoFolder = "memo_folder";
|
|
13
12
|
const msgCreatedMemoIDMissing = "Created memo response did not contain an ID.";
|
|
14
13
|
const msgMemoMissing = "Memo could not be resolved after the mutation.";
|
|
@@ -21,10 +20,7 @@ export class MemosFX {
|
|
|
21
20
|
}
|
|
22
21
|
async createMemo(opts) {
|
|
23
22
|
const out = await this.memos.insertOneMemo(opts);
|
|
24
|
-
const id = requiredOperationID(out,
|
|
25
|
-
resource: resourceMemoID,
|
|
26
|
-
msg: msgCreatedMemoIDMissing,
|
|
27
|
-
});
|
|
23
|
+
const id = requiredOperationID(out, msgCreatedMemoIDMissing);
|
|
28
24
|
return await this.findMemo(id);
|
|
29
25
|
}
|
|
30
26
|
async replaceMemo(opts) {
|
|
@@ -33,10 +29,7 @@ export class MemosFX {
|
|
|
33
29
|
}
|
|
34
30
|
async createMemoFolder(opts) {
|
|
35
31
|
const out = await this.memos.insertOneMemoFolder(opts);
|
|
36
|
-
const id = requiredOperationID(out,
|
|
37
|
-
resource: resourceMemoFolderID,
|
|
38
|
-
msg: msgCreatedMemoFolderIDMissing,
|
|
39
|
-
});
|
|
32
|
+
const id = requiredOperationID(out, msgCreatedMemoFolderIDMissing);
|
|
40
33
|
return await this.findMemoFolder(id);
|
|
41
34
|
}
|
|
42
35
|
async replaceMemoFolder(opts) {
|
|
@@ -95,20 +88,3 @@ export class MemosFX {
|
|
|
95
88
|
export function newMemosFX(opts) {
|
|
96
89
|
return new MemosFX(opts);
|
|
97
90
|
}
|
|
98
|
-
function requiredOperationID(out, opts) {
|
|
99
|
-
const id = resolvedID(out.id);
|
|
100
|
-
if (id === undefined) {
|
|
101
|
-
throw errResolveFailed({
|
|
102
|
-
resource: opts.resource,
|
|
103
|
-
msg: opts.msg,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
return id;
|
|
107
|
-
}
|
|
108
|
-
function resolvedID(value) {
|
|
109
|
-
const id = value?.trim();
|
|
110
|
-
if (id === undefined || id === "" || id === ZeroID) {
|
|
111
|
-
return undefined;
|
|
112
|
-
}
|
|
113
|
-
return id;
|
|
114
|
-
}
|