@baadal-sdk/dapi 0.31.6 → 1.0.0
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/README.md +62 -2
- package/dist/index.d.ts +674 -0
- package/dist/index.js +1118 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -106
- package/LICENSE.txt +0 -21
- package/dist/cjs/index.js +0 -3
- package/dist/cjs/index.js.LICENSE.txt +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/package.json +0 -3
- package/dist/esm/index.js +0 -3
- package/dist/esm/index.js.LICENSE.txt +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/dist/types/aws/client.d.ts +0 -13
- package/dist/types/aws/client.d.ts.map +0 -1
- package/dist/types/aws/db.d.ts +0 -291
- package/dist/types/aws/db.d.ts.map +0 -1
- package/dist/types/aws/index.d.ts +0 -12
- package/dist/types/aws/index.d.ts.map +0 -1
- package/dist/types/aws/s3.d.ts +0 -90
- package/dist/types/aws/s3.d.ts.map +0 -1
- package/dist/types/common/common.model.d.ts +0 -4
- package/dist/types/common/common.model.d.ts.map +0 -1
- package/dist/types/common/const.d.ts +0 -4
- package/dist/types/common/const.d.ts.map +0 -1
- package/dist/types/common/error.d.ts +0 -4
- package/dist/types/common/error.d.ts.map +0 -1
- package/dist/types/common/logger.d.ts +0 -29
- package/dist/types/common/logger.d.ts.map +0 -1
- package/dist/types/fs/index.d.ts +0 -102
- package/dist/types/fs/index.d.ts.map +0 -1
- package/dist/types/gh/index.d.ts +0 -22
- package/dist/types/gh/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -13
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts +0 -6
- package/dist/types/utils/index.d.ts.map +0 -1
- package/src/aws/client.ts +0 -18
- package/src/aws/db.ts +0 -764
- package/src/aws/index.ts +0 -33
- package/src/aws/s3.ts +0 -476
- package/src/common/common.model.ts +0 -3
- package/src/common/const.ts +0 -3
- package/src/common/error.ts +0 -12
- package/src/common/logger.ts +0 -18
- package/src/fs/index.ts +0 -316
- package/src/gh/index.ts +0 -60
- package/src/index.ts +0 -8
- package/src/typings/index.d.ts +0 -0
- package/src/utils/index.ts +0 -39
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check whether a file exists
|
|
3
|
+
* @param file file path
|
|
4
|
+
* @param loud whether to throw errors [default: false]
|
|
5
|
+
* @returns true if it exists, false if it doesn't, null in case of error
|
|
6
|
+
*/
|
|
7
|
+
declare const existsFileSync: (file: string, loud?: boolean) => boolean | null;
|
|
8
|
+
/**
|
|
9
|
+
* Check whether a directory exists
|
|
10
|
+
* @param dir directory path
|
|
11
|
+
* @param loud whether to throw errors [default: false]
|
|
12
|
+
* @returns true if it exists, false if it doesn't, null in case of error
|
|
13
|
+
*/
|
|
14
|
+
declare const existsDirSync: (dir: string, loud?: boolean) => boolean | null;
|
|
15
|
+
/**
|
|
16
|
+
* Read contents of a file
|
|
17
|
+
* @param file file path
|
|
18
|
+
* @param warn whether to show warnings [default: false]
|
|
19
|
+
* @returns contents of the file, null in case of error
|
|
20
|
+
*/
|
|
21
|
+
declare const readFile: (file: string, warn?: boolean) => Promise<string | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Read contents of a file
|
|
24
|
+
* @param file file path
|
|
25
|
+
* @param warn whether to show warnings [default: false]
|
|
26
|
+
* @returns contents of the file, null in case of error
|
|
27
|
+
*/
|
|
28
|
+
declare const readFileSync: (file: string, warn?: boolean) => string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Get the list of files/directories in a directory
|
|
31
|
+
* @param dir directory path
|
|
32
|
+
* @param warn whether to show warnings [default: false]
|
|
33
|
+
* @param hiddenItems whether to include items starting with dot(.) [default: false]
|
|
34
|
+
* @returns an object {dirs,files} containing list of directories & files, null in case or error
|
|
35
|
+
*/
|
|
36
|
+
declare const readDir: (dir: string, warn?: boolean, hiddenItems?: boolean) => Promise<{
|
|
37
|
+
dirs: string[];
|
|
38
|
+
files: string[];
|
|
39
|
+
} | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Get the list of files in a directory
|
|
42
|
+
* @param dir directory path
|
|
43
|
+
* @param warn whether to show warnings [default: false]
|
|
44
|
+
* @param hiddenItems whether to include items starting with dot(.) [default: false]
|
|
45
|
+
* @returns list of files, null in case of error
|
|
46
|
+
*/
|
|
47
|
+
declare const readDirFiles: (dir: string, warn?: boolean, hiddenItems?: boolean) => Promise<string[] | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Get the list of directories in a directory
|
|
50
|
+
* @param dir directory path
|
|
51
|
+
* @param warn whether to show warnings [default: false]
|
|
52
|
+
* @param hiddenItems whether to include items starting with dot(.) [default: false]
|
|
53
|
+
* @returns list of directories, null in case of error
|
|
54
|
+
*/
|
|
55
|
+
declare const readDirDirs: (dir: string, warn?: boolean, hiddenItems?: boolean) => Promise<string[] | null>;
|
|
56
|
+
/**
|
|
57
|
+
* Get the (recursive) list of files in a directory
|
|
58
|
+
* @param dir directory path
|
|
59
|
+
* @param hiddenItems whether to include items starting with dot(.) [default: false]
|
|
60
|
+
* @returns complete (recursive) list of files, null in case of error
|
|
61
|
+
*/
|
|
62
|
+
declare const readDirFilesRec: (dir: string, hiddenItems?: boolean) => Promise<string[] | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Write contents to a file (creates the file path if it doesn't exist)
|
|
65
|
+
* @param file file path
|
|
66
|
+
* @param contents contents to write
|
|
67
|
+
* @returns true if successful, null in case of error
|
|
68
|
+
*/
|
|
69
|
+
declare const writeFile: (file: string, contents: string) => Promise<true | null>;
|
|
70
|
+
/**
|
|
71
|
+
* Append contents to a file
|
|
72
|
+
* @param file file path
|
|
73
|
+
* @param contents contents to append
|
|
74
|
+
* @returns true if successful, null in case of error
|
|
75
|
+
*/
|
|
76
|
+
declare const appendToFile: (file: string, contents: string) => Promise<true | null>;
|
|
77
|
+
/**
|
|
78
|
+
* Rename a file
|
|
79
|
+
* @param oldpath old file path
|
|
80
|
+
* @param newpath new file path
|
|
81
|
+
* @returns true if successful, null in case of error
|
|
82
|
+
*/
|
|
83
|
+
declare const renameFile: (oldpath: string, newpath: string) => Promise<true | null>;
|
|
84
|
+
/**
|
|
85
|
+
* Create a directory, if it doesn't exist
|
|
86
|
+
* @param dir directory path
|
|
87
|
+
* @returns true if successful, null in case of failure/error
|
|
88
|
+
*/
|
|
89
|
+
declare const createDir: (dir: string) => Promise<true | null>;
|
|
90
|
+
/**
|
|
91
|
+
* Delete a file
|
|
92
|
+
* @param file file path
|
|
93
|
+
* @returns true if successful, null in case of error
|
|
94
|
+
*/
|
|
95
|
+
declare const deleteFile: (file: string) => Promise<true | null>;
|
|
96
|
+
/**
|
|
97
|
+
* Delete a directory
|
|
98
|
+
* @param dir directory path
|
|
99
|
+
* @returns true if successful, null in case of error
|
|
100
|
+
*/
|
|
101
|
+
declare const deleteDir: (dir: string) => Promise<true | null>;
|
|
102
|
+
|
|
103
|
+
declare const fs_appendToFile: typeof appendToFile;
|
|
104
|
+
declare const fs_createDir: typeof createDir;
|
|
105
|
+
declare const fs_deleteDir: typeof deleteDir;
|
|
106
|
+
declare const fs_deleteFile: typeof deleteFile;
|
|
107
|
+
declare const fs_existsDirSync: typeof existsDirSync;
|
|
108
|
+
declare const fs_existsFileSync: typeof existsFileSync;
|
|
109
|
+
declare const fs_readDir: typeof readDir;
|
|
110
|
+
declare const fs_readDirDirs: typeof readDirDirs;
|
|
111
|
+
declare const fs_readDirFiles: typeof readDirFiles;
|
|
112
|
+
declare const fs_readDirFilesRec: typeof readDirFilesRec;
|
|
113
|
+
declare const fs_readFile: typeof readFile;
|
|
114
|
+
declare const fs_readFileSync: typeof readFileSync;
|
|
115
|
+
declare const fs_renameFile: typeof renameFile;
|
|
116
|
+
declare const fs_writeFile: typeof writeFile;
|
|
117
|
+
declare namespace fs {
|
|
118
|
+
export { fs_appendToFile as appendToFile, fs_createDir as createDir, fs_deleteDir as deleteDir, fs_deleteFile as deleteFile, fs_existsDirSync as existsDirSync, fs_existsFileSync as existsFileSync, fs_readDir as readDir, fs_readDirDirs as readDirDirs, fs_readDirFiles as readDirFiles, fs_readDirFilesRec as readDirFilesRec, fs_readFile as readFile, fs_readFileSync as readFileSync, fs_renameFile as renameFile, fs_writeFile as writeFile };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface StringIndexable<T = any> {
|
|
122
|
+
[key: string]: T;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Examples:
|
|
127
|
+
* Ref: https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/dynamodb-examples.html
|
|
128
|
+
*
|
|
129
|
+
* Partition key vs Composite primary key:
|
|
130
|
+
* Ref: https://aws.amazon.com/premiumsupport/knowledge-center/primary-key-dynamodb-table/
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
/** @internal */
|
|
134
|
+
declare const init$2: (_region?: string) => Promise<boolean>;
|
|
135
|
+
/** @internal */
|
|
136
|
+
declare const status$2: () => string | null;
|
|
137
|
+
interface WriteItemForceInput<T = any> {
|
|
138
|
+
table: string;
|
|
139
|
+
item: T;
|
|
140
|
+
key?: string;
|
|
141
|
+
}
|
|
142
|
+
type WriteItemUniqueInput<T = any> = WriteItemForceInput<T>;
|
|
143
|
+
/**
|
|
144
|
+
* Write an item to a DynamoDB table, retry in case of key conflict
|
|
145
|
+
* @param input input command object
|
|
146
|
+
* @returns the created item, null in case of error
|
|
147
|
+
*
|
|
148
|
+
* ```js
|
|
149
|
+
* writeItemForce({
|
|
150
|
+
* table: 'lesson_list',
|
|
151
|
+
* item: { title: 'My Lesson' },
|
|
152
|
+
* key: 'id',
|
|
153
|
+
* });
|
|
154
|
+
*
|
|
155
|
+
* interface WriteItemForceInput<T = any> {
|
|
156
|
+
* table: string;
|
|
157
|
+
* item: T;
|
|
158
|
+
* key?: string; // default: `id`
|
|
159
|
+
* }
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
declare const writeItemForce: <T = any>(input: WriteItemForceInput<T>) => Promise<T | null>;
|
|
163
|
+
/**
|
|
164
|
+
* Write an item (uniquely) to a DynamoDB table.
|
|
165
|
+
* Unlike `writeItemForce`, it does not retry in case of key conflict
|
|
166
|
+
* Unlike `writeItem`, it does not overwrite an item with the same key (if it exists)
|
|
167
|
+
* @param input input command object
|
|
168
|
+
* @returns the created item, null in case of error or key conflict (i.e., if item with same key already exists)
|
|
169
|
+
*
|
|
170
|
+
* ```js
|
|
171
|
+
* writeItemUnique({
|
|
172
|
+
* table: 'lesson_list',
|
|
173
|
+
* item: { id: 'id_001', title: 'My Lesson' },
|
|
174
|
+
* key: 'id',
|
|
175
|
+
* });
|
|
176
|
+
*
|
|
177
|
+
* interface WriteItemUniqueInput<T = any> {
|
|
178
|
+
* table: string;
|
|
179
|
+
* item: T;
|
|
180
|
+
* key?: string; // default: `id`
|
|
181
|
+
* }
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
declare const writeItemUnique: <T = any>(input: WriteItemUniqueInput<T>) => Promise<T | null>;
|
|
185
|
+
interface WriteItemInput {
|
|
186
|
+
table: string;
|
|
187
|
+
item: StringIndexable;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Write an item to a DynamoDB table
|
|
191
|
+
* @param input input command object
|
|
192
|
+
* @returns true if successful, null in case of error
|
|
193
|
+
*
|
|
194
|
+
* ```js
|
|
195
|
+
* writeItem({
|
|
196
|
+
* table: 'lesson_list',
|
|
197
|
+
* item: { id: 'id_001', title: 'My Lesson' },
|
|
198
|
+
* });
|
|
199
|
+
*
|
|
200
|
+
* interface WriteItemInput {
|
|
201
|
+
* table: string;
|
|
202
|
+
* item: StringIndexable;
|
|
203
|
+
* }
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
declare const writeItem: (input: WriteItemInput) => Promise<true | null>;
|
|
207
|
+
interface WriteItemsAllInput {
|
|
208
|
+
table: string;
|
|
209
|
+
items: StringIndexable[];
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Write a list of items to a DynamoDB table
|
|
213
|
+
* @param input input command object
|
|
214
|
+
* @returns true if successful, null in case of error
|
|
215
|
+
*
|
|
216
|
+
* ```js
|
|
217
|
+
* writeItemsAll({
|
|
218
|
+
* table: 'lesson_list',
|
|
219
|
+
* items: [{ id: 'id_001', title: 'My Lesson' }, { id: 'id_002', title: 'My Lesson 2' }],
|
|
220
|
+
* });
|
|
221
|
+
*
|
|
222
|
+
* interface WriteItemInput {
|
|
223
|
+
* table: string;
|
|
224
|
+
* items: StringIndexable[];
|
|
225
|
+
* }
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
declare const writeItemsAll: (input: WriteItemsAllInput) => Promise<true | null>;
|
|
229
|
+
interface UpdateItemInput {
|
|
230
|
+
table: string;
|
|
231
|
+
key: StringIndexable;
|
|
232
|
+
update: string;
|
|
233
|
+
attr: StringIndexable;
|
|
234
|
+
attrNames?: StringIndexable;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Update an item in DynamoDB table
|
|
238
|
+
* @param input input command object
|
|
239
|
+
* @returns true if successful, null in case of error
|
|
240
|
+
*
|
|
241
|
+
* ```js
|
|
242
|
+
* updateItem({
|
|
243
|
+
* table: 'lesson_list',
|
|
244
|
+
* key: { id: 'id_001' },
|
|
245
|
+
* update: 'SET status = :status, #rev = 10',
|
|
246
|
+
* attr: { ':status': 'completed' },
|
|
247
|
+
* attrNames: { '#rev': 'revision' },
|
|
248
|
+
* });
|
|
249
|
+
*
|
|
250
|
+
* interface UpdateItemInput {
|
|
251
|
+
* table: string;
|
|
252
|
+
* key: StringIndexable;
|
|
253
|
+
* update: string;
|
|
254
|
+
* attr: StringIndexable;
|
|
255
|
+
* attrNames?: StringIndexable;
|
|
256
|
+
* }
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
declare const updateItem: (input: UpdateItemInput) => Promise<true | null>;
|
|
260
|
+
interface ReadItemInput {
|
|
261
|
+
table: string;
|
|
262
|
+
key: StringIndexable;
|
|
263
|
+
projection?: string;
|
|
264
|
+
attrNames?: StringIndexable;
|
|
265
|
+
loud?: boolean;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Read an item from DynamoDB table
|
|
269
|
+
* @param input input command object
|
|
270
|
+
* @returns item contents, null in case of error
|
|
271
|
+
*
|
|
272
|
+
* ```js
|
|
273
|
+
* readItem({
|
|
274
|
+
* table: 'lesson_list',
|
|
275
|
+
* key: { id: 'id_001' },
|
|
276
|
+
* projection: 'id, lesson, status',
|
|
277
|
+
* });
|
|
278
|
+
*
|
|
279
|
+
* interface ReadItemInput {
|
|
280
|
+
* table: string;
|
|
281
|
+
* key: StringIndexable;
|
|
282
|
+
* projection?: string;
|
|
283
|
+
* attrNames?: StringIndexable;
|
|
284
|
+
* }
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
declare const readItem: <T = any>(input: ReadItemInput) => Promise<T | null>;
|
|
288
|
+
interface ReadItemsAllInput {
|
|
289
|
+
table: string;
|
|
290
|
+
keys: StringIndexable[];
|
|
291
|
+
projection?: string;
|
|
292
|
+
attrNames?: StringIndexable;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Read a list of items from DynamoDB table
|
|
296
|
+
* Note: ordering of items in result may not be same as that in `keys`
|
|
297
|
+
* @param input input command object
|
|
298
|
+
* @returns list of contents for items, null in case of error
|
|
299
|
+
*
|
|
300
|
+
* ```js
|
|
301
|
+
* readItemsAll({
|
|
302
|
+
* table: 'lesson_list',
|
|
303
|
+
* keys: [{ id: 'id_001' }, { id: 'id_002' }],
|
|
304
|
+
* projection: 'id, lesson, status',
|
|
305
|
+
* });
|
|
306
|
+
*
|
|
307
|
+
* interface ReadItemsAllInput {
|
|
308
|
+
* table: string;
|
|
309
|
+
* keys: StringIndexable[];
|
|
310
|
+
* projection?: string;
|
|
311
|
+
* attrNames?: StringIndexable;
|
|
312
|
+
* }
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
declare const readItemsAll: <T = any>(input: ReadItemsAllInput) => Promise<StringIndexable<T>[] | null>;
|
|
316
|
+
interface QueryItemsInput {
|
|
317
|
+
table: string;
|
|
318
|
+
indexName?: string;
|
|
319
|
+
cond: string;
|
|
320
|
+
attr: StringIndexable;
|
|
321
|
+
attrNames?: StringIndexable;
|
|
322
|
+
projection?: string;
|
|
323
|
+
desc?: boolean;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Query items from a DynamoDB table based on some condition
|
|
327
|
+
* @param input input command object
|
|
328
|
+
* @returns query results array, null in case of error
|
|
329
|
+
*
|
|
330
|
+
* ```js
|
|
331
|
+
* dbQueryItems({
|
|
332
|
+
* table: 'lesson_list',
|
|
333
|
+
* indexName: 'status-revision-index',
|
|
334
|
+
* cond: 'status = :comp AND #rev >= :rev',
|
|
335
|
+
* attr: { ':comp': 'completed', ':rev': 9 },
|
|
336
|
+
* attrNames: { '#rev': 'revision' },
|
|
337
|
+
* projection: 'id, lesson, status, revision',
|
|
338
|
+
* });
|
|
339
|
+
*
|
|
340
|
+
* interface QueryItemsInput {
|
|
341
|
+
* table: string;
|
|
342
|
+
* indexName?: string;
|
|
343
|
+
* cond: string;
|
|
344
|
+
* attr: StringIndexable;
|
|
345
|
+
* attrNames?: StringIndexable;
|
|
346
|
+
* projection?: string;
|
|
347
|
+
* desc?: boolean;
|
|
348
|
+
* }
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
declare const queryItems: (input: QueryItemsInput) => Promise<StringIndexable<any>[] | null>;
|
|
352
|
+
interface ScanItemsInput {
|
|
353
|
+
table: string;
|
|
354
|
+
projection?: string;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Scan all items in a DynamoDB table
|
|
358
|
+
* Note: avoid using this method in favour of `queryItems` method due to performance reasons
|
|
359
|
+
* @param input input command object
|
|
360
|
+
* @returns results of the scan query, null in case of error
|
|
361
|
+
*
|
|
362
|
+
* ```js
|
|
363
|
+
* scanItems({
|
|
364
|
+
* table: 'lesson_list',
|
|
365
|
+
* projection: 'id, status',
|
|
366
|
+
* });
|
|
367
|
+
*
|
|
368
|
+
* interface ScanItemsInput {
|
|
369
|
+
* table: string;
|
|
370
|
+
* projection?: string;
|
|
371
|
+
* }
|
|
372
|
+
* ```
|
|
373
|
+
*/
|
|
374
|
+
declare const scanItems: (input: ScanItemsInput) => Promise<StringIndexable<any>[] | null>;
|
|
375
|
+
interface DeleteItemInput {
|
|
376
|
+
table: string;
|
|
377
|
+
key: StringIndexable;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Delete an item in a DynamoDB table
|
|
381
|
+
* @param input input command object
|
|
382
|
+
* @returns true if successful, null in case of error
|
|
383
|
+
*
|
|
384
|
+
* ```js
|
|
385
|
+
* deleteItem({
|
|
386
|
+
* table: 'lesson_list',
|
|
387
|
+
* key: { id: 'id_001' },
|
|
388
|
+
* });
|
|
389
|
+
*
|
|
390
|
+
* interface DeleteItemInput {
|
|
391
|
+
* table: string;
|
|
392
|
+
* key: StringIndexable;
|
|
393
|
+
* }
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
declare const deleteItem: (input: DeleteItemInput) => Promise<true | null>;
|
|
397
|
+
interface DeleteItemsAllInput {
|
|
398
|
+
table: string;
|
|
399
|
+
keys: StringIndexable[];
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Delete a list of items in a DynamoDB table
|
|
403
|
+
* @param input input command object
|
|
404
|
+
* @returns true if successful, null in case of error
|
|
405
|
+
*
|
|
406
|
+
* ```js
|
|
407
|
+
* deleteItemsAll({
|
|
408
|
+
* table: 'lesson_list',
|
|
409
|
+
* keys: [{ id: 'id_001' }, { id: 'id_002' }],
|
|
410
|
+
* });
|
|
411
|
+
*
|
|
412
|
+
* interface DeleteItemsAllInput {
|
|
413
|
+
* table: string;
|
|
414
|
+
* keys: StringIndexable[];
|
|
415
|
+
* }
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
declare const deleteItemsAll: (input: DeleteItemsAllInput) => Promise<true | null>;
|
|
419
|
+
|
|
420
|
+
type db_DeleteItemInput = DeleteItemInput;
|
|
421
|
+
type db_DeleteItemsAllInput = DeleteItemsAllInput;
|
|
422
|
+
type db_QueryItemsInput = QueryItemsInput;
|
|
423
|
+
type db_ReadItemInput = ReadItemInput;
|
|
424
|
+
type db_ReadItemsAllInput = ReadItemsAllInput;
|
|
425
|
+
type db_ScanItemsInput = ScanItemsInput;
|
|
426
|
+
type db_UpdateItemInput = UpdateItemInput;
|
|
427
|
+
type db_WriteItemForceInput<T = any> = WriteItemForceInput<T>;
|
|
428
|
+
type db_WriteItemInput = WriteItemInput;
|
|
429
|
+
type db_WriteItemUniqueInput<T = any> = WriteItemUniqueInput<T>;
|
|
430
|
+
type db_WriteItemsAllInput = WriteItemsAllInput;
|
|
431
|
+
declare const db_deleteItem: typeof deleteItem;
|
|
432
|
+
declare const db_deleteItemsAll: typeof deleteItemsAll;
|
|
433
|
+
declare const db_queryItems: typeof queryItems;
|
|
434
|
+
declare const db_readItem: typeof readItem;
|
|
435
|
+
declare const db_readItemsAll: typeof readItemsAll;
|
|
436
|
+
declare const db_scanItems: typeof scanItems;
|
|
437
|
+
declare const db_updateItem: typeof updateItem;
|
|
438
|
+
declare const db_writeItem: typeof writeItem;
|
|
439
|
+
declare const db_writeItemForce: typeof writeItemForce;
|
|
440
|
+
declare const db_writeItemUnique: typeof writeItemUnique;
|
|
441
|
+
declare const db_writeItemsAll: typeof writeItemsAll;
|
|
442
|
+
declare namespace db {
|
|
443
|
+
export { type db_DeleteItemInput as DeleteItemInput, type db_DeleteItemsAllInput as DeleteItemsAllInput, type db_QueryItemsInput as QueryItemsInput, type db_ReadItemInput as ReadItemInput, type db_ReadItemsAllInput as ReadItemsAllInput, type db_ScanItemsInput as ScanItemsInput, type db_UpdateItemInput as UpdateItemInput, type db_WriteItemForceInput as WriteItemForceInput, type db_WriteItemInput as WriteItemInput, type db_WriteItemUniqueInput as WriteItemUniqueInput, type db_WriteItemsAllInput as WriteItemsAllInput, db_deleteItem as deleteItem, db_deleteItemsAll as deleteItemsAll, init$2 as init, db_queryItems as queryItems, db_readItem as readItem, db_readItemsAll as readItemsAll, db_scanItems as scanItems, status$2 as status, db_updateItem as updateItem, db_writeItem as writeItem, db_writeItemForce as writeItemForce, db_writeItemUnique as writeItemUnique, db_writeItemsAll as writeItemsAll };
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Examples:
|
|
448
|
+
* Ref: https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/s3-examples.html
|
|
449
|
+
*/
|
|
450
|
+
|
|
451
|
+
/** @internal */
|
|
452
|
+
declare const init$1: (_region?: string) => Promise<boolean>;
|
|
453
|
+
/** @internal */
|
|
454
|
+
declare const status$1: () => string | null;
|
|
455
|
+
/**
|
|
456
|
+
* Create a new file in S3 bucket
|
|
457
|
+
* @param bucket S3 bucket name
|
|
458
|
+
* @param s3path S3 path to be created
|
|
459
|
+
* @param contents contents of the file to be created
|
|
460
|
+
* @returns true if the write is successful, null in case of error
|
|
461
|
+
*/
|
|
462
|
+
declare const putObject: (bucket: string, s3path: string, contents: string) => Promise<true | null>;
|
|
463
|
+
/**
|
|
464
|
+
* Upload a file to S3 bucket
|
|
465
|
+
* @param bucket S3 bucket name
|
|
466
|
+
* @param file (local) path of the file to upload
|
|
467
|
+
* @param s3path [optional] S3 path to be created, if not provided then derived from `file` path
|
|
468
|
+
* @returns true if the write is successful, null in case of error
|
|
469
|
+
*/
|
|
470
|
+
declare const uploadFile: (bucket: string, file: string, s3path?: string) => Promise<true | null>;
|
|
471
|
+
/**
|
|
472
|
+
* Upload a list of files to S3 bucket
|
|
473
|
+
* @param bucket S3 bucket name
|
|
474
|
+
* @param files (local) list of file paths to upload
|
|
475
|
+
* @param s3paths [optional] S3 path to be created, if not provided then derived from `file` path
|
|
476
|
+
* @returns true if all uploads are successful, null in case of error
|
|
477
|
+
*/
|
|
478
|
+
declare const uploadFilesAll: (bucket: string, files: string[], s3paths?: string[]) => Promise<true | null>;
|
|
479
|
+
/**
|
|
480
|
+
* Get the contents of a file in S3 bucket
|
|
481
|
+
* @param bucket S3 bucket name
|
|
482
|
+
* @param s3path S3 path of the file to be read
|
|
483
|
+
* @returns contents of the file, null in case of error
|
|
484
|
+
*/
|
|
485
|
+
declare const getObject: (bucket: string, s3path: string) => Promise<string | null>;
|
|
486
|
+
/**
|
|
487
|
+
* Download a file from S3 bucket
|
|
488
|
+
* @param bucket S3 bucket name
|
|
489
|
+
* @param s3path S3 path of the file to be downloaded
|
|
490
|
+
* @param outPath [optional] path where the downloaded file is written, if not provided then derived from `s3path`
|
|
491
|
+
* @returns true if download is successful, null in case of error
|
|
492
|
+
*/
|
|
493
|
+
declare const downloadFile: (bucket: string, s3path: string, outPath?: string) => Promise<true | null>;
|
|
494
|
+
/**
|
|
495
|
+
* List objects in a S3 bucket
|
|
496
|
+
* @param bucket S3 bucket name
|
|
497
|
+
* @param prefix [optional] prefix for object names in the bucket
|
|
498
|
+
* @returns list of objects in the S3 bucket (optionally starting with the given prefix), null in case of error
|
|
499
|
+
*/
|
|
500
|
+
declare const listObjects: (bucket: string, prefix?: string) => Promise<string[] | null>;
|
|
501
|
+
/**
|
|
502
|
+
* Get head content for a file in S3 bucket
|
|
503
|
+
* @param bucket S3 bucket name
|
|
504
|
+
* @param s3path S3 path of the file
|
|
505
|
+
* @returns head content for the given file, null in case of error
|
|
506
|
+
*/
|
|
507
|
+
declare const getObjectHead: (bucket: string, s3path: string) => Promise<HeadObject | null>;
|
|
508
|
+
/**
|
|
509
|
+
* Get head contents for a list of files in S3 bucket
|
|
510
|
+
* @param bucket S3 bucket name
|
|
511
|
+
* @param s3paths list of S3 paths of the files
|
|
512
|
+
* @returns head contents for the given files, null in case of error
|
|
513
|
+
*/
|
|
514
|
+
declare const getObjectHeadsAll: (bucket: string, s3paths: string[]) => Promise<HeadObject[] | null>;
|
|
515
|
+
/**
|
|
516
|
+
* Delete a file in S3 bucket
|
|
517
|
+
* @param bucket S3 bucket name
|
|
518
|
+
* @param s3path S3 file path to be deleted
|
|
519
|
+
* @returns true if delete is successful, null in case of error
|
|
520
|
+
*/
|
|
521
|
+
declare const deleteObject: (bucket: string, s3path: string) => Promise<true | null>;
|
|
522
|
+
/**
|
|
523
|
+
* Delete a list of files in S3 bucket
|
|
524
|
+
* @param bucket S3 bucket name
|
|
525
|
+
* @param s3paths list of S3 file paths to be deleted
|
|
526
|
+
* @returns true if all deletes are successful, null in case of error
|
|
527
|
+
*/
|
|
528
|
+
declare const deleteObjectsAll: (bucket: string, s3paths: string[]) => Promise<true | null>;
|
|
529
|
+
interface HeadObject {
|
|
530
|
+
Key: string;
|
|
531
|
+
ContentLength?: number;
|
|
532
|
+
ContentType?: string;
|
|
533
|
+
ETag?: string;
|
|
534
|
+
CacheControl?: string;
|
|
535
|
+
Expires?: Date;
|
|
536
|
+
LastModified?: Date;
|
|
537
|
+
Metadata?: StringIndexable;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
type s3_HeadObject = HeadObject;
|
|
541
|
+
declare const s3_deleteObject: typeof deleteObject;
|
|
542
|
+
declare const s3_deleteObjectsAll: typeof deleteObjectsAll;
|
|
543
|
+
declare const s3_downloadFile: typeof downloadFile;
|
|
544
|
+
declare const s3_getObject: typeof getObject;
|
|
545
|
+
declare const s3_getObjectHead: typeof getObjectHead;
|
|
546
|
+
declare const s3_getObjectHeadsAll: typeof getObjectHeadsAll;
|
|
547
|
+
declare const s3_listObjects: typeof listObjects;
|
|
548
|
+
declare const s3_putObject: typeof putObject;
|
|
549
|
+
declare const s3_uploadFile: typeof uploadFile;
|
|
550
|
+
declare const s3_uploadFilesAll: typeof uploadFilesAll;
|
|
551
|
+
declare namespace s3 {
|
|
552
|
+
export { type s3_HeadObject as HeadObject, s3_deleteObject as deleteObject, s3_deleteObjectsAll as deleteObjectsAll, s3_downloadFile as downloadFile, s3_getObject as getObject, s3_getObjectHead as getObjectHead, s3_getObjectHeadsAll as getObjectHeadsAll, init$1 as init, s3_listObjects as listObjects, s3_putObject as putObject, status$1 as status, s3_uploadFile as uploadFile, s3_uploadFilesAll as uploadFilesAll };
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* @deprecated explicit init deprecated!
|
|
557
|
+
*/
|
|
558
|
+
declare const init: (region: string) => Promise<boolean>;
|
|
559
|
+
declare const status: () => {
|
|
560
|
+
db: string | null;
|
|
561
|
+
s3: string | null;
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
declare const aws_db: typeof db;
|
|
565
|
+
declare const aws_init: typeof init;
|
|
566
|
+
declare const aws_s3: typeof s3;
|
|
567
|
+
declare const aws_status: typeof status;
|
|
568
|
+
declare namespace aws {
|
|
569
|
+
export { aws_db as db, aws_init as init, aws_s3 as s3, aws_status as status };
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
interface GitHubContent {
|
|
573
|
+
path: string;
|
|
574
|
+
content: string;
|
|
575
|
+
sha: string;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Initialize GitHub client
|
|
579
|
+
* @param authToken GitHub auth token for the user account [GITHUB_TOKEN]
|
|
580
|
+
* @param owner account id for the GitHub user account [GITHUB_ACCOUNT]
|
|
581
|
+
* @returns an instance of GitHubClient
|
|
582
|
+
*/
|
|
583
|
+
declare function getInstance(authToken: string, owner: string): GitHubClient;
|
|
584
|
+
declare class GitHubClient {
|
|
585
|
+
private client;
|
|
586
|
+
private owner;
|
|
587
|
+
constructor(authToken: string, owner: string);
|
|
588
|
+
/**
|
|
589
|
+
* Get contents of a particular file in a repo
|
|
590
|
+
* @param repo name of the repo
|
|
591
|
+
* @param path path of a file in the repo
|
|
592
|
+
* @returns an object {data, headers} containing normalized file content and response headers
|
|
593
|
+
* @throws {GitHubError} in case of failure or invalid response
|
|
594
|
+
*/
|
|
595
|
+
getContent(repo: string, path: string): Promise<{
|
|
596
|
+
data: GitHubContent;
|
|
597
|
+
headers: Record<string, unknown>;
|
|
598
|
+
}>;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
type gh_GitHubClient = GitHubClient;
|
|
602
|
+
declare const gh_GitHubClient: typeof GitHubClient;
|
|
603
|
+
type gh_GitHubContent = GitHubContent;
|
|
604
|
+
declare const gh_getInstance: typeof getInstance;
|
|
605
|
+
declare namespace gh {
|
|
606
|
+
export { gh_GitHubClient as GitHubClient, type gh_GitHubContent as GitHubContent, gh_getInstance as getInstance };
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Generate SHA1 hash from given data
|
|
611
|
+
* @param input data string for which SHA1 hash has to be generated
|
|
612
|
+
* @returns SHA1 hash of the given data
|
|
613
|
+
*/
|
|
614
|
+
declare function sha1Hash(input: string): string;
|
|
615
|
+
/**
|
|
616
|
+
* Generate SHA256 hash from given data
|
|
617
|
+
* @param input data string for which SHA256 hash has to be generated
|
|
618
|
+
* @returns SHA256 hash of the given data
|
|
619
|
+
*/
|
|
620
|
+
declare function sha256Hash(input: string | Buffer): string | null;
|
|
621
|
+
|
|
622
|
+
declare const assertPath: (p: string) => string;
|
|
623
|
+
declare const fileHash: (file: string) => Promise<string | null>;
|
|
624
|
+
/**
|
|
625
|
+
* base64-encode given data
|
|
626
|
+
* @param data data string to be base64-encoded
|
|
627
|
+
* @returns base64-encoded string
|
|
628
|
+
*/
|
|
629
|
+
declare const base64Encode: (data: string) => string;
|
|
630
|
+
/**
|
|
631
|
+
* decode base64-encoded data
|
|
632
|
+
* @param base64 base64 string to be decoded
|
|
633
|
+
* @returns base64-decoded string
|
|
634
|
+
*/
|
|
635
|
+
declare const base64Decode: (base64: string) => string;
|
|
636
|
+
/**
|
|
637
|
+
* Create a Map from a given Array based on some field
|
|
638
|
+
* Note that the items of the array should generally be of type `object`
|
|
639
|
+
* so that the `key` property exists on the object item. However, if the
|
|
640
|
+
* `key` parameter is not provided, then the items of the array must be of
|
|
641
|
+
* a primitive data type (string or number) which will be treated as key.
|
|
642
|
+
* @param arr given Array to be converted to Map
|
|
643
|
+
* @param key [optional] a string field from Array items
|
|
644
|
+
* @returns a map created from the array items
|
|
645
|
+
*/
|
|
646
|
+
declare const arrayToMap: <T = any>(arr: T[] | null, key?: string) => Map<string, T> | null;
|
|
647
|
+
/**
|
|
648
|
+
* Convert an array into an array of chunks of array
|
|
649
|
+
* @param arr a given array
|
|
650
|
+
* @param chunkSize maximum number of items in a chunk
|
|
651
|
+
* @returns array of chunks of the given array
|
|
652
|
+
*/
|
|
653
|
+
declare const chunkifyArray: <T = any>(arr: T[], chunkSize: number) => T[][];
|
|
654
|
+
|
|
655
|
+
declare const utils_arrayToMap: typeof arrayToMap;
|
|
656
|
+
declare const utils_assertPath: typeof assertPath;
|
|
657
|
+
declare const utils_base64Decode: typeof base64Decode;
|
|
658
|
+
declare const utils_base64Encode: typeof base64Encode;
|
|
659
|
+
declare const utils_chunkifyArray: typeof chunkifyArray;
|
|
660
|
+
declare const utils_fileHash: typeof fileHash;
|
|
661
|
+
declare const utils_sha1Hash: typeof sha1Hash;
|
|
662
|
+
declare const utils_sha256Hash: typeof sha256Hash;
|
|
663
|
+
declare namespace utils {
|
|
664
|
+
export { utils_arrayToMap as arrayToMap, utils_assertPath as assertPath, utils_base64Decode as base64Decode, utils_base64Encode as base64Encode, utils_chunkifyArray as chunkifyArray, utils_fileHash as fileHash, utils_sha1Hash as sha1Hash, utils_sha256Hash as sha256Hash };
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
declare const _default: {
|
|
668
|
+
fs: typeof fs;
|
|
669
|
+
aws: typeof aws;
|
|
670
|
+
gh: typeof gh;
|
|
671
|
+
utils: typeof utils;
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
export { aws, _default as default, fs, gh, utils };
|