@keystrokehq/spotify 0.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 (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +113 -0
  3. package/dist/_official/index.d.mts +32 -0
  4. package/dist/_official/index.mjs +3 -0
  5. package/dist/_runtime/index.d.mts +1 -0
  6. package/dist/_runtime/index.mjs +1 -0
  7. package/dist/albums.d.mts +265 -0
  8. package/dist/albums.mjs +72 -0
  9. package/dist/artists.d.mts +237 -0
  10. package/dist/artists.mjs +84 -0
  11. package/dist/audio-analysis.d.mts +91 -0
  12. package/dist/audio-analysis.mjs +19 -0
  13. package/dist/audio-features.d.mts +61 -0
  14. package/dist/audio-features.mjs +31 -0
  15. package/dist/audiobooks.d.mts +176 -0
  16. package/dist/audiobooks.mjs +59 -0
  17. package/dist/browse.d.mts +74 -0
  18. package/dist/browse.mjs +31 -0
  19. package/dist/categories.d.mts +118 -0
  20. package/dist/categories.mjs +66 -0
  21. package/dist/chapters.d.mts +163 -0
  22. package/dist/chapters.mjs +39 -0
  23. package/dist/client.d.mts +3486 -0
  24. package/dist/client.mjs +758 -0
  25. package/dist/connection.d.mts +2 -0
  26. package/dist/connection.mjs +3 -0
  27. package/dist/episodes.d.mts +149 -0
  28. package/dist/episodes.mjs +39 -0
  29. package/dist/errors.d.mts +34 -0
  30. package/dist/errors.mjs +89 -0
  31. package/dist/events.d.mts +613 -0
  32. package/dist/events.mjs +55 -0
  33. package/dist/factory-tZba6Hij.mjs +8 -0
  34. package/dist/follow.d.mts +83 -0
  35. package/dist/follow.mjs +65 -0
  36. package/dist/genres.d.mts +14 -0
  37. package/dist/genres.mjs +19 -0
  38. package/dist/index.d.mts +1 -0
  39. package/dist/index.mjs +1 -0
  40. package/dist/integration-DQ5Egd4f.d.mts +41 -0
  41. package/dist/integration-ykoImsCq.mjs +78 -0
  42. package/dist/library.d.mts +472 -0
  43. package/dist/library.mjs +225 -0
  44. package/dist/markets.d.mts +14 -0
  45. package/dist/markets.mjs +20 -0
  46. package/dist/me.d.mts +169 -0
  47. package/dist/me.mjs +58 -0
  48. package/dist/messaging.d.mts +1 -0
  49. package/dist/messaging.mjs +1 -0
  50. package/dist/operations.d.mts +6 -0
  51. package/dist/operations.mjs +237 -0
  52. package/dist/player.d.mts +877 -0
  53. package/dist/player.mjs +220 -0
  54. package/dist/playlists.d.mts +546 -0
  55. package/dist/playlists.mjs +243 -0
  56. package/dist/recommendations.d.mts +144 -0
  57. package/dist/recommendations.mjs +137 -0
  58. package/dist/schemas.d.mts +3312 -0
  59. package/dist/schemas.mjs +460 -0
  60. package/dist/search.d.mts +389 -0
  61. package/dist/search.mjs +42 -0
  62. package/dist/shows.d.mts +159 -0
  63. package/dist/shows.mjs +59 -0
  64. package/dist/tracks.d.mts +173 -0
  65. package/dist/tracks.mjs +37 -0
  66. package/dist/triggers.d.mts +45 -0
  67. package/dist/triggers.mjs +201 -0
  68. package/dist/users.d.mts +35 -0
  69. package/dist/users.mjs +20 -0
  70. package/dist/verification.d.mts +1 -0
  71. package/dist/verification.mjs +1 -0
  72. package/package.json +187 -0
@@ -0,0 +1,83 @@
1
+ import { z } from "zod";
2
+ import * as _keystrokehq_core0 from "@keystrokehq/core";
3
+ import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
4
+
5
+ //#region src/follow.d.ts
6
+ declare const getFollowedArtists: _keystrokehq_core0.Operation<z.ZodObject<{
7
+ after: z.ZodOptional<z.ZodString>;
8
+ limit: z.ZodOptional<z.ZodNumber>;
9
+ }, z.core.$strip>, z.ZodObject<{
10
+ href: z.ZodOptional<z.ZodURL>;
11
+ items: z.ZodArray<z.ZodObject<{
12
+ externalUrls: z.ZodOptional<z.ZodObject<{
13
+ spotify: z.ZodOptional<z.ZodURL>;
14
+ }, z.core.$strip>>;
15
+ href: z.ZodOptional<z.ZodURL>;
16
+ id: z.ZodString;
17
+ name: z.ZodString;
18
+ type: z.ZodLiteral<"artist">;
19
+ uri: z.ZodOptional<z.ZodString>;
20
+ followers: z.ZodOptional<z.ZodObject<{
21
+ href: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
22
+ total: z.ZodNumber;
23
+ }, z.core.$strip>>;
24
+ genres: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
+ images: z.ZodOptional<z.ZodArray<z.ZodObject<{
26
+ url: z.ZodURL;
27
+ height: z.ZodNullable<z.ZodNumber>;
28
+ width: z.ZodNullable<z.ZodNumber>;
29
+ }, z.core.$strip>>>;
30
+ popularity: z.ZodOptional<z.ZodNumber>;
31
+ }, z.core.$strip>>;
32
+ limit: z.ZodNumber;
33
+ nextPageToken: z.ZodOptional<z.ZodString>;
34
+ previousPageToken: z.ZodOptional<z.ZodString>;
35
+ total: z.ZodOptional<z.ZodNumber>;
36
+ cursors: z.ZodOptional<z.ZodObject<{
37
+ after: z.ZodOptional<z.ZodString>;
38
+ before: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strip>>;
40
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"spotify", z.ZodObject<{
41
+ SPOTIFY_ACCESS_TOKEN: z.ZodString;
42
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
43
+ SPOTIFY_ACCESS_TOKEN: z.ZodString;
44
+ }, z.core.$strip>>[] | undefined>], undefined>;
45
+ declare const followArtistsOrUsers: _keystrokehq_core0.Operation<z.ZodObject<{
46
+ type: z.ZodEnum<{
47
+ artist: "artist";
48
+ user: "user";
49
+ }>;
50
+ ids: z.ZodArray<z.ZodString>;
51
+ }, z.core.$strip>, z.ZodObject<{
52
+ success: z.ZodLiteral<true>;
53
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"spotify", z.ZodObject<{
54
+ SPOTIFY_ACCESS_TOKEN: z.ZodString;
55
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
56
+ SPOTIFY_ACCESS_TOKEN: z.ZodString;
57
+ }, z.core.$strip>>[] | undefined>], undefined>;
58
+ declare const unfollowArtistsOrUsers: _keystrokehq_core0.Operation<z.ZodObject<{
59
+ type: z.ZodEnum<{
60
+ artist: "artist";
61
+ user: "user";
62
+ }>;
63
+ ids: z.ZodArray<z.ZodString>;
64
+ }, z.core.$strip>, z.ZodObject<{
65
+ success: z.ZodLiteral<true>;
66
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"spotify", z.ZodObject<{
67
+ SPOTIFY_ACCESS_TOKEN: z.ZodString;
68
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
69
+ SPOTIFY_ACCESS_TOKEN: z.ZodString;
70
+ }, z.core.$strip>>[] | undefined>], undefined>;
71
+ declare const checkFollowingArtistsOrUsers: _keystrokehq_core0.Operation<z.ZodObject<{
72
+ type: z.ZodEnum<{
73
+ artist: "artist";
74
+ user: "user";
75
+ }>;
76
+ ids: z.ZodArray<z.ZodString>;
77
+ }, z.core.$strip>, z.ZodArray<z.ZodBoolean>, readonly [_keystrokehq_core0.CredentialSet<"spotify", z.ZodObject<{
78
+ SPOTIFY_ACCESS_TOKEN: z.ZodString;
79
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
80
+ SPOTIFY_ACCESS_TOKEN: z.ZodString;
81
+ }, z.core.$strip>>[] | undefined>], undefined>;
82
+ //#endregion
83
+ export { checkFollowingArtistsOrUsers, followArtistsOrUsers, getFollowedArtists, unfollowArtistsOrUsers };
@@ -0,0 +1,65 @@
1
+ import { createSpotifyCursorPageSchema, spotifyArtistSchema, spotifyBooleanListSchema, spotifyIdSchema, spotifyMutationSuccessSchema } from "./schemas.mjs";
2
+ import { createSpotifyClient } from "./client.mjs";
3
+ import { t as spotifyOperation } from "./factory-tZba6Hij.mjs";
4
+ import { z } from "zod";
5
+
6
+ //#region src/follow.ts
7
+ const followTypeSchema = z.enum(["artist", "user"]);
8
+ const followIdsSchema = z.array(spotifyIdSchema).min(1).max(50);
9
+ const followedArtistsPageSchema = createSpotifyCursorPageSchema(spotifyArtistSchema);
10
+ const followedArtistsInputSchema = z.object({
11
+ after: z.string().min(1).optional(),
12
+ limit: z.number().int().min(1).max(50).optional()
13
+ });
14
+ const followMutationInputSchema = z.object({
15
+ type: followTypeSchema,
16
+ ids: followIdsSchema
17
+ });
18
+ const getFollowedArtists = spotifyOperation({
19
+ id: "get_spotify_followed_artists",
20
+ name: "Get Followed Spotify Artists",
21
+ description: "List the artists followed by the current Spotify user.",
22
+ input: followedArtistsInputSchema,
23
+ output: followedArtistsPageSchema,
24
+ run: async (input, credentials) => {
25
+ return createSpotifyClient(credentials).follow.getFollowedArtists({
26
+ after: input.after,
27
+ limit: input.limit
28
+ });
29
+ }
30
+ });
31
+ const followArtistsOrUsers = spotifyOperation({
32
+ id: "follow_spotify_artists_or_users",
33
+ name: "Follow Spotify Artists Or Users",
34
+ description: "Follow Spotify artists or users for the current account.",
35
+ needsApproval: true,
36
+ input: followMutationInputSchema,
37
+ output: spotifyMutationSuccessSchema,
38
+ run: async (input, credentials) => {
39
+ return createSpotifyClient(credentials).follow.followArtistsOrUsers(input.type, input.ids);
40
+ }
41
+ });
42
+ const unfollowArtistsOrUsers = spotifyOperation({
43
+ id: "unfollow_spotify_artists_or_users",
44
+ name: "Unfollow Spotify Artists Or Users",
45
+ description: "Unfollow Spotify artists or users for the current account.",
46
+ needsApproval: true,
47
+ input: followMutationInputSchema,
48
+ output: spotifyMutationSuccessSchema,
49
+ run: async (input, credentials) => {
50
+ return createSpotifyClient(credentials).follow.unfollowArtistsOrUsers(input.type, input.ids);
51
+ }
52
+ });
53
+ const checkFollowingArtistsOrUsers = spotifyOperation({
54
+ id: "check_spotify_following_artists_or_users",
55
+ name: "Check Following Spotify Artists Or Users",
56
+ description: "Check whether the current Spotify user follows the given artists or users.",
57
+ input: followMutationInputSchema,
58
+ output: spotifyBooleanListSchema,
59
+ run: async (input, credentials) => {
60
+ return createSpotifyClient(credentials).follow.checkFollowingArtistsOrUsers(input.type, input.ids);
61
+ }
62
+ });
63
+
64
+ //#endregion
65
+ export { checkFollowingArtistsOrUsers, followArtistsOrUsers, getFollowedArtists, unfollowArtistsOrUsers };
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ import * as _keystrokehq_core0 from "@keystrokehq/core";
3
+ import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
4
+
5
+ //#region src/genres.d.ts
6
+ declare const getAvailableGenreSeeds: _keystrokehq_core0.Operation<z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
7
+ genres: z.ZodArray<z.ZodString>;
8
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"spotify", z.ZodObject<{
9
+ SPOTIFY_ACCESS_TOKEN: z.ZodString;
10
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
11
+ SPOTIFY_ACCESS_TOKEN: z.ZodString;
12
+ }, z.core.$strip>>[] | undefined>], undefined>;
13
+ //#endregion
14
+ export { getAvailableGenreSeeds };
@@ -0,0 +1,19 @@
1
+ import { createSpotifyClient } from "./client.mjs";
2
+ import { t as spotifyOperation } from "./factory-tZba6Hij.mjs";
3
+ import { z } from "zod";
4
+
5
+ //#region src/genres.ts
6
+ const availableGenreSeedsResponseSchema = z.object({ genres: z.array(z.string().min(1)) });
7
+ const getAvailableGenreSeeds = spotifyOperation({
8
+ id: "get_spotify_available_genre_seeds",
9
+ name: "Get Spotify Available Genre Seeds",
10
+ description: "List Spotify recommendation genre seeds. This endpoint is deprecated upstream by Spotify.",
11
+ input: z.object({}),
12
+ output: availableGenreSeedsResponseSchema,
13
+ run: async (_input, credentials) => {
14
+ return createSpotifyClient(credentials).discovery.getAvailableGenreSeeds();
15
+ }
16
+ });
17
+
18
+ //#endregion
19
+ export { getAvailableGenreSeeds };
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,41 @@
1
+ import * as _keystrokehq_integration_authoring_official0 from "@keystrokehq/integration-authoring/official";
2
+ import { z } from "zod";
3
+ import * as _keystrokehq_core0 from "@keystrokehq/core";
4
+ import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
5
+ import { InferCredentialSetAuth } from "@keystrokehq/core/credential-set";
6
+
7
+ //#region src/integration.d.ts
8
+ declare const spotifyOfficialIntegration: {
9
+ id: "spotify";
10
+ name: string;
11
+ description: string;
12
+ proxy: {
13
+ hosts: string[];
14
+ };
15
+ auth: z.ZodObject<{
16
+ SPOTIFY_ACCESS_TOKEN: z.ZodString;
17
+ }, z.core.$strip>;
18
+ connections: {
19
+ id: string;
20
+ kind: "oauth";
21
+ tokenType: "refreshable";
22
+ authUrl: string;
23
+ tokenUrl: string;
24
+ revokeUrl: null;
25
+ scopes: ("user-read-private" | "user-read-email" | "user-read-recently-played" | "user-top-read" | "user-library-read" | "user-library-modify" | "playlist-read-private" | "playlist-read-collaborative" | "playlist-modify-private" | "playlist-modify-public" | "user-read-currently-playing" | "user-modify-playback-state" | "user-read-playback-state" | "user-follow-read" | "user-follow-modify" | "user-read-playback-position" | "ugc-image-upload")[];
26
+ vault: {
27
+ accessToken: "SPOTIFY_ACCESS_TOKEN";
28
+ };
29
+ }[];
30
+ };
31
+ declare const spotifyBundle: _keystrokehq_integration_authoring_official0.OfficialIntegrationBundle<"spotify", z.ZodObject<{
32
+ SPOTIFY_ACCESS_TOKEN: z.ZodString;
33
+ }, z.core.$strip>>;
34
+ declare const spotify: _keystrokehq_core0.CredentialSet<"spotify", z.ZodObject<{
35
+ SPOTIFY_ACCESS_TOKEN: z.ZodString;
36
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
37
+ SPOTIFY_ACCESS_TOKEN: z.ZodString;
38
+ }, z.core.$strip>>[] | undefined>;
39
+ type SpotifyCredentials = InferCredentialSetAuth<typeof spotify>;
40
+ //#endregion
41
+ export { spotifyOfficialIntegration as i, spotify as n, spotifyBundle as r, SpotifyCredentials as t };
@@ -0,0 +1,78 @@
1
+ import { defineOfficialIntegration } from "@keystrokehq/integration-authoring/official";
2
+ import { z } from "zod";
3
+ import { CredentialSet } from "@keystrokehq/core";
4
+
5
+ //#region src/_official/provider-app.ts
6
+ const spotifyAppCredentialSet = new CredentialSet({
7
+ id: "spotify-app",
8
+ exposure: "platform-only",
9
+ name: "Spotify App",
10
+ auth: z.object({
11
+ clientId: z.string().min(1),
12
+ clientSecret: z.string().min(1)
13
+ })
14
+ });
15
+ const spotifyPlatformProviderSeed = {
16
+ provider: "spotify",
17
+ appRef: "spotify-platform",
18
+ displayName: "Spotify Platform",
19
+ credentialSetName: "Keystroke Spotify Platform App",
20
+ envShape: {
21
+ KEYSTROKE_PLATFORM_SPOTIFY_CLIENT_ID: z.string().optional(),
22
+ KEYSTROKE_PLATFORM_SPOTIFY_CLIENT_SECRET: z.string().optional()
23
+ },
24
+ requiredEnvKeys: ["KEYSTROKE_PLATFORM_SPOTIFY_CLIENT_ID", "KEYSTROKE_PLATFORM_SPOTIFY_CLIENT_SECRET"],
25
+ externalAppIdEnvKey: "KEYSTROKE_PLATFORM_SPOTIFY_CLIENT_ID",
26
+ buildCredentials: (env) => ({
27
+ clientId: env.KEYSTROKE_PLATFORM_SPOTIFY_CLIENT_ID,
28
+ clientSecret: env.KEYSTROKE_PLATFORM_SPOTIFY_CLIENT_SECRET
29
+ })
30
+ };
31
+
32
+ //#endregion
33
+ //#region src/integration.ts
34
+ const spotifyAuthSchema = z.object({ SPOTIFY_ACCESS_TOKEN: z.string().min(1) });
35
+ const spotifyScopes = [
36
+ "user-read-private",
37
+ "user-read-email",
38
+ "user-read-recently-played",
39
+ "user-top-read",
40
+ "user-library-read",
41
+ "user-library-modify",
42
+ "playlist-read-private",
43
+ "playlist-read-collaborative",
44
+ "playlist-modify-private",
45
+ "playlist-modify-public",
46
+ "user-read-currently-playing",
47
+ "user-modify-playback-state",
48
+ "user-read-playback-state",
49
+ "user-follow-read",
50
+ "user-follow-modify",
51
+ "user-read-playback-position",
52
+ "ugc-image-upload"
53
+ ];
54
+ const spotifyOfficialIntegration = {
55
+ id: "spotify",
56
+ name: "Spotify",
57
+ description: "Spotify playback, catalog, playlists, library, and polling triggers for Keystroke workflows",
58
+ proxy: { hosts: ["api.spotify.com", "accounts.spotify.com"] },
59
+ auth: spotifyAuthSchema,
60
+ connections: [{
61
+ id: "oauth",
62
+ kind: "oauth",
63
+ tokenType: "refreshable",
64
+ authUrl: "https://accounts.spotify.com/authorize",
65
+ tokenUrl: "https://accounts.spotify.com/api/token",
66
+ revokeUrl: null,
67
+ scopes: [...spotifyScopes],
68
+ vault: { accessToken: "SPOTIFY_ACCESS_TOKEN" }
69
+ }]
70
+ };
71
+ const spotifyBundle = defineOfficialIntegration({
72
+ ...spotifyOfficialIntegration,
73
+ internal: { providerApp: spotifyAppCredentialSet }
74
+ });
75
+ const spotify = spotifyBundle.credentialSet;
76
+
77
+ //#endregion
78
+ export { spotifyPlatformProviderSeed as a, spotifyAppCredentialSet as i, spotifyBundle as n, spotifyOfficialIntegration as r, spotify as t };