d5-api-initializer 1.0.1 → 1.0.3

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.0.1",
3
+ "version": "1.0.3",
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,
@@ -802,17 +803,12 @@ var EngineInitializer = class {
802
803
  this.engine.putJSWapiOper(operationName, (jsWapiRequest, jsWapiResponse) => {
803
804
  const request = new ApiRequest(jsWapiRequest, this.engine.getName());
804
805
  const apiCore = new ApiCore({ http: this.engine, request });
805
- return this._operations[operationName](
806
- apiCore,
807
- request,
808
- new ApiResponse(jsWapiResponse, this.engine.getName()),
809
- {
810
- parameters: this.engine.getExternalSystemParameters(),
811
- objectName: this.engine.getName(),
812
- externalObject: this.engine.getExternalName(),
813
- externalFieldsMap: this.engine.getExternalObjectFields()
814
- }
815
- );
806
+ return this._operations[operationName](apiCore, request, new ApiResponse(jsWapiResponse, this.engine.getName()), {
807
+ parameters: this.engine.getExternalSystemParameters(),
808
+ objectName: this.engine.getName(),
809
+ externalObject: this.engine.getExternalName(),
810
+ externalFieldsMap: this.engine.getExternalObjectFields()
811
+ });
816
812
  });
817
813
  }
