@8ms/helpers 2.0.28 → 2.0.30
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/.yarn/install-state.gz +0 -0
- package/api/ApiResponseClass.d.ts +1 -1
- package/aws/s3/AwsS3Namespace.js +1 -10
- package/aws/s3/server.d.ts +1 -13
- package/aws/s3/server.js +2 -13
- package/file/index.d.ts +4 -0
- package/file/index.js +25 -1
- package/google/bigQuery/GoogleBigQueryNamespace.d.ts +2 -2
- package/google/bigQuery/server.d.ts +1 -0
- package/package.json +1 -1
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
|
@@ -25,7 +25,7 @@ export declare class ApiResponseClass<T = any, E = any> {
|
|
|
25
25
|
isSuccess: () => boolean;
|
|
26
26
|
setToIdle: () => this;
|
|
27
27
|
setToPending: () => this;
|
|
28
|
-
setToError: (error: any, body
|
|
28
|
+
setToError: (error: any, body?: any) => this;
|
|
29
29
|
setToSuccess: (body: any) => this;
|
|
30
30
|
setBody: (body: any) => this;
|
|
31
31
|
setError: (error: any) => this;
|
package/aws/s3/AwsS3Namespace.js
CHANGED
|
@@ -286,17 +286,8 @@ class AwsS3Namespace extends _class_1.BaseNamespace {
|
|
|
286
286
|
}));
|
|
287
287
|
//console.log('apiResponse', apiResponse);
|
|
288
288
|
if ((0, server_1.isResponse200)(apiResponse)) {
|
|
289
|
-
let modified = (0, date_1.getDate)(apiResponse.LastModified);
|
|
290
289
|
// Convert the date to unix
|
|
291
|
-
response.modified
|
|
292
|
-
// Compare now to unix
|
|
293
|
-
response.modified.vs_now.months = today.diff(modified, "months").months;
|
|
294
|
-
response.modified.vs_now.days = today.diff(modified, "days").days;
|
|
295
|
-
response.modified.vs_now.hours = today.diff(modified, "hours").hours;
|
|
296
|
-
response.modified.vs_now.minutes = today.diff(modified, "minutes").minutes;
|
|
297
|
-
// Compare now to midnight
|
|
298
|
-
response.modified.vs_midnight.hours = today.diff(midnight, "hours").hours;
|
|
299
|
-
response.modified.vs_midnight.minutes = today.diff(midnight, "minutes").hours;
|
|
290
|
+
response.modified = (0, date_1.getYmdHisString)(apiResponse.LastModified);
|
|
300
291
|
// Convert stream into a string
|
|
301
292
|
response.body = await (0, string_1.getStringFromStream)(apiResponse.Body);
|
|
302
293
|
}
|
package/aws/s3/server.d.ts
CHANGED
|
@@ -3,19 +3,7 @@ import { AwsConfig } from "../server";
|
|
|
3
3
|
export declare const awsS3Client: (key?: string, config?: AwsConfig, vaultId?: string, itemId?: string) => Promise<AwsS3Namespace>;
|
|
4
4
|
export type Modified = {
|
|
5
5
|
now: number;
|
|
6
|
-
modified:
|
|
7
|
-
unix: null | number;
|
|
8
|
-
vs_now: {
|
|
9
|
-
months: number;
|
|
10
|
-
days: number;
|
|
11
|
-
hours: number;
|
|
12
|
-
minutes: number;
|
|
13
|
-
};
|
|
14
|
-
vs_midnight: {
|
|
15
|
-
hours: number;
|
|
16
|
-
minutes: number;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
6
|
+
modified: string;
|
|
19
7
|
};
|
|
20
8
|
export type ReadFileResponse = Modified & {
|
|
21
9
|
body: any;
|
package/aws/s3/server.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.payloadSchema = exports.readFileDefault = exports.awsS3Client = void 0;
|
|
4
4
|
const AwsS3Namespace_1 = require("./AwsS3Namespace");
|
|
5
5
|
const server_1 = require("../server");
|
|
6
|
+
const date_1 = require("../../date");
|
|
6
7
|
const awsS3Namespaces = new Map();
|
|
7
8
|
const awsS3Client = async (key = "default", config, vaultId, itemId) => {
|
|
8
9
|
if (awsS3Namespaces.has(key)) {
|
|
@@ -18,19 +19,7 @@ exports.readFileDefault = {
|
|
|
18
19
|
body: undefined,
|
|
19
20
|
now: undefined,
|
|
20
21
|
error: undefined,
|
|
21
|
-
modified:
|
|
22
|
-
unix: null,
|
|
23
|
-
vs_now: {
|
|
24
|
-
months: 0,
|
|
25
|
-
days: 0,
|
|
26
|
-
hours: 0,
|
|
27
|
-
minutes: 0,
|
|
28
|
-
},
|
|
29
|
-
vs_midnight: {
|
|
30
|
-
hours: 0,
|
|
31
|
-
minutes: 0,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
22
|
+
modified: date_1.defaultDateTime,
|
|
34
23
|
};
|
|
35
24
|
var payload_1 = require("./payload");
|
|
36
25
|
Object.defineProperty(exports, "payloadSchema", { enumerable: true, get: function () { return payload_1.payloadSchema; } });
|
package/file/index.d.ts
CHANGED
package/file/index.js
CHANGED
|
@@ -33,7 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.createDirectory = void 0;
|
|
36
|
+
exports.getFileKey = exports.createDirectory = void 0;
|
|
37
|
+
const date_1 = require("../date");
|
|
38
|
+
const luxon_1 = require("luxon");
|
|
37
39
|
/**
|
|
38
40
|
* Create a directory recursively.
|
|
39
41
|
* Requires fs-extra
|
|
@@ -48,3 +50,25 @@ const createDirectory = (filePath) => {
|
|
|
48
50
|
});
|
|
49
51
|
};
|
|
50
52
|
exports.createDirectory = createDirectory;
|
|
53
|
+
/**
|
|
54
|
+
* Create a file key from the inputs so it can handle objects/number/etc.
|
|
55
|
+
*/
|
|
56
|
+
const getFileKey = (inputs) => {
|
|
57
|
+
let response = "";
|
|
58
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
59
|
+
if (i > 0) {
|
|
60
|
+
response += "/";
|
|
61
|
+
}
|
|
62
|
+
if ("string" === typeof inputs[i]) {
|
|
63
|
+
response += inputs[i];
|
|
64
|
+
}
|
|
65
|
+
else if (inputs[i] instanceof Date || inputs[i] instanceof luxon_1.DateTime) {
|
|
66
|
+
response += (0, date_1.format)(inputs[i], "YYYY-MM-DD");
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
response += JSON.stringify(inputs[i]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return response;
|
|
73
|
+
};
|
|
74
|
+
exports.getFileKey = getFileKey;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseNamespace } from "../../_class";
|
|
2
2
|
import type { BigQuery, QueryOptions } from "@google-cloud/bigquery";
|
|
3
3
|
import { GoogleCloudConfig } from "../server";
|
|
4
|
-
type
|
|
4
|
+
export type QueryInput = string | {
|
|
5
5
|
query: string;
|
|
6
6
|
location?: string;
|
|
7
7
|
params: QueryOptions;
|
|
@@ -33,7 +33,7 @@ export declare class GoogleBigQueryNamespace extends BaseNamespace {
|
|
|
33
33
|
* Retrieve all the Datasets
|
|
34
34
|
*/
|
|
35
35
|
getDataset: () => Promise<Datasets[]>;
|
|
36
|
-
query: (props:
|
|
36
|
+
query: (props: QueryInput) => Promise<any>;
|
|
37
37
|
/**
|
|
38
38
|
* Create a Table if it doesn't already exist.
|
|
39
39
|
*/
|
|
@@ -3,3 +3,4 @@ import type { GoogleAuthOptions } from "@google-cloud/common";
|
|
|
3
3
|
export declare const googleBigQueryClient: (key?: string, config?: GoogleAuthOptions, vaultId?: string, itemId?: string) => Promise<GoogleBigQueryNamespace>;
|
|
4
4
|
export declare const getHandlerPath: (input: string) => string;
|
|
5
5
|
export { loadData } from "./loadData";
|
|
6
|
+
export type { QueryInput } from "./GoogleBigQueryNamespace";
|