@hlmr/sdk-js 1.12.0 → 1.14.0
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/dist/cjs/client/HlmrClient.d.ts +2 -0
- package/dist/cjs/client/HlmrClient.d.ts.map +1 -1
- package/dist/cjs/client/HlmrClient.js +2 -0
- package/dist/cjs/client/HlmrClient.js.map +1 -1
- package/dist/cjs/index.d.ts +4 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/modules/files.d.ts +14 -0
- package/dist/cjs/modules/files.d.ts.map +1 -0
- package/dist/cjs/modules/files.js +72 -0
- package/dist/cjs/modules/files.js.map +1 -0
- package/dist/cjs/modules/user.d.ts.map +1 -1
- package/dist/cjs/modules/user.js +23 -24
- package/dist/cjs/modules/user.js.map +1 -1
- package/dist/cjs/types/files.d.ts +57 -0
- package/dist/cjs/types/files.d.ts.map +1 -0
- package/dist/cjs/types/files.js +13 -0
- package/dist/cjs/types/files.js.map +1 -0
- package/dist/cjs/types/user.d.ts +32 -14
- package/dist/cjs/types/user.d.ts.map +1 -1
- package/dist/esm/client/HlmrClient.d.ts +2 -0
- package/dist/esm/client/HlmrClient.d.ts.map +1 -1
- package/dist/esm/client/HlmrClient.js +2 -0
- package/dist/esm/client/HlmrClient.js.map +1 -1
- package/dist/esm/index.d.ts +4 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/modules/files.d.ts +14 -0
- package/dist/esm/modules/files.d.ts.map +1 -0
- package/dist/esm/modules/files.js +68 -0
- package/dist/esm/modules/files.js.map +1 -0
- package/dist/esm/modules/user.d.ts.map +1 -1
- package/dist/esm/modules/user.js +23 -24
- package/dist/esm/modules/user.js.map +1 -1
- package/dist/esm/types/files.d.ts +57 -0
- package/dist/esm/types/files.d.ts.map +1 -0
- package/dist/esm/types/files.js +9 -0
- package/dist/esm/types/files.js.map +1 -0
- package/dist/esm/types/user.d.ts +32 -14
- package/dist/esm/types/user.d.ts.map +1 -1
- package/dist/types/client/HlmrClient.d.ts +2 -0
- package/dist/types/client/HlmrClient.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/files.d.ts +14 -0
- package/dist/types/modules/files.d.ts.map +1 -0
- package/dist/types/modules/user.d.ts.map +1 -1
- package/dist/types/types/files.d.ts +57 -0
- package/dist/types/types/files.d.ts.map +1 -0
- package/dist/types/types/user.d.ts +32 -14
- package/dist/types/types/user.d.ts.map +1 -1
- package/dist/umd/hlmr-sdk.js +120 -42
- package/dist/umd/hlmr-sdk.js.map +1 -1
- package/dist/umd/hlmr-sdk.min.js +1 -1
- package/dist/umd/hlmr-sdk.min.js.map +1 -1
- package/package.json +1 -1
package/dist/umd/hlmr-sdk.js
CHANGED
|
@@ -324,39 +324,38 @@
|
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
+
function mapUserProfile(data) {
|
|
328
|
+
var _a, _b, _c;
|
|
329
|
+
return {
|
|
330
|
+
id: data._id || data.id,
|
|
331
|
+
public_name: data.public_name || '',
|
|
332
|
+
display_name: data.display_name,
|
|
333
|
+
avatar_url: data.avatar_url,
|
|
334
|
+
emails: data.emails || [],
|
|
335
|
+
phones: data.phones || [],
|
|
336
|
+
identity: data.identity || {},
|
|
337
|
+
identity_verified: (_a = data.identity_verified) !== null && _a !== void 0 ? _a : false,
|
|
338
|
+
identity_locked: (_b = data.identity_locked) !== null && _b !== void 0 ? _b : false,
|
|
339
|
+
role: data.role,
|
|
340
|
+
is_founder: (_c = data.is_founder) !== null && _c !== void 0 ? _c : false,
|
|
341
|
+
status: data.status,
|
|
342
|
+
created_at: data.created_at || '',
|
|
343
|
+
updated_at: data.updated_at || '',
|
|
344
|
+
deleted_at: data.deleted_at,
|
|
345
|
+
synced_from_supabase_at: data.synced_from_supabase_at,
|
|
346
|
+
};
|
|
347
|
+
}
|
|
327
348
|
class UserModule {
|
|
328
349
|
constructor(http) {
|
|
329
350
|
this.http = http;
|
|
330
351
|
}
|
|
331
352
|
async getProfile() {
|
|
332
353
|
const response = await this.http.get('users/me');
|
|
333
|
-
|
|
334
|
-
return {
|
|
335
|
-
id: userData.user_id,
|
|
336
|
-
email: userData.email || '',
|
|
337
|
-
full_name: userData.display_name || userData.public_name,
|
|
338
|
-
avatar_url: userData.avatar_url,
|
|
339
|
-
user_metadata: userData.user_metadata || {},
|
|
340
|
-
created_at: userData.created_at || '',
|
|
341
|
-
updated_at: userData.updated_at || '',
|
|
342
|
-
last_sign_in_at: userData.last_sign_in_at,
|
|
343
|
-
email_confirmed_at: userData.email_verified ? userData.email_confirmed_at || userData.updated_at : undefined
|
|
344
|
-
};
|
|
354
|
+
return mapUserProfile(response.data.user);
|
|
345
355
|
}
|
|
346
356
|
async updateProfile(params) {
|
|
347
357
|
const response = await this.http.patch('users/me/profile', params);
|
|
348
|
-
|
|
349
|
-
return {
|
|
350
|
-
id: userData.user_id,
|
|
351
|
-
email: userData.email || '',
|
|
352
|
-
full_name: userData.display_name || userData.public_name,
|
|
353
|
-
avatar_url: userData.avatar_url,
|
|
354
|
-
user_metadata: userData.user_metadata || {},
|
|
355
|
-
created_at: userData.created_at || '',
|
|
356
|
-
updated_at: userData.updated_at || '',
|
|
357
|
-
last_sign_in_at: userData.last_sign_in_at,
|
|
358
|
-
email_confirmed_at: userData.email_verified ? userData.email_confirmed_at || userData.updated_at : undefined
|
|
359
|
-
};
|
|
358
|
+
return mapUserProfile(response.data.user);
|
|
360
359
|
}
|
|
361
360
|
async getSettings(appId) {
|
|
362
361
|
const targetAppId = appId || 'default';
|
|
@@ -886,13 +885,13 @@
|
|
|
886
885
|
this.http = http;
|
|
887
886
|
}
|
|
888
887
|
async listOffers(params) {
|
|
889
|
-
const query = buildQueryString$
|
|
888
|
+
const query = buildQueryString$5(params);
|
|
890
889
|
const path = query ? `offers/public/offers?${query}` : 'offers/public/offers';
|
|
891
890
|
const response = await this.http.get(path, { skipAuth: true });
|
|
892
891
|
return response.data;
|
|
893
892
|
}
|
|
894
893
|
async searchOffers(params) {
|
|
895
|
-
const query = buildQueryString$
|
|
894
|
+
const query = buildQueryString$5(params);
|
|
896
895
|
const path = query ? `offers/public/offers/search?${query}` : 'offers/public/offers/search';
|
|
897
896
|
const response = await this.http.get(path, { skipAuth: true });
|
|
898
897
|
return response.data;
|
|
@@ -902,24 +901,24 @@
|
|
|
902
901
|
return response.data;
|
|
903
902
|
}
|
|
904
903
|
async getOfferAvailability(offerId, params) {
|
|
905
|
-
const query = buildQueryString$
|
|
904
|
+
const query = buildQueryString$5(params);
|
|
906
905
|
const response = await this.http.get(`offers/public/offers/${offerId}/availability?${query}`, { skipAuth: true });
|
|
907
906
|
return response.data.days;
|
|
908
907
|
}
|
|
909
908
|
async listDestinations(params) {
|
|
910
|
-
const query = buildQueryString$
|
|
909
|
+
const query = buildQueryString$5(params);
|
|
911
910
|
const path = query ? `geo/public/destinations?${query}` : 'geo/public/destinations';
|
|
912
911
|
const response = await this.http.get(path, { skipAuth: true });
|
|
913
912
|
return response.data;
|
|
914
913
|
}
|
|
915
914
|
async listCities(params) {
|
|
916
|
-
const query = buildQueryString$
|
|
915
|
+
const query = buildQueryString$5(params);
|
|
917
916
|
const path = query ? `geo/public/cities?${query}` : 'geo/public/cities';
|
|
918
917
|
const response = await this.http.get(path, { skipAuth: true });
|
|
919
918
|
return response.data;
|
|
920
919
|
}
|
|
921
920
|
async listDocuments(params) {
|
|
922
|
-
const query = buildQueryString$
|
|
921
|
+
const query = buildQueryString$5(params);
|
|
923
922
|
const path = query ? `terms/public/documents?${query}` : 'terms/public/documents';
|
|
924
923
|
const response = await this.http.get(path, { skipAuth: true });
|
|
925
924
|
return response.data;
|
|
@@ -929,7 +928,7 @@
|
|
|
929
928
|
return response.data;
|
|
930
929
|
}
|
|
931
930
|
}
|
|
932
|
-
function buildQueryString$
|
|
931
|
+
function buildQueryString$5(params) {
|
|
933
932
|
if (!params)
|
|
934
933
|
return '';
|
|
935
934
|
const searchParams = new URLSearchParams();
|
|
@@ -946,13 +945,13 @@
|
|
|
946
945
|
this.http = http;
|
|
947
946
|
}
|
|
948
947
|
async list(params) {
|
|
949
|
-
const query = buildQueryString$
|
|
948
|
+
const query = buildQueryString$4(params);
|
|
950
949
|
const path = query ? `offers/offers?${query}` : 'offers/offers';
|
|
951
950
|
const response = await this.http.get(path);
|
|
952
951
|
return response.data;
|
|
953
952
|
}
|
|
954
953
|
}
|
|
955
|
-
function buildQueryString$
|
|
954
|
+
function buildQueryString$4(params) {
|
|
956
955
|
if (!params)
|
|
957
956
|
return '';
|
|
958
957
|
const searchParams = new URLSearchParams();
|
|
@@ -999,7 +998,7 @@
|
|
|
999
998
|
return response.data.requirement;
|
|
1000
999
|
}
|
|
1001
1000
|
async list(params) {
|
|
1002
|
-
const query = buildQueryString$
|
|
1001
|
+
const query = buildQueryString$3(params);
|
|
1003
1002
|
const path = query ? `booking/bookings?${query}` : 'booking/bookings';
|
|
1004
1003
|
const response = await this.http.get(path);
|
|
1005
1004
|
return response.data;
|
|
@@ -1069,7 +1068,7 @@
|
|
|
1069
1068
|
return response.data.booking;
|
|
1070
1069
|
}
|
|
1071
1070
|
}
|
|
1072
|
-
function buildQueryString$
|
|
1071
|
+
function buildQueryString$3(params) {
|
|
1073
1072
|
if (!params)
|
|
1074
1073
|
return '';
|
|
1075
1074
|
const searchParams = new URLSearchParams();
|
|
@@ -1086,7 +1085,7 @@
|
|
|
1086
1085
|
this.http = http;
|
|
1087
1086
|
}
|
|
1088
1087
|
async getWallets(params) {
|
|
1089
|
-
const query = buildQueryString$
|
|
1088
|
+
const query = buildQueryString$2(params);
|
|
1090
1089
|
const path = query ? `ledger/wallets?${query}` : 'ledger/wallets';
|
|
1091
1090
|
const response = await this.http.get(path);
|
|
1092
1091
|
return response.data;
|
|
@@ -1096,7 +1095,7 @@
|
|
|
1096
1095
|
return response.data.wallet;
|
|
1097
1096
|
}
|
|
1098
1097
|
async getBalanceHistory(walletId, params) {
|
|
1099
|
-
const query = buildQueryString$
|
|
1098
|
+
const query = buildQueryString$2(params);
|
|
1100
1099
|
const path = query
|
|
1101
1100
|
? `ledger/wallets/${walletId}/balance-history?${query}`
|
|
1102
1101
|
: `ledger/wallets/${walletId}/balance-history`;
|
|
@@ -1104,7 +1103,7 @@
|
|
|
1104
1103
|
return response.data;
|
|
1105
1104
|
}
|
|
1106
1105
|
async getTransactions(params) {
|
|
1107
|
-
const query = buildQueryString$
|
|
1106
|
+
const query = buildQueryString$2(params);
|
|
1108
1107
|
const path = query ? `ledger/transactions?${query}` : 'ledger/transactions';
|
|
1109
1108
|
const response = await this.http.get(path);
|
|
1110
1109
|
return response.data;
|
|
@@ -1114,7 +1113,7 @@
|
|
|
1114
1113
|
return response.data.transaction;
|
|
1115
1114
|
}
|
|
1116
1115
|
}
|
|
1117
|
-
function buildQueryString$
|
|
1116
|
+
function buildQueryString$2(params) {
|
|
1118
1117
|
if (!params)
|
|
1119
1118
|
return '';
|
|
1120
1119
|
const searchParams = new URLSearchParams();
|
|
@@ -1196,7 +1195,7 @@
|
|
|
1196
1195
|
return response.data.signature;
|
|
1197
1196
|
}
|
|
1198
1197
|
async listSignatures(params) {
|
|
1199
|
-
const query = buildQueryString(params);
|
|
1198
|
+
const query = buildQueryString$1(params);
|
|
1200
1199
|
const path = query ? `${SIGS}?${query}` : SIGS;
|
|
1201
1200
|
const response = await this.http.get(path);
|
|
1202
1201
|
return response.data;
|
|
@@ -1206,7 +1205,7 @@
|
|
|
1206
1205
|
return response.data.signature;
|
|
1207
1206
|
}
|
|
1208
1207
|
async getPendingDocuments(params) {
|
|
1209
|
-
const query = buildQueryString(params);
|
|
1208
|
+
const query = buildQueryString$1(params);
|
|
1210
1209
|
const path = query ? `${SIGS}/pending?${query}` : `${SIGS}/pending`;
|
|
1211
1210
|
const response = await this.http.get(path);
|
|
1212
1211
|
return response.data;
|
|
@@ -1225,7 +1224,7 @@
|
|
|
1225
1224
|
return response.data;
|
|
1226
1225
|
}
|
|
1227
1226
|
}
|
|
1228
|
-
function buildQueryString(params) {
|
|
1227
|
+
function buildQueryString$1(params) {
|
|
1229
1228
|
if (!params)
|
|
1230
1229
|
return '';
|
|
1231
1230
|
const searchParams = new URLSearchParams();
|
|
@@ -1284,6 +1283,82 @@
|
|
|
1284
1283
|
}
|
|
1285
1284
|
}
|
|
1286
1285
|
|
|
1286
|
+
class FileUploadError extends Error {
|
|
1287
|
+
constructor(step, message, cause) {
|
|
1288
|
+
super(message);
|
|
1289
|
+
this.name = 'FileUploadError';
|
|
1290
|
+
this.step = step;
|
|
1291
|
+
this.cause = cause;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
class FilesModule {
|
|
1296
|
+
constructor(http) {
|
|
1297
|
+
this.http = http;
|
|
1298
|
+
}
|
|
1299
|
+
async upload(blob, options) {
|
|
1300
|
+
let declared;
|
|
1301
|
+
try {
|
|
1302
|
+
const response = await this.http.post('files/files/declare', options);
|
|
1303
|
+
declared = response.data;
|
|
1304
|
+
}
|
|
1305
|
+
catch (err) {
|
|
1306
|
+
throw new FileUploadError('declare', 'Failed to declare file', err);
|
|
1307
|
+
}
|
|
1308
|
+
try {
|
|
1309
|
+
const uploadResponse = await fetch(declared.upload_url, {
|
|
1310
|
+
method: 'PUT',
|
|
1311
|
+
headers: { 'Content-Type': options.content_type },
|
|
1312
|
+
body: blob,
|
|
1313
|
+
});
|
|
1314
|
+
if (!uploadResponse.ok) {
|
|
1315
|
+
throw new Error(`OVH upload failed: ${uploadResponse.status} ${uploadResponse.statusText}`);
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
catch (err) {
|
|
1319
|
+
if (err instanceof FileUploadError)
|
|
1320
|
+
throw err;
|
|
1321
|
+
throw new FileUploadError('upload', 'Failed to upload file to storage', err);
|
|
1322
|
+
}
|
|
1323
|
+
try {
|
|
1324
|
+
const response = await this.http.post(`files/files/${declared.file_id}/confirm`);
|
|
1325
|
+
return response.data;
|
|
1326
|
+
}
|
|
1327
|
+
catch (err) {
|
|
1328
|
+
throw new FileUploadError('confirm', 'Failed to confirm upload', err);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
async list(params) {
|
|
1332
|
+
const query = buildQueryString(params);
|
|
1333
|
+
const path = query ? `files/files?${query}` : 'files/files';
|
|
1334
|
+
const response = await this.http.get(path);
|
|
1335
|
+
return response.data;
|
|
1336
|
+
}
|
|
1337
|
+
async get(fileId) {
|
|
1338
|
+
const response = await this.http.get(`files/files/${fileId}`);
|
|
1339
|
+
return response.data;
|
|
1340
|
+
}
|
|
1341
|
+
async getUrl(fileId) {
|
|
1342
|
+
const response = await this.http.get(`files/files/${fileId}/url`);
|
|
1343
|
+
return response.data;
|
|
1344
|
+
}
|
|
1345
|
+
async delete(fileId) {
|
|
1346
|
+
const response = await this.http.delete(`files/files/${fileId}`);
|
|
1347
|
+
return response.data;
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
function buildQueryString(params) {
|
|
1351
|
+
if (!params)
|
|
1352
|
+
return '';
|
|
1353
|
+
const searchParams = new URLSearchParams();
|
|
1354
|
+
for (const [key, value] of Object.entries(params)) {
|
|
1355
|
+
if (value !== undefined && value !== null) {
|
|
1356
|
+
searchParams.append(key, String(value));
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
return searchParams.toString();
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1287
1362
|
class HlmrClient {
|
|
1288
1363
|
constructor(options) {
|
|
1289
1364
|
const config = this.buildConfig(options);
|
|
@@ -1302,6 +1377,7 @@
|
|
|
1302
1377
|
this.terms = new TermsModule(this.httpClient);
|
|
1303
1378
|
this.promo = new PromoModule(this.httpClient);
|
|
1304
1379
|
this.subscription = new SubscriptionModule(this.httpClient);
|
|
1380
|
+
this.files = new FilesModule(this.httpClient);
|
|
1305
1381
|
}
|
|
1306
1382
|
buildConfig(options) {
|
|
1307
1383
|
var _a, _b, _c;
|
|
@@ -14766,6 +14842,8 @@
|
|
|
14766
14842
|
exports.AppsModule = AppsModule;
|
|
14767
14843
|
exports.BookingModule = BookingModule;
|
|
14768
14844
|
exports.EventsModule = EventsModule;
|
|
14845
|
+
exports.FileUploadError = FileUploadError;
|
|
14846
|
+
exports.FilesModule = FilesModule;
|
|
14769
14847
|
exports.HlmrApiError = HlmrApiError;
|
|
14770
14848
|
exports.HlmrClient = HlmrClient;
|
|
14771
14849
|
exports.LedgerModule = LedgerModule;
|