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.
- package/.eslintrc.js +25 -0
- package/.prettierrc +4 -0
- package/README.md +435 -0
- package/dist/jest.config.d.ts +3 -0
- package/dist/jest.config.js +14 -0
- package/dist/jest.config.js.map +1 -0
- package/dist/src/__test__/mocks/index.d.ts +2 -0
- package/dist/src/__test__/mocks/index.js +6 -0
- package/dist/src/__test__/mocks/index.js.map +1 -0
- package/dist/src/error/operand-error.d.ts +8 -0
- package/dist/src/error/operand-error.js +196 -0
- package/dist/src/error/operand-error.js.map +1 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.js +22 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces/ing-publish.d.ts +53 -0
- package/dist/src/interfaces/ing-publish.js +3 -0
- package/dist/src/interfaces/ing-publish.js.map +1 -0
- package/dist/src/interfaces/meta-auth.d.ts +14 -0
- package/dist/src/interfaces/meta-auth.js +3 -0
- package/dist/src/interfaces/meta-auth.js.map +1 -0
- package/dist/src/interfaces/meta-mkt.d.ts +4 -0
- package/dist/src/interfaces/meta-mkt.js +3 -0
- package/dist/src/interfaces/meta-mkt.js.map +1 -0
- package/dist/src/interfaces/meta-response.d.ts +285 -0
- package/dist/src/interfaces/meta-response.js +3 -0
- package/dist/src/interfaces/meta-response.js.map +1 -0
- package/dist/src/interfaces/meta.d.ts +6 -0
- package/dist/src/interfaces/meta.js +3 -0
- package/dist/src/interfaces/meta.js.map +1 -0
- package/dist/src/interfaces/page-publish.d.ts +66 -0
- package/dist/src/interfaces/page-publish.js +3 -0
- package/dist/src/interfaces/page-publish.js.map +1 -0
- package/dist/src/modules/auth/meta-auth.d.ts +35 -0
- package/dist/src/modules/auth/meta-auth.js +131 -0
- package/dist/src/modules/auth/meta-auth.js.map +1 -0
- package/dist/src/modules/auth/meta-auth.spec.d.ts +1 -0
- package/dist/src/modules/auth/meta-auth.spec.js +76 -0
- package/dist/src/modules/auth/meta-auth.spec.js.map +1 -0
- package/dist/src/modules/comments/ing-comments.d.ts +7 -0
- package/dist/src/modules/comments/ing-comments.js +27 -0
- package/dist/src/modules/comments/ing-comments.js.map +1 -0
- package/dist/src/modules/comments/page-comments.d.ts +6 -0
- package/dist/src/modules/comments/page-comments.js +18 -0
- package/dist/src/modules/comments/page-comments.js.map +1 -0
- package/dist/src/modules/insights/ing-insights.d.ts +42 -0
- package/dist/src/modules/insights/ing-insights.js +150 -0
- package/dist/src/modules/insights/ing-insights.js.map +1 -0
- package/dist/src/modules/insights/mkt-insights.d.ts +10 -0
- package/dist/src/modules/insights/mkt-insights.js +46 -0
- package/dist/src/modules/insights/mkt-insights.js.map +1 -0
- package/dist/src/modules/insights/page-insights.d.ts +34 -0
- package/dist/src/modules/insights/page-insights.js +146 -0
- package/dist/src/modules/insights/page-insights.js.map +1 -0
- package/dist/src/modules/meta-ing.d.ts +5 -0
- package/dist/src/modules/meta-ing.js +11 -0
- package/dist/src/modules/meta-ing.js.map +1 -0
- package/dist/src/modules/meta-mkt.d.ts +5 -0
- package/dist/src/modules/meta-mkt.js +11 -0
- package/dist/src/modules/meta-mkt.js.map +1 -0
- package/dist/src/modules/meta-page.d.ts +5 -0
- package/dist/src/modules/meta-page.js +11 -0
- package/dist/src/modules/meta-page.js.map +1 -0
- package/dist/src/modules/meta.d.ts +10 -0
- package/dist/src/modules/meta.js +23 -0
- package/dist/src/modules/meta.js.map +1 -0
- package/dist/src/modules/publish/ing-publish.d.ts +39 -0
- package/dist/src/modules/publish/ing-publish.js +464 -0
- package/dist/src/modules/publish/ing-publish.js.map +1 -0
- package/dist/src/modules/publish/page-publish.d.ts +51 -0
- package/dist/src/modules/publish/page-publish.js +560 -0
- package/dist/src/modules/publish/page-publish.js.map +1 -0
- package/dist/src/modules/publish/page-publish.spec.d.ts +1 -0
- package/dist/src/modules/publish/page-publish.spec.js +280 -0
- package/dist/src/modules/publish/page-publish.spec.js.map +1 -0
- package/dist/src/modules/utils/meta-utils.d.ts +8 -0
- package/dist/src/modules/utils/meta-utils.js +28 -0
- package/dist/src/modules/utils/meta-utils.js.map +1 -0
- package/dist/src/utils/api.d.ts +8 -0
- package/dist/src/utils/api.js +36 -0
- package/dist/src/utils/api.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/jest.config.ts +198 -0
- package/package.json +39 -0
- package/src/__test__/mocks/image.jpeg +0 -0
- package/src/__test__/mocks/index.ts +5 -0
- package/src/__test__/mocks/video-to-post.mp4 +0 -0
- package/src/__test__/mocks/video-to-stories.mp4 +0 -0
- package/src/error/operand-error.ts +217 -0
- package/src/index.ts +21 -0
- package/src/interfaces/ing-publish.ts +58 -0
- package/src/interfaces/meta-auth.ts +52 -0
- package/src/interfaces/meta-mkt.ts +5 -0
- package/src/interfaces/meta-response.ts +319 -0
- package/src/interfaces/meta.ts +7 -0
- package/src/interfaces/page-publish.ts +72 -0
- package/src/modules/auth/meta-auth.spec.ts +93 -0
- package/src/modules/auth/meta-auth.ts +227 -0
- package/src/modules/comments/ing-comments.ts +38 -0
- package/src/modules/comments/page-comments.ts +20 -0
- package/src/modules/insights/ing-insights.ts +275 -0
- package/src/modules/insights/mkt-insights.ts +68 -0
- package/src/modules/insights/page-insights.ts +267 -0
- package/src/modules/meta-ing.ts +8 -0
- package/src/modules/meta-mkt.ts +8 -0
- package/src/modules/meta-page.ts +8 -0
- package/src/modules/meta.ts +31 -0
- package/src/modules/publish/ing-publish.ts +754 -0
- package/src/modules/publish/page-publish.spec.ts +386 -0
- package/src/modules/publish/page-publish.ts +881 -0
- package/src/modules/utils/meta-utils.ts +37 -0
- package/src/utils/api.ts +45 -0
- 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
|
+
}
|
package/src/utils/api.ts
ADDED
|
@@ -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
|
+
}
|