zova-module-rest-actions 5.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016-present Zova
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js ADDED
@@ -0,0 +1,130 @@
1
+ import { BeanBase, BeanInfo, BeanScopeBase, cast } from "zova";
2
+ import { Action } from "zova-module-a-action";
3
+ import { Scope } from "zova-module-a-bean";
4
+ //#region src/bean/action.alert.tsx
5
+ var _dec$8, _dec2$8, _class$8;
6
+ var ActionAlert = (_dec$8 = Action({ wait: true }), _dec2$8 = BeanInfo({ module: "rest-actions" }), _dec$8(_class$8 = _dec2$8(_class$8 = class ActionAlert extends BeanBase {
7
+ execute(options, _renderContext, next) {
8
+ if (options.wait) window.alert(options.message);
9
+ else setTimeout(() => {
10
+ window.alert(options.message);
11
+ }, 0);
12
+ return next();
13
+ }
14
+ }) || _class$8) || _class$8);
15
+ //#endregion
16
+ //#region src/bean/action.confirm.tsx
17
+ var _dec$7, _dec2$7, _class$7;
18
+ var ActionConfirm = (_dec$7 = Action(), _dec2$7 = BeanInfo({ module: "rest-actions" }), _dec$7(_class$7 = _dec2$7(_class$7 = class ActionConfirm extends BeanBase {
19
+ execute(options, _renderContext, next) {
20
+ return next(window.confirm(options.message));
21
+ }
22
+ }) || _class$7) || _class$7);
23
+ //#endregion
24
+ //#region src/bean/action.copy.tsx
25
+ var _dec$6, _dec2$6, _class$6;
26
+ var ActionCopy = (_dec$6 = Action(), _dec2$6 = BeanInfo({ module: "rest-actions" }), _dec$6(_class$6 = _dec2$6(_class$6 = class ActionCopy extends BeanBase {
27
+ execute(options, _renderContext, next) {
28
+ return next(navigator.clipboard.writeText(options.text));
29
+ }
30
+ }) || _class$6) || _class$6);
31
+ //#endregion
32
+ //#region src/bean/action.create.tsx
33
+ var _dec$5, _dec2$5, _class$5;
34
+ var ActionCreate = (_dec$5 = Action(), _dec2$5 = BeanInfo({ module: "rest-actions" }), _dec$5(_class$5 = _dec2$5(_class$5 = class ActionCreate extends BeanBase {
35
+ execute(options, renderContext, next) {
36
+ const { $host } = renderContext;
37
+ let resource;
38
+ if (renderContext.$scene === "page") {
39
+ const { $celScope } = renderContext;
40
+ resource = options.resource ?? $celScope.resource;
41
+ }
42
+ if (!resource) throw new Error(`should specify resource in scene: ${renderContext.$scene}`);
43
+ const url = $host.$router.getPagePath("/rest/resource/:resource/create", { params: { resource } });
44
+ $host.$router.push(url);
45
+ return next();
46
+ }
47
+ }) || _class$5) || _class$5);
48
+ //#endregion
49
+ //#region src/bean/action.delete.tsx
50
+ var _dec$4, _dec2$4, _class$4;
51
+ var ActionDelete = (_dec$4 = Action(), _dec2$4 = BeanInfo({ module: "rest-actions" }), _dec$4(_class$4 = _dec2$4(_class$4 = class ActionDelete extends BeanBase {
52
+ async execute(options, renderContext, next) {
53
+ if (renderContext.$scene === "tableCell") {
54
+ const { $celScope, cellContext } = renderContext;
55
+ const id = options.id ?? cellContext.row.id;
56
+ await $celScope.onActionRow?.("delete", id);
57
+ }
58
+ return next();
59
+ }
60
+ }) || _class$4) || _class$4);
61
+ //#endregion
62
+ //#region src/bean/action.edit.tsx
63
+ var _dec$3, _dec2$3, _class$3;
64
+ var ActionEdit = (_dec$3 = Action(), _dec2$3 = BeanInfo({ module: "rest-actions" }), _dec$3(_class$3 = _dec2$3(_class$3 = class ActionEdit extends BeanBase {
65
+ execute(options, renderContext, next) {
66
+ const { $host } = renderContext;
67
+ let resource;
68
+ let id;
69
+ if (renderContext.$scene === "tableCell") {
70
+ const { $celScope, cellContext } = renderContext;
71
+ resource = options.resource ?? $celScope.resource;
72
+ id = options.id ?? cellContext.row.id;
73
+ }
74
+ if (!resource || !id) throw new Error(`should specify resource or id in scene: ${renderContext.$scene}`);
75
+ const url = $host.$router.getPagePath("/rest/resource/:resource/:id/:formScene?", { params: {
76
+ resource,
77
+ id,
78
+ formScene: "edit"
79
+ } });
80
+ $host.$router.push(url);
81
+ return next();
82
+ }
83
+ }) || _class$3) || _class$3);
84
+ //#endregion
85
+ //#region src/bean/action.setValue.tsx
86
+ var _dec$2, _dec2$2, _class$2;
87
+ var ActionSetValue = (_dec$2 = Action(), _dec2$2 = BeanInfo({ module: "rest-actions" }), _dec$2(_class$2 = _dec2$2(_class$2 = class ActionSetValue extends BeanBase {
88
+ execute(options, renderContext, next) {
89
+ if (renderContext.$scene === "formField") {
90
+ const { $celScope, $jsx, $$form } = renderContext;
91
+ const name = options.name ?? $celScope.name;
92
+ const value = options.value !== void 0 ? options.value : cast($jsx.event?.target)?.value;
93
+ $$form.setFieldValue(name, value, options.disableNotifyChanged);
94
+ }
95
+ return next();
96
+ }
97
+ }) || _class$2) || _class$2);
98
+ //#endregion
99
+ //#region src/bean/action.view.tsx
100
+ var _dec$1, _dec2$1, _class$1;
101
+ var ActionView = (_dec$1 = Action(), _dec2$1 = BeanInfo({ module: "rest-actions" }), _dec$1(_class$1 = _dec2$1(_class$1 = class ActionView extends BeanBase {
102
+ execute(options, renderContext, next) {
103
+ const { $host } = renderContext;
104
+ let resource;
105
+ let id;
106
+ if (renderContext.$scene === "tableCell") {
107
+ const { $celScope, cellContext } = renderContext;
108
+ resource = options.resource ?? $celScope.resource;
109
+ id = options.id ?? cellContext.row.id;
110
+ }
111
+ if (!resource || !id) throw new Error(`should specify resource or id in scene: ${renderContext.$scene}`);
112
+ const url = $host.$router.getPagePath("/rest/resource/:resource/:id/:formScene?", { params: {
113
+ resource,
114
+ id
115
+ } });
116
+ $host.$router.push(url);
117
+ return next();
118
+ }
119
+ }) || _class$1) || _class$1);
120
+ //#endregion
121
+ //#region src/.metadata/index.ts
122
+ /** action: end */
123
+ /** scope: begin */
124
+ var _dec, _dec2, _class;
125
+ var ScopeModuleRestActions = (_dec = Scope(), _dec2 = BeanInfo({ module: "rest-actions" }), _dec(_class = _dec2(_class = class ScopeModuleRestActions extends BeanScopeBase {}) || _class) || _class);
126
+ /** scope: end */
127
+ //#endregion
128
+ export { ActionAlert, ActionConfirm, ActionCopy, ActionCreate, ActionDelete, ActionEdit, ActionSetValue, ActionView, ScopeModuleRestActions };
129
+
130
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["BeanBase","Action","ActionAlert","_dec","wait","_dec2","__z_BeanInfo","module","_class","execute","options","_renderContext","next","window","alert","message","setTimeout","BeanBase","Action","ActionConfirm","_dec","_dec2","__z_BeanInfo","module","_class","execute","options","_renderContext","next","res","window","confirm","message","BeanBase","Action","ActionCopy","_dec","_dec2","__z_BeanInfo","module","_class","execute","options","_renderContext","next","res","navigator","clipboard","writeText","text","BeanBase","Action","ActionCreate","_dec","_dec2","__z_BeanInfo","module","_class","execute","options","renderContext","next","$host","resource","$scene","$celScope","Error","url","$router","getPagePath","params","push","BeanBase","Action","ActionDelete","_dec","_dec2","__z_BeanInfo","module","_class","execute","options","renderContext","next","$scene","$celScope","cellContext","id","row","onActionRow","BeanBase","Action","ActionEdit","_dec","_dec2","__z_BeanInfo","module","_class","execute","options","renderContext","next","$host","resource","id","$scene","$celScope","cellContext","row","Error","url","$router","getPagePath","params","formScene","push","BeanBase","cast","Action","ActionSetValue","_dec","_dec2","__z_BeanInfo","module","_class","execute","options","renderContext","next","$scene","$celScope","$jsx","$$form","name","value","undefined","event","target","setFieldValue","disableNotifyChanged","BeanBase","Action","ActionView","_dec","_dec2","__z_BeanInfo","module","_class","execute","options","renderContext","next","$host","resource","id","$scene","$celScope","cellContext","row","Error","url","$router","getPagePath","params","push"],"sources":["../src/bean/action.alert.tsx","../src/bean/action.confirm.tsx","../src/bean/action.copy.tsx","../src/bean/action.create.tsx","../src/bean/action.delete.tsx","../src/bean/action.edit.tsx","../src/bean/action.setValue.tsx","../src/bean/action.view.tsx","../src/.metadata/index.ts"],"sourcesContent":["import type { IActionExecute } from 'zova-module-a-action';\nimport type { IDecoratorActionOptions } from 'zova-module-a-action';\nimport type { NextActionExecute } from 'zova-module-a-action';\nimport type { IJsxRenderContextBase } from 'zova-module-a-openapi';\n\nimport { BeanBase } from 'zova';\nimport { Action } from 'zova-module-a-action';\n\nexport type TypeActionAlertResult = unknown;\n\nexport interface IActionOptionsAlert extends IDecoratorActionOptions<TypeActionAlertResult> {\n message: string;\n wait?: boolean;\n}\n\n@Action<IActionOptionsAlert>({ wait: true })\nexport class ActionAlert extends BeanBase implements IActionExecute {\n execute(options: IActionOptionsAlert, _renderContext: IJsxRenderContextBase, next: NextActionExecute) {\n if (options.wait) {\n // eslint-disable-next-line no-alert\n window.alert(options.message);\n } else {\n setTimeout(() => {\n // eslint-disable-next-line no-alert\n window.alert(options.message);\n }, 0);\n }\n return next();\n }\n}\n","import { BeanBase } from 'zova';\nimport { Action, IActionExecute, IDecoratorActionOptions, NextActionExecute } from 'zova-module-a-action';\nimport { IJsxRenderContextBase } from 'zova-module-a-openapi';\n\nexport type TypeActionConfirmResult = boolean;\n\nexport interface IActionOptionsConfirm extends IDecoratorActionOptions<TypeActionConfirmResult> {\n message: string;\n}\n\n@Action<IActionOptionsConfirm>()\nexport class ActionConfirm extends BeanBase implements IActionExecute {\n execute(options: IActionOptionsConfirm, _renderContext: IJsxRenderContextBase, next: NextActionExecute) {\n // eslint-disable-next-line no-alert\n const res = window.confirm(options.message);\n return next(res);\n }\n}\n","import { BeanBase } from 'zova';\nimport { Action, IActionExecute, IDecoratorActionOptions, NextActionExecute } from 'zova-module-a-action';\nimport { IJsxRenderContextBase } from 'zova-module-a-openapi';\n\nexport type TypeActionCopyResult = unknown;\n\nexport interface IActionOptionsCopy extends IDecoratorActionOptions<TypeActionCopyResult> {\n text: any;\n}\n\n@Action<IActionOptionsCopy>()\nexport class ActionCopy extends BeanBase implements IActionExecute {\n execute(options: IActionOptionsCopy, _renderContext: IJsxRenderContextBase, next: NextActionExecute) {\n const res = navigator.clipboard.writeText(options.text);\n return next(res);\n }\n}\n","import { BeanBase } from 'zova';\nimport { Action, IActionExecute, IDecoratorActionOptions, NextActionExecute } from 'zova-module-a-action';\nimport { IJsxRenderContextBase } from 'zova-module-a-openapi';\nimport { IJsxRenderContextPageWrapper } from 'zova-module-rest-resource';\n\nexport type TypeActionCreateResult = unknown;\n\nexport interface IActionOptionsCreate extends IDecoratorActionOptions<TypeActionCreateResult> {\n resource?: string;\n}\n\n@Action<IActionOptionsCreate>()\nexport class ActionCreate extends BeanBase implements IActionExecute {\n execute(options: IActionOptionsCreate, renderContext: IJsxRenderContextBase, next: NextActionExecute) {\n const { $host } = renderContext;\n let resource: string | undefined;\n if (renderContext.$scene === 'page') {\n const { $celScope } = renderContext as IJsxRenderContextPageWrapper;\n resource = options.resource ?? $celScope.resource;\n }\n if (!resource) throw new Error(`should specify resource in scene: ${renderContext.$scene}`);\n const url = $host.$router.getPagePath('/rest/resource/:resource/create', {\n params: { resource },\n });\n $host.$router.push(url);\n return next();\n }\n}\n","import { BeanBase } from 'zova';\nimport { Action, IActionExecute, IDecoratorActionOptions, NextActionExecute } from 'zova-module-a-action';\nimport { IJsxRenderContextBase } from 'zova-module-a-openapi';\nimport { IJsxRenderContextTableCell } from 'zova-module-a-table';\n\nexport type TypeActionDeleteResult = unknown;\n\nexport interface IActionOptionsDelete extends IDecoratorActionOptions<TypeActionDeleteResult> {\n id?: string;\n}\n\n@Action<IActionOptionsDelete>()\nexport class ActionDelete extends BeanBase implements IActionExecute {\n async execute(options: IActionOptionsDelete, renderContext: IJsxRenderContextBase, next: NextActionExecute) {\n if (renderContext.$scene === 'tableCell') {\n const { $celScope, cellContext } = renderContext as IJsxRenderContextTableCell;\n const id = options.id ?? cellContext.row.id;\n await $celScope.onActionRow?.('delete', id);\n }\n return next();\n }\n}\n","import { BeanBase } from 'zova';\nimport { Action, IActionExecute, IDecoratorActionOptions, NextActionExecute } from 'zova-module-a-action';\nimport { IJsxRenderContextBase } from 'zova-module-a-openapi';\nimport { IJsxRenderContextTableCell } from 'zova-module-a-table';\n\nexport type TypeActionEditResult = unknown;\n\nexport interface IActionOptionsEdit extends IDecoratorActionOptions<TypeActionEditResult> {\n resource?: string;\n id?: string;\n}\n\n@Action<IActionOptionsEdit>()\nexport class ActionEdit extends BeanBase implements IActionExecute {\n execute(options: IActionOptionsEdit, renderContext: IJsxRenderContextBase, next: NextActionExecute) {\n const { $host } = renderContext;\n let resource: string | undefined;\n let id: string | undefined;\n if (renderContext.$scene === 'tableCell') {\n const { $celScope, cellContext } = renderContext as IJsxRenderContextTableCell;\n resource = options.resource ?? $celScope.resource;\n id = options.id ?? cellContext.row.id;\n }\n if (!resource || !id) throw new Error(`should specify resource or id in scene: ${renderContext.$scene}`);\n const url = $host.$router.getPagePath('/rest/resource/:resource/:id/:formScene?', {\n params: { resource, id, formScene: 'edit' },\n });\n $host.$router.push(url);\n return next();\n }\n}\n","import { BeanBase, cast } from 'zova';\nimport { Action, IActionExecute, IDecoratorActionOptions, NextActionExecute } from 'zova-module-a-action';\nimport { IJsxRenderContextFormField } from 'zova-module-a-form';\nimport { IJsxRenderContextBase } from 'zova-module-a-openapi';\n\nexport type TypeActionSetValueResult = unknown;\n\nexport interface IActionOptionsSetValue extends IDecoratorActionOptions<TypeActionSetValueResult> {\n name?: string;\n value?: any;\n disableNotifyChanged?: boolean;\n}\n\n@Action<IActionOptionsSetValue>()\nexport class ActionSetValue extends BeanBase implements IActionExecute {\n execute(options: IActionOptionsSetValue, renderContext: IJsxRenderContextBase, next: NextActionExecute) {\n if (renderContext.$scene === 'formField') {\n const { $celScope, $jsx, $$form } = renderContext as IJsxRenderContextFormField;\n const name = options.name ?? $celScope.name;\n // null means valid prop value\n const value = options.value !== undefined ? options.value : cast($jsx.event?.target)?.value;\n $$form.setFieldValue(name, value, options.disableNotifyChanged);\n }\n return next();\n }\n}\n","import { BeanBase } from 'zova';\nimport { Action, IActionExecute, IDecoratorActionOptions, NextActionExecute } from 'zova-module-a-action';\nimport { IJsxRenderContextBase } from 'zova-module-a-openapi';\nimport { IJsxRenderContextTableCell } from 'zova-module-a-table';\n\nexport type TypeActionViewResult = unknown;\n\nexport interface IActionOptionsView extends IDecoratorActionOptions<TypeActionViewResult> {\n resource?: string;\n id?: string;\n}\n\n@Action<IActionOptionsView>()\nexport class ActionView extends BeanBase implements IActionExecute {\n execute(options: IActionOptionsView, renderContext: IJsxRenderContextBase, next: NextActionExecute) {\n const { $host } = renderContext;\n let resource: string | undefined;\n let id: string | undefined;\n if (renderContext.$scene === 'tableCell') {\n const { $celScope, cellContext } = renderContext as IJsxRenderContextTableCell;\n resource = options.resource ?? $celScope.resource;\n id = options.id ?? cellContext.row.id;\n }\n if (!resource || !id) throw new Error(`should specify resource or id in scene: ${renderContext.$scene}`);\n const url = $host.$router.getPagePath('/rest/resource/:resource/:id/:formScene?', {\n params: { resource, id },\n });\n $host.$router.push(url);\n return next();\n }\n}\n","// eslint-disable\n/** action: begin */\nexport * from '../bean/action.alert.jsx';\nexport * from '../bean/action.confirm.jsx';\nexport * from '../bean/action.copy.jsx';\nexport * from '../bean/action.create.jsx';\nexport * from '../bean/action.delete.jsx';\nexport * from '../bean/action.edit.jsx';\nexport * from '../bean/action.setValue.jsx';\nexport * from '../bean/action.view.jsx';\nimport { IActionOptionsAlert } from '../bean/action.alert.jsx';\nimport { IActionOptionsConfirm } from '../bean/action.confirm.jsx';\nimport { IActionOptionsCopy } from '../bean/action.copy.jsx';\nimport { IActionOptionsCreate } from '../bean/action.create.jsx';\nimport { IActionOptionsDelete } from '../bean/action.delete.jsx';\nimport { IActionOptionsEdit } from '../bean/action.edit.jsx';\nimport { IActionOptionsSetValue } from '../bean/action.setValue.jsx';\nimport { IActionOptionsView } from '../bean/action.view.jsx';\nimport 'zova-module-a-action';\ndeclare module 'zova-module-a-action' {\n \n export interface IActionRecord {\n 'rest-actions:alert': IActionOptionsAlert;\n'rest-actions:confirm': IActionOptionsConfirm;\n'rest-actions:copy': IActionOptionsCopy;\n'rest-actions:create': IActionOptionsCreate;\n'rest-actions:delete': IActionOptionsDelete;\n'rest-actions:edit': IActionOptionsEdit;\n'rest-actions:setValue': IActionOptionsSetValue;\n'rest-actions:view': IActionOptionsView;\n }\n\n \n}\ndeclare module 'zova-module-rest-actions' {\n \n export interface ActionAlert {\n /** @internal */\n get scope(): ScopeModuleRestActions;\n }\n\n export interface ActionAlert {\n get $beanFullName(): 'rest-actions.action.alert';\n get $onionName(): 'rest-actions:alert';\n get $onionOptions(): IActionOptionsAlert;\n }\n\n export interface ActionConfirm {\n /** @internal */\n get scope(): ScopeModuleRestActions;\n }\n\n export interface ActionConfirm {\n get $beanFullName(): 'rest-actions.action.confirm';\n get $onionName(): 'rest-actions:confirm';\n get $onionOptions(): IActionOptionsConfirm;\n }\n\n export interface ActionCopy {\n /** @internal */\n get scope(): ScopeModuleRestActions;\n }\n\n export interface ActionCopy {\n get $beanFullName(): 'rest-actions.action.copy';\n get $onionName(): 'rest-actions:copy';\n get $onionOptions(): IActionOptionsCopy;\n }\n\n export interface ActionCreate {\n /** @internal */\n get scope(): ScopeModuleRestActions;\n }\n\n export interface ActionCreate {\n get $beanFullName(): 'rest-actions.action.create';\n get $onionName(): 'rest-actions:create';\n get $onionOptions(): IActionOptionsCreate;\n }\n\n export interface ActionDelete {\n /** @internal */\n get scope(): ScopeModuleRestActions;\n }\n\n export interface ActionDelete {\n get $beanFullName(): 'rest-actions.action.delete';\n get $onionName(): 'rest-actions:delete';\n get $onionOptions(): IActionOptionsDelete;\n }\n\n export interface ActionEdit {\n /** @internal */\n get scope(): ScopeModuleRestActions;\n }\n\n export interface ActionEdit {\n get $beanFullName(): 'rest-actions.action.edit';\n get $onionName(): 'rest-actions:edit';\n get $onionOptions(): IActionOptionsEdit;\n }\n\n export interface ActionSetValue {\n /** @internal */\n get scope(): ScopeModuleRestActions;\n }\n\n export interface ActionSetValue {\n get $beanFullName(): 'rest-actions.action.setValue';\n get $onionName(): 'rest-actions:setValue';\n get $onionOptions(): IActionOptionsSetValue;\n }\n\n export interface ActionView {\n /** @internal */\n get scope(): ScopeModuleRestActions;\n }\n\n export interface ActionView {\n get $beanFullName(): 'rest-actions.action.view';\n get $onionName(): 'rest-actions:view';\n get $onionOptions(): IActionOptionsView;\n } \n}\n/** action: end */\n/** action: begin */\nimport { ActionAlert } from '../bean/action.alert.jsx';\nimport { ActionConfirm } from '../bean/action.confirm.jsx';\nimport { ActionCopy } from '../bean/action.copy.jsx';\nimport { ActionCreate } from '../bean/action.create.jsx';\nimport { ActionDelete } from '../bean/action.delete.jsx';\nimport { ActionEdit } from '../bean/action.edit.jsx';\nimport { ActionSetValue } from '../bean/action.setValue.jsx';\nimport { ActionView } from '../bean/action.view.jsx';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordGeneral {\n 'rest-actions.action.alert': ActionAlert;\n'rest-actions.action.confirm': ActionConfirm;\n'rest-actions.action.copy': ActionCopy;\n'rest-actions.action.create': ActionCreate;\n'rest-actions.action.delete': ActionDelete;\n'rest-actions.action.edit': ActionEdit;\n'rest-actions.action.setValue': ActionSetValue;\n'rest-actions.action.view': ActionView;\n }\n}\n/** action: end */\n/** scope: begin */\nimport { BeanScopeBase, type BeanScopeUtil } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\n\n@Scope()\nexport class ScopeModuleRestActions extends BeanScopeBase {}\n\nexport interface ScopeModuleRestActions {\n util: BeanScopeUtil;\n}\n\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanScopeRecord {\n 'rest-actions': ScopeModuleRestActions;\n }\n \n \n\n \n\n \n}\n \n/** scope: end */\n"],"mappings":"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"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "zova-module-rest-actions",
3
+ "version": "5.1.0",
4
+ "description": "",
5
+ "keywords": [
6
+ "Zova Module"
7
+ ],
8
+ "author": "",
9
+ "files": [
10
+ "dist",
11
+ "mock",
12
+ "rest",
13
+ "src",
14
+ "icons",
15
+ "assets"
16
+ ],
17
+ "type": "module",
18
+ "exports": {
19
+ ".": {
20
+ "types": [
21
+ "./src/index.ts",
22
+ "./dist/index.d.ts"
23
+ ],
24
+ "default": "./dist/index.js"
25
+ },
26
+ "./*": "./*"
27
+ },
28
+ "scripts": {
29
+ "clean": "rimraf dist tsconfig.build.tsbuildinfo",
30
+ "tsc:publish": "npm run clean && zova :bin:buildModule --sourcemap",
31
+ "prepublishOnly": "npm run tsc:publish",
32
+ "prepack": "clean-package",
33
+ "postpack": "clean-package restore && npm run clean"
34
+ },
35
+ "title": "rest-actions",
36
+ "gitHead": "bf1ceb4582381c74ba41ccf11b89d3b9e7b73628"
37
+ }
@@ -0,0 +1,8 @@
1
+ import type { TypeActionOptionsRest } from 'zova-module-a-action';
2
+ import type { IActionOptionsAlert } from '../../src/bean/action.alert.jsx';
3
+
4
+ export function AARestActionsAlert(
5
+ _props: TypeActionOptionsRest<IActionOptionsAlert>,
6
+ ) {
7
+ return 'rest-actions:alert';
8
+ }
@@ -0,0 +1,8 @@
1
+ import type { TypeActionOptionsRest } from 'zova-module-a-action';
2
+ import type { IActionOptionsConfirm } from '../../src/bean/action.confirm.jsx';
3
+
4
+ export function AARestActionsConfirm(
5
+ _props: TypeActionOptionsRest<IActionOptionsConfirm>,
6
+ ) {
7
+ return 'rest-actions:confirm';
8
+ }
@@ -0,0 +1,8 @@
1
+ import type { TypeActionOptionsRest } from 'zova-module-a-action';
2
+ import type { IActionOptionsCopy } from '../../src/bean/action.copy.jsx';
3
+
4
+ export function AARestActionsCopy(
5
+ _props: TypeActionOptionsRest<IActionOptionsCopy>,
6
+ ) {
7
+ return 'rest-actions:copy';
8
+ }
@@ -0,0 +1,8 @@
1
+ import type { TypeActionOptionsRest } from 'zova-module-a-action';
2
+ import type { IActionOptionsCreate } from '../../src/bean/action.create.jsx';
3
+
4
+ export function AARestActionsCreate(
5
+ _props: TypeActionOptionsRest<IActionOptionsCreate>,
6
+ ) {
7
+ return 'rest-actions:create';
8
+ }
@@ -0,0 +1,8 @@
1
+ import type { TypeActionOptionsRest } from 'zova-module-a-action';
2
+ import type { IActionOptionsDelete } from '../../src/bean/action.delete.jsx';
3
+
4
+ export function AARestActionsDelete(
5
+ _props: TypeActionOptionsRest<IActionOptionsDelete>,
6
+ ) {
7
+ return 'rest-actions:delete';
8
+ }
@@ -0,0 +1,8 @@
1
+ import type { TypeActionOptionsRest } from 'zova-module-a-action';
2
+ import type { IActionOptionsEdit } from '../../src/bean/action.edit.jsx';
3
+
4
+ export function AARestActionsEdit(
5
+ _props: TypeActionOptionsRest<IActionOptionsEdit>,
6
+ ) {
7
+ return 'rest-actions:edit';
8
+ }
@@ -0,0 +1,8 @@
1
+ import type { TypeActionOptionsRest } from 'zova-module-a-action';
2
+ import type { IActionOptionsSetValue } from '../../src/bean/action.setValue.jsx';
3
+
4
+ export function AARestActionsSetValue(
5
+ _props: TypeActionOptionsRest<IActionOptionsSetValue>,
6
+ ) {
7
+ return 'rest-actions:setValue';
8
+ }
@@ -0,0 +1,8 @@
1
+ import type { TypeActionOptionsRest } from 'zova-module-a-action';
2
+ import type { IActionOptionsView } from '../../src/bean/action.view.jsx';
3
+
4
+ export function AARestActionsView(
5
+ _props: TypeActionOptionsRest<IActionOptionsView>,
6
+ ) {
7
+ return 'rest-actions:view';
8
+ }
@@ -0,0 +1,8 @@
1
+ export * from './action/alert.js';
2
+ export * from './action/confirm.js';
3
+ export * from './action/copy.js';
4
+ export * from './action/create.js';
5
+ export * from './action/delete.js';
6
+ export * from './action/edit.js';
7
+ export * from './action/setValue.js';
8
+ export * from './action/view.js';
package/rest/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './actions.js';
@@ -0,0 +1,173 @@
1
+ // eslint-disable
2
+ /** action: begin */
3
+ export * from '../bean/action.alert.jsx';
4
+ export * from '../bean/action.confirm.jsx';
5
+ export * from '../bean/action.copy.jsx';
6
+ export * from '../bean/action.create.jsx';
7
+ export * from '../bean/action.delete.jsx';
8
+ export * from '../bean/action.edit.jsx';
9
+ export * from '../bean/action.setValue.jsx';
10
+ export * from '../bean/action.view.jsx';
11
+ import { IActionOptionsAlert } from '../bean/action.alert.jsx';
12
+ import { IActionOptionsConfirm } from '../bean/action.confirm.jsx';
13
+ import { IActionOptionsCopy } from '../bean/action.copy.jsx';
14
+ import { IActionOptionsCreate } from '../bean/action.create.jsx';
15
+ import { IActionOptionsDelete } from '../bean/action.delete.jsx';
16
+ import { IActionOptionsEdit } from '../bean/action.edit.jsx';
17
+ import { IActionOptionsSetValue } from '../bean/action.setValue.jsx';
18
+ import { IActionOptionsView } from '../bean/action.view.jsx';
19
+ import 'zova-module-a-action';
20
+ declare module 'zova-module-a-action' {
21
+
22
+ export interface IActionRecord {
23
+ 'rest-actions:alert': IActionOptionsAlert;
24
+ 'rest-actions:confirm': IActionOptionsConfirm;
25
+ 'rest-actions:copy': IActionOptionsCopy;
26
+ 'rest-actions:create': IActionOptionsCreate;
27
+ 'rest-actions:delete': IActionOptionsDelete;
28
+ 'rest-actions:edit': IActionOptionsEdit;
29
+ 'rest-actions:setValue': IActionOptionsSetValue;
30
+ 'rest-actions:view': IActionOptionsView;
31
+ }
32
+
33
+
34
+ }
35
+ declare module 'zova-module-rest-actions' {
36
+
37
+ export interface ActionAlert {
38
+ /** @internal */
39
+ get scope(): ScopeModuleRestActions;
40
+ }
41
+
42
+ export interface ActionAlert {
43
+ get $beanFullName(): 'rest-actions.action.alert';
44
+ get $onionName(): 'rest-actions:alert';
45
+ get $onionOptions(): IActionOptionsAlert;
46
+ }
47
+
48
+ export interface ActionConfirm {
49
+ /** @internal */
50
+ get scope(): ScopeModuleRestActions;
51
+ }
52
+
53
+ export interface ActionConfirm {
54
+ get $beanFullName(): 'rest-actions.action.confirm';
55
+ get $onionName(): 'rest-actions:confirm';
56
+ get $onionOptions(): IActionOptionsConfirm;
57
+ }
58
+
59
+ export interface ActionCopy {
60
+ /** @internal */
61
+ get scope(): ScopeModuleRestActions;
62
+ }
63
+
64
+ export interface ActionCopy {
65
+ get $beanFullName(): 'rest-actions.action.copy';
66
+ get $onionName(): 'rest-actions:copy';
67
+ get $onionOptions(): IActionOptionsCopy;
68
+ }
69
+
70
+ export interface ActionCreate {
71
+ /** @internal */
72
+ get scope(): ScopeModuleRestActions;
73
+ }
74
+
75
+ export interface ActionCreate {
76
+ get $beanFullName(): 'rest-actions.action.create';
77
+ get $onionName(): 'rest-actions:create';
78
+ get $onionOptions(): IActionOptionsCreate;
79
+ }
80
+
81
+ export interface ActionDelete {
82
+ /** @internal */
83
+ get scope(): ScopeModuleRestActions;
84
+ }
85
+
86
+ export interface ActionDelete {
87
+ get $beanFullName(): 'rest-actions.action.delete';
88
+ get $onionName(): 'rest-actions:delete';
89
+ get $onionOptions(): IActionOptionsDelete;
90
+ }
91
+
92
+ export interface ActionEdit {
93
+ /** @internal */
94
+ get scope(): ScopeModuleRestActions;
95
+ }
96
+
97
+ export interface ActionEdit {
98
+ get $beanFullName(): 'rest-actions.action.edit';
99
+ get $onionName(): 'rest-actions:edit';
100
+ get $onionOptions(): IActionOptionsEdit;
101
+ }
102
+
103
+ export interface ActionSetValue {
104
+ /** @internal */
105
+ get scope(): ScopeModuleRestActions;
106
+ }
107
+
108
+ export interface ActionSetValue {
109
+ get $beanFullName(): 'rest-actions.action.setValue';
110
+ get $onionName(): 'rest-actions:setValue';
111
+ get $onionOptions(): IActionOptionsSetValue;
112
+ }
113
+
114
+ export interface ActionView {
115
+ /** @internal */
116
+ get scope(): ScopeModuleRestActions;
117
+ }
118
+
119
+ export interface ActionView {
120
+ get $beanFullName(): 'rest-actions.action.view';
121
+ get $onionName(): 'rest-actions:view';
122
+ get $onionOptions(): IActionOptionsView;
123
+ }
124
+ }
125
+ /** action: end */
126
+ /** action: begin */
127
+ import { ActionAlert } from '../bean/action.alert.jsx';
128
+ import { ActionConfirm } from '../bean/action.confirm.jsx';
129
+ import { ActionCopy } from '../bean/action.copy.jsx';
130
+ import { ActionCreate } from '../bean/action.create.jsx';
131
+ import { ActionDelete } from '../bean/action.delete.jsx';
132
+ import { ActionEdit } from '../bean/action.edit.jsx';
133
+ import { ActionSetValue } from '../bean/action.setValue.jsx';
134
+ import { ActionView } from '../bean/action.view.jsx';
135
+ import 'zova';
136
+ declare module 'zova' {
137
+ export interface IBeanRecordGeneral {
138
+ 'rest-actions.action.alert': ActionAlert;
139
+ 'rest-actions.action.confirm': ActionConfirm;
140
+ 'rest-actions.action.copy': ActionCopy;
141
+ 'rest-actions.action.create': ActionCreate;
142
+ 'rest-actions.action.delete': ActionDelete;
143
+ 'rest-actions.action.edit': ActionEdit;
144
+ 'rest-actions.action.setValue': ActionSetValue;
145
+ 'rest-actions.action.view': ActionView;
146
+ }
147
+ }
148
+ /** action: end */
149
+ /** scope: begin */
150
+ import { BeanScopeBase, type BeanScopeUtil } from 'zova';
151
+ import { Scope } from 'zova-module-a-bean';
152
+
153
+ @Scope()
154
+ export class ScopeModuleRestActions extends BeanScopeBase {}
155
+
156
+ export interface ScopeModuleRestActions {
157
+ util: BeanScopeUtil;
158
+ }
159
+
160
+ import 'zova';
161
+ declare module 'zova' {
162
+ export interface IBeanScopeRecord {
163
+ 'rest-actions': ScopeModuleRestActions;
164
+ }
165
+
166
+
167
+
168
+
169
+
170
+
171
+ }
172
+
173
+ /** scope: end */
@@ -0,0 +1,2 @@
1
+ export const __ThisModule__ = 'rest-actions';
2
+ export { ScopeModuleRestActions as ScopeModule } from './index.js';
@@ -0,0 +1,30 @@
1
+ import type { IActionExecute } from 'zova-module-a-action';
2
+ import type { IDecoratorActionOptions } from 'zova-module-a-action';
3
+ import type { NextActionExecute } from 'zova-module-a-action';
4
+ import type { IJsxRenderContextBase } from 'zova-module-a-openapi';
5
+
6
+ import { BeanBase } from 'zova';
7
+ import { Action } from 'zova-module-a-action';
8
+
9
+ export type TypeActionAlertResult = unknown;
10
+
11
+ export interface IActionOptionsAlert extends IDecoratorActionOptions<TypeActionAlertResult> {
12
+ message: string;
13
+ wait?: boolean;
14
+ }
15
+
16
+ @Action<IActionOptionsAlert>({ wait: true })
17
+ export class ActionAlert extends BeanBase implements IActionExecute {
18
+ execute(options: IActionOptionsAlert, _renderContext: IJsxRenderContextBase, next: NextActionExecute) {
19
+ if (options.wait) {
20
+ // eslint-disable-next-line no-alert
21
+ window.alert(options.message);
22
+ } else {
23
+ setTimeout(() => {
24
+ // eslint-disable-next-line no-alert
25
+ window.alert(options.message);
26
+ }, 0);
27
+ }
28
+ return next();
29
+ }
30
+ }
@@ -0,0 +1,18 @@
1
+ import { BeanBase } from 'zova';
2
+ import { Action, IActionExecute, IDecoratorActionOptions, NextActionExecute } from 'zova-module-a-action';
3
+ import { IJsxRenderContextBase } from 'zova-module-a-openapi';
4
+
5
+ export type TypeActionConfirmResult = boolean;
6
+
7
+ export interface IActionOptionsConfirm extends IDecoratorActionOptions<TypeActionConfirmResult> {
8
+ message: string;
9
+ }
10
+
11
+ @Action<IActionOptionsConfirm>()
12
+ export class ActionConfirm extends BeanBase implements IActionExecute {
13
+ execute(options: IActionOptionsConfirm, _renderContext: IJsxRenderContextBase, next: NextActionExecute) {
14
+ // eslint-disable-next-line no-alert
15
+ const res = window.confirm(options.message);
16
+ return next(res);
17
+ }
18
+ }
@@ -0,0 +1,17 @@
1
+ import { BeanBase } from 'zova';
2
+ import { Action, IActionExecute, IDecoratorActionOptions, NextActionExecute } from 'zova-module-a-action';
3
+ import { IJsxRenderContextBase } from 'zova-module-a-openapi';
4
+
5
+ export type TypeActionCopyResult = unknown;
6
+
7
+ export interface IActionOptionsCopy extends IDecoratorActionOptions<TypeActionCopyResult> {
8
+ text: any;
9
+ }
10
+
11
+ @Action<IActionOptionsCopy>()
12
+ export class ActionCopy extends BeanBase implements IActionExecute {
13
+ execute(options: IActionOptionsCopy, _renderContext: IJsxRenderContextBase, next: NextActionExecute) {
14
+ const res = navigator.clipboard.writeText(options.text);
15
+ return next(res);
16
+ }
17
+ }
@@ -0,0 +1,28 @@
1
+ import { BeanBase } from 'zova';
2
+ import { Action, IActionExecute, IDecoratorActionOptions, NextActionExecute } from 'zova-module-a-action';
3
+ import { IJsxRenderContextBase } from 'zova-module-a-openapi';
4
+ import { IJsxRenderContextPageWrapper } from 'zova-module-rest-resource';
5
+
6
+ export type TypeActionCreateResult = unknown;
7
+
8
+ export interface IActionOptionsCreate extends IDecoratorActionOptions<TypeActionCreateResult> {
9
+ resource?: string;
10
+ }
11
+
12
+ @Action<IActionOptionsCreate>()
13
+ export class ActionCreate extends BeanBase implements IActionExecute {
14
+ execute(options: IActionOptionsCreate, renderContext: IJsxRenderContextBase, next: NextActionExecute) {
15
+ const { $host } = renderContext;
16
+ let resource: string | undefined;
17
+ if (renderContext.$scene === 'page') {
18
+ const { $celScope } = renderContext as IJsxRenderContextPageWrapper;
19
+ resource = options.resource ?? $celScope.resource;
20
+ }
21
+ if (!resource) throw new Error(`should specify resource in scene: ${renderContext.$scene}`);
22
+ const url = $host.$router.getPagePath('/rest/resource/:resource/create', {
23
+ params: { resource },
24
+ });
25
+ $host.$router.push(url);
26
+ return next();
27
+ }
28
+ }
@@ -0,0 +1,22 @@
1
+ import { BeanBase } from 'zova';
2
+ import { Action, IActionExecute, IDecoratorActionOptions, NextActionExecute } from 'zova-module-a-action';
3
+ import { IJsxRenderContextBase } from 'zova-module-a-openapi';
4
+ import { IJsxRenderContextTableCell } from 'zova-module-a-table';
5
+
6
+ export type TypeActionDeleteResult = unknown;
7
+
8
+ export interface IActionOptionsDelete extends IDecoratorActionOptions<TypeActionDeleteResult> {
9
+ id?: string;
10
+ }
11
+
12
+ @Action<IActionOptionsDelete>()
13
+ export class ActionDelete extends BeanBase implements IActionExecute {
14
+ async execute(options: IActionOptionsDelete, renderContext: IJsxRenderContextBase, next: NextActionExecute) {
15
+ if (renderContext.$scene === 'tableCell') {
16
+ const { $celScope, cellContext } = renderContext as IJsxRenderContextTableCell;
17
+ const id = options.id ?? cellContext.row.id;
18
+ await $celScope.onActionRow?.('delete', id);
19
+ }
20
+ return next();
21
+ }
22
+ }
@@ -0,0 +1,31 @@
1
+ import { BeanBase } from 'zova';
2
+ import { Action, IActionExecute, IDecoratorActionOptions, NextActionExecute } from 'zova-module-a-action';
3
+ import { IJsxRenderContextBase } from 'zova-module-a-openapi';
4
+ import { IJsxRenderContextTableCell } from 'zova-module-a-table';
5
+
6
+ export type TypeActionEditResult = unknown;
7
+
8
+ export interface IActionOptionsEdit extends IDecoratorActionOptions<TypeActionEditResult> {
9
+ resource?: string;
10
+ id?: string;
11
+ }
12
+
13
+ @Action<IActionOptionsEdit>()
14
+ export class ActionEdit extends BeanBase implements IActionExecute {
15
+ execute(options: IActionOptionsEdit, renderContext: IJsxRenderContextBase, next: NextActionExecute) {
16
+ const { $host } = renderContext;
17
+ let resource: string | undefined;
18
+ let id: string | undefined;
19
+ if (renderContext.$scene === 'tableCell') {
20
+ const { $celScope, cellContext } = renderContext as IJsxRenderContextTableCell;
21
+ resource = options.resource ?? $celScope.resource;
22
+ id = options.id ?? cellContext.row.id;
23
+ }
24
+ if (!resource || !id) throw new Error(`should specify resource or id in scene: ${renderContext.$scene}`);
25
+ const url = $host.$router.getPagePath('/rest/resource/:resource/:id/:formScene?', {
26
+ params: { resource, id, formScene: 'edit' },
27
+ });
28
+ $host.$router.push(url);
29
+ return next();
30
+ }
31
+ }
@@ -0,0 +1,26 @@
1
+ import { BeanBase, cast } from 'zova';
2
+ import { Action, IActionExecute, IDecoratorActionOptions, NextActionExecute } from 'zova-module-a-action';
3
+ import { IJsxRenderContextFormField } from 'zova-module-a-form';
4
+ import { IJsxRenderContextBase } from 'zova-module-a-openapi';
5
+
6
+ export type TypeActionSetValueResult = unknown;
7
+
8
+ export interface IActionOptionsSetValue extends IDecoratorActionOptions<TypeActionSetValueResult> {
9
+ name?: string;
10
+ value?: any;
11
+ disableNotifyChanged?: boolean;
12
+ }
13
+
14
+ @Action<IActionOptionsSetValue>()
15
+ export class ActionSetValue extends BeanBase implements IActionExecute {
16
+ execute(options: IActionOptionsSetValue, renderContext: IJsxRenderContextBase, next: NextActionExecute) {
17
+ if (renderContext.$scene === 'formField') {
18
+ const { $celScope, $jsx, $$form } = renderContext as IJsxRenderContextFormField;
19
+ const name = options.name ?? $celScope.name;
20
+ // null means valid prop value
21
+ const value = options.value !== undefined ? options.value : cast($jsx.event?.target)?.value;
22
+ $$form.setFieldValue(name, value, options.disableNotifyChanged);
23
+ }
24
+ return next();
25
+ }
26
+ }
@@ -0,0 +1,31 @@
1
+ import { BeanBase } from 'zova';
2
+ import { Action, IActionExecute, IDecoratorActionOptions, NextActionExecute } from 'zova-module-a-action';
3
+ import { IJsxRenderContextBase } from 'zova-module-a-openapi';
4
+ import { IJsxRenderContextTableCell } from 'zova-module-a-table';
5
+
6
+ export type TypeActionViewResult = unknown;
7
+
8
+ export interface IActionOptionsView extends IDecoratorActionOptions<TypeActionViewResult> {
9
+ resource?: string;
10
+ id?: string;
11
+ }
12
+
13
+ @Action<IActionOptionsView>()
14
+ export class ActionView extends BeanBase implements IActionExecute {
15
+ execute(options: IActionOptionsView, renderContext: IJsxRenderContextBase, next: NextActionExecute) {
16
+ const { $host } = renderContext;
17
+ let resource: string | undefined;
18
+ let id: string | undefined;
19
+ if (renderContext.$scene === 'tableCell') {
20
+ const { $celScope, cellContext } = renderContext as IJsxRenderContextTableCell;
21
+ resource = options.resource ?? $celScope.resource;
22
+ id = options.id ?? cellContext.row.id;
23
+ }
24
+ if (!resource || !id) throw new Error(`should specify resource or id in scene: ${renderContext.$scene}`);
25
+ const url = $host.$router.getPagePath('/rest/resource/:resource/:id/:formScene?', {
26
+ params: { resource, id },
27
+ });
28
+ $host.$router.push(url);
29
+ return next();
30
+ }
31
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './.metadata/index.js';
2
+ export * from './types/index.js';
@@ -0,0 +1,12 @@
1
+ import type { TypeActionProvider } from 'zova-module-a-openapi';
2
+
3
+ import 'zova-module-a-action';
4
+
5
+ declare module 'zova-module-a-action' {
6
+ export interface IActionsRecord {
7
+ actionCreate?: TypeActionProvider;
8
+ actionView?: TypeActionProvider;
9
+ actionEdit?: TypeActionProvider;
10
+ actionDelete?: TypeActionProvider;
11
+ }
12
+ }
@@ -0,0 +1 @@
1
+ export * from './actions.js';