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 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
@@ -444,6 +444,7 @@ var InstagramProvider = {
444
444
  };
445
445
  }
446
446
  },
447
+ profileURL: (username) => `https://instagram.com/${username}`,
447
448
  fetchProfile: async (accessToken) => {
448
449
  const user = await getInstagramUser(
449
450
  accessToken,
@@ -388,6 +388,7 @@ var InstagramProvider = {
388
388
  };
389
389
  }
390
390
  },
391
+ profileURL: (username) => `https://instagram.com/${username}`,
391
392
  fetchProfile: async (accessToken) => {
392
393
  const user = await getInstagramUser(
393
394
  accessToken,
@@ -239,6 +239,7 @@ var InstagramProvider = {
239
239
  };
240
240
  }
241
241
  },
242
+ profileURL: (username) => `https://instagram.com/${username}`,
242
243
  fetchProfile: async (accessToken) => {
243
244
  const user = await getInstagramUser(
244
245
  accessToken,
@@ -213,6 +213,7 @@ var InstagramProvider = {
213
213
  };
214
214
  }
215
215
  },
216
+ profileURL: (username) => `https://instagram.com/${username}`,
216
217
  fetchProfile: async (accessToken) => {
217
218
  const user = await getInstagramUser(
218
219
  accessToken,
@@ -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[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naystack",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "description": "A stack built with Next + GraphQL + S3 + Auth",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",