@wix/auto-patterns 1.19.0 → 1.20.0
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/cjs/components/AutoPatternsTable/AutoPatternsTable.js +4 -2
- package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
- package/dist/cjs/hooks/useTableFeatures.js +9 -1
- package/dist/cjs/hooks/useTableFeatures.js.map +1 -1
- package/dist/cjs/providers/ErrorContext.js +64 -0
- package/dist/cjs/providers/ErrorContext.js.map +1 -0
- package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
- package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/cjs/providers/RootAppProvider.js +16 -8
- package/dist/cjs/providers/RootAppProvider.js.map +1 -1
- package/dist/cjs/providers/SchemaContext.js +7 -2
- package/dist/cjs/providers/SchemaContext.js.map +1 -1
- package/dist/cjs/providers/index.js +6 -0
- package/dist/cjs/providers/index.js.map +1 -1
- package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
- package/dist/cjs/types/actions/collectionPageActions.js.map +1 -1
- package/dist/cjs/types/types.js.map +1 -1
- package/dist/docs/action_cell.md +21 -8
- package/dist/docs/app_config_structure.md +2 -1
- package/dist/docs/auto-patterns-guide.md +416 -116
- package/dist/docs/bulk_actions.md +20 -7
- package/dist/docs/collection_page_actions.md +44 -18
- package/dist/docs/custom_overrides.md +318 -71
- package/dist/docs/index.md +1 -1
- package/dist/docs/installation.md +8 -9
- package/dist/docs/introduction.md +3 -2
- package/dist/docs/wix_fqdn_custom_data_source.md +111 -54
- package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js +4 -2
- package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
- package/dist/esm/hooks/useTableFeatures.js +10 -2
- package/dist/esm/hooks/useTableFeatures.js.map +1 -1
- package/dist/esm/providers/ErrorContext.js +44 -0
- package/dist/esm/providers/ErrorContext.js.map +1 -0
- package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/esm/providers/RootAppProvider.js +2 -1
- package/dist/esm/providers/RootAppProvider.js.map +1 -1
- package/dist/esm/providers/SchemaContext.js +6 -1
- package/dist/esm/providers/SchemaContext.js.map +1 -1
- package/dist/esm/providers/index.js +1 -0
- package/dist/esm/providers/index.js.map +1 -1
- package/dist/esm/types/CollectionPageConfig.js.map +1 -1
- package/dist/esm/types/actions/collectionPageActions.js.map +1 -1
- package/dist/esm/types/types.js.map +1 -1
- package/dist/types/components/AutoPatternsTable/AutoPatternsTable.d.ts.map +1 -1
- package/dist/types/hooks/useTableFeatures.d.ts +6 -0
- package/dist/types/hooks/useTableFeatures.d.ts.map +1 -1
- package/dist/types/providers/ErrorContext.d.ts +11 -0
- package/dist/types/providers/ErrorContext.d.ts.map +1 -0
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts +2 -0
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
- package/dist/types/providers/RootAppProvider.d.ts.map +1 -1
- package/dist/types/providers/SchemaContext.d.ts.map +1 -1
- package/dist/types/providers/index.d.ts +1 -0
- package/dist/types/providers/index.d.ts.map +1 -1
- package/dist/types/types/CollectionPageConfig.d.ts +3 -0
- package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
- package/dist/types/types/actions/collectionPageActions.d.ts +7 -0
- package/dist/types/types/actions/collectionPageActions.d.ts.map +1 -1
- package/dist/types/types/types.d.ts +1 -5
- package/dist/types/types/types.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -22,7 +22,8 @@ const AutoPatternsTable = ({
|
|
|
22
22
|
bulkActionToolbar,
|
|
23
23
|
onRowClick,
|
|
24
24
|
stickyColumns,
|
|
25
|
-
stickySelectionColumn
|
|
25
|
+
stickySelectionColumn,
|
|
26
|
+
sections
|
|
26
27
|
} = (0, _hooks.useTableFeatures)(configuration);
|
|
27
28
|
return /*#__PURE__*/_react.default.createElement(_patterns.Table, {
|
|
28
29
|
dataHook: "auto-patterns-table",
|
|
@@ -39,10 +40,11 @@ const AutoPatternsTable = ({
|
|
|
39
40
|
horizontalScroll: true,
|
|
40
41
|
stickyColumns: stickyColumns,
|
|
41
42
|
stickySelectionColumn: stickySelectionColumn,
|
|
43
|
+
sections: sections,
|
|
42
44
|
__self: void 0,
|
|
43
45
|
__source: {
|
|
44
46
|
fileName: _jsxFileName,
|
|
45
|
-
lineNumber:
|
|
47
|
+
lineNumber: 30,
|
|
46
48
|
columnNumber: 5
|
|
47
49
|
}
|
|
48
50
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_patterns","_hooks","_jsxFileName","AutoPatternsTable","configuration","state","columns","customColumns","search","title","emptyState","filters","actionCell","bulkActionToolbar","onRowClick","stickyColumns","stickySelectionColumn","useTableFeatures","default","createElement","Table","dataHook","horizontalScroll","__self","__source","fileName","lineNumber","columnNumber","exports"],"sources":["../../../../src/components/AutoPatternsTable/AutoPatternsTable.tsx"],"sourcesContent":["import React from 'react';\nimport { Table } from '@wix/patterns';\nimport { TableConfig } from '../../types';\nimport { useTableFeatures } from '../../hooks';\n\nexport interface AutoPatternsTableContentProps {\n configuration: TableConfig;\n}\n\nexport const AutoPatternsTable = ({\n configuration,\n}: AutoPatternsTableContentProps) => {\n const {\n state,\n columns,\n customColumns,\n search,\n title,\n emptyState,\n filters,\n actionCell,\n bulkActionToolbar,\n onRowClick,\n stickyColumns,\n stickySelectionColumn,\n } = useTableFeatures(configuration);\n\n return (\n <Table\n dataHook=\"auto-patterns-table\"\n search={search}\n title={title}\n state={state}\n columns={columns}\n customColumns={customColumns}\n actionCell={actionCell}\n filters={filters}\n emptyState={emptyState}\n bulkActionToolbar={bulkActionToolbar}\n onRowClick={onRowClick}\n horizontalScroll\n stickyColumns={stickyColumns}\n stickySelectionColumn={stickySelectionColumn}\n />\n );\n};\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAA+C,IAAAG,YAAA;AAMxC,MAAMC,iBAAiB,GAAGA,CAAC;EAChCC;AAC6B,CAAC,KAAK;EACnC,MAAM;IACJC,KAAK;IACLC,OAAO;IACPC,aAAa;IACbC,MAAM;IACNC,KAAK;IACLC,UAAU;IACVC,OAAO;IACPC,UAAU;IACVC,iBAAiB;IACjBC,UAAU;IACVC,aAAa;IACbC;EACF,CAAC,GAAG,IAAAC,uBAAgB,
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_patterns","_hooks","_jsxFileName","AutoPatternsTable","configuration","state","columns","customColumns","search","title","emptyState","filters","actionCell","bulkActionToolbar","onRowClick","stickyColumns","stickySelectionColumn","sections","useTableFeatures","default","createElement","Table","dataHook","horizontalScroll","__self","__source","fileName","lineNumber","columnNumber","exports"],"sources":["../../../../src/components/AutoPatternsTable/AutoPatternsTable.tsx"],"sourcesContent":["import React from 'react';\nimport { Table } from '@wix/patterns';\nimport { TableConfig } from '../../types';\nimport { useTableFeatures } from '../../hooks';\n\nexport interface AutoPatternsTableContentProps {\n configuration: TableConfig;\n}\n\nexport const AutoPatternsTable = ({\n configuration,\n}: AutoPatternsTableContentProps) => {\n const {\n state,\n columns,\n customColumns,\n search,\n title,\n emptyState,\n filters,\n actionCell,\n bulkActionToolbar,\n onRowClick,\n stickyColumns,\n stickySelectionColumn,\n sections,\n } = useTableFeatures(configuration);\n\n return (\n <Table\n dataHook=\"auto-patterns-table\"\n search={search}\n title={title}\n state={state}\n columns={columns}\n customColumns={customColumns}\n actionCell={actionCell}\n filters={filters}\n emptyState={emptyState}\n bulkActionToolbar={bulkActionToolbar}\n onRowClick={onRowClick}\n horizontalScroll\n stickyColumns={stickyColumns}\n stickySelectionColumn={stickySelectionColumn}\n sections={sections}\n />\n );\n};\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAA+C,IAAAG,YAAA;AAMxC,MAAMC,iBAAiB,GAAGA,CAAC;EAChCC;AAC6B,CAAC,KAAK;EACnC,MAAM;IACJC,KAAK;IACLC,OAAO;IACPC,aAAa;IACbC,MAAM;IACNC,KAAK;IACLC,UAAU;IACVC,OAAO;IACPC,UAAU;IACVC,iBAAiB;IACjBC,UAAU;IACVC,aAAa;IACbC,qBAAqB;IACrBC;EACF,CAAC,GAAG,IAAAC,uBAAgB,EAACd,aAAa,CAAC;EAEnC,oBACEP,MAAA,CAAAsB,OAAA,CAAAC,aAAA,CAACpB,SAAA,CAAAqB,KAAK;IACJC,QAAQ,EAAC,qBAAqB;IAC9Bd,MAAM,EAAEA,MAAO;IACfC,KAAK,EAAEA,KAAM;IACbJ,KAAK,EAAEA,KAAM;IACbC,OAAO,EAAEA,OAAQ;IACjBC,aAAa,EAAEA,aAAc;IAC7BK,UAAU,EAAEA,UAAW;IACvBD,OAAO,EAAEA,OAAQ;IACjBD,UAAU,EAAEA,UAAW;IACvBG,iBAAiB,EAAEA,iBAAkB;IACrCC,UAAU,EAAEA,UAAW;IACvBS,gBAAgB;IAChBR,aAAa,EAAEA,aAAc;IAC7BC,qBAAqB,EAAEA,qBAAsB;IAC7CC,QAAQ,EAAEA,QAAS;IAAAO,MAAA;IAAAC,QAAA;MAAAC,QAAA,EAAAxB,YAAA;MAAAyB,UAAA;MAAAC,YAAA;IAAA;EAAA,CACpB,CAAC;AAEN,CAAC;AAACC,OAAA,CAAA1B,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -9,7 +9,9 @@ var _useFilters = require("./useFilters");
|
|
|
9
9
|
var _SchemaContext = require("../providers/SchemaContext");
|
|
10
10
|
var _useAutoPatternsOptimisticActions = require("./useAutoPatternsOptimisticActions");
|
|
11
11
|
var _useBaseTableFeatures = require("./useBaseTableFeatures");
|
|
12
|
+
var _PatternsWizardOverridesContext = require("../providers/PatternsWizardOverridesContext");
|
|
12
13
|
const useTableFeatures = configuration => {
|
|
14
|
+
var _configuration$sectio, _overrides$sections;
|
|
13
15
|
const {
|
|
14
16
|
collectionId,
|
|
15
17
|
limit,
|
|
@@ -37,6 +39,7 @@ const useTableFeatures = configuration => {
|
|
|
37
39
|
filterFieldMapping
|
|
38
40
|
});
|
|
39
41
|
const schema = (0, _SchemaContext.useSchema)();
|
|
42
|
+
const overrides = (0, _PatternsWizardOverridesContext.usePatternsWizardOverridesContext)();
|
|
40
43
|
const state = (0, _patterns.useTableCollection)({
|
|
41
44
|
queryName: `${collectionId}`,
|
|
42
45
|
itemKey: item => item[schema.idField],
|
|
@@ -57,6 +60,10 @@ const useTableFeatures = configuration => {
|
|
|
57
60
|
...configuration,
|
|
58
61
|
optimisticActions
|
|
59
62
|
});
|
|
63
|
+
const sections = (_configuration$sectio = configuration.sections) != null && _configuration$sectio.id && overrides != null && (_overrides$sections = overrides.sections) != null && _overrides$sections[configuration.sections.id] ? {
|
|
64
|
+
renderSection: overrides.sections[configuration.sections.id],
|
|
65
|
+
TableSections: _patterns.TableSections
|
|
66
|
+
} : undefined;
|
|
60
67
|
return {
|
|
61
68
|
...commonFeatures,
|
|
62
69
|
state,
|
|
@@ -66,7 +73,8 @@ const useTableFeatures = configuration => {
|
|
|
66
73
|
customColumns,
|
|
67
74
|
onRowClick,
|
|
68
75
|
stickyColumns,
|
|
69
|
-
stickySelectionColumn
|
|
76
|
+
stickySelectionColumn,
|
|
77
|
+
sections
|
|
70
78
|
};
|
|
71
79
|
};
|
|
72
80
|
exports.useTableFeatures = useTableFeatures;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_useFetchData","require","_patterns","_useCommonCollectionFeatures","_useFilters","_SchemaContext","_useAutoPatternsOptimisticActions","_useBaseTableFeatures","useTableFeatures","configuration","collectionId","limit","reflectQueryInUrl","selectAllScope","selectionUpdateMode","collection","filterComponent","filtersObject","filterFieldMapping","useFilters","filters","customColumns","visibleFieldIds","columns","onRowClick","stickyColumns","stickySelectionColumn","useBaseTableFeatures","fetchData","useFetchData","searchableFieldIds","schema","useSchema","state","useTableCollection","queryName","itemKey","item","idField","itemName","displayField","toExtendedFields","extendedFields","fetchErrorMessage","err","String","persistQueryToUrl","disableAutoSelectAllCount","selectionConsistencyMode","optimisticActions","useAutoPatternsOptimisticActions","commonFeatures","useCommonCollectionFeatures","exports"],"sources":["../../../src/hooks/useTableFeatures.tsx"],"sourcesContent":["import { TableConfig } from '../types';\nimport { useFetchData } from './useFetchData';\nimport { useTableCollection } from '@wix/patterns';\nimport { useCommonCollectionFeatures } from './useCommonCollectionFeatures';\nimport { useFilters } from './useFilters';\nimport { useSchema } from '../providers/SchemaContext';\nimport { useAutoPatternsOptimisticActions } from './useAutoPatternsOptimisticActions';\nimport { useBaseTableFeatures } from './useBaseTableFeatures';\n\nexport const useTableFeatures = (configuration: TableConfig) => {\n const {\n collectionId,\n limit,\n reflectQueryInUrl,\n selectAllScope,\n selectionUpdateMode,\n } = configuration.collection;\n\n const { filterComponent, filtersObject, filterFieldMapping } = useFilters(\n configuration.filters,\n );\n const {\n customColumns,\n visibleFieldIds,\n columns,\n onRowClick,\n stickyColumns,\n stickySelectionColumn,\n } = useBaseTableFeatures(configuration);\n\n const { fetchData } = useFetchData({\n searchableFieldIds: visibleFieldIds,\n filterFieldMapping,\n });\n\n const schema = useSchema();\n\n const state = useTableCollection<any>({\n queryName: `${collectionId}`,\n itemKey: (item) => item[schema.idField],\n itemName: (item) => item[schema.displayField],\n filters: filtersObject,\n toExtendedFields: (item) => item.extendedFields,\n fetchErrorMessage: ({ err }) => String(err),\n fetchData,\n limit,\n persistQueryToUrl: reflectQueryInUrl,\n disableAutoSelectAllCount: selectAllScope === 'page',\n selectionConsistencyMode: selectionUpdateMode,\n });\n\n const optimisticActions = useAutoPatternsOptimisticActions(\n collectionId,\n state.collection,\n );\n\n const commonFeatures = useCommonCollectionFeatures({\n ...configuration,\n optimisticActions,\n });\n\n return {\n ...commonFeatures,\n state,\n columns,\n filters: filterComponent,\n optimisticActions,\n customColumns,\n onRowClick,\n stickyColumns,\n stickySelectionColumn,\n };\n};\n"],"mappings":";;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,4BAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,iCAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AAEO,
|
|
1
|
+
{"version":3,"names":["_useFetchData","require","_patterns","_useCommonCollectionFeatures","_useFilters","_SchemaContext","_useAutoPatternsOptimisticActions","_useBaseTableFeatures","_PatternsWizardOverridesContext","useTableFeatures","configuration","_configuration$sectio","_overrides$sections","collectionId","limit","reflectQueryInUrl","selectAllScope","selectionUpdateMode","collection","filterComponent","filtersObject","filterFieldMapping","useFilters","filters","customColumns","visibleFieldIds","columns","onRowClick","stickyColumns","stickySelectionColumn","useBaseTableFeatures","fetchData","useFetchData","searchableFieldIds","schema","useSchema","overrides","usePatternsWizardOverridesContext","state","useTableCollection","queryName","itemKey","item","idField","itemName","displayField","toExtendedFields","extendedFields","fetchErrorMessage","err","String","persistQueryToUrl","disableAutoSelectAllCount","selectionConsistencyMode","optimisticActions","useAutoPatternsOptimisticActions","commonFeatures","useCommonCollectionFeatures","sections","id","renderSection","TableSections","undefined","exports"],"sources":["../../../src/hooks/useTableFeatures.tsx"],"sourcesContent":["import { TableConfig } from '../types';\nimport { useFetchData } from './useFetchData';\nimport { TableSections, useTableCollection } from '@wix/patterns';\nimport { useCommonCollectionFeatures } from './useCommonCollectionFeatures';\nimport { useFilters } from './useFilters';\nimport { useSchema } from '../providers/SchemaContext';\nimport { useAutoPatternsOptimisticActions } from './useAutoPatternsOptimisticActions';\nimport { useBaseTableFeatures } from './useBaseTableFeatures';\nimport { usePatternsWizardOverridesContext } from '../providers/PatternsWizardOverridesContext';\n\nexport const useTableFeatures = (configuration: TableConfig) => {\n const {\n collectionId,\n limit,\n reflectQueryInUrl,\n selectAllScope,\n selectionUpdateMode,\n } = configuration.collection;\n\n const { filterComponent, filtersObject, filterFieldMapping } = useFilters(\n configuration.filters,\n );\n const {\n customColumns,\n visibleFieldIds,\n columns,\n onRowClick,\n stickyColumns,\n stickySelectionColumn,\n } = useBaseTableFeatures(configuration);\n\n const { fetchData } = useFetchData({\n searchableFieldIds: visibleFieldIds,\n filterFieldMapping,\n });\n\n const schema = useSchema();\n const overrides = usePatternsWizardOverridesContext();\n\n const state = useTableCollection<any>({\n queryName: `${collectionId}`,\n itemKey: (item) => item[schema.idField],\n itemName: (item) => item[schema.displayField],\n filters: filtersObject,\n toExtendedFields: (item) => item.extendedFields,\n fetchErrorMessage: ({ err }) => String(err),\n fetchData,\n limit,\n persistQueryToUrl: reflectQueryInUrl,\n disableAutoSelectAllCount: selectAllScope === 'page',\n selectionConsistencyMode: selectionUpdateMode,\n });\n\n const optimisticActions = useAutoPatternsOptimisticActions(\n collectionId,\n state.collection,\n );\n\n const commonFeatures = useCommonCollectionFeatures({\n ...configuration,\n optimisticActions,\n });\n\n const sections =\n configuration.sections?.id &&\n overrides?.sections?.[configuration.sections.id]\n ? {\n renderSection: overrides.sections[configuration.sections.id],\n TableSections,\n }\n : undefined;\n\n return {\n ...commonFeatures,\n state,\n columns,\n filters: filterComponent,\n optimisticActions,\n customColumns,\n onRowClick,\n stickyColumns,\n stickySelectionColumn,\n sections,\n };\n};\n"],"mappings":";;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,4BAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,iCAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AACA,IAAAO,+BAAA,GAAAP,OAAA;AAEO,MA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D1C,YAAY,EACZyB,KAAK,CAACpB,UACR,CAAC;EAED,MAAMsC,cAAc,GAAG,IAAAC,wDAA2B,EAAC;IACjD,GAAG/C,aAAa;IAChB4C;EACF,CAAC,CAAC;EAEF,MAAMI,QAAQ,GACZ,CAAA/C,qBAAA,GAAAD,aAAa,CAACgD,QAAQ,aAAtB/C,qBAAA,CAAwBgD,EAAE,IAC1BvB,SAAS,aAAAxB,mBAAA,GAATwB,SAAS,CAAEsB,QAAQ,aAAnB9C,mBAAA,CAAsBF,aAAa,CAACgD,QAAQ,CAACC,EAAE,CAAC,GAC5C;IACEC,aAAa,EAAExB,SAAS,CAACsB,QAAQ,CAAChD,aAAa,CAACgD,QAAQ,CAACC,EAAE,CAAC;IAC5DE,aAAa,EAAbA;EACF,CAAC,GACDC,SAAS;EAEf,OAAO;IACL,GAAGN,cAAc;IACjBlB,KAAK;IACLZ,OAAO;IACPH,OAAO,EAAEJ,eAAe;IACxBmC,iBAAiB;IACjB9B,aAAa;IACbG,UAAU;IACVC,aAAa;IACbC,qBAAqB;IACrB6B;EACF,CAAC;AACH,CAAC;AAACK,OAAA,CAAAtD,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useError = exports.ErrorProvider = void 0;
|
|
5
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
6
|
+
var _patterns = require("@wix/patterns");
|
|
7
|
+
var _jsxFileName = "/home/builduser/work/73d19ce3378ce4dd/packages/auto-patterns/dist/cjs/providers/ErrorContext.tsx";
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
+
const ErrorContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
11
|
+
const ErrorProvider = ({
|
|
12
|
+
children
|
|
13
|
+
}) => {
|
|
14
|
+
const [errorState, setErrorState] = (0, _react.useState)({
|
|
15
|
+
hasError: false,
|
|
16
|
+
error: null
|
|
17
|
+
});
|
|
18
|
+
const showError = (0, _react.useCallback)(error => {
|
|
19
|
+
const errorObj = typeof error === 'string' ? new Error(error) : error;
|
|
20
|
+
setErrorState({
|
|
21
|
+
hasError: true,
|
|
22
|
+
error: errorObj
|
|
23
|
+
});
|
|
24
|
+
}, []);
|
|
25
|
+
const clearError = (0, _react.useCallback)(() => {
|
|
26
|
+
setErrorState({
|
|
27
|
+
hasError: false,
|
|
28
|
+
error: null
|
|
29
|
+
});
|
|
30
|
+
}, []);
|
|
31
|
+
if (errorState.hasError && errorState.error) {
|
|
32
|
+
return /*#__PURE__*/_react.default.createElement(_patterns.PageErrorState, {
|
|
33
|
+
subtitle: errorState.error.message,
|
|
34
|
+
__self: void 0,
|
|
35
|
+
__source: {
|
|
36
|
+
fileName: _jsxFileName,
|
|
37
|
+
lineNumber: 46,
|
|
38
|
+
columnNumber: 12
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement(ErrorContext.Provider, {
|
|
43
|
+
value: {
|
|
44
|
+
showError,
|
|
45
|
+
clearError
|
|
46
|
+
},
|
|
47
|
+
__self: void 0,
|
|
48
|
+
__source: {
|
|
49
|
+
fileName: _jsxFileName,
|
|
50
|
+
lineNumber: 50,
|
|
51
|
+
columnNumber: 5
|
|
52
|
+
}
|
|
53
|
+
}, children);
|
|
54
|
+
};
|
|
55
|
+
exports.ErrorProvider = ErrorProvider;
|
|
56
|
+
const useError = () => {
|
|
57
|
+
const context = (0, _react.useContext)(ErrorContext);
|
|
58
|
+
if (!context) {
|
|
59
|
+
throw new Error('useError must be used within an ErrorProvider');
|
|
60
|
+
}
|
|
61
|
+
return context;
|
|
62
|
+
};
|
|
63
|
+
exports.useError = useError;
|
|
64
|
+
//# sourceMappingURL=ErrorContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_patterns","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ErrorContext","createContext","undefined","ErrorProvider","children","errorState","setErrorState","useState","hasError","error","showError","useCallback","errorObj","Error","clearError","createElement","PageErrorState","subtitle","message","__self","__source","fileName","lineNumber","columnNumber","Provider","value","exports","useError","context","useContext"],"sources":["../../../src/providers/ErrorContext.tsx"],"sourcesContent":["import React, {\n createContext,\n useContext,\n useState,\n useCallback,\n ReactNode,\n} from 'react';\nimport { PageErrorState } from '@wix/patterns';\n\ninterface ErrorState {\n hasError: boolean;\n error: Error | null;\n}\n\ninterface ErrorContextType {\n showError: (error: Error) => void;\n clearError: () => void;\n}\n\nconst ErrorContext = createContext<ErrorContextType | undefined>(undefined);\n\nexport const ErrorProvider: React.FC<{ children: ReactNode }> = ({\n children,\n}) => {\n const [errorState, setErrorState] = useState<ErrorState>({\n hasError: false,\n error: null,\n });\n\n const showError = useCallback((error: Error | string) => {\n const errorObj = typeof error === 'string' ? new Error(error) : error;\n setErrorState({\n hasError: true,\n error: errorObj,\n });\n }, []);\n\n const clearError = useCallback(() => {\n setErrorState({\n hasError: false,\n error: null,\n });\n }, []);\n\n if (errorState.hasError && errorState.error) {\n return <PageErrorState subtitle={errorState.error.message} />;\n }\n\n return (\n <ErrorContext.Provider value={{ showError, clearError }}>\n {children}\n </ErrorContext.Provider>\n );\n};\n\nexport const useError = (): ErrorContextType => {\n const context = useContext(ErrorContext);\n if (!context) {\n throw new Error('useError must be used within an ErrorProvider');\n }\n return context;\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,SAAA,GAAAD,OAAA;AAA+C,IAAAE,YAAA;AAAA,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,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IAAW,CAAE;IAAAK,MAAA;IAAAC,QAAA;MAAAC,QAAA,EAAA1C,YAAA;MAAA2C,UAAA;MAAAC,YAAA;IAAA;EAAA,GACrDnB,QACoB,CAAC;AAE5B,CAAC;AAACsB,OAAA,CAAAvB,aAAA,GAAAA,aAAA;AAEK,MAAMwB,QAAQ,GAAGA,CAAA,KAAwB;EAC9C,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAAC7B,YAAY,CAAC;EACxC,IAAI,CAAC4B,OAAO,EAAE;IACZ,MAAM,IAAIf,KAAK,CAAC,+CAA+C,CAAC;EAClE;EACA,OAAOe,OAAO;AAChB,CAAC;AAACF,OAAA,CAAAC,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","PatternsWizardOverridesContext","createContext","undefined","PatternsWizardOverridesProvider","children","value","createElement","Provider","__self","__source","fileName","lineNumber","columnNumber","exports","usePatternsWizardOverridesContext","useContext"],"sources":["../../../src/providers/PatternsWizardOverridesContext.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode } from 'react';\nimport {\n CustomComponentProps,\n EntityPageMoreActionsActionParams,\n IColumnValue,\n SchemaConfig,\n} from '../types';\n\nimport { CustomActionParams, ResolvedAction } from '../utils/actions/types';\nimport {\n CollectionPageActionOnRowClickParams,\n CollectionPageActionParams,\n} from '../types/actions/collectionPageActions';\nimport { ActionCellActionParams } from '../types/actions/actionCell';\n\nexport interface PatternsWizardOverridesContextProps {\n actions?: Record<\n string,\n (\n props: CustomActionParams<\n | EntityPageMoreActionsActionParams\n | CollectionPageActionParams\n | ActionCellActionParams\n | CollectionPageActionOnRowClickParams\n >,\n ) => ResolvedAction\n >;\n columns?: Record<string, (props: IColumnValue<any>) => void>;\n modals?: Record<string, React.FC<any>>;\n HeaderAddon?: React.FC;\n emptyState?: Record<string, () => void>;\n components?: Record<string, React.FC<CustomComponentProps>>;\n customDataSources?: Record<\n string,\n (collectionId: string, context: any) => Promise<SchemaConfig>\n >;\n}\n\nconst PatternsWizardOverridesContext = createContext<\n PatternsWizardOverridesContextProps | undefined\n>(undefined);\n\nexport const PatternsWizardOverridesProvider: React.FC<{\n children: ReactNode;\n value: PatternsWizardOverridesContextProps;\n}> = ({ children, value }) => {\n return (\n <PatternsWizardOverridesContext.Provider value={value}>\n {children}\n </PatternsWizardOverridesContext.Provider>\n );\n};\n\nexport const usePatternsWizardOverridesContext = ():\n | PatternsWizardOverridesContextProps\n | undefined => {\n return useContext(PatternsWizardOverridesContext);\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAoE,IAAAC,YAAA;AAAA,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","PatternsWizardOverridesContext","createContext","undefined","PatternsWizardOverridesProvider","children","value","createElement","Provider","__self","__source","fileName","lineNumber","columnNumber","exports","usePatternsWizardOverridesContext","useContext"],"sources":["../../../src/providers/PatternsWizardOverridesContext.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode } from 'react';\nimport {\n CustomComponentProps,\n EntityPageMoreActionsActionParams,\n IColumnValue,\n SchemaConfig,\n} from '../types';\n\nimport { Section } from '@wix/patterns';\n\nimport { CustomActionParams, ResolvedAction } from '../utils/actions/types';\nimport {\n CollectionPageActionOnRowClickParams,\n CollectionPageActionParams,\n} from '../types/actions/collectionPageActions';\nimport { ActionCellActionParams } from '../types/actions/actionCell';\n\nexport interface PatternsWizardOverridesContextProps {\n actions?: Record<\n string,\n (\n props: CustomActionParams<\n | EntityPageMoreActionsActionParams\n | CollectionPageActionParams\n | ActionCellActionParams\n | CollectionPageActionOnRowClickParams\n >,\n ) => ResolvedAction\n >;\n columns?: Record<string, (props: IColumnValue<any>) => void>;\n modals?: Record<string, React.FC<any>>;\n HeaderAddon?: React.FC;\n emptyState?: Record<string, () => void>;\n components?: Record<string, React.FC<CustomComponentProps>>;\n customDataSources?: Record<\n string,\n (collectionId: string, context: any) => Promise<SchemaConfig>\n >;\n sections?: Record<string, (item: any) => Section>;\n}\n\nconst PatternsWizardOverridesContext = createContext<\n PatternsWizardOverridesContextProps | undefined\n>(undefined);\n\nexport const PatternsWizardOverridesProvider: React.FC<{\n children: ReactNode;\n value: PatternsWizardOverridesContextProps;\n}> = ({ children, value }) => {\n return (\n <PatternsWizardOverridesContext.Provider value={value}>\n {children}\n </PatternsWizardOverridesContext.Provider>\n );\n};\n\nexport const usePatternsWizardOverridesContext = ():\n | PatternsWizardOverridesContextProps\n | undefined => {\n return useContext(PatternsWizardOverridesContext);\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAoE,IAAAC,YAAA;AAAA,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAyCpE,MAAMW,8BAA8B,gBAAG,IAAAC,oBAAa,EAElDC,SAAS,CAAC;AAEL,MAAMC,+BAGX,GAAGA,CAAC;EAAEC,QAAQ;EAAEC;AAAM,CAAC,KAAK;EAC5B,oBACE7B,MAAA,CAAAU,OAAA,CAAAoB,aAAA,CAACN,8BAA8B,CAACO,QAAQ;IAACF,KAAK,EAAEA,KAAM;IAAAG,MAAA;IAAAC,QAAA;MAAAC,QAAA,EAAA/B,YAAA;MAAAgC,UAAA;MAAAC,YAAA;IAAA;EAAA,GACnDR,QACsC,CAAC;AAE9C,CAAC;AAACS,OAAA,CAAAV,+BAAA,GAAAA,+BAAA;AAEK,MAAMW,iCAAiC,GAAGA,CAAA,KAEhC;EACf,OAAO,IAAAC,iBAAU,EAACf,8BAA8B,CAAC;AACnD,CAAC;AAACa,OAAA,CAAAC,iCAAA,GAAAA,iCAAA","ignoreList":[]}
|
|
@@ -8,6 +8,7 @@ var _AppConfigContext = require("./AppConfigContext");
|
|
|
8
8
|
var _ModalContext = require("./ModalContext");
|
|
9
9
|
var _SchemaRegistryContext = require("./SchemaRegistryContext");
|
|
10
10
|
var _OptimisticActionsContext = require("./OptimisticActionsContext");
|
|
11
|
+
var _ErrorContext = require("./ErrorContext");
|
|
11
12
|
var _jsxFileName = "/home/builduser/work/73d19ce3378ce4dd/packages/auto-patterns/dist/cjs/providers/RootAppProvider.tsx";
|
|
12
13
|
const RootAppProvider = ({
|
|
13
14
|
appConfig,
|
|
@@ -18,31 +19,38 @@ const RootAppProvider = ({
|
|
|
18
19
|
__self: void 0,
|
|
19
20
|
__source: {
|
|
20
21
|
fileName: _jsxFileName,
|
|
21
|
-
lineNumber:
|
|
22
|
+
lineNumber: 17,
|
|
22
23
|
columnNumber: 5
|
|
23
24
|
}
|
|
24
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
25
|
+
}, /*#__PURE__*/_react.default.createElement(_ErrorContext.ErrorProvider, {
|
|
25
26
|
__self: void 0,
|
|
26
27
|
__source: {
|
|
27
28
|
fileName: _jsxFileName,
|
|
28
|
-
lineNumber:
|
|
29
|
+
lineNumber: 18,
|
|
29
30
|
columnNumber: 7
|
|
30
31
|
}
|
|
31
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
32
|
+
}, /*#__PURE__*/_react.default.createElement(_SchemaRegistryContext.SchemaRegistryProvider, {
|
|
32
33
|
__self: void 0,
|
|
33
34
|
__source: {
|
|
34
35
|
fileName: _jsxFileName,
|
|
35
|
-
lineNumber:
|
|
36
|
+
lineNumber: 19,
|
|
36
37
|
columnNumber: 9
|
|
37
38
|
}
|
|
38
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
39
|
+
}, /*#__PURE__*/_react.default.createElement(_OptimisticActionsContext.OptimisticActionsProvider, {
|
|
39
40
|
__self: void 0,
|
|
40
41
|
__source: {
|
|
41
42
|
fileName: _jsxFileName,
|
|
42
|
-
lineNumber:
|
|
43
|
+
lineNumber: 20,
|
|
43
44
|
columnNumber: 11
|
|
44
45
|
}
|
|
45
|
-
},
|
|
46
|
+
}, /*#__PURE__*/_react.default.createElement(_ModalContext.ModalProvider, {
|
|
47
|
+
__self: void 0,
|
|
48
|
+
__source: {
|
|
49
|
+
fileName: _jsxFileName,
|
|
50
|
+
lineNumber: 21,
|
|
51
|
+
columnNumber: 13
|
|
52
|
+
}
|
|
53
|
+
}, children)))));
|
|
46
54
|
};
|
|
47
55
|
exports.RootAppProvider = RootAppProvider;
|
|
48
56
|
//# sourceMappingURL=RootAppProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_AppConfigContext","_ModalContext","_SchemaRegistryContext","_OptimisticActionsContext","_jsxFileName","RootAppProvider","appConfig","children","default","createElement","AppConfigProvider","__self","__source","fileName","lineNumber","columnNumber","SchemaRegistryProvider","OptimisticActionsProvider","ModalProvider","exports"],"sources":["../../../src/providers/RootAppProvider.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport { AppConfig } from '../types';\nimport { AppConfigProvider } from './AppConfigContext';\nimport { ModalProvider } from './ModalContext';\nimport { SchemaRegistryProvider } from './SchemaRegistryContext';\nimport { OptimisticActionsProvider } from './OptimisticActionsContext';\n\nexport const RootAppProvider = ({\n appConfig,\n children,\n}: {\n appConfig: AppConfig;\n children: ReactNode;\n}) => {\n return (\n <AppConfigProvider appConfig={appConfig}>\n <
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_AppConfigContext","_ModalContext","_SchemaRegistryContext","_OptimisticActionsContext","_ErrorContext","_jsxFileName","RootAppProvider","appConfig","children","default","createElement","AppConfigProvider","__self","__source","fileName","lineNumber","columnNumber","ErrorProvider","SchemaRegistryProvider","OptimisticActionsProvider","ModalProvider","exports"],"sources":["../../../src/providers/RootAppProvider.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport { AppConfig } from '../types';\nimport { AppConfigProvider } from './AppConfigContext';\nimport { ModalProvider } from './ModalContext';\nimport { SchemaRegistryProvider } from './SchemaRegistryContext';\nimport { OptimisticActionsProvider } from './OptimisticActionsContext';\nimport { ErrorProvider } from './ErrorContext';\n\nexport const RootAppProvider = ({\n appConfig,\n children,\n}: {\n appConfig: AppConfig;\n children: ReactNode;\n}) => {\n return (\n <AppConfigProvider appConfig={appConfig}>\n <ErrorProvider>\n <SchemaRegistryProvider>\n <OptimisticActionsProvider>\n <ModalProvider>{children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AAA,GAAER,QAAwB,CACf,CACL,CACX,CACE,CAAC;AAExB,CAAC;AAACa,OAAA,CAAAf,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -7,6 +7,7 @@ var _factory = require("../dataSourceAdapters/factory");
|
|
|
7
7
|
var _SchemaRegistryContext = require("./SchemaRegistryContext");
|
|
8
8
|
var _PatternsWizardOverridesContext = require("./PatternsWizardOverridesContext");
|
|
9
9
|
var _patterns = require("@wix/patterns");
|
|
10
|
+
var _ErrorContext = require("./ErrorContext");
|
|
10
11
|
var _jsxFileName = "/home/builduser/work/73d19ce3378ce4dd/packages/auto-patterns/dist/cjs/providers/SchemaContext.tsx";
|
|
11
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -26,6 +27,9 @@ const SchemaProvider = ({
|
|
|
26
27
|
getSchema: getSchemaFromRegistry,
|
|
27
28
|
addSchema: addSchemaToRegistry
|
|
28
29
|
} = (0, _SchemaRegistryContext.useSchemaRegistry)();
|
|
30
|
+
const {
|
|
31
|
+
showError
|
|
32
|
+
} = (0, _ErrorContext.useError)();
|
|
29
33
|
const [schema, setSchema] = (0, _react.useState)(null);
|
|
30
34
|
const [isLoading, setIsLoading] = (0, _react.useState)(false);
|
|
31
35
|
const overrides = (0, _PatternsWizardOverridesContext.usePatternsWizardOverridesContext)();
|
|
@@ -83,10 +87,11 @@ const SchemaProvider = ({
|
|
|
83
87
|
await fetchReferencedSchemas(fetchedSchema);
|
|
84
88
|
}).catch(error => {
|
|
85
89
|
console.error('Error fetching schema config:', error);
|
|
90
|
+
showError(error);
|
|
86
91
|
}).finally(() => {
|
|
87
92
|
setIsLoading(false);
|
|
88
93
|
});
|
|
89
|
-
}, [collectionId, entityTypeSource, customDataSourceId, addSchemaToRegistry, getSchemaFromRegistry, overrides, httpClient]);
|
|
94
|
+
}, [collectionId, entityTypeSource, customDataSourceId, addSchemaToRegistry, getSchemaFromRegistry, overrides, httpClient, showError]);
|
|
90
95
|
if (!schema || isLoading) {
|
|
91
96
|
return skeleton;
|
|
92
97
|
}
|
|
@@ -95,7 +100,7 @@ const SchemaProvider = ({
|
|
|
95
100
|
__self: void 0,
|
|
96
101
|
__source: {
|
|
97
102
|
fileName: _jsxFileName,
|
|
98
|
-
lineNumber:
|
|
103
|
+
lineNumber: 139,
|
|
99
104
|
columnNumber: 5
|
|
100
105
|
}
|
|
101
106
|
}, children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_factory","_SchemaRegistryContext","_PatternsWizardOverridesContext","_patterns","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SchemaContext","createContext","SchemaProvider","collection","children","skeleton","_collection$custom","collectionId","entityTypeSource","customDataSourceId","custom","id","undefined","getSchema","getSchemaFromRegistry","addSchema","addSchemaToRegistry","useSchemaRegistry","schema","setSchema","useState","isLoading","setIsLoading","overrides","usePatternsWizardOverridesContext","httpClient","useWixPatternsContainer","useEffect","fetchSchemaForCollection","targetCollectionId","targetCustomDataSourceId","customDataSources","customSchemaProvider","Error","fetchReferencedSchemas","referencedSchema","referencedCollectionIds","Set","values","fields","forEach","field","type","referenceMetadata","referencedCollectionId","add","size","fetchPromises","Array","from","map","refCollectionId","refSchema","error","console","Promise","all","cachedSchema","then","fetchedSchema","catch","finally","createElement","Provider","value","__self","__source","fileName","lineNumber","columnNumber","exports","useSchema","context","useContext"],"sources":["../../../src/providers/SchemaContext.tsx"],"sourcesContent":["import React, {\n createContext,\n useContext,\n useEffect,\n useState,\n ReactNode,\n} from 'react';\n\nimport { SchemaConfig, BaseCollectionConfig } from '../types';\nimport { getSchema } from '../dataSourceAdapters/factory';\nimport { useSchemaRegistry } from './SchemaRegistryContext';\nimport { usePatternsWizardOverridesContext } from './PatternsWizardOverridesContext';\nimport { useWixPatternsContainer } from '@wix/patterns';\n\nconst SchemaContext = createContext<SchemaConfig | null>(null);\n\ninterface SchemaProviderProps {\n collection: BaseCollectionConfig;\n children: ReactNode;\n skeleton: JSX.Element;\n}\n\nexport const SchemaProvider = ({\n collection,\n children,\n skeleton,\n}: SchemaProviderProps) => {\n const { collectionId, entityTypeSource } = collection;\n const customDataSourceId =\n collection.entityTypeSource === 'custom' && 'custom' in collection\n ? collection.custom?.id\n : undefined;\n const { getSchema: getSchemaFromRegistry, addSchema: addSchemaToRegistry } =\n useSchemaRegistry();\n const [schema, setSchema] = useState<SchemaConfig | null>(null);\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const overrides = usePatternsWizardOverridesContext();\n const { httpClient } = useWixPatternsContainer();\n\n useEffect(() => {\n const fetchSchemaForCollection = async (\n targetCollectionId: string,\n targetCustomDataSourceId?: string,\n ): Promise<SchemaConfig> => {\n if (\n entityTypeSource === 'custom' &&\n targetCustomDataSourceId &&\n overrides?.customDataSources\n ) {\n const customSchemaProvider =\n overrides.customDataSources[targetCustomDataSourceId];\n if (customSchemaProvider) {\n return customSchemaProvider(targetCollectionId, { httpClient });\n }\n throw new Error(\n `Custom schema provider '${targetCustomDataSourceId}' not found`,\n );\n }\n\n return getSchema(targetCollectionId, entityTypeSource);\n };\n\n const fetchReferencedSchemas = async (referencedSchema: SchemaConfig) => {\n const referencedCollectionIds = new Set<string>();\n\n Object.values(referencedSchema.fields).forEach((field) => {\n if (field && field.type === 'REFERENCE' && field.referenceMetadata) {\n const { referencedCollectionId } = field.referenceMetadata;\n if (\n referencedCollectionId &&\n !getSchemaFromRegistry(referencedCollectionId)\n ) {\n referencedCollectionIds.add(referencedCollectionId);\n }\n }\n });\n\n if (referencedCollectionIds.size === 0) {\n return;\n }\n\n const fetchPromises = Array.from(referencedCollectionIds).map(\n async (refCollectionId) => {\n try {\n const refSchema = await fetchSchemaForCollection(refCollectionId);\n\n addSchemaToRegistry(refCollectionId, refSchema);\n\n await fetchReferencedSchemas(refSchema);\n } catch (error) {\n console.error(\n `Error fetching referenced schema ${refCollectionId}:`,\n error,\n );\n }\n },\n );\n\n await Promise.all(fetchPromises);\n };\n\n const cachedSchema = getSchemaFromRegistry(collectionId);\n if (cachedSchema) {\n setSchema(cachedSchema);\n return;\n }\n setIsLoading(true);\n fetchSchemaForCollection(collectionId, customDataSourceId)\n .then(async (fetchedSchema) => {\n setSchema(fetchedSchema);\n addSchemaToRegistry(collectionId, fetchedSchema);\n\n await fetchReferencedSchemas(fetchedSchema);\n })\n .catch((error) => {\n console.error('Error fetching schema config:', error);\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, [\n collectionId,\n entityTypeSource,\n customDataSourceId,\n addSchemaToRegistry,\n getSchemaFromRegistry,\n overrides,\n httpClient,\n ]);\n if (!schema || isLoading) {\n return skeleton;\n }\n\n return (\n <SchemaContext.Provider value={schema}>{children}</SchemaContext.Provider>\n );\n};\n\nexport const useSchema = (): SchemaConfig => {\n const context = useContext(SchemaContext);\n if (!context) {\n throw new Error('useSchema must be used within a SchemaProvider');\n }\n return context;\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,+BAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAAwD,IAA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xB3C,mBAAmB,CAACT,YAAY,EAAEoD,aAAa,CAAC;MAEhD,MAAMzB,sBAAsB,CAACyB,aAAa,CAAC;IAC7C,CAAC,CAAC,CACDC,KAAK,CAAEP,KAAK,IAAK;MAChBC,OAAO,CAACD,KAAK,CAAC,+BAA+B,EAAEA,KAAK,CAAC;IACvD,CAAC,CAAC,CACDQ,OAAO,CAAC,MAAM;MACbvC,YAAY,CAAC,KAAK,CAAC;IACrB,CAAC,CAAC;EACN,CAAC,EAAE,CACDf,YAAY,EACZC,gBAAgB,EAChBC,kBAAkB,EAClBO,mBAAmB,EACnBF,qBAAqB,EACrBS,SAAS,EACTE,UAAU,CACX,CAAC;EACF,IAAI,CAACP,MAAM,IAAIG,SAAS,EAAE;IACxB,OAAOhB,QAAQ;EACjB;EAEA,oBACEjC,MAAA,CAAAc,OAAA,CAAA4E,aAAA,CAAC9D,aAAa,CAAC+D,QAAQ;IAACC,KAAK,EAAE9C,MAAO;IAAA+C,MAAA;IAAAC,QAAA;MAAAC,QAAA,EAAAxF,YAAA;MAAAyF,UAAA;MAAAC,YAAA;IAAA;EAAA,GAAEjE,QAAiC,CAAC;AAE9E,CAAC;AAACkE,OAAA,CAAApE,cAAA,GAAAA,cAAA;AAEK,MAAMqE,SAAS,GAAGA,CAAA,KAAoB;EAC3C,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACzE,aAAa,CAAC;EACzC,IAAI,CAACwE,OAAO,EAAE;IACZ,MAAM,IAAIvC,KAAK,CAAC,gDAAgD,CAAC;EACnE;EACA,OAAOuC,OAAO;AAChB,CAAC;AAACF,OAAA,CAAAC,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_factory","_SchemaRegistryContext","_PatternsWizardOverridesContext","_patterns","_ErrorContext","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SchemaContext","createContext","SchemaProvider","collection","children","skeleton","_collection$custom","collectionId","entityTypeSource","customDataSourceId","custom","id","undefined","getSchema","getSchemaFromRegistry","addSchema","addSchemaToRegistry","useSchemaRegistry","showError","useError","schema","setSchema","useState","isLoading","setIsLoading","overrides","usePatternsWizardOverridesContext","httpClient","useWixPatternsContainer","useEffect","fetchSchemaForCollection","targetCollectionId","targetCustomDataSourceId","customDataSources","customSchemaProvider","Error","fetchReferencedSchemas","referencedSchema","referencedCollectionIds","Set","values","fields","forEach","field","type","referenceMetadata","referencedCollectionId","add","size","fetchPromises","Array","from","map","refCollectionId","refSchema","error","console","Promise","all","cachedSchema","then","fetchedSchema","catch","finally","createElement","Provider","value","__self","__source","fileName","lineNumber","columnNumber","exports","useSchema","context","useContext"],"sources":["../../../src/providers/SchemaContext.tsx"],"sourcesContent":["import React, {\n createContext,\n useContext,\n useEffect,\n useState,\n ReactNode,\n} from 'react';\n\nimport { SchemaConfig, BaseCollectionConfig } from '../types';\nimport { getSchema } from '../dataSourceAdapters/factory';\nimport { useSchemaRegistry } from './SchemaRegistryContext';\nimport { usePatternsWizardOverridesContext } from './PatternsWizardOverridesContext';\nimport { useWixPatternsContainer } from '@wix/patterns';\nimport { useError } from './ErrorContext';\n\nconst SchemaContext = createContext<SchemaConfig | null>(null);\n\ninterface SchemaProviderProps {\n collection: BaseCollectionConfig;\n children: ReactNode;\n skeleton: JSX.Element;\n}\n\nexport const SchemaProvider = ({\n collection,\n children,\n skeleton,\n}: SchemaProviderProps) => {\n const { collectionId, entityTypeSource } = collection;\n const customDataSourceId =\n collection.entityTypeSource === 'custom' && 'custom' in collection\n ? collection.custom?.id\n : undefined;\n const { getSchema: getSchemaFromRegistry, addSchema: addSchemaToRegistry } =\n useSchemaRegistry();\n const { showError } = useError();\n const [schema, setSchema] = useState<SchemaConfig | null>(null);\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const overrides = usePatternsWizardOverridesContext();\n const { httpClient } = useWixPatternsContainer();\n\n useEffect(() => {\n const fetchSchemaForCollection = async (\n targetCollectionId: string,\n targetCustomDataSourceId?: string,\n ): Promise<SchemaConfig> => {\n if (\n entityTypeSource === 'custom' &&\n targetCustomDataSourceId &&\n overrides?.customDataSources\n ) {\n const customSchemaProvider =\n overrides.customDataSources[targetCustomDataSourceId];\n if (customSchemaProvider) {\n return customSchemaProvider(targetCollectionId, { httpClient });\n }\n throw new Error(\n `Custom schema provider '${targetCustomDataSourceId}' not found`,\n );\n }\n\n return getSchema(targetCollectionId, entityTypeSource);\n };\n\n const fetchReferencedSchemas = async (referencedSchema: SchemaConfig) => {\n const referencedCollectionIds = new Set<string>();\n\n Object.values(referencedSchema.fields).forEach((field) => {\n if (field && field.type === 'REFERENCE' && field.referenceMetadata) {\n const { referencedCollectionId } = field.referenceMetadata;\n if (\n referencedCollectionId &&\n !getSchemaFromRegistry(referencedCollectionId)\n ) {\n referencedCollectionIds.add(referencedCollectionId);\n }\n }\n });\n\n if (referencedCollectionIds.size === 0) {\n return;\n }\n\n const fetchPromises = Array.from(referencedCollectionIds).map(\n async (refCollectionId) => {\n try {\n const refSchema = await fetchSchemaForCollection(refCollectionId);\n\n addSchemaToRegistry(refCollectionId, refSchema);\n\n await fetchReferencedSchemas(refSchema);\n } catch (error) {\n console.error(\n `Error fetching referenced schema ${refCollectionId}:`,\n error,\n );\n }\n },\n );\n\n await Promise.all(fetchPromises);\n };\n\n const cachedSchema = getSchemaFromRegistry(collectionId);\n if (cachedSchema) {\n setSchema(cachedSchema);\n return;\n }\n setIsLoading(true);\n fetchSchemaForCollection(collectionId, customDataSourceId)\n .then(async (fetchedSchema) => {\n setSchema(fetchedSchema);\n addSchemaToRegistry(collectionId, fetchedSchema);\n\n await fetchReferencedSchemas(fetchedSchema);\n })\n .catch((error) => {\n console.error('Error fetching schema config:', error);\n showError(error);\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, [\n collectionId,\n entityTypeSource,\n customDataSourceId,\n addSchemaToRegistry,\n getSchemaFromRegistry,\n overrides,\n httpClient,\n showError,\n ]);\n if (!schema || isLoading) {\n return skeleton;\n }\n\n return (\n <SchemaContext.Provider value={schema}>{children}</SchemaContext.Provider>\n );\n};\n\nexport const useSchema = (): SchemaConfig => {\n const context = useContext(SchemaContext);\n if (!context) {\n throw new Error('useSchema must be used within a SchemaProvider');\n }\n return context;\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,+BAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAA0C,IAAAM,YAAA;AAAA,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAA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IAAA;EAAA,GAAEnE,QAAiC,CAAC;AAE9E,CAAC;AAACoE,OAAA,CAAAtE,cAAA,GAAAA,cAAA;AAEK,MAAMuE,SAAS,GAAGA,CAAA,KAAoB;EAC3C,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAAC3E,aAAa,CAAC;EACzC,IAAI,CAAC0E,OAAO,EAAE;IACZ,MAAM,IAAIvC,KAAK,CAAC,gDAAgD,CAAC;EACnE;EACA,OAAOuC,OAAO;AAChB,CAAC;AAACF,OAAA,CAAAC,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -31,4 +31,10 @@ Object.keys(_AppConfigContext).forEach(function (key) {
|
|
|
31
31
|
if (key in exports && exports[key] === _AppConfigContext[key]) return;
|
|
32
32
|
exports[key] = _AppConfigContext[key];
|
|
33
33
|
});
|
|
34
|
+
var _ErrorContext = require("./ErrorContext");
|
|
35
|
+
Object.keys(_ErrorContext).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (key in exports && exports[key] === _ErrorContext[key]) return;
|
|
38
|
+
exports[key] = _ErrorContext[key];
|
|
39
|
+
});
|
|
34
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_SchemaContext","require","Object","keys","forEach","key","exports","_PatternsWizardOverridesContext","_ModalContext","_SchemaRegistryContext","_AppConfigContext"],"sources":["../../../src/providers/index.ts"],"sourcesContent":["export * from './SchemaContext';\nexport * from './PatternsWizardOverridesContext';\nexport * from './ModalContext';\nexport * from './SchemaRegistryContext';\nexport * from './AppConfigContext';\n"],"mappings":";;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,cAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,cAAA,CAAAK,GAAA;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ys","forEach","key","exports","_PatternsWizardOverridesContext","_ModalContext","_SchemaRegistryContext","_AppConfigContext","_ErrorContext"],"sources":["../../../src/providers/index.ts"],"sourcesContent":["export * from './SchemaContext';\nexport * from './PatternsWizardOverridesContext';\nexport * from './ModalContext';\nexport * from './SchemaRegistryContext';\nexport * from './AppConfigContext';\nexport * from './ErrorContext';\n"],"mappings":";;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,cAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,cAAA,CAAAK,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAL,cAAA,CAAAK,GAAA;AAAA;AACA,IAAAE,+BAAA,GAAAN,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAI,+BAAA,EAAAH,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAE,+BAAA,CAAAF,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAE,+BAAA,CAAAF,GAAA;AAAA;AACA,IAAAG,aAAA,GAAAP,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAK,aAAA,EAAAJ,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAG,aAAA,CAAAH,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAG,aAAA,CAAAH,GAAA;AAAA;AACA,IAAAI,sBAAA,GAAAR,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAM,sBAAA,EAAAL,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAI,sBAAA,CAAAJ,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAI,sBAAA,CAAAJ,GAAA;AAAA;AACA,IAAAK,iBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,iBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,iBAAA,CAAAL,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAK,iBAAA,CAAAL,GAAA;AAAA;AACA,IAAAM,aAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,aAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,aAAA,CAAAN,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAM,aAAA,CAAAN,GAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ComponentTypeEnum","exports"],"sources":["../../../src/types/CollectionPageConfig.ts"],"sourcesContent":["import { CollectionToolbarFiltersProps } from '@wix/patterns';\nimport { DateRangeFilterMode, DateRangeOptions } from '@wix/patterns/core';\nimport { BaseCollectionConfig } from './types';\nimport {\n ActionCellConfig,\n BulkActionsConfig,\n CollectionPageOnRowClickActionConfig,\n CollectionPagePrimaryActions,\n CollectionPageSecondaryActions,\n} from './actions';\n\nexport interface CollectionPageTitle {\n text: string;\n hideTotal?: boolean;\n}\n\nexport interface CollectionPageSubtitle {\n text: string;\n learnMore?: {\n url: string;\n label?: string;\n };\n}\n\nexport interface CollectionPageConfig {\n route: {\n path: string;\n };\n title: CollectionPageTitle;\n subtitle?: CollectionPageSubtitle;\n actions?: {\n primaryActions?: CollectionPagePrimaryActions;\n secondaryActions?: CollectionPageSecondaryActions;\n };\n components: ComponentConfig[];\n}\n\nexport interface ComponentConfig extends BaseCollectionComponentConfig {\n layout: LayoutItemConfig[];\n}\n\nexport interface LayoutItemConfig {\n type: 'Table' | 'Grid';\n table?: TableSpecificConfig;\n grid?: GridSpecificConfig;\n}\n\nexport type ColumnsConfig = Column[];\n\nexport interface TableSpecificConfig {\n columns: ColumnsConfig;\n customColumns?: {\n enabled: boolean;\n };\n stickyColumns?: number;\n onRowClick?: CollectionPageOnRowClickActionConfig;\n}\n\nexport interface GridSpecificConfig {\n item: GridItem;\n}\n\nexport interface TableConfig\n extends BaseCollectionComponentConfig,\n TableSpecificConfig {}\nexport interface GridConfig\n extends BaseCollectionComponentConfig,\n GridSpecificConfig {}\nexport interface TableGridSwitchConfig\n extends BaseCollectionComponentConfig,\n TableSpecificConfig,\n GridSpecificConfig {}\n\nexport type CollectionConfig = BaseCollectionConfig & {\n limit?: number;\n reflectQueryInUrl?: boolean;\n selectAllScope?: 'page' | 'all';\n selectionUpdateMode?: 'preserve' | 'clear';\n};\n\nexport interface BaseCollectionComponentConfig {\n collection: CollectionConfig;\n entityPageId?: string;\n search?: { shown?: boolean };\n toolbarTitle?: ToolbarTitle;\n actionCell?: ActionCellConfig;\n emptyState?: EmptyState;\n filters?: FiltersConfig;\n bulkActionToolbar?: BulkActionsConfig;\n}\n\nexport interface ToolbarTitle {\n title: string;\n subtitle?: {\n text: string;\n info?: {\n content: {\n text: string;\n link?: {\n url: string;\n label: string;\n };\n };\n };\n learnMore?: {\n url: string;\n label?: string;\n };\n };\n showTotal?: boolean;\n itemsLimit?: number;\n}\n\nexport interface Column {\n id: string;\n name: string;\n width: string;\n sortable?: boolean;\n defaultSortOrder?: 'asc' | 'desc';\n sortMode?: 'asc' | 'desc';\n defaultHidden?: boolean;\n hiddenFromCustomColumnsSelection?: boolean;\n hideable?: boolean;\n reorderDisabled?: boolean;\n}\n\nexport interface GridItem {\n titleFieldId: string;\n subtitleFieldId?: string;\n imageFieldId?: string;\n cardContentMode?: 'full' | 'title' | 'empty'; // Footer is not supported in auto-patterns\n imagePlacement?: 'top' | 'side';\n}\n\nexport interface EmptyState {\n title?: string;\n subtitle?: string;\n image?: {\n id: string;\n };\n addNewCta?: {\n id?: string;\n text?: string;\n };\n customCta?: {\n id?: string;\n };\n}\n\nexport interface FilterOption {\n value: string;\n label: string;\n}\n\nexport type FilterSelectionMode = 'single' | 'multiple';\nexport type FilterOptionType =\n | 'checkbox'\n | 'inlineCheckbox'\n | 'radio'\n | 'select';\n\nexport enum ComponentTypeEnum {\n SINGLE = 'single',\n MULTI_SELECT = 'multi-select',\n RADIO_GROUP = 'radio-group',\n NUMBER = 'number',\n DATE_RANGE = 'date-range',\n}\n\nexport type FilterItems = Filter[];\nexport interface FiltersConfig {\n items: FilterItems;\n maxInlineFilters?: CollectionToolbarFiltersProps['inline'];\n panelTitle?: string;\n}\n\nexport interface BaseOptionsFilterConfig {\n selectionMode: FilterSelectionMode;\n}\n\nexport interface DateFilterConfig {\n mode?: DateRangeFilterMode;\n presets?: DateRangeOptions;\n includeTime?: boolean;\n}\n\nexport interface NumberFilterConfig {\n min?: number;\n max?: number;\n allowedDecimals?: boolean;\n}\n\nexport interface BooleanFilterConfig {\n trueLabel?: string;\n falseLabel?: string;\n}\n\nexport interface EnumFilterConfig extends BaseOptionsFilterConfig {\n options: FilterOption[];\n optionType?: FilterOptionType;\n}\n\nexport interface DynamicOptionsFilterConfig extends BaseOptionsFilterConfig {}\n\nexport interface Filter {\n id: string;\n fieldId: string;\n displayName?: string;\n sectionTitle?: string;\n openByDefault?: boolean;\n tagLabel?: string;\n numberConfig?: NumberFilterConfig;\n dateConfig?: DateFilterConfig;\n booleanConfig?: BooleanFilterConfig;\n enumConfig?: EnumFilterConfig;\n dynamicOptionsConfig?: DynamicOptionsFilterConfig;\n}\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"names":["ComponentTypeEnum","exports"],"sources":["../../../src/types/CollectionPageConfig.ts"],"sourcesContent":["import { CollectionToolbarFiltersProps } from '@wix/patterns';\nimport { DateRangeFilterMode, DateRangeOptions } from '@wix/patterns/core';\nimport { BaseCollectionConfig } from './types';\nimport {\n ActionCellConfig,\n BulkActionsConfig,\n CollectionPageOnRowClickActionConfig,\n CollectionPagePrimaryActions,\n CollectionPageSecondaryActions,\n} from './actions';\n\nexport interface CollectionPageTitle {\n text: string;\n hideTotal?: boolean;\n}\n\nexport interface CollectionPageSubtitle {\n text: string;\n learnMore?: {\n url: string;\n label?: string;\n };\n}\n\nexport interface CollectionPageConfig {\n route: {\n path: string;\n };\n title: CollectionPageTitle;\n subtitle?: CollectionPageSubtitle;\n actions?: {\n primaryActions?: CollectionPagePrimaryActions;\n secondaryActions?: CollectionPageSecondaryActions;\n };\n components: ComponentConfig[];\n}\n\nexport interface ComponentConfig extends BaseCollectionComponentConfig {\n layout: LayoutItemConfig[];\n}\n\nexport interface LayoutItemConfig {\n type: 'Table' | 'Grid';\n table?: TableSpecificConfig;\n grid?: GridSpecificConfig;\n}\n\nexport type ColumnsConfig = Column[];\n\nexport interface TableSpecificConfig {\n columns: ColumnsConfig;\n customColumns?: {\n enabled: boolean;\n };\n stickyColumns?: number;\n onRowClick?: CollectionPageOnRowClickActionConfig;\n sections?: {\n id: string;\n };\n}\n\nexport interface GridSpecificConfig {\n item: GridItem;\n}\n\nexport interface TableConfig\n extends BaseCollectionComponentConfig,\n TableSpecificConfig {}\nexport interface GridConfig\n extends BaseCollectionComponentConfig,\n GridSpecificConfig {}\nexport interface TableGridSwitchConfig\n extends BaseCollectionComponentConfig,\n TableSpecificConfig,\n GridSpecificConfig {}\n\nexport type CollectionConfig = BaseCollectionConfig & {\n limit?: number;\n reflectQueryInUrl?: boolean;\n selectAllScope?: 'page' | 'all';\n selectionUpdateMode?: 'preserve' | 'clear';\n};\n\nexport interface BaseCollectionComponentConfig {\n collection: CollectionConfig;\n entityPageId?: string;\n search?: { shown?: boolean };\n toolbarTitle?: ToolbarTitle;\n actionCell?: ActionCellConfig;\n emptyState?: EmptyState;\n filters?: FiltersConfig;\n bulkActionToolbar?: BulkActionsConfig;\n}\n\nexport interface ToolbarTitle {\n title: string;\n subtitle?: {\n text: string;\n info?: {\n content: {\n text: string;\n link?: {\n url: string;\n label: string;\n };\n };\n };\n learnMore?: {\n url: string;\n label?: string;\n };\n };\n showTotal?: boolean;\n itemsLimit?: number;\n}\n\nexport interface Column {\n id: string;\n name: string;\n width: string;\n sortable?: boolean;\n defaultSortOrder?: 'asc' | 'desc';\n sortMode?: 'asc' | 'desc';\n defaultHidden?: boolean;\n hiddenFromCustomColumnsSelection?: boolean;\n hideable?: boolean;\n reorderDisabled?: boolean;\n}\n\nexport interface GridItem {\n titleFieldId: string;\n subtitleFieldId?: string;\n imageFieldId?: string;\n cardContentMode?: 'full' | 'title' | 'empty'; // Footer is not supported in auto-patterns\n imagePlacement?: 'top' | 'side';\n}\n\nexport interface EmptyState {\n title?: string;\n subtitle?: string;\n image?: {\n id: string;\n };\n addNewCta?: {\n id?: string;\n text?: string;\n };\n customCta?: {\n id?: string;\n };\n}\n\nexport interface FilterOption {\n value: string;\n label: string;\n}\n\nexport type FilterSelectionMode = 'single' | 'multiple';\nexport type FilterOptionType =\n | 'checkbox'\n | 'inlineCheckbox'\n | 'radio'\n | 'select';\n\nexport enum ComponentTypeEnum {\n SINGLE = 'single',\n MULTI_SELECT = 'multi-select',\n RADIO_GROUP = 'radio-group',\n NUMBER = 'number',\n DATE_RANGE = 'date-range',\n}\n\nexport type FilterItems = Filter[];\nexport interface FiltersConfig {\n items: FilterItems;\n maxInlineFilters?: CollectionToolbarFiltersProps['inline'];\n panelTitle?: string;\n}\n\nexport interface BaseOptionsFilterConfig {\n selectionMode: FilterSelectionMode;\n}\n\nexport interface DateFilterConfig {\n mode?: DateRangeFilterMode;\n presets?: DateRangeOptions;\n includeTime?: boolean;\n}\n\nexport interface NumberFilterConfig {\n min?: number;\n max?: number;\n allowedDecimals?: boolean;\n}\n\nexport interface BooleanFilterConfig {\n trueLabel?: string;\n falseLabel?: string;\n}\n\nexport interface EnumFilterConfig extends BaseOptionsFilterConfig {\n options: FilterOption[];\n optionType?: FilterOptionType;\n}\n\nexport interface DynamicOptionsFilterConfig extends BaseOptionsFilterConfig {}\n\nexport interface Filter {\n id: string;\n fieldId: string;\n displayName?: string;\n sectionTitle?: string;\n openByDefault?: boolean;\n tagLabel?: string;\n numberConfig?: NumberFilterConfig;\n dateConfig?: DateFilterConfig;\n booleanConfig?: BooleanFilterConfig;\n enumConfig?: EnumFilterConfig;\n dynamicOptionsConfig?: DynamicOptionsFilterConfig;\n}\n"],"mappings":";;;;IAoKYA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../../src/types/actions/collectionPageActions.ts"],"sourcesContent":["import {\n CustomActionModalProps,\n CustomActionParams,\n ResolvedAction,\n} from '../../exports/types';\nimport {\n CreateActionConfig,\n CustomActionConfig,\n DividerActionConfig,\n} from './base';\n\nexport type CollectionPageActionConfig = (\n | CreateActionConfig\n | CustomActionConfig\n) & {\n collection
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/types/actions/collectionPageActions.ts"],"sourcesContent":["import {\n CustomActionModalProps,\n CustomActionParams,\n ResolvedAction,\n} from '../../exports/types';\nimport {\n CreateActionConfig,\n CustomActionConfig,\n DividerActionConfig,\n} from './base';\n\nexport type CollectionPageActionConfig = (\n | CreateActionConfig\n | CustomActionConfig\n) & {\n collection:\n | {\n collectionId: string;\n entityTypeSource: 'cms';\n custom?: never;\n }\n | {\n collectionId: string;\n entityTypeSource: 'custom';\n custom: {\n id: string;\n };\n };\n};\n\ntype CollectionPageAction = {\n type: 'action';\n action: {\n item: CollectionPageActionConfig;\n };\n menu?: never;\n};\n\ntype CollectionPageMenu = {\n type: 'menu';\n menu: {\n label: string;\n items: (CollectionPageActionConfig | DividerActionConfig)[];\n };\n action?: never;\n};\n\nexport type CollectionPagePrimaryActions =\n | CollectionPageAction\n | CollectionPageMenu;\n\nexport type CollectionPageSecondaryActions =\n | CollectionPageAction\n | CollectionPageMenu;\n\nexport interface CollectionPageActionParams {\n collectionId: string;\n}\n\nexport type CustomActionCollectionPageActionParams =\n CustomActionParams<CollectionPageActionParams>;\n\nexport type CustomActionCollectionPageActionResolver = (\n params: CustomActionCollectionPageActionParams,\n) => ResolvedAction;\n\nexport interface CustomActionCollectionPageActionModalProps\n extends CustomActionModalProps {\n actionParams: CollectionPageActionParams;\n}\n\nexport type CollectionPageOnRowClickActionConfig = CustomActionConfig & {\n item: any;\n};\n\nexport interface CollectionPageActionOnRowClickParams {\n item: any;\n}\n\nexport type CustomActionCollectionPageActionOnRowClickParams =\n CustomActionParams<CollectionPageActionOnRowClickParams>;\n\nexport type CustomActionCollectionPageActionOnRowClickResolver = (\n params: CustomActionCollectionPageActionOnRowClickParams,\n) => ResolvedAction;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../src/types/types.ts"],"sourcesContent":["import { EntityPageConfig } from './EntityPageConfig';\nimport { CollectionPageConfig } from './CollectionPageConfig';\n\ninterface BaseCollectionConfigCommon {\n collectionId: string;\n}\n\ninterface CMSCollectionConfig extends BaseCollectionConfigCommon {\n entityTypeSource: 'cms';\n custom?: never;\n}\n\ninterface
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/types/types.ts"],"sourcesContent":["import { EntityPageConfig } from './EntityPageConfig';\nimport { CollectionPageConfig } from './CollectionPageConfig';\n\ninterface BaseCollectionConfigCommon {\n collectionId: string;\n}\n\ninterface CMSCollectionConfig extends BaseCollectionConfigCommon {\n entityTypeSource: 'cms';\n custom?: never;\n}\n\ninterface CustomCollectionConfig extends BaseCollectionConfigCommon {\n entityTypeSource: 'custom';\n custom: {\n id: string;\n };\n}\n\nexport type BaseCollectionConfig = CMSCollectionConfig | CustomCollectionConfig;\n\nexport type PatternsFieldType =\n | 'SHORT_TEXT'\n | 'LONG_TEXT'\n | 'NUMBER'\n | 'BOOLEAN'\n | 'DATE'\n | 'DATETIME'\n | 'URL'\n | 'ARRAY'\n | 'REFERENCE'\n | 'IMAGE';\n\nexport interface AppConfig {\n pages: PageConfig[];\n}\n\nexport interface BasePageConfig {\n id: string;\n appMainPage?: boolean;\n}\n\nexport interface CollectionPageConfigType extends BasePageConfig {\n type: 'collectionPage';\n collectionPage: CollectionPageConfig;\n entityPage?: never;\n}\n\nexport interface EntityPageConfigType extends BasePageConfig {\n type: 'entityPage';\n entityPage: EntityPageConfig;\n collectionPage?: never;\n}\n\nexport type PageConfig = CollectionPageConfigType | EntityPageConfigType;\n\nexport type EntityProps = { [key: string]: any };\n\nexport interface IMenuItem<T extends EntityProps = any> {\n item: T;\n}\nexport interface IColumnValue<T> {\n value: T;\n row: Record<string, any>;\n}\n\nexport type QueryOperator =\n | 'CONTAINS'\n | 'ENDS_WITH'\n | 'EQ'\n | 'EXISTS'\n | 'GT'\n | 'GTE'\n | 'HAS_ALL'\n | 'HAS_SOME'\n | 'LT'\n | 'LTE'\n | 'NE'\n | 'STARTS_WITH'\n | 'URLIZED';\n\ninterface BaseField {\n id: string;\n displayName: string;\n validation?: {\n numberRange?: NumberRange;\n stringLengthRange?: StringLengthRange;\n required: boolean;\n };\n capabilities: {\n supportedQueryOperators: QueryOperator[];\n sortable: boolean;\n };\n}\n\nexport interface ReferenceField extends BaseField {\n type: 'REFERENCE';\n referenceMetadata: {\n referencedCollectionId: string;\n };\n}\n\nexport interface NonReferenceField extends BaseField {\n type: Exclude<PatternsFieldType, 'REFERENCE'>;\n}\n\nexport type Field = ReferenceField | NonReferenceField;\n\nexport interface NumberRange {\n min?: number;\n max?: number;\n}\nexport interface StringLengthRange {\n minLength?: number;\n maxLength?: number;\n}\n\nexport interface Query {\n limit: number;\n offset: number;\n page: number;\n search?: string;\n cursor?: string | null;\n filters: Record<string, any>;\n sort?: {\n fieldName: string;\n order: 'asc' | 'desc';\n }[];\n}\n\nexport interface SchemaConfig {\n id: string;\n fields: Record<string, Field | undefined>;\n displayField: string;\n idField: string;\n actions: {\n get: (entityId: string) => Promise<any>;\n create: (newEntity: Partial<any>) => Promise<any>;\n update: (updatedEntity: any) => Promise<any>;\n delete: (entityId: string) => Promise<any>;\n bulkDelete: (entityIds: string[]) => Promise<any>;\n find: (\n query: Query,\n options?: {\n searchableFieldIds?: string[];\n filterFieldMapping?: Record<string, { fieldId: string }>;\n },\n ) => Promise<{ items: any[]; total: number }>;\n };\n}\n"],"mappings":"","ignoreList":[]}
|
package/dist/docs/action_cell.md
CHANGED
|
@@ -99,7 +99,7 @@ Custom actions execute JavaScript code that you define. These actions receive pa
|
|
|
99
99
|
├── page.tsx
|
|
100
100
|
└── components/
|
|
101
101
|
└── actions/
|
|
102
|
-
├── index.tsx // Exports
|
|
102
|
+
├── index.tsx // Exports useActions hook
|
|
103
103
|
└── downloadPetDetails.tsx // Your custom action (name = action id)
|
|
104
104
|
```
|
|
105
105
|
|
|
@@ -142,12 +142,19 @@ Custom actions execute JavaScript code that you define. These actions receive pa
|
|
|
142
142
|
|
|
143
143
|
3. Export your action in `actions/index.tsx`:
|
|
144
144
|
```typescript
|
|
145
|
-
|
|
145
|
+
import { downloadPetDetails } from './downloadPetDetails';
|
|
146
|
+
|
|
147
|
+
export const useActions = () => {
|
|
148
|
+
// You can access React context and other hooks here
|
|
149
|
+
return {
|
|
150
|
+
downloadPetDetails
|
|
151
|
+
};
|
|
152
|
+
};
|
|
146
153
|
```
|
|
147
154
|
|
|
148
|
-
**Important:** Every time you create a new action, you must
|
|
155
|
+
**Important:** Every time you create a new action, you must import it and add it to the `useActions` hook return object in this `index.tsx` file. For example, if you create `sendEmail.tsx`, you must add `import { sendEmail } from './sendEmail';` and include `sendEmail` in the return object.
|
|
149
156
|
|
|
150
|
-
4. Configure the action in your
|
|
157
|
+
4. Configure the action in your TypeScript configuration:
|
|
151
158
|
```ts
|
|
152
159
|
{
|
|
153
160
|
"id": "downloadPetDetails", // MUST match the function name exactly
|
|
@@ -158,11 +165,17 @@ Custom actions execute JavaScript code that you define. These actions receive pa
|
|
|
158
165
|
|
|
159
166
|
5. Register your action in the `PatternsWizardOverridesProvider`:
|
|
160
167
|
```typescript
|
|
161
|
-
import
|
|
168
|
+
import { useActions } from '../components/actions';
|
|
169
|
+
|
|
170
|
+
export default function YourPage() {
|
|
171
|
+
const actions = useActions();
|
|
162
172
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
173
|
+
return (
|
|
174
|
+
<PatternsWizardOverridesProvider value={{ actions }}>
|
|
175
|
+
<AutoPatternsApp configuration={config} />
|
|
176
|
+
</PatternsWizardOverridesProvider>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
166
179
|
```
|
|
167
180
|
|
|
168
181
|
### Key Points for Custom Actions:
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## ⚠️ Configuration Rules
|
|
4
4
|
|
|
5
|
-
- **Configuration must come only from a
|
|
5
|
+
- **Configuration must come only from a TypeScript file** - never inline or from other sources
|
|
6
|
+
- **Always use proper TypeScript typing**: `export const config: AppConfig = { ... }`
|
|
6
7
|
- **DO NOT fill optional fields unless explicitly requested** - leave optional properties undefined to avoid unnecessary complexity
|
|
7
8
|
- **After each configuration change, verify that the configuration strictly aligns with the structure described below** - any configuration entries not defined in this structure must be removed
|
|
8
9
|
- **When generating config for the first time, select up to 3 columns from the schema that best represent the entity**
|