naystack 1.8.12 → 1.8.14

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 (74) hide show
  1. package/README.md +189 -31
  2. package/dist/auth/index.cjs.js +158 -18
  3. package/dist/auth/index.d.mts +3 -1
  4. package/dist/auth/index.d.ts +3 -1
  5. package/dist/auth/index.esm.js +158 -18
  6. package/dist/auth/instagram/index.cjs.js +158 -18
  7. package/dist/auth/instagram/index.d.mts +6 -1
  8. package/dist/auth/instagram/index.d.ts +6 -1
  9. package/dist/auth/instagram/index.esm.js +158 -18
  10. package/dist/auth/instagram/route.cjs.js +158 -18
  11. package/dist/auth/instagram/route.d.mts +3 -1
  12. package/dist/auth/instagram/route.d.ts +3 -1
  13. package/dist/auth/instagram/route.esm.js +158 -18
  14. package/dist/auth/instagram/utils.cjs.js +2 -2
  15. package/dist/auth/instagram/utils.d.mts +13 -2
  16. package/dist/auth/instagram/utils.d.ts +13 -2
  17. package/dist/auth/instagram/utils.esm.js +2 -2
  18. package/dist/file/setup.d.mts +13 -5
  19. package/dist/file/setup.d.ts +13 -5
  20. package/dist/index.d.mts +1 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/socials/index.cjs.js +298 -72
  23. package/dist/socials/index.d.mts +6 -4
  24. package/dist/socials/index.d.ts +6 -4
  25. package/dist/socials/index.esm.js +296 -72
  26. package/dist/socials/instagram/getters.cjs.js +76 -25
  27. package/dist/socials/instagram/getters.d.mts +56 -6
  28. package/dist/socials/instagram/getters.d.ts +56 -6
  29. package/dist/socials/instagram/getters.esm.js +74 -25
  30. package/dist/socials/instagram/setters.cjs.js +192 -14
  31. package/dist/socials/instagram/setters.d.mts +43 -3
  32. package/dist/socials/instagram/setters.d.ts +43 -3
  33. package/dist/socials/instagram/setters.esm.js +191 -14
  34. package/dist/socials/instagram/types.d.mts +48 -11
  35. package/dist/socials/instagram/types.d.ts +48 -11
  36. package/dist/socials/instagram/utils.cjs.js +28 -15
  37. package/dist/socials/instagram/utils.d.mts +7 -18
  38. package/dist/socials/instagram/utils.d.ts +7 -18
  39. package/dist/socials/instagram/utils.esm.js +26 -14
  40. package/dist/socials/instagram/webhook.cjs.js +1 -1
  41. package/dist/socials/instagram/webhook.esm.js +1 -1
  42. package/dist/socials/meta/container.cjs.js +82 -0
  43. package/dist/socials/meta/container.d.mts +38 -0
  44. package/dist/socials/meta/container.d.ts +38 -0
  45. package/dist/socials/meta/container.esm.js +57 -0
  46. package/dist/socials/meta/request.cjs.js +60 -0
  47. package/dist/socials/meta/request.d.mts +50 -0
  48. package/dist/socials/meta/request.d.ts +50 -0
  49. package/dist/socials/meta/request.esm.js +34 -0
  50. package/dist/socials/meta/types.cjs.js +34 -0
  51. package/dist/socials/meta/types.d.mts +51 -0
  52. package/dist/socials/meta/types.d.ts +51 -0
  53. package/dist/socials/meta/types.esm.js +9 -0
  54. package/dist/socials/{meta-webhook.cjs.js → meta/webhook.cjs.js} +4 -4
  55. package/dist/socials/{meta-webhook.esm.js → meta/webhook.esm.js} +1 -1
  56. package/dist/socials/threads/getters.cjs.js +36 -11
  57. package/dist/socials/threads/getters.d.mts +23 -2
  58. package/dist/socials/threads/getters.d.ts +23 -2
  59. package/dist/socials/threads/getters.esm.js +35 -11
  60. package/dist/socials/threads/setters.cjs.js +150 -44
  61. package/dist/socials/threads/setters.d.mts +25 -34
  62. package/dist/socials/threads/setters.d.ts +25 -34
  63. package/dist/socials/threads/setters.esm.js +149 -41
  64. package/dist/socials/threads/types.d.mts +40 -1
  65. package/dist/socials/threads/types.d.ts +40 -1
  66. package/dist/socials/threads/utils.cjs.js +29 -11
  67. package/dist/socials/threads/utils.d.mts +8 -17
  68. package/dist/socials/threads/utils.d.ts +8 -17
  69. package/dist/socials/threads/utils.esm.js +27 -10
  70. package/dist/socials/threads/webhook.cjs.js +1 -1
  71. package/dist/socials/threads/webhook.esm.js +1 -1
  72. package/package.json +1 -1
  73. /package/dist/socials/{meta-webhook.d.mts → meta/webhook.d.mts} +0 -0
  74. /package/dist/socials/{meta-webhook.d.ts → meta/webhook.d.ts} +0 -0
