@jphil/bookwhen-client 0.2.6 → 0.3.1
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 +146 -15
- package/dist/index.d.ts +199 -3
- package/dist/index.js +6575 -4
- package/dist/index.js.map +1 -1
- package/package.json +33 -21
- package/dist/client/BookwhenClient.d.ts +0 -39
- package/dist/client/BookwhenClient.js +0 -78
- package/dist/client/BookwhenClient.js.map +0 -1
- package/dist/request/BookwhenRequest.d.ts +0 -46
- package/dist/request/BookwhenRequest.js +0 -116
- package/dist/request/BookwhenRequest.js.map +0 -1
- package/dist/request/httpStatusCodes.d.ts +0 -3
- package/dist/request/httpStatusCodes.js +0 -15
- package/dist/request/httpStatusCodes.js.map +0 -1
- package/dist/services/event/Event.d.ts +0 -32
- package/dist/services/event/Event.js +0 -72
- package/dist/services/event/Event.js.map +0 -1
- package/dist/services/event/EventInterfaces.d.ts +0 -53
- package/dist/services/event/EventInterfaces.js +0 -3
- package/dist/services/event/EventInterfaces.js.map +0 -1
- package/dist/services/event/EventSchemas.d.ts +0 -12
- package/dist/services/event/EventSchemas.js +0 -8
- package/dist/services/event/EventSchemas.js.map +0 -1
- package/dist/services/event/EventTypes.d.ts +0 -36
- package/dist/services/event/EventTypes.js +0 -2
- package/dist/services/event/EventTypes.js.map +0 -1
- package/dist/types/GlobalTypes.d.ts +0 -9
- package/dist/types/GlobalTypes.js +0 -2
- package/dist/types/GlobalTypes.js.map +0 -1
- package/dist/utils/http-utils.d.ts +0 -8
- package/dist/utils/http-utils.js +0 -19
- package/dist/utils/http-utils.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jphil/bookwhen-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "TypeScript client for the Bookwhen API (v2)",
|
|
5
5
|
"private": false,
|
|
6
|
+
"type": "module",
|
|
6
7
|
"main": "./dist/index.js",
|
|
7
8
|
"module": "./dist/index.js",
|
|
8
9
|
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
9
17
|
"keywords": [
|
|
10
18
|
"bookwhen",
|
|
11
19
|
"booking",
|
|
12
20
|
"api client"
|
|
13
21
|
],
|
|
14
|
-
"type": "module",
|
|
15
22
|
"author": {
|
|
16
23
|
"name": "Justin Philpott",
|
|
17
24
|
"email": "justin@jphil.dev"
|
|
@@ -35,10 +42,14 @@
|
|
|
35
42
|
"@changesets/cli": "^2.27.9",
|
|
36
43
|
"@commitlint/cli": "^19.5.0",
|
|
37
44
|
"@commitlint/config-conventional": "^19.5.0",
|
|
45
|
+
"@mswjs/data": "^0.16.2",
|
|
46
|
+
"@mswjs/http-middleware": "^0.10.3",
|
|
47
|
+
"@playwright/test": "^1.52.0",
|
|
38
48
|
"@types/node": "^22.9.0",
|
|
39
49
|
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
|
40
50
|
"@typescript-eslint/parser": "^8.13.0",
|
|
41
51
|
"@vitest/coverage-v8": "2.1.3",
|
|
52
|
+
"axios": "^1.7.7",
|
|
42
53
|
"c8": "^10.1.2",
|
|
43
54
|
"commitizen": "^4.3.1",
|
|
44
55
|
"cz-conventional-changelog": "^3.3.0",
|
|
@@ -46,44 +57,45 @@
|
|
|
46
57
|
"eslint": "^9.13.0",
|
|
47
58
|
"eslint-config-prettier": "^9.1.0",
|
|
48
59
|
"eslint-plugin-prettier": "^5.2.1",
|
|
60
|
+
"http-server": "^14.1.1",
|
|
49
61
|
"husky": "^9.1.6",
|
|
62
|
+
"msw": "^2.7.5",
|
|
63
|
+
"playwright": "^1.52.0",
|
|
64
|
+
"playwright-msw": "^3.0.1",
|
|
50
65
|
"prettier": "^3.3.3",
|
|
66
|
+
"start-server-and-test": "^2.0.12",
|
|
51
67
|
"tsup": "^8.3.4",
|
|
52
68
|
"typescript": "^5.6.3",
|
|
53
69
|
"vite": "^5.4.10",
|
|
70
|
+
"vite-plugin-dts": "^4.5.3",
|
|
54
71
|
"vite-tsconfig-paths": "^5.1.0",
|
|
55
|
-
"vitest": "^2.1.3"
|
|
72
|
+
"vitest": "^2.1.3",
|
|
73
|
+
"zod": "^3.23.8"
|
|
56
74
|
},
|
|
57
75
|
"config": {
|
|
58
76
|
"commitizen": {
|
|
59
77
|
"path": "./node_modules/cz-conventional-changelog"
|
|
60
78
|
}
|
|
61
79
|
},
|
|
62
|
-
"
|
|
63
|
-
"axios": "^1.7.
|
|
64
|
-
"zod": "^3.23.
|
|
65
|
-
},
|
|
66
|
-
"exports": {
|
|
67
|
-
".": {
|
|
68
|
-
"types": "./dist/index.d.ts",
|
|
69
|
-
"import": "./dist/index.js"
|
|
70
|
-
}
|
|
80
|
+
"peerDependencies": {
|
|
81
|
+
"axios": "^1.7.0",
|
|
82
|
+
"zod": "^3.23.0"
|
|
71
83
|
},
|
|
72
84
|
"scripts": {
|
|
73
85
|
"dev": "vitest",
|
|
74
|
-
"
|
|
86
|
+
"preview": "vite preview --config vite.preview.config.ts",
|
|
87
|
+
"build": "vite build -c vite.library.config.ts",
|
|
88
|
+
"build:node": "vite build -c vite.test.config.ts",
|
|
75
89
|
"lint": "tsc",
|
|
76
|
-
"test": "
|
|
77
|
-
"
|
|
90
|
+
"serve:test:browser": "http-server . -p 3000 -c-1",
|
|
91
|
+
"test:browser": "playwright test",
|
|
92
|
+
"test:node": "vitest run",
|
|
93
|
+
"test": "pnpm test:node && pnpm build && start-server-and-test serve:test:browser http://localhost:3000 test:browser",
|
|
94
|
+
"test:node:coverage": "vitest run --coverage",
|
|
78
95
|
"type-check": "tsc --noEmit",
|
|
79
96
|
"check-exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
|
|
80
97
|
"prettier-check": "prettier --check 'src/**/*.ts'",
|
|
81
98
|
"format": "prettier --write 'src/**/*.ts' README.md",
|
|
82
|
-
"pre-commit": "pnpm lint && pnpm build"
|
|
83
|
-
"commit": "cz",
|
|
84
|
-
"prepush": "pnpm test",
|
|
85
|
-
"local-release": "changeset version && changeset publish",
|
|
86
|
-
"release": "pnpm lint && pnpm test && pnpm build && changeset publish",
|
|
87
|
-
"ci": "pnpm test && pnpm check-exports && pnpm build"
|
|
99
|
+
"pre-commit": "pnpm lint && pnpm build && pnpm test && pnpm check-exports"
|
|
88
100
|
}
|
|
89
101
|
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { AxiosInstance } from 'axios';
|
|
2
|
-
import { EventService } from '../services/event/Event.js';
|
|
3
|
-
/**
|
|
4
|
-
* Client for the Bookwhen API.
|
|
5
|
-
*
|
|
6
|
-
* @see https://petstore.swagger.io/?url=https://api.bookwhen.com/v2/openapi.yaml#/ClassPass/get_class_passes__class_pass_id_
|
|
7
|
-
*/
|
|
8
|
-
export declare class BookwhenClient {
|
|
9
|
-
private axiosInstance;
|
|
10
|
-
private eventService?;
|
|
11
|
-
/**
|
|
12
|
-
* Creates a new instance of the BookwhenClient class.
|
|
13
|
-
* @param axiosInstance - Configured Axios instance for making HTTP requests.
|
|
14
|
-
* @throws Error if axiosInstance is not provided.
|
|
15
|
-
*/
|
|
16
|
-
constructor(axiosInstance: AxiosInstance);
|
|
17
|
-
/**
|
|
18
|
-
* Gets the EventService instance.
|
|
19
|
-
*
|
|
20
|
-
* Available methods:
|
|
21
|
-
* - getById(params: GetEventByIdParams): Promise<BookwhenEvent>
|
|
22
|
-
* - getMultiple(params: GetMultipleEventsParams): Promise<BookwhenEvent[]>
|
|
23
|
-
*
|
|
24
|
-
* @returns The EventService instance.
|
|
25
|
-
*/
|
|
26
|
-
get events(): EventService;
|
|
27
|
-
}
|
|
28
|
-
interface BookwhenClientOptions {
|
|
29
|
-
apiKey: string;
|
|
30
|
-
baseURL?: string;
|
|
31
|
-
debug?: boolean;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Creates an instance of Axios with the provided API key.
|
|
35
|
-
* @param apiKey - The API key used for authentication.
|
|
36
|
-
* @returns The Axios instance.
|
|
37
|
-
*/
|
|
38
|
-
export declare function createBookwhenClient(options: BookwhenClientOptions): BookwhenClient;
|
|
39
|
-
export {};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// src/clients/BookwhenClient.ts
|
|
2
|
-
import axios from 'axios';
|
|
3
|
-
import { EventService } from '../services/event/Event.js'; // Ensure this file and class are setup accordingly
|
|
4
|
-
import { CLIENT_HTTP_STATUS_CODES } from '../request/httpStatusCodes.js';
|
|
5
|
-
/**
|
|
6
|
-
* Client for the Bookwhen API.
|
|
7
|
-
*
|
|
8
|
-
* @see https://petstore.swagger.io/?url=https://api.bookwhen.com/v2/openapi.yaml#/ClassPass/get_class_passes__class_pass_id_
|
|
9
|
-
*/
|
|
10
|
-
export class BookwhenClient {
|
|
11
|
-
axiosInstance;
|
|
12
|
-
eventService;
|
|
13
|
-
/**
|
|
14
|
-
* Creates a new instance of the BookwhenClient class.
|
|
15
|
-
* @param axiosInstance - Configured Axios instance for making HTTP requests.
|
|
16
|
-
* @throws Error if axiosInstance is not provided.
|
|
17
|
-
*/
|
|
18
|
-
constructor(axiosInstance) {
|
|
19
|
-
this.axiosInstance = axiosInstance;
|
|
20
|
-
if (!axiosInstance) {
|
|
21
|
-
throw new Error('BookwhenClient - you must provide an axios instance');
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Gets the EventService instance.
|
|
26
|
-
*
|
|
27
|
-
* Available methods:
|
|
28
|
-
* - getById(params: GetEventByIdParams): Promise<BookwhenEvent>
|
|
29
|
-
* - getMultiple(params: GetMultipleEventsParams): Promise<BookwhenEvent[]>
|
|
30
|
-
*
|
|
31
|
-
* @returns The EventService instance.
|
|
32
|
-
*/
|
|
33
|
-
get events() {
|
|
34
|
-
if (!this.eventService) {
|
|
35
|
-
this.eventService = new EventService(this.axiosInstance);
|
|
36
|
-
}
|
|
37
|
-
return this.eventService;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Creates an instance of Axios with the provided API key.
|
|
42
|
-
* @param apiKey - The API key used for authentication.
|
|
43
|
-
* @returns The Axios instance.
|
|
44
|
-
*/
|
|
45
|
-
export function createBookwhenClient(options) {
|
|
46
|
-
const { apiKey, baseURL = 'https://api.bookwhen.com/v2', debug = false } = options;
|
|
47
|
-
const axiosInstance = axios.create({
|
|
48
|
-
baseURL: baseURL,
|
|
49
|
-
auth: { username: apiKey, password: '' },
|
|
50
|
-
});
|
|
51
|
-
axiosInstance.interceptors.response.use((response) => response, (error) => {
|
|
52
|
-
if (error.response) {
|
|
53
|
-
const status = error.response.status;
|
|
54
|
-
const clientError = CLIENT_HTTP_STATUS_CODES[status];
|
|
55
|
-
if (clientError) {
|
|
56
|
-
return Promise.reject(new Error(clientError.message));
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else if (error.request) {
|
|
60
|
-
throw new Error('No response received from the server');
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
throw new Error('An error occurred setting up the request');
|
|
64
|
-
}
|
|
65
|
-
return Promise.reject(error);
|
|
66
|
-
});
|
|
67
|
-
if (debug) {
|
|
68
|
-
// Add a request interceptor to log the details
|
|
69
|
-
axiosInstance.interceptors.request.use(request => {
|
|
70
|
-
console.log('Bookwhen Request Debug:', {
|
|
71
|
-
request: request
|
|
72
|
-
});
|
|
73
|
-
return request;
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
return new BookwhenClient(axiosInstance);
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=BookwhenClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BookwhenClient.js","sourceRoot":"","sources":["../../src/client/BookwhenClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAA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I,WAAW,EAAE,CAAC;gBAChB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC,CACF,CAAC;IAEF,IAAG,KAAK,EAAE,CAAC;QACT,+CAA+C;QAC/C,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YAC/C,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE;gBACrC,OAAO,EAAE,OAAO;aACjB,CAAC,CAAC;YACH,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,IAAI,cAAc,CAAC,aAAa,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { Resources, Filters } from "../types/GlobalTypes.js";
|
|
2
|
-
/**
|
|
3
|
-
* QueryBuilder class to help build query strings for Bookwhen API requests.
|
|
4
|
-
*/
|
|
5
|
-
export declare class BookwhenRequest {
|
|
6
|
-
private path;
|
|
7
|
-
private filters;
|
|
8
|
-
private includes;
|
|
9
|
-
constructor(path: string);
|
|
10
|
-
/**
|
|
11
|
-
* Adds filters to the BookwhenQuery object.
|
|
12
|
-
* @param filters - An array of key-value pairs representing the filters to be added.
|
|
13
|
-
*
|
|
14
|
-
* Example resultant query strings:
|
|
15
|
-
* /v2/events?filter[from]=20200401&filter[to]=20200404
|
|
16
|
-
* /v2/events?filter[tag]=tag%20one,tag%20two
|
|
17
|
-
* /v2/events?filter[title]=advanced,pro&filter[detail]=masterclass
|
|
18
|
-
*
|
|
19
|
-
* @see https://petstore.swagger.io/?url=https://api.bookwhen.com/v2/openapi.yaml
|
|
20
|
-
*
|
|
21
|
-
* @returns The updated BookwhenQuery object.
|
|
22
|
-
*/
|
|
23
|
-
addFilters(filters: Filters): BookwhenRequest;
|
|
24
|
-
/**
|
|
25
|
-
* Adds an include query parameter to the BookwhenRequest object.
|
|
26
|
-
* @param includes - An array of strings representing the resources to include.
|
|
27
|
-
*
|
|
28
|
-
* @returns The updated BookwhenRequest object.
|
|
29
|
-
*
|
|
30
|
-
* @throws Error if any include is not a valid string.
|
|
31
|
-
*/
|
|
32
|
-
addIncludes(includes: Resources): BookwhenRequest;
|
|
33
|
-
/**
|
|
34
|
-
* Does the actual work of putting together a valid query string given:
|
|
35
|
-
* - filters
|
|
36
|
-
* - includes
|
|
37
|
-
* - segments
|
|
38
|
-
*
|
|
39
|
-
* @returns
|
|
40
|
-
*/
|
|
41
|
-
build(): string;
|
|
42
|
-
/**
|
|
43
|
-
* @returns the constructed query string
|
|
44
|
-
*/
|
|
45
|
-
toString(): string;
|
|
46
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
/**
|
|
3
|
-
* QueryBuilder class to help build query strings for Bookwhen API requests.
|
|
4
|
-
*/
|
|
5
|
-
export class BookwhenRequest {
|
|
6
|
-
path = '';
|
|
7
|
-
filters = [];
|
|
8
|
-
includes = [];
|
|
9
|
-
constructor(path) {
|
|
10
|
-
try {
|
|
11
|
-
if (!path) {
|
|
12
|
-
throw new Error('Path is required');
|
|
13
|
-
}
|
|
14
|
-
this.path = path;
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
throw new Error("BookwhenQuery error: " + error.message);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Adds filters to the BookwhenQuery object.
|
|
22
|
-
* @param filters - An array of key-value pairs representing the filters to be added.
|
|
23
|
-
*
|
|
24
|
-
* Example resultant query strings:
|
|
25
|
-
* /v2/events?filter[from]=20200401&filter[to]=20200404
|
|
26
|
-
* /v2/events?filter[tag]=tag%20one,tag%20two
|
|
27
|
-
* /v2/events?filter[title]=advanced,pro&filter[detail]=masterclass
|
|
28
|
-
*
|
|
29
|
-
* @see https://petstore.swagger.io/?url=https://api.bookwhen.com/v2/openapi.yaml
|
|
30
|
-
*
|
|
31
|
-
* @returns The updated BookwhenQuery object.
|
|
32
|
-
*/
|
|
33
|
-
addFilters(filters) {
|
|
34
|
-
// @todo add zod validation for filters?
|
|
35
|
-
try {
|
|
36
|
-
for (let key in filters) {
|
|
37
|
-
let value = filters[key];
|
|
38
|
-
if (Array.isArray(value) && value && value.length > 0) {
|
|
39
|
-
const encodedValues = value
|
|
40
|
-
.filter((v) => typeof v === 'string' && v.length > 0)
|
|
41
|
-
.map((v) => encodeURIComponent(v))
|
|
42
|
-
.join(',');
|
|
43
|
-
this.filters.push(`filter[${encodeURIComponent(key)}]=${encodedValues}`);
|
|
44
|
-
}
|
|
45
|
-
else if (typeof value === 'string' && value !== '') {
|
|
46
|
-
if (key.length === 0) {
|
|
47
|
-
throw new Error('Invalid filter key' + key);
|
|
48
|
-
}
|
|
49
|
-
this.filters.push(`filter[${encodeURIComponent(key)}]=${encodeURIComponent(value)}`);
|
|
50
|
-
}
|
|
51
|
-
else if (typeof value === 'undefined' && value !== '') {
|
|
52
|
-
// ignore undefined values
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
throw new Error("BookwhenQuery error: " + error.message);
|
|
58
|
-
}
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Adds an include query parameter to the BookwhenRequest object.
|
|
63
|
-
* @param includes - An array of strings representing the resources to include.
|
|
64
|
-
*
|
|
65
|
-
* @returns The updated BookwhenRequest object.
|
|
66
|
-
*
|
|
67
|
-
* @throws Error if any include is not a valid string.
|
|
68
|
-
*/
|
|
69
|
-
addIncludes(includes) {
|
|
70
|
-
try {
|
|
71
|
-
const validIncludes = includes.filter((include) => include.length > 0);
|
|
72
|
-
if (validIncludes.length !== includes.length) {
|
|
73
|
-
throw new Error('Invalid includes');
|
|
74
|
-
}
|
|
75
|
-
if (validIncludes.length > 0) {
|
|
76
|
-
const includeQuery = validIncludes.join(',');
|
|
77
|
-
this.includes.push(`include=${includeQuery}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
throw new Error("BookwhenQuery error: " + error.message);
|
|
82
|
-
}
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Does the actual work of putting together a valid query string given:
|
|
87
|
-
* - filters
|
|
88
|
-
* - includes
|
|
89
|
-
* - segments
|
|
90
|
-
*
|
|
91
|
-
* @returns
|
|
92
|
-
*/
|
|
93
|
-
build() {
|
|
94
|
-
let queryString = '';
|
|
95
|
-
// Concatenate filters and includes, if any
|
|
96
|
-
if (this.filters.length > 0) {
|
|
97
|
-
queryString += this.filters.join('&');
|
|
98
|
-
}
|
|
99
|
-
if (this.includes.length > 0) {
|
|
100
|
-
// Add '&' if filters already added to queryString
|
|
101
|
-
queryString += queryString ? '&' : '';
|
|
102
|
-
queryString += this.includes.join('&');
|
|
103
|
-
}
|
|
104
|
-
// Strip any leading slashes from this.path
|
|
105
|
-
const cleanedPath = this.path.replace(/^\/+/, '');
|
|
106
|
-
// Return the full URI, including query string only if it's non-empty
|
|
107
|
-
return `/${cleanedPath}${queryString ? '?' + queryString : ''}`;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* @returns the constructed query string
|
|
111
|
-
*/
|
|
112
|
-
toString() {
|
|
113
|
-
return this.build();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=BookwhenRequest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BookwhenRequest.js","sour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C;QACtE,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACH,KAAK;QACH,IAAI,WAAW,GAAG,EAAE,CAAC;QAErB,2CAA2C;QAC3C,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,WAAW,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,kDAAkD;YAClD,WAAW,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACtC,WAAW,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzC,CAAC;QAED,2CAA2C;QAC3C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAElD,qEAAqE;QACrE,OAAO,IAAI,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export const CLIENT_HTTP_STATUS_CODES = {
|
|
2
|
-
400: { code: 400, message: 'BookwhenClient: Bad request' },
|
|
3
|
-
401: { code: 401, message: 'BookwhenClient: Unauthorized - check your API key' },
|
|
4
|
-
403: { code: 403, message: 'BookwhenClient: Forbidden - check your permissions' },
|
|
5
|
-
500: { code: 500, message: 'BookwhenClient: Internal server error' },
|
|
6
|
-
502: { code: 502, message: 'BookwhenClient: Bad gateway' },
|
|
7
|
-
503: { code: 503, message: 'BookwhenClient: Service unavailable' },
|
|
8
|
-
504: { code: 504, message: 'BookwhenClient: Gateway timeout' },
|
|
9
|
-
};
|
|
10
|
-
export const SERVICE_HTTP_STATUS_CODES = {
|
|
11
|
-
400: { code: 400, message: 'BookwhenClient: Bad request' },
|
|
12
|
-
404: { code: 404, message: 'BookwhenClient: The requested resource could not be found' },
|
|
13
|
-
429: { code: 429, message: 'BookwhenClient: Rate limit exceeded' },
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=httpStatusCodes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"httpStatusCodes.js","sourceRoot":"","sources":["../../src/request/httpStatusCodes.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,wBAAwB,GAA+B;IAClE,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,6BAA6B,EAAE;IAC1D,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,mDAAmD,EAAE;IAChF,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,oDAAoD,EAAE;IACjF,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,uCAAuC,EAAE;IACpE,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,6BAA6B,EAAE;IAC1D,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,qCAAqC,EAAE;IAClE,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,iCAAiC,EAAE;CAC/D,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAA+B;IACnE,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,6BAA6B,EAAE;IAC1D,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,2DAA2D,EAAE;IACxF,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,qCAAqC,EAAE;CACnE,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { IEventService, GetMultipleEventsParams } from './EventInterfaces.js';
|
|
2
|
-
import type { BookwhenEvent } from './EventTypes.js';
|
|
3
|
-
import type { AxiosInstance } from 'axios';
|
|
4
|
-
import { GetEventByIdParamsSchema } from './EventSchemas.js';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
/**
|
|
7
|
-
* Service class for managing events in the Bookwhen API.
|
|
8
|
-
*/
|
|
9
|
-
export declare class EventService implements IEventService {
|
|
10
|
-
private axiosInstance;
|
|
11
|
-
/**
|
|
12
|
-
* Initializes EventService with an Axios instance for dependency injection.
|
|
13
|
-
* @param axiosInstance - The Axios instance to use for API requests.
|
|
14
|
-
*/
|
|
15
|
-
constructor(axiosInstance: AxiosInstance);
|
|
16
|
-
/**
|
|
17
|
-
* Retrieves a single event by its ID from the Bookwhen API.
|
|
18
|
-
*
|
|
19
|
-
* @param {Object} param - The parameters for retrieving an event.
|
|
20
|
-
* @param {string} param.eventId - The ID of the event to retrieve.
|
|
21
|
-
* @param {string} [param.include] - Optional parameter to include additional data.
|
|
22
|
-
* @returns {Promise<BookwhenEvent>} A Promise that resolves to the BookwhenEvent object.
|
|
23
|
-
*/
|
|
24
|
-
getById(params: z.infer<typeof GetEventByIdParamsSchema>): Promise<BookwhenEvent>;
|
|
25
|
-
/**
|
|
26
|
-
* Retrieves multiple events based on filtering and pagination parameters.
|
|
27
|
-
*
|
|
28
|
-
* @param {GetMultipleEventsParams} params - Optional parameters for filtering and pagination.
|
|
29
|
-
* @return {Promise<BookwhenEvent[]>} A Promise that resolves to an array of BookwhenEvent objects.
|
|
30
|
-
*/
|
|
31
|
-
getMultiple(params?: GetMultipleEventsParams): Promise<BookwhenEvent[]>;
|
|
32
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { handleServiceHTTPErrors } from '../../utils/http-utils.js';
|
|
2
|
-
import { SERVICE_HTTP_STATUS_CODES } from '../../request/httpStatusCodes.js';
|
|
3
|
-
import { BookwhenRequest } from '../../request/BookwhenRequest.js';
|
|
4
|
-
import { GetEventByIdParamsSchema } from './EventSchemas.js';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
/**
|
|
7
|
-
* Service class for managing events in the Bookwhen API.
|
|
8
|
-
*/
|
|
9
|
-
export class EventService {
|
|
10
|
-
axiosInstance;
|
|
11
|
-
/**
|
|
12
|
-
* Initializes EventService with an Axios instance for dependency injection.
|
|
13
|
-
* @param axiosInstance - The Axios instance to use for API requests.
|
|
14
|
-
*/
|
|
15
|
-
constructor(axiosInstance) {
|
|
16
|
-
this.axiosInstance = axiosInstance;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Retrieves a single event by its ID from the Bookwhen API.
|
|
20
|
-
*
|
|
21
|
-
* @param {Object} param - The parameters for retrieving an event.
|
|
22
|
-
* @param {string} param.eventId - The ID of the event to retrieve.
|
|
23
|
-
* @param {string} [param.include] - Optional parameter to include additional data.
|
|
24
|
-
* @returns {Promise<BookwhenEvent>} A Promise that resolves to the BookwhenEvent object.
|
|
25
|
-
*/
|
|
26
|
-
async getById(params) {
|
|
27
|
-
try {
|
|
28
|
-
const validParams = GetEventByIdParamsSchema.parse(params);
|
|
29
|
-
const query = new BookwhenRequest(`/events/${validParams.eventId}`);
|
|
30
|
-
if (validParams.includes) {
|
|
31
|
-
query.addIncludes(validParams.includes);
|
|
32
|
-
}
|
|
33
|
-
const response = await this.axiosInstance.get(`${query}`);
|
|
34
|
-
return response.data?.data;
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
if (error instanceof z.ZodError) {
|
|
38
|
-
const errorMessages = error.errors.map(e => e.message).join(', ');
|
|
39
|
-
throw new Error(`events.getById: Schema Validation failed: ${errorMessages}`);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
handleServiceHTTPErrors(error, SERVICE_HTTP_STATUS_CODES, {
|
|
43
|
-
404: {
|
|
44
|
-
code: 404,
|
|
45
|
-
message: 'Event not found. Please check the event ID and try again.',
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Retrieves multiple events based on filtering and pagination parameters.
|
|
53
|
-
*
|
|
54
|
-
* @param {GetMultipleEventsParams} params - Optional parameters for filtering and pagination.
|
|
55
|
-
* @return {Promise<BookwhenEvent[]>} A Promise that resolves to an array of BookwhenEvent objects.
|
|
56
|
-
*/
|
|
57
|
-
async getMultiple(params = {}) {
|
|
58
|
-
try {
|
|
59
|
-
const query = new BookwhenRequest('/events');
|
|
60
|
-
if (params.includes)
|
|
61
|
-
query.addIncludes(params.includes);
|
|
62
|
-
if (params.filters)
|
|
63
|
-
query.addFilters(params.filters);
|
|
64
|
-
const response = await this.axiosInstance.get(`${query}`); // uses the toString method
|
|
65
|
-
return response.data.data;
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
handleServiceHTTPErrors(error, SERVICE_HTTP_STATUS_CODES);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=Event.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Event.js","sourceRoot":"","sources":["../../../src/services/event/Event.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,OAAO,YAAY;IAEf,aAAa,CAAgB;IAErC;;;OAGG;IACH,YAAY,aAA4B;QACtC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;I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,CAAC;YACxD,IAAI,MAAM,CAAC,OAAO;gBAAE,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAErD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAiB,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,2BAA2B;YACtG,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,uBAAuB,CAAC,KAAK,EAAE,yBAAyB,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { BookwhenEvent } from './EventTypes.js';
|
|
2
|
-
/**
|
|
3
|
-
* Interface for services handling events via the Bookwhen API V2.
|
|
4
|
-
*/
|
|
5
|
-
export interface IEventService {
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves a single event by its ID.
|
|
8
|
-
* @param eventId The unique identifier of the event.
|
|
9
|
-
* @param include Optional parameter to include additional data.
|
|
10
|
-
* @returns A Promise that resolves to an Event object, as defined by the Bookwhen API data structure.
|
|
11
|
-
*/
|
|
12
|
-
getById(params: GetEventByIdParams): Promise<BookwhenEvent>;
|
|
13
|
-
/**
|
|
14
|
-
* Retrieves multiple events based on specified parameters.
|
|
15
|
-
* @param params Optional parameters to filter and control the list of returned events, according to what the Bookwhen API supports.
|
|
16
|
-
* @returns A Promise that resolves to an array of Event objects.
|
|
17
|
-
*/
|
|
18
|
-
getMultiple?(params?: GetMultipleEventsParams): Promise<BookwhenEvent[]>;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Parameters for querying a single event from the Bookwhen API, including optional include parameter.
|
|
22
|
-
* @param eventId The unique identifier of the event.
|
|
23
|
-
* @param include Optional parameter to include additional data.
|
|
24
|
-
*/
|
|
25
|
-
export interface GetEventByIdParams {
|
|
26
|
-
eventId: string;
|
|
27
|
-
includes?: EventResource[];
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Represents the parameters for getting multiple events.
|
|
31
|
-
* @param filter The filter parameters to apply to the query.
|
|
32
|
-
* @param include The data to side load and include with the returned events.
|
|
33
|
-
*/
|
|
34
|
-
export interface GetMultipleEventsParams {
|
|
35
|
-
filters?: EventFilters;
|
|
36
|
-
includes?: EventResource[];
|
|
37
|
-
}
|
|
38
|
-
interface EventFiltersMap {
|
|
39
|
-
calendar?: string[];
|
|
40
|
-
entry?: string[];
|
|
41
|
-
location?: string[];
|
|
42
|
-
tag?: string[];
|
|
43
|
-
title?: string[];
|
|
44
|
-
detail?: string[];
|
|
45
|
-
from?: string;
|
|
46
|
-
to?: string;
|
|
47
|
-
compact?: boolean;
|
|
48
|
-
}
|
|
49
|
-
export type EventFilters = {
|
|
50
|
-
[K in keyof EventFiltersMap]?: EventFiltersMap[K];
|
|
51
|
-
};
|
|
52
|
-
export type EventResource = 'location' | 'attachments' | 'tickets' | 'tickets.events' | 'tickets.class_passes';
|
|
53
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventInterfaces.js","sourceRoot":"","sources":["../../../src/services/event/EventInterfaces.ts"],"names":[],"mappings":"AAqDC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const EventResourceSchema: z.ZodEnum<["location", "attachments", "tickets", "tickets.events", "tickets.class_passes"]>;
|
|
3
|
-
export declare const GetEventByIdParamsSchema: z.ZodObject<{
|
|
4
|
-
eventId: z.ZodString;
|
|
5
|
-
includes: z.ZodOptional<z.ZodArray<z.ZodEnum<["location", "attachments", "tickets", "tickets.events", "tickets.class_passes"]>, "many">>;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
eventId: string;
|
|
8
|
-
includes?: ("location" | "attachments" | "tickets" | "tickets.events" | "tickets.class_passes")[] | undefined;
|
|
9
|
-
}, {
|
|
10
|
-
eventId: string;
|
|
11
|
-
includes?: ("location" | "attachments" | "tickets" | "tickets.events" | "tickets.class_passes")[] | undefined;
|
|
12
|
-
}>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export const EventResourceSchema = z.enum(['location', 'attachments', 'tickets', 'tickets.events', 'tickets.class_passes']);
|
|
3
|
-
// Define GetEventByIdParams schema
|
|
4
|
-
export const GetEventByIdParamsSchema = z.object({
|
|
5
|
-
eventId: z.string().min(1, 'Invalid event ID'),
|
|
6
|
-
includes: EventResourceSchema.array().optional(),
|
|
7
|
-
});
|
|
8
|
-
//# sourceMappingURL=EventSchemas.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventSchemas.js","sourceRoot":"","sources":["../../../src/services/event/EventSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAE,sBAAsB,CAAC,CAAC,CAAC;AAE5H,mCAAmC;AACnC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,kBAAkB,CAAC;IAC9C,QAAQ,EAAE,mBAAmB,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;CACjD,CAAC,CAAC"}
|