@tmdb-graphql-api/resolvers 0.0.34 → 0.1.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.
Files changed (105) hide show
  1. package/dist/cjs/index.cjs +1 -1
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/esm/index.mjs +1 -1
  4. package/dist/esm/index.mjs.map +1 -1
  5. package/dist/production.analysis.txt +37 -37
  6. package/dist/types/cjs/helpers/getTvIdSeasonAndEpisode.d.cts +3 -2
  7. package/dist/types/cjs/helpers/getTvIdSeasonAndEpisode.d.cts.map +1 -1
  8. package/dist/types/cjs/queries/collection.d.cts +387 -387
  9. package/dist/types/cjs/queries/company.d.cts +1 -1
  10. package/dist/types/cjs/queries/credit.d.cts +468 -472
  11. package/dist/types/cjs/queries/credit.d.cts.map +1 -1
  12. package/dist/types/cjs/queries/episode.d.cts +12 -13
  13. package/dist/types/cjs/queries/episode.d.cts.map +1 -1
  14. package/dist/types/cjs/queries/episodeCredits.d.cts +5 -5
  15. package/dist/types/cjs/queries/episodeVideos.d.cts +1 -1
  16. package/dist/types/cjs/queries/find.d.cts +197 -197
  17. package/dist/types/cjs/queries/genres.d.cts +1 -1
  18. package/dist/types/cjs/queries/keyword.d.cts +1 -1
  19. package/dist/types/cjs/queries/movie.d.cts +398 -398
  20. package/dist/types/cjs/queries/movieCredits.d.cts +5 -5
  21. package/dist/types/cjs/queries/movieRecommendations.d.cts +203 -203
  22. package/dist/types/cjs/queries/movieReviews.d.cts +203 -203
  23. package/dist/types/cjs/queries/movieSimilarMovies.d.cts +203 -203
  24. package/dist/types/cjs/queries/movieVideos.d.cts +1 -1
  25. package/dist/types/cjs/queries/movieWatchProviders.d.cts +180 -180
  26. package/dist/types/cjs/queries/network.d.cts +1 -1
  27. package/dist/types/cjs/queries/person.d.cts +2 -2
  28. package/dist/types/cjs/queries/review.d.cts +2 -2
  29. package/dist/types/cjs/queries/season.d.cts +31 -34
  30. package/dist/types/cjs/queries/season.d.cts.map +1 -1
  31. package/dist/types/cjs/queries/seasonCredits.d.cts +5 -5
  32. package/dist/types/cjs/queries/seasonVideos.d.cts +1 -1
  33. package/dist/types/cjs/queries/tv.d.cts +1144 -1167
  34. package/dist/types/cjs/queries/tv.d.cts.map +1 -1
  35. package/dist/types/cjs/queries/tvCredits.d.cts +5 -5
  36. package/dist/types/cjs/queries/tvEpisodeGroups.d.cts +2 -2
  37. package/dist/types/cjs/queries/tvKeywords.d.cts +1 -1
  38. package/dist/types/cjs/queries/tvRecommendations.d.cts +582 -594
  39. package/dist/types/cjs/queries/tvRecommendations.d.cts.map +1 -1
  40. package/dist/types/cjs/queries/tvReviews.d.cts +582 -594
  41. package/dist/types/cjs/queries/tvReviews.d.cts.map +1 -1
  42. package/dist/types/cjs/queries/tvSimilarTvShows.d.cts +582 -594
  43. package/dist/types/cjs/queries/tvSimilarTvShows.d.cts.map +1 -1
  44. package/dist/types/cjs/queries/tvVideos.d.cts +1 -1
  45. package/dist/types/cjs/queries/tvWatchProviders.d.cts +180 -180
  46. package/dist/types/cjs/types.d.cts +0 -2
  47. package/dist/types/cjs/types.d.cts.map +1 -1
  48. package/dist/types/esm/helpers/getTvIdSeasonAndEpisode.d.ts +3 -2
  49. package/dist/types/esm/helpers/getTvIdSeasonAndEpisode.d.ts.map +1 -1
  50. package/dist/types/esm/queries/collection.d.ts +387 -387
  51. package/dist/types/esm/queries/company.d.ts +1 -1
  52. package/dist/types/esm/queries/credit.d.ts +468 -472
  53. package/dist/types/esm/queries/credit.d.ts.map +1 -1
  54. package/dist/types/esm/queries/episode.d.ts +12 -13
  55. package/dist/types/esm/queries/episode.d.ts.map +1 -1
  56. package/dist/types/esm/queries/episodeCredits.d.ts +5 -5
  57. package/dist/types/esm/queries/episodeVideos.d.ts +1 -1
  58. package/dist/types/esm/queries/find.d.ts +197 -197
  59. package/dist/types/esm/queries/genres.d.ts +1 -1
  60. package/dist/types/esm/queries/keyword.d.ts +1 -1
  61. package/dist/types/esm/queries/movie.d.ts +398 -398
  62. package/dist/types/esm/queries/movieCredits.d.ts +5 -5
  63. package/dist/types/esm/queries/movieRecommendations.d.ts +203 -203
  64. package/dist/types/esm/queries/movieReviews.d.ts +203 -203
  65. package/dist/types/esm/queries/movieSimilarMovies.d.ts +203 -203
  66. package/dist/types/esm/queries/movieVideos.d.ts +1 -1
  67. package/dist/types/esm/queries/movieWatchProviders.d.ts +180 -180
  68. package/dist/types/esm/queries/network.d.ts +1 -1
  69. package/dist/types/esm/queries/person.d.ts +2 -2
  70. package/dist/types/esm/queries/review.d.ts +2 -2
  71. package/dist/types/esm/queries/season.d.ts +31 -34
  72. package/dist/types/esm/queries/season.d.ts.map +1 -1
  73. package/dist/types/esm/queries/seasonCredits.d.ts +5 -5
  74. package/dist/types/esm/queries/seasonVideos.d.ts +1 -1
  75. package/dist/types/esm/queries/tv.d.ts +1144 -1167
  76. package/dist/types/esm/queries/tv.d.ts.map +1 -1
  77. package/dist/types/esm/queries/tvCredits.d.ts +5 -5
  78. package/dist/types/esm/queries/tvEpisodeGroups.d.ts +2 -2
  79. package/dist/types/esm/queries/tvKeywords.d.ts +1 -1
  80. package/dist/types/esm/queries/tvRecommendations.d.ts +582 -594
  81. package/dist/types/esm/queries/tvRecommendations.d.ts.map +1 -1
  82. package/dist/types/esm/queries/tvReviews.d.ts +582 -594
  83. package/dist/types/esm/queries/tvReviews.d.ts.map +1 -1
  84. package/dist/types/esm/queries/tvSimilarTvShows.d.ts +582 -594
  85. package/dist/types/esm/queries/tvSimilarTvShows.d.ts.map +1 -1
  86. package/dist/types/esm/queries/tvVideos.d.ts +1 -1
  87. package/dist/types/esm/queries/tvWatchProviders.d.ts +180 -180
  88. package/dist/types/esm/types.d.ts +0 -2
  89. package/dist/types/esm/types.d.ts.map +1 -1
  90. package/dist/types/tsconfig.build.tsbuildinfo +1 -1
  91. package/package.json +3 -3
  92. package/src/helpers/__snapshots__/typePropNames.test.ts.snap +0 -2
  93. package/src/helpers/getTvIdSeasonAndEpisode.ts +10 -6
  94. package/src/queries/__snapshots__/episode.test.ts.snap +1 -2
  95. package/src/queries/__snapshots__/season.test.ts.snap +1 -2
  96. package/src/queries/episode.test.ts +2 -2
  97. package/src/queries/episode.ts +7 -7
  98. package/src/queries/episodeCredits.test.ts +5 -15
  99. package/src/queries/episodeExternalIds.test.ts +3 -13
  100. package/src/queries/episodeStills.test.ts +3 -13
  101. package/src/queries/episodeTranslations.test.ts +3 -13
  102. package/src/queries/episodeVideos.test.ts +3 -13
  103. package/src/queries/season.test.ts +2 -2
  104. package/src/queries/season.ts +6 -6
  105. package/src/types.ts +2 -9
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tmdb-graphql-api/resolvers",
3
3
  "description": "The TMDB GraphQL resolvers module.",
