@foxtware/mineral 0.1.27 → 0.1.29

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 (178) hide show
  1. package/.creds.yml.sample +29 -0
  2. package/AGENTS.md +24 -0
  3. package/_build_scripts/createNewFunction.js +26 -3
  4. package/api/dropbox/docs.md +7 -0
  5. package/api/dropbox/dropbox.constants.js +10 -0
  6. package/api/dropbox/dropbox.utils.js +67 -0
  7. package/api/dropbox/dropboxAccountGet.js +64 -0
  8. package/api/dropbox/dropboxFileCopy.js +67 -0
  9. package/api/dropbox/dropboxFileDelete.js +89 -0
  10. package/api/dropbox/dropboxFileDownload.js +139 -0
  11. package/api/dropbox/dropboxFileMetadataGet.js +100 -0
  12. package/api/dropbox/dropboxFileMove.js +67 -0
  13. package/api/dropbox/dropboxFileUpload.js +129 -0
  14. package/api/dropbox/dropboxFolderCreate.js +68 -0
  15. package/api/dropbox/dropboxFolderList.js +66 -0
  16. package/api/dropbox/dropboxGet.js +158 -0
  17. package/api/dropbox/dropboxSearch.js +161 -0
  18. package/api/dropbox/dropboxSharedLinkCreate.js +68 -0
  19. package/api/dropbox/dropboxSpaceUsageGet.js +55 -0
  20. package/api/dropbox/dropboxTemporaryLinkGet.js +75 -0
  21. package/api/fastsimon/.gitkeep +0 -0
  22. package/api/fastsimon/docs.md +14 -0
  23. package/api/fastsimon/fastsimon.constants.js +18 -0
  24. package/api/fastsimon/fastsimon.utils.js +246 -0
  25. package/api/fastsimon/fastsimonSearch.js +84 -0
  26. package/api/figma/docs.md +3 -3
  27. package/api/figma/figma.constants.js +1 -1
  28. package/api/figma/figma.utils.js +13 -2
  29. package/api/figma/figmaActivityLogsGet.js +44 -0
  30. package/api/figma/figmaAiUsageDailyGet.js +44 -0
  31. package/api/figma/figmaComponentGet.js +48 -0
  32. package/api/figma/figmaComponentSetGet.js +48 -0
  33. package/api/figma/figmaDevResourcesCreate.js +47 -0
  34. package/api/figma/figmaDevResourcesUpdate.js +47 -0
  35. package/api/figma/figmaDeveloperLogsCreate.js +47 -0
  36. package/api/figma/figmaDiscoveryGet.js +44 -0
  37. package/api/figma/figmaFileCommentCreate.js +50 -0
  38. package/api/figma/figmaFileCommentDelete.js +51 -0
  39. package/api/figma/figmaFileCommentReactionCreate.js +53 -0
  40. package/api/figma/figmaFileCommentReactionDelete.js +51 -0
  41. package/api/figma/figmaFileCommentReactionsGet.js +51 -0
  42. package/api/figma/figmaFileCommentsGet.js +48 -0
  43. package/api/figma/figmaFileComponentSetsGet.js +48 -0
  44. package/api/figma/figmaFileComponentsGet.js +48 -0
  45. package/api/figma/figmaFileDevResourceDelete.js +51 -0
  46. package/api/figma/figmaFileDevResourcesGet.js +48 -0
  47. package/api/figma/figmaFileGet.js +48 -0
  48. package/api/figma/figmaFileImageFillsGet.js +48 -0
  49. package/api/figma/figmaFileImagesGet.js +48 -0
  50. package/api/figma/figmaFileMetaGet.js +48 -0
  51. package/api/figma/figmaFileNodesGet.js +48 -0
  52. package/api/figma/figmaFileStylesGet.js +48 -0
  53. package/api/figma/figmaFileVersionsGet.js +48 -0
  54. package/api/figma/figmaFolderFilesGet.js +48 -0
  55. package/api/figma/figmaFolderFoldersGet.js +48 -0
  56. package/api/figma/figmaFolderMetaGet.js +48 -0
  57. package/api/figma/figmaGet.js +15 -63
  58. package/api/figma/figmaMeGet.js +53 -0
  59. package/api/figma/figmaOembedGet.js +44 -0
  60. package/api/figma/figmaPaymentsGet.js +44 -0
  61. package/api/figma/figmaProjectFilesGet.js +48 -0
  62. package/api/figma/figmaProjectMetaGet.js +48 -0
  63. package/api/figma/figmaStyleGet.js +48 -0
  64. package/api/figma/figmaTeamComponentSetsGet.js +48 -0
  65. package/api/figma/figmaTeamComponentsGet.js +48 -0
  66. package/api/figma/figmaTeamFoldersGet.js +48 -0
  67. package/api/figma/figmaTeamProjectsGet.js +48 -0
  68. package/api/figma/figmaTeamStylesGet.js +48 -0
  69. package/api/figma/figmaTeamWebhooksGet.js +47 -0
  70. package/api/figma/figmaVariablesLocalGet.js +48 -0
  71. package/api/figma/figmaVariablesPublishedGet.js +48 -0
  72. package/api/figma/figmaVariablesUpdate.js +50 -0
  73. package/api/figma/figmaWebhookCreate.js +47 -0
  74. package/api/figma/figmaWebhookDelete.js +48 -0
  75. package/api/figma/figmaWebhookGet.js +46 -0
  76. package/api/figma/figmaWebhookRequestsGet.js +47 -0
  77. package/api/figma/figmaWebhookUpdate.js +50 -0
  78. package/api/figma/figmaWebhooksGet.js +47 -0
  79. package/api/google/docs.md +1 -0
  80. package/api/google/google.constants.js +1 -0
  81. package/api/google/google.utils.js +21 -0
  82. package/api/google/googleanalyticsMetadataGet.js +62 -0
  83. package/api/google/googleanalyticsRealtimeReportRun.js +103 -0
  84. package/api/google/googleanalyticsReportRun.js +114 -0
  85. package/api/gorgias/gorgiasTicketCreate.js +1 -1
  86. package/api/gorgias/gorgiasTicketMessageCreate.js +1 -1
  87. package/api/gorgias/gorgiasTicketUpdate.js +1 -1
  88. package/api/linear/linearAttachmentCreate.js +1 -1
  89. package/api/linear/linearCommentCreate.js +1 -1
  90. package/api/linear/linearCommentUpdate.js +1 -1
  91. package/api/linear/linearIssueLabelCreate.js +1 -1
  92. package/api/linear/linearIssueUpdate.js +1 -1
  93. package/api/linear/linearProjectCreate.js +1 -1
  94. package/api/linear/linearProjectUpdate.js +1 -1
  95. package/api/linear/linearWebhookCreate.js +1 -1
  96. package/api/salesforce/salesforce.constants.js +13 -0
  97. package/api/salesforce/salesforce.utils.js +61 -0
  98. package/api/salesforce/salesforceAuthGet.js +115 -0
  99. package/api/salesforce/salesforceComposite.js +79 -0
  100. package/api/salesforce/salesforceCompositeBatch.js +73 -0
  101. package/api/salesforce/salesforceLimitsGet.js +55 -0
  102. package/api/salesforce/salesforceQuery.js +69 -0
  103. package/api/salesforce/salesforceQueryAll.js +62 -0
  104. package/api/salesforce/salesforceQueryMore.js +75 -0
  105. package/api/salesforce/salesforceRecentItemsGet.js +63 -0
  106. package/api/salesforce/salesforceResourcesGet.js +55 -0
  107. package/api/salesforce/salesforceSearch.js +62 -0
  108. package/api/salesforce/salesforceSobjectBasicInfoGet.js +81 -0
  109. package/api/salesforce/salesforceSobjectBlobGet.js +67 -0
  110. package/api/salesforce/salesforceSobjectCollectionCreate.js +78 -0
  111. package/api/salesforce/salesforceSobjectCollectionDelete.js +70 -0
  112. package/api/salesforce/salesforceSobjectCollectionGet.js +75 -0
  113. package/api/salesforce/salesforceSobjectCollectionUpdate.js +74 -0
  114. package/api/salesforce/salesforceSobjectCreate.js +66 -0
  115. package/api/salesforce/salesforceSobjectDelete.js +86 -0
  116. package/api/salesforce/salesforceSobjectDeleteByExternalId.js +91 -0
  117. package/api/salesforce/salesforceSobjectDeletedGet.js +71 -0
  118. package/api/salesforce/salesforceSobjectDescribe.js +81 -0
  119. package/api/salesforce/salesforceSobjectDescribeLayouts.js +64 -0
  120. package/api/salesforce/salesforceSobjectGet.js +93 -0
  121. package/api/salesforce/salesforceSobjectGetByExternalId.js +98 -0
  122. package/api/salesforce/salesforceSobjectTreeCreate.js +79 -0
  123. package/api/salesforce/salesforceSobjectUpdate.js +94 -0
  124. package/api/salesforce/salesforceSobjectUpdatedGet.js +71 -0
  125. package/api/salesforce/salesforceSobjectUpsert.js +74 -0
  126. package/api/salesforce/salesforceSobjectsDescribeGlobal.js +55 -0
  127. package/api/salesforce/salesforceVersionsGet.js +62 -0
  128. package/api/shopify/shopify.utils.js +53 -4
  129. package/api/shopify/shopifyMetaobjectCreate.js +79 -0
  130. package/api/shopify/shopifyMetaobjectDelete.js +90 -0
  131. package/api/shopify/shopifyMetaobjectGet.js +80 -0
  132. package/api/shopify/shopifyMetaobjectUpdate.js +108 -0
  133. package/api/shopify/shopifyStorefrontSearch.js +158 -0
  134. package/api/spotify/docs.md +8 -0
  135. package/api/spotify/spotify.constants.js +12 -0
  136. package/api/spotify/spotify.utils.js +106 -0
  137. package/api/spotify/spotifyAlbumGet.js +76 -0
  138. package/api/spotify/spotifyAlbumTracksGet.js +49 -0
  139. package/api/spotify/spotifyArtistAlbumsGet.js +55 -0
  140. package/api/spotify/spotifyArtistGet.js +71 -0
  141. package/api/spotify/spotifyArtistTopTracksGet.js +56 -0
  142. package/api/spotify/spotifyGet.js +171 -0
  143. package/api/spotify/spotifyMeGet.js +48 -0
  144. package/api/spotify/spotifyPlayerCurrentlyPlayingGet.js +62 -0
  145. package/api/spotify/spotifyPlayerDevicesGet.js +51 -0
  146. package/api/spotify/spotifyPlayerGet.js +63 -0
  147. package/api/spotify/spotifyPlayerNext.js +55 -0
  148. package/api/spotify/spotifyPlayerPause.js +55 -0
  149. package/api/spotify/spotifyPlayerPlay.js +70 -0
  150. package/api/spotify/spotifyPlayerPrevious.js +55 -0
  151. package/api/spotify/spotifyPlaylistCreate.js +63 -0
  152. package/api/spotify/spotifyPlaylistGet.js +91 -0
  153. package/api/spotify/spotifyPlaylistItemsAdd.js +61 -0
  154. package/api/spotify/spotifyPlaylistItemsGet.js +58 -0
  155. package/api/spotify/spotifyPlaylistItemsRemove.js +67 -0
  156. package/api/spotify/spotifyPlaylistUpdate.js +64 -0
  157. package/api/spotify/spotifyPlaylistsGet.js +47 -0
  158. package/api/spotify/spotifySavedTracksGet.js +46 -0
  159. package/api/spotify/spotifySavedTracksRemove.js +59 -0
  160. package/api/spotify/spotifySavedTracksSave.js +59 -0
  161. package/api/spotify/spotifySearch.js +174 -0
  162. package/api/spotify/spotifyTrackGet.js +76 -0
  163. package/api/tableau/tableau.constants.js +8 -0
  164. package/api/tableau/tableau.utils.js +93 -0
  165. package/api/tableau/tableauGet.js +174 -0
  166. package/api/tableau/tableauUserAdd.js +16 -94
  167. package/api/tableau/tableauUsersGet.js +46 -134
  168. package/api/tagalys/docs.md +2 -2
  169. package/api/tagalys/tagalys.constants.js +17 -0
  170. package/api/tagalys/tagalys.utils.js +125 -0
  171. package/api/tagalys/tagalysAnalyticsEventSend.js +125 -0
  172. package/api/tagalys/tagalysCollectionGet.js +100 -0
  173. package/api/tagalys/tagalysPopularSearchesGet.js +60 -0
  174. package/api/tagalys/tagalysRecommendationGet.js +109 -0
  175. package/api/tagalys/tagalysSearch.js +15 -89
  176. package/api/tagalys/tagalysSearchSuggestionsGet.js +76 -0
  177. package/package.json +2 -1
  178. package/server.js +3 -1
