operand-meta-sdk 1.2.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.
Files changed (113) hide show
  1. package/.eslintrc.js +25 -0
  2. package/.prettierrc +4 -0
  3. package/README.md +435 -0
  4. package/dist/jest.config.d.ts +3 -0
  5. package/dist/jest.config.js +14 -0
  6. package/dist/jest.config.js.map +1 -0
  7. package/dist/src/__test__/mocks/index.d.ts +2 -0
  8. package/dist/src/__test__/mocks/index.js +6 -0
  9. package/dist/src/__test__/mocks/index.js.map +1 -0
  10. package/dist/src/error/operand-error.d.ts +8 -0
  11. package/dist/src/error/operand-error.js +196 -0
  12. package/dist/src/error/operand-error.js.map +1 -0
  13. package/dist/src/index.d.ts +10 -0
  14. package/dist/src/index.js +22 -0
  15. package/dist/src/index.js.map +1 -0
  16. package/dist/src/interfaces/ing-publish.d.ts +53 -0
  17. package/dist/src/interfaces/ing-publish.js +3 -0
  18. package/dist/src/interfaces/ing-publish.js.map +1 -0
  19. package/dist/src/interfaces/meta-auth.d.ts +14 -0
  20. package/dist/src/interfaces/meta-auth.js +3 -0
  21. package/dist/src/interfaces/meta-auth.js.map +1 -0
  22. package/dist/src/interfaces/meta-mkt.d.ts +4 -0
  23. package/dist/src/interfaces/meta-mkt.js +3 -0
  24. package/dist/src/interfaces/meta-mkt.js.map +1 -0
  25. package/dist/src/interfaces/meta-response.d.ts +285 -0
  26. package/dist/src/interfaces/meta-response.js +3 -0
  27. package/dist/src/interfaces/meta-response.js.map +1 -0
  28. package/dist/src/interfaces/meta.d.ts +6 -0
  29. package/dist/src/interfaces/meta.js +3 -0
  30. package/dist/src/interfaces/meta.js.map +1 -0
  31. package/dist/src/interfaces/page-publish.d.ts +66 -0
  32. package/dist/src/interfaces/page-publish.js +3 -0
  33. package/dist/src/interfaces/page-publish.js.map +1 -0
  34. package/dist/src/modules/auth/meta-auth.d.ts +35 -0
  35. package/dist/src/modules/auth/meta-auth.js +131 -0
  36. package/dist/src/modules/auth/meta-auth.js.map +1 -0
  37. package/dist/src/modules/auth/meta-auth.spec.d.ts +1 -0
  38. package/dist/src/modules/auth/meta-auth.spec.js +76 -0
  39. package/dist/src/modules/auth/meta-auth.spec.js.map +1 -0
  40. package/dist/src/modules/comments/ing-comments.d.ts +7 -0
  41. package/dist/src/modules/comments/ing-comments.js +27 -0
  42. package/dist/src/modules/comments/ing-comments.js.map +1 -0
  43. package/dist/src/modules/comments/page-comments.d.ts +6 -0
  44. package/dist/src/modules/comments/page-comments.js +18 -0
  45. package/dist/src/modules/comments/page-comments.js.map +1 -0
  46. package/dist/src/modules/insights/ing-insights.d.ts +42 -0
  47. package/dist/src/modules/insights/ing-insights.js +150 -0
  48. package/dist/src/modules/insights/ing-insights.js.map +1 -0
  49. package/dist/src/modules/insights/mkt-insights.d.ts +10 -0
  50. package/dist/src/modules/insights/mkt-insights.js +46 -0
  51. package/dist/src/modules/insights/mkt-insights.js.map +1 -0
  52. package/dist/src/modules/insights/page-insights.d.ts +34 -0
  53. package/dist/src/modules/insights/page-insights.js +146 -0
  54. package/dist/src/modules/insights/page-insights.js.map +1 -0
  55. package/dist/src/modules/meta-ing.d.ts +5 -0
  56. package/dist/src/modules/meta-ing.js +11 -0
  57. package/dist/src/modules/meta-ing.js.map +1 -0
  58. package/dist/src/modules/meta-mkt.d.ts +5 -0
  59. package/dist/src/modules/meta-mkt.js +11 -0
  60. package/dist/src/modules/meta-mkt.js.map +1 -0
  61. package/dist/src/modules/meta-page.d.ts +5 -0
  62. package/dist/src/modules/meta-page.js +11 -0
  63. package/dist/src/modules/meta-page.js.map +1 -0
  64. package/dist/src/modules/meta.d.ts +10 -0
  65. package/dist/src/modules/meta.js +23 -0
  66. package/dist/src/modules/meta.js.map +1 -0
  67. package/dist/src/modules/publish/ing-publish.d.ts +39 -0
  68. package/dist/src/modules/publish/ing-publish.js +464 -0
  69. package/dist/src/modules/publish/ing-publish.js.map +1 -0
  70. package/dist/src/modules/publish/page-publish.d.ts +51 -0
  71. package/dist/src/modules/publish/page-publish.js +560 -0
  72. package/dist/src/modules/publish/page-publish.js.map +1 -0
  73. package/dist/src/modules/publish/page-publish.spec.d.ts +1 -0
  74. package/dist/src/modules/publish/page-publish.spec.js +280 -0
  75. package/dist/src/modules/publish/page-publish.spec.js.map +1 -0
  76. package/dist/src/modules/utils/meta-utils.d.ts +8 -0
  77. package/dist/src/modules/utils/meta-utils.js +28 -0
  78. package/dist/src/modules/utils/meta-utils.js.map +1 -0
  79. package/dist/src/utils/api.d.ts +8 -0
  80. package/dist/src/utils/api.js +36 -0
  81. package/dist/src/utils/api.js.map +1 -0
  82. package/dist/tsconfig.tsbuildinfo +1 -0
  83. package/jest.config.ts +198 -0
  84. package/package.json +39 -0
  85. package/src/__test__/mocks/image.jpeg +0 -0
  86. package/src/__test__/mocks/index.ts +5 -0
  87. package/src/__test__/mocks/video-to-post.mp4 +0 -0
  88. package/src/__test__/mocks/video-to-stories.mp4 +0 -0
  89. package/src/error/operand-error.ts +217 -0
  90. package/src/index.ts +21 -0
  91. package/src/interfaces/ing-publish.ts +58 -0
  92. package/src/interfaces/meta-auth.ts +52 -0
  93. package/src/interfaces/meta-mkt.ts +5 -0
  94. package/src/interfaces/meta-response.ts +319 -0
  95. package/src/interfaces/meta.ts +7 -0
  96. package/src/interfaces/page-publish.ts +72 -0
  97. package/src/modules/auth/meta-auth.spec.ts +93 -0
  98. package/src/modules/auth/meta-auth.ts +227 -0
  99. package/src/modules/comments/ing-comments.ts +38 -0
  100. package/src/modules/comments/page-comments.ts +20 -0
  101. package/src/modules/insights/ing-insights.ts +275 -0
  102. package/src/modules/insights/mkt-insights.ts +68 -0
  103. package/src/modules/insights/page-insights.ts +267 -0
  104. package/src/modules/meta-ing.ts +8 -0
  105. package/src/modules/meta-mkt.ts +8 -0
  106. package/src/modules/meta-page.ts +8 -0
  107. package/src/modules/meta.ts +31 -0
  108. package/src/modules/publish/ing-publish.ts +754 -0
  109. package/src/modules/publish/page-publish.spec.ts +386 -0
  110. package/src/modules/publish/page-publish.ts +881 -0
  111. package/src/modules/utils/meta-utils.ts +37 -0
  112. package/src/utils/api.ts +45 -0
  113. package/tsconfig.json +22 -0
