@foxtware/mineral 0.1.17 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/.creds.yml.sample +16 -7
  2. package/AGENTS.md +3 -0
  3. package/_build_scripts/publish.js +15 -1
  4. package/api/backblaze/backblaze.constants.js +11 -0
  5. package/api/backblaze/backblaze.utils.js +322 -0
  6. package/api/backblaze/backblazeBucketsGet.js +68 -0
  7. package/api/backblaze/backblazeFileDelete.js +62 -0
  8. package/api/backblaze/backblazeFileHide.js +62 -0
  9. package/api/backblaze/backblazeFileUpload.js +142 -0
  10. package/api/backblaze/backblazeFilesGet.js +85 -0
  11. package/api/backblaze/backblazeGet.js +139 -0
  12. package/api/backblaze/docs.md +6 -0
  13. package/api/etsy/etsyListingUpdate.js +1 -1
  14. package/api/gorgias/gorgias.constants.js +8 -0
  15. package/api/gorgias/gorgias.utils.js +46 -0
  16. package/api/gorgias/gorgiasAccountGet.js +51 -0
  17. package/api/gorgias/gorgiasCustomerGet.js +70 -0
  18. package/api/gorgias/gorgiasCustomersGet.js +56 -0
  19. package/api/gorgias/gorgiasGet.js +150 -0
  20. package/api/gorgias/gorgiasGetSingle.js +26 -0
  21. package/api/gorgias/gorgiasMessagesGet.js +56 -0
  22. package/api/gorgias/gorgiasTagsGet.js +52 -0
  23. package/api/gorgias/gorgiasTicketCreate.js +66 -0
  24. package/api/gorgias/gorgiasTicketGet.js +70 -0
  25. package/api/gorgias/gorgiasTicketMessageCreate.js +65 -0
  26. package/api/gorgias/gorgiasTicketMessagesGet.js +66 -0
  27. package/api/gorgias/gorgiasTicketUpdate.js +62 -0
  28. package/api/gorgias/gorgiasTicketsGet.js +58 -0
  29. package/api/gorgias/gorgiasUsersGet.js +52 -0
  30. package/api/gorgias/gorgiasViewItemsGet.js +57 -0
  31. package/api/gorgias/gorgiasViewsGet.js +72 -0
  32. package/api/linear/docs.md +6 -0
  33. package/api/linear/linear.constants.js +3 -0
  34. package/api/linear/linear.utils.js +59 -0
  35. package/api/linear/linearAttachmentCreate.js +77 -0
  36. package/api/linear/linearAttachmentDelete.js +68 -0
  37. package/api/linear/linearCommentCreate.js +77 -0
  38. package/api/linear/linearCommentDelete.js +68 -0
  39. package/api/linear/linearCommentGet.js +77 -0
  40. package/api/linear/linearCommentUpdate.js +87 -0
  41. package/api/linear/linearCommentsGet.js +70 -0
  42. package/api/linear/linearCyclesGet.js +67 -0
  43. package/api/linear/linearGet.js +218 -0
  44. package/api/linear/linearIssueAddLabel.js +77 -0
  45. package/api/linear/linearIssueArchive.js +74 -0
  46. package/api/linear/linearIssueCreate.js +94 -0
  47. package/api/linear/linearIssueDelete.js +74 -0
  48. package/api/linear/linearIssueGet.js +87 -0
  49. package/api/linear/linearIssueLabelCreate.js +81 -0
  50. package/api/linear/linearIssueLabelsGet.js +66 -0
  51. package/api/linear/linearIssueRemoveLabel.js +77 -0
  52. package/api/linear/linearIssueUpdate.js +96 -0
  53. package/api/linear/linearIssuesGet.js +39 -63
  54. package/api/linear/linearOrganizationGet.js +64 -0
  55. package/api/linear/linearProjectCreate.js +92 -0
  56. package/api/linear/linearProjectGet.js +74 -0
  57. package/api/linear/linearProjectUpdate.js +80 -0
  58. package/api/linear/linearProjectsGet.js +71 -0
  59. package/api/linear/linearTeamGet.js +71 -0
  60. package/api/linear/linearTeamsGet.js +66 -0
  61. package/api/linear/linearUserGet.js +72 -0
  62. package/api/linear/linearUsersGet.js +71 -0
  63. package/api/linear/linearViewerGet.js +65 -0
  64. package/api/linear/linearWebhookCreate.js +77 -0
  65. package/api/linear/linearWebhookDelete.js +68 -0
  66. package/api/linear/linearWebhooksGet.js +67 -0
  67. package/api/linear/linearWorkflowStatesGet.js +73 -0
  68. package/api/pipe17/pipe17.utils.js +7 -20
  69. package/api/pipe17/pipe17ArrivalGet.js +1 -1
  70. package/api/pipe17/pipe17FulfillmentGet.js +1 -1
  71. package/api/pipe17/pipe17InventoryItemGet.js +1 -1
  72. package/api/pipe17/pipe17JobGet.js +11 -24
  73. package/api/pipe17/pipe17LocationGet.js +1 -1
  74. package/api/pipe17/pipe17OrderGet.js +1 -1
  75. package/api/pipe17/pipe17ProductGet.js +1 -1
  76. package/api/pipe17/pipe17PurchaseGet.js +1 -1
  77. package/api/pipe17/pipe17ReceiptGet.js +1 -1
  78. package/api/pipe17/pipe17ReturnGet.js +1 -1
  79. package/api/shopify/shopifyFileCreate.js +107 -0
  80. package/api/shopify/shopifyMetafieldDefinitionCreate.js +2 -0
  81. package/api/shopify/shopifyMetafieldDefinitionGet.js +108 -0
  82. package/api/shopify/shopifyMetafieldDefinitionPropagate.js +27 -71
  83. package/api/shopify/shopifyThemeFileGet.js +112 -0
  84. package/api/shopify/shopifyThemeFilePropagate.js +410 -0
  85. package/api/shopify/shopifyThemeFilesUpsert.js +88 -0
  86. package/api/starshipit/starshipit.utils.js +1 -0
  87. package/api/starshipit/starshipitOrderGet.js +2 -10
  88. package/api/utils.js +12 -4
  89. package/package.json +1 -1
  90. package/server.utils.js +1 -1
package/.creds.yml.sample CHANGED
@@ -78,27 +78,36 @@ etsy:
78
78
  SHARED_SECRET: _________________________
79
79
 
80
80
  clickup:
81
- API_KEY: pk________________________________
81
+ API_KEY: pk_____________________________
82
82
 
83
83
  asana:
84
84
  ACCESS_TOKEN: __________________________
85
85
 
86
86
  notion:
87
- API_KEY: secret________________________________
87
+ API_KEY: secret_________________________
88
88
 
89
89
  discord:
90
- BOT_TOKEN: ______________________________
90
+ BOT_TOKEN: _____________________________
91
91
 
92
92
  telnyx:
93
- API_KEY: KEY__________________________________
93
+ API_KEY: KEY____________________________
94
94
 
95
95
  figma:
96
- API_KEY: figd________________________________
96
+ API_KEY: figd___________________________
97
97
 
98
98
  pipe17:
99
- API_KEY: ____________________________________
99
+ API_KEY: _______________________________
100
100
  sandbox:
101
- API_KEY: ____________________________________
101
+ API_KEY: _____________________________
102
+
103
+ backblaze:
104
+ APP_ID: ________________________________
105
+ API_KEY: _______________________________
106
+
107
+ gorgias:
108
+ DOMAIN: ________________________________
109
+ EMAIL: _________________________________
110
+ API_KEY: _______________________________
102
111
 
103
112
  google:
104
113
  SERVICE_ACCOUNT_JSON:
package/AGENTS.md CHANGED
@@ -17,6 +17,9 @@ Notes for AI assistants working in this directory. **Read this file at the start
17
17
  - Refer to _example.js files for reference on how functions are laid out, e.g. use of argsWarden.
18
18
  - If other functions in the platform use fetchClient as passed through options, support it as well.
19
19
  - skim an existing platform of the same shape before considering inventing a new pattern.
20
+ - docs.md in each platform should not describe the details of our implementation, handlers or anything relating to Mineral. It is for describing the platform's API itself and does not change based on what we do with it. It should also be brief.
21
+ - Usually when making a function that gets multiples of a resource, it should be implemented as a Getter, with a paginator and digester. If done in this way, export platformThingGet and platformThingGetter, using the .bind() syntax seen in other Get functions.
22
+ - When making functions that act on single resources, consider using actionSingleOrMultiple to allow a queue of actions.
20
23
 
