adminforth 1.0.63 → 1.0.64

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/dist/index.js CHANGED
@@ -590,7 +590,7 @@ class AdminForth {
590
590
  method: 'POST',
591
591
  path: '/get_resource_foreign_data',
592
592
  handler: (_p) => __awaiter(this, [_p], void 0, function* ({ body, adminUser }) {
593
- var _q, _r;
593
+ var _q, _r, _s, _t;
594
594
  const { resourceId, column } = body;
595
595
  if (!this.statuses.dbDiscover) {
596
596
  return { error: 'Database discovery not started' };
@@ -611,7 +611,7 @@ class AdminForth {
611
611
  }
612
612
  const targetResourceId = columnConfig.foreignResource.resourceId;
613
613
  const targetResource = this.config.resources.find((res) => res.resourceId == targetResourceId);
614
- for (const hook of getFunctionList((_q = columnConfig.foreignResource.hooks) === null || _q === void 0 ? void 0 : _q.beforeDatasourceRequest)) {
614
+ for (const hook of getFunctionList((_r = (_q = columnConfig.foreignResource.hooks) === null || _q === void 0 ? void 0 : _q.dropdownList) === null || _r === void 0 ? void 0 : _r.beforeDatasourceRequest)) {
615
615
  const resp = yield hook({ query: body, adminUser });
616
616
  if (!resp || (!resp.ok && !resp.error)) {
617
617
  throw new Error(`Hook must return object with {ok: true} or { error: 'Error' } `);
@@ -640,7 +640,7 @@ class AdminForth {
640
640
  const response = {
641
641
  items
642
642
  };
643
- for (const hook of getFunctionList((_r = columnConfig.foreignResource.hooks) === null || _r === void 0 ? void 0 : _r.afterDatasourceResponse)) {
643
+ for (const hook of getFunctionList((_t = (_s = columnConfig.foreignResource.hooks) === null || _s === void 0 ? void 0 : _s.dropdownList) === null || _t === void 0 ? void 0 : _t.afterDatasourceResponse)) {
644
644
  const resp = yield hook({ response, adminUser });
645
645
  if (!resp || (!resp.ok && !resp.error)) {
646
646
  throw new Error(`Hook must return object with {ok: true} or { error: 'Error' } `);
@@ -655,7 +655,7 @@ class AdminForth {
655
655
  server.endpoint({
656
656
  method: 'POST',
657
657
  path: '/get_min_max_for_columns',
658
- handler: (_s) => __awaiter(this, [_s], void 0, function* ({ body }) {
658
+ handler: (_u) => __awaiter(this, [_u], void 0, function* ({ body }) {
659
659
  const { resourceId } = body;
660
660
  if (!this.statuses.dbDiscover) {
661
661
  return { error: 'Database discovery not started' };
@@ -684,8 +684,8 @@ class AdminForth {
684
684
  server.endpoint({
685
685
  method: 'POST',
686
686
  path: '/create_record',
687
- handler: (_t) => __awaiter(this, [_t], void 0, function* ({ body, adminUser }) {
688
- var _u, _v, _w, _x, _y;
687
+ handler: (_v) => __awaiter(this, [_v], void 0, function* ({ body, adminUser }) {
688
+ var _w, _x, _y, _z, _0;
689
689
  console.log('create_record', body, this.config.resources);
690
690
  const resource = this.config.resources.find((res) => res.resourceId == body['resourceId']);
691
691
  if (!resource) {
@@ -693,7 +693,7 @@ class AdminForth {
693
693
  }
694
694
  const record = body['record'];
695
695
  // execute hook if needed
696
- for (const hook of getFunctionList((_v = (_u = resource.hooks) === null || _u === void 0 ? void 0 : _u.create) === null || _v === void 0 ? void 0 : _v.beforeSave)) {
696
+ for (const hook of getFunctionList((_x = (_w = resource.hooks) === null || _w === void 0 ? void 0 : _w.create) === null || _x === void 0 ? void 0 : _x.beforeSave)) {
697
697
  const resp = yield hook({ resource, record, adminUser });
698
698
  if (!resp || (!resp.ok && !resp.error)) {
699
699
  throw new Error(`Hook beforeSave must return object with {ok: true} or { error: 'Error' } `);
@@ -710,7 +710,7 @@ class AdminForth {
710
710
  });
711
711
  }
712
712
  }
713
- if (((_w = column.required) === null || _w === void 0 ? void 0 : _w.create) && body['record'][column.name] === undefined) {
713
+ if (((_y = column.required) === null || _y === void 0 ? void 0 : _y.create) && body['record'][column.name] === undefined) {
714
714
  return { error: `Column '${column.name}' is required` };
715
715
  }
716
716
  if (column.isUnique) {
@@ -735,7 +735,7 @@ class AdminForth {
735
735
  const connector = this.connectors[resource.dataSource];
736
736
  yield connector.createRecord({ resource, record });
737
737
  // execute hook if needed
738
- for (const hook of getFunctionList((_y = (_x = resource.hooks) === null || _x === void 0 ? void 0 : _x.create) === null || _y === void 0 ? void 0 : _y.afterSave)) {
738
+ for (const hook of getFunctionList((_0 = (_z = resource.hooks) === null || _z === void 0 ? void 0 : _z.create) === null || _0 === void 0 ? void 0 : _0.afterSave)) {
739
739
  const resp = yield hook({ resource, record, adminUser });
740
740
  if (!resp || (!resp.ok && !resp.error)) {
741
741
  throw new Error(`Hook afterSave must return object with {ok: true} or { error: 'Error' } `);
@@ -752,8 +752,8 @@ class AdminForth {
752
752
  server.endpoint({
753
753
  method: 'POST',
754
754
  path: '/update_record',
755
- handler: (_z) => __awaiter(this, [_z], void 0, function* ({ body, adminUser }) {
756
- var _0, _1, _2, _3;
755
+ handler: (_1) => __awaiter(this, [_1], void 0, function* ({ body, adminUser }) {
756
+ var _2, _3, _4, _5;
757
757
  const resource = this.config.resources.find((res) => res.resourceId == body['resourceId']);
758
758
  if (!resource) {
759
759
  return { error: `Resource '${body['resourceId']}' not found` };
@@ -767,7 +767,7 @@ class AdminForth {
767
767
  }
768
768
  const record = body['record'];
769
769
  // execute hook if needed
770
- for (const hook of getFunctionList((_1 = (_0 = resource.hooks) === null || _0 === void 0 ? void 0 : _0.edit) === null || _1 === void 0 ? void 0 : _1.beforeSave)) {
770
+ for (const hook of getFunctionList((_3 = (_2 = resource.hooks) === null || _2 === void 0 ? void 0 : _2.edit) === null || _3 === void 0 ? void 0 : _3.beforeSave)) {
771
771
  const resp = yield hook({ resource, record, adminUser });
772
772
  if (!resp || (!resp.ok && !resp.error)) {
773
773
  throw new Error(`Hook beforeSave must return object with {ok: true} or { error: 'Error' } `);
@@ -793,7 +793,7 @@ class AdminForth {
793
793
  yield connector.updateRecord({ resource, recordId, record, newValues });
794
794
  }
795
795
  // execute hook if needed
796
- for (const hook of getFunctionList((_3 = (_2 = resource.hooks) === null || _2 === void 0 ? void 0 : _2.edit) === null || _3 === void 0 ? void 0 : _3.afterSave)) {
796
+ for (const hook of getFunctionList((_5 = (_4 = resource.hooks) === null || _4 === void 0 ? void 0 : _4.edit) === null || _5 === void 0 ? void 0 : _5.afterSave)) {
797
797
  const resp = yield hook({ resource, record, adminUser });
798
798
  if (!resp || (!resp.ok && !resp.error)) {
799
799
  throw new Error(`Hook afterSave must return object with {ok: true} or { error: 'Error' } `);
@@ -810,15 +810,15 @@ class AdminForth {
810
810
  server.endpoint({
811
811
  method: 'POST',
812
812
  path: '/delete_record',
813
- handler: (_4) => __awaiter(this, [_4], void 0, function* ({ body, adminUser }) {
814
- var _5, _6, _7, _8;
813
+ handler: (_6) => __awaiter(this, [_6], void 0, function* ({ body, adminUser }) {
814
+ var _7, _8, _9, _10;
815
815
  const resource = this.config.resources.find((res) => res.resourceId == body['resourceId']);
816
816
  const record = yield this.connectors[resource.dataSource].getRecordByPrimaryKey(resource, body['primaryKey']);
817
817
  if (!resource) {
818
818
  return { error: `Resource '${body['resourceId']}' not found` };
819
819
  }
820
820
  // execute hook if needed
821
- for (const hook of getFunctionList((_6 = (_5 = resource.hooks) === null || _5 === void 0 ? void 0 : _5.delete) === null || _6 === void 0 ? void 0 : _6.beforeSave)) {
821
+ for (const hook of getFunctionList((_8 = (_7 = resource.hooks) === null || _7 === void 0 ? void 0 : _7.delete) === null || _8 === void 0 ? void 0 : _8.beforeSave)) {
822
822
  const resp = yield hook({ resource, record, adminUser });
823
823
  if (!resp || (!resp.ok && !resp.error)) {
824
824
  throw new Error(`Hook beforeSave must return object with {ok: true} or { error: 'Error' } `);
@@ -830,7 +830,7 @@ class AdminForth {
830
830
  const connector = this.connectors[resource.dataSource];
831
831
  yield connector.deleteRecord({ resource, recordId: body['primaryKey'] });
832
832
  // execute hook if needed
833
- for (const hook of getFunctionList((_8 = (_7 = resource.hooks) === null || _7 === void 0 ? void 0 : _7.delete) === null || _8 === void 0 ? void 0 : _8.afterSave)) {
833
+ for (const hook of getFunctionList((_10 = (_9 = resource.hooks) === null || _9 === void 0 ? void 0 : _9.delete) === null || _10 === void 0 ? void 0 : _10.afterSave)) {
834
834
  const resp = yield hook({ resource, record, adminUser });
835
835
  if (!resp || (!resp.ok && !resp.error)) {
836
836
  throw new Error(`Hook afterSave must return object with {ok: true} or { error: 'Error' } `);
@@ -847,7 +847,7 @@ class AdminForth {
847
847
  server.endpoint({
848
848
  method: 'POST',
849
849
  path: '/start_bulk_action',
850
- handler: (_9) => __awaiter(this, [_9], void 0, function* ({ body }) {
850
+ handler: (_11) => __awaiter(this, [_11], void 0, function* ({ body }) {
851
851
  const { resourceId, actionId, recordIds } = body;
852
852
  const resource = this.config.resources.find((res) => res.resourceId == resourceId);
853
853
  if (!resource) {
@@ -448,10 +448,7 @@ fetchStatus.value.pending = false;
448
448
  allowedActions.value = data.options?.allowedActions;
449
449
 
450
450
 
451
- // setTimeout(() => {
452
- // initFlowbite();
453
- // console.log('initFlowbite');
454
- // });
451
+
455
452
  }
456
453
 
457
454
 
@@ -528,7 +525,7 @@ async function init() {
528
525
  }
529
526
 
530
527
  onMounted(async () => {
531
-
528
+ initFlowbite();
532
529
 
533
530
  await init();
534
531
 
package/index.ts CHANGED
@@ -698,7 +698,7 @@ class AdminForth {
698
698
  const targetResourceId = columnConfig.foreignResource.resourceId;
699
699
  const targetResource = this.config.resources.find((res) => res.resourceId == targetResourceId);
700
700
 
701
- for (const hook of getFunctionList(columnConfig.foreignResource.hooks?.beforeDatasourceRequest)) {
701
+ for (const hook of getFunctionList(columnConfig.foreignResource.hooks?.dropdownList?.beforeDatasourceRequest)) {
702
702
  const resp = await hook({ query: body, adminUser });
703
703
  if (!resp || (!resp.ok && !resp.error)) {
704
704
  throw new Error(`Hook must return object with {ok: true} or { error: 'Error' } `);
@@ -729,7 +729,7 @@ class AdminForth {
729
729
  items
730
730
  };
731
731
 
732
- for (const hook of getFunctionList(columnConfig.foreignResource.hooks?.afterDatasourceResponse)) {
732
+ for (const hook of getFunctionList(columnConfig.foreignResource.hooks?.dropdownList?.afterDatasourceResponse)) {
733
733
  const resp = await hook({ response, adminUser });
734
734
  if (!resp || (!resp.ok && !resp.error)) {
735
735
  throw new Error(`Hook must return object with {ok: true} or { error: 'Error' } `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.0.63",
3
+ "version": "1.0.64",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -448,10 +448,7 @@ fetchStatus.value.pending = false;
448
448
  allowedActions.value = data.options?.allowedActions;
449
449
 
450
450
 
451
- // setTimeout(() => {
452
- // initFlowbite();
453
- // console.log('initFlowbite');
454
- // });
451
+
455
452
  }
456
453
 
457
454
 
@@ -528,7 +525,7 @@ async function init() {
528
525
  }
529
526
 
530
527
  onMounted(async () => {
531
-
528
+ initFlowbite();
532
529
 
533
530
  await init();
534
531
 
@@ -162,7 +162,9 @@ export type AdminForthResourceColumnEnumElement = {
162
162
  export type AdminForthResourceColumnForeignResource = {
163
163
  resourceId: string,
164
164
  hooks?: {
165
+ dropdownList?: {
165
166
  beforeDatasourceRequest?: Function,
166
167
  afterDatasourceResponse?: Function,
168
+ },
167
169
  },
168
170
  }