@tmdb-graphql-api/rest-client 0.0.15 → 0.0.17
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/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/production.analysis.txt +12 -12
- package/dist/types/cjs/main.d.cts +1 -1
- package/dist/types/cjs/main.d.cts.map +1 -1
- package/dist/types/cjs/types.d.cts +3 -3
- package/dist/types/cjs/types.d.cts.map +1 -1
- package/dist/types/esm/main.d.ts +1 -1
- package/dist/types/esm/main.d.ts.map +1 -1
- package/dist/types/esm/types.d.ts +3 -3
- package/dist/types/esm/types.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/main.test.ts +55 -2
- package/src/main.ts +5 -1
- package/src/types.ts +3 -3
- package/src/__snapshots__/main.test.ts.snap +0 -57
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmdb-graphql-api/rest-client",
|
|
3
3
|
"description": "The TMDB GraphQL rest client module.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.17",
|
|
5
5
|
"author": "miami-man",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/badbatch/themoviedb-graphql-api",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@cachemap/core": "^5.2.7",
|
|
33
33
|
"@graphql-box/core": "^5.4.11",
|
|
34
|
-
"getta": "^1.0.
|
|
34
|
+
"getta": "^1.0.19",
|
|
35
35
|
"type-fest": "^4.37.0",
|
|
36
36
|
"winston": "^3.17.0"
|
|
37
37
|
},
|
package/src/main.test.ts
CHANGED
|
@@ -11,11 +11,64 @@ describe('createRestClient >', () => {
|
|
|
11
11
|
const { createRestClient } = await import('./index.ts');
|
|
12
12
|
|
|
13
13
|
const restClient = createRestClient({
|
|
14
|
+
apiKey: '12345',
|
|
14
15
|
cache: 'mock-cache' as unknown as Core,
|
|
15
|
-
queryParams: { api_key: '12345' },
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
expect({ ...restClient }).
|
|
18
|
+
expect({ ...restClient }).toMatchInlineSnapshot(`
|
|
19
|
+
{
|
|
20
|
+
"_basePath": "https://api.themoviedb.org/3/",
|
|
21
|
+
"_bodyParser": [Function],
|
|
22
|
+
"_cache": "mock-cache",
|
|
23
|
+
"_conditionalRequestsEnabled": true,
|
|
24
|
+
"_fetchTimeout": 5000,
|
|
25
|
+
"_headers": {
|
|
26
|
+
"authorization": "Bearer 12345",
|
|
27
|
+
"content-type": "application/json",
|
|
28
|
+
},
|
|
29
|
+
"_log": [Function],
|
|
30
|
+
"_maxRedirects": 5,
|
|
31
|
+
"_maxRetries": 3,
|
|
32
|
+
"_optionalPathTemplateRegExp": /\\(\\{\\\\w\\+\\\\\\?\\}\\)/g,
|
|
33
|
+
"_pathTemplateCallback": [Function],
|
|
34
|
+
"_pathTemplateRegExp": /\\(\\{type\\}\\)\\|\\(\\{subType\\}\\)\\|\\(\\{number\\}\\)\\|\\(\\{seasonNumber\\}\\)\\|\\(\\{episodeNumber\\}\\)\\|\\(\\{id\\}\\)/g,
|
|
35
|
+
"_performance": "mock-performance",
|
|
36
|
+
"_queryParams": {},
|
|
37
|
+
"_rateLimit": false,
|
|
38
|
+
"_rateLimitCount": 0,
|
|
39
|
+
"_rateLimitPerSecond": 30,
|
|
40
|
+
"_rateLimitTimer": undefined,
|
|
41
|
+
"_rateLimitedRequestQueue": [],
|
|
42
|
+
"_requestRetryWait": 100,
|
|
43
|
+
"_requestTracker": {
|
|
44
|
+
"active": [],
|
|
45
|
+
"pending": Map {},
|
|
46
|
+
},
|
|
47
|
+
"_streamReader": "json",
|
|
48
|
+
"authenticate": [Function],
|
|
49
|
+
"certifications": [Function],
|
|
50
|
+
"collection": [Function],
|
|
51
|
+
"company": [Function],
|
|
52
|
+
"configuration": [Function],
|
|
53
|
+
"credit": [Function],
|
|
54
|
+
"discover": [Function],
|
|
55
|
+
"episode": [Function],
|
|
56
|
+
"find": [Function],
|
|
57
|
+
"genres": [Function],
|
|
58
|
+
"keyword": [Function],
|
|
59
|
+
"movie": [Function],
|
|
60
|
+
"network": [Function],
|
|
61
|
+
"person": [Function],
|
|
62
|
+
"popular": [Function],
|
|
63
|
+
"rated": [Function],
|
|
64
|
+
"review": [Function],
|
|
65
|
+
"search": [Function],
|
|
66
|
+
"season": [Function],
|
|
67
|
+
"trending": [Function],
|
|
68
|
+
"tv": [Function],
|
|
69
|
+
"watchProviders": [Function],
|
|
70
|
+
}
|
|
71
|
+
`);
|
|
19
72
|
});
|
|
20
73
|
});
|
|
21
74
|
});
|
package/src/main.ts
CHANGED
|
@@ -50,12 +50,16 @@ const logMessages = {
|
|
|
50
50
|
[RESPONSE_RECEIVED]: 'Response received for resource',
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
export const createRestClient = ({ cache, logger, queryParams }: CreateRestClientParams) =>
|
|
53
|
+
export const createRestClient = ({ apiKey, cache, headers = {}, logger, queryParams = {} }: CreateRestClientParams) =>
|
|
54
54
|
create<ShortcutMethodNames>(
|
|
55
55
|
{
|
|
56
56
|
basePath: BASE_PATH,
|
|
57
57
|
cache,
|
|
58
58
|
fetchTimeout: NODE_ENV === 'development' ? 999_999 : undefined,
|
|
59
|
+
headers: {
|
|
60
|
+
...headers,
|
|
61
|
+
authorization: `Bearer ${apiKey}`,
|
|
62
|
+
},
|
|
59
63
|
log: (message, { context, stats }) => {
|
|
60
64
|
const { args, fieldPath } = context as ExecutionContextValueData & {
|
|
61
65
|
args?: Record<string, unknown>;
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type Core } from '@cachemap/core';
|
|
2
|
-
import { type JsonObject } from 'type-fest';
|
|
3
2
|
import { type Logger } from 'winston';
|
|
4
3
|
|
|
5
4
|
export type ShortcutMethodNames =
|
|
@@ -28,8 +27,9 @@ export type ShortcutMethodNames =
|
|
|
28
27
|
| 'watchProviders';
|
|
29
28
|
|
|
30
29
|
export interface CreateRestClientParams {
|
|
30
|
+
apiKey: string;
|
|
31
31
|
cache?: Core;
|
|
32
|
+
headers?: Record<string, string>;
|
|
32
33
|
logger?: Logger;
|
|
33
|
-
|
|
34
|
-
queryParams: JsonObject & { api_key: string; language?: string };
|
|
34
|
+
queryParams?: Record<string, string> & { language?: string };
|
|
35
35
|
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`createRestClient > WHEN the dollygrip rest client is created > THEN it should have the correct properties and methods 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"_basePath": "https://api.themoviedb.org/3/",
|
|
6
|
-
"_bodyParser": [Function],
|
|
7
|
-
"_cache": "mock-cache",
|
|
8
|
-
"_conditionalRequestsEnabled": true,
|
|
9
|
-
"_fetchTimeout": 5000,
|
|
10
|
-
"_headers": {
|
|
11
|
-
"content-type": "application/json",
|
|
12
|
-
},
|
|
13
|
-
"_log": [Function],
|
|
14
|
-
"_maxRedirects": 5,
|
|
15
|
-
"_maxRetries": 3,
|
|
16
|
-
"_optionalPathTemplateRegExp": /\\(\\{\\\\w\\+\\\\\\?\\}\\)/g,
|
|
17
|
-
"_pathTemplateCallback": [Function],
|
|
18
|
-
"_pathTemplateRegExp": /\\(\\{type\\}\\)\\|\\(\\{subType\\}\\)\\|\\(\\{number\\}\\)\\|\\(\\{seasonNumber\\}\\)\\|\\(\\{episodeNumber\\}\\)\\|\\(\\{id\\}\\)/g,
|
|
19
|
-
"_performance": "mock-performance",
|
|
20
|
-
"_queryParams": {
|
|
21
|
-
"api_key": "12345",
|
|
22
|
-
},
|
|
23
|
-
"_rateLimit": false,
|
|
24
|
-
"_rateLimitCount": 0,
|
|
25
|
-
"_rateLimitPerSecond": 30,
|
|
26
|
-
"_rateLimitTimer": undefined,
|
|
27
|
-
"_rateLimitedRequestQueue": [],
|
|
28
|
-
"_requestRetryWait": 100,
|
|
29
|
-
"_requestTracker": {
|
|
30
|
-
"active": [],
|
|
31
|
-
"pending": Map {},
|
|
32
|
-
},
|
|
33
|
-
"_streamReader": "json",
|
|
34
|
-
"authenticate": [Function],
|
|
35
|
-
"certifications": [Function],
|
|
36
|
-
"collection": [Function],
|
|
37
|
-
"company": [Function],
|
|
38
|
-
"configuration": [Function],
|
|
39
|
-
"credit": [Function],
|
|
40
|
-
"discover": [Function],
|
|
41
|
-
"episode": [Function],
|
|
42
|
-
"find": [Function],
|
|
43
|
-
"genres": [Function],
|
|
44
|
-
"keyword": [Function],
|
|
45
|
-
"movie": [Function],
|
|
46
|
-
"network": [Function],
|
|
47
|
-
"person": [Function],
|
|
48
|
-
"popular": [Function],
|
|
49
|
-
"rated": [Function],
|
|
50
|
-
"review": [Function],
|
|
51
|
-
"search": [Function],
|
|
52
|
-
"season": [Function],
|
|
53
|
-
"trending": [Function],
|
|
54
|
-
"tv": [Function],
|
|
55
|
-
"watchProviders": [Function],
|
|
56
|
-
}
|
|
57
|
-
`;
|