@headless-adminapp/app 0.0.17-alpha.54 → 0.0.17-alpha.55

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.
Files changed (220) hide show
  1. package/app/AppProvider.js +24 -32
  2. package/app/AuthWrapper.js +13 -9
  3. package/app/LayoutProvider.js +34 -39
  4. package/app/context.js +5 -2
  5. package/app/hooks/index.js +17 -1
  6. package/app/hooks/useAppContext.js +7 -4
  7. package/app/index.js +11 -4
  8. package/auth/AuthProvider.js +27 -36
  9. package/auth/context.d.ts +1 -1
  10. package/auth/context.js +5 -2
  11. package/auth/hooks/index.js +18 -2
  12. package/auth/hooks/useAuthSession.js +7 -4
  13. package/auth/hooks/useIsSkipAuthCheck.js +7 -4
  14. package/auth/hooks/useLogout.js +11 -8
  15. package/auth/index.js +23 -4
  16. package/auth/types.js +2 -1
  17. package/board/BoardColumnDataResolver.js +23 -20
  18. package/board/BoardColumnProvider.js +14 -10
  19. package/board/context.d.ts +2 -2
  20. package/board/context.js +6 -3
  21. package/board/hooks/index.js +15 -6
  22. package/board/hooks/useBoardColumnConfig.js +7 -4
  23. package/board/hooks/useBoardColumnData.d.ts +3 -1
  24. package/board/hooks/useBoardColumnData.js +7 -4
  25. package/board/hooks/useBoardColumnDataState.js +7 -4
  26. package/board/hooks/useBoardConfig.js +7 -4
  27. package/board/hooks/useBoardSchema.js +6 -3
  28. package/board/hooks/useSearchText.js +10 -7
  29. package/board/types.js +2 -1
  30. package/board/utils.js +4 -1
  31. package/builders/CommandBuilder/CommandBuilder.js +13 -10
  32. package/builders/CommandBuilder/DefaultCommandBuilder.js +30 -23
  33. package/builders/CommandBuilder/FormCommandBuilder.js +29 -38
  34. package/builders/CommandBuilder/SubgridCommandBuilder.js +27 -36
  35. package/builders/CommandBuilder/ViewCommandBuilder.js +29 -38
  36. package/builders/CommandBuilder/index.js +5 -1
  37. package/builders/CommandBuilder/utils.js +7 -3
  38. package/builders/SchemaExperienceBuilder.js +55 -31
  39. package/builders/index.js +7 -2
  40. package/builders/utils.js +59 -44
  41. package/command/hooks/index.js +18 -2
  42. package/command/hooks/useBaseCommandHandlerContext.js +29 -25
  43. package/command/hooks/useCommands.js +9 -6
  44. package/command/index.js +18 -2
  45. package/command/types.js +2 -1
  46. package/command/utils/index.js +41 -13
  47. package/components/ScrollView/index.js +11 -4
  48. package/components/ScrollbarWithMoreDataRequest/index.js +14 -11
  49. package/dataform/DataFormProvider/DataResolver.js +81 -89
  50. package/dataform/DataFormProvider/InitialValueResolver.js +22 -20
  51. package/dataform/DataFormProvider/ReadonlyInfoResolver.js +14 -12
  52. package/dataform/DataFormProvider/index.js +26 -32
  53. package/dataform/context.js +5 -2
  54. package/dataform/hooks/index.js +29 -13
  55. package/dataform/hooks/useFormInstance.js +6 -3
  56. package/dataform/hooks/useFormIsDirty.js +6 -3
  57. package/dataform/hooks/useFormIsReadonly.js +7 -4
  58. package/dataform/hooks/useFormNotifications.js +12 -9
  59. package/dataform/hooks/useFormRecord.js +7 -4
  60. package/dataform/hooks/useFormSave.js +40 -46
  61. package/dataform/hooks/useFormSchema.js +7 -4
  62. package/dataform/hooks/useLoadFormGridPage.js +19 -25
  63. package/dataform/hooks/useMainFormCommands.js +37 -30
  64. package/dataform/hooks/useProcessFlowSteps.js +27 -23
  65. package/dataform/hooks/useRecordId.js +7 -4
  66. package/dataform/hooks/useRecordTitle.js +12 -9
  67. package/dataform/hooks/useSelectedForm.js +7 -4
  68. package/dataform/index.js +23 -4
  69. package/dataform/utils/defaultParameters.js +16 -6
  70. package/dataform/utils/index.js +90 -56
  71. package/dataform/utils/saveRecord.js +99 -104
  72. package/datagrid/DataGridProvider/DataResolver.js +36 -34
  73. package/datagrid/DataGridProvider/index.js +31 -32
  74. package/datagrid/DataGridProvider/transformViewColumns.js +17 -6
  75. package/datagrid/DataGridProvider/utils.js +13 -5
  76. package/datagrid/column-filter/constants.js +5 -2
  77. package/datagrid/column-filter/index.js +7 -2
  78. package/datagrid/column-filter/types.js +2 -1
  79. package/datagrid/column-filter/utils.js +13 -3
  80. package/datagrid/context.d.ts +1 -1
  81. package/datagrid/context.js +5 -2
  82. package/datagrid/hooks/index.js +36 -20
  83. package/datagrid/hooks/useChangeView.js +10 -7
  84. package/datagrid/hooks/useGridColumnFilter.js +14 -8
  85. package/datagrid/hooks/useGridColumns.js +7 -4
  86. package/datagrid/hooks/useGridCommands.js +7 -4
  87. package/datagrid/hooks/useGridData.js +7 -4
  88. package/datagrid/hooks/useGridDataState.js +7 -4
  89. package/datagrid/hooks/useGridExtraFilter.js +7 -4
  90. package/datagrid/hooks/useGridOptions.js +4 -1
  91. package/datagrid/hooks/useGridPagination.js +4 -1
  92. package/datagrid/hooks/useGridRefresh.js +10 -7
  93. package/datagrid/hooks/useGridSchema.js +7 -4
  94. package/datagrid/hooks/useGridSelection.js +10 -7
  95. package/datagrid/hooks/useGridSorting.js +10 -7
  96. package/datagrid/hooks/useGridViewLookupData.js +7 -4
  97. package/datagrid/hooks/useLoadMainGridPage.js +12 -9
  98. package/datagrid/hooks/useMainGridCommands.js +62 -54
  99. package/datagrid/hooks/useMaxRecords.js +7 -4
  100. package/datagrid/hooks/useOpenRecord.js +20 -17
  101. package/datagrid/hooks/useSearchText.js +10 -7
  102. package/datagrid/hooks/useSelectedView.js +7 -4
  103. package/datagrid/hooks/useSubGridCommands.js +34 -23
  104. package/datagrid/index.js +27 -5
  105. package/defaults.js +5 -2
  106. package/dialog/DialogProvider.js +10 -6
  107. package/dialog/context.d.ts +1 -1
  108. package/dialog/context.js +5 -2
  109. package/dialog/hooks/index.js +24 -8
  110. package/dialog/hooks/useCloseDialog.js +10 -7
  111. package/dialog/hooks/useDialogItem.d.ts +1 -1
  112. package/dialog/hooks/useDialogItem.js +7 -4
  113. package/dialog/hooks/useDialogItems.d.ts +1 -1
  114. package/dialog/hooks/useDialogItems.js +7 -4
  115. package/dialog/hooks/useOpenAlertDialog.js +16 -8
  116. package/dialog/hooks/useOpenConfirmDialog.js +18 -9
  117. package/dialog/hooks/useOpenDialog.js +18 -11
  118. package/dialog/hooks/useOpenErrorDialog.js +16 -8
  119. package/dialog/hooks/useOpenPromptDialog.js +18 -9
  120. package/dialog/index.js +22 -3
  121. package/form/FormValidationStringContext.js +9 -5
  122. package/form/index.js +7 -1
  123. package/hooks/index.js +24 -6
  124. package/hooks/useDebouncedValue.js +11 -8
  125. package/hooks/useElementLayout.js +7 -4
  126. package/hooks/useIsMobile.js +12 -6
  127. package/hooks/useItemsWithKey.js +8 -5
  128. package/hooks/useStorageState.js +7 -5
  129. package/hooks/useSystemColorScheme.js +7 -4
  130. package/insights/InsightsProvider.js +13 -10
  131. package/insights/context.d.ts +1 -1
  132. package/insights/context.js +5 -2
  133. package/insights/hooks/index.js +7 -4
  134. package/insights/index.js +20 -2
  135. package/locale/LocaleProvider.js +12 -8
  136. package/locale/context.js +5 -2
  137. package/locale/index.js +23 -4
  138. package/locale/useCurrencySymbol.js +10 -8
  139. package/locale/useLocale.js +7 -4
  140. package/locale/utils.js +8 -3
  141. package/metadata/MetadataProvider.js +21 -17
  142. package/metadata/context.d.ts +1 -1
  143. package/metadata/context.js +5 -2
  144. package/metadata/hooks/index.js +24 -8
  145. package/metadata/hooks/useAppStore.js +7 -4
  146. package/metadata/hooks/useExperienceStore.js +7 -4
  147. package/metadata/hooks/useExperienceView.js +11 -17
  148. package/metadata/hooks/useExperienceViewCommands.js +14 -20
  149. package/metadata/hooks/useExperienceViewLookup.js +10 -16
  150. package/metadata/hooks/useExperienceViewSubgridCommands.js +14 -20
  151. package/metadata/hooks/useMetadata.js +11 -8
  152. package/metadata/hooks/useSchema.js +6 -3
  153. package/metadata/index.js +22 -3
  154. package/mutable/context.js +25 -17
  155. package/mutable/index.js +27 -3
  156. package/mutable/state.js +10 -6
  157. package/mutable/type.js +2 -1
  158. package/mutable/utils.js +12 -8
  159. package/navigation/hooks/index.js +17 -1
  160. package/navigation/hooks/useOpenForm.js +14 -11
  161. package/navigation/index.js +17 -1
  162. package/package.json +4 -12
  163. package/progress-indicator/ProgressIndicatorProvider.js +16 -12
  164. package/progress-indicator/context.js +5 -2
  165. package/progress-indicator/hooks/index.js +17 -1
  166. package/progress-indicator/hooks/useProgressIndicator.d.ts +1 -1
  167. package/progress-indicator/hooks/useProgressIndicator.js +7 -4
  168. package/progress-indicator/index.js +22 -3
  169. package/providers/PageEntityFormProvider/index.js +7 -4
  170. package/providers/PageEntityViewProvider/index.js +7 -4
  171. package/recordset/RecordSetProvider.js +16 -12
  172. package/recordset/context.d.ts +1 -1
  173. package/recordset/context.js +5 -2
  174. package/recordset/hooks/index.js +19 -3
  175. package/recordset/hooks/useRecordSetResult.js +22 -29
  176. package/recordset/hooks/useRecordSetSetter.js +9 -6
  177. package/recordset/hooks/useRecordSetVisibility.js +10 -7
  178. package/recordset/index.js +22 -3
  179. package/route/RouteProvider.js +18 -14
  180. package/route/context.js +9 -6
  181. package/route/hooks/index.js +22 -6
  182. package/route/hooks/useBasePath.js +7 -4
  183. package/route/hooks/useIsRouteActive.js +7 -4
  184. package/route/hooks/usePathname.js +7 -4
  185. package/route/hooks/useRouteResolver.js +7 -4
  186. package/route/hooks/useRouter.js +7 -4
  187. package/route/hooks/useSearchParams.js +7 -4
  188. package/route/index.js +20 -2
  189. package/route/types.js +2 -1
  190. package/store/ClientAppStore.js +12 -21
  191. package/store/ComponentStore.js +6 -4
  192. package/store/EventManager.js +20 -32
  193. package/store/SchemaExperienceStore.js +186 -217
  194. package/store/index.js +20 -4
  195. package/toast-notification/ToastNotificationProvider.js +10 -6
  196. package/toast-notification/context.d.ts +1 -1
  197. package/toast-notification/context.js +5 -2
  198. package/toast-notification/hooks/index.js +19 -3
  199. package/toast-notification/hooks/useCloseToastNotification.js +10 -7
  200. package/toast-notification/hooks/useOpenToastNotification.js +18 -11
  201. package/toast-notification/hooks/useToastNotificationItems.d.ts +1 -1
  202. package/toast-notification/hooks/useToastNotificationItems.js +7 -4
  203. package/toast-notification/index.js +22 -3
  204. package/transport/InMemoryDataService/index.js +59 -78
  205. package/transport/RestDataService/index.d.ts +2 -2
  206. package/transport/RestDataService/index.js +72 -91
  207. package/transport/context.js +9 -15
  208. package/transport/hooks/index.js +18 -2
  209. package/transport/hooks/useDataService.js +7 -4
  210. package/transport/hooks/useFileService.js +7 -4
  211. package/transport/hooks/useRetriveRecords.d.ts +1 -1
  212. package/transport/hooks/useRetriveRecords.js +25 -31
  213. package/transport/index.js +20 -2
  214. package/utils/calculateColumnWidths.js +5 -2
  215. package/utils/color.js +4 -1
  216. package/utils/getAttributeFormattedValue.js +38 -40
  217. package/utils/index.js +18 -2
  218. package/widget/context.js +5 -2
  219. package/widget/hooks/index.js +7 -4
  220. package/widget/index.js +5 -1