21
24
  ## API clients
22
25
  - Base URLs for platform clients should live in `{platform}.constants.js`, not creds, if they are static for all users of the API.
@@ -53,7 +53,21 @@ const ensureLoggedIn = () => {
53
53
  stdio: 'pipe',
54
54
  });
55
55
  } catch {
56
- throw new Error('Not logged in to npm. Run `npm login` with an account that can publish @foxtware/mineral.');
56
+ console.log('Not logged in to npm. Running `npm login`…');
57
+ execSync('npm login', {
58
+ cwd: mineralRoot,
59
+ stdio: 'inherit',
60
+ });
61
+
62
+ try {
63
+ execSync('npm whoami', {
64
+ cwd: mineralRoot,
65
+ encoding: 'utf8',
66
+ stdio: 'pipe',
67
+ });
68
+ } catch {
69
+ throw new Error('Still not logged in to npm. Use an account that can publish @foxtware/mineral.');
70
+ }
57
71
  }
58
72
  };
59
73
 
@@ -0,0 +1,11 @@
1
+ const BASE_URL = 'https://api.backblazeb2.com';
2
+
3
+ const B2_API_VERSION_PATH = '/b2api/v2';
4
+
5
+ const MAX_FILES_PER_PAGE = 1000;
6
+
7
+ module.exports = {
8
+ BASE_URL,
9
+ B2_API_VERSION_PATH,
10
+ MAX_FILES_PER_PAGE,
11
+ };
@@ -0,0 +1,322 @@
1
+ const crypto = require('crypto');
2
+
3
+ const { BASE_URL, B2_API_VERSION_PATH } = require('../backblaze/backblaze.constants');
4
+ const { resolveCreds } = require('../pipelineSteps');
5
+ const {
6
+ appendUrlToBase,
7
+ credsFromPayload,
8
+ customFetch,
9
+ FetchClient,
10
+ fetchClientCommonSteps,
11
+ objHasAny,
12
+ } = require('../utils');
13
+
14
+ const bucketIdentifierValidator = (bucketIdentifier) => {
15
+ return objHasAny(bucketIdentifier, [
16
+ 'bucketId',
17
+ 'bucketName',
18
+ ]);
19
+ };
20
+
21
+ const sessionCacheKeyForCredsPayload = (credsPayload) => {
22
+ if (credsPayload?.credsPath) {
23
+ return credsPayload.credsPath;
24
+ }
25
+
26
+ return JSON.stringify(credsPayload);
27
+ };
28
+
29
+ const backblazeSessionsByKey = new Map();
30
+
31
+ const getBackblazeSession = async (credsPayload) => {
32
+ const cacheKey = sessionCacheKeyForCredsPayload(credsPayload);
33
+
34
+ if (backblazeSessionsByKey.has(cacheKey)) {
35
+ return {
36
+ ok: true,
37
+ data: backblazeSessionsByKey.get(cacheKey),
38
+ };
39
+ }
40
+
41
+ const creds = await credsFromPayload(credsPayload);
42
+ const { APP_ID, API_KEY } = creds ?? {};
43
+
44
+ if (!APP_ID || !API_KEY) {
45
+ return {
46
+ ok: false,
47
+ error: {
48
+ code: 'MISSING_BACKBLAZE_CREDS',
49
+ message: 'backblaze creds require APP_ID and API_KEY',
50
+ },
51
+ };
52
+ }
53
+
54
+ const basicToken = Buffer
55
+ .from(`${ APP_ID }:${ API_KEY }`)
56
+ .toString('base64');
57
+
58
+ const authorizeResponse = await customFetch(
59
+ `${ BASE_URL }${ B2_API_VERSION_PATH }/b2_authorize_account`,
60
+ {
61
+ method: 'get',
62
+ headers: {
63
+ Authorization: `Basic ${ basicToken }`,
64
+ },
65
+ },
66
+ );
67
+
68
+ if (!authorizeResponse.ok) {
69
+ return authorizeResponse;
70
+ }
71
+
72
+ const {
73
+ accountId,
74
+ authorizationToken,
75
+ apiUrl,
76
+ downloadUrl,
77
+ } = authorizeResponse.data ?? {};
78
+
79
+ if (!accountId || !authorizationToken || !apiUrl) {
80
+ return {
81
+ ok: false,
82
+ error: {
83
+ code: 'INVALID_AUTHORIZE_RESPONSE',
84
+ message: 'b2_authorize_account response missing accountId, authorizationToken, or apiUrl',
85
+ },
86
+ };
87
+ }
88
+
89
+ const session = {
90
+ accountId,
91
+ authorizationToken,
92
+ apiUrl,
93
+ downloadUrl,
94
+ };
95
+
96
+ backblazeSessionsByKey.set(cacheKey, session);
97
+
98
+ return {
99
+ ok: true,
100
+ data: session,
101
+ };
102
+ };
103
+
104
+ const attachBackblazeSession = async (state) => {
105
+ const { context } = state;
106
+ const { credsPayload, session } = context;
107
+
108
+ if (session) {
109
+ return {};
110
+ }
111
+
112
+ const sessionResponse = await getBackblazeSession(credsPayload);
113
+
114
+ if (!sessionResponse.ok) {
115
+ return {
116
+ breakChain: true,
117
+ response: sessionResponse,
118
+ };
119
+ }
120
+
121
+ return {
122
+ context: {
123
+ ...context,
124
+ session: sessionResponse.data,
125
+ },
126
+ };
127
+ };
128
+
129
+ const useBackblazeApiUrl = async (state) => {
130
+ const { requestPayload, context } = state;
131
+ const { session } = context;
132
+
133
+ return {
134
+ requestPayload: {
135
+ ...requestPayload,
136
+ url: appendUrlToBase(session.apiUrl, requestPayload.url),
137
+ },
138
+ };
139
+ };
140
+
141
+ const useBackblazeAuthorizationHeader = async (state) => {
142
+ const { requestPayload, context } = state;
143
+ const { session } = context;
144
+
145
+ return {
146
+ requestPayload: {
147
+ ...requestPayload,
148
+ headers: {
149
+ Authorization: session.authorizationToken,
150
+ ...requestPayload.headers,
151
+ },
152
+ },
153
+ };
154
+ };
155
+
156
+ const backblazeClient = new FetchClient({
157
+ pipeline: [
158
+ resolveCreds,
159
+ attachBackblazeSession,
160
+ useBackblazeAuthorizationHeader,
161
+ useBackblazeApiUrl,
162
+ 'fetch',
163
+ fetchClientCommonSteps.exitEarlyOnNotOk,
164
+ fetchClientCommonSteps.digToPath,
165
+ ],
166
+ });
167
+
168
+ const publicFileUrlForBucketName = ({
169
+ downloadUrl,
170
+ bucketName,
171
+ fileName,
172
+ }) => {
173
+ if (!downloadUrl || !bucketName || !fileName) {
174
+ return null;
175
+ }
176
+
177
+ const encodedFileName = encodeURIComponent(fileName)
178
+ .replace(/%2F/g, '/');
179
+
180
+ return `${ downloadUrl }/file/${ bucketName }/${ encodedFileName }`;
181
+ };
182
+
183
+ const sha1HexForBuffer = (buffer) => {
184
+ return crypto
185
+ .createHash('sha1')
186
+ .update(buffer)
187
+ .digest('hex');
188
+ };
189
+
190
+ const backblazeUploadFileBytes = async ({
191
+ credsPayload,
192
+ session,
193
+ bucketId,
194
+ fileName,
195
+ fileBytes,
196
+ contentType = 'b2/x-auto',
197
+ }) => {
198
+ let resolvedSession = session;
199
+
200
+ if (!resolvedSession) {
201
+ const sessionResponse = await getBackblazeSession(credsPayload);
202
+
203
+ if (!sessionResponse.ok) {
204
+ return sessionResponse;
205
+ }
206
+
207
+ ({ data: resolvedSession } = sessionResponse);
208
+ }
209
+
210
+ const uploadUrlResponse = await backblazeClient.fetch({
211
+ requestPayload: {
212
+ method: 'post',
213
+ url: `${ B2_API_VERSION_PATH }/b2_get_upload_url`,
214
+ body: { bucketId },
215
+ },
216
+ context: {
217
+ credsPayload,
218
+ session: resolvedSession,
219
+ },
220
+ });
221
+
222
+ if (!uploadUrlResponse.ok) {
223
+ return uploadUrlResponse;
224
+ }
225
+
226
+ const {
227
+ uploadUrl,
228
+ authorizationToken: uploadAuthorizationToken,
229
+ } = uploadUrlResponse.data ?? {};
230
+
231
+ if (!uploadUrl || !uploadAuthorizationToken) {
232
+ return {
233
+ ok: false,
234
+ error: {
235
+ code: 'INVALID_UPLOAD_URL_RESPONSE',
236
+ message: 'b2_get_upload_url response missing uploadUrl or authorizationToken',
237
+ },
238
+ };
239
+ }
240
+
241
+ const contentSha1 = sha1HexForBuffer(fileBytes);
242
+
243
+ return customFetch(uploadUrl, {
244
+ method: 'post',
245
+ headers: {
246
+ Authorization: uploadAuthorizationToken,
247
+ 'X-Bz-File-Name': encodeURIComponent(fileName),
248
+ 'X-Bz-Content-Sha1': contentSha1,
249
+ 'Content-Type': contentType,
250
+ },
251
+ body: fileBytes,
252
+ });
253
+ };
254
+
255
+ const resolveBucketIdFromIdentifier = async (
256
+ credsPayload,
257
+ bucketIdentifier,
258
+ {
259
+ fetchClient,
260
+ } = {},
261
+ ) => {
262
+ const {
263
+ bucketId,
264
+ bucketName,
265
+ } = bucketIdentifier;
266
+
267
+ if (bucketId) {
268
+ return {
269
+ ok: true,
270
+ data: bucketId,
271
+ };
272
+ }
273
+
274
+ if (!bucketName) {
275
+ return {
276
+ ok: false,
277
+ error: {
278
+ code: 'BUCKET_NOT_FOUND',
279
+ message: 'Provide bucketId or bucketName',
280
+ },
281
+ };
282
+ }
283
+
284
+ const { backblazeBucketsGet } = require('../backblaze/backblazeBucketsGet');
285
+
286
+ const bucketsResponse = await backblazeBucketsGet(credsPayload, {
287
+ bucketName,
288
+ fetchClient,
289
+ });
290
+
291
+ if (!bucketsResponse.ok) {
292
+ return bucketsResponse;
293
+ }
294
+
295
+ const bucket = bucketsResponse.data?.find(
296
+ (candidate) => candidate.bucketName === bucketName,
297
+ );
298
+
299
+ if (!bucket?.bucketId) {
300
+ return {
301
+ ok: false,
302
+ error: {
303
+ code: 'BUCKET_NOT_FOUND',
304
+ message: `Bucket ${ bucketName } not found`,
305
+ },
306
+ };
307
+ }
308
+
309
+ return {
310
+ ok: true,
311
+ data: bucket.bucketId,
312
+ };
313
+ };
314
+
315
+ module.exports = {
316
+ backblazeClient,
317
+ bucketIdentifierValidator,
318
+ getBackblazeSession,
319
+ publicFileUrlForBucketName,
320
+ backblazeUploadFileBytes,
321
+ resolveBucketIdFromIdentifier,
322
+ };
@@ -0,0 +1,68 @@
1
+ // https://www.backblaze.com/apidocs/b2-list-buckets
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { B2_API_VERSION_PATH } = require('../backblaze/backblaze.constants');
6
+ const { backblazeClient, getBackblazeSession } = require('../backblaze/backblaze.utils');
7
+
8
+ const argsWarden = new ArgsWarden([
9
+ ['credsPayload', credsValidator],
10
+ ]);
11
+
12
+ const backblazeBucketsGet = async (
13
+ credsPayload,
14
+ {
15
+ bucketName,
16
+ fetchClient = backblazeClient,
17
+ } = {},
18
+ ) => {
19
+
20
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
21
+ credsPayload,
22
+ });
23
+ if (rejectResponse) {
24
+ return rejectResponse;
25
+ }
26
+
27
+ const sessionResponse = await getBackblazeSession(credsPayload);
28
+
29
+ if (!sessionResponse.ok) {
30
+ return sessionResponse;
31
+ }
32
+
33
+ const { data: session } = sessionResponse;
34
+ const { accountId } = session;
35
+
36
+ return fetchClient.fetch({
37
+ requestPayload: {
38
+ method: 'post',
39
+ url: `${ B2_API_VERSION_PATH }/b2_list_buckets`,
40
+ body: {
41
+ accountId,
42
+ ...bucketName && { bucketName },
43
+ },
44
+ },
45
+ context: {
46
+ credsPayload,
47
+ session,
48
+ resultPath: 'buckets',
49
+ },
50
+ });
51
+ };
52
+
53
+ const funcApiConfig = {
54
+ argsWarden,
55
+ };
56
+
57
+ module.exports = {
58
+ backblazeBucketsGet,
59
+ funcApiConfig,
60
+ };
61
+
62
+ /*
63
+ curl -X POST "http://localhost:8000/backblazeBucketsGet" \
64
+ -H "Content-Type: application/json" \
65
+ -d '{
66
+ "credsPayload": { "credsPath": "backblaze" }
67
+ }'
68
+ */
@@ -0,0 +1,62 @@
1
+ // https://www.backblaze.com/apidocs/b2-delete-file-version
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { B2_API_VERSION_PATH } = require('../backblaze/backblaze.constants');
6
+ const { backblazeClient } = require('../backblaze/backblaze.utils');
7
+
8
+ const argsWarden = new ArgsWarden([
9
+ ['credsPayload', credsValidator],
10
+ ['fileName'],
11
+ ['fileId'],
12
+ ]);
13
+
14
+ const backblazeFileDelete = async (
15
+ credsPayload,
16
+ fileName,
17
+ fileId,
18
+ {
19
+ fetchClient = backblazeClient,
20
+ } = {},
21
+ ) => {
22
+
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ fileName,
26
+ fileId,
27
+ });
28
+ if (rejectResponse) {
29
+ return rejectResponse;
30
+ }
31
+
32
+ return fetchClient.fetch({
33
+ requestPayload: {
34
+ method: 'post',
35
+ url: `${ B2_API_VERSION_PATH }/b2_delete_file_version`,
36
+ body: {
37
+ fileName,
38
+ fileId,
39
+ },
40
+ },
41
+ context: { credsPayload },
42
+ });
43
+ };
44
+
45
+ const funcApiConfig = {
46
+ argsWarden,
47
+ };
48
+
49
+ module.exports = {
50
+ backblazeFileDelete,
51
+ funcApiConfig,
52
+ };
53
+
54
+ /*
55
+ curl -X POST "http://localhost:8000/backblazeFileDelete" \
56
+ -H "Content-Type: application/json" \
57
+ -d '{
58
+ "credsPayload": { "credsPath": "backblaze" },
59
+ "fileName": "hello.txt",
60
+ "fileId": "REPLACE_FILE_ID"
61
+ }'
62
+ */
@@ -0,0 +1,62 @@
1
+ // https://www.backblaze.com/apidocs/b2-hide-file
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { B2_API_VERSION_PATH } = require('../backblaze/backblaze.constants');
6
+ const { backblazeClient } = require('../backblaze/backblaze.utils');
7
+
8
+ const argsWarden = new ArgsWarden([
9
+ ['credsPayload', credsValidator],
10
+ ['fileName'],
11
+ ['fileId'],
12
+ ]);
13
+
14
+ const backblazeFileHide = async (
15
+ credsPayload,
16
+ fileName,
17
+ fileId,
18
+ {
19
+ fetchClient = backblazeClient,
20
+ } = {},
21
+ ) => {
22
+
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ fileName,
26
+ fileId,
27
+ });
28
+ if (rejectResponse) {
29
+ return rejectResponse;
30
+ }
31
+
32
+ return fetchClient.fetch({
33
+ requestPayload: {
34
+ method: 'post',
35
+ url: `${ B2_API_VERSION_PATH }/b2_hide_file`,
36
+ body: {
37
+ fileName,
38
+ fileId,
39
+ },
40
+ },
41
+ context: { credsPayload },
42
+ });
43
+ };
44
+
45
+ const funcApiConfig = {
46
+ argsWarden,
47
+ };
48
+
49
+ module.exports = {
50
+ backblazeFileHide,
51
+ funcApiConfig,
52
+ };
53
+
54
+ /*
55
+ curl -X POST "http://localhost:8000/backblazeFileHide" \
56
+ -H "Content-Type: application/json" \
57
+ -d '{
58
+ "credsPayload": { "credsPath": "backblaze" },
59
+ "fileName": "hello.txt",
60
+ "fileId": "REPLACE_FILE_ID"
61
+ }'
62
+ */