zova-module-a-command 5.1.34 → 5.1.35

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/index.js CHANGED
@@ -78,6 +78,31 @@ var BeanCommandRowBase = class extends BeanBase {
78
78
  }
79
79
  };
80
80
  //#endregion
81
+ //#region src/lib/beanCommandSelectedBase.ts
82
+ var BeanCommandSelectedBase = class extends BeanBase {
83
+ getResourceAndIds(options, renderContext) {
84
+ let resource = options.resource;
85
+ let ids = options.ids;
86
+ if (renderContext.$scene === "page") {
87
+ const { $celScope } = renderContext;
88
+ resource = resource ?? $celScope.resource;
89
+ ids = ids ?? $celScope.selection?.ids;
90
+ }
91
+ if (isNil(resource) || !ids || ids.length === 0) throw new Error(`should specify resource and selected ids in scene: ${renderContext.$scene}`);
92
+ const keys = /* @__PURE__ */ new Set();
93
+ for (const id of ids) {
94
+ if (isNil(id) || id === "") throw new Error("selected row id cannot empty");
95
+ const key = String(id);
96
+ if (keys.has(key)) throw new Error(`duplicate selected row id: ${key}`);
97
+ keys.add(key);
98
+ }
99
+ return {
100
+ resource,
101
+ ids
102
+ };
103
+ }
104
+ };
105
+ //#endregion
81
106
  //#region src/lib/command.ts
