@keystrokehq/spotify 0.0.9 → 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.
- package/README.md +22 -53
- package/dist/{schemas.mjs → browse-BaBol4IR.mjs} +87 -72
- package/dist/credential-sets/index.d.mts +2 -0
- package/dist/credential-sets/index.mjs +4 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +6 -1
- package/dist/operations/index.d.mts +2 -0
- package/dist/operations/index.mjs +3 -0
- package/dist/{schemas.d.mts → schemas/index.d.mts} +407 -397
- package/dist/schemas/index.mjs +3 -0
- package/dist/spotify-app.credential-set-DT2fivE7.d.mts +34 -0
- package/dist/spotify-app.credential-set-O5UKOpLR.mjs +16 -0
- package/dist/spotify.credential-set-CS3lCW-x.mjs +44 -0
- package/dist/upload-playlist-cover-image.operation-CnyIlv11.mjs +4247 -0
- package/dist/upload-playlist-cover-image.operation-Cqbmylzz.d.mts +5246 -0
- package/package.json +11 -127
- package/dist/_official/index.d.mts +0 -32
- package/dist/_official/index.mjs +0 -3
- package/dist/_runtime/index.d.mts +0 -1
- package/dist/_runtime/index.mjs +0 -1
- package/dist/albums.d.mts +0 -265
- package/dist/albums.mjs +0 -72
- package/dist/artists.d.mts +0 -237
- package/dist/artists.mjs +0 -84
- package/dist/audio-analysis.d.mts +0 -91
- package/dist/audio-analysis.mjs +0 -19
- package/dist/audio-features.d.mts +0 -61
- package/dist/audio-features.mjs +0 -31
- package/dist/audiobooks.d.mts +0 -176
- package/dist/audiobooks.mjs +0 -59
- package/dist/browse.d.mts +0 -74
- package/dist/browse.mjs +0 -31
- package/dist/categories.d.mts +0 -118
- package/dist/categories.mjs +0 -66
- package/dist/chapters.d.mts +0 -163
- package/dist/chapters.mjs +0 -39
- package/dist/client.d.mts +0 -3486
- package/dist/client.mjs +0 -758
- package/dist/connection.d.mts +0 -2
- package/dist/connection.mjs +0 -3
- package/dist/episodes.d.mts +0 -149
- package/dist/episodes.mjs +0 -39
- package/dist/errors.d.mts +0 -34
- package/dist/errors.mjs +0 -89
- package/dist/events.d.mts +0 -613
- package/dist/events.mjs +0 -55
- package/dist/factory-C9W7aXmR.mjs +0 -7
- package/dist/follow.d.mts +0 -83
- package/dist/follow.mjs +0 -65
- package/dist/genres.d.mts +0 -14
- package/dist/genres.mjs +0 -19
- package/dist/integration-CrkQTg9q.mjs +0 -170
- package/dist/integration-DXXNe4_j.d.mts +0 -40
- package/dist/library.d.mts +0 -472
- package/dist/library.mjs +0 -225
- package/dist/markets.d.mts +0 -14
- package/dist/markets.mjs +0 -20
- package/dist/me.d.mts +0 -169
- package/dist/me.mjs +0 -58
- package/dist/messaging.d.mts +0 -1
- package/dist/messaging.mjs +0 -1
- package/dist/operations.d.mts +0 -6
- package/dist/operations.mjs +0 -237
- package/dist/player.d.mts +0 -877
- package/dist/player.mjs +0 -220
- package/dist/playlists.d.mts +0 -546
- package/dist/playlists.mjs +0 -243
- package/dist/recommendations.d.mts +0 -144
- package/dist/recommendations.mjs +0 -137
- package/dist/search.d.mts +0 -389
- package/dist/search.mjs +0 -42
- package/dist/shows.d.mts +0 -159
- package/dist/shows.mjs +0 -59
- package/dist/tracks.d.mts +0 -173
- package/dist/tracks.mjs +0 -37
- package/dist/triggers.d.mts +0 -44
- package/dist/triggers.mjs +0 -235
- package/dist/users.d.mts +0 -35
- package/dist/users.mjs +0 -20
- package/dist/verification.d.mts +0 -1
- package/dist/verification.mjs +0 -1
package/dist/tracks.d.mts
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import * as _keystrokehq_core0 from "@keystrokehq/core";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
|
|
4
|
-
|
|
5
|
-
//#region src/tracks.d.ts
|
|
6
|
-
declare const getTrack: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
7
|
-
id: z.ZodString;
|
|
8
|
-
market: z.ZodOptional<z.ZodString>;
|
|
9
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
10
|
-
album: z.ZodOptional<z.ZodObject<{
|
|
11
|
-
albumType: z.ZodOptional<z.ZodEnum<{
|
|
12
|
-
album: "album";
|
|
13
|
-
single: "single";
|
|
14
|
-
compilation: "compilation";
|
|
15
|
-
}>>;
|
|
16
|
-
artists: z.ZodArray<z.ZodObject<{
|
|
17
|
-
externalUrls: z.ZodOptional<z.ZodObject<{
|
|
18
|
-
spotify: z.ZodOptional<z.ZodURL>;
|
|
19
|
-
}, z.core.$strip>>;
|
|
20
|
-
href: z.ZodOptional<z.ZodURL>;
|
|
21
|
-
id: z.ZodString;
|
|
22
|
-
name: z.ZodString;
|
|
23
|
-
type: z.ZodLiteral<"artist">;
|
|
24
|
-
uri: z.ZodOptional<z.ZodString>;
|
|
25
|
-
}, z.core.$strip>>;
|
|
26
|
-
availableMarkets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
-
externalUrls: z.ZodOptional<z.ZodObject<{
|
|
28
|
-
spotify: z.ZodOptional<z.ZodURL>;
|
|
29
|
-
}, z.core.$strip>>;
|
|
30
|
-
href: z.ZodOptional<z.ZodURL>;
|
|
31
|
-
id: z.ZodString;
|
|
32
|
-
images: z.ZodArray<z.ZodObject<{
|
|
33
|
-
url: z.ZodURL;
|
|
34
|
-
height: z.ZodNullable<z.ZodNumber>;
|
|
35
|
-
width: z.ZodNullable<z.ZodNumber>;
|
|
36
|
-
}, z.core.$strip>>;
|
|
37
|
-
name: z.ZodString;
|
|
38
|
-
releaseDate: z.ZodOptional<z.ZodString>;
|
|
39
|
-
releaseDatePrecision: z.ZodOptional<z.ZodEnum<{
|
|
40
|
-
year: "year";
|
|
41
|
-
month: "month";
|
|
42
|
-
day: "day";
|
|
43
|
-
}>>;
|
|
44
|
-
totalTracks: z.ZodOptional<z.ZodNumber>;
|
|
45
|
-
type: z.ZodLiteral<"album">;
|
|
46
|
-
uri: z.ZodOptional<z.ZodString>;
|
|
47
|
-
}, z.core.$strip>>;
|
|
48
|
-
artists: z.ZodArray<z.ZodObject<{
|
|
49
|
-
externalUrls: z.ZodOptional<z.ZodObject<{
|
|
50
|
-
spotify: z.ZodOptional<z.ZodURL>;
|
|
51
|
-
}, z.core.$strip>>;
|
|
52
|
-
href: z.ZodOptional<z.ZodURL>;
|
|
53
|
-
id: z.ZodString;
|
|
54
|
-
name: z.ZodString;
|
|
55
|
-
type: z.ZodLiteral<"artist">;
|
|
56
|
-
uri: z.ZodOptional<z.ZodString>;
|
|
57
|
-
}, z.core.$strip>>;
|
|
58
|
-
availableMarkets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
59
|
-
discNumber: z.ZodOptional<z.ZodNumber>;
|
|
60
|
-
durationMs: z.ZodNumber;
|
|
61
|
-
explicit: z.ZodBoolean;
|
|
62
|
-
externalIds: z.ZodOptional<z.ZodObject<{
|
|
63
|
-
isrc: z.ZodOptional<z.ZodString>;
|
|
64
|
-
ean: z.ZodOptional<z.ZodString>;
|
|
65
|
-
upc: z.ZodOptional<z.ZodString>;
|
|
66
|
-
}, z.core.$strip>>;
|
|
67
|
-
externalUrls: z.ZodOptional<z.ZodObject<{
|
|
68
|
-
spotify: z.ZodOptional<z.ZodURL>;
|
|
69
|
-
}, z.core.$strip>>;
|
|
70
|
-
href: z.ZodOptional<z.ZodURL>;
|
|
71
|
-
id: z.ZodString;
|
|
72
|
-
isLocal: z.ZodOptional<z.ZodBoolean>;
|
|
73
|
-
isPlayable: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
-
name: z.ZodString;
|
|
75
|
-
popularity: z.ZodOptional<z.ZodNumber>;
|
|
76
|
-
previewUrl: z.ZodOptional<z.ZodUnion<readonly [z.ZodURL, z.ZodNull]>>;
|
|
77
|
-
restrictions: z.ZodOptional<z.ZodObject<{
|
|
78
|
-
reason: z.ZodString;
|
|
79
|
-
}, z.core.$strip>>;
|
|
80
|
-
trackNumber: z.ZodOptional<z.ZodNumber>;
|
|
81
|
-
type: z.ZodLiteral<"track">;
|
|
82
|
-
uri: z.ZodOptional<z.ZodString>;
|
|
83
|
-
}, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"spotify", z.ZodObject<{
|
|
84
|
-
SPOTIFY_ACCESS_TOKEN: z.ZodString;
|
|
85
|
-
}, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
|
|
86
|
-
SPOTIFY_ACCESS_TOKEN: z.ZodString;
|
|
87
|
-
}, z.core.$strip>>[] | undefined>], undefined>;
|
|
88
|
-
declare const getSeveralTracks: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
89
|
-
ids: z.ZodArray<z.ZodString>;
|
|
90
|
-
market: z.ZodOptional<z.ZodString>;
|
|
91
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
92
|
-
tracks: z.ZodArray<z.ZodObject<{
|
|
93
|
-
album: z.ZodOptional<z.ZodObject<{
|
|
94
|
-
albumType: z.ZodOptional<z.ZodEnum<{
|
|
95
|
-
album: "album";
|
|
96
|
-
single: "single";
|
|
97
|
-
compilation: "compilation";
|
|
98
|
-
}>>;
|
|
99
|
-
artists: z.ZodArray<z.ZodObject<{
|
|
100
|
-
externalUrls: z.ZodOptional<z.ZodObject<{
|
|
101
|
-
spotify: z.ZodOptional<z.ZodURL>;
|
|
102
|
-
}, z.core.$strip>>;
|
|
103
|
-
href: z.ZodOptional<z.ZodURL>;
|
|
104
|
-
id: z.ZodString;
|
|
105
|
-
name: z.ZodString;
|
|
106
|
-
type: z.ZodLiteral<"artist">;
|
|
107
|
-
uri: z.ZodOptional<z.ZodString>;
|
|
108
|
-
}, z.core.$strip>>;
|
|
109
|
-
availableMarkets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
110
|
-
externalUrls: z.ZodOptional<z.ZodObject<{
|
|
111
|
-
spotify: z.ZodOptional<z.ZodURL>;
|
|
112
|
-
}, z.core.$strip>>;
|
|
113
|
-
href: z.ZodOptional<z.ZodURL>;
|
|
114
|
-
id: z.ZodString;
|
|
115
|
-
images: z.ZodArray<z.ZodObject<{
|
|
116
|
-
url: z.ZodURL;
|
|
117
|
-
height: z.ZodNullable<z.ZodNumber>;
|
|
118
|
-
width: z.ZodNullable<z.ZodNumber>;
|
|
119
|
-
}, z.core.$strip>>;
|
|
120
|
-
name: z.ZodString;
|
|
121
|
-
releaseDate: z.ZodOptional<z.ZodString>;
|
|
122
|
-
releaseDatePrecision: z.ZodOptional<z.ZodEnum<{
|
|
123
|
-
year: "year";
|
|
124
|
-
month: "month";
|
|
125
|
-
day: "day";
|
|
126
|
-
}>>;
|
|
127
|
-
totalTracks: z.ZodOptional<z.ZodNumber>;
|
|
128
|
-
type: z.ZodLiteral<"album">;
|
|
129
|
-
uri: z.ZodOptional<z.ZodString>;
|
|
130
|
-
}, z.core.$strip>>;
|
|
131
|
-
artists: z.ZodArray<z.ZodObject<{
|
|
132
|
-
externalUrls: z.ZodOptional<z.ZodObject<{
|
|
133
|
-
spotify: z.ZodOptional<z.ZodURL>;
|
|
134
|
-
}, z.core.$strip>>;
|
|
135
|
-
href: z.ZodOptional<z.ZodURL>;
|
|
136
|
-
id: z.ZodString;
|
|
137
|
-
name: z.ZodString;
|
|
138
|
-
type: z.ZodLiteral<"artist">;
|
|
139
|
-
uri: z.ZodOptional<z.ZodString>;
|
|
140
|
-
}, z.core.$strip>>;
|
|
141
|
-
availableMarkets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
142
|
-
discNumber: z.ZodOptional<z.ZodNumber>;
|
|
143
|
-
durationMs: z.ZodNumber;
|
|
144
|
-
explicit: z.ZodBoolean;
|
|
145
|
-
externalIds: z.ZodOptional<z.ZodObject<{
|
|
146
|
-
isrc: z.ZodOptional<z.ZodString>;
|
|
147
|
-
ean: z.ZodOptional<z.ZodString>;
|
|
148
|
-
upc: z.ZodOptional<z.ZodString>;
|
|
149
|
-
}, z.core.$strip>>;
|
|
150
|
-
externalUrls: z.ZodOptional<z.ZodObject<{
|
|
151
|
-
spotify: z.ZodOptional<z.ZodURL>;
|
|
152
|
-
}, z.core.$strip>>;
|
|
153
|
-
href: z.ZodOptional<z.ZodURL>;
|
|
154
|
-
id: z.ZodString;
|
|
155
|
-
isLocal: z.ZodOptional<z.ZodBoolean>;
|
|
156
|
-
isPlayable: z.ZodOptional<z.ZodBoolean>;
|
|
157
|
-
name: z.ZodString;
|
|
158
|
-
popularity: z.ZodOptional<z.ZodNumber>;
|
|
159
|
-
previewUrl: z.ZodOptional<z.ZodUnion<readonly [z.ZodURL, z.ZodNull]>>;
|
|
160
|
-
restrictions: z.ZodOptional<z.ZodObject<{
|
|
161
|
-
reason: z.ZodString;
|
|
162
|
-
}, z.core.$strip>>;
|
|
163
|
-
trackNumber: z.ZodOptional<z.ZodNumber>;
|
|
164
|
-
type: z.ZodLiteral<"track">;
|
|
165
|
-
uri: z.ZodOptional<z.ZodString>;
|
|
166
|
-
}, z.core.$strip>>;
|
|
167
|
-
}, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"spotify", z.ZodObject<{
|
|
168
|
-
SPOTIFY_ACCESS_TOKEN: z.ZodString;
|
|
169
|
-
}, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
|
|
170
|
-
SPOTIFY_ACCESS_TOKEN: z.ZodString;
|
|
171
|
-
}, z.core.$strip>>[] | undefined>], undefined>;
|
|
172
|
-
//#endregion
|
|
173
|
-
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-C9W7aXmR.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 };
|
package/dist/triggers.d.mts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { n as spotify } from "./integration-DXXNe4_j.mjs";
|
|
2
|
-
import { spotifyNewDeviceAddedEventSchema, spotifyPlaylistItemsChangedEventSchema, spotifyRecentlyPlayedTrackAddedEventSchema, spotifySavedItemAddedEventSchema, spotifyUserPlaylistsChangedEventSchema } from "./events.mjs";
|
|
3
|
-
import { BoundTrigger, Operation } from "@keystrokehq/core";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { PollingTriggerManifest } from "@keystrokehq/core/trigger";
|
|
6
|
-
|
|
7
|
-
//#region src/triggers.d.ts
|
|
8
|
-
type SpotifyCredentialSets = readonly [typeof spotify];
|
|
9
|
-
type SpotifyPollingSchedule = number | `${number}s` | `${number}m` | `${number}h` | `${number}d` | `${number}w` | `${number}y`;
|
|
10
|
-
type SpotifyPollingBoundTrigger<TEvent> = BoundTrigger<TEvent | null, SpotifyCredentialSets, PollingTriggerManifest, TEvent | null>;
|
|
11
|
-
interface SpotifyPollingBindingOptions<TEvent> extends IntegrationTriggerBindingOptions<TEvent | null, TEvent | null> {
|
|
12
|
-
readonly schedule?: SpotifyPollingSchedule;
|
|
13
|
-
}
|
|
14
|
-
interface PlaylistItemsChangedOptions extends SpotifyPollingBindingOptions<z.infer<typeof spotifyPlaylistItemsChangedEventSchema>> {
|
|
15
|
-
readonly playlistId: string;
|
|
16
|
-
readonly market?: string;
|
|
17
|
-
readonly limit?: number;
|
|
18
|
-
}
|
|
19
|
-
interface UserPlaylistsChangedOptions extends SpotifyPollingBindingOptions<z.infer<typeof spotifyUserPlaylistsChangedEventSchema>> {
|
|
20
|
-
readonly limit?: number;
|
|
21
|
-
readonly offset?: number;
|
|
22
|
-
}
|
|
23
|
-
interface RecentlyPlayedTrackAddedOptions extends SpotifyPollingBindingOptions<z.infer<typeof spotifyRecentlyPlayedTrackAddedEventSchema>> {
|
|
24
|
-
readonly limit?: number;
|
|
25
|
-
}
|
|
26
|
-
interface SavedItemAddedOptions extends SpotifyPollingBindingOptions<z.infer<typeof spotifySavedItemAddedEventSchema>> {
|
|
27
|
-
readonly itemType: 'album' | 'track' | 'show' | 'episode' | 'audiobook';
|
|
28
|
-
readonly limit?: number;
|
|
29
|
-
readonly market?: string;
|
|
30
|
-
}
|
|
31
|
-
declare function newDeviceAdded(options?: SpotifyPollingBindingOptions<z.infer<typeof spotifyNewDeviceAddedEventSchema>>): SpotifyPollingBoundTrigger<z.infer<typeof spotifyNewDeviceAddedEventSchema>>;
|
|
32
|
-
declare function playlistItemsChanged(options: PlaylistItemsChangedOptions): SpotifyPollingBoundTrigger<z.infer<typeof spotifyPlaylistItemsChangedEventSchema>>;
|
|
33
|
-
declare function userPlaylistsChanged(options?: UserPlaylistsChangedOptions): SpotifyPollingBoundTrigger<z.infer<typeof spotifyUserPlaylistsChangedEventSchema>>;
|
|
34
|
-
declare function recentlyPlayedTrackAdded(options?: RecentlyPlayedTrackAddedOptions): SpotifyPollingBoundTrigger<z.infer<typeof spotifyRecentlyPlayedTrackAddedEventSchema>>;
|
|
35
|
-
declare function savedItemAdded(options: SavedItemAddedOptions): SpotifyPollingBoundTrigger<z.infer<typeof spotifySavedItemAddedEventSchema>>;
|
|
36
|
-
declare const polling: Readonly<{
|
|
37
|
-
newDeviceAdded: typeof newDeviceAdded;
|
|
38
|
-
playlistItemsChanged: typeof playlistItemsChanged;
|
|
39
|
-
userPlaylistsChanged: typeof userPlaylistsChanged;
|
|
40
|
-
recentlyPlayedTrackAdded: typeof recentlyPlayedTrackAdded;
|
|
41
|
-
savedItemAdded: typeof savedItemAdded;
|
|
42
|
-
}>;
|
|
43
|
-
//#endregion
|
|
44
|
-
export { newDeviceAdded, playlistItemsChanged, polling, recentlyPlayedTrackAdded, savedItemAdded, userPlaylistsChanged };
|
package/dist/triggers.mjs
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { t as spotify } from "./integration-CrkQTg9q.mjs";
|
|
2
|
-
import { createSpotifyClient } from "./client.mjs";
|
|
3
|
-
import { spotifyNewDeviceAddedEventSchema, spotifyPlaylistItemsChangedEventSchema, spotifyRecentlyPlayedTrackAddedEventSchema, spotifySavedItemAddedEventSchema, spotifyUserPlaylistsChangedEventSchema } from "./events.mjs";
|
|
4
|
-
import { Operation } from "@keystrokehq/core";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
import { pollingTrigger } from "@keystrokehq/core/trigger";
|
|
7
|
-
|
|
8
|
-
//#region ../../packages/integration-authoring/dist/index.mjs
|
|
9
|
-
const IntegrationConfigSchema = z.object({
|
|
10
|
-
id: z.string().min(1),
|
|
11
|
-
name: z.string().min(1),
|
|
12
|
-
description: z.string().optional()
|
|
13
|
-
});
|
|
14
|
-
function resolveMetadata(metadata, defaults) {
|
|
15
|
-
return {
|
|
16
|
-
id: metadata?.id ?? defaults.defaultId,
|
|
17
|
-
description: metadata?.description ?? defaults.defaultDescription
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function resolveAuthorPayload(payload, mapPayload) {
|
|
21
|
-
if (!mapPayload) return payload;
|
|
22
|
-
return mapPayload(payload);
|
|
23
|
-
}
|
|
24
|
-
function createIntegrationTriggerBindingFactory(config) {
|
|
25
|
-
const bind = (options) => {
|
|
26
|
-
const resolvedMetadata = resolveMetadata(options, config);
|
|
27
|
-
const baseTrigger = config.createBaseTrigger(resolvedMetadata);
|
|
28
|
-
const userTransform = options?.transform;
|
|
29
|
-
return baseTrigger({ transform: userTransform || config.mapPayload ? (runtimePayload, request) => {
|
|
30
|
-
const authorPayload = resolveAuthorPayload(runtimePayload, config.mapPayload);
|
|
31
|
-
if (authorPayload === null) throw new Error(`Trigger "${resolvedMetadata.id}" mapPayload returned null after the trigger filter passed; tighten the trigger filter schema.`);
|
|
32
|
-
if (!userTransform) return authorPayload;
|
|
33
|
-
return userTransform(authorPayload, request);
|
|
34
|
-
} : void 0 });
|
|
35
|
-
};
|
|
36
|
-
return Object.freeze(bind);
|
|
37
|
-
}
|
|
38
|
-
function createPollingTriggerBindingFactory(config) {
|
|
39
|
-
return createIntegrationTriggerBindingFactory({
|
|
40
|
-
defaultId: config.defaultId,
|
|
41
|
-
defaultDescription: config.defaultDescription,
|
|
42
|
-
mapPayload: config.mapPayload,
|
|
43
|
-
createBaseTrigger: (metadata) => pollingTrigger({
|
|
44
|
-
id: metadata.id,
|
|
45
|
-
description: metadata.description,
|
|
46
|
-
schedule: config.schedule,
|
|
47
|
-
response: config.response,
|
|
48
|
-
poll: config.poll,
|
|
49
|
-
...config.credentialSets ? { credentialSets: config.credentialSets } : {},
|
|
50
|
-
...config.filter ? { filter: config.filter } : {}
|
|
51
|
-
})
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
//#region src/triggers.ts
|
|
57
|
-
const nullableNewDeviceEventSchema = z.union([spotifyNewDeviceAddedEventSchema, z.null()]);
|
|
58
|
-
const nullablePlaylistItemsChangedEventSchema = z.union([spotifyPlaylistItemsChangedEventSchema, z.null()]);
|
|
59
|
-
const nullableUserPlaylistsChangedEventSchema = z.union([spotifyUserPlaylistsChangedEventSchema, z.null()]);
|
|
60
|
-
const nullableRecentlyPlayedTrackAddedEventSchema = z.union([spotifyRecentlyPlayedTrackAddedEventSchema, z.null()]);
|
|
61
|
-
const nullableSavedItemAddedEventSchema = z.union([spotifySavedItemAddedEventSchema, z.null()]);
|
|
62
|
-
function newDeviceAdded(options) {
|
|
63
|
-
return createPollingTriggerBindingFactory({
|
|
64
|
-
defaultId: "spotify.new_device_added",
|
|
65
|
-
defaultDescription: "Poll available Spotify devices and emit the most recent device snapshot.",
|
|
66
|
-
schedule: options?.schedule ?? "5m",
|
|
67
|
-
credentialSets: [spotify],
|
|
68
|
-
response: nullableNewDeviceEventSchema,
|
|
69
|
-
poll: async (ctx) => {
|
|
70
|
-
const device = (await createSpotifyClient(ctx.credentials["spotify"]).player.getAvailableDevices()).devices[0];
|
|
71
|
-
return device ? {
|
|
72
|
-
eventId: `device:${device.id ?? device.name}`,
|
|
73
|
-
type: "device.added",
|
|
74
|
-
device
|
|
75
|
-
} : null;
|
|
76
|
-
}
|
|
77
|
-
})({
|
|
78
|
-
...options?.id ? { id: options.id } : {},
|
|
79
|
-
...options?.description ? { description: options.description } : {},
|
|
80
|
-
...options?.transform ? { transform: options.transform } : {}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function playlistItemsChanged(options) {
|
|
84
|
-
return createPollingTriggerBindingFactory({
|
|
85
|
-
defaultId: "spotify.playlist_items_changed",
|
|
86
|
-
defaultDescription: "Poll playlist items and emit the most recent playlist entry.",
|
|
87
|
-
schedule: options.schedule ?? "5m",
|
|
88
|
-
credentialSets: [spotify],
|
|
89
|
-
response: nullablePlaylistItemsChangedEventSchema,
|
|
90
|
-
poll: async (ctx) => {
|
|
91
|
-
const item = (await createSpotifyClient(ctx.credentials["spotify"]).playlists.getPlaylistItems(options.playlistId, {
|
|
92
|
-
market: options.market,
|
|
93
|
-
limit: options.limit ?? 20
|
|
94
|
-
})).items[0];
|
|
95
|
-
const itemUri = item?.track?.uri ?? item?.track?.id;
|
|
96
|
-
return item && itemUri ? {
|
|
97
|
-
eventId: `${options.playlistId}:${item.addedAt ?? "unknown"}:${itemUri}:0`,
|
|
98
|
-
type: "playlist.item_added",
|
|
99
|
-
playlistId: options.playlistId,
|
|
100
|
-
snapshotId: item.addedAt ?? "unknown",
|
|
101
|
-
item
|
|
102
|
-
} : null;
|
|
103
|
-
}
|
|
104
|
-
})({
|
|
105
|
-
...options.id ? { id: options.id } : {},
|
|
106
|
-
...options.description ? { description: options.description } : {},
|
|
107
|
-
...options.transform ? { transform: options.transform } : {}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
function userPlaylistsChanged(options) {
|
|
111
|
-
return createPollingTriggerBindingFactory({
|
|
112
|
-
defaultId: "spotify.user_playlists_changed",
|
|
113
|
-
defaultDescription: "Poll the current user playlists and emit the most recent playlist snapshot.",
|
|
114
|
-
schedule: options?.schedule ?? "5m",
|
|
115
|
-
credentialSets: [spotify],
|
|
116
|
-
response: nullableUserPlaylistsChangedEventSchema,
|
|
117
|
-
poll: async (ctx) => {
|
|
118
|
-
const playlist = (await createSpotifyClient(ctx.credentials["spotify"]).playlists.listMyPlaylists({
|
|
119
|
-
limit: options?.limit ?? 20,
|
|
120
|
-
offset: options?.offset
|
|
121
|
-
})).items[0];
|
|
122
|
-
return playlist ? {
|
|
123
|
-
eventId: `${playlist.id}:${playlist.tracks?.total ?? 0}:details_changed`,
|
|
124
|
-
type: "playlist.details_changed",
|
|
125
|
-
playlist
|
|
126
|
-
} : null;
|
|
127
|
-
}
|
|
128
|
-
})({
|
|
129
|
-
...options?.id ? { id: options.id } : {},
|
|
130
|
-
...options?.description ? { description: options.description } : {},
|
|
131
|
-
...options?.transform ? { transform: options.transform } : {}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
function recentlyPlayedTrackAdded(options) {
|
|
135
|
-
return createPollingTriggerBindingFactory({
|
|
136
|
-
defaultId: "spotify.recently_played_track_added",
|
|
137
|
-
defaultDescription: "Poll recently played tracks and emit the most recent playback event.",
|
|
138
|
-
schedule: options?.schedule ?? "5m",
|
|
139
|
-
credentialSets: [spotify],
|
|
140
|
-
response: nullableRecentlyPlayedTrackAddedEventSchema,
|
|
141
|
-
poll: async (ctx) => {
|
|
142
|
-
const play = (await createSpotifyClient(ctx.credentials["spotify"]).player.getRecentlyPlayed({
|
|
143
|
-
limit: options?.limit ?? 1,
|
|
144
|
-
after: ctx.lastPolledAt ? Date.parse(ctx.lastPolledAt) : void 0
|
|
145
|
-
})).items[0];
|
|
146
|
-
return play ? {
|
|
147
|
-
eventId: `${play.playedAt}:${play.track.id}`,
|
|
148
|
-
type: "recently_played.track_added",
|
|
149
|
-
play
|
|
150
|
-
} : null;
|
|
151
|
-
}
|
|
152
|
-
})({
|
|
153
|
-
...options?.id ? { id: options.id } : {},
|
|
154
|
-
...options?.description ? { description: options.description } : {},
|
|
155
|
-
...options?.transform ? { transform: options.transform } : {}
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
function savedItemAdded(options) {
|
|
159
|
-
return createPollingTriggerBindingFactory({
|
|
160
|
-
defaultId: "spotify.saved_item_added",
|
|
161
|
-
defaultDescription: "Poll the Spotify library and emit the most recent saved item for a resource type.",
|
|
162
|
-
schedule: options.schedule ?? "5m",
|
|
163
|
-
credentialSets: [spotify],
|
|
164
|
-
response: nullableSavedItemAddedEventSchema,
|
|
165
|
-
poll: async (ctx) => {
|
|
166
|
-
const client = createSpotifyClient(ctx.credentials["spotify"]);
|
|
167
|
-
if (options.itemType === "album") {
|
|
168
|
-
const item = (await client.library.listSavedAlbums({
|
|
169
|
-
limit: options.limit ?? 1,
|
|
170
|
-
market: options.market
|
|
171
|
-
})).items[0];
|
|
172
|
-
return item ? {
|
|
173
|
-
eventId: `album:${item.album.id}:${item.addedAt}`,
|
|
174
|
-
type: "library.saved_item_added",
|
|
175
|
-
itemType: "album",
|
|
176
|
-
item
|
|
177
|
-
} : null;
|
|
178
|
-
}
|
|
179
|
-
if (options.itemType === "track") {
|
|
180
|
-
const item = (await client.library.listSavedTracks({
|
|
181
|
-
limit: options.limit ?? 1,
|
|
182
|
-
market: options.market
|
|
183
|
-
})).items[0];
|
|
184
|
-
return item ? {
|
|
185
|
-
eventId: `track:${item.track.id}:${item.addedAt}`,
|
|
186
|
-
type: "library.saved_item_added",
|
|
187
|
-
itemType: "track",
|
|
188
|
-
item
|
|
189
|
-
} : null;
|
|
190
|
-
}
|
|
191
|
-
if (options.itemType === "show") {
|
|
192
|
-
const item = (await client.library.listSavedShows({ limit: options.limit ?? 1 })).items[0];
|
|
193
|
-
return item ? {
|
|
194
|
-
eventId: `show:${item.show.id}:${item.addedAt}`,
|
|
195
|
-
type: "library.saved_item_added",
|
|
196
|
-
itemType: "show",
|
|
197
|
-
item
|
|
198
|
-
} : null;
|
|
199
|
-
}
|
|
200
|
-
if (options.itemType === "episode") {
|
|
201
|
-
const item = (await client.library.listSavedEpisodes({
|
|
202
|
-
limit: options.limit ?? 1,
|
|
203
|
-
market: options.market
|
|
204
|
-
})).items[0];
|
|
205
|
-
return item ? {
|
|
206
|
-
eventId: `episode:${item.episode.id}:${item.addedAt}`,
|
|
207
|
-
type: "library.saved_item_added",
|
|
208
|
-
itemType: "episode",
|
|
209
|
-
item
|
|
210
|
-
} : null;
|
|
211
|
-
}
|
|
212
|
-
const item = (await client.library.listSavedAudiobooks({ limit: options.limit ?? 1 })).items[0];
|
|
213
|
-
return item ? {
|
|
214
|
-
eventId: `audiobook:${item.audiobook.id}:${item.addedAt}`,
|
|
215
|
-
type: "library.saved_item_added",
|
|
216
|
-
itemType: "audiobook",
|
|
217
|
-
item
|
|
218
|
-
} : null;
|
|
219
|
-
}
|
|
220
|
-
})({
|
|
221
|
-
...options.id ? { id: options.id } : {},
|
|
222
|
-
...options.description ? { description: options.description } : {},
|
|
223
|
-
...options.transform ? { transform: options.transform } : {}
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
const polling = Object.freeze({
|
|
227
|
-
newDeviceAdded,
|
|
228
|
-
playlistItemsChanged,
|
|
229
|
-
userPlaylistsChanged,
|
|
230
|
-
recentlyPlayedTrackAdded,
|
|
231
|
-
savedItemAdded
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
//#endregion
|
|
235
|
-
export { newDeviceAdded, playlistItemsChanged, polling, recentlyPlayedTrackAdded, savedItemAdded, userPlaylistsChanged };
|
package/dist/users.d.mts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as _keystrokehq_core0 from "@keystrokehq/core";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
|
|
4
|
-
|
|
5
|
-
//#region src/users.d.ts
|
|
6
|
-
declare const getUser: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
7
|
-
id: z.ZodString;
|
|
8
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
9
|
-
displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
10
|
-
externalUrls: z.ZodOptional<z.ZodObject<{
|
|
11
|
-
spotify: z.ZodOptional<z.ZodURL>;
|
|
12
|
-
}, z.core.$strip>>;
|
|
13
|
-
followers: z.ZodOptional<z.ZodObject<{
|
|
14
|
-
href: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
|
|
15
|
-
total: z.ZodNumber;
|
|
16
|
-
}, z.core.$strip>>;
|
|
17
|
-
href: z.ZodOptional<z.ZodURL>;
|
|
18
|
-
id: z.ZodString;
|
|
19
|
-
type: z.ZodLiteral<"user">;
|
|
20
|
-
uri: z.ZodOptional<z.ZodString>;
|
|
21
|
-
email: z.ZodOptional<z.ZodEmail>;
|
|
22
|
-
country: z.ZodOptional<z.ZodString>;
|
|
23
|
-
product: z.ZodOptional<z.ZodString>;
|
|
24
|
-
images: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
25
|
-
url: z.ZodURL;
|
|
26
|
-
height: z.ZodNullable<z.ZodNumber>;
|
|
27
|
-
width: z.ZodNullable<z.ZodNumber>;
|
|
28
|
-
}, z.core.$strip>>>;
|
|
29
|
-
}, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"spotify", z.ZodObject<{
|
|
30
|
-
SPOTIFY_ACCESS_TOKEN: z.ZodString;
|
|
31
|
-
}, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
|
|
32
|
-
SPOTIFY_ACCESS_TOKEN: z.ZodString;
|
|
33
|
-
}, z.core.$strip>>[] | undefined>], undefined>;
|
|
34
|
-
//#endregion
|
|
35
|
-
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-C9W7aXmR.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 };
|
package/dist/verification.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/verification.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|