@@ -1,3 +1,6 @@
1
+ import { WaitForContainerOptions } from '../meta/container.mjs';
2
+ import { MetaMediaType } from '../meta/types.mjs';
3
+
1
4
  /**
2
5
  * Threads post (single post or reply).
3
6
  *
@@ -12,5 +15,41 @@ type ThreadsPost = {
12
15
  permalink: string;
13
16
  username: string;
14
17
  };
18
+ /**
19
+ * One image or video to publish. The URL must be publicly reachable — Threads
20
+ * downloads it server-side.
21
+ *
22
+ * @property url - Public URL. Images: JPEG/PNG, 8 MB max. Videos: MP4/MOV, 1 GB / 5 min max.
23
+ * @property type - `"image"` or `"video"`.
24
+ * @property altText - Accessibility description.
25
+ *
26
+ * @category Socials
27
+ */
28
+ type ThreadsPostMedia = {
29
+ url: string;
30
+ type: MetaMediaType;
31
+ altText?: string;
32
+ };
33
+ /**
34
+ * Input for {@link createThreadsPost}. What gets published follows from `media`:
35
+ * none is a text post, one is a single image or video, 2–20 is a carousel.
36
+ *
37
+ * @property text - Post text, 500 characters max.
38
+ * @property media - One item or an array.
39
+ * @property linkAttachment - URL to render as a preview card. Text-only posts.
40
+ * @property replyToID - Parent post id, to make this post a reply.
41
+ * @property replyControl - Who may reply.
42
+ * @property wait - Container polling settings.
43
+ *
44
+ * @category Socials
45
+ */
46
+ type ThreadsPostInput = {
47
+ text?: string;
48
+ media?: ThreadsPostMedia | ThreadsPostMedia[];
49
+ linkAttachment?: string;
50
+ replyToID?: string;
51
+ replyControl?: "everyone" | "accounts_you_follow" | "mentioned_only";
52
+ wait?: WaitForContainerOptions;
53
+ };
15
54
 
