@vrplatform/hyperline-client 1.0.24 → 1.0.26
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/build/main/client.d.ts +215 -0
- package/build/main/client.js +87 -16
- package/build/main/client.js.map +1 -1
- package/build/main/const.d.ts +17 -0
- package/build/main/const.js +17 -0
- package/build/main/const.js.map +1 -1
- package/build/main/src/_types.generated.d.ts +22310 -0
- package/build/main/src/_types.generated.js +6 -0
- package/build/main/src/_types.generated.js.map +1 -0
- package/build/main/src/client.d.ts +1706 -0
- package/build/main/src/client.js +294 -0
- package/build/main/src/client.js.map +1 -0
- package/build/main/src/const.d.ts +73 -0
- package/build/main/src/const.js +257 -0
- package/build/main/src/const.js.map +1 -0
- package/build/main/src/hooks.d.ts +10 -0
- package/build/main/src/hooks.js +13 -0
- package/build/main/src/hooks.js.map +1 -0
- package/build/main/src/index.d.ts +5 -0
- package/build/main/src/index.js +6 -0
- package/build/main/src/index.js.map +1 -0
- package/build/main/src/types.d.ts +35 -0
- package/build/main/src/types.js +2 -0
- package/build/main/src/types.js.map +1 -0
- package/build/main/src/utils/arrayBufferToBase64.d.ts +1 -0
- package/build/main/src/utils/arrayBufferToBase64.js +9 -0
- package/build/main/src/utils/arrayBufferToBase64.js.map +1 -0
- package/build/main/src/utils/calculateMrr.d.ts +45 -0
- package/build/main/src/utils/calculateMrr.js +107 -0
- package/build/main/src/utils/calculateMrr.js.map +1 -0
- package/build/main/src/utils/getMrrDiffReasons.d.ts +15 -0
- package/build/main/src/utils/getMrrDiffReasons.js +217 -0
- package/build/main/src/utils/getMrrDiffReasons.js.map +1 -0
- package/build/main/src/utils/index.d.ts +3 -0
- package/build/main/src/utils/index.js +4 -0
- package/build/main/src/utils/index.js.map +1 -0
- package/build/main/tsconfig.main.tsbuildinfo +1 -1
- package/build/main/utils/arrayBufferToBase64.js +5 -2
- package/build/main/utils/arrayBufferToBase64.js.map +1 -1
- package/build/main/utils/calculateMrr.d.ts +45 -0
- package/build/main/utils/calculateMrr.js +107 -0
- package/build/main/utils/calculateMrr.js.map +1 -0
- package/build/main/utils/index.d.ts +1 -0
- package/build/main/utils/index.js +1 -0
- package/build/main/utils/index.js.map +1 -1
- package/build/module/client.d.ts +215 -0
- package/build/module/client.js +87 -16
- package/build/module/client.js.map +1 -1
- package/build/module/const.d.ts +17 -0
- package/build/module/const.js +17 -0
- package/build/module/const.js.map +1 -1
- package/build/module/src/_types.generated.d.ts +22310 -0
- package/build/module/src/_types.generated.js +6 -0
- package/build/module/src/_types.generated.js.map +1 -0
- package/build/module/src/client.d.ts +1706 -0
- package/build/module/src/client.js +296 -0
- package/build/module/src/client.js.map +1 -0
- package/build/module/src/const.d.ts +73 -0
- package/build/module/src/const.js +257 -0
- package/build/module/src/const.js.map +1 -0
- package/build/module/src/hooks.d.ts +10 -0
- package/build/module/src/hooks.js +13 -0
- package/build/module/src/hooks.js.map +1 -0
- package/build/module/src/index.d.ts +5 -0
- package/build/module/src/index.js +6 -0
- package/build/module/src/index.js.map +1 -0
- package/build/module/src/types.d.ts +35 -0
- package/build/module/src/types.js +2 -0
- package/build/module/src/types.js.map +1 -0
- package/build/module/src/utils/arrayBufferToBase64.d.ts +1 -0
- package/build/module/src/utils/arrayBufferToBase64.js +9 -0
- package/build/module/src/utils/arrayBufferToBase64.js.map +1 -0
- package/build/module/src/utils/calculateMrr.d.ts +45 -0
- package/build/module/src/utils/calculateMrr.js +107 -0
- package/build/module/src/utils/calculateMrr.js.map +1 -0
- package/build/module/src/utils/getMrrDiffReasons.d.ts +15 -0
- package/build/module/src/utils/getMrrDiffReasons.js +217 -0
- package/build/module/src/utils/getMrrDiffReasons.js.map +1 -0
- package/build/module/src/utils/index.d.ts +3 -0
- package/build/module/src/utils/index.js +4 -0
- package/build/module/src/utils/index.js.map +1 -0
- package/build/module/tsconfig.esm.tsbuildinfo +1 -1
- package/build/module/utils/arrayBufferToBase64.js +5 -2
- package/build/module/utils/arrayBufferToBase64.js.map +1 -1
- package/build/module/utils/calculateMrr.d.ts +45 -0
- package/build/module/utils/calculateMrr.js +107 -0
- package/build/module/utils/calculateMrr.js.map +1 -0
- package/build/module/utils/index.d.ts +1 -0
- package/build/module/utils/index.js +1 -0
- package/build/module/utils/index.js.map +1 -1
- package/package.json +19 -18
- package/src/client.ts +117 -22
- package/src/const.ts +21 -0
- package/src/utils/arrayBufferToBase64.ts +9 -2
- package/src/utils/calculateMrr.ts +206 -0
- package/src/utils/index.ts +1 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
// Tenants
|
|
2
|
+
export const VRP_TENANT_ID = '7bfec41f-aa3f-4602-95d2-f7996e4f0e59';
|
|
3
|
+
export const DEMO_TEST_PARTNER_TENANT_ID = '0b6a7bd6-56cc-46b5-b2ab-1bd7d1e994fa';
|
|
4
|
+
export const XIMPLIFI_TENANT_ID = 'd6ab2bbe-e0fc-48d9-89a3-c3c05f4e79b5';
|
|
5
|
+
// Customers
|
|
6
|
+
export const XIMPLIFI_CUSTOMER_ID = 'cus_HDUZawnaJbPa9p';
|
|
7
|
+
export const XIMPLIFI_DEV_CUSTOMER_ID = 'cus_dNUGCETGYVu3ZV';
|
|
8
|
+
// Coupons
|
|
9
|
+
export const XIMPLIFI_COUPON_ID = 'cou_MXCaik3r19_Xkn';
|
|
10
|
+
export const XIMPLIFI_DEV_COUPON_ID = 'cou_MGtxHbT8IR1gK9';
|
|
11
|
+
export const ACCOUNTING_PARTNER_COUPON_ID = 'cou_PJQ328MBAD9kxY';
|
|
12
|
+
export const ACCOUNTING_PARTNER_DEV_COUPON_ID = 'cou_y6UfaI2X1m34Qg';
|
|
13
|
+
export const VRTRUST_HALF_PRICE_COUPON_ID = 'cou_CTOQqs0SOeSc-e'; // 50% off
|
|
14
|
+
export const VRTRUST_HALF_PRICE_DEV_COUPON_ID = 'cou_tHLiRdwQ6xGqKA'; // 50% off
|
|
15
|
+
export const VRTRUST_FREE_PRICE_COUPON_ID = 'cou_JGiLite8_nFtnX'; // 100% off
|
|
16
|
+
export const VRTRUST_FREE_PRICE_DEV_COUPON_ID = 'cou_N4GNqSSLEFscto'; // 100% off
|
|
17
|
+
export const HYPERLINE_PARTNER_TIER_10_PERCENT_COUPON_ID = 'cou_56kMhdo4fYNs7c';
|
|
18
|
+
export const HYPERLINE_PARTNER_TIER_20_PERCENT_COUPON_ID = 'cou_ExjGVUcu15XKeq';
|
|
19
|
+
export const HYPERLINE_PARTNER_TIER_30_PERCENT_COUPON_ID = 'cou_PJI6mXZHOyoWlx';
|
|
20
|
+
export const HYPERLINE_PARTNER_TIER_40_PERCENT_COUPON_ID = 'cou_gnYic7Uu8zHJX9';
|
|
21
|
+
export const HYPERLINE_PARTNER_TIER_50_PERCENT_COUPON_ID = 'cou_1saVofWCoJsVyz';
|
|
22
|
+
export const HYPERLINE_PARTNER_TIER_60_PERCENT_COUPON_ID = 'cou_tJI9hmHkQXjXOp';
|
|
23
|
+
export const HYPERLINE_PARTNER_TIER_COUPON_IDS = {
|
|
24
|
+
10: HYPERLINE_PARTNER_TIER_10_PERCENT_COUPON_ID,
|
|
25
|
+
20: HYPERLINE_PARTNER_TIER_20_PERCENT_COUPON_ID,
|
|
26
|
+
30: HYPERLINE_PARTNER_TIER_30_PERCENT_COUPON_ID,
|
|
27
|
+
40: HYPERLINE_PARTNER_TIER_40_PERCENT_COUPON_ID,
|
|
28
|
+
50: HYPERLINE_PARTNER_TIER_50_PERCENT_COUPON_ID,
|
|
29
|
+
60: HYPERLINE_PARTNER_TIER_60_PERCENT_COUPON_ID,
|
|
30
|
+
};
|
|
31
|
+
// Plans
|
|
32
|
+
export const HYPERLINE_DEFAULT_PLAN_ID = 'plan_Dyb5P0ICZ6HsIT';
|
|
33
|
+
export const HYPERLINE_DEFAULT_DEV_PLAN_ID = 'plan_UTCVXFQnKD0oMS';
|
|
34
|
+
export const HYPERLINE_DEFAULT_PLAN_NAME = 'All-in-One VRP Subscription';
|
|
35
|
+
export const HYPERLINE_DEFAULT_PRODUCT_ID = 'itm_9NU7ffT14I4ris';
|
|
36
|
+
export const HYPERLINE_DEFAULT_MIN_AMOUNT = 12500;
|
|
37
|
+
export const HYPERLINE_NEW_PRICING_DIRECT_PRODUCT_ID = 'itm_VeR6AJi9OyUQN2';
|
|
38
|
+
export const HYPERLINE_NEW_PRICING_PARTNER_CLIENT_PRODUCT_ID = 'itm_wrrT0HuAZ8Tlh1';
|
|
39
|
+
export const HYPERLINE_PARTNER_PLAN_ID = 'plan_vkYJcCz7z0XD0N';
|
|
40
|
+
export const HYPERLINE_PARTNER_DEV_PLAN_ID = 'plan_8qtj8T4j0W3oiS';
|
|
41
|
+
export const HYPERLINE_PARTNER_PLAN_NAME = 'VRP Subscription - Partners';
|
|
42
|
+
export const HYPERLINE_PARTNER_PRODUCT_ID = 'itm_AJBM0_jPsrqizl';
|
|
43
|
+
export const GL_HYPERLINE_DEFAULT_PLAN_ID = 'plan_JXviWSpU5yuokD';
|
|
44
|
+
export const GL_HYPERLINE_DEFAULT_DEV_PLAN_ID = 'plan_Nnozk8_TfYqTkj';
|
|
45
|
+
export const GL_HYPERLINE_DEFAULT_PLAN_NAME = 'VRTrust Subscription';
|
|
46
|
+
export const GL_HYPERLINE_DEFAULT_PRODUCT_ID = 'itm_NRTRBQ0fc8bFGW';
|
|
47
|
+
export const GL_HYPERLINE_DEFAULT_MIN_AMOUNT = 25000;
|
|
48
|
+
export const GL_HYPERLINE_PARTNER_PLAN_ID = 'plan_vyxckdvUi8X_mr';
|
|
49
|
+
export const GL_HYPERLINE_PARTNER_DEV_PLAN_ID = 'plan_CVXQ47ErOWANhJ';
|
|
50
|
+
export const GL_HYPERLINE_PARTNER_PLAN_NAME = 'VRTrust Subscription - Partners';
|
|
51
|
+
export const GL_HYPERLINE_PARTNER_PRODUCT_ID = 'itm_bE4y9lhrZ6Qtsf';
|
|
52
|
+
export const WEBHOOKS = {
|
|
53
|
+
'payment_method.created': 'hyperline_payment_method_created',
|
|
54
|
+
'payment_method.errored': 'hyperline_payment_method_errored',
|
|
55
|
+
'payment_method.deleted': 'hyperline_payment_method_deleted',
|
|
56
|
+
'payment_method.expired': 'hyperline_payment_method_expired',
|
|
57
|
+
'subscription.activated': 'hyperline_subscription_status_changed',
|
|
58
|
+
'subscription.reactivated': 'hyperline_subscription_status_changed',
|
|
59
|
+
'subscription.cancellation_scheduled': 'hyperline_subscription_cancellation_scheduled',
|
|
60
|
+
'subscription.cancelled': 'hyperline_subscription_status_changed',
|
|
61
|
+
'subscription.reinstated': 'hyperline_subscription_status_changed',
|
|
62
|
+
'subscription.charged': 'hyperline_subscription_charged',
|
|
63
|
+
'subscription.errored': 'hyperline_subscription_status_changed',
|
|
64
|
+
'subscription.paused': 'hyperline_subscription_status_changed',
|
|
65
|
+
'subscription.trial_ended': 'hyperline_trial_ended',
|
|
66
|
+
'subscription.voided': 'hyperline_subscription_status_changed',
|
|
67
|
+
'customer.created': 'hyperline_customer_created',
|
|
68
|
+
'customer.updated': 'hyperline_customer_updated',
|
|
69
|
+
'customer.deleted': 'hyperline_customer_deleted',
|
|
70
|
+
'invoice.errored': 'hyperline_invoice_errored',
|
|
71
|
+
'invoice.ready': 'hyperline_invoice_ready',
|
|
72
|
+
'invoice.settled': 'hyperline_invoice_settled',
|
|
73
|
+
'invoice.voided': 'hyperline_invoice_voided',
|
|
74
|
+
};
|
|
75
|
+
export const CURRENCY_MAP = {
|
|
76
|
+
aed: 'AED',
|
|
77
|
+
afn: 'AFN',
|
|
78
|
+
all: 'ALL',
|
|
79
|
+
amd: 'AMD',
|
|
80
|
+
ang: 'ANG',
|
|
81
|
+
aoa: 'AOA',
|
|
82
|
+
ars: 'ARS',
|
|
83
|
+
aud: 'AUD',
|
|
84
|
+
awg: 'AWG',
|
|
85
|
+
azn: 'AZN',
|
|
86
|
+
bam: 'BAM',
|
|
87
|
+
bbd: 'BBD',
|
|
88
|
+
bdt: 'BDT',
|
|
89
|
+
bgn: 'BGN',
|
|
90
|
+
bhd: 'BHD',
|
|
91
|
+
bif: 'BIF',
|
|
92
|
+
bmd: 'BMD',
|
|
93
|
+
bnd: 'BND',
|
|
94
|
+
bob: 'BOB',
|
|
95
|
+
bov: 'BOB',
|
|
96
|
+
brl: 'BRL',
|
|
97
|
+
bsd: 'BSD',
|
|
98
|
+
btn: 'BTN',
|
|
99
|
+
bwp: 'BWP',
|
|
100
|
+
byn: 'BYR',
|
|
101
|
+
byr: 'BYR',
|
|
102
|
+
bzd: 'BZD',
|
|
103
|
+
cad: 'CAD',
|
|
104
|
+
cdf: 'CDF',
|
|
105
|
+
che: 'CHF',
|
|
106
|
+
chf: 'CHF',
|
|
107
|
+
chw: 'CHF',
|
|
108
|
+
clf: 'CLP',
|
|
109
|
+
clp: 'CLP',
|
|
110
|
+
cny: 'CNY',
|
|
111
|
+
cop: 'COP',
|
|
112
|
+
cou: 'COP',
|
|
113
|
+
crc: 'CRC',
|
|
114
|
+
cuc: 'CUP',
|
|
115
|
+
cup: 'CUP',
|
|
116
|
+
cve: 'CVE',
|
|
117
|
+
czk: 'CZK',
|
|
118
|
+
djf: 'DJF',
|
|
119
|
+
dkk: 'DKK',
|
|
120
|
+
dop: 'DOP',
|
|
121
|
+
dzd: 'DZD',
|
|
122
|
+
egp: 'EGP',
|
|
123
|
+
ern: 'ERN',
|
|
124
|
+
etb: 'ETB',
|
|
125
|
+
eur: 'EUR',
|
|
126
|
+
fjd: 'FJD',
|
|
127
|
+
fkp: 'FKP',
|
|
128
|
+
gbp: 'GBP',
|
|
129
|
+
gel: 'GEL',
|
|
130
|
+
ghs: 'GHS',
|
|
131
|
+
gip: 'GIP',
|
|
132
|
+
gmd: 'GMD',
|
|
133
|
+
gnf: 'GNF',
|
|
134
|
+
gtq: 'GTQ',
|
|
135
|
+
gyd: 'GYD',
|
|
136
|
+
hkd: 'HKD',
|
|
137
|
+
hnl: 'HNL',
|
|
138
|
+
hrk: 'HRK',
|
|
139
|
+
htg: 'HTG',
|
|
140
|
+
huf: 'HUF',
|
|
141
|
+
idr: 'IDR',
|
|
142
|
+
ils: 'ILS',
|
|
143
|
+
inr: 'INR',
|
|
144
|
+
iqd: 'IQD',
|
|
145
|
+
irr: 'IRR',
|
|
146
|
+
isk: 'ISK',
|
|
147
|
+
jmd: 'JMD',
|
|
148
|
+
jod: 'JOD',
|
|
149
|
+
jpy: 'JPY',
|
|
150
|
+
kes: 'KES',
|
|
151
|
+
kgs: 'KGS',
|
|
152
|
+
khr: 'KHR',
|
|
153
|
+
kmf: 'KMF',
|
|
154
|
+
kpw: 'KPW',
|
|
155
|
+
krw: 'KRW',
|
|
156
|
+
kwd: 'KWD',
|
|
157
|
+
kyd: 'KYD',
|
|
158
|
+
kzt: 'KZT',
|
|
159
|
+
lak: 'LAK',
|
|
160
|
+
lbp: 'LBP',
|
|
161
|
+
lkr: 'LKR',
|
|
162
|
+
lrd: 'LRD',
|
|
163
|
+
lsl: 'LSL',
|
|
164
|
+
ltl: 'EUR',
|
|
165
|
+
lvl: 'EUR',
|
|
166
|
+
lyd: 'LYD',
|
|
167
|
+
mad: 'MAD',
|
|
168
|
+
mdl: 'MDL',
|
|
169
|
+
mga: 'MGA',
|
|
170
|
+
mkd: 'MKD',
|
|
171
|
+
mmk: 'MMK',
|
|
172
|
+
mnt: 'MNT',
|
|
173
|
+
mop: 'MOP',
|
|
174
|
+
mro: 'MRO',
|
|
175
|
+
mur: 'MUR',
|
|
176
|
+
mvr: 'MVR',
|
|
177
|
+
mwk: 'MWK',
|
|
178
|
+
mxn: 'MXN',
|
|
179
|
+
mxv: 'MXN',
|
|
180
|
+
myr: 'MYR',
|
|
181
|
+
mzn: 'MZN',
|
|
182
|
+
nad: 'NAD',
|
|
183
|
+
ngn: 'NGN',
|
|
184
|
+
nio: 'NIO',
|
|
185
|
+
nok: 'NOK',
|
|
186
|
+
npr: 'NPR',
|
|
187
|
+
nzd: 'NZD',
|
|
188
|
+
omr: 'OMR',
|
|
189
|
+
pab: 'PAB',
|
|
190
|
+
pen: 'PEN',
|
|
191
|
+
pgk: 'PGK',
|
|
192
|
+
php: 'PHP',
|
|
193
|
+
pkr: 'PKR',
|
|
194
|
+
pln: 'PLN',
|
|
195
|
+
pyg: 'PYG',
|
|
196
|
+
qar: 'QAR',
|
|
197
|
+
ron: 'RON',
|
|
198
|
+
rsd: 'RSD',
|
|
199
|
+
rub: 'RUB',
|
|
200
|
+
rwf: 'RWF',
|
|
201
|
+
sar: 'SAR',
|
|
202
|
+
sbd: 'SBD',
|
|
203
|
+
scr: 'SCR',
|
|
204
|
+
sdg: 'SDG',
|
|
205
|
+
sek: 'SEK',
|
|
206
|
+
sgd: 'SGD',
|
|
207
|
+
shp: 'SHP',
|
|
208
|
+
sll: 'SLL',
|
|
209
|
+
sos: 'SOS',
|
|
210
|
+
srd: 'SRD',
|
|
211
|
+
ssp: 'SSP',
|
|
212
|
+
std: 'STD',
|
|
213
|
+
syp: 'SYP',
|
|
214
|
+
szl: 'SZL',
|
|
215
|
+
thb: 'THB',
|
|
216
|
+
tjs: 'TJS',
|
|
217
|
+
tmt: 'TMT',
|
|
218
|
+
tnd: 'TND',
|
|
219
|
+
top: 'TOP',
|
|
220
|
+
try: 'TRY',
|
|
221
|
+
ttd: 'TTD',
|
|
222
|
+
twd: 'TWD',
|
|
223
|
+
tzs: 'TZS',
|
|
224
|
+
uah: 'UAH',
|
|
225
|
+
ugx: 'UGX',
|
|
226
|
+
usd: 'USD',
|
|
227
|
+
uyu: 'UYU',
|
|
228
|
+
uzs: 'UZS',
|
|
229
|
+
vef: 'VEF',
|
|
230
|
+
vnd: 'VND',
|
|
231
|
+
vuv: 'VUV',
|
|
232
|
+
wst: 'WST',
|
|
233
|
+
xaf: 'XAF',
|
|
234
|
+
xpf: 'XPF',
|
|
235
|
+
yer: 'YER',
|
|
236
|
+
zar: 'ZAR',
|
|
237
|
+
zmw: 'ZMW',
|
|
238
|
+
zwl: 'ZWL',
|
|
239
|
+
usn: undefined,
|
|
240
|
+
uss: undefined,
|
|
241
|
+
uyi: undefined,
|
|
242
|
+
xag: undefined,
|
|
243
|
+
xau: undefined,
|
|
244
|
+
xba: undefined,
|
|
245
|
+
xbb: undefined,
|
|
246
|
+
xbc: undefined,
|
|
247
|
+
xbd: undefined,
|
|
248
|
+
xcd: undefined,
|
|
249
|
+
xdr: undefined,
|
|
250
|
+
xfu: undefined,
|
|
251
|
+
xof: undefined,
|
|
252
|
+
xpd: undefined,
|
|
253
|
+
xpt: undefined,
|
|
254
|
+
xts: undefined,
|
|
255
|
+
xxx: undefined,
|
|
256
|
+
};
|
|
257
|
+
//# sourceMappingURL=const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"src/","sources":["src/const.ts"],"names":[],"mappings":"AAIA,UAAU;AACV,MAAM,CAAC,MAAM,aAAa,GAAG,sCAAsC,CAAC;AACpE,MAAM,CAAC,MAAM,2BAA2B,GACtC,sCAAsC,CAAC;AACzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,sCAAsC,CAAC;AAEzE,YAAY;AACZ,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AACzD,MAAM,CAAC,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AAE7D,UAAU;AACV,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AACvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAE3D,MAAM,CAAC,MAAM,4BAA4B,GAAG,oBAAoB,CAAC;AACjE,MAAM,CAAC,MAAM,gCAAgC,GAAG,oBAAoB,CAAC;AAErE,MAAM,CAAC,MAAM,4BAA4B,GAAG,oBAAoB,CAAC,CAAC,UAAU;AAC5E,MAAM,CAAC,MAAM,gCAAgC,GAAG,oBAAoB,CAAC,CAAC,UAAU;AAChF,MAAM,CAAC,MAAM,4BAA4B,GAAG,oBAAoB,CAAC,CAAC,WAAW;AAC7E,MAAM,CAAC,MAAM,gCAAgC,GAAG,oBAAoB,CAAC,CAAC,WAAW;AAEjF,MAAM,CAAC,MA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GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;CACf,CAAC","sourcesContent":["import type { currency_enum } from '@vrplatform/graphql';\nimport type { TrackingEvent } from '@vrplatform/log';\nimport { HyperlineEntities } from './types';\n\n// Tenants\nexport const VRP_TENANT_ID = '7bfec41f-aa3f-4602-95d2-f7996e4f0e59';\nexport const DEMO_TEST_PARTNER_TENANT_ID =\n '0b6a7bd6-56cc-46b5-b2ab-1bd7d1e994fa';\nexport const XIMPLIFI_TENANT_ID = 'd6ab2bbe-e0fc-48d9-89a3-c3c05f4e79b5';\n\n// Customers\nexport const XIMPLIFI_CUSTOMER_ID = 'cus_HDUZawnaJbPa9p';\nexport const XIMPLIFI_DEV_CUSTOMER_ID = 'cus_dNUGCETGYVu3ZV';\n\n// Coupons\nexport const XIMPLIFI_COUPON_ID = 'cou_MXCaik3r19_Xkn';\nexport const XIMPLIFI_DEV_COUPON_ID = 'cou_MGtxHbT8IR1gK9';\n\nexport const ACCOUNTING_PARTNER_COUPON_ID = 'cou_PJQ328MBAD9kxY';\nexport const ACCOUNTING_PARTNER_DEV_COUPON_ID = 'cou_y6UfaI2X1m34Qg';\n\nexport const VRTRUST_HALF_PRICE_COUPON_ID = 'cou_CTOQqs0SOeSc-e'; // 50% off\nexport const VRTRUST_HALF_PRICE_DEV_COUPON_ID = 'cou_tHLiRdwQ6xGqKA'; // 50% off\nexport const VRTRUST_FREE_PRICE_COUPON_ID = 'cou_JGiLite8_nFtnX'; // 100% off\nexport const VRTRUST_FREE_PRICE_DEV_COUPON_ID = 'cou_N4GNqSSLEFscto'; // 100% off\n\nexport const HYPERLINE_PARTNER_TIER_10_PERCENT_COUPON_ID = 'cou_56kMhdo4fYNs7c';\nexport const HYPERLINE_PARTNER_TIER_20_PERCENT_COUPON_ID = 'cou_ExjGVUcu15XKeq';\nexport const HYPERLINE_PARTNER_TIER_30_PERCENT_COUPON_ID = 'cou_PJI6mXZHOyoWlx';\nexport const HYPERLINE_PARTNER_TIER_40_PERCENT_COUPON_ID = 'cou_gnYic7Uu8zHJX9';\nexport const HYPERLINE_PARTNER_TIER_50_PERCENT_COUPON_ID = 'cou_1saVofWCoJsVyz';\nexport const HYPERLINE_PARTNER_TIER_60_PERCENT_COUPON_ID = 'cou_tJI9hmHkQXjXOp';\n\nexport const HYPERLINE_PARTNER_TIER_COUPON_IDS = {\n 10: HYPERLINE_PARTNER_TIER_10_PERCENT_COUPON_ID,\n 20: HYPERLINE_PARTNER_TIER_20_PERCENT_COUPON_ID,\n 30: HYPERLINE_PARTNER_TIER_30_PERCENT_COUPON_ID,\n 40: HYPERLINE_PARTNER_TIER_40_PERCENT_COUPON_ID,\n 50: HYPERLINE_PARTNER_TIER_50_PERCENT_COUPON_ID,\n 60: HYPERLINE_PARTNER_TIER_60_PERCENT_COUPON_ID,\n} as const;\n\n// Plans\nexport const HYPERLINE_DEFAULT_PLAN_ID = 'plan_Dyb5P0ICZ6HsIT';\nexport const HYPERLINE_DEFAULT_DEV_PLAN_ID = 'plan_UTCVXFQnKD0oMS';\nexport const HYPERLINE_DEFAULT_PLAN_NAME = 'All-in-One VRP Subscription';\nexport const HYPERLINE_DEFAULT_PRODUCT_ID = 'itm_9NU7ffT14I4ris';\nexport const HYPERLINE_DEFAULT_MIN_AMOUNT = 12500;\n\nexport const HYPERLINE_NEW_PRICING_DIRECT_PRODUCT_ID = 'itm_VeR6AJi9OyUQN2';\nexport const HYPERLINE_NEW_PRICING_PARTNER_CLIENT_PRODUCT_ID =\n 'itm_wrrT0HuAZ8Tlh1';\n\nexport const HYPERLINE_PARTNER_PLAN_ID = 'plan_vkYJcCz7z0XD0N';\nexport const HYPERLINE_PARTNER_DEV_PLAN_ID = 'plan_8qtj8T4j0W3oiS';\nexport const HYPERLINE_PARTNER_PLAN_NAME = 'VRP Subscription - Partners';\nexport const HYPERLINE_PARTNER_PRODUCT_ID = 'itm_AJBM0_jPsrqizl';\n\nexport const GL_HYPERLINE_DEFAULT_PLAN_ID = 'plan_JXviWSpU5yuokD';\nexport const GL_HYPERLINE_DEFAULT_DEV_PLAN_ID = 'plan_Nnozk8_TfYqTkj';\nexport const GL_HYPERLINE_DEFAULT_PLAN_NAME = 'VRTrust Subscription';\nexport const GL_HYPERLINE_DEFAULT_PRODUCT_ID = 'itm_NRTRBQ0fc8bFGW';\nexport const GL_HYPERLINE_DEFAULT_MIN_AMOUNT = 25000;\n\nexport const GL_HYPERLINE_PARTNER_PLAN_ID = 'plan_vyxckdvUi8X_mr';\nexport const GL_HYPERLINE_PARTNER_DEV_PLAN_ID = 'plan_CVXQ47ErOWANhJ';\nexport const GL_HYPERLINE_PARTNER_PLAN_NAME = 'VRTrust Subscription - Partners';\nexport const GL_HYPERLINE_PARTNER_PRODUCT_ID = 'itm_bE4y9lhrZ6Qtsf';\n\nexport const WEBHOOKS = {\n 'payment_method.created': 'hyperline_payment_method_created',\n 'payment_method.errored': 'hyperline_payment_method_errored',\n 'payment_method.deleted': 'hyperline_payment_method_deleted',\n 'payment_method.expired': 'hyperline_payment_method_expired',\n 'subscription.activated': 'hyperline_subscription_status_changed',\n 'subscription.reactivated': 'hyperline_subscription_status_changed',\n 'subscription.cancellation_scheduled':\n 'hyperline_subscription_cancellation_scheduled',\n 'subscription.cancelled': 'hyperline_subscription_status_changed',\n 'subscription.reinstated': 'hyperline_subscription_status_changed',\n 'subscription.charged': 'hyperline_subscription_charged',\n 'subscription.errored': 'hyperline_subscription_status_changed',\n 'subscription.paused': 'hyperline_subscription_status_changed',\n 'subscription.trial_ended': 'hyperline_trial_ended',\n 'subscription.voided': 'hyperline_subscription_status_changed',\n 'customer.created': 'hyperline_customer_created',\n 'customer.updated': 'hyperline_customer_updated',\n 'customer.deleted': 'hyperline_customer_deleted',\n 'invoice.errored': 'hyperline_invoice_errored',\n 'invoice.ready': 'hyperline_invoice_ready',\n 'invoice.settled': 'hyperline_invoice_settled',\n 'invoice.voided': 'hyperline_invoice_voided',\n} satisfies Record<string, TrackingEvent>;\n\nexport const CURRENCY_MAP: Record<\n currency_enum,\n HyperlineEntities['Invoice']['currency'] | undefined\n> = {\n aed: 'AED',\n afn: 'AFN',\n all: 'ALL',\n amd: 'AMD',\n ang: 'ANG',\n aoa: 'AOA',\n ars: 'ARS',\n aud: 'AUD',\n awg: 'AWG',\n azn: 'AZN',\n bam: 'BAM',\n bbd: 'BBD',\n bdt: 'BDT',\n bgn: 'BGN',\n bhd: 'BHD',\n bif: 'BIF',\n bmd: 'BMD',\n bnd: 'BND',\n bob: 'BOB',\n bov: 'BOB',\n brl: 'BRL',\n bsd: 'BSD',\n btn: 'BTN',\n bwp: 'BWP',\n byn: 'BYR',\n byr: 'BYR',\n bzd: 'BZD',\n cad: 'CAD',\n cdf: 'CDF',\n che: 'CHF',\n chf: 'CHF',\n chw: 'CHF',\n clf: 'CLP',\n clp: 'CLP',\n cny: 'CNY',\n cop: 'COP',\n cou: 'COP',\n crc: 'CRC',\n cuc: 'CUP',\n cup: 'CUP',\n cve: 'CVE',\n czk: 'CZK',\n djf: 'DJF',\n dkk: 'DKK',\n dop: 'DOP',\n dzd: 'DZD',\n egp: 'EGP',\n ern: 'ERN',\n etb: 'ETB',\n eur: 'EUR',\n fjd: 'FJD',\n fkp: 'FKP',\n gbp: 'GBP',\n gel: 'GEL',\n ghs: 'GHS',\n gip: 'GIP',\n gmd: 'GMD',\n gnf: 'GNF',\n gtq: 'GTQ',\n gyd: 'GYD',\n hkd: 'HKD',\n hnl: 'HNL',\n hrk: 'HRK',\n htg: 'HTG',\n huf: 'HUF',\n idr: 'IDR',\n ils: 'ILS',\n inr: 'INR',\n iqd: 'IQD',\n irr: 'IRR',\n isk: 'ISK',\n jmd: 'JMD',\n jod: 'JOD',\n jpy: 'JPY',\n kes: 'KES',\n kgs: 'KGS',\n khr: 'KHR',\n kmf: 'KMF',\n kpw: 'KPW',\n krw: 'KRW',\n kwd: 'KWD',\n kyd: 'KYD',\n kzt: 'KZT',\n lak: 'LAK',\n lbp: 'LBP',\n lkr: 'LKR',\n lrd: 'LRD',\n lsl: 'LSL',\n ltl: 'EUR',\n lvl: 'EUR',\n lyd: 'LYD',\n mad: 'MAD',\n mdl: 'MDL',\n mga: 'MGA',\n mkd: 'MKD',\n mmk: 'MMK',\n mnt: 'MNT',\n mop: 'MOP',\n mro: 'MRO',\n mur: 'MUR',\n mvr: 'MVR',\n mwk: 'MWK',\n mxn: 'MXN',\n mxv: 'MXN',\n myr: 'MYR',\n mzn: 'MZN',\n nad: 'NAD',\n ngn: 'NGN',\n nio: 'NIO',\n nok: 'NOK',\n npr: 'NPR',\n nzd: 'NZD',\n omr: 'OMR',\n pab: 'PAB',\n pen: 'PEN',\n pgk: 'PGK',\n php: 'PHP',\n pkr: 'PKR',\n pln: 'PLN',\n pyg: 'PYG',\n qar: 'QAR',\n ron: 'RON',\n rsd: 'RSD',\n rub: 'RUB',\n rwf: 'RWF',\n sar: 'SAR',\n sbd: 'SBD',\n scr: 'SCR',\n sdg: 'SDG',\n sek: 'SEK',\n sgd: 'SGD',\n shp: 'SHP',\n sll: 'SLL',\n sos: 'SOS',\n srd: 'SRD',\n ssp: 'SSP',\n std: 'STD',\n syp: 'SYP',\n szl: 'SZL',\n thb: 'THB',\n tjs: 'TJS',\n tmt: 'TMT',\n tnd: 'TND',\n top: 'TOP',\n try: 'TRY',\n ttd: 'TTD',\n twd: 'TWD',\n tzs: 'TZS',\n uah: 'UAH',\n ugx: 'UGX',\n usd: 'USD',\n uyu: 'UYU',\n uzs: 'UZS',\n vef: 'VEF',\n vnd: 'VND',\n vuv: 'VUV',\n wst: 'WST',\n xaf: 'XAF',\n xpf: 'XPF',\n yer: 'YER',\n zar: 'ZAR',\n zmw: 'ZMW',\n zwl: 'ZWL',\n usn: undefined,\n uss: undefined,\n uyi: undefined,\n xag: undefined,\n xau: undefined,\n xba: undefined,\n xbb: undefined,\n xbc: undefined,\n xbd: undefined,\n xcd: undefined,\n xdr: undefined,\n xfu: undefined,\n xof: undefined,\n xpd: undefined,\n xpt: undefined,\n xts: undefined,\n xxx: undefined,\n};\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HyperlineAPI, Logger } from './client';
|
|
2
|
+
export declare function useHyperline(env: {
|
|
3
|
+
PRODUCTION_HYPERLINE_API_KEY: string;
|
|
4
|
+
DEV_HYPERLINE_API_KEY: string;
|
|
5
|
+
}, environment: 'production' | 'development', logger?: Logger): {
|
|
6
|
+
hyperline: HyperlineAPI;
|
|
7
|
+
token: string;
|
|
8
|
+
isProduction: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function useHyperlineByToken(token: string, logger?: Logger): HyperlineAPI;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HyperlineAPI } from './client';
|
|
2
|
+
export function useHyperline(env, environment, logger) {
|
|
3
|
+
const isProduction = environment === 'production';
|
|
4
|
+
const token = isProduction
|
|
5
|
+
? env.PRODUCTION_HYPERLINE_API_KEY
|
|
6
|
+
: env.DEV_HYPERLINE_API_KEY;
|
|
7
|
+
const hyperline = useHyperlineByToken(token, logger);
|
|
8
|
+
return { hyperline, token, isProduction };
|
|
9
|
+
}
|
|
10
|
+
export function useHyperlineByToken(token, logger = console) {
|
|
11
|
+
return new HyperlineAPI(token, logger);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"src/","sources":["src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAU,MAAM,UAAU,CAAC;AAEhD,MAAM,UAAU,YAAY,CAC1B,GAGC,EACD,WAAyC,EACzC,MAAe;IAEf,MAAM,YAAY,GAAG,WAAW,KAAK,YAAY,CAAC;IAElD,MAAM,KAAK,GAAG,YAAY;QACxB,CAAC,CAAC,GAAG,CAAC,4BAA4B;QAClC,CAAC,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAE9B,MAAM,SAAS,GAAG,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAErD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAa,EAAE,SAAiB,OAAO;IACzE,OAAO,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import { HyperlineAPI, Logger } from './client';\n\nexport function useHyperline(\n env: {\n PRODUCTION_HYPERLINE_API_KEY: string;\n DEV_HYPERLINE_API_KEY: string;\n },\n environment: 'production' | 'development',\n logger?: Logger\n) {\n const isProduction = environment === 'production';\n\n const token = isProduction\n ? env.PRODUCTION_HYPERLINE_API_KEY\n : env.DEV_HYPERLINE_API_KEY;\n\n const hyperline = useHyperlineByToken(token, logger);\n\n return { hyperline, token, isProduction };\n}\n\nexport function useHyperlineByToken(token: string, logger: Logger = console) {\n return new HyperlineAPI(token, logger);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC","sourcesContent":["export * from './client';\nexport * from './const';\nexport * from './hooks';\nexport * from './types';\nexport * from './utils';\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { components, paths } from './_types.generated';
|
|
2
|
+
import { WEBHOOKS } from './const';
|
|
3
|
+
export type HyperlineEntities = components['schemas'];
|
|
4
|
+
export type HyperlineEndpoints = paths;
|
|
5
|
+
export type HyperlineWebhook = keyof typeof WEBHOOKS;
|
|
6
|
+
export type HyperlineEvent<T extends HyperlineWebhook> = (typeof WEBHOOKS)[T];
|
|
7
|
+
export type HyperlinePayload<T extends HyperlineWebhook> = {
|
|
8
|
+
event_type: T;
|
|
9
|
+
data: Record<string, any>;
|
|
10
|
+
};
|
|
11
|
+
export type BillableEvent = {
|
|
12
|
+
record: {
|
|
13
|
+
id: '202408_cus_w_Q7M9bXcHMKB6';
|
|
14
|
+
amount: 26;
|
|
15
|
+
};
|
|
16
|
+
timestamp: '2024-08-07T07:35:20.307Z';
|
|
17
|
+
event_type: 'api_call';
|
|
18
|
+
customer_id: 'cus_w_Q7M9bXcHMKB6';
|
|
19
|
+
};
|
|
20
|
+
export type BillableEvents = {
|
|
21
|
+
events_created: BillableEvent[];
|
|
22
|
+
};
|
|
23
|
+
export type CreateBillableEvent = {
|
|
24
|
+
customer_id: string;
|
|
25
|
+
event_type: 'api_call';
|
|
26
|
+
timestamp: string;
|
|
27
|
+
record: {
|
|
28
|
+
id?: string;
|
|
29
|
+
durationInMs?: number;
|
|
30
|
+
isVerified?: true;
|
|
31
|
+
amount?: number;
|
|
32
|
+
amountGl?: number;
|
|
33
|
+
amountNonGl?: number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"src/","sources":["src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { components, paths } from './_types.generated';\nimport { WEBHOOKS } from './const';\n\nexport type HyperlineEntities = components['schemas'];\n\nexport type HyperlineEndpoints = paths;\n\nexport type HyperlineWebhook = keyof typeof WEBHOOKS;\n\nexport type HyperlineEvent<T extends HyperlineWebhook> = (typeof WEBHOOKS)[T];\n\nexport type HyperlinePayload<T extends HyperlineWebhook> = {\n event_type: T;\n data: Record<string, any>;\n};\n\nexport type BillableEvent = {\n record: {\n id: '202408_cus_w_Q7M9bXcHMKB6';\n amount: 26;\n };\n timestamp: '2024-08-07T07:35:20.307Z';\n event_type: 'api_call';\n customer_id: 'cus_w_Q7M9bXcHMKB6';\n};\n\nexport type BillableEvents = {\n events_created: BillableEvent[];\n};\n\nexport type CreateBillableEvent = {\n customer_id: string;\n event_type: 'api_call';\n timestamp: string;\n record: {\n id?: string;\n durationInMs?: number;\n isVerified?: true;\n amount?: number;\n amountGl?: number;\n amountNonGl?: number;\n };\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function arrayBufferToBase64(arrayBuffer: ArrayBuffer): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function arrayBufferToBase64(arrayBuffer) {
|
|
2
|
+
const binaryChunks = [];
|
|
3
|
+
const uint8Array = new Uint8Array(arrayBuffer);
|
|
4
|
+
// Avoid passing the full PDF as function arguments, which overflows worker stacks on larger files.
|
|
5
|
+
for (let index = 0; index < uint8Array.length; index += 0x8000)
|
|
6
|
+
binaryChunks.push(String.fromCharCode(...uint8Array.subarray(index, index + 0x8000)));
|
|
7
|
+
return btoa(binaryChunks.join(''));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=arrayBufferToBase64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrayBufferToBase64.js","sourceRoot":"src/","sources":["src/utils/arrayBufferToBase64.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CAAC,WAAwB;IAC1D,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;IAE/C,mGAAmG;IACnG,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,IAAI,MAAM;QAC5D,YAAY,CAAC,IAAI,CACf,MAAM,CAAC,YAAY,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC,CACnE,CAAC;IAEJ,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACrC,CAAC","sourcesContent":["export function arrayBufferToBase64(arrayBuffer: ArrayBuffer) {\n const binaryChunks: string[] = [];\n const uint8Array = new Uint8Array(arrayBuffer);\n\n // Avoid passing the full PDF as function arguments, which overflows worker stacks on larger files.\n for (let index = 0; index < uint8Array.length; index += 0x8000)\n binaryChunks.push(\n String.fromCharCode(...uint8Array.subarray(index, index + 0x8000))\n );\n\n return btoa(binaryChunks.join(''));\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export declare function calculateMrr(subscriptionId: string, estimated?: boolean, _activeListings?: number, hyperline?: {
|
|
2
|
+
getSubscription(id: string, liveBilling?: boolean): Promise<{
|
|
3
|
+
customer_id: string;
|
|
4
|
+
plan_id: string | null;
|
|
5
|
+
products?: unknown[];
|
|
6
|
+
coupons?: ({
|
|
7
|
+
type: 'amount';
|
|
8
|
+
repeat: 'once' | 'forever' | 'custom';
|
|
9
|
+
discount_amount: number;
|
|
10
|
+
} | {
|
|
11
|
+
type: 'percent';
|
|
12
|
+
repeat: 'once' | 'forever' | 'custom';
|
|
13
|
+
discount_percent: number;
|
|
14
|
+
})[];
|
|
15
|
+
phases?: {
|
|
16
|
+
type: 'setup' | 'trial' | 'standard';
|
|
17
|
+
status: 'pending' | 'active' | 'finished';
|
|
18
|
+
products: {
|
|
19
|
+
min_amount?: number | null;
|
|
20
|
+
max_amount?: number | null;
|
|
21
|
+
prices: ({
|
|
22
|
+
type: 'volume';
|
|
23
|
+
amount: number;
|
|
24
|
+
from: number;
|
|
25
|
+
to: number | null;
|
|
26
|
+
unit_count: number;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'bps' | 'bulk' | 'bundle' | 'fee' | 'flat_fee' | 'packaged';
|
|
29
|
+
})[];
|
|
30
|
+
}[];
|
|
31
|
+
}[];
|
|
32
|
+
live_billing?: {
|
|
33
|
+
total_amount: number;
|
|
34
|
+
};
|
|
35
|
+
} | null>;
|
|
36
|
+
getInvoicesByCustomerId(id: string): Promise<{
|
|
37
|
+
data: {
|
|
38
|
+
emitted_at: string;
|
|
39
|
+
total_amount: number;
|
|
40
|
+
}[];
|
|
41
|
+
} | null>;
|
|
42
|
+
}, includeLiveBilling?: boolean): Promise<{
|
|
43
|
+
mrr: number;
|
|
44
|
+
mrrAlt: number | null;
|
|
45
|
+
}>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { GL_HYPERLINE_DEFAULT_DEV_PLAN_ID, GL_HYPERLINE_DEFAULT_MIN_AMOUNT, GL_HYPERLINE_DEFAULT_PLAN_ID, HYPERLINE_DEFAULT_DEV_PLAN_ID, HYPERLINE_DEFAULT_MIN_AMOUNT, HYPERLINE_DEFAULT_PLAN_ID, } from '../const';
|
|
2
|
+
import { useHyperlineByToken } from '../hooks';
|
|
3
|
+
export async function calculateMrr(subscriptionId, estimated = false, _activeListings, hyperline = useHyperlineByToken(process.env.HYPERLINE_TOKEN), includeLiveBilling = false) {
|
|
4
|
+
const _subscription = await hyperline.getSubscription(subscriptionId, includeLiveBilling);
|
|
5
|
+
if (!_subscription)
|
|
6
|
+
throw new Error('Subscription not found');
|
|
7
|
+
const { products, phases, ...subscription } = _subscription;
|
|
8
|
+
let mrr = 0;
|
|
9
|
+
const activeListings = _activeListings || 0;
|
|
10
|
+
const phase = phases?.filter((x) => estimated
|
|
11
|
+
? x.type === 'standard'
|
|
12
|
+
: (x.type === 'trial' && x.status === 'active') || x.type === 'standard')?.[0];
|
|
13
|
+
const product = phase?.products?.[0];
|
|
14
|
+
const type = product?.prices?.[0].type;
|
|
15
|
+
if (type === 'volume') {
|
|
16
|
+
const volumePrices = [];
|
|
17
|
+
product?.prices?.forEach((price) => {
|
|
18
|
+
if (price.type !== 'volume' ||
|
|
19
|
+
!('amount' in price) ||
|
|
20
|
+
!('from' in price) ||
|
|
21
|
+
!('to' in price) ||
|
|
22
|
+
!('unit_count' in price))
|
|
23
|
+
return;
|
|
24
|
+
volumePrices.push({
|
|
25
|
+
amount: price.amount,
|
|
26
|
+
from: price.from,
|
|
27
|
+
to: price.to,
|
|
28
|
+
unit_count: price.unit_count,
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
volumePrices.sort((a, b) => a.from - b.from);
|
|
32
|
+
mrr =
|
|
33
|
+
volumePrices.reduce((acc, price) => {
|
|
34
|
+
const listings = price.to && activeListings >= price.to
|
|
35
|
+
? price.to - price.from
|
|
36
|
+
: activeListings >= price.from
|
|
37
|
+
? activeListings - price.from
|
|
38
|
+
: 0;
|
|
39
|
+
acc += (price.amount / 100) * (listings / price.unit_count);
|
|
40
|
+
return acc;
|
|
41
|
+
}, 0) || 0;
|
|
42
|
+
const firstTier = volumePrices[0];
|
|
43
|
+
const secondTier = volumePrices[1];
|
|
44
|
+
const product_min_amount = product &&
|
|
45
|
+
'min_amount' in product &&
|
|
46
|
+
typeof product.min_amount === 'number'
|
|
47
|
+
? product.min_amount
|
|
48
|
+
: null;
|
|
49
|
+
const product_max_amount = product &&
|
|
50
|
+
'max_amount' in product &&
|
|
51
|
+
typeof product.max_amount === 'number'
|
|
52
|
+
? product.max_amount
|
|
53
|
+
: null;
|
|
54
|
+
const inferred_min_amount = firstTier &&
|
|
55
|
+
secondTier &&
|
|
56
|
+
firstTier.from === 0 &&
|
|
57
|
+
firstTier.to != null &&
|
|
58
|
+
secondTier.from === firstTier.to &&
|
|
59
|
+
firstTier.amount === secondTier.amount &&
|
|
60
|
+
firstTier.unit_count === secondTier.unit_count
|
|
61
|
+
? firstTier.amount *
|
|
62
|
+
((firstTier.to - firstTier.from) / firstTier.unit_count)
|
|
63
|
+
: 0;
|
|
64
|
+
const plan_min_amount = [
|
|
65
|
+
GL_HYPERLINE_DEFAULT_PLAN_ID,
|
|
66
|
+
GL_HYPERLINE_DEFAULT_DEV_PLAN_ID,
|
|
67
|
+
].includes(subscription.plan_id)
|
|
68
|
+
? GL_HYPERLINE_DEFAULT_MIN_AMOUNT
|
|
69
|
+
: [HYPERLINE_DEFAULT_PLAN_ID, HYPERLINE_DEFAULT_DEV_PLAN_ID].includes(subscription.plan_id)
|
|
70
|
+
? HYPERLINE_DEFAULT_MIN_AMOUNT
|
|
71
|
+
: 0;
|
|
72
|
+
const min_amount = ((product_min_amount || plan_min_amount || inferred_min_amount) ?? 0) /
|
|
73
|
+
100;
|
|
74
|
+
mrr = Math.max(mrr, min_amount);
|
|
75
|
+
const max_amount = ((product_max_amount || 0) ?? 0) / 100;
|
|
76
|
+
mrr = max_amount > 0 ? Math.min(mrr, max_amount) : mrr;
|
|
77
|
+
// apply discounts (only these who repeat forever if estimated is true)
|
|
78
|
+
(subscription.coupons || [])
|
|
79
|
+
.filter((coupon) => (estimated ? coupon.repeat === 'forever' : true))
|
|
80
|
+
.forEach((x) => {
|
|
81
|
+
if ('discount_amount' in x && x.discount_amount)
|
|
82
|
+
mrr -= x.discount_amount / 100;
|
|
83
|
+
else if ('discount_percent' in x && x.discount_percent)
|
|
84
|
+
mrr -= (x.discount_percent / 100) * mrr;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
else if (type === 'bps') {
|
|
88
|
+
const { data } = subscription?.customer_id
|
|
89
|
+
? (await hyperline.getInvoicesByCustomerId(subscription.customer_id)) || {
|
|
90
|
+
data: [],
|
|
91
|
+
}
|
|
92
|
+
: { data: [] };
|
|
93
|
+
// sort invoices by date
|
|
94
|
+
const invoices = data
|
|
95
|
+
?.sort((a, b) => a.emitted_at.localeCompare(b.emitted_at))
|
|
96
|
+
.reverse();
|
|
97
|
+
// get the last invoice
|
|
98
|
+
mrr = (invoices[0]?.total_amount || 0) / 100;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
mrr,
|
|
102
|
+
mrrAlt: subscription.live_billing?.total_amount == null
|
|
103
|
+
? null
|
|
104
|
+
: subscription.live_billing.total_amount / 100,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=calculateMrr.js.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,GAAG,IAAI;YACnB,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;aACzD,OAAO,EAAE,CAAC;QAEb,uBAAuB;QACvB,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,YAAY,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;IAC/C,CAAC;IAED,OAAO;QACL,GAAG;QACH,MAAM,EACJ,YAAY,CAAC,YAAY,EAAE,YAAY,IAAI,IAAI;YAC7C,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,YAAY,GAAG,GAAG;KACnD,CAAC;AACJ,CAAC","sourcesContent":["import {\n GL_HYPERLINE_DEFAULT_DEV_PLAN_ID,\n GL_HYPERLINE_DEFAULT_MIN_AMOUNT,\n GL_HYPERLINE_DEFAULT_PLAN_ID,\n HYPERLINE_DEFAULT_DEV_PLAN_ID,\n HYPERLINE_DEFAULT_MIN_AMOUNT,\n HYPERLINE_DEFAULT_PLAN_ID,\n} from '../const';\nimport { useHyperlineByToken } from '../hooks';\n\nexport async function calculateMrr(\n subscriptionId: string,\n estimated = false,\n _activeListings?: number,\n hyperline: {\n getSubscription(\n id: string,\n liveBilling?: boolean\n ): Promise<{\n customer_id: string;\n plan_id: string | null;\n products?: unknown[];\n coupons?: (\n | {\n type: 'amount';\n repeat: 'once' | 'forever' | 'custom';\n discount_amount: number;\n }\n | {\n type: 'percent';\n repeat: 'once' | 'forever' | 'custom';\n discount_percent: number;\n }\n )[];\n phases?: {\n type: 'setup' | 'trial' | 'standard';\n status: 'pending' | 'active' | 'finished';\n products: {\n min_amount?: number | null;\n max_amount?: number | null;\n prices: (\n | {\n type: 'volume';\n amount: number;\n from: number;\n to: number | null;\n unit_count: number;\n }\n | {\n type:\n | 'bps'\n | 'bulk'\n | 'bundle'\n | 'fee'\n | 'flat_fee'\n | 'packaged';\n }\n )[];\n }[];\n }[];\n live_billing?: { total_amount: number };\n } | null>;\n getInvoicesByCustomerId(id: string): Promise<{\n data: {\n emitted_at: string;\n total_amount: number;\n }[];\n } | null>;\n } = useHyperlineByToken(process.env.HYPERLINE_TOKEN!),\n includeLiveBilling = false\n) {\n const _subscription = await hyperline.getSubscription(\n subscriptionId,\n includeLiveBilling\n );\n if (!_subscription) throw new Error('Subscription not found');\n\n const { products, phases, ...subscription } = _subscription;\n\n let mrr = 0;\n const activeListings = _activeListings || 0;\n const phase = phases?.filter((x) =>\n estimated\n ? x.type === 'standard'\n : (x.type === 'trial' && x.status === 'active') || x.type === 'standard'\n )?.[0];\n const product = phase?.products?.[0];\n const type = product?.prices?.[0].type;\n if (type === 'volume') {\n const volumePrices: Array<{\n amount: number;\n from: number;\n to: number | null;\n unit_count: number;\n }> = [];\n\n product?.prices?.forEach((price) => {\n if (\n price.type !== 'volume' ||\n !('amount' in price) ||\n !('from' in price) ||\n !('to' in price) ||\n !('unit_count' in price)\n )\n return;\n\n volumePrices.push({\n amount: price.amount,\n from: price.from,\n to: price.to,\n unit_count: price.unit_count,\n });\n });\n volumePrices.sort((a, b) => a.from - b.from);\n\n mrr =\n volumePrices.reduce((acc, price) => {\n const listings =\n price.to && activeListings >= price.to\n ? price.to - price.from\n : activeListings >= price.from\n ? activeListings - price.from\n : 0;\n\n acc += (price.amount / 100) * (listings / price.unit_count);\n\n return acc;\n }, 0) || 0;\n\n const firstTier = volumePrices[0];\n const secondTier = volumePrices[1];\n const product_min_amount =\n product &&\n 'min_amount' in product &&\n typeof product.min_amount === 'number'\n ? product.min_amount\n : null;\n const product_max_amount =\n product &&\n 'max_amount' in product &&\n typeof product.max_amount === 'number'\n ? product.max_amount\n : null;\n const inferred_min_amount =\n firstTier &&\n secondTier &&\n firstTier.from === 0 &&\n firstTier.to != null &&\n secondTier.from === firstTier.to &&\n firstTier.amount === secondTier.amount &&\n firstTier.unit_count === secondTier.unit_count\n ? firstTier.amount *\n ((firstTier.to - firstTier.from) / firstTier.unit_count)\n : 0;\n const plan_min_amount = [\n GL_HYPERLINE_DEFAULT_PLAN_ID,\n GL_HYPERLINE_DEFAULT_DEV_PLAN_ID,\n ].includes(subscription.plan_id!)\n ? GL_HYPERLINE_DEFAULT_MIN_AMOUNT\n : [HYPERLINE_DEFAULT_PLAN_ID, HYPERLINE_DEFAULT_DEV_PLAN_ID].includes(\n subscription.plan_id!\n )\n ? HYPERLINE_DEFAULT_MIN_AMOUNT\n : 0;\n\n const min_amount =\n ((product_min_amount || plan_min_amount || inferred_min_amount) ?? 0) /\n 100;\n mrr = Math.max(mrr, min_amount);\n\n const max_amount = ((product_max_amount || 0) ?? 0) / 100;\n mrr = max_amount > 0 ? Math.min(mrr, max_amount) : mrr;\n\n // apply discounts (only these who repeat forever if estimated is true)\n (subscription.coupons || [])\n .filter((coupon) => (estimated ? coupon.repeat === 'forever' : true))\n .forEach((x) => {\n if ('discount_amount' in x && x.discount_amount)\n mrr -= x.discount_amount / 100;\n else if ('discount_percent' in x && x.discount_percent)\n mrr -= (x.discount_percent / 100) * mrr;\n });\n } else if (type === 'bps') {\n const { data } = subscription?.customer_id\n ? (await hyperline.getInvoicesByCustomerId(subscription.customer_id)) || {\n data: [],\n }\n : { data: [] };\n\n // sort invoices by date\n const invoices = data\n ?.sort((a, b) => a.emitted_at.localeCompare(b.emitted_at))\n .reverse();\n\n // get the last invoice\n mrr = (invoices[0]?.total_amount || 0) / 100;\n }\n\n return {\n mrr,\n mrrAlt:\n subscription.live_billing?.total_amount == null\n ? null\n : subscription.live_billing.total_amount / 100,\n };\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HasuraClient } from '@vrplatform/graphql';
|
|
2
|
+
export declare function getMrrDiffReasons(firstDate: string, lastDate: string, client: HasuraClient): Promise<{
|
|
3
|
+
messages: string[];
|
|
4
|
+
result: {
|
|
5
|
+
mrrDiff: number;
|
|
6
|
+
listingsDiff: number;
|
|
7
|
+
hasCancelled: boolean;
|
|
8
|
+
id: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
plan?: string;
|
|
11
|
+
activePartnerTeamsDiff: number;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
isNew: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
}>;
|