tonightpass 0.0.80 → 0.0.82
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +14 -0
- package/dist/index.d.mts +144 -397
- package/dist/index.d.ts +144 -397
- package/dist/index.js +37 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/rest/client.ts +79 -27
- package/src/rest/endpoints.ts +0 -17
- package/src/rest/request/request.ts +1 -1
- package/src/rest/types/organizations/events/tickets/index.ts +2 -1
- package/src/rest/types/organizations/members/index.ts +1 -1
package/src/rest/client.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { pathcat } from "pathcat";
|
|
2
|
-
import { Options, Response } from "redaxios";
|
|
2
|
+
import { Options, Response as RedaxiosResponse } from "redaxios";
|
|
3
3
|
|
|
4
4
|
import { ParamValue, Query } from "..";
|
|
5
|
-
import {
|
|
5
|
+
import { Endpoints } from "./endpoints";
|
|
6
6
|
import { APIRequestOptions, request } from "./request";
|
|
7
7
|
import { DEFAULT_API_URL } from "../constants";
|
|
8
8
|
|
|
@@ -11,11 +11,43 @@ export type PathsFor<M extends Options["method"]> = Extract<
|
|
|
11
11
|
{ method: M }
|
|
12
12
|
>["path"];
|
|
13
13
|
|
|
14
|
+
export type SuccessfulAPIResponse<T> = {
|
|
15
|
+
success: true;
|
|
16
|
+
data: T;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type ErroredAPIResponse = {
|
|
20
|
+
success: false;
|
|
21
|
+
message: string;
|
|
22
|
+
errors?: {
|
|
23
|
+
[key: string]: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type APIResponse<T> = SuccessfulAPIResponse<T> | ErroredAPIResponse;
|
|
28
|
+
|
|
29
|
+
export type PromisedAPIResponse<T> = Promise<APIResponse<T>>;
|
|
30
|
+
|
|
31
|
+
export type Response<
|
|
32
|
+
M extends Options["method"],
|
|
33
|
+
P extends PathsFor<M>,
|
|
34
|
+
> = APIResponse<Extract<Endpoints, { method: M; path: P }>["res"]>;
|
|
35
|
+
|
|
36
|
+
export type PromisedResponse<
|
|
37
|
+
M extends Options["method"],
|
|
38
|
+
P extends PathsFor<M>,
|
|
39
|
+
> = PromisedAPIResponse<Extract<Endpoints, { method: M; path: P }>["res"]>;
|
|
40
|
+
|
|
41
|
+
export type Body<M extends Options["method"], P extends PathsFor<M>> = Extract<
|
|
42
|
+
Endpoints,
|
|
43
|
+
{ method: M; path: P }
|
|
44
|
+
>["body"];
|
|
45
|
+
|
|
14
46
|
export class TonightPassAPIError<T> extends Error {
|
|
15
47
|
public readonly status: number;
|
|
16
48
|
|
|
17
49
|
constructor(
|
|
18
|
-
public readonly response:
|
|
50
|
+
public readonly response: RedaxiosResponse<APIResponse<T>>,
|
|
19
51
|
public readonly data: ErroredAPIResponse,
|
|
20
52
|
) {
|
|
21
53
|
super(data.message);
|
|
@@ -49,53 +81,73 @@ export class Client {
|
|
|
49
81
|
query?: Query<Path>,
|
|
50
82
|
options?: APIRequestOptions,
|
|
51
83
|
) {
|
|
52
|
-
return this.requester<
|
|
53
|
-
|
|
54
|
-
|
|
84
|
+
return this.requester<Response<"GET", Path>>(
|
|
85
|
+
"GET",
|
|
86
|
+
path,
|
|
87
|
+
undefined,
|
|
88
|
+
query,
|
|
89
|
+
options,
|
|
90
|
+
);
|
|
55
91
|
}
|
|
56
92
|
|
|
57
|
-
async post<Path extends
|
|
93
|
+
async post<Path extends PathsFor<"POST">>(
|
|
58
94
|
path: Path,
|
|
59
|
-
body:
|
|
95
|
+
body: Body<"POST", Path>,
|
|
60
96
|
query?: Query<Path>,
|
|
61
97
|
options?: APIRequestOptions,
|
|
62
98
|
) {
|
|
63
|
-
return this.requester<
|
|
64
|
-
|
|
65
|
-
|
|
99
|
+
return this.requester<Response<"POST", Path>>(
|
|
100
|
+
"POST",
|
|
101
|
+
path,
|
|
102
|
+
body,
|
|
103
|
+
query,
|
|
104
|
+
options,
|
|
105
|
+
);
|
|
66
106
|
}
|
|
67
107
|
|
|
68
|
-
async put<Path extends
|
|
108
|
+
async put<Path extends PathsFor<"PUT">>(
|
|
69
109
|
path: Path,
|
|
70
|
-
body:
|
|
110
|
+
body: Body<"PUT", Path>,
|
|
71
111
|
query?: Query<Path>,
|
|
72
112
|
options?: APIRequestOptions,
|
|
73
113
|
) {
|
|
74
|
-
return this.requester<
|
|
75
|
-
|
|
76
|
-
|
|
114
|
+
return this.requester<Response<"PUT", Path>>(
|
|
115
|
+
"PUT",
|
|
116
|
+
path,
|
|
117
|
+
body,
|
|
118
|
+
query,
|
|
119
|
+
options,
|
|
120
|
+
);
|
|
77
121
|
}
|
|
78
122
|
|
|
79
|
-
async patch<Path extends
|
|
123
|
+
async patch<Path extends PathsFor<"PATCH">>(
|
|
80
124
|
path: Path,
|
|
81
|
-
body:
|
|
125
|
+
body: Body<"PATCH", Path>,
|
|
82
126
|
query?: Query<Path>,
|
|
83
127
|
options?: APIRequestOptions,
|
|
84
128
|
) {
|
|
85
|
-
return this.requester<
|
|
86
|
-
|
|
87
|
-
|
|
129
|
+
return this.requester<Response<"PATCH", Path>>(
|
|
130
|
+
"PATCH",
|
|
131
|
+
path,
|
|
132
|
+
body,
|
|
133
|
+
query,
|
|
134
|
+
options,
|
|
135
|
+
);
|
|
88
136
|
}
|
|
89
137
|
|
|
90
|
-
async delete<Path extends
|
|
138
|
+
async delete<Path extends PathsFor<"DELETE">>(
|
|
91
139
|
path: Path,
|
|
92
|
-
body:
|
|
140
|
+
body: Body<"DELETE", Path>,
|
|
93
141
|
query?: Query<Path>,
|
|
94
142
|
options?: APIRequestOptions,
|
|
95
143
|
) {
|
|
96
|
-
return this.requester<
|
|
97
|
-
|
|
98
|
-
|
|
144
|
+
return this.requester<Response<"DELETE", Path>>(
|
|
145
|
+
"DELETE",
|
|
146
|
+
path,
|
|
147
|
+
body,
|
|
148
|
+
query,
|
|
149
|
+
options,
|
|
150
|
+
);
|
|
99
151
|
}
|
|
100
152
|
|
|
101
153
|
private async requester<T>(
|
|
@@ -113,7 +165,7 @@ export class Client {
|
|
|
113
165
|
}
|
|
114
166
|
}
|
|
115
167
|
|
|
116
|
-
const response:
|
|
168
|
+
const response: RedaxiosResponse<APIResponse<T>> = await request<T>(url, {
|
|
117
169
|
method,
|
|
118
170
|
data: body,
|
|
119
171
|
...options,
|
package/src/rest/endpoints.ts
CHANGED
|
@@ -12,23 +12,6 @@ import {
|
|
|
12
12
|
WebhookEndpoints,
|
|
13
13
|
} from "./types";
|
|
14
14
|
|
|
15
|
-
export type SuccessfulAPIResponse<T> = {
|
|
16
|
-
success: true;
|
|
17
|
-
data: T;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type ErroredAPIResponse = {
|
|
21
|
-
success: false;
|
|
22
|
-
message: string;
|
|
23
|
-
errors?: {
|
|
24
|
-
[key: string]: string;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type APIResponse<T> = SuccessfulAPIResponse<T> | ErroredAPIResponse;
|
|
29
|
-
|
|
30
|
-
export type PromisedAPIResponse<T> = Promise<APIResponse<T>>;
|
|
31
|
-
|
|
32
15
|
export type Endpoint<
|
|
33
16
|
M extends Options["method"],
|
|
34
17
|
Path extends string,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import axios, { Options, Response } from "redaxios";
|
|
2
2
|
|
|
3
3
|
import { isBrowser } from "../../utils";
|
|
4
|
-
import { APIResponse, ErroredAPIResponse } from "../
|
|
4
|
+
import { APIResponse, ErroredAPIResponse } from "../client";
|
|
5
5
|
|
|
6
6
|
const instance = axios.create({
|
|
7
7
|
headers: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Stripe from "stripe";
|
|
2
2
|
|
|
3
|
-
import { Base } from "../../..";
|
|
3
|
+
import { Base, OrganizationEvent } from "../../..";
|
|
4
4
|
import {
|
|
5
5
|
CreateOrganizationEventTicketDto,
|
|
6
6
|
UpdateOrganizationEventTicketDto,
|
|
@@ -21,6 +21,7 @@ export type OrganizationEventTicket = Base & {
|
|
|
21
21
|
isFeesIncluded: boolean;
|
|
22
22
|
startAt?: Date;
|
|
23
23
|
endAt?: Date;
|
|
24
|
+
event: OrganizationEvent;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
export enum OrganizationEventTicketType {
|