@8ms/helpers 2.0.29 → 2.0.31
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/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/string/getCapitalised.js +7 -0
- package/string/getProperCase.d.ts +1 -1
- package/string/getProperCase.js +32 -10
- package/string/reservedWords.d.ts +5 -0
- package/string/reservedWords.js +26 -0
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
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";
|
package/package.json
CHANGED
package/string/getCapitalised.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCapitalised = void 0;
|
|
4
|
+
const reservedWords_1 = require("./reservedWords");
|
|
4
5
|
/**
|
|
5
6
|
* Convert a string into Capitalised Text.
|
|
6
7
|
* https://stackoverflow.com/a/196991/2664955
|
|
@@ -10,6 +11,12 @@ const getCapitalised = (input, split = "_") => {
|
|
|
10
11
|
return input
|
|
11
12
|
.replace(regex, " ")
|
|
12
13
|
.replace(/\w\S*/g, function (txt) {
|
|
14
|
+
// Check if individual word is reserved
|
|
15
|
+
const reservedWord = (0, reservedWords_1.isReservedWord)(txt);
|
|
16
|
+
if (reservedWord) {
|
|
17
|
+
return reservedWord;
|
|
18
|
+
}
|
|
19
|
+
// Regular capitalization for non-reserved words
|
|
13
20
|
return txt.charAt(0)
|
|
14
21
|
.toUpperCase() + txt.substr(1)
|
|
15
22
|
.toLowerCase();
|
package/string/getProperCase.js
CHANGED
|
@@ -1,25 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getProperCase = void 0;
|
|
4
|
+
const reservedWords_1 = require("./reservedWords");
|
|
4
5
|
/**
|
|
5
6
|
* Return a string "With Proper Casing".
|
|
6
7
|
*/
|
|
7
8
|
const getProperCase = (props) => {
|
|
8
|
-
|
|
9
|
+
const cleanInput = props.input.toString()
|
|
10
|
+
.trim();
|
|
11
|
+
// Don't process if the entire input is a reserved word
|
|
12
|
+
if (reservedWords_1.reservedWords.includes(cleanInput.toUpperCase())) {
|
|
13
|
+
return cleanInput;
|
|
14
|
+
}
|
|
15
|
+
// Build the split pattern - always include spaces
|
|
16
|
+
let splitPattern = /\s+/;
|
|
17
|
+
// Add optional separators based on user preferences
|
|
18
|
+
const separators = [];
|
|
9
19
|
if (props?.hyphen) {
|
|
10
|
-
|
|
11
|
-
.join(" ");
|
|
20
|
+
separators.push("-");
|
|
12
21
|
}
|
|
13
22
|
if (props?.pipe) {
|
|
14
|
-
|
|
15
|
-
.join(" ");
|
|
23
|
+
separators.push("\\|");
|
|
16
24
|
}
|
|
17
25
|
if (props?.underscore) {
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
separators.push("_");
|
|
27
|
+
}
|
|
28
|
+
if (separators.length > 0) {
|
|
29
|
+
splitPattern = new RegExp(`[\\s${separators.join("")}]+`, "g");
|
|
20
30
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.
|
|
31
|
+
// Split the input into words and apply proper casing
|
|
32
|
+
const words = cleanInput.split(splitPattern)
|
|
33
|
+
.filter(word => word.length > 0) // Remove empty strings
|
|
34
|
+
.map(word => {
|
|
35
|
+
// Check if individual word is reserved
|
|
36
|
+
const reservedWord = (0, reservedWords_1.isReservedWord)(word);
|
|
37
|
+
if (reservedWord) {
|
|
38
|
+
return reservedWord;
|
|
39
|
+
}
|
|
40
|
+
// Apply proper case
|
|
41
|
+
return word.charAt(0)
|
|
42
|
+
.toUpperCase() + word.slice(1)
|
|
43
|
+
.toLowerCase();
|
|
44
|
+
});
|
|
45
|
+
return words.join(' ');
|
|
24
46
|
};
|
|
25
47
|
exports.getProperCase = getProperCase;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isReservedWord = exports.reservedWords = void 0;
|
|
4
|
+
exports.reservedWords = [
|
|
5
|
+
"AI",
|
|
6
|
+
"GA4",
|
|
7
|
+
"GSC",
|
|
8
|
+
"OpenAI",
|
|
9
|
+
"PPC",
|
|
10
|
+
"SEO",
|
|
11
|
+
"UpTimeRobot",
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* Check if its a reserved word, the casing may be specific eg, OpenAI.
|
|
15
|
+
*/
|
|
16
|
+
const isReservedWord = (word) => {
|
|
17
|
+
let response = null;
|
|
18
|
+
for (let i = 0; i < exports.reservedWords.length; i++) {
|
|
19
|
+
if (exports.reservedWords[i].toLowerCase() === word.toLowerCase()) {
|
|
20
|
+
response = exports.reservedWords[i];
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return response;
|
|
25
|
+
};
|
|
26
|
+
exports.isReservedWord = isReservedWord;
|