@keystrokehq/spotify 0.0.1 → 0.0.4

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 (55) hide show
  1. package/dist/_official/index.d.mts +2 -2
  2. package/dist/_official/index.mjs +1 -1
  3. package/dist/albums.d.mts +4 -4
  4. package/dist/albums.mjs +1 -1
  5. package/dist/artists.d.mts +5 -5
  6. package/dist/artists.mjs +1 -1
  7. package/dist/audio-analysis.d.mts +1 -1
  8. package/dist/audio-analysis.mjs +1 -1
  9. package/dist/audio-features.d.mts +2 -2
  10. package/dist/audio-features.mjs +1 -1
  11. package/dist/audiobooks.d.mts +3 -3
  12. package/dist/audiobooks.mjs +1 -1
  13. package/dist/browse.d.mts +1 -1
  14. package/dist/browse.mjs +1 -1
  15. package/dist/categories.d.mts +3 -3
  16. package/dist/categories.mjs +1 -1
  17. package/dist/chapters.d.mts +2 -2
  18. package/dist/chapters.mjs +1 -1
  19. package/dist/client.d.mts +230 -230
  20. package/dist/connection.d.mts +1 -1
  21. package/dist/connection.mjs +1 -1
  22. package/dist/episodes.d.mts +2 -2
  23. package/dist/episodes.mjs +1 -1
  24. package/dist/events.d.mts +2 -2
  25. package/dist/{factory-tZba6Hij.mjs → factory-CunabgAr.mjs} +1 -1
  26. package/dist/follow.d.mts +4 -4
  27. package/dist/follow.mjs +1 -1
  28. package/dist/genres.d.mts +1 -1
  29. package/dist/genres.mjs +1 -1
  30. package/dist/{integration-ykoImsCq.mjs → integration-C5PGWTYs.mjs} +2 -2
  31. package/dist/{integration-DQ5Egd4f.d.mts → integration-Dzf1u4u-.d.mts} +1 -1
  32. package/dist/library.d.mts +20 -20
  33. package/dist/library.mjs +1 -1
  34. package/dist/markets.d.mts +1 -1
  35. package/dist/markets.mjs +1 -1
  36. package/dist/me.d.mts +3 -3
  37. package/dist/me.mjs +1 -1
  38. package/dist/player.d.mts +17 -17
  39. package/dist/player.mjs +1 -1
  40. package/dist/playlists.d.mts +14 -14
  41. package/dist/playlists.mjs +1 -1
  42. package/dist/recommendations.d.mts +1 -1
  43. package/dist/recommendations.mjs +1 -1
  44. package/dist/schemas.d.mts +1 -1
  45. package/dist/search.d.mts +4 -4
  46. package/dist/search.mjs +1 -1
  47. package/dist/shows.d.mts +3 -3
  48. package/dist/shows.mjs +1 -1
  49. package/dist/tracks.d.mts +2 -2
  50. package/dist/tracks.mjs +1 -1
  51. package/dist/triggers.d.mts +3 -3
  52. package/dist/triggers.mjs +31 -46
  53. package/dist/users.d.mts +1 -1
  54. package/dist/users.mjs +1 -1
  55. package/package.json +18 -19