16
- export type { ThreadsPost };
55
+ export type { ThreadsPost, ThreadsPostInput, ThreadsPostMedia };
@@ -1,3 +1,6 @@
1
+ import { WaitForContainerOptions } from '../meta/container.js';
2
+ import { MetaMediaType } from '../meta/types.js';
3
+
1
4
  /**
2
5
  * Threads post (single post or reply).
3
6
  *
@@ -12,5 +15,41 @@ type ThreadsPost = {
12
15
  permalink: string;
13
16
  username: string;
14
17
  };
18
+ /**
19
+ * One image or video to publish. The URL must be publicly reachable — Threads
20
+ * downloads it server-side.
21
+ *
22
+ * @property url - Public URL. Images: JPEG/PNG, 8 MB max. Videos: MP4/MOV, 1 GB / 5 min max.
23
+ * @property type - `"image"` or `"video"`.
24
+ * @property altText - Accessibility description.
25
+ *
26
+ * @category Socials
27
+ */
28
+ type ThreadsPostMedia = {
29
+ url: string;
30
+ type: MetaMediaType;
31
+ altText?: string;
32
+ };
33
+ /**
34
+ * Input for {@link createThreadsPost}. What gets published follows from `media`:
35
+ * none is a text post, one is a single image or video, 2–20 is a carousel.
36
+ *
37
+ * @property text - Post text, 500 characters max.
38
+ * @property media - One item or an array.
39
+ * @property linkAttachment - URL to render as a preview card. Text-only posts.
40
+ * @property replyToID - Parent post id, to make this post a reply.
41
+ * @property replyControl - Who may reply.
42
+ * @property wait - Container polling settings.
43
+ *
44
+ * @category Socials
45
+ */
46
+ type ThreadsPostInput = {
47
+ text?: string;
48
+ media?: ThreadsPostMedia | ThreadsPostMedia[];
49
+ linkAttachment?: string;
50
+ replyToID?: string;
51
+ replyControl?: "everyone" | "accounts_you_follow" | "mentioned_only";
52
+ wait?: WaitForContainerOptions;
53
+ };
15
54
 
16
- export type { ThreadsPost };
55
+ export type { ThreadsPost, ThreadsPostInput, ThreadsPostMedia };
@@ -20,20 +20,38 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/socials/threads/utils.ts
21
21
  var utils_exports = {};
22
22
  __export(utils_exports, {
23
- getThreadsData: () => getThreadsData,
24
- getThreadsURL: () => getThreadsURL
23
+ getThreadsData: () => getThreadsData
25
24
  });
26
25
  module.exports = __toCommonJS(utils_exports);
27
- function getThreadsURL(token, path, params) {
28
- return `https://graph.threads.net/v1.0/${path}?${Object.keys(params).map((key) => `${key}=${params[key]}`).join("&")}&access_token=${token}`;
29
- }
30
- function getThreadsData(token, path, params, method) {
31
- return fetch(getThreadsURL(token, path, params), {
32
- method: method || "GET"
33
- }).then((res) => res.json());
26
+
27
+ // src/socials/meta/request.ts
28
+ function createGraphClient(baseURL) {
29
+ const buildURL = (token, path, params = {}) => {
30
+ const search = new URLSearchParams();
31
+ for (const [key, value] of Object.entries(params)) {
32
+ if (value !== void 0) search.set(key, String(value));
33
+ }
34
+ search.set("access_token", token);
35
+ return `${baseURL}/${path}?${search.toString()}`;
36
+ };
37
+ const request = async (token, path, options = {}) => {
38
+ const response = await fetch(buildURL(token, path, options.params), {
39
+ method: options.method || (options.body ? "POST" : "GET"),
40
+ headers: {
41
+ Authorization: `Bearer ${token}`,
42
+ ...options.body ? { "Content-Type": "application/json" } : {}
43
+ },
44
+ ...options.body ? { body: JSON.stringify(options.body) } : {}
45
+ });
46
+ return response.json().catch(() => null);
47
+ };
48
+ return { buildURL, request };
34
49
  }
50
+
51
+ // src/socials/threads/utils.ts
52
+ var client = createGraphClient("https://graph.threads.net/v1.0");
53
+ var getThreadsData = client.request;
35
54
  // Annotate the CommonJS export names for ESM import in node:
36
55
  0 && (module.exports = {
37
- getThreadsData,
38
- getThreadsURL
56
+ getThreadsData
39
57
  });
@@ -1,23 +1,14 @@
1
+ import { GraphError } from '../meta/types.mjs';
2
+ import { GraphRequestOptions } from '../meta/request.mjs';
3
+
1
4
  /**
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
- */
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).
5
+ * Fetches JSON from the Threads Graph API.
13
6
  *
14
7
  * @param token - Threads access token.
15
8
  * @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
