@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.
Files changed (51) hide show
  1. package/README.md +62 -2
  2. package/dist/index.d.ts +674 -0
  3. package/dist/index.js +1118 -0
  4. package/dist/index.js.map +1 -0
  5. package/package.json +44 -106
  6. package/LICENSE.txt +0 -21
  7. package/dist/cjs/index.js +0 -3
  8. package/dist/cjs/index.js.LICENSE.txt +0 -1
  9. package/dist/cjs/index.js.map +0 -1
  10. package/dist/cjs/package.json +0 -3
  11. package/dist/esm/index.js +0 -3
  12. package/dist/esm/index.js.LICENSE.txt +0 -1
  13. package/dist/esm/index.js.map +0 -1
  14. package/dist/esm/package.json +0 -3
  15. package/dist/types/aws/client.d.ts +0 -13
  16. package/dist/types/aws/client.d.ts.map +0 -1
  17. package/dist/types/aws/db.d.ts +0 -291
  18. package/dist/types/aws/db.d.ts.map +0 -1
  19. package/dist/types/aws/index.d.ts +0 -12
  20. package/dist/types/aws/index.d.ts.map +0 -1
  21. package/dist/types/aws/s3.d.ts +0 -90
  22. package/dist/types/aws/s3.d.ts.map +0 -1
  23. package/dist/types/common/common.model.d.ts +0 -4
  24. package/dist/types/common/common.model.d.ts.map +0 -1
  25. package/dist/types/common/const.d.ts +0 -4
  26. package/dist/types/common/const.d.ts.map +0 -1
  27. package/dist/types/common/error.d.ts +0 -4
  28. package/dist/types/common/error.d.ts.map +0 -1
  29. package/dist/types/common/logger.d.ts +0 -29
  30. package/dist/types/common/logger.d.ts.map +0 -1
  31. package/dist/types/fs/index.d.ts +0 -102
  32. package/dist/types/fs/index.d.ts.map +0 -1
  33. package/dist/types/gh/index.d.ts +0 -22
  34. package/dist/types/gh/index.d.ts.map +0 -1
  35. package/dist/types/index.d.ts +0 -13
  36. package/dist/types/index.d.ts.map +0 -1
  37. package/dist/types/utils/index.d.ts +0 -6
  38. package/dist/types/utils/index.d.ts.map +0 -1
  39. package/src/aws/client.ts +0 -18
  40. package/src/aws/db.ts +0 -764
  41. package/src/aws/index.ts +0 -33
  42. package/src/aws/s3.ts +0 -476
  43. package/src/common/common.model.ts +0 -3
  44. package/src/common/const.ts +0 -3
  45. package/src/common/error.ts +0 -12
  46. package/src/common/logger.ts +0 -18
  47. package/src/fs/index.ts +0 -316
  48. package/src/gh/index.ts +0 -60
  49. package/src/index.ts +0 -8
  50. package/src/typings/index.d.ts +0 -0
  51. package/src/utils/index.ts +0 -39
