@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.
- package/app/AppProvider.js +24 -32
- package/app/AuthWrapper.js +13 -9
- package/app/LayoutProvider.js +34 -39
- package/app/context.js +5 -2
- package/app/hooks/index.js +17 -1
- package/app/hooks/useAppContext.js +7 -4
- package/app/index.js +11 -4
- package/auth/AuthProvider.js +27 -36
- package/auth/context.d.ts +1 -1
- package/auth/context.js +5 -2
- package/auth/hooks/index.js +18 -2
- package/auth/hooks/useAuthSession.js +7 -4
- package/auth/hooks/useIsSkipAuthCheck.js +7 -4
- package/auth/hooks/useLogout.js +11 -8
- package/auth/index.js +23 -4
- package/auth/types.js +2 -1
- package/board/BoardColumnDataResolver.js +23 -20
- package/board/BoardColumnProvider.js +14 -10
- package/board/context.d.ts +2 -2
- package/board/context.js +6 -3
- package/board/hooks/index.js +15 -6
- package/board/hooks/useBoardColumnConfig.js +7 -4
- package/board/hooks/useBoardColumnData.d.ts +3 -1
- package/board/hooks/useBoardColumnData.js +7 -4
- package/board/hooks/useBoardColumnDataState.js +7 -4
- package/board/hooks/useBoardConfig.js +7 -4
- package/board/hooks/useBoardSchema.js +6 -3
- package/board/hooks/useSearchText.js +10 -7
- package/board/types.js +2 -1
- package/board/utils.js +4 -1
- package/builders/CommandBuilder/CommandBuilder.js +13 -10
- package/builders/CommandBuilder/DefaultCommandBuilder.js +30 -23
- package/builders/CommandBuilder/FormCommandBuilder.js +29 -38
- package/builders/CommandBuilder/SubgridCommandBuilder.js +27 -36
- package/builders/CommandBuilder/ViewCommandBuilder.js +29 -38
- package/builders/CommandBuilder/index.js +5 -1
- package/builders/CommandBuilder/utils.js +7 -3
- package/builders/SchemaExperienceBuilder.js +55 -31
- package/builders/index.js +7 -2
- package/builders/utils.js +59 -44
- package/command/hooks/index.js +18 -2
- package/command/hooks/useBaseCommandHandlerContext.js +29 -25
- package/command/hooks/useCommands.js +9 -6
- package/command/index.js +18 -2
- package/command/types.js +2 -1
- package/command/utils/index.js +41 -13
- package/components/ScrollView/index.js +11 -4
- package/components/ScrollbarWithMoreDataRequest/index.js +14 -11
- package/dataform/DataFormProvider/DataResolver.js +81 -89
- package/dataform/DataFormProvider/InitialValueResolver.js +22 -20
- package/dataform/DataFormProvider/ReadonlyInfoResolver.js +14 -12
- package/dataform/DataFormProvider/index.js +26 -32
- package/dataform/context.js +5 -2
- package/dataform/hooks/index.js +29 -13
- package/dataform/hooks/useFormInstance.js +6 -3
- package/dataform/hooks/useFormIsDirty.js +6 -3
- package/dataform/hooks/useFormIsReadonly.js +7 -4
- package/dataform/hooks/useFormNotifications.js +12 -9
- package/dataform/hooks/useFormRecord.js +7 -4
- package/dataform/hooks/useFormSave.js +40 -46
- package/dataform/hooks/useFormSchema.js +7 -4
- package/dataform/hooks/useLoadFormGridPage.js +19 -25
- package/dataform/hooks/useMainFormCommands.js +37 -30
- package/dataform/hooks/useProcessFlowSteps.js +27 -23
- package/dataform/hooks/useRecordId.js +7 -4
- package/dataform/hooks/useRecordTitle.js +12 -9
- package/dataform/hooks/useSelectedForm.js +7 -4
- package/dataform/index.js +23 -4
- package/dataform/utils/defaultParameters.js +16 -6
- package/dataform/utils/index.js +90 -56
- package/dataform/utils/saveRecord.js +99 -104
- package/datagrid/DataGridProvider/DataResolver.js +36 -34
- package/datagrid/DataGridProvider/index.js +31 -32
- package/datagrid/DataGridProvider/transformViewColumns.js +17 -6
- package/datagrid/DataGridProvider/utils.js +13 -5
- package/datagrid/column-filter/constants.js +5 -2
- package/datagrid/column-filter/index.js +7 -2
- package/datagrid/column-filter/types.js +2 -1
- package/datagrid/column-filter/utils.js +13 -3
- package/datagrid/context.d.ts +1 -1
- package/datagrid/context.js +5 -2
- package/datagrid/hooks/index.js +36 -20
- package/datagrid/hooks/useChangeView.js +10 -7
- package/datagrid/hooks/useGridColumnFilter.js +14 -8
- package/datagrid/hooks/useGridColumns.js +7 -4
- package/datagrid/hooks/useGridCommands.js +7 -4
- package/datagrid/hooks/useGridData.js +7 -4
- package/datagrid/hooks/useGridDataState.js +7 -4
- package/datagrid/hooks/useGridExtraFilter.js +7 -4
- package/datagrid/hooks/useGridOptions.js +4 -1
- package/datagrid/hooks/useGridPagination.js +4 -1
- package/datagrid/hooks/useGridRefresh.js +10 -7
- package/datagrid/hooks/useGridSchema.js +7 -4
- package/datagrid/hooks/useGridSelection.js +10 -7
- package/datagrid/hooks/useGridSorting.js +10 -7
- package/datagrid/hooks/useGridViewLookupData.js +7 -4
- package/datagrid/hooks/useLoadMainGridPage.js +12 -9
- package/datagrid/hooks/useMainGridCommands.js +62 -54
- package/datagrid/hooks/useMaxRecords.js +7 -4
- package/datagrid/hooks/useOpenRecord.js +20 -17
- package/datagrid/hooks/useSearchText.js +10 -7
- package/datagrid/hooks/useSelectedView.js +7 -4
- package/datagrid/hooks/useSubGridCommands.js +34 -23
- package/datagrid/index.js +27 -5
- package/defaults.js +5 -2
- package/dialog/DialogProvider.js +10 -6
- package/dialog/context.d.ts +1 -1
- package/dialog/context.js +5 -2
- package/dialog/hooks/index.js +24 -8
- package/dialog/hooks/useCloseDialog.js +10 -7
- package/dialog/hooks/useDialogItem.d.ts +1 -1
- package/dialog/hooks/useDialogItem.js +7 -4
- package/dialog/hooks/useDialogItems.d.ts +1 -1
- package/dialog/hooks/useDialogItems.js +7 -4
- package/dialog/hooks/useOpenAlertDialog.js +16 -8
- package/dialog/hooks/useOpenConfirmDialog.js +18 -9
- package/dialog/hooks/useOpenDialog.js +18 -11
- package/dialog/hooks/useOpenErrorDialog.js +16 -8
- package/dialog/hooks/useOpenPromptDialog.js +18 -9
- package/dialog/index.js +22 -3
- package/form/FormValidationStringContext.js +9 -5
- package/form/index.js +7 -1
- package/hooks/index.js +24 -6
- package/hooks/useDebouncedValue.js +11 -8
- package/hooks/useElementLayout.js +7 -4
- package/hooks/useIsMobile.js +12 -6
- package/hooks/useItemsWithKey.js +8 -5
- package/hooks/useStorageState.js +7 -5
- package/hooks/useSystemColorScheme.js +7 -4
- package/insights/InsightsProvider.js +13 -10
- package/insights/context.d.ts +1 -1
- package/insights/context.js +5 -2
- package/insights/hooks/index.js +7 -4
- package/insights/index.js +20 -2
- package/locale/LocaleProvider.js +12 -8
- package/locale/context.js +5 -2
- package/locale/index.js +23 -4
- package/locale/useCurrencySymbol.js +10 -8
- package/locale/useLocale.js +7 -4
- package/locale/utils.js +8 -3
- package/metadata/MetadataProvider.js +21 -17
- package/metadata/context.d.ts +1 -1
- package/metadata/context.js +5 -2
- package/metadata/hooks/index.js +24 -8
- package/metadata/hooks/useAppStore.js +7 -4
- package/metadata/hooks/useExperienceStore.js +7 -4
- package/metadata/hooks/useExperienceView.js +11 -17
- package/metadata/hooks/useExperienceViewCommands.js +14 -20
- package/metadata/hooks/useExperienceViewLookup.js +10 -16
- package/metadata/hooks/useExperienceViewSubgridCommands.js +14 -20
- package/metadata/hooks/useMetadata.js +11 -8
- package/metadata/hooks/useSchema.js +6 -3
- package/metadata/index.js +22 -3
- package/mutable/context.js +25 -17
- package/mutable/index.js +27 -3
- package/mutable/state.js +10 -6
- package/mutable/type.js +2 -1
- package/mutable/utils.js +12 -8
- package/navigation/hooks/index.js +17 -1
- package/navigation/hooks/useOpenForm.js +14 -11
- package/navigation/index.js +17 -1
- package/package.json +4 -12
- package/progress-indicator/ProgressIndicatorProvider.js +16 -12
- package/progress-indicator/context.js +5 -2
- package/progress-indicator/hooks/index.js +17 -1
- package/progress-indicator/hooks/useProgressIndicator.d.ts +1 -1
- package/progress-indicator/hooks/useProgressIndicator.js +7 -4
- package/progress-indicator/index.js +22 -3
- package/providers/PageEntityFormProvider/index.js +7 -4
- package/providers/PageEntityViewProvider/index.js +7 -4
- package/recordset/RecordSetProvider.js +16 -12
- package/recordset/context.d.ts +1 -1
- package/recordset/context.js +5 -2
- package/recordset/hooks/index.js +19 -3
- package/recordset/hooks/useRecordSetResult.js +22 -29
- package/recordset/hooks/useRecordSetSetter.js +9 -6
- package/recordset/hooks/useRecordSetVisibility.js +10 -7
- package/recordset/index.js +22 -3
- package/route/RouteProvider.js +18 -14
- package/route/context.js +9 -6
- package/route/hooks/index.js +22 -6
- package/route/hooks/useBasePath.js +7 -4
- package/route/hooks/useIsRouteActive.js +7 -4
- package/route/hooks/usePathname.js +7 -4
- package/route/hooks/useRouteResolver.js +7 -4
- package/route/hooks/useRouter.js +7 -4
- package/route/hooks/useSearchParams.js +7 -4
- package/route/index.js +20 -2
- package/route/types.js +2 -1
- package/store/ClientAppStore.js +12 -21
- package/store/ComponentStore.js +6 -4
- package/store/EventManager.js +20 -32
- package/store/SchemaExperienceStore.js +186 -217
- package/store/index.js +20 -4
- package/toast-notification/ToastNotificationProvider.js +10 -6
- package/toast-notification/context.d.ts +1 -1
- package/toast-notification/context.js +5 -2
- package/toast-notification/hooks/index.js +19 -3
- package/toast-notification/hooks/useCloseToastNotification.js +10 -7
- package/toast-notification/hooks/useOpenToastNotification.js +18 -11
- package/toast-notification/hooks/useToastNotificationItems.d.ts +1 -1
- package/toast-notification/hooks/useToastNotificationItems.js +7 -4
- package/toast-notification/index.js +22 -3
- package/transport/InMemoryDataService/index.js +59 -78
- package/transport/RestDataService/index.d.ts +2 -2
- package/transport/RestDataService/index.js +72 -91
- package/transport/context.js +9 -15
- package/transport/hooks/index.js +18 -2
- package/transport/hooks/useDataService.js +7 -4
- package/transport/hooks/useFileService.js +7 -4
- package/transport/hooks/useRetriveRecords.d.ts +1 -1
- package/transport/hooks/useRetriveRecords.js +25 -31
- package/transport/index.js +20 -2
- package/utils/calculateColumnWidths.js +5 -2
- package/utils/color.js +4 -1
- package/utils/getAttributeFormattedValue.js +38 -40
- package/utils/index.js +18 -2
- package/widget/context.js +5 -2
- package/widget/hooks/index.js +7 -4
- package/widget/index.js +5 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
18
|
+
{
|
|
19
|
+
id,
|
|
20
|
+
isOpen: true,
|
|
21
|
+
...options,
|
|
22
|
+
},
|
|
16
23
|
],
|
|
17
24
|
};
|
|
18
25
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useToastNotificationItems(): import("
|
|
1
|
+
export declare function useToastNotificationItems(): import("../context").ToastNotificationItem[];
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
|
90
|
-
return {};
|
|
91
|
-
});
|
|
76
|
+
async executeAction() {
|
|
77
|
+
return {};
|
|
92
78
|
}
|
|
93
|
-
getReportData() {
|
|
94
|
-
return
|
|
95
|
-
return {};
|
|
96
|
-
});
|
|
79
|
+
async getReportData() {
|
|
80
|
+
return {};
|
|
97
81
|
}
|
|
98
|
-
retriveAggregate() {
|
|
99
|
-
return
|
|
100
|
-
return [];
|
|
101
|
-
});
|
|
82
|
+
async retriveAggregate() {
|
|
83
|
+
return [];
|
|
102
84
|
}
|
|
103
|
-
customAction() {
|
|
104
|
-
return
|
|
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
|
|
20
|
-
updateRecord<T>(logicalName: string, id: string, data: Partial<T>): Promise<CreateRecordResult<import("@headless-adminapp/core
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
24
|
-
|
|
15
|
+
}
|
|
16
|
+
throw new transport_1.HttpError(response.status, response.statusText);
|
|
25
17
|
}
|
|
26
|
-
|
|
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
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
|
66
|
-
|
|
67
|
-
|
|
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
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
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;
|
package/transport/context.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
11
|
+
exports.FileServiceContext = (0, react_1.createContext)(exports.noopFileService);
|
package/transport/hooks/index.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 |
|
|
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: {
|