zova-module-a-command 5.1.24 → 5.1.25
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 +0 -0
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +10 -7
- package/src/lib/index.ts +2 -2
- package/src/types/index.ts +1 -1
package/LICENSE
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -47,11 +47,6 @@ var _dec, _dec2, _class;
|
|
|
47
47
|
var ScopeModuleACommand = (_dec = Scope(), _dec2 = BeanInfo({ module: "a-command" }), _dec(_class = _dec2(_class = class ScopeModuleACommand extends BeanScopeBase {}) || _class) || _class);
|
|
48
48
|
/** scope: end */
|
|
49
49
|
//#endregion
|
|
50
|
-
//#region src/lib/command.ts
|
|
51
|
-
function Command(options) {
|
|
52
|
-
return createBeanDecorator("command", "sys", true, options);
|
|
53
|
-
}
|
|
54
|
-
//#endregion
|
|
55
50
|
//#region src/lib/beanCommandBulkBase.ts
|
|
56
51
|
var BeanCommandBulkBase = class extends BeanBase {
|
|
57
52
|
getResource(options, renderContext) {
|
|
@@ -83,6 +78,11 @@ var BeanCommandRowBase = class extends BeanBase {
|
|
|
83
78
|
}
|
|
84
79
|
};
|
|
85
80
|
//#endregion
|
|
81
|
+
//#region src/lib/command.ts
|
|
82
|
+
function Command(options) {
|
|
83
|
+
return createBeanDecorator("command", "sys", true, options);
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
86
|
//#region src/types/command.ts
|
|
87
87
|
var SymbolCommandResult = Symbol("SymbolCommandResult");
|
|
88
88
|
//#endregion
|
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/
|
|
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 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 { 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 { 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(\n options: IDecoratorCommandOptions,\n renderContext: IJsxRenderContextBase,\n next: NextCommandExecute,\n ): 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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AK,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;;;;;;AClBJ,QAAS,oBAAoB,WAAQ,OAAK,MAAA,QAAA;;;;ACF1C,IAAa,sBAAmB,OAAK,sBAAA"}
|
package/dist/lib/index.d.ts
CHANGED
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,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,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zova-module-a-command",
|
|
3
|
-
"version": "5.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "5.1.25",
|
|
4
|
+
"gitHead": "09d901d17140a80ee0764211b441cda72fd94663",
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Zova Module"
|
|
@@ -23,6 +23,13 @@
|
|
|
23
23
|
},
|
|
24
24
|
"./*": "./*"
|
|
25
25
|
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"clean": "rimraf dist tsconfig.build.tsbuildinfo",
|
|
28
|
+
"tsc:publish": "npm run clean && zova :bin:buildModule --sourcemap && tsc -p tsconfig.build.json",
|
|
29
|
+
"prepublishOnly": "npm run tsc:publish",
|
|
30
|
+
"prepack": "clean-package",
|
|
31
|
+
"postpack": "clean-package restore && npm run clean"
|
|
32
|
+
},
|
|
26
33
|
"title": "a-command",
|
|
27
34
|
"zovaModule": {
|
|
28
35
|
"onions": {
|
|
@@ -39,9 +46,5 @@
|
|
|
39
46
|
"monkey": true
|
|
40
47
|
},
|
|
41
48
|
"dependencies": {}
|
|
42
|
-
},
|
|
43
|
-
"scripts": {
|
|
44
|
-
"clean": "rimraf dist tsconfig.build.tsbuildinfo",
|
|
45
|
-
"tsc:publish": "npm run clean && zova :bin:buildModule --sourcemap && tsc -p tsconfig.build.json"
|
|
46
49
|
}
|
|
47
|
-
}
|
|
50
|
+
}
|
package/src/lib/index.ts
CHANGED
package/src/types/index.ts
CHANGED