@keystrokehq/spotify 0.0.15 → 0.0.16-integration-id-canonicalization.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 (81) hide show
  1. package/README.md +22 -53
  2. package/dist/{schemas.mjs → browse-BaBol4IR.mjs} +87 -72
  3. package/dist/credential-sets/index.d.mts +2 -0
  4. package/dist/credential-sets/index.mjs +4 -0
  5. package/dist/index.d.mts +4 -1
  6. package/dist/index.mjs +6 -1
  7. package/dist/operations/index.d.mts +2 -0
  8. package/dist/operations/index.mjs +3 -0
  9. package/dist/{schemas.d.mts → schemas/index.d.mts} +408 -398
  10. package/dist/schemas/index.mjs +3 -0
  11. package/dist/spotify-app.credential-set-DT2fivE7.d.mts +34 -0
  12. package/dist/spotify-app.credential-set-O5UKOpLR.mjs +16 -0
  13. package/dist/spotify.credential-set-CS3lCW-x.mjs +44 -0
  14. package/dist/upload-playlist-cover-image.operation-CnyIlv11.mjs +4247 -0
  15. package/dist/upload-playlist-cover-image.operation-Cqbmylzz.d.mts +5246 -0
  16. package/package.json +12 -128
  17. package/dist/_official/index.d.mts +0 -28
  18. package/dist/_official/index.mjs +0 -3
  19. package/dist/_runtime/index.d.mts +0 -1
  20. package/dist/_runtime/index.mjs +0 -1
  21. package/dist/albums.d.mts +0 -256
  22. package/dist/albums.mjs +0 -72
  23. package/dist/artists.d.mts +0 -226
  24. package/dist/artists.mjs +0 -84
  25. package/dist/audio-analysis.d.mts +0 -88
  26. package/dist/audio-analysis.mjs +0 -19
  27. package/dist/audio-features.d.mts +0 -56
  28. package/dist/audio-features.mjs +0 -31
  29. package/dist/audiobooks.d.mts +0 -169
  30. package/dist/audiobooks.mjs +0 -59
  31. package/dist/browse.d.mts +0 -71
  32. package/dist/browse.mjs +0 -31
  33. package/dist/categories.d.mts +0 -111
  34. package/dist/categories.mjs +0 -66
  35. package/dist/chapters.d.mts +0 -158
  36. package/dist/chapters.mjs +0 -39
  37. package/dist/client.d.mts +0 -3486
  38. package/dist/client.mjs +0 -758
  39. package/dist/connection.d.mts +0 -2
  40. package/dist/connection.mjs +0 -3
  41. package/dist/episodes.d.mts +0 -144
  42. package/dist/episodes.mjs +0 -39
  43. package/dist/errors.d.mts +0 -34
  44. package/dist/errors.mjs +0 -89
  45. package/dist/events.d.mts +0 -613
  46. package/dist/events.mjs +0 -55
  47. package/dist/factory-DMprpzS1.mjs +0 -8
  48. package/dist/follow.d.mts +0 -74
  49. package/dist/follow.mjs +0 -65
  50. package/dist/genres.d.mts +0 -11
  51. package/dist/genres.mjs +0 -19
  52. package/dist/integration-B5oEi2sg.d.mts +0 -27
  53. package/dist/integration-D9ABjTOP.mjs +0 -51
  54. package/dist/library.d.mts +0 -431
  55. package/dist/library.mjs +0 -225
  56. package/dist/markets.d.mts +0 -11
  57. package/dist/markets.mjs +0 -20
  58. package/dist/me.d.mts +0 -162
  59. package/dist/me.mjs +0 -58
  60. package/dist/messaging.d.mts +0 -1
  61. package/dist/messaging.mjs +0 -1
  62. package/dist/operations.d.mts +0 -6
  63. package/dist/operations.mjs +0 -237
  64. package/dist/player.d.mts +0 -846
  65. package/dist/player.mjs +0 -220
  66. package/dist/playlists.d.mts +0 -517
  67. package/dist/playlists.mjs +0 -243
  68. package/dist/recommendations.d.mts +0 -141
  69. package/dist/recommendations.mjs +0 -137
  70. package/dist/search.d.mts +0 -386
  71. package/dist/search.mjs +0 -42
  72. package/dist/shows.d.mts +0 -152
  73. package/dist/shows.mjs +0 -59
  74. package/dist/tracks.d.mts +0 -168
  75. package/dist/tracks.mjs +0 -37
  76. package/dist/triggers.d.mts +0 -45
  77. package/dist/triggers.mjs +0 -186
  78. package/dist/users.d.mts +0 -32
  79. package/dist/users.mjs +0 -20
  80. package/dist/verification.d.mts +0 -1
  81. package/dist/verification.mjs +0 -1