@@ -0,0 +1,37 @@
1
+ import { Meta } from "../meta";
2
+ import { ConstructorMain } from "../../interfaces/meta";
3
+ import axios from "axios";
4
+ import { GetInstagramDiscoveryResponse } from "../../interfaces/meta-response";
5
+
6
+ export class MetaUtils extends Meta {
7
+ constructor(data: ConstructorMain) {
8
+ super(data);
9
+ }
10
+
11
+ public async getTimePageTokenExpires() {
12
+ return this.api.get("debug_token", {
13
+ params: {
14
+ input_token: this.pageAccessToken,
15
+ access_token: this.pageAccessToken,
16
+ },
17
+ });
18
+ }
19
+
20
+ public static async getInstagramProfileByUsername(
21
+ username: string,
22
+ userId: string,
23
+ token: string,
24
+ ) {
25
+ return (
26
+ await axios.get<GetInstagramDiscoveryResponse>(
27
+ `https://graph.facebook.com/${userId}`,
28
+ {
29
+ params: {
30
+ fields: `business_discovery.username(${username}){followers_count,media_count,profile_picture_url.as(picture)}`,
31
+ access_token: token,
32
+ },
33
+ },
34
+ )
35
+ ).data;
36
+ }
37
+ }
@@ -0,0 +1,45 @@
1
+ import { ApiVersion } from "@/interfaces/meta-auth";
2
+ import axios from "axios";
3
+ import * as http from "node:http";
4
+
5
+ export interface IGenerateAxiosInstance {
6
+ apiVersion: ApiVersion;
7
+ isVideoApi?: boolean;
8
+ isInstagramApi?: boolean;
9
+ isInstagramAccessToken?: boolean;
10
+ }
11
+
12
+ export const generateAxiosInstance = ({
13
+ apiVersion,
14
+ isInstagramAccessToken,
15
+ isInstagramApi,
16
+ isVideoApi,
17
+ }: IGenerateAxiosInstance) => {
18
+ const timeout = 60000;
19
+
20
+ if (isVideoApi) {
21
+ return axios.create({
22
+ baseURL: `https://graph-video.facebook.com/${apiVersion}`,
23
+ timeout,
24
+ httpAgent: new http.Agent({ keepAlive: true }),
25
+ });
26
+ } else if (isInstagramAccessToken) {
27
+ return axios.create({
28
+ baseURL: `https://api.instagram.com`,
29
+ timeout,
30
+ httpAgent: new http.Agent({ keepAlive: true }),
31
+ });
32
+ } else if (isInstagramApi) {
33
+ return axios.create({
34
+ baseURL: `https://graph.instagram.com/${apiVersion}`,
35
+ timeout,
36
+ httpAgent: new http.Agent({ keepAlive: true }),
37
+ });
38
+ }
39
+
40
+ return axios.create({
41
+ baseURL: `https://graph.facebook.com/${apiVersion}`,
42
+ timeout,
43
+ httpAgent: new http.Agent({ keepAlive: true }),
44
+ });
45
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "declaration": true,
5
+ "removeComments": true,
6
+ "allowSyntheticDefaultImports": true,
7
+ "target": "ES2017",
8
+ "sourceMap": true,
9
+ "outDir": "./dist",
10
+ "baseUrl": "./",
11
+ "incremental": true,
12
+ "skipLibCheck": true,
13
+ "strictNullChecks": false,
14
+ "noImplicitAny": false,
15
+ "strictBindCallApply": false,
16
+ "forceConsistentCasingInFileNames": false,
17
+ "noFallthroughCasesInSwitch": false,
18
+ "paths": {
19
+ "@/*": ["src/*"]
20
+ }
21
+ }
22
+ }