package/dist/tracks.d.mts CHANGED
@@ -80,7 +80,7 @@ declare const getTrack: _keystrokehq_core0.Operation<z.ZodObject<{
80
80
  trackNumber: z.ZodOptional<z.ZodNumber>;
81
81
  type: z.ZodLiteral<"track">;
82
82
  uri: z.ZodOptional<z.ZodString>;
83
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"spotify", z.ZodObject<{
83
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:spotify", z.ZodObject<{
84
84
  SPOTIFY_ACCESS_TOKEN: z.ZodString;
85
85
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
86
86
  SPOTIFY_ACCESS_TOKEN: z.ZodString;
@@ -164,7 +164,7 @@ declare const getSeveralTracks: _keystrokehq_core0.Operation<z.ZodObject<{
164
164
  type: z.ZodLiteral<"track">;
165
165
  uri: z.ZodOptional<z.ZodString>;
166
166
  }, z.core.$strip>>;
167
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"spotify", z.ZodObject<{
167
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:spotify", z.ZodObject<{
168
168
  SPOTIFY_ACCESS_TOKEN: z.ZodString;
169
169
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
170
170
  SPOTIFY_ACCESS_TOKEN: z.ZodString;
package/dist/tracks.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { spotifyIdSchema, spotifyMarketSchema, spotifyTrackSchema } from "./schemas.mjs";
2
2
  import { createSpotifyClient } from "./client.mjs";
3
- import { t as spotifyOperation } from "./factory-tZba6Hij.mjs";
3
+ import { t as spotifyOperation } from "./factory-CunabgAr.mjs";
4
4
  import { z } from "zod";
5
5
 
6
6
  //#region src/tracks.ts
@@ -1,4 +1,4 @@
1
- import { n as spotify } from "./integration-DQ5Egd4f.mjs";
1
+ import { n as spotify } from "./integration-Dzf1u4u-.mjs";
2
2
  import { spotifyNewDeviceAddedEventSchema, spotifyPlaylistItemsChangedEventSchema, spotifyRecentlyPlayedTrackAddedEventSchema, spotifySavedItemAddedEventSchema, spotifyUserPlaylistsChangedEventSchema } from "./events.mjs";
3
3
  import { z } from "zod";
4
4
  import { BoundTrigger } from "@keystrokehq/core";
@@ -8,8 +8,8 @@ import { PollingTriggerManifest } from "@keystrokehq/core/trigger";
8
8
  //#region src/triggers.d.ts
9
9
  type SpotifyCredentialSets = readonly [typeof spotify];
10
10
  type SpotifyPollingSchedule = number | `${number}s` | `${number}m` | `${number}h` | `${number}d` | `${number}w` | `${number}y`;
11
- type SpotifyPollingBoundTrigger<TEvent> = BoundTrigger<TEvent, SpotifyCredentialSets, PollingTriggerManifest, TEvent>;
12
- interface SpotifyPollingBindingOptions<TEvent> extends IntegrationTriggerBindingOptions<TEvent, TEvent> {
11
+ type SpotifyPollingBoundTrigger<TEvent> = BoundTrigger<TEvent | null, SpotifyCredentialSets, PollingTriggerManifest, TEvent | null>;
12
+ interface SpotifyPollingBindingOptions<TEvent> extends IntegrationTriggerBindingOptions<TEvent | null, TEvent | null> {
13
13
  readonly schedule?: SpotifyPollingSchedule;
14
14
  }
15
15
  interface PlaylistItemsChangedOptions extends SpotifyPollingBindingOptions<z.infer<typeof spotifyPlaylistItemsChangedEventSchema>> {
package/dist/triggers.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as spotify } from "./integration-ykoImsCq.mjs";
1
+ import { t as spotify } from "./integration-C5PGWTYs.mjs";
2
2
  import { createSpotifyClient } from "./client.mjs";
3
3
  import { spotifyNewDeviceAddedEventSchema, spotifyPlaylistItemsChangedEventSchema, spotifyRecentlyPlayedTrackAddedEventSchema, spotifySavedItemAddedEventSchema, spotifyUserPlaylistsChangedEventSchema } from "./events.mjs";
4
4
  import { z } from "zod";
@@ -12,37 +12,34 @@ const nullableRecentlyPlayedTrackAddedEventSchema = z.union([spotifyRecentlyPlay
12
12
  const nullableSavedItemAddedEventSchema = z.union([spotifySavedItemAddedEventSchema, z.null()]);
13
13
  function newDeviceAdded(options) {
14
14
  return createPollingTriggerBindingFactory({
15
- defaultName: "Spotify New Device Added",
15
+ defaultId: "spotify.new_device_added",
16
16
  defaultDescription: "Poll available Spotify devices and emit the most recent device snapshot.",
17
17
  schedule: options?.schedule ?? "5m",
18
18
  credentialSets: [spotify],
19
19
  response: nullableNewDeviceEventSchema,
20
20
  poll: async (ctx) => {
21
- const device = (await createSpotifyClient(ctx.credentials.spotify).player.getAvailableDevices()).devices[0];
21
+ const device = (await createSpotifyClient(ctx.credentials["keystroke:spotify"]).player.getAvailableDevices()).devices[0];
22
22
  return device ? {
23
23
  eventId: `device:${device.id ?? device.name}`,
24
24
  type: "device.added",
25
25
  device
26
26
  } : null;
27
- },
28
- mapPayload: (response) => response,
29
- idempotencyKey: (response) => response?.eventId
27
+ }
30
28
  })({
31
- name: options?.name,
32
- description: options?.description,
33
- filter: options?.filter,
34
- transform: options?.transform
29
+ ...options?.id ? { id: options.id } : {},
30
+ ...options?.description ? { description: options.description } : {},
31
+ ...options?.transform ? { transform: options.transform } : {}
35
32
  });
36
33
  }
37
34
  function playlistItemsChanged(options) {
38
35
  return createPollingTriggerBindingFactory({
39
- defaultName: "Spotify Playlist Items Changed",
36
+ defaultId: "spotify.playlist_items_changed",
40
37
  defaultDescription: "Poll playlist items and emit the most recent playlist entry.",
41
38
  schedule: options.schedule ?? "5m",
42
39
  credentialSets: [spotify],
43
40
  response: nullablePlaylistItemsChangedEventSchema,
44
41
  poll: async (ctx) => {
45
- const item = (await createSpotifyClient(ctx.credentials.spotify).playlists.getPlaylistItems(options.playlistId, {
42
+ const item = (await createSpotifyClient(ctx.credentials["keystroke:spotify"]).playlists.getPlaylistItems(options.playlistId, {
46
43
  market: options.market,
47
44
  limit: options.limit ?? 20
48
45
  })).items[0];
@@ -54,25 +51,22 @@ function playlistItemsChanged(options) {
54
51
  snapshotId: item.addedAt ?? "unknown",
55
52
  item
56
53
  } : null;
57
- },
58
- mapPayload: (response) => response,
59
- idempotencyKey: (response) => response?.eventId
54
+ }
60
55
  })({
61
- name: options.name,
62
- description: options.description,
63
- filter: options.filter,
64
- transform: options.transform
56
+ ...options.id ? { id: options.id } : {},
57
+ ...options.description ? { description: options.description } : {},
58
+ ...options.transform ? { transform: options.transform } : {}
65
59
  });
66
60
  }
67
61
  function userPlaylistsChanged(options) {
68
62
  return createPollingTriggerBindingFactory({
69
- defaultName: "Spotify User Playlists Changed",
63
+ defaultId: "spotify.user_playlists_changed",
70
64
  defaultDescription: "Poll the current user playlists and emit the most recent playlist snapshot.",
71
65
  schedule: options?.schedule ?? "5m",
72
66
  credentialSets: [spotify],
73
67
  response: nullableUserPlaylistsChangedEventSchema,
74
68
  poll: async (ctx) => {
75
- const playlist = (await createSpotifyClient(ctx.credentials.spotify).playlists.listMyPlaylists({
69
+ const playlist = (await createSpotifyClient(ctx.credentials["keystroke:spotify"]).playlists.listMyPlaylists({
76
70
  limit: options?.limit ?? 20,
77
71
  offset: options?.offset
78
72
  })).items[0];
@@ -81,25 +75,22 @@ function userPlaylistsChanged(options) {
81
75
  type: "playlist.details_changed",
82
76
  playlist
83
77
  } : null;
84
- },
85
- mapPayload: (response) => response,
86
- idempotencyKey: (response) => response?.eventId
78
+ }
87
79
  })({
88
- name: options?.name,
89
- description: options?.description,
90
- filter: options?.filter,
91
- transform: options?.transform
80
+ ...options?.id ? { id: options.id } : {},
81
+ ...options?.description ? { description: options.description } : {},
82
+ ...options?.transform ? { transform: options.transform } : {}
92
83
  });
93
84
  }
94
85
  function recentlyPlayedTrackAdded(options) {
95
86
  return createPollingTriggerBindingFactory({
96
- defaultName: "Spotify Recently Played Track Added",
87
+ defaultId: "spotify.recently_played_track_added",
97
88
  defaultDescription: "Poll recently played tracks and emit the most recent playback event.",
98
89
  schedule: options?.schedule ?? "5m",
99
90
  credentialSets: [spotify],
100
91
  response: nullableRecentlyPlayedTrackAddedEventSchema,
101
92
  poll: async (ctx) => {
102
- const play = (await createSpotifyClient(ctx.credentials.spotify).player.getRecentlyPlayed({
93
+ const play = (await createSpotifyClient(ctx.credentials["keystroke:spotify"]).player.getRecentlyPlayed({
103
94
  limit: options?.limit ?? 1,
104
95
  after: ctx.lastPolledAt ? Date.parse(ctx.lastPolledAt) : void 0
105
96
  })).items[0];
@@ -108,25 +99,22 @@ function recentlyPlayedTrackAdded(options) {
108
99
  type: "recently_played.track_added",
109
100
  play
110
101
  } : null;
111
- },
112
- mapPayload: (response) => response,
113
- idempotencyKey: (response) => response?.eventId
102
+ }
114
103
  })({
115
- name: options?.name,
116
- description: options?.description,
117
- filter: options?.filter,
118
- transform: options?.transform
104
+ ...options?.id ? { id: options.id } : {},
105
+ ...options?.description ? { description: options.description } : {},
106
+ ...options?.transform ? { transform: options.transform } : {}
119
107
  });
120
108
  }
121
109
  function savedItemAdded(options) {
122
110
  return createPollingTriggerBindingFactory({
123
- defaultName: "Spotify Saved Item Added",
111
+ defaultId: "spotify.saved_item_added",
124
112
  defaultDescription: "Poll the Spotify library and emit the most recent saved item for a resource type.",
125
113
  schedule: options.schedule ?? "5m",
126
114
  credentialSets: [spotify],
127
115
  response: nullableSavedItemAddedEventSchema,
128
116
  poll: async (ctx) => {
129
- const client = createSpotifyClient(ctx.credentials.spotify);
117
+ const client = createSpotifyClient(ctx.credentials["keystroke:spotify"]);
130
118
  if (options.itemType === "album") {
131
119
  const item = (await client.library.listSavedAlbums({
132
120
  limit: options.limit ?? 1,
@@ -179,14 +167,11 @@ function savedItemAdded(options) {
179
167
  itemType: "audiobook",
180
168
  item
181
169
  } : null;
182
- },
183
- mapPayload: (response) => response,
184
- idempotencyKey: (response) => response?.eventId
170
+ }
185
171
  })({
186
- name: options.name,
187
- description: options.description,
188
- filter: options.filter,
189
- transform: options.transform
172
+ ...options.id ? { id: options.id } : {},
173
+ ...options.description ? { description: options.description } : {},
174
+ ...options.transform ? { transform: options.transform } : {}
190
175
  });
191
176
  }
192
177
  const polling = Object.freeze({
package/dist/users.d.mts CHANGED
@@ -26,7 +26,7 @@ declare const getUser: _keystrokehq_core0.Operation<z.ZodObject<{
26
26
  height: z.ZodNullable<z.ZodNumber>;
27
27
  width: z.ZodNullable<z.ZodNumber>;
28
28
  }, z.core.$strip>>>;
29
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"spotify", z.ZodObject<{
29
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:spotify", z.ZodObject<{
30
30
  SPOTIFY_ACCESS_TOKEN: z.ZodString;
31
31
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
32
32
  SPOTIFY_ACCESS_TOKEN: z.ZodString;
package/dist/users.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { spotifyIdSchema, spotifyUserSchema } from "./schemas.mjs";
2
2
  import { createSpotifyClient } from "./client.mjs";
3
- import { t as spotifyOperation } from "./factory-tZba6Hij.mjs";
3
+ import { t as spotifyOperation } from "./factory-CunabgAr.mjs";
4
4
  import { z } from "zod";
5
5
 
6
6
  //#region src/users.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keystrokehq/spotify",
3
- "version": "0.0.1",
3
+ "version": "0.0.4",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -143,27 +143,18 @@
143
143
  "README.md",
144
144
  "LICENSE"
145
145
  ],
146
- "scripts": {
147
- "typecheck": "tsgo --build",
148
- "build": "tsdown",
149
- "lint": "biome check .",
150
- "test:unit": "vitest run --passWithNoTests --project unit",
151
- "prepublishOnly": "pnpm build && pnpm test:unit",
152
- "lint:fix": "biome check --write .",
153
- "test:int": "vitest run --passWithNoTests --project int"
154
- },
155
146
  "dependencies": {
156
- "@keystrokehq/integration-authoring": "^0.0.1",
157
- "@keystrokehq/core": "^0.0.5",
147
+ "@keystrokehq/core": "^0.0.7",
148
+ "@keystrokehq/integration-authoring": "^0.0.4",
158
149
  "zod": "^4.3.6"
159
150
  },
160
151
  "devDependencies": {
161
- "@types/node": "catalog:",
162
- "@keystrokehq/test-utils": "workspace:*",
163
- "@keystrokehq/typescript-config": "workspace:*",
164
- "tsdown": "catalog:",
165
- "typescript": "catalog:",
166
- "vitest": "catalog:"
152
+ "@types/node": "^22.19.11",
153
+ "tsdown": "^0.20.3",
154
+ "typescript": "^5.9.3",
155
+ "vitest": "^4.0.18",
156
+ "@keystrokehq/test-utils": "0.0.0",
157
+ "@keystrokehq/typescript-config": "0.0.0"
167
158
  },
168
159
  "keywords": [
169
160
  "spotify",
@@ -183,5 +174,13 @@
183
174
  "publishConfig": {
184
175
  "access": "public",
185
176
  "registry": "https://registry.npmjs.org/"
177
+ },
178
+ "scripts": {
179
+ "typecheck": "tsgo --build",
180
+ "build": "tsdown",
181
+ "lint": "biome check .",
182
+ "test:unit": "vitest run --passWithNoTests --project unit",
183
+ "lint:fix": "biome check --write .",
184
+ "test:int": "vitest run --passWithNoTests --project int"
186
185
  }
187
- }
186
+ }