@@ -1,10 +1,13 @@
1
- import { useCallback } from 'react';
2
- import { useContextSetValue } from '../../mutable/context';
3
- import { ToastNotificationContext } from '../context';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCloseToastNotification = useCloseToastNotification;
4
+ const react_1 = require("react");
5
+ const context_1 = require("../../mutable/context");
6
+ const context_2 = require("../context");
4
7
  function markToastNotificationAsClosed(items, id) {
5
8
  return items.map((item) => {
6
9
  if (item.id === id) {
7
- return Object.assign(Object.assign({}, item), { isOpen: false });
10
+ return { ...item, isOpen: false };
8
11
  }
9
12
  return item;
10
13
  });
@@ -12,9 +15,9 @@ function markToastNotificationAsClosed(items, id) {
12
15
  function excludeToastNotificationItemById(items, id) {
13
16
  return items.filter((item) => item.id !== id);
14
17
  }
15
- export function useCloseToastNotification() {
16
- const setValue = useContextSetValue(ToastNotificationContext);
17
- const closeDialog = useCallback((id) => {
18
+ function useCloseToastNotification() {
19
+ const setValue = (0, context_1.useContextSetValue)(context_2.ToastNotificationContext);
20
+ const closeDialog = (0, react_1.useCallback)((id) => {
18
21
  setValue((state) => ({
19
22
  items: markToastNotificationAsClosed(state.items, id),
20
23
  }));
@@ -1,18 +1,25 @@
1
- import { useCallback } from 'react';
2
- import { v4 as uuid } from 'uuid';
3
- import { useContextSetValue } from '../../mutable/context';
4
- import { ToastNotificationContext } from '../context';
5
- import { useCloseToastNotification } from './useCloseToastNotification';
6
- export function useOpenToastNotification() {
7
- const setValue = useContextSetValue(ToastNotificationContext);
8
- const closeDialog = useCloseToastNotification();
9
- const openToastNotification = useCallback((options) => {
10
- const id = uuid();
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useOpenToastNotification = useOpenToastNotification;
4
+ const react_1 = require("react");
5
+ const uuid_1 = require("uuid");
6
+ const context_1 = require("../../mutable/context");
7
+ const context_2 = require("../context");
8
+ const useCloseToastNotification_1 = require("./useCloseToastNotification");
9
+ function useOpenToastNotification() {
10
+ const setValue = (0, context_1.useContextSetValue)(context_2.ToastNotificationContext);
11
+ const closeDialog = (0, useCloseToastNotification_1.useCloseToastNotification)();
12
+ const openToastNotification = (0, react_1.useCallback)((options) => {
13
+ const id = (0, uuid_1.v4)();
11
14
  setValue((state) => {
12
15
  return {
13
16
  items: [
14
17
  ...state.items,
15
- Object.assign({ id, isOpen: true }, options),
18
+ {
19
+ id,
20
+ isOpen: true,
21
+ ...options,
22
+ },
16
23
  ],
17
24
  };
18
25
  });
@@ -1 +1 @@
1
- export declare function useToastNotificationItems(): import("..").ToastNotificationItem[];
1
+ export declare function useToastNotificationItems(): import("../context").ToastNotificationItem[];
@@ -1,5 +1,8 @@
1
- import { useContextSelector } from '../../mutable/context';
2
- import { ToastNotificationContext } from '../context';
3
- export function useToastNotificationItems() {
4
- return useContextSelector(ToastNotificationContext, (state) => state.items);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useToastNotificationItems = useToastNotificationItems;
4
+ const context_1 = require("../../mutable/context");
5
+ const context_2 = require("../context");
6
+ function useToastNotificationItems() {
7
+ return (0, context_1.useContextSelector)(context_2.ToastNotificationContext, (state) => state.items);
5
8
  }
@@ -1,3 +1,22 @@
1
- export { ToastNotificationContext, } from './context';
2
- export { ToastNotificationProvider } from './ToastNotificationProvider';
3
- export * from './hooks';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ToastNotificationProvider = exports.ToastNotificationContext = void 0;
18
+ var context_1 = require("./context");
19
+ Object.defineProperty(exports, "ToastNotificationContext", { enumerable: true, get: function () { return context_1.ToastNotificationContext; } });
20
+ var ToastNotificationProvider_1 = require("./ToastNotificationProvider");
21
+ Object.defineProperty(exports, "ToastNotificationProvider", { enumerable: true, get: function () { return ToastNotificationProvider_1.ToastNotificationProvider; } });
22
+ __exportStar(require("./hooks"), exports);
@@ -1,13 +1,8 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- export class InMemoryDataService {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InMemoryDataService = void 0;
4
+ class InMemoryDataService {
5
+ options;
11
6
  // , IActionService, IReportService
12
7
  constructor(options) {
13
8
  this.options = options;
@@ -25,84 +20,70 @@ export class InMemoryDataService {
25
20
  }
26
21
  return this.options.data[logicalName];
27
22
  }
28
- retriveRecord(logicalName, id) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- const schema = this.getSchema(logicalName);
31
- const records = this.getCollection(logicalName);
32
- const record = records.find((record) => {
33
- return record[schema.idAttribute] === id;
34
- });
35
- if (!record) {
36
- throw new Error(`Record with id ${id} not found`);
37
- }
38
- return record;
23
+ async retriveRecord(logicalName, id) {
24
+ const schema = this.getSchema(logicalName);
25
+ const records = this.getCollection(logicalName);
26
+ const record = records.find((record) => {
27
+ return record[schema.idAttribute] === id;
39
28
  });
29
+ if (!record) {
30
+ throw new Error(`Record with id ${id} not found`);
31
+ }
32
+ return record;
40
33
  }
41
- retriveRecords(_a) {
42
- return __awaiter(this, arguments, void 0, function* ({ logicalName, }) {
43
- const records = this.getCollection(logicalName);
44
- return {
45
- logicalName,
46
- records: records,
47
- count: records.length,
48
- };
49
- });
34
+ async retriveRecords({ logicalName, }) {
35
+ const records = this.getCollection(logicalName);
36
+ return {
37
+ logicalName,
38
+ records: records,
39
+ count: records.length,
40
+ };
50
41
  }
51
- createRecord(logicalName, data) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- const schema = this.getSchema(logicalName);
54
- const records = this.getCollection(logicalName);
55
- const newId = this.options.idGenerator(logicalName, records);
56
- const newRecord = Object.assign(Object.assign({}, data), { [schema.idAttribute]: newId });
57
- records.push(newRecord);
58
- return { id: newId };
59
- });
42
+ async createRecord(logicalName, data) {
43
+ const schema = this.getSchema(logicalName);
44
+ const records = this.getCollection(logicalName);
45
+ const newId = this.options.idGenerator(logicalName, records);
46
+ const newRecord = {
47
+ ...data,
48
+ [schema.idAttribute]: newId,
49
+ };
50
+ records.push(newRecord);
51
+ return { id: newId };
60
52
  }
61
- updateRecord(logicalName, id, data) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- const schema = this.getSchema(logicalName);
64
- const records = this.getCollection(logicalName);
65
- const record = records.find((record) => {
66
- return record[schema.idAttribute] === id;
67
- });
68
- if (!record) {
69
- throw new Error(`Record with id ${id} not found`);
70
- }
71
- Object.assign(record, data);
72
- return { id };
53
+ async updateRecord(logicalName, id, data) {
54
+ const schema = this.getSchema(logicalName);
55
+ const records = this.getCollection(logicalName);
56
+ const record = records.find((record) => {
57
+ return record[schema.idAttribute] === id;
73
58
  });
59
+ if (!record) {
60
+ throw new Error(`Record with id ${id} not found`);
61
+ }
62
+ Object.assign(record, data);
63
+ return { id };
74
64
  }
75
- deleteRecord(logicalName, id) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const schema = this.getSchema(logicalName);
78
- const records = this.getCollection(logicalName);
79
- const index = records.findIndex((record) => {
80
- return record[schema.idAttribute] === id;
81
- });
82
- if (index === -1) {
83
- throw new Error(`Record with id ${id} not found`);
84
- }
85
- records.splice(index, 1);
65
+ async deleteRecord(logicalName, id) {
66
+ const schema = this.getSchema(logicalName);
67
+ const records = this.getCollection(logicalName);
68
+ const index = records.findIndex((record) => {
69
+ return record[schema.idAttribute] === id;
86
70
  });
71
+ if (index === -1) {
72
+ throw new Error(`Record with id ${id} not found`);
73
+ }
74
+ records.splice(index, 1);
87
75
  }
88
- executeAction() {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- return {};
91
- });
76
+ async executeAction() {
77
+ return {};
92
78
  }
93
- getReportData() {
94
- return __awaiter(this, void 0, void 0, function* () {
95
- return {};
96
- });
79
+ async getReportData() {
80
+ return {};
97
81
  }
98
- retriveAggregate() {
99
- return __awaiter(this, void 0, void 0, function* () {
100
- return [];
101
- });
82
+ async retriveAggregate() {
83
+ return [];
102
84
  }
103
- customAction() {
104
- return __awaiter(this, void 0, void 0, function* () {
105
- return {};
106
- });
85
+ async customAction() {
86
+ return {};
107
87
  }
108
88
  }
89
+ exports.InMemoryDataService = InMemoryDataService;
@@ -16,8 +16,8 @@ export declare class RestDataService implements IDataService {
16
16
  [key in keyof T]?: string[];
17
17
  }): Promise<Data<T>>;
18
18
  retriveRecords<T = unknown>(params: RetriveRecordsFnOptions<T>): Promise<RetriveRecordsResult<T>>;
19
- createRecord<T>(logicalName: string, data: Partial<T>): Promise<CreateRecordResult<import("@headless-adminapp/core/attributes").Id>>;
20
- updateRecord<T>(logicalName: string, id: string, data: Partial<T>): Promise<CreateRecordResult<import("@headless-adminapp/core/attributes").Id>>;
19
+ createRecord<T>(logicalName: string, data: Partial<T>): Promise<CreateRecordResult<import("@headless-adminapp/core").Id>>;
20
+ updateRecord<T>(logicalName: string, id: string, data: Partial<T>): Promise<CreateRecordResult<import("@headless-adminapp/core").Id>>;
21
21
  deleteRecord(logicalName: string, id: string): Promise<void>;
22
22
  retriveAggregate<Q extends Record<string, AggregateAttribute> = Record<string, AggregateAttribute>>(query: AggregateQuery<Q>): Promise<InferredAggregateQueryResult<Q>[]>;
23
23
  customAction<T = unknown>(_actionName: string, _payload: unknown): Promise<T>;
@@ -1,35 +1,31 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { HttpError, } from '@headless-adminapp/core/transport';
11
- export function handleResponseError(response) {
12
- return __awaiter(this, void 0, void 0, function* () {
13
- var _a;
14
- if (response.ok) {
15
- return;
16
- }
17
- if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
18
- const data = yield response.json();
19
- if (data.error) {
20
- throw new HttpError(response.status, data.error);
21
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RestDataService = void 0;
4
+ exports.handleResponseError = handleResponseError;
5
+ const transport_1 = require("@headless-adminapp/core/transport");
6
+ async function handleResponseError(response) {
7
+ if (response.ok) {
8
+ return;
9
+ }
10
+ if (response.headers.get('content-type')?.includes('application/json')) {
11
+ const data = await response.json();
12
+ if (data.error) {
13
+ throw new transport_1.HttpError(response.status, data.error);
22
14
  }
23
- throw new HttpError(response.status, response.statusText);
24
- });
15
+ }
16
+ throw new transport_1.HttpError(response.status, response.statusText);
25
17
  }
26
- export class RestDataService {
18
+ class RestDataService {
19
+ options;
27
20
  constructor(options) {
28
21
  this.options = options;
29
- this.headers = {};
30
22
  }
23
+ headers = {};
31
24
  getHeaders() {
32
- return Object.assign({ 'content-type': 'application/json' }, this.headers);
25
+ return {
26
+ 'content-type': 'application/json',
27
+ ...this.headers,
28
+ };
33
29
  }
34
30
  setHeader(name, value) {
35
31
  this.headers[name] = value;
@@ -37,84 +33,69 @@ export class RestDataService {
37
33
  removeHeader(name) {
38
34
  delete this.headers[name];
39
35
  }
40
- execute(data) {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- const response = yield fetch(this.options.endpoint, {
43
- headers: this.getHeaders(),
44
- method: 'POST',
45
- body: JSON.stringify(data),
46
- });
47
- yield handleResponseError(response);
48
- return response.json();
36
+ async execute(data) {
37
+ const response = await fetch(this.options.endpoint, {
38
+ headers: this.getHeaders(),
39
+ method: 'POST',
40
+ body: JSON.stringify(data),
49
41
  });
42
+ await handleResponseError(response);
43
+ return response.json();
50
44
  }
51
- retriveRecord(logicalName, id, columns, expand) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- return this.execute({
54
- type: 'retriveRecord',
55
- payload: {
56
- logicalName,
57
- id,
58
- columns,
59
- expand,
60
- },
61
- });
45
+ async retriveRecord(logicalName, id, columns, expand) {
46
+ return this.execute({
47
+ type: 'retriveRecord',
48
+ payload: {
49
+ logicalName,
50
+ id,
51
+ columns,
52
+ expand,
53
+ },
62
54
  });
63
55
  }
64
- retriveRecords(params) {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- return this.execute({
67
- type: 'retriveRecords',
68
- payload: params,
69
- });
56
+ async retriveRecords(params) {
57
+ return this.execute({
58
+ type: 'retriveRecords',
59
+ payload: params,
70
60
  });
71
61
  }
72
- createRecord(logicalName, data) {
73
- return __awaiter(this, void 0, void 0, function* () {
74
- return this.execute({
75
- type: 'createRecord',
76
- payload: {
77
- logicalName,
78
- data,
79
- },
80
- });
62
+ async createRecord(logicalName, data) {
63
+ return this.execute({
64
+ type: 'createRecord',
65
+ payload: {
66
+ logicalName,
67
+ data,
68
+ },
81
69
  });
82
70
  }
83
- updateRecord(logicalName, id, data) {
84
- return __awaiter(this, void 0, void 0, function* () {
85
- return this.execute({
86
- type: 'updateRecord',
87
- payload: {
88
- logicalName,
89
- id,
90
- data,
91
- },
92
- });
71
+ async updateRecord(logicalName, id, data) {
72
+ return this.execute({
73
+ type: 'updateRecord',
74
+ payload: {
75
+ logicalName,
76
+ id,
77
+ data,
78
+ },
93
79
  });
94
80
  }
95
- deleteRecord(logicalName, id) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- return this.execute({
98
- type: 'deleteRecord',
99
- payload: {
100
- logicalName,
101
- id,
102
- },
103
- });
81
+ async deleteRecord(logicalName, id) {
82
+ return this.execute({
83
+ type: 'deleteRecord',
84
+ payload: {
85
+ logicalName,
86
+ id,
87
+ },
104
88
  });
105
89
  }
106
- retriveAggregate(query) {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- const result = yield this.execute({
109
- type: 'retriveAggregate',
110
- payload: query,
111
- });
112
- return result;
90
+ async retriveAggregate(query) {
91
+ const result = await this.execute({
92
+ type: 'retriveAggregate',
93
+ payload: query,
113
94
  });
95
+ return result;
114
96
  }
115
- customAction(_actionName, _payload) {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- throw new Error('Custom action not implemented in RestDataService, to use custom actions, define a custom data service extending RestDataService');
118
- });
97
+ async customAction(_actionName, _payload) {
98
+ throw new Error('Custom action not implemented in RestDataService, to use custom actions, define a custom data service extending RestDataService');
119
99
  }
120
100
  }
101
+ exports.RestDataService = RestDataService;
@@ -1,17 +1,11 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { createContext } from 'react';
11
- export const DataServiceContext = createContext(undefined);
12
- export const noopFileService = {
13
- uploadFile: () => __awaiter(void 0, void 0, void 0, function* () {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileServiceContext = exports.noopFileService = exports.DataServiceContext = void 0;
4
+ const react_1 = require("react");
5
+ exports.DataServiceContext = (0, react_1.createContext)(undefined);
6
+ exports.noopFileService = {
7
+ uploadFile: async () => {
14
8
  throw new Error('File service not implemented');
15
- }),
9
+ },
16
10
  };
17
- export const FileServiceContext = createContext(noopFileService);
11
+ exports.FileServiceContext = (0, react_1.createContext)(exports.noopFileService);
@@ -1,2 +1,18 @@
1
- export * from './useDataService';
2
- export * from './useFileService';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./useDataService"), exports);
18
+ __exportStar(require("./useFileService"), exports);
@@ -1,7 +1,10 @@
1
- import { useContext } from 'react';
2
- import { DataServiceContext } from '../context';
3
- export function useDataService() {
4
- const context = useContext(DataServiceContext);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useDataService = useDataService;
4
+ const react_1 = require("react");
5
+ const context_1 = require("../context");
6
+ function useDataService() {
7
+ const context = (0, react_1.useContext)(context_1.DataServiceContext);
5
8
  if (!context) {
6
9
  throw new Error('DataServiceContext must be used within a DataServiceProvider');
7
10
  }
@@ -1,7 +1,10 @@
1
- import { useContext } from 'react';
2
- import { FileServiceContext } from '../context';
3
- export function useFileService() {
4
- const context = useContext(FileServiceContext);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFileService = useFileService;
4
+ const react_1 = require("react");
5
+ const context_1 = require("../context");
6
+ function useFileService() {
7
+ const context = (0, react_1.useContext)(context_1.FileServiceContext);
5
8
  if (!context) {
6
9
  throw new Error('FileServiceContext must be used within a FileServiceProvider');
7
10
  }
@@ -11,7 +11,7 @@ interface UseRetriveRecordProps<S extends SchemaAttributes = SchemaAttributes> {
11
11
  expand?: Partial<Record<string, string[]>>;
12
12
  maxRecords: number;
13
13
  }
14
- export declare function useRetrieveRecordsKey<S extends SchemaAttributes = SchemaAttributes>({ schema, search, filter, sorting, columns, expand, maxRecords, }: UseRetriveRecordProps<S>): (string | number | string[] | Filter | SortingState<S> | Partial<Record<string, string[]>> | null | undefined)[];
14
+ export declare function useRetrieveRecordsKey<S extends SchemaAttributes = SchemaAttributes>({ schema, search, filter, sorting, columns, expand, maxRecords, }: UseRetriveRecordProps<S>): (string | number | string[] | Filter | Partial<Record<string, string[]>> | SortingState<S> | null | undefined)[];
15
15
  export declare function useClearDataExceptFirstPage(queryKey: QueryKey): void;
16
16
  export declare function useRetriveRecords<S extends SchemaAttributes = SchemaAttributes>(queryKey: QueryKey, { columns, expand, filter, maxRecords, schema, search, sorting, }: UseRetriveRecordProps): {
17
17
  data: {