my-q-format-response-aws-lambda 1.0.50 → 1.0.53
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/index.js +39 -13
- package/index.ts +43 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.controlResponseNull = exports.normaliseMongoPaginate = exports.normaliseMongoFilter = exports.optionsPaginationParams = exports.messagesREST = exports.CreateResponse = exports.ResponseVO = exports.ResponseBodyVO = exports.StatusCode = exports.StatusResult = void 0;
|
|
3
|
+
exports.parseMessageResponse = exports.controlResponseNull = exports.normaliseMongoPaginate = exports.normaliseMongoFilter = exports.optionsPaginationParams = exports.messagesREST = exports.CreateResponse = exports.ResponseVO = exports.ResponseBodyVO = exports.StatusCode = exports.StatusResult = void 0;
|
|
4
4
|
class StatusResult {
|
|
5
5
|
}
|
|
6
6
|
exports.StatusResult = StatusResult;
|
|
@@ -69,6 +69,7 @@ class ResponseBodyVO {
|
|
|
69
69
|
this.count = null;
|
|
70
70
|
this.error = null;
|
|
71
71
|
this.info = null;
|
|
72
|
+
this.identity = null;
|
|
72
73
|
this.redirectTo = undefined;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
@@ -81,7 +82,7 @@ class ResponseVO {
|
|
|
81
82
|
}
|
|
82
83
|
exports.ResponseVO = ResponseVO;
|
|
83
84
|
class Result {
|
|
84
|
-
constructor({ statusCode = StatusCode.OK, statusResult = StatusResult.ok, message, data = null, count = null, error = null, info = null, redirectTo = undefined, bodyWrap = true, }) {
|
|
85
|
+
constructor({ statusCode = StatusCode.OK, statusResult = StatusResult.ok, message, data = null, count = null, error = null, info = null, identity = null, redirectTo = undefined, bodyWrap = true, }) {
|
|
85
86
|
this.statusCode = statusCode;
|
|
86
87
|
this.statusResult = statusResult;
|
|
87
88
|
this.message = !message ? '' : message;
|
|
@@ -89,6 +90,7 @@ class Result {
|
|
|
89
90
|
this.data = data;
|
|
90
91
|
this.error = error;
|
|
91
92
|
this.info = info;
|
|
93
|
+
this.identity = identity;
|
|
92
94
|
this.redirectTo = redirectTo;
|
|
93
95
|
this.bodyWrap = bodyWrap;
|
|
94
96
|
}
|
|
@@ -105,6 +107,7 @@ class Result {
|
|
|
105
107
|
count: this.count,
|
|
106
108
|
error: _err,
|
|
107
109
|
info: this.info,
|
|
110
|
+
identity: this.identity,
|
|
108
111
|
};
|
|
109
112
|
if (this.redirectTo)
|
|
110
113
|
valueBody.redirectTo = this.redirectTo;
|
|
@@ -123,7 +126,7 @@ class CreateResponse {
|
|
|
123
126
|
* @param message
|
|
124
127
|
* @param bodyWrap
|
|
125
128
|
*/
|
|
126
|
-
static success({ data = null, count = null, message = 'success', bodyWrap = true, info = null, }) {
|
|
129
|
+
static success({ data = null, count = null, message = 'success', bodyWrap = true, info = null, identity = null, }) {
|
|
127
130
|
const result = new Result({
|
|
128
131
|
statusCode: StatusCode.OK,
|
|
129
132
|
statusResult: StatusResult.ok,
|
|
@@ -132,6 +135,7 @@ class CreateResponse {
|
|
|
132
135
|
count,
|
|
133
136
|
bodyWrap,
|
|
134
137
|
info,
|
|
138
|
+
identity,
|
|
135
139
|
});
|
|
136
140
|
return result.bodyToString();
|
|
137
141
|
}
|
|
@@ -141,13 +145,15 @@ class CreateResponse {
|
|
|
141
145
|
* @param message
|
|
142
146
|
* @param bodyWrap
|
|
143
147
|
*/
|
|
144
|
-
static created({ data, message = 'created', bodyWrap = true }) {
|
|
148
|
+
static created({ data, message = 'created', bodyWrap = true, info = null, identity = null }) {
|
|
145
149
|
const result = new Result({
|
|
146
150
|
statusCode: StatusCode.Created,
|
|
147
151
|
statusResult: StatusResult.ok,
|
|
148
152
|
message,
|
|
149
153
|
data,
|
|
150
154
|
bodyWrap,
|
|
155
|
+
info,
|
|
156
|
+
identity,
|
|
151
157
|
});
|
|
152
158
|
return result.bodyToString();
|
|
153
159
|
}
|
|
@@ -157,7 +163,7 @@ class CreateResponse {
|
|
|
157
163
|
* @param message
|
|
158
164
|
* @param bodyWrap
|
|
159
165
|
*/
|
|
160
|
-
static updated({ data, message = 'updated', bodyWrap = true, info = null }) {
|
|
166
|
+
static updated({ data, message = 'updated', bodyWrap = true, info = null, identity = null }) {
|
|
161
167
|
const result = new Result({
|
|
162
168
|
statusCode: StatusCode.OK,
|
|
163
169
|
statusResult: StatusResult.ok,
|
|
@@ -165,6 +171,7 @@ class CreateResponse {
|
|
|
165
171
|
data,
|
|
166
172
|
bodyWrap,
|
|
167
173
|
info,
|
|
174
|
+
identity,
|
|
168
175
|
});
|
|
169
176
|
return result.bodyToString();
|
|
170
177
|
}
|
|
@@ -174,7 +181,7 @@ class CreateResponse {
|
|
|
174
181
|
* @param message
|
|
175
182
|
* @param bodyWrap
|
|
176
183
|
*/
|
|
177
|
-
static updateOrCreate({ data, message = 'update_or_create', bodyWrap = true, info = null, }) {
|
|
184
|
+
static updateOrCreate({ data, message = 'update_or_create', bodyWrap = true, info = null, identity = null, }) {
|
|
178
185
|
const result = new Result({
|
|
179
186
|
statusCode: StatusCode.OK,
|
|
180
187
|
statusResult: StatusResult.ok,
|
|
@@ -182,6 +189,7 @@ class CreateResponse {
|
|
|
182
189
|
data,
|
|
183
190
|
bodyWrap,
|
|
184
191
|
info,
|
|
192
|
+
identity,
|
|
185
193
|
});
|
|
186
194
|
return result.bodyToString();
|
|
187
195
|
}
|
|
@@ -191,7 +199,7 @@ class CreateResponse {
|
|
|
191
199
|
* @param message
|
|
192
200
|
* @param bodyWrap
|
|
193
201
|
*/
|
|
194
|
-
static notFound({ error = null, message = '', bodyWrap = true }) {
|
|
202
|
+
static notFound({ error = null, message = '', bodyWrap = true, identity = null }) {
|
|
195
203
|
const result = new Result({
|
|
196
204
|
statusCode: StatusCode.NotFound,
|
|
197
205
|
statusResult: StatusResult.notFound,
|
|
@@ -199,6 +207,7 @@ class CreateResponse {
|
|
|
199
207
|
data: null,
|
|
200
208
|
error,
|
|
201
209
|
bodyWrap,
|
|
210
|
+
identity,
|
|
202
211
|
});
|
|
203
212
|
return result.bodyToString();
|
|
204
213
|
}
|
|
@@ -209,7 +218,7 @@ class CreateResponse {
|
|
|
209
218
|
* @param message
|
|
210
219
|
* @param bodyWrap
|
|
211
220
|
*/
|
|
212
|
-
static error({ error = null, statusCode = StatusCode.BadRequest, message = 'Error', bodyWrap = true, }) {
|
|
221
|
+
static error({ error = null, statusCode = StatusCode.BadRequest, message = 'Error', bodyWrap = true, identity = null, }) {
|
|
213
222
|
const result = new Result({
|
|
214
223
|
statusCode,
|
|
215
224
|
statusResult: StatusResult.error,
|
|
@@ -217,6 +226,7 @@ class CreateResponse {
|
|
|
217
226
|
error,
|
|
218
227
|
message,
|
|
219
228
|
bodyWrap,
|
|
229
|
+
identity,
|
|
220
230
|
});
|
|
221
231
|
return result.bodyToString();
|
|
222
232
|
}
|
|
@@ -227,7 +237,7 @@ class CreateResponse {
|
|
|
227
237
|
* @param message
|
|
228
238
|
* @param bodyWrap
|
|
229
239
|
*/
|
|
230
|
-
static unauthorized({ error = null, statusCode = StatusCode.Unauthorized, message = 'Unauthorized', bodyWrap = true, }) {
|
|
240
|
+
static unauthorized({ error = null, statusCode = StatusCode.Unauthorized, message = 'Unauthorized', bodyWrap = true, identity = null, }) {
|
|
231
241
|
const result = new Result({
|
|
232
242
|
statusCode,
|
|
233
243
|
statusResult: StatusResult.unauthorized,
|
|
@@ -235,6 +245,7 @@ class CreateResponse {
|
|
|
235
245
|
error,
|
|
236
246
|
message,
|
|
237
247
|
bodyWrap,
|
|
248
|
+
identity,
|
|
238
249
|
});
|
|
239
250
|
return result.bodyToString();
|
|
240
251
|
}
|
|
@@ -245,7 +256,7 @@ class CreateResponse {
|
|
|
245
256
|
* @param message
|
|
246
257
|
* @param bodyWrap
|
|
247
258
|
*/
|
|
248
|
-
static redirect({ statusCode = StatusCode.MovedTemporarily, message = '', bodyWrap = true, redirectTo = '', }) {
|
|
259
|
+
static redirect({ statusCode = StatusCode.MovedTemporarily, message = '', bodyWrap = true, redirectTo = '', identity = null, }) {
|
|
249
260
|
const result = new Result({
|
|
250
261
|
statusCode,
|
|
251
262
|
statusResult: StatusResult.needRedirect,
|
|
@@ -254,6 +265,7 @@ class CreateResponse {
|
|
|
254
265
|
message,
|
|
255
266
|
redirectTo,
|
|
256
267
|
bodyWrap,
|
|
268
|
+
identity,
|
|
257
269
|
});
|
|
258
270
|
return result.bodyToString();
|
|
259
271
|
}
|
|
@@ -267,7 +279,7 @@ class CreateResponse {
|
|
|
267
279
|
* @param count
|
|
268
280
|
* @param bodyWrap
|
|
269
281
|
*/
|
|
270
|
-
static custom({ statusCode = StatusCode.OK, statusResult = StatusResult.ok, message = '', error = null, data = null, count = null, bodyWrap = true, info = null, }) {
|
|
282
|
+
static custom({ statusCode = StatusCode.OK, statusResult = StatusResult.ok, message = '', error = null, data = null, count = null, bodyWrap = true, info = null, identity = null, }) {
|
|
271
283
|
const result = new Result({
|
|
272
284
|
statusCode,
|
|
273
285
|
statusResult,
|
|
@@ -276,7 +288,8 @@ class CreateResponse {
|
|
|
276
288
|
data,
|
|
277
289
|
count,
|
|
278
290
|
bodyWrap,
|
|
279
|
-
info
|
|
291
|
+
info,
|
|
292
|
+
identity,
|
|
280
293
|
});
|
|
281
294
|
return result.bodyToString();
|
|
282
295
|
}
|
|
@@ -419,7 +432,7 @@ const normaliseMongoPaginate = (filter) => {
|
|
|
419
432
|
return res;
|
|
420
433
|
};
|
|
421
434
|
exports.normaliseMongoPaginate = normaliseMongoPaginate;
|
|
422
|
-
const controlResponseNull = (data, okResultOf, prefix, bodyWrap = true) => {
|
|
435
|
+
const controlResponseNull = (data, okResultOf, prefix, bodyWrap = true, identity = null) => {
|
|
423
436
|
let result;
|
|
424
437
|
if (data) {
|
|
425
438
|
if (okResultOf === 'create') {
|
|
@@ -427,6 +440,7 @@ const controlResponseNull = (data, okResultOf, prefix, bodyWrap = true) => {
|
|
|
427
440
|
data,
|
|
428
441
|
message: (0, exports.messagesREST)(prefix).CREATE,
|
|
429
442
|
bodyWrap,
|
|
443
|
+
identity,
|
|
430
444
|
});
|
|
431
445
|
}
|
|
432
446
|
if (okResultOf === 'update') {
|
|
@@ -434,6 +448,7 @@ const controlResponseNull = (data, okResultOf, prefix, bodyWrap = true) => {
|
|
|
434
448
|
data,
|
|
435
449
|
message: (0, exports.messagesREST)(prefix).UPDATE,
|
|
436
450
|
bodyWrap,
|
|
451
|
+
identity,
|
|
437
452
|
});
|
|
438
453
|
}
|
|
439
454
|
if (okResultOf === 'update_or_create') {
|
|
@@ -448,6 +463,7 @@ const controlResponseNull = (data, okResultOf, prefix, bodyWrap = true) => {
|
|
|
448
463
|
data,
|
|
449
464
|
message: (0, exports.messagesREST)(prefix).UPDATE_MANY,
|
|
450
465
|
bodyWrap,
|
|
466
|
+
identity,
|
|
451
467
|
});
|
|
452
468
|
}
|
|
453
469
|
if (okResultOf === 'increment') {
|
|
@@ -455,6 +471,7 @@ const controlResponseNull = (data, okResultOf, prefix, bodyWrap = true) => {
|
|
|
455
471
|
data,
|
|
456
472
|
message: (0, exports.messagesREST)(prefix).INCREMENT,
|
|
457
473
|
bodyWrap,
|
|
474
|
+
identity,
|
|
458
475
|
});
|
|
459
476
|
}
|
|
460
477
|
if (okResultOf === 'decrement') {
|
|
@@ -462,6 +479,7 @@ const controlResponseNull = (data, okResultOf, prefix, bodyWrap = true) => {
|
|
|
462
479
|
data,
|
|
463
480
|
message: (0, exports.messagesREST)(prefix).DECREMENT,
|
|
464
481
|
bodyWrap,
|
|
482
|
+
identity,
|
|
465
483
|
});
|
|
466
484
|
}
|
|
467
485
|
}
|
|
@@ -483,8 +501,16 @@ const controlResponseNull = (data, okResultOf, prefix, bodyWrap = true) => {
|
|
|
483
501
|
data: data,
|
|
484
502
|
message: messageErr,
|
|
485
503
|
bodyWrap,
|
|
504
|
+
identity,
|
|
486
505
|
});
|
|
487
506
|
}
|
|
488
507
|
return result;
|
|
489
508
|
};
|
|
490
509
|
exports.controlResponseNull = controlResponseNull;
|
|
510
|
+
const parseMessageResponse = (message, separator = '__') => {
|
|
511
|
+
let res = message.split(separator);
|
|
512
|
+
if (res.length < 2)
|
|
513
|
+
return ['', '', ''];
|
|
514
|
+
return res;
|
|
515
|
+
};
|
|
516
|
+
exports.parseMessageResponse = parseMessageResponse;
|
package/index.ts
CHANGED
|
@@ -74,6 +74,7 @@ type TData = object | boolean | string | null
|
|
|
74
74
|
type TCount = number | null
|
|
75
75
|
type TError = any | null
|
|
76
76
|
type TInfo = any | null
|
|
77
|
+
type TIdentity = any | null
|
|
77
78
|
type TRedirectTo = string | undefined
|
|
78
79
|
|
|
79
80
|
interface TResultIn {
|
|
@@ -84,6 +85,7 @@ interface TResultIn {
|
|
|
84
85
|
count?: TCount
|
|
85
86
|
error?: TError
|
|
86
87
|
info?: TInfo
|
|
88
|
+
identity?: TIdentity
|
|
87
89
|
redirectTo?: TRedirectTo
|
|
88
90
|
bodyWrap: boolean
|
|
89
91
|
}
|
|
@@ -94,6 +96,7 @@ interface TFuncParams {
|
|
|
94
96
|
message?: string
|
|
95
97
|
error?: TError
|
|
96
98
|
info?: TInfo
|
|
99
|
+
identity?: TIdentity
|
|
97
100
|
data?: TData
|
|
98
101
|
count?: TCount
|
|
99
102
|
redirectTo?: TRedirectTo
|
|
@@ -107,6 +110,7 @@ export class ResponseBodyVO {
|
|
|
107
110
|
count: TCount = null
|
|
108
111
|
error: TError = null
|
|
109
112
|
info: TInfo = null
|
|
113
|
+
identity: TIdentity = null
|
|
110
114
|
redirectTo?: TRedirectTo = undefined
|
|
111
115
|
}
|
|
112
116
|
|
|
@@ -125,6 +129,7 @@ class Result {
|
|
|
125
129
|
private count: TCount
|
|
126
130
|
private error: any
|
|
127
131
|
private info: any
|
|
132
|
+
private identity: any
|
|
128
133
|
private redirectTo: TRedirectTo
|
|
129
134
|
private bodyWrap: boolean
|
|
130
135
|
|
|
@@ -136,6 +141,7 @@ class Result {
|
|
|
136
141
|
count = null,
|
|
137
142
|
error = null,
|
|
138
143
|
info = null,
|
|
144
|
+
identity = null,
|
|
139
145
|
redirectTo = undefined,
|
|
140
146
|
bodyWrap = true,
|
|
141
147
|
}: TResultIn) {
|
|
@@ -146,6 +152,7 @@ class Result {
|
|
|
146
152
|
this.data = data
|
|
147
153
|
this.error = error
|
|
148
154
|
this.info = info
|
|
155
|
+
this.identity = identity
|
|
149
156
|
this.redirectTo = redirectTo
|
|
150
157
|
this.bodyWrap = bodyWrap
|
|
151
158
|
}
|
|
@@ -164,6 +171,7 @@ class Result {
|
|
|
164
171
|
count: this.count,
|
|
165
172
|
error: _err,
|
|
166
173
|
info: this.info,
|
|
174
|
+
identity: this.identity,
|
|
167
175
|
}
|
|
168
176
|
if (this.redirectTo) valueBody.redirectTo = this.redirectTo
|
|
169
177
|
const valueBodyWrap: ResponseVO = {
|
|
@@ -189,6 +197,7 @@ export class CreateResponse {
|
|
|
189
197
|
message = 'success',
|
|
190
198
|
bodyWrap = true,
|
|
191
199
|
info = null,
|
|
200
|
+
identity = null,
|
|
192
201
|
}: TFuncParams): ResponseVoAWS {
|
|
193
202
|
const result = new Result({
|
|
194
203
|
statusCode: StatusCode.OK,
|
|
@@ -198,6 +207,7 @@ export class CreateResponse {
|
|
|
198
207
|
count,
|
|
199
208
|
bodyWrap,
|
|
200
209
|
info,
|
|
210
|
+
identity,
|
|
201
211
|
})
|
|
202
212
|
return result.bodyToString()
|
|
203
213
|
}
|
|
@@ -208,13 +218,15 @@ export class CreateResponse {
|
|
|
208
218
|
* @param message
|
|
209
219
|
* @param bodyWrap
|
|
210
220
|
*/
|
|
211
|
-
static created({ data, message = 'created', bodyWrap = true }: TFuncParams): ResponseVoAWS {
|
|
221
|
+
static created({ data, message = 'created', bodyWrap = true, info = null, identity = null }: TFuncParams): ResponseVoAWS {
|
|
212
222
|
const result = new Result({
|
|
213
223
|
statusCode: StatusCode.Created,
|
|
214
224
|
statusResult: StatusResult.ok,
|
|
215
225
|
message,
|
|
216
226
|
data,
|
|
217
227
|
bodyWrap,
|
|
228
|
+
info,
|
|
229
|
+
identity,
|
|
218
230
|
})
|
|
219
231
|
return result.bodyToString()
|
|
220
232
|
}
|
|
@@ -225,7 +237,7 @@ export class CreateResponse {
|
|
|
225
237
|
* @param message
|
|
226
238
|
* @param bodyWrap
|
|
227
239
|
*/
|
|
228
|
-
static updated({ data, message = 'updated', bodyWrap = true, info = null }: TFuncParams): ResponseVoAWS {
|
|
240
|
+
static updated({ data, message = 'updated', bodyWrap = true, info = null, identity = null }: TFuncParams): ResponseVoAWS {
|
|
229
241
|
const result = new Result({
|
|
230
242
|
statusCode: StatusCode.OK,
|
|
231
243
|
statusResult: StatusResult.ok,
|
|
@@ -233,6 +245,7 @@ export class CreateResponse {
|
|
|
233
245
|
data,
|
|
234
246
|
bodyWrap,
|
|
235
247
|
info,
|
|
248
|
+
identity,
|
|
236
249
|
})
|
|
237
250
|
return result.bodyToString()
|
|
238
251
|
}
|
|
@@ -248,6 +261,7 @@ export class CreateResponse {
|
|
|
248
261
|
message = 'update_or_create',
|
|
249
262
|
bodyWrap = true,
|
|
250
263
|
info = null,
|
|
264
|
+
identity = null,
|
|
251
265
|
}: TFuncParams): ResponseVoAWS {
|
|
252
266
|
const result = new Result({
|
|
253
267
|
statusCode: StatusCode.OK,
|
|
@@ -256,6 +270,7 @@ export class CreateResponse {
|
|
|
256
270
|
data,
|
|
257
271
|
bodyWrap,
|
|
258
272
|
info,
|
|
273
|
+
identity,
|
|
259
274
|
})
|
|
260
275
|
return result.bodyToString()
|
|
261
276
|
}
|
|
@@ -266,7 +281,7 @@ export class CreateResponse {
|
|
|
266
281
|
* @param message
|
|
267
282
|
* @param bodyWrap
|
|
268
283
|
*/
|
|
269
|
-
static notFound({ error = null, message = '', bodyWrap = true }: TFuncParams): ResponseVoAWS {
|
|
284
|
+
static notFound({ error = null, message = '', bodyWrap = true, identity = null }: TFuncParams): ResponseVoAWS {
|
|
270
285
|
const result = new Result({
|
|
271
286
|
statusCode: StatusCode.NotFound,
|
|
272
287
|
statusResult: StatusResult.notFound,
|
|
@@ -274,6 +289,7 @@ export class CreateResponse {
|
|
|
274
289
|
data: null,
|
|
275
290
|
error,
|
|
276
291
|
bodyWrap,
|
|
292
|
+
identity,
|
|
277
293
|
})
|
|
278
294
|
return result.bodyToString()
|
|
279
295
|
}
|
|
@@ -290,6 +306,7 @@ export class CreateResponse {
|
|
|
290
306
|
statusCode = StatusCode.BadRequest,
|
|
291
307
|
message = 'Error',
|
|
292
308
|
bodyWrap = true,
|
|
309
|
+
identity = null,
|
|
293
310
|
}: TFuncParams): ResponseVoAWS {
|
|
294
311
|
const result = new Result({
|
|
295
312
|
statusCode,
|
|
@@ -298,6 +315,7 @@ export class CreateResponse {
|
|
|
298
315
|
error,
|
|
299
316
|
message,
|
|
300
317
|
bodyWrap,
|
|
318
|
+
identity,
|
|
301
319
|
})
|
|
302
320
|
return result.bodyToString()
|
|
303
321
|
}
|
|
@@ -314,6 +332,7 @@ export class CreateResponse {
|
|
|
314
332
|
statusCode = StatusCode.Unauthorized,
|
|
315
333
|
message = 'Unauthorized',
|
|
316
334
|
bodyWrap = true,
|
|
335
|
+
identity = null,
|
|
317
336
|
}: TFuncParams): ResponseVoAWS {
|
|
318
337
|
const result = new Result({
|
|
319
338
|
statusCode,
|
|
@@ -322,6 +341,7 @@ export class CreateResponse {
|
|
|
322
341
|
error,
|
|
323
342
|
message,
|
|
324
343
|
bodyWrap,
|
|
344
|
+
identity,
|
|
325
345
|
})
|
|
326
346
|
return result.bodyToString()
|
|
327
347
|
}
|
|
@@ -338,6 +358,7 @@ export class CreateResponse {
|
|
|
338
358
|
message = '',
|
|
339
359
|
bodyWrap = true,
|
|
340
360
|
redirectTo = '',
|
|
361
|
+
identity = null,
|
|
341
362
|
}: TFuncParams): ResponseVoAWS {
|
|
342
363
|
const result = new Result({
|
|
343
364
|
statusCode,
|
|
@@ -347,6 +368,7 @@ export class CreateResponse {
|
|
|
347
368
|
message,
|
|
348
369
|
redirectTo,
|
|
349
370
|
bodyWrap,
|
|
371
|
+
identity,
|
|
350
372
|
})
|
|
351
373
|
return result.bodyToString()
|
|
352
374
|
}
|
|
@@ -370,6 +392,7 @@ export class CreateResponse {
|
|
|
370
392
|
count = null,
|
|
371
393
|
bodyWrap = true,
|
|
372
394
|
info = null,
|
|
395
|
+
identity = null,
|
|
373
396
|
}: TFuncParams): ResponseVoAWS {
|
|
374
397
|
const result = new Result({
|
|
375
398
|
statusCode,
|
|
@@ -379,7 +402,8 @@ export class CreateResponse {
|
|
|
379
402
|
data,
|
|
380
403
|
count,
|
|
381
404
|
bodyWrap,
|
|
382
|
-
info
|
|
405
|
+
info,
|
|
406
|
+
identity,
|
|
383
407
|
})
|
|
384
408
|
return result.bodyToString()
|
|
385
409
|
}
|
|
@@ -598,7 +622,8 @@ export const controlResponseNull = (
|
|
|
598
622
|
data: object,
|
|
599
623
|
okResultOf: 'create' | 'update' | 'update_or_create' | 'update_many' | 'increment' | 'decrement',
|
|
600
624
|
prefix: string,
|
|
601
|
-
bodyWrap: boolean = true
|
|
625
|
+
bodyWrap: boolean = true,
|
|
626
|
+
identity: string | null = null
|
|
602
627
|
) => {
|
|
603
628
|
let result
|
|
604
629
|
|
|
@@ -608,6 +633,7 @@ export const controlResponseNull = (
|
|
|
608
633
|
data,
|
|
609
634
|
message: messagesREST(prefix).CREATE,
|
|
610
635
|
bodyWrap,
|
|
636
|
+
identity,
|
|
611
637
|
})
|
|
612
638
|
}
|
|
613
639
|
|
|
@@ -616,6 +642,7 @@ export const controlResponseNull = (
|
|
|
616
642
|
data,
|
|
617
643
|
message: messagesREST(prefix).UPDATE,
|
|
618
644
|
bodyWrap,
|
|
645
|
+
identity,
|
|
619
646
|
})
|
|
620
647
|
}
|
|
621
648
|
|
|
@@ -632,6 +659,7 @@ export const controlResponseNull = (
|
|
|
632
659
|
data,
|
|
633
660
|
message: messagesREST(prefix).UPDATE_MANY,
|
|
634
661
|
bodyWrap,
|
|
662
|
+
identity,
|
|
635
663
|
})
|
|
636
664
|
}
|
|
637
665
|
|
|
@@ -640,6 +668,7 @@ export const controlResponseNull = (
|
|
|
640
668
|
data,
|
|
641
669
|
message: messagesREST(prefix).INCREMENT,
|
|
642
670
|
bodyWrap,
|
|
671
|
+
identity,
|
|
643
672
|
})
|
|
644
673
|
}
|
|
645
674
|
|
|
@@ -648,6 +677,7 @@ export const controlResponseNull = (
|
|
|
648
677
|
data,
|
|
649
678
|
message: messagesREST(prefix).DECREMENT,
|
|
650
679
|
bodyWrap,
|
|
680
|
+
identity,
|
|
651
681
|
})
|
|
652
682
|
}
|
|
653
683
|
} else {
|
|
@@ -663,8 +693,16 @@ export const controlResponseNull = (
|
|
|
663
693
|
data: data,
|
|
664
694
|
message: messageErr,
|
|
665
695
|
bodyWrap,
|
|
696
|
+
identity,
|
|
666
697
|
})
|
|
667
698
|
}
|
|
668
699
|
|
|
669
700
|
return result
|
|
670
701
|
}
|
|
702
|
+
|
|
703
|
+
export const parseMessageResponse =(message: string, separator: string = '__'): string[] => {
|
|
704
|
+
let res = message.split(separator)
|
|
705
|
+
if(res.length < 2) return ['', '', '']
|
|
706
|
+
|
|
707
|
+
return res
|
|
708
|
+
}
|
package/package.json
CHANGED