@fabriktor/client 0.0.28 → 0.0.29
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 +213 -0
- package/dist/src/billable/billable.js +441 -0
- package/dist/src/calls/calls.d.ts +34 -0
- package/dist/src/calls/calls.js +65 -0
- package/dist/src/chat/chat.d.ts +97 -0
- package/dist/src/chat/chat.js +234 -0
- package/dist/src/contacts/contacts.d.ts +37 -0
- package/dist/src/contacts/contacts.js +94 -0
- package/dist/src/core/crud.d.ts +1 -1
- package/dist/src/core/crud.js +1 -1
- package/dist/src/core/http.d.ts +3 -0
- package/dist/src/core/http.js +3 -3
- package/dist/src/core/idempotency.js +1 -1
- package/dist/src/core/multipart.d.ts +25 -0
- package/dist/src/core/multipart.js +93 -0
- package/dist/src/feed/feed.d.ts +65 -0
- package/dist/src/feed/feed.js +130 -0
- package/dist/src/fulfillments/fulfillments.d.ts +36 -0
- package/dist/src/fulfillments/fulfillments.js +68 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +14 -0
- package/dist/src/jobs/jobs.d.ts +69 -0
- package/dist/src/jobs/jobs.js +143 -0
- package/dist/src/marketplace/marketplace.d.ts +49 -0
- package/dist/src/marketplace/marketplace.js +94 -0
- package/dist/src/payments/payments.d.ts +154 -0
- package/dist/src/payments/payments.js +328 -0
- package/dist/src/payrolls/payrolls.d.ts +179 -0
- package/dist/src/payrolls/payrolls.js +380 -0
- package/dist/src/processes/processes.d.ts +3 -3
- package/dist/src/routes/routes.d.ts +93 -0
- package/dist/src/routes/routes.js +185 -0
- package/dist/src/storage/storage.d.ts +124 -0
- package/dist/src/storage/storage.js +249 -0
- package/dist/src/timesheets/timesheets.d.ts +49 -0
- package/dist/src/timesheets/timesheets.js +105 -0
- package/dist/src/users/tmp_phones.d.ts +1 -1
- package/dist/src/users/tmp_usernames.d.ts +1 -1
- package/dist/src/users/users.d.ts +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { type ClientAvailability, type InClientAvailability, type InRoute, type InRouteTeam, type InTag, type InTracking, type OperationResult, type PLRoutesAvailability, type PLRoutesDesignation, type Route, type RouteTeam, type RPRoutesAvailability, type Tag, type Tracking } from "@fabriktor/schema";
|
|
2
|
+
import type { TokenProvider } from "../core/auth.js";
|
|
3
|
+
import type { DeleteManyOptionsCRUD, DeleteOneOptionsCRUD, FindOneOptionsCRUD, InsertOneOptionsCRUD, OperationResultOf, QueryOptionsCRUD, ReplaceOneOptionsCRUD, SearchManyOptionsCRUD, SearchResultOf } from "../core/crud.js";
|
|
4
|
+
import type { HTTPDoer } from "../core/http.js";
|
|
5
|
+
export type GetAvailabilityOptions = PLRoutesAvailability;
|
|
6
|
+
export type GetDesignationOptions = PLRoutesDesignation;
|
|
7
|
+
export type RoutesClientOptions = {
|
|
8
|
+
http: HTTPDoer;
|
|
9
|
+
base_url: string;
|
|
10
|
+
get_token?: TokenProvider;
|
|
11
|
+
};
|
|
12
|
+
export interface RoutesOperator {
|
|
13
|
+
queryRoutes(opts?: QueryOptionsCRUD): Promise<OperationResultOf<Route[]>>;
|
|
14
|
+
insertOneRoute(opts: InsertOneOptionsCRUD<InRoute>): Promise<OperationResult>;
|
|
15
|
+
findOneRoute(opts: FindOneOptionsCRUD): Promise<OperationResultOf<Route>>;
|
|
16
|
+
replaceOneRoute(opts: ReplaceOneOptionsCRUD<InRoute>): Promise<OperationResult>;
|
|
17
|
+
deleteOneRoute(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
18
|
+
deleteManyRoutes(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
19
|
+
queryTags(opts?: QueryOptionsCRUD): Promise<OperationResultOf<Tag[]>>;
|
|
20
|
+
insertOneTag(opts: InsertOneOptionsCRUD<InTag>): Promise<OperationResult>;
|
|
21
|
+
findOneTag(opts: FindOneOptionsCRUD): Promise<OperationResultOf<Tag>>;
|
|
22
|
+
replaceOneTag(opts: ReplaceOneOptionsCRUD<InTag>): Promise<OperationResult>;
|
|
23
|
+
deleteOneTag(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
24
|
+
deleteManyTags(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
25
|
+
searchManyTags(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<Tag>>>;
|
|
26
|
+
queryClientAvailabilities(opts?: QueryOptionsCRUD): Promise<OperationResultOf<ClientAvailability[]>>;
|
|
27
|
+
insertOneClientAvailability(opts: InsertOneOptionsCRUD<InClientAvailability>): Promise<OperationResult>;
|
|
28
|
+
findOneClientAvailability(opts: FindOneOptionsCRUD): Promise<OperationResultOf<ClientAvailability>>;
|
|
29
|
+
replaceOneClientAvailability(opts: ReplaceOneOptionsCRUD<InClientAvailability>): Promise<OperationResult>;
|
|
30
|
+
deleteOneClientAvailability(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
31
|
+
deleteManyClientAvailabilities(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
32
|
+
queryTracking(opts?: QueryOptionsCRUD): Promise<OperationResultOf<Tracking[]>>;
|
|
33
|
+
insertOneTracking(opts: InsertOneOptionsCRUD<InTracking>): Promise<OperationResult>;
|
|
34
|
+
findOneTracking(opts: FindOneOptionsCRUD): Promise<OperationResultOf<Tracking>>;
|
|
35
|
+
replaceOneTracking(opts: ReplaceOneOptionsCRUD<InTracking>): Promise<OperationResult>;
|
|
36
|
+
deleteOneTracking(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
37
|
+
deleteManyTracking(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
38
|
+
queryRouteTeams(opts?: QueryOptionsCRUD): Promise<OperationResultOf<RouteTeam[]>>;
|
|
39
|
+
insertOneRouteTeam(opts: InsertOneOptionsCRUD<InRouteTeam>): Promise<OperationResult>;
|
|
40
|
+
findOneRouteTeam(opts: FindOneOptionsCRUD): Promise<OperationResultOf<RouteTeam>>;
|
|
41
|
+
replaceOneRouteTeam(opts: ReplaceOneOptionsCRUD<InRouteTeam>): Promise<OperationResult>;
|
|
42
|
+
deleteOneRouteTeam(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
43
|
+
deleteManyRouteTeams(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
44
|
+
searchManyRouteTeams(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<RouteTeam>>>;
|
|
45
|
+
getAvailability(opts: GetAvailabilityOptions): Promise<OperationResultOf<RPRoutesAvailability>>;
|
|
46
|
+
getDesignation(opts: GetDesignationOptions): Promise<OperationResultOf<Route[]>>;
|
|
47
|
+
}
|
|
48
|
+
export declare class RoutesClient implements RoutesOperator {
|
|
49
|
+
private routes;
|
|
50
|
+
private tags;
|
|
51
|
+
private client_availabilities;
|
|
52
|
+
private tracking;
|
|
53
|
+
private route_teams;
|
|
54
|
+
private http;
|
|
55
|
+
private base_url;
|
|
56
|
+
private get_token?;
|
|
57
|
+
constructor(opts: RoutesClientOptions);
|
|
58
|
+
queryRoutes(opts?: QueryOptionsCRUD): Promise<OperationResultOf<Route[]>>;
|
|
59
|
+
insertOneRoute(opts: InsertOneOptionsCRUD<InRoute>): Promise<OperationResult>;
|
|
60
|
+
findOneRoute(opts: FindOneOptionsCRUD): Promise<OperationResultOf<Route>>;
|
|
61
|
+
replaceOneRoute(opts: ReplaceOneOptionsCRUD<InRoute>): Promise<OperationResult>;
|
|
62
|
+
deleteOneRoute(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
63
|
+
deleteManyRoutes(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
64
|
+
queryTags(opts?: QueryOptionsCRUD): Promise<OperationResultOf<Tag[]>>;
|
|
65
|
+
insertOneTag(opts: InsertOneOptionsCRUD<InTag>): Promise<OperationResult>;
|
|
66
|
+
findOneTag(opts: FindOneOptionsCRUD): Promise<OperationResultOf<Tag>>;
|
|
67
|
+
replaceOneTag(opts: ReplaceOneOptionsCRUD<InTag>): Promise<OperationResult>;
|
|
68
|
+
deleteOneTag(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
69
|
+
deleteManyTags(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
70
|
+
searchManyTags(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<Tag>>>;
|
|
71
|
+
queryClientAvailabilities(opts?: QueryOptionsCRUD): Promise<OperationResultOf<ClientAvailability[]>>;
|
|
72
|
+
insertOneClientAvailability(opts: InsertOneOptionsCRUD<InClientAvailability>): Promise<OperationResult>;
|
|
73
|
+
findOneClientAvailability(opts: FindOneOptionsCRUD): Promise<OperationResultOf<ClientAvailability>>;
|
|
74
|
+
replaceOneClientAvailability(opts: ReplaceOneOptionsCRUD<InClientAvailability>): Promise<OperationResult>;
|
|
75
|
+
deleteOneClientAvailability(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
76
|
+
deleteManyClientAvailabilities(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
77
|
+
queryTracking(opts?: QueryOptionsCRUD): Promise<OperationResultOf<Tracking[]>>;
|
|
78
|
+
insertOneTracking(opts: InsertOneOptionsCRUD<InTracking>): Promise<OperationResult>;
|
|
79
|
+
findOneTracking(opts: FindOneOptionsCRUD): Promise<OperationResultOf<Tracking>>;
|
|
80
|
+
replaceOneTracking(opts: ReplaceOneOptionsCRUD<InTracking>): Promise<OperationResult>;
|
|
81
|
+
deleteOneTracking(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
82
|
+
deleteManyTracking(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
83
|
+
queryRouteTeams(opts?: QueryOptionsCRUD): Promise<OperationResultOf<RouteTeam[]>>;
|
|
84
|
+
insertOneRouteTeam(opts: InsertOneOptionsCRUD<InRouteTeam>): Promise<OperationResult>;
|
|
85
|
+
findOneRouteTeam(opts: FindOneOptionsCRUD): Promise<OperationResultOf<RouteTeam>>;
|
|
86
|
+
replaceOneRouteTeam(opts: ReplaceOneOptionsCRUD<InRouteTeam>): Promise<OperationResult>;
|
|
87
|
+
deleteOneRouteTeam(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
88
|
+
deleteManyRouteTeams(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
89
|
+
searchManyRouteTeams(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<RouteTeam>>>;
|
|
90
|
+
getAvailability(opts: GetAvailabilityOptions): Promise<OperationResultOf<RPRoutesAvailability>>;
|
|
91
|
+
getDesignation(opts: GetDesignationOptions): Promise<OperationResultOf<Route[]>>;
|
|
92
|
+
}
|
|
93
|
+
export declare function newRoutesClient(opts: RoutesClientOptions): RoutesClient;
|
|
@@ -0,0 +1,185 @@
|
|
|
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 { ColRoutesClientAvailabilities, ColRoutesRouteTeams, ColRoutesRoutes, ColRoutesTags, ColRoutesTracking, HTTPMethodPost, PathRoutesGetAvailability, PathRoutesGetDesignation, SvcRoutes, } from "@fabriktor/schema";
|
|
7
|
+
import { requiredToken } from "../core/auth.js";
|
|
8
|
+
import { newCRUDClient } from "../core/crud.js";
|
|
9
|
+
import { buildPath } from "../core/path.js";
|
|
10
|
+
export class RoutesClient {
|
|
11
|
+
routes;
|
|
12
|
+
tags;
|
|
13
|
+
client_availabilities;
|
|
14
|
+
tracking;
|
|
15
|
+
route_teams;
|
|
16
|
+
http;
|
|
17
|
+
base_url;
|
|
18
|
+
get_token;
|
|
19
|
+
constructor(opts) {
|
|
20
|
+
this.routes = newCRUDClient({
|
|
21
|
+
http: opts.http,
|
|
22
|
+
base_url: opts.base_url,
|
|
23
|
+
svc: SvcRoutes,
|
|
24
|
+
col: ColRoutesRoutes,
|
|
25
|
+
get_token: opts.get_token,
|
|
26
|
+
});
|
|
27
|
+
this.tags = newCRUDClient({
|
|
28
|
+
http: opts.http,
|
|
29
|
+
base_url: opts.base_url,
|
|
30
|
+
svc: SvcRoutes,
|
|
31
|
+
col: ColRoutesTags,
|
|
32
|
+
get_token: opts.get_token,
|
|
33
|
+
});
|
|
34
|
+
this.client_availabilities = newCRUDClient({
|
|
35
|
+
http: opts.http,
|
|
36
|
+
base_url: opts.base_url,
|
|
37
|
+
svc: SvcRoutes,
|
|
38
|
+
col: ColRoutesClientAvailabilities,
|
|
39
|
+
get_token: opts.get_token,
|
|
40
|
+
});
|
|
41
|
+
this.tracking = newCRUDClient({
|
|
42
|
+
http: opts.http,
|
|
43
|
+
base_url: opts.base_url,
|
|
44
|
+
svc: SvcRoutes,
|
|
45
|
+
col: ColRoutesTracking,
|
|
46
|
+
get_token: opts.get_token,
|
|
47
|
+
});
|
|
48
|
+
this.route_teams = newCRUDClient({
|
|
49
|
+
http: opts.http,
|
|
50
|
+
base_url: opts.base_url,
|
|
51
|
+
svc: SvcRoutes,
|
|
52
|
+
col: ColRoutesRouteTeams,
|
|
53
|
+
get_token: opts.get_token,
|
|
54
|
+
});
|
|
55
|
+
this.http = opts.http;
|
|
56
|
+
this.base_url = opts.base_url;
|
|
57
|
+
this.get_token = opts.get_token;
|
|
58
|
+
}
|
|
59
|
+
async queryRoutes(opts) {
|
|
60
|
+
return await this.routes.query(opts);
|
|
61
|
+
}
|
|
62
|
+
async insertOneRoute(opts) {
|
|
63
|
+
return await this.routes.insertOne(opts);
|
|
64
|
+
}
|
|
65
|
+
async findOneRoute(opts) {
|
|
66
|
+
return await this.routes.findOne(opts);
|
|
67
|
+
}
|
|
68
|
+
async replaceOneRoute(opts) {
|
|
69
|
+
return await this.routes.replaceOne(opts);
|
|
70
|
+
}
|
|
71
|
+
async deleteOneRoute(opts) {
|
|
72
|
+
return await this.routes.deleteOne(opts);
|
|
73
|
+
}
|
|
74
|
+
async deleteManyRoutes(opts) {
|
|
75
|
+
return await this.routes.deleteMany(opts);
|
|
76
|
+
}
|
|
77
|
+
async queryTags(opts) {
|
|
78
|
+
return await this.tags.query(opts);
|
|
79
|
+
}
|
|
80
|
+
async insertOneTag(opts) {
|
|
81
|
+
return await this.tags.insertOne(opts);
|
|
82
|
+
}
|
|
83
|
+
async findOneTag(opts) {
|
|
84
|
+
return await this.tags.findOne(opts);
|
|
85
|
+
}
|
|
86
|
+
async replaceOneTag(opts) {
|
|
87
|
+
return await this.tags.replaceOne(opts);
|
|
88
|
+
}
|
|
89
|
+
async deleteOneTag(opts) {
|
|
90
|
+
return await this.tags.deleteOne(opts);
|
|
91
|
+
}
|
|
92
|
+
async deleteManyTags(opts) {
|
|
93
|
+
return await this.tags.deleteMany(opts);
|
|
94
|
+
}
|
|
95
|
+
async searchManyTags(opts) {
|
|
96
|
+
return await this.tags.searchMany(opts);
|
|
97
|
+
}
|
|
98
|
+
async queryClientAvailabilities(opts) {
|
|
99
|
+
return await this.client_availabilities.query(opts);
|
|
100
|
+
}
|
|
101
|
+
async insertOneClientAvailability(opts) {
|
|
102
|
+
return await this.client_availabilities.insertOne(opts);
|
|
103
|
+
}
|
|
104
|
+
async findOneClientAvailability(opts) {
|
|
105
|
+
return await this.client_availabilities.findOne(opts);
|
|
106
|
+
}
|
|
107
|
+
async replaceOneClientAvailability(opts) {
|
|
108
|
+
return await this.client_availabilities.replaceOne(opts);
|
|
109
|
+
}
|
|
110
|
+
async deleteOneClientAvailability(opts) {
|
|
111
|
+
return await this.client_availabilities.deleteOne(opts);
|
|
112
|
+
}
|
|
113
|
+
async deleteManyClientAvailabilities(opts) {
|
|
114
|
+
return await this.client_availabilities.deleteMany(opts);
|
|
115
|
+
}
|
|
116
|
+
async queryTracking(opts) {
|
|
117
|
+
return await this.tracking.query(opts);
|
|
118
|
+
}
|
|
119
|
+
async insertOneTracking(opts) {
|
|
120
|
+
return await this.tracking.insertOne(opts);
|
|
121
|
+
}
|
|
122
|
+
async findOneTracking(opts) {
|
|
123
|
+
return await this.tracking.findOne(opts);
|
|
124
|
+
}
|
|
125
|
+
async replaceOneTracking(opts) {
|
|
126
|
+
return await this.tracking.replaceOne(opts);
|
|
127
|
+
}
|
|
128
|
+
async deleteOneTracking(opts) {
|
|
129
|
+
return await this.tracking.deleteOne(opts);
|
|
130
|
+
}
|
|
131
|
+
async deleteManyTracking(opts) {
|
|
132
|
+
return await this.tracking.deleteMany(opts);
|
|
133
|
+
}
|
|
134
|
+
async queryRouteTeams(opts) {
|
|
135
|
+
return await this.route_teams.query(opts);
|
|
136
|
+
}
|
|
137
|
+
async insertOneRouteTeam(opts) {
|
|
138
|
+
return await this.route_teams.insertOne(opts);
|
|
139
|
+
}
|
|
140
|
+
async findOneRouteTeam(opts) {
|
|
141
|
+
return await this.route_teams.findOne(opts);
|
|
142
|
+
}
|
|
143
|
+
async replaceOneRouteTeam(opts) {
|
|
144
|
+
return await this.route_teams.replaceOne(opts);
|
|
145
|
+
}
|
|
146
|
+
async deleteOneRouteTeam(opts) {
|
|
147
|
+
return await this.route_teams.deleteOne(opts);
|
|
148
|
+
}
|
|
149
|
+
async deleteManyRouteTeams(opts) {
|
|
150
|
+
return await this.route_teams.deleteMany(opts);
|
|
151
|
+
}
|
|
152
|
+
async searchManyRouteTeams(opts) {
|
|
153
|
+
return await this.route_teams.searchMany(opts);
|
|
154
|
+
}
|
|
155
|
+
async getAvailability(opts) {
|
|
156
|
+
const token = await requiredToken(this.get_token);
|
|
157
|
+
return await this.http.do({
|
|
158
|
+
base_url: this.base_url,
|
|
159
|
+
path: routePath(PathRoutesGetAvailability),
|
|
160
|
+
method: HTTPMethodPost,
|
|
161
|
+
token,
|
|
162
|
+
body: opts,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
async getDesignation(opts) {
|
|
166
|
+
const token = await requiredToken(this.get_token);
|
|
167
|
+
return await this.http.do({
|
|
168
|
+
base_url: this.base_url,
|
|
169
|
+
path: routePath(PathRoutesGetDesignation),
|
|
170
|
+
method: HTTPMethodPost,
|
|
171
|
+
token,
|
|
172
|
+
body: opts,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
export function newRoutesClient(opts) {
|
|
177
|
+
return new RoutesClient(opts);
|
|
178
|
+
}
|
|
179
|
+
function routePath(action) {
|
|
180
|
+
return buildPath({
|
|
181
|
+
svc: SvcRoutes,
|
|
182
|
+
col: ColRoutesRoutes,
|
|
183
|
+
action,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { type Object as StorageObject, type OperationResult, type PLStorageDownload, type RPStorageUpload } from "@fabriktor/schema";
|
|
2
|
+
import type { TokenProvider } from "../core/auth.js";
|
|
3
|
+
import type { DeleteManyOptionsCRUD, DeleteOneOptionsCRUD, OperationResultOf } from "../core/crud.js";
|
|
4
|
+
import type { HTTPDoer } from "../core/http.js";
|
|
5
|
+
import { type MultipartDoer } from "../core/multipart.js";
|
|
6
|
+
export declare const storageCollections: readonly ["calls", "chat", "contacts", "jobs", "locations", "memos", "qr", "reports", "tickets", "users"];
|
|
7
|
+
export type StorageCollection = (typeof storageCollections)[number];
|
|
8
|
+
export type StorageUploadFile = File | {
|
|
9
|
+
blob: Blob;
|
|
10
|
+
filename: string;
|
|
11
|
+
};
|
|
12
|
+
export type UploadStorageOptions = {
|
|
13
|
+
owner_id: string;
|
|
14
|
+
uploader_id?: string;
|
|
15
|
+
full_quality?: boolean;
|
|
16
|
+
files: StorageUploadFile[];
|
|
17
|
+
};
|
|
18
|
+
export type DownloadStorageOptions = PLStorageDownload;
|
|
19
|
+
export type StorageClientOptions = {
|
|
20
|
+
http: HTTPDoer;
|
|
21
|
+
base_url: string;
|
|
22
|
+
get_token?: TokenProvider;
|
|
23
|
+
multipart?: MultipartDoer;
|
|
24
|
+
};
|
|
25
|
+
export interface StorageOperator {
|
|
26
|
+
upload(col: StorageCollection, opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
27
|
+
download(col: StorageCollection, opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
28
|
+
deleteOne(col: StorageCollection, opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
29
|
+
deleteMany(col: StorageCollection, opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
30
|
+
uploadCalls(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
31
|
+
downloadCalls(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
32
|
+
deleteOneCallObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
33
|
+
deleteManyCallObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
34
|
+
uploadChat(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
35
|
+
downloadChat(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
36
|
+
deleteOneChatObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
37
|
+
deleteManyChatObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
38
|
+
uploadContacts(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
39
|
+
downloadContacts(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
40
|
+
deleteOneContactObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
41
|
+
deleteManyContactObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
42
|
+
uploadJobs(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
43
|
+
downloadJobs(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
44
|
+
deleteOneJobObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
45
|
+
deleteManyJobObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
46
|
+
uploadLocations(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
47
|
+
downloadLocations(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
48
|
+
deleteOneLocationObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
49
|
+
deleteManyLocationObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
50
|
+
uploadMemos(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
51
|
+
downloadMemos(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
52
|
+
deleteOneMemoObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
53
|
+
deleteManyMemoObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
54
|
+
uploadQR(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
55
|
+
downloadQR(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
56
|
+
deleteOneQRObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
57
|
+
deleteManyQRObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
58
|
+
uploadReports(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
59
|
+
downloadReports(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
60
|
+
deleteOneReportObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
61
|
+
deleteManyReportObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
62
|
+
uploadTickets(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
63
|
+
downloadTickets(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
64
|
+
deleteOneTicketObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
65
|
+
deleteManyTicketObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
66
|
+
uploadUsers(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
67
|
+
downloadUsers(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
68
|
+
deleteOneUserObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
69
|
+
deleteManyUserObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
70
|
+
}
|
|
71
|
+
export declare class StorageClient implements StorageOperator {
|
|
72
|
+
private objects;
|
|
73
|
+
private http;
|
|
74
|
+
private multipart;
|
|
75
|
+
private base_url;
|
|
76
|
+
private get_token?;
|
|
77
|
+
constructor(opts: StorageClientOptions);
|
|
78
|
+
upload(col: StorageCollection, opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
79
|
+
download(col: StorageCollection, opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
80
|
+
deleteOne(col: StorageCollection, opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
81
|
+
deleteMany(col: StorageCollection, opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
82
|
+
uploadCalls(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
83
|
+
downloadCalls(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
84
|
+
deleteOneCallObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
85
|
+
deleteManyCallObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
86
|
+
uploadChat(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
87
|
+
downloadChat(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
88
|
+
deleteOneChatObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
89
|
+
deleteManyChatObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
90
|
+
uploadContacts(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
91
|
+
downloadContacts(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
92
|
+
deleteOneContactObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
93
|
+
deleteManyContactObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
94
|
+
uploadJobs(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
95
|
+
downloadJobs(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
96
|
+
deleteOneJobObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
97
|
+
deleteManyJobObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
98
|
+
uploadLocations(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
99
|
+
downloadLocations(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
100
|
+
deleteOneLocationObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
101
|
+
deleteManyLocationObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
102
|
+
uploadMemos(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
103
|
+
downloadMemos(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
104
|
+
deleteOneMemoObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
105
|
+
deleteManyMemoObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
106
|
+
uploadQR(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
107
|
+
downloadQR(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
108
|
+
deleteOneQRObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
109
|
+
deleteManyQRObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
110
|
+
uploadReports(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
111
|
+
downloadReports(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
112
|
+
deleteOneReportObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
113
|
+
deleteManyReportObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
114
|
+
uploadTickets(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
115
|
+
downloadTickets(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
116
|
+
deleteOneTicketObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
117
|
+
deleteManyTicketObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
118
|
+
uploadUsers(opts: UploadStorageOptions): Promise<OperationResultOf<RPStorageUpload>>;
|
|
119
|
+
downloadUsers(opts: DownloadStorageOptions): Promise<OperationResultOf<StorageObject[]>>;
|
|
120
|
+
deleteOneUserObject(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
121
|
+
deleteManyUserObjects(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
|
|
122
|
+
private object;
|
|
123
|
+
}
|
|
124
|
+
export declare function newStorageClient(opts: StorageClientOptions): StorageClient;
|
|
@@ -0,0 +1,249 @@
|
|
|
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 { ColStorageCalls, ColStorageChat, ColStorageContacts, ColStorageJobs, ColStorageLocations, ColStorageMemos, ColStorageQR, ColStorageReports, ColStorageTickets, ColStorageUsers, HTTPMethodPost, PathStorageDownload, PathStorageUpload, SvcStorage, } from "@fabriktor/schema";
|
|
7
|
+
import { requiredToken } from "../core/auth.js";
|
|
8
|
+
import { newCRUDClient } from "../core/crud.js";
|
|
9
|
+
import { newMultipartClient } from "../core/multipart.js";
|
|
10
|
+
import { buildPath } from "../core/path.js";
|
|
11
|
+
const queryOwnerID = "owner_id";
|
|
12
|
+
const queryUploaderID = "uploader_id";
|
|
13
|
+
const queryFullQuality = "full_quality";
|
|
14
|
+
const fileFieldName = "file";
|
|
15
|
+
export const storageCollections = [
|
|
16
|
+
ColStorageCalls,
|
|
17
|
+
ColStorageChat,
|
|
18
|
+
ColStorageContacts,
|
|
19
|
+
ColStorageJobs,
|
|
20
|
+
ColStorageLocations,
|
|
21
|
+
ColStorageMemos,
|
|
22
|
+
ColStorageQR,
|
|
23
|
+
ColStorageReports,
|
|
24
|
+
ColStorageTickets,
|
|
25
|
+
ColStorageUsers,
|
|
26
|
+
];
|
|
27
|
+
export class StorageClient {
|
|
28
|
+
objects;
|
|
29
|
+
http;
|
|
30
|
+
multipart;
|
|
31
|
+
base_url;
|
|
32
|
+
get_token;
|
|
33
|
+
constructor(opts) {
|
|
34
|
+
this.objects = new Map(storageCollections.map((col) => [
|
|
35
|
+
col,
|
|
36
|
+
newCRUDClient({
|
|
37
|
+
http: opts.http,
|
|
38
|
+
base_url: opts.base_url,
|
|
39
|
+
svc: SvcStorage,
|
|
40
|
+
col,
|
|
41
|
+
get_token: opts.get_token,
|
|
42
|
+
}),
|
|
43
|
+
]));
|
|
44
|
+
this.http = opts.http;
|
|
45
|
+
this.multipart = opts.multipart ?? newMultipartClient();
|
|
46
|
+
this.base_url = opts.base_url;
|
|
47
|
+
this.get_token = opts.get_token;
|
|
48
|
+
}
|
|
49
|
+
async upload(col, opts) {
|
|
50
|
+
const token = await requiredToken(this.get_token);
|
|
51
|
+
return await this.multipart.do({
|
|
52
|
+
base_url: this.base_url,
|
|
53
|
+
path: uploadPath(col, opts),
|
|
54
|
+
method: HTTPMethodPost,
|
|
55
|
+
token,
|
|
56
|
+
form: uploadForm(opts),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async download(col, opts) {
|
|
60
|
+
const token = await requiredToken(this.get_token);
|
|
61
|
+
return await this.http.do({
|
|
62
|
+
base_url: this.base_url,
|
|
63
|
+
path: storagePath(col, PathStorageDownload),
|
|
64
|
+
method: HTTPMethodPost,
|
|
65
|
+
token,
|
|
66
|
+
body: opts,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async deleteOne(col, opts) {
|
|
70
|
+
return await this.object(col).deleteOne(opts);
|
|
71
|
+
}
|
|
72
|
+
async deleteMany(col, opts) {
|
|
73
|
+
return await this.object(col).deleteMany(opts);
|
|
74
|
+
}
|
|
75
|
+
async uploadCalls(opts) {
|
|
76
|
+
return await this.upload(ColStorageCalls, opts);
|
|
77
|
+
}
|
|
78
|
+
async downloadCalls(opts) {
|
|
79
|
+
return await this.download(ColStorageCalls, opts);
|
|
80
|
+
}
|
|
81
|
+
async deleteOneCallObject(opts) {
|
|
82
|
+
return await this.deleteOne(ColStorageCalls, opts);
|
|
83
|
+
}
|
|
84
|
+
async deleteManyCallObjects(opts) {
|
|
85
|
+
return await this.deleteMany(ColStorageCalls, opts);
|
|
86
|
+
}
|
|
87
|
+
async uploadChat(opts) {
|
|
88
|
+
return await this.upload(ColStorageChat, opts);
|
|
89
|
+
}
|
|
90
|
+
async downloadChat(opts) {
|
|
91
|
+
return await this.download(ColStorageChat, opts);
|
|
92
|
+
}
|
|
93
|
+
async deleteOneChatObject(opts) {
|
|
94
|
+
return await this.deleteOne(ColStorageChat, opts);
|
|
95
|
+
}
|
|
96
|
+
async deleteManyChatObjects(opts) {
|
|
97
|
+
return await this.deleteMany(ColStorageChat, opts);
|
|
98
|
+
}
|
|
99
|
+
async uploadContacts(opts) {
|
|
100
|
+
return await this.upload(ColStorageContacts, opts);
|
|
101
|
+
}
|
|
102
|
+
async downloadContacts(opts) {
|
|
103
|
+
return await this.download(ColStorageContacts, opts);
|
|
104
|
+
}
|
|
105
|
+
async deleteOneContactObject(opts) {
|
|
106
|
+
return await this.deleteOne(ColStorageContacts, opts);
|
|
107
|
+
}
|
|
108
|
+
async deleteManyContactObjects(opts) {
|
|
109
|
+
return await this.deleteMany(ColStorageContacts, opts);
|
|
110
|
+
}
|
|
111
|
+
async uploadJobs(opts) {
|
|
112
|
+
return await this.upload(ColStorageJobs, opts);
|
|
113
|
+
}
|
|
114
|
+
async downloadJobs(opts) {
|
|
115
|
+
return await this.download(ColStorageJobs, opts);
|
|
116
|
+
}
|
|
117
|
+
async deleteOneJobObject(opts) {
|
|
118
|
+
return await this.deleteOne(ColStorageJobs, opts);
|
|
119
|
+
}
|
|
120
|
+
async deleteManyJobObjects(opts) {
|
|
121
|
+
return await this.deleteMany(ColStorageJobs, opts);
|
|
122
|
+
}
|
|
123
|
+
async uploadLocations(opts) {
|
|
124
|
+
return await this.upload(ColStorageLocations, opts);
|
|
125
|
+
}
|
|
126
|
+
async downloadLocations(opts) {
|
|
127
|
+
return await this.download(ColStorageLocations, opts);
|
|
128
|
+
}
|
|
129
|
+
async deleteOneLocationObject(opts) {
|
|
130
|
+
return await this.deleteOne(ColStorageLocations, opts);
|
|
131
|
+
}
|
|
132
|
+
async deleteManyLocationObjects(opts) {
|
|
133
|
+
return await this.deleteMany(ColStorageLocations, opts);
|
|
134
|
+
}
|
|
135
|
+
async uploadMemos(opts) {
|
|
136
|
+
return await this.upload(ColStorageMemos, opts);
|
|
137
|
+
}
|
|
138
|
+
async downloadMemos(opts) {
|
|
139
|
+
return await this.download(ColStorageMemos, opts);
|
|
140
|
+
}
|
|
141
|
+
async deleteOneMemoObject(opts) {
|
|
142
|
+
return await this.deleteOne(ColStorageMemos, opts);
|
|
143
|
+
}
|
|
144
|
+
async deleteManyMemoObjects(opts) {
|
|
145
|
+
return await this.deleteMany(ColStorageMemos, opts);
|
|
146
|
+
}
|
|
147
|
+
async uploadQR(opts) {
|
|
148
|
+
return await this.upload(ColStorageQR, opts);
|
|
149
|
+
}
|
|
150
|
+
async downloadQR(opts) {
|
|
151
|
+
return await this.download(ColStorageQR, opts);
|
|
152
|
+
}
|
|
153
|
+
async deleteOneQRObject(opts) {
|
|
154
|
+
return await this.deleteOne(ColStorageQR, opts);
|
|
155
|
+
}
|
|
156
|
+
async deleteManyQRObjects(opts) {
|
|
157
|
+
return await this.deleteMany(ColStorageQR, opts);
|
|
158
|
+
}
|
|
159
|
+
async uploadReports(opts) {
|
|
160
|
+
return await this.upload(ColStorageReports, opts);
|
|
161
|
+
}
|
|
162
|
+
async downloadReports(opts) {
|
|
163
|
+
return await this.download(ColStorageReports, opts);
|
|
164
|
+
}
|
|
165
|
+
async deleteOneReportObject(opts) {
|
|
166
|
+
return await this.deleteOne(ColStorageReports, opts);
|
|
167
|
+
}
|
|
168
|
+
async deleteManyReportObjects(opts) {
|
|
169
|
+
return await this.deleteMany(ColStorageReports, opts);
|
|
170
|
+
}
|
|
171
|
+
async uploadTickets(opts) {
|
|
172
|
+
return await this.upload(ColStorageTickets, opts);
|
|
173
|
+
}
|
|
174
|
+
async downloadTickets(opts) {
|
|
175
|
+
return await this.download(ColStorageTickets, opts);
|
|
176
|
+
}
|
|
177
|
+
async deleteOneTicketObject(opts) {
|
|
178
|
+
return await this.deleteOne(ColStorageTickets, opts);
|
|
179
|
+
}
|
|
180
|
+
async deleteManyTicketObjects(opts) {
|
|
181
|
+
return await this.deleteMany(ColStorageTickets, opts);
|
|
182
|
+
}
|
|
183
|
+
async uploadUsers(opts) {
|
|
184
|
+
return await this.upload(ColStorageUsers, opts);
|
|
185
|
+
}
|
|
186
|
+
async downloadUsers(opts) {
|
|
187
|
+
return await this.download(ColStorageUsers, opts);
|
|
188
|
+
}
|
|
189
|
+
async deleteOneUserObject(opts) {
|
|
190
|
+
return await this.deleteOne(ColStorageUsers, opts);
|
|
191
|
+
}
|
|
192
|
+
async deleteManyUserObjects(opts) {
|
|
193
|
+
return await this.deleteMany(ColStorageUsers, opts);
|
|
194
|
+
}
|
|
195
|
+
object(col) {
|
|
196
|
+
const c = this.objects.get(col);
|
|
197
|
+
if (c === undefined) {
|
|
198
|
+
throw new Error(`unknown storage collection: ${col}`);
|
|
199
|
+
}
|
|
200
|
+
return c;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
export function newStorageClient(opts) {
|
|
204
|
+
return new StorageClient(opts);
|
|
205
|
+
}
|
|
206
|
+
function uploadPath(col, opts) {
|
|
207
|
+
return withQuery(storagePath(col, PathStorageUpload), {
|
|
208
|
+
[queryOwnerID]: opts.owner_id,
|
|
209
|
+
[queryUploaderID]: opts.uploader_id,
|
|
210
|
+
[queryFullQuality]: opts.full_quality === undefined ? undefined : String(opts.full_quality),
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function storagePath(col, action) {
|
|
214
|
+
return buildPath({
|
|
215
|
+
svc: SvcStorage,
|
|
216
|
+
col,
|
|
217
|
+
action,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
function uploadForm(opts) {
|
|
221
|
+
if (opts.files.length === 0) {
|
|
222
|
+
throw new Error("upload requires at least one file");
|
|
223
|
+
}
|
|
224
|
+
const form = new FormData();
|
|
225
|
+
for (const f of opts.files) {
|
|
226
|
+
appendFile(form, f);
|
|
227
|
+
}
|
|
228
|
+
return form;
|
|
229
|
+
}
|
|
230
|
+
function appendFile(form, f) {
|
|
231
|
+
if (isFile(f)) {
|
|
232
|
+
form.append(fileFieldName, f, f.name);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
form.append(fileFieldName, f.blob, f.filename);
|
|
236
|
+
}
|
|
237
|
+
function isFile(f) {
|
|
238
|
+
return typeof File !== "undefined" && f instanceof File;
|
|
239
|
+
}
|
|
240
|
+
function withQuery(path, query) {
|
|
241
|
+
const q = new URLSearchParams();
|
|
242
|
+
for (const [k, v] of Object.entries(query)) {
|
|
243
|
+
if (v !== undefined && v.trim() !== "") {
|
|
244
|
+
q.set(k, v);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
const s = q.toString();
|
|
248
|
+
return s === "" ? path : `${path}?${s}`;
|
|
249
|
+
}
|