@fabriktor/fx 0.0.65 → 0.0.66
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 +12 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/preferences/preferences.d.ts +12 -0
- package/dist/src/preferences/preferences.js +35 -5
- package/dist/src/processes/processes.d.ts +27 -0
- package/dist/src/processes/processes.js +38 -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, FulfillmentsOperator, 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, ProcessesOperator, 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";
|
|
@@ -14,6 +14,7 @@ import type { PaymentsFX, PaymentsFXOperator } from "./payments/payments.js";
|
|
|
14
14
|
import type { PayrollsFX, PayrollsFXOperator } from "./payrolls/payrolls.js";
|
|
15
15
|
import type { PreferencesFX, PreferencesFXOperator } from "./preferences/preferences.js";
|
|
16
16
|
import type { PrivacyFX, PrivacyFXOperator } from "./privacy/privacy.js";
|
|
17
|
+
import type { ProcessesFX, ProcessesFXOperator } from "./processes/processes.js";
|
|
17
18
|
import type { RoutesFX, RoutesFXOperator } from "./routes/routes.js";
|
|
18
19
|
import type { SessionFX, SessionFXOperator } from "./session/session.js";
|
|
19
20
|
import type { StorageFX, StorageFXOperator } from "./storage/storage.js";
|
|
@@ -36,6 +37,7 @@ export type FXOptions = {
|
|
|
36
37
|
payrolls: PayrollsOperator;
|
|
37
38
|
preferences: PreferencesOperator;
|
|
38
39
|
privacy: PrivacyOperator;
|
|
40
|
+
processes: ProcessesOperator;
|
|
39
41
|
routes: RoutesOperator;
|
|
40
42
|
storage: StorageOperator;
|
|
41
43
|
timesheets: TimesheetsOperator;
|
|
@@ -68,6 +70,7 @@ export interface FXOperator {
|
|
|
68
70
|
payrolls: PayrollsFXOperator;
|
|
69
71
|
preferences: PreferencesFXOperator;
|
|
70
72
|
privacy: PrivacyFXOperator;
|
|
73
|
+
processes: ProcessesFXOperator;
|
|
71
74
|
routes: RoutesFXOperator;
|
|
72
75
|
session: SessionFXOperator;
|
|
73
76
|
storage: StorageFXOperator;
|
|
@@ -89,6 +92,7 @@ export declare class FX implements FXOperator {
|
|
|
89
92
|
payrolls: PayrollsFX;
|
|
90
93
|
preferences: PreferencesFX;
|
|
91
94
|
privacy: PrivacyFX;
|
|
95
|
+
processes: ProcessesFX;
|
|
92
96
|
routes: RoutesFX;
|
|
93
97
|
session: SessionFX;
|
|
94
98
|
storage: StorageFX;
|
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, newFulfillmentsClient, 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, newProcessesClient, 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";
|
|
@@ -18,6 +18,7 @@ import { newPaymentsFX } from "./payments/payments.js";
|
|
|
18
18
|
import { newPayrollsFX } from "./payrolls/payrolls.js";
|
|
19
19
|
import { newPreferencesFX } from "./preferences/preferences.js";
|
|
20
20
|
import { newPrivacyFX } from "./privacy/privacy.js";
|
|
21
|
+
import { newProcessesFX } from "./processes/processes.js";
|
|
21
22
|
import { newRoutesFX } from "./routes/routes.js";
|
|
22
23
|
import { newSessionFX } from "./session/session.js";
|
|
23
24
|
import { newStorageFX } from "./storage/storage.js";
|
|
@@ -38,6 +39,7 @@ export class FX {
|
|
|
38
39
|
payrolls;
|
|
39
40
|
preferences;
|
|
40
41
|
privacy;
|
|
42
|
+
processes;
|
|
41
43
|
routes;
|
|
42
44
|
session;
|
|
43
45
|
storage;
|
|
@@ -83,6 +85,10 @@ export class FX {
|
|
|
83
85
|
this.privacy = newPrivacyFX({
|
|
84
86
|
privacy: opts.privacy,
|
|
85
87
|
});
|
|
88
|
+
this.processes = newProcessesFX({
|
|
89
|
+
processes: opts.processes,
|
|
90
|
+
preferences_fx: this.preferences,
|
|
91
|
+
});
|
|
86
92
|
this.routes = newRoutesFX({
|
|
87
93
|
routes: opts.routes,
|
|
88
94
|
});
|
|
@@ -197,6 +203,11 @@ export function newDefaultFX(opts) {
|
|
|
197
203
|
base_url: opts.base_url,
|
|
198
204
|
get_token,
|
|
199
205
|
}),
|
|
206
|
+
processes: newProcessesClient({
|
|
207
|
+
http,
|
|
208
|
+
base_url: opts.base_url,
|
|
209
|
+
get_token,
|
|
210
|
+
}),
|
|
200
211
|
routes: newRoutesClient({
|
|
201
212
|
http,
|
|
202
213
|
base_url: opts.base_url,
|
package/dist/src/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./payments/payments.js";
|
|
|
18
18
|
export * from "./payrolls/payrolls.js";
|
|
19
19
|
export * from "./preferences/preferences.js";
|
|
20
20
|
export * from "./privacy/privacy.js";
|
|
21
|
+
export * from "./processes/processes.js";
|
|
21
22
|
export * from "./routes/routes.js";
|
|
22
23
|
export * from "./session/session.js";
|
|
23
24
|
export * from "./storage/storage.js";
|
package/dist/src/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./payments/payments.js";
|
|
|
18
18
|
export * from "./payrolls/payrolls.js";
|
|
19
19
|
export * from "./preferences/preferences.js";
|
|
20
20
|
export * from "./privacy/privacy.js";
|
|
21
|
+
export * from "./processes/processes.js";
|
|
21
22
|
export * from "./routes/routes.js";
|
|
22
23
|
export * from "./session/session.js";
|
|
23
24
|
export * from "./storage/storage.js";
|
|
@@ -36,12 +36,19 @@ export type CreatePrefEmailOptions = PrefEmailInsertOptions;
|
|
|
36
36
|
export type ReplacePrefEmailOptions = PrefEmailReplaceOptions;
|
|
37
37
|
export type CreatePrefTutorialOptions = PrefTutorialInsertOptions;
|
|
38
38
|
export type ReplacePrefTutorialOptions = PrefTutorialReplaceOptions;
|
|
39
|
+
export type GetPrefLanguageOptions = {
|
|
40
|
+
owner_id: string;
|
|
41
|
+
};
|
|
39
42
|
export type EnsurePrefLanguageOptions = {
|
|
40
43
|
owner_id: string;
|
|
41
44
|
language: string;
|
|
42
45
|
country: string;
|
|
43
46
|
speech_to_text_source_language?: string;
|
|
44
47
|
};
|
|
48
|
+
export type SaveSpeechToTextSourceLanguageOptions = {
|
|
49
|
+
owner_id: string;
|
|
50
|
+
speech_to_text_source_language: string;
|
|
51
|
+
};
|
|
45
52
|
export interface PreferencesFXOperator {
|
|
46
53
|
createPrefPayment(opts: CreatePrefPaymentOptions): Promise<PrefPayment>;
|
|
47
54
|
replacePrefPayment(opts: ReplacePrefPaymentOptions): Promise<PrefPayment>;
|
|
@@ -55,6 +62,8 @@ export interface PreferencesFXOperator {
|
|
|
55
62
|
replacePrefVisibility(opts: ReplacePrefVisibilityOptions): Promise<PrefVisibility>;
|
|
56
63
|
createPrefLanguage(opts: CreatePrefLanguageOptions): Promise<PrefLanguage>;
|
|
57
64
|
replacePrefLanguage(opts: ReplacePrefLanguageOptions): Promise<PrefLanguage>;
|
|
65
|
+
getPrefLanguage(opts: GetPrefLanguageOptions): Promise<PrefLanguage>;
|
|
66
|
+
saveSpeechToTextSourceLanguage(opts: SaveSpeechToTextSourceLanguageOptions): Promise<PrefLanguage>;
|
|
58
67
|
createPrefNotif(opts: CreatePrefNotifOptions): Promise<PrefNotif>;
|
|
59
68
|
replacePrefNotif(opts: ReplacePrefNotifOptions): Promise<PrefNotif>;
|
|
60
69
|
createPrefEmail(opts: CreatePrefEmailOptions): Promise<PrefEmail>;
|
|
@@ -81,6 +90,8 @@ export declare class PreferencesFX implements PreferencesFXOperator {
|
|
|
81
90
|
replacePrefVisibility(opts: ReplacePrefVisibilityOptions): Promise<PrefVisibility>;
|
|
82
91
|
createPrefLanguage(opts: CreatePrefLanguageOptions): Promise<PrefLanguage>;
|
|
83
92
|
replacePrefLanguage(opts: ReplacePrefLanguageOptions): Promise<PrefLanguage>;
|
|
93
|
+
getPrefLanguage(opts: GetPrefLanguageOptions): Promise<PrefLanguage>;
|
|
94
|
+
saveSpeechToTextSourceLanguage(opts: SaveSpeechToTextSourceLanguageOptions): Promise<PrefLanguage>;
|
|
84
95
|
createPrefNotif(opts: CreatePrefNotifOptions): Promise<PrefNotif>;
|
|
85
96
|
replacePrefNotif(opts: ReplacePrefNotifOptions): Promise<PrefNotif>;
|
|
86
97
|
createPrefEmail(opts: CreatePrefEmailOptions): Promise<PrefEmail>;
|
|
@@ -88,6 +99,7 @@ export declare class PreferencesFX implements PreferencesFXOperator {
|
|
|
88
99
|
createPrefTutorial(opts: CreatePrefTutorialOptions): Promise<PrefTutorial>;
|
|
89
100
|
replacePrefTutorial(opts: ReplacePrefTutorialOptions): Promise<PrefTutorial>;
|
|
90
101
|
ensurePrefLanguage(opts: EnsurePrefLanguageOptions): Promise<OperationResult>;
|
|
102
|
+
private queryPrefLanguage;
|
|
91
103
|
private findPrefPayment;
|
|
92
104
|
private findPrefClient;
|
|
93
105
|
private findPrefEmployee;
|
|
@@ -4,6 +4,7 @@
|
|
|
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
6
|
import { queryParam } from "@fabriktor/client";
|
|
7
|
+
import { OwnerIDKey, } from "@fabriktor/schema";
|
|
7
8
|
import { errResolveFailed } from "../core/err.js";
|
|
8
9
|
import { requiredOperationID } from "../core/id.js";
|
|
9
10
|
const resourcePrefPayment = "pref_payment";
|
|
@@ -92,6 +93,33 @@ export class PreferencesFX {
|
|
|
92
93
|
await this.preferences.replaceOnePrefLanguage(opts);
|
|
93
94
|
return await this.findPrefLanguage(opts.id);
|
|
94
95
|
}
|
|
96
|
+
async getPrefLanguage(opts) {
|
|
97
|
+
const pref_language = await this.queryPrefLanguage(opts.owner_id);
|
|
98
|
+
if (pref_language === undefined) {
|
|
99
|
+
throw errResolveFailed({
|
|
100
|
+
resource: resourcePrefLanguage,
|
|
101
|
+
msg: msgPrefLanguageMissing,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return pref_language;
|
|
105
|
+
}
|
|
106
|
+
async saveSpeechToTextSourceLanguage(opts) {
|
|
107
|
+
const pref = await this.getPrefLanguage({ owner_id: opts.owner_id });
|
|
108
|
+
if (!pref.is_default &&
|
|
109
|
+
pref.speech_to_text_source_language === opts.speech_to_text_source_language) {
|
|
110
|
+
return pref;
|
|
111
|
+
}
|
|
112
|
+
const input = {
|
|
113
|
+
is_default: false,
|
|
114
|
+
country: pref.country,
|
|
115
|
+
language: pref.language,
|
|
116
|
+
speech_to_text_source_language: opts.speech_to_text_source_language,
|
|
117
|
+
};
|
|
118
|
+
if (pref.is_default) {
|
|
119
|
+
return await this.createPrefLanguage({ in: input });
|
|
120
|
+
}
|
|
121
|
+
return await this.replacePrefLanguage({ id: pref.id, in: input });
|
|
122
|
+
}
|
|
95
123
|
async createPrefNotif(opts) {
|
|
96
124
|
const out = await this.preferences.insertOnePrefNotif(opts);
|
|
97
125
|
const id = requiredOperationID(out, msgCreatedPrefNotifIDMissing);
|
|
@@ -120,11 +148,7 @@ export class PreferencesFX {
|
|
|
120
148
|
return await this.findPrefTutorial(opts.id);
|
|
121
149
|
}
|
|
122
150
|
async ensurePrefLanguage(opts) {
|
|
123
|
-
const
|
|
124
|
-
query: queryParam("owner_id", opts.owner_id),
|
|
125
|
-
});
|
|
126
|
-
const prefs = out.value ?? [];
|
|
127
|
-
const pref = prefs[0];
|
|
151
|
+
const pref = await this.queryPrefLanguage(opts.owner_id);
|
|
128
152
|
const input = {
|
|
129
153
|
is_default: false,
|
|
130
154
|
language: opts.language,
|
|
@@ -150,6 +174,12 @@ export class PreferencesFX {
|
|
|
150
174
|
in: input,
|
|
151
175
|
});
|
|
152
176
|
}
|
|
177
|
+
async queryPrefLanguage(owner_id) {
|
|
178
|
+
const out = await this.preferences.queryPrefLanguages({
|
|
179
|
+
query: queryParam(OwnerIDKey, owner_id),
|
|
180
|
+
});
|
|
181
|
+
return out.value?.[0];
|
|
182
|
+
}
|
|
153
183
|
async findPrefPayment(id) {
|
|
154
184
|
const out = await this.preferences.findOnePrefPayment({
|
|
155
185
|
id,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ProcessesOperator, SpeechToTextOptions } from "@fabriktor/client";
|
|
2
|
+
import type { PrefLanguage } from "@fabriktor/schema";
|
|
3
|
+
import type { PreferencesFXOperator } from "../preferences/preferences.js";
|
|
4
|
+
export type SpeechToTextAndSaveSourceLanguageOptions = {
|
|
5
|
+
owner_id: string;
|
|
6
|
+
speech_to_text: SpeechToTextOptions;
|
|
7
|
+
};
|
|
8
|
+
export type SpeechToTextAndSaveSourceLanguageResult = {
|
|
9
|
+
transcription: string;
|
|
10
|
+
preference: PrefLanguage;
|
|
11
|
+
};
|
|
12
|
+
export type ProcessesFXOptions = {
|
|
13
|
+
processes: ProcessesOperator;
|
|
14
|
+
preferences_fx: PreferencesFXOperator;
|
|
15
|
+
};
|
|
16
|
+
export interface ProcessesFXOperator {
|
|
17
|
+
speechToText(opts: SpeechToTextOptions): Promise<string>;
|
|
18
|
+
speechToTextAndSaveSourceLanguage(opts: SpeechToTextAndSaveSourceLanguageOptions): Promise<SpeechToTextAndSaveSourceLanguageResult>;
|
|
19
|
+
}
|
|
20
|
+
export declare class ProcessesFX implements ProcessesFXOperator {
|
|
21
|
+
private processes;
|
|
22
|
+
private preferences_fx;
|
|
23
|
+
constructor(opts: ProcessesFXOptions);
|
|
24
|
+
speechToText(opts: SpeechToTextOptions): Promise<string>;
|
|
25
|
+
speechToTextAndSaveSourceLanguage(opts: SpeechToTextAndSaveSourceLanguageOptions): Promise<SpeechToTextAndSaveSourceLanguageResult>;
|
|
26
|
+
}
|
|
27
|
+
export declare function newProcessesFX(opts: ProcessesFXOptions): ProcessesFX;
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { errResolveFailed } from "../core/err.js";
|
|
7
|
+
const resourceSpeechToTextTranscription = "speech_to_text_transcription";
|
|
8
|
+
const msgSpeechToTextTranscriptionMissing = "Speech-to-text response did not include a transcription.";
|
|
9
|
+
export class ProcessesFX {
|
|
10
|
+
processes;
|
|
11
|
+
preferences_fx;
|
|
12
|
+
constructor(opts) {
|
|
13
|
+
this.processes = opts.processes;
|
|
14
|
+
this.preferences_fx = opts.preferences_fx;
|
|
15
|
+
}
|
|
16
|
+
async speechToText(opts) {
|
|
17
|
+
const out = await this.processes.speechToText(opts);
|
|
18
|
+
const transcription = out.value?.transcriptions.at(0)?.text.trim() ?? "";
|
|
19
|
+
if (transcription === "") {
|
|
20
|
+
throw errResolveFailed({
|
|
21
|
+
resource: resourceSpeechToTextTranscription,
|
|
22
|
+
msg: msgSpeechToTextTranscriptionMissing,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return transcription;
|
|
26
|
+
}
|
|
27
|
+
async speechToTextAndSaveSourceLanguage(opts) {
|
|
28
|
+
const preference = await this.preferences_fx.saveSpeechToTextSourceLanguage({
|
|
29
|
+
owner_id: opts.owner_id,
|
|
30
|
+
speech_to_text_source_language: opts.speech_to_text.audio_locale,
|
|
31
|
+
});
|
|
32
|
+
const transcription = await this.speechToText(opts.speech_to_text);
|
|
33
|
+
return { transcription, preference };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function newProcessesFX(opts) {
|
|
37
|
+
return new ProcessesFX(opts);
|
|
38
|
+
}
|