818
814
  /**
@@ -829,13 +825,47 @@ var EngineInitializer = class {
829
825
  initTranslation(translations) {
830
826
  UserMessages_default.appendDictionary(translations);
831
827
  }
832
- call({ apiCore, apiRequest, apiResponse, operation, meta }) {
833
- return this._operations[operation](
834
- apiCore,
835
- apiRequest,
836
- apiResponse,
837
- meta
838
- );
828
+ call({
829
+ apiCore,
830
+ apiRequest,
831
+ apiResponse,
832
+ operation,
833
+ meta
834
+ }) {
835
+ return this._operations[operation](apiCore, apiRequest, apiResponse, meta);
836
+ }
837
+ };
838
+
839
+ // src/classes/ApplicationInitializer.ts
840
+ var ApplicationInitializer = class {
841
+ constructor(operations) {
842
+ __publicField(this, "jSWapiApplication");
843
+ __publicField(this, "_operations");
844
+ const throwError = (msg) => {
845
+ throw new Error(msg);
846
+ };
847
+ if (!operations)
848
+ throwError('Property "operations" in the settings is required');
849
+ this._operations = operations;
850
+ this.internalCreate();
851
+ }
852
+ internalCreate() {
853
+ jsWapi.setJSWapiObject((jSWapiApplication) => {
854
+ this.jSWapiApplication = jSWapiApplication;
855
+ for (const operationName in this._operations) {
856
+ this.putOperation(operationName);
857
+ }
858
+ });
859
+ }
860
+ putOperation(operationName) {
861
+ this.jSWapiApplication.putJSWapiOper(operationName, (jsWapiRequest, jsWapiResponse) => {
862
+ const request = new ApiRequest(jsWapiRequest, this.jSWapiApplication.getName());
863
+ return this._operations[operationName](
864
+ new ApiCore({ http: this.jSWapiApplication, request }),
865
+ request,
866
+ new ApiResponse(jsWapiResponse, this.jSWapiApplication.getName())
867
+ );
868
+ });
839
869
  }
840
870
  };
841
871
 
@@ -860,6 +890,7 @@ var lib_index_default = ApiObjectInitializer;
860
890
  ApiObjectCollectionIterator,
861
891
  ApiRequest,
862
892
  ApiResponse,
893
+ ApplicationInitializer,
863
894
  EngineInitializer,
864
895
  LanguageCode,
865
896
  UserMessages
@@ -93,6 +93,12 @@ declare namespace jsWapi {
93
93
  putJSWapiOper(operation: string, callback: (jsWapiRequest: JSWapiRequest, jsWapiResponse: JSWapiResponse) => void): void;
94
94
  }
95
95
  function setJSWapiEngine(init: (object: JSWapiEngine) => void): void;
96
+ interface JSWapiApplication {
97
+ getName(): string;
98
+ newJSWapiHttp(url: string): JSWapiHttp;
99
+ putJSWapiOper(operation: string, callback: (request: JSWapiRequest, response: JSWapiResponse) => void): void;
100
+ }
101
+ function setJSWapiObject(init: (object: JSWapiApplication) => void): void;
96
102
  }
97
103
 
98
104
  declare class ApiHttpResponse {
@@ -418,6 +424,14 @@ declare class EngineInitializer<MetaParams = Record<string, any>> {
418
424
  }): void;
419
425
  }
420
426
 
427
+ declare class ApplicationInitializer<MetaParams = undefined> {
428
+ private jSWapiApplication;
429
+ protected _operations: IApiOperations<MetaParams>;
430
+ constructor(operations: IApiOperations<MetaParams>);
431
+ private internalCreate;
432
+ private putOperation;
433
+ }
434
+
421
435
  declare class ApiJoinInvoker {
422
436
  readonly _jsWapiJoinInvoker: any;
423
437
  constructor(jsWapiJoinInvoker: any);
@@ -432,4 +446,4 @@ declare class UserMessages {
432
446
  }
433
447
  declare const _default: UserMessages;
434
448
 
435
- export { ApiCore, ApiHttpRequest, ApiHttpResponse, ApiInvoker, ApiJoinInvoker, ApiObjectCollectionIterator, ApiRequest, ApiResponse, EngineInitializer, IApiOperations, IFilter, IFilterValue, IFiltersCollection, IHttpCallback, IMappedCollection, LanguageCode, _default as UserMessages, ApiObjectInitializer as default };
449
+ export { ApiCore, ApiHttpRequest, ApiHttpResponse, ApiInvoker, ApiJoinInvoker, ApiObjectCollectionIterator, ApiRequest, ApiResponse, ApplicationInitializer, EngineInitializer, IApiOperations, IFilter, IFilterValue, IFiltersCollection, IHttpCallback, IMappedCollection, LanguageCode, _default as UserMessages, ApiObjectInitializer as default };
@@ -767,17 +767,12 @@ var EngineInitializer = class {
767
767
  this.engine.putJSWapiOper(operationName, (jsWapiRequest, jsWapiResponse) => {
768
768
  const request = new ApiRequest(jsWapiRequest, this.engine.getName());
769
769
  const apiCore = new ApiCore({ http: this.engine, request });
770
- return this._operations[operationName](
771
- apiCore,
772
- request,
773
- new ApiResponse(jsWapiResponse, this.engine.getName()),
774
- {
775
- parameters: this.engine.getExternalSystemParameters(),
776
- objectName: this.engine.getName(),
777
- externalObject: this.engine.getExternalName(),
778
- externalFieldsMap: this.engine.getExternalObjectFields()
779
- }
780
- );
770
+ return this._operations[operationName](apiCore, request, new ApiResponse(jsWapiResponse, this.engine.getName()), {
771
+ parameters: this.engine.getExternalSystemParameters(),
772
+ objectName: this.engine.getName(),
773
+ externalObject: this.engine.getExternalName(),
774
+ externalFieldsMap: this.engine.getExternalObjectFields()
775
+ });
781
776
  });
782
777
  }
783
778
  /**
@@ -794,13 +789,47 @@ var EngineInitializer = class {
794
789
  initTranslation(translations) {
795
790
  UserMessages_default.appendDictionary(translations);
796
791
  }
797
- call({ apiCore, apiRequest, apiResponse, operation, meta }) {
798
- return this._operations[operation](
799
- apiCore,
800
- apiRequest,
801
- apiResponse,
802
- meta
803
- );
792
+ call({
793
+ apiCore,
794
+ apiRequest,
795
+ apiResponse,
796
+ operation,
797
+ meta
798
+ }) {
799
+ return this._operations[operation](apiCore, apiRequest, apiResponse, meta);
800
+ }
801
+ };
802
+
803
+ // src/classes/ApplicationInitializer.ts
804
+ var ApplicationInitializer = class {
805
+ constructor(operations) {
806
+ __publicField(this, "jSWapiApplication");
807
+ __publicField(this, "_operations");
808
+ const throwError = (msg) => {
809
+ throw new Error(msg);
810
+ };
811
+ if (!operations)
812
+ throwError('Property "operations" in the settings is required');
813
+ this._operations = operations;
814
+ this.internalCreate();
815
+ }
816
+ internalCreate() {
817
+ jsWapi.setJSWapiObject((jSWapiApplication) => {
818
+ this.jSWapiApplication = jSWapiApplication;
819
+ for (const operationName in this._operations) {
820
+ this.putOperation(operationName);
821
+ }
822
+ });
823
+ }
824
+ putOperation(operationName) {
825
+ this.jSWapiApplication.putJSWapiOper(operationName, (jsWapiRequest, jsWapiResponse) => {
826
+ const request = new ApiRequest(jsWapiRequest, this.jSWapiApplication.getName());
827
+ return this._operations[operationName](
828
+ new ApiCore({ http: this.jSWapiApplication, request }),
829
+ request,
830
+ new ApiResponse(jsWapiResponse, this.jSWapiApplication.getName())
831
+ );
832
+ });
804
833
  }
805
834
  };
806
835
 
@@ -824,6 +853,7 @@ export {
824
853
  ApiObjectCollectionIterator,
825
854
  ApiRequest,
826
855
  ApiResponse,
856
+ ApplicationInitializer,
827
857
  EngineInitializer,
828
858
  LanguageCode,
829
859
  UserMessages_default as UserMessages,
@@ -767,17 +767,12 @@ var EngineInitializer = class {
767
767
  this.engine.putJSWapiOper(operationName, (jsWapiRequest, jsWapiResponse) => {
768
768
  const request = new ApiRequest(jsWapiRequest, this.engine.getName());
769
769
  const apiCore = new ApiCore({ http: this.engine, request });
770
- return this._operations[operationName](
771
- apiCore,
772
- request,
773
- new ApiResponse(jsWapiResponse, this.engine.getName()),
774
- {
775
- parameters: this.engine.getExternalSystemParameters(),
776
- objectName: this.engine.getName(),
777
- externalObject: this.engine.getExternalName(),
778
- externalFieldsMap: this.engine.getExternalObjectFields()
779
- }
780
- );
770
+ return this._operations[operationName](apiCore, request, new ApiResponse(jsWapiResponse, this.engine.getName()), {
771
+ parameters: this.engine.getExternalSystemParameters(),
772
+ objectName: this.engine.getName(),
773
+ externalObject: this.engine.getExternalName(),
774
+ externalFieldsMap: this.engine.getExternalObjectFields()
775
+ });
781
776
  });
782
777
  }
783
778
  /**
@@ -794,13 +789,47 @@ var EngineInitializer = class {
794
789
  initTranslation(translations) {
795
790
  UserMessages_default.appendDictionary(translations);
796
791
  }
797
- call({ apiCore, apiRequest, apiResponse, operation, meta }) {
798
- return this._operations[operation](
799
- apiCore,
800
- apiRequest,
801
- apiResponse,
802
- meta
803
- );
792
+ call({
793
+ apiCore,
794
+ apiRequest,
795
+ apiResponse,
796
+ operation,
797
+ meta
798
+ }) {
799
+ return this._operations[operation](apiCore, apiRequest, apiResponse, meta);
800
+ }
801
+ };
802
+
803
+ // src/classes/ApplicationInitializer.ts
804
+ var ApplicationInitializer = class {
805
+ constructor(operations) {
806
+ __publicField(this, "jSWapiApplication");
807
+ __publicField(this, "_operations");
808
+ const throwError = (msg) => {
809
+ throw new Error(msg);
810
+ };
811
+ if (!operations)
812
+ throwError('Property "operations" in the settings is required');
813
+ this._operations = operations;
814
+ this.internalCreate();
815
+ }
816
+ internalCreate() {
817
+ jsWapi.setJSWapiObject((jSWapiApplication) => {
818
+ this.jSWapiApplication = jSWapiApplication;
819
+ for (const operationName in this._operations) {
820
+ this.putOperation(operationName);
821
+ }
822
+ });
823
+ }
824
+ putOperation(operationName) {
825
+ this.jSWapiApplication.putJSWapiOper(operationName, (jsWapiRequest, jsWapiResponse) => {
826
+ const request = new ApiRequest(jsWapiRequest, this.jSWapiApplication.getName());
827
+ return this._operations[operationName](
828
+ new ApiCore({ http: this.jSWapiApplication, request }),
829
+ request,
830
+ new ApiResponse(jsWapiResponse, this.jSWapiApplication.getName())
831
+ );
832
+ });
804
833
  }
805
834
  };
806
835
 
@@ -824,6 +853,7 @@ export {
824
853
  ApiObjectCollectionIterator,
825
854
  ApiRequest,
826
855
  ApiResponse,
856
+ ApplicationInitializer,
827
857
  EngineInitializer,
828
858
  LanguageCode,
829
859
  UserMessages_default as UserMessages,