naystack 1.5.9 → 1.5.11

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 (114) hide show
  1. package/README.md +646 -91
  2. package/dist/auth/constants.d.mts +4 -0
  3. package/dist/auth/constants.d.ts +4 -0
  4. package/dist/auth/email/client.d.mts +149 -0
  5. package/dist/auth/email/client.d.ts +149 -0
  6. package/dist/auth/email/index.cjs.js +2 -20
  7. package/dist/auth/email/index.d.mts +41 -1
  8. package/dist/auth/email/index.d.ts +41 -1
  9. package/dist/auth/email/index.esm.js +1 -17
  10. package/dist/auth/email/routes/delete.cjs.js +0 -1
  11. package/dist/auth/email/routes/delete.d.mts +5 -0
  12. package/dist/auth/email/routes/delete.d.ts +5 -0
  13. package/dist/auth/email/routes/delete.esm.js +0 -1
  14. package/dist/auth/email/routes/get.d.mts +5 -0
  15. package/dist/auth/email/routes/get.d.ts +5 -0
  16. package/dist/auth/email/routes/post.cjs.js +0 -1
  17. package/dist/auth/email/routes/post.d.mts +5 -0
  18. package/dist/auth/email/routes/post.d.ts +5 -0
  19. package/dist/auth/email/routes/post.esm.js +0 -1
  20. package/dist/auth/email/routes/put.cjs.js +0 -1
  21. package/dist/auth/email/routes/put.d.mts +5 -0
  22. package/dist/auth/email/routes/put.d.ts +5 -0
  23. package/dist/auth/email/routes/put.esm.js +0 -1
  24. package/dist/auth/email/token.d.mts +62 -0
  25. package/dist/auth/email/token.d.ts +62 -0
  26. package/dist/auth/email/types.d.mts +22 -0
  27. package/dist/auth/email/types.d.ts +22 -0
  28. package/dist/auth/email/utils.cjs.js +0 -18
  29. package/dist/auth/email/utils.d.mts +41 -3
  30. package/dist/auth/email/utils.d.ts +41 -3
  31. package/dist/auth/email/utils.esm.js +0 -16
  32. package/dist/auth/google/get.d.mts +5 -0
  33. package/dist/auth/google/get.d.ts +5 -0
  34. package/dist/auth/google/index.d.mts +39 -0
  35. package/dist/auth/google/index.d.ts +39 -0
  36. package/dist/auth/index.cjs.js +4 -22
  37. package/dist/auth/index.d.mts +1 -1
  38. package/dist/auth/index.d.ts +1 -1
  39. package/dist/auth/index.esm.js +3 -19
  40. package/dist/auth/instagram/client.d.mts +19 -0
  41. package/dist/auth/instagram/client.d.ts +19 -0
  42. package/dist/auth/instagram/index.d.mts +37 -0
  43. package/dist/auth/instagram/index.d.ts +37 -0
  44. package/dist/auth/instagram/route.d.mts +5 -0
  45. package/dist/auth/instagram/route.d.ts +5 -0
  46. package/dist/auth/instagram/utils.d.mts +13 -0
  47. package/dist/auth/instagram/utils.d.ts +13 -0
  48. package/dist/auth/types.d.mts +24 -0
  49. package/dist/auth/types.d.ts +24 -0
  50. package/dist/auth/utils/errors.d.mts +10 -0
  51. package/dist/auth/utils/errors.d.ts +10 -0
  52. package/dist/auth/utils/token.d.mts +20 -0
  53. package/dist/auth/utils/token.d.ts +20 -0
  54. package/dist/client/hooks.d.mts +59 -0
  55. package/dist/client/hooks.d.ts +59 -0
  56. package/dist/client/seo.d.mts +46 -0
  57. package/dist/client/seo.d.ts +46 -0
  58. package/dist/env.d.mts +61 -0
  59. package/dist/env.d.ts +61 -0
  60. package/dist/file/client.d.mts +53 -1
  61. package/dist/file/client.d.ts +53 -1
  62. package/dist/file/index.cjs.js +0 -1
  63. package/dist/file/index.esm.js +0 -1
  64. package/dist/file/put.cjs.js +0 -1
  65. package/dist/file/put.d.mts +11 -0
  66. package/dist/file/put.d.ts +11 -0
  67. package/dist/file/put.esm.js +0 -1
  68. package/dist/file/setup.cjs.js +0 -1
  69. package/dist/file/setup.d.mts +48 -0
  70. package/dist/file/setup.d.ts +48 -0
  71. package/dist/file/setup.esm.js +0 -1
  72. package/dist/file/utils.d.mts +41 -0
  73. package/dist/file/utils.d.ts +41 -0
  74. package/dist/graphql/client.d.mts +113 -0
  75. package/dist/graphql/client.d.ts +113 -0
  76. package/dist/graphql/errors.d.mts +26 -0
  77. package/dist/graphql/errors.d.ts +26 -0
  78. package/dist/graphql/index.cjs.js +2 -3
  79. package/dist/graphql/index.esm.js +2 -3
  80. package/dist/graphql/init.cjs.js +0 -1
  81. package/dist/graphql/init.d.mts +33 -0
  82. package/dist/graphql/init.d.ts +33 -0
  83. package/dist/graphql/init.esm.js +0 -1
  84. package/dist/graphql/server.d.mts +88 -0
  85. package/dist/graphql/server.d.ts +88 -0
  86. package/dist/graphql/types.d.mts +21 -0
  87. package/dist/graphql/types.d.ts +21 -0
  88. package/dist/graphql/utils.d.mts +217 -0
  89. package/dist/graphql/utils.d.ts +217 -0
  90. package/dist/index.d.mts +16 -0
  91. package/dist/index.d.ts +16 -0
  92. package/dist/socials/instagram/getters.d.mts +115 -0
  93. package/dist/socials/instagram/getters.d.ts +115 -0
  94. package/dist/socials/instagram/setters.d.mts +18 -0
  95. package/dist/socials/instagram/setters.d.ts +18 -0
  96. package/dist/socials/instagram/types.d.mts +46 -0
  97. package/dist/socials/instagram/types.d.ts +46 -0
  98. package/dist/socials/instagram/utils.d.mts +19 -0
  99. package/dist/socials/instagram/utils.d.ts +19 -0
  100. package/dist/socials/instagram/webhook.d.mts +31 -0
  101. package/dist/socials/instagram/webhook.d.ts +31 -0
  102. package/dist/socials/meta-webhook.d.mts +11 -0
  103. package/dist/socials/meta-webhook.d.ts +11 -0
  104. package/dist/socials/threads/getters.d.mts +57 -0
  105. package/dist/socials/threads/getters.d.ts +57 -0
  106. package/dist/socials/threads/setters.d.mts +59 -0
  107. package/dist/socials/threads/setters.d.ts +59 -0
  108. package/dist/socials/threads/types.d.mts +9 -0
  109. package/dist/socials/threads/types.d.ts +9 -0
  110. package/dist/socials/threads/utils.d.mts +19 -0
  111. package/dist/socials/threads/utils.d.ts +19 -0
  112. package/dist/socials/threads/webhook.d.mts +30 -0
  113. package/dist/socials/threads/webhook.d.ts +30 -0
  114. package/package.json +9 -5
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Instagram Messaging API message shape.
3
+ *
4
+ * @property id - Message id.
5
+ * @property created_time - ISO timestamp of when the message was sent.
6
+ * @property from - Sender's id and username.
7
+ * @property to - Array of recipient ids and usernames.
8
+ * @property message - Text content of the message.
9
+ *
10
+ * @category Socials
11
+ */
1
12
  type InstagramMessage = {
2
13
  id: string;
3
14
  created_time: string;
@@ -13,16 +24,44 @@ type InstagramMessage = {
13
24
  };
14
25
  message: string;
15
26
  };