4
- "version": "0.0.34",
4
+ "version": "0.1.0",
5
5
  "author": "Dylan Aubrey",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/badbatch/themoviedb-graphql-api",
@@ -40,7 +40,7 @@
40
40
  "query-string": "^8.1.0",
41
41
  "type-fest": "^4.5.0",
42
42
  "@tmdb-graphql-api/rest-client": "0.0.9",
43
- "@tmdb-graphql-api/schema": "0.0.26"
43
+ "@tmdb-graphql-api/schema": "0.1.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@babel/runtime": "<8",
@@ -59,7 +59,7 @@
59
59
  "fetch-mocked": "^0.0.21",
60
60
  "graphql": "^16.8.1",
61
61
  "lodash-es": "^4.17.21",
62
- "@tmdb-graphql-api/test-utils": "0.0.4"
62
+ "@tmdb-graphql-api/test-utils": "0.1.0"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "pnpm run clean:dist && pnpm run compile",
@@ -266,7 +266,6 @@ exports[`typePropNames the correct prop names are returned 1`] = `
266
266
  "airDate",
267
267
  "cast",
268
268
  "crew",
269
- "episodeLookupId",
270
269
  "episodeNumber",
271
270
  "externalIds",
272
271
  "guestStars",
@@ -563,7 +562,6 @@ exports[`typePropNames the correct prop names are returned 1`] = `
563
562
  "overview",
