@anmiles/google-api-wrapper 7.0.6 → 8.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/.eslintrc.js +1 -86
- package/.gitlab-ci.yml +0 -1
- package/.vscode/settings.json +0 -4
- package/CHANGELOG.md +11 -0
- package/README.md +5 -2
- package/dist/index.d.ts +5 -5
- package/dist/index.js +15 -15
- package/dist/lib/api/calendar.d.ts +3 -3
- package/dist/lib/api/calendar.js +13 -13
- package/dist/lib/api/shared.d.ts +23 -23
- package/dist/lib/api/shared.js +26 -23
- package/dist/lib/api/shared.js.map +1 -1
- package/dist/lib/api/youtube.d.ts +3 -3
- package/dist/lib/api/youtube.js +13 -13
- package/dist/lib/auth.d.ts +10 -10
- package/dist/lib/auth.js +34 -34
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/paths.d.ts +12 -16
- package/dist/lib/paths.js +28 -45
- package/dist/lib/paths.js.map +1 -1
- package/dist/lib/profiles.d.ts +11 -10
- package/dist/lib/profiles.js +33 -33
- package/dist/lib/profiles.js.map +1 -1
- package/dist/lib/secrets.d.ts +26 -22
- package/dist/lib/secrets.js +152 -146
- package/dist/lib/secrets.js.map +1 -1
- package/dist/types/common.d.ts +3 -3
- package/dist/types/common.js +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +18 -18
- package/dist/types/secrets.d.ts +15 -15
- package/dist/types/secrets.js +2 -2
- package/package.json +18 -15
- package/src/lib/__tests__/auth.test.ts +23 -23
- package/src/lib/__tests__/paths.test.ts +1 -63
- package/src/lib/__tests__/profiles.test.ts +25 -21
- package/src/lib/__tests__/secrets.test.ts +100 -94
- package/src/lib/api/__tests__/calendar.test.ts +3 -3
- package/src/lib/api/__tests__/shared.test.ts +12 -14
- package/src/lib/api/__tests__/youtube.test.ts +3 -3
- package/src/lib/api/shared.ts +2 -2
- package/src/lib/auth.ts +1 -1
- package/src/lib/paths.ts +2 -20
- package/src/lib/profiles.ts +5 -5
- package/src/lib/secrets.ts +24 -17
- package/dist/lib/jsonLib.d.ts +0 -14
- package/dist/lib/jsonLib.js +0 -56
- package/dist/lib/jsonLib.js.map +0 -1
- package/dist/lib/logger.d.ts +0 -12
- package/dist/lib/logger.js +0 -46
- package/dist/lib/logger.js.map +0 -1
- package/dist/lib/sleep.d.ts +0 -6
- package/dist/lib/sleep.js +0 -11
- package/dist/lib/sleep.js.map +0 -1
- package/src/lib/__tests__/jsonLib.test.ts +0 -253
- package/src/lib/__tests__/logger.test.ts +0 -57
- package/src/lib/__tests__/sleep.test.ts +0 -17
- package/src/lib/jsonLib.ts +0 -57
- package/src/lib/logger.ts +0 -21
- package/src/lib/sleep.ts +0 -8
package/.eslintrc.js
CHANGED
|
@@ -1,91 +1,6 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
root : true,
|
|
3
3
|
extends : [
|
|
4
|
-
'eslint
|
|
5
|
-
'plugin:jest/recommended',
|
|
4
|
+
'./node_modules/@anmiles/eslint-config/.eslintrc.js',
|
|
6
5
|
],
|
|
7
|
-
parser : '@typescript-eslint/parser',
|
|
8
|
-
parserOptions : {
|
|
9
|
-
ecmaVersion : 2019,
|
|
10
|
-
sourceType : 'module',
|
|
11
|
-
},
|
|
12
|
-
plugins : [
|
|
13
|
-
'@typescript-eslint',
|
|
14
|
-
'align-assignments',
|
|
15
|
-
'import',
|
|
16
|
-
'jest',
|
|
17
|
-
],
|
|
18
|
-
env : {
|
|
19
|
-
node : true,
|
|
20
|
-
jest : true,
|
|
21
|
-
},
|
|
22
|
-
ignorePatterns : [
|
|
23
|
-
'**/node_modules/',
|
|
24
|
-
'coverage/',
|
|
25
|
-
'dist/',
|
|
26
|
-
],
|
|
27
|
-
rules : {
|
|
28
|
-
'no-unused-vars' : [ 'off' ],
|
|
29
|
-
'@typescript-eslint/no-unused-vars' : [ 'error' ],
|
|
30
|
-
'align-assignments/align-assignments' : [ 'error' ],
|
|
31
|
-
'array-bracket-spacing' : [ 'error', 'always' ],
|
|
32
|
-
'arrow-body-style' : [ 'error' ],
|
|
33
|
-
'arrow-parens' : [ 'error' ],
|
|
34
|
-
'arrow-spacing' : [ 'error' ],
|
|
35
|
-
'block-spacing' : [ 'error' ],
|
|
36
|
-
'brace-style' : [ 'error' ],
|
|
37
|
-
'camelcase' : [ 'error' ],
|
|
38
|
-
'comma-dangle' : [ 'error', 'always-multiline' ],
|
|
39
|
-
'comma-spacing' : [ 'error' ],
|
|
40
|
-
'comma-style' : [ 'error' ],
|
|
41
|
-
'complexity' : [ 'error' ],
|
|
42
|
-
'computed-property-spacing' : [ 'error', 'never' ],
|
|
43
|
-
'curly' : [ 'error' ],
|
|
44
|
-
'dot-location' : [ 'error', 'property' ],
|
|
45
|
-
'eol-last' : [ 'error' ],
|
|
46
|
-
'func-call-spacing' : [ 'error' ],
|
|
47
|
-
'func-style' : [ 'error', 'declaration', { allowArrowFunctions : true } ],
|
|
48
|
-
'generator-star-spacing' : [ 'error', 'neither' ],
|
|
49
|
-
'import/order' : [ 'error', { groups : [ 'builtin', 'external', 'unknown', 'internal', 'parent', 'sibling', 'index' ] } ],
|
|
50
|
-
'indent' : [ 'error', 'tab', { SwitchCase : 1 } ],
|
|
51
|
-
'jest/no-standalone-expect' : [ 'error' ],
|
|
52
|
-
'key-spacing' : [ 'error', { beforeColon : true, afterColon : true, align : 'colon' } ],
|
|
53
|
-
'keyword-spacing' : [ 'error' ],
|
|
54
|
-
'linebreak-style' : [ 'error', 'unix' ],
|
|
55
|
-
'max-params' : [ 'error', { max : 5 } ],
|
|
56
|
-
'new-parens' : [ 'error' ],
|
|
57
|
-
'no-eval' : [ 'error' ],
|
|
58
|
-
'no-extra-bind' : [ 'error' ],
|
|
59
|
-
'no-floating-decimal' : [ 'error' ],
|
|
60
|
-
'no-implied-eval' : [ 'error' ],
|
|
61
|
-
'no-loop-func' : [ 'error' ],
|
|
62
|
-
'no-mixed-spaces-and-tabs' : [ 'error', 'smart-tabs' ],
|
|
63
|
-
'no-multiple-empty-lines' : [ 'error', { max : 1, maxEOF : 1, maxBOF : 0 } ],
|
|
64
|
-
'no-return-await' : [ 'error' ],
|
|
65
|
-
'no-trailing-spaces' : [ 'error' ],
|
|
66
|
-
'no-useless-rename' : [ 'error' ],
|
|
67
|
-
'no-var' : [ 'error' ],
|
|
68
|
-
'no-whitespace-before-property' : [ 'error' ],
|
|
69
|
-
'object-curly-spacing' : [ 'error', 'always' ],
|
|
70
|
-
'object-property-newline' : [ 'error', { allowMultiplePropertiesPerLine : true } ],
|
|
71
|
-
'object-shorthand' : [ 'error' ],
|
|
72
|
-
'operator-linebreak' : [ 'error', 'before' ],
|
|
73
|
-
'prefer-const' : [ 'error' ],
|
|
74
|
-
'prefer-numeric-literals' : [ 'error' ],
|
|
75
|
-
'prefer-spread' : [ 'error' ],
|
|
76
|
-
'prefer-template' : [ 'error' ],
|
|
77
|
-
'quote-props' : [ 'error', 'consistent-as-needed' ],
|
|
78
|
-
'quotes' : [ 'error', 'single', { avoidEscape : true } ],
|
|
79
|
-
'semi-spacing' : [ 'error' ],
|
|
80
|
-
'semi' : [ 'error' ],
|
|
81
|
-
'space-before-blocks' : [ 'error' ],
|
|
82
|
-
'space-before-function-paren' : [ 'error', { anonymous : 'never', named : 'never', asyncArrow : 'always' } ],
|
|
83
|
-
'space-in-parens' : [ 'error' ],
|
|
84
|
-
'space-infix-ops' : [ 'error' ],
|
|
85
|
-
'space-unary-ops' : [ 'error' ],
|
|
86
|
-
'spaced-comment' : [ 'error' ],
|
|
87
|
-
'template-curly-spacing' : [ 'error' ],
|
|
88
|
-
'yield-star-spacing' : [ 'error' ],
|
|
89
|
-
'yoda' : [ 'error' ],
|
|
90
|
-
},
|
|
91
6
|
};
|
package/.gitlab-ci.yml
CHANGED
package/.vscode/settings.json
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [8.0.0](../../tags/v8.0.0) - 2023-05-08
|
|
9
|
+
### Changed
|
|
10
|
+
- Use `@anmiles/prototypes` instead of old built-in fs functions
|
|
11
|
+
|
|
12
|
+
## [7.0.7](../../tags/v7.0.7) - 2023-05-07
|
|
13
|
+
### Changed
|
|
14
|
+
- Move repository
|
|
15
|
+
- Use shared eslint config
|
|
16
|
+
- Use `@anmiles/logger` instead of old built-in logger
|
|
17
|
+
- Cleanup cSpell words
|
|
18
|
+
|
|
8
19
|
## [7.0.6](../../tags/v7.0.6) - 2023-05-02
|
|
9
20
|
### Changed
|
|
10
21
|
- Display scopes on instructions page
|
package/README.md
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
# google-api-wrapper
|
|
1
|
+
# @anmiles/google-api-wrapper
|
|
2
2
|
|
|
3
3
|
Provides quick interface for getting google API data
|
|
4
4
|
|
|
5
5
|
----
|
|
6
6
|
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
`npm install @anmiles/google-api-wrapper`
|
|
10
|
+
|
|
7
11
|
## Usage
|
|
8
12
|
|
|
9
13
|
``` bash
|
|
10
|
-
> $ npm install @anmiles/google-api-wrapper
|
|
11
14
|
> $ node ./auth.js
|
|
12
15
|
> $ node ./videos.js
|
|
13
16
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { getAPI as getCalendarAPI } from './lib/api/calendar';
|
|
2
|
-
export { getAPI as getYoutubeAPI } from './lib/api/youtube';
|
|
3
|
-
export { getItems } from './lib/api/shared';
|
|
4
|
-
export { createProfile, getProfiles } from './lib/profiles';
|
|
5
|
-
export { login, getAuth } from './lib/auth';
|
|
1
|
+
export { getAPI as getCalendarAPI } from './lib/api/calendar';
|
|
2
|
+
export { getAPI as getYoutubeAPI } from './lib/api/youtube';
|
|
3
|
+
export { getItems } from './lib/api/shared';
|
|
4
|
+
export { createProfile, getProfiles } from './lib/profiles';
|
|
5
|
+
export { login, getAuth } from './lib/auth';
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAuth = exports.login = exports.getProfiles = exports.createProfile = exports.getItems = exports.getYoutubeAPI = exports.getCalendarAPI = void 0;
|
|
4
|
-
var calendar_1 = require("./lib/api/calendar");
|
|
5
|
-
Object.defineProperty(exports, "getCalendarAPI", { enumerable: true, get: function () { return calendar_1.getAPI; } });
|
|
6
|
-
var youtube_1 = require("./lib/api/youtube");
|
|
7
|
-
Object.defineProperty(exports, "getYoutubeAPI", { enumerable: true, get: function () { return youtube_1.getAPI; } });
|
|
8
|
-
var shared_1 = require("./lib/api/shared");
|
|
9
|
-
Object.defineProperty(exports, "getItems", { enumerable: true, get: function () { return shared_1.getItems; } });
|
|
10
|
-
var profiles_1 = require("./lib/profiles");
|
|
11
|
-
Object.defineProperty(exports, "createProfile", { enumerable: true, get: function () { return profiles_1.createProfile; } });
|
|
12
|
-
Object.defineProperty(exports, "getProfiles", { enumerable: true, get: function () { return profiles_1.getProfiles; } });
|
|
13
|
-
var auth_1 = require("./lib/auth");
|
|
14
|
-
Object.defineProperty(exports, "login", { enumerable: true, get: function () { return auth_1.login; } });
|
|
15
|
-
Object.defineProperty(exports, "getAuth", { enumerable: true, get: function () { return auth_1.getAuth; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAuth = exports.login = exports.getProfiles = exports.createProfile = exports.getItems = exports.getYoutubeAPI = exports.getCalendarAPI = void 0;
|
|
4
|
+
var calendar_1 = require("./lib/api/calendar");
|
|
5
|
+
Object.defineProperty(exports, "getCalendarAPI", { enumerable: true, get: function () { return calendar_1.getAPI; } });
|
|
6
|
+
var youtube_1 = require("./lib/api/youtube");
|
|
7
|
+
Object.defineProperty(exports, "getYoutubeAPI", { enumerable: true, get: function () { return youtube_1.getAPI; } });
|
|
8
|
+
var shared_1 = require("./lib/api/shared");
|
|
9
|
+
Object.defineProperty(exports, "getItems", { enumerable: true, get: function () { return shared_1.getItems; } });
|
|
10
|
+
var profiles_1 = require("./lib/profiles");
|
|
11
|
+
Object.defineProperty(exports, "createProfile", { enumerable: true, get: function () { return profiles_1.createProfile; } });
|
|
12
|
+
Object.defineProperty(exports, "getProfiles", { enumerable: true, get: function () { return profiles_1.getProfiles; } });
|
|
13
|
+
var auth_1 = require("./lib/auth");
|
|
14
|
+
Object.defineProperty(exports, "login", { enumerable: true, get: function () { return auth_1.login; } });
|
|
15
|
+
Object.defineProperty(exports, "getAuth", { enumerable: true, get: function () { return auth_1.getAuth; } });
|
|
16
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type GoogleApis from 'googleapis';
|
|
2
|
-
import type { AuthOptions } from '../../types';
|
|
3
|
-
export declare function getAPI(profile: string, options?: AuthOptions): Promise<GoogleApis.calendar_v3.Calendar>;
|
|
1
|
+
import type GoogleApis from 'googleapis';
|
|
2
|
+
import type { AuthOptions } from '../../types';
|
|
3
|
+
export declare function getAPI(profile: string, options?: AuthOptions): Promise<GoogleApis.calendar_v3.Calendar>;
|
package/dist/lib/api/calendar.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAPI = void 0;
|
|
4
|
-
const googleapis_1 = require("googleapis");
|
|
5
|
-
const auth_1 = require("../auth");
|
|
6
|
-
async function getAPI(profile, options) {
|
|
7
|
-
const googleAuth = await (0, auth_1.getAuth)(profile, options);
|
|
8
|
-
return googleapis_1.google.calendar({
|
|
9
|
-
version: 'v3',
|
|
10
|
-
auth: googleAuth,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
exports.getAPI = getAPI;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAPI = void 0;
|
|
4
|
+
const googleapis_1 = require("googleapis");
|
|
5
|
+
const auth_1 = require("../auth");
|
|
6
|
+
async function getAPI(profile, options) {
|
|
7
|
+
const googleAuth = await (0, auth_1.getAuth)(profile, options);
|
|
8
|
+
return googleapis_1.google.calendar({
|
|
9
|
+
version: 'v3',
|
|
10
|
+
auth: googleAuth,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.getAPI = getAPI;
|
|
14
14
|
//# sourceMappingURL=calendar.js.map
|
package/dist/lib/api/shared.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import type GoogleApis from 'googleapis';
|
|
2
|
-
import type { CommonOptions } from '../../types';
|
|
3
|
-
export { getItems };
|
|
4
|
-
declare const _default: {
|
|
5
|
-
getItems: typeof getItems;
|
|
6
|
-
};
|
|
7
|
-
export default _default;
|
|
8
|
-
type CommonApi<TItem> = {
|
|
9
|
-
list: {
|
|
10
|
-
(params?: {
|
|
11
|
-
pageToken: string | undefined;
|
|
12
|
-
}, options?: GoogleApis.Common.MethodOptions): Promise<GoogleApis.Common.GaxiosResponse<CommonResponse<TItem>>>;
|
|
13
|
-
(callback: (err: Error | null, res?: GoogleApis.Common.GaxiosResponse<CommonResponse<TItem>> | null) => void): void;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
type CommonResponse<TItem> = {
|
|
17
|
-
items?: TItem[];
|
|
18
|
-
pageInfo?: {
|
|
19
|
-
totalResults?: number | null | undefined;
|
|
20
|
-
};
|
|
21
|
-
nextPageToken?: string | null | undefined;
|
|
22
|
-
};
|
|
23
|
-
declare function getItems<TItem>(api: CommonApi<TItem>, params: any, options?: CommonOptions): Promise<TItem[]>;
|
|
1
|
+
import type GoogleApis from 'googleapis';
|
|
2
|
+
import type { CommonOptions } from '../../types';
|
|
3
|
+
export { getItems };
|
|
4
|
+
declare const _default: {
|
|
5
|
+
getItems: typeof getItems;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
type CommonApi<TItem> = {
|
|
9
|
+
list: {
|
|
10
|
+
(params?: {
|
|
11
|
+
pageToken: string | undefined;
|
|
12
|
+
}, options?: GoogleApis.Common.MethodOptions): Promise<GoogleApis.Common.GaxiosResponse<CommonResponse<TItem>>>;
|
|
13
|
+
(callback: (err: Error | null, res?: GoogleApis.Common.GaxiosResponse<CommonResponse<TItem>> | null) => void): void;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
type CommonResponse<TItem> = {
|
|
17
|
+
items?: TItem[];
|
|
18
|
+
pageInfo?: {
|
|
19
|
+
totalResults?: number | null | undefined;
|
|
20
|
+
};
|
|
21
|
+
nextPageToken?: string | null | undefined;
|
|
22
|
+
};
|
|
23
|
+
declare function getItems<TItem>(api: CommonApi<TItem>, params: any, options?: CommonOptions): Promise<TItem[]>;
|
package/dist/lib/api/shared.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getItems = void 0;
|
|
7
|
+
const logger_1 = require("@anmiles/logger");
|
|
8
|
+
const sleep_1 = __importDefault(require("@anmiles/sleep"));
|
|
9
|
+
exports.default = { getItems };
|
|
10
|
+
const requestInterval = 300;
|
|
11
|
+
async function getItems(api, params, options) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const items = [];
|
|
14
|
+
let pageToken = undefined;
|
|
15
|
+
do {
|
|
16
|
+
const response = await api.list({ ...params, pageToken });
|
|
17
|
+
(_a = response.data.items) === null || _a === void 0 ? void 0 : _a.forEach((item) => items.push(item));
|
|
18
|
+
if (!(options === null || options === void 0 ? void 0 : options.hideProgress)) {
|
|
19
|
+
(0, logger_1.log)(`Getting items (${items.length} of ${((_b = response.data.pageInfo) === null || _b === void 0 ? void 0 : _b.totalResults) || 'many'})...`);
|
|
20
|
+
}
|
|
21
|
+
await (0, sleep_1.default)(requestInterval);
|
|
22
|
+
pageToken = response.data.nextPageToken;
|
|
23
|
+
} while (pageToken);
|
|
24
|
+
return items;
|
|
25
|
+
}
|
|
26
|
+
exports.getItems = getItems;
|
|
24
27
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/lib/api/shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/lib/api/shared.ts"],"names":[],"mappings":";;;;;;AACA,4CAAsC;AACtC,2DAAmC;AAInC,kBAAe,EAAE,QAAQ,EAAE,CAAC;AAE5B,MAAM,eAAe,GAAG,GAAG,CAAC;AAiB5B,KAAK,UAAU,QAAQ,CAAQ,GAAqB,EAAE,MAAW,EAAE,OAAuB;;IACzF,MAAM,KAAK,GAAY,EAAE,CAAC;IAE1B,IAAI,SAAS,GAA8B,SAAS,CAAC;IAErD,GAAG;QACF,MAAM,QAAQ,GAA4D,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QACnH,MAAA,QAAQ,CAAC,IAAI,CAAC,KAAK,0CAAE,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEzD,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAA,EAAE;YAC3B,IAAA,YAAG,EAAC,kBAAkB,KAAK,CAAC,MAAM,OAAO,CAAA,MAAA,QAAQ,CAAC,IAAI,CAAC,QAAQ,0CAAE,YAAY,KAAI,MAAM,MAAM,CAAC,CAAC;SAC/F;QAED,MAAM,IAAA,eAAK,EAAC,eAAe,CAAC,CAAC;QAC7B,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC;KACxC,QAAQ,SAAS,EAAE;IAEpB,OAAO,KAAK,CAAC;AACd,CAAC;AAtCQ,4BAAQ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type GoogleApis from 'googleapis';
|
|
2
|
-
import type { AuthOptions } from '../../types';
|
|
3
|
-
export declare function getAPI(profile: string, options?: AuthOptions): Promise<GoogleApis.youtube_v3.Youtube>;
|
|
1
|
+
import type GoogleApis from 'googleapis';
|
|
2
|
+
import type { AuthOptions } from '../../types';
|
|
3
|
+
export declare function getAPI(profile: string, options?: AuthOptions): Promise<GoogleApis.youtube_v3.Youtube>;
|
package/dist/lib/api/youtube.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAPI = void 0;
|
|
4
|
-
const googleapis_1 = require("googleapis");
|
|
5
|
-
const auth_1 = require("../auth");
|
|
6
|
-
async function getAPI(profile, options) {
|
|
7
|
-
const googleAuth = await (0, auth_1.getAuth)(profile, options);
|
|
8
|
-
return googleapis_1.google.youtube({
|
|
9
|
-
version: 'v3',
|
|
10
|
-
auth: googleAuth,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
exports.getAPI = getAPI;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAPI = void 0;
|
|
4
|
+
const googleapis_1 = require("googleapis");
|
|
5
|
+
const auth_1 = require("../auth");
|
|
6
|
+
async function getAPI(profile, options) {
|
|
7
|
+
const googleAuth = await (0, auth_1.getAuth)(profile, options);
|
|
8
|
+
return googleapis_1.google.youtube({
|
|
9
|
+
version: 'v3',
|
|
10
|
+
auth: googleAuth,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.getAPI = getAPI;
|
|
14
14
|
//# sourceMappingURL=youtube.js.map
|
package/dist/lib/auth.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type GoogleApis from 'googleapis';
|
|
2
|
-
import type { CommonOptions, AuthOptions } from '../types';
|
|
3
|
-
export { login, getAuth };
|
|
4
|
-
declare const _default: {
|
|
5
|
-
login: typeof login;
|
|
6
|
-
getAuth: typeof getAuth;
|
|
7
|
-
};
|
|
8
|
-
export default _default;
|
|
9
|
-
declare function login(profile?: string, options?: CommonOptions & AuthOptions): Promise<void>;
|
|
10
|
-
declare function getAuth(profile: string, options?: AuthOptions): Promise<GoogleApis.Common.OAuth2Client>;
|
|
1
|
+
import type GoogleApis from 'googleapis';
|
|
2
|
+
import type { CommonOptions, AuthOptions } from '../types';
|
|
3
|
+
export { login, getAuth };
|
|
4
|
+
declare const _default: {
|
|
5
|
+
login: typeof login;
|
|
6
|
+
getAuth: typeof getAuth;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
9
|
+
declare function login(profile?: string, options?: CommonOptions & AuthOptions): Promise<void>;
|
|
10
|
+
declare function getAuth(profile: string, options?: AuthOptions): Promise<GoogleApis.Common.OAuth2Client>;
|
package/dist/lib/auth.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getAuth = exports.login = void 0;
|
|
7
|
-
const googleapis_1 = require("googleapis");
|
|
8
|
-
const logger_1 = require("
|
|
9
|
-
const profiles_1 = require("./profiles");
|
|
10
|
-
const secrets_1 = require("./secrets");
|
|
11
|
-
const auth_1 = __importDefault(require("./auth"));
|
|
12
|
-
exports.default = { login, getAuth };
|
|
13
|
-
async function login(profile, options) {
|
|
14
|
-
const profiles = (0, profiles_1.getProfiles)().filter((p) => !profile || p === profile);
|
|
15
|
-
for (const profile of profiles) {
|
|
16
|
-
if (!(options === null || options === void 0 ? void 0 : options.hideProgress)) {
|
|
17
|
-
(0, logger_1.warn)(`${profile} - logging in...`);
|
|
18
|
-
}
|
|
19
|
-
await auth_1.default.getAuth(profile, options);
|
|
20
|
-
if (!(options === null || options === void 0 ? void 0 : options.hideProgress)) {
|
|
21
|
-
(0, logger_1.info)(`${profile} - logged in successfully`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.login = login;
|
|
26
|
-
async function getAuth(profile, options) {
|
|
27
|
-
const secrets = (0, secrets_1.getSecrets)(profile);
|
|
28
|
-
const googleAuth = new googleapis_1.google.auth.OAuth2(secrets.web.client_id, secrets.web.client_secret, secrets.web.redirect_uris[0]);
|
|
29
|
-
const tokens = await (0, secrets_1.getCredentials)(profile, googleAuth, options);
|
|
30
|
-
googleAuth.setCredentials(tokens);
|
|
31
|
-
googleapis_1.google.options({ auth: googleAuth });
|
|
32
|
-
return googleAuth;
|
|
33
|
-
}
|
|
34
|
-
exports.getAuth = getAuth;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getAuth = exports.login = void 0;
|
|
7
|
+
const googleapis_1 = require("googleapis");
|
|
8
|
+
const logger_1 = require("@anmiles/logger");
|
|
9
|
+
const profiles_1 = require("./profiles");
|
|
10
|
+
const secrets_1 = require("./secrets");
|
|
11
|
+
const auth_1 = __importDefault(require("./auth"));
|
|
12
|
+
exports.default = { login, getAuth };
|
|
13
|
+
async function login(profile, options) {
|
|
14
|
+
const profiles = (0, profiles_1.getProfiles)().filter((p) => !profile || p === profile);
|
|
15
|
+
for (const profile of profiles) {
|
|
16
|
+
if (!(options === null || options === void 0 ? void 0 : options.hideProgress)) {
|
|
17
|
+
(0, logger_1.warn)(`${profile} - logging in...`);
|
|
18
|
+
}
|
|
19
|
+
await auth_1.default.getAuth(profile, options);
|
|
20
|
+
if (!(options === null || options === void 0 ? void 0 : options.hideProgress)) {
|
|
21
|
+
(0, logger_1.info)(`${profile} - logged in successfully`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.login = login;
|
|
26
|
+
async function getAuth(profile, options) {
|
|
27
|
+
const secrets = (0, secrets_1.getSecrets)(profile);
|
|
28
|
+
const googleAuth = new googleapis_1.google.auth.OAuth2(secrets.web.client_id, secrets.web.client_secret, secrets.web.redirect_uris[0]);
|
|
29
|
+
const tokens = await (0, secrets_1.getCredentials)(profile, googleAuth, options);
|
|
30
|
+
googleAuth.setCredentials(tokens);
|
|
31
|
+
googleapis_1.google.options({ auth: googleAuth });
|
|
32
|
+
return googleAuth;
|
|
33
|
+
}
|
|
34
|
+
exports.getAuth = getAuth;
|
|
35
35
|
//# sourceMappingURL=auth.js.map
|
package/dist/lib/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAoC;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAoC;AAEpC,4CAA6C;AAE7C,yCAAyC;AACzC,uCAAuD;AAEvD,kDAA0B;AAG1B,kBAAe,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAElC,KAAK,UAAU,KAAK,CAAC,OAAgB,EAAE,OAAqC;IAC3E,MAAM,QAAQ,GAAG,IAAA,sBAAW,GAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,IAAI,CAAC,KAAK,OAAO,CAAC,CAAC;IAExE,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC/B,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAA,EAAE;YAC3B,IAAA,aAAI,EAAC,GAAG,OAAO,kBAAkB,CAAC,CAAC;SACnC;QAED,MAAM,cAAI,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAErC,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAA,EAAE;YAC3B,IAAA,aAAI,EAAC,GAAG,OAAO,2BAA2B,CAAC,CAAC;SAC5C;KACD;AACF,CAAC;AAjBQ,sBAAK;AAmBd,KAAK,UAAU,OAAO,CAAC,OAAe,EAAE,OAAqB;IAC5D,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,OAAO,CAAC,CAAC;IAEpC,MAAM,UAAU,GAAG,IAAI,mBAAM,CAAC,IAAI,CAAC,MAAM,CACxC,OAAO,CAAC,GAAG,CAAC,SAAS,EACrB,OAAO,CAAC,GAAG,CAAC,aAAa,EACzB,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAC5B,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAc,EAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAClE,UAAU,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAClC,mBAAM,CAAC,OAAO,CAAC,EAAE,IAAI,EAAG,UAAU,EAAE,CAAC,CAAC;IACtC,OAAO,UAAU,CAAC;AACnB,CAAC;AAhCe,0BAAO"}
|
package/dist/lib/paths.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
export {
|
|
2
|
-
declare const _default: {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
declare function
|
|
12
|
-
declare function
|
|
13
|
-
declare function getProfilesFile(): string;
|
|
14
|
-
declare function getScopesFile(): string;
|
|
15
|
-
declare function getSecretsFile(profile: string): string;
|
|
16
|
-
declare function getCredentialsFile(profile: string): string;
|
|
1
|
+
export { getProfilesFile, getScopesFile, getSecretsFile, getCredentialsFile };
|
|
2
|
+
declare const _default: {
|
|
3
|
+
getProfilesFile: typeof getProfilesFile;
|
|
4
|
+
getScopesFile: typeof getScopesFile;
|
|
5
|
+
getSecretsFile: typeof getSecretsFile;
|
|
6
|
+
getCredentialsFile: typeof getCredentialsFile;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
9
|
+
declare function getProfilesFile(): string;
|
|
10
|
+
declare function getScopesFile(): string;
|
|
11
|
+
declare function getSecretsFile(profile: string): string;
|
|
12
|
+
declare function getCredentialsFile(profile: string): string;
|
package/dist/lib/paths.js
CHANGED
|
@@ -1,46 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getCredentialsFile = exports.getSecretsFile = exports.getScopesFile = exports.getProfilesFile =
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
exports.ensureFile = ensureFile;
|
|
30
|
-
function getProfilesFile() {
|
|
31
|
-
return path_1.default.join(dirPaths.input, 'profiles.json');
|
|
32
|
-
}
|
|
33
|
-
exports.getProfilesFile = getProfilesFile;
|
|
34
|
-
function getScopesFile() {
|
|
35
|
-
return 'scopes.json';
|
|
36
|
-
}
|
|
37
|
-
exports.getScopesFile = getScopesFile;
|
|
38
|
-
function getSecretsFile(profile) {
|
|
39
|
-
return path_1.default.join(dirPaths.secrets, `${profile}.json`);
|
|
40
|
-
}
|
|
41
|
-
exports.getSecretsFile = getSecretsFile;
|
|
42
|
-
function getCredentialsFile(profile) {
|
|
43
|
-
return path_1.default.join(dirPaths.secrets, `${profile}.credentials.json`);
|
|
44
|
-
}
|
|
45
|
-
exports.getCredentialsFile = getCredentialsFile;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getCredentialsFile = exports.getSecretsFile = exports.getScopesFile = exports.getProfilesFile = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
exports.default = { getProfilesFile, getScopesFile, getSecretsFile, getCredentialsFile };
|
|
9
|
+
const dirPaths = {
|
|
10
|
+
input: 'input',
|
|
11
|
+
secrets: 'secrets',
|
|
12
|
+
};
|
|
13
|
+
function getProfilesFile() {
|
|
14
|
+
return path_1.default.join(dirPaths.input, 'profiles.json');
|
|
15
|
+
}
|
|
16
|
+
exports.getProfilesFile = getProfilesFile;
|
|
17
|
+
function getScopesFile() {
|
|
18
|
+
return 'scopes.json';
|
|
19
|
+
}
|
|
20
|
+
exports.getScopesFile = getScopesFile;
|
|
21
|
+
function getSecretsFile(profile) {
|
|
22
|
+
return path_1.default.join(dirPaths.secrets, `${profile}.json`);
|
|
23
|
+
}
|
|
24
|
+
exports.getSecretsFile = getSecretsFile;
|
|
25
|
+
function getCredentialsFile(profile) {
|
|
26
|
+
return path_1.default.join(dirPaths.secrets, `${profile}.credentials.json`);
|
|
27
|
+
}
|
|
28
|
+
exports.getCredentialsFile = getCredentialsFile;
|
|
46
29
|
//# sourceMappingURL=paths.js.map
|
package/dist/lib/paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/lib/paths.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/lib/paths.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAGxB,kBAAe,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;AAEtF,MAAM,QAAQ,GAAG;IAChB,KAAK,EAAK,OAAO;IACjB,OAAO,EAAG,SAAS;CACnB,CAAC;AAEF,SAAS,eAAe;IACvB,OAAO,cAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;AACnD,CAAC;AAVQ,0CAAe;AAYxB,SAAS,aAAa;IACrB,OAAO,aAAa,CAAC;AACtB,CAAC;AAdyB,sCAAa;AAgBvC,SAAS,cAAc,CAAC,OAAe;IACtC,OAAO,cAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,OAAO,OAAO,CAAC,CAAC;AACvD,CAAC;AAlBwC,wCAAc;AAoBvD,SAAS,kBAAkB,CAAC,OAAe;IAC1C,OAAO,cAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,OAAO,mBAAmB,CAAC,CAAC;AACnE,CAAC;AAtBwD,gDAAkB"}
|
package/dist/lib/profiles.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
declare function
|
|
10
|
-
declare function
|
|
1
|
+
import '@anmiles/prototypes';
|
|
2
|
+
export { getProfiles, setProfiles, createProfile };
|
|
3
|
+
declare const _default: {
|
|
4
|
+
getProfiles: typeof getProfiles;
|
|
5
|
+
setProfiles: typeof setProfiles;
|
|
6
|
+
createProfile: typeof createProfile;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
9
|
+
declare function getProfiles(): string[];
|
|
10
|
+
declare function setProfiles(profiles: string[]): void;
|
|
11
|
+
declare function createProfile(profile: string): void;
|