@nx-ddd/x 0.0.0-PLACEHOLDER
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 +11 -0
- package/package.json +23 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +5 -0
- package/src/index.js.map +1 -0
- package/src/lib/converter.d.ts +4 -0
- package/src/lib/converter.js +31 -0
- package/src/lib/converter.js.map +1 -0
- package/src/lib/domain/models/index.d.ts +23 -0
- package/src/lib/domain/models/index.js +18 -0
- package/src/lib/domain/models/index.js.map +1 -0
- package/src/lib/domain/models/message-event.d.ts +19 -0
- package/src/lib/domain/models/message-event.js +31 -0
- package/src/lib/domain/models/message-event.js.map +1 -0
- package/src/lib/domain/models/token.d.ts +9 -0
- package/src/lib/domain/models/token.js +40 -0
- package/src/lib/domain/models/token.js.map +1 -0
- package/src/lib/index.d.ts +2 -0
- package/src/lib/index.js +6 -0
- package/src/lib/index.js.map +1 -0
- package/src/lib/x.config.d.ts +19 -0
- package/src/lib/x.config.js +6 -0
- package/src/lib/x.config.js.map +1 -0
- package/src/lib/x.service.d.ts +4 -0
- package/src/lib/x.service.impl.d.ts +59 -0
- package/src/lib/x.service.impl.js +265 -0
- package/src/lib/x.service.impl.js.map +1 -0
- package/src/lib/x.service.js +11 -0
- package/src/lib/x.service.js.map +1 -0
- package/src/lib/x.service.mock.d.ts +1 -0
- package/src/lib/x.service.mock.js +13 -0
- package/src/lib/x.service.mock.js.map +1 -0
- package/src/test-setup.d.ts +0 -0
- package/src/test-setup.js +1 -0
- package/src/test-setup.js.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @nx-ddd-x
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Running unit tests
|
|
6
|
+
|
|
7
|
+
Run `nx test @nx-ddd-x` to execute the unit tests via [Jest](https://jestjs.io).
|
|
8
|
+
|
|
9
|
+
## Running lint
|
|
10
|
+
|
|
11
|
+
Run `nx lint @nx-ddd-x` to execute the lint via [ESLint](https://eslint.org/).
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nx-ddd/x",
|
|
3
|
+
"version": "0.0.0-PLACEHOLDER",
|
|
4
|
+
"main": "./index.js",
|
|
5
|
+
"types": "./index.d.ts",
|
|
6
|
+
"homepage": "https://github.com/xx-machina/plaform/tree/main/packages/@nx-ddd/x",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/xx-machina/plaform.git"
|
|
10
|
+
},
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"@angular/core": "19.1.4",
|
|
13
|
+
"@nx-ddd/common": "0.0.0-PLACEHOLDER",
|
|
14
|
+
"@nx-ddd/core": "0.0.0-PLACEHOLDER",
|
|
15
|
+
"@nx-ddd/firestore": "0.0.0-PLACEHOLDER",
|
|
16
|
+
"class-validator": "^0.14.0",
|
|
17
|
+
"dayjs": "1.11.13",
|
|
18
|
+
"tslib": "^2.3.0",
|
|
19
|
+
"twitter-api-v2": "^1.14.2"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {},
|
|
22
|
+
"type": "commonjs"
|
|
23
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib';
|
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/x/src/index.ts"],"names":[],"mappings":";;;AAAA,gDAAsB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TweetConverter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@angular/core");
|
|
6
|
+
const models_1 = require("./domain/models");
|
|
7
|
+
let TweetConverter = class TweetConverter {
|
|
8
|
+
fromTwitterResponseData(data) {
|
|
9
|
+
var _a;
|
|
10
|
+
return ((_a = data.data) !== null && _a !== void 0 ? _a : []).map(tweet => {
|
|
11
|
+
const user = data.includes.users.find(user => user.id === tweet.author_id);
|
|
12
|
+
return models_1.Tweet.from({
|
|
13
|
+
id: tweet.id,
|
|
14
|
+
authorId: tweet.author_id,
|
|
15
|
+
author: {
|
|
16
|
+
id: tweet.author_id,
|
|
17
|
+
name: user.name,
|
|
18
|
+
username: user.username,
|
|
19
|
+
description: user.description,
|
|
20
|
+
},
|
|
21
|
+
text: tweet.text,
|
|
22
|
+
liked: tweet.public_metrics.like_count > 0,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.TweetConverter = TweetConverter;
|
|
28
|
+
exports.TweetConverter = TweetConverter = tslib_1.__decorate([
|
|
29
|
+
(0, core_1.Injectable)({ providedIn: 'root' })
|
|
30
|
+
], TweetConverter);
|
|
31
|
+
//# sourceMappingURL=converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/x/src/lib/converter.ts"],"names":[],"mappings":";;;;AAAA,wCAA2C;AAC3C,4CAAwC;AAGjC,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,uBAAuB,CAAC,IAAI;;QAC1B,OAAO,CAAC,MAAA,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YACnC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;YAC3E,OAAO,cAAK,CAAC,IAAI,CAAC;gBAChB,EAAE,EAAE,KAAK,CAAC,EAAE;gBACZ,QAAQ,EAAE,KAAK,CAAC,SAAS;gBACzB,MAAM,EAAE;oBACN,EAAE,EAAE,KAAK,CAAC,SAAS;oBACnB,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,WAAW,EAAE,IAAI,CAAC,WAAW;iBAC9B;gBACD,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,UAAU,GAAG,CAAC;aAC3C,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAlBY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,iBAAU,EAAC,EAAC,UAAU,EAAE,MAAM,EAAC,CAAC;GACpB,cAAc,CAkB1B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from './message-event';
|
|
2
|
+
export * from './token';
|
|
3
|
+
export interface Twitter {
|
|
4
|
+
id: string;
|
|
5
|
+
accessToken: string;
|
|
6
|
+
secret: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const nullTwitter: Twitter;
|
|
9
|
+
export declare class Tweet {
|
|
10
|
+
id: string;
|
|
11
|
+
authorId: string;
|
|
12
|
+
author?: TwitterUser;
|
|
13
|
+
text: string;
|
|
14
|
+
liked: boolean;
|
|
15
|
+
createdAt: any;
|
|
16
|
+
static from(obj: Partial<Tweet>): Tweet & Partial<Tweet>;
|
|
17
|
+
}
|
|
18
|
+
export interface TwitterUser {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
username: string;
|
|
22
|
+
description: string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tweet = exports.nullTwitter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./message-event"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./token"), exports);
|
|
7
|
+
exports.nullTwitter = {
|
|
8
|
+
id: null,
|
|
9
|
+
accessToken: null,
|
|
10
|
+
secret: null
|
|
11
|
+
};
|
|
12
|
+
class Tweet {
|
|
13
|
+
static from(obj) {
|
|
14
|
+
return Object.assign(new Tweet(), obj);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Tweet = Tweet;
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/@nx-ddd/x/src/lib/domain/models/index.ts"],"names":[],"mappings":";;;;AAAA,0DAAgC;AAChC,kDAAwB;AAQX,QAAA,WAAW,GAAY;IAClC,EAAE,EAAE,IAAI;IACR,WAAW,EAAE,IAAI;IACjB,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,MAAa,KAAK;IAQhB,MAAM,CAAC,IAAI,CAAC,GAAmB;QAC7B,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;CACF;AAXD,sBAWC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Entity } from "@nx-ddd/common/domain";
|
|
2
|
+
declare class User {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
username: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class MessageEvent extends Entity {
|
|
8
|
+
id: string;
|
|
9
|
+
communityId?: string;
|
|
10
|
+
sender?: User;
|
|
11
|
+
senderId: string;
|
|
12
|
+
eventType: 'MessageCreate';
|
|
13
|
+
dmConversationId: string;
|
|
14
|
+
text: string;
|
|
15
|
+
createdAt: Date;
|
|
16
|
+
updatedAt: Date;
|
|
17
|
+
static from(params: Partial<MessageEvent>): MessageEvent;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageEvent = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const domain_1 = require("@nx-ddd/common/domain");
|
|
6
|
+
const firestore_1 = require("@nx-ddd/firestore");
|
|
7
|
+
class User {
|
|
8
|
+
}
|
|
9
|
+
class MessageEvent extends domain_1.Entity {
|
|
10
|
+
static from(params) {
|
|
11
|
+
return Object.assign(new MessageEvent(), params);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.MessageEvent = MessageEvent;
|
|
15
|
+
tslib_1.__decorate([
|
|
16
|
+
firestore_1.Firestore.String(),
|
|
17
|
+
tslib_1.__metadata("design:type", String)
|
|
18
|
+
], MessageEvent.prototype, "senderId", void 0);
|
|
19
|
+
tslib_1.__decorate([
|
|
20
|
+
firestore_1.Firestore.String(),
|
|
21
|
+
tslib_1.__metadata("design:type", String)
|
|
22
|
+
], MessageEvent.prototype, "eventType", void 0);
|
|
23
|
+
tslib_1.__decorate([
|
|
24
|
+
firestore_1.Firestore.String(),
|
|
25
|
+
tslib_1.__metadata("design:type", String)
|
|
26
|
+
], MessageEvent.prototype, "dmConversationId", void 0);
|
|
27
|
+
tslib_1.__decorate([
|
|
28
|
+
firestore_1.Firestore.String(),
|
|
29
|
+
tslib_1.__metadata("design:type", String)
|
|
30
|
+
], MessageEvent.prototype, "text", void 0);
|
|
31
|
+
//# sourceMappingURL=message-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-event.js","sourceRoot":"","sources":["../../../../../../../../packages/@nx-ddd/x/src/lib/domain/models/message-event.ts"],"names":[],"mappings":";;;;AAAA,kDAA+C;AAC/C,iDAA8C;AAE9C,MAAM,IAAI;CAIT;AAED,MAAa,YAAa,SAAQ,eAAM;IAatC,MAAM,CAAC,IAAI,CAAC,MAA6B;QACvC,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,YAAY,EAAE,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;CACF;AAhBD,oCAgBC;AAXqB;IAAnB,qBAAS,CAAC,MAAM,EAAE;;8CAAkB;AACjB;IAAnB,qBAAS,CAAC,MAAM,EAAE;;+CAA4B;AAC3B;IAAnB,qBAAS,CAAC,MAAM,EAAE;;sDAA0B;AACzB;IAAnB,qBAAS,CAAC,MAAM,EAAE;;0CAAc"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
export declare class TwitterToken {
|
|
3
|
+
token_type: string;
|
|
4
|
+
access_token: string;
|
|
5
|
+
scope: string;
|
|
6
|
+
refresh_token: string;
|
|
7
|
+
expires_at: dayjs.Dayjs;
|
|
8
|
+
static validate(token?: Partial<TwitterToken>): import("class-validator").ValidationError[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TwitterToken = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@nx-ddd/core");
|
|
6
|
+
const firestore_1 = require("@nx-ddd/firestore");
|
|
7
|
+
const class_validator_1 = require("class-validator");
|
|
8
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
9
|
+
class TwitterToken {
|
|
10
|
+
static validate(token) {
|
|
11
|
+
return (0, class_validator_1.validateSync)(Object.assign(new TwitterToken(), token));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.TwitterToken = TwitterToken;
|
|
15
|
+
tslib_1.__decorate([
|
|
16
|
+
firestore_1.Firestore.String(),
|
|
17
|
+
(0, class_validator_1.IsString)(),
|
|
18
|
+
tslib_1.__metadata("design:type", String)
|
|
19
|
+
], TwitterToken.prototype, "token_type", void 0);
|
|
20
|
+
tslib_1.__decorate([
|
|
21
|
+
firestore_1.Firestore.String(),
|
|
22
|
+
(0, class_validator_1.IsString)(),
|
|
23
|
+
tslib_1.__metadata("design:type", String)
|
|
24
|
+
], TwitterToken.prototype, "access_token", void 0);
|
|
25
|
+
tslib_1.__decorate([
|
|
26
|
+
firestore_1.Firestore.String(),
|
|
27
|
+
(0, class_validator_1.IsString)(),
|
|
28
|
+
tslib_1.__metadata("design:type", String)
|
|
29
|
+
], TwitterToken.prototype, "scope", void 0);
|
|
30
|
+
tslib_1.__decorate([
|
|
31
|
+
firestore_1.Firestore.String(),
|
|
32
|
+
(0, class_validator_1.IsString)(),
|
|
33
|
+
tslib_1.__metadata("design:type", String)
|
|
34
|
+
], TwitterToken.prototype, "refresh_token", void 0);
|
|
35
|
+
tslib_1.__decorate([
|
|
36
|
+
firestore_1.Firestore.Timestamp(),
|
|
37
|
+
(0, core_1.IsDayjs)(),
|
|
38
|
+
tslib_1.__metadata("design:type", dayjs_1.default.Dayjs)
|
|
39
|
+
], TwitterToken.prototype, "expires_at", void 0);
|
|
40
|
+
//# sourceMappingURL=token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../../../../../../../packages/@nx-ddd/x/src/lib/domain/models/token.ts"],"names":[],"mappings":";;;;AAAA,uCAAuC;AACvC,iDAA8C;AAC9C,qDAAyD;AACzD,0DAA0B;AAE1B,MAAa,YAAY;IAOvB,MAAM,CAAC,QAAQ,CAAC,KAA6B;QAC3C,OAAO,IAAA,8BAAY,EAAC,MAAM,CAAC,MAAM,CAAC,IAAI,YAAY,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;IAChE,CAAC;CACF;AAVD,oCAUC;AATiC;IAA/B,qBAAS,CAAC,MAAM,EAAE;IAAE,IAAA,0BAAQ,GAAE;;gDAAoB;AACnB;IAA/B,qBAAS,CAAC,MAAM,EAAE;IAAE,IAAA,0BAAQ,GAAE;;kDAAsB;AACrB;IAA/B,qBAAS,CAAC,MAAM,EAAE;IAAE,IAAA,0BAAQ,GAAE;;2CAAe;AACd;IAA/B,qBAAS,CAAC,MAAM,EAAE;IAAE,IAAA,0BAAQ,GAAE;;mDAAuB;AACpB;IAAjC,qBAAS,CAAC,SAAS,EAAE;IAAE,IAAA,cAAO,GAAE;sCAAa,eAAK,CAAC,KAAK;gDAAC"}
|
package/src/lib/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/x/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,sDAA4B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { InjectionToken } from "@angular/core";
|
|
2
|
+
export interface XOauth2Config {
|
|
3
|
+
clientId: string;
|
|
4
|
+
clientSecret: string;
|
|
5
|
+
callback?: string;
|
|
6
|
+
scopes?: string[];
|
|
7
|
+
token: string;
|
|
8
|
+
}
|
|
9
|
+
export interface XOauthConfig {
|
|
10
|
+
consumerKey: string;
|
|
11
|
+
consumerSecret: string;
|
|
12
|
+
accessToken: string;
|
|
13
|
+
accessTokenSecret: string;
|
|
14
|
+
}
|
|
15
|
+
export interface XConfig {
|
|
16
|
+
oauth: XOauthConfig;
|
|
17
|
+
oauth2: XOauth2Config;
|
|
18
|
+
}
|
|
19
|
+
export declare const X_CONFIG: InjectionToken<XConfig>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x.config.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/x/src/lib/x.config.ts"],"names":[],"mappings":";;;AAAA,wCAA+C;AAsBlC,QAAA,QAAQ,GAAG,IAAI,qBAAc,CAAU,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { MessageEvent } from './domain/models/message-event';
|
|
2
|
+
import { TwitterToken } from './domain/models/token';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
import { XConfig } from './x.config';
|
|
5
|
+
import { ApiResponseError, TwitterApi } from 'twitter-api-v2';
|
|
6
|
+
import { TwitterUser } from './domain/models';
|
|
7
|
+
export declare class XServiceImpl {
|
|
8
|
+
private config;
|
|
9
|
+
isExpired(token: TwitterToken): boolean;
|
|
10
|
+
refreshToken(token: TwitterToken): Promise<TwitterToken>;
|
|
11
|
+
get consumerClient(): TwitterApi;
|
|
12
|
+
get consumerClientByCredentials(): TwitterApi;
|
|
13
|
+
get consumerClientById(): TwitterApi;
|
|
14
|
+
get consumerClientByToken(): TwitterApi;
|
|
15
|
+
getClientV2Next(token: TwitterToken): TwitterApi;
|
|
16
|
+
getClient(props: {
|
|
17
|
+
accessToken: string;
|
|
18
|
+
accessTokenSecret: string;
|
|
19
|
+
}): TwitterApi;
|
|
20
|
+
generateOAuth2AuthLink(client: TwitterApi): import("twitter-api-v2").IOAuth2RequestTokenResult;
|
|
21
|
+
loginWithOAuth2(client: TwitterApi, code: string, codeVerifier: string): Promise<any>;
|
|
22
|
+
getDirectMessageEventsList(client: TwitterApi, options: {
|
|
23
|
+
count?: number;
|
|
24
|
+
}): Promise<MessageEvent[]>;
|
|
25
|
+
getAccountVerifyCredentials(client?: TwitterApi): Promise<{
|
|
26
|
+
id: string;
|
|
27
|
+
}>;
|
|
28
|
+
getUser(client: TwitterApi, id: string): Promise<TwitterUser>;
|
|
29
|
+
getUsers(client: TwitterApi, ids: string[]): Promise<TwitterUser[]>;
|
|
30
|
+
sendDirectMessage(client: TwitterApi, recipientId: string, text: string): Promise<import("twitter-api-v2/dist/esm/types/v2/dm.v2.types").PostDMInConversationResult>;
|
|
31
|
+
sendReply(client: TwitterApi, tweetId: string, text: string): Promise<void>;
|
|
32
|
+
reply(client: TwitterApi, tweetId: string, text: string): Promise<void>;
|
|
33
|
+
searchTweets(client: TwitterApi, query: string, sinceId?: string): Promise<any>;
|
|
34
|
+
private convertTweet;
|
|
35
|
+
getTweets(client: TwitterApi, id: string): Promise<{
|
|
36
|
+
id: any;
|
|
37
|
+
text: any;
|
|
38
|
+
authorId: any;
|
|
39
|
+
author: {
|
|
40
|
+
id: any;
|
|
41
|
+
name: any;
|
|
42
|
+
username: any;
|
|
43
|
+
};
|
|
44
|
+
createdAt: dayjs.Dayjs;
|
|
45
|
+
}[]>;
|
|
46
|
+
searchPosts(client: TwitterApi, query: string, sinceId?: string): Promise<any>;
|
|
47
|
+
deletePost(tweetId: string): Promise<void>;
|
|
48
|
+
like(tweetId: string): Promise<void>;
|
|
49
|
+
isApiResponseError(error: any): error is ApiResponseError;
|
|
50
|
+
}
|
|
51
|
+
export declare function provideXConfig(config: XConfig): ({
|
|
52
|
+
provide: import("@angular/core").InjectionToken<XServiceImpl>;
|
|
53
|
+
useClass: typeof XServiceImpl;
|
|
54
|
+
useValue?: undefined;
|
|
55
|
+
} | {
|
|
56
|
+
provide: import("@angular/core").InjectionToken<XConfig>;
|
|
57
|
+
useValue: XConfig;
|
|
58
|
+
useClass?: undefined;
|
|
59
|
+
})[];
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XServiceImpl = void 0;
|
|
4
|
+
exports.provideXConfig = provideXConfig;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const core_1 = require("@angular/core");
|
|
7
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
8
|
+
const x_config_1 = require("./x.config");
|
|
9
|
+
const twitter_api_v2_1 = require("twitter-api-v2");
|
|
10
|
+
const x_service_1 = require("./x.service");
|
|
11
|
+
let XServiceImpl = class XServiceImpl {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.config = (0, core_1.inject)(x_config_1.X_CONFIG);
|
|
14
|
+
}
|
|
15
|
+
isExpired(token) {
|
|
16
|
+
console.debug('token.expires_at:', token.expires_at.toISOString());
|
|
17
|
+
console.debug('token.expires_at.add(-60, \'minutes\'):', token.expires_at.add(-60, 'minutes').toISOString());
|
|
18
|
+
console.debug('dayjs():', (0, dayjs_1.default)().toISOString());
|
|
19
|
+
return (0, dayjs_1.default)().isAfter(token.expires_at.add(-30, 'minutes'));
|
|
20
|
+
}
|
|
21
|
+
refreshToken(token) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const client = this.consumerClientById;
|
|
24
|
+
console.debug('refreshToken:', token.refresh_token);
|
|
25
|
+
const data = yield client.refreshOAuth2Token(token.refresh_token);
|
|
26
|
+
return {
|
|
27
|
+
token_type: 'bearer',
|
|
28
|
+
access_token: data.accessToken,
|
|
29
|
+
scope: data.scope.join(' '),
|
|
30
|
+
refresh_token: data.refreshToken,
|
|
31
|
+
expires_at: (0, dayjs_1.default)().add(data.expiresIn, 'seconds'),
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
get consumerClient() {
|
|
36
|
+
// return this.consumerClientByCredentials;
|
|
37
|
+
return this.consumerClientByToken;
|
|
38
|
+
}
|
|
39
|
+
get consumerClientByCredentials() {
|
|
40
|
+
return new twitter_api_v2_1.TwitterApi({
|
|
41
|
+
appKey: this.config.oauth.consumerKey,
|
|
42
|
+
appSecret: this.config.oauth.consumerSecret,
|
|
43
|
+
accessToken: this.config.oauth.accessToken,
|
|
44
|
+
accessSecret: this.config.oauth.accessTokenSecret,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
get consumerClientById() {
|
|
48
|
+
return new twitter_api_v2_1.TwitterApi({
|
|
49
|
+
clientId: this.config.oauth2.clientId,
|
|
50
|
+
clientSecret: this.config.oauth2.clientSecret,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
get consumerClientByToken() {
|
|
54
|
+
return new twitter_api_v2_1.TwitterApi(this.config.oauth2.token);
|
|
55
|
+
}
|
|
56
|
+
getClientV2Next(token) {
|
|
57
|
+
return new twitter_api_v2_1.TwitterApi(token.access_token);
|
|
58
|
+
}
|
|
59
|
+
getClient(props) {
|
|
60
|
+
return new twitter_api_v2_1.TwitterApi({
|
|
61
|
+
appKey: this.config.oauth.consumerKey,
|
|
62
|
+
appSecret: this.config.oauth.consumerSecret,
|
|
63
|
+
accessToken: props.accessToken,
|
|
64
|
+
accessSecret: props.accessTokenSecret,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
generateOAuth2AuthLink(client) {
|
|
68
|
+
return client.generateOAuth2AuthLink(this.config.oauth2.callback, {
|
|
69
|
+
state: 'test',
|
|
70
|
+
scope: ['offline.access', 'dm.read', 'tweet.write', 'users.read', 'dm.write', 'tweet.read'],
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
loginWithOAuth2(client, code, codeVerifier) {
|
|
74
|
+
return client.loginWithOAuth2({
|
|
75
|
+
code,
|
|
76
|
+
codeVerifier,
|
|
77
|
+
redirectUri: this.config.oauth2.callback,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
getDirectMessageEventsList(client, options) {
|
|
81
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
try {
|
|
83
|
+
const events = yield client.v2.listDmEvents({
|
|
84
|
+
'dm_event.fields': [
|
|
85
|
+
'attachments', 'created_at', 'dm_conversation_id',
|
|
86
|
+
'event_type', 'id', 'participant_ids',
|
|
87
|
+
'referenced_tweets', 'sender_id', 'text',
|
|
88
|
+
],
|
|
89
|
+
expansions: ['sender_id', 'participant_ids'],
|
|
90
|
+
event_types: ['MessageCreate'],
|
|
91
|
+
max_results: options.count,
|
|
92
|
+
'user.fields': [
|
|
93
|
+
'created_at', 'description', 'entities', 'id', 'location', 'name',
|
|
94
|
+
'pinned_tweet_id', 'profile_image_url', 'protected', 'public_metrics',
|
|
95
|
+
'url', 'username', 'verified', 'verified_type', 'withheld'
|
|
96
|
+
],
|
|
97
|
+
});
|
|
98
|
+
return events.data.data.map(data => ({
|
|
99
|
+
id: data.id,
|
|
100
|
+
senderId: data.sender_id,
|
|
101
|
+
eventType: 'MessageCreate',
|
|
102
|
+
dmConversationId: data.dm_conversation_id,
|
|
103
|
+
text: data.text,
|
|
104
|
+
createdAt: (0, dayjs_1.default)(data.created_at),
|
|
105
|
+
updatedAt: null,
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
console.error(error);
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
getAccountVerifyCredentials() {
|
|
115
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (client = this.consumerClient) {
|
|
116
|
+
const data = yield client.v2.me();
|
|
117
|
+
return { id: data.data.id };
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
// async getUserShow(options: {user_id?: string}): Promise<Twitter.UserShow> {
|
|
121
|
+
// // const {data} = await this.client.get('users/show', options) as any;
|
|
122
|
+
// // return camelize(data);
|
|
123
|
+
// return null;
|
|
124
|
+
// }
|
|
125
|
+
getUser() {
|
|
126
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (client = this.consumerClient, id) {
|
|
127
|
+
try {
|
|
128
|
+
const { data } = yield client.v2.user(id, {
|
|
129
|
+
'user.fields': [
|
|
130
|
+
'created_at', 'description', 'entities', 'id', 'location',
|
|
131
|
+
'name', 'pinned_tweet_id', 'profile_image_url', 'protected',
|
|
132
|
+
'public_metrics', 'url', 'username', 'verified', 'verified_type', 'withheld'
|
|
133
|
+
],
|
|
134
|
+
});
|
|
135
|
+
return data;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
console.error('error:', error);
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
getUsers() {
|
|
144
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (client = this.consumerClient, ids) {
|
|
145
|
+
try {
|
|
146
|
+
const { data } = yield client.v2.users(ids, {
|
|
147
|
+
'user.fields': [
|
|
148
|
+
'created_at',
|
|
149
|
+
'description',
|
|
150
|
+
'entities',
|
|
151
|
+
'id',
|
|
152
|
+
'location',
|
|
153
|
+
'name',
|
|
154
|
+
'pinned_tweet_id',
|
|
155
|
+
'profile_image_url',
|
|
156
|
+
'protected',
|
|
157
|
+
'public_metrics',
|
|
158
|
+
'url',
|
|
159
|
+
'username',
|
|
160
|
+
],
|
|
161
|
+
});
|
|
162
|
+
return data;
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
console.error(err);
|
|
166
|
+
throw err;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
sendDirectMessage() {
|
|
171
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (client = this.consumerClient, recipientId, text) {
|
|
172
|
+
return client.v2.sendDmToParticipant(recipientId, { text });
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
sendReply() {
|
|
176
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (client = this.consumerClient, tweetId, text) {
|
|
177
|
+
return this.reply(client, tweetId, text);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
reply() {
|
|
181
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (client = this.consumerClient, tweetId, text) {
|
|
182
|
+
try {
|
|
183
|
+
yield client.v2.reply(text, tweetId);
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
console.error('sendReply Error');
|
|
187
|
+
console.error('error:', error);
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
searchTweets() {
|
|
193
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (client = this.consumerClient, query, sinceId) {
|
|
194
|
+
return this.searchPosts(client, query, sinceId);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
convertTweet(tweet, includes) {
|
|
198
|
+
const author = includes.users.find(user => user.id === tweet.author_id);
|
|
199
|
+
return {
|
|
200
|
+
id: tweet.id,
|
|
201
|
+
text: tweet.text,
|
|
202
|
+
authorId: tweet.author_id,
|
|
203
|
+
author: {
|
|
204
|
+
id: author.id,
|
|
205
|
+
name: author.name,
|
|
206
|
+
username: author.username,
|
|
207
|
+
},
|
|
208
|
+
createdAt: (0, dayjs_1.default)(tweet.created_at),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
getTweets() {
|
|
212
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (client = this.consumerClient, id) {
|
|
213
|
+
return client.v2.tweets(id, {
|
|
214
|
+
"tweet.fields": ["created_at", "lang", "conversation_id", 'author_id'],
|
|
215
|
+
'user.fields': ['id', 'name', 'username'],
|
|
216
|
+
expansions: ['author_id'],
|
|
217
|
+
}).then(res => res.data.map((tweet) => this.convertTweet(tweet, res.includes)));
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
searchPosts() {
|
|
221
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (client = this.consumerClient, query, sinceId) {
|
|
222
|
+
var _a, _b;
|
|
223
|
+
try {
|
|
224
|
+
const res = yield client.v2.search({
|
|
225
|
+
query,
|
|
226
|
+
since_id: sinceId,
|
|
227
|
+
"tweet.fields": ["created_at", "lang", "conversation_id", 'author_id'],
|
|
228
|
+
'user.fields': ['id', 'name', 'username'],
|
|
229
|
+
expansions: ['author_id'],
|
|
230
|
+
});
|
|
231
|
+
if (!((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.data))
|
|
232
|
+
return [];
|
|
233
|
+
return (_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.data.map((tweet) => this.convertTweet(tweet, res.includes));
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
console.error(error);
|
|
237
|
+
throw error;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
deletePost(tweetId) {
|
|
242
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
243
|
+
throw new Error('Method not implemented.');
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
like(tweetId) {
|
|
247
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
248
|
+
throw new Error('Method not implemented.');
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
isApiResponseError(error) {
|
|
252
|
+
return error instanceof twitter_api_v2_1.ApiResponseError;
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
exports.XServiceImpl = XServiceImpl;
|
|
256
|
+
exports.XServiceImpl = XServiceImpl = tslib_1.__decorate([
|
|
257
|
+
(0, core_1.Injectable)()
|
|
258
|
+
], XServiceImpl);
|
|
259
|
+
function provideXConfig(config) {
|
|
260
|
+
return [
|
|
261
|
+
{ provide: x_service_1.X_SERVICE, useClass: XServiceImpl },
|
|
262
|
+
{ provide: x_config_1.X_CONFIG, useValue: config },
|
|
263
|
+
];
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=x.service.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x.service.impl.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/x/src/lib/x.service.impl.ts"],"names":[],"mappings":";;;AA0PA,wCAKC;;AA/PD,wCAAmD;AAGnD,0DAA0B;AAC1B,yCAA+C;AAC/C,mDAA8D;AAE9D,2CAAwC;AAGjC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAAlB;QACG,WAAM,GAAG,IAAA,aAAM,EAAC,mBAAQ,CAAC,CAAC;IA6OpC,CAAC;IA3OC,SAAS,CAAC,KAAmB;QAC3B,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;QACnE,OAAO,CAAC,KAAK,CAAC,yCAAyC,EAAE,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QAC7G,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,IAAA,eAAK,GAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QACjD,OAAO,IAAA,eAAK,GAAE,CAAC,OAAO,CAA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,CAAC,CAAC,CAAC;YAChF,CAAC;YAAC,OAAM,KAAK,EAAE,CAAC;gBACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACrB,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;KAAA;IAEK,UAAU,CAAC,OAAe;;YAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;KAAA;IAEK,IAAI,CAAC,OAAe;;YACxB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;KAAA;IAED,kBAAkB,CAAC,KAAU;QAC3B,OAAO,KAAK,YAAY,iCAAgB,CAAC;IAC3C,CAAC;CACF,CAAA;AA9OY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,iBAAU,GAAE;GACA,YAAY,CA8OxB;AAED,SAAgB,cAAc,CAAC,MAAe;IAC5C,OAAO;QACL,EAAE,OAAO,EAAE,qBAAS,EAAE,QAAQ,EAAE,YAAY,EAAE;QAC9C,EAAE,OAAO,EAAE,mBAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE;KACxC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.X_SERVICE = void 0;
|
|
4
|
+
exports.injectXService = injectXService;
|
|
5
|
+
const core_1 = require("@angular/core");
|
|
6
|
+
exports.X_SERVICE = new core_1.InjectionToken('[@nx-ddd/x] X Service');
|
|
7
|
+
function injectXService() {
|
|
8
|
+
var _a;
|
|
9
|
+
return (_a = (0, core_1.inject)(exports.X_SERVICE, { optional: true })) !== null && _a !== void 0 ? _a : {};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=x.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x.service.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/x/src/lib/x.service.ts"],"names":[],"mappings":";;;AAIA,wCAEC;AAND,wCAAuD;AAG1C,QAAA,SAAS,GAAG,IAAI,qBAAc,CAAe,uBAAuB,CAAC,CAAC;AACnF,SAAgB,cAAc;;IAC5B,OAAO,MAAA,IAAA,aAAM,EAAC,iBAAS,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,mCAAI,EAAkB,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// import type { XServiceImpl } from "./x.service.impl";
|
|
4
|
+
// @Injectable()
|
|
5
|
+
// export class MockXService extends XServiceImpl {
|
|
6
|
+
// async reply(client: TwitterApi, tweetId: string, text: string): Promise<void> {
|
|
7
|
+
// console.log('MockXService.reply() is called!');
|
|
8
|
+
// }
|
|
9
|
+
// async sendDirectMessage(client: TwitterApi, recipientId: string, text: string): Promise<any> {
|
|
10
|
+
// console.log('MockXService.sendDirectMessage() is called!');
|
|
11
|
+
// }
|
|
12
|
+
// }
|
|
13
|
+
//# sourceMappingURL=x.service.mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x.service.mock.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/x/src/lib/x.service.mock.ts"],"names":[],"mappings":";;AAEA,wDAAwD;AAExD,gBAAgB;AAChB,mDAAmD;AACnD,oFAAoF;AACpF,sDAAsD;AACtD,MAAM;AAEN,mGAAmG;AACnG,kEAAkE;AAClE,MAAM;AACN,IAAI"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=test-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-setup.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/x/src/test-setup.ts"],"names":[],"mappings":""}
|