naystack 1.9.1 → 1.9.2
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 +2 -0
- package/dist/socials/index.cjs.js +5 -1
- package/dist/socials/index.esm.js +5 -1
- package/dist/socials/instagram/adapter.cjs.js +5 -1
- package/dist/socials/instagram/adapter.esm.js +5 -1
- package/dist/socials/provider.d.mts +2 -2
- package/dist/socials/provider.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -724,6 +724,8 @@ const profile = await InstagramProvider.fetchProfile(accessToken);
|
|
|
724
724
|
|
|
725
725
|
const posts = await InstagramProvider.fetchMedia?.(accessToken, { limit: 6 });
|
|
726
726
|
// [{ kind: "video", permalink: "…", likes: 812, comments: null, … }]
|
|
727
|
+
// null instead means the request failed — an account with nothing posted
|
|
728
|
+
// returns []. Cache the empty, retry the null.
|
|
727
729
|
|
|
728
730
|
InstagramProvider.profileURL(profile.username);
|
|
729
731
|
// "https://instagram.com/…" — so a stored account row links out without the
|
|
@@ -471,7 +471,11 @@ var InstagramProvider = {
|
|
|
471
471
|
MEDIA_FIELDS,
|
|
472
472
|
options?.limit
|
|
473
473
|
);
|
|
474
|
-
if (!result?.data)
|
|
474
|
+
if (!Array.isArray(result?.data)) {
|
|
475
|
+
if (result?.error)
|
|
476
|
+
console.error("[naystack] Instagram media:", result.error.message);
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
475
479
|
return result.data.map(toPost);
|
|
476
480
|
}
|
|
477
481
|
};
|
|
@@ -415,7 +415,11 @@ var InstagramProvider = {
|
|
|
415
415
|
MEDIA_FIELDS,
|
|
416
416
|
options?.limit
|
|
417
417
|
);
|
|
418
|
-
if (!result?.data)
|
|
418
|
+
if (!Array.isArray(result?.data)) {
|
|
419
|
+
if (result?.error)
|
|
420
|
+
console.error("[naystack] Instagram media:", result.error.message);
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
419
423
|
return result.data.map(toPost);
|
|
420
424
|
}
|
|
421
425
|
};
|
|
@@ -266,7 +266,11 @@ var InstagramProvider = {
|
|
|
266
266
|
MEDIA_FIELDS,
|
|
267
267
|
options?.limit
|
|
268
268
|
);
|
|
269
|
-
if (!result?.data)
|
|
269
|
+
if (!Array.isArray(result?.data)) {
|
|
270
|
+
if (result?.error)
|
|
271
|
+
console.error("[naystack] Instagram media:", result.error.message);
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
270
274
|
return result.data.map(toPost);
|
|
271
275
|
}
|
|
272
276
|
};
|
|
@@ -240,7 +240,11 @@ var InstagramProvider = {
|
|
|
240
240
|
MEDIA_FIELDS,
|
|
241
241
|
options?.limit
|
|
242
242
|
);
|
|
243
|
-
if (!result?.data)
|
|
243
|
+
if (!Array.isArray(result?.data)) {
|
|
244
|
+
if (result?.error)
|
|
245
|
+
console.error("[naystack] Instagram media:", result.error.message);
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
244
248
|
return result.data.map(toPost);
|
|
245
249
|
}
|
|
246
250
|
};
|
|
@@ -15,7 +15,7 @@ import { SocialPlatform, SocialTokens, SocialProfile, SocialPost } from './types
|
|
|
15
15
|
* @property auth.authorizationURL - `state` comes back on the callback; `redirectURI` must match what the platform has registered.
|
|
16
16
|
* @property auth.exchangeCode - Trades the callback `code` for tokens. `platformUserId` is `null` on platforms whose token response carries no id (Google); the route then takes it from `fetchProfile`.
|
|
17
17
|
* @property auth.refresh - Omitted by platforms whose tokens don't expire or can't be refreshed.
|
|
18
|
-
* @property fetchMedia - Omitted by platforms with no content-listing API.
|
|
18
|
+
* @property fetchMedia - Omitted by platforms with no content-listing API. Resolves to `null` when the request failed and `[]` when the account genuinely has no content — a caller that caches results must not treat an outage as an empty grid.
|
|
19
19
|
* @property profileURL - Public profile link for a handle. Platform knowledge, not a capability, so every adapter has one.
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
@@ -48,7 +48,7 @@ type SocialProvider = {
|
|
|
48
48
|
profileURL: (username: string) => string;
|
|
49
49
|
fetchMedia?: (accessToken: string, options?: {
|
|
50
50
|
limit?: number;
|
|
51
|
-
}) => Promise<SocialPost[]>;
|
|
51
|
+
}) => Promise<SocialPost[] | null>;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
export type { SocialProvider };
|
|
@@ -15,7 +15,7 @@ import { SocialPlatform, SocialTokens, SocialProfile, SocialPost } from './types
|
|
|
15
15
|
* @property auth.authorizationURL - `state` comes back on the callback; `redirectURI` must match what the platform has registered.
|
|
16
16
|
* @property auth.exchangeCode - Trades the callback `code` for tokens. `platformUserId` is `null` on platforms whose token response carries no id (Google); the route then takes it from `fetchProfile`.
|
|
17
17
|
* @property auth.refresh - Omitted by platforms whose tokens don't expire or can't be refreshed.
|
|
18
|
-
* @property fetchMedia - Omitted by platforms with no content-listing API.
|
|
18
|
+
* @property fetchMedia - Omitted by platforms with no content-listing API. Resolves to `null` when the request failed and `[]` when the account genuinely has no content — a caller that caches results must not treat an outage as an empty grid.
|
|
19
19
|
* @property profileURL - Public profile link for a handle. Platform knowledge, not a capability, so every adapter has one.
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
@@ -48,7 +48,7 @@ type SocialProvider = {
|
|
|
48
48
|
profileURL: (username: string) => string;
|
|
49
49
|
fetchMedia?: (accessToken: string, options?: {
|
|
50
50
|
limit?: number;
|
|
51
|
-
}) => Promise<SocialPost[]>;
|
|
51
|
+
}) => Promise<SocialPost[] | null>;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
export type { SocialProvider };
|