@mtcute/core 0.23.2 → 0.23.3
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/client.cjs +12 -0
- package/client.js +12 -0
- package/highlevel/client.d.cts +44 -5
- package/highlevel/client.d.ts +44 -5
- package/highlevel/methods/chats/get-chat-event-log.cjs +5 -3
- package/highlevel/methods/chats/get-chat-event-log.js +3 -1
- package/highlevel/methods/premium/_normalize-input-star-gift.cjs +6 -0
- package/highlevel/methods/premium/_normalize-input-star-gift.js +6 -0
- package/highlevel/methods/premium/buy-resale-gift.cjs +30 -0
- package/highlevel/methods/premium/buy-resale-gift.d.cts +13 -0
- package/highlevel/methods/premium/buy-resale-gift.d.ts +13 -0
- package/highlevel/methods/premium/buy-resale-gift.js +25 -0
- package/highlevel/methods/premium/get-resale-star-gifts.cjs +107 -0
- package/highlevel/methods/premium/get-resale-star-gifts.d.cts +45 -0
- package/highlevel/methods/premium/get-resale-star-gifts.d.ts +45 -0
- package/highlevel/methods/premium/get-resale-star-gifts.js +102 -0
- package/highlevel/methods/premium/get-unique-star-gift.cjs +1 -1
- package/highlevel/methods/premium/get-unique-star-gift.js +1 -1
- package/highlevel/methods/premium/set-gift-resale-price.cjs +19 -0
- package/highlevel/methods/premium/set-gift-resale-price.d.cts +9 -0
- package/highlevel/methods/premium/set-gift-resale-price.d.ts +9 -0
- package/highlevel/methods/premium/set-gift-resale-price.js +14 -0
- package/highlevel/methods/premium/transfer-star-gift.cjs +26 -11
- package/highlevel/methods/premium/transfer-star-gift.js +26 -11
- package/highlevel/methods/premium/upgrade-star-gift.cjs +26 -11
- package/highlevel/methods/premium/upgrade-star-gift.js +26 -11
- package/highlevel/methods.d.cts +4 -0
- package/highlevel/methods.d.ts +4 -0
- package/highlevel/types/messages/message-action.cjs +8 -2
- package/highlevel/types/messages/message-action.d.cts +6 -0
- package/highlevel/types/messages/message-action.d.ts +6 -0
- package/highlevel/types/messages/message-action.js +8 -2
- package/highlevel/types/peers/chat-event/actions.cjs +49 -1
- package/highlevel/types/peers/chat-event/actions.d.cts +60 -2
- package/highlevel/types/peers/chat-event/actions.d.ts +60 -2
- package/highlevel/types/peers/chat-event/actions.js +49 -1
- package/highlevel/types/peers/chat-event/filters.cjs +9 -0
- package/highlevel/types/peers/chat-event/filters.js +9 -0
- package/highlevel/types/peers/chat-event/index.cjs +3 -2
- package/highlevel/types/peers/chat-event/index.d.cts +2 -1
- package/highlevel/types/peers/chat-event/index.d.ts +2 -1
- package/highlevel/types/peers/chat-event/index.js +3 -2
- package/highlevel/types/peers/chat.cjs +5 -4
- package/highlevel/types/peers/chat.d.cts +2 -0
- package/highlevel/types/peers/chat.d.ts +2 -0
- package/highlevel/types/peers/chat.js +5 -4
- package/highlevel/types/peers/user.cjs +1 -4
- package/highlevel/types/peers/user.js +1 -4
- package/highlevel/types/premium/saved-star-gift.cjs +8 -0
- package/highlevel/types/premium/saved-star-gift.d.cts +4 -0
- package/highlevel/types/premium/saved-star-gift.d.ts +4 -0
- package/highlevel/types/premium/saved-star-gift.js +8 -0
- package/highlevel/types/premium/stars-gift-unique.cjs +11 -1
- package/highlevel/types/premium/stars-gift-unique.d.cts +4 -0
- package/highlevel/types/premium/stars-gift-unique.d.ts +4 -0
- package/highlevel/types/premium/stars-gift-unique.js +11 -1
- package/highlevel/types/premium/stars-gift.cjs +11 -1
- package/highlevel/types/premium/stars-gift.d.cts +8 -1
- package/highlevel/types/premium/stars-gift.d.ts +8 -1
- package/highlevel/types/premium/stars-gift.js +11 -1
- package/highlevel/types/premium/stars-transaction.cjs +6 -0
- package/highlevel/types/premium/stars-transaction.d.cts +7 -0
- package/highlevel/types/premium/stars-transaction.d.ts +7 -0
- package/highlevel/types/premium/stars-transaction.js +6 -0
- package/highlevel/types/reactions/emoji-status.cjs +6 -0
- package/highlevel/types/reactions/emoji-status.d.cts +1 -0
- package/highlevel/types/reactions/emoji-status.d.ts +1 -0
- package/highlevel/types/reactions/emoji-status.js +6 -0
- package/highlevel/types/utils.d.cts +4 -0
- package/highlevel/types/utils.d.ts +4 -0
- package/highlevel/utils/misc-utils.cjs +8 -0
- package/highlevel/utils/misc-utils.d.cts +2 -1
- package/highlevel/utils/misc-utils.d.ts +2 -1
- package/highlevel/utils/misc-utils.js +8 -0
- package/methods.cjs +6 -0
- package/methods.js +6 -0
- package/network/network-manager.cjs +1 -1
- package/network/network-manager.js +1 -1
- package/package.json +2 -2
- package/utils/binary/compat.cjs +9 -0
- package/utils/binary/compat.js +9 -0
- package/utils.cjs +1 -0
- package/utils.js +2 -1
|
@@ -29,6 +29,10 @@ class StarGiftUniqueBackdrop {
|
|
|
29
29
|
constructor(raw) {
|
|
30
30
|
this.raw = raw;
|
|
31
31
|
}
|
|
32
|
+
/** ID of the backdrop */
|
|
33
|
+
get id() {
|
|
34
|
+
return this.raw.backdropId;
|
|
35
|
+
}
|
|
32
36
|
/** Rarity permille of the attribute */
|
|
33
37
|
get permille() {
|
|
34
38
|
return this.raw.rarityPermille;
|
|
@@ -93,6 +97,7 @@ class StarGiftUniqueOriginalDetails {
|
|
|
93
97
|
return this.raw.message ?? null;
|
|
94
98
|
}
|
|
95
99
|
}
|
|
100
|
+
const StarGiftUniqueOriginalDetails$1 = /* @__PURE__ */ makeInspectable(StarGiftUniqueOriginalDetails);
|
|
96
101
|
class StarGiftUnique {
|
|
97
102
|
constructor(raw, _peers) {
|
|
98
103
|
this.raw = raw;
|
|
@@ -148,12 +153,17 @@ class StarGiftUnique {
|
|
|
148
153
|
get ownerName() {
|
|
149
154
|
return this.raw.ownerName ?? null;
|
|
150
155
|
}
|
|
156
|
+
// todo: merge into one property
|
|
151
157
|
get availabilityIssued() {
|
|
152
158
|
return this.raw.availabilityIssued;
|
|
153
159
|
}
|
|
154
160
|
get availabilityTotal() {
|
|
155
161
|
return this.raw.availabilityTotal;
|
|
156
162
|
}
|
|
163
|
+
/** Number of stars this gift is up for resell for */
|
|
164
|
+
get resellPrice() {
|
|
165
|
+
return this.raw.resellStars ?? null;
|
|
166
|
+
}
|
|
157
167
|
/** Model (i.e. the gift itself) of the unique star gift */
|
|
158
168
|
get model() {
|
|
159
169
|
return new StarGiftUniqueAttribute(this._model);
|
|
@@ -186,5 +196,5 @@ export {
|
|
|
186
196
|
StarGiftUnique$2 as StarGiftUnique,
|
|
187
197
|
StarGiftUniqueAttribute$2 as StarGiftUniqueAttribute,
|
|
188
198
|
StarGiftUniqueBackdrop$1 as StarGiftUniqueBackdrop,
|
|
189
|
-
StarGiftUniqueOriginalDetails
|
|
199
|
+
StarGiftUniqueOriginalDetails$1 as StarGiftUniqueOriginalDetails
|
|
190
200
|
};
|
|
@@ -5,6 +5,7 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
|
|
|
5
5
|
}
|
|
6
6
|
"use strict";
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
+
const Long = require("long");
|
|
8
9
|
const errors = require("../../../types/errors.cjs");
|
|
9
10
|
const typeAssertions = require("../../../utils/type-assertions.cjs");
|
|
10
11
|
const inspectable = require("../../utils/inspectable.cjs");
|
|
@@ -73,9 +74,18 @@ class StarGift {
|
|
|
73
74
|
}
|
|
74
75
|
return {
|
|
75
76
|
remains: this.raw.availabilityRemains,
|
|
76
|
-
total: this.raw.availabilityTotal
|
|
77
|
+
total: this.raw.availabilityTotal,
|
|
78
|
+
resale: this.raw.availabilityResale ?? Long.ZERO
|
|
77
79
|
};
|
|
78
80
|
}
|
|
81
|
+
/** Floor price for the gift on the secondary market */
|
|
82
|
+
get resaleFloorPrice() {
|
|
83
|
+
return this.raw.resellMinStars ?? null;
|
|
84
|
+
}
|
|
85
|
+
/** Title of the gift */
|
|
86
|
+
get title() {
|
|
87
|
+
return this.raw.title ?? null;
|
|
88
|
+
}
|
|
79
89
|
}
|
|
80
90
|
const StarGift$1 = /* @__PURE__ */ inspectable.makeInspectable(StarGift);
|
|
81
91
|
const StarGift$2 = /* @__PURE__ */ memoize.memoizeGetters(StarGift$1, ["sticker"]);
|
|
@@ -2,6 +2,7 @@ import { tl } from '@mtcute/tl';
|
|
|
2
2
|
import { Sticker } from '../media/sticker.js';
|
|
3
3
|
import { Message } from '../messages/message.js';
|
|
4
4
|
import { InputPeerLike } from '../peers/peer.js';
|
|
5
|
+
import { default as Long } from 'long';
|
|
5
6
|
export type InputStarGift = {
|
|
6
7
|
/** ID of the message containing the gift */
|
|
7
8
|
message: number | Message;
|
|
@@ -10,7 +11,7 @@ export type InputStarGift = {
|
|
|
10
11
|
owner: InputPeerLike;
|
|
11
12
|
/** ID of the gift */
|
|
12
13
|
savedId: tl.Long;
|
|
13
|
-
};
|
|
14
|
+
} | string;
|
|
14
15
|
/**
|
|
15
16
|
* A gift bought with stars
|
|
16
17
|
*/
|
|
@@ -51,5 +52,11 @@ export declare class StarGift {
|
|
|
51
52
|
get availability(): {
|
|
52
53
|
remains: number;
|
|
53
54
|
total: number;
|
|
55
|
+
/** Number of gifts available on the secondary market */
|
|
56
|
+
resale: Long;
|
|
54
57
|
} | null;
|
|
58
|
+
/** Floor price for the gift on the secondary market */
|
|
59
|
+
get resaleFloorPrice(): tl.Long | null;
|
|
60
|
+
/** Title of the gift */
|
|
61
|
+
get title(): string | null;
|
|
55
62
|
}
|
|
@@ -2,6 +2,7 @@ import { tl } from '@mtcute/tl';
|
|
|
2
2
|
import { Sticker } from '../media/sticker.js';
|
|
3
3
|
import { Message } from '../messages/message.js';
|
|
4
4
|
import { InputPeerLike } from '../peers/peer.js';
|
|
5
|
+
import { default as Long } from 'long';
|
|
5
6
|
export type InputStarGift = {
|
|
6
7
|
/** ID of the message containing the gift */
|
|
7
8
|
message: number | Message;
|
|
@@ -10,7 +11,7 @@ export type InputStarGift = {
|
|
|
10
11
|
owner: InputPeerLike;
|
|
11
12
|
/** ID of the gift */
|
|
12
13
|
savedId: tl.Long;
|
|
13
|
-
};
|
|
14
|
+
} | string;
|
|
14
15
|
/**
|
|
15
16
|
* A gift bought with stars
|
|
16
17
|
*/
|
|
@@ -51,5 +52,11 @@ export declare class StarGift {
|
|
|
51
52
|
get availability(): {
|
|
52
53
|
remains: number;
|
|
53
54
|
total: number;
|
|
55
|
+
/** Number of gifts available on the secondary market */
|
|
56
|
+
resale: Long;
|
|
54
57
|
} | null;
|
|
58
|
+
/** Floor price for the gift on the secondary market */
|
|
59
|
+
get resaleFloorPrice(): tl.Long | null;
|
|
60
|
+
/** Title of the gift */
|
|
61
|
+
get title(): string | null;
|
|
55
62
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Long from "long";
|
|
1
2
|
import { MtTypeAssertionError } from "../../../types/errors.js";
|
|
2
3
|
import { assertTypeIs } from "../../../utils/type-assertions.js";
|
|
3
4
|
import { makeInspectable } from "../../utils/inspectable.js";
|
|
@@ -66,9 +67,18 @@ class StarGift {
|
|
|
66
67
|
}
|
|
67
68
|
return {
|
|
68
69
|
remains: this.raw.availabilityRemains,
|
|
69
|
-
total: this.raw.availabilityTotal
|
|
70
|
+
total: this.raw.availabilityTotal,
|
|
71
|
+
resale: this.raw.availabilityResale ?? Long.ZERO
|
|
70
72
|
};
|
|
71
73
|
}
|
|
74
|
+
/** Floor price for the gift on the secondary market */
|
|
75
|
+
get resaleFloorPrice() {
|
|
76
|
+
return this.raw.resellMinStars ?? null;
|
|
77
|
+
}
|
|
78
|
+
/** Title of the gift */
|
|
79
|
+
get title() {
|
|
80
|
+
return this.raw.title ?? null;
|
|
81
|
+
}
|
|
72
82
|
}
|
|
73
83
|
const StarGift$1 = /* @__PURE__ */ makeInspectable(StarGift);
|
|
74
84
|
const StarGift$2 = /* @__PURE__ */ memoizeGetters(StarGift$1, ["sticker"]);
|
|
@@ -123,6 +123,12 @@ class StarsTransaction {
|
|
|
123
123
|
peer: peer$1,
|
|
124
124
|
gift: new starsGiftUnique.StarGiftUnique(this.raw.stargift, this.peers)
|
|
125
125
|
};
|
|
126
|
+
} else if (this.raw.stargiftResale) {
|
|
127
|
+
return {
|
|
128
|
+
type: "star_gift_resale",
|
|
129
|
+
peer: peer$1,
|
|
130
|
+
gift: new starsGiftUnique.StarGiftUnique(this.raw.stargift, this.peers)
|
|
131
|
+
};
|
|
126
132
|
} else {
|
|
127
133
|
return {
|
|
128
134
|
type: "star_gift_transfer",
|
|
@@ -21,6 +21,7 @@ import { StarGift } from './stars-gift.js';
|
|
|
21
21
|
* - `star_gift`: This transaction is either a star gift to a user (if outgoing), or converting a star gift to stars (if incoming)
|
|
22
22
|
* - `star_gift_upgrade`: This transaction is for a star gift upgrade
|
|
23
23
|
* - `star_gift_transfer`: This transaction is for a star gift transfer
|
|
24
|
+
* - `star_gift_resale`: This transaction is for a star gift resale
|
|
24
25
|
* - `paid_message`: This transaction is a payment for a paid message
|
|
25
26
|
* - `premium_gift`: This transaction is a payment for a premium gift to a user
|
|
26
27
|
* - `api_*`: This transaction is a payment for paid API features
|
|
@@ -119,6 +120,12 @@ export type StarsTransactionType = {
|
|
|
119
120
|
peer: Peer;
|
|
120
121
|
/** The upgraded gift */
|
|
121
122
|
gift: StarGiftUnique;
|
|
123
|
+
} | {
|
|
124
|
+
type: 'star_gift_resale';
|
|
125
|
+
/** Related peer */
|
|
126
|
+
peer: Peer;
|
|
127
|
+
/** The resold gift */
|
|
128
|
+
gift: StarGiftUnique;
|
|
122
129
|
} | {
|
|
123
130
|
type: 'star_gift_transfer';
|
|
124
131
|
/** Recepient peer */
|
|
@@ -21,6 +21,7 @@ import { StarGift } from './stars-gift.js';
|
|
|
21
21
|
* - `star_gift`: This transaction is either a star gift to a user (if outgoing), or converting a star gift to stars (if incoming)
|
|
22
22
|
* - `star_gift_upgrade`: This transaction is for a star gift upgrade
|
|
23
23
|
* - `star_gift_transfer`: This transaction is for a star gift transfer
|
|
24
|
+
* - `star_gift_resale`: This transaction is for a star gift resale
|
|
24
25
|
* - `paid_message`: This transaction is a payment for a paid message
|
|
25
26
|
* - `premium_gift`: This transaction is a payment for a premium gift to a user
|
|
26
27
|
* - `api_*`: This transaction is a payment for paid API features
|
|
@@ -119,6 +120,12 @@ export type StarsTransactionType = {
|
|
|
119
120
|
peer: Peer;
|
|
120
121
|
/** The upgraded gift */
|
|
121
122
|
gift: StarGiftUnique;
|
|
123
|
+
} | {
|
|
124
|
+
type: 'star_gift_resale';
|
|
125
|
+
/** Related peer */
|
|
126
|
+
peer: Peer;
|
|
127
|
+
/** The resold gift */
|
|
128
|
+
gift: StarGiftUnique;
|
|
122
129
|
} | {
|
|
123
130
|
type: 'star_gift_transfer';
|
|
124
131
|
/** Recepient peer */
|
|
@@ -116,6 +116,12 @@ class StarsTransaction {
|
|
|
116
116
|
peer,
|
|
117
117
|
gift: new StarGiftUnique$2(this.raw.stargift, this.peers)
|
|
118
118
|
};
|
|
119
|
+
} else if (this.raw.stargiftResale) {
|
|
120
|
+
return {
|
|
121
|
+
type: "star_gift_resale",
|
|
122
|
+
peer,
|
|
123
|
+
gift: new StarGiftUnique$2(this.raw.stargift, this.peers)
|
|
124
|
+
};
|
|
119
125
|
} else {
|
|
120
126
|
return {
|
|
121
127
|
type: "star_gift_transfer",
|
|
@@ -41,6 +41,12 @@ class EmojiStatus {
|
|
|
41
41
|
constructor(raw) {
|
|
42
42
|
this.raw = raw;
|
|
43
43
|
}
|
|
44
|
+
static fromTl(status) {
|
|
45
|
+
if (!status || status._ === "emojiStatusEmpty" || status._ === "inputEmojiStatusCollectible") {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return new EmojiStatus(status);
|
|
49
|
+
}
|
|
44
50
|
/** ID of the custom emoji */
|
|
45
51
|
get emoji() {
|
|
46
52
|
return this.raw.documentId;
|
|
@@ -24,6 +24,7 @@ export declare class EmojiStatusCollectible {
|
|
|
24
24
|
export declare class EmojiStatus {
|
|
25
25
|
readonly raw: Exclude<tl.TypeEmojiStatus, tl.RawEmojiStatusEmpty | tl.RawInputEmojiStatusCollectible>;
|
|
26
26
|
constructor(raw: Exclude<tl.TypeEmojiStatus, tl.RawEmojiStatusEmpty | tl.RawInputEmojiStatusCollectible>);
|
|
27
|
+
static fromTl(status?: tl.TypeEmojiStatus): EmojiStatus | null;
|
|
27
28
|
/** ID of the custom emoji */
|
|
28
29
|
get emoji(): tl.Long;
|
|
29
30
|
/** This status is valid at most until this date */
|
|
@@ -24,6 +24,7 @@ export declare class EmojiStatusCollectible {
|
|
|
24
24
|
export declare class EmojiStatus {
|
|
25
25
|
readonly raw: Exclude<tl.TypeEmojiStatus, tl.RawEmojiStatusEmpty | tl.RawInputEmojiStatusCollectible>;
|
|
26
26
|
constructor(raw: Exclude<tl.TypeEmojiStatus, tl.RawEmojiStatusEmpty | tl.RawInputEmojiStatusCollectible>);
|
|
27
|
+
static fromTl(status?: tl.TypeEmojiStatus): EmojiStatus | null;
|
|
27
28
|
/** ID of the custom emoji */
|
|
28
29
|
get emoji(): tl.Long;
|
|
29
30
|
/** This status is valid at most until this date */
|
|
@@ -34,6 +34,12 @@ class EmojiStatus {
|
|
|
34
34
|
constructor(raw) {
|
|
35
35
|
this.raw = raw;
|
|
36
36
|
}
|
|
37
|
+
static fromTl(status) {
|
|
38
|
+
if (!status || status._ === "emojiStatusEmpty" || status._ === "inputEmojiStatusCollectible") {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return new EmojiStatus(status);
|
|
42
|
+
}
|
|
37
43
|
/** ID of the custom emoji */
|
|
38
44
|
get emoji() {
|
|
39
45
|
return this.raw.documentId;
|
|
@@ -7,6 +7,10 @@ export type ArrayPaginated<T, Offset> = T[] & {
|
|
|
7
7
|
total: number;
|
|
8
8
|
next?: Offset;
|
|
9
9
|
};
|
|
10
|
+
export type ArrayPaginatedWithMeta<T, Offset, Meta> = T[] & {
|
|
11
|
+
total: number;
|
|
12
|
+
next?: Offset;
|
|
13
|
+
} & Meta;
|
|
10
14
|
export type ParametersSkip1<T> = T extends (a: any, ...args: infer P) => any ? P : never;
|
|
11
15
|
export type ParametersSkip2<T> = T extends (a: any, b: any, ...args: infer P) => any ? P : never;
|
|
12
16
|
export type ParametersSkip3<T> = T extends (a: any, b: any, c: any, ...args: infer P) => any ? P : never;
|
|
@@ -7,6 +7,10 @@ export type ArrayPaginated<T, Offset> = T[] & {
|
|
|
7
7
|
total: number;
|
|
8
8
|
next?: Offset;
|
|
9
9
|
};
|
|
10
|
+
export type ArrayPaginatedWithMeta<T, Offset, Meta> = T[] & {
|
|
11
|
+
total: number;
|
|
12
|
+
next?: Offset;
|
|
13
|
+
} & Meta;
|
|
10
14
|
export type ParametersSkip1<T> = T extends (a: any, ...args: infer P) => any ? P : never;
|
|
11
15
|
export type ParametersSkip2<T> = T extends (a: any, b: any, ...args: infer P) => any ? P : never;
|
|
12
16
|
export type ParametersSkip3<T> = T extends (a: any, b: any, c: any, ...args: infer P) => any ? P : never;
|
|
@@ -25,6 +25,13 @@ function makeArrayPaginated(arr, total, next) {
|
|
|
25
25
|
a.next = next;
|
|
26
26
|
return a;
|
|
27
27
|
}
|
|
28
|
+
function makeArrayPaginatedWithMeta(arr, total, meta, next) {
|
|
29
|
+
const a = arr;
|
|
30
|
+
a.total = total;
|
|
31
|
+
a.next = next;
|
|
32
|
+
Object.assign(a, meta);
|
|
33
|
+
return a;
|
|
34
|
+
}
|
|
28
35
|
function normalizeDate(date) {
|
|
29
36
|
return date ? ~~((typeof date === "number" ? date : date.getTime()) / 1e3) : void 0;
|
|
30
37
|
}
|
|
@@ -33,6 +40,7 @@ function normalizeMessageId(msg) {
|
|
|
33
40
|
return typeof msg === "number" ? msg : msg.id;
|
|
34
41
|
}
|
|
35
42
|
exports.makeArrayPaginated = makeArrayPaginated;
|
|
43
|
+
exports.makeArrayPaginatedWithMeta = makeArrayPaginatedWithMeta;
|
|
36
44
|
exports.makeArrayWithTotal = makeArrayWithTotal;
|
|
37
45
|
exports.normalizeDate = normalizeDate;
|
|
38
46
|
exports.normalizeMessageId = normalizeMessageId;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayPaginated, ArrayWithTotal, MaybeDynamic, Message } from '../types/index.js';
|
|
1
|
+
import { ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, MaybeDynamic, Message } from '../types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Normalize phone number by stripping formatting
|
|
4
4
|
* @param phone Phone number
|
|
@@ -7,6 +7,7 @@ export declare function normalizePhoneNumber(phone: string): string;
|
|
|
7
7
|
export declare function resolveMaybeDynamic<T>(val: MaybeDynamic<T>): Promise<T>;
|
|
8
8
|
export declare function makeArrayWithTotal<T>(arr: T[], total: number): ArrayWithTotal<T>;
|
|
9
9
|
export declare function makeArrayPaginated<T, Offset>(arr: T[], total: number, next?: Offset): ArrayPaginated<T, Offset>;
|
|
10
|
+
export declare function makeArrayPaginatedWithMeta<T, Offset, Meta>(arr: T[], total: number, meta: Meta, next?: Offset): ArrayPaginatedWithMeta<T, Offset, Meta>;
|
|
10
11
|
export declare function normalizeDate(date: Date | number): number;
|
|
11
12
|
export declare function normalizeDate(date: Date | number | undefined): number | undefined;
|
|
12
13
|
export declare function normalizeMessageId(msg: Message | number | undefined): number | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayPaginated, ArrayWithTotal, MaybeDynamic, Message } from '../types/index.js';
|
|
1
|
+
import { ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, MaybeDynamic, Message } from '../types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Normalize phone number by stripping formatting
|
|
4
4
|
* @param phone Phone number
|
|
@@ -7,6 +7,7 @@ export declare function normalizePhoneNumber(phone: string): string;
|
|
|
7
7
|
export declare function resolveMaybeDynamic<T>(val: MaybeDynamic<T>): Promise<T>;
|
|
8
8
|
export declare function makeArrayWithTotal<T>(arr: T[], total: number): ArrayWithTotal<T>;
|
|
9
9
|
export declare function makeArrayPaginated<T, Offset>(arr: T[], total: number, next?: Offset): ArrayPaginated<T, Offset>;
|
|
10
|
+
export declare function makeArrayPaginatedWithMeta<T, Offset, Meta>(arr: T[], total: number, meta: Meta, next?: Offset): ArrayPaginatedWithMeta<T, Offset, Meta>;
|
|
10
11
|
export declare function normalizeDate(date: Date | number): number;
|
|
11
12
|
export declare function normalizeDate(date: Date | number | undefined): number | undefined;
|
|
12
13
|
export declare function normalizeMessageId(msg: Message | number | undefined): number | undefined;
|
|
@@ -18,6 +18,13 @@ function makeArrayPaginated(arr, total, next) {
|
|
|
18
18
|
a.next = next;
|
|
19
19
|
return a;
|
|
20
20
|
}
|
|
21
|
+
function makeArrayPaginatedWithMeta(arr, total, meta, next) {
|
|
22
|
+
const a = arr;
|
|
23
|
+
a.total = total;
|
|
24
|
+
a.next = next;
|
|
25
|
+
Object.assign(a, meta);
|
|
26
|
+
return a;
|
|
27
|
+
}
|
|
21
28
|
function normalizeDate(date) {
|
|
22
29
|
return date ? ~~((typeof date === "number" ? date : date.getTime()) / 1e3) : void 0;
|
|
23
30
|
}
|
|
@@ -27,6 +34,7 @@ function normalizeMessageId(msg) {
|
|
|
27
34
|
}
|
|
28
35
|
export {
|
|
29
36
|
makeArrayPaginated,
|
|
37
|
+
makeArrayPaginatedWithMeta,
|
|
30
38
|
makeArrayWithTotal,
|
|
31
39
|
normalizeDate,
|
|
32
40
|
normalizeMessageId,
|
package/methods.cjs
CHANGED
|
@@ -188,6 +188,7 @@ const removeCloudPassword = require("./highlevel/methods/password/remove-cloud-p
|
|
|
188
188
|
const _normalizeInputStarGift = require("./highlevel/methods/premium/_normalize-input-star-gift.cjs");
|
|
189
189
|
const acceptStarGift = require("./highlevel/methods/premium/accept-star-gift.cjs");
|
|
190
190
|
const applyBoost = require("./highlevel/methods/premium/apply-boost.cjs");
|
|
191
|
+
const buyResaleGift = require("./highlevel/methods/premium/buy-resale-gift.cjs");
|
|
191
192
|
const canApplyBoost = require("./highlevel/methods/premium/can-apply-boost.cjs");
|
|
192
193
|
const createBusinessChatLink = require("./highlevel/methods/premium/create-business-chat-link.cjs");
|
|
193
194
|
const editBusinessChatLink = require("./highlevel/methods/premium/edit-business-chat-link.cjs");
|
|
@@ -196,6 +197,7 @@ const getBoosts = require("./highlevel/methods/premium/get-boosts.cjs");
|
|
|
196
197
|
const getBusinessChatLinks = require("./highlevel/methods/premium/get-business-chat-links.cjs");
|
|
197
198
|
const getBusinessConnection = require("./highlevel/methods/premium/get-business-connection.cjs");
|
|
198
199
|
const getMyBoostSlots = require("./highlevel/methods/premium/get-my-boost-slots.cjs");
|
|
200
|
+
const getResaleStarGifts = require("./highlevel/methods/premium/get-resale-star-gifts.cjs");
|
|
199
201
|
const getSavedStarGiftsById = require("./highlevel/methods/premium/get-saved-star-gifts-by-id.cjs");
|
|
200
202
|
const getSavedStarGifts = require("./highlevel/methods/premium/get-saved-star-gifts.cjs");
|
|
201
203
|
const getStarGiftOptions = require("./highlevel/methods/premium/get-star-gift-options.cjs");
|
|
@@ -209,6 +211,7 @@ const pinStarGift = require("./highlevel/methods/premium/pin-star-gift.cjs");
|
|
|
209
211
|
const sendStarGift = require("./highlevel/methods/premium/send-star-gift.cjs");
|
|
210
212
|
const setBusinessIntro = require("./highlevel/methods/premium/set-business-intro.cjs");
|
|
211
213
|
const setBusinessWorkHours = require("./highlevel/methods/premium/set-business-work-hours.cjs");
|
|
214
|
+
const setGiftResalePrice = require("./highlevel/methods/premium/set-gift-resale-price.cjs");
|
|
212
215
|
const transferStarGift = require("./highlevel/methods/premium/transfer-star-gift.cjs");
|
|
213
216
|
const upgradeStarGift = require("./highlevel/methods/premium/upgrade-star-gift.cjs");
|
|
214
217
|
const addStickerToSet = require("./highlevel/methods/stickers/add-sticker-to-set.cjs");
|
|
@@ -466,6 +469,7 @@ exports.removeCloudPassword = removeCloudPassword.removeCloudPassword;
|
|
|
466
469
|
exports._normalizeInputStarGift = _normalizeInputStarGift._normalizeInputStarGift;
|
|
467
470
|
exports.acceptStarGift = acceptStarGift.acceptStarGift;
|
|
468
471
|
exports.applyBoost = applyBoost.applyBoost;
|
|
472
|
+
exports.buyResaleGift = buyResaleGift.buyResaleGift;
|
|
469
473
|
exports.canApplyBoost = canApplyBoost.canApplyBoost;
|
|
470
474
|
exports.createBusinessChatLink = createBusinessChatLink.createBusinessChatLink;
|
|
471
475
|
exports.deleteBusinessChatLink = editBusinessChatLink.deleteBusinessChatLink;
|
|
@@ -475,6 +479,7 @@ exports.getBoosts = getBoosts.getBoosts;
|
|
|
475
479
|
exports.getBusinessChatLinks = getBusinessChatLinks.getBusinessChatLinks;
|
|
476
480
|
exports.getBusinessConnection = getBusinessConnection.getBusinessConnection;
|
|
477
481
|
exports.getMyBoostSlots = getMyBoostSlots.getMyBoostSlots;
|
|
482
|
+
exports.getResaleOptions = getResaleStarGifts.getResaleOptions;
|
|
478
483
|
exports.getSavedStarGiftsById = getSavedStarGiftsById.getSavedStarGiftsById;
|
|
479
484
|
exports.getSavedStarGifts = getSavedStarGifts.getSavedStarGifts;
|
|
480
485
|
exports.getStarGiftOptions = getStarGiftOptions.getStarGiftOptions;
|
|
@@ -488,6 +493,7 @@ exports.togglePinnedStarGifts = pinStarGift.togglePinnedStarGifts;
|
|
|
488
493
|
exports.sendStarGift = sendStarGift.sendStarGift;
|
|
489
494
|
exports.setBusinessIntro = setBusinessIntro.setBusinessIntro;
|
|
490
495
|
exports.setBusinessWorkHours = setBusinessWorkHours.setBusinessWorkHours;
|
|
496
|
+
exports.setResaleStarGiftPrice = setGiftResalePrice.setResaleStarGiftPrice;
|
|
491
497
|
exports.transferStarGift = transferStarGift.transferStarGift;
|
|
492
498
|
exports.upgradeStarGift = upgradeStarGift.upgradeStarGift;
|
|
493
499
|
exports.addStickerToSet = addStickerToSet.addStickerToSet;
|
package/methods.js
CHANGED
|
@@ -181,6 +181,7 @@ import { removeCloudPassword } from "./highlevel/methods/password/remove-cloud-p
|
|
|
181
181
|
import { _normalizeInputStarGift } from "./highlevel/methods/premium/_normalize-input-star-gift.js";
|
|
182
182
|
import { acceptStarGift } from "./highlevel/methods/premium/accept-star-gift.js";
|
|
183
183
|
import { applyBoost } from "./highlevel/methods/premium/apply-boost.js";
|
|
184
|
+
import { buyResaleGift } from "./highlevel/methods/premium/buy-resale-gift.js";
|
|
184
185
|
import { canApplyBoost } from "./highlevel/methods/premium/can-apply-boost.js";
|
|
185
186
|
import { createBusinessChatLink } from "./highlevel/methods/premium/create-business-chat-link.js";
|
|
186
187
|
import { deleteBusinessChatLink, editBusinessChatLink } from "./highlevel/methods/premium/edit-business-chat-link.js";
|
|
@@ -189,6 +190,7 @@ import { getBoosts } from "./highlevel/methods/premium/get-boosts.js";
|
|
|
189
190
|
import { getBusinessChatLinks } from "./highlevel/methods/premium/get-business-chat-links.js";
|
|
190
191
|
import { getBusinessConnection } from "./highlevel/methods/premium/get-business-connection.js";
|
|
191
192
|
import { getMyBoostSlots } from "./highlevel/methods/premium/get-my-boost-slots.js";
|
|
193
|
+
import { getResaleOptions } from "./highlevel/methods/premium/get-resale-star-gifts.js";
|
|
192
194
|
import { getSavedStarGiftsById } from "./highlevel/methods/premium/get-saved-star-gifts-by-id.js";
|
|
193
195
|
import { getSavedStarGifts } from "./highlevel/methods/premium/get-saved-star-gifts.js";
|
|
194
196
|
import { getStarGiftOptions } from "./highlevel/methods/premium/get-star-gift-options.js";
|
|
@@ -202,6 +204,7 @@ import { togglePinnedStarGifts } from "./highlevel/methods/premium/pin-star-gift
|
|
|
202
204
|
import { sendStarGift } from "./highlevel/methods/premium/send-star-gift.js";
|
|
203
205
|
import { setBusinessIntro } from "./highlevel/methods/premium/set-business-intro.js";
|
|
204
206
|
import { setBusinessWorkHours } from "./highlevel/methods/premium/set-business-work-hours.js";
|
|
207
|
+
import { setResaleStarGiftPrice } from "./highlevel/methods/premium/set-gift-resale-price.js";
|
|
205
208
|
import { transferStarGift } from "./highlevel/methods/premium/transfer-star-gift.js";
|
|
206
209
|
import { upgradeStarGift } from "./highlevel/methods/premium/upgrade-star-gift.js";
|
|
207
210
|
import { addStickerToSet } from "./highlevel/methods/stickers/add-sticker-to-set.js";
|
|
@@ -277,6 +280,7 @@ export {
|
|
|
277
280
|
archiveChats,
|
|
278
281
|
banChatMember,
|
|
279
282
|
blockUser,
|
|
283
|
+
buyResaleGift,
|
|
280
284
|
canApplyBoost,
|
|
281
285
|
canSendStory,
|
|
282
286
|
cancelPasswordEmail,
|
|
@@ -391,6 +395,7 @@ export {
|
|
|
391
395
|
getProfileStories,
|
|
392
396
|
getReactionUsers,
|
|
393
397
|
getReplyTo,
|
|
398
|
+
getResaleOptions,
|
|
394
399
|
getSavedStarGifts,
|
|
395
400
|
getSavedStarGiftsById,
|
|
396
401
|
getScheduledMessages,
|
|
@@ -511,6 +516,7 @@ export {
|
|
|
511
516
|
setMyProfilePhoto,
|
|
512
517
|
setMyUsername,
|
|
513
518
|
setOnline,
|
|
519
|
+
setResaleStarGiftPrice,
|
|
514
520
|
setSlowMode,
|
|
515
521
|
setStickerSetThumb,
|
|
516
522
|
setTyping,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtcute/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.23.
|
|
4
|
+
"version": "0.23.3",
|
|
5
5
|
"description": "Type-safe library for MTProto (Telegram API)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {},
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"@fuman/net": "0.0.14",
|
|
11
11
|
"@fuman/utils": "0.0.14",
|
|
12
12
|
"@mtcute/file-id": "^0.23.0",
|
|
13
|
-
"@mtcute/tl": "^
|
|
13
|
+
"@mtcute/tl": "^203.0.0",
|
|
14
14
|
"@mtcute/tl-runtime": "^0.23.0",
|
|
15
15
|
"@types/events": "3.0.0",
|
|
16
16
|
"long": "5.2.3"
|
package/utils/binary/compat.cjs
CHANGED
|
@@ -30,7 +30,10 @@ function mapCompatStarGift(obj) {
|
|
|
30
30
|
ownerId: obj.ownerId ? { _: "peerUser", userId: obj.ownerId } : void 0
|
|
31
31
|
};
|
|
32
32
|
case "starGiftUnique_layer198":
|
|
33
|
+
case "starGiftUnique_layer202":
|
|
33
34
|
return replaceType(obj, "starGiftUnique");
|
|
35
|
+
case "starGift_layer202":
|
|
36
|
+
return replaceType(obj, "starGift");
|
|
34
37
|
default:
|
|
35
38
|
return obj;
|
|
36
39
|
}
|
|
@@ -58,6 +61,7 @@ function mapCompatMessageMedia(obj) {
|
|
|
58
61
|
function mapCompatMessageAction(obj) {
|
|
59
62
|
switch (obj._) {
|
|
60
63
|
case "messageActionStarGiftUnique_layer197":
|
|
64
|
+
case "messageActionStarGiftUnique_layer202":
|
|
61
65
|
return {
|
|
62
66
|
...obj,
|
|
63
67
|
_: "messageActionStarGiftUnique",
|
|
@@ -77,6 +81,8 @@ function mapCompatObject(obj) {
|
|
|
77
81
|
switch (obj._) {
|
|
78
82
|
case "starGiftUnique_layer197":
|
|
79
83
|
case "starGiftUnique_layer198":
|
|
84
|
+
case "starGiftUnique_layer202":
|
|
85
|
+
case "starGift_layer202":
|
|
80
86
|
return mapCompatStarGift(obj);
|
|
81
87
|
case "emojiStatus_layer197":
|
|
82
88
|
return mapCompatEmojiStatus(obj);
|
|
@@ -86,6 +92,7 @@ function mapCompatObject(obj) {
|
|
|
86
92
|
return replaceType(obj, "channelFull");
|
|
87
93
|
case "messageActionStarGiftUnique_layer197":
|
|
88
94
|
case "messageActionStarGift_layer197":
|
|
95
|
+
case "messageActionStarGiftUnique_layer202":
|
|
89
96
|
return mapCompatMessageAction(obj);
|
|
90
97
|
case "userFull_layer199":
|
|
91
98
|
return replaceType(dropFields(obj, ["premiumGifts"]), "userFull");
|
|
@@ -109,6 +116,8 @@ function mapCompatObject(obj) {
|
|
|
109
116
|
_: "message",
|
|
110
117
|
media: obj.media ? mapCompatMessageMedia(obj.media) : void 0
|
|
111
118
|
};
|
|
119
|
+
case "phoneCallDiscardReasonAllowGroupCall_layer202":
|
|
120
|
+
return { _: "phoneCallDiscardReasonMissed" };
|
|
112
121
|
default:
|
|
113
122
|
return obj;
|
|
114
123
|
}
|
package/utils/binary/compat.js
CHANGED
|
@@ -23,7 +23,10 @@ function mapCompatStarGift(obj) {
|
|
|
23
23
|
ownerId: obj.ownerId ? { _: "peerUser", userId: obj.ownerId } : void 0
|
|
24
24
|
};
|
|
25
25
|
case "starGiftUnique_layer198":
|
|
26
|
+
case "starGiftUnique_layer202":
|
|
26
27
|
return replaceType(obj, "starGiftUnique");
|
|
28
|
+
case "starGift_layer202":
|
|
29
|
+
return replaceType(obj, "starGift");
|
|
27
30
|
default:
|
|
28
31
|
return obj;
|
|
29
32
|
}
|
|
@@ -51,6 +54,7 @@ function mapCompatMessageMedia(obj) {
|
|
|
51
54
|
function mapCompatMessageAction(obj) {
|
|
52
55
|
switch (obj._) {
|
|
53
56
|
case "messageActionStarGiftUnique_layer197":
|
|
57
|
+
case "messageActionStarGiftUnique_layer202":
|
|
54
58
|
return {
|
|
55
59
|
...obj,
|
|
56
60
|
_: "messageActionStarGiftUnique",
|
|
@@ -70,6 +74,8 @@ function mapCompatObject(obj) {
|
|
|
70
74
|
switch (obj._) {
|
|
71
75
|
case "starGiftUnique_layer197":
|
|
72
76
|
case "starGiftUnique_layer198":
|
|
77
|
+
case "starGiftUnique_layer202":
|
|
78
|
+
case "starGift_layer202":
|
|
73
79
|
return mapCompatStarGift(obj);
|
|
74
80
|
case "emojiStatus_layer197":
|
|
75
81
|
return mapCompatEmojiStatus(obj);
|
|
@@ -79,6 +85,7 @@ function mapCompatObject(obj) {
|
|
|
79
85
|
return replaceType(obj, "channelFull");
|
|
80
86
|
case "messageActionStarGiftUnique_layer197":
|
|
81
87
|
case "messageActionStarGift_layer197":
|
|
88
|
+
case "messageActionStarGiftUnique_layer202":
|
|
82
89
|
return mapCompatMessageAction(obj);
|
|
83
90
|
case "userFull_layer199":
|
|
84
91
|
return replaceType(dropFields(obj, ["premiumGifts"]), "userFull");
|
|
@@ -102,6 +109,8 @@ function mapCompatObject(obj) {
|
|
|
102
109
|
_: "message",
|
|
103
110
|
media: obj.media ? mapCompatMessageMedia(obj.media) : void 0
|
|
104
111
|
};
|
|
112
|
+
case "phoneCallDiscardReasonAllowGroupCall_layer202":
|
|
113
|
+
return { _: "phoneCallDiscardReasonMissed" };
|
|
105
114
|
default:
|
|
106
115
|
return obj;
|
|
107
116
|
}
|
package/utils.cjs
CHANGED
|
@@ -111,6 +111,7 @@ exports.normalizeInlineId = inlineUtils.normalizeInlineId;
|
|
|
111
111
|
exports.parseInlineMessageId = inlineUtils.parseInlineMessageId;
|
|
112
112
|
exports.makeInspectable = inspectable.makeInspectable;
|
|
113
113
|
exports.makeArrayPaginated = miscUtils.makeArrayPaginated;
|
|
114
|
+
exports.makeArrayPaginatedWithMeta = miscUtils.makeArrayPaginatedWithMeta;
|
|
114
115
|
exports.makeArrayWithTotal = miscUtils.makeArrayWithTotal;
|
|
115
116
|
exports.normalizeDate = miscUtils.normalizeDate;
|
|
116
117
|
exports.normalizeMessageId = miscUtils.normalizeMessageId;
|
package/utils.js
CHANGED
|
@@ -22,7 +22,7 @@ import { joinTextWithEntities } from "./highlevel/utils/entities.js";
|
|
|
22
22
|
import { determinePartSize, extractFileName, inflateSvgPath, isProbablyPlainText, strippedPhotoToJpg, svgPathToFile } from "./highlevel/utils/file-utils.js";
|
|
23
23
|
import { encodeInlineMessageId, normalizeInlineId, parseInlineMessageId } from "./highlevel/utils/inline-utils.js";
|
|
24
24
|
import { makeInspectable } from "./highlevel/utils/inspectable.js";
|
|
25
|
-
import { makeArrayPaginated, makeArrayWithTotal, normalizeDate, normalizeMessageId, normalizePhoneNumber, resolveMaybeDynamic } from "./highlevel/utils/misc-utils.js";
|
|
25
|
+
import { makeArrayPaginated, makeArrayPaginatedWithMeta, makeArrayWithTotal, normalizeDate, normalizeMessageId, normalizePhoneNumber, resolveMaybeDynamic } from "./highlevel/utils/misc-utils.js";
|
|
26
26
|
import { INVITE_LINK_REGEX, extractUsernames, inputPeerToPeer, isInputPeerChannel, isInputPeerChat, isInputPeerUser, toInputChannel, toInputPeer, toInputUser } from "./highlevel/utils/peer-utils.js";
|
|
27
27
|
import { RpsMeter } from "./highlevel/utils/rps-meter.js";
|
|
28
28
|
import { streamToBuffer } from "./highlevel/utils/stream-utils.js";
|
|
@@ -105,6 +105,7 @@ export {
|
|
|
105
105
|
longFromFastString,
|
|
106
106
|
longToFastString,
|
|
107
107
|
makeArrayPaginated,
|
|
108
|
+
makeArrayPaginatedWithMeta,
|
|
108
109
|
makeArrayWithTotal,
|
|
109
110
|
makeInspectable,
|
|
110
111
|
millerRabin,
|