d5-api-initializer 1.0.2 → 1.1.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/README.md CHANGED
@@ -0,0 +1,6 @@
1
+ Для локальної роботи з даною бібліотекою потрібно слідувати наступної інструкції -
2
+ 1. Підключаємо бібліотеку через команду yarn link.
3
+ 2. На проекті, до якого треба підключити дану бібліотеку, виконуємо команду yarn link "d5-api-initializer".
4
+ 3. Білдимо бібліотеку через команду yarn compile.
5
+
6
+ Ура, все підключилось. Тепер ви можете користуватись бібліотекою локально. Гарної роботи!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "d5-api-initializer",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "license": "MIT",
5
5
  "dependencies": {},
6
6
  "main": "publish/cjs/d5-api-initializer",
@@ -33,6 +33,7 @@ __export(lib_index_exports, {
33
33
  ApiObjectCollectionIterator: () => ApiObjectCollectionIterator,
34
34
  ApiRequest: () => ApiRequest,
35
35
  ApiResponse: () => ApiResponse,
36
+ ApplicationInitializer: () => ApplicationInitializer,
36
37
  EngineInitializer: () => EngineInitializer,
37
38
  LanguageCode: () => LanguageCode,
38
39
  UserMessages: () => UserMessages_default,
@@ -399,6 +400,30 @@ var ApiObjectCollectionIterator = class {
399
400
  }
400
401
  };
401
402
 
403
+ // src/classes/ApiFileInvoker.ts
404
+ var ApiFileInvoker = class {
405
+ constructor(jsWapiInvoker, params) {
406
+ __publicField(this, "_jsWapiInvoker");
407
+ __publicField(this, "_objectName");
408
+ this._jsWapiInvoker = jsWapiInvoker;
409
+ this._objectName = params.objectName;
410
+ this.setParams(params.keyValue, params.fileFieldName);
411
+ }
412
+ get objectName() {
413
+ return this._objectName;
414
+ }
415
+ setParams(keyValue, fileFieldName) {
416
+ this._jsWapiInvoker.setSingleColumn(fileFieldName);
417
+ this._jsWapiInvoker.setKeyValue(keyValue);
418
+ }
419
+ getExcelFileAsJson() {
420
+ return this._jsWapiInvoker.invokeAndGetExcelFileAsJson();
421
+ }
422
+ getFileAsString() {
423
+ return this._jsWapiInvoker.invokeAndGetFileAsString();
424
+ }
425
+ };
426
+
402
427
  // src/classes/ApiCore.ts
403
428
  var ApiCore = class {
404
429
  constructor({ http, request }) {
@@ -430,6 +455,13 @@ var ApiCore = class {
430
455
  newApiInvoker(objectName, operName) {
431
456
  return new ApiInvoker(this._request.newJSWapiInvoker(objectName, operName), objectName);
432
457
  }
458
+ newApiFileInvoker(objectName, keyValue, fileFieldName) {
459
+ return new ApiFileInvoker(this._request.newJSWapiInvoker(objectName, "List"), {
460
+ objectName,
461
+ keyValue,
462
+ fileFieldName
463
+ });
464
+ }
433
465
  newApiObjectCollectionIterator(objectName) {
434
466
  return new ApiObjectCollectionIterator({
435
467
  invoker: this.newApiInvoker(objectName, "List")
@@ -835,6 +867,39 @@ var EngineInitializer = class {
835
867
  }
836
868
  };
837
869
 
870
+ // src/classes/ApplicationInitializer.ts
871
+ var ApplicationInitializer = class {
872
+ constructor(operations) {
873
+ __publicField(this, "jSWapiApplication");
874
+ __publicField(this, "_operations");
875
+ const throwError = (msg) => {
876
+ throw new Error(msg);
877
+ };
878
+ if (!operations)
879
+ throwError('Property "operations" in the settings is required');
880
+ this._operations = operations;
881
+ this.internalCreate();
882
+ }
883
+ internalCreate() {
884
+ jsWapi.setJSWapiObject((jSWapiApplication) => {
885
+ this.jSWapiApplication = jSWapiApplication;
886
+ for (const operationName in this._operations) {
887
+ this.putOperation(operationName);
888
+ }
889
+ });
890
+ }
891
+ putOperation(operationName) {
892
+ this.jSWapiApplication.putJSWapiOper(operationName, (jsWapiRequest, jsWapiResponse) => {
893
+ const request = new ApiRequest(jsWapiRequest, this.jSWapiApplication.getName());
894
+ return this._operations[operationName](
895
+ new ApiCore({ http: this.jSWapiApplication, request }),
896
+ request,
897
+ new ApiResponse(jsWapiResponse, this.jSWapiApplication.getName())
898
+ );
899
+ });
900
+ }
901
+ };
902
+
838
903
  // src/classes/ApiJoinInvoker.ts
839
904
  var ApiJoinInvoker = class {
840
905
  constructor(jsWapiJoinInvoker) {
@@ -856,6 +921,7 @@ var lib_index_default = ApiObjectInitializer;
856
921
  ApiObjectCollectionIterator,
857
922
  ApiRequest,
858
923
  ApiResponse,
924
+ ApplicationInitializer,
859
925
  EngineInitializer,
860
926
  LanguageCode,
861
927
  UserMessages
@@ -22,6 +22,10 @@ declare namespace jsWapi {
22
22
  getRequest(objectName?: string): Record<string, any>[];
23
23
  getSrcRequest(): Record<string, any>[];
24
24
  getFirstRows(): number;
25
+ setKeyValue(keyValue: number | string): JSWapiInvoker;
26
+ setSingleColumn(column: string): JSWapiInvoker;
27
+ invokeAndGetFileAsString(): string;
28
+ invokeAndGetExcelFileAsJson(): Map<string, any>;
25
29
  invoke(): JSWapiResponse;
26
30
  };
27
31
  type JSWapiRequest = {
@@ -142,7 +146,7 @@ declare class ApiResponse {
142
146
  setPagesPredict(pagesPredict: number): this;
143
147
  }
144
148
 
145
- interface IInvoker<T> {
149
+ interface IInvoker$1<T> {
146
150
  setColumns(columns: string[]): T;
147
151
  setFilters(filters: IFiltersCollection): T;
148
152
  setSorts(sorts: string[]): T;
@@ -150,7 +154,7 @@ interface IInvoker<T> {
150
154
  addSorts(sorts: string[]): T;
151
155
  objectName: string;
152
156
  }
153
- declare class ApiInvoker implements IInvoker<ApiInvoker> {
157
+ declare class ApiInvoker implements IInvoker$1<ApiInvoker> {
154
158
  _jsWapiInvoker: jsWapi.JSWapiInvoker;
155
159
  protected readonly _objectName: string;
156
160
  constructor(jsWapiInvoker: jsWapi.JSWapiInvoker, objectName: string);
@@ -287,7 +291,7 @@ declare class ApiRequest {
287
291
  _getWithStringifiedElements(array: any[]): string[];
288
292
  }
289
293
 
290
- declare class ApiObjectCollectionIterator implements IInvoker<ApiObjectCollectionIterator> {
294
+ declare class ApiObjectCollectionIterator implements IInvoker$1<ApiObjectCollectionIterator> {
291
295
  private _invoker;
292
296
  constructor({ invoker }: {
293
297
  invoker: ApiInvoker;
@@ -301,6 +305,26 @@ declare class ApiObjectCollectionIterator implements IInvoker<ApiObjectCollectio
301
305
  invoke(): Generator<ApiResponse>;
302
306
  }
303
307
 
308
+ interface IInvoker {
309
+ getExcelFileAsJson(): Map<string, any>;
310
+ getFileAsString(): string;
311
+ objectName: string;
312
+ }
313
+ interface IParams {
314
+ objectName: string;
315
+ keyValue: string | number;
316
+ fileFieldName: string;
317
+ }
318
+ declare class ApiFileInvoker implements IInvoker {
319
+ _jsWapiInvoker: jsWapi.JSWapiInvoker;
320
+ protected readonly _objectName: string;
321
+ constructor(jsWapiInvoker: jsWapi.JSWapiInvoker, params: IParams);
322
+ get objectName(): string;
323
+ setParams(keyValue: string | number, fileFieldName: string): void;
324
+ getExcelFileAsJson(): Map<string, any>;
325
+ getFileAsString(): string;
326
+ }
327
+
304
328
  type HTTPSender = {
305
329
  newJSWapiHttp(url: string): jsWapi.JSWapiHttp;
306
330
  };
@@ -327,6 +351,7 @@ declare class ApiCore {
327
351
  t(msgKey: string, params?: string[]): string;
328
352
  newHttpRequest(url: string): ApiHttpRequest;
329
353
  newApiInvoker(objectName: string, operName: string): ApiInvoker;
354
+ newApiFileInvoker(objectName: string, keyValue: string | number, fileFieldName: string): ApiFileInvoker;
330
355
  newApiObjectCollectionIterator(objectName: string): ApiObjectCollectionIterator;
331
356
  newApiException(message: string, code?: string | number): Error;
332
357
  }
@@ -424,6 +449,14 @@ declare class EngineInitializer<MetaParams = Record<string, any>> {
424
449
  }): void;
425
450
  }
426
451
 
452
+ declare class ApplicationInitializer<MetaParams = undefined> {
453
+ private jSWapiApplication;
454
+ protected _operations: IApiOperations<MetaParams>;
455
+ constructor(operations: IApiOperations<MetaParams>);
456
+ private internalCreate;
457
+ private putOperation;
458
+ }
459
+
427
460
  declare class ApiJoinInvoker {
428
461
  readonly _jsWapiJoinInvoker: any;
429
462
  constructor(jsWapiJoinInvoker: any);
@@ -438,4 +471,4 @@ declare class UserMessages {
438
471
  }
439
472
  declare const _default: UserMessages;
440
473
 
441
- export { ApiCore, ApiHttpRequest, ApiHttpResponse, ApiInvoker, ApiJoinInvoker, ApiObjectCollectionIterator, ApiRequest, ApiResponse, EngineInitializer, IApiOperations, IFilter, IFilterValue, IFiltersCollection, IHttpCallback, IMappedCollection, LanguageCode, _default as UserMessages, ApiObjectInitializer as default };
474
+ export { ApiCore, ApiHttpRequest, ApiHttpResponse, ApiInvoker, ApiJoinInvoker, ApiObjectCollectionIterator, ApiRequest, ApiResponse, ApplicationInitializer, EngineInitializer, IApiOperations, IFilter, IFilterValue, IFiltersCollection, IHttpCallback, IMappedCollection, LanguageCode, _default as UserMessages, ApiObjectInitializer as default };
@@ -364,6 +364,30 @@ var ApiObjectCollectionIterator = class {
364
364
  }
365
365
  };
366
366
 
367
+ // src/classes/ApiFileInvoker.ts
368
+ var ApiFileInvoker = class {
369
+ constructor(jsWapiInvoker, params) {
370
+ __publicField(this, "_jsWapiInvoker");
371
+ __publicField(this, "_objectName");
372
+ this._jsWapiInvoker = jsWapiInvoker;
373
+ this._objectName = params.objectName;
374
+ this.setParams(params.keyValue, params.fileFieldName);
375
+ }
376
+ get objectName() {
377
+ return this._objectName;
378
+ }
379
+ setParams(keyValue, fileFieldName) {
380
+ this._jsWapiInvoker.setSingleColumn(fileFieldName);
381
+ this._jsWapiInvoker.setKeyValue(keyValue);
382
+ }
383
+ getExcelFileAsJson() {
384
+ return this._jsWapiInvoker.invokeAndGetExcelFileAsJson();
385
+ }
386
+ getFileAsString() {
387
+ return this._jsWapiInvoker.invokeAndGetFileAsString();
388
+ }
389
+ };
390
+
367
391
  // src/classes/ApiCore.ts
368
392
  var ApiCore = class {
369
393
  constructor({ http, request }) {
@@ -395,6 +419,13 @@ var ApiCore = class {
395
419
  newApiInvoker(objectName, operName) {
396
420
  return new ApiInvoker(this._request.newJSWapiInvoker(objectName, operName), objectName);
397
421
  }
422
+ newApiFileInvoker(objectName, keyValue, fileFieldName) {
423
+ return new ApiFileInvoker(this._request.newJSWapiInvoker(objectName, "List"), {
424
+ objectName,
425
+ keyValue,
426
+ fileFieldName
427
+ });
428
+ }
398
429
  newApiObjectCollectionIterator(objectName) {
399
430
  return new ApiObjectCollectionIterator({
400
431
  invoker: this.newApiInvoker(objectName, "List")
@@ -800,6 +831,39 @@ var EngineInitializer = class {
800
831
  }
801
832
  };
802
833
 
834
+ // src/classes/ApplicationInitializer.ts
835
+ var ApplicationInitializer = class {
836
+ constructor(operations) {
837
+ __publicField(this, "jSWapiApplication");
838
+ __publicField(this, "_operations");
839
+ const throwError = (msg) => {
840
+ throw new Error(msg);
841
+ };
842
+ if (!operations)
843
+ throwError('Property "operations" in the settings is required');
844
+ this._operations = operations;
845
+ this.internalCreate();
846
+ }
847
+ internalCreate() {
848
+ jsWapi.setJSWapiObject((jSWapiApplication) => {
849
+ this.jSWapiApplication = jSWapiApplication;
850
+ for (const operationName in this._operations) {
851
+ this.putOperation(operationName);
852
+ }
853
+ });
854
+ }
855
+ putOperation(operationName) {
856
+ this.jSWapiApplication.putJSWapiOper(operationName, (jsWapiRequest, jsWapiResponse) => {
857
+ const request = new ApiRequest(jsWapiRequest, this.jSWapiApplication.getName());
858
+ return this._operations[operationName](
859
+ new ApiCore({ http: this.jSWapiApplication, request }),
860
+ request,
861
+ new ApiResponse(jsWapiResponse, this.jSWapiApplication.getName())
862
+ );
863
+ });
864
+ }
865
+ };
866
+
803
867
  // src/classes/ApiJoinInvoker.ts
804
868
  var ApiJoinInvoker = class {
805
869
  constructor(jsWapiJoinInvoker) {
@@ -820,6 +884,7 @@ export {
820
884
  ApiObjectCollectionIterator,
821
885
  ApiRequest,
822
886
  ApiResponse,
887
+ ApplicationInitializer,
823
888
  EngineInitializer,
824
889
  LanguageCode,
825
890
  UserMessages_default as UserMessages,
@@ -364,6 +364,30 @@ var ApiObjectCollectionIterator = class {
364
364
  }
365
365
  };
366
366
 
367
+ // src/classes/ApiFileInvoker.ts
368
+ var ApiFileInvoker = class {
369
+ constructor(jsWapiInvoker, params) {
370
+ __publicField(this, "_jsWapiInvoker");
371
+ __publicField(this, "_objectName");
372
+ this._jsWapiInvoker = jsWapiInvoker;
373
+ this._objectName = params.objectName;
374
+ this.setParams(params.keyValue, params.fileFieldName);
375
+ }
376
+ get objectName() {
377
+ return this._objectName;
378
+ }
379
+ setParams(keyValue, fileFieldName) {
380
+ this._jsWapiInvoker.setSingleColumn(fileFieldName);
381
+ this._jsWapiInvoker.setKeyValue(keyValue);
382
+ }
383
+ getExcelFileAsJson() {
384
+ return this._jsWapiInvoker.invokeAndGetExcelFileAsJson();
385
+ }
386
+ getFileAsString() {
387
+ return this._jsWapiInvoker.invokeAndGetFileAsString();
388
+ }
389
+ };
390
+
367
391
  // src/classes/ApiCore.ts
368
392
  var ApiCore = class {
369
393
  constructor({ http, request }) {
@@ -395,6 +419,13 @@ var ApiCore = class {
395
419
  newApiInvoker(objectName, operName) {
396
420
  return new ApiInvoker(this._request.newJSWapiInvoker(objectName, operName), objectName);
397
421
  }
422
+ newApiFileInvoker(objectName, keyValue, fileFieldName) {
423
+ return new ApiFileInvoker(this._request.newJSWapiInvoker(objectName, "List"), {
424
+ objectName,
425
+ keyValue,
426
+ fileFieldName
427
+ });
428
+ }
398
429
  newApiObjectCollectionIterator(objectName) {
399
430
  return new ApiObjectCollectionIterator({
400
431
  invoker: this.newApiInvoker(objectName, "List")
@@ -800,6 +831,39 @@ var EngineInitializer = class {
800
831
  }
801
832
  };
802
833
 
834
+ // src/classes/ApplicationInitializer.ts
835
+ var ApplicationInitializer = class {
836
+ constructor(operations) {
837
+ __publicField(this, "jSWapiApplication");
838
+ __publicField(this, "_operations");
839
+ const throwError = (msg) => {
840
+ throw new Error(msg);
841
+ };
842
+ if (!operations)
843
+ throwError('Property "operations" in the settings is required');
844
+ this._operations = operations;
845
+ this.internalCreate();
846
+ }
847
+ internalCreate() {
848
+ jsWapi.setJSWapiObject((jSWapiApplication) => {
849
+ this.jSWapiApplication = jSWapiApplication;
850
+ for (const operationName in this._operations) {
851
+ this.putOperation(operationName);
852
+ }
853
+ });
854
+ }
855
+ putOperation(operationName) {
856
+ this.jSWapiApplication.putJSWapiOper(operationName, (jsWapiRequest, jsWapiResponse) => {
857
+ const request = new ApiRequest(jsWapiRequest, this.jSWapiApplication.getName());
858
+ return this._operations[operationName](
859
+ new ApiCore({ http: this.jSWapiApplication, request }),
860
+ request,
861
+ new ApiResponse(jsWapiResponse, this.jSWapiApplication.getName())
862
+ );
863
+ });
864
+ }
865
+ };
866
+
803
867
  // src/classes/ApiJoinInvoker.ts
804
868
  var ApiJoinInvoker = class {
805
869
  constructor(jsWapiJoinInvoker) {
@@ -820,6 +884,7 @@ export {
820
884
  ApiObjectCollectionIterator,
821
885
  ApiRequest,
822
886
  ApiResponse,
887
+ ApplicationInitializer,
823
888
  EngineInitializer,
824
889
  LanguageCode,
825
890
  UserMessages_default as UserMessages,