@8ms/helpers 3.0.23 → 3.0.25
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/dist/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/aws/glue/server/AwsGlue.cjs +2 -1
- package/dist/aws/glue/server/AwsGlue.mjs +2 -1
- package/dist/aws/lambda/server/AwsLambda.cjs +10 -8
- package/dist/aws/lambda/server/AwsLambda.mjs +10 -8
- package/dist/aws/s3/server/AwsS3.cjs +3 -2
- package/dist/aws/s3/server/AwsS3.mjs +3 -2
- package/dist/aws/ssm/server/AwsSsm.cjs +5 -4
- package/dist/aws/ssm/server/AwsSsm.mjs +5 -4
- package/dist/brightData/serpApi/server/buildGoogleSerpUrl.cjs +0 -2
- package/dist/brightData/serpApi/server/buildGoogleSerpUrl.mjs +0 -2
- package/dist/brightData/serpApi/server/buildGoogleTrendsUrl.cjs +0 -1
- package/dist/brightData/serpApi/server/buildGoogleTrendsUrl.mjs +0 -1
- package/dist/brightData/serpApi/server/getAsyncResults.cjs +7 -4
- package/dist/brightData/serpApi/server/getAsyncResults.mjs +7 -4
- package/dist/brightData/webScraperIde/server/getRealtime.cjs +10 -6
- package/dist/brightData/webScraperIde/server/getRealtime.mjs +10 -6
- package/dist/date/calculation.cjs +27 -24
- package/dist/date/calculation.mjs +27 -24
- package/dist/emsApi/awsTs/get.cjs +2 -1
- package/dist/emsApi/awsTs/get.mjs +2 -1
- package/dist/emsApi/awsTs/post.cjs +2 -1
- package/dist/emsApi/awsTs/post.mjs +2 -1
- package/dist/emsApi/vercel/get.cjs +2 -1
- package/dist/emsApi/vercel/get.mjs +2 -1
- package/dist/emsApi/vercel/post.cjs +2 -1
- package/dist/emsApi/vercel/post.mjs +2 -1
- package/dist/googleCloud/drive/server/GoogleCloudDrive.cjs +139 -0
- package/dist/googleCloud/drive/server/GoogleCloudDrive.d.cts +53 -0
- package/dist/googleCloud/drive/server/GoogleCloudDrive.d.mts +53 -0
- package/dist/googleCloud/drive/server/GoogleCloudDrive.mjs +138 -0
- package/dist/googleCloud/drive/server/index.cjs +3 -0
- package/dist/googleCloud/drive/server/index.d.cts +2 -0
- package/dist/googleCloud/drive/server/index.d.mts +2 -0
- package/dist/googleCloud/drive/server/index.mjs +2 -0
- package/dist/googleCloud/sheets/server/GoogleCloudSheets.d.cts +1 -2
- package/dist/googleCloud/sheets/server/GoogleCloudSheets.d.mts +1 -2
- package/dist/googlePageSpeed/server/GooglePageSpeed.cjs +2 -1
- package/dist/googlePageSpeed/server/GooglePageSpeed.mjs +2 -1
- package/dist/greenDomain/server/greenDomain.cjs +2 -1
- package/dist/greenDomain/server/greenDomain.mjs +2 -1
- package/dist/littleWarden/server/LittleWarden.cjs +2 -1
- package/dist/littleWarden/server/LittleWarden.mjs +2 -1
- package/dist/lumar/api/server/buildRequest.cjs +0 -1
- package/dist/lumar/api/server/buildRequest.mjs +0 -1
- package/dist/snapchat/server/Snapchat.cjs +3 -2
- package/dist/snapchat/server/Snapchat.mjs +3 -2
- package/dist/util/defaultTo.cjs +6 -3
- package/dist/util/defaultTo.mjs +6 -3
- package/dist/xlsx/cell.cjs +102 -0
- package/dist/xlsx/cell.d.cts +38 -0
- package/dist/xlsx/cell.d.mts +38 -0
- package/dist/xlsx/cell.mjs +97 -0
- package/dist/xlsx/column.cjs +37 -0
- package/dist/xlsx/column.d.cts +23 -0
- package/dist/xlsx/column.d.mts +23 -0
- package/dist/xlsx/column.mjs +35 -0
- package/dist/xlsx/createXlsx.cjs +138 -0
- package/dist/xlsx/createXlsx.d.cts +18 -0
- package/dist/xlsx/createXlsx.d.mts +18 -0
- package/dist/xlsx/createXlsx.mjs +136 -0
- package/dist/xlsx/index.cjs +18 -0
- package/dist/xlsx/index.d.cts +6 -0
- package/dist/xlsx/index.d.mts +6 -0
- package/dist/xlsx/index.mjs +6 -0
- package/dist/xlsx/modifyXlsx.cjs +125 -0
- package/dist/xlsx/modifyXlsx.d.cts +24 -0
- package/dist/xlsx/modifyXlsx.d.mts +24 -0
- package/dist/xlsx/modifyXlsx.mjs +124 -0
- package/dist/xlsx/sheet.cjs +36 -0
- package/dist/xlsx/sheet.d.cts +29 -0
- package/dist/xlsx/sheet.d.mts +29 -0
- package/dist/xlsx/sheet.mjs +34 -0
- package/package.json +110 -51
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require__class_BaseNamespace = require("../../../_class/BaseNamespace.cjs");
|
|
3
|
+
const require_util_server_getGzipCompressed = require("../../../util/server/getGzipCompressed.cjs");
|
|
4
|
+
const require_util_server_getGzipDecompressed = require("../../../util/server/getGzipDecompressed.cjs");
|
|
5
|
+
//#region src/googleCloud/drive/server/GoogleCloudDrive.ts
|
|
6
|
+
var GoogleCloudDrive = class extends require__class_BaseNamespace.BaseNamespace {
|
|
7
|
+
/**
|
|
8
|
+
* Either a Google Cloud JSON Config or V10 Auth helper.
|
|
9
|
+
*/
|
|
10
|
+
init = async (isOidc, config, projectId, region) => {
|
|
11
|
+
if (!this.client) try {
|
|
12
|
+
const googleApisDrive = await import("@googleapis/drive");
|
|
13
|
+
this.client = new googleApisDrive.auth.GoogleAuth({
|
|
14
|
+
authClient: isOidc ? config : void 0,
|
|
15
|
+
credentials: isOidc ? void 0 : config,
|
|
16
|
+
projectId,
|
|
17
|
+
scopes: ["https://www.googleapis.com/auth/drive"]
|
|
18
|
+
});
|
|
19
|
+
} catch (e) {
|
|
20
|
+
throw new Error("Google Drive Client not installed");
|
|
21
|
+
}
|
|
22
|
+
return this;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* List the files within the given (optional) parent folder.
|
|
26
|
+
*/
|
|
27
|
+
listFiles = async (parentFolderId) => {
|
|
28
|
+
const googleApisDrive = await import("@googleapis/drive");
|
|
29
|
+
const parentClause = parentFolderId ? `'${parentFolderId}' in parents and ` : "";
|
|
30
|
+
const apiResponse = await googleApisDrive.drive("v3").files.list({
|
|
31
|
+
auth: this.client,
|
|
32
|
+
fields: "files(id, name, mimeType, modifiedTime)",
|
|
33
|
+
q: `${parentClause}mimeType != 'application/vnd.google-apps.folder' and trashed = false`
|
|
34
|
+
});
|
|
35
|
+
if (!apiResponse?.data?.files) return [];
|
|
36
|
+
return apiResponse.data.files.filter((file) => !!file?.id).map((file) => ({
|
|
37
|
+
id: file.id,
|
|
38
|
+
name: file.name ?? "",
|
|
39
|
+
mimeType: file.mimeType ?? "",
|
|
40
|
+
modifiedTime: file.modifiedTime ?? ""
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* List the folders within the given (optional) parent folder.
|
|
45
|
+
*/
|
|
46
|
+
listFolders = async (parentFolderId) => {
|
|
47
|
+
const googleApisDrive = await import("@googleapis/drive");
|
|
48
|
+
const parentClause = parentFolderId ? `'${parentFolderId}' in parents and ` : "";
|
|
49
|
+
const apiResponse = await googleApisDrive.drive("v3").files.list({
|
|
50
|
+
auth: this.client,
|
|
51
|
+
fields: "files(id, name, mimeType, modifiedTime)",
|
|
52
|
+
q: `${parentClause}mimeType = 'application/vnd.google-apps.folder' and trashed = false`
|
|
53
|
+
});
|
|
54
|
+
if (!apiResponse?.data?.files) return [];
|
|
55
|
+
return apiResponse.data.files.filter((file) => !!file?.id).map((file) => ({
|
|
56
|
+
id: file.id,
|
|
57
|
+
name: file.name ?? "",
|
|
58
|
+
mimeType: file.mimeType ?? "",
|
|
59
|
+
modifiedTime: file.modifiedTime ?? ""
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Check to see if a file with the given name exists in the given parent folder.
|
|
64
|
+
*/
|
|
65
|
+
fileExists = async (parentFolderId, fileName) => {
|
|
66
|
+
let response = false;
|
|
67
|
+
try {
|
|
68
|
+
response = 0 < ((await (await import("@googleapis/drive")).drive("v3").files.list({
|
|
69
|
+
auth: this.client,
|
|
70
|
+
fields: "files(id)",
|
|
71
|
+
q: `name = '${fileName}' and '${parentFolderId}' in parents and trashed = false`
|
|
72
|
+
}))?.data?.files?.length ?? 0);
|
|
73
|
+
} catch (exception) {
|
|
74
|
+
response = false;
|
|
75
|
+
}
|
|
76
|
+
return response;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Move a file to the Google Drive trash.
|
|
80
|
+
*/
|
|
81
|
+
deleteFile = async (fileId) => {
|
|
82
|
+
await (await import("@googleapis/drive")).drive("v3").files.update({
|
|
83
|
+
auth: this.client,
|
|
84
|
+
fileId,
|
|
85
|
+
requestBody: { trashed: true }
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Write a file to Google Drive within the given parent folder.
|
|
90
|
+
*/
|
|
91
|
+
writeFile = async (parentFolderId, fileName, data, options = {}) => {
|
|
92
|
+
return (await (await import("@googleapis/drive")).drive("v3").files.create({
|
|
93
|
+
auth: this.client,
|
|
94
|
+
fields: "id, name",
|
|
95
|
+
media: {
|
|
96
|
+
body: data,
|
|
97
|
+
mimeType: options.mimeType ?? "text/plain"
|
|
98
|
+
},
|
|
99
|
+
requestBody: {
|
|
100
|
+
name: fileName,
|
|
101
|
+
parents: [parentFolderId]
|
|
102
|
+
}
|
|
103
|
+
})).data;
|
|
104
|
+
};
|
|
105
|
+
writeJson = async (parentFolderId, fileName, data, options = {}) => {
|
|
106
|
+
return await this.writeFile(parentFolderId, fileName, JSON.stringify(data), options);
|
|
107
|
+
};
|
|
108
|
+
writeJsonGzip = async (parentFolderId, fileName, data, gzipOptions = {}, driveOptions = {}) => {
|
|
109
|
+
let finalData = JSON.stringify(data);
|
|
110
|
+
finalData = await require_util_server_getGzipCompressed.getGzipCompressed(finalData, gzipOptions);
|
|
111
|
+
return await this.writeFile(parentFolderId, fileName, finalData, driveOptions);
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Read a file's contents from Google Drive.
|
|
115
|
+
*/
|
|
116
|
+
readFile = async (fileId, options = {}) => {
|
|
117
|
+
return { body: (await (await import("@googleapis/drive")).drive("v3").files.get({
|
|
118
|
+
auth: this.client,
|
|
119
|
+
fileId,
|
|
120
|
+
alt: "media",
|
|
121
|
+
...options
|
|
122
|
+
}, { responseType: "text" })).data };
|
|
123
|
+
};
|
|
124
|
+
readJson = async (fileId) => {
|
|
125
|
+
const apiResponse = await this.readFile(fileId);
|
|
126
|
+
apiResponse.body = JSON.parse(apiResponse.body) || null;
|
|
127
|
+
return apiResponse;
|
|
128
|
+
};
|
|
129
|
+
readJsonGzip = async (fileId, gzipOptions = {}, driveOptions = {}) => {
|
|
130
|
+
const apiResponse = await this.readFile(fileId, driveOptions);
|
|
131
|
+
if (void 0 !== apiResponse.body) {
|
|
132
|
+
apiResponse.body = await require_util_server_getGzipDecompressed.getGzipDecompressed(apiResponse.body, gzipOptions);
|
|
133
|
+
apiResponse.body = JSON.parse(apiResponse.body) || null;
|
|
134
|
+
}
|
|
135
|
+
return apiResponse;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
//#endregion
|
|
139
|
+
exports.GoogleCloudDrive = GoogleCloudDrive;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { BaseNamespace } from "../../../_class/BaseNamespace.cjs";
|
|
2
|
+
//#region src/googleCloud/drive/server/GoogleCloudDrive.d.ts
|
|
3
|
+
type Options = {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
};
|
|
6
|
+
type DriveFile = {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
mimeType: string;
|
|
10
|
+
modifiedTime: string;
|
|
11
|
+
};
|
|
12
|
+
declare class GoogleCloudDrive extends BaseNamespace {
|
|
13
|
+
client: any;
|
|
14
|
+
config: any;
|
|
15
|
+
/**
|
|
16
|
+
* Either a Google Cloud JSON Config or V10 Auth helper.
|
|
17
|
+
*/
|
|
18
|
+
init: (isOidc: boolean, config: any, projectId: string, region?: string) => Promise<this>;
|
|
19
|
+
/**
|
|
20
|
+
* List the files within the given (optional) parent folder.
|
|
21
|
+
*/
|
|
22
|
+
listFiles: (parentFolderId?: string) => Promise<DriveFile[]>;
|
|
23
|
+
/**
|
|
24
|
+
* List the folders within the given (optional) parent folder.
|
|
25
|
+
*/
|
|
26
|
+
listFolders: (parentFolderId?: string) => Promise<DriveFile[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Check to see if a file with the given name exists in the given parent folder.
|
|
29
|
+
*/
|
|
30
|
+
fileExists: (parentFolderId: string, fileName: string) => Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Move a file to the Google Drive trash.
|
|
33
|
+
*/
|
|
34
|
+
deleteFile: (fileId: string) => Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Write a file to Google Drive within the given parent folder.
|
|
37
|
+
*/
|
|
38
|
+
writeFile: (parentFolderId: string, fileName: string, data: any, options?: Options) => Promise<import("@googleapis/drive").drive_v3.Schema$File>;
|
|
39
|
+
writeJson: (parentFolderId: string, fileName: string, data: any, options?: Options) => Promise<import("@googleapis/drive").drive_v3.Schema$File>;
|
|
40
|
+
writeJsonGzip: (parentFolderId: string, fileName: string, data: any, gzipOptions?: object, driveOptions?: Options) => Promise<import("@googleapis/drive").drive_v3.Schema$File>;
|
|
41
|
+
/**
|
|
42
|
+
* Read a file's contents from Google Drive.
|
|
43
|
+
*/
|
|
44
|
+
readFile: (fileId: string, options?: Options) => Promise<{
|
|
45
|
+
body: string;
|
|
46
|
+
}>;
|
|
47
|
+
readJson: (fileId: string) => Promise<{
|
|
48
|
+
body: string;
|
|
49
|
+
}>;
|
|
50
|
+
readJsonGzip: (fileId: string, gzipOptions?: object, driveOptions?: Options) => Promise<any>;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { GoogleCloudDrive };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { BaseNamespace } from "../../../_class/BaseNamespace.mjs";
|
|
2
|
+
//#region src/googleCloud/drive/server/GoogleCloudDrive.d.ts
|
|
3
|
+
type Options = {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
};
|
|
6
|
+
type DriveFile = {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
mimeType: string;
|
|
10
|
+
modifiedTime: string;
|
|
11
|
+
};
|
|
12
|
+
declare class GoogleCloudDrive extends BaseNamespace {
|
|
13
|
+
client: any;
|
|
14
|
+
config: any;
|
|
15
|
+
/**
|
|
16
|
+
* Either a Google Cloud JSON Config or V10 Auth helper.
|
|
17
|
+
*/
|
|
18
|
+
init: (isOidc: boolean, config: any, projectId: string, region?: string) => Promise<this>;
|
|
19
|
+
/**
|
|
20
|
+
* List the files within the given (optional) parent folder.
|
|
21
|
+
*/
|
|
22
|
+
listFiles: (parentFolderId?: string) => Promise<DriveFile[]>;
|
|
23
|
+
/**
|
|
24
|
+
* List the folders within the given (optional) parent folder.
|
|
25
|
+
*/
|
|
26
|
+
listFolders: (parentFolderId?: string) => Promise<DriveFile[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Check to see if a file with the given name exists in the given parent folder.
|
|
29
|
+
*/
|
|
30
|
+
fileExists: (parentFolderId: string, fileName: string) => Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Move a file to the Google Drive trash.
|
|
33
|
+
*/
|
|
34
|
+
deleteFile: (fileId: string) => Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Write a file to Google Drive within the given parent folder.
|
|
37
|
+
*/
|
|
38
|
+
writeFile: (parentFolderId: string, fileName: string, data: any, options?: Options) => Promise<import("@googleapis/drive").drive_v3.Schema$File>;
|
|
39
|
+
writeJson: (parentFolderId: string, fileName: string, data: any, options?: Options) => Promise<import("@googleapis/drive").drive_v3.Schema$File>;
|
|
40
|
+
writeJsonGzip: (parentFolderId: string, fileName: string, data: any, gzipOptions?: object, driveOptions?: Options) => Promise<import("@googleapis/drive").drive_v3.Schema$File>;
|
|
41
|
+
/**
|
|
42
|
+
* Read a file's contents from Google Drive.
|
|
43
|
+
*/
|
|
44
|
+
readFile: (fileId: string, options?: Options) => Promise<{
|
|
45
|
+
body: string;
|
|
46
|
+
}>;
|
|
47
|
+
readJson: (fileId: string) => Promise<{
|
|
48
|
+
body: string;
|
|
49
|
+
}>;
|
|
50
|
+
readJsonGzip: (fileId: string, gzipOptions?: object, driveOptions?: Options) => Promise<any>;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { GoogleCloudDrive };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { BaseNamespace } from "../../../_class/BaseNamespace.mjs";
|
|
2
|
+
import { getGzipCompressed } from "../../../util/server/getGzipCompressed.mjs";
|
|
3
|
+
import { getGzipDecompressed } from "../../../util/server/getGzipDecompressed.mjs";
|
|
4
|
+
//#region src/googleCloud/drive/server/GoogleCloudDrive.ts
|
|
5
|
+
var GoogleCloudDrive = class extends BaseNamespace {
|
|
6
|
+
/**
|
|
7
|
+
* Either a Google Cloud JSON Config or V10 Auth helper.
|
|
8
|
+
*/
|
|
9
|
+
init = async (isOidc, config, projectId, region) => {
|
|
10
|
+
if (!this.client) try {
|
|
11
|
+
const googleApisDrive = await import("@googleapis/drive");
|
|
12
|
+
this.client = new googleApisDrive.auth.GoogleAuth({
|
|
13
|
+
authClient: isOidc ? config : void 0,
|
|
14
|
+
credentials: isOidc ? void 0 : config,
|
|
15
|
+
projectId,
|
|
16
|
+
scopes: ["https://www.googleapis.com/auth/drive"]
|
|
17
|
+
});
|
|
18
|
+
} catch (e) {
|
|
19
|
+
throw new Error("Google Drive Client not installed");
|
|
20
|
+
}
|
|
21
|
+
return this;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* List the files within the given (optional) parent folder.
|
|
25
|
+
*/
|
|
26
|
+
listFiles = async (parentFolderId) => {
|
|
27
|
+
const googleApisDrive = await import("@googleapis/drive");
|
|
28
|
+
const parentClause = parentFolderId ? `'${parentFolderId}' in parents and ` : "";
|
|
29
|
+
const apiResponse = await googleApisDrive.drive("v3").files.list({
|
|
30
|
+
auth: this.client,
|
|
31
|
+
fields: "files(id, name, mimeType, modifiedTime)",
|
|
32
|
+
q: `${parentClause}mimeType != 'application/vnd.google-apps.folder' and trashed = false`
|
|
33
|
+
});
|
|
34
|
+
if (!apiResponse?.data?.files) return [];
|
|
35
|
+
return apiResponse.data.files.filter((file) => !!file?.id).map((file) => ({
|
|
36
|
+
id: file.id,
|
|
37
|
+
name: file.name ?? "",
|
|
38
|
+
mimeType: file.mimeType ?? "",
|
|
39
|
+
modifiedTime: file.modifiedTime ?? ""
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* List the folders within the given (optional) parent folder.
|
|
44
|
+
*/
|
|
45
|
+
listFolders = async (parentFolderId) => {
|
|
46
|
+
const googleApisDrive = await import("@googleapis/drive");
|
|
47
|
+
const parentClause = parentFolderId ? `'${parentFolderId}' in parents and ` : "";
|
|
48
|
+
const apiResponse = await googleApisDrive.drive("v3").files.list({
|
|
49
|
+
auth: this.client,
|
|
50
|
+
fields: "files(id, name, mimeType, modifiedTime)",
|
|
51
|
+
q: `${parentClause}mimeType = 'application/vnd.google-apps.folder' and trashed = false`
|
|
52
|
+
});
|
|
53
|
+
if (!apiResponse?.data?.files) return [];
|
|
54
|
+
return apiResponse.data.files.filter((file) => !!file?.id).map((file) => ({
|
|
55
|
+
id: file.id,
|
|
56
|
+
name: file.name ?? "",
|
|
57
|
+
mimeType: file.mimeType ?? "",
|
|
58
|
+
modifiedTime: file.modifiedTime ?? ""
|
|
59
|
+
}));
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Check to see if a file with the given name exists in the given parent folder.
|
|
63
|
+
*/
|
|
64
|
+
fileExists = async (parentFolderId, fileName) => {
|
|
65
|
+
let response = false;
|
|
66
|
+
try {
|
|
67
|
+
response = 0 < ((await (await import("@googleapis/drive")).drive("v3").files.list({
|
|
68
|
+
auth: this.client,
|
|
69
|
+
fields: "files(id)",
|
|
70
|
+
q: `name = '${fileName}' and '${parentFolderId}' in parents and trashed = false`
|
|
71
|
+
}))?.data?.files?.length ?? 0);
|
|
72
|
+
} catch (exception) {
|
|
73
|
+
response = false;
|
|
74
|
+
}
|
|
75
|
+
return response;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Move a file to the Google Drive trash.
|
|
79
|
+
*/
|
|
80
|
+
deleteFile = async (fileId) => {
|
|
81
|
+
await (await import("@googleapis/drive")).drive("v3").files.update({
|
|
82
|
+
auth: this.client,
|
|
83
|
+
fileId,
|
|
84
|
+
requestBody: { trashed: true }
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Write a file to Google Drive within the given parent folder.
|
|
89
|
+
*/
|
|
90
|
+
writeFile = async (parentFolderId, fileName, data, options = {}) => {
|
|
91
|
+
return (await (await import("@googleapis/drive")).drive("v3").files.create({
|
|
92
|
+
auth: this.client,
|
|
93
|
+
fields: "id, name",
|
|
94
|
+
media: {
|
|
95
|
+
body: data,
|
|
96
|
+
mimeType: options.mimeType ?? "text/plain"
|
|
97
|
+
},
|
|
98
|
+
requestBody: {
|
|
99
|
+
name: fileName,
|
|
100
|
+
parents: [parentFolderId]
|
|
101
|
+
}
|
|
102
|
+
})).data;
|
|
103
|
+
};
|
|
104
|
+
writeJson = async (parentFolderId, fileName, data, options = {}) => {
|
|
105
|
+
return await this.writeFile(parentFolderId, fileName, JSON.stringify(data), options);
|
|
106
|
+
};
|
|
107
|
+
writeJsonGzip = async (parentFolderId, fileName, data, gzipOptions = {}, driveOptions = {}) => {
|
|
108
|
+
let finalData = JSON.stringify(data);
|
|
109
|
+
finalData = await getGzipCompressed(finalData, gzipOptions);
|
|
110
|
+
return await this.writeFile(parentFolderId, fileName, finalData, driveOptions);
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Read a file's contents from Google Drive.
|
|
114
|
+
*/
|
|
115
|
+
readFile = async (fileId, options = {}) => {
|
|
116
|
+
return { body: (await (await import("@googleapis/drive")).drive("v3").files.get({
|
|
117
|
+
auth: this.client,
|
|
118
|
+
fileId,
|
|
119
|
+
alt: "media",
|
|
120
|
+
...options
|
|
121
|
+
}, { responseType: "text" })).data };
|
|
122
|
+
};
|
|
123
|
+
readJson = async (fileId) => {
|
|
124
|
+
const apiResponse = await this.readFile(fileId);
|
|
125
|
+
apiResponse.body = JSON.parse(apiResponse.body) || null;
|
|
126
|
+
return apiResponse;
|
|
127
|
+
};
|
|
128
|
+
readJsonGzip = async (fileId, gzipOptions = {}, driveOptions = {}) => {
|
|
129
|
+
const apiResponse = await this.readFile(fileId, driveOptions);
|
|
130
|
+
if (void 0 !== apiResponse.body) {
|
|
131
|
+
apiResponse.body = await getGzipDecompressed(apiResponse.body, gzipOptions);
|
|
132
|
+
apiResponse.body = JSON.parse(apiResponse.body) || null;
|
|
133
|
+
}
|
|
134
|
+
return apiResponse;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
//#endregion
|
|
138
|
+
export { GoogleCloudDrive };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BaseNamespace } from "../../../_class/BaseNamespace.cjs";
|
|
2
|
-
import { GoogleAuth } from "googleapis-common";
|
|
3
2
|
//#region src/googleCloud/sheets/server/GoogleCloudSheets.d.ts
|
|
4
3
|
type GetBatchDataProps = {
|
|
5
4
|
spreadsheetId: string;
|
|
@@ -8,7 +7,7 @@ type GetBatchDataProps = {
|
|
|
8
7
|
valueRender?: string;
|
|
9
8
|
};
|
|
10
9
|
declare class GoogleCloudSheets extends BaseNamespace {
|
|
11
|
-
client:
|
|
10
|
+
client: any;
|
|
12
11
|
config: any;
|
|
13
12
|
/**
|
|
14
13
|
* Either a Google Cloud JSON Config or V10 Auth helper.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BaseNamespace } from "../../../_class/BaseNamespace.mjs";
|
|
2
|
-
import { GoogleAuth } from "googleapis-common";
|
|
3
2
|
//#region src/googleCloud/sheets/server/GoogleCloudSheets.d.ts
|
|
4
3
|
type GetBatchDataProps = {
|
|
5
4
|
spreadsheetId: string;
|
|
@@ -8,7 +7,7 @@ type GetBatchDataProps = {
|
|
|
8
7
|
valueRender?: string;
|
|
9
8
|
};
|
|
10
9
|
declare class GoogleCloudSheets extends BaseNamespace {
|
|
11
|
-
client:
|
|
10
|
+
client: any;
|
|
12
11
|
config: any;
|
|
13
12
|
/**
|
|
14
13
|
* Either a Google Cloud JSON Config or V10 Auth helper.
|
|
@@ -18,7 +18,8 @@ var GooglePageSpeed = class extends require__class_BaseNamespace.BaseNamespace {
|
|
|
18
18
|
return this;
|
|
19
19
|
};
|
|
20
20
|
getReport = async (url, inputCategory = require_googlePageSpeed_server_category.category.PERFORMANCE, inputStrategy = require_googlePageSpeed_server_strategy.strategy.MOBILE) => {
|
|
21
|
-
const
|
|
21
|
+
const requestUrl = `https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=${url}&strategy=${inputStrategy}&category=${inputCategory}&key=${this.config.apiKey}`;
|
|
22
|
+
const apiResponse = await require_api_get.get(requestUrl);
|
|
22
23
|
if (apiResponse.isSuccess()) return apiResponse.getBody();
|
|
23
24
|
return null;
|
|
24
25
|
};
|
|
@@ -17,7 +17,8 @@ var GooglePageSpeed = class extends BaseNamespace {
|
|
|
17
17
|
return this;
|
|
18
18
|
};
|
|
19
19
|
getReport = async (url, inputCategory = category.PERFORMANCE, inputStrategy = strategy.MOBILE) => {
|
|
20
|
-
const
|
|
20
|
+
const requestUrl = `https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=${url}&strategy=${inputStrategy}&category=${inputCategory}&key=${this.config.apiKey}`;
|
|
21
|
+
const apiResponse = await get(requestUrl);
|
|
21
22
|
if (apiResponse.isSuccess()) return apiResponse.getBody();
|
|
22
23
|
return null;
|
|
23
24
|
};
|
|
@@ -6,7 +6,8 @@ let zod_v4 = require("zod/v4");
|
|
|
6
6
|
* https://developers.thegreenwebfoundation.org/api/greencheck/v3/check-single-domain/
|
|
7
7
|
*/
|
|
8
8
|
const getSingleReport = async (domain) => {
|
|
9
|
-
const
|
|
9
|
+
const url = `https://api.thegreenwebfoundation.org/greencheck/${domain}`;
|
|
10
|
+
const apiResponse = await require_api_get.get(url);
|
|
10
11
|
if (apiResponse.isSuccess()) return apiResponse.getBody();
|
|
11
12
|
return null;
|
|
12
13
|
};
|
|
@@ -5,7 +5,8 @@ import { z } from "zod/v4";
|
|
|
5
5
|
* https://developers.thegreenwebfoundation.org/api/greencheck/v3/check-single-domain/
|
|
6
6
|
*/
|
|
7
7
|
const getSingleReport = async (domain) => {
|
|
8
|
-
const
|
|
8
|
+
const url = `https://api.thegreenwebfoundation.org/greencheck/${domain}`;
|
|
9
|
+
const apiResponse = await get(url);
|
|
9
10
|
if (apiResponse.isSuccess()) return apiResponse.getBody();
|
|
10
11
|
return null;
|
|
11
12
|
};
|
|
@@ -16,7 +16,8 @@ var LittleWarden = class extends require__class_BaseNamespace.BaseNamespace {
|
|
|
16
16
|
return this;
|
|
17
17
|
};
|
|
18
18
|
getReport = async (urlId) => {
|
|
19
|
-
const
|
|
19
|
+
const url = `https://littlewarden.com/api/sites/${urlId}`;
|
|
20
|
+
const apiResponse = await require_api_get.get(url, { headers: { "Authorization": `Token token="${this.config.apiKey}"` } });
|
|
20
21
|
if (apiResponse.isSuccess()) return apiResponse.getBody();
|
|
21
22
|
return null;
|
|
22
23
|
};
|
|
@@ -15,7 +15,8 @@ var LittleWarden = class extends BaseNamespace {
|
|
|
15
15
|
return this;
|
|
16
16
|
};
|
|
17
17
|
getReport = async (urlId) => {
|
|
18
|
-
const
|
|
18
|
+
const url = `https://littlewarden.com/api/sites/${urlId}`;
|
|
19
|
+
const apiResponse = await get(url, { headers: { "Authorization": `Token token="${this.config.apiKey}"` } });
|
|
19
20
|
if (apiResponse.isSuccess()) return apiResponse.getBody();
|
|
20
21
|
return null;
|
|
21
22
|
};
|
|
@@ -33,7 +33,6 @@ const buildRequest = (props) => {
|
|
|
33
33
|
url += `/projects/${props.projectId}/crawls/${props.crawlId}/reports/${props.subReport}`;
|
|
34
34
|
if (require_lumar_api_server_lumarApi.report.REPORT_ROWS === props.report) url += `/report_rows`;
|
|
35
35
|
else if (require_lumar_api_server_lumarApi.report.REPORT_STATISTICS === props.report) url += `/statistics`;
|
|
36
|
-
break;
|
|
37
36
|
}
|
|
38
37
|
url += -1 === url.indexOf("?") ? "?" : "&";
|
|
39
38
|
url += `per_page=${props.limit}`;
|
|
@@ -32,7 +32,6 @@ const buildRequest = (props) => {
|
|
|
32
32
|
url += `/projects/${props.projectId}/crawls/${props.crawlId}/reports/${props.subReport}`;
|
|
33
33
|
if (report.REPORT_ROWS === props.report) url += `/report_rows`;
|
|
34
34
|
else if (report.REPORT_STATISTICS === props.report) url += `/statistics`;
|
|
35
|
-
break;
|
|
36
35
|
}
|
|
37
36
|
url += -1 === url.indexOf("?") ? "?" : "&";
|
|
38
37
|
url += `per_page=${props.limit}`;
|
|
@@ -10,9 +10,10 @@ var Snapchat = class extends require__class_BaseNamespace.BaseNamespace {
|
|
|
10
10
|
init = async (config) => {
|
|
11
11
|
if (!this.client) {
|
|
12
12
|
this.config = config;
|
|
13
|
-
const
|
|
13
|
+
const url = `https://accounts.snapchat.com/login/oauth2/access_token?client_id=${this.config.clientId}&client_secret=${this.config.clientSecret}&grant_type=refresh_token&refresh_token=${this.config.refreshToken}`;
|
|
14
|
+
const apiResponse = await require_api_post.post(url);
|
|
14
15
|
if (apiResponse.isSuccess()) this.client = {
|
|
15
|
-
expires: luxon.DateTime.now().toUnixInteger() +
|
|
16
|
+
expires: luxon.DateTime.now().toUnixInteger() + 108e5,
|
|
16
17
|
refreshToken: apiResponse.getBodyDefaultTo(["data", "access_token"], null)
|
|
17
18
|
};
|
|
18
19
|
}
|
|
@@ -9,9 +9,10 @@ var Snapchat = class extends BaseNamespace {
|
|
|
9
9
|
init = async (config) => {
|
|
10
10
|
if (!this.client) {
|
|
11
11
|
this.config = config;
|
|
12
|
-
const
|
|
12
|
+
const url = `https://accounts.snapchat.com/login/oauth2/access_token?client_id=${this.config.clientId}&client_secret=${this.config.clientSecret}&grant_type=refresh_token&refresh_token=${this.config.refreshToken}`;
|
|
13
|
+
const apiResponse = await post(url);
|
|
13
14
|
if (apiResponse.isSuccess()) this.client = {
|
|
14
|
-
expires: DateTime.now().toUnixInteger() +
|
|
15
|
+
expires: DateTime.now().toUnixInteger() + 108e5,
|
|
15
16
|
refreshToken: apiResponse.getBodyDefaultTo(["data", "access_token"], null)
|
|
16
17
|
};
|
|
17
18
|
}
|
package/dist/util/defaultTo.cjs
CHANGED
|
@@ -11,9 +11,12 @@ const defaultTo = (instance, keys, defaultValue = null) => {
|
|
|
11
11
|
let pointer = instance;
|
|
12
12
|
if ("undefined" === typeof instance || null === pointer) found = false;
|
|
13
13
|
else keysArray.forEach((key) => {
|
|
14
|
-
if (found)
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
if (found) {
|
|
15
|
+
if (require_lodash_isObject.isObject(pointer)) {
|
|
16
|
+
if ("undefined" === typeof pointer[key] || null === pointer[key]) found = false;
|
|
17
|
+
else pointer = pointer[key];
|
|
18
|
+
} else found = false;
|
|
19
|
+
}
|
|
17
20
|
});
|
|
18
21
|
return found ? pointer : defaultValue;
|
|
19
22
|
};
|
package/dist/util/defaultTo.mjs
CHANGED
|
@@ -10,9 +10,12 @@ const defaultTo = (instance, keys, defaultValue = null) => {
|
|
|
10
10
|
let pointer = instance;
|
|
11
11
|
if ("undefined" === typeof instance || null === pointer) found = false;
|
|
12
12
|
else keysArray.forEach((key) => {
|
|
13
|
-
if (found)
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (found) {
|
|
14
|
+
if (isObject(pointer)) {
|
|
15
|
+
if ("undefined" === typeof pointer[key] || null === pointer[key]) found = false;
|
|
16
|
+
else pointer = pointer[key];
|
|
17
|
+
} else found = false;
|
|
18
|
+
}
|
|
16
19
|
});
|
|
17
20
|
return found ? pointer : defaultValue;
|
|
18
21
|
};
|