pict-section-recordset 1.0.6 → 1.0.7

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": "pict-section-recordset",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Pict dynamic record set management views",
5
5
  "main": "source/Pict-Section-RecordSet.js",
6
6
  "directories": {
@@ -40,7 +40,7 @@ class RecordSetProvider extends libRecordSetProviderBase
40
40
  this.options;
41
41
  /** @type {import('fable')} */
42
42
  this.fable;
43
- /** @type {import('pict')} */
43
+ /** @type {import('fable') & import('pict')} */
44
44
  this.pict;
45
45
  //TODO: make this typedef better
46
46
  /** @type {Record<string, any>} */
@@ -319,20 +319,43 @@ class RecordSetProvider extends libRecordSetProviderBase
319
319
  {
320
320
  this.fable.log.info('Initializing RecordSetProvider-MeadowEndpoints');
321
321
  this.restClient = this.fable.RestClient;
322
- this.restClient.getJSON(`${this.options.URLPrefix}${this.options.Entity}/Schema`, (error, response, result) =>
322
+ const checkSession = this.pict.services.PictSectionRecordSet ? this.pict.services.PictSectionRecordSet.checkSession.bind(this.pict.services.PictSectionRecordSet) : async () => true;
323
+ checkSession('Schema').then(async (supported) =>
323
324
  {
324
- if (error)
325
+ if (!supported)
325
326
  {
326
- this._Schema = { };
327
- return fCallback(error);
327
+ return fCallback();
328
328
  }
329
- this._Schema = result;
330
- return fCallback(null);
329
+ this.restClient.getJSON(`${this.options.URLPrefix}${this.options.Entity}/Schema`, (error, response, result) =>
330
+ {
331
+ if (error)
332
+ {
333
+ throw error;
334
+ }
335
+ this._Schema = result;
336
+ return fCallback(null);
337
+ });
338
+ }).catch((error) =>
339
+ {
340
+ this._Schema = null;
341
+ this.fable.log.error('Error checking session for schema', error);
342
+ return fCallback(error);
331
343
  });
332
344
  }
333
345
 
334
- get recordSchema()
346
+ async getRecordSchema()
335
347
  {
348
+ if (!this._Schema)
349
+ {
350
+ await new Promise((resolve, reject) => this.onInitializeAsync((pError) =>
351
+ {
352
+ if (pError)
353
+ {
354
+ return reject(pError);
355
+ }
356
+ resolve();
357
+ }));
358
+ }
336
359
  return this._Schema;
337
360
  }
338
361
  }
@@ -45,6 +45,7 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
45
45
  this.recordSetProviderConfigurations = {};
46
46
 
47
47
  this.recordSetListConfigurations = {};
48
+ this.sessionProviders = [];
48
49
 
49
50
  this.has_initialized = false;
50
51
  }
@@ -254,6 +255,18 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
254
255
  return true;
255
256
  }
256
257
 
258
+ async checkSession(pCapability)
259
+ {
260
+ for (const sessionProvider of this.sessionProviders)
261
+ {
262
+ if (!await sessionProvider(pCapability))
263
+ {
264
+ return false;
265
+ }
266
+ }
267
+ return true;
268
+ }
269
+
257
270
  addRecordLinkTemplate(pNameTemplate, pURLTemplate, pDefault)
