UNPKG

4.23 kBTypeScriptView Raw
1declare class SDK {
2 constructor(opts?: Options);
3
4 base: string;
5 token: string | (() => string);
6 auth: string;
7
8 pet: PetAPI;
9 store: PetAPI;
10}
11
12export interface Options {
13 base?: string;
14 token?: string | (() => string);
15}
16
17export interface PetAPI {
18 /**
19 * List all pets
20 */
21 listPets(
22 req: ListPetsRequest,
23 options: fetchOptions
24 ): Promise<ListPetsResponse>;
25 /**
26 * Create a pet
27 */
28 createPet(req: CreatePetRequest): Promise<CreatePetResponse>;
29 /**
30 * Find pet by id
31 */
32 showPetById(req: ShowPetByIdRequest): Promise<ShowPetByIdResponse>;
33 /**
34 * Update pet
35 */
36 updatePet(req: UpdatePetRequest): Promise<UpdatePetResponse>;
37 /**
38 *
39 */
40 deletePet(req: DeletePetRequest): Promise<void>;
41}
42
43export interface ListPetsRequest {
44 query?: {
45 _limit?: number;
46 _offset?: number;
47 _sort?: string;
48 _select?: string[];
49 tag?: string;
50 age_gt?: number;
51 birthAt_gt?: string;
52 birthAt_lt?: string;
53 grade_gt?: string;
54 grade_lt?: string;
55 };
56}
57export interface ListPetsResponse {
58 body: ({
59 /**
60 * pet's name
61 */
62 name?: string;
63 tag?: "DOG" | "CAT";
64 age?: number;
65 birthAt?: string | null;
66 grade?: number;
67 owner?: string;
68 other1?: string;
69 } & {
70 id: string;
71 updateAt?: Date;
72 updateBy?: string;
73 createAt?: Date;
74 createBy?: string;
75 })[];
76 headers: {
77 "X-Total-Count": number;
78 };
79}
80export interface CreatePetRequest {
81 body: {
82 /**
83 * pet's name
84 */
85 name?: string;
86 tag?: "DOG" | "CAT";
87 age?: number;
88 birthAt?: string | null;
89 grade?: number;
90 owner?: string;
91 other2?: string;
92 } & {
93 /**
94 * pet's name
95 */
96 name: string;
97 };
98}
99export interface CreatePetResponse {
100 body: {
101 /**
102 * pet's name
103 */
104 name?: string;
105 tag?: "DOG" | "CAT";
106 age?: number;
107 birthAt?: string | null;
108 grade?: number;
109 owner?: string;
110 other1?: string;
111 } & {
112 id: string;
113 updateAt?: Date;
114 updateBy?: string;
115 createAt?: Date;
116 createBy?: string;
117 };
118}
119export interface ShowPetByIdRequest {
120 petId: string;
121}
122export interface ShowPetByIdResponse {
123 body: {
124 /**
125 * pet's name
126 */
127 name?: string;
128 tag?: "DOG" | "CAT";
129 age?: number;
130 birthAt?: string | null;
131 grade?: number;
132 owner?: string;
133 other1?: string;
134 } & {
135 id: string;
136 updateAt?: Date;
137 updateBy?: string;
138 createAt?: Date;
139 createBy?: string;
140 };
141}
142export interface UpdatePetRequest {
143 petId: string;
144 body: {
145 /**
146 * pet's name
147 */
148 name?: string;
149 tag?: "DOG" | "CAT";
150 age?: number;
151 birthAt?: string | null;
152 grade?: number;
153 owner?: string;
154 other2?: string;
155 };
156}
157export interface UpdatePetResponse {
158 body: {
159 /**
160 * pet's name
161 */
162 name?: string;
163 tag?: "DOG" | "CAT";
164 age?: number;
165 birthAt?: string | null;
166 grade?: number;
167 owner?: string;
168 other1?: string;
169 } & {
170 id: string;
171 updateAt?: Date;
172 updateBy?: string;
173 createAt?: Date;
174 createBy?: string;
175 };
176}
177export interface DeletePetRequest {
178 petId: string;
179}
180export interface PetDoc {
181 /**
182 * pet's name
183 */
184 name?: string;
185 tag?: "DOG" | "CAT";
186 age?: number;
187 birthAt?: string | null;
188 grade?: number;
189 owner?: string;
190 other1?: string;
191}
192
193export type PetCreateDoc = {
194 /**
195 * pet's name
196 */
197 name?: string;
198 tag?: "DOG" | "CAT";
199 age?: number;
200 birthAt?: string | null;
201 grade?: number;
202 owner?: string;
203 other1?: string;
204} & {
205 /**
206 * pet's name
207 */
208 name: string;
209};
210
211export type Pet = {
212 /**
213 * pet's name
214 */
215 name?: string;
216 tag?: "DOG" | "CAT";
217 age?: number;
218 birthAt?: string | null;
219 grade?: number;
220 owner?: string;
221 other1?: string;
222} & {
223 id: string;
224 updateAt?: Date;
225 updateBy?: string;
226 createAt?: Date;
227 createBy?: string;
228};
229
230export interface MongoDefault {
231 id: string;
232 updateAt?: Date;
233 updateBy?: string;
234 createAt?: Date;
235 createBy?: string;
236}
237
238export interface Err {
239 code?: string;
240 type?: string;
241 message: boolean;
242 name: string;
243 details?: {
244 keyword?: string;
245 message?: string;
246 path?: string;
247 value?: string;
248 }[];
249}
250
251export = SDK;
252
\No newline at end of file