@jwn-js/common 1.3.10 → 1.3.14
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 +70 -16
- package/docs/classes/Server.html +4 -4
- package/docs/classes/Ssr.html +4 -4
- package/docs/classes/Web.html +4 -4
- package/docs/index.html +4 -4
- package/docs/interfaces/ApiErrorMessage.html +4 -4
- package/docs/interfaces/ContextSsr.html +4 -4
- package/docs/interfaces/ContextWeb.html +4 -4
- package/docs/interfaces/OptionsSsr.html +4 -4
- package/docs/interfaces/OptionsWeb.html +4 -4
- package/docs/interfaces/Route.html +4 -4
- package/docs/interfaces/Schema.html +4 -4
- 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 +4 -4
- package/index.d.ts +7 -1
- package/index.js +27 -4
- package/package.json +1 -1
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
-
<title>ServerWebsocket | @jwn-js/common - v1.3.
|
|
7
|
-
<meta name="description" content="Documentation for @jwn-js/common - v1.3.
|
|
6
|
+
<title>ServerWebsocket | @jwn-js/common - v1.3.14</title>
|
|
7
|
+
<meta name="description" content="Documentation for @jwn-js/common - v1.3.14">
|
|
8
8
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
9
9
|
<link rel="stylesheet" href="../assets/css/main.css">
|
|
10
10
|
<script async src="../assets/js/search.js" id="search-script"></script>
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<li class="state loading">Preparing search index...</li>
|
|
24
24
|
<li class="state failure">The search index is not available</li>
|
|
25
25
|
</ul>
|
|
26
|
-
<a href="../index.html" class="title">@jwn-js/common - v1.3.
|
|
26
|
+
<a href="../index.html" class="title">@jwn-js/common - v1.3.14</a>
|
|
27
27
|
</div>
|
|
28
28
|
<div class="table-cell" id="tsd-widgets">
|
|
29
29
|
<div id="tsd-filter">
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
<div class="container">
|
|
53
53
|
<ul class="tsd-breadcrumb">
|
|
54
54
|
<li>
|
|
55
|
-
<a href="../modules.html">@jwn-js/common - v1.3.
|
|
55
|
+
<a href="../modules.html">@jwn-js/common - v1.3.14</a>
|
|
56
56
|
</li>
|
|
57
57
|
<li>
|
|
58
58
|
<a href="ServerWebsocket.html">ServerWebsocket</a>
|
package/docs/modules.html
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
-
<title>@jwn-js/common - v1.3.
|
|
7
|
-
<meta name="description" content="Documentation for @jwn-js/common - v1.3.
|
|
6
|
+
<title>@jwn-js/common - v1.3.14</title>
|
|
7
|
+
<meta name="description" content="Documentation for @jwn-js/common - v1.3.14">
|
|
8
8
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
9
9
|
<link rel="stylesheet" href="assets/css/main.css">
|
|
10
10
|
<script async src="assets/js/search.js" id="search-script"></script>
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<li class="state loading">Preparing search index...</li>
|
|
24
24
|
<li class="state failure">The search index is not available</li>
|
|
25
25
|
</ul>
|
|
26
|
-
<a href="index.html" class="title">@jwn-js/common - v1.3.
|
|
26
|
+
<a href="index.html" class="title">@jwn-js/common - v1.3.14</a>
|
|
27
27
|
</div>
|
|
28
28
|
<div class="table-cell" id="tsd-widgets">
|
|
29
29
|
<div id="tsd-filter">
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
</div>
|
|
51
51
|
<div class="tsd-page-title">
|
|
52
52
|
<div class="container">
|
|
53
|
-
<h1>@jwn-js/common - v1.3.
|
|
53
|
+
<h1>@jwn-js/common - v1.3.14</h1>
|
|
54
54
|
</div>
|
|
55
55
|
</div>
|
|
56
56
|
</header>
|
package/index.d.ts
CHANGED
|
@@ -411,12 +411,14 @@ declare class Model {
|
|
|
411
411
|
getConfig(): Record<string, any>;
|
|
412
412
|
getMethod(): method$1;
|
|
413
413
|
getHeaders(): Record<string, any>;
|
|
414
|
+
getCookies(): Record<string, any>;
|
|
414
415
|
getController(): Context["controller"];
|
|
415
416
|
getAction(): Context["action"];
|
|
416
417
|
getSubaction(): Context["subaction"];
|
|
417
418
|
getDb(): Record<string, Query>;
|
|
418
419
|
getHome(): Query;
|
|
419
420
|
getPool(key?: string): Query;
|
|
421
|
+
setCookieHeader(name: string, value: any, options?: Record<string, any>): any;
|
|
420
422
|
}
|
|
421
423
|
|
|
422
424
|
interface ResponseOptions {
|
|
@@ -428,6 +430,7 @@ interface ResponseOptions {
|
|
|
428
430
|
* Base Controller
|
|
429
431
|
*/
|
|
430
432
|
declare class Controller {
|
|
433
|
+
private responseHeaders;
|
|
431
434
|
$context: ContextWebController;
|
|
432
435
|
/**
|
|
433
436
|
* Set cookies
|
|
@@ -490,7 +493,9 @@ declare class Controller {
|
|
|
490
493
|
* @param options addition options
|
|
491
494
|
*/
|
|
492
495
|
successXml(data?: {}, options?: ResponseOptions): {
|
|
493
|
-
headers:
|
|
496
|
+
headers: {
|
|
497
|
+
"content-type": string;
|
|
498
|
+
} & Record<string, string | string[]> & Record<string, any>;
|
|
494
499
|
body: string;
|
|
495
500
|
memcache: any;
|
|
496
501
|
};
|
|
@@ -535,6 +540,7 @@ declare class Controller {
|
|
|
535
540
|
getSubaction(): ContextWebController["subaction"];
|
|
536
541
|
getHome(): Query;
|
|
537
542
|
getPool(key?: string): Query;
|
|
543
|
+
setResponseHeader(key: string, value: string): void;
|
|
538
544
|
}
|
|
539
545
|
|
|
540
546
|
/**
|
package/index.js
CHANGED
|
@@ -872,12 +872,15 @@ const cookieString = (name, value, options = {}) => {
|
|
|
872
872
|
|
|
873
873
|
const xmlOptions = { compact: true, ignoreComment: true, spaces: 4 };
|
|
874
874
|
class Controller {
|
|
875
|
+
constructor() {
|
|
876
|
+
this.responseHeaders = {};
|
|
877
|
+
}
|
|
875
878
|
setCookieHeader(name, value, options = {}) {
|
|
876
879
|
return cookieString(name, value, options);
|
|
877
880
|
}
|
|
878
881
|
success(data = {}, options) {
|
|
879
882
|
return {
|
|
880
|
-
headers:
|
|
883
|
+
headers: Object.assign({ "content-type": "application/json" }, this.responseHeaders, options?.headers || {}),
|
|
881
884
|
body: {
|
|
882
885
|
isError: false,
|
|
883
886
|
data
|
|
@@ -928,7 +931,7 @@ class Controller {
|
|
|
928
931
|
};
|
|
929
932
|
const response = this.success(data, options);
|
|
930
933
|
return {
|
|
931
|
-
headers:
|
|
934
|
+
headers: Object.assign({ "content-type": "application/xml" }, this.responseHeaders, options?.headers || {}),
|
|
932
935
|
body: xmljs__default['default'].js2xml(Object.assign(defaultXml, { body: { ...response.body } }), xmlOptions),
|
|
933
936
|
memcache: response.memcache
|
|
934
937
|
};
|
|
@@ -960,9 +963,12 @@ class Controller {
|
|
|
960
963
|
config: this.$context.config,
|
|
961
964
|
db: this.$context.db,
|
|
962
965
|
headers: this.$context.headers,
|
|
966
|
+
cookies: this.$context.cookies,
|
|
963
967
|
controller: this.$context.controller,
|
|
964
968
|
action: this.$context.action,
|
|
965
|
-
subaction: this.$context.subaction
|
|
969
|
+
subaction: this.$context.subaction,
|
|
970
|
+
setResponseHeader: this.setResponseHeader,
|
|
971
|
+
setCookieHeader: this.setCookieHeader
|
|
966
972
|
});
|
|
967
973
|
}
|
|
968
974
|
const inits = ["init", ...obj.$inits || []];
|
|
@@ -1027,6 +1033,14 @@ class Controller {
|
|
|
1027
1033
|
getPool(key = "home") {
|
|
1028
1034
|
return this.getDb()[key];
|
|
1029
1035
|
}
|
|
1036
|
+
setResponseHeader(key, value) {
|
|
1037
|
+
if (this.responseHeaders.hasOwnProperty(key)) {
|
|
1038
|
+
this.responseHeaders[key] = Array.isArray(this.responseHeaders[key]) ? this.responseHeaders[key] : [this.responseHeaders[key]];
|
|
1039
|
+
this.responseHeaders[key].push(value);
|
|
1040
|
+
} else {
|
|
1041
|
+
this.responseHeaders[key] = value;
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1030
1044
|
}
|
|
1031
1045
|
|
|
1032
1046
|
class Model {
|
|
@@ -1039,9 +1053,12 @@ class Model {
|
|
|
1039
1053
|
config: this.$context.config,
|
|
1040
1054
|
db: this.$context.db,
|
|
1041
1055
|
headers: this.$context.headers,
|
|
1056
|
+
cookies: this.$context.cookies,
|
|
1042
1057
|
controller: this.$context.controller,
|
|
1043
1058
|
action: this.$context.action,
|
|
1044
|
-
subaction: this.$context.subaction
|
|
1059
|
+
subaction: this.$context.subaction,
|
|
1060
|
+
setResponseHeader: this.$context.setResponseHeader,
|
|
1061
|
+
setCookieHeader: this.$context.setCookieHeader
|
|
1045
1062
|
});
|
|
1046
1063
|
}
|
|
1047
1064
|
if ("init" in obj) {
|
|
@@ -1067,6 +1084,9 @@ class Model {
|
|
|
1067
1084
|
getHeaders() {
|
|
1068
1085
|
return this.$context.headers;
|
|
1069
1086
|
}
|
|
1087
|
+
getCookies() {
|
|
1088
|
+
return this.$context.cookies;
|
|
1089
|
+
}
|
|
1070
1090
|
getController() {
|
|
1071
1091
|
return this.$context.controller;
|
|
1072
1092
|
}
|
|
@@ -1085,6 +1105,9 @@ class Model {
|
|
|
1085
1105
|
getPool(key = "home") {
|
|
1086
1106
|
return this.getDb()[key];
|
|
1087
1107
|
}
|
|
1108
|
+
setCookieHeader(name, value, options = {}) {
|
|
1109
|
+
return this.$context.setCookieHeader(name, value, options);
|
|
1110
|
+
}
|
|
1088
1111
|
}
|
|
1089
1112
|
|
|
1090
1113
|
const argumentsSubactionsKey = Symbol("arguments");
|