@vrplatform/hyperline-client 1.0.0 → 1.0.2
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 +812 -0
- package/build/main/client.js +187 -0
- package/build/main/client.js.map +1 -0
- package/build/main/const.d.ts +26 -0
- package/build/main/const.js +209 -0
- package/build/main/const.js.map +1 -0
- package/build/main/hooks.d.ts +10 -0
- package/build/main/hooks.js +13 -0
- package/build/main/hooks.js.map +1 -0
- package/build/main/index.d.ts +4 -868
- package/build/main/index.js +4 -216
- package/build/main/index.js.map +1 -1
- package/build/main/tsconfig.main.tsbuildinfo +1 -1
- package/build/main/types.d.ts +35 -0
- package/build/main/types.js +2 -0
- package/build/main/types.js.map +1 -0
- package/build/main/utils.d.ts +1 -0
- package/build/main/utils.js +6 -0
- package/build/main/utils.js.map +1 -0
- package/build/module/client.d.ts +812 -0
- package/build/module/client.js +189 -0
- package/build/module/client.js.map +1 -0
- package/build/module/const.d.ts +26 -0
- package/build/module/const.js +209 -0
- package/build/module/const.js.map +1 -0
- package/build/module/hooks.d.ts +10 -0
- package/build/module/hooks.js +13 -0
- package/build/module/hooks.js.map +1 -0
- package/build/module/index.d.ts +4 -868
- package/build/module/index.js +4 -218
- package/build/module/index.js.map +1 -1
- package/build/module/tsconfig.esm.tsbuildinfo +1 -1
- package/build/module/types.d.ts +35 -0
- package/build/module/types.js +2 -0
- package/build/module/types.js.map +1 -0
- package/build/module/utils.d.ts +1 -0
- package/build/module/utils.js +6 -0
- package/build/module/utils.js.map +1 -0
- package/package.json +3 -3
- package/src/client.ts +362 -0
- package/src/const.ts +220 -0
- package/src/hooks.ts +24 -0
- package/src/index.ts +4 -443
- package/src/types.ts +43 -0
- package/src/utils.ts +5 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { utc } from '@finalytic/utils';
|
|
2
|
+
import { arrayBufferToBase64 } from './utils';
|
|
3
|
+
export class HyperlineAPI {
|
|
4
|
+
constructor(token, logger = console) {
|
|
5
|
+
this.headers = {
|
|
6
|
+
'Content-Type': 'application/json',
|
|
7
|
+
Authorization: `Bearer ${token}`,
|
|
8
|
+
};
|
|
9
|
+
this.logger = logger;
|
|
10
|
+
}
|
|
11
|
+
async fetchBasic(path, options, data) {
|
|
12
|
+
if (data)
|
|
13
|
+
options = { body: JSON.stringify(data), ...(options || {}) };
|
|
14
|
+
const sandbox = this.headers.Authorization.includes('test')
|
|
15
|
+
? 'sandbox.'
|
|
16
|
+
: '';
|
|
17
|
+
const result = await fetch(`https://${sandbox}${path}`, {
|
|
18
|
+
method: 'GET',
|
|
19
|
+
...options,
|
|
20
|
+
headers: { ...this.headers, ...options?.headers },
|
|
21
|
+
});
|
|
22
|
+
if (!result || !result?.ok) {
|
|
23
|
+
const status = result?.status;
|
|
24
|
+
const statusText = result?.statusText;
|
|
25
|
+
if (status === 429) {
|
|
26
|
+
// get difference between rate limit reset and now
|
|
27
|
+
const rateLimitReset = utc(result?.headers.get('x-ratelimit-reset'));
|
|
28
|
+
const diff = rateLimitReset.diff(utc(), 'milliseconds');
|
|
29
|
+
// wait until rate limit resets
|
|
30
|
+
await new Promise((resolve) => setTimeout(resolve, diff));
|
|
31
|
+
return await this.fetchBasic(path, options, data);
|
|
32
|
+
}
|
|
33
|
+
else if (status === 404) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const content = await result.json();
|
|
38
|
+
throw new Error(`Hyperline Error ${status} (${statusText}) in ${path} for ${options?.method || 'GET'}: ${content.message}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else if (result.headers.get('content-type')?.includes('application/pdf'))
|
|
42
|
+
return arrayBufferToBase64(await result.arrayBuffer());
|
|
43
|
+
return (await result.json());
|
|
44
|
+
}
|
|
45
|
+
async fetch(path, options, data) {
|
|
46
|
+
return await this.fetchBasic(`api.hyperline.co${path}`, options, data);
|
|
47
|
+
}
|
|
48
|
+
async fetchIngest(path, options, data) {
|
|
49
|
+
return await this.fetchBasic(`ingest.hyperline.co${path}`, options, data);
|
|
50
|
+
}
|
|
51
|
+
// CUSTOMER
|
|
52
|
+
async getCustomer(id) {
|
|
53
|
+
if (!id) {
|
|
54
|
+
this.logger.error('Missing customer ID', { id });
|
|
55
|
+
throw new Error('Missing customer ID');
|
|
56
|
+
}
|
|
57
|
+
return await this.fetch(`/v1/customers/${id}`);
|
|
58
|
+
}
|
|
59
|
+
async getCustomers(skip = 0, take = 100) {
|
|
60
|
+
return await this.fetch(`/v1/customers?take=${take}&skip=${skip}`);
|
|
61
|
+
}
|
|
62
|
+
async getAllCustomers(items = []) {
|
|
63
|
+
const { data } = (await this.getCustomers(items.length)) || { data: [] };
|
|
64
|
+
return data.length
|
|
65
|
+
? this.getAllCustomers([...items, ...data])
|
|
66
|
+
: [...items, ...data];
|
|
67
|
+
}
|
|
68
|
+
async createCustomer(data) {
|
|
69
|
+
return await this.fetch('/v1/customers', { method: 'POST' }, { currency: 'USD', timezone: 'Etc/UTC', ...data });
|
|
70
|
+
}
|
|
71
|
+
async updateCustomer(id, data) {
|
|
72
|
+
if (!id) {
|
|
73
|
+
this.logger.error('Missing customer ID', { id });
|
|
74
|
+
throw new Error('Missing customer ID');
|
|
75
|
+
}
|
|
76
|
+
return await this.fetch(`/v1/customers/${id}`, { method: 'PUT' }, data);
|
|
77
|
+
}
|
|
78
|
+
async deleteCustomer(id) {
|
|
79
|
+
return await this.fetch(`/v1/customers/${id}`, {
|
|
80
|
+
method: 'DELETE',
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async archiveCustomer(id) {
|
|
84
|
+
return await this.fetch(`/v1/customers/${id}/archive`, {
|
|
85
|
+
method: 'PUT',
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async unarchiveCustomer(id) {
|
|
89
|
+
if (!id) {
|
|
90
|
+
this.logger.error('Missing customer ID', { id });
|
|
91
|
+
throw new Error('Missing customer ID');
|
|
92
|
+
}
|
|
93
|
+
return await this.fetch(`/v1/customers/${id}/unarchive`, { method: 'PUT' });
|
|
94
|
+
}
|
|
95
|
+
async getCustomerPortal(id) {
|
|
96
|
+
return await this.fetch(`/v1/customers/${id}/portal`);
|
|
97
|
+
}
|
|
98
|
+
// SUBSCRIPTION
|
|
99
|
+
async getSubscription(id) {
|
|
100
|
+
if (!id) {
|
|
101
|
+
this.logger.error('Missing subscription ID', { id });
|
|
102
|
+
throw new Error('Missing subscription ID');
|
|
103
|
+
}
|
|
104
|
+
return await this.fetch(`/v2/subscriptions/${id}?include_live_billing=true`);
|
|
105
|
+
}
|
|
106
|
+
async getSubscriptions(skip = 0, take = 100, query = {
|
|
107
|
+
status: 'all',
|
|
108
|
+
}) {
|
|
109
|
+
return await this.fetch(`/v2/subscriptions?take=${take}&skip=${skip}${Object.entries(query)
|
|
110
|
+
.filter(([_, value]) => value !== undefined)
|
|
111
|
+
.map(([key, value]) => `&${key}=${value}`)
|
|
112
|
+
.join('')}`);
|
|
113
|
+
}
|
|
114
|
+
async getAllSubscriptions(items = [], query = {}) {
|
|
115
|
+
const { data } = (await this.getSubscriptions(items.length, 100, query)) || { data: [] };
|
|
116
|
+
return data.length
|
|
117
|
+
? this.getAllSubscriptions([...items, ...data], query)
|
|
118
|
+
: [...items, ...data];
|
|
119
|
+
}
|
|
120
|
+
async createSubscription(data) {
|
|
121
|
+
return await this.fetch('/v2/subscriptions', { method: 'POST' }, data);
|
|
122
|
+
}
|
|
123
|
+
async updateSubscription(id, data) {
|
|
124
|
+
return await this.fetch(`/v1/subscriptions/${id}/update`, { method: 'POST' }, data);
|
|
125
|
+
}
|
|
126
|
+
async cancelSubscription(id, data) {
|
|
127
|
+
return await this.fetch(`/v1/subscriptions/${id}/cancel`, {
|
|
128
|
+
method: 'POST',
|
|
129
|
+
}, data);
|
|
130
|
+
}
|
|
131
|
+
async reinstateSubscription(id) {
|
|
132
|
+
return await this.fetch(`/v1/subscriptions/${id}/reinstate`, {
|
|
133
|
+
method: 'POST',
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
// PLAN
|
|
137
|
+
async getPlan(id) {
|
|
138
|
+
if (!id) {
|
|
139
|
+
this.logger.error('Missing plan ID', { id });
|
|
140
|
+
throw new Error('Missing plan ID');
|
|
141
|
+
}
|
|
142
|
+
return await this.fetch(`/v1/plans/${id}`);
|
|
143
|
+
}
|
|
144
|
+
async getPlans(skip = 0, take = 100) {
|
|
145
|
+
return await this.fetch(`/v1/plans?take=${take}&skip=${skip}`);
|
|
146
|
+
}
|
|
147
|
+
// INVOICE
|
|
148
|
+
async getInvoice(id) {
|
|
149
|
+
if (!id) {
|
|
150
|
+
this.logger.error('Missing invoice ID', { id });
|
|
151
|
+
throw new Error('Missing invoice ID');
|
|
152
|
+
}
|
|
153
|
+
return await this.fetch(`/v1/invoices/${id}`);
|
|
154
|
+
}
|
|
155
|
+
async getInvoices(skip = 0, take = 100, query = { status: 'all' }) {
|
|
156
|
+
return await this.fetch(`/v1/invoices?take=${take}&skip=${skip}&${Object.entries(query)
|
|
157
|
+
.filter(([_, value]) => value !== undefined)
|
|
158
|
+
.map(([key, value]) => `&${key}=${value}`)
|
|
159
|
+
.join('')}`);
|
|
160
|
+
}
|
|
161
|
+
async getInvoicesByCustomerId(id) {
|
|
162
|
+
return await this.fetch(`/v1/invoices?customerId__equals=${id}`);
|
|
163
|
+
}
|
|
164
|
+
async getInvoiceDownload(id) {
|
|
165
|
+
return await this.fetch(
|
|
166
|
+
// TODO: fix if type != unknown paths['/v1/invoices/{id}/download']['get']['responses'][200]['content']['application/pdf']
|
|
167
|
+
`/v1/invoices/${id}/download`, {
|
|
168
|
+
headers: { 'Content-type': 'application/pdf' },
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
async getAllInvoices(items = []) {
|
|
172
|
+
const { data } = (await this.getInvoices(items.length)) || { data: [] };
|
|
173
|
+
return data.length
|
|
174
|
+
? this.getAllInvoices([...items, ...data])
|
|
175
|
+
: [...items, ...data];
|
|
176
|
+
}
|
|
177
|
+
// OTHERS
|
|
178
|
+
async createBillableEvent(data) {
|
|
179
|
+
if (!data.length)
|
|
180
|
+
return { events_created: [] };
|
|
181
|
+
return await this.fetchIngest('/v1/events/batch', { method: 'POST' }, data);
|
|
182
|
+
}
|
|
183
|
+
async getComponentToken(data) {
|
|
184
|
+
return await this.fetch('/v1/integrations/components/token', { method: 'POST' }, data);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"src/","sources":["client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAGvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAI9C,MAAM,OAAO,YAAY;IACvB,YAAY,KAAa,EAAE,SAAiB,OAAO;QACjD,IAAI,CAAC,OAAO,GAAG;YACb,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,KAAK,EAAE;SACjC,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAMO,KAAK,CAAC,UAAU,CACtB,IAAY,EACZ,OAAqB,EACrB,IAA0B;QAE1B,IAAI,IAAI;YAAE,OAAO,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAC;QAEvE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC;YACzD,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,EAAE,CAAC;QAEP,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,WAAW,OAAO,GAAG,IAAI,EAAE,EAAE;YACtD,MAAM,EAAE,KAAK;YACb,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO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EAAE;SAC/C,CACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAA+F,EAAE;QAIjG,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QAExE,OAAO,IAAI,CAAC,MAAM;YAChB,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,SAAS;IAET,KAAK,CAAC,mBAAmB,CAAC,IAA2B;QACnD,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC;QAEhD,OAAO,MAAM,IAAI,CAAC,WAAW,CAC3B,kBAAkB,EAClB,EAAE,MAAM,EAAE,MAAM,EAAE,EAClB,IAAI,CACL,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,IAEvB;QACC,OAAO,MAAM,IAAI,CAAC,KAAK,CAErB,mCAAmC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;CACF","sourcesContent":["import { utc } from '@finalytic/utils';\nimport type { operations, paths } from './_types.generated';\nimport { BillableEvents, CreateBillableEvent } from './types';\nimport { arrayBufferToBase64 } from './utils';\n\nexport type Logger = { error(message?: any, ...optionalParams: any[]): void };\n\nexport class HyperlineAPI {\n constructor(token: string, logger: Logger = console) {\n this.headers = {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n };\n this.logger = logger;\n }\n\n private headers: Record<string, string>;\n\n private logger: Logger;\n\n private async fetchBasic<T>(\n path: string,\n options?: RequestInit,\n data?: Record<string, any>\n ): Promise<T | null> {\n if (data) options = { body: JSON.stringify(data), ...(options || {}) };\n\n const sandbox = this.headers.Authorization.includes('test')\n ? 'sandbox.'\n : '';\n\n const result = await fetch(`https://${sandbox}${path}`, {\n method: 'GET',\n ...options,\n headers: { ...this.headers, ...options?.headers },\n });\n\n if (!result || !result?.ok) {\n const status = result?.status;\n const statusText = result?.statusText;\n\n if (status === 429) {\n // get difference between rate limit reset and now\n const rateLimitReset = utc(result?.headers.get('x-ratelimit-reset'));\n const diff = rateLimitReset.diff(utc(), 'milliseconds');\n\n // wait until rate limit resets\n await new Promise((resolve) => setTimeout(resolve, diff));\n\n return await this.fetchBasic<T>(path, options, data);\n } else if (status === 404) {\n return null;\n } else {\n const content: any = await result.json();\n throw new Error(\n `Hyperline Error ${status} (${statusText}) in ${path} for ${options?.method || 'GET'}: ${content.message}`\n );\n }\n } else if (result.headers.get('content-type')?.includes('application/pdf'))\n return arrayBufferToBase64(await result.arrayBuffer()) as T;\n\n return (await result.json()) as T;\n }\n\n private async fetch<T>(\n path: string,\n options?: RequestInit,\n data?: Record<string, any>\n ): Promise<T | null> {\n return await this.fetchBasic(`api.hyperline.co${path}`, options, data);\n }\n\n private async fetchIngest<T>(\n path: string,\n options?: RequestInit,\n data?: Record<string, any>\n ): Promise<T | null> {\n return await this.fetchBasic(`ingest.hyperline.co${path}`, options, data);\n }\n\n // CUSTOMER\n\n async getCustomer(id?: string) {\n if (!id) {\n this.logger.error('Missing customer ID', { id });\n throw new Error('Missing customer ID');\n }\n\n return await this.fetch<\n paths['/v1/customers/{id}']['get']['responses'][200]['content']['application/json']\n >(`/v1/customers/${id}`);\n }\n\n async getCustomers(skip = 0, take = 100) {\n return await this.fetch<\n paths['/v1/customers']['get']['responses'][200]['content']['application/json']\n >(`/v1/customers?take=${take}&skip=${skip}`);\n }\n\n async getAllCustomers(\n items: paths['/v1/customers']['get']['responses'][200]['content']['application/json']['data'] = []\n ): Promise<\n paths['/v1/customers']['get']['responses'][200]['content']['application/json']['data']\n > {\n const { data } = (await this.getCustomers(items.length)) || { data: [] };\n\n return data.length\n ? this.getAllCustomers([...items, ...data])\n : [...items, ...data];\n }\n\n async createCustomer(\n data: NonNullable<\n paths['/v1/customers']['post']['requestBody']\n >['content']['application/json']\n ) {\n return await this.fetch<\n paths['/v1/customers']['post']['responses'][201]['content']['application/json']\n >(\n '/v1/customers',\n { method: 'POST' },\n { currency: 'USD', timezone: 'Etc/UTC', ...data }\n );\n }\n\n async updateCustomer(\n id: string,\n data: NonNullable<\n paths['/v1/customers/{id}']['put']['requestBody']\n >['content']['application/json']\n ) {\n if (!id) {\n this.logger.error('Missing customer ID', { id });\n throw new Error('Missing customer ID');\n }\n\n return await this.fetch<\n paths['/v1/customers/{id}']['put']['responses'][200]['content']['application/json']\n >(`/v1/customers/${id}`, { method: 'PUT' }, data);\n }\n\n async deleteCustomer(id: string) {\n return await this.fetch<\n paths['/v1/customers/{id}']['delete']['responses'][204]['content']\n >(`/v1/customers/${id}`, {\n method: 'DELETE',\n });\n }\n\n async archiveCustomer(id: string) {\n return await this.fetch<\n paths['/v1/customers/{id}/archive']['put']['responses'][200]['content']['application/json']\n >(`/v1/customers/${id}/archive`, {\n method: 'PUT',\n });\n }\n\n async unarchiveCustomer(id: string) {\n if (!id) {\n this.logger.error('Missing customer ID', { id });\n throw new Error('Missing customer ID');\n }\n\n return await this.fetch<\n paths['/v1/customers/{id}/unarchive']['put']['responses'][200]['content']['application/json']\n >(`/v1/customers/${id}/unarchive`, { method: 'PUT' });\n }\n\n async getCustomerPortal(id: string) {\n return await this.fetch<\n paths['/v1/customers/{id}/portal']['get']['responses'][200]['content']['application/json']\n >(`/v1/customers/${id}/portal`);\n }\n\n // SUBSCRIPTION\n\n async getSubscription(id: string) {\n if (!id) {\n this.logger.error('Missing subscription ID', { id });\n throw new Error('Missing subscription ID');\n }\n\n return await this.fetch<\n paths['/v2/subscriptions/{id}']['get']['responses'][200]['content']['application/json']\n >(`/v2/subscriptions/${id}?include_live_billing=true`);\n }\n\n async getSubscriptions(\n skip = 0,\n take = 100,\n query: operations['getSubscriptions']['parameters']['query'] = {\n status: 'all',\n }\n ) {\n return await this.fetch<\n paths['/v2/subscriptions']['get']['responses'][200]['content']['application/json']\n >(\n `/v2/subscriptions?take=${take}&skip=${skip}${Object.entries(query)\n .filter(([_, value]) => value !== undefined)\n .map(([key, value]) => `&${key}=${value}`)\n .join('')}`\n );\n }\n\n async getAllSubscriptions(\n items: paths['/v2/subscriptions']['get']['responses'][200]['content']['application/json']['data'] = [],\n query: operations['getSubscriptions']['parameters']['query'] = {}\n ): Promise<\n paths['/v2/subscriptions']['get']['responses'][200]['content']['application/json']['data']\n > {\n const { data } = (await this.getSubscriptions(\n items.length,\n 100,\n query\n )) || { data: [] };\n\n return data.length\n ? this.getAllSubscriptions([...items, ...data], query)\n : [...items, ...data];\n }\n\n async createSubscription(\n data: NonNullable<\n paths['/v2/subscriptions']['post']['requestBody']\n >['content']['application/json']\n ) {\n return await this.fetch<\n paths['/v2/subscriptions']['post']['responses'][201]['content']['application/json']\n >('/v2/subscriptions', { method: 'POST' }, data);\n }\n\n async updateSubscription(\n id: string,\n data: NonNullable<\n paths['/v1/subscriptions/{id}/update']['post']['requestBody']\n >['content']['application/json']\n ) {\n return await this.fetch<\n paths['/v1/subscriptions/{id}/update']['post']['responses'][201]['content']['application/json']\n >(`/v1/subscriptions/${id}/update`, { method: 'POST' }, data);\n }\n\n async cancelSubscription(\n id: string,\n data: NonNullable<\n paths['/v1/subscriptions/{id}/cancel']['post']['requestBody']\n >['content']['application/json']\n ) {\n return await this.fetch<\n paths['/v1/subscriptions/{id}/cancel']['post']['responses'][200]['content']['application/json']\n >(\n `/v1/subscriptions/${id}/cancel`,\n {\n method: 'POST',\n },\n data\n );\n }\n\n async reinstateSubscription(id: string) {\n return await this.fetch<\n paths['/v1/subscriptions/{id}/reinstate']['post']['responses'][200]['content']['application/json']\n >(`/v1/subscriptions/${id}/reinstate`, {\n method: 'POST',\n });\n }\n\n // PLAN\n\n async getPlan(id: string) {\n if (!id) {\n this.logger.error('Missing plan ID', { id });\n throw new Error('Missing plan ID');\n }\n\n return await this.fetch<\n paths['/v1/plans/{id}']['get']['responses'][200]['content']['application/json']\n >(`/v1/plans/${id}`);\n }\n\n async getPlans(skip = 0, take = 100) {\n return await this.fetch<\n paths['/v1/plans']['get']['responses'][200]['content']['application/json']\n >(`/v1/plans?take=${take}&skip=${skip}`);\n }\n\n // INVOICE\n\n async getInvoice(id: string) {\n if (!id) {\n this.logger.error('Missing invoice ID', { id });\n throw new Error('Missing invoice ID');\n }\n\n return await this.fetch<\n paths['/v1/invoices/{id}']['get']['responses'][200]['content']['application/json']\n >(`/v1/invoices/${id}`);\n }\n\n async getInvoices(\n skip = 0,\n take = 100,\n query: operations['getInvoices']['parameters']['query'] = { status: 'all' }\n ) {\n return await this.fetch<\n paths['/v1/invoices']['get']['responses'][200]['content']['application/json']\n >(\n `/v1/invoices?take=${take}&skip=${skip}&${Object.entries(query)\n .filter(([_, value]) => value !== undefined)\n .map(([key, value]) => `&${key}=${value}`)\n .join('')}`\n );\n }\n\n async getInvoicesByCustomerId(id: string) {\n return await this.fetch<\n paths['/v1/invoices']['get']['responses'][200]['content']['application/json']\n >(`/v1/invoices?customerId__equals=${id}`);\n }\n\n async getInvoiceDownload(id: string) {\n return await this.fetch<string>(\n // TODO: fix if type != unknown paths['/v1/invoices/{id}/download']['get']['responses'][200]['content']['application/pdf']\n `/v1/invoices/${id}/download`,\n {\n headers: { 'Content-type': 'application/pdf' },\n }\n );\n }\n\n async getAllInvoices(\n items: paths['/v1/invoices']['get']['responses'][200]['content']['application/json']['data'] = []\n ): Promise<\n paths['/v1/invoices']['get']['responses'][200]['content']['application/json']['data']\n > {\n const { data } = (await this.getInvoices(items.length)) || { data: [] };\n\n return data.length\n ? this.getAllInvoices([...items, ...data])\n : [...items, ...data];\n }\n\n // OTHERS\n\n async createBillableEvent(data: CreateBillableEvent[]) {\n if (!data.length) return { events_created: [] };\n\n return await this.fetchIngest<BillableEvents>(\n '/v1/events/batch',\n { method: 'POST' },\n data\n );\n }\n\n async getComponentToken(data: {\n customer_id: string;\n }) {\n return await this.fetch<\n paths['/v1/integrations/components/token']['post']['responses'][201]['content']['application/json']\n >('/v1/integrations/components/token', { method: 'POST' }, data);\n }\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { currency_enum } from '@finalytic/graphql';
|
|
2
|
+
import { HyperlineEntities } from './types';
|
|
3
|
+
export declare const VRP_TENANT_ID = "7bfec41f-aa3f-4602-95d2-f7996e4f0e59";
|
|
4
|
+
export declare const DEMO_TEST_PARTNER_TENANT_ID = "0b6a7bd6-56cc-46b5-b2ab-1bd7d1e994fa";
|
|
5
|
+
export declare const XIMPLIFI_TENANT_ID = "d6ab2bbe-e0fc-48d9-89a3-c3c05f4e79b5";
|
|
6
|
+
export declare const XIMPLIFI_CUSTOMER_ID = "cus_HDUZawnaJbPa9p";
|
|
7
|
+
export declare const XIMPLIFI_COUPON_ID = "cou_MXCaik3r19_Xkn";
|
|
8
|
+
export declare const ACCOUNTING_PARTNER_COUPON_ID = "cou_PJQ328MBAD9kxY";
|
|
9
|
+
export declare const HYPERLINE_DEFAULT_PLAN_ID = "plan_Dyb5P0ICZ6HsIT";
|
|
10
|
+
export declare const HYPERLINE_PARTNER_PLAN_ID = "plan_vkYJcCz7z0XD0N";
|
|
11
|
+
export declare const DEV_HYPERLINE_DEFAULT_PLAN_ID = "plan_UTCVXFQnKD0oMS";
|
|
12
|
+
export declare const WEBHOOKS: {
|
|
13
|
+
'payment_method.created': "hyperline_payment_method_created";
|
|
14
|
+
'payment_method.errored': "hyperline_payment_method_errored";
|
|
15
|
+
'payment_method.deleted': "hyperline_payment_method_deleted";
|
|
16
|
+
'subscription.activated': "hyperline_subscription_status_changed";
|
|
17
|
+
'subscription.reactivated': "hyperline_subscription_status_changed";
|
|
18
|
+
'subscription.cancelled': "hyperline_subscription_status_changed";
|
|
19
|
+
'subscription.cancellation_scheduled': "hyperline_subscription_cancellation_scheduled";
|
|
20
|
+
'subscription.errored': "hyperline_subscription_status_changed";
|
|
21
|
+
'subscription.paused': "hyperline_subscription_status_changed";
|
|
22
|
+
'subscription.voided': "hyperline_subscription_status_changed";
|
|
23
|
+
'customer.created': "hyperline_customer_created";
|
|
24
|
+
'customer.updated': "hyperline_customer_updated";
|
|
25
|
+
};
|
|
26
|
+
export declare const CURRENCY_MAP: Record<currency_enum, HyperlineEntities['Currency'] | undefined>;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
export const VRP_TENANT_ID = '7bfec41f-aa3f-4602-95d2-f7996e4f0e59';
|
|
2
|
+
export const DEMO_TEST_PARTNER_TENANT_ID = '0b6a7bd6-56cc-46b5-b2ab-1bd7d1e994fa';
|
|
3
|
+
export const XIMPLIFI_TENANT_ID = 'd6ab2bbe-e0fc-48d9-89a3-c3c05f4e79b5';
|
|
4
|
+
// Hyperline
|
|
5
|
+
export const XIMPLIFI_CUSTOMER_ID = 'cus_HDUZawnaJbPa9p';
|
|
6
|
+
export const XIMPLIFI_COUPON_ID = 'cou_MXCaik3r19_Xkn';
|
|
7
|
+
export const ACCOUNTING_PARTNER_COUPON_ID = 'cou_PJQ328MBAD9kxY';
|
|
8
|
+
export const HYPERLINE_DEFAULT_PLAN_ID = 'plan_Dyb5P0ICZ6HsIT';
|
|
9
|
+
export const HYPERLINE_PARTNER_PLAN_ID = 'plan_vkYJcCz7z0XD0N';
|
|
10
|
+
export const DEV_HYPERLINE_DEFAULT_PLAN_ID = 'plan_UTCVXFQnKD0oMS';
|
|
11
|
+
export const WEBHOOKS = {
|
|
12
|
+
'payment_method.created': 'hyperline_payment_method_created',
|
|
13
|
+
'payment_method.errored': 'hyperline_payment_method_errored',
|
|
14
|
+
'payment_method.deleted': 'hyperline_payment_method_deleted',
|
|
15
|
+
'subscription.activated': 'hyperline_subscription_status_changed',
|
|
16
|
+
'subscription.reactivated': 'hyperline_subscription_status_changed',
|
|
17
|
+
'subscription.cancelled': 'hyperline_subscription_status_changed',
|
|
18
|
+
'subscription.cancellation_scheduled': 'hyperline_subscription_cancellation_scheduled',
|
|
19
|
+
// 'subscription.created': 'hyperline_subscription_created',
|
|
20
|
+
'subscription.errored': 'hyperline_subscription_status_changed',
|
|
21
|
+
'subscription.paused': 'hyperline_subscription_status_changed',
|
|
22
|
+
'subscription.voided': 'hyperline_subscription_status_changed',
|
|
23
|
+
// 'subscription.charged': 'hyperline_subscription_charged',
|
|
24
|
+
'customer.created': 'hyperline_customer_created',
|
|
25
|
+
'customer.updated': 'hyperline_customer_updated',
|
|
26
|
+
};
|
|
27
|
+
export const CURRENCY_MAP = {
|
|
28
|
+
aed: 'AED',
|
|
29
|
+
afn: 'AFN',
|
|
30
|
+
all: 'ALL',
|
|
31
|
+
amd: 'AMD',
|
|
32
|
+
ang: 'ANG',
|
|
33
|
+
aoa: 'AOA',
|
|
34
|
+
ars: 'ARS',
|
|
35
|
+
aud: 'AUD',
|
|
36
|
+
awg: 'AWG',
|
|
37
|
+
azn: 'AZN',
|
|
38
|
+
bam: 'BAM',
|
|
39
|
+
bbd: 'BBD',
|
|
40
|
+
bdt: 'BDT',
|
|
41
|
+
bgn: 'BGN',
|
|
42
|
+
bhd: 'BHD',
|
|
43
|
+
bif: 'BIF',
|
|
44
|
+
bmd: 'BMD',
|
|
45
|
+
bnd: 'BND',
|
|
46
|
+
bob: 'BOB',
|
|
47
|
+
bov: 'BOB',
|
|
48
|
+
brl: 'BRL',
|
|
49
|
+
bsd: 'BSD',
|
|
50
|
+
btn: 'BTN',
|
|
51
|
+
bwp: 'BWP',
|
|
52
|
+
byn: 'BYR',
|
|
53
|
+
byr: 'BYR',
|
|
54
|
+
bzd: 'BZD',
|
|
55
|
+
cad: 'CAD',
|
|
56
|
+
cdf: 'CDF',
|
|
57
|
+
che: 'CHF',
|
|
58
|
+
chf: 'CHF',
|
|
59
|
+
chw: 'CHF',
|
|
60
|
+
clf: 'CLP',
|
|
61
|
+
clp: 'CLP',
|
|
62
|
+
cny: 'CNY',
|
|
63
|
+
cop: 'COP',
|
|
64
|
+
cou: 'COP',
|
|
65
|
+
crc: 'CRC',
|
|
66
|
+
cuc: 'CUP',
|
|
67
|
+
cup: 'CUP',
|
|
68
|
+
cve: 'CVE',
|
|
69
|
+
czk: 'CZK',
|
|
70
|
+
djf: 'DJF',
|
|
71
|
+
dkk: 'DKK',
|
|
72
|
+
dop: 'DOP',
|
|
73
|
+
dzd: 'DZD',
|
|
74
|
+
egp: 'EGP',
|
|
75
|
+
ern: 'ERN',
|
|
76
|
+
etb: 'ETB',
|
|
77
|
+
eur: 'EUR',
|
|
78
|
+
fjd: 'FJD',
|
|
79
|
+
fkp: 'FKP',
|
|
80
|
+
gbp: 'GBP',
|
|
81
|
+
gel: 'GEL',
|
|
82
|
+
ghs: 'GHS',
|
|
83
|
+
gip: 'GIP',
|
|
84
|
+
gmd: 'GMD',
|
|
85
|
+
gnf: 'GNF',
|
|
86
|
+
gtq: 'GTQ',
|
|
87
|
+
gyd: 'GYD',
|
|
88
|
+
hkd: 'HKD',
|
|
89
|
+
hnl: 'HNL',
|
|
90
|
+
hrk: 'HRK',
|
|
91
|
+
htg: 'HTG',
|
|
92
|
+
huf: 'HUF',
|
|
93
|
+
idr: 'IDR',
|
|
94
|
+
ils: 'ILS',
|
|
95
|
+
inr: 'INR',
|
|
96
|
+
iqd: 'IQD',
|
|
97
|
+
irr: 'IRR',
|
|
98
|
+
isk: 'ISK',
|
|
99
|
+
jmd: 'JMD',
|
|
100
|
+
jod: 'JOD',
|
|
101
|
+
jpy: 'JPY',
|
|
102
|
+
kes: 'KES',
|
|
103
|
+
kgs: 'KGS',
|
|
104
|
+
khr: 'KHR',
|
|
105
|
+
kmf: 'KMF',
|
|
106
|
+
kpw: 'KPW',
|
|
107
|
+
krw: 'KRW',
|
|
108
|
+
kwd: 'KWD',
|
|
109
|
+
kyd: 'KYD',
|
|
110
|
+
kzt: 'KZT',
|
|
111
|
+
lak: 'LAK',
|
|
112
|
+
lbp: 'LBP',
|
|
113
|
+
lkr: 'LKR',
|
|
114
|
+
lrd: 'LRD',
|
|
115
|
+
lsl: 'LSL',
|
|
116
|
+
ltl: 'EUR',
|
|
117
|
+
lvl: 'EUR',
|
|
118
|
+
lyd: 'LYD',
|
|
119
|
+
mad: 'MAD',
|
|
120
|
+
mdl: 'MDL',
|
|
121
|
+
mga: 'MGA',
|
|
122
|
+
mkd: 'MKD',
|
|
123
|
+
mmk: 'MMK',
|
|
124
|
+
mnt: 'MNT',
|
|
125
|
+
mop: 'MOP',
|
|
126
|
+
mro: 'MRO',
|
|
127
|
+
mur: 'MUR',
|
|
128
|
+
mvr: 'MVR',
|
|
129
|
+
mwk: 'MWK',
|
|
130
|
+
mxn: 'MXN',
|
|
131
|
+
mxv: 'MXN',
|
|
132
|
+
myr: 'MYR',
|
|
133
|
+
mzn: 'MZN',
|
|
134
|
+
nad: 'NAD',
|
|
135
|
+
ngn: 'NGN',
|
|
136
|
+
nio: 'NIO',
|
|
137
|
+
nok: 'NOK',
|
|
138
|
+
npr: 'NPR',
|
|
139
|
+
nzd: 'NZD',
|
|
140
|
+
omr: 'OMR',
|
|
141
|
+
pab: 'PAB',
|
|
142
|
+
pen: 'PEN',
|
|
143
|
+
pgk: 'PGK',
|
|
144
|
+
php: 'PHP',
|
|
145
|
+
pkr: 'PKR',
|
|
146
|
+
pln: 'PLN',
|
|
147
|
+
pyg: 'PYG',
|
|
148
|
+
qar: 'QAR',
|
|
149
|
+
ron: 'RON',
|
|
150
|
+
rsd: 'RSD',
|
|
151
|
+
rub: 'RUB',
|
|
152
|
+
rwf: 'RWF',
|
|
153
|
+
sar: 'SAR',
|
|
154
|
+
sbd: 'SBD',
|
|
155
|
+
scr: 'SCR',
|
|
156
|
+
sdg: 'SDG',
|
|
157
|
+
sek: 'SEK',
|
|
158
|
+
sgd: 'SGD',
|
|
159
|
+
shp: 'SHP',
|
|
160
|
+
sll: 'SLL',
|
|
161
|
+
sos: 'SOS',
|
|
162
|
+
srd: 'SRD',
|
|
163
|
+
ssp: 'SSP',
|
|
164
|
+
std: 'STD',
|
|
165
|
+
syp: 'SYP',
|
|
166
|
+
szl: 'SZL',
|
|
167
|
+
thb: 'THB',
|
|
168
|
+
tjs: 'TJS',
|
|
169
|
+
tmt: 'TMT',
|
|
170
|
+
tnd: 'TND',
|
|
171
|
+
top: 'TOP',
|
|
172
|
+
try: 'TRY',
|
|
173
|
+
ttd: 'TTD',
|
|
174
|
+
twd: 'TWD',
|
|
175
|
+
tzs: 'TZS',
|
|
176
|
+
uah: 'UAH',
|
|
177
|
+
ugx: 'UGX',
|
|
178
|
+
usd: 'USD',
|
|
179
|
+
uyu: 'UYU',
|
|
180
|
+
uzs: 'UZS',
|
|
181
|
+
vef: 'VEF',
|
|
182
|
+
vnd: 'VND',
|
|
183
|
+
vuv: 'VUV',
|
|
184
|
+
wst: 'WST',
|
|
185
|
+
xaf: 'XAF',
|
|
186
|
+
xpf: 'XPF',
|
|
187
|
+
yer: 'YER',
|
|
188
|
+
zar: 'ZAR',
|
|
189
|
+
zmw: 'ZMW',
|
|
190
|
+
zwl: 'ZWL',
|
|
191
|
+
usn: undefined,
|
|
192
|
+
uss: undefined,
|
|
193
|
+
uyi: undefined,
|
|
194
|
+
xag: undefined,
|
|
195
|
+
xau: undefined,
|
|
196
|
+
xba: undefined,
|
|
197
|
+
xbb: undefined,
|
|
198
|
+
xbc: undefined,
|
|
199
|
+
xbd: undefined,
|
|
200
|
+
xcd: undefined,
|
|
201
|
+
xdr: undefined,
|
|
202
|
+
xfu: undefined,
|
|
203
|
+
xof: undefined,
|
|
204
|
+
xpd: undefined,
|
|
205
|
+
xpt: undefined,
|
|
206
|
+
xts: undefined,
|
|
207
|
+
xxx: undefined,
|
|
208
|
+
};
|
|
209
|
+
//# sourceMappingURL=const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"src/","sources":["const.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,aAAa,G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AS;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 '@finalytic/graphql';\nimport type { TrackingEvent } from '@vrplatform/log';\nimport { HyperlineEntities } from './types';\n\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// Hyperline\nexport const XIMPLIFI_CUSTOMER_ID = 'cus_HDUZawnaJbPa9p';\nexport const XIMPLIFI_COUPON_ID = 'cou_MXCaik3r19_Xkn';\nexport const ACCOUNTING_PARTNER_COUPON_ID = 'cou_PJQ328MBAD9kxY';\nexport const HYPERLINE_DEFAULT_PLAN_ID = 'plan_Dyb5P0ICZ6HsIT';\nexport const HYPERLINE_PARTNER_PLAN_ID = 'plan_vkYJcCz7z0XD0N';\nexport const DEV_HYPERLINE_DEFAULT_PLAN_ID = 'plan_UTCVXFQnKD0oMS';\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 'subscription.activated': 'hyperline_subscription_status_changed',\n 'subscription.reactivated': 'hyperline_subscription_status_changed',\n 'subscription.cancelled': 'hyperline_subscription_status_changed',\n 'subscription.cancellation_scheduled':\n 'hyperline_subscription_cancellation_scheduled',\n // 'subscription.created': 'hyperline_subscription_created',\n 'subscription.errored': 'hyperline_subscription_status_changed',\n 'subscription.paused': 'hyperline_subscription_status_changed',\n 'subscription.voided': 'hyperline_subscription_status_changed',\n // 'subscription.charged': 'hyperline_subscription_charged',\n 'customer.created': 'hyperline_customer_created',\n 'customer.updated': 'hyperline_customer_updated',\n} satisfies Record<string, TrackingEvent>;\n\nexport const CURRENCY_MAP: Record<\n currency_enum,\n HyperlineEntities['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":["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"]}
|