@pulsar.money/atlas-sdk 0.4.5 → 0.4.7

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.
@@ -1,2 +1,3 @@
1
1
  export * from "./profiles";
2
2
  export * from "./payments";
3
+ export * from "./public-profiles";
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./profiles"), exports);
18
18
  __exportStar(require("./payments"), exports);
19
+ __exportStar(require("./public-profiles"), exports);
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,6CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,6CAA2B;AAC3B,oDAAkC"}
@@ -97,4 +97,18 @@ export interface Profile {
97
97
  followers: number;
98
98
  createdAt: Date;
99
99
  updatedAt: Date;
100
+ userAddresses: AddressUser[];
101
+ profileImage: string;
102
+ username: string;
103
+ }
104
+ export declare enum Chain {
105
+ MULTIVERSX = "multiversx",
106
+ ETHEREUM = "ethereum"
107
+ }
108
+ export interface AddressUser {
109
+ id: number;
110
+ address: string;
111
+ chainId: Chain;
112
+ userId: number;
113
+ emailVerified: boolean;
100
114
  }
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KYC_Status = void 0;
3
+ exports.Chain = exports.KYC_Status = void 0;
4
4
  var KYC_Status;
5
5
  (function (KYC_Status) {
6
6
  KYC_Status["PENDING"] = "PENDING";
7
7
  KYC_Status["APPROVED"] = "APPROVED";
8
8
  KYC_Status["REJECTED"] = "REJECTED";
9
9
  })(KYC_Status || (exports.KYC_Status = KYC_Status = {}));
10
+ var Chain;
11
+ (function (Chain) {
12
+ Chain["MULTIVERSX"] = "multiversx";
13
+ Chain["ETHEREUM"] = "ethereum";
14
+ })(Chain || (exports.Chain = Chain = {}));
10
15
  //# sourceMappingURL=profiles.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.types.js","sourceRoot":"","sources":["../../../src/modules/profiles/profiles.types.ts"],"names":[],"mappings":";;;AA6CA,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,iCAAmB,CAAA;IACnB,mCAAqB,CAAA;IACrB,mCAAqB,CAAA;AACvB,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB"}
