@wavemaker-ai/react-runtime 1.0.0-rc.647684 → 12.0.0-rc.335
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/components/advanced/carousel/index.d.ts +1 -0
- package/components/advanced/carousel/template.d.ts +1 -0
- package/components/advanced/login/index.d.ts +1 -0
- package/components/advanced/marquee/index.d.ts +1 -0
- package/components/basic/anchor/index.d.ts +1 -0
- package/components/basic/anchor/index.js +3 -5
- package/components/basic/audio/index.d.ts +1 -0
- package/components/basic/html/index.d.ts +1 -0
- package/components/basic/icon/index.d.ts +1 -0
- package/components/basic/iframe/index.d.ts +1 -0
- package/components/basic/label/index.d.ts +1 -0
- package/components/basic/picture/index.d.ts +1 -0
- package/components/basic/progress-bar/index.d.ts +1 -0
- package/components/basic/progress-circle/index.d.ts +1 -0
- package/components/basic/richtexteditor/index.d.ts +3 -0
- package/components/basic/search/index.js +5 -4
- package/components/basic/search/utils.d.ts +1 -0
- package/components/basic/search/utils.js +9 -0
- package/components/basic/spinner/index.d.ts +1 -0
- package/components/basic/tile/index.d.ts +1 -0
- package/components/basic/tree/index.d.ts +1 -0
- package/components/basic/video/index.d.ts +1 -0
- package/components/chart/index.d.ts +1 -0
- package/components/common/index.d.ts +2 -0
- package/components/common/index.js +2 -0
- package/components/common/partial-content-wrapper.d.ts +15 -0
- package/components/common/partial-content-wrapper.js +11 -0
- package/components/container/accordion/accordion-pane/index.d.ts +1 -0
- package/components/container/accordion/index.d.ts +1 -0
- package/components/container/index.d.ts +4 -0
- package/components/container/index.js +38 -11
- package/components/container/layout-grid/grid-column/index.d.ts +1 -0
- package/components/container/layout-grid/grid-row/index.d.ts +1 -0
- package/components/container/layout-grid/index.d.ts +1 -0
- package/components/container/layout-grid/index.js +1 -1
- package/components/container/linear-layout/index.d.ts +1 -0
- package/components/container/linear-layout/linear-layout-item/index.d.ts +1 -0
- package/components/container/panel/index.d.ts +1 -0
- package/components/container/props.d.ts +1 -0
- package/components/container/repeat-template/index.d.ts +1 -0
- package/components/container/repeat-template/index.js +1 -1
- package/components/container/tabs/index.d.ts +1 -0
- package/components/container/tabs/index.js +12 -8
- package/components/container/tabs/tab-pane/index.d.ts +1 -0
- package/components/container/tabs/tab-pane/index.js +2 -2
- package/components/container/wizard/index.d.ts +2 -0
- package/components/container/wizard/index.js +92 -43
- package/components/container/wizard/props.d.ts +2 -2
- package/components/container/wizard/wizard-step/index.d.ts +1 -0
- package/components/data/card/card-actions/index.d.ts +1 -0
- package/components/data/card/card-content/index.d.ts +1 -0
- package/components/data/card/card-footer/index.d.ts +1 -0
- package/components/data/card/index.d.ts +1 -0
- package/components/data/form/base-form/hooks/useFormOperations.d.ts +1 -1
- package/components/data/form/base-form/hooks/useFormOperations.js +5 -2
- package/components/data/form/base-form/index.js +10 -14
- package/components/data/form/base-form/props.d.ts +1 -0
- package/components/data/form/dynamic-fields/WmxDynamicFormField.js +9 -23
- package/components/data/form/form-action/index.d.ts +2 -0
- package/components/data/form/form-controller/props.d.ts +2 -0
- package/components/data/form/form-controller/utils.js +3 -2
- package/components/data/form/form-controller/validation-contrustor.js +112 -1
- package/components/data/form/form-controller/withFormController.js +16 -3
- package/components/data/form/form-field/index.js +38 -11
- package/components/data/form/form-field/props.d.ts +8 -2
- package/components/data/list/components/ListItemWithTemplate.js +1 -1
- package/components/data/list/index.d.ts +2 -0
- package/components/data/list/index.js +5 -10
- package/components/data/pagination/hooks/usePagination.js +6 -6
- package/components/data/table/components/EditableCell.js +47 -24
- package/components/data/table/components/FieldValidationError.js +1 -1
- package/components/data/table/components/RowExpansionButton.js +5 -1
- package/components/data/table/components/TableBody.js +2 -0
- package/components/data/table/components/TableHeader.js +12 -4
- package/components/data/table/hooks/useFormWidget.js +13 -2
- package/components/data/table/hooks/usePanelStructure.js +6 -1
- package/components/data/table/hooks/useResponsiveColumns.d.ts +1 -0
- package/components/data/table/hooks/useRowHandlers.js +1 -1
- package/components/data/table/hooks/useRowSelection.js +65 -4
- package/components/data/table/hooks/useTableData.js +10 -2
- package/components/data/table/hooks/useTableEdit.d.ts +1 -1
- package/components/data/table/hooks/useTableEdit.js +115 -75
- package/components/data/table/hooks/useTableEditForms.d.ts +25 -0
- package/components/data/table/hooks/useTableEditForms.js +30 -0
- package/components/data/table/index.d.ts +2 -0
- package/components/data/table/index.js +82 -45
- package/components/data/table/live-table/index.d.ts +1 -0
- package/components/data/table/props.d.ts +43 -23
- package/components/data/table/table-action/index.d.ts +1 -0
- package/components/data/table/table-column/index.d.ts +1 -0
- package/components/data/table/table-row/index.d.ts +1 -0
- package/components/data/table/table-row-action/index.d.ts +1 -0
- package/components/data/table/utils/buildSelectionColumns.js +19 -24
- package/components/data/table/utils/columnProxy.d.ts +7 -1
- package/components/data/table/utils/columnProxy.js +21 -1
- package/components/data/table/utils/columnValidation.d.ts +19 -0
- package/components/data/table/utils/columnValidation.js +76 -0
- package/components/data/table/utils/constants.d.ts +2 -0
- package/components/data/table/utils/constants.js +2 -0
- package/components/data/table/utils/crud-handlers.js +3 -1
- package/components/data/table/utils/expansionColumn.js +1 -1
- package/components/data/table/utils/index.d.ts +14 -15
- package/components/data/table/utils/index.js +18 -85
- package/components/data/table/utils/selectionUtils.d.ts +12 -0
- package/components/data/table/utils/selectionUtils.js +23 -5
- package/components/dialogs/alert-dialog/index.d.ts +2 -0
- package/components/dialogs/confirm-dialog/index.d.ts +2 -0
- package/components/dialogs/dialog/index.d.ts +2 -0
- package/components/dialogs/dialog-actions/index.d.ts +1 -0
- package/components/dialogs/dialog-body/index.d.ts +1 -0
- package/components/dialogs/dialog-content/index.d.ts +1 -0
- package/components/dialogs/dialog-header/index.d.ts +1 -0
- package/components/dialogs/iframe-dialog/index.d.ts +2 -0
- package/components/dialogs/login-dialog/index.d.ts +2 -0
- package/components/dialogs/page-dialog/index.d.ts +2 -0
- package/components/dialogs/withDialogWrapper.js +12 -2
- package/components/form/button/index.d.ts +1 -0
- package/components/form/button-group/index.d.ts +1 -0
- package/components/input/calendar/index.d.ts +2 -0
- package/components/input/chips/index.d.ts +3 -0
- package/components/input/color-picker/index.d.ts +3 -0
- package/components/input/composite/index.d.ts +1 -0
- package/components/input/composite/index.js +32 -6
- package/components/input/currency/index.d.ts +1 -0
- package/components/input/default/checkbox/index.d.ts +3 -0
- package/components/input/default/checkboxset/index.d.ts +3 -0
- package/components/input/default/radioset/index.d.ts +3 -0
- package/components/input/default/switch/index.d.ts +3 -0
- package/components/input/epoch/date/index.d.ts +1 -0
- package/components/input/epoch/datetime/index.d.ts +1 -0
- package/components/input/epoch/datetime/index.js +13 -3
- package/components/input/epoch/time/index.d.ts +1 -0
- package/components/input/fileupload/index.d.ts +1 -0
- package/components/input/fileupload/index.js +2 -1
- package/components/input/number/index.d.ts +3 -0
- package/components/input/rating/index.d.ts +3 -0
- package/components/input/select/index.d.ts +1 -0
- package/components/input/slider/index.d.ts +3 -0
- package/components/input/text/index.d.ts +3 -0
- package/components/input/text/index.js +9 -2
- package/components/input/textarea/index.d.ts +3 -0
- package/components/input/upload/index.d.ts +3 -0
- package/components/layout/footer/index.js +4 -2
- package/components/layout/footer/props.d.ts +1 -0
- package/components/layout/header/index.js +29 -3
- package/components/layout/header/props.d.ts +1 -0
- package/components/layout/leftnav/index.js +22 -6
- package/components/layout/leftnav/props.d.ts +1 -0
- package/components/layout/leftnav/utils/page-class-util.d.ts +1 -0
- package/components/layout/leftnav/utils/page-class-util.js +4 -3
- package/components/layout/rightnav/index.js +4 -2
- package/components/layout/rightnav/props.d.ts +1 -0
- package/components/layout/topnav/index.js +4 -2
- package/components/layout/topnav/props.d.ts +1 -0
- package/components/navbar/index.d.ts +1 -0
- package/components/navbar/index.js +32 -7
- package/components/navbar/nav-item/index.d.ts +1 -0
- package/components/navigation/breadcrumb/index.d.ts +1 -0
- package/components/navigation/menu/index.d.ts +1 -0
- package/components/navigation/menu/index.js +19 -11
- package/components/navigation/menu/props.d.ts +1 -0
- package/components/navigation/popover/index.d.ts +1 -0
- package/components/navigation/popover/index.js +15 -3
- package/components/page/index.js +60 -19
- package/components/page/page-context.d.ts +4 -0
- package/components/page/partial/index.d.ts +1 -0
- package/context/PopoverContext.d.ts +5 -0
- package/context/PopoverContext.js +5 -0
- package/context/WidgetProvider.js +9 -2
- package/core/proxy-service.d.ts +2 -0
- package/core/proxy-service.js +132 -22
- package/higherOrder/BaseApp.js +3 -2
- package/higherOrder/BasePage.js +4 -10
- package/higherOrder/props.d.ts +1 -0
- package/higherOrder/useActivePageReactivity.js +1 -4
- package/higherOrder/withBaseWrapper.js +12 -3
- package/hooks/useHttp.d.ts +14 -4
- package/hooks/useHttp.js +47 -9
- package/package-lock.json +332 -325
- package/package.json +3 -3
- package/runtime-dynamic/App.js +21 -2
- package/runtime-dynamic/app-initializer.js +8 -1
- package/runtime-dynamic/components/PageWrapper.js +1 -1
- package/runtime-dynamic/components/PrefabPreview.js +1 -1
- package/runtime-dynamic/components/partial-content.js +17 -1
- package/runtime-dynamic/factories/build-base-page-like-component.js +11 -7
- package/runtime-dynamic/factories/dynamic-component.js +5 -10
- package/runtime-dynamic/main.d.ts +1 -0
- package/runtime-dynamic/main.js +9 -1
- package/runtime-dynamic/routes.js +17 -8
- package/runtime-dynamic/services/compile-render.js +7 -0
- package/runtime-dynamic/services/css-scoping.d.ts +1 -1
- package/runtime-dynamic/services/css-scoping.js +2 -2
- package/runtime-dynamic/services/variable-factory.js +2 -1
- package/runtime-dynamic/services/variable-transpiler.js +4 -1
- package/runtime-dynamic/wmx-shared.d.ts +40 -0
- package/runtime-dynamic/wmx-shared.js +33 -0
- package/utils/page-params-util.js +22 -1
- package/utils/partial-host-util.d.ts +40 -0
- package/utils/partial-host-util.js +41 -0
- package/utils/style-utils.js +1 -1
- package/utils/wmx.utils.d.ts +0 -1
- package/utils/wmx.utils.js +0 -25
- package/variables/crud-variable.d.ts +10 -0
- package/variables/crud-variable.js +53 -2
- package/variables/live-variable.d.ts +1 -0
- package/variables/live-variable.js +2 -1
- package/variables/model-variable.d.ts +2 -0
- package/variables/model-variable.js +14 -0
- package/variables/operation-params.d.ts +29 -0
- package/variables/operation-params.js +69 -0
- package/variables/service-variable.d.ts +9 -0
- package/variables/service-variable.js +21 -2
- package/components/data/table/utils/validation.d.ts +0 -13
- package/components/data/table/utils/validation.js +0 -82
|
@@ -9,7 +9,9 @@ import {
|
|
|
9
9
|
internalBoundNodeMap
|
|
10
10
|
} from "@wavemaker-ai/variables";
|
|
11
11
|
import { VariableEvents, isStaticParamVariable } from "./base-variable";
|
|
12
|
-
import { isEqual, isUndefined, isFunction, forEach, isEmpty, isArray, set } from "lodash-es";
|
|
12
|
+
import { isEqual, isUndefined, isFunction, forEach, isEmpty, isArray, set, merge } from "lodash-es";
|
|
13
|
+
import { metadataService } from "./metadata.service";
|
|
14
|
+
import { resolveOperationParams } from "./operation-params";
|
|
13
15
|
import httpService from "../hooks/useHttp";
|
|
14
16
|
import { deepCopy } from "../core/util";
|
|
15
17
|
import Formatters from "../core/formatters";
|
|
@@ -63,12 +65,26 @@ class CrudVariable extends _CrudVariable {
|
|
|
63
65
|
EventNotifier.ROOT.notify("SERVICE_ERROR", [args.variable, args.data, args.options]);
|
|
64
66
|
}
|
|
65
67
|
return config.onError && config.onError(args.variable, args.data, args.options);
|
|
66
|
-
}
|
|
68
|
+
},
|
|
69
|
+
// Outside preview mode useHttp's send() calls variable.invokeHttp — without this the
|
|
70
|
+
// generated glue is dropped here and every CRUD call throws "invokeHttp is not a function".
|
|
71
|
+
invokeHttp: (config == null ? void 0 : config.invokeHttp) || void 0
|
|
67
72
|
};
|
|
68
73
|
super(variableConfig);
|
|
69
74
|
this.config = config;
|
|
70
75
|
__publicField(this, "params", {});
|
|
71
76
|
__publicField(this, "filters", {});
|
|
77
|
+
/**
|
|
78
|
+
* The by-name params a generated invokeHttp receives. Same field name ServiceVariable uses, so
|
|
79
|
+
* useHttp's call site needs no per-kind chain. NOT `lastInvokedParams`: that name is
|
|
80
|
+
* ServiceVariable's RAW provider snapshot (compared against by invokeOnParamChange), and it is
|
|
81
|
+
* private there — reading it cross-object would also be reading a different thing.
|
|
82
|
+
*/
|
|
83
|
+
__publicField(this, "resolvedParams");
|
|
84
|
+
// Which CRUD operation this call is for. A CrudVariable maps to a SET of operations
|
|
85
|
+
// (list/create/update/delete) resolved per call, so a generated invokeHttp has to be told which
|
|
86
|
+
// one to dispatch to — unlike a ServiceVariable, which is always one fixed operation.
|
|
87
|
+
__publicField(this, "lastInvokedOperation");
|
|
72
88
|
this.dateFormatter = Formatters.get("toDate");
|
|
73
89
|
this.init();
|
|
74
90
|
}
|
|
@@ -79,6 +95,36 @@ class CrudVariable extends _CrudVariable {
|
|
|
79
95
|
r.value = filter[r.target];
|
|
80
96
|
});
|
|
81
97
|
}
|
|
98
|
+
captureLastInvokedParams(options, operation) {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
this.lastInvokedOperation = (_a = operation != null ? operation : options == null ? void 0 : options.operation) != null ? _a : "list";
|
|
101
|
+
let inputFields = merge({}, this.config.paramProvider(), this.dataBinding, this.params);
|
|
102
|
+
if (options) {
|
|
103
|
+
const overrides = (_b = options.inputFields) != null ? _b : options;
|
|
104
|
+
inputFields = merge({}, inputFields, overrides);
|
|
105
|
+
}
|
|
106
|
+
this.resolvedParams = this.resolveParams(inputFields, options);
|
|
107
|
+
}
|
|
108
|
+
// CrudVariableManager calls httpCall(requestParams, variable) with NO third argument (unlike
|
|
109
|
+
// Live/ServiceVariable), so a generated invokeHttp never receives this call's values by name.
|
|
110
|
+
// The manager does resolve them — onto operationInfo.parameters[].sampleValue in
|
|
111
|
+
// getMethodInfoForCrud — but keeps that local. Rebuild the same flat map from the same
|
|
112
|
+
// servicedefs entry, using the resolver shared with ServiceVariable.
|
|
113
|
+
resolveParams(inputFields, options) {
|
|
114
|
+
var _a, _b, _c, _d;
|
|
115
|
+
const defs = (_c = (_a = metadataService) == null ? void 0 : _a.getByCrudId) == null ? void 0 : _c.call(
|
|
116
|
+
_a,
|
|
117
|
+
this.config.crudOperationId,
|
|
118
|
+
(_b = this.getPrefabName) == null ? void 0 : _b.call(this)
|
|
119
|
+
);
|
|
120
|
+
const def = (defs || []).find((d) => (d == null ? void 0 : d.operationType) === this.lastInvokedOperation);
|
|
121
|
+
return resolveOperationParams({
|
|
122
|
+
parameters: (_d = def == null ? void 0 : def.wmServiceOperationInfo) == null ? void 0 : _d.parameters,
|
|
123
|
+
inputFields,
|
|
124
|
+
options,
|
|
125
|
+
config: this.config
|
|
126
|
+
});
|
|
127
|
+
}
|
|
82
128
|
invokeOnParamChange() {
|
|
83
129
|
const isStatic = isStaticParamVariable(this.config, this);
|
|
84
130
|
if (isStatic) return isStatic;
|
|
@@ -125,21 +171,25 @@ class CrudVariable extends _CrudVariable {
|
|
|
125
171
|
options = options || {};
|
|
126
172
|
options.filterFields = this.filters;
|
|
127
173
|
this.setFilterExpValue(this.filters);
|
|
174
|
+
this.captureLastInvokedParams(options, "list");
|
|
128
175
|
return super.listRecords(options, onSuccess, onError);
|
|
129
176
|
}
|
|
130
177
|
updateRecord(options, success, error) {
|
|
131
178
|
this.processBinding(this);
|
|
132
179
|
this.notify(VariableEvents.BEFORE_INVOKE, [this]);
|
|
180
|
+
this.captureLastInvokedParams(options, "update");
|
|
133
181
|
return super.updateRecord(options, success, error);
|
|
134
182
|
}
|
|
135
183
|
insertRecord(options, success, error) {
|
|
136
184
|
this.processBinding(this);
|
|
137
185
|
this.notify(VariableEvents.BEFORE_INVOKE, [this]);
|
|
186
|
+
this.captureLastInvokedParams(options, "create");
|
|
138
187
|
return super.insertRecord(options, success, error);
|
|
139
188
|
}
|
|
140
189
|
deleteRecord(options, success, error) {
|
|
141
190
|
this.processBinding(this);
|
|
142
191
|
this.notify(VariableEvents.BEFORE_INVOKE, [this]);
|
|
192
|
+
this.captureLastInvokedParams(options, "delete");
|
|
143
193
|
return super.deleteRecord(options, success, error);
|
|
144
194
|
}
|
|
145
195
|
processBindExp(d, variable) {
|
|
@@ -187,6 +237,7 @@ class CrudVariable extends _CrudVariable {
|
|
|
187
237
|
}
|
|
188
238
|
invoke(options, onSuccess, onError) {
|
|
189
239
|
this.processBinding(this);
|
|
240
|
+
this.captureLastInvokedParams(options);
|
|
190
241
|
return super.invoke(options, onSuccess, onError);
|
|
191
242
|
}
|
|
192
243
|
}
|
|
@@ -34,6 +34,7 @@ export interface LiveVariableConfig extends VariableConfig {
|
|
|
34
34
|
insertRecord: (options?: any, success?: any, error?: any) => Promise<any>;
|
|
35
35
|
deleteRecord: (options?: any, success?: any, error?: any) => Promise<any>;
|
|
36
36
|
notify: (event: VariableEvents, args: any) => void;
|
|
37
|
+
invokeHttp?: Function;
|
|
37
38
|
}
|
|
38
39
|
declare enum _LiveVariableEvents {
|
|
39
40
|
BEFORE_INVOKE = "beforeInvoke"
|
|
@@ -66,7 +66,8 @@ class LiveVariable extends _LiveVariable {
|
|
|
66
66
|
EventNotifier.ROOT.notify("SERVICE_ERROR", [args.variable, args.data, args.options]);
|
|
67
67
|
}
|
|
68
68
|
return config.onError && config.onError(args.variable, args.data, args.options);
|
|
69
|
-
}
|
|
69
|
+
},
|
|
70
|
+
invokeHttp: (config == null ? void 0 : config.invokeHttp) || void 0
|
|
70
71
|
};
|
|
71
72
|
super(variableConfig);
|
|
72
73
|
this.config = config;
|
|
@@ -8,5 +8,7 @@ export declare class ModelVariable extends ModelVariable_base {
|
|
|
8
8
|
constructor(config: VariableConfig);
|
|
9
9
|
invoke(params?: any, onSuccess?: Function, onError?: Function): any;
|
|
10
10
|
invokeOnParamChange(obj?: any, newVal?: any, oldVal?: any): Promise<this>;
|
|
11
|
+
addItem(value: any, options?: any): any;
|
|
12
|
+
removeItem(index: any, options?: any): any;
|
|
11
13
|
}
|
|
12
14
|
export {};
|
|
@@ -70,6 +70,20 @@ class ModelVariable extends _ModelVariable {
|
|
|
70
70
|
}
|
|
71
71
|
return Promise.resolve(this);
|
|
72
72
|
}
|
|
73
|
+
// addItem/removeItem (inherited from @wavemaker-ai/variables) mutate `dataSet` in place
|
|
74
|
+
// and return it, with no notification - that's precisely the bug being fixed here.
|
|
75
|
+
addItem(value, options) {
|
|
76
|
+
this.dataSet = Array.isArray(this.dataSet) ? [...this.dataSet] : __spreadValues({}, this.dataSet);
|
|
77
|
+
const result = super.addItem(value, options);
|
|
78
|
+
this.notify(VariableEvents.AFTER_INVOKE, [this, this.dataSet]);
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
removeItem(index, options) {
|
|
82
|
+
this.dataSet = Array.isArray(this.dataSet) ? [...this.dataSet] : __spreadValues({}, this.dataSet);
|
|
83
|
+
const result = super.removeItem(index, options);
|
|
84
|
+
this.notify(VariableEvents.AFTER_INVOKE, [this, this.dataSet]);
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
73
87
|
}
|
|
74
88
|
export {
|
|
75
89
|
ModelVariable
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Port of getEvaluatedOrderBy (not exported from the package root): the options order wins, and a
|
|
3
|
+
* field ordered by both is kept only once.
|
|
4
|
+
*/
|
|
5
|
+
export declare function evaluatedOrderBy(varOrder: any, optionsOrder: any): any;
|
|
6
|
+
export interface ResolveParamsInput {
|
|
7
|
+
/** The operation's declared parameters — `wmServiceOperationInfo.parameters`. */
|
|
8
|
+
parameters?: any[];
|
|
9
|
+
/** The values the variable already holds, keyed by param name. */
|
|
10
|
+
inputFields?: any;
|
|
11
|
+
/** The per-call options (`options.page`, `options.size`, `options.orderBy`). */
|
|
12
|
+
options?: any;
|
|
13
|
+
/** The variable's own config, for its defaults. */
|
|
14
|
+
config?: any;
|
|
15
|
+
/**
|
|
16
|
+
* ServiceVariableUtils' `isBodyTypeQueryOrProcedure` — `controller` in
|
|
17
|
+
* {QueryExecution, ProcedureExecution} and `operationType` in {put, post}. Its BODY branch
|
|
18
|
+
* assembles the body from the body param's declared children instead of reading the param's
|
|
19
|
+
* own value.
|
|
20
|
+
*/
|
|
21
|
+
isBodyTypeQueryOrProcedure?: boolean;
|
|
22
|
+
/** `wmServiceOperationInfo.definitions` — keyed by a param's `type`, listing its children. */
|
|
23
|
+
definitions?: Record<string, any>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns `inputFields` unchanged when the operation has no declared parameters — there is nothing
|
|
27
|
+
* to resolve against, so passing the raw fields through is strictly better than emptying them.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveOperationParams({ parameters, inputFields, options, config, isBodyTypeQueryOrProcedure, definitions, }: ResolveParamsInput): any;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { includes, isEmpty, join, map, remove, split, trim } from "lodash-es";
|
|
2
|
+
const PAGINATION_PARAMS = ["page", "size", "sort"];
|
|
3
|
+
function evaluatedOrderBy(varOrder, optionsOrder) {
|
|
4
|
+
if (!optionsOrder || isEmpty(optionsOrder)) {
|
|
5
|
+
return varOrder;
|
|
6
|
+
}
|
|
7
|
+
if (!varOrder) {
|
|
8
|
+
return optionsOrder;
|
|
9
|
+
}
|
|
10
|
+
const varFields = split(varOrder, ",");
|
|
11
|
+
const optionFields = map(split(optionsOrder, ","), (order) => split(trim(order), " ")[0]);
|
|
12
|
+
remove(varFields, (orderBy) => includes(optionFields, split(trim(orderBy), " ")[0]));
|
|
13
|
+
return join(split(optionsOrder, ","), ",") + (varFields.length ? "," + join(varFields, ",") : "");
|
|
14
|
+
}
|
|
15
|
+
function buildQueryProcedureBody(param, inputFields, definitions) {
|
|
16
|
+
const children = definitions == null ? void 0 : definitions[param == null ? void 0 : param.type];
|
|
17
|
+
const wrapped = inputFields == null ? void 0 : inputFields[param == null ? void 0 : param.name];
|
|
18
|
+
const values = wrapped && typeof wrapped === "object" && !Array.isArray(wrapped) ? wrapped : inputFields;
|
|
19
|
+
const declared = (children == null ? void 0 : children.length) ? children.filter((child) => !(child == null ? void 0 : child.readOnly)) : Object.keys(values != null ? values : {}).map((name) => ({ name }));
|
|
20
|
+
const body = {};
|
|
21
|
+
for (const child of declared) {
|
|
22
|
+
const value = values == null ? void 0 : values[child.name];
|
|
23
|
+
if (value !== void 0 && value !== "" && value !== null) {
|
|
24
|
+
body[child.name] = value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return body;
|
|
28
|
+
}
|
|
29
|
+
function resolveOperationParams({
|
|
30
|
+
parameters,
|
|
31
|
+
inputFields,
|
|
32
|
+
options,
|
|
33
|
+
config,
|
|
34
|
+
isBodyTypeQueryOrProcedure,
|
|
35
|
+
definitions
|
|
36
|
+
}) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
if (!(parameters == null ? void 0 : parameters.length)) {
|
|
39
|
+
return inputFields;
|
|
40
|
+
}
|
|
41
|
+
if (isBodyTypeQueryOrProcedure) {
|
|
42
|
+
const bodyParam = parameters.find((p) => (p == null ? void 0 : p.parameterType) === "body");
|
|
43
|
+
if (bodyParam) {
|
|
44
|
+
return buildQueryProcedureBody(bodyParam, inputFields, definitions);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const resolved = {};
|
|
48
|
+
for (const param of parameters) {
|
|
49
|
+
if (param.readOnly) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
let value = inputFields == null ? void 0 : inputFields[param.name];
|
|
53
|
+
if (includes(PAGINATION_PARAMS, param.name)) {
|
|
54
|
+
if (param.name === "size") {
|
|
55
|
+
value = (options == null ? void 0 : options.size) || value || ((_b = (_a = config == null ? void 0 : config._paginationConfig) == null ? void 0 : _a.input) == null ? void 0 : _b.size) || parseInt(config == null ? void 0 : config.maxResults, 10);
|
|
56
|
+
} else if (param.name === "page") {
|
|
57
|
+
value = (options == null ? void 0 : options.page) || value || 1;
|
|
58
|
+
} else if (param.name === "sort") {
|
|
59
|
+
value = evaluatedOrderBy(config == null ? void 0 : config.orderBy, options == null ? void 0 : options.orderBy) || value || "";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
resolved[param.name] = value;
|
|
63
|
+
}
|
|
64
|
+
return resolved;
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
evaluatedOrderBy,
|
|
68
|
+
resolveOperationParams
|
|
69
|
+
};
|
|
@@ -11,6 +11,7 @@ export interface ServiceVariableConfig extends VariableConfig {
|
|
|
11
11
|
inFlightBehavior: string;
|
|
12
12
|
controller: string;
|
|
13
13
|
getServiceInfo: Function;
|
|
14
|
+
invokeHttp?: Function;
|
|
14
15
|
}
|
|
15
16
|
declare enum _ServiceVariableEvents {
|
|
16
17
|
BEFORE_INVOKE = "beforeInvoke"
|
|
@@ -24,6 +25,14 @@ export declare class ServiceVariable extends ServiceVariable_base {
|
|
|
24
25
|
private initialized;
|
|
25
26
|
params: any;
|
|
26
27
|
private lastInvokedParams;
|
|
28
|
+
/**
|
|
29
|
+
* The by-name params a generated invokeHttp receives — resolved from the operation's declared
|
|
30
|
+
* parameters, so the pagination defaults the manager applies internally are present. Kept
|
|
31
|
+
* separate from lastInvokedParams, which invokeOnParamChange() compares against the RAW provider
|
|
32
|
+
* values: adding `page`/`size` to that snapshot would make every comparison unequal and
|
|
33
|
+
* re-invoke in a loop.
|
|
34
|
+
*/
|
|
35
|
+
resolvedParams: any;
|
|
27
36
|
private dateFormatter;
|
|
28
37
|
private lastParams;
|
|
29
38
|
private lastParamProviderValues;
|
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { VariableEvents, isStaticParamVariable } from "./base-variable";
|
|
5
|
+
import { resolveOperationParams } from "./operation-params";
|
|
5
6
|
import { forEach, isEmpty, isEqual, isNumber, isObject, isString, merge } from "lodash-es";
|
|
6
7
|
import { deepCopy } from "../core/util";
|
|
7
8
|
import { ServiceVariable as _ServiceVariable } from "@wavemaker-ai/variables";
|
|
@@ -73,7 +74,8 @@ class ServiceVariable extends _ServiceVariable {
|
|
|
73
74
|
},
|
|
74
75
|
onBeforeDatasetReady: (context, args) => {
|
|
75
76
|
return config.onBeforeDatasetReady && config.onBeforeDatasetReady(args.variable, args.data, args.options);
|
|
76
|
-
}
|
|
77
|
+
},
|
|
78
|
+
invokeHttp: (config == null ? void 0 : config.invokeHttp) || void 0
|
|
77
79
|
};
|
|
78
80
|
super(variableConfig);
|
|
79
81
|
this.config = config;
|
|
@@ -82,6 +84,14 @@ class ServiceVariable extends _ServiceVariable {
|
|
|
82
84
|
__publicField(this, "initialized", false);
|
|
83
85
|
__publicField(this, "params");
|
|
84
86
|
__publicField(this, "lastInvokedParams");
|
|
87
|
+
/**
|
|
88
|
+
* The by-name params a generated invokeHttp receives — resolved from the operation's declared
|
|
89
|
+
* parameters, so the pagination defaults the manager applies internally are present. Kept
|
|
90
|
+
* separate from lastInvokedParams, which invokeOnParamChange() compares against the RAW provider
|
|
91
|
+
* values: adding `page`/`size` to that snapshot would make every comparison unequal and
|
|
92
|
+
* re-invoke in a loop.
|
|
93
|
+
*/
|
|
94
|
+
__publicField(this, "resolvedParams");
|
|
85
95
|
__publicField(this, "dateFormatter");
|
|
86
96
|
__publicField(this, "lastParams");
|
|
87
97
|
__publicField(this, "lastParamProviderValues");
|
|
@@ -182,7 +192,7 @@ class ServiceVariable extends _ServiceVariable {
|
|
|
182
192
|
console.log("called in onDataUpdated");
|
|
183
193
|
}
|
|
184
194
|
invoke(options, onSuccess, onError) {
|
|
185
|
-
var _a;
|
|
195
|
+
var _a, _b, _c;
|
|
186
196
|
let inputFields = merge({}, this.config.paramProvider(), this.dataBinding, this.params);
|
|
187
197
|
if (options) {
|
|
188
198
|
const overrides = (_a = options.inputFields) != null ? _a : options;
|
|
@@ -204,6 +214,15 @@ class ServiceVariable extends _ServiceVariable {
|
|
|
204
214
|
if (!this.serviceInfo) {
|
|
205
215
|
console.error(`Service Info is missing for (${this.name}) variable.`);
|
|
206
216
|
}
|
|
217
|
+
this.resolvedParams = resolveOperationParams({
|
|
218
|
+
parameters: (_b = this.serviceInfo) == null ? void 0 : _b.parameters,
|
|
219
|
+
inputFields,
|
|
220
|
+
options,
|
|
221
|
+
config: this.config,
|
|
222
|
+
// ServiceVariableUtils' isBodyTypeQueryOrProcedure
|
|
223
|
+
isBodyTypeQueryOrProcedure: ["QueryExecution", "ProcedureExecution"].includes(this.config.controller) && ["put", "post"].includes(this.config.operationType),
|
|
224
|
+
definitions: (_c = this.serviceInfo) == null ? void 0 : _c.definitions
|
|
225
|
+
});
|
|
207
226
|
return super.invoke(options, onSuccess, onError);
|
|
208
227
|
}
|
|
209
228
|
setInput(key, val, options) {
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { WmTableColumnProps, FieldValidationState } from "../props";
|
|
2
|
-
/**
|
|
3
|
-
* Validates a single field and updates validation state
|
|
4
|
-
*/
|
|
5
|
-
export declare const validateField: (rowId: string, fieldName: string, value: any, column: WmTableColumnProps | undefined, validationState: FieldValidationState) => boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Resets validation state for specific context
|
|
8
|
-
*/
|
|
9
|
-
export declare const resetValidationState: (context: "editing" | "new-row" | "all" | undefined, editingRowId: string | null, validationState: FieldValidationState) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Updates validation errors for fields based on validation results
|
|
12
|
-
*/
|
|
13
|
-
export declare const updateValidationErrors: (validationResult: any, relevantFieldRefs: Record<string, HTMLElement | null>, validationState: FieldValidationState) => void;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { forEach, entries, keys } from "lodash-es";
|
|
2
|
-
const validateField = (rowId, fieldName, value, column, validationState) => {
|
|
3
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4
|
-
const fieldKey = `${rowId}_${fieldName}`;
|
|
5
|
-
const { fieldRefs, fieldValidationErrors, cellUpdateCallbacks } = validationState;
|
|
6
|
-
if (!(column == null ? void 0 : column.required)) return true;
|
|
7
|
-
if ((column == null ? void 0 : column.required) && (value === void 0 || value === null || value === "")) {
|
|
8
|
-
fieldValidationErrors.current[fieldKey] = true;
|
|
9
|
-
(_b = (_a = cellUpdateCallbacks.current)[fieldKey]) == null ? void 0 : _b.call(_a);
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
const fieldElement = fieldRefs.current[fieldKey];
|
|
13
|
-
if (fieldElement) {
|
|
14
|
-
const input = fieldElement.querySelector("input, textarea, select");
|
|
15
|
-
if (input && !input.validity.valid) {
|
|
16
|
-
fieldValidationErrors.current[fieldKey] = true;
|
|
17
|
-
(_d = (_c = cellUpdateCallbacks.current)[fieldKey]) == null ? void 0 : _d.call(_c);
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
fieldValidationErrors.current[fieldKey] = false;
|
|
22
|
-
(_f = (_e = cellUpdateCallbacks.current)[fieldKey]) == null ? void 0 : _f.call(_e);
|
|
23
|
-
return true;
|
|
24
|
-
};
|
|
25
|
-
const resetValidationState = (context, editingRowId, validationState) => {
|
|
26
|
-
const { fieldRefs, fieldValidationErrors, cellUpdateCallbacks } = validationState;
|
|
27
|
-
if (context === "editing" && editingRowId) {
|
|
28
|
-
forEach(keys(fieldRefs.current), (key) => {
|
|
29
|
-
if (key.startsWith(`${editingRowId}_`)) {
|
|
30
|
-
delete fieldRefs.current[key];
|
|
31
|
-
delete fieldValidationErrors.current[key];
|
|
32
|
-
delete cellUpdateCallbacks.current[key];
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
} else if (context === "new-row") {
|
|
36
|
-
forEach(keys(fieldRefs.current), (key) => {
|
|
37
|
-
if (key.startsWith("new-row_")) {
|
|
38
|
-
delete fieldRefs.current[key];
|
|
39
|
-
delete fieldValidationErrors.current[key];
|
|
40
|
-
delete cellUpdateCallbacks.current[key];
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
} else {
|
|
44
|
-
forEach(keys(fieldRefs.current), (key) => {
|
|
45
|
-
delete fieldRefs.current[key];
|
|
46
|
-
});
|
|
47
|
-
fieldValidationErrors.current = {};
|
|
48
|
-
cellUpdateCallbacks.current = {};
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
const updateValidationErrors = (validationResult, relevantFieldRefs, validationState) => {
|
|
52
|
-
const { fieldValidationErrors, cellUpdateCallbacks } = validationState;
|
|
53
|
-
const errors = {};
|
|
54
|
-
forEach(keys(relevantFieldRefs), (fieldKey) => {
|
|
55
|
-
errors[fieldKey] = false;
|
|
56
|
-
});
|
|
57
|
-
if (validationResult.invalidFieldKeys && validationResult.invalidFieldKeys.length > 0) {
|
|
58
|
-
forEach(validationResult.invalidFieldKeys, (fieldKey) => {
|
|
59
|
-
errors[fieldKey] = true;
|
|
60
|
-
});
|
|
61
|
-
} else {
|
|
62
|
-
validationResult.invalidElements.forEach((invalidElement) => {
|
|
63
|
-
forEach(entries(relevantFieldRefs), ([fieldKey, fieldElement]) => {
|
|
64
|
-
if (fieldElement === invalidElement || (fieldElement == null ? void 0 : fieldElement.contains(invalidElement))) {
|
|
65
|
-
errors[fieldKey] = true;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
forEach(entries(errors), ([fieldKey, hasError]) => {
|
|
71
|
-
var _a, _b;
|
|
72
|
-
if (fieldValidationErrors.current[fieldKey] !== hasError) {
|
|
73
|
-
fieldValidationErrors.current[fieldKey] = hasError;
|
|
74
|
-
(_b = (_a = cellUpdateCallbacks.current)[fieldKey]) == null ? void 0 : _b.call(_a);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
export {
|
|
79
|
-
resetValidationState,
|
|
80
|
-
updateValidationErrors,
|
|
81
|
-
validateField
|
|
82
|
-
};
|