pict-section-recordset 1.0.6 → 1.0.8

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.8",
4
4
  "description": "Pict dynamic record set management views",
5
5
  "main": "source/Pict-Section-RecordSet.js",
6
6
  "directories": {
@@ -34,19 +34,23 @@ class RecordSetProvider extends libRecordSetProviderBase
34
34
  {
35
35
  super(pFable, pOptions, pServiceHash);
36
36
 
37
- /** @type {RestClient} */
38
- this.restClient;
39
37
  /** @type {Record<string, any>} */
40
38
  this.options;
41
39
  /** @type {import('fable')} */
42
40
  this.fable;
43
- /** @type {import('pict')} */
41
+ /** @type {import('fable') & import('pict')} */
44
42
  this.pict;
45
43
  //TODO: make this typedef better
46
44
  /** @type {Record<string, any>} */
47
45
  this._Schema = { };
48
46
  }
49
47
 
48
+ /** @type {RestClient} */
49
+ get restClient()
50
+ {
51
+ return this.fable.RestClient;
52
+ }
53
+
50
54
  /**
51
55
  * @typedef {(error?: Error, result?: T) => void} RecordSetCallback
52
56
  * @template T = Record<string, any>
@@ -318,21 +322,43 @@ class RecordSetProvider extends libRecordSetProviderBase
318
322
  onInitializeAsync(fCallback)
319
323
  {
320
324
  this.fable.log.info('Initializing RecordSetProvider-MeadowEndpoints');
321
- this.restClient = this.fable.RestClient;
322
- this.restClient.getJSON(`${this.options.URLPrefix}${this.options.Entity}/Schema`, (error, response, result) =>
325
+ const checkSession = this.pict.services.PictSectionRecordSet ? this.pict.services.PictSectionRecordSet.checkSession.bind(this.pict.services.PictSectionRecordSet) : async () => true;
326
+ checkSession('Schema').then(async (supported) =>
323
327
  {
324
- if (error)
328
+ if (!supported)
325
329
  {
326
- this._Schema = { };
327
- return fCallback(error);
330
+ return fCallback();
328
331
  }
329
- this._Schema = result;
330
- return fCallback(null);
332
+ this.restClient.getJSON(`${this.options.URLPrefix}${this.options.Entity}/Schema`, (error, response, result) =>
333
+ {
334
+ if (error)
335
+ {
336
+ throw error;
337
+ }
338
+ this._Schema = result;
339
+ return fCallback(null);
340
+ });
341
+ }).catch((error) =>
342
+ {
343
+ this._Schema = null;
344
+ this.fable.log.error('Error checking session for schema', error);
345
+ return fCallback(error);
331
346
  });
332
347
  }
333
348
 
334
- get recordSchema()
349
+ async getRecordSchema()
335
350
  {
351
+ if (!this._Schema)
352
+ {
353
+ await new Promise((resolve, reject) => this.onInitializeAsync((pError) =>
354
+ {
355
+ if (pError)
356
+ {
357
+ return reject(pError);
358
+ }
359
+ resolve();
360
+ }));
361
+ }
336
362
  return this._Schema;
337
363
  }
338
364
  }
@@ -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
  });
@@ -20,10 +20,12 @@ export = RecordSetProvider;
20
20
  * @extends libRecordSetProviderBase
21
21
  */
22
22
  declare class RecordSetProvider extends libRecordSetProviderBase {
23
- /** @type {RestClient} */
24
- restClient: RestClient;
23
+ /** @type {import('fable') & import('pict')} */
24
+ pict: any & import("pict");
25
25
  /** @type {Record<string, any>} */
26
26
  _Schema: Record<string, any>;
27
+ /** @type {RestClient} */
28
+ get restClient(): RestClient;
27
29
  /**
28
30
  * @typedef {(error?: Error, result?: T) => void} RecordSetCallback
29
31
  * @template T = Record<string, any>
@@ -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,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,QAgBjC;CAMD;;;;;0BA7UY,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"}
1
+ {"version":3,"file":"RecordSet-RecordProvider-MeadowEndpoints.d.ts","sourceRoot":"","sources":["../../source/providers/RecordSet-RecordProvider-MeadowEndpoints.js"],"names":[],"mappings":";AAGA;;;;;;;;;;;;;;;GAeG;AAEH;;;GAGG;AACH;IAgBE,+CAA+C;IAC/C,MADW,GAAe,GAAG,OAAO,MAAM,CAAC,CAClC;IAET,kCAAkC;IAClC,SADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACZ;IAGnB,yBAAyB;IACzB,kBADW,UAAU,CAIpB;IAED;;;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,gBAsB7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AC,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"}