@@ -1,90 +0,0 @@
1
- /**
2
- * Examples:
3
- * Ref: https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/s3-examples.html
4
- */
5
- import { StringIndexable } from 'src/common/common.model';
6
- /**
7
- * Create a new file in S3 bucket
8
- * @param bucket S3 bucket name
9
- * @param s3path S3 path to be created
10
- * @param contents contents of the file to be created
11
- * @returns true if the write is successful, null in case of error
12
- */
13
- export declare const putObject: (bucket: string, s3path: string, contents: string) => Promise<true | null>;
14
- /**
15
- * Upload a file to S3 bucket
16
- * @param bucket S3 bucket name
17
- * @param file (local) path of the file to upload
18
- * @param s3path [optional] S3 path to be created, if not provided then derived from `file` path
19
- * @returns true if the write is successful, null in case of error
20
- */
21
- export declare const uploadFile: (bucket: string, file: string, s3path?: string) => Promise<true | null>;
22
- /**
23
- * Upload a list of files to S3 bucket
24
- * @param bucket S3 bucket name
25
- * @param files (local) list of file paths to upload
26
- * @param s3paths [optional] S3 path to be created, if not provided then derived from `file` path
27
- * @returns true if all uploads are successful, null in case of error
28
- */
29
- export declare const uploadFilesAll: (bucket: string, files: string[], s3paths?: string[]) => Promise<true | null>;
30
- /**
31
- * Get the contents of a file in S3 bucket
32
- * @param bucket S3 bucket name
33
- * @param s3path S3 path of the file to be read
34
- * @returns contents of the file, null in case of error
35
- */
36
- export declare const getObject: (bucket: string, s3path: string) => Promise<string | null>;
37
- /**
38
- * Download a file from S3 bucket
39
- * @param bucket S3 bucket name
40
- * @param s3path S3 path of the file to be downloaded
41
- * @param outPath [optional] path where the downloaded file is written, if not provided then derived from `s3path`
42
- * @returns true if download is successful, null in case of error
43
- */
44
- export declare const downloadFile: (bucket: string, s3path: string, outPath?: string) => Promise<true | null>;
45
- /**
46
- * List objects in a S3 bucket
47
- * @param bucket S3 bucket name
48
- * @param prefix [optional] prefix for object names in the bucket
49
- * @returns list of objects in the S3 bucket (optionally starting with the given prefix), null in case of error
50
- */
51
- export declare const listObjects: (bucket: string, prefix?: string) => Promise<string[] | null>;
52
- /**
53
- * Get head content for a file in S3 bucket
54
- * @param bucket S3 bucket name
55
- * @param s3path S3 path of the file
56
- * @returns head content for the given file, null in case of error
57
- */
58
- export declare const getObjectHead: (bucket: string, s3path: string) => Promise<HeadObject | null>;
59
- /**
60
- * Get head contents for a list of files in S3 bucket
61
- * @param bucket S3 bucket name
62
- * @param s3paths list of S3 paths of the files
63
- * @returns head contents for the given files, null in case of error
64
- */
65
- export declare const getObjectHeadsAll: (bucket: string, s3paths: string[]) => Promise<HeadObject[] | null>;
66
- /**
67
- * Delete a file in S3 bucket
68
- * @param bucket S3 bucket name
69
- * @param s3path S3 file path to be deleted
70
- * @returns true if delete is successful, null in case of error
71
- */
72
- export declare const deleteObject: (bucket: string, s3path: string) => Promise<true | null>;
73
- /**
74
- * Delete a list of files in S3 bucket
75
- * @param bucket S3 bucket name
76
- * @param s3paths list of S3 file paths to be deleted
77
- * @returns true if all deletes are successful, null in case of error
78
- */
79
- export declare const deleteObjectsAll: (bucket: string, s3paths: string[]) => Promise<true | null>;
80
- export interface HeadObject {
81
- Key: string;
82
- ContentLength?: number;
83
- ContentType?: string;
84
- ETag?: string;
85
- CacheControl?: string;
86
- Expires?: Date;
87
- LastModified?: Date;
88
- Metadata?: StringIndexable;
89
- }
90
- //# sourceMappingURL=s3.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../../src/aws/s3.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwBH,OAAO,EAAE,eAAe,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
@@ -1,4 +0,0 @@
1
- export interface StringIndexable<T = any> {
2
- [key: string]: T;
3
- }
4
- //# sourceMappingURL=common.model.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.model.d.ts","sourceRoot":"","sources":["../../../src/common/common.model.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,GAAG;IACtC,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;CAClB"}
@@ -1,4 +0,0 @@
1
- export declare const BATCH_SIZE = 20;
2
- export declare const CHUNK_SIZE = 10;
3
- export declare const MAX_RETRY_ATTEMPTS = 3;
4
- //# sourceMappingURL=const.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../../src/common/const.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,kBAAkB,IAAI,CAAC"}
@@ -1,4 +0,0 @@
1
- export declare class CustomError extends Error {
2
- constructor(message: string, options?: any);
3
- }
4
- //# sourceMappingURL=error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/common/error.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,GAAQ;CAU/C"}
@@ -1,29 +0,0 @@
1
- declare const log: {
2
- (...data: any[]): void;
3
- (message?: any, ...optionalParams: any[]): void;
4
- };
5
- declare const warn: {
6
- (...data: any[]): void;
7
- (message?: any, ...optionalParams: any[]): void;
8
- };
9
- declare const error: {
10
- (...data: any[]): void;
11
- (message?: any, ...optionalParams: any[]): void;
12
- };
13
- export { log, warn, error };
14
- declare const _default: {
15
- log: {
16
- (...data: any[]): void;
17
- (message?: any, ...optionalParams: any[]): void;
18
- };
19
- warn: {
20
- (...data: any[]): void;
21
- (message?: any, ...optionalParams: any[]): void;
22
- };
23
- error: {
24
- (...data: any[]): void;
25
- (message?: any, ...optionalParams: any[]): void;
26
- };
27
- };
28
- export default _default;
29
- //# sourceMappingURL=logger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/common/logger.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,GAAG;;;CAAO,CAAC;AACjB,QAAA,MAAM,IAAI;;;CAAQ,CAAC;AACnB,QAAA,MAAM,KAAK;;;CAAS,CAAC;AAErB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;;;;;;;;;;;;;;AAC5B,wBAAoC"}
@@ -1,102 +0,0 @@
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
- export 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
- export 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
- export 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
- export 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
- export 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
- export 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
- export 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
- export 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
- export 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
- export 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
- export 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
- export 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
- export 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
- export declare const deleteDir: (dir: string) => Promise<true | null>;
102
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fs/index.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,eAAO,MAAM,cAAc,SAAU,MAAM,mCAiB1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAS,MAAM,mCAiBxC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,SAAgB,MAAM,2CAU1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,SAAU,MAAM,kCAUxC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,QAAe,MAAM;;;SA2BxC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,QAAe,MAAM,oEAI7C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QAAe,MAAM,oEAI5C,CAAC;AA0BF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QAAe,MAAM,oDAMhD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,SAAgB,MAAM,YAAY,MAAM,yBAY7D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,SAAgB,MAAM,YAAY,MAAM,yBAkBhE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,YAAmB,MAAM,WAAW,MAAM,yBAWhE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,QAAe,MAAM,yBAY1C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,SAAgB,MAAM,yBAU5C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,QAAe,MAAM,yBAe1C,CAAC"}
@@ -1,22 +0,0 @@
1
- /**
2
- * Initialize GitHub SDK
3
- * @param authToken GitHub auth token for the user account [GITHUB_TOKEN]
4
- * @param account account id for the GitHub user account [GITHUB_ACCOUNT]
5
- */
6
- export declare const init: (authToken: string, account: string) => void;
7
- /**
8
- * Get contents of a particular file in a repo
9
- * @param repo name of the repo
10
- * @param path path of a file in the repo
11
- * @returns an object {response,headers} containing response and response headers, null in case of error
12
- */
13
- export declare const getContent: (repo: string, path: string) => Promise<{
14
- response: GitHubContent;
15
- headers: import("@octokit/types").ResponseHeaders;
16
- } | null>;
17
- export interface GitHubContent {
18
- path: string;
19
- content: string;
20
- sha: string;
21
- }
22
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gh/index.ts"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,eAAO,MAAM,IAAI,cAAe,MAAM,WAAW,MAAM,SAOtD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,SAAgB,MAAM,QAAQ,MAAM;;;SAiB1D,CAAC;AAIF,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb"}
@@ -1,13 +0,0 @@
1
- import * as fs from './fs';
2
- import * as aws from './aws';
3
- import * as gh from './gh';
4
- import * as utils from './utils';
5
- export { fs, aws, gh, utils };
6
- declare const _default: {
7
- fs: typeof fs;
8
- aws: typeof aws;
9
- gh: typeof gh;
10
- utils: typeof utils;
11
- };
12
- export default _default;
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAGjC,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;;;;;;;AAC9B,wBAAsC"}
@@ -1,6 +0,0 @@
1
- /// <reference types="node" />
2
- export declare const assertPath: (p: string) => string;
3
- export declare const sha1Hash: (data: string) => string | null;
4
- export declare const sha256Hash: (data: string | Buffer) => string | null;
5
- export declare const fileHash: (file: string) => Promise<string | null>;
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";AAMA,eAAO,MAAM,UAAU,MAAO,MAAM,WAGnC,CAAC;AAEF,eAAO,MAAM,QAAQ,SAAU,MAAM,kBAKpC,CAAC;AAEF,eAAO,MAAM,UAAU,SAAU,MAAM,GAAG,MAAM,kBAK/C,CAAC;AAEF,eAAO,MAAM,QAAQ,SAAgB,MAAM,2BAa1C,CAAC"}
package/src/aws/client.ts DELETED
@@ -1,18 +0,0 @@
1
- import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
2
- import { S3Client } from '@aws-sdk/client-s3';
3
-
4
- const dbDocClient: DynamoDBDocumentClient | null = null;
5
- const awsS3Client: S3Client | null = null;
6
-
7
- export const dbClient = { client: dbDocClient, id: null } as DBClientType;
8
- export const s3Client = { client: awsS3Client, id: null } as S3ClientType;
9
-
10
- export interface DBClientType {
11
- client: DynamoDBDocumentClient | null;
12
- id: string | null;
13
- }
14
-
15
- export interface S3ClientType {
16
- client: S3Client | null;
17
- id: string | null;
18
- }