zova-module-a-command 5.1.18 → 5.1.20

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.
@@ -0,0 +1,15 @@
1
+ import type { IJsxRenderContextBase } from 'zova-module-a-openapi';
2
+
3
+ import { BeanCommandBulkBase, Command, type ICommandBulkOptionsBase, type ICommandExecute, type NextCommandExecute } from 'zova-module-a-command';
4
+
5
+ export type TypeCommand<%=argv.beanNameCapitalize%>Result = unknown;
6
+
7
+ export interface ICommandOptions<%=argv.beanNameCapitalize%> extends ICommandBulkOptionsBase<TypeCommand<%=argv.beanNameCapitalize%>Result> {}
8
+
9
+ @Command<ICommandOptions<%=argv.beanNameCapitalize%>>()
10
+ export class Command<%=argv.beanNameCapitalize%> extends BeanCommandBulkBase implements ICommandExecute {
11
+ execute(options: ICommandOptions<%=argv.beanNameCapitalize%>, renderContext: IJsxRenderContextBase, next: NextCommandExecute) {
12
+ const { resource } = this.getResource(options, renderContext);
13
+ return next();
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ import type { IJsxRenderContextBase } from 'zova-module-a-openapi';
2
+
3
+ import { BeanCommandRowBase, Command, type ICommandExecute, type ICommandRowOptionsBase, type NextCommandExecute } from 'zova-module-a-command';
4
+
5
+ export type TypeCommand<%=argv.beanNameCapitalize%>Result = unknown;
6
+
7
+ export interface ICommandOptions<%=argv.beanNameCapitalize%> extends ICommandRowOptionsBase<TypeCommand<%=argv.beanNameCapitalize%>Result> {}
8
+
9
+ @Command<ICommandOptions<%=argv.beanNameCapitalize%>>()
10
+ export class Command<%=argv.beanNameCapitalize%> extends BeanCommandRowBase implements ICommandExecute {
11
+ execute(options: ICommandOptions<%=argv.beanNameCapitalize%>, renderContext: IJsxRenderContextBase, next: NextCommandExecute) {
12
+ const { resource, id } = this.getResourceAndId(options, renderContext);
13
+ return next();
14
+ }
15
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/.metadata/index.ts"],"names":[],"mappings":"AACA,oBAAoB;AACpB,cAAc,cAAc,CAAC;AAC7B,kBAAkB;AAClB,mBAAmB;AACnB,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAGzD,qBACa,mBAAoB,SAAQ,aAAa;CAAG;AAEzD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,OAAO,MAAM,CAAC;AACd,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAiB,gBAAgB;QAC/B,WAAW,EAAE,mBAAmB,CAAC;KAClC;CAMF;AAED,iBAAiB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/.metadata/index.ts"],"names":[],"mappings":"AACA,oBAAoB;AACpB,cAAc,cAAc,CAAC;AAC7B,kBAAkB;AAClB,mBAAmB;AACnB,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAGzD,qBACa,mBAAoB,SAAQ,aAAa;CAAG;AAEzD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,OAAO,MAAM,CAAC;AACd,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAiB,gBAAgB;QAC/B,WAAW,EAAE,mBAAmB,CAAC;KAClC;CAOF;AAED,iBAAiB"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
- import { BeanInfo, BeanScopeBase, BeanSimple, beanFullNameFromOnionName, cast, createBeanDecorator, deepExtend } from "zova";
1
+ import { BeanBase, BeanInfo, BeanScopeBase, BeanSimple, beanFullNameFromOnionName, cast, createBeanDecorator, deepExtend } from "zova";
2
2
  import { Scope } from "zova-module-a-bean";
3
+ import { isNil } from "@cabloy/utils";
3
4
  //#region src/lib/performCommand.ts
4
5
  function $performCommand(sys, commandName, options, renderContext, next) {
5
6
  if (!next) next = (commandRes) => {
@@ -51,9 +52,40 @@ function Command(options) {
51
52
  return createBeanDecorator("command", "sys", true, options);
52
53
  }
53
54
  //#endregion
55
+ //#region src/lib/beanCommandBulkBase.ts
56
+ var BeanCommandBulkBase = class extends BeanBase {
57
+ getResource(options, renderContext) {
58
+ let resource = options.resource;
59
+ if (renderContext.$scene === "page") {
60
+ const { $celScope } = renderContext;
61
+ resource = resource ?? $celScope.resource;
62
+ }
63
+ if (!resource) throw new Error(`should specify resource in scene: ${renderContext.$scene}`);
64
+ return { resource };
65
+ }
66
+ };
67
+ //#endregion
68
+ //#region src/lib/beanCommandRowBase.ts
69
+ var BeanCommandRowBase = class extends BeanBase {
70
+ getResourceAndId(options, renderContext) {
71
+ let resource = options.resource;
72
+ let id = options.id;
73
+ if (renderContext.$scene === "tableCell") {
74
+ const { $celScope, cellContext } = renderContext;
75
+ resource = resource ?? $celScope.resource;
76
+ id = id ?? cellContext.row.id;
77
+ }
78
+ if (isNil(resource) || isNil(id)) throw new Error(`should specify resource or id in scene: ${renderContext.$scene}`);
79
+ return {
80
+ resource,
81
+ id
82
+ };
83
+ }
84
+ };
85
+ //#endregion
54
86
  //#region src/types/command.ts
55
87
  var SymbolCommandResult = Symbol("SymbolCommandResult");
56
88
  //#endregion
57
- export { $performCommand, Command, Monkey, ScopeModuleACommand, SymbolCommandResult };
89
+ export { $performCommand, BeanCommandBulkBase, BeanCommandRowBase, Command, Monkey, ScopeModuleACommand, SymbolCommandResult };
58
90
 
59
91
  //# 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/command.ts","../src/types/command.ts"],"sourcesContent":["import type { ZovaSys } from 'zova';\nimport type { IJsxRenderContextBase } from 'zova-module-a-openapi';\n\nimport { beanFullNameFromOnionName, deepExtend } from 'zova';\n\nimport type { ICommandRecord, SymbolCommandResult } from '../types/command.js';\n\nexport function $performCommand<T extends keyof ICommandRecord>(\n sys: ZovaSys,\n commandName: T,\n options: Partial<ICommandRecord[T]> | undefined,\n renderContext: IJsxRenderContextBase,\n next?: Function,\n): ICommandRecord[T][typeof SymbolCommandResult] {\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}\n\nfunction _renderEventCommandNormal_inner(\n beanInstance: any,\n options: {} | undefined,\n renderContext: IJsxRenderContextBase,\n next?: Function,\n) {\n const onionOptions = beanInstance.$onionOptions;\n // props\n const props = onionOptions ? deepExtend({}, onionOptions, options) : (options ?? {});\n return beanInstance.execute(props, renderContext, next);\n}\n","import type { BeanBase, BeanContainer, IMonkeyBeanInit } from 'zova';\nimport type { IJsxRenderContextBase } from 'zova-module-a-openapi';\n\nimport { BeanSimple, cast } from 'zova';\n\nimport type { ICommandRecord } from './types/command.js';\n\nimport { $performCommand } from './lib/performCommand.js';\n\nexport class Monkey extends BeanSimple implements IMonkeyBeanInit {\n async beanInit(bean: BeanContainer, beanInstance: BeanBase) {\n const self = this;\n bean.defineProperty(beanInstance, '$performCommand', {\n enumerable: false,\n configurable: true,\n get() {\n return function <T extends keyof ICommandRecord>(\n commandName: T,\n options: Partial<ICommandRecord[T]> | undefined,\n renderContext?: IJsxRenderContextBase,\n next?: Function,\n ) {\n renderContext = Object.assign(\n {\n app: cast(beanInstance).app,\n ctx: cast(beanInstance).ctx,\n $host: beanInstance,\n },\n renderContext,\n );\n return $performCommand(self.sys, commandName, options, renderContext, next);\n };\n },\n });\n }\n}\n","// eslint-disable\n/** monkey: begin */\nexport * from '../monkey.js';\n/** monkey: end */\n/** scope: begin */\nimport { BeanScopeBase, type BeanScopeUtil } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\n\n@Scope()\nexport class ScopeModuleACommand extends BeanScopeBase {}\n\nexport interface ScopeModuleACommand {\n util: BeanScopeUtil;\n}\n\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanScopeRecord {\n 'a-command': ScopeModuleACommand;\n }\n\n\n\n\n\n}\n\n/** scope: end */\n","import type { PowerPartial } from 'zova';\n\nimport { createBeanDecorator } from 'zova';\n\nimport type { IDecoratorCommandOptions } from '../types/command.js';\n\nexport function Command<T extends IDecoratorCommandOptions>(\n options?: PowerPartial<T>,\n): ClassDecorator {\n return createBeanDecorator('command', 'sys', true, options);\n}\n","import type { OmitNever } from 'zova';\nimport type { ServiceOnion } from 'zova-module-a-bean';\nimport type { IJsxRenderContextBase } from 'zova-module-a-openapi';\n\nimport { TableIdentity } from 'table-identity';\n\nexport const SymbolCommandResult = Symbol('SymbolCommandResult');\n\nexport type TypeCommandOptions<K extends keyof ICommandRecord> = {\n name: K;\n options?: Omit<ICommandRecord[K], typeof SymbolCommandResult>;\n res?: string;\n};\n\nexport type NextCommandExecute = (res?: any) => any | Promise<any>;\n\nexport interface ICommandRecord {}\n\nexport interface ICommandExecute {\n execute(options: IDecoratorCommandOptions, renderContext: IJsxRenderContextBase, next: NextCommandExecute): any | Promise<any>;\n}\n\nexport interface IDecoratorCommandOptions<Result = any> {\n [SymbolCommandResult]: Result;\n // res?: string; // need not define here\n}\n\nexport interface ICommandOptionsBase<Result = any> extends IDecoratorCommandOptions<Result> {}\n\nexport interface ICommandBulkOptionsBase<Result = any> extends ICommandOptionsBase<Result> {\n resource?: string;\n}\n\nexport interface ICommandRowOptionsBase<Result = any> extends ICommandOptionsBase<Result> {\n resource?: string;\n id?: TableIdentity;\n}\n\ndeclare module 'zova-module-a-bean' {\n export interface SysOnion {\n command: ServiceOnion<IDecoratorCommandOptions, keyof ICommandRecord>;\n }\n}\n\ndeclare module 'zova' {\n export interface ConfigOnions {\n command: OmitNever<ICommandRecord>;\n }\n\n export interface IBeanSceneRecord {\n command: never;\n }\n}\n"],"mappings":";;;AACA,SAAc,gBAAA,KAAuB,aAAY,SAAS,eAAQ,MAAA;WAElE,SAAS,eAAA;;;CAKP,MAAK,eAAO,0BAAA,aAAA,UAAA;CACZ,MAAA,eAAc,IAAA,KAAA,iBAAA,aAAA;AACd,KAAA,aAEA,QAAO,gCAAQ,cAAA,SAAA,eAAA,KAAA;AAGf,QAAO,IAAE,KAAA,SAAc,cAAA,MAAA,CAAA,MAAA,iBAAA;AACrB,SAAE,gCAAiB,cAAA,SAAA,eAAA,KAAA;GACnB;;AAEJ,SAAK,gCAAA,cAAA,SAAA,eAAA,MAAA;CACH,MAAM,eAAe,aAAA;CAErB,MAAI,QAAA,eAAc,WAAA,EAAA,EAAA,cAAA,QAAA,GAAA,WAAA,EAAA;AAClB,QAAK,aAAA,QAAA,OAAA,eAAA,KAAA;;;;;CCpBP,MAAQ,SAAC,MAAY,cAAa;;AAElC,OAAO,eAAO,cAAwB,mBAAkB;;GAElD,cAAI;;AAEH,WAAM,SAAO,aAAkB,SAAC,eAAW,MAAgB;AAC1D,qBAAe,OAAA,OAAe;MAC5B,KAAO,KAAI,aAAA,CAAA;MACZ,KAAA,KAAA,aAAe,CAAY;MAC9B,OAAY;MACZ,EAAA,cAAkB;AACd,YAAE,gBAAA,KAAA,KAAA,aAAA,SAAA,eAAA,KAAA;;;GAGP,CAAC;;;;;;;AClBN,IAAG,MAAO,OAAA;AASV,IAAO,uBAA0B,OAAQ,OAAA,EAAA,QAAe,SAAA,EAAA,QAAA,aAExD,CAAA,EAAA,KAAO,SAAU,MAAA,SAAA,MAAoB,4BAAA,cAAA,GAAA,IAAA,OAAA,IAAA;;;;;ACTrC,QAAS,oBAAoB,WAAQ,OAAK,MAAA,QAAA;;;;ACF1C,IAAa,sBAAmB,OAAK,sBAAA"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/lib/performCommand.ts","../src/monkey.ts","../src/.metadata/index.ts","../src/lib/command.ts","../src/lib/beanCommandBulkBase.ts","../src/lib/beanCommandRowBase.ts","../src/types/command.ts"],"sourcesContent":["import type { ZovaSys } from 'zova';\nimport type { IJsxRenderContextBase } from 'zova-module-a-openapi';\n\nimport { beanFullNameFromOnionName, deepExtend } from 'zova';\n\nimport type { ICommandRecord, SymbolCommandResult } from '../types/command.js';\n\nexport function $performCommand<T extends keyof ICommandRecord>(\n sys: ZovaSys,\n commandName: T,\n options: Partial<ICommandRecord[T]> | undefined,\n renderContext: IJsxRenderContextBase,\n next?: Function,\n): ICommandRecord[T][typeof SymbolCommandResult] {\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}\n\nfunction _renderEventCommandNormal_inner(\n beanInstance: any,\n options: {} | undefined,\n renderContext: IJsxRenderContextBase,\n next?: Function,\n) {\n const onionOptions = beanInstance.$onionOptions;\n // props\n const props = onionOptions ? deepExtend({}, onionOptions, options) : (options ?? {});\n return beanInstance.execute(props, renderContext, next);\n}\n","import type { BeanBase, BeanContainer, IMonkeyBeanInit } from 'zova';\nimport type { IJsxRenderContextBase } from 'zova-module-a-openapi';\n\nimport { BeanSimple, cast } from 'zova';\n\nimport type { ICommandRecord } from './types/command.js';\n\nimport { $performCommand } from './lib/performCommand.js';\n\nexport class Monkey extends BeanSimple implements IMonkeyBeanInit {\n async beanInit(bean: BeanContainer, beanInstance: BeanBase) {\n const self = this;\n bean.defineProperty(beanInstance, '$performCommand', {\n enumerable: false,\n configurable: true,\n get() {\n return function <T extends keyof ICommandRecord>(\n commandName: T,\n options: Partial<ICommandRecord[T]> | undefined,\n renderContext?: IJsxRenderContextBase,\n next?: Function,\n ) {\n renderContext = Object.assign(\n {\n app: cast(beanInstance).app,\n ctx: cast(beanInstance).ctx,\n $host: beanInstance,\n },\n renderContext,\n );\n return $performCommand(self.sys, commandName, options, renderContext, next);\n };\n },\n });\n }\n}\n","// eslint-disable\n/** monkey: begin */\nexport * from '../monkey.js';\n/** monkey: end */\n/** scope: begin */\nimport { BeanScopeBase, type BeanScopeUtil } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\n\n@Scope()\nexport class ScopeModuleACommand extends BeanScopeBase {}\n\nexport interface ScopeModuleACommand {\n util: BeanScopeUtil;\n}\n\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanScopeRecord {\n 'a-command': ScopeModuleACommand;\n }\n \n \n\n \n\n \n}\n \n/** scope: end */\n","import type { PowerPartial } from 'zova';\n\nimport { createBeanDecorator } from 'zova';\n\nimport type { IDecoratorCommandOptions } from '../types/command.js';\n\nexport function Command<T extends IDecoratorCommandOptions>(\n options?: PowerPartial<T>,\n): ClassDecorator {\n return createBeanDecorator('command', 'sys', true, options);\n}\n","import type { IJsxRenderContextBase, IJsxRenderContextPage } from 'zova-module-a-openapi';\n\nimport { BeanBase } from 'zova';\n\nimport type { ICommandBulkOptionsBase } from '../types/command.js';\n\nexport class BeanCommandBulkBase extends BeanBase {\n getResource(options: ICommandBulkOptionsBase, renderContext: IJsxRenderContextBase) {\n let resource: string | undefined = options.resource;\n if (renderContext.$scene === 'page') {\n const { $celScope } = renderContext as IJsxRenderContextPage;\n resource = resource ?? $celScope.resource;\n }\n if (!resource) {\n throw new Error(`should specify resource in scene: ${renderContext.$scene}`);\n }\n return { resource };\n }\n}\n","import type { IJsxRenderContextBase } from 'zova-module-a-openapi';\nimport type { IJsxRenderContextTableCell } from 'zova-module-a-table';\n\nimport { isNil } from '@cabloy/utils';\nimport { TableIdentity } from 'table-identity';\nimport { BeanBase } from 'zova';\n\nimport type { ICommandRowOptionsBase } from '../types/command.js';\n\nexport class BeanCommandRowBase extends BeanBase {\n getResourceAndId(options: ICommandRowOptionsBase, renderContext: IJsxRenderContextBase) {\n let resource: string | undefined = options.resource;\n let id: TableIdentity | undefined = options.id;\n if (renderContext.$scene === 'tableCell') {\n const { $celScope, cellContext } = renderContext as IJsxRenderContextTableCell;\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 { resource, id };\n }\n}\n","import type { OmitNever } from 'zova';\nimport type { ServiceOnion } from 'zova-module-a-bean';\nimport type { IJsxRenderContextBase } from 'zova-module-a-openapi';\n\nimport { TableIdentity } from 'table-identity';\n\nexport const SymbolCommandResult = Symbol('SymbolCommandResult');\n\nexport type TypeCommandOptions<K extends keyof ICommandRecord> = {\n name: K;\n options?: Omit<ICommandRecord[K], typeof SymbolCommandResult>;\n res?: string;\n};\n\nexport type NextCommandExecute = (res?: any) => any | Promise<any>;\n\nexport interface ICommandRecord {}\n\nexport interface ICommandExecute {\n execute(options: IDecoratorCommandOptions, renderContext: IJsxRenderContextBase, next: NextCommandExecute): any | Promise<any>;\n}\n\nexport interface IDecoratorCommandOptions<Result = any> {\n [SymbolCommandResult]: Result;\n // res?: string; // need not define here\n}\n\nexport interface ICommandOptionsBase<Result = any> extends IDecoratorCommandOptions<Result> {}\n\nexport interface ICommandBulkOptionsBase<Result = any> extends ICommandOptionsBase<Result> {\n resource?: string;\n}\n\nexport interface ICommandRowOptionsBase<Result = any> extends ICommandOptionsBase<Result> {\n resource?: string;\n id?: TableIdentity;\n}\n\ndeclare module 'zova-module-a-bean' {\n export interface SysOnion {\n command: ServiceOnion<IDecoratorCommandOptions, keyof ICommandRecord>;\n }\n}\n\ndeclare module 'zova' {\n export interface ConfigOnions {\n command: OmitNever<ICommandRecord>;\n }\n\n export interface IBeanSceneRecord {\n command: never;\n }\n}\n"],"mappings":";;;;AACA,SAAc,gBAAA,KAAuB,aAAY,SAAS,eAAQ,MAAA;WAElE,SAAS,eAAA;;;CAKP,MAAK,eAAO,0BAAA,aAAA,UAAA;CACZ,MAAA,eAAc,IAAA,KAAA,iBAAA,aAAA;AACd,KAAA,aAEA,QAAO,gCAAQ,cAAA,SAAA,eAAA,KAAA;AAGf,QAAO,IAAE,KAAA,SAAc,cAAA,MAAA,CAAA,MAAA,iBAAA;AACrB,SAAE,gCAAiB,cAAA,SAAA,eAAA,KAAA;GACnB;;AAEJ,SAAK,gCAAA,cAAA,SAAA,eAAA,MAAA;CACH,MAAM,eAAe,aAAA;CAErB,MAAI,QAAA,eAAc,WAAA,EAAA,EAAA,cAAA,QAAA,GAAA,WAAA,EAAA;AAClB,QAAK,aAAA,QAAA,OAAA,eAAA,KAAA;;;;;CCpBP,MAAQ,SAAC,MAAY,cAAa;;AAElC,OAAO,eAAO,cAAwB,mBAAkB;;GAElD,cAAI;;AAEH,WAAM,SAAO,aAAkB,SAAC,eAAW,MAAgB;AAC1D,qBAAe,OAAA,OAAe;MAC5B,KAAO,KAAI,aAAA,CAAA;MACZ,KAAA,KAAA,aAAe,CAAY;MAC9B,OAAY;MACZ,EAAA,cAAkB;AACd,YAAE,gBAAA,KAAA,KAAA,aAAA,SAAA,eAAA,KAAA;;;GAGP,CAAC;;;;;;;AClBN,IAAG,MAAO,OAAA;AASV,IAAO,uBAA0B,OAAQ,OAAA,EAAA,QAAe,SAAA,EAAA,QAAA,aAExD,CAAA,EAAA,KAAO,SAAU,MAAA,SAAA,MAAoB,4BAAA,cAAA,GAAA,IAAA,OAAA,IAAA;;;;;ACTrC,QAAS,oBAAoB,WAAQ,OAAK,MAAA,QAAA;;;;;CCA1C,YAAS,SAAW,eAAW;;AAE/B,MAAO,cAAO,WAAA,QAA0B;WAEjC,cACL;AACE,cAAa,YAAU,UAAY;;AAEnC,MAAE,CAAA,SACA,OAAA,IAAU,MAAC,qCAA8B,cAAA,SAAA;AAE3C,SAAK,EACH,UACF;;;;;;CCZJ,iBAAiB,SAAO,eAAa;EACrC,IAAQ,WAAC,QAAgB;EACzB,IAAQ,KAAC,QAAW;;GAEd,MAAM,EAAA,WAEL,gBACL;AACE,cAAa,YAAU,UAAY;AACnC,QAAO,MAAC,YAAgB,IAAA;;AAExB,MAAE,MAAQ,SAAS,IAAE,MAAA,GAAW,CAC9B,OAAA,IAAU,MAAC,2CAA8B,cAAA,SAAA;AAE3C,SAAA;GACE;GACA;GACF;;;;;ACpBJ,IAAa,sBAAmB,OAAK,sBAAA"}
@@ -0,0 +1,9 @@
1
+ import type { IJsxRenderContextBase } from 'zova-module-a-openapi';
2
+ import { BeanBase } from 'zova';
3
+ import type { ICommandBulkOptionsBase } from '../types/command.js';
4
+ export declare class BeanCommandBulkBase extends BeanBase {
5
+ getResource(options: ICommandBulkOptionsBase, renderContext: IJsxRenderContextBase): {
6
+ resource: string;
7
+ };
8
+ }
9
+ //# sourceMappingURL=beanCommandBulkBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"beanCommandBulkBase.d.ts","sourceRoot":"","sources":["../../src/lib/beanCommandBulkBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAyB,MAAM,uBAAuB,CAAC;AAE1F,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,qBAAa,mBAAoB,SAAQ,QAAQ;IAC/C,WAAW,CAAC,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,qBAAqB;;;CAWnF"}
@@ -0,0 +1,11 @@
1
+ import type { IJsxRenderContextBase } from 'zova-module-a-openapi';
2
+ import { TableIdentity } from 'table-identity';
3
+ import { BeanBase } from 'zova';
4
+ import type { ICommandRowOptionsBase } from '../types/command.js';
5
+ export declare class BeanCommandRowBase extends BeanBase {
6
+ getResourceAndId(options: ICommandRowOptionsBase, renderContext: IJsxRenderContextBase): {
7
+ resource: string;
8
+ id: TableIdentity;
9
+ };
10
+ }
11
+ //# sourceMappingURL=beanCommandRowBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"beanCommandRowBase.d.ts","sourceRoot":"","sources":["../../src/lib/beanCommandRowBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAInE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,qBAAa,kBAAmB,SAAQ,QAAQ;IAC9C,gBAAgB,CAAC,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,qBAAqB;;;;CAavF"}
@@ -1,3 +1,5 @@
1
1
  export * from './command.js';
2
2
  export * from './performCommand.js';
3
+ export * from './beanCommandBulkBase.js';
4
+ export * from './beanCommandRowBase.js';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zova-module-a-command",
3
- "version": "5.1.18",
4
- "gitHead": "67d21659b3d827cb503706a52bfdd7fb2f63e76d",
3
+ "version": "5.1.20",
4
+ "gitHead": "8edb6021cb1a8999e38b3809ef607fdeaf56d5f2",
5
5
  "description": "",
6
6
  "keywords": [
7
7
  "Zova Module"
@@ -37,7 +37,9 @@
37
37
  "beanGeneral": true,
38
38
  "optionsGlobalInterfaceName": "IDecoratorCommandOptions",
39
39
  "optionsGlobalInterfaceFrom": "zova-module-a-command",
40
- "boilerplate": "command/boilerplate"
40
+ "boilerplate": "command/boilerplate",
41
+ "boilerplateCommandBulk": "commandBulk/boilerplate",
42
+ "boilerplateCommandRow": "commandRow/boilerplate"
41
43
  }
42
44
  },
43
45
  "capabilities": {
@@ -18,11 +18,12 @@ declare module 'zova' {
18
18
  export interface IBeanScopeRecord {
19
19
  'a-command': ScopeModuleACommand;
20
20
  }
21
+
22
+
21
23
 
24
+
22
25
 
23
-
24
-
25
-
26
+
26
27
  }
27
-
28
+
28
29
  /** scope: end */
@@ -0,0 +1,19 @@
1
+ import type { IJsxRenderContextBase, IJsxRenderContextPage } from 'zova-module-a-openapi';
2
+
3
+ import { BeanBase } from 'zova';
4
+
5
+ import type { ICommandBulkOptionsBase } from '../types/command.js';
6
+
7
+ export class BeanCommandBulkBase extends BeanBase {
8
+ getResource(options: ICommandBulkOptionsBase, renderContext: IJsxRenderContextBase) {
9
+ let resource: string | undefined = options.resource;
10
+ if (renderContext.$scene === 'page') {
11
+ const { $celScope } = renderContext as IJsxRenderContextPage;
12
+ resource = resource ?? $celScope.resource;
13
+ }
14
+ if (!resource) {
15
+ throw new Error(`should specify resource in scene: ${renderContext.$scene}`);
16
+ }
17
+ return { resource };
18
+ }
19
+ }
@@ -0,0 +1,24 @@
1
+ import type { IJsxRenderContextBase } from 'zova-module-a-openapi';
2
+ import type { IJsxRenderContextTableCell } from 'zova-module-a-table';
3
+
4
+ import { isNil } from '@cabloy/utils';
5
+ import { TableIdentity } from 'table-identity';
6
+ import { BeanBase } from 'zova';
7
+
8
+ import type { ICommandRowOptionsBase } from '../types/command.js';
9
+
10
+ export class BeanCommandRowBase extends BeanBase {
11
+ getResourceAndId(options: ICommandRowOptionsBase, renderContext: IJsxRenderContextBase) {
12
+ let resource: string | undefined = options.resource;
13
+ let id: TableIdentity | undefined = options.id;
14
+ if (renderContext.$scene === 'tableCell') {
15
+ const { $celScope, cellContext } = renderContext as IJsxRenderContextTableCell;
16
+ resource = resource ?? $celScope.resource;
17
+ id = id ?? cellContext.row.id;
18
+ }
19
+ if (isNil(resource) || isNil(id)) {
20
+ throw new Error(`should specify resource or id in scene: ${renderContext.$scene}`);
21
+ }
22
+ return { resource, id };
23
+ }
24
+ }
package/src/lib/index.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from './command.js';
2
2
  export * from './performCommand.js';
3
+ export * from './beanCommandBulkBase.js';
4
+ export * from './beanCommandRowBase.js';