@hubs101/js-api-skd-client 1.0.10249 → 1.0.10252
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/README.md +29 -29
- package/lib/api/event/index.js +3 -3
- package/lib/utils/api.d.ts +1 -2
- package/lib/utils/api.js +3 -40
- package/package.json +55 -55
package/README.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
## API Doc
|
|
2
|
-
|
|
3
|
-
[API Documentation](https://github.com/We-Conect/event-app-api/blob/main/src/README.md)
|
|
4
|
-
|
|
5
|
-
## Using BaseAPI, stateless
|
|
6
|
-
|
|
7
|
-
Used before initWithToken
|
|
8
|
-
`BaseAPI.login(basePath, username, password)`
|
|
9
|
-
|
|
10
|
-
Accessing API via stateless interface:
|
|
11
|
-
`BaseAPI.fetchAttendees(basePath, token, eventID)`
|
|
12
|
-
|
|
13
|
-
## Using EventAPIProvider
|
|
14
|
-
|
|
15
|
-
1. Wrap app with Provider:
|
|
16
|
-
`import { EventAPIProvider } from '@hubs101/js-api-skd-client';`
|
|
17
|
-
2. Access api via hook:
|
|
18
|
-
` const { fetchAttendees } = useAPIContext();`
|
|
19
|
-
|
|
20
|
-
\*\*First init or initWithToken needs to be called in order to have authentication setup.
|
|
21
|
-
|
|
22
|
-
## Creating new release
|
|
23
|
-
|
|
24
|
-
1. Commit al changes to git.
|
|
25
|
-
2. Prepare build: `npm run build`
|
|
26
|
-
3. Create new patch version run: `npm version patch`
|
|
27
|
-
4. Publish package to NPM: `npm publish`
|
|
28
|
-
|
|
29
|
-
All in one publish alternative run: `npm run new-version`
|
|
1
|
+
## API Doc
|
|
2
|
+
|
|
3
|
+
[API Documentation](https://github.com/We-Conect/event-app-api/blob/main/src/README.md)
|
|
4
|
+
|
|
5
|
+
## Using BaseAPI, stateless
|
|
6
|
+
|
|
7
|
+
Used before initWithToken
|
|
8
|
+
`BaseAPI.login(basePath, username, password)`
|
|
9
|
+
|
|
10
|
+
Accessing API via stateless interface:
|
|
11
|
+
`BaseAPI.fetchAttendees(basePath, token, eventID)`
|
|
12
|
+
|
|
13
|
+
## Using EventAPIProvider
|
|
14
|
+
|
|
15
|
+
1. Wrap app with Provider:
|
|
16
|
+
`import { EventAPIProvider } from '@hubs101/js-api-skd-client';`
|
|
17
|
+
2. Access api via hook:
|
|
18
|
+
` const { fetchAttendees } = useAPIContext();`
|
|
19
|
+
|
|
20
|
+
\*\*First init or initWithToken needs to be called in order to have authentication setup.
|
|
21
|
+
|
|
22
|
+
## Creating new release
|
|
23
|
+
|
|
24
|
+
1. Commit al changes to git.
|
|
25
|
+
2. Prepare build: `npm run build`
|
|
26
|
+
3. Create new patch version run: `npm version patch`
|
|
27
|
+
4. Publish package to NPM: `npm publish`
|
|
28
|
+
|
|
29
|
+
All in one publish alternative run: `npm run new-version`
|
package/lib/api/event/index.js
CHANGED
|
@@ -113,7 +113,7 @@ const _createOption = (basePath, token, data) => __awaiter(void 0, void 0, void
|
|
|
113
113
|
exports._createOption = _createOption;
|
|
114
114
|
const _updateOption = (basePath, token, optionId, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
115
115
|
const base = (0, base_1.getBasePath)(basePath);
|
|
116
|
-
const response = yield (0, api_1.putRequest)(`${base.OPTIONS}/${optionId}`, token, data);
|
|
116
|
+
const response = yield (0, api_1.putRequest)(`${base.OPTIONS}/${optionId}`, token, data, false);
|
|
117
117
|
return response;
|
|
118
118
|
});
|
|
119
119
|
exports._updateOption = _updateOption;
|
|
@@ -288,8 +288,8 @@ const _fetchEventGroups = (basePath, token, eventId) => __awaiter(void 0, void 0
|
|
|
288
288
|
exports._fetchEventGroups = _fetchEventGroups;
|
|
289
289
|
const _fetchMyBookings = (basePath, token) => __awaiter(void 0, void 0, void 0, function* () {
|
|
290
290
|
const base = (0, base_1.getBasePath)(basePath);
|
|
291
|
-
const
|
|
292
|
-
return
|
|
291
|
+
const response = yield (0, api_1.getRequest)(`${base.USERS}/bookings?limit=2000`, token);
|
|
292
|
+
return response;
|
|
293
293
|
});
|
|
294
294
|
exports._fetchMyBookings = _fetchMyBookings;
|
|
295
295
|
const _assignTicket = (basePath, token, bookingId, ticketId, data) => __awaiter(void 0, void 0, void 0, function* () {
|
package/lib/utils/api.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const postRequestSimple: (url: string, body?: any, headers?: any)
|
|
|
6
6
|
export declare const getRequestSimple: (url: string, token?: string, headers?: any) => Promise<string>;
|
|
7
7
|
export declare const deleteRequest: (url: string, body: any, token: string, headers?: any) => Promise<any>;
|
|
8
8
|
export declare const postFileRequest: (url: string, file: any, param: string, token: string) => Promise<any>;
|
|
9
|
-
export declare const putRequest: (url: string, token: string, body: any) => Promise<any>;
|
|
9
|
+
export declare const putRequest: (url: string, token: string, body: any, withoutStatus?: boolean) => Promise<any>;
|
|
10
10
|
export declare const patchRequest: (url: string, token: string, body: any) => Promise<any>;
|
|
11
11
|
export declare const getRequest: (url: string, token?: string, headers?: any) => Promise<any>;
|
|
12
12
|
export declare const getFormRequest: (url: string, token: string, body: any, headers?: any) => Promise<any>;
|
|
@@ -19,4 +19,3 @@ export declare const postRequestWithRetry: (url: string, body?: any, token?: str
|
|
|
19
19
|
export declare const postRequestWE: (url: string, body?: any, token?: string, headers?: any) => Promise<any>;
|
|
20
20
|
export declare const deleteRequestWE: (url: string, token: string) => Promise<any>;
|
|
21
21
|
export declare const postFileRequestWE: (url: string, file: File, param: string, token: string) => Promise<any>;
|
|
22
|
-
export declare const getRequestWE: (url: string, token?: string, headers?: any) => Promise<any>;
|
package/lib/utils/api.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable prettier/prettier */
|
|
3
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
9
|
});
|
|
11
10
|
};
|
|
12
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
12
|
+
exports.postFileRequestWE = exports.deleteRequestWE = exports.postRequestWE = exports.postRequestWithRetry = exports.postFilesAndDataRequest = exports.validateConfig = exports.getFormRequest = exports.getRequest = exports.patchRequest = exports.putRequest = exports.postFileRequest = exports.deleteRequest = exports.getRequestSimple = exports.postRequestSimple = exports.postRequest = exports.trimUndefined = exports.error400 = void 0;
|
|
14
13
|
exports.error400 = '"status":400';
|
|
15
14
|
const trimUndefined = (obj) => Object.keys(obj).reduce((result, key) => obj[key] === undefined ? result : ((result[key] = obj[key]), result), {});
|
|
16
15
|
exports.trimUndefined = trimUndefined;
|
|
@@ -164,7 +163,7 @@ const postFileRequest = (url, file, param, token) => __awaiter(void 0, void 0, v
|
|
|
164
163
|
return data === null || data === void 0 ? void 0 : data.result;
|
|
165
164
|
});
|
|
166
165
|
exports.postFileRequest = postFileRequest;
|
|
167
|
-
const putRequest = (url, token, body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
166
|
+
const putRequest = (url, token, body, withoutStatus = true) => __awaiter(void 0, void 0, void 0, function* () {
|
|
168
167
|
let form;
|
|
169
168
|
if (body) {
|
|
170
169
|
form = new FormData();
|
|
@@ -190,7 +189,7 @@ const putRequest = (url, token, body) => __awaiter(void 0, void 0, void 0, funct
|
|
|
190
189
|
throw { invalid_fields: data.invalid_fields };
|
|
191
190
|
}
|
|
192
191
|
}
|
|
193
|
-
if ((data === null || data === void 0 ? void 0 : data.result) && typeof (data === null || data === void 0 ? void 0 : data.result) !== "string") {
|
|
192
|
+
if ((data === null || data === void 0 ? void 0 : data.result) && typeof (data === null || data === void 0 ? void 0 : data.result) !== "string" && withoutStatus) {
|
|
194
193
|
return data === null || data === void 0 ? void 0 : data.result;
|
|
195
194
|
}
|
|
196
195
|
return data;
|
|
@@ -423,39 +422,3 @@ const postFileRequestWE = (url, file, param, token) => __awaiter(void 0, void 0,
|
|
|
423
422
|
return data === null || data === void 0 ? void 0 : data.result;
|
|
424
423
|
});
|
|
425
424
|
exports.postFileRequestWE = postFileRequestWE;
|
|
426
|
-
const getRequestWE = (url, token, headers) => __awaiter(void 0, void 0, void 0, function* () {
|
|
427
|
-
const response = yield fetch(url, {
|
|
428
|
-
method: "GET",
|
|
429
|
-
headers: Object.assign({ accept: "application/json", Authorization: `Bearer ${token}` }, headers),
|
|
430
|
-
});
|
|
431
|
-
const data = yield response.json();
|
|
432
|
-
if ((data === null || data === void 0 ? void 0 : data.message_code) === 40100001) {
|
|
433
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
434
|
-
console.log(`Error:${data.status} for url:${url}`);
|
|
435
|
-
throw new Error(String(data === null || data === void 0 ? void 0 : data.message_code));
|
|
436
|
-
}
|
|
437
|
-
if (String(data === null || data === void 0 ? void 0 : data.status).startsWith("4")) {
|
|
438
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
439
|
-
console.log(`Error:${data.status} for url:${url}`);
|
|
440
|
-
throw new Error(data.message);
|
|
441
|
-
}
|
|
442
|
-
if ((data === null || data === void 0 ? void 0 : data.error) && (data === null || data === void 0 ? void 0 : data.message)) {
|
|
443
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
444
|
-
console.log(`Error:${data.status} for url:${url}`);
|
|
445
|
-
throw new Error(data.message);
|
|
446
|
-
}
|
|
447
|
-
if ((data === null || data === void 0 ? void 0 : data.code) === 429) {
|
|
448
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
449
|
-
console.log(`Error to may requests for for url:${url}`);
|
|
450
|
-
throw new Error("Error:" + String(data.msg || data.message) + " Try again in 30-60 sec.");
|
|
451
|
-
}
|
|
452
|
-
// handling inconsistency in API response format
|
|
453
|
-
if (Array.isArray(data === null || data === void 0 ? void 0 : data.members)) {
|
|
454
|
-
return data.members;
|
|
455
|
-
}
|
|
456
|
-
if ((data === null || data === void 0 ? void 0 : data.result) && typeof (data === null || data === void 0 ? void 0 : data.result) !== "string") {
|
|
457
|
-
return data.result;
|
|
458
|
-
}
|
|
459
|
-
return data;
|
|
460
|
-
});
|
|
461
|
-
exports.getRequestWE = getRequestWE;
|
package/package.json
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@hubs101/js-api-skd-client",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"author": "Liveware",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"test": "jest --config jestconfig.json",
|
|
7
|
-
"build": "tsc",
|
|
8
|
-
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.ts\"",
|
|
9
|
-
"lint": "tslint -p tsconfig.json",
|
|
10
|
-
"prepare": "npm run build",
|
|
11
|
-
"prepublishOnly": "npm test && npm run lint",
|
|
12
|
-
"preversion": "npm run lint",
|
|
13
|
-
"version": "npm run format && git add -A src",
|
|
14
|
-
"postversion": "git push && git push --tags",
|
|
15
|
-
"new-version": "git pull && npm run build && git commit -m
|
|
16
|
-
},
|
|
17
|
-
"meta": {},
|
|
18
|
-
"description": "Package for easy access to Event App API",
|
|
19
|
-
"repository": {
|
|
20
|
-
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/We-Conect/hubs101-js-api-skd-client.git"
|
|
22
|
-
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"We-Conect",
|
|
25
|
-
"Liveware",
|
|
26
|
-
"EventApp"
|
|
27
|
-
],
|
|
28
|
-
"license": "ISC",
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"@types/react": "*",
|
|
31
|
-
"react": "^18.2.0"
|
|
32
|
-
},
|
|
33
|
-
"peerDependencies": {
|
|
34
|
-
"react": "^18.2.0"
|
|
35
|
-
},
|
|
36
|
-
"main": "lib/index",
|
|
37
|
-
"react-native": "lib/index",
|
|
38
|
-
"types": "lib/index.d.ts",
|
|
39
|
-
"source": "src/index",
|
|
40
|
-
"directories": {
|
|
41
|
-
"test": "test"
|
|
42
|
-
},
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"@types/jest": "^29.5.0",
|
|
45
|
-
"jest": "^29.5.0",
|
|
46
|
-
"prettier": "^2.8.7",
|
|
47
|
-
"ts-jest": "^29.1.0",
|
|
48
|
-
"tslint": "^6.1.3",
|
|
49
|
-
"tslint-config-prettier": "^1.18.0",
|
|
50
|
-
"typescript": "^5.0.4"
|
|
51
|
-
},
|
|
52
|
-
"files": [
|
|
53
|
-
"lib/**/*"
|
|
54
|
-
]
|
|
55
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@hubs101/js-api-skd-client",
|
|
3
|
+
"version": "1.0.10252",
|
|
4
|
+
"author": "Liveware",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "jest --config jestconfig.json",
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.ts\"",
|
|
9
|
+
"lint": "tslint -p tsconfig.json",
|
|
10
|
+
"prepare": "npm run build",
|
|
11
|
+
"prepublishOnly": "npm test && npm run lint",
|
|
12
|
+
"preversion": "npm run lint",
|
|
13
|
+
"version": "npm run format && git add -A src",
|
|
14
|
+
"postversion": "git push && git push --tags",
|
|
15
|
+
"new-version": "git pull && npm run build && git commit -m \"update api\" -a --no-verify && npm version patch && npm publish"
|
|
16
|
+
},
|
|
17
|
+
"meta": {},
|
|
18
|
+
"description": "Package for easy access to Event App API",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/We-Conect/hubs101-js-api-skd-client.git"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"We-Conect",
|
|
25
|
+
"Liveware",
|
|
26
|
+
"EventApp"
|
|
27
|
+
],
|
|
28
|
+
"license": "ISC",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@types/react": "*",
|
|
31
|
+
"react": "^18.2.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": "^18.2.0"
|
|
35
|
+
},
|
|
36
|
+
"main": "lib/index",
|
|
37
|
+
"react-native": "lib/index",
|
|
38
|
+
"types": "lib/index.d.ts",
|
|
39
|
+
"source": "src/index",
|
|
40
|
+
"directories": {
|
|
41
|
+
"test": "test"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/jest": "^29.5.0",
|
|
45
|
+
"jest": "^29.5.0",
|
|
46
|
+
"prettier": "^2.8.7",
|
|
47
|
+
"ts-jest": "^29.1.0",
|
|
48
|
+
"tslint": "^6.1.3",
|
|
49
|
+
"tslint-config-prettier": "^1.18.0",
|
|
50
|
+
"typescript": "^5.0.4"
|
|
51
|
+
},
|
|
52
|
+
"files": [
|
|
53
|
+
"lib/**/*"
|
|
54
|
+
]
|
|
55
|
+
}
|