@@ -0,0 +1,91 @@
1
+ // https://developer.spotify.com/documentation/web-api/reference/get-playlist
2
+
3
+ const { ArgsWarden, actionSingleOrMultiple, logDeep } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { spotifyClient } = require('../spotify/spotify.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['playlistId'],
10
+ ]);
11
+
12
+ const spotifyPlaylistGetSingle = async (
13
+ credsPayload,
14
+ playlistId,
15
+ {
16
+ market,
17
+ fields,
18
+ additionalTypes,
19
+ fetchClient = spotifyClient,
20
+ } = {},
21
+ ) => {
22
+ const response = await fetchClient.fetch({
23
+ context: { credsPayload },
24
+ requestPayload: {
25
+ method: 'get',
26
+ url: `/playlists/${ playlistId }`,
27
+ params: {
28
+ ...(market !== undefined && { market }),
29
+ ...(fields !== undefined && { fields }),
30
+ ...(additionalTypes !== undefined && {
31
+ additional_types: Array.isArray(additionalTypes)
32
+ ? additionalTypes.join(',')
33
+ : additionalTypes,
34
+ }),
35
+ },
36
+ },
37
+ });
38
+
39
+ const { ok, data, error } = response;
40
+ if (!ok) {
41
+ logDeep({ error });
42
+ return { ok: false, error };
43
+ }
44
+
45
+ return { ok: true, data };
46
+ };
47
+
48
+ const spotifyPlaylistGet = async (
49
+ credsPayload,
50
+ playlistId,
51
+ {
52
+ market,
53
+ fields,
54
+ additionalTypes,
55
+ queueRunOptions,
56
+ fetchClient,
57
+ } = {},
58
+ ) => {
59
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
60
+ credsPayload,
61
+ playlistId,
62
+ });
63
+ if (rejectResponse) {
64
+ return rejectResponse;
65
+ }
66
+
67
+ return actionSingleOrMultiple(
68
+ playlistId,
69
+ spotifyPlaylistGetSingle,
70
+ (playlistIdItem) => ({
71
+ args: [credsPayload, playlistIdItem, {
72
+ market,
73
+ fields,
74
+ additionalTypes,
75
+ fetchClient,
76
+ }],
77
+ }),
78
+ {
79
+ ...(queueRunOptions ? { queueRunOptions } : {}),
80
+ },
81
+ );
82
+ };
83
+
84
+ const funcApiConfig = {
85
+ argsWarden,
86
+ };
87
+
88
+ module.exports = {
89
+ spotifyPlaylistGet,
90
+ funcApiConfig,
91
+ };
@@ -0,0 +1,61 @@
1
+ // https://developer.spotify.com/documentation/web-api/reference/add-items-to-playlist
2
+
3
+ const { ArgsWarden, logDeep } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { spotifyClient } = require('../spotify/spotify.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['playlistId'],
10
+ ['uris'],
11
+ ]);
12
+
13
+ const spotifyPlaylistItemsAdd = async (
14
+ credsPayload,
15
+ playlistId,
16
+ uris,
17
+ {
18
+ position,
19
+ fetchClient = spotifyClient,
20
+ } = {},
21
+ ) => {
22
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
23
+ credsPayload,
24
+ playlistId,
25
+ uris,
26
+ });
27
+ if (rejectResponse) {
28
+ return rejectResponse;
29
+ }
30
+
31
+ const uriList = Array.isArray(uris) ? uris : [uris];
32
+
33
+ const response = await fetchClient.fetch({
34
+ context: { credsPayload },
35
+ requestPayload: {
36
+ method: 'post',
37
+ url: `/playlists/${ playlistId }/items`,
38
+ body: {
39
+ uris: uriList,
40
+ ...(position !== undefined && { position }),
41
+ },
42
+ },
43
+ });
44
+
45
+ const { ok, data, error } = response;
46
+ if (!ok) {
47
+ logDeep({ error });
48
+ return { ok: false, error };
49
+ }
50
+
51
+ return { ok: true, data };
52
+ };
53
+
54
+ const funcApiConfig = {
55
+ argsWarden,
56
+ };
57
+
58
+ module.exports = {
59
+ spotifyPlaylistItemsAdd,
60
+ funcApiConfig,
61
+ };
@@ -0,0 +1,58 @@
1
+ // https://developer.spotify.com/documentation/web-api/reference/get-playlists-items
2
+ // (formerly /tracks; renamed to /items)
3
+
4
+ const { ArgsWarden } = require('../utils');
5
+ const { credsValidator } = require('../validators');
6
+ const { spotifyGet } = require('../spotify/spotifyGet');
7
+ const { MAX_PER_PAGE } = require('../spotify/spotify.constants');
8
+
9
+ const argsWarden = new ArgsWarden([
10
+ ['credsPayload', credsValidator],
11
+ ['playlistId'],
12
+ ]);
13
+
14
+ const spotifyPlaylistItemsGet = async (
15
+ credsPayload,
16
+ playlistId,
17
+ {
18
+ market,
19
+ fields,
20
+ additionalTypes,
21
+ perPage = MAX_PER_PAGE,
22
+ fetchClient,
23
+ ...getterOptions
24
+ } = {},
25
+ ) => {
26
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
27
+ credsPayload,
28
+ playlistId,
29
+ });
30
+ if (rejectResponse) {
31
+ return rejectResponse;
32
+ }
33
+
34
+ return spotifyGet(credsPayload, `/playlists/${ playlistId }/items`, {
35
+ params: {
36
+ ...(market !== undefined && { market }),
37
+ ...(fields !== undefined && { fields }),
38
+ ...(additionalTypes !== undefined && {
39
+ additional_types: Array.isArray(additionalTypes)
40
+ ? additionalTypes.join(',')
41
+ : additionalTypes,
42
+ }),
43
+ },
44
+ perPage,
45
+ resultsKey: 'items',
46
+ fetchClient,
47
+ ...getterOptions,
48
+ });
49
+ };
50
+
51
+ const funcApiConfig = {
52
+ argsWarden,
53
+ };
54
+
55
+ module.exports = {
56
+ spotifyPlaylistItemsGet,
57
+ funcApiConfig,
58
+ };
@@ -0,0 +1,67 @@
1
+ // https://developer.spotify.com/documentation/web-api/reference/remove-playlist-items
2
+
3
+ const { ArgsWarden, logDeep } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { spotifyClient } = require('../spotify/spotify.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['playlistId'],
10
+ ['tracks'],
11
+ ]);
12
+
13
+ // tracks: array of { uri, positions? } or array of uri strings
14
+ const spotifyPlaylistItemsRemove = async (
15
+ credsPayload,
16
+ playlistId,
17
+ tracks,
18
+ {
19
+ snapshotId,
20
+ fetchClient = spotifyClient,
21
+ } = {},
22
+ ) => {
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ playlistId,
26
+ tracks,
27
+ });
28
+ if (rejectResponse) {
29
+ return rejectResponse;
30
+ }
31
+
32
+ const trackList = (Array.isArray(tracks) ? tracks : [tracks]).map((entry) => {
33
+ if (typeof entry === 'string') {
34
+ return { uri: entry };
35
+ }
36
+ return entry;
37
+ });
38
+
39
+ const response = await fetchClient.fetch({
40
+ context: { credsPayload },
41
+ requestPayload: {
42
+ method: 'delete',
43
+ url: `/playlists/${ playlistId }/items`,
44
+ body: {
45
+ tracks: trackList,
46
+ ...(snapshotId !== undefined && { snapshot_id: snapshotId }),
47
+ },
48
+ },
49
+ });
50
+
51
+ const { ok, data, error } = response;
52
+ if (!ok) {
53
+ logDeep({ error });
54
+ return { ok: false, error };
55
+ }
56
+
57
+ return { ok: true, data };
58
+ };
59
+
60
+ const funcApiConfig = {
61
+ argsWarden,
62
+ };
63
+
64
+ module.exports = {
65
+ spotifyPlaylistItemsRemove,
66
+ funcApiConfig,
67
+ };
@@ -0,0 +1,64 @@
1
+ // https://developer.spotify.com/documentation/web-api/reference/change-playlist-details
2
+
3
+ const { ArgsWarden, logDeep } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { spotifyClient } = require('../spotify/spotify.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['playlistId'],
10
+ ]);
11
+
12
+ const spotifyPlaylistUpdate = async (
13
+ credsPayload,
14
+ playlistId,
15
+ {
16
+ name,
17
+ public: isPublic,
18
+ collaborative,
19
+ description,
20
+ fetchClient = spotifyClient,
21
+ } = {},
22
+ ) => {
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ playlistId,
26
+ });
27
+ if (rejectResponse) {
28
+ return rejectResponse;
29
+ }
30
+
31
+ const response = await fetchClient.fetch({
32
+ context: { credsPayload },
33
+ requestPayload: {
34
+ method: 'put',
35
+ url: `/playlists/${ playlistId }`,
36
+ body: {
37
+ ...(name !== undefined && { name }),
38
+ ...(isPublic !== undefined && { public: isPublic }),
39
+ ...(collaborative !== undefined && { collaborative }),
40
+ ...(description !== undefined && { description }),
41
+ },
42
+ },
43
+ });
44
+
45
+ const { ok, data, error } = response;
46
+ if (!ok) {
47
+ logDeep({ error });
48
+ return { ok: false, error };
49
+ }
50
+
51
+ return {
52
+ ok: true,
53
+ data: data ?? null,
54
+ };
55
+ };
56
+
57
+ const funcApiConfig = {
58
+ argsWarden,
59
+ };
60
+
61
+ module.exports = {
62
+ spotifyPlaylistUpdate,
63
+ funcApiConfig,
64
+ };
@@ -0,0 +1,47 @@
1
+ // https://developer.spotify.com/documentation/web-api/reference/get-a-list-of-current-users-playlists
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { spotifyGet } = require('../spotify/spotifyGet');
6
+ const { MAX_PER_PAGE } = require('../spotify/spotify.constants');
7
+
8
+ const argsWarden = new ArgsWarden([
9
+ ['credsPayload', credsValidator],
10
+ ]);
11
+
12
+ const spotifyPlaylistsGet = async (
13
+ credsPayload,
14
+ {
15
+ userId,
16
+ perPage = MAX_PER_PAGE,
17
+ fetchClient,
18
+ ...getterOptions
19
+ } = {},
20
+ ) => {
21
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
22
+ credsPayload,
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ const url = userId
29
+ ? `/users/${ userId }/playlists`
30
+ : '/me/playlists';
31
+
32
+ return spotifyGet(credsPayload, url, {
33
+ perPage,
34
+ resultsKey: 'items',
35
+ fetchClient,
36
+ ...getterOptions,
37
+ });
38
+ };
39
+
40
+ const funcApiConfig = {
41
+ argsWarden,
42
+ };
43
+
44
+ module.exports = {
45
+ spotifyPlaylistsGet,
46
+ funcApiConfig,
47
+ };
@@ -0,0 +1,46 @@
1
+ // https://developer.spotify.com/documentation/web-api/reference/get-users-saved-tracks
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { spotifyGet } = require('../spotify/spotifyGet');
6
+ const { MAX_PER_PAGE } = require('../spotify/spotify.constants');
7
+
8
+ const argsWarden = new ArgsWarden([
9
+ ['credsPayload', credsValidator],
10
+ ]);
11
+
12
+ const spotifySavedTracksGet = async (
13
+ credsPayload,
14
+ {
15
+ market,
16
+ perPage = MAX_PER_PAGE,
17
+ fetchClient,
18
+ ...getterOptions
19
+ } = {},
20
+ ) => {
21
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
22
+ credsPayload,
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ return spotifyGet(credsPayload, '/me/tracks', {
29
+ params: {
30
+ ...(market !== undefined && { market }),
31
+ },
32
+ perPage,
33
+ resultsKey: 'items',
34
+ fetchClient,
35
+ ...getterOptions,
36
+ });
37
+ };
38
+
39
+ const funcApiConfig = {
40
+ argsWarden,
41
+ };
42
+
43
+ module.exports = {
44
+ spotifySavedTracksGet,
45
+ funcApiConfig,
46
+ };
@@ -0,0 +1,59 @@
1
+ // https://developer.spotify.com/documentation/web-api/reference/remove-tracks-user
2
+
3
+ const { ArgsWarden, logDeep } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { spotifyClient } = require('../spotify/spotify.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['ids'],
10
+ ]);
11
+
12
+ const spotifySavedTracksRemove = async (
13
+ credsPayload,
14
+ ids,
15
+ {
16
+ fetchClient = spotifyClient,
17
+ } = {},
18
+ ) => {
19
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
20
+ credsPayload,
21
+ ids,
22
+ });
23
+ if (rejectResponse) {
24
+ return rejectResponse;
25
+ }
26
+
27
+ const idList = Array.isArray(ids) ? ids : [ids];
28
+
29
+ const response = await fetchClient.fetch({
30
+ context: { credsPayload },
31
+ requestPayload: {
32
+ method: 'delete',
33
+ url: '/me/tracks',
34
+ params: {
35
+ ids: idList.join(','),
36
+ },
37
+ },
38
+ });
39
+
40
+ const { ok, data, error } = response;
41
+ if (!ok) {
42
+ logDeep({ error });
43
+ return { ok: false, error };
44
+ }
45
+
46
+ return {
47
+ ok: true,
48
+ data: data ?? null,
49
+ };
50
+ };
51
+
52
+ const funcApiConfig = {
53
+ argsWarden,
54
+ };
55
+
56
+ module.exports = {
57
+ spotifySavedTracksRemove,
58
+ funcApiConfig,
59
+ };
@@ -0,0 +1,59 @@
1
+ // https://developer.spotify.com/documentation/web-api/reference/save-tracks-user
2
+
3
+ const { ArgsWarden, logDeep } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { spotifyClient } = require('../spotify/spotify.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['ids'],
10
+ ]);
11
+
12
+ const spotifySavedTracksSave = async (
13
+ credsPayload,
14
+ ids,
15
+ {
16
+ fetchClient = spotifyClient,
17
+ } = {},
18
+ ) => {
19
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
20
+ credsPayload,
21
+ ids,
22
+ });
23
+ if (rejectResponse) {
24
+ return rejectResponse;
25
+ }
26
+
27
+ const idList = Array.isArray(ids) ? ids : [ids];
28
+
29
+ const response = await fetchClient.fetch({
30
+ context: { credsPayload },
31
+ requestPayload: {
32
+ method: 'put',
33
+ url: '/me/tracks',
34
+ params: {
35
+ ids: idList.join(','),
36
+ },
37
+ },
38
+ });
39
+
40
+ const { ok, data, error } = response;
41
+ if (!ok) {
42
+ logDeep({ error });
43
+ return { ok: false, error };
44
+ }
45
+
46
+ return {
47
+ ok: true,
48
+ data: data ?? null,
49
+ };
50
+ };
51
+
52
+ const funcApiConfig = {
53
+ argsWarden,
54
+ };
55
+
56
+ module.exports = {
57
+ spotifySavedTracksSave,
58
+ funcApiConfig,
59
+ };