naystack 1.9.0 → 1.9.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.
- package/README.md +6 -1
- package/dist/socials/index.cjs.js +1 -0
- package/dist/socials/index.esm.js +1 -0
- package/dist/socials/instagram/adapter.cjs.js +1 -0
- package/dist/socials/instagram/adapter.esm.js +1 -0
- package/dist/socials/provider.d.mts +2 -0
- package/dist/socials/provider.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -713,7 +713,8 @@ constant so the generalized pieces pick it up for free.
|
|
|
713
713
|
A provider is a plain object with no per-instance state — import the constant, no
|
|
714
714
|
construction. Capability is method presence: a platform that can't refresh tokens
|
|
715
715
|
omits `refresh`, one with no content-listing API omits `fetchMedia`, and callers
|
|
716
|
-
narrow with a plain `if`.
|
|
716
|
+
narrow with a plain `if`. Platform *knowledge* is not a capability, so it is
|
|
717
|
+
always there: `platform` and `profileURL(username)` are required of every adapter.
|
|
717
718
|
|
|
718
719
|
```typescript
|
|
719
720
|
import { InstagramProvider } from "naystack/socials";
|
|
@@ -723,6 +724,10 @@ const profile = await InstagramProvider.fetchProfile(accessToken);
|
|
|
723
724
|
|
|
724
725
|
const posts = await InstagramProvider.fetchMedia?.(accessToken, { limit: 6 });
|
|
725
726
|
// [{ kind: "video", permalink: "…", likes: 812, comments: null, … }]
|
|
727
|
+
|
|
728
|
+
InstagramProvider.profileURL(profile.username);
|
|
729
|
+
// "https://instagram.com/…" — so a stored account row links out without the
|
|
730
|
+
// consumer keeping its own per-platform URL table
|
|
726
731
|
```
|
|
727
732
|
|
|
728
733
|
Every metric on a `SocialPost` is `number | null`, and `null` always means *the
|
|
@@ -16,6 +16,7 @@ import { SocialPlatform, SocialTokens, SocialProfile, SocialPost } from './types
|
|
|
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
18
|
* @property fetchMedia - Omitted by platforms with no content-listing API.
|
|
19
|
+
* @property profileURL - Public profile link for a handle. Platform knowledge, not a capability, so every adapter has one.
|
|
19
20
|
*
|
|
20
21
|
* @example
|
|
21
22
|
* ```ts
|
|
@@ -44,6 +45,7 @@ type SocialProvider = {
|
|
|
44
45
|
refresh?: (tokens: SocialTokens) => Promise<SocialTokens | null>;
|
|
45
46
|
};
|
|
46
47
|
fetchProfile: (accessToken: string) => Promise<SocialProfile | null>;
|
|
48
|
+
profileURL: (username: string) => string;
|
|
47
49
|
fetchMedia?: (accessToken: string, options?: {
|
|
48
50
|
limit?: number;
|
|
49
51
|
}) => Promise<SocialPost[]>;
|
|
@@ -16,6 +16,7 @@ import { SocialPlatform, SocialTokens, SocialProfile, SocialPost } from './types
|
|
|
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
18
|
* @property fetchMedia - Omitted by platforms with no content-listing API.
|
|
19
|
+
* @property profileURL - Public profile link for a handle. Platform knowledge, not a capability, so every adapter has one.
|
|
19
20
|
*
|
|
20
21
|
* @example
|
|
21
22
|
* ```ts
|
|
@@ -44,6 +45,7 @@ type SocialProvider = {
|
|
|
44
45
|
refresh?: (tokens: SocialTokens) => Promise<SocialTokens | null>;
|
|
45
46
|
};
|
|
46
47
|
fetchProfile: (accessToken: string) => Promise<SocialProfile | null>;
|
|
48
|
+
profileURL: (username: string) => string;
|
|
47
49
|
fetchMedia?: (accessToken: string, options?: {
|
|
48
50
|
limit?: number;
|
|
49
51
|
}) => Promise<SocialPost[]>;
|