564
563
  "posterPath",
565
564
  "posters",
566
- "seasonLookupId",
567
565
  "seasonNumber",
568
566
  "translations",
569
567
  "tvShowId",
@@ -1,21 +1,25 @@
1
+ import { type QueryEpisodeArgs, type QuerySeasonArgs } from '@tmdb-graphql-api/schema/types';
1
2
  import { type RawEpisode, type RawSeason } from '../types.ts';
2
3
  import { decodeId } from './decodeId.ts';
3
4
 
4
- export const getTvIdSeasonAndEpisode = (obj: RawSeason | RawEpisode | undefined, lookupId: string) => {
5
- let tvId: number;
5
+ export const getTvIdSeasonAndEpisode = (
6
+ obj: RawSeason | RawEpisode | undefined,
7
+ args: QuerySeasonArgs | QueryEpisodeArgs
8
+ ) => {
9
+ let id: string | number;
6
10
  let seasonNumber: number;
7
11
  let episodeNumber: number | undefined;
8
12
 
9
13
  if (obj) {
10
- tvId = obj.tv_show_id;
14
+ id = obj.tv_show_id;
11
15
  seasonNumber = obj.season_number;
12
16
  episodeNumber = 'episode_number' in obj ? obj.episode_number : undefined;
13
17
  } else {
14
- const parsed = decodeId<{ episodeNumber?: number; id: string; seasonNumber: number }>(lookupId);
15
- tvId = Number(parsed.id);
18
+ const parsed = decodeId<{ episodeNumber?: number; id: string; seasonNumber: number }>(args.id as string);
19
+ id = parsed.id;
16
20
  seasonNumber = parsed.seasonNumber;
17
21
  episodeNumber = parsed.episodeNumber;
18
22
  }
19
23
 
20
- return { episodeNumber, seasonNumber, tvId };
24
+ return { episodeNumber, id, seasonNumber };
21
25
  };
@@ -70,7 +70,6 @@ exports[`resolveEpisode > should return the correct episode details 1`] = `
70
70
  "profile_path": "/xvNN5huL0X8yJ7h3IZfGG4O2zBD.jpg",
71
71
  },
72
72
  ],
73
- "episode_lookup_id": "eyJzZWFzb25OdW1iZXIiOjEsInR2SWQiOjEzOTksImVwaXNvZGVOdW1iZXIiOjF9",
74
73
  "episode_number": 1,
75
74
  "guest_stars": [
76
75
  {
@@ -347,7 +346,7 @@ exports[`resolveEpisode > should return the correct episode details 1`] = `
347
346
  "profile_path": "/tNW2DukUhi0ljCxOcYqs6x30LIH.jpg",
348
347
  },
349
348
  ],
350
- "id": 63056,
349
+ "id": "eyJpZCI6MTM5OSwic2Vhc29uTnVtYmVyIjoxLCJlcGlzb2RlTnVtYmVyIjoxfQ%3D%3D",
351
350
  "name": "Winter Is Coming",
352
351
  "overview": "Jon Arryn, the Hand of the King, is dead. King Robert Baratheon plans to ask his oldest friend, Eddard Stark, to take Jon's place. Across the sea, Viserys Targaryen plans to wed his sister to a nomadic warlord in exchange for an army.",
353
352
  "production_code": "101",
@@ -4684,11 +4684,10 @@ exports[`resolveSeason > should return the correct season details 1`] = `
4684
4684
  "vote_count": 115,
4685
4685
  },
4686
4686
  ],
4687
- "id": 3624,
4687
+ "id": "eyJpZCI6MTM5OSwic2Vhc29uTnVtYmVyIjoxfQ%3D%3D",
4688
4688
  "name": "Season 1",
4689
4689
  "overview": "Trouble is brewing in the Seven Kingdoms of Westeros. For the driven inhabitants of this visionary world, control of Westeros' Iron Throne holds the lure of great power. But in a land where the seasons can last a lifetime, winter is coming...and beyond the Great Wall that protects them, an ancient evil has returned. In Season One, the story centers on three primary areas: the Stark and the Lannister families, whose designs on controlling the throne threaten a tenuous peace; the dragon princess Daenerys, heir to the former dynasty, who waits just over the Narrow Sea with her malevolent brother Viserys; and the Great Wall--a massive barrier of ice where a forgotten danger is stirring.",
4690
4690
  "poster_path": "/zwaj4egrhnXOBIit1tyb4Sbt3KP.jpg",
4691
- "season_lookup_id": "eyJzZWFzb25OdW1iZXIiOjEsInR2SWQiOjEzOTl9",
4692
4691
  "season_number": 1,
4693
4692
  "tv_show_id": 1399,
4694
4693
  }
@@ -44,7 +44,7 @@ describe('resolveEpisode >', () => {
44
44
  await expect(
45
45
  resolveEpisode(
46
46
  undefined,
47
- { episodeLookupId: encodeId({ episodeNumber: 1, id, seasonNumber: 1 }) },
47
+ { id: encodeId({ episodeNumber: 1, id, seasonNumber: 1 }) },
48
48
  { restClient, setCacheMetadata, tmdbGuestSessionId: 'mock-tmdbGuestSessionId' } as unknown as Context,
49
49
  { fieldNodes: [fieldNode] } as unknown as GraphQLResolveInfo
50
50
  )
@@ -61,7 +61,7 @@ describe('resolveEpisode >', () => {
61
61
 
62
62
  await resolveEpisode(
63
63
  undefined,
64
- { episodeLookupId: encodeId({ episodeNumber: 1, id, seasonNumber: 1 }) },
64
+ { id: encodeId({ episodeNumber: 1, id, seasonNumber: 1 }) },
65
65
  {
66
66
  restClient: { episode: episodeFetchMock } as unknown as Getta & ShortcutProperties<ShortcutMethodNames>,
67
67
  setCacheMetadata,
@@ -24,11 +24,11 @@ export const resolveEpisode = async (
24
24
  { fieldName, fieldNodes }: GraphQLResolveInfo
25
25
  ) => {
26
26
  const typedFieldName = snakeCase(fieldName) as keyof RawEpisode;
27
- const { episodeNumber, seasonNumber, tvId } = getTvIdSeasonAndEpisode(obj, args.episodeLookupId);
27
+ const { episodeNumber, id, seasonNumber } = getTvIdSeasonAndEpisode(obj, args);
28
28
 
29
29
  if (obj && !isUndefined(obj[typedFieldName])) {
30
- return typedFieldName === 'episode_lookup_id'
31
- ? encodeId({ seasonNumber, tvId, ...(episodeNumber ? { episodeNumber } : {}) })
30
+ return typedFieldName === 'id'
31
+ ? encodeId({ id, seasonNumber, ...(episodeNumber ? { episodeNumber } : {}) })
32
32
  : obj[typedFieldName];
33
33
  }
34
34
 
@@ -36,7 +36,7 @@ export const resolveEpisode = async (
36
36
 
37
37
  const { data, errors, headers } = await restClient.episode<RawEpisodeWithAppendToResponse>(
38
38
  {
39
- pathTemplateData: { episodeNumber, id: tvId, seasonNumber },
39
+ pathTemplateData: { episodeNumber, id, seasonNumber },
40
40
  ...(appendToResponseKeys.length > 0
41
41
  ? {
42
42
  queryParams: {
@@ -50,16 +50,16 @@ export const resolveEpisode = async (
50
50
 
51
51
  if (errors?.length) {
52
52
  throw new GraphQLError(
53
- `Failed to resolve ${TV} show ${tvId} ${SEASON} ${seasonNumber} ${EPISODE} ${episodeNumber!}.`,
53
+ `Failed to resolve ${TV} show ${id} ${SEASON} ${seasonNumber} ${EPISODE} ${episodeNumber!}.`,
54
54
  { nodes: fieldNodes, originalError: errors[0] }
55
55
  );
56
56
  }
57
57
 
58
58
  const rawEpisode = data!;
59
- rawEpisode.episode_lookup_id = encodeId({ seasonNumber, tvId, ...(episodeNumber ? { episodeNumber } : {}) });
59
+ rawEpisode.id = encodeId({ id, seasonNumber, ...(episodeNumber ? { episodeNumber } : {}) });
60
60
 
61
61
  if (!rawEpisode.tv_show_id) {
62
- rawEpisode.tv_show_id = tvId;
62
+ rawEpisode.tv_show_id = id;
63
63
  }
64
64
 
65
65
  if (obj) {
@@ -8,21 +8,11 @@ import { type FetchResponse, type Getta, type ShortcutProperties } from 'getta';
8
8
  import { type GraphQLResolveInfo } from 'graphql';
9
9
  import { buildEndpoint } from '../__testUtils__/helpers/buildEndpoint.ts';
10
10
  import { createRestClient } from '../__testUtils__/helpers/createRestClient.ts';
11
- import { encodeId } from '../helpers/encodeId.ts';
12
11
  import { type Context, type RawEpisode } from '../types.ts';
13
12
  import { resolveEpisodeCredits } from './episodeCredits.ts';
14
13
 
15
14
  const mockedFetch = mockFetch(jest.fn);
16
15
 
17
- const episodeDetailsWithLookupId: RawEpisode = {
18
- ...episodeDetails,
19
- episode_lookup_id: encodeId({
20
- episodeNumber: episodeDetails.episode_number,
21
- seasonNumber: episodeDetails.season_number,
22
- tvId: episodeDetails.tv_show_id,
23
- }),
24
- };
25
-
26
16
  describe('resolveEpisodeCredits >', () => {
27
17
  let restClient: Getta & ShortcutProperties<ShortcutMethodNames>;
28
18
  const setCacheMetadata = jest.fn();
@@ -52,7 +42,7 @@ describe('resolveEpisodeCredits >', () => {
52
42
  it('should return the correct response', async () => {
53
43
  await expect(
54
44
  resolveEpisodeCredits(
55
- episodeDetailsWithLookupId,
45
+ episodeDetails as RawEpisode,
56
46
  undefined,
57
47
  { restClient, setCacheMetadata, tmdbGuestSessionId: 'mock-tmdbGuestSessionId' } as unknown as Context,
58
48
  {
@@ -67,7 +57,7 @@ describe('resolveEpisodeCredits >', () => {
67
57
  it('should return the correct response', async () => {
68
58
  await expect(
69
59
  resolveEpisodeCredits(
70
- episodeDetailsWithLookupId,
60
+ episodeDetails as RawEpisode,
71
61
  undefined,
72
62
  { restClient, setCacheMetadata, tmdbGuestSessionId: 'mock-tmdbGuestSessionId' } as unknown as Context,
73
63
  {
@@ -82,7 +72,7 @@ describe('resolveEpisodeCredits >', () => {
82
72
  it('should return the correct response', async () => {
83
73
  await expect(
84
74
  resolveEpisodeCredits(
85
- episodeDetailsWithLookupId,
75
+ episodeDetails as RawEpisode,
86
76
  undefined,
87
77
  { restClient, setCacheMetadata, tmdbGuestSessionId: 'mock-tmdbGuestSessionId' } as unknown as Context,
88
78
  {
@@ -103,7 +93,7 @@ describe('resolveEpisodeCredits >', () => {
103
93
 
104
94
  await expect(
105
95
  resolveEpisodeCredits(
106
- { ...episodeDetailsWithLookupId, __headers: new Headers(), credits: rest },
96
+ { ...episodeDetails, __headers: new Headers(), credits: rest },
107
97
  undefined,
108
98
  {
109
99
  restClient: { episode: episodeFetchMock } as unknown as Getta & ShortcutProperties<ShortcutMethodNames>,
@@ -125,7 +115,7 @@ describe('resolveEpisodeCredits >', () => {
125
115
  const { id, ...rest } = episodeCredits;
126
116
 
127
117
  await resolveEpisodeCredits(
128
- { ...episodeDetailsWithLookupId, __headers: new Headers(), credits: rest },
118
+ { ...episodeDetails, __headers: new Headers(), credits: rest },
129
119
  undefined,
130
120
  {
131
121
  restClient: { episode: episodeFetchMock } as unknown as Getta & ShortcutProperties<ShortcutMethodNames>,
@@ -8,21 +8,11 @@ import { type FetchResponse, type Getta, type ShortcutProperties } from 'getta';
8
8
  import { type GraphQLResolveInfo } from 'graphql';
9
9
  import { buildEndpoint } from '../__testUtils__/helpers/buildEndpoint.ts';
10
10
  import { createRestClient } from '../__testUtils__/helpers/createRestClient.ts';
11
- import { encodeId } from '../helpers/encodeId.ts';
12
11
  import { type Context, type RawEpisode, type RawEpisodeWithAppendToResponse } from '../types.ts';
13
12
  import { resolveEpisodeExternalIds } from './episodeExternalIds.ts';
14
13
 
15
14
  const mockedFetch = mockFetch(jest.fn);
16
15
 
17
- const episodeDetailsWithLookupId: RawEpisode = {
18
- ...episodeDetails,
19
- episode_lookup_id: encodeId({
20
- episodeNumber: episodeDetails.episode_number,
21
- seasonNumber: episodeDetails.season_number,
22
- tvId: episodeDetails.tv_show_id,
23
- }),
24
- };
25
-
26
16
  describe('resolveEpisodeExternalIds >', () => {
27
17
  let restClient: Getta & ShortcutProperties<ShortcutMethodNames>;
28
18
  const setCacheMetadata = jest.fn();
@@ -51,7 +41,7 @@ describe('resolveEpisodeExternalIds >', () => {
51
41
  it('should return the episode external IDs', async () => {
52
42
  await expect(
53
43
  resolveEpisodeExternalIds(
54
- episodeDetailsWithLookupId,
44
+ episodeDetails as RawEpisode,
55
45
  undefined,
56
46
  { restClient, setCacheMetadata, tmdbGuestSessionId: 'mock-tmdbGuestSessionId' } as unknown as Context,
57
47
  {} as GraphQLResolveInfo
@@ -70,7 +60,7 @@ describe('resolveEpisodeExternalIds >', () => {
70
60
  await expect(
71
61
  resolveEpisodeExternalIds(
72
62
  {
73
- ...episodeDetailsWithLookupId,
63
+ ...episodeDetails,
74
64
  __headers: new Headers(),
75
65
  external_ids: rest,
76
66
  } as unknown as RawEpisodeWithAppendToResponse,
@@ -94,7 +84,7 @@ describe('resolveEpisodeExternalIds >', () => {
94
84
 
95
85
  await resolveEpisodeExternalIds(
96
86
  {
97
- ...episodeDetailsWithLookupId,
87
+ ...episodeDetails,
98
88
  __headers: new Headers(),
99
89
  external_ids: rest,
100
90
  } as unknown as RawEpisodeWithAppendToResponse,
@@ -8,21 +8,11 @@ import { type FetchResponse, type Getta, type ShortcutProperties } from 'getta';
8
8
  import { type GraphQLResolveInfo } from 'graphql';
9
9
  import { buildEndpoint } from '../__testUtils__/helpers/buildEndpoint.ts';
10
10
  import { createRestClient } from '../__testUtils__/helpers/createRestClient.ts';
11
- import { encodeId } from '../helpers/encodeId.ts';
12
11
  import { type Context, type RawEpisode } from '../types.ts';
13
12
  import { resolveEpisodeStills } from './episodeStills.ts';
14
13
 
15
14
  const mockedFetch = mockFetch(jest.fn);
16
15
 
17
- const episodeDetailsWithLookupId: RawEpisode = {
18
- ...episodeDetails,
19
- episode_lookup_id: encodeId({
20
- episodeNumber: episodeDetails.episode_number,
21
- seasonNumber: episodeDetails.season_number,
22
- tvId: episodeDetails.tv_show_id,
23
- }),
24
- };
25
-
26
16
  describe('resolveEpisodeStills >', () => {
27
17
  let restClient: Getta & ShortcutProperties<ShortcutMethodNames>;
28
18
  const setCacheMetadata = jest.fn();
@@ -51,7 +41,7 @@ describe('resolveEpisodeStills >', () => {
51
41
  it('should return the episode stills', async () => {
52
42
  await expect(
53
43
  resolveEpisodeStills(
54
- episodeDetailsWithLookupId,
44
+ episodeDetails as RawEpisode,
55
45
  undefined,
56
46
  { restClient, setCacheMetadata, tmdbGuestSessionId: 'mock-tmdbGuestSessionId' } as unknown as Context,
57
47
  {} as GraphQLResolveInfo
@@ -69,7 +59,7 @@ describe('resolveEpisodeStills >', () => {
69
59
 
70
60
  await expect(
71
61
  resolveEpisodeStills(
72
- { ...episodeDetailsWithLookupId, __headers: new Headers(), images: rest },
62
+ { ...episodeDetails, __headers: new Headers(), images: rest },
73
63
  undefined,
74
64
  {
75
65
  restClient: { episode: episodeFetchMock } as unknown as Getta & ShortcutProperties<ShortcutMethodNames>,
@@ -89,7 +79,7 @@ describe('resolveEpisodeStills >', () => {
89
79
  const { id, ...rest } = episodeStills;
90
80
 
91
81
  await resolveEpisodeStills(
92
- { ...episodeDetailsWithLookupId, __headers: new Headers(), images: rest },
82
+ { ...episodeDetails, __headers: new Headers(), images: rest },
93
83
  undefined,
94
84
  {
95
85
  restClient: { episode: episodeFetchMock } as unknown as Getta & ShortcutProperties<ShortcutMethodNames>,
@@ -8,21 +8,11 @@ import { type FetchResponse, type Getta, type ShortcutProperties } from 'getta';
8
8
  import { type GraphQLResolveInfo } from 'graphql';
9
9
  import { buildEndpoint } from '../__testUtils__/helpers/buildEndpoint.ts';
10
10
  import { createRestClient } from '../__testUtils__/helpers/createRestClient.ts';
11
- import { encodeId } from '../helpers/encodeId.ts';
12
11
  import { type Context, type RawEpisode } from '../types.ts';
13
12
  import { resolveEpisodeTranslations } from './episodeTranslations.ts';
14
13
 
15
14
  const mockedFetch = mockFetch(jest.fn);
16
15
 
17
- const episodeDetailsWithLookupId: RawEpisode = {
18
- ...episodeDetails,
19
- episode_lookup_id: encodeId({
20
- episodeNumber: episodeDetails.episode_number,
21
- seasonNumber: episodeDetails.season_number,
22
- tvId: episodeDetails.tv_show_id,
23
- }),
24
- };
25
-
26
16
  describe('resolveEpisodeTranslations >', () => {
27
17
  let restClient: Getta & ShortcutProperties<ShortcutMethodNames>;
28
18
  const setCacheMetadata = jest.fn();
@@ -51,7 +41,7 @@ describe('resolveEpisodeTranslations >', () => {
51
41
  it('should return the episode translations', async () => {
52
42
  await expect(
53
43
  resolveEpisodeTranslations(
54
- episodeDetailsWithLookupId,
44
+ episodeDetails as RawEpisode,
55
45
  undefined,
56
46
  { restClient, setCacheMetadata, tmdbGuestSessionId: 'mock-tmdbGuestSessionId' } as unknown as Context,
57
47
  {} as GraphQLResolveInfo
@@ -69,7 +59,7 @@ describe('resolveEpisodeTranslations >', () => {
69
59
 
70
60
  await expect(
71
61
  resolveEpisodeTranslations(
72
- { ...episodeDetailsWithLookupId, __headers: new Headers(), translations: rest },
62
+ { ...episodeDetails, __headers: new Headers(), translations: rest },
73
63
  undefined,
74
64
  {
75
65
  restClient: { episode: episodeFetchMock } as unknown as Getta & ShortcutProperties<ShortcutMethodNames>,
@@ -89,7 +79,7 @@ describe('resolveEpisodeTranslations >', () => {
89
79
  const { id, ...rest } = episodeTranslations;
90
80
 
91
81
  await resolveEpisodeTranslations(
92
- { ...episodeDetailsWithLookupId, __headers: new Headers(), translations: rest },
82
+ { ...episodeDetails, __headers: new Headers(), translations: rest },
93
83
  undefined,
94
84
  {
95
85
  restClient: { episode: episodeFetchMock } as unknown as Getta & ShortcutProperties<ShortcutMethodNames>,
@@ -8,21 +8,11 @@ import { type FetchResponse, type Getta, type ShortcutProperties } from 'getta';
8
8
  import { type GraphQLResolveInfo } from 'graphql';
9
9
  import { buildEndpoint } from '../__testUtils__/helpers/buildEndpoint.ts';
10
10
  import { createRestClient } from '../__testUtils__/helpers/createRestClient.ts';
11
- import { encodeId } from '../helpers/encodeId.ts';
12
11
  import { type Context, type RawEpisode } from '../types.ts';
13
12
  import { resolveEpisodeVideos } from './episodeVideos.ts';
14
13
 
15
14
  const mockedFetch = mockFetch(jest.fn);
16
15
 
17
- const episodeDetailsWithLookupId: RawEpisode = {
18
- ...episodeDetails,
19
- episode_lookup_id: encodeId({
20
- episodeNumber: episodeDetails.episode_number,
21
- seasonNumber: episodeDetails.season_number,
22
- tvId: episodeDetails.tv_show_id,
23
- }),
24
- };
25
-
26
16
  describe('resolveEpisodeVideos >', () => {
27
17
  let restClient: Getta & ShortcutProperties<ShortcutMethodNames>;
28
18
  const setCacheMetadata = jest.fn();
@@ -51,7 +41,7 @@ describe('resolveEpisodeVideos >', () => {
51
41
  it('should return the episode videos', async () => {
52
42
  await expect(
53
43
  resolveEpisodeVideos(
54
- episodeDetailsWithLookupId,
44
+ episodeDetails as RawEpisode,
55
45
  undefined,
56
46
  { restClient, setCacheMetadata, tmdbGuestSessionId: 'mock-tmdbGuestSessionId' } as unknown as Context,
57
47
  {} as GraphQLResolveInfo
@@ -69,7 +59,7 @@ describe('resolveEpisodeVideos >', () => {
69
59
 
70
60
  await expect(
71
61
  resolveEpisodeVideos(
72
- { ...episodeDetailsWithLookupId, __headers: new Headers(), videos: rest },
62
+ { ...episodeDetails, __headers: new Headers(), videos: rest },
73
63
  undefined,
74
64
  {
75
65
  restClient: { episode: episodeFetchMock } as unknown as Getta & ShortcutProperties<ShortcutMethodNames>,
@@ -89,7 +79,7 @@ describe('resolveEpisodeVideos >', () => {
89
79
  const { id, ...rest } = episodeVideos;
90
80
 
91
81
  await resolveEpisodeVideos(
92
- { ...episodeDetailsWithLookupId, __headers: new Headers(), videos: rest },
82
+ { ...episodeDetails, __headers: new Headers(), videos: rest },
93
83
  undefined,
94
84
  {
95
85
  restClient: { episode: episodeFetchMock } as unknown as Getta & ShortcutProperties<ShortcutMethodNames>,
@@ -44,7 +44,7 @@ describe('resolveSeason >', () => {
44
44
  await expect(
45
45
  resolveSeason(
46
46
  undefined,
47
- { seasonLookupId: encodeId({ id, seasonNumber: 1 }) },
47
+ { id: encodeId({ id, seasonNumber: 1 }) },
48
48
  { restClient, setCacheMetadata, tmdbGuestSessionId: 'mock-tmdbGuestSessionId' } as unknown as Context,
49
49
  { fieldNodes: [fieldNode] } as unknown as GraphQLResolveInfo
50
50
  )
@@ -61,7 +61,7 @@ describe('resolveSeason >', () => {
61
61
 
62
62
  await resolveSeason(
63
63
  undefined,
64
- { seasonLookupId: encodeId({ id, seasonNumber: 1 }) },
64
+ { id: encodeId({ id, seasonNumber: 1 }) },
65
65
  {
66
66
  restClient: { season: seasonFetchMock } as unknown as Getta & ShortcutProperties<ShortcutMethodNames>,
67
67
  setCacheMetadata,
@@ -31,17 +31,17 @@ export const resolveSeason = async (
31
31
  { fieldName, fieldNodes }: GraphQLResolveInfo
32
32
  ) => {
33
33
  const typedFieldName = snakeCase(fieldName) as keyof RawSeason;
34
- const { seasonNumber, tvId } = getTvIdSeasonAndEpisode(obj, args.seasonLookupId);
34
+ const { id, seasonNumber } = getTvIdSeasonAndEpisode(obj, args);
35
35
 
36
36
  if (obj && !isUndefined(obj[typedFieldName])) {
37
- return typedFieldName === 'season_lookup_id' ? encodeId({ seasonNumber, tvId }) : obj[typedFieldName];
37
+ return typedFieldName === 'id' ? encodeId({ id, seasonNumber }) : obj[typedFieldName];
38
38
  }
39
39
 
40
40
  const appendToResponseKeys = getAppendToResponseKeys(fieldNodes[0]!, appendToResponse, fragmentDefinitions);
41
41
 
42
42
  const { data, errors, headers } = await restClient.season<RawSeasonWithAppendToResponse>(
43
43
  {
44
- pathTemplateData: { id: tvId, number: seasonNumber },
44
+ pathTemplateData: { id, number: seasonNumber },
45
45
  ...(appendToResponseKeys.length > 0
46
46
  ? {
47
47
  queryParams: {
@@ -54,17 +54,17 @@ export const resolveSeason = async (
54
54
  );
55
55
 
56
56
  if (errors?.length) {
57
- throw new GraphQLError(`Failed to resolve ${TV} show ${tvId} ${SEASON} ${seasonNumber}.`, {
57
+ throw new GraphQLError(`Failed to resolve ${TV} show ${id} ${SEASON} ${seasonNumber}.`, {
58
58
  nodes: fieldNodes,
59
59
  originalError: errors[0],
60
60
  });
61
61
  }
62
62
 
63
63
  const rawSeason = data!;
64
- rawSeason.season_lookup_id = encodeId({ seasonNumber, tvId });
64
+ rawSeason.id = encodeId({ id, seasonNumber });
65
65
 
66
66
  if (!rawSeason.tv_show_id) {
67
- rawSeason.tv_show_id = tvId;
67
+ rawSeason.tv_show_id = id;
68
68
  }
69
69
 
70
70
  enrichEpisodeData(rawSeason);
package/src/types.ts CHANGED
@@ -107,10 +107,7 @@ export interface RawDiscoverTv extends PlainObject {
107
107
 
108
108
  export type RawEpisode = SnakeCasedPropertiesDeep<
109
109
  Omit<Episode, 'cast' | 'crew' | 'externalIds' | 'guestStars' | 'stills' | 'translations' | 'videos'>
110
- > & {
111
- episode_lookup_id: Scalars['String'];
112
- tv_show_id?: Scalars['ID'];
113
- };
110
+ > & { tv_show_id?: Scalars['ID'] };
114
111
 
115
112
  export type RawEpisodeCredits = SnakeCasedPropertiesDeep<Pick<Episode, 'id' | 'cast' | 'crew' | 'guestStars'>>;
116
113
 
@@ -308,11 +305,7 @@ export type RawMedia = RawMovie | RawTv | RawPerson;
308
305
 
309
306
  export type RawSeason = SnakeCasedPropertiesDeep<
310
307
  Omit<Season, 'cast' | 'crew' | 'externalIds' | 'posters' | 'translations' | 'videos'>
311
- > & {
312
- episodes?: RawEpisode[];
313
- season_lookup_id: Scalars['String'];
314
- tv_show_id: Scalars['ID'];
315
- };
308
+ > & { episodes?: RawEpisode[]; tv_show_id: Scalars['ID'] };
316
309
 
317
310
  export type RawSeasonCredits = SnakeCasedPropertiesDeep<Pick<Season, 'id' | 'cast' | 'crew'>>;
318
311