@anmiles/google-api-wrapper 18.0.3 → 19.0.1

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 (108) hide show
  1. package/.nycrc.json +27 -0
  2. package/CHANGELOG.md +32 -21
  3. package/README.md +1 -1
  4. package/cspell.json +22 -0
  5. package/dist/index.d.ts +3 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +4 -3
  8. package/dist/index.js.map +1 -1
  9. package/dist/lib/api.d.ts +5 -11
  10. package/dist/lib/api.d.ts.map +1 -1
  11. package/dist/lib/api.js +5 -6
  12. package/dist/lib/api.js.map +1 -1
  13. package/dist/lib/auth.d.ts +2 -9
  14. package/dist/lib/auth.d.ts.map +1 -1
  15. package/dist/lib/auth.js +3 -23
  16. package/dist/lib/auth.js.map +1 -1
  17. package/dist/lib/credentials/generator.d.ts +4 -0
  18. package/dist/lib/credentials/generator.d.ts.map +1 -0
  19. package/dist/lib/credentials/generator.js +60 -0
  20. package/dist/lib/credentials/generator.js.map +1 -0
  21. package/dist/lib/credentials/index.d.ts +5 -0
  22. package/dist/lib/credentials/index.d.ts.map +1 -0
  23. package/dist/lib/credentials/index.js +42 -0
  24. package/dist/lib/credentials/index.js.map +1 -0
  25. package/dist/lib/credentials/validator.d.ts +7 -0
  26. package/dist/lib/credentials/validator.d.ts.map +1 -0
  27. package/dist/lib/credentials/validator.js +20 -0
  28. package/dist/lib/credentials/validator.js.map +1 -0
  29. package/dist/lib/login.d.ts +3 -0
  30. package/dist/lib/login.d.ts.map +1 -0
  31. package/dist/lib/login.js +19 -0
  32. package/dist/lib/login.js.map +1 -0
  33. package/dist/lib/profiles.d.ts +4 -12
  34. package/dist/lib/profiles.d.ts.map +1 -1
  35. package/dist/lib/profiles.js +8 -11
  36. package/dist/lib/profiles.js.map +1 -1
  37. package/dist/lib/renderer.d.ts +7 -25
  38. package/dist/lib/renderer.d.ts.map +1 -1
  39. package/dist/lib/renderer.js +26 -23
  40. package/dist/lib/renderer.js.map +1 -1
  41. package/dist/lib/scopes.d.ts +2 -0
  42. package/dist/lib/scopes.d.ts.map +1 -0
  43. package/dist/lib/scopes.js +22 -0
  44. package/dist/lib/scopes.js.map +1 -0
  45. package/dist/lib/secrets.d.ts +2 -28
  46. package/dist/lib/secrets.d.ts.map +1 -1
  47. package/dist/lib/secrets.js +15 -115
  48. package/dist/lib/secrets.js.map +1 -1
  49. package/dist/lib/utils/paths.d.ts +7 -0
  50. package/dist/lib/utils/paths.d.ts.map +1 -0
  51. package/dist/lib/{paths.js → utils/paths.js} +6 -8
  52. package/dist/lib/utils/paths.js.map +1 -0
  53. package/dist/templates/auth.html +1 -1
  54. package/dist/templates/index.html +6 -1
  55. package/dist/templates/page.html +1 -2
  56. package/dist/templates/script.html +0 -0
  57. package/{src/templates/css.html → dist/templates/style.html} +2 -2
  58. package/dist/types/options.d.ts +2 -3
  59. package/dist/types/options.d.ts.map +1 -1
  60. package/dist/types/secrets.d.ts +1 -2
  61. package/dist/types/secrets.d.ts.map +1 -1
  62. package/eslint.config.mts +43 -0
  63. package/jest.config.js +9 -9
  64. package/package.json +40 -30
  65. package/src/index.ts +3 -2
  66. package/src/lib/__tests__/__snapshots__/renderer.test.ts.snap +273 -0
  67. package/src/lib/__tests__/__snapshots__/scopes.test.ts.snap +6 -0
  68. package/src/lib/__tests__/__snapshots__/secrets.test.ts.snap +38 -0
  69. package/src/lib/__tests__/api.test.ts +72 -74
  70. package/src/lib/__tests__/auth.test.ts +38 -114
  71. package/src/lib/__tests__/login.test.ts +71 -0
  72. package/src/lib/__tests__/profiles.test.ts +50 -93
  73. package/src/lib/__tests__/renderer.test.ts +16 -89
  74. package/src/lib/__tests__/scopes.test.ts +41 -0
  75. package/src/lib/__tests__/secrets.test.ts +47 -541
  76. package/src/lib/api.ts +19 -21
  77. package/src/lib/auth.ts +5 -25
  78. package/src/lib/credentials/__tests__/generator.test.ts +249 -0
  79. package/src/lib/credentials/__tests__/index.test.ts +213 -0
  80. package/src/lib/credentials/__tests__/validator.test.ts +43 -0
  81. package/src/lib/credentials/generator.ts +70 -0
  82. package/src/lib/credentials/index.ts +50 -0
  83. package/src/lib/credentials/validator.ts +29 -0
  84. package/src/lib/login.ts +22 -0
  85. package/src/lib/profiles.ts +9 -12
  86. package/src/lib/renderer.ts +32 -27
  87. package/src/lib/scopes.ts +18 -0
  88. package/src/lib/secrets.ts +21 -141
  89. package/src/lib/utils/paths.ts +30 -0
  90. package/src/templates/auth.html +1 -1
  91. package/src/templates/index.html +6 -1
  92. package/src/templates/page.html +1 -2
  93. package/src/templates/script.html +0 -0
  94. package/{dist/templates/css.html → src/templates/style.html} +2 -2
  95. package/src/types/options.ts +5 -7
  96. package/src/types/secrets.ts +8 -10
  97. package/tsconfig.build.json +6 -0
  98. package/tsconfig.json +0 -5
  99. package/tsconfig.test.json +1 -1
  100. package/.eslintignore +0 -2
  101. package/.eslintrc.js +0 -30
  102. package/.vscode/settings.json +0 -9
  103. package/coverage.config.js +0 -8
  104. package/dist/lib/paths.d.ts +0 -16
  105. package/dist/lib/paths.d.ts.map +0 -1
  106. package/dist/lib/paths.js.map +0 -1
  107. package/src/lib/__tests__/paths.test.ts +0 -77
  108. package/src/lib/paths.ts +0 -32
