naystack 1.5.8 → 1.5.10
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 +646 -91
- package/dist/auth/constants.d.mts +4 -0
- package/dist/auth/constants.d.ts +4 -0
- package/dist/auth/email/client.d.mts +149 -0
- package/dist/auth/email/client.d.ts +149 -0
- package/dist/auth/email/index.cjs.js +2 -14
- package/dist/auth/email/index.d.mts +41 -1
- package/dist/auth/email/index.d.ts +41 -1
- package/dist/auth/email/index.esm.js +1 -12
- package/dist/auth/email/routes/delete.cjs.js +0 -1
- package/dist/auth/email/routes/delete.d.mts +5 -0
- package/dist/auth/email/routes/delete.d.ts +5 -0
- package/dist/auth/email/routes/delete.esm.js +0 -1
- package/dist/auth/email/routes/get.d.mts +5 -0
- package/dist/auth/email/routes/get.d.ts +5 -0
- package/dist/auth/email/routes/post.cjs.js +0 -1
- package/dist/auth/email/routes/post.d.mts +5 -0
- package/dist/auth/email/routes/post.d.ts +5 -0
- package/dist/auth/email/routes/post.esm.js +0 -1
- package/dist/auth/email/routes/put.cjs.js +0 -1
- package/dist/auth/email/routes/put.d.mts +5 -0
- package/dist/auth/email/routes/put.d.ts +5 -0
- package/dist/auth/email/routes/put.esm.js +0 -1
- package/dist/auth/email/token.d.mts +62 -0
- package/dist/auth/email/token.d.ts +62 -0
- package/dist/auth/email/types.d.mts +22 -0
- package/dist/auth/email/types.d.ts +22 -0
- package/dist/auth/email/utils.cjs.js +0 -12
- package/dist/auth/email/utils.d.mts +41 -2
- package/dist/auth/email/utils.d.ts +41 -2
- package/dist/auth/email/utils.esm.js +0 -11
- package/dist/auth/google/get.d.mts +5 -0
- package/dist/auth/google/get.d.ts +5 -0
- package/dist/auth/google/index.d.mts +39 -0
- package/dist/auth/google/index.d.ts +39 -0
- package/dist/auth/index.cjs.js +4 -16
- package/dist/auth/index.d.mts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.esm.js +3 -14
- package/dist/auth/instagram/client.d.mts +19 -0
- package/dist/auth/instagram/client.d.ts +19 -0
- package/dist/auth/instagram/index.d.mts +37 -0
- package/dist/auth/instagram/index.d.ts +37 -0
- package/dist/auth/instagram/route.d.mts +5 -0
- package/dist/auth/instagram/route.d.ts +5 -0
- package/dist/auth/instagram/utils.d.mts +13 -0
- package/dist/auth/instagram/utils.d.ts +13 -0
- package/dist/auth/types.d.mts +24 -0
- package/dist/auth/types.d.ts +24 -0
- package/dist/auth/utils/errors.d.mts +10 -0
- package/dist/auth/utils/errors.d.ts +10 -0
- package/dist/auth/utils/token.d.mts +20 -0
- package/dist/auth/utils/token.d.ts +20 -0
- package/dist/client/hooks.d.mts +59 -0
- package/dist/client/hooks.d.ts +59 -0
- package/dist/client/seo.d.mts +46 -0
- package/dist/client/seo.d.ts +46 -0
- package/dist/env.d.mts +61 -0
- package/dist/env.d.ts +61 -0
- package/dist/file/client.d.mts +53 -1
- package/dist/file/client.d.ts +53 -1
- package/dist/file/index.cjs.js +0 -1
- package/dist/file/index.esm.js +0 -1
- package/dist/file/put.cjs.js +0 -1
- package/dist/file/put.d.mts +11 -0
- package/dist/file/put.d.ts +11 -0
- package/dist/file/put.esm.js +0 -1
- package/dist/file/setup.cjs.js +0 -1
- package/dist/file/setup.d.mts +48 -0
- package/dist/file/setup.d.ts +48 -0
- package/dist/file/setup.esm.js +0 -1
- package/dist/file/utils.d.mts +41 -0
- package/dist/file/utils.d.ts +41 -0
- package/dist/graphql/client.d.mts +113 -0
- package/dist/graphql/client.d.ts +113 -0
- package/dist/graphql/errors.d.mts +26 -0
- package/dist/graphql/errors.d.ts +26 -0
- package/dist/graphql/index.cjs.js +2 -3
- package/dist/graphql/index.esm.js +2 -3
- package/dist/graphql/init.cjs.js +0 -1
- package/dist/graphql/init.d.mts +33 -0
- package/dist/graphql/init.d.ts +33 -0
- package/dist/graphql/init.esm.js +0 -1
- package/dist/graphql/server.d.mts +88 -0
- package/dist/graphql/server.d.ts +88 -0
- package/dist/graphql/types.d.mts +21 -0
- package/dist/graphql/types.d.ts +21 -0
- package/dist/graphql/utils.d.mts +217 -0
- package/dist/graphql/utils.d.ts +217 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/socials/instagram/getters.d.mts +115 -0
- package/dist/socials/instagram/getters.d.ts +115 -0
- package/dist/socials/instagram/setters.d.mts +18 -0
- package/dist/socials/instagram/setters.d.ts +18 -0
- package/dist/socials/instagram/types.d.mts +46 -0
- package/dist/socials/instagram/types.d.ts +46 -0
- package/dist/socials/instagram/utils.d.mts +19 -0
- package/dist/socials/instagram/utils.d.ts +19 -0
- package/dist/socials/instagram/webhook.d.mts +31 -0
- package/dist/socials/instagram/webhook.d.ts +31 -0
- package/dist/socials/meta-webhook.d.mts +11 -0
- package/dist/socials/meta-webhook.d.ts +11 -0
- package/dist/socials/threads/getters.d.mts +57 -0
- package/dist/socials/threads/getters.d.ts +57 -0
- package/dist/socials/threads/setters.d.mts +59 -0
- package/dist/socials/threads/setters.d.ts +59 -0
- package/dist/socials/threads/types.d.mts +9 -0
- package/dist/socials/threads/types.d.ts +9 -0
- package/dist/socials/threads/utils.d.mts +19 -0
- package/dist/socials/threads/utils.d.ts +19 -0
- package/dist/socials/threads/webhook.d.mts +30 -0
- package/dist/socials/threads/webhook.d.ts +30 -0
- package/package.json +4 -2
|
@@ -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 };
|
|
@@ -1,6 +1,36 @@
|
|
|
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 Threads 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.
|
|
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: `(field, value) => Promise<boolean>`.
|
|
13
|
+
* - `field` — Event field name.
|
|
14
|
+
* - `value` — Event payload.
|
|
15
|
+
* Return `true` to acknowledge; return `false` to respond with HTTP 500.
|
|
16
|
+
* @returns Object with `GET` and `POST` — export as your route's handlers.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* // app/api/webhooks/threads/route.ts
|
|
21
|
+
* import { setupThreadsWebhook } from "naystack/socials";
|
|
22
|
+
*
|
|
23
|
+
* export const { GET, POST } = setupThreadsWebhook({
|
|
24
|
+
* secret: process.env.WEBHOOK_SECRET!,
|
|
25
|
+
* callback: async (field, value) => {
|
|
26
|
+
* console.log("Threads event:", field, value);
|
|
27
|
+
* return true; // Return false to respond with 500
|
|
28
|
+
* },
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @category Socials
|
|
33
|
+
*/
|
|
4
34
|
declare const setupThreadsWebhook: (options: {
|
|
5
35
|
secret: string;
|
|
6
36
|
callback: (type: string, value: any) => Promise<boolean>;
|
|
@@ -1,6 +1,36 @@
|
|
|
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 Threads 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.
|
|
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: `(field, value) => Promise<boolean>`.
|
|
13
|
+
* - `field` — Event field name.
|
|
14
|
+
* - `value` — Event payload.
|
|
15
|
+
* Return `true` to acknowledge; return `false` to respond with HTTP 500.
|
|
16
|
+
* @returns Object with `GET` and `POST` — export as your route's handlers.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* // app/api/webhooks/threads/route.ts
|
|
21
|
+
* import { setupThreadsWebhook } from "naystack/socials";
|
|
22
|
+
*
|
|
23
|
+
* export const { GET, POST } = setupThreadsWebhook({
|
|
24
|
+
* secret: process.env.WEBHOOK_SECRET!,
|
|
25
|
+
* callback: async (field, value) => {
|
|
26
|
+
* console.log("Threads event:", field, value);
|
|
27
|
+
* return true; // Return false to respond with 500
|
|
28
|
+
* },
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @category Socials
|
|
33
|
+
*/
|
|
4
34
|
declare const setupThreadsWebhook: (options: {
|
|
5
35
|
secret: string;
|
|
6
36
|
callback: (type: string, value: any) => Promise<boolean>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "naystack",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.10",
|
|
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",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "NODE_OPTIONS='--max-old-space-size=16384' tsup"
|
|
12
|
+
"build": "NODE_OPTIONS='--max-old-space-size=16384' tsup",
|
|
13
|
+
"docs": "typedoc"
|
|
13
14
|
},
|
|
14
15
|
"exports": {
|
|
15
16
|
"./auth": {
|
|
@@ -125,6 +126,7 @@
|
|
|
125
126
|
"prettier": "^3.5.3",
|
|
126
127
|
"tsup": "^8.5.0",
|
|
127
128
|
"tsx": "^4.20.5",
|
|
129
|
+
"typedoc": "^0.28.16",
|
|
128
130
|
"typescript": "^5.9.2",
|
|
129
131
|
"typescript-eslint": "^8.31.1"
|
|
130
132
|
},
|