d5-api-initializer 1.1.2 → 1.1.3-alpha.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "d5-api-initializer",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {},
|
|
6
6
|
"main": "publish/cjs/d5-api-initializer",
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"compile": "tsup",
|
|
28
28
|
"changelog": "node ./scripts/releaseChangelog.mjs changelog -p v1.0.0",
|
|
29
29
|
"prepublishOnly": "yarn clean",
|
|
30
|
-
"prepack": "yarn compile"
|
|
30
|
+
"prepack": "yarn compile",
|
|
31
|
+
"prerelease": "npm version prerelease --preid=alpha"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@babel/core": "7.23.9",
|
|
@@ -130,6 +130,9 @@ var ApiResponse = class {
|
|
|
130
130
|
getResponse(responseName) {
|
|
131
131
|
return this._jsWapiResponse.getResponse(responseName || this._objectName);
|
|
132
132
|
}
|
|
133
|
+
getResponseObject() {
|
|
134
|
+
return this._jsWapiResponse.getResponse();
|
|
135
|
+
}
|
|
133
136
|
setResponse(response, fieldsMap) {
|
|
134
137
|
if (Array.isArray(response)) {
|
|
135
138
|
const data = !fieldsMap ? response : response.map((row) => {
|
|
@@ -406,7 +409,7 @@ var ApiObjectCollectionIterator = class {
|
|
|
406
409
|
let lastPage = false;
|
|
407
410
|
while (!lastPage) {
|
|
408
411
|
this._invoker.page = pageCount;
|
|
409
|
-
data =
|
|
412
|
+
data = this._invoker.invoke().getResponse();
|
|
410
413
|
pageCount++;
|
|
411
414
|
if (Array.isArray(data)) {
|
|
412
415
|
for (let i = 0; i < data.length; i++) {
|
|
@@ -491,6 +494,15 @@ var ApiCore = class {
|
|
|
491
494
|
}
|
|
492
495
|
return new JSWapiException(message);
|
|
493
496
|
}
|
|
497
|
+
/**
|
|
498
|
+
* Валидирует xml по переданому xsd.
|
|
499
|
+
* Если валидация происходит с ошибками, то бросается исключение.
|
|
500
|
+
*/
|
|
501
|
+
validateXml(xml, xsd) {
|
|
502
|
+
if (!this.httpSender.validateXml)
|
|
503
|
+
throw this.newApiException("validateXml() is not allowed");
|
|
504
|
+
return this.httpSender.validateXml(xsd, xml);
|
|
505
|
+
}
|
|
494
506
|
/*
|
|
495
507
|
* Will be implemented later
|
|
496
508
|
*
|
|
@@ -63,7 +63,21 @@ declare namespace jsWapi {
|
|
|
63
63
|
setRequest(request: any): JSWapiRequest;
|
|
64
64
|
setHierarchy(parentColumn: string, requestKind?: number): JSWapiRequest;
|
|
65
65
|
};
|
|
66
|
-
type JSWapiResponse = {
|
|
66
|
+
type JSWapiResponse = {
|
|
67
|
+
getResponse(): {
|
|
68
|
+
[key: string]: Record<string, any>[];
|
|
69
|
+
};
|
|
70
|
+
getResponse(objectName: string): Record<string, any>[] | null;
|
|
71
|
+
putResponse(objectName: string, records: Record<string, any>[]): void;
|
|
72
|
+
setResponse(resp: {
|
|
73
|
+
[key: string]: Record<string, any>[];
|
|
74
|
+
}): void;
|
|
75
|
+
sendHttpResponse(headers: Record<string, any>, body: string | BinaryDataStream): void;
|
|
76
|
+
getPagesPredict(): number;
|
|
77
|
+
setPagesPredict(pagesPredict: number): void;
|
|
78
|
+
getPage(): number;
|
|
79
|
+
setPage(page: number): void;
|
|
80
|
+
};
|
|
67
81
|
type BinaryDataStream = unknown;
|
|
68
82
|
interface JSWapiHttpResponse {
|
|
69
83
|
getStatusCode(): number;
|
|
@@ -138,10 +152,11 @@ declare class ApiHttpRequest {
|
|
|
138
152
|
declare class ApiResponse {
|
|
139
153
|
private _jsWapiResponse;
|
|
140
154
|
private readonly _objectName;
|
|
141
|
-
constructor(jsWapiResponse:
|
|
155
|
+
constructor(jsWapiResponse: jsWapi.JSWapiResponse, objectName: string);
|
|
142
156
|
get objectName(): string;
|
|
143
157
|
set response(response: IMappedCollection | any[]);
|
|
144
158
|
getResponse(responseName?: string): IMappedCollection[] | any;
|
|
159
|
+
getResponseObject(): IMappedCollection[] | any;
|
|
145
160
|
setResponse(response: IMappedCollection | any[], fieldsMap?: Record<string, any>): this;
|
|
146
161
|
sendHttpResponse(headers: IMappedCollection, body: string | jsWapi.BinaryDataStream): this;
|
|
147
162
|
sendHttpBody(body: string): this;
|
|
@@ -339,6 +354,8 @@ declare class ApiFileInvoker implements IInvoker {
|
|
|
339
354
|
|
|
340
355
|
type HTTPSender = {
|
|
341
356
|
newJSWapiHttp(url: string): jsWapi.JSWapiHttp;
|
|
357
|
+
/** Если не валидируется, то будет exception. */
|
|
358
|
+
validateXml?(xsd: string, xml: string): boolean;
|
|
342
359
|
};
|
|
343
360
|
declare class ApiCore {
|
|
344
361
|
private readonly httpSender;
|
|
@@ -366,6 +383,11 @@ declare class ApiCore {
|
|
|
366
383
|
newApiFileInvoker(objectName: string, keyValue: string | number, fileFieldName: string): ApiFileInvoker;
|
|
367
384
|
newApiObjectCollectionIterator(objectName: string): ApiObjectCollectionIterator;
|
|
368
385
|
newApiException(message: string, code?: string | number): Error;
|
|
386
|
+
/**
|
|
387
|
+
* Валидирует xml по переданому xsd.
|
|
388
|
+
* Если валидация происходит с ошибками, то бросается исключение.
|
|
389
|
+
*/
|
|
390
|
+
validateXml(xml: string, xsd: string): boolean;
|
|
369
391
|
}
|
|
370
392
|
|
|
371
393
|
interface IFilterValue {
|
|
@@ -94,6 +94,9 @@ var ApiResponse = class {
|
|
|
94
94
|
getResponse(responseName) {
|
|
95
95
|
return this._jsWapiResponse.getResponse(responseName || this._objectName);
|
|
96
96
|
}
|
|
97
|
+
getResponseObject() {
|
|
98
|
+
return this._jsWapiResponse.getResponse();
|
|
99
|
+
}
|
|
97
100
|
setResponse(response, fieldsMap) {
|
|
98
101
|
if (Array.isArray(response)) {
|
|
99
102
|
const data = !fieldsMap ? response : response.map((row) => {
|
|
@@ -370,7 +373,7 @@ var ApiObjectCollectionIterator = class {
|
|
|
370
373
|
let lastPage = false;
|
|
371
374
|
while (!lastPage) {
|
|
372
375
|
this._invoker.page = pageCount;
|
|
373
|
-
data =
|
|
376
|
+
data = this._invoker.invoke().getResponse();
|
|
374
377
|
pageCount++;
|
|
375
378
|
if (Array.isArray(data)) {
|
|
376
379
|
for (let i = 0; i < data.length; i++) {
|
|
@@ -455,6 +458,15 @@ var ApiCore = class {
|
|
|
455
458
|
}
|
|
456
459
|
return new JSWapiException(message);
|
|
457
460
|
}
|
|
461
|
+
/**
|
|
462
|
+
* Валидирует xml по переданому xsd.
|
|
463
|
+
* Если валидация происходит с ошибками, то бросается исключение.
|
|
464
|
+
*/
|
|
465
|
+
validateXml(xml, xsd) {
|
|
466
|
+
if (!this.httpSender.validateXml)
|
|
467
|
+
throw this.newApiException("validateXml() is not allowed");
|
|
468
|
+
return this.httpSender.validateXml(xsd, xml);
|
|
469
|
+
}
|
|
458
470
|
/*
|
|
459
471
|
* Will be implemented later
|
|
460
472
|
*
|
|
@@ -94,6 +94,9 @@ var ApiResponse = class {
|
|
|
94
94
|
getResponse(responseName) {
|
|
95
95
|
return this._jsWapiResponse.getResponse(responseName || this._objectName);
|
|
96
96
|
}
|
|
97
|
+
getResponseObject() {
|
|
98
|
+
return this._jsWapiResponse.getResponse();
|
|
99
|
+
}
|
|
97
100
|
setResponse(response, fieldsMap) {
|
|
98
101
|
if (Array.isArray(response)) {
|
|
99
102
|
const data = !fieldsMap ? response : response.map((row) => {
|
|
@@ -370,7 +373,7 @@ var ApiObjectCollectionIterator = class {
|
|
|
370
373
|
let lastPage = false;
|
|
371
374
|
while (!lastPage) {
|
|
372
375
|
this._invoker.page = pageCount;
|
|
373
|
-
data =
|
|
376
|
+
data = this._invoker.invoke().getResponse();
|
|
374
377
|
pageCount++;
|
|
375
378
|
if (Array.isArray(data)) {
|
|
376
379
|
for (let i = 0; i < data.length; i++) {
|
|
@@ -455,6 +458,15 @@ var ApiCore = class {
|
|
|
455
458
|
}
|
|
456
459
|
return new JSWapiException(message);
|
|
457
460
|
}
|
|
461
|
+
/**
|
|
462
|
+
* Валидирует xml по переданому xsd.
|
|
463
|
+
* Если валидация происходит с ошибками, то бросается исключение.
|
|
464
|
+
*/
|
|
465
|
+
validateXml(xml, xsd) {
|
|
466
|
+
if (!this.httpSender.validateXml)
|
|
467
|
+
throw this.newApiException("validateXml() is not allowed");
|
|
468
|
+
return this.httpSender.validateXml(xsd, xml);
|
|
469
|
+
}
|
|
458
470
|
/*
|
|
459
471
|
* Will be implemented later
|
|
460
472
|
*
|