@fabriktor/fx 0.0.34 → 0.0.36
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/fx.d.ts +5 -1
- package/dist/src/fx.js +11 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/memos/memos.d.ts +31 -0
- package/dist/src/memos/memos.js +91 -0
- package/package.json +1 -1
package/dist/src/fx.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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";
|
|
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";
|
|
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";
|
|
@@ -7,6 +7,7 @@ import type { ContactsFX, ContactsFXOperator } from "./contacts/contacts.js";
|
|
|
7
7
|
import type { FeedFX, FeedFXOperator } from "./feed/feed.js";
|
|
8
8
|
import type { JobsFX, JobsFXOperator } from "./jobs/jobs.js";
|
|
9
9
|
import type { MarketplaceFX, MarketplaceFXOperator } from "./marketplace/marketplace.js";
|
|
10
|
+
import type { MemosFX, MemosFXOperator } from "./memos/memos.js";
|
|
10
11
|
import type { DeviceTokenProvider, NotificationsFX, NotificationsFXOperator } from "./notifications/notifications.js";
|
|
11
12
|
import type { PaymentsFX, PaymentsFXOperator } from "./payments/payments.js";
|
|
12
13
|
import type { PayrollsFX, PayrollsFXOperator } from "./payrolls/payrolls.js";
|
|
@@ -27,6 +28,7 @@ export type FXOptions = {
|
|
|
27
28
|
feed: FeedOperator;
|
|
28
29
|
jobs: JobsOperator;
|
|
29
30
|
marketplace: MarketplaceOperator;
|
|
31
|
+
memos: MemosOperator;
|
|
30
32
|
notifications: NotificationsOperator;
|
|
31
33
|
payments: PaymentsOperator;
|
|
32
34
|
payrolls: PayrollsOperator;
|
|
@@ -57,6 +59,7 @@ export interface FXOperator {
|
|
|
57
59
|
feed: FeedFXOperator;
|
|
58
60
|
jobs: JobsFXOperator;
|
|
59
61
|
marketplace: MarketplaceFXOperator;
|
|
62
|
+
memos: MemosFXOperator;
|
|
60
63
|
notifications: NotificationsFXOperator;
|
|
61
64
|
payments: PaymentsFXOperator;
|
|
62
65
|
payrolls: PayrollsFXOperator;
|
|
@@ -76,6 +79,7 @@ export declare class FX implements FXOperator {
|
|
|
76
79
|
feed: FeedFX;
|
|
77
80
|
jobs: JobsFX;
|
|
78
81
|
marketplace: MarketplaceFX;
|
|
82
|
+
memos: MemosFX;
|
|
79
83
|
notifications: NotificationsFX;
|
|
80
84
|
payments: PaymentsFX;
|
|
81
85
|
payrolls: PayrollsFX;
|
package/dist/src/fx.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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, newNotificationsClient, newPaymentsClient, newPayrollsClient, newPreferencesClient, newPrivacyClient, newRoutesClient, newStorageClient, newTimesheetsClient, newTmpPhonesClient, newTmpUsernamesClient, newUsersClient, } from "@fabriktor/client";
|
|
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";
|
|
7
7
|
import { newBillableFX } from "./billable/billable.js";
|
|
8
8
|
import { newCallsFX } from "./calls/calls.js";
|
|
9
9
|
import { newChatFX } from "./chat/chat.js";
|
|
@@ -11,6 +11,7 @@ import { newContactsFX } from "./contacts/contacts.js";
|
|
|
11
11
|
import { newFeedFX } from "./feed/feed.js";
|
|
12
12
|
import { newJobsFX } from "./jobs/jobs.js";
|
|
13
13
|
import { newMarketplaceFX } from "./marketplace/marketplace.js";
|
|
14
|
+
import { newMemosFX } from "./memos/memos.js";
|
|
14
15
|
import { newNotificationsFX } from "./notifications/notifications.js";
|
|
15
16
|
import { newPaymentsFX } from "./payments/payments.js";
|
|
16
17
|
import { newPayrollsFX } from "./payrolls/payrolls.js";
|
|
@@ -29,6 +30,7 @@ export class FX {
|
|
|
29
30
|
feed;
|
|
30
31
|
jobs;
|
|
31
32
|
marketplace;
|
|
33
|
+
memos;
|
|
32
34
|
notifications;
|
|
33
35
|
payments;
|
|
34
36
|
payrolls;
|
|
@@ -56,6 +58,9 @@ export class FX {
|
|
|
56
58
|
this.jobs = newJobsFX({
|
|
57
59
|
jobs: opts.jobs,
|
|
58
60
|
});
|
|
61
|
+
this.memos = newMemosFX({
|
|
62
|
+
memos: opts.memos,
|
|
63
|
+
});
|
|
59
64
|
this.notifications = newNotificationsFX({
|
|
60
65
|
notifications: opts.notifications,
|
|
61
66
|
get_device_token: opts.get_device_token,
|
|
@@ -151,6 +156,11 @@ export function newDefaultFX(opts) {
|
|
|
151
156
|
base_url: opts.base_url,
|
|
152
157
|
get_token,
|
|
153
158
|
}),
|
|
159
|
+
memos: newMemosClient({
|
|
160
|
+
http,
|
|
161
|
+
base_url: opts.base_url,
|
|
162
|
+
get_token,
|
|
163
|
+
}),
|
|
154
164
|
notifications: newNotificationsClient({
|
|
155
165
|
http,
|
|
156
166
|
base_url: opts.base_url,
|
package/dist/src/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./feed/feed.js";
|
|
|
9
9
|
export * from "./fx.js";
|
|
10
10
|
export * from "./jobs/jobs.js";
|
|
11
11
|
export * from "./marketplace/marketplace.js";
|
|
12
|
+
export * from "./memos/memos.js";
|
|
12
13
|
export * from "./notifications/notifications.js";
|
|
13
14
|
export * from "./payments/payments.js";
|
|
14
15
|
export * from "./payrolls/payrolls.js";
|
package/dist/src/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./feed/feed.js";
|
|
|
9
9
|
export * from "./fx.js";
|
|
10
10
|
export * from "./jobs/jobs.js";
|
|
11
11
|
export * from "./marketplace/marketplace.js";
|
|
12
|
+
export * from "./memos/memos.js";
|
|
12
13
|
export * from "./notifications/notifications.js";
|
|
13
14
|
export * from "./payments/payments.js";
|
|
14
15
|
export * from "./payrolls/payrolls.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { MemosOperator } from "@fabriktor/client";
|
|
2
|
+
import { type Memo, type MemoFolder } from "@fabriktor/schema";
|
|
3
|
+
type MemoInsertOptions = Parameters<MemosOperator["insertOneMemo"]>[0];
|
|
4
|
+
type MemoReplaceOptions = Parameters<MemosOperator["replaceOneMemo"]>[0];
|
|
5
|
+
type MemoFolderInsertOptions = Parameters<MemosOperator["insertOneMemoFolder"]>[0];
|
|
6
|
+
type MemoFolderReplaceOptions = Parameters<MemosOperator["replaceOneMemoFolder"]>[0];
|
|
7
|
+
export type CreateMemoOptions = MemoInsertOptions;
|
|
8
|
+
export type ReplaceMemoOptions = MemoReplaceOptions;
|
|
9
|
+
export type CreateMemoFolderOptions = MemoFolderInsertOptions;
|
|
10
|
+
export type ReplaceMemoFolderOptions = MemoFolderReplaceOptions;
|
|
11
|
+
export interface MemosFXOperator {
|
|
12
|
+
createMemo(opts: CreateMemoOptions): Promise<Memo>;
|
|
13
|
+
replaceMemo(opts: ReplaceMemoOptions): Promise<Memo>;
|
|
14
|
+
createMemoFolder(opts: CreateMemoFolderOptions): Promise<MemoFolder>;
|
|
15
|
+
replaceMemoFolder(opts: ReplaceMemoFolderOptions): Promise<MemoFolder>;
|
|
16
|
+
}
|
|
17
|
+
export type MemosFXOptions = {
|
|
18
|
+
memos: MemosOperator;
|
|
19
|
+
};
|
|
20
|
+
export declare class MemosFX implements MemosFXOperator {
|
|
21
|
+
private memos;
|
|
22
|
+
constructor(opts: MemosFXOptions);
|
|
23
|
+
createMemo(opts: CreateMemoOptions): Promise<Memo>;
|
|
24
|
+
replaceMemo(opts: ReplaceMemoOptions): Promise<Memo>;
|
|
25
|
+
createMemoFolder(opts: CreateMemoFolderOptions): Promise<MemoFolder>;
|
|
26
|
+
replaceMemoFolder(opts: ReplaceMemoFolderOptions): Promise<MemoFolder>;
|
|
27
|
+
private findMemo;
|
|
28
|
+
private findMemoFolder;
|
|
29
|
+
}
|
|
30
|
+
export declare function newMemosFX(opts: MemosFXOptions): MemosFX;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
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 { ZeroID, } from "@fabriktor/schema";
|
|
7
|
+
import { errResolveFailed } from "../core/err.js";
|
|
8
|
+
const resourceMemoID = "memo_id";
|
|
9
|
+
const resourceMemo = "memo";
|
|
10
|
+
const resourceMemoFolderID = "memo_folder_id";
|
|
11
|
+
const resourceMemoFolder = "memo_folder";
|
|
12
|
+
const msgCreatedMemoIDMissing = "Created memo response did not contain an ID.";
|
|
13
|
+
const msgMemoMissing = "Memo could not be resolved after the mutation.";
|
|
14
|
+
const msgCreatedMemoFolderIDMissing = "Created memo folder response did not contain an ID.";
|
|
15
|
+
const msgMemoFolderMissing = "Memo folder could not be resolved after the mutation.";
|
|
16
|
+
export class MemosFX {
|
|
17
|
+
memos;
|
|
18
|
+
constructor(opts) {
|
|
19
|
+
this.memos = opts.memos;
|
|
20
|
+
}
|
|
21
|
+
async createMemo(opts) {
|
|
22
|
+
const out = await this.memos.insertOneMemo(opts);
|
|
23
|
+
const id = requiredOperationID(out, {
|
|
24
|
+
resource: resourceMemoID,
|
|
25
|
+
msg: msgCreatedMemoIDMissing,
|
|
26
|
+
});
|
|
27
|
+
return await this.findMemo(id);
|
|
28
|
+
}
|
|
29
|
+
async replaceMemo(opts) {
|
|
30
|
+
await this.memos.replaceOneMemo(opts);
|
|
31
|
+
return await this.findMemo(opts.id);
|
|
32
|
+
}
|
|
33
|
+
async createMemoFolder(opts) {
|
|
34
|
+
const out = await this.memos.insertOneMemoFolder(opts);
|
|
35
|
+
const id = requiredOperationID(out, {
|
|
36
|
+
resource: resourceMemoFolderID,
|
|
37
|
+
msg: msgCreatedMemoFolderIDMissing,
|
|
38
|
+
});
|
|
39
|
+
return await this.findMemoFolder(id);
|
|
40
|
+
}
|
|
41
|
+
async replaceMemoFolder(opts) {
|
|
42
|
+
await this.memos.replaceOneMemoFolder(opts);
|
|
43
|
+
return await this.findMemoFolder(opts.id);
|
|
44
|
+
}
|
|
45
|
+
async findMemo(id) {
|
|
46
|
+
const out = await this.memos.findOneMemo({
|
|
47
|
+
id,
|
|
48
|
+
});
|
|
49
|
+
const memo = out.value;
|
|
50
|
+
if (memo === undefined) {
|
|
51
|
+
throw errResolveFailed({
|
|
52
|
+
resource: resourceMemo,
|
|
53
|
+
msg: msgMemoMissing,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return memo;
|
|
57
|
+
}
|
|
58
|
+
async findMemoFolder(id) {
|
|
59
|
+
const out = await this.memos.findOneMemoFolder({
|
|
60
|
+
id,
|
|
61
|
+
});
|
|
62
|
+
const folder = out.value;
|
|
63
|
+
if (folder === undefined) {
|
|
64
|
+
throw errResolveFailed({
|
|
65
|
+
resource: resourceMemoFolder,
|
|
66
|
+
msg: msgMemoFolderMissing,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return folder;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export function newMemosFX(opts) {
|
|
73
|
+
return new MemosFX(opts);
|
|
74
|
+
}
|
|
75
|
+
function requiredOperationID(out, opts) {
|
|
76
|
+
const id = resolvedID(out.id);
|
|
77
|
+
if (id === undefined) {
|
|
78
|
+
throw errResolveFailed({
|
|
79
|
+
resource: opts.resource,
|
|
80
|
+
msg: opts.msg,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return id;
|
|
84
|
+
}
|
|
85
|
+
function resolvedID(value) {
|
|
86
|
+
const id = value?.trim();
|
|
87
|
+
if (id === undefined || id === "" || id === ZeroID) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
return id;
|
|
91
|
+
}
|