1
+ {"version":3,"file":"profiles.types.js","sourceRoot":"","sources":["../../../src/modules/profiles/profiles.types.ts"],"names":[],"mappings":";;;AA6CA,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,iCAAmB,CAAA;IACnB,mCAAqB,CAAA;IACrB,mCAAqB,CAAA;AACvB,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB;AAmED,IAAY,KAGX;AAHD,WAAY,KAAK;IACf,kCAAyB,CAAA;IACzB,8BAAqB,CAAA;AACvB,CAAC,EAHW,KAAK,qBAAL,KAAK,QAGhB"}
@@ -0,0 +1,2 @@
1
+ export * from "./public-profile.service";
2
+ export * from "./public_profile.type";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./public-profile.service"), exports);
18
+ __exportStar(require("./public_profile.type"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/public-profiles/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,wDAAsC"}
@@ -0,0 +1,11 @@
1
+ import { CreateDonationInput, Thread } from "./public_profile.type";
2
+ import { Profile } from "../profiles";
3
+ export declare class PublicProfilesAtlasService {
4
+ private readonly axiosInstance;
5
+ constructor();
6
+ private createJwt;
7
+ private handleAxiosError;
8
+ donate(input: CreateDonationInput): Promise<Thread>;
9
+ getDonations(username: string): Promise<Thread[]>;
10
+ getPublicProfile(username: string): Promise<Profile>;
11
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PublicProfilesAtlasService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const axios_1 = require("axios");
15
+ const api_config_service_1 = require("../../config/api-config.service");
16
+ const jsonwebtoken_1 = require("jsonwebtoken");
17
+ let PublicProfilesAtlasService = class PublicProfilesAtlasService {
18
+ constructor() {
19
+ this.axiosInstance = axios_1.default.create({
20
+ baseURL: api_config_service_1.ApiConfigService.getAtlasBaseUrl(),
21
+ });
22
+ this.axiosInstance.interceptors.request.use((config) => {
23
+ const token = this.createJwt();
24
+ config.headers["Authorization"] = `Bearer ${token}`;
25
+ return config;
26
+ });
27
+ }
28
+ createJwt() {
29
+ const payload = {
30
+ exp: Math.floor(Date.now() / 1000) + 60,
31
+ };
32
+ return (0, jsonwebtoken_1.sign)(payload, api_config_service_1.ApiConfigService.getAtlasJwtSecret());
33
+ }
34
+ handleAxiosError(error) {
35
+ var _a, _b;
36
+ const errorMessage = ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) || "An error occurred";
37
+ throw new common_1.BadRequestException(errorMessage);
38
+ }
39
+ async donate(input) {
40
+ try {
41
+ const response = await this.axiosInstance.post(`/public-profiles/donate`, input);
42
+ return response.data;
43
+ }
44
+ catch (error) {
45
+ this.handleAxiosError(error);
46
+ }
47
+ }
48
+ async getDonations(username) {
49
+ try {
50
+ const response = await this.axiosInstance.get(`/public-profiles/threads/${username}`);
51
+ return response.data;
52
+ }
53
+ catch (error) {
54
+ this.handleAxiosError(error);
55
+ }
56
+ }
57
+ async getPublicProfile(username) {
58
+ try {
59
+ const response = await this.axiosInstance.get(`/public-profiles/${username}`);
60
+ return response.data;
61
+ }
62
+ catch (error) {
63
+ this.handleAxiosError(error);
64
+ }
65
+ }
66
+ };
67
+ exports.PublicProfilesAtlasService = PublicProfilesAtlasService;
68
+ exports.PublicProfilesAtlasService = PublicProfilesAtlasService = __decorate([
69
+ (0, common_1.Injectable)(),
70
+ __metadata("design:paramtypes", [])
71
+ ], PublicProfilesAtlasService);
72
+ //# sourceMappingURL=public-profile.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-profile.service.js","sourceRoot":"","sources":["../../../src/modules/public-profiles/public-profile.service.ts"],"names":[],"mappings":";;;;;;;;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M,KAAK,CAAC,YAAY,CAAC,QAAgB;QACxC,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAC3C,4BAA4B,QAAQ,EAAE,CACvC,CAAC;YACF,OAAO,QAAQ,CAAC,IAAI,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;SAC9B;IACH,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,QAAgB;QAC5C,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAC3C,oBAAoB,QAAQ,EAAE,CAC/B,CAAC;YACF,OAAO,QAAQ,CAAC,IAAI,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;SAC9B;IACH,CAAC;CACF,CAAA;AA5DY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAU,GAAE;;GACA,0BAA0B,CA4DtC"}
@@ -0,0 +1,65 @@
1
+ import { UserProfile } from "../profiles";
2
+ export declare enum PulsarPaymentType {
3
+ DONATION = "donation"
4
+ }
5
+ export interface TokenForm {
6
+ address: string;
7
+ symbol: string;
8
+ logoUrl?: string;
9
+ decimals: number;
10
+ }
11
+ export interface CreateDonationInput {
12
+ address: string;
13
+ receiverAddress: string;
14
+ txHash: string;
15
+ content: string;
16
+ imageUrl: string;
17
+ token: TokenForm;
18
+ amount: string;
19
+ amountUSD: string;
20
+ }
21
+ export interface PulsarPayment {
22
+ id: number;
23
+ createDate: Date;
24
+ updateDate: Date;
25
+ type: PulsarPaymentType;
26
+ txHash: string;
27
+ tokenAddress: string;
28
+ tokenSymbol: string;
29
+ tokenImage: string;
30
+ amount: string;
31
+ amountUSD: string;
32
+ decimals: number;
33
+ senderAddress: string;
34
+ receiverAddress: string;
35
+ }
36
+ export interface Thread {
37
+ id: number;
38
+ createDate: Date;
39
+ senderAddress: string;
40
+ receiverId: number;
41
+ Receiver: UserProfile;
42
+ content: string;
43
+ isPublic: boolean;
44
+ pulsarPaymentId: number;
45
+ imageUrl: string;
46
+ PulsarPayment: PulsarPayment;
47
+ senderName: string;
48
+ senderUsername: string;
49
+ senderImage: string;
50
+ receiverName: string;
51
+ receiverUsername: string;
52
+ receiverImage: string;
53
+ }
54
+ export interface Reply {
55
+ id: number;
56
+ threadId: number;
57
+ thread: Thread;
58
+ createDate: Date;
59
+ updateDate: Date;
60
+ userId: number;
61
+ replyId?: number;
62
+ reply?: Reply;
63
+ imageUrl: string;
64
+ content: string;
65
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PulsarPaymentType = void 0;
4
+ var PulsarPaymentType;
5
+ (function (PulsarPaymentType) {
6
+ PulsarPaymentType["DONATION"] = "donation";
7
+ })(PulsarPaymentType || (exports.PulsarPaymentType = PulsarPaymentType = {}));
8
+ //# sourceMappingURL=public_profile.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public_profile.type.js","sourceRoot":"","sources":["../../../src/modules/public-profiles/public_profile.type.ts"],"names":[],"mappings":";;;AAEA,IAAY,iBAEX;AAFD,WAAY,iBAAiB;IAC3B,0CAAqB,CAAA;AACvB,CAAC,EAFW,iBAAiB,iCAAjB,iBAAiB,QAE5B"}