9
+ * @param options - `params` (query), `method`, `body`.
10
+ * @returns Promise of `(T & GraphError) | null`.
20
11
  */
21
- declare function getThreadsData<T>(token: string, path: string, params: Record<string, string>, method?: "POST"): Promise<T | null>;
12
+ declare const getThreadsData: <T>(token: string, path: string, options?: GraphRequestOptions) => Promise<(T & GraphError) | null>;
22
13
 
23
- export { getThreadsData, getThreadsURL };
14
+ export { getThreadsData };
@@ -1,23 +1,14 @@
1
+ import { GraphError } from '../meta/types.js';
2
+ import { GraphRequestOptions } from '../meta/request.js';
3
+
1
4
  /**
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
- */
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).
5
+ * Fetches JSON from the Threads Graph API.
13
6
  *
14
7
  * @param token - Threads access token.
15
8
  * @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
9
+ * @param options - `params` (query), `method`, `body`.
10
+ * @returns Promise of `(T & GraphError) | null`.
20
11
  */
21
- declare function getThreadsData<T>(token: string, path: string, params: Record<string, string>, method?: "POST"): Promise<T | null>;
12
+ declare const getThreadsData: <T>(token: string, path: string, options?: GraphRequestOptions) => Promise<(T & GraphError) | null>;
22
13
 
23
- export { getThreadsData, getThreadsURL };
14
+ export { getThreadsData };
@@ -1,13 +1,30 @@
1
- // src/socials/threads/utils.ts
2
- function getThreadsURL(token, path, params) {
3
- return `https://graph.threads.net/v1.0/${path}?${Object.keys(params).map((key) => `${key}=${params[key]}`).join("&")}&access_token=${token}`;
4
- }
5
- function getThreadsData(token, path, params, method) {
6
- return fetch(getThreadsURL(token, path, params), {
7
- method: method || "GET"
8
- }).then((res) => res.json());
1
+ // src/socials/meta/request.ts
2
+ function createGraphClient(baseURL) {
3
+ const buildURL = (token, path, params = {}) => {
4
+ const search = new URLSearchParams();
5
+ for (const [key, value] of Object.entries(params)) {
6
+ if (value !== void 0) search.set(key, String(value));
7
+ }
8
+ search.set("access_token", token);
9
+ return `${baseURL}/${path}?${search.toString()}`;
10
+ };
11
+ const request = async (token, path, options = {}) => {
12
+ const response = await fetch(buildURL(token, path, options.params), {
13
+ method: options.method || (options.body ? "POST" : "GET"),
14
+ headers: {
15
+ Authorization: `Bearer ${token}`,
16
+ ...options.body ? { "Content-Type": "application/json" } : {}
17
+ },
18
+ ...options.body ? { body: JSON.stringify(options.body) } : {}
19
+ });
20
+ return response.json().catch(() => null);
21
+ };
22
+ return { buildURL, request };
9
23
  }
24
+
25
+ // src/socials/threads/utils.ts
26
+ var client = createGraphClient("https://graph.threads.net/v1.0");
27
+ var getThreadsData = client.request;
10
28
  export {
11
- getThreadsData,
12
- getThreadsURL
29
+ getThreadsData
13
30
  };
@@ -24,7 +24,7 @@ __export(webhook_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(webhook_exports);
26
26
 
27
- // src/socials/meta-webhook.ts
27
+ // src/socials/meta/webhook.ts
28
28
  var import_server = require("next/server");
29
29
  var verifyWebhook = (secret) => (req) => {
30
30
  const params = req.nextUrl.searchParams;
@@ -1,4 +1,4 @@
1
- // src/socials/meta-webhook.ts
1
+ // src/socials/meta/webhook.ts
2
2
  import { NextResponse } from "next/server";
3
3
  var verifyWebhook = (secret) => (req) => {
4
4
  const params = req.nextUrl.searchParams;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naystack",
3
- "version": "1.8.12",
3
+ "version": "1.8.14",
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",