package/tsconfig.json CHANGED
@@ -1,11 +1,6 @@
1
1
  {
2
2
  "extends" : "./node_modules/@anmiles/tsconfig/tsconfig.json",
3
3
 
4
- "compilerOptions" : {
5
- "rootDir" : "./src",
6
- "outDir" : "./dist",
7
- },
8
-
9
4
  "include" : [
10
5
  "src",
11
6
  ],
@@ -2,6 +2,6 @@
2
2
  "extends" : "./tsconfig.json",
3
3
 
4
4
  "compilerOptions" : {
5
- "moduleResolution" : "Node",
5
+ "isolatedModules" : true, // otherwise tests are slowing down a lot because of googleapis
6
6
  },
7
7
  }
package/.eslintignore DELETED
@@ -1,2 +0,0 @@
1
- coverage
2
- dist
package/.eslintrc.js DELETED
@@ -1,30 +0,0 @@
1
- module.exports = {
2
- root : true,
3
-
4
- extends : [
5
- './node_modules/@anmiles/eslint-config/src/base.preset.js',
6
- './node_modules/@anmiles/eslint-config/src/ts.preset.js',
7
- './node_modules/@anmiles/eslint-config/src/jest.preset.js',
8
- ],
9
-
10
- globals : {
11
- NodeJS : true,
12
- },
13
-
14
- rules : {
15
- camelcase : [ 'error', { allow : [
16
- 'access_token',
17
- 'access_type',
18
- 'auth_provider_x509_cert_url',
19
- 'auth_uri',
20
- 'calendar_v3',
21
- 'client_id',
22
- 'client_secret',
23
- 'expiry_date',
24
- 'project_id',
25
- 'redirect_uris',
26
- 'refresh_token',
27
- 'token_uri',
28
- ] } ],
29
- },
30
- };
@@ -1,9 +0,0 @@
1
- {
2
- "cSpell.words": [
3
- "anmiles",
4
- "Gaxios",
5
- "googleusercontent",
6
- "nycrc",
7
- "Playlistitems"
8
- ]
9
- }
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- 'check-coverage' : true,
3
- 'statements' : 100,
4
- 'branches' : 100,
5
- 'lines' : 100,
6
- 'functions' : 100,
7
- 'reporter' : [ 'html', 'text' ],
8
- };
@@ -1,16 +0,0 @@
1
- import type { templates } from './renderer';
2
- declare function getProfilesFile(): string;
3
- declare function getScopesFile(): string;
4
- declare function getSecretsFile(profile: string): string;
5
- declare function getCredentialsFile(profile: string): string;
6
- declare function getTemplateFile(templateName: keyof typeof templates): string;
7
- export { getProfilesFile, getScopesFile, getSecretsFile, getCredentialsFile, getTemplateFile };
8
- declare const _default: {
9
- getProfilesFile: typeof getProfilesFile;
10
- getScopesFile: typeof getScopesFile;
11
- getSecretsFile: typeof getSecretsFile;
12
- getCredentialsFile: typeof getCredentialsFile;
13
- getTemplateFile: typeof getTemplateFile;
14
- };
15
- export default _default;
16
- //# sourceMappingURL=paths.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/lib/paths.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY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AY,OAAO,CAAC,CAAC;AAC9D,CAAC;AAE4E,0CAAe;AAC5F,kBAAe,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,kBAAkB,EAAE,eAAe,EAAE,CAAC"}
@@ -1,77 +0,0 @@
1
- import type fs from 'fs';
2
- import type path from 'path';
3
-
4
- import type paths from '../paths';
5
-
6
- const original = jest.requireActual<{ default : typeof paths }>('../paths').default;
7
- jest.mock<typeof paths>('../paths', () => ({
8
- getProfilesFile : jest.fn().mockImplementation(() => profilesFile),
9
- getScopesFile : jest.fn().mockImplementation(() => scopesFile),
10
- getSecretsFile : jest.fn().mockImplementation(() => secretsFile),
11
- getCredentialsFile : jest.fn().mockImplementation(() => credentialsFile),
12
- getTemplateFile : jest.fn().mockImplementation(() => templateFile),
13
- }));
14
-
15
- jest.mock<Partial<typeof fs>>('fs', () => ({
16
- mkdirSync : jest.fn(),
17
- writeFileSync : jest.fn(),
18
- existsSync : jest.fn().mockImplementation(() => exists),
19
- }));
20
-
21
- jest.mock<Partial<typeof path>>('path', () => ({
22
- join : jest.fn().mockImplementation((...args: string[]) => args.join('/')),
23
- }));
24
-
25
- const profile = 'username';
26
- const templateName = 'auth';
27
-
28
- const profilesFile = 'input/profiles.json';
29
- const scopesFile = 'scopes.json';
30
- const secretsFile = 'secrets/username.json';
31
- const credentialsFile = 'secrets/username.credentials.json';
32
- const templateFile = 'node_modules/@anmiles/google-api-wrapper/dist/templates/auth.html';
33
-
34
- let exists: boolean;
35
-
36
- describe('src/lib/paths', () => {
37
- describe('getProfilesFile', () => {
38
- it('should return profiles file', () => {
39
- const result = original.getProfilesFile();
40
-
41
- expect(result).toEqual(profilesFile);
42
- });
43
- });
44
-
45
- describe('getScopesFile', () => {
46
- it('should return scopes file', () => {
47
- const result = original.getScopesFile();
48
-
49
- expect(result).toEqual(scopesFile);
50
- });
51
- });
52
-
53
- describe('getSecretsFile', () => {
54
- it('should return secrets file', () => {
55
- const result = original.getSecretsFile(profile);
56
-
57
- expect(result).toEqual(secretsFile);
58
- });
59
- });
60
-
61
- describe('getCredentialsFile', () => {
62
- it('should return credentials file', () => {
63
- const result = original.getCredentialsFile(profile);
64
-
65
- expect(result).toEqual(credentialsFile);
66
- });
67
- });
68
-
69
- describe('getTemplateFile', () => {
70
-
71
- it('should return credentials file', () => {
72
- const result = original.getTemplateFile(templateName);
73
-
74
- expect(result).toEqual(templateFile);
75
- });
76
- });
77
- });
package/src/lib/paths.ts DELETED
@@ -1,32 +0,0 @@
1
- import path from 'path';
2
- import type { templates } from './renderer';
3
-
4
- const dirPaths = {
5
- input : 'input',
6
- secrets : 'secrets',
7
- // TODO: Remove this hack after moving to React
8
- templates : 'node_modules/@anmiles/google-api-wrapper/dist/templates',
9
- };
10
-
11
- function getProfilesFile(): string {
12
- return path.join(dirPaths.input, 'profiles.json');
13
- }
14
-
15
- function getScopesFile(): string {
16
- return 'scopes.json';
17
- }
18
-
19
- function getSecretsFile(profile: string): string {
20
- return path.join(dirPaths.secrets, `${profile}.json`);
21
- }
22
-
23
- function getCredentialsFile(profile: string): string {
24
- return path.join(dirPaths.secrets, `${profile}.credentials.json`);
25
- }
26
-
27
- function getTemplateFile(templateName: keyof typeof templates): string {
28
- return path.join(dirPaths.templates, `${templateName}.html`);
29
- }
30
-
31
- export { getProfilesFile, getScopesFile, getSecretsFile, getCredentialsFile, getTemplateFile };
32
- export default { getProfilesFile, getScopesFile, getSecretsFile, getCredentialsFile, getTemplateFile };