skapi-js 1.0.16 → 1.0.17

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/js/main/skapi.js CHANGED
@@ -22,7 +22,7 @@ export default class Skapi {
22
22
  set user(value) {
23
23
  }
24
24
  constructor(service, owner, options) {
25
- this.version = '1.0.16';
25
+ this.version = '1.0.17';
26
26
  this.session = null;
27
27
  this.connection = null;
28
28
  this.host = 'skapi';
@@ -555,6 +555,9 @@ export async function getRecords(query, fetchOptions) {
555
555
  throw new SkapiError("User has no access", { code: 'INVALID_REQUEST' });
556
556
  }
557
557
  }
558
+ if (!query.table.hasOwnProperty('access_group')) {
559
+ query.table.access_group = query.table?.subscription ? 1 : 0;
560
+ }
558
561
  }
559
562
  if (query?.index && !query.index?.name) {
560
563
  throw new SkapiError('"index.name" is required when using "index" parameter.', { code: 'INVALID_REQUEST' });
@@ -725,7 +728,7 @@ export async function postRecord(form, config) {
725
728
  if (!config_chkd?.table && !config_chkd?.record_id) {
726
729
  throw new SkapiError('Either "record_id" or "table" should have a value.', { code: 'INVALID_PARAMETER' });
727
730
  }
728
- if (typeof config_chkd.table !== 'string' && config_chkd.table) {
731
+ if (config_chkd.table) {
729
732
  if (config_chkd.table.access_group === 'public') {
730
733
  config_chkd.table.access_group = 0;
731
734
  }
@@ -747,8 +750,8 @@ export async function postRecord(form, config) {
747
750
  }
748
751
  }
749
752
  if (config_chkd.table?.subscription) {
750
- if (!config_chkd?.record_id && !config_chkd.table?.access_group) {
751
- throw new SkapiError('Public records cannot require subscription.', { code: 'INVALID_REQUEST' });
753
+ if (!config_chkd?.record_id && !config_chkd.table.hasOwnProperty('access_group')) {
754
+ config_chkd.table.access_group = 1;
752
755
  }
753
756
  if (config_chkd.table.access_group === 0) {
754
757
  throw new SkapiError('Public records cannot require subscription.', { code: 'INVALID_REQUEST' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skapi-js",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "Javascript library for Skapi: Complete JAM Stack, front-end driven serverless backend API service.",
5
5
  "main": "./dist/skapi.module.js",
6
6
  "types": "./js/Main.d.ts",