@denevads/dnv-smo 1.0.37 → 1.0.39

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.
@@ -3,6 +3,8 @@ export interface setDatasource {
3
3
  }
4
4
  export interface start {
5
5
  }
6
+ export interface dispose {
7
+ }
6
8
  export interface variable {
7
9
  variable: string;
8
10
  valor: string;
@@ -73,3 +75,10 @@ export interface Recurso {
73
75
  dias: string;
74
76
  nombre: string;
75
77
  }
78
+ export interface Datasource {
79
+ data: string;
80
+ tipo: string;
81
+ }
82
+ export interface DatasourceMap {
83
+ [codigo: string]: Datasource;
84
+ }
package/dist/smo.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { setDatasource, variable, location, DataSalida, ExecFunction, Notify, start, GetRecursosByCodigo, GetRecursos, GetRecursosRelleno, GetRecursosMetadatos, RecursosMetadato } from "./interfaces/callbacks";
1
+ import { setDatasource, variable, location, DataSalida, ExecFunction, Notify, start, GetRecursosByCodigo, GetRecursos, GetRecursosRelleno, GetRecursosMetadatos, RecursosMetadato, DatasourceMap } from "./interfaces/callbacks";
2
2
  import { Subject } from 'rxjs';
3
3
  export declare class SMO {
4
4
  vars: any;
@@ -12,6 +12,7 @@ export declare class SMO {
12
12
  init(): void;
13
13
  initOnMessage(): void;
14
14
  start(): void;
15
+ dispose(): void;
15
16
  setDatasource(datasource: setDatasource): void;
16
17
  getVariable(variable: variable): void;
17
18
  setCurrentStream(stream: string): void;
@@ -28,9 +29,11 @@ export declare class SMO {
28
29
  checkHealth(json: string): void;
29
30
  checkHealthPrinter(json: string): void;
30
31
  getValorCalendario(estado: boolean): void;
32
+ getLocalDatasource(data: DatasourceMap): void;
31
33
  }
32
34
  declare class SmoEvents {
33
35
  start: Subject<start>;
36
+ dispose: Subject<start>;
34
37
  setDatasource: Subject<setDatasource>;
35
38
  setDatasourceJson: Subject<any>;
36
39
  getVariable: Subject<variable>;
@@ -48,6 +51,7 @@ declare class SmoEvents {
48
51
  checkHealth: Subject<string>;
49
52
  checkHealthPrinter: Subject<string>;
50
53
  getValorCalendario: Subject<boolean>;
54
+ getLocalDatasource: Subject<DatasourceMap>;
51
55
  constructor(smo: SMO);
52
56
  }
53
57
  declare class smoCallBacks {
@@ -98,6 +102,12 @@ declare class smoCallBacks {
98
102
  checkHealthPrinter(): void;
99
103
  printImage(image: string): void;
100
104
  getValorCalendario(codigo: number, tipoObjeto?: number): void;
105
+ /**
106
+ * Funcion que permite obtener uno o varios datasources pasando su/sus codigos
107
+ * Permite un solo codigo o un array de codigos
108
+ * @param codDS Puede ser un número o un array de números
109
+ */
110
+ getLocalDatasource(codDS: number | number[]): void;
101
111
  }
102
112
  declare class Utils {
103
113
  smo: SMO;
@@ -111,6 +121,7 @@ declare class Utils {
111
121
  }
112
122
  export declare enum SMO_EVENT_TYPE {
113
123
  start = "start",
124
+ dispose = "dispose",
114
125
  setDatasource = "setDatasource",
115
126
  getVariable = "getVariable",
116
127
  setCurrentStream = "setCurrentStream",
@@ -127,7 +138,8 @@ export declare enum SMO_EVENT_TYPE {
127
138
  getVariableStorage = "getVariableStorage",
128
139
  checkHealth = "checkHealth",
129
140
  checkHealthPrinter = "checkHealthPrinter",
130
- getValorCalendario = "getValorCalendario"
141
+ getValorCalendario = "getValorCalendario",
142
+ getLocalDatasource = "getLocalDatasource"
131
143
  }
132
144
  export declare enum LogLevel {
133
145
  Debug = 0,
@@ -177,5 +189,6 @@ export interface ObjJSType {
177
189
  checkHealthPrinter: () => void;
178
190
  checkHealth: () => void;
179
191
  getValorCalendario: () => void;
192
+ getLocalDatasource: () => void;
180
193
  }
181
194
  export {};
package/dist/smo.js CHANGED
@@ -108,7 +108,9 @@ var SMO = /** @class */ (function () {
108
108
  // @ts-ignore
109
109
  CheckHealth: window.objJS.checkHealth,
110
110
  // @ts-ignore
111
- getValorCalendario: window.objJS.getValorCalendario
111
+ getValorCalendario: window.objJS.getValorCalendario,
112
+ // @ts-ignore
113
+ getLocalDatasource: window.objJS.getLocalDatasource,
112
114
  };
113
115
  }
114
116
  else {
@@ -154,6 +156,10 @@ var SMO = /** @class */ (function () {
154
156
  selft.start();
155
157
  return;
156
158
  }
159
+ if (func == SMO_EVENT_TYPE.dispose) {
160
+ selft.dispose();
161
+ return;
162
+ }
157
163
  if (func == SMO_EVENT_TYPE.setDatasource) {
158
164
  selft.setDatasource(e.data.objData);
159
165
  return;
@@ -216,6 +222,10 @@ var SMO = /** @class */ (function () {
216
222
  selft.getValorCalendario(e.data.objData);
217
223
  return;
218
224
  }
225
+ if (func == SMO_EVENT_TYPE.getLocalDatasource) {
226
+ selft.getLocalDatasource(e.data.objData);
227
+ return;
228
+ }
219
229
  console.warn("message not implemented!!" + func);
220
230
  }
221
231
  };
@@ -223,6 +233,9 @@ var SMO = /** @class */ (function () {
223
233
  SMO.prototype.start = function () {
224
234
  this.events.start.next({});
225
235
  };
236
+ SMO.prototype.dispose = function () {
237
+ this.events.dispose.next({});
238
+ };
226
239
  SMO.prototype.setDatasource = function (datasource) {
227
240
  this.events.setDatasource.next(datasource);
228
241
  this.events.setDatasourceJson.next(this.utils.xmlToJSON(datasource.xml));
@@ -272,12 +285,16 @@ var SMO = /** @class */ (function () {
272
285
  SMO.prototype.getValorCalendario = function (estado) {
273
286
  this.events.getValorCalendario.next(estado);
274
287
  };
288
+ SMO.prototype.getLocalDatasource = function (data) {
289
+ this.events.getLocalDatasource.next(data);
290
+ };
275
291
  return SMO;
276
292
  }());
277
293
  exports.SMO = SMO;
278
294
  var SmoEvents = /** @class */ (function () {
279
295
  function SmoEvents(smo) {
280
296
  this.start = new rxjs_1.Subject();
297
+ this.dispose = new rxjs_1.Subject();
281
298
  this.setDatasource = new rxjs_1.Subject();
282
299
  this.setDatasourceJson = new rxjs_1.Subject();
283
300
  this.getVariable = new rxjs_1.Subject();
@@ -295,6 +312,7 @@ var SmoEvents = /** @class */ (function () {
295
312
  this.checkHealth = new rxjs_1.Subject();
296
313
  this.checkHealthPrinter = new rxjs_1.Subject();
297
314
  this.getValorCalendario = new rxjs_1.Subject();
315
+ this.getLocalDatasource = new rxjs_1.Subject();
298
316
  }
299
317
  return SmoEvents;
300
318
  }());
@@ -668,6 +686,20 @@ var smoCallBacks = /** @class */ (function () {
668
686
  idSmo: this.smo.id
669
687
  }, this.smo.vars.idSmo);
670
688
  };
689
+ /**
690
+ * Funcion que permite obtener uno o varios datasources pasando su/sus codigos
691
+ * Permite un solo codigo o un array de codigos
692
+ * @param codDS Puede ser un número o un array de números
693
+ */
694
+ smoCallBacks.prototype.getLocalDatasource = function (codDS) {
695
+ // Si es un solo código, lo convertimos a un array para tratar ambos casos de la misma manera
696
+ var codDSArray = Array.isArray(codDS) ? codDS : [codDS];
697
+ this.smo.utils.sendToParent({
698
+ target: "Dnv.smoCallbacks.getLocalDatasource",
699
+ objData: codDSArray, // Enviamos el array, sea de un solo código o varios
700
+ idSmo: this.smo.id
701
+ }, this.smo.vars.idSmo);
702
+ };
671
703
  return smoCallBacks;
672
704
  }());
673
705
  var Utils = /** @class */ (function () {
@@ -828,6 +860,7 @@ var Utils = /** @class */ (function () {
828
860
  var SMO_EVENT_TYPE;
829
861
  (function (SMO_EVENT_TYPE) {
830
862
  SMO_EVENT_TYPE["start"] = "start";
863
+ SMO_EVENT_TYPE["dispose"] = "dispose";
831
864
  SMO_EVENT_TYPE["setDatasource"] = "setDatasource";
832
865
  SMO_EVENT_TYPE["getVariable"] = "getVariable";
833
866
  SMO_EVENT_TYPE["setCurrentStream"] = "setCurrentStream";
@@ -845,6 +878,7 @@ var SMO_EVENT_TYPE;
845
878
  SMO_EVENT_TYPE["checkHealth"] = "checkHealth";
846
879
  SMO_EVENT_TYPE["checkHealthPrinter"] = "checkHealthPrinter";
847
880
  SMO_EVENT_TYPE["getValorCalendario"] = "getValorCalendario";
881
+ SMO_EVENT_TYPE["getLocalDatasource"] = "getLocalDatasource";
848
882
  })(SMO_EVENT_TYPE || (exports.SMO_EVENT_TYPE = SMO_EVENT_TYPE = {}));
849
883
  var LogLevel;
850
884
  (function (LogLevel) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@denevads/dnv-smo",
3
- "version": "1.0.37",
3
+ "version": "1.0.39",
4
4
  "description": "SMO module",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -1,9 +1,12 @@
1
1
 
2
- export interface setDatasource{
2
+ export interface setDatasource{
3
3
  xml:string
4
4
  }
5
5
  export interface start{
6
6
 
7
+ }
8
+ export interface dispose{
9
+
7
10
  }
8
11
  export interface variable{
9
12
  variable:string,
@@ -77,4 +80,11 @@ export interface Recurso {
77
80
  dias:string;
78
81
  nombre:string;
79
82
  }
83
+ export interface Datasource{
84
+ data : string;
85
+ tipo: string;
86
+ }
87
+ export interface DatasourceMap {
88
+ [codigo: string]: Datasource; // Cada clave tiene un solo Datasource
89
+ }
80
90
 
package/src/smo.ts CHANGED
@@ -6,9 +6,10 @@ import {
6
6
  ExecFunction,
7
7
  Notify,
8
8
  start,
9
+ dispose,
9
10
  GetRecursosByCodigo,
10
11
  GetRecursos,
11
- GetRecursosRelleno, GetRecursosMetadatos, RecursosMetadato
12
+ GetRecursosRelleno, GetRecursosMetadatos, RecursosMetadato, Datasource, DatasourceMap
12
13
  } from "./interfaces/callbacks";
13
14
  import {interval, Subject, Subscription} from 'rxjs';
14
15
 
@@ -128,7 +129,9 @@ export class SMO {
128
129
  // @ts-ignore
129
130
  CheckHealth: window.objJS.checkHealth,
130
131
  // @ts-ignore
131
- getValorCalendario: window.objJS.getValorCalendario
132
+ getValorCalendario: window.objJS.getValorCalendario,
133
+ // @ts-ignore
134
+ getLocalDatasource: window.objJS.getLocalDatasource,
132
135
  };
133
136
  }else{
134
137
  console.log("No existe objJS en window");
@@ -168,82 +171,93 @@ export class SMO {
168
171
  initOnMessage():void{
169
172
  let selft = this;
170
173
  window.onmessage = function(e) {
171
- if (e.data.target) {
172
- var targets = e.data.target.split('.');
173
- var func = targets[targets.length-1];
174
- if(func == SMO_EVENT_TYPE.start){
175
- selft.start();
176
- return;
177
- }
178
- if(func == SMO_EVENT_TYPE.setDatasource){
179
- selft.setDatasource(e.data.objData);
180
- return;
181
- }
182
- if(func == SMO_EVENT_TYPE.getVariable){
183
- selft.getVariable(e.data.objData);
184
- return;
185
- }
186
- if(func ==SMO_EVENT_TYPE.setCurrentStream){
187
- selft.setCurrentStream(e.data.objData);
188
- return;
189
- }
190
- if(func==SMO_EVENT_TYPE.infoCurrentLocation){
191
- selft.infoCurrentLocation(e.data.objData);
192
- return;
193
- }
194
- if(func==SMO_EVENT_TYPE.setSalidaData){
195
- selft.setSalidaData(e.data.objData);
196
- return;
197
- }
198
- if(func ==SMO_EVENT_TYPE.updatefromsalida){
199
- selft.updatefromsalida(e.data.objData);
200
- return;
201
- }
202
- if(func == SMO_EVENT_TYPE.getRecursosByCodigo){
203
- selft.getRecursosByCodigo(e.data.objData);
204
- return;
205
- }
206
- if(func == SMO_EVENT_TYPE.getRecursosByMetadato){
207
- selft.getRecursosByMetadato(e.data.objData);
208
- return;
209
- }
210
- if(func == SMO_EVENT_TYPE.getRecursosByMetadatos){
211
- selft.getRecursosByMetadatos(e.data.objData);
212
- return;
213
- }
214
- if(func == SMO_EVENT_TYPE.getRecursos){
215
- selft.getRecursos(e.data.objData);
216
- }
217
- if(func == SMO_EVENT_TYPE.getRecursosDefault){
218
- selft.getRecursosDefault(e.data.objData);
219
- }
220
- if(func == SMO_EVENT_TYPE.getRecursosRelleno){
221
- selft.getRecursosRelleno(e.data.objData);
222
- return;
223
- }
224
- if(func == SMO_EVENT_TYPE.getVariableStorage){
225
- selft.getVariableStorage(e.data.objData);
226
- return;
227
- }
228
- if(func == SMO_EVENT_TYPE.checkHealth){
229
- selft.checkHealth(e.data.objData);
230
- return;
231
- }
232
- if(func == SMO_EVENT_TYPE.checkHealthPrinter){
233
- selft.checkHealthPrinter(e.data.objData);
234
- return;
235
- }
236
- if(func == SMO_EVENT_TYPE.getValorCalendario){
237
- selft.getValorCalendario(e.data.objData);
238
- return;
239
- }
240
- console.warn("message not implemented!!" +func);
174
+ if (e.data.target) {
175
+ var targets = e.data.target.split('.');
176
+ var func = targets[targets.length-1];
177
+ if(func == SMO_EVENT_TYPE.start){
178
+ selft.start();
179
+ return;
180
+ }
181
+ if(func == SMO_EVENT_TYPE.dispose){
182
+ selft.dispose();
183
+ return;
184
+ }
185
+ if(func == SMO_EVENT_TYPE.setDatasource){
186
+ selft.setDatasource(e.data.objData);
187
+ return;
188
+ }
189
+ if(func == SMO_EVENT_TYPE.getVariable){
190
+ selft.getVariable(e.data.objData);
191
+ return;
192
+ }
193
+ if(func ==SMO_EVENT_TYPE.setCurrentStream){
194
+ selft.setCurrentStream(e.data.objData);
195
+ return;
196
+ }
197
+ if(func==SMO_EVENT_TYPE.infoCurrentLocation){
198
+ selft.infoCurrentLocation(e.data.objData);
199
+ return;
200
+ }
201
+ if(func==SMO_EVENT_TYPE.setSalidaData){
202
+ selft.setSalidaData(e.data.objData);
203
+ return;
204
+ }
205
+ if(func ==SMO_EVENT_TYPE.updatefromsalida){
206
+ selft.updatefromsalida(e.data.objData);
207
+ return;
208
+ }
209
+ if(func == SMO_EVENT_TYPE.getRecursosByCodigo){
210
+ selft.getRecursosByCodigo(e.data.objData);
211
+ return;
212
+ }
213
+ if(func == SMO_EVENT_TYPE.getRecursosByMetadato){
214
+ selft.getRecursosByMetadato(e.data.objData);
215
+ return;
216
+ }
217
+ if(func == SMO_EVENT_TYPE.getRecursosByMetadatos){
218
+ selft.getRecursosByMetadatos(e.data.objData);
219
+ return;
220
+ }
221
+ if(func == SMO_EVENT_TYPE.getRecursos){
222
+ selft.getRecursos(e.data.objData);
223
+ }
224
+ if(func == SMO_EVENT_TYPE.getRecursosDefault){
225
+ selft.getRecursosDefault(e.data.objData);
226
+ }
227
+ if(func == SMO_EVENT_TYPE.getRecursosRelleno){
228
+ selft.getRecursosRelleno(e.data.objData);
229
+ return;
230
+ }
231
+ if(func == SMO_EVENT_TYPE.getVariableStorage){
232
+ selft.getVariableStorage(e.data.objData);
233
+ return;
234
+ }
235
+ if(func == SMO_EVENT_TYPE.checkHealth){
236
+ selft.checkHealth(e.data.objData);
237
+ return;
238
+ }
239
+ if(func == SMO_EVENT_TYPE.checkHealthPrinter){
240
+ selft.checkHealthPrinter(e.data.objData);
241
+ return;
242
+ }
243
+ if(func == SMO_EVENT_TYPE.getValorCalendario){
244
+ selft.getValorCalendario(e.data.objData);
245
+ return;
246
+ }
247
+ if(func == SMO_EVENT_TYPE.getLocalDatasource){
248
+ selft.getLocalDatasource(e.data.objData);
249
+ return;
250
+ }
251
+ console.warn("message not implemented!!" +func);
241
252
  }
242
253
  }
243
254
  }
244
255
  start():void{
245
256
  this.events.start.next({});
246
257
  }
258
+ dispose():void{
259
+ this.events.dispose.next({});
260
+ }
247
261
  setDatasource(datasource:setDatasource):void {
248
262
  this.events.setDatasource.next(datasource);
249
263
  this.events.setDatasourceJson.next(this.utils.xmlToJSON(datasource.xml));
@@ -294,10 +308,14 @@ export class SMO {
294
308
  getValorCalendario(estado:boolean):void{
295
309
  this.events.getValorCalendario.next(estado);
296
310
  }
311
+ getLocalDatasource(data: DatasourceMap):void{
312
+ this.events.getLocalDatasource.next(data);
313
+ }
297
314
  }
298
315
 
299
316
  class SmoEvents{
300
317
  public start: Subject<start> = new Subject<start>();
318
+ public dispose: Subject<start> = new Subject<dispose>();
301
319
  public setDatasource: Subject<setDatasource> = new Subject<setDatasource>();
302
320
  public setDatasourceJson: Subject<any> = new Subject<any>();
303
321
  public getVariable: Subject<variable> = new Subject<variable>();
@@ -315,6 +333,7 @@ class SmoEvents{
315
333
  public checkHealth: Subject<string> = new Subject<string>();
316
334
  public checkHealthPrinter: Subject<string> = new Subject<string>();
317
335
  public getValorCalendario: Subject<boolean> = new Subject<boolean>();
336
+ public getLocalDatasource: Subject<DatasourceMap> = new Subject<DatasourceMap>();
318
337
  constructor(smo:SMO){}
319
338
  }
320
339
  class smoCallBacks{
@@ -691,6 +710,21 @@ class smoCallBacks{
691
710
  idSmo: this.smo.id
692
711
  }, this.smo.vars.idSmo);
693
712
  }
713
+ /**
714
+ * Funcion que permite obtener uno o varios datasources pasando su/sus codigos
715
+ * Permite un solo codigo o un array de codigos
716
+ * @param codDS Puede ser un número o un array de números
717
+ */
718
+ getLocalDatasource(codDS: number | number[]): void {
719
+ // Si es un solo código, lo convertimos a un array para tratar ambos casos de la misma manera
720
+ const codDSArray = Array.isArray(codDS) ? codDS : [codDS];
721
+
722
+ this.smo.utils.sendToParent({
723
+ target: "Dnv.smoCallbacks.getLocalDatasource",
724
+ objData: codDSArray, // Enviamos el array, sea de un solo código o varios
725
+ idSmo: this.smo.id
726
+ }, this.smo.vars.idSmo);
727
+ }
694
728
 
695
729
  }
696
730
  class Utils{
@@ -866,6 +900,7 @@ class Utils{
866
900
  }
867
901
  export enum SMO_EVENT_TYPE{
868
902
  start = "start",
903
+ dispose = "dispose",
869
904
  setDatasource = "setDatasource",
870
905
  getVariable = "getVariable",
871
906
  setCurrentStream = "setCurrentStream",
@@ -882,7 +917,8 @@ export enum SMO_EVENT_TYPE{
882
917
  getVariableStorage = "getVariableStorage",
883
918
  checkHealth = "checkHealth",
884
919
  checkHealthPrinter = "checkHealthPrinter",
885
- getValorCalendario = "getValorCalendario"
920
+ getValorCalendario = "getValorCalendario",
921
+ getLocalDatasource = "getLocalDatasource"
886
922
  }
887
923
  export enum LogLevel {
888
924
  Debug= 0,
@@ -932,5 +968,6 @@ export interface ObjJSType {
932
968
  checkHealthPrinter: () => void;
933
969
  checkHealth: () => void;
934
970
  getValorCalendario: () => void;
971
+ getLocalDatasource: () => void;
935
972
  }
936
973