82
107
  function Command(options) {
83
108
  return createBeanDecorator("command", "sys", true, options);
@@ -86,6 +111,6 @@ function Command(options) {
86
111
  //#region src/types/command.ts
87
112
  var SymbolCommandResult = Symbol("SymbolCommandResult");
88
113
  //#endregion
89
- export { $performCommand, BeanCommandBulkBase, BeanCommandRowBase, Command, Monkey, ScopeModuleACommand, SymbolCommandResult };
114
+ export { $performCommand, BeanCommandBulkBase, BeanCommandRowBase, BeanCommandSelectedBase, Command, Monkey, ScopeModuleACommand, SymbolCommandResult };
90
115
 
91
116
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/lib/performCommand.ts","../src/monkey.ts","../src/.metadata/index.ts","../src/lib/beanCommandBulkBase.ts","../src/lib/beanCommandRowBase.ts","../src/lib/command.ts","../src/types/command.ts"],"sourcesContent":["import { beanFullNameFromOnionName, deepExtend } from 'zova';\nexport function $performCommand(sys, commandName, options, renderContext, next) {\n if (!next) {\n next = commandRes => {\n return commandRes;\n };\n }\n // command\n const beanFullName = beanFullNameFromOnionName(commandName, 'command');\n const beanInstance = sys.bean._getBeanSyncOnly(beanFullName);\n if (beanInstance) {\n // sync\n return _renderEventCommandNormal_inner(beanInstance, options, renderContext, next);\n }\n // async\n return sys.bean._getBean(beanFullName, false).then(beanInstance => {\n return _renderEventCommandNormal_inner(beanInstance, options, renderContext, next);\n });\n}\nfunction _renderEventCommandNormal_inner(beanInstance, options, renderContext, next) {\n const onionOptions = beanInstance.$onionOptions;\n // props\n const props = onionOptions ? deepExtend({}, onionOptions, options) : options ?? {};\n return beanInstance.execute(props, renderContext, next);\n}","import { BeanSimple, cast } from 'zova';\nimport { $performCommand } from './lib/performCommand.js';\nexport class Monkey extends BeanSimple {\n async beanInit(bean, beanInstance) {\n const self = this;\n bean.defineProperty(beanInstance, '$performCommand', {\n enumerable: false,\n configurable: true,\n get() {\n return function (commandName, options, renderContext, next) {\n renderContext = Object.assign({\n app: cast(beanInstance).app,\n ctx: cast(beanInstance).ctx,\n $host: beanInstance\n }, renderContext);\n return $performCommand(self.sys, commandName, options, renderContext, next);\n };\n }\n });\n }\n}","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\n// eslint-disable\n/** monkey: begin */\nexport * from '../monkey.js';\n/** monkey: end */\n/** scope: begin */\nimport { BeanScopeBase } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\nexport let ScopeModuleACommand = (_dec = Scope(), _dec2 = __z_BeanInfo({\n module: \"a-command\"\n}), _dec(_class = _dec2(_class = class ScopeModuleACommand extends BeanScopeBase {}) || _class) || _class);\nimport 'zova';\n\n/** scope: end */","import { BeanBase } from 'zova';\nexport class BeanCommandBulkBase extends BeanBase {\n getResource(options, renderContext) {\n let resource = options.resource;\n if (renderContext.$scene === 'page') {\n const {\n $celScope\n } = renderContext;\n resource = resource ?? $celScope.resource;\n }\n if (!resource) {\n throw new Error(`should specify resource in scene: ${renderContext.$scene}`);\n }\n return {\n resource\n };\n }\n}","import { isNil } from '@cabloy/utils';\nimport { BeanBase } from 'zova';\nexport class BeanCommandRowBase extends BeanBase {\n getResourceAndId(options, renderContext) {\n let resource = options.resource;\n let id = options.id;\n if (renderContext.$scene === 'tableCell') {\n const {\n $celScope,\n cellContext\n } = renderContext;\n resource = resource ?? $celScope.resource;\n id = id ?? cellContext.row.id;\n }\n if (isNil(resource) || isNil(id)) {\n throw new Error(`should specify resource or id in scene: ${renderContext.$scene}`);\n }\n return {\n resource,\n id\n };\n }\n}","import { createBeanDecorator } from 'zova';\nexport function Command(options) {\n return createBeanDecorator('command', 'sys', true, options);\n}","export const SymbolCommandResult = Symbol('SymbolCommandResult');"],"mappings":";;;;AACA,SAAgB,gBAAgB,KAAK,aAAa,SAAS,eAAe,MAAM;CAC9E,IAAI,CAAC,MACH,QAAO,eAAc;EACnB,OAAO;CACT;CAGF,MAAM,eAAe,0BAA0B,aAAa,SAAS;CACrE,MAAM,eAAe,IAAI,KAAK,iBAAiB,YAAY;CAC3D,IAAI,cAEF,OAAO,gCAAgC,cAAc,SAAS,eAAe,IAAI;CAGnF,OAAO,IAAI,KAAK,SAAS,cAAc,KAAK,CAAC,CAAC,MAAK,iBAAgB;EACjE,OAAO,gCAAgC,cAAc,SAAS,eAAe,IAAI;CACnF,CAAC;AACH;AACA,SAAS,gCAAgC,cAAc,SAAS,eAAe,MAAM;CACnF,MAAM,eAAe,aAAa;CAElC,MAAM,QAAQ,eAAe,WAAW,CAAC,GAAG,cAAc,OAAO,IAAI,WAAW,CAAC;CACjF,OAAO,aAAa,QAAQ,OAAO,eAAe,IAAI;AACxD;;;ACtBA,IAAa,SAAb,cAA4B,WAAW;CACrC,MAAM,SAAS,MAAM,cAAc;EACj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5D;;;ACHA,IAAa,sBAAsB,OAAO,qBAAqB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/lib/performCommand.ts","../src/monkey.ts","../src/.metadata/index.ts","../src/lib/beanCommandBulkBase.ts","../src/lib/beanCommandRowBase.ts","../src/lib/beanCommandSelectedBase.ts","../src/lib/command.ts","../src/types/command.ts"],"sourcesContent":["import { beanFullNameFromOnionName, deepExtend } from 'zova';\nexport function $performCommand(sys, commandName, options, renderContext, next) {\n if (!next) {\n next = commandRes => {\n return commandRes;\n };\n }\n // command\n const beanFullName = beanFullNameFromOnionName(commandName, 'command');\n const beanInstance = sys.bean._getBeanSyncOnly(beanFullName);\n if (beanInstance) {\n // sync\n return _renderEventCommandNormal_inner(beanInstance, options, renderContext, next);\n }\n // async\n return sys.bean._getBean(beanFullName, false).then(beanInstance => {\n return _renderEventCommandNormal_inner(beanInstance, options, renderContext, next);\n });\n}\nfunction _renderEventCommandNormal_inner(beanInstance, options, renderContext, next) {\n const onionOptions = beanInstance.$onionOptions;\n // props\n const props = onionOptions ? deepExtend({}, onionOptions, options) : options ?? {};\n return beanInstance.execute(props, renderContext, next);\n}","import { BeanSimple, cast } from 'zova';\nimport { $performCommand } from './lib/performCommand.js';\nexport class Monkey extends BeanSimple {\n async beanInit(bean, beanInstance) {\n const self = this;\n bean.defineProperty(beanInstance, '$performCommand', {\n enumerable: false,\n configurable: true,\n get() {\n return function (commandName, options, renderContext, next) {\n renderContext = Object.assign({\n app: cast(beanInstance).app,\n ctx: cast(beanInstance).ctx,\n $host: beanInstance\n }, renderContext);\n return $performCommand(self.sys, commandName, options, renderContext, next);\n };\n }\n });\n }\n}","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\n// eslint-disable\n/** monkey: begin */\nexport * from '../monkey.js';\n/** monkey: end */\n/** scope: begin */\nimport { BeanScopeBase } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\nexport let ScopeModuleACommand = (_dec = Scope(), _dec2 = __z_BeanInfo({\n module: \"a-command\"\n}), _dec(_class = _dec2(_class = class ScopeModuleACommand extends BeanScopeBase {}) || _class) || _class);\nimport 'zova';\n\n/** scope: end */","import { BeanBase } from 'zova';\nexport class BeanCommandBulkBase extends BeanBase {\n getResource(options, renderContext) {\n let resource = options.resource;\n if (renderContext.$scene === 'page') {\n const {\n $celScope\n } = renderContext;\n resource = resource ?? $celScope.resource;\n }\n if (!resource) {\n throw new Error(`should specify resource in scene: ${renderContext.$scene}`);\n }\n return {\n resource\n };\n }\n}","import { isNil } from '@cabloy/utils';\nimport { BeanBase } from 'zova';\nexport class BeanCommandRowBase extends BeanBase {\n getResourceAndId(options, renderContext) {\n let resource = options.resource;\n let id = options.id;\n if (renderContext.$scene === 'tableCell') {\n const {\n $celScope,\n cellContext\n } = renderContext;\n resource = resource ?? $celScope.resource;\n id = id ?? cellContext.row.id;\n }\n if (isNil(resource) || isNil(id)) {\n throw new Error(`should specify resource or id in scene: ${renderContext.$scene}`);\n }\n return {\n resource,\n id\n };\n }\n}","import { isNil } from '@cabloy/utils';\nimport { BeanBase } from 'zova';\nexport class BeanCommandSelectedBase extends BeanBase {\n getResourceAndIds(options, renderContext) {\n let resource = options.resource;\n let ids = options.ids;\n if (renderContext.$scene === 'page') {\n const {\n $celScope\n } = renderContext;\n resource = resource ?? $celScope.resource;\n ids = ids ?? $celScope.selection?.ids;\n }\n if (isNil(resource) || !ids || ids.length === 0) {\n throw new Error(`should specify resource and selected ids in scene: ${renderContext.$scene}`);\n }\n const keys = new Set();\n for (const id of ids) {\n if (isNil(id) || id === '') throw new Error('selected row id cannot empty');\n const key = String(id);\n if (keys.has(key)) throw new Error(`duplicate selected row id: ${key}`);\n keys.add(key);\n }\n return {\n resource,\n ids\n };\n }\n}","import { createBeanDecorator } from 'zova';\nexport function Command(options) {\n return createBeanDecorator('command', 'sys', true, options);\n}","export const SymbolCommandResult = Symbol('SymbolCommandResult');"],"mappings":";;;;AACA,SAAgB,gBAAgB,KAAK,aA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;;ACHA,IAAa,sBAAsB,OAAO,qBAAqB"}
@@ -0,0 +1,11 @@
1
+ import type { TableIdentity } from 'table-identity';
2
+ import type { IJsxRenderContextBase } from 'zova-module-a-openapi';
3
+ import { BeanBase } from 'zova';
4
+ import type { ICommandSelectedOptionsBase } from '../types/command.js';
5
+ export declare class BeanCommandSelectedBase extends BeanBase {
6
+ getResourceAndIds(options: ICommandSelectedOptionsBase, renderContext: IJsxRenderContextBase): {
7
+ resource: string;
8
+ ids: readonly TableIdentity[];
9
+ };
10
+ }
11
+ //# sourceMappingURL=beanCommandSelectedBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"beanCommandSelectedBase.d.ts","sourceRoot":"","sources":["../../src/lib/beanCommandSelectedBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAyB,MAAM,uBAAuB,CAAC;AAG1F,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAEvE,qBAAa,uBAAwB,SAAQ,QAAQ;IACnD,iBAAiB,CACf,OAAO,EAAE,2BAA2B,EACpC,aAAa,EAAE,qBAAqB,GACnC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,SAAS,aAAa,EAAE,CAAA;KAAE;CAoBvD"}
@@ -1,5 +1,6 @@
1
1
  export * from './beanCommandBulkBase.js';
2
2
  export * from './beanCommandRowBase.js';
3
+ export * from './beanCommandSelectedBase.js';
3
4
  export * from './command.js';
4
5
  export * from './performCommand.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
@@ -26,6 +26,10 @@ export interface ICommandRowOptionsBase<Result = any> extends ICommandOptionsBas
26
26
  resource?: string;
27
27
  id?: TableIdentity;
28
28
  }
29
+ export interface ICommandSelectedOptionsBase<Result = any> extends ICommandOptionsBase<Result> {
30
+ resource?: string;
31
+ ids?: readonly TableIdentity[];
32
+ }
29
33
  export interface ICommandDetailsRowOptionsBase<Result = any> extends ICommandOptionsBase<Result> {
30
34
  }
31
35
  declare module 'zova-module-a-bean' {
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/types/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,eAAO,MAAM,mBAAmB,eAAgC,CAAC;AAEjE,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,cAAc,IAAI;IAC/D,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,OAAO,mBAAmB,CAAC,CAAC;IAC9D,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;AAEnE,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ACpB;AAED,MAAM,WAAW,2BAA2B,CAAC,MAAM,GAAG,GAAG,CAAE,SAAQ,mBAAmB,CAAC,MAAM,CAAC;IAC5F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,6BAA6B,CAAC,MAAM,GAAG,GAAG,CAAE,SAAQ,mBAAmB,CAAC,MAAM,CAAC;CAAG;AAEnG,OAAO,QAAQ,oBAAoB,CAAC;IAClC,UAAiB,QAAQ;QACvB,OAAO,EAAE,YAAY,CAAC,wBAAwB,EAAE,MAAM,cAAc,CAAC,CAAC;KACvE;CACF;AAED,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAiB,YAAY;QAC3B,OAAO,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;KACpC;IAED,UAAiB,gBAAgB;QAC/B,OAAO,EAAE,KAAK,CAAC;KAChB;CACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zova-module-a-command",
3
- "version": "5.1.34",
4
- "gitHead": "eb85d771ef75776a439e56df3af8be6a3a36c1c2",
3
+ "version": "5.1.35",
4
+ "gitHead": "8ecb407bf2c0bb2e28592206ca1a39f37ab50902",
5
5
  "description": "",
6
6
  "keywords": [
7
7
  "Zova Module"
@@ -0,0 +1,33 @@
1
+ import type { TableIdentity } from 'table-identity';
2
+ import type { IJsxRenderContextBase, IJsxRenderContextPage } from 'zova-module-a-openapi';
3
+
4
+ import { isNil } from '@cabloy/utils';
5
+ import { BeanBase } from 'zova';
6
+
7
+ import type { ICommandSelectedOptionsBase } from '../types/command.js';
8
+
9
+ export class BeanCommandSelectedBase extends BeanBase {
10
+ getResourceAndIds(
11
+ options: ICommandSelectedOptionsBase,
12
+ renderContext: IJsxRenderContextBase,
13
+ ): { resource: string; ids: readonly TableIdentity[] } {
14
+ let resource: string | undefined = options.resource;
15
+ let ids = options.ids;
16
+ if (renderContext.$scene === 'page') {
17
+ const { $celScope } = renderContext as IJsxRenderContextPage;
18
+ resource = resource ?? $celScope.resource;
19
+ ids = ids ?? $celScope.selection?.ids;
20
+ }
21
+ if (isNil(resource) || !ids || ids.length === 0) {
22
+ throw new Error(`should specify resource and selected ids in scene: ${renderContext.$scene}`);
23
+ }
24
+ const keys = new Set<string>();
25
+ for (const id of ids) {
26
+ if (isNil(id) || id === '') throw new Error('selected row id cannot empty');
27
+ const key = String(id);
28
+ if (keys.has(key)) throw new Error(`duplicate selected row id: ${key}`);
29
+ keys.add(key);
30
+ }
31
+ return { resource, ids };
32
+ }
33
+ }
package/src/lib/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './beanCommandBulkBase.js';
2
2
  export * from './beanCommandRowBase.js';
3
+ export * from './beanCommandSelectedBase.js';
3
4
  export * from './command.js';
4
5
  export * from './performCommand.js';
@@ -40,6 +40,11 @@ export interface ICommandRowOptionsBase<Result = any> extends ICommandOptionsBas
40
40
  id?: TableIdentity;
41
41
  }
42
42
 
43
+ export interface ICommandSelectedOptionsBase<Result = any> extends ICommandOptionsBase<Result> {
44
+ resource?: string;
45
+ ids?: readonly TableIdentity[];
46
+ }
47
+
43
48
  export interface ICommandDetailsRowOptionsBase<Result = any> extends ICommandOptionsBase<Result> {}
44
49
 
45
50
  declare module 'zova-module-a-bean' {