258
271
  {
259
272
  return this.fable.providers.RecordSetLinkManager.addRecordLinkTemplate(pNameTemplate, pURLTemplate, pDefault);
@@ -222,7 +222,7 @@ class viewRecordSetList extends libPictRecordSetRecordView
222
222
  // Get the total record count
223
223
  tmpRecordListData.TotalRecordCount = await this.pict.providers[pProviderHash].getRecordSetCount(tmpRecordListData);
224
224
  // Get the record schema
225
- tmpRecordListData.RecordSchema = this.pict.providers[pProviderHash].recordSchema;
225
+ tmpRecordListData.RecordSchema = await this.pict.providers[pProviderHash].getRecordSchema();
226
226
 
227
227
  // TODO: This should be coming from the schema but that can come after we discuss how we deal with default routing
228
228
  tmpRecordListData.GUIDAddress = `GUID${this.pict.providers[pProviderHash].options.Entity}`;
@@ -154,7 +154,7 @@ class viewRecordSetRead extends libPictRecordSetRecordView
154
154
  tmpRecordReadData.GUIDAddress = `GUID${this.pict.providers[pProviderHash].options.Entity}`;
155
155
 
156
156
  tmpRecordReadData.Record = await this.pict.providers[pProviderHash].getRecordByGUID(pRecordGUID);
157
- tmpRecordReadData.RecordSchema = this.pict.providers[pProviderHash].recordSchema;
157
+ tmpRecordReadData.RecordSchema = await this.pict.providers[pProviderHash].getRecordSchema();
158
158
 
159
159
  tmpRecordReadData = this.onBeforeRenderRead(tmpRecordReadData);
160
160
 
@@ -194,7 +194,7 @@ suite
194
194
 
195
195
  test('recordSchema', async () =>
196
196
  {
197
- const schema = await _Pict.providers.BooksProvider.recordSchema;
197
+ const schema = await _Pict.providers.BooksProvider.getRecordSchema();
198
198
  Expect(schema).to.be.an('object', 'Schema should be an object.');
199
199
  Expect(Object.keys(schema).length).to.be.greaterThan(0, 'Schema should have properties.');
200
200
  });
@@ -22,6 +22,8 @@ export = RecordSetProvider;
22
22
  declare class RecordSetProvider extends libRecordSetProviderBase {
23
23
  /** @type {RestClient} */
24
24
  restClient: RestClient;
25
+ /** @type {import('fable') & import('pict')} */
26
+ pict: any & import("pict");
25
27
  /** @type {Record<string, any>} */
26
28
  _Schema: Record<string, any>;
27
29
  /**
@@ -80,6 +82,7 @@ declare class RecordSetProvider extends libRecordSetProviderBase {
80
82
  * @param {(error?: Error) => void} fCallback - The callback function.
81
83
  */
82
84
  onInitializeAsync(fCallback: (error?: Error) => void): void;
85
+ getRecordSchema(): Promise<Record<string, any>>;
83
86
  }
84
87
  declare namespace RecordSetProvider {
85
88
  export { RestClientCallback, RecordSetFilter, RecordSetResult, RestClient };
@@ -1 +1 @@
1
- {"version":3,"file":"RecordSet-RecordProvider-MeadowEndpoints.d.ts","sourceRoot":"","sources":["../../source/providers/RecordSet-RecordProvider-MeadowEndpoints.js"],"names":[],"mappings":";AAGA;;;;;;;;;;;;;;;GAeG;AAEH;;;GAGG;AACH;IAYE,yBAAyB;IACzB,YADW,UAAU,CACN;IAQf,kCAAkC;IAClC,SADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACZ;IAGnB;;;OAGG;IAEH;;;;OAIG;IACH,qBAFW,MAAM,GAAC,MAAM,gBA4BvB;IAED;;;;OAIG;IACH,uBAFW,MAAM,GAAC,MAAM,g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C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC5E,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAC7F"}
1
+ {"version":3,"file":"RecordSet-RecordProvider-MeadowEndpoints.d.ts","sourceRoot":"","sources":["../../source/providers/RecordSet-RecordProvider-MeadowEndpoints.js"],"names":[],"mappings":";AAGA;;;;;;;;;;;;;;;GAeG;AAEH;;;GAGG;AACH;IAYE,yBAAyB;IACzB,YADW,UAAU,CACN;IAKf,+CAA+C;IAC/C,MADW,GAAe,GAAG,OAAO,MAAM,CAAC,CAClC;IAET,kCAAkC;IAClC,SADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACZ;IAGnB;;;OAGG;IAEH;;;;OAIG;IACH,qBAFW,MAAM,GAAC,MAAM,gBA4BvB;IAED;;;;OAIG;IACH,uBAFW,MAAM,GAAC,MAAM,gBAuBvB;IA+CD;;;;OAIG;IACH,4BAFW,eAAe,gBAyBzB;IAED;;;;OAIG;IACH,sBAFW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,gBAsB7B;IAED;;;;OAIG;IACH,sBAFW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,gBAsB7B;IAED;;;;OAIG;IACH,sBAFW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,gBAsB7B;IAED;;;;OAIG;IACH,sBAFW,MAAM,GAAC,MAAM,gBAKvB;IAaD;;;;OAIG;IACH,qBAFW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,gBAK7B;IAcD;;OAEG;IACH,6BAFW,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,QA4BjC;IAED,gDAcC;CACD;;;;;0BApWY,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI;uBAErC,OAAO,oCAAoC,EAAE,eAAe;uBAC5D,OAAO,oCAAoC,EAAE,eAAe;kBAE5D;IACT,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC1F,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC5E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC7E,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC9E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC7E,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC5E,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAC7F"}
@@ -20,12 +20,14 @@ declare class RecordSetMetacontroller {
20
20
  recordSetProviders: {};
21
21
  recordSetProviderConfigurations: {};
22
22
  recordSetListConfigurations: {};
23
+ sessionProviders: any[];
23
24
  has_initialized: boolean;
24
25
  loadRecordSetConfiguration(pRecordSetConfiguration: any): boolean;
25
26
  loadRecordSetConfigurationArray(pRecordSetConfigurationArray: any): boolean;
26
27
  loadRecordSetDynamcally(pRecordSet: any, pEntity: any, pDefaultFilter: any): any;
27
28
  handleLoadDynamicRecordSetRoute(pRoutePayload: any): any;
28
29
  addRoutes(pPictRouter: any): boolean;
30
+ checkSession(pCapability: any): Promise<boolean>;
29
31
  addRecordLinkTemplate(pNameTemplate: any, pURLTemplate: any, pDefault: any): any;
30
32
  initialize(): true | this;
31
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RecordsSet-MetaController.d.ts","sourceRoot":"","sources":["../../source/services/RecordsSet-MetaController.js"],"names":[],"mappings":";AAoBA;IAEC,2DA2BC;IAtBA,0HAA0H;IAC1H,OADW,OAAO,MAAM,CAAC,GAAG;QAAE,iCAAiC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,KAAK,GAAG,CAAA;KAAE,CAC5G;IACV,kBAAkB;IAClB,KADW,GAAG,CACN;IACR,kBAAkB;IAClB,SADW,GAAG,CACF;IACZ,qBAAqB;IACrB,MADW,MAAM,CACR;IAET;;;;;MAKC;IAED,uBAA4B;IAC5B,oCAAyC;IAEzC,gCAAqC;IAErC,yBAA4B;IA6B7B,kEA0FC;IAED,4EAmBC;IAED,iFAyCC;IAED,yDAaC;IAED,qCAMC;IAED,iFAGC;IAED,0BAuCC;CACD"}
1
+ {"version":3,"file":"RecordsSet-MetaController.d.ts","sourceRoot":"","sources":["../../source/services/RecordsSet-MetaController.js"],"names":[],"mappings":";AAoBA;IAEC,2DA4BC;IAvBA,0HAA0H;IAC1H,OADW,OAAO,MAAM,CAAC,GAAG;QAAE,iCAAiC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,KAAK,GAAG,CAAA;KAAE,CAC5G;IACV,kBAAkB;IAClB,KADW,GAAG,CACN;IACR,kBAAkB;IAClB,SADW,GAAG,CACF;IACZ,qBAAqB;IACrB,MADW,MAAM,CACR;IAET;;;;;MAKC;IAED,uBAA4B;IAC5B,oCAAyC;IAEzC,gCAAqC;IACrC,wBAA0B;IAE1B,yBAA4B;IA6B7B,kEA0FC;IAED,4EAmBC;IAED,iFAyCC;IAED,yDAaC;IAED,qCAMC;IAED,iDAUC;IAED,iFAGC;IAED,0BAuCC;CACD"}