package/dist/tracks.d.mts DELETED
@@ -1,168 +0,0 @@
1
- import { z } from "zod";
2
- import * as _keystrokehq_core0 from "@keystrokehq/core";
3
-
4
- //#region src/tracks.d.ts
5
- declare const getTrack: _keystrokehq_core0.Operation<z.ZodObject<{
6
- id: z.ZodString;
7
- market: z.ZodOptional<z.ZodString>;
8
- }, z.core.$strip>, z.ZodObject<{
9
- album: z.ZodOptional<z.ZodObject<{
10
- albumType: z.ZodOptional<z.ZodEnum<{
11
- album: "album";
12
- single: "single";
13
- compilation: "compilation";
14
- }>>;
15
- artists: z.ZodArray<z.ZodObject<{
16
- externalUrls: z.ZodOptional<z.ZodObject<{
17
- spotify: z.ZodOptional<z.ZodURL>;
18
- }, z.core.$strip>>;
19
- href: z.ZodOptional<z.ZodURL>;
20
- id: z.ZodString;
21
- name: z.ZodString;
22
- type: z.ZodLiteral<"artist">;
23
- uri: z.ZodOptional<z.ZodString>;
24
- }, z.core.$strip>>;
25
- availableMarkets: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
- externalUrls: z.ZodOptional<z.ZodObject<{
27
- spotify: z.ZodOptional<z.ZodURL>;
28
- }, z.core.$strip>>;
29
- href: z.ZodOptional<z.ZodURL>;
30
- id: z.ZodString;
31
- images: z.ZodArray<z.ZodObject<{
32
- url: z.ZodURL;
33
- height: z.ZodNullable<z.ZodNumber>;
34
- width: z.ZodNullable<z.ZodNumber>;
35
- }, z.core.$strip>>;
36
- name: z.ZodString;
37
- releaseDate: z.ZodOptional<z.ZodString>;
38
- releaseDatePrecision: z.ZodOptional<z.ZodEnum<{
39
- year: "year";
40
- month: "month";
41
- day: "day";
42
- }>>;
43
- totalTracks: z.ZodOptional<z.ZodNumber>;
44
- type: z.ZodLiteral<"album">;
45
- uri: z.ZodOptional<z.ZodString>;
46
- }, z.core.$strip>>;
47
- artists: z.ZodArray<z.ZodObject<{
48
- externalUrls: z.ZodOptional<z.ZodObject<{
49
- spotify: z.ZodOptional<z.ZodURL>;
50
- }, z.core.$strip>>;
51
- href: z.ZodOptional<z.ZodURL>;
52
- id: z.ZodString;
53
- name: z.ZodString;
54
- type: z.ZodLiteral<"artist">;
55
- uri: z.ZodOptional<z.ZodString>;
56
- }, z.core.$strip>>;
57
- availableMarkets: z.ZodOptional<z.ZodArray<z.ZodString>>;
58
- discNumber: z.ZodOptional<z.ZodNumber>;
59
- durationMs: z.ZodNumber;
60
- explicit: z.ZodBoolean;
61
- externalIds: z.ZodOptional<z.ZodObject<{
62
- isrc: z.ZodOptional<z.ZodString>;
63
- ean: z.ZodOptional<z.ZodString>;
64
- upc: z.ZodOptional<z.ZodString>;
65
- }, z.core.$strip>>;
66
- externalUrls: z.ZodOptional<z.ZodObject<{
67
- spotify: z.ZodOptional<z.ZodURL>;
68
- }, z.core.$strip>>;
69
- href: z.ZodOptional<z.ZodURL>;
70
- id: z.ZodString;
71
- isLocal: z.ZodOptional<z.ZodBoolean>;
72
- isPlayable: z.ZodOptional<z.ZodBoolean>;
73
- name: z.ZodString;
74
- popularity: z.ZodOptional<z.ZodNumber>;
75
- previewUrl: z.ZodOptional<z.ZodUnion<readonly [z.ZodURL, z.ZodNull]>>;
76
- restrictions: z.ZodOptional<z.ZodObject<{
77
- reason: z.ZodString;
78
- }, z.core.$strip>>;
79
- trackNumber: z.ZodOptional<z.ZodNumber>;
80
- type: z.ZodLiteral<"track">;
81
- uri: z.ZodOptional<z.ZodString>;
82
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:spotify", z.ZodObject<{
83
- SPOTIFY_ACCESS_TOKEN: z.ZodString;
84
- }, z.core.$strip>>], undefined>;
85
- declare const getSeveralTracks: _keystrokehq_core0.Operation<z.ZodObject<{
86
- ids: z.ZodArray<z.ZodString>;
87
- market: z.ZodOptional<z.ZodString>;
88
- }, z.core.$strip>, z.ZodObject<{
89
- tracks: z.ZodArray<z.ZodObject<{
90
- album: z.ZodOptional<z.ZodObject<{
91
- albumType: z.ZodOptional<z.ZodEnum<{
92
- album: "album";
93
- single: "single";
94
- compilation: "compilation";
95
- }>>;
96
- artists: z.ZodArray<z.ZodObject<{
97
- externalUrls: z.ZodOptional<z.ZodObject<{
98
- spotify: z.ZodOptional<z.ZodURL>;
99
- }, z.core.$strip>>;
100
- href: z.ZodOptional<z.ZodURL>;
101
- id: z.ZodString;
102
- name: z.ZodString;
103
- type: z.ZodLiteral<"artist">;
104
- uri: z.ZodOptional<z.ZodString>;
105
- }, z.core.$strip>>;
106
- availableMarkets: z.ZodOptional<z.ZodArray<z.ZodString>>;
107
- externalUrls: z.ZodOptional<z.ZodObject<{
108
- spotify: z.ZodOptional<z.ZodURL>;
109
- }, z.core.$strip>>;
110
- href: z.ZodOptional<z.ZodURL>;
111
- id: z.ZodString;
112
- images: z.ZodArray<z.ZodObject<{
113
- url: z.ZodURL;
114
- height: z.ZodNullable<z.ZodNumber>;
115
- width: z.ZodNullable<z.ZodNumber>;
116
- }, z.core.$strip>>;
117
- name: z.ZodString;
118
- releaseDate: z.ZodOptional<z.ZodString>;
119
- releaseDatePrecision: z.ZodOptional<z.ZodEnum<{
120
- year: "year";
121
- month: "month";
122
- day: "day";
123
- }>>;
124
- totalTracks: z.ZodOptional<z.ZodNumber>;
125
- type: z.ZodLiteral<"album">;
126
- uri: z.ZodOptional<z.ZodString>;
127
- }, z.core.$strip>>;
128
- artists: z.ZodArray<z.ZodObject<{
129
- externalUrls: z.ZodOptional<z.ZodObject<{
130
- spotify: z.ZodOptional<z.ZodURL>;
131
- }, z.core.$strip>>;
132
- href: z.ZodOptional<z.ZodURL>;
133
- id: z.ZodString;
134
- name: z.ZodString;
135
- type: z.ZodLiteral<"artist">;
136
- uri: z.ZodOptional<z.ZodString>;
137
- }, z.core.$strip>>;
138
- availableMarkets: z.ZodOptional<z.ZodArray<z.ZodString>>;
139
- discNumber: z.ZodOptional<z.ZodNumber>;
140
- durationMs: z.ZodNumber;
141
- explicit: z.ZodBoolean;
142
- externalIds: z.ZodOptional<z.ZodObject<{
143
- isrc: z.ZodOptional<z.ZodString>;
144
- ean: z.ZodOptional<z.ZodString>;
145
- upc: z.ZodOptional<z.ZodString>;
146
- }, z.core.$strip>>;
147
- externalUrls: z.ZodOptional<z.ZodObject<{
148
- spotify: z.ZodOptional<z.ZodURL>;
149
- }, z.core.$strip>>;
150
- href: z.ZodOptional<z.ZodURL>;
151
- id: z.ZodString;
152
- isLocal: z.ZodOptional<z.ZodBoolean>;
153
- isPlayable: z.ZodOptional<z.ZodBoolean>;
154
- name: z.ZodString;
155
- popularity: z.ZodOptional<z.ZodNumber>;
156
- previewUrl: z.ZodOptional<z.ZodUnion<readonly [z.ZodURL, z.ZodNull]>>;
157
- restrictions: z.ZodOptional<z.ZodObject<{
158
- reason: z.ZodString;
159
- }, z.core.$strip>>;
160
- trackNumber: z.ZodOptional<z.ZodNumber>;
161
- type: z.ZodLiteral<"track">;
162
- uri: z.ZodOptional<z.ZodString>;
163
- }, z.core.$strip>>;
164
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:spotify", z.ZodObject<{
165
- SPOTIFY_ACCESS_TOKEN: z.ZodString;
166
- }, z.core.$strip>>], undefined>;
167
- //#endregion
168
- export { getSeveralTracks, getTrack };
package/dist/tracks.mjs DELETED
@@ -1,37 +0,0 @@
1
- import { spotifyIdSchema, spotifyMarketSchema, spotifyTrackSchema } from "./schemas.mjs";
2
- import { createSpotifyClient } from "./client.mjs";
3
- import { t as spotifyOperation } from "./factory-DMprpzS1.mjs";
4
- import { z } from "zod";
5
-
6
- //#region src/tracks.ts
7
- const trackIdListSchema = z.array(spotifyIdSchema).min(1).max(50);
8
- const severalTracksResponseSchema = z.object({ tracks: z.array(spotifyTrackSchema) });
9
- const getTrack = spotifyOperation({
10
- id: "spotify.get-spotify-track",
11
- name: "Get Spotify Track",
12
- description: "Fetch a Spotify track by its ID.",
13
- input: z.object({
14
- id: spotifyIdSchema,
15
- market: spotifyMarketSchema.optional()
16
- }),
17
- output: spotifyTrackSchema,
18
- run: async (input, credentials) => {
19
- return createSpotifyClient(credentials).tracks.getTrack(input.id, input.market);
20
- }
21
- });
22
- const getSeveralTracks = spotifyOperation({
23
- id: "spotify.get-spotify-several-tracks",
24
- name: "Get Several Spotify Tracks",
25
- description: "Fetch multiple Spotify tracks in one request.",
26
- input: z.object({
27
- ids: trackIdListSchema,
28
- market: spotifyMarketSchema.optional()
29
- }),
30
- output: severalTracksResponseSchema,
31
- run: async (input, credentials) => {
32
- return createSpotifyClient(credentials).tracks.getSeveralTracks(input.ids, input.market);
33
- }
34
- });
35
-
36
- //#endregion
37
- export { getSeveralTracks, getTrack };
@@ -1,45 +0,0 @@
1
- import { n as spotify } from "./integration-B5oEi2sg.mjs";
2
- import { spotifyNewDeviceAddedEventSchema, spotifyPlaylistItemsChangedEventSchema, spotifyRecentlyPlayedTrackAddedEventSchema, spotifySavedItemAddedEventSchema, spotifyUserPlaylistsChangedEventSchema } from "./events.mjs";
3
- import { z } from "zod";
4
- import { BoundTrigger } from "@keystrokehq/core";
5
- import { IntegrationTriggerBindingOptions } from "@keystrokehq/integration-authoring";
6
- import { PollingTriggerManifest } from "@keystrokehq/core/trigger";
7
-
8
- //#region src/triggers.d.ts
9
- type SpotifyCredentialSets = readonly [typeof spotify];
10
- type SpotifyPollingSchedule = number | `${number}s` | `${number}m` | `${number}h` | `${number}d` | `${number}w` | `${number}y`;
11
- type SpotifyPollingBoundTrigger<TEvent> = BoundTrigger<TEvent | null, SpotifyCredentialSets, PollingTriggerManifest, TEvent | null>;
12
- interface SpotifyPollingBindingOptions<TEvent> extends IntegrationTriggerBindingOptions<TEvent | null, TEvent | null> {
13
- readonly schedule?: SpotifyPollingSchedule;
14
- }
15
- interface PlaylistItemsChangedOptions extends SpotifyPollingBindingOptions<z.infer<typeof spotifyPlaylistItemsChangedEventSchema>> {
16
- readonly playlistId: string;
17
- readonly market?: string;
18
- readonly limit?: number;
19
- }
20
- interface UserPlaylistsChangedOptions extends SpotifyPollingBindingOptions<z.infer<typeof spotifyUserPlaylistsChangedEventSchema>> {
21
- readonly limit?: number;
22
- readonly offset?: number;
23
- }
24
- interface RecentlyPlayedTrackAddedOptions extends SpotifyPollingBindingOptions<z.infer<typeof spotifyRecentlyPlayedTrackAddedEventSchema>> {
25
- readonly limit?: number;
26
- }
27
- interface SavedItemAddedOptions extends SpotifyPollingBindingOptions<z.infer<typeof spotifySavedItemAddedEventSchema>> {
28
- readonly itemType: 'album' | 'track' | 'show' | 'episode' | 'audiobook';
29
- readonly limit?: number;
30
- readonly market?: string;
31
- }
32
- declare function newDeviceAdded(options?: SpotifyPollingBindingOptions<z.infer<typeof spotifyNewDeviceAddedEventSchema>>): SpotifyPollingBoundTrigger<z.infer<typeof spotifyNewDeviceAddedEventSchema>>;
33
- declare function playlistItemsChanged(options: PlaylistItemsChangedOptions): SpotifyPollingBoundTrigger<z.infer<typeof spotifyPlaylistItemsChangedEventSchema>>;
34
- declare function userPlaylistsChanged(options?: UserPlaylistsChangedOptions): SpotifyPollingBoundTrigger<z.infer<typeof spotifyUserPlaylistsChangedEventSchema>>;
35
- declare function recentlyPlayedTrackAdded(options?: RecentlyPlayedTrackAddedOptions): SpotifyPollingBoundTrigger<z.infer<typeof spotifyRecentlyPlayedTrackAddedEventSchema>>;
36
- declare function savedItemAdded(options: SavedItemAddedOptions): SpotifyPollingBoundTrigger<z.infer<typeof spotifySavedItemAddedEventSchema>>;
37
- declare const polling: Readonly<{
38
- newDeviceAdded: typeof newDeviceAdded;
39
- playlistItemsChanged: typeof playlistItemsChanged;
40
- userPlaylistsChanged: typeof userPlaylistsChanged;
41
- recentlyPlayedTrackAdded: typeof recentlyPlayedTrackAdded;
42
- savedItemAdded: typeof savedItemAdded;
43
- }>;
44
- //#endregion
45
- export { newDeviceAdded, playlistItemsChanged, polling, recentlyPlayedTrackAdded, savedItemAdded, userPlaylistsChanged };
package/dist/triggers.mjs DELETED
@@ -1,186 +0,0 @@
1
- import { t as spotify } from "./integration-D9ABjTOP.mjs";
2
- import { createSpotifyClient } from "./client.mjs";
3
- import { spotifyNewDeviceAddedEventSchema, spotifyPlaylistItemsChangedEventSchema, spotifyRecentlyPlayedTrackAddedEventSchema, spotifySavedItemAddedEventSchema, spotifyUserPlaylistsChangedEventSchema } from "./events.mjs";
4
- import { z } from "zod";
5
- import { createPollingTriggerBindingFactory } from "@keystrokehq/integration-authoring";
6
-
7
- //#region src/triggers.ts
8
- const nullableNewDeviceEventSchema = z.union([spotifyNewDeviceAddedEventSchema, z.null()]);
9
- const nullablePlaylistItemsChangedEventSchema = z.union([spotifyPlaylistItemsChangedEventSchema, z.null()]);
10
- const nullableUserPlaylistsChangedEventSchema = z.union([spotifyUserPlaylistsChangedEventSchema, z.null()]);
11
- const nullableRecentlyPlayedTrackAddedEventSchema = z.union([spotifyRecentlyPlayedTrackAddedEventSchema, z.null()]);
12
- const nullableSavedItemAddedEventSchema = z.union([spotifySavedItemAddedEventSchema, z.null()]);
13
- function newDeviceAdded(options) {
14
- return createPollingTriggerBindingFactory({
15
- defaultId: "spotify.new_device_added",
16
- defaultDescription: "Poll available Spotify devices and emit the most recent device snapshot.",
17
- schedule: options?.schedule ?? "5m",
18
- credentialSets: [spotify],
19
- response: nullableNewDeviceEventSchema,
20
- poll: async (ctx) => {
21
- const device = (await createSpotifyClient(ctx.credentials["keystroke:spotify"]).player.getAvailableDevices()).devices[0];
22
- return device ? {
23
- eventId: `device:${device.id ?? device.name}`,
24
- type: "device.added",
25
- device
26
- } : null;
27
- }
28
- })({
29
- ...options?.id ? { id: options.id } : {},
30
- ...options?.description ? { description: options.description } : {},
31
- ...options?.transform ? { transform: options.transform } : {}
32
- });
33
- }
34
- function playlistItemsChanged(options) {
35
- return createPollingTriggerBindingFactory({
36
- defaultId: "spotify.playlist_items_changed",
37
- defaultDescription: "Poll playlist items and emit the most recent playlist entry.",
38
- schedule: options.schedule ?? "5m",
39
- credentialSets: [spotify],
40
- response: nullablePlaylistItemsChangedEventSchema,
41
- poll: async (ctx) => {
42
- const item = (await createSpotifyClient(ctx.credentials["keystroke:spotify"]).playlists.getPlaylistItems(options.playlistId, {
43
- market: options.market,
44
- limit: options.limit ?? 20
45
- })).items[0];
46
- const itemUri = item?.track?.uri ?? item?.track?.id;
47
- return item && itemUri ? {
48
- eventId: `${options.playlistId}:${item.addedAt ?? "unknown"}:${itemUri}:0`,
49
- type: "playlist.item_added",
50
- playlistId: options.playlistId,
51
- snapshotId: item.addedAt ?? "unknown",
52
- item
53
- } : null;
54
- }
55
- })({
56
- ...options.id ? { id: options.id } : {},
57
- ...options.description ? { description: options.description } : {},
58
- ...options.transform ? { transform: options.transform } : {}
59
- });
60
- }
61
- function userPlaylistsChanged(options) {
62
- return createPollingTriggerBindingFactory({
63
- defaultId: "spotify.user_playlists_changed",
64
- defaultDescription: "Poll the current user playlists and emit the most recent playlist snapshot.",
65
- schedule: options?.schedule ?? "5m",
66
- credentialSets: [spotify],
67
- response: nullableUserPlaylistsChangedEventSchema,
68
- poll: async (ctx) => {
69
- const playlist = (await createSpotifyClient(ctx.credentials["keystroke:spotify"]).playlists.listMyPlaylists({
70
- limit: options?.limit ?? 20,
71
- offset: options?.offset
72
- })).items[0];
73
- return playlist ? {
74
- eventId: `${playlist.id}:${playlist.tracks?.total ?? 0}:details_changed`,
75
- type: "playlist.details_changed",
76
- playlist
77
- } : null;
78
- }
79
- })({
80
- ...options?.id ? { id: options.id } : {},
81
- ...options?.description ? { description: options.description } : {},
82
- ...options?.transform ? { transform: options.transform } : {}
83
- });
84
- }
85
- function recentlyPlayedTrackAdded(options) {
86
- return createPollingTriggerBindingFactory({
87
- defaultId: "spotify.recently_played_track_added",
88
- defaultDescription: "Poll recently played tracks and emit the most recent playback event.",
89
- schedule: options?.schedule ?? "5m",
90
- credentialSets: [spotify],
91
- response: nullableRecentlyPlayedTrackAddedEventSchema,
92
- poll: async (ctx) => {
93
- const play = (await createSpotifyClient(ctx.credentials["keystroke:spotify"]).player.getRecentlyPlayed({
94
- limit: options?.limit ?? 1,
95
- after: ctx.lastPolledAt ? Date.parse(ctx.lastPolledAt) : void 0
96
- })).items[0];
97
- return play ? {
98
- eventId: `${play.playedAt}:${play.track.id}`,
99
- type: "recently_played.track_added",
100
- play
101
- } : null;
102
- }
103
- })({
104
- ...options?.id ? { id: options.id } : {},
105
- ...options?.description ? { description: options.description } : {},
106
- ...options?.transform ? { transform: options.transform } : {}
107
- });
108
- }
109
- function savedItemAdded(options) {
110
- return createPollingTriggerBindingFactory({
111
- defaultId: "spotify.saved_item_added",
112
- defaultDescription: "Poll the Spotify library and emit the most recent saved item for a resource type.",
113
- schedule: options.schedule ?? "5m",
114
- credentialSets: [spotify],
115
- response: nullableSavedItemAddedEventSchema,
116
- poll: async (ctx) => {
117
- const client = createSpotifyClient(ctx.credentials["keystroke:spotify"]);
118
- if (options.itemType === "album") {
119
- const item = (await client.library.listSavedAlbums({
120
- limit: options.limit ?? 1,
121
- market: options.market
122
- })).items[0];
123
- return item ? {
124
- eventId: `album:${item.album.id}:${item.addedAt}`,
125
- type: "library.saved_item_added",
126
- itemType: "album",
127
- item
128
- } : null;
129
- }
130
- if (options.itemType === "track") {
131
- const item = (await client.library.listSavedTracks({
132
- limit: options.limit ?? 1,
133
- market: options.market
134
- })).items[0];
135
- return item ? {
136
- eventId: `track:${item.track.id}:${item.addedAt}`,
137
- type: "library.saved_item_added",
138
- itemType: "track",
139
- item
140
- } : null;
141
- }
142
- if (options.itemType === "show") {
143
- const item = (await client.library.listSavedShows({ limit: options.limit ?? 1 })).items[0];
144
- return item ? {
145
- eventId: `show:${item.show.id}:${item.addedAt}`,
146
- type: "library.saved_item_added",
147
- itemType: "show",
148
- item
149
- } : null;
150
- }
151
- if (options.itemType === "episode") {
152
- const item = (await client.library.listSavedEpisodes({
153
- limit: options.limit ?? 1,
154
- market: options.market
155
- })).items[0];
156
- return item ? {
157
- eventId: `episode:${item.episode.id}:${item.addedAt}`,
158
- type: "library.saved_item_added",
159
- itemType: "episode",
160
- item
161
- } : null;
162
- }
163
- const item = (await client.library.listSavedAudiobooks({ limit: options.limit ?? 1 })).items[0];
164
- return item ? {
165
- eventId: `audiobook:${item.audiobook.id}:${item.addedAt}`,
166
- type: "library.saved_item_added",
167
- itemType: "audiobook",
168
- item
169
- } : null;
170
- }
171
- })({
172
- ...options.id ? { id: options.id } : {},
173
- ...options.description ? { description: options.description } : {},
174
- ...options.transform ? { transform: options.transform } : {}
175
- });
176
- }
177
- const polling = Object.freeze({
178
- newDeviceAdded,
179
- playlistItemsChanged,
180
- userPlaylistsChanged,
181
- recentlyPlayedTrackAdded,
182
- savedItemAdded
183
- });
184
-
185
- //#endregion
186
- export { newDeviceAdded, playlistItemsChanged, polling, recentlyPlayedTrackAdded, savedItemAdded, userPlaylistsChanged };
package/dist/users.d.mts DELETED
@@ -1,32 +0,0 @@
1
- import { z } from "zod";
2
- import * as _keystrokehq_core0 from "@keystrokehq/core";
3
-
4
- //#region src/users.d.ts
5
- declare const getUser: _keystrokehq_core0.Operation<z.ZodObject<{
6
- id: z.ZodString;
7
- }, z.core.$strip>, z.ZodObject<{
8
- displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
9
- externalUrls: z.ZodOptional<z.ZodObject<{
10
- spotify: z.ZodOptional<z.ZodURL>;
11
- }, z.core.$strip>>;
12
- followers: z.ZodOptional<z.ZodObject<{
13
- href: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
14
- total: z.ZodNumber;
15
- }, z.core.$strip>>;
16
- href: z.ZodOptional<z.ZodURL>;
17
- id: z.ZodString;
18
- type: z.ZodLiteral<"user">;
19
- uri: z.ZodOptional<z.ZodString>;
20
- email: z.ZodOptional<z.ZodEmail>;
21
- country: z.ZodOptional<z.ZodString>;
22
- product: z.ZodOptional<z.ZodString>;
23
- images: z.ZodOptional<z.ZodArray<z.ZodObject<{
24
- url: z.ZodURL;
25
- height: z.ZodNullable<z.ZodNumber>;
26
- width: z.ZodNullable<z.ZodNumber>;
27
- }, z.core.$strip>>>;
28
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:spotify", z.ZodObject<{
29
- SPOTIFY_ACCESS_TOKEN: z.ZodString;
30
- }, z.core.$strip>>], undefined>;
31
- //#endregion
32
- export { getUser };
package/dist/users.mjs DELETED
@@ -1,20 +0,0 @@
1
- import { spotifyIdSchema, spotifyUserSchema } from "./schemas.mjs";
2
- import { createSpotifyClient } from "./client.mjs";
3
- import { t as spotifyOperation } from "./factory-DMprpzS1.mjs";
4
- import { z } from "zod";
5
-
6
- //#region src/users.ts
7
- const userLookupInputSchema = z.object({ id: spotifyIdSchema });
8
- const getUser = spotifyOperation({
9
- id: "spotify.get-spotify-user",
10
- name: "Get Spotify User",
11
- description: "Fetch a Spotify user profile by user ID.",
12
- input: userLookupInputSchema,
13
- output: spotifyUserSchema,
14
- run: async (input, credentials) => {
15
- return createSpotifyClient(credentials).users.getUser(input.id);
16
- }
17
- });
18
-
19
- //#endregion
20
- export { getUser };
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };