@neuralinnovations/dataisland-sdk 0.6.12 → 0.6.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.
- package/dist/package.json +1 -1
- package/dist/src/dto/instaResponse.d.ts +9 -3
- package/dist/src/dto/instaResponse.d.ts.map +1 -1
- package/dist/src/dto/instaResponse.js +6 -0
- package/dist/src/dto/instaResponse.js.map +1 -1
- package/dist/src/storages/insta/instaAccount.d.ts +1 -1
- package/dist/src/storages/insta/instaAccount.d.ts.map +1 -1
- package/dist/src/storages/insta/instaAccount.impl.d.ts +1 -1
- package/dist/src/storages/insta/instaAccount.impl.d.ts.map +1 -1
- package/dist/src/storages/insta/instaAccount.impl.js +4 -2
- package/dist/src/storages/insta/instaAccount.impl.js.map +1 -1
- package/dist/src/storages/insta/instaAccounts.d.ts +5 -4
- package/dist/src/storages/insta/instaAccounts.d.ts.map +1 -1
- package/dist/src/storages/insta/instaAccounts.impl.d.ts +10 -5
- package/dist/src/storages/insta/instaAccounts.impl.d.ts.map +1 -1
- package/dist/src/storages/insta/instaAccounts.impl.js +49 -8
- package/dist/src/storages/insta/instaAccounts.impl.js.map +1 -1
- package/dist/src/storages/insta/instaAccounts.js.map +1 -1
- package/dist/src/storages/insta/instaPost.d.ts +10 -0
- package/dist/src/storages/insta/instaPost.d.ts.map +1 -0
- package/dist/src/storages/insta/instaPost.impl.d.ts +15 -0
- package/dist/src/storages/insta/instaPost.impl.d.ts.map +1 -0
- package/dist/src/storages/insta/instaPost.impl.js +55 -0
- package/dist/src/storages/insta/instaPost.impl.js.map +1 -0
- package/dist/src/storages/insta/instaPost.js +7 -0
- package/dist/src/storages/insta/instaPost.js.map +1 -0
- package/package.json +1 -1
- package/src/dto/instaResponse.ts +10 -3
- package/src/storages/insta/instaAccount.impl.ts +4 -2
- package/src/storages/insta/instaAccount.ts +1 -1
- package/src/storages/insta/instaAccounts.impl.ts +73 -10
- package/src/storages/insta/instaAccounts.ts +7 -6
- package/src/storages/insta/instaPost.impl.ts +68 -0
- package/src/storages/insta/instaPost.ts +17 -0
package/dist/package.json
CHANGED
@@ -11,8 +11,14 @@ export interface InstaCutAccountDto {
|
|
11
11
|
id: string;
|
12
12
|
name: string;
|
13
13
|
}
|
14
|
-
export interface
|
15
|
-
|
16
|
-
|
14
|
+
export interface InstaPostDto {
|
15
|
+
id: string;
|
16
|
+
status: PostStatus;
|
17
|
+
message: string;
|
18
|
+
postsLeft: number;
|
19
|
+
}
|
20
|
+
export declare enum PostStatus {
|
21
|
+
Generation = 0,
|
22
|
+
Finished = 1
|
17
23
|
}
|
18
24
|
//# sourceMappingURL=instaResponse.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"instaResponse.d.ts","sourceRoot":"","sources":["../../../src/dto/instaResponse.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,iBAAiB,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,
|
1
|
+
{"version":3,"file":"instaResponse.d.ts","sourceRoot":"","sources":["../../../src/dto/instaResponse.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,iBAAiB,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,UAAU,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,oBAAY,UAAU;IACpB,UAAU,IAAI;IACd,QAAQ,IAAI;CACb"}
|
@@ -1,3 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.PostStatus = void 0;
|
4
|
+
var PostStatus;
|
5
|
+
(function (PostStatus) {
|
6
|
+
PostStatus[PostStatus["Generation"] = 0] = "Generation";
|
7
|
+
PostStatus[PostStatus["Finished"] = 1] = "Finished";
|
8
|
+
})(PostStatus || (exports.PostStatus = PostStatus = {}));
|
3
9
|
//# sourceMappingURL=instaResponse.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"instaResponse.js","sourceRoot":"","sources":["../../../src/dto/instaResponse.ts"],"names":[],"mappings":""}
|
1
|
+
{"version":3,"file":"instaResponse.js","sourceRoot":"","sources":["../../../src/dto/instaResponse.ts"],"names":[],"mappings":";;;AAyBA,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,uDAAc,CAAA;IACd,mDAAY,CAAA;AACd,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB"}
|
@@ -3,6 +3,6 @@ export type InstaAccountId = string;
|
|
3
3
|
export declare abstract class InstaAccount {
|
4
4
|
abstract get id(): InstaAccountId;
|
5
5
|
abstract data(): Promise<InstaAccountDto>;
|
6
|
-
abstract update(name: string, additionalContext: string, folderId: string): Promise<InstaAccountDto>;
|
6
|
+
abstract update(name: string, additionalContext: string, folderId: string, token: string, proxy: string): Promise<InstaAccountDto>;
|
7
7
|
}
|
8
8
|
//# sourceMappingURL=instaAccount.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"instaAccount.d.ts","sourceRoot":"","sources":["../../../../src/storages/insta/instaAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAA;AAGvD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAA;AAGnC,8BAAsB,YAAY;IAEhC,QAAQ,KAAK,EAAE,IAAI,cAAc,CAAA;IAEjC,QAAQ,CAAC,IAAI,IAAI,OAAO,CAAC,eAAe,CAAC;IAEzC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;
|
1
|
+
{"version":3,"file":"instaAccount.d.ts","sourceRoot":"","sources":["../../../../src/storages/insta/instaAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAA;AAGvD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAA;AAGnC,8BAAsB,YAAY;IAEhC,QAAQ,KAAK,EAAE,IAAI,cAAc,CAAA;IAEjC,QAAQ,CAAC,IAAI,IAAI,OAAO,CAAC,eAAe,CAAC;IAEzC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAEnI"}
|
@@ -7,6 +7,6 @@ export declare class InstaAccountImpl extends InstaAccount {
|
|
7
7
|
constructor(context: Context, id: string);
|
8
8
|
get id(): InstaAccountId;
|
9
9
|
data(): Promise<InstaAccountDto>;
|
10
|
-
update(name: string, additionalContext: string, folderId: string): Promise<InstaAccountDto>;
|
10
|
+
update(name: string, additionalContext: string, folderId: string, token: string, proxy: string): Promise<InstaAccountDto>;
|
11
11
|
}
|
12
12
|
//# sourceMappingURL=instaAccount.impl.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"instaAccount.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/insta/instaAccount.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAA;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAA;AAGvD,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AAGrC,qBAAa,gBAAiB,SAAQ,YAAY;IAGpC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;gBAEC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM;IAMzD,IAAI,EAAE,IAAI,cAAc,CAEvB;IAEK,IAAI,IAAI,OAAO,CAAC,eAAe,CAAC;IAehC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;
|
1
|
+
{"version":3,"file":"instaAccount.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/insta/instaAccount.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAA;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAA;AAGvD,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AAGrC,qBAAa,gBAAiB,SAAQ,YAAY;IAGpC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;gBAEC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM;IAMzD,IAAI,EAAE,IAAI,cAAc,CAEvB;IAEK,IAAI,IAAI,OAAO,CAAC,eAAe,CAAC;IAehC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAsBhI"}
|
@@ -23,7 +23,7 @@ class InstaAccountImpl extends instaAccount_1.InstaAccount {
|
|
23
23
|
}
|
24
24
|
return (await response.json()).instaAccount;
|
25
25
|
}
|
26
|
-
async update(name, additionalContext, folderId) {
|
26
|
+
async update(name, additionalContext, folderId, token, proxy) {
|
27
27
|
var _a;
|
28
28
|
// send request to the server
|
29
29
|
const response = await ((_a = this.context
|
@@ -31,7 +31,9 @@ class InstaAccountImpl extends instaAccount_1.InstaAccount {
|
|
31
31
|
instaId: this._id,
|
32
32
|
name: name,
|
33
33
|
additionalContext: additionalContext,
|
34
|
-
folderId: folderId
|
34
|
+
folderId: folderId,
|
35
|
+
token: token,
|
36
|
+
proxy: proxy
|
35
37
|
}));
|
36
38
|
// check response status
|
37
39
|
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"instaAccount.impl.js","sourceRoot":"","sources":["../../../../src/storages/insta/instaAccount.impl.ts"],"names":[],"mappings":";;;AAAA,iDAA2D;AAE3D,0DAAoD;AACpD,gEAA0D;AAI1D,MAAa,gBAAiB,SAAQ,2BAAY;IAGhD,YAA6B,OAAgB,EAAE,EAAU;QACvD,KAAK,EAAE,CAAA;QADoB,YAAO,GAAP,OAAO,CAAS;QAG3C,IAAI,CAAC,GAAG,GAAG,EAAE,CAAA;IACf,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;IAED,KAAK,CAAC,IAAI;;QACR,MAAM,QAAQ,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,OAAO;aAChC,OAAO,CAAC,uBAAU,CAAC,0CAClB,cAAc,CAAC,cAAc,EAC9B,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,EAC/B,OAAO,EAAE,CAAA,CAAA;QAEZ,wBAAw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AAE,iBAAyB,EAAE,QAAgB,EAAE,KAAa,EAAE,KAAa;;QAClG,6BAA6B;QAC7B,MAAM,QAAQ,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,OAAO;aAChC,OAAO,CAAC,uBAAU,CAAC,0CAClB,cAAc,CAAC,cAAc,EAC9B,WAAW,CAAC;YACX,OAAO,EAAE,IAAI,CAAC,GAAG;YACjB,IAAI,EAAE,IAAI;YACV,iBAAiB,EAAE,iBAAiB;YACpC,QAAQ,EAAE,QAAQ;YAClB,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,KAAK;SACb,CAAC,CAAA,CAAA;QAEJ,wBAAwB;QACxB,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAAC,2CAA2C,IAAI,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAA;QACjG,CAAC;QAED,OAAO,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;IAC1B,CAAC;CAEF;AAlDD,4CAkDC"}
|
@@ -1,10 +1,11 @@
|
|
1
|
-
import { InstaPostResult } from "../../dto/instaResponse";
|
2
1
|
import { InstaAccount } from "./instaAccount";
|
2
|
+
import { InstaPost } from "./instaPost";
|
3
3
|
export declare abstract class InstaAccounts {
|
4
|
-
abstract get
|
4
|
+
abstract get accounts(): InstaAccount[];
|
5
|
+
abstract get posts(): InstaPost[];
|
5
6
|
abstract update(): Promise<void>;
|
6
|
-
abstract add(name: string, token: string, accountId: string, additionalContext: string, folderId: string): Promise<void>;
|
7
|
+
abstract add(name: string, token: string, accountId: string, proxy: string, additionalContext: string, folderId: string): Promise<void>;
|
7
8
|
abstract delete(id: string): Promise<void>;
|
8
|
-
abstract post(message: string): Promise<
|
9
|
+
abstract post(message: string): Promise<void>;
|
9
10
|
}
|
10
11
|
//# sourceMappingURL=instaAccounts.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"instaAccounts.d.ts","sourceRoot":"","sources":["../../../../src/storages/insta/instaAccounts.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"instaAccounts.d.ts","sourceRoot":"","sources":["../../../../src/storages/insta/instaAccounts.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AAGrC,8BAAsB,aAAa;IAEjC,QAAQ,KAAK,QAAQ,IAAI,YAAY,EAAE,CAAA;IAEvC,QAAQ,KAAK,KAAK,IAAI,SAAS,EAAE,CAAA;IAEjC,QAAQ,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAEhC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAEvI,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1C,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAE9C"}
|
@@ -1,17 +1,22 @@
|
|
1
1
|
import { InstaAccounts } from "./instaAccounts";
|
2
|
-
import { InstaPostResult } from "../../dto/instaResponse";
|
3
2
|
import { OrganizationImpl } from "../organizations/organization.impl";
|
4
3
|
import { Context } from "../../context";
|
5
4
|
import { InstaAccount } from "./instaAccount";
|
5
|
+
import { InstaPost } from "./instaPost";
|
6
6
|
export declare class InstaAccountsImpl extends InstaAccounts {
|
7
7
|
readonly organization: OrganizationImpl;
|
8
8
|
readonly context: Context;
|
9
|
-
private
|
9
|
+
private _accounts?;
|
10
|
+
private _posts?;
|
11
|
+
private _inProgress;
|
12
|
+
private _fetchTimeout?;
|
10
13
|
constructor(organization: OrganizationImpl, context: Context);
|
11
|
-
get
|
14
|
+
get accounts(): InstaAccount[];
|
15
|
+
get posts(): InstaPost[];
|
16
|
+
internalFetchPosts(): Promise<void>;
|
12
17
|
update(): Promise<void>;
|
13
|
-
add(name: string, token: string, accountId: string, additionalContext: string, folderId: string): Promise<void>;
|
18
|
+
add(name: string, token: string, accountId: string, proxy: string, additionalContext: string, folderId: string): Promise<void>;
|
14
19
|
delete(id: string): Promise<void>;
|
15
|
-
post(message: string): Promise<
|
20
|
+
post(message: string): Promise<void>;
|
16
21
|
}
|
17
22
|
//# sourceMappingURL=instaAccounts.impl.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"instaAccounts.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/insta/instaAccounts.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;
|
1
|
+
{"version":3,"file":"instaAccounts.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/insta/instaAccounts.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAQ7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oCAAoC,CAAA;AACnE,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AAErC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAE3C,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AAGrC,qBAAa,iBAAkB,SAAQ,aAAa;aAUhC,YAAY,EAAE,gBAAgB;aAC9B,OAAO,EAAE,OAAO;IAVlC,OAAO,CAAC,SAAS,CAAC,CAAoB;IACtC,OAAO,CAAC,MAAM,CAAC,CAAiB;IAGhC,OAAO,CAAC,WAAW,CAAsB;IAEzC,OAAO,CAAC,aAAa,CAAC,CAAgB;gBAGpB,YAAY,EAAE,gBAAgB,EAC9B,OAAO,EAAE,OAAO;IAKlC,IAAI,QAAQ,IAAI,YAAY,EAAE,CAM7B;IAED,IAAI,KAAK,IAAI,SAAS,EAAE,CAMvB;IAEK,kBAAkB;IAelB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IA6CvB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA4C9H,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BjC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAwB3C"}
|
@@ -2,25 +2,48 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.InstaAccountsImpl = void 0;
|
4
4
|
const instaAccounts_1 = require("./instaAccounts");
|
5
|
+
const instaResponse_1 = require("../../dto/instaResponse");
|
5
6
|
const rpcService_1 = require("../../services/rpcService");
|
6
7
|
const responseUtils_1 = require("../../services/responseUtils");
|
7
8
|
const instaAccount_impl_1 = require("./instaAccount.impl");
|
9
|
+
const instaPost_impl_1 = require("./instaPost.impl");
|
8
10
|
class InstaAccountsImpl extends instaAccounts_1.InstaAccounts {
|
9
11
|
constructor(organization, context) {
|
10
12
|
super();
|
11
13
|
this.organization = organization;
|
12
14
|
this.context = context;
|
15
|
+
this._inProgress = [];
|
13
16
|
}
|
14
|
-
get
|
15
|
-
if (this.
|
16
|
-
return this.
|
17
|
+
get accounts() {
|
18
|
+
if (this._accounts !== undefined) {
|
19
|
+
return this._accounts;
|
17
20
|
}
|
18
21
|
else {
|
19
22
|
throw new Error("Insta accounts collection is not loaded, please update it first");
|
20
23
|
}
|
21
24
|
}
|
25
|
+
get posts() {
|
26
|
+
if (this._posts !== undefined) {
|
27
|
+
return this._posts;
|
28
|
+
}
|
29
|
+
else {
|
30
|
+
throw new Error("Insta posts collection is not loaded, please update it first");
|
31
|
+
}
|
32
|
+
}
|
33
|
+
async internalFetchPosts() {
|
34
|
+
for (const post of this._inProgress) {
|
35
|
+
await post.update();
|
36
|
+
}
|
37
|
+
this._inProgress = this._inProgress.filter(post => post.status == instaResponse_1.PostStatus.Generation);
|
38
|
+
if (this._inProgress.length > 0) {
|
39
|
+
this._fetchTimeout = setTimeout(async () => await this.internalFetchPosts(), 2000);
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
clearTimeout(this._fetchTimeout);
|
43
|
+
}
|
44
|
+
}
|
22
45
|
async update() {
|
23
|
-
var _a;
|
46
|
+
var _a, _b;
|
24
47
|
const response = await ((_a = this.context
|
25
48
|
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Insta/list").searchParam("organizationId", this.organization.id).sendGet());
|
26
49
|
// check response status
|
@@ -28,9 +51,23 @@ class InstaAccountsImpl extends instaAccounts_1.InstaAccounts {
|
|
28
51
|
await responseUtils_1.ResponseUtils.throwError(`Insta accounts list for organization ${this.organization.id} failed`, response);
|
29
52
|
}
|
30
53
|
const accounts = (await response.json()).instaAccounts;
|
31
|
-
this.
|
54
|
+
this._accounts = accounts.map(acc => new instaAccount_impl_1.InstaAccountImpl(this.context, acc.id));
|
55
|
+
const postsResponse = await ((_b = this.context
|
56
|
+
.resolve(rpcService_1.RpcService)) === null || _b === void 0 ? void 0 : _b.requestBuilder("api/v1/Insta/post/list").searchParam("organizationId", this.organization.id).sendGet());
|
57
|
+
// check response status
|
58
|
+
if (responseUtils_1.ResponseUtils.isFail(postsResponse)) {
|
59
|
+
await responseUtils_1.ResponseUtils.throwError(`Insta posts list for organization ${this.organization.id} failed`, postsResponse);
|
60
|
+
}
|
61
|
+
const posts = (await postsResponse.json()).posts;
|
62
|
+
this._posts = posts.map(acc => new instaPost_impl_1.InstaPostImpl(this.context, acc.id));
|
63
|
+
this._inProgress = [];
|
64
|
+
clearTimeout(this._fetchTimeout);
|
65
|
+
this._inProgress = this._posts.filter(post => post.status == instaResponse_1.PostStatus.Generation);
|
66
|
+
if (this._inProgress.length > 0) {
|
67
|
+
this._fetchTimeout = setTimeout(async () => await this.internalFetchPosts(), 2000);
|
68
|
+
}
|
32
69
|
}
|
33
|
-
async add(name, token, accountId, additionalContext, folderId) {
|
70
|
+
async add(name, token, accountId, proxy, additionalContext, folderId) {
|
34
71
|
var _a;
|
35
72
|
if (name === undefined || name === null || name.trim() === "") {
|
36
73
|
throw new Error("Add insta account, name can not be null or empty");
|
@@ -41,6 +78,9 @@ class InstaAccountsImpl extends instaAccounts_1.InstaAccounts {
|
|
41
78
|
if (accountId === undefined || accountId === null || accountId.trim() === "") {
|
42
79
|
throw new Error("Add insta account, accountId can not be null or empty");
|
43
80
|
}
|
81
|
+
if (proxy === undefined || proxy === null || proxy.trim() === "") {
|
82
|
+
throw new Error("Add insta account, proxy can not be null or empty");
|
83
|
+
}
|
44
84
|
if (additionalContext === undefined || additionalContext === null) {
|
45
85
|
throw new Error("Add insta account, additionalContext can not be null");
|
46
86
|
}
|
@@ -54,6 +94,7 @@ class InstaAccountsImpl extends instaAccounts_1.InstaAccounts {
|
|
54
94
|
organizationId: this.organization.id,
|
55
95
|
token: token,
|
56
96
|
accountId: accountId,
|
97
|
+
proxy: proxy,
|
57
98
|
additionalContext: additionalContext,
|
58
99
|
folderId: folderId
|
59
100
|
}));
|
@@ -65,7 +106,7 @@ class InstaAccountsImpl extends instaAccounts_1.InstaAccounts {
|
|
65
106
|
}
|
66
107
|
async delete(id) {
|
67
108
|
var _a, _b;
|
68
|
-
const account = (_a = this.
|
109
|
+
const account = (_a = this._accounts) === null || _a === void 0 ? void 0 : _a.find(acc => acc.id === id);
|
69
110
|
// check if account is found
|
70
111
|
if (!account) {
|
71
112
|
throw new Error(`Insta account ${id} is not found, organization: ${this.organization.id}`);
|
@@ -94,7 +135,7 @@ class InstaAccountsImpl extends instaAccounts_1.InstaAccounts {
|
|
94
135
|
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
95
136
|
await responseUtils_1.ResponseUtils.throwError(`Failed to add post for insta accounts in organization ${this.organization.id}`, response);
|
96
137
|
}
|
97
|
-
|
138
|
+
await this.update();
|
98
139
|
}
|
99
140
|
}
|
100
141
|
exports.InstaAccountsImpl = InstaAccountsImpl;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"instaAccounts.impl.js","sourceRoot":"","sources":["../../../../src/storages/insta/instaAccounts.impl.ts"],"names":[],"mappings":";;;AAAA,mDAA6C;
|
1
|
+
{"version":3,"file":"instaAccounts.impl.js","sourceRoot":"","sources":["../../../../src/storages/insta/instaAccounts.impl.ts"],"names":[],"mappings":";;;AAAA,mDAA6C;AAC7C,2DAIgC;AAChC,0DAAoD;AACpD,gEAA0D;AAG1D,2DAAoD;AAEpD,qDAA8C;AAI9C,MAAa,iBAAkB,SAAQ,6BAAa;IASlD,YACkB,YAA8B,EAC9B,OAAgB;QAChC,KAAK,EAAE,CAAA;QAFS,iBAAY,GAAZ,YAAY,CAAkB;QAC9B,YAAO,GAAP,OAAO,CAAS;QAN1B,gBAAW,GAAoB,EAAE,CAAA;IAQzC,CAAC;IAGD,IAAI,QAAQ;QACV,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC,SAAS,CAAA;QACvB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAA;QACpF,CAAC;IACH,CAAC;IAED,IAAI,KAAK;QACP,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC,MAAM,CAAA;QACpB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAA;QACjF,CAAC;IACH,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,WAAW,EAAC,CAAC;YACnC,MAAM,IAA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AAC,kDAAkD,CAAC,CAAA;QACrE,CAAC;QAED,oCAAoC;QACpC,MAAM,QAAQ,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,OAAO;aAChC,OAAO,CAAC,uBAAU,CAAC,0CAClB,cAAc,CAAC,mBAAmB,EACnC,YAAY,CAAC;YACZ,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE;YACpC,OAAO,EAAE,OAAO;SACjB,CAAC,CAAA,CAAA;QAEJ,wBAAwB;QACxB,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAAC,yDAAyD,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAA;QAC3H,CAAC;QAGD,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;IACrB,CAAC;CAGF;AA1LD,8CA0LC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"instaAccounts.js","sourceRoot":"","sources":["../../../../src/storages/insta/instaAccounts.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"instaAccounts.js","sourceRoot":"","sources":["../../../../src/storages/insta/instaAccounts.ts"],"names":[],"mappings":";;;AAKA,MAAsB,aAAa;CAclC;AAdD,sCAcC"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { PostStatus } from "../../dto/instaResponse";
|
2
|
+
export type InstaPostId = string;
|
3
|
+
export declare abstract class InstaPost {
|
4
|
+
abstract get id(): InstaPostId;
|
5
|
+
abstract get message(): string;
|
6
|
+
abstract get status(): PostStatus;
|
7
|
+
abstract get postsLeft(): number;
|
8
|
+
abstract update(): Promise<void>;
|
9
|
+
}
|
10
|
+
//# sourceMappingURL=instaPost.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"instaPost.d.ts","sourceRoot":"","sources":["../../../../src/storages/insta/instaPost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAGlD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC,8BAAsB,SAAS;IAE7B,QAAQ,KAAK,EAAE,IAAI,WAAW,CAAA;IAE9B,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAA;IAE9B,QAAQ,KAAK,MAAM,IAAI,UAAU,CAAA;IAEjC,QAAQ,KAAK,SAAS,IAAI,MAAM,CAAA;IAEhC,QAAQ,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CACjC"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { InstaPost, InstaPostId } from "./instaPost";
|
2
|
+
import { Context } from "../../context";
|
3
|
+
import { PostStatus } from "../../dto/instaResponse";
|
4
|
+
export declare class InstaPostImpl extends InstaPost {
|
5
|
+
private readonly context;
|
6
|
+
private readonly _id;
|
7
|
+
private _data?;
|
8
|
+
constructor(context: Context, id: string);
|
9
|
+
get id(): InstaPostId;
|
10
|
+
get message(): string;
|
11
|
+
get status(): PostStatus;
|
12
|
+
get postsLeft(): number;
|
13
|
+
update(): Promise<void>;
|
14
|
+
}
|
15
|
+
//# sourceMappingURL=instaPost.impl.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"instaPost.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/insta/instaPost.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,aAAa,CAAA;AAClD,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AACrC,OAAO,EAEL,UAAU,EACX,MAAM,yBAAyB,CAAA;AAKhC,qBAAa,aAAc,SAAQ,SAAS;IAK9B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAE5B,OAAO,CAAC,KAAK,CAAC,CAAc;gBAEC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM;IAMzD,IAAI,EAAE,IAAI,WAAW,CAEpB;IAED,IAAI,OAAO,IAAI,MAAM,CAMpB;IAED,IAAI,MAAM,IAAI,UAAU,CAMvB;IAED,IAAI,SAAS,IAAI,MAAM,CAMtB;IAEK,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAkB9B"}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.InstaPostImpl = void 0;
|
4
|
+
const instaPost_1 = require("./instaPost");
|
5
|
+
const rpcService_1 = require("../../services/rpcService");
|
6
|
+
const responseUtils_1 = require("../../services/responseUtils");
|
7
|
+
class InstaPostImpl extends instaPost_1.InstaPost {
|
8
|
+
constructor(context, id) {
|
9
|
+
super();
|
10
|
+
this.context = context;
|
11
|
+
this._id = id;
|
12
|
+
}
|
13
|
+
get id() {
|
14
|
+
return this._id;
|
15
|
+
}
|
16
|
+
get message() {
|
17
|
+
var _a;
|
18
|
+
if (this._data) {
|
19
|
+
return (_a = this._data) === null || _a === void 0 ? void 0 : _a.message;
|
20
|
+
}
|
21
|
+
else {
|
22
|
+
throw new Error("Insta post data not loaded, please call update first");
|
23
|
+
}
|
24
|
+
}
|
25
|
+
get status() {
|
26
|
+
var _a;
|
27
|
+
if (this._data) {
|
28
|
+
return (_a = this._data) === null || _a === void 0 ? void 0 : _a.status;
|
29
|
+
}
|
30
|
+
else {
|
31
|
+
throw new Error("Insta post data not loaded, please call update first");
|
32
|
+
}
|
33
|
+
}
|
34
|
+
get postsLeft() {
|
35
|
+
var _a;
|
36
|
+
if (this._data) {
|
37
|
+
return (_a = this._data) === null || _a === void 0 ? void 0 : _a.postsLeft;
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
throw new Error("Insta post data not loaded, please call update first");
|
41
|
+
}
|
42
|
+
}
|
43
|
+
async update() {
|
44
|
+
var _a;
|
45
|
+
const response = await ((_a = this.context
|
46
|
+
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Insta/post/status").searchParam("postId", this._id).sendGet());
|
47
|
+
// check response status
|
48
|
+
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
49
|
+
await responseUtils_1.ResponseUtils.throwError(`Insta post status get for post ${this._id} failes`, response);
|
50
|
+
}
|
51
|
+
this._data = (await response.json()).post;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
exports.InstaPostImpl = InstaPostImpl;
|
55
|
+
//# sourceMappingURL=instaPost.impl.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"instaPost.impl.js","sourceRoot":"","sources":["../../../../src/storages/insta/instaPost.impl.ts"],"names":[],"mappings":";;;AAAA,2CAAkD;AAMlD,0DAAoD;AACpD,gEAA0D;AAG1D,MAAa,aAAc,SAAQ,qBAAS;IAK1C,YAA6B,OAAgB,EAAE,EAAU;QACvD,KAAK,EAAE,CAAA;QADoB,YAAO,GAAP,OAAO,CAAS;QAG3C,IAAI,CAAC,GAAG,GAAG,EAAE,CAAA;IACf,CAAC;IAED,IAAI,EAAE;QACJ,OAAoB,IAAI,CAAC,GAAG,CAAA;IAC9B,CAAC;IAED,IAAI,OAAO;;QACT,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,MAAA,IAAI,CAAC,KAAK,0CAAE,OAAO,CAAA;QAC5B,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;QACzE,CAAC;IACH,CAAC;IAED,IAAI,MAAM;;QACR,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,MAAA,IAAI,CAAC,KAAK,0CAAE,MAAM,CAAA;QAC3B,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;QACzE,CAAC;IACH,CAAC;IAED,IAAI,SAAS;;QACX,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,MAAA,IAAI,CAAC,KAAK,0CAAE,SAAS,CAAA;QAC9B,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;QACzE,CAAC;IACH,CAAC;IAED,KAAK,CAAC,MAAM;;QACV,MAAM,QAAQ,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,OAAO;aAChC,OAAO,CAAC,uBAAU,CAAC,0CAClB,cAAc,CAAC,0BAA0B,EAC1C,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,EAC9B,OAAO,EAAE,CAAA,CAAA;QAEZ,wBAAwB;QACxB,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAC5B,kCAAkC,IAAI,CAAC,GAAG,SAAS,EACnD,QAAQ,CACT,CAAA;QACH,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,CAAC,MAAM,QAAS,CAAC,IAAI,EAA2B,CAAA,CAAC,IAAI,CAAA;IACpE,CAAC;CAEF;AAzDD,sCAyDC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"instaPost.js","sourceRoot":"","sources":["../../../../src/storages/insta/instaPost.ts"],"names":[],"mappings":";;;AAKA,MAAsB,SAAS;CAW9B;AAXD,8BAWC"}
|
package/package.json
CHANGED
package/src/dto/instaResponse.ts
CHANGED
@@ -16,7 +16,14 @@ export interface InstaCutAccountDto {
|
|
16
16
|
name: string
|
17
17
|
}
|
18
18
|
|
19
|
-
export interface
|
20
|
-
|
21
|
-
|
19
|
+
export interface InstaPostDto {
|
20
|
+
id: string
|
21
|
+
status: PostStatus
|
22
|
+
message: string
|
23
|
+
postsLeft: number
|
24
|
+
}
|
25
|
+
|
26
|
+
export enum PostStatus {
|
27
|
+
Generation = 0,
|
28
|
+
Finished = 1
|
22
29
|
}
|
@@ -33,7 +33,7 @@ export class InstaAccountImpl extends InstaAccount {
|
|
33
33
|
return (await response!.json() as { instaAccount: InstaAccountDto }).instaAccount
|
34
34
|
}
|
35
35
|
|
36
|
-
async update(name: string, additionalContext: string, folderId: string): Promise<InstaAccountDto> {
|
36
|
+
async update(name: string, additionalContext: string, folderId: string, token: string, proxy: string): Promise<InstaAccountDto> {
|
37
37
|
// send request to the server
|
38
38
|
const response = await this.context
|
39
39
|
.resolve(RpcService)
|
@@ -42,7 +42,9 @@ export class InstaAccountImpl extends InstaAccount {
|
|
42
42
|
instaId: this._id,
|
43
43
|
name: name,
|
44
44
|
additionalContext: additionalContext,
|
45
|
-
folderId: folderId
|
45
|
+
folderId: folderId,
|
46
|
+
token: token,
|
47
|
+
proxy: proxy
|
46
48
|
})
|
47
49
|
|
48
50
|
// check response status
|
@@ -10,7 +10,7 @@ export abstract class InstaAccount {
|
|
10
10
|
|
11
11
|
abstract data(): Promise<InstaAccountDto>
|
12
12
|
|
13
|
-
abstract update(name: string, additionalContext: string, folderId: string): Promise<InstaAccountDto>
|
13
|
+
abstract update(name: string, additionalContext: string, folderId: string, token: string, proxy: string): Promise<InstaAccountDto>
|
14
14
|
|
15
15
|
}
|
16
16
|
|
@@ -1,15 +1,27 @@
|
|
1
1
|
import {InstaAccounts} from "./instaAccounts"
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
InstaCutAccountDto,
|
4
|
+
InstaPostDto,
|
5
|
+
PostStatus,
|
6
|
+
} from "../../dto/instaResponse"
|
3
7
|
import {RpcService} from "../../services/rpcService"
|
4
8
|
import {ResponseUtils} from "../../services/responseUtils"
|
5
9
|
import {OrganizationImpl} from "../organizations/organization.impl"
|
6
10
|
import {Context} from "../../context"
|
7
11
|
import {InstaAccountImpl} from "./instaAccount.impl"
|
8
12
|
import {InstaAccount} from "./instaAccount"
|
13
|
+
import {InstaPostImpl} from "./instaPost.impl"
|
14
|
+
import {InstaPost} from "./instaPost"
|
9
15
|
|
10
16
|
|
11
17
|
export class InstaAccountsImpl extends InstaAccounts {
|
12
|
-
private
|
18
|
+
private _accounts?: InstaAccountImpl[]
|
19
|
+
private _posts?: InstaPostImpl[]
|
20
|
+
|
21
|
+
|
22
|
+
private _inProgress: InstaPostImpl[] = []
|
23
|
+
|
24
|
+
private _fetchTimeout?: NodeJS.Timeout
|
13
25
|
|
14
26
|
constructor(
|
15
27
|
public readonly organization: OrganizationImpl,
|
@@ -18,14 +30,36 @@ export class InstaAccountsImpl extends InstaAccounts {
|
|
18
30
|
}
|
19
31
|
|
20
32
|
|
21
|
-
get
|
22
|
-
if (this.
|
23
|
-
return this.
|
33
|
+
get accounts(): InstaAccount[] {
|
34
|
+
if (this._accounts !== undefined) {
|
35
|
+
return this._accounts
|
24
36
|
} else {
|
25
37
|
throw new Error("Insta accounts collection is not loaded, please update it first")
|
26
38
|
}
|
27
39
|
}
|
28
40
|
|
41
|
+
get posts(): InstaPost[] {
|
42
|
+
if (this._posts !== undefined) {
|
43
|
+
return this._posts
|
44
|
+
} else {
|
45
|
+
throw new Error("Insta posts collection is not loaded, please update it first")
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
async internalFetchPosts() {
|
50
|
+
for (const post of this._inProgress){
|
51
|
+
await post.update()
|
52
|
+
}
|
53
|
+
|
54
|
+
this._inProgress = this._inProgress.filter(post => post.status == PostStatus.Generation)
|
55
|
+
|
56
|
+
if (this._inProgress.length > 0) {
|
57
|
+
this._fetchTimeout = setTimeout(async () => await this.internalFetchPosts(), 2000)
|
58
|
+
} else {
|
59
|
+
clearTimeout(this._fetchTimeout)
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
29
63
|
|
30
64
|
async update(): Promise<void> {
|
31
65
|
const response = await this.context
|
@@ -43,11 +77,36 @@ export class InstaAccountsImpl extends InstaAccounts {
|
|
43
77
|
}
|
44
78
|
|
45
79
|
const accounts = (await response!.json() as {instaAccounts: InstaCutAccountDto[]}).instaAccounts
|
80
|
+
this._accounts = accounts.map(acc => new InstaAccountImpl(this.context, acc.id))
|
46
81
|
|
47
|
-
|
82
|
+
const postsResponse = await this.context
|
83
|
+
.resolve(RpcService)
|
84
|
+
?.requestBuilder("api/v1/Insta/post/list")
|
85
|
+
.searchParam("organizationId", this.organization.id)
|
86
|
+
.sendGet()
|
87
|
+
|
88
|
+
// check response status
|
89
|
+
if (ResponseUtils.isFail(postsResponse)) {
|
90
|
+
await ResponseUtils.throwError(
|
91
|
+
`Insta posts list for organization ${this.organization.id} failed`,
|
92
|
+
postsResponse
|
93
|
+
)
|
94
|
+
}
|
95
|
+
|
96
|
+
const posts = (await postsResponse!.json() as {posts: InstaPostDto[]}).posts
|
97
|
+
this._posts = posts.map(acc => new InstaPostImpl(this.context, acc.id))
|
98
|
+
|
99
|
+
this._inProgress = []
|
100
|
+
clearTimeout(this._fetchTimeout)
|
101
|
+
|
102
|
+
this._inProgress = this._posts.filter(post => post.status == PostStatus.Generation)
|
103
|
+
|
104
|
+
if (this._inProgress.length > 0) {
|
105
|
+
this._fetchTimeout = setTimeout(async () => await this.internalFetchPosts(), 2000)
|
106
|
+
}
|
48
107
|
}
|
49
108
|
|
50
|
-
async add(name: string, token: string, accountId: string, additionalContext: string, folderId: string): Promise<void> {
|
109
|
+
async add(name: string, token: string, accountId: string, proxy: string, additionalContext: string, folderId: string): Promise<void> {
|
51
110
|
if (name === undefined || name === null || name.trim() === "") {
|
52
111
|
throw new Error("Add insta account, name can not be null or empty")
|
53
112
|
}
|
@@ -57,6 +116,9 @@ export class InstaAccountsImpl extends InstaAccounts {
|
|
57
116
|
if (accountId === undefined || accountId === null || accountId.trim() === "") {
|
58
117
|
throw new Error("Add insta account, accountId can not be null or empty")
|
59
118
|
}
|
119
|
+
if (proxy === undefined || proxy === null || proxy.trim() === "") {
|
120
|
+
throw new Error("Add insta account, proxy can not be null or empty")
|
121
|
+
}
|
60
122
|
if (additionalContext === undefined || additionalContext === null) {
|
61
123
|
throw new Error("Add insta account, additionalContext can not be null")
|
62
124
|
}
|
@@ -73,6 +135,7 @@ export class InstaAccountsImpl extends InstaAccounts {
|
|
73
135
|
organizationId: this.organization.id,
|
74
136
|
token: token,
|
75
137
|
accountId: accountId,
|
138
|
+
proxy: proxy,
|
76
139
|
additionalContext: additionalContext,
|
77
140
|
folderId: folderId
|
78
141
|
})
|
@@ -88,7 +151,7 @@ export class InstaAccountsImpl extends InstaAccounts {
|
|
88
151
|
|
89
152
|
|
90
153
|
async delete(id: string): Promise<void> {
|
91
|
-
const account = this.
|
154
|
+
const account = this._accounts?.find(acc => acc.id === id)
|
92
155
|
|
93
156
|
// check if account is found
|
94
157
|
if (!account) {
|
@@ -113,7 +176,7 @@ export class InstaAccountsImpl extends InstaAccounts {
|
|
113
176
|
await this.update()
|
114
177
|
}
|
115
178
|
|
116
|
-
async post(message: string): Promise<
|
179
|
+
async post(message: string): Promise<void> {
|
117
180
|
if (message === undefined || message === null || message.trim() === "") {
|
118
181
|
throw new Error("Add insta post, message can not be null or empty")
|
119
182
|
}
|
@@ -133,7 +196,7 @@ export class InstaAccountsImpl extends InstaAccounts {
|
|
133
196
|
}
|
134
197
|
|
135
198
|
|
136
|
-
|
199
|
+
await this.update()
|
137
200
|
}
|
138
201
|
|
139
202
|
|
@@ -1,19 +1,20 @@
|
|
1
|
-
|
2
|
-
InstaPostResult
|
3
|
-
} from "../../dto/instaResponse"
|
1
|
+
|
4
2
|
import {InstaAccount} from "./instaAccount"
|
3
|
+
import {InstaPost} from "./instaPost"
|
5
4
|
|
6
5
|
|
7
6
|
export abstract class InstaAccounts {
|
8
7
|
|
9
|
-
abstract get
|
8
|
+
abstract get accounts(): InstaAccount[]
|
9
|
+
|
10
|
+
abstract get posts(): InstaPost[]
|
10
11
|
|
11
12
|
abstract update(): Promise<void>
|
12
13
|
|
13
|
-
abstract add(name: string, token: string, accountId: string, additionalContext: string, folderId: string): Promise<void>
|
14
|
+
abstract add(name: string, token: string, accountId: string, proxy: string, additionalContext: string, folderId: string): Promise<void>
|
14
15
|
|
15
16
|
abstract delete(id: string): Promise<void>
|
16
17
|
|
17
|
-
abstract post(message: string): Promise<
|
18
|
+
abstract post(message: string): Promise<void>
|
18
19
|
|
19
20
|
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import {InstaPost, InstaPostId} from "./instaPost"
|
2
|
+
import {Context} from "../../context"
|
3
|
+
import {
|
4
|
+
InstaPostDto,
|
5
|
+
PostStatus
|
6
|
+
} from "../../dto/instaResponse"
|
7
|
+
import {RpcService} from "../../services/rpcService"
|
8
|
+
import {ResponseUtils} from "../../services/responseUtils"
|
9
|
+
|
10
|
+
|
11
|
+
export class InstaPostImpl extends InstaPost {
|
12
|
+
private readonly _id: string
|
13
|
+
|
14
|
+
private _data?: InstaPostDto
|
15
|
+
|
16
|
+
constructor(private readonly context: Context, id: string) {
|
17
|
+
super()
|
18
|
+
|
19
|
+
this._id = id
|
20
|
+
}
|
21
|
+
|
22
|
+
get id(): InstaPostId {
|
23
|
+
return <InstaPostId>this._id
|
24
|
+
}
|
25
|
+
|
26
|
+
get message(): string {
|
27
|
+
if (this._data) {
|
28
|
+
return this._data?.message
|
29
|
+
} else {
|
30
|
+
throw new Error("Insta post data not loaded, please call update first")
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
get status(): PostStatus {
|
35
|
+
if (this._data) {
|
36
|
+
return this._data?.status
|
37
|
+
} else {
|
38
|
+
throw new Error("Insta post data not loaded, please call update first")
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
get postsLeft(): number {
|
43
|
+
if (this._data) {
|
44
|
+
return this._data?.postsLeft
|
45
|
+
} else {
|
46
|
+
throw new Error("Insta post data not loaded, please call update first")
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
async update(): Promise<void> {
|
51
|
+
const response = await this.context
|
52
|
+
.resolve(RpcService)
|
53
|
+
?.requestBuilder("api/v1/Insta/post/status")
|
54
|
+
.searchParam("postId", this._id)
|
55
|
+
.sendGet()
|
56
|
+
|
57
|
+
// check response status
|
58
|
+
if (ResponseUtils.isFail(response)) {
|
59
|
+
await ResponseUtils.throwError(
|
60
|
+
`Insta post status get for post ${this._id} failes`,
|
61
|
+
response
|
62
|
+
)
|
63
|
+
}
|
64
|
+
|
65
|
+
this._data = (await response!.json() as {post: InstaPostDto}).post
|
66
|
+
}
|
67
|
+
|
68
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import {PostStatus} from "../../dto/instaResponse"
|
2
|
+
|
3
|
+
|
4
|
+
export type InstaPostId = string;
|
5
|
+
|
6
|
+
export abstract class InstaPost {
|
7
|
+
|
8
|
+
abstract get id(): InstaPostId
|
9
|
+
|
10
|
+
abstract get message(): string
|
11
|
+
|
12
|
+
abstract get status(): PostStatus
|
13
|
+
|
14
|
+
abstract get postsLeft(): number
|
15
|
+
|
16
|
+
abstract update(): Promise<void>
|
17
|
+
}
|