@jwn-js/common 1.3.9 → 1.3.13
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/docs/assets/js/search.js +1 -1
- package/docs/classes/ApiError.html +4 -4
- package/docs/classes/Controller.html +62 -32
- package/docs/classes/Jwt.html +4 -4
- package/docs/classes/Memcached.html +4 -4
- package/docs/classes/Model.html +37 -16
- package/docs/classes/Server.html +4 -4
- package/docs/classes/Ssr.html +4 -4
- package/docs/classes/Web.html +15 -15
- package/docs/index.html +7 -4
- package/docs/interfaces/ApiErrorMessage.html +4 -4
- package/docs/interfaces/ContextSsr.html +4 -4
- package/docs/interfaces/ContextWeb.html +24 -16
- package/docs/interfaces/OptionsSsr.html +4 -4
- package/docs/interfaces/OptionsWeb.html +21 -7
- package/docs/interfaces/Route.html +7 -7
- package/docs/interfaces/Schema.html +180 -0
- package/docs/interfaces/ServerHandler.html +4 -4
- package/docs/interfaces/ServerOptions.html +4 -4
- package/docs/interfaces/ServerWebsocket.html +4 -4
- package/docs/modules.html +9 -5
- package/index.d.ts +124 -96
- package/index.js +276 -185
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -6,10 +6,19 @@ import { HttpResponse, HttpRequest } from 'uWebSockets.js';
|
|
|
6
6
|
export { ApiError, ApiErrorMessage } from './ApiError';
|
|
7
7
|
export { Server, Handler as ServerHandler, Options as ServerOptions, Routes as ServerRoutes, WebSocket as ServerWebsocket, codeToStatus } from './Server';
|
|
8
8
|
export { Jwt } from './Jwt';
|
|
9
|
+
export { Memcached } from './Memcached';
|
|
9
10
|
import { Client } from 'memjs';
|
|
10
11
|
import { Query } from 'buildmsql';
|
|
11
12
|
export { Context as ContextSsr } from 'vite-ssr-vue';
|
|
12
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Reed static files
|
|
16
|
+
* @param req
|
|
17
|
+
* @param res
|
|
18
|
+
* @param base
|
|
19
|
+
*/
|
|
20
|
+
declare function staticBody(res: HttpResponse, req: HttpRequest, base: string): Promise<void>;
|
|
21
|
+
|
|
13
22
|
declare class Memcached {
|
|
14
23
|
memjs: Client;
|
|
15
24
|
specialHeaders: Record<string, any>;
|
|
@@ -50,14 +59,6 @@ declare class Memcached {
|
|
|
50
59
|
private objectKeysToLower;
|
|
51
60
|
}
|
|
52
61
|
|
|
53
|
-
/**
|
|
54
|
-
* Reed static files
|
|
55
|
-
* @param req
|
|
56
|
-
* @param res
|
|
57
|
-
* @param base
|
|
58
|
-
*/
|
|
59
|
-
declare function staticBody(res: HttpResponse, req: HttpRequest, base: string): Promise<void>;
|
|
60
|
-
|
|
61
62
|
interface OptionsSsr {
|
|
62
63
|
readonly manifest: Record<string, any>;
|
|
63
64
|
readonly memcached: Memcached;
|
|
@@ -136,6 +137,35 @@ declare class ApiError extends Error {
|
|
|
136
137
|
getHeaders(): Record<string, string>;
|
|
137
138
|
}
|
|
138
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Select controller params from json file
|
|
142
|
+
* And check permissions and method
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
interface Schema {
|
|
146
|
+
controllers: Array<{
|
|
147
|
+
id: number;
|
|
148
|
+
name: string;
|
|
149
|
+
isActive?: boolean;
|
|
150
|
+
isSitemap?: boolean;
|
|
151
|
+
subactions: Array<{
|
|
152
|
+
id: number;
|
|
153
|
+
action: string;
|
|
154
|
+
name: string;
|
|
155
|
+
isPermission?: boolean;
|
|
156
|
+
isCheckMethod?: boolean;
|
|
157
|
+
isLog?: boolean;
|
|
158
|
+
isActive?: boolean;
|
|
159
|
+
}>;
|
|
160
|
+
}>;
|
|
161
|
+
actions: Array<{
|
|
162
|
+
id: number;
|
|
163
|
+
name: string;
|
|
164
|
+
isActive?: boolean;
|
|
165
|
+
method?: method$2 | string;
|
|
166
|
+
}>;
|
|
167
|
+
}
|
|
168
|
+
|
|
139
169
|
declare type method$2 = 'any' | 'connect' | 'del' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
|
|
140
170
|
declare module "uWebSockets.js" {
|
|
141
171
|
interface HttpRequest {
|
|
@@ -151,6 +181,7 @@ interface OptionsWeb {
|
|
|
151
181
|
readonly routes: Array<Route$1>;
|
|
152
182
|
readonly config: Config$1;
|
|
153
183
|
readonly db: Record<string, Query>;
|
|
184
|
+
readonly schema?: Schema;
|
|
154
185
|
readonly [key: string]: any;
|
|
155
186
|
}
|
|
156
187
|
interface Response$1 {
|
|
@@ -163,9 +194,7 @@ interface Config$1 {
|
|
|
163
194
|
db: Record<string, any>;
|
|
164
195
|
[key: string]: any;
|
|
165
196
|
}
|
|
166
|
-
interface
|
|
167
|
-
readonly config: Config$1;
|
|
168
|
-
readonly db: Record<string, Query>;
|
|
197
|
+
interface ActionsParmas$1 {
|
|
169
198
|
controller: {
|
|
170
199
|
id: number;
|
|
171
200
|
name: string;
|
|
@@ -186,20 +215,11 @@ interface ContextWeb {
|
|
|
186
215
|
isActive: boolean;
|
|
187
216
|
method: method$2;
|
|
188
217
|
};
|
|
189
|
-
[key: string]: any;
|
|
190
218
|
}
|
|
191
|
-
interface
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
protocol: string;
|
|
196
|
-
url: string;
|
|
197
|
-
headers: Record<string, any>;
|
|
198
|
-
getRequest: () => Record<string, any>;
|
|
199
|
-
db: Record<string, Query>;
|
|
200
|
-
$stream?: Stream;
|
|
201
|
-
$body?: any;
|
|
202
|
-
$route?: Route$1;
|
|
219
|
+
interface ContextWeb$1 extends ActionsParmas$1 {
|
|
220
|
+
readonly config: Config$1;
|
|
221
|
+
readonly db: Record<string, Query>;
|
|
222
|
+
[key: string]: any;
|
|
203
223
|
}
|
|
204
224
|
/**
|
|
205
225
|
* Entry point for /web api
|
|
@@ -222,7 +242,7 @@ declare class Web {
|
|
|
222
242
|
body: {};
|
|
223
243
|
};
|
|
224
244
|
route: Route$1;
|
|
225
|
-
contextWeb: ContextWeb;
|
|
245
|
+
contextWeb: ContextWeb$1;
|
|
226
246
|
/**
|
|
227
247
|
* @constructor
|
|
228
248
|
* @param res response
|
|
@@ -265,25 +285,8 @@ declare class Web {
|
|
|
265
285
|
error(e: ApiError | Error): void;
|
|
266
286
|
}
|
|
267
287
|
|
|
268
|
-
declare type method$1 = 'any' | 'connect' | 'del' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
|
|
269
|
-
declare module "uWebSockets.js" {
|
|
270
|
-
interface HttpRequest {
|
|
271
|
-
cookies: Record<string, any>;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
interface Route {
|
|
275
|
-
name: string;
|
|
276
|
-
method?: method$1 | Array<method$1>;
|
|
277
|
-
component: any;
|
|
278
|
-
}
|
|
279
|
-
interface Config {
|
|
280
|
-
server: Record<string, any>;
|
|
281
|
-
db: Record<string, any>;
|
|
282
|
-
[key: string]: any;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
288
|
interface TestContext {
|
|
286
|
-
readonly config?: Config;
|
|
289
|
+
readonly config?: Config$1;
|
|
287
290
|
readonly db?: Record<string, Query>;
|
|
288
291
|
controller?: {
|
|
289
292
|
id: number;
|
|
@@ -303,9 +306,9 @@ interface TestContext {
|
|
|
303
306
|
id: number;
|
|
304
307
|
name: string;
|
|
305
308
|
isActive: boolean;
|
|
306
|
-
method: method$
|
|
309
|
+
method: method$2;
|
|
307
310
|
};
|
|
308
|
-
method?: method$
|
|
311
|
+
method?: method$2;
|
|
309
312
|
cookies?: Record<string, any>;
|
|
310
313
|
hostname?: string;
|
|
311
314
|
protocol?: string;
|
|
@@ -314,7 +317,7 @@ interface TestContext {
|
|
|
314
317
|
getRequest?: () => Record<string, any>;
|
|
315
318
|
$stream?: Stream;
|
|
316
319
|
$body?: any;
|
|
317
|
-
$route?: Route;
|
|
320
|
+
$route?: Route$1;
|
|
318
321
|
[key: string]: any;
|
|
319
322
|
}
|
|
320
323
|
/**
|
|
@@ -322,7 +325,64 @@ interface TestContext {
|
|
|
322
325
|
*/
|
|
323
326
|
declare const mountWithContext: <T>($class: new () => T, $context: TestContext, request?: Record<string, any>) => Promise<T>;
|
|
324
327
|
|
|
325
|
-
|
|
328
|
+
declare type method$1 = 'any' | 'connect' | 'del' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
|
|
329
|
+
declare module "uWebSockets.js" {
|
|
330
|
+
interface HttpRequest {
|
|
331
|
+
cookies: Record<string, any>;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
interface Route {
|
|
335
|
+
name: string;
|
|
336
|
+
method?: method$1 | Array<method$1>;
|
|
337
|
+
component: any;
|
|
338
|
+
}
|
|
339
|
+
interface Config {
|
|
340
|
+
server: Record<string, any>;
|
|
341
|
+
db: Record<string, any>;
|
|
342
|
+
[key: string]: any;
|
|
343
|
+
}
|
|
344
|
+
interface ActionsParmas {
|
|
345
|
+
controller: {
|
|
346
|
+
id: number;
|
|
347
|
+
name: string;
|
|
348
|
+
isActive: boolean;
|
|
349
|
+
isSitemap: boolean;
|
|
350
|
+
};
|
|
351
|
+
subaction: {
|
|
352
|
+
id: number;
|
|
353
|
+
name: string;
|
|
354
|
+
isPermission: boolean;
|
|
355
|
+
isCheckMethod: boolean;
|
|
356
|
+
isLog: boolean;
|
|
357
|
+
isActive: boolean;
|
|
358
|
+
};
|
|
359
|
+
action: {
|
|
360
|
+
id: number;
|
|
361
|
+
name: string;
|
|
362
|
+
isActive: boolean;
|
|
363
|
+
method: method$1;
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
interface ContextWeb extends ActionsParmas {
|
|
367
|
+
readonly config: Config;
|
|
368
|
+
readonly db: Record<string, Query>;
|
|
369
|
+
[key: string]: any;
|
|
370
|
+
}
|
|
371
|
+
interface ContextWebController extends ContextWeb {
|
|
372
|
+
method: string;
|
|
373
|
+
cookies: Record<string, any>;
|
|
374
|
+
hostname: string;
|
|
375
|
+
protocol: string;
|
|
376
|
+
url: string;
|
|
377
|
+
headers: Record<string, any>;
|
|
378
|
+
getRequest: () => Record<string, any>;
|
|
379
|
+
db: Record<string, Query>;
|
|
380
|
+
$stream?: Stream;
|
|
381
|
+
$body?: any;
|
|
382
|
+
$route?: Route;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
interface Context extends ContextWeb {
|
|
326
386
|
method: string;
|
|
327
387
|
getRequest: () => Record<string, any>;
|
|
328
388
|
db: Record<string, any>;
|
|
@@ -331,14 +391,14 @@ interface Context$1 extends ContextWeb {
|
|
|
331
391
|
/**
|
|
332
392
|
* Base model
|
|
333
393
|
*/
|
|
334
|
-
declare class Model
|
|
335
|
-
protected $context: Context
|
|
394
|
+
declare class Model {
|
|
395
|
+
protected $context: Context;
|
|
336
396
|
/**
|
|
337
397
|
* Create model
|
|
338
398
|
* @param model
|
|
339
399
|
* @param args
|
|
340
400
|
*/
|
|
341
|
-
protected $create<T extends Model
|
|
401
|
+
protected $create<T extends Model | Record<string, any>, A extends Array<any>>(model: {
|
|
342
402
|
new (...args: [...A]): T;
|
|
343
403
|
}, ...args: [...A]): Promise<T>;
|
|
344
404
|
/**
|
|
@@ -346,14 +406,15 @@ declare class Model$1 {
|
|
|
346
406
|
* @param context
|
|
347
407
|
*/
|
|
348
408
|
$inject(context: any): void;
|
|
349
|
-
getContext(): Context
|
|
409
|
+
getContext(): Context;
|
|
350
410
|
getRequest(): Record<string, any>;
|
|
351
411
|
getConfig(): Record<string, any>;
|
|
352
|
-
getMethod(): method$
|
|
412
|
+
getMethod(): method$1;
|
|
353
413
|
getHeaders(): Record<string, any>;
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
414
|
+
getCookies(): Record<string, any>;
|
|
415
|
+
getController(): Context["controller"];
|
|
416
|
+
getAction(): Context["action"];
|
|
417
|
+
getSubaction(): Context["subaction"];
|
|
357
418
|
getDb(): Record<string, Query>;
|
|
358
419
|
getHome(): Query;
|
|
359
420
|
getPool(key?: string): Query;
|
|
@@ -368,6 +429,7 @@ interface ResponseOptions {
|
|
|
368
429
|
* Base Controller
|
|
369
430
|
*/
|
|
370
431
|
declare class Controller {
|
|
432
|
+
private responseHeaders;
|
|
371
433
|
$context: ContextWebController;
|
|
372
434
|
/**
|
|
373
435
|
* Set cookies
|
|
@@ -430,7 +492,9 @@ declare class Controller {
|
|
|
430
492
|
* @param options addition options
|
|
431
493
|
*/
|
|
432
494
|
successXml(data?: {}, options?: ResponseOptions): {
|
|
433
|
-
headers:
|
|
495
|
+
headers: {
|
|
496
|
+
"content-type": string;
|
|
497
|
+
} & Record<string, string | string[]> & Record<string, any>;
|
|
434
498
|
body: string;
|
|
435
499
|
memcache: any;
|
|
436
500
|
};
|
|
@@ -450,7 +514,7 @@ declare class Controller {
|
|
|
450
514
|
* @param model
|
|
451
515
|
* @param args
|
|
452
516
|
*/
|
|
453
|
-
$create<T extends Model
|
|
517
|
+
$create<T extends Model | Record<string, any>, A extends Array<any>>(model: {
|
|
454
518
|
new (...args: [...A]): T;
|
|
455
519
|
}, ...args: [...A]): Promise<T>;
|
|
456
520
|
/**
|
|
@@ -463,7 +527,7 @@ declare class Controller {
|
|
|
463
527
|
getBody(): Buffer;
|
|
464
528
|
getStream(): Stream;
|
|
465
529
|
getConfig(): Record<string, any>;
|
|
466
|
-
getMethod(): method$
|
|
530
|
+
getMethod(): method$1;
|
|
467
531
|
getCookies(): Record<string, any>;
|
|
468
532
|
getHostname(): string;
|
|
469
533
|
getUrl(): string;
|
|
@@ -475,43 +539,7 @@ declare class Controller {
|
|
|
475
539
|
getSubaction(): ContextWebController["subaction"];
|
|
476
540
|
getHome(): Query;
|
|
477
541
|
getPool(key?: string): Query;
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
interface Context extends ContextWeb {
|
|
481
|
-
method: string;
|
|
482
|
-
getRequest: () => Record<string, any>;
|
|
483
|
-
db: Record<string, any>;
|
|
484
|
-
headers: Record<string, any>;
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* Base model
|
|
488
|
-
*/
|
|
489
|
-
declare class Model {
|
|
490
|
-
protected $context: Context;
|
|
491
|
-
/**
|
|
492
|
-
* Create model
|
|
493
|
-
* @param model
|
|
494
|
-
* @param args
|
|
495
|
-
*/
|
|
496
|
-
protected $create<T extends Model | Record<string, any>, A extends Array<any>>(model: {
|
|
497
|
-
new (...args: [...A]): T;
|
|
498
|
-
}, ...args: [...A]): Promise<T>;
|
|
499
|
-
/**
|
|
500
|
-
* Inject app context
|
|
501
|
-
* @param context
|
|
502
|
-
*/
|
|
503
|
-
$inject(context: any): void;
|
|
504
|
-
getContext(): Context;
|
|
505
|
-
getRequest(): Record<string, any>;
|
|
506
|
-
getConfig(): Record<string, any>;
|
|
507
|
-
getMethod(): method$2;
|
|
508
|
-
getHeaders(): Record<string, any>;
|
|
509
|
-
getController(): Context["controller"];
|
|
510
|
-
getAction(): Context["action"];
|
|
511
|
-
getSubaction(): Context["subaction"];
|
|
512
|
-
getDb(): Record<string, Query>;
|
|
513
|
-
getHome(): Query;
|
|
514
|
-
getPool(key?: string): Query;
|
|
542
|
+
setResponseHeader(key: string, value: string): void;
|
|
515
543
|
}
|
|
516
544
|
|
|
517
545
|
/**
|
|
@@ -644,4 +672,4 @@ declare const helpers: {
|
|
|
644
672
|
getExt: (path: string) => string;
|
|
645
673
|
};
|
|
646
674
|
|
|
647
|
-
export { ContextWeb, Controller,
|
|
675
|
+
export { ContextWeb$1 as ContextWeb, Controller, Model, OptionsSsr, OptionsWeb, Route$1 as Route, Schema, Ssr, Web, action, body, config, connection, context, controller, cookies, db, headers, helpers, home, hostname, http, init, json, logerror, method, mixin, mountWithContext as mount, pool, protocol, request, stream, subaction, url, xml };
|