27
+ /**
28
+ * Instagram user/profile data (e.g. from the `"me"` endpoint).
29
+ *
30
+ * @property username - Instagram handle.
31
+ * @property followers_count - Number of followers.
32
+ * @property media_count - Number of media posts.
33
+ *
34
+ * @category Socials
35
+ */
16
36
  type InstagramUser = {
17
37
  username: string;
18
38
  followers_count: number;
19
39
  media_count: number;
20
40
  };
41
+ /**
42
+ * Instagram media item (e.g. from the `me/media` endpoint).
43
+ *
44
+ * @property like_count - Number of likes (may be undefined if not requested).
45
+ * @property comments_count - Number of comments.
46
+ * @property permalink - Permanent URL to the post on Instagram.
47
+ *
48
+ * @category Socials
49
+ */
21
50
  type InstagramMedia = {
22
51
  like_count?: number;
23
52
  comments_count: number;
24
53
  permalink: string;
25
54
  };
55
+ /**
56
+ * Instagram conversation (DM thread) from the Messaging API.
57
+ *
58
+ * @property id - Conversation id.
59
+ * @property updated_time - ISO timestamp of the last update.
60
+ * @property messages - Optional nested messages with pagination cursors.
61
+ * @property participants - Optional array of participant ids and usernames.
62
+ *
63
+ * @category Socials
64
+ */
26
65
  type InstagramConversation = {
27
66
  id: string;
28
67
  updated_time: string;
@@ -44,6 +83,13 @@ type InstagramConversation = {
44
83
  }[];
45
84
  };
46
85
  };
86
+ /**
87
+ * Instagram Graph API error response shape.
88
+ *
89
+ * @property error - Error details from the API (message, type, code, subcode, trace id).
90
+ *
91
+ * @category Socials
92
+ */
47
93
  type InstagramError = {
48
94
  error?: {
49
95
  message: string;
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Instagram Messaging API message shape.
3
+ *
4
+ * @property id - Message id.
5
+ * @property created_time - ISO timestamp of when the message was sent.
6
+ * @property from - Sender's id and username.
7
+ * @property to - Array of recipient ids and usernames.
8
+ * @property message - Text content of the message.
9
+ *
10
+ * @category Socials
11
+ */
1
12
  type InstagramMessage = {
2
13
  id: string;
3
14
  created_time: string;
@@ -13,16 +24,44 @@ type InstagramMessage = {
13
24
  };
14
25
  message: string;
15
26
  };
27
+ /**
28
+ * Instagram user/profile data (e.g. from the `"me"` endpoint).
29
+ *
30
+ * @property username - Instagram handle.
31
+ * @property followers_count - Number of followers.
32
+ * @property media_count - Number of media posts.
33
+ *
34
+ * @category Socials
35
+ */
16
36
  type InstagramUser = {
17
37
  username: string;
18
38
  followers_count: number;
19
39
  media_count: number;
20
40
  };
41
+ /**
42
+ * Instagram media item (e.g. from the `me/media` endpoint).
43
+ *
44
+ * @property like_count - Number of likes (may be undefined if not requested).
45
+ * @property comments_count - Number of comments.
46
+ * @property permalink - Permanent URL to the post on Instagram.
47
+ *
48
+ * @category Socials
49
+ */
21
50
  type InstagramMedia = {
22
51
  like_count?: number;
23
52
  comments_count: number;
24
53
  permalink: string;
25
54
  };
55
+ /**
56
+ * Instagram conversation (DM thread) from the Messaging API.
57
+ *
58
+ * @property id - Conversation id.
59
+ * @property updated_time - ISO timestamp of the last update.
60
+ * @property messages - Optional nested messages with pagination cursors.
61
+ * @property participants - Optional array of participant ids and usernames.
62
+ *
63
+ * @category Socials
64
+ */
26
65
  type InstagramConversation = {
27
66
  id: string;
28
67
  updated_time: string;
@@ -44,6 +83,13 @@ type InstagramConversation = {
44
83
  }[];
45
84
  };
46
85
  };
86
+ /**
87
+ * Instagram Graph API error response shape.
88
+ *
89
+ * @property error - Error details from the API (message, type, code, subcode, trace id).
90
+ *
91
+ * @category Socials
92
+ */
47
93
  type InstagramError = {
48
94
  error?: {
49
95
  message: string;
@@ -1,6 +1,25 @@
1
1
  import { InstagramError } from './types.mjs';
2
2
 
3
+ /**
4
+ * Builds an Instagram Graph API URL with the given path and query parameters (includes `access_token`).
5
+ *
6
+ * @param token - Instagram access token.
7
+ * @param path - API path (e.g. `"me"`, `"me/media"`, `"me/conversations"`).
8
+ * @param params - Additional query parameters.
9
+ * @returns Full URL string.
10
+ * @category Socials
11
+ */
3
12
  declare function getInstagramURL(token: string, path: string, params: Record<string, string>): string;
13
+ /**
14
+ * Fetches JSON from the Instagram Graph API (GET or POST depending on whether `postData` is provided).
15
+ *
16
+ * @param token - Instagram access token.
17
+ * @param path - API path.
18
+ * @param params - Query parameters (default: `{}`).
19
+ * @param postData - Optional POST body (if provided, the request becomes a POST).
20
+ * @returns Promise of `(T & InstagramError) | null`.
21
+ * @category Socials
22
+ */
4
23
  declare function getInstagramData<T>(token: string, path: string, params?: Record<string, string>, postData?: object): Promise<(T & InstagramError) | null>;
5
24
 
6
25
  export { getInstagramData, getInstagramURL };
@@ -1,6 +1,25 @@
1
1
  import { InstagramError } from './types.js';
2
2
 
3
+ /**
4
+ * Builds an Instagram Graph API URL with the given path and query parameters (includes `access_token`).
5
+ *
6
+ * @param token - Instagram access token.
7
+ * @param path - API path (e.g. `"me"`, `"me/media"`, `"me/conversations"`).
8
+ * @param params - Additional query parameters.
9
+ * @returns Full URL string.
10
+ * @category Socials
11
+ */
3
12
  declare function getInstagramURL(token: string, path: string, params: Record<string, string>): string;
13
+ /**
14
+ * Fetches JSON from the Instagram Graph API (GET or POST depending on whether `postData` is provided).
15
+ *
16
+ * @param token - Instagram access token.
17
+ * @param path - API path.
18
+ * @param params - Query parameters (default: `{}`).
19
+ * @param postData - Optional POST body (if provided, the request becomes a POST).
20
+ * @returns Promise of `(T & InstagramError) | null`.
21
+ * @category Socials
22
+ */
4
23
  declare function getInstagramData<T>(token: string, path: string, params?: Record<string, string>, postData?: object): Promise<(T & InstagramError) | null>;
5
24
 
6
25
  export { getInstagramData, getInstagramURL };
@@ -1,6 +1,37 @@
1
1
  import * as next_server from 'next/server';
2
2
  import { NextRequest } from 'next/server';
3
3
 
4
+ /**
5
+ * Sets up GET (verification) and POST (event handling) route handlers for the Instagram webhook.
6
+ *
7
+ * - **GET**: Responds to Meta's webhook verification challenge (checks `hub.verify_token` against `secret`).
8
+ * - **POST**: Parses incoming webhook events and calls your `callback` for each event in the payload.
9
+ *
10
+ * @param options - Configuration object.
11
+ * @param options.secret - The verify token you configured in the Meta Developer Portal.
12
+ * @param options.callback - Called for each webhook event: `(type, value, pageId) => Promise<void>`.
13
+ * - `type` — Event type (e.g. `"messaging"`, `"changes"`).
14
+ * - `value` — Event payload.
15
+ * - `id` — The page/account id from the entry.
16
+ * @returns Object with `GET` and `POST` — export as your route's handlers.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * // app/api/webhooks/instagram/route.ts
21
+ * import { setupInstagramWebhook } from "naystack/socials";
22
+ *
23
+ * export const { GET, POST } = setupInstagramWebhook({
24
+ * secret: process.env.WEBHOOK_SECRET!,
25
+ * callback: async (type, value, id) => {
26
+ * if (type === "messaging") {
27
+ * console.log("New message from page", id, value);
28
+ * }
29
+ * },
30
+ * });
31
+ * ```
32
+ *
33
+ * @category Socials
34
+ */
4
35
  declare const setupInstagramWebhook: (options: {
5
36
  secret: string;
6
37
  callback: (type: string, value: any, id: string) => Promise<void>;
@@ -1,6 +1,37 @@
1
1
  import * as next_server from 'next/server';
2
2
  import { NextRequest } from 'next/server';
3
3
 
4
+ /**
5
+ * Sets up GET (verification) and POST (event handling) route handlers for the Instagram webhook.
6
+ *
7
+ * - **GET**: Responds to Meta's webhook verification challenge (checks `hub.verify_token` against `secret`).
8
+ * - **POST**: Parses incoming webhook events and calls your `callback` for each event in the payload.
9
+ *
10
+ * @param options - Configuration object.
11
+ * @param options.secret - The verify token you configured in the Meta Developer Portal.
12
+ * @param options.callback - Called for each webhook event: `(type, value, pageId) => Promise<void>`.
13
+ * - `type` — Event type (e.g. `"messaging"`, `"changes"`).
14
+ * - `value` — Event payload.
15
+ * - `id` — The page/account id from the entry.
16
+ * @returns Object with `GET` and `POST` — export as your route's handlers.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * // app/api/webhooks/instagram/route.ts
21
+ * import { setupInstagramWebhook } from "naystack/socials";
22
+ *
23
+ * export const { GET, POST } = setupInstagramWebhook({
24
+ * secret: process.env.WEBHOOK_SECRET!,
25
+ * callback: async (type, value, id) => {
26
+ * if (type === "messaging") {
27
+ * console.log("New message from page", id, value);
28
+ * }
29
+ * },
30
+ * });
31
+ * ```
32
+ *
33
+ * @category Socials
34
+ */
4
35
  declare const setupInstagramWebhook: (options: {
5
36
  secret: string;
6
37
  callback: (type: string, value: any, id: string) => Promise<void>;
@@ -1,5 +1,16 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
2
 
3
+ /**
4
+ * Returns a GET handler that verifies a Meta (Instagram/Threads) webhook subscription.
5
+ * Responds with `hub.challenge` when `hub.verify_token` matches the provided secret.
6
+ *
7
+ * Used internally by `setupInstagramWebhook` and `setupThreadsWebhook`.
8
+ *
9
+ * @param secret - Expected `hub.verify_token` value (configured in the Meta Developer Portal).
10
+ * @returns GET route handler that responds to Meta's verification request.
11
+ *
12
+ * @category Socials
13
+ */
3
14
  declare const verifyWebhook: (secret: string) => (req: NextRequest) => NextResponse<unknown> | undefined;
4
15
 
5
16
  export { verifyWebhook };
@@ -1,5 +1,16 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
2
 
3
+ /**
4
+ * Returns a GET handler that verifies a Meta (Instagram/Threads) webhook subscription.
5
+ * Responds with `hub.challenge` when `hub.verify_token` matches the provided secret.
6
+ *
7
+ * Used internally by `setupInstagramWebhook` and `setupThreadsWebhook`.
8
+ *
9
+ * @param secret - Expected `hub.verify_token` value (configured in the Meta Developer Portal).
10
+ * @returns GET route handler that responds to Meta's verification request.
11
+ *
12
+ * @category Socials
13
+ */
3
14
  declare const verifyWebhook: (secret: string) => (req: NextRequest) => NextResponse<unknown> | undefined;
4
15
 
5
16
  export { verifyWebhook };
@@ -1,7 +1,64 @@
1
1
  import { ThreadsPost } from './types.mjs';
2
2
 
3
+ /**
4
+ * Fetches a single Threads post by id.
5
+ *
6
+ * @param token - Threads access token.
7
+ * @param id - Post id.
8
+ * @param fields - Optional array of field names. Default: `["text", "permalink", "username"]`.
9
+ * @returns Promise of post data (typed as `T`, defaults to {@link ThreadsPost}).
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { getThread } from "naystack/socials";
14
+ *
15
+ * const post = await getThread(accessToken, postId);
16
+ * console.log(post?.text, post?.permalink);
17
+ * ```
18
+ *
19
+ * @category Socials
20
+ */
3
21
  declare const getThread: <T = ThreadsPost>(token: string, id: string, fields?: string[]) => Promise<T | null>;
22
+ /**
23
+ * Fetches the authenticated user's Threads posts.
24
+ *
25
+ * @param token - Threads access token.
26
+ * @param fields - Optional array of field names. Default: `["text", "permalink", "username"]`.
27
+ * @returns Promise of an array of posts (typed as `T[]`, defaults to {@link ThreadsPost}`[]`).
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { getThreads } from "naystack/socials";
32
+ *
33
+ * const threads = await getThreads(accessToken);
34
+ * for (const thread of threads ?? []) {
35
+ * console.log(thread.text, thread.permalink);
36
+ * }
37
+ * ```
38
+ *
39
+ * @category Socials
40
+ */
4
41
  declare const getThreads: <T = ThreadsPost>(token: string, fields?: string[]) => Promise<T[] | undefined>;
42
+ /**
43
+ * Fetches replies to a Threads post.
44
+ *
45
+ * @param token - Threads access token.
46
+ * @param id - Parent post id.
47
+ * @param fields - Optional array of field names. Default: `["text", "username", "permalink"]`.
48
+ * @returns Promise of an array of reply posts.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * import { getThreadsReplies } from "naystack/socials";
53
+ *
54
+ * const replies = await getThreadsReplies(accessToken, postId);
55
+ * for (const reply of replies ?? []) {
56
+ * console.log(reply.username, ":", reply.text);
57
+ * }
58
+ * ```
59
+ *
60
+ * @category Socials
61
+ */
5
62
  declare const getThreadsReplies: <T = ThreadsPost>(token: string, id: string, fields?: string[]) => Promise<T[] | undefined>;
6
63
 
7
64
  export { getThread, getThreads, getThreadsReplies };
@@ -1,7 +1,64 @@
1
1
  import { ThreadsPost } from './types.js';
2
2
 
3
+ /**
4
+ * Fetches a single Threads post by id.
5
+ *
6
+ * @param token - Threads access token.
7
+ * @param id - Post id.
8
+ * @param fields - Optional array of field names. Default: `["text", "permalink", "username"]`.
9
+ * @returns Promise of post data (typed as `T`, defaults to {@link ThreadsPost}).
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { getThread } from "naystack/socials";
14
+ *
15
+ * const post = await getThread(accessToken, postId);
16
+ * console.log(post?.text, post?.permalink);
17
+ * ```
18
+ *
19
+ * @category Socials
20
+ */
3
21
  declare const getThread: <T = ThreadsPost>(token: string, id: string, fields?: string[]) => Promise<T | null>;
22
+ /**
23
+ * Fetches the authenticated user's Threads posts.
24
+ *
25
+ * @param token - Threads access token.
26
+ * @param fields - Optional array of field names. Default: `["text", "permalink", "username"]`.
27
+ * @returns Promise of an array of posts (typed as `T[]`, defaults to {@link ThreadsPost}`[]`).
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { getThreads } from "naystack/socials";
32
+ *
33
+ * const threads = await getThreads(accessToken);
34
+ * for (const thread of threads ?? []) {
35
+ * console.log(thread.text, thread.permalink);
36
+ * }
37
+ * ```
38
+ *
39
+ * @category Socials
40
+ */
4
41
  declare const getThreads: <T = ThreadsPost>(token: string, fields?: string[]) => Promise<T[] | undefined>;
42
+ /**
43
+ * Fetches replies to a Threads post.
44
+ *
45
+ * @param token - Threads access token.
46
+ * @param id - Parent post id.
47
+ * @param fields - Optional array of field names. Default: `["text", "username", "permalink"]`.
48
+ * @returns Promise of an array of reply posts.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * import { getThreadsReplies } from "naystack/socials";
53
+ *
54
+ * const replies = await getThreadsReplies(accessToken, postId);
55
+ * for (const reply of replies ?? []) {
56
+ * console.log(reply.username, ":", reply.text);
57
+ * }
58
+ * ```
59
+ *
60
+ * @category Socials
61
+ */
5
62
  declare const getThreadsReplies: <T = ThreadsPost>(token: string, id: string, fields?: string[]) => Promise<T[] | undefined>;
6
63
 
7
64
  export { getThread, getThreads, getThreadsReplies };
@@ -1,6 +1,65 @@
1
+ /**
2
+ * Creates a Threads container (draft post). Must be published with `publishContainer`.
3
+ * This is a low-level function — prefer using {@link createThreadsPost} which handles both steps.
4
+ *
5
+ * @param token - Threads access token.
6
+ * @param text - Post text.
7
+ * @param reply_to_id - Optional parent post id (for replies).
8
+ * @returns Promise of the container creation id.
9
+ * @category Socials
10
+ */
1
11
  declare function createContainer(token: string, text: string, reply_to_id?: string): Promise<string | undefined>;
12
+ /**
13
+ * Publishes a Threads container (created with `createContainer`).
14
+ * This is a low-level function — prefer using {@link createThreadsPost} which handles both steps.
15
+ *
16
+ * @param token - Threads access token.
17
+ * @param creation_id - Container id from `createContainer`.
18
+ * @returns Promise of the published post id.
19
+ * @category Socials
20
+ */
2
21
  declare function publishContainer(token: string, creation_id: string): Promise<string | undefined>;
22
+ /**
23
+ * Creates and publishes a single Threads post. Handles the two-step container + publish flow
24
+ * with an automatic 2-second delay between creation and publishing (required by the Threads API).
25
+ *
26
+ * @param token - Threads access token.
27
+ * @param text - Post text.
28
+ * @param reply_to_id - Optional parent post id (to make this post a reply).
29
+ * @returns Promise of the published post id, or `null` if creation failed.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { createThreadsPost } from "naystack/socials";
34
+ *
35
+ * const postId = await createThreadsPost(accessToken, "Hello from Naystack!");
36
+ * console.log("Published:", postId);
37
+ * ```
38
+ *
39
+ * @category Socials
40
+ */
3
41
  declare const createThreadsPost: (token: string, text: string, reply_to_id?: string) => Promise<string | null | undefined>;
42
+ /**
43
+ * Creates a thread — a sequence of posts where each replies to the previous one.
44
+ * Newlines in post text are converted to `%0A` for the API.
45
+ *
46
+ * @param token - Threads access token.
47
+ * @param threads - Array of post text strings (in order). Each post after the first becomes a reply to the previous.
48
+ * @returns Promise of the first published post's id.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * import { createThread } from "naystack/socials";
53
+ *
54
+ * const firstPostId = await createThread(accessToken, [
55
+ * "First post in thread",
56
+ * "Second post (reply to first)",
57
+ * "Third post (reply to second)",
58
+ * ]);
59
+ * ```
60
+ *
61
+ * @category Socials
62
+ */
4
63
  declare const createThread: (token: string, threads: string[]) => Promise<string | undefined>;
5
64
 
6
65
  export { createContainer, createThread, createThreadsPost, publishContainer };
@@ -1,6 +1,65 @@
1
+ /**
2
+ * Creates a Threads container (draft post). Must be published with `publishContainer`.
3
+ * This is a low-level function — prefer using {@link createThreadsPost} which handles both steps.
4
+ *
5
+ * @param token - Threads access token.
6
+ * @param text - Post text.
7
+ * @param reply_to_id - Optional parent post id (for replies).
8
+ * @returns Promise of the container creation id.
9
+ * @category Socials
10
+ */
1
11
  declare function createContainer(token: string, text: string, reply_to_id?: string): Promise<string | undefined>;
12
+ /**
13
+ * Publishes a Threads container (created with `createContainer`).
14
+ * This is a low-level function — prefer using {@link createThreadsPost} which handles both steps.
15
+ *
16
+ * @param token - Threads access token.
17
+ * @param creation_id - Container id from `createContainer`.
18
+ * @returns Promise of the published post id.
19
+ * @category Socials
20
+ */
2
21
  declare function publishContainer(token: string, creation_id: string): Promise<string | undefined>;
22
+ /**
23
+ * Creates and publishes a single Threads post. Handles the two-step container + publish flow
24
+ * with an automatic 2-second delay between creation and publishing (required by the Threads API).
25
+ *
26
+ * @param token - Threads access token.
27
+ * @param text - Post text.
28
+ * @param reply_to_id - Optional parent post id (to make this post a reply).
29
+ * @returns Promise of the published post id, or `null` if creation failed.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { createThreadsPost } from "naystack/socials";
34
+ *
35
+ * const postId = await createThreadsPost(accessToken, "Hello from Naystack!");
36
+ * console.log("Published:", postId);
37
+ * ```
38
+ *
39
+ * @category Socials
40
+ */
3
41
  declare const createThreadsPost: (token: string, text: string, reply_to_id?: string) => Promise<string | null | undefined>;
42
+ /**
43
+ * Creates a thread — a sequence of posts where each replies to the previous one.
44
+ * Newlines in post text are converted to `%0A` for the API.
45
+ *
46
+ * @param token - Threads access token.
47
+ * @param threads - Array of post text strings (in order). Each post after the first becomes a reply to the previous.
48
+ * @returns Promise of the first published post's id.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * import { createThread } from "naystack/socials";
53
+ *
54
+ * const firstPostId = await createThread(accessToken, [
55
+ * "First post in thread",
56
+ * "Second post (reply to first)",
57
+ * "Third post (reply to second)",
58
+ * ]);
59
+ * ```
60
+ *
61
+ * @category Socials
62
+ */
4
63
  declare const createThread: (token: string, threads: string[]) => Promise<string | undefined>;
5
64
 
6
65
  export { createContainer, createThread, createThreadsPost, publishContainer };
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Threads post (single post or reply).
3
+ *
4
+ * @property text - Post text content.
5
+ * @property permalink - Permanent URL to the post on Threads.
6
+ * @property username - Author's username.
7
+ *
8
+ * @category Socials
9
+ */
1
10
  type ThreadsPost = {
2
11
  text: string;
3
12
  permalink: string;
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Threads post (single post or reply).
3
+ *
4
+ * @property text - Post text content.
5
+ * @property permalink - Permanent URL to the post on Threads.
6
+ * @property username - Author's username.
7
+ *
8
+ * @category Socials
9
+ */
1
10
  type ThreadsPost = {
2
11
  text: string;
3
12
  permalink: string;
@@ -1,4 +1,23 @@
1
+ /**
2
+ * Builds a Threads Graph API URL with the given path and query parameters (includes `access_token`).
3
+ *
4
+ * @param token - Threads access token.
5
+ * @param path - API path (e.g. `"me/threads"`, `"me/threads_publish"`).
6
+ * @param params - Query parameters.
7
+ * @returns Full URL string.
8
+ * @category Socials
9
+ */
1
10
  declare function getThreadsURL(token: string, path: string, params: Record<string, string>): string;
11
+ /**
12
+ * Fetches JSON from the Threads Graph API (GET or POST).
13
+ *
14
+ * @param token - Threads access token.
15
+ * @param path - API path.
16
+ * @param params - Query parameters.
17
+ * @param method - Set to `"POST"` for mutations; defaults to `"GET"`.
18
+ * @returns Promise of response data (typed as `T`) or `null`.
19
+ * @category Socials
20
+ */
2
21
  declare function getThreadsData<T>(token: string, path: string, params: Record<string, string>, method?: "POST"): Promise<T | null>;
3
22
 
4
23
  export { getThreadsData, getThreadsURL };
@@ -1,4 +1,23 @@
1
+ /**
2
+ * Builds a Threads Graph API URL with the given path and query parameters (includes `access_token`).
3
+ *
4
+ * @param token - Threads access token.
5
+ * @param path - API path (e.g. `"me/threads"`, `"me/threads_publish"`).
6
+ * @param params - Query parameters.
7
+ * @returns Full URL string.
8
+ * @category Socials
9
+ */
1
10
  declare function getThreadsURL(token: string, path: string, params: Record<string, string>): string;
11
+ /**
12
+ * Fetches JSON from the Threads Graph API (GET or POST).
13
+ *
14
+ * @param token - Threads access token.
15
+ * @param path - API path.
16
+ * @param params - Query parameters.
17
+ * @param method - Set to `"POST"` for mutations; defaults to `"GET"`.
18
+ * @returns Promise of response data (typed as `T`) or `null`.
19
+ * @category Socials
20
+ */
2
21
  declare function getThreadsData<T>(token: string, path: string, params: Record<string, string>, method?: "POST"): Promise<T | null>;
3
22
 
4
23
  export { getThreadsData, getThreadsURL };