zova-module-rest-resource 5.1.32 → 5.1.36
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 +50 -20
- package/dist/index.js.map +1 -1
- package/dist/model/resource.d.ts +22 -1
- package/dist/model/resource.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/model/resource.ts +66 -16
package/dist/index.js
CHANGED
|
@@ -72,13 +72,8 @@ var ModelResource = (_dec$4 = Model({ enableSelector: true }), _dec2$4 = BeanInf
|
|
|
72
72
|
await this._bootstrap();
|
|
73
73
|
}
|
|
74
74
|
selectGeneral(actionPath, query) {
|
|
75
|
-
const queryHash = hashkey(query);
|
|
76
75
|
return this.$useStateData({
|
|
77
|
-
queryKey:
|
|
78
|
-
"select",
|
|
79
|
-
actionPath ?? "",
|
|
80
|
-
queryHash
|
|
81
|
-
],
|
|
76
|
+
queryKey: this.keySelect(actionPath, query),
|
|
82
77
|
queryFn: async () => {
|
|
83
78
|
const apiPath = actionPath ? `${this.resourceApi}/${actionPath}` : this.resourceApi;
|
|
84
79
|
return this.$fetch.get(this.sys.util.apiActionPathTranslate(apiPath), this.sys.util.apiActionConfigPrepare(void 0, { query }));
|
|
@@ -88,10 +83,19 @@ var ModelResource = (_dec$4 = Model({ enableSelector: true }), _dec2$4 = BeanInf
|
|
|
88
83
|
select(query) {
|
|
89
84
|
return this.selectGeneral(void 0, query);
|
|
90
85
|
}
|
|
91
|
-
|
|
86
|
+
queryItem(options) {
|
|
87
|
+
const { id, action, queryFn, meta } = options;
|
|
92
88
|
if (isNil(id)) throw new Error("row id cannot empty");
|
|
93
89
|
return this.$useStateData({
|
|
94
|
-
queryKey:
|
|
90
|
+
queryKey: this.keyItem(id, action),
|
|
91
|
+
queryFn,
|
|
92
|
+
meta
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
view(id) {
|
|
96
|
+
return this.queryItem({
|
|
97
|
+
id,
|
|
98
|
+
action: "view",
|
|
95
99
|
queryFn: async () => {
|
|
96
100
|
return await this.$fetch.get(this.sys.util.apiActionPathTranslate(`${this.resourceApi}/:id`, { id }), this.sys.util.apiActionConfigPrepare()) ?? null;
|
|
97
101
|
}
|
|
@@ -108,27 +112,34 @@ var ModelResource = (_dec$4 = Model({ enableSelector: true }), _dec2$4 = BeanInf
|
|
|
108
112
|
}
|
|
109
113
|
});
|
|
110
114
|
}
|
|
111
|
-
|
|
115
|
+
mutationItem(options) {
|
|
116
|
+
const { id, action, mutationFn, onSuccess, invalidateSelect = true } = options;
|
|
117
|
+
if (isNil(id)) throw new Error("row id cannot empty");
|
|
112
118
|
return this.$useMutationData({
|
|
113
|
-
mutationKey: ["
|
|
119
|
+
mutationKey: [...this.keyItem(id, action), "mutation"],
|
|
120
|
+
mutationFn,
|
|
121
|
+
onSuccess: async (data, variables, context) => {
|
|
122
|
+
if (invalidateSelect) this.$invalidateQueries({ queryKey: ["select"] });
|
|
123
|
+
this.$invalidateQueries({ queryKey: this.keyItemRoot(id) });
|
|
124
|
+
await onSuccess?.(data, variables, context);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
update(id) {
|
|
129
|
+
return this.mutationItem({
|
|
130
|
+
id,
|
|
131
|
+
action: "update",
|
|
114
132
|
mutationFn: async (params) => {
|
|
115
133
|
return this.$fetch.patch(this.sys.util.apiActionPathTranslate(`${this.resourceApi}/:id`, { id }), params, this.sys.util.apiActionConfigPrepare());
|
|
116
|
-
},
|
|
117
|
-
onSuccess: () => {
|
|
118
|
-
this.$invalidateQueries({ queryKey: ["select"] });
|
|
119
|
-
this.$invalidateQueries({ queryKey: ["get", id] });
|
|
120
134
|
}
|
|
121
135
|
});
|
|
122
136
|
}
|
|
123
137
|
delete(id) {
|
|
124
|
-
return this
|
|
125
|
-
|
|
138
|
+
return this.mutationItem({
|
|
139
|
+
id,
|
|
140
|
+
action: "delete",
|
|
126
141
|
mutationFn: async () => {
|
|
127
142
|
return this.$fetch.delete(this.sys.util.apiActionPathTranslate(`${this.resourceApi}/:id`, { id }), this.sys.util.apiActionConfigPrepare());
|
|
128
|
-
},
|
|
129
|
-
onSuccess: () => {
|
|
130
|
-
this.$invalidateQueries({ queryKey: ["select"] });
|
|
131
|
-
this.$invalidateQueries({ queryKey: ["get", id] });
|
|
132
143
|
}
|
|
133
144
|
});
|
|
134
145
|
}
|
|
@@ -172,6 +183,25 @@ var ModelResource = (_dec$4 = Model({ enableSelector: true }), _dec2$4 = BeanInf
|
|
|
172
183
|
if (typeof schemaName === "object") schemaName = schemaName[SymbolOpenapiSchemaName];
|
|
173
184
|
return this.$sdk.getSchemaDefaultValue(schemaName);
|
|
174
185
|
}
|
|
186
|
+
keySelect(actionPath, query) {
|
|
187
|
+
return [
|
|
188
|
+
"select",
|
|
189
|
+
actionPath ?? "",
|
|
190
|
+
hashkey(query)
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
keyItemRoot(id) {
|
|
194
|
+
if (isNil(id)) throw new Error("row id cannot empty");
|
|
195
|
+
return ["item", id];
|
|
196
|
+
}
|
|
197
|
+
keyItem(id, action) {
|
|
198
|
+
if (isNil(id)) throw new Error("row id cannot empty");
|
|
199
|
+
return [
|
|
200
|
+
"item",
|
|
201
|
+
id,
|
|
202
|
+
action
|
|
203
|
+
];
|
|
204
|
+
}
|
|
175
205
|
async _bootstrap() {
|
|
176
206
|
const queryBootstrap = await $QueryAutoLoad(() => this.$sdk.getBootstrap(this.resource));
|
|
177
207
|
if (!queryBootstrap?.data) throw new Error(`not found sdk of resource: ${this.resource}`);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isNil","z","BeanControllerPageBase","deepExtend","Use","usePrepareArg","ZovaJsx","Controller","formMetaFromFormScene","$QueryAutoLoad","_isSlot","s","Object","prototype","toString","call","_isVNode","ControllerPageEntrySchemaParams","object","resource","string","id","optional","formScene","ControllerPageEntry","_dec","_dec2","__z_BeanInfo","module","_dec3","beanFullName","_dec4","Reflect","metadata","Function","_dec5","_class","_class2","constructor","args","formMeta","formProvider","formSchema","jsxZova","$$modelResource","$params","entryId","__init__","$computed","getFormSchema","_prepareJsx","getFormApiSchemas","sdk","bean","_newBeanSimple","components","render","blocks","rest","length","domBlocks","forEach","block","index","options","key","domBlock","Array","isArray","push","_createVNode","ZPage","default","_applyDecoratedDescriptor","getOwnPropertyDescriptor","Virtual","Controller","ControllerPageEntry","ControllerPageEntrySchemaParams","ControllerPageEntryCreateSchemaParams","ControllerPageEntryCreate","_dec","_dec2","_dec3","__z_BeanInfo","module","_class","z","BeanControllerPageBase","deepExtend","Use","usePrepareArg","ZovaJsx","Controller","$QueryAutoLoad","_isSlot","s","Object","prototype","toString","call","_isVNode","ControllerPageResourceSchemaParams","object","resource","string","ControllerPageResource","_dec","_dec2","__z_BeanInfo","module","_dec3","beanFullName","_dec4","Reflect","metadata","Function","_dec5","_class","_class2","constructor","args","jsxZova","$$modelResource","$params","__init__","_prepareJsx","apiSchemasSelect","sdk","bean","_newBeanSimple","schemaRow","render","blocks","rest","length","domBlocks","forEach","block","index","options","key","domBlock","Array","isArray","push","_createVNode","ZPage","default","_applyDecoratedDescriptor","getOwnPropertyDescriptor"],"sources":["../src/model/resource.ts","../src/page/entry/controller.tsx","../src/page/entryCreate/controller.tsx","../src/page/resource/controller.tsx","../src/.metadata/page/entry.ts","../src/.metadata/page/entryCreate.ts","../src/.metadata/page/resource.ts","../src/routes.ts","../src/.metadata/index.ts"],"sourcesContent":["import type { TableIdentity } from 'table-identity';\nimport type { DataMutation, IDecoratorModelOptions } from 'zova-module-a-model';\nimport type {\n IFormMeta,\n IFormProvider,\n ISchemaObjectExtensionField,\n ITableQuery,\n ITableRes,\n TypeOpenapiPermissions,\n} from 'zova-module-a-openapi';\n\nimport { hashkey, isNil } from '@cabloy/utils';\nimport { SchemaObject } from 'openapi3-ts/oas31';\nimport { UseScope } from 'zova';\nimport { formSceneFromFormMeta } from 'zova-module-a-form';\nimport { $QueryAutoLoad, BeanModelBase, Model } from 'zova-module-a-model';\nimport { ScopeModuleAOpenapi, SymbolOpenapiSchemaName } from 'zova-module-a-openapi';\n\nexport interface IModelOptionsResource extends IDecoratorModelOptions {}\n\n@Model<IModelOptionsResource>({\n enableSelector: true,\n})\nexport class ModelResource<\n Entity = any,\n EntityCreate = Partial<Entity>,\n EntityUpdate = Partial<Entity>,\n> extends BeanModelBase {\n public resource: string;\n public resourceApi: string;\n public permissions?: TypeOpenapiPermissions;\n public formProvider: IFormProvider;\n public schemaView?: ISchemaObjectExtensionField;\n public schemaCreate?: ISchemaObjectExtensionField;\n public schemaUpdate?: ISchemaObjectExtensionField;\n public schemaFilter?: ISchemaObjectExtensionField;\n public schemaRow?: ISchemaObjectExtensionField;\n public schemaPages?: ISchemaObjectExtensionField;\n\n @UseScope()\n $$scopeOpenapi: ScopeModuleAOpenapi;\n\n protected async __init__(resource: string) {\n if (!resource) throw new Error('resource not specified');\n await super.__init__(resource);\n this.resource = resource;\n this.permissions = this.$computed(() => {\n const permissions = this.$sdk.getPermissions(this.resource);\n return permissions.data;\n });\n this.formProvider = this.$computed(() => {\n return this.$$scopeOpenapi.config.formProvider;\n });\n this.schemaView = this.$computed(() => {\n return this.apiSchemasView.responseBody;\n });\n this.schemaCreate = this.$computed(() => {\n return this.apiSchemasCreate.requestBody;\n });\n this.schemaUpdate = this.$computed(() => {\n return this.apiSchemasUpdate.requestBody;\n });\n this.schemaFilter = this.$computed(() => {\n return this.apiSchemasSelect.filter;\n });\n this.schemaRow = this.$computed(() => {\n return this.apiSchemasSelect.row;\n });\n this.schemaPages = this.$computed(() => {\n return this.apiSchemasSelect.paged;\n });\n // bootstrap\n await this._bootstrap();\n }\n\n selectGeneral(actionPath?: string, query?: ITableQuery) {\n const queryHash = hashkey(query);\n return this.$useStateData({\n queryKey: ['select', actionPath ?? '', queryHash],\n queryFn: async () => {\n const apiPath = actionPath ? `${this.resourceApi}/${actionPath}` : this.resourceApi;\n return this.$fetch.get<any, ITableRes<Entity>>(\n this.sys.util.apiActionPathTranslate(apiPath),\n this.sys.util.apiActionConfigPrepare(undefined, { query }),\n );\n },\n });\n }\n\n select(query?: ITableQuery) {\n return this.selectGeneral(undefined, query);\n }\n\n view(id: TableIdentity) {\n if (isNil(id)) throw new Error('row id cannot empty');\n return this.$useStateData({\n queryKey: ['get', id],\n queryFn: async () => {\n const res = await this.$fetch.get<any, Entity>(\n this.sys.util.apiActionPathTranslate(`${this.resourceApi}/:id`, { id }),\n this.sys.util.apiActionConfigPrepare(),\n );\n return res ?? null;\n },\n });\n }\n\n create() {\n return this.$useMutationData<void, EntityCreate>({\n mutationKey: ['create'],\n mutationFn: async params => {\n return this.$fetch.post<any, void, EntityCreate>(\n this.sys.util.apiActionPathTranslate(this.resourceApi),\n params,\n this.sys.util.apiActionConfigPrepare(),\n );\n },\n onSuccess: () => {\n this.$invalidateQueries({ queryKey: ['select'] });\n },\n });\n }\n\n update(id: TableIdentity) {\n return this.$useMutationData<void, EntityUpdate>({\n mutationKey: ['update', id],\n mutationFn: async params => {\n return this.$fetch.patch<any, void, EntityUpdate>(\n this.sys.util.apiActionPathTranslate(`${this.resourceApi}/:id`, { id }),\n params,\n this.sys.util.apiActionConfigPrepare(),\n );\n },\n onSuccess: () => {\n this.$invalidateQueries({ queryKey: ['select'] });\n this.$invalidateQueries({ queryKey: ['get', id] });\n },\n });\n }\n\n delete(id: TableIdentity) {\n return this.$useMutationData<void, void>({\n mutationKey: ['delete', id],\n mutationFn: async () => {\n return this.$fetch.delete<any, void, void>(\n this.sys.util.apiActionPathTranslate(`${this.resourceApi}/:id`, { id }),\n this.sys.util.apiActionConfigPrepare(),\n );\n },\n onSuccess: () => {\n this.$invalidateQueries({ queryKey: ['select'] });\n this.$invalidateQueries({ queryKey: ['get', id] });\n },\n });\n }\n\n public get apiSchemasSelect() {\n return this.$sdk.createApiSchemas(this.resourceApi, 'get');\n }\n\n public get apiSchemasView() {\n return this.$sdk.createApiSchemas(`${this.resourceApi}/:id`, 'get');\n }\n\n public get apiSchemasCreate() {\n return this.$sdk.createApiSchemas(this.resourceApi, 'post');\n }\n\n public get apiSchemasUpdate() {\n return this.$sdk.createApiSchemas(`${this.resourceApi}/:id`, 'patch');\n }\n\n public getFormSchema(formMeta: IFormMeta) {\n const formScene = formMeta.formScene ?? formSceneFromFormMeta(formMeta);\n if (formScene === 'view') return this.schemaView;\n if (formScene === 'create') return this.schemaCreate;\n if (formScene === 'edit') return this.schemaUpdate;\n }\n\n public getFormApiSchemas(formMeta: IFormMeta) {\n const formScene = formMeta.formScene ?? formSceneFromFormMeta(formMeta);\n if (formScene === 'view') return this.apiSchemasView;\n if (formScene === 'create') return this.apiSchemasCreate;\n if (formScene === 'edit') return this.apiSchemasUpdate;\n throw new Error('invalid parameters');\n }\n\n public getFormMutationSubmit(formMeta: IFormMeta, id?: TableIdentity): DataMutation | undefined {\n if (formMeta.formMode !== 'edit') return;\n if (formMeta.editMode === 'create') {\n return this.create() as any;\n } else if (formMeta.editMode === 'update') {\n return this.update(id!) as any;\n }\n }\n\n public getFormData(\n formMeta: IFormMeta,\n id?: TableIdentity,\n ): Entity | EntityCreate | EntityUpdate | undefined {\n if (formMeta.formMode === 'edit' && formMeta.editMode === 'create') {\n return this.getQueryDataDefaultValue(this.schemaCreate);\n }\n if (isNil(id)) return undefined;\n return this.view(id).data as Entity | EntityUpdate | undefined;\n }\n\n public getQueryDataDefaultValue(schemaName?: SchemaObject | string): EntityCreate | undefined {\n if (!schemaName) return;\n if (typeof schemaName === 'object') {\n schemaName = schemaName[SymbolOpenapiSchemaName] as string;\n }\n return this.$sdk.getSchemaDefaultValue(schemaName) as EntityCreate | undefined;\n }\n\n private async _bootstrap() {\n const queryBootstrap = await $QueryAutoLoad(() => this.$sdk.getBootstrap(this.resource));\n if (!queryBootstrap?.data) {\n throw new Error(`not found sdk of resource: ${this.resource}`);\n }\n this.resourceApi = this.sys.util.parseResourceApi(this.resource, queryBootstrap.data.apiPath);\n }\n}\n","import type {\n IFormMeta,\n IFormProvider,\n ISchemaObjectExtensionField,\n TypeFormScene,\n} from 'zova-module-a-openapi';\n\nimport { isNil } from '@cabloy/utils';\nimport { VNode } from 'vue';\nimport { z } from 'zod';\nimport { BeanControllerPageBase, deepExtend, Use, usePrepareArg } from 'zova';\nimport { ZovaJsx } from 'zova-jsx';\nimport { Controller } from 'zova-module-a-bean';\nimport { formMetaFromFormScene } from 'zova-module-a-form';\nimport { $QueryAutoLoad } from 'zova-module-a-model';\nimport { ZPage } from 'zova-module-home-base';\n\nimport type { ModelResource } from '../../model/resource.js';\n\nexport const ControllerPageEntrySchemaParams = z.object({\n resource: z.string(),\n id: z.string().optional(),\n formScene: z.string().optional(),\n});\n\n@Controller()\nexport class ControllerPageEntry extends BeanControllerPageBase {\n formMeta: IFormMeta;\n formProvider: IFormProvider;\n formSchema?: ISchemaObjectExtensionField;\n jsxZova: ZovaJsx;\n\n @Use({ beanFullName: 'rest-resource.model.resource' })\n get $$modelResource(): ModelResource {\n return usePrepareArg(this.$params.resource, true);\n }\n\n get resource() {\n return this.$params.resource;\n }\n\n get entryId() {\n return this.$params.id;\n }\n\n get formScene() {\n return (\n (this.$params.formScene as TypeFormScene | undefined) ??\n (isNil(this.entryId) ? 'create' : 'view')\n );\n }\n\n protected async __init__() {\n this.formMeta = this.$computed(() => {\n const formScene = this.formScene;\n return { ...formMetaFromFormScene(formScene), formScene };\n });\n this.formProvider = this.$computed(() => {\n return this.$$modelResource.formProvider;\n });\n this.formSchema = this.$computed(() => {\n return this.$$modelResource.getFormSchema(this.formMeta);\n });\n // jsx\n this._prepareJsx();\n // load schema\n await $QueryAutoLoad(() => this.$$modelResource.getFormApiSchemas(this.formMeta)?.sdk);\n }\n\n private _prepareJsx() {\n this.jsxZova = this.bean._newBeanSimple(ZovaJsx, false, this.formProvider.components);\n }\n\n protected render() {\n const blocks = this.formSchema?.rest?.blocks;\n if (!blocks || blocks.length === 0) return;\n const domBlocks: VNode[] = [];\n blocks.forEach((block, index) => {\n const options = deepExtend(\n { key: index },\n {\n resource: this.resource,\n id: this.entryId,\n formScene: this.formScene,\n },\n block.options,\n );\n const domBlock = this.jsxZova.render(block.render!, options);\n if (!domBlock) return;\n if (Array.isArray(domBlock)) {\n domBlocks.push(...domBlock);\n } else {\n domBlocks.push(domBlock);\n }\n });\n return <ZPage>{domBlocks}</ZPage>;\n }\n}\n","import { Virtual } from 'zova-core';\nimport { Controller } from 'zova-module-a-bean';\n\nimport { ControllerPageEntry, ControllerPageEntrySchemaParams } from '../entry/controller.jsx';\n\nexport const ControllerPageEntryCreateSchemaParams = ControllerPageEntrySchemaParams;\n\n@Controller()\n@Virtual()\nexport class ControllerPageEntryCreate extends ControllerPageEntry {}\n","import { VNode } from 'vue';\nimport { z } from 'zod';\nimport { BeanControllerPageBase, deepExtend, Use, usePrepareArg } from 'zova';\nimport { ZovaJsx } from 'zova-jsx';\nimport { Controller } from 'zova-module-a-bean';\nimport { $QueryAutoLoad } from 'zova-module-a-model';\nimport { ZPage } from 'zova-module-home-base';\n\nimport type { ModelResource } from '../../model/resource.js';\n\nexport const ControllerPageResourceSchemaParams = z.object({\n resource: z.string(),\n});\n\n@Controller()\nexport class ControllerPageResource extends BeanControllerPageBase {\n jsxZova: ZovaJsx;\n\n @Use({ beanFullName: 'rest-resource.model.resource' })\n get $$modelResource(): ModelResource {\n return usePrepareArg(this.$params.resource, true);\n }\n\n get resource() {\n return this.$params.resource;\n }\n\n protected async __init__() {\n // jsx\n this._prepareJsx();\n // load schema/data\n await $QueryAutoLoad(() => this.$$modelResource.apiSchemasSelect.sdk);\n }\n\n private _prepareJsx() {\n this.jsxZova = this.bean._newBeanSimple(ZovaJsx, false);\n }\n\n get schemaRow() {\n return this.$$modelResource.schemaRow;\n }\n\n public render() {\n const blocks = this.schemaRow?.rest?.blocks;\n if (!blocks || blocks.length === 0) return;\n const domBlocks: VNode[] = [];\n blocks.forEach((block, index) => {\n const options = deepExtend(\n { key: index },\n {\n resource: this.resource,\n },\n block.options,\n );\n const domBlock = this.jsxZova.render(block.render!, options);\n if (!domBlock) return;\n if (Array.isArray(domBlock)) {\n domBlocks.push(...domBlock);\n } else {\n domBlocks.push(domBlock);\n }\n });\n return <ZPage>{domBlocks}</ZPage>;\n }\n}\n","import { z } from 'zod';\nimport { createZovaComponentPage } from 'zova';\n\nimport { ControllerPageEntry } from '../../page/entry/controller.jsx';\nimport { ControllerPageEntrySchemaParams } from '../../page/entry/controller.jsx';\nexport namespace NSControllerPageEntry {\n export const paramsSchema = ControllerPageEntrySchemaParams;\n export type ParamsInput = z.input<typeof ControllerPageEntrySchemaParams>;\n export type ParamsOutput = z.output<typeof ControllerPageEntrySchemaParams>;\n}\n\nexport const ZPageEntry = createZovaComponentPage(ControllerPageEntry, undefined, undefined);\n","import { z } from 'zod';\nimport { createZovaComponentPage } from 'zova';\n\nimport { ControllerPageEntryCreate } from '../../page/entryCreate/controller.jsx';\nimport { ControllerPageEntryCreateSchemaParams } from '../../page/entryCreate/controller.jsx';\nexport namespace NSControllerPageEntryCreate {\n export const paramsSchema = ControllerPageEntryCreateSchemaParams;\n export type ParamsInput = z.input<typeof ControllerPageEntryCreateSchemaParams>;\n export type ParamsOutput = z.output<typeof ControllerPageEntryCreateSchemaParams>;\n}\n\nexport const ZPageEntryCreate = createZovaComponentPage(\n ControllerPageEntryCreate,\n undefined,\n undefined,\n);\n","import { z } from 'zod';\nimport { createZovaComponentPage } from 'zova';\n\nimport { ControllerPageResource } from '../../page/resource/controller.jsx';\nimport { ControllerPageResourceSchemaParams } from '../../page/resource/controller.jsx';\nexport namespace NSControllerPageResource {\n export const paramsSchema = ControllerPageResourceSchemaParams;\n export type ParamsInput = z.input<typeof ControllerPageResourceSchemaParams>;\n export type ParamsOutput = z.output<typeof ControllerPageResourceSchemaParams>;\n}\n\nexport const ZPageResource = createZovaComponentPage(ControllerPageResource, undefined, undefined);\n","import type { IModuleRoute } from 'zova-module-a-router';\n\nimport { ZPageEntry } from './.metadata/page/entry.js';\nimport { ZPageEntryCreate } from './.metadata/page/entryCreate.js';\nimport { ZPageResource } from './.metadata/page/resource.js';\n\nexport const routes: IModuleRoute[] = [\n {\n name: 'resource',\n path: ':resource',\n component: ZPageResource,\n meta: {\n tabKey,\n },\n },\n {\n name: 'entryCreate',\n path: ':resource/create',\n component: ZPageEntryCreate,\n meta: {\n tabKey,\n },\n },\n {\n name: 'entry',\n path: ':resource/:id/:formScene?',\n component: ZPageEntry,\n meta: {\n tabKey,\n },\n },\n];\n\nfunction tabKey(route) {\n return `/rest/resource/${encodeURIComponent(route.params.resource)}`;\n}\n","// eslint-disable\n/** model: begin */\nexport * from '../model/resource.js';\nimport { IModelOptionsResource } from '../model/resource.js';\nimport 'zova-module-a-model';\ndeclare module 'zova-module-a-model' {\n \n export interface IModelRecord {\n 'rest-resource:resource': IModelOptionsResource;\n }\n\n \n}\ndeclare module 'zova-module-rest-resource' {\n \n export interface ModelResource {\n /** @internal */\n get scope(): ScopeModuleRestResource;\n }\n\n export interface ModelResource {\n get $beanFullName(): 'rest-resource.model.resource';\n get $onionName(): 'rest-resource:resource';\n get $onionOptions(): IModelOptionsResource;\n } \n}\n/** model: end */\n/** model: begin */\nimport { ModelResource } from '../model/resource.js';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordGeneral {\n 'rest-resource.model.resource': ModelResource;\n }\n}\n/** model: end */\n/** controller: begin */\nexport * from '../page/entry/controller.jsx';\nexport * from '../page/entryCreate/controller.jsx';\nexport * from '../page/resource/controller.jsx';\n\nimport 'zova';\ndeclare module 'zova' {\n \n \n}\ndeclare module 'zova-module-rest-resource' {\n \n export interface ControllerPageEntry {\n /** @internal */\n get scope(): ScopeModuleRestResource;\n }\n\n export interface ControllerPageResource {\n /** @internal */\n get scope(): ScopeModuleRestResource;\n } \n}\n/** controller: end */\n/** controller: begin */\nimport { ControllerPageEntry } from '../page/entry/controller.jsx';\nimport { ControllerPageEntryCreate } from '../page/entryCreate/controller.jsx';\nimport { ControllerPageResource } from '../page/resource/controller.jsx';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordLocal {\n 'rest-resource.controller.pageEntry': ControllerPageEntry;\n'rest-resource.controller.pageEntryCreate': ControllerPageEntryCreate;\n'rest-resource.controller.pageResource': ControllerPageResource;\n }\n}\n/** controller: end */\n/** pages: begin */\nexport * from './page/entry.js';\nimport { NSControllerPageEntry } from './page/entry.js';\nexport * from './page/entryCreate.js';\nimport { NSControllerPageEntryCreate } from './page/entryCreate.js';\nexport * from './page/resource.js';\nimport { NSControllerPageResource } from './page/resource.js';\nexport * from '../routes.js';\nimport { TypePagePathSchema } from 'zova-module-a-router';\nimport 'zova';\ndeclare module 'zova-module-a-router' {\nexport interface IPagePathRecord {\n '/rest/resource/:resource/:id/:formScene?': TypePagePathSchema<NSControllerPageEntry.ParamsInput,undefined>;\n'/rest/resource/:resource/create': TypePagePathSchema<NSControllerPageEntryCreate.ParamsInput,undefined>;\n'/rest/resource/:resource': TypePagePathSchema<NSControllerPageResource.ParamsInput,undefined>;\n}\nexport interface IPageNameRecord {\n 'rest-resource:entry': undefined;\n'rest-resource:entryCreate': undefined;\n'rest-resource:resource': undefined;\n}\n}\nexport const pagePathSchemas = {\n\n};\nexport const pageNameSchemas = {\n'rest-resource:entry': {\n params: NSControllerPageEntry.paramsSchema,\n \n },\n'rest-resource:entryCreate': {\n params: NSControllerPageEntryCreate.paramsSchema,\n \n },\n'rest-resource:resource': {\n params: NSControllerPageResource.paramsSchema,\n \n },\n};\ndeclare module 'zova-module-rest-resource' {\n export interface ControllerPageEntry {\n $params: NSControllerPageEntry.ParamsOutput;\n }\nexport interface ControllerPageEntryCreate {\n $params: NSControllerPageEntryCreate.ParamsOutput;\n }\nexport interface ControllerPageResource {\n $params: NSControllerPageResource.ParamsOutput;\n }\n}\n/** pages: end */\n\n/** scope: begin */\nimport { BeanScopeBase, type BeanScopeUtil } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\n\n@Scope()\nexport class ScopeModuleRestResource extends BeanScopeBase {}\n\nexport interface ScopeModuleRestResource {\n util: BeanScopeUtil;\n}\n\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanScopeRecord {\n 'rest-resource': ScopeModuleRestResource;\n }\n \n \n\n \n\n \n}\n \n/** scope: end */\n"],"mappings":";;;;;;;;;;;AAAA,IAAA,QAAO,SAAO,SAAA,SAAgB,UAAM,WAAM;AAC1C,SAAO,2BAAqB,GAAA,GAAA,GAAA,GAAA;AAAsB,MAAG,OAAM,eAAc,GAAM,GAAA;EAAA,YAAA,EAAA;EAAA,cAAA,EAAA;EAAA,UAAA,EAAA;EAAA,OAAA,EAAA,cAAA,EAAA,YAAA,KAAA,EAAA,GAAA,KAAA;EAAA,CAAA;;AAC/E,SAAO,4BAAK,GAAA,GAAA,GAAA,GAAA,GAAA;CAAA,IAAA,IAAA,EAAA;AAAA,QAAA,OAAA,KAAA,EAAA,CAAA,QAAA,SAAA,GAAA;AAAA,IAAA,KAAA,EAAA;GAAA,EAAA,EAAA,aAAA,CAAA,CAAA,EAAA,YAAA,EAAA,eAAA,CAAA,CAAA,EAAA,eAAA,WAAA,KAAA,EAAA,iBAAA,EAAA,WAAA,CAAA,IAAA,IAAA,EAAA,OAAA,CAAA,SAAA,CAAA,OAAA,SAAA,GAAA,GAAA;AAAA,SAAA,EAAA,GAAA,GAAA,EAAA,IAAA;IAAA,EAAA,EAAA,KAAA,KAAA,MAAA,EAAA,gBAAA,EAAA,QAAA,EAAA,cAAA,EAAA,YAAA,KAAA,EAAA,GAAA,KAAA,GAAA,EAAA,cAAA,KAAA,IAAA,KAAA,MAAA,EAAA,eAAA,OAAA,eAAA,GAAA,GAAA,EAAA,EAAA,QAAA;;sCASZ,gBAAkB,MAClB,CAAA,EAAA,UAAS,SAAe,EACxB,QAAS,iBACT,CAAA,EAAA,UAAS,SAAA,YAAwB,EAAA,UAAU,QAAQ,SAAO,eAAA,OAAA,wBAAA,cAAA,SAAA,oBAAA,EAAA,OAAA,WAAA,QAAA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WAAG;EACH,MAAC,EACD,QACC;EACF;CAAE;EACD,MAAE;EACF,MAAM;EACN,WAAU;EACV,MAAG,EACF,QACD;EACD;CAAC;AACF,SAAS,OAAG,OAAU;AACpB,QAAE,kBAAqB,mBAAA,MAAA,OAAA,SAAA;;;;;;AC1BzB,IAAG,MAAO,OAAA;AAgCV,IAAU,kBAAe,EAAQ;AACjC,IAAE,kBAAA;CACF,uBAAA,EACI,QAAO,sBAAK,cACb;CACH,6BAA6B,EAC7B,QAAS,4BAA0B,cACnC;6BAEA,QAAY,yBAAC,cACb;CACC;AAMD,IAAW,2BAAc,OAAA,OAAA,EAAA,QAAA,SAAA,EACvB,QAAQ,iBACT,CAAC,EAAE,KAAI,SAAA,MAAA,SAAA,MAAA,gCAAA,cAAA,GAAA,IAAA,OAAA,IAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["isNil","z","BeanControllerPageBase","deepExtend","Use","usePrepareArg","ZovaJsx","Controller","formMetaFromFormScene","$QueryAutoLoad","_isSlot","s","Object","prototype","toString","call","_isVNode","ControllerPageEntrySchemaParams","object","resource","string","id","optional","formScene","ControllerPageEntry","_dec","_dec2","__z_BeanInfo","module","_dec3","beanFullName","_dec4","Reflect","metadata","Function","_dec5","_class","_class2","constructor","args","formMeta","formProvider","formSchema","jsxZova","$$modelResource","$params","entryId","__init__","$computed","getFormSchema","_prepareJsx","getFormApiSchemas","sdk","bean","_newBeanSimple","components","render","blocks","rest","length","domBlocks","forEach","block","index","options","key","domBlock","Array","isArray","push","_createVNode","ZPage","default","_applyDecoratedDescriptor","getOwnPropertyDescriptor","Virtual","Controller","ControllerPageEntry","ControllerPageEntrySchemaParams","ControllerPageEntryCreateSchemaParams","ControllerPageEntryCreate","_dec","_dec2","_dec3","__z_BeanInfo","module","_class","z","BeanControllerPageBase","deepExtend","Use","usePrepareArg","ZovaJsx","Controller","$QueryAutoLoad","_isSlot","s","Object","prototype","toString","call","_isVNode","ControllerPageResourceSchemaParams","object","resource","string","ControllerPageResource","_dec","_dec2","__z_BeanInfo","module","_dec3","beanFullName","_dec4","Reflect","metadata","Function","_dec5","_class","_class2","constructor","args","jsxZova","$$modelResource","$params","__init__","_prepareJsx","apiSchemasSelect","sdk","bean","_newBeanSimple","schemaRow","render","blocks","rest","length","domBlocks","forEach","block","index","options","key","domBlock","Array","isArray","push","_createVNode","ZPage","default","_applyDecoratedDescriptor","getOwnPropertyDescriptor"],"sources":["../src/model/resource.ts","../src/page/entry/controller.tsx","../src/page/entryCreate/controller.tsx","../src/page/resource/controller.tsx","../src/.metadata/page/entry.ts","../src/.metadata/page/entryCreate.ts","../src/.metadata/page/resource.ts","../src/routes.ts","../src/.metadata/index.ts"],"sourcesContent":["import type { TableIdentity } from 'table-identity';\nimport type { DataMutation, IDecoratorModelOptions } from 'zova-module-a-model';\nimport type {\n IFormMeta,\n IFormProvider,\n ISchemaObjectExtensionField,\n ITableQuery,\n ITableRes,\n TypeOpenapiPermissions,\n} from 'zova-module-a-openapi';\n\nimport { hashkey, isNil } from '@cabloy/utils';\nimport { SchemaObject } from 'openapi3-ts/oas31';\nimport { UseScope } from 'zova';\nimport { formSceneFromFormMeta } from 'zova-module-a-form';\nimport { $QueryAutoLoad, BeanModelBase, Model } from 'zova-module-a-model';\nimport { ScopeModuleAOpenapi, SymbolOpenapiSchemaName } from 'zova-module-a-openapi';\n\nexport interface IModelOptionsResource extends IDecoratorModelOptions {}\n\ninterface IModelResourceQueryItemOptions<TData> {\n id: TableIdentity;\n action: string;\n queryFn: () => Promise<TData>;\n meta?: {\n disableSuspenseOnInit?: boolean;\n };\n}\n\ninterface IModelResourceMutationItemOptions<TData = void, TVariables = void> {\n id: TableIdentity;\n action: string;\n mutationFn: (params: TVariables) => Promise<TData>;\n onSuccess?: (data: TData, variables: TVariables, context: unknown) => void | Promise<void>;\n invalidateSelect?: boolean;\n}\n\n@Model<IModelOptionsResource>({\n enableSelector: true,\n})\nexport class ModelResource<\n Entity = any,\n EntityCreate = Partial<Entity>,\n EntityUpdate = Partial<Entity>,\n> extends BeanModelBase {\n public resource: string;\n public resourceApi: string;\n public permissions?: TypeOpenapiPermissions;\n public formProvider: IFormProvider;\n public schemaView?: ISchemaObjectExtensionField;\n public schemaCreate?: ISchemaObjectExtensionField;\n public schemaUpdate?: ISchemaObjectExtensionField;\n public schemaFilter?: ISchemaObjectExtensionField;\n public schemaRow?: ISchemaObjectExtensionField;\n public schemaPages?: ISchemaObjectExtensionField;\n\n @UseScope()\n $$scopeOpenapi: ScopeModuleAOpenapi;\n\n protected async __init__(resource: string) {\n if (!resource) throw new Error('resource not specified');\n await super.__init__(resource);\n this.resource = resource;\n this.permissions = this.$computed(() => {\n const permissions = this.$sdk.getPermissions(this.resource);\n return permissions.data;\n });\n this.formProvider = this.$computed(() => {\n return this.$$scopeOpenapi.config.formProvider;\n });\n this.schemaView = this.$computed(() => {\n return this.apiSchemasView.responseBody;\n });\n this.schemaCreate = this.$computed(() => {\n return this.apiSchemasCreate.requestBody;\n });\n this.schemaUpdate = this.$computed(() => {\n return this.apiSchemasUpdate.requestBody;\n });\n this.schemaFilter = this.$computed(() => {\n return this.apiSchemasSelect.filter;\n });\n this.schemaRow = this.$computed(() => {\n return this.apiSchemasSelect.row;\n });\n this.schemaPages = this.$computed(() => {\n return this.apiSchemasSelect.paged;\n });\n // bootstrap\n await this._bootstrap();\n }\n\n selectGeneral(actionPath?: string, query?: ITableQuery) {\n return this.$useStateData({\n queryKey: this.keySelect(actionPath, query),\n queryFn: async () => {\n const apiPath = actionPath ? `${this.resourceApi}/${actionPath}` : this.resourceApi;\n return this.$fetch.get<any, ITableRes<Entity>>(\n this.sys.util.apiActionPathTranslate(apiPath),\n this.sys.util.apiActionConfigPrepare(undefined, { query }),\n );\n },\n });\n }\n\n select(query?: ITableQuery) {\n return this.selectGeneral(undefined, query);\n }\n\n queryItem<TData>(options: IModelResourceQueryItemOptions<TData>) {\n const { id, action, queryFn, meta } = options;\n if (isNil(id)) throw new Error('row id cannot empty');\n return this.$useStateData({\n queryKey: this.keyItem(id, action),\n queryFn,\n meta,\n });\n }\n\n view(id: TableIdentity) {\n return this.queryItem<Entity | null>({\n id,\n action: 'view',\n queryFn: async () => {\n const res = await this.$fetch.get<any, Entity>(\n this.sys.util.apiActionPathTranslate(`${this.resourceApi}/:id`, { id }),\n this.sys.util.apiActionConfigPrepare(),\n );\n return res ?? null;\n },\n });\n }\n\n create() {\n return this.$useMutationData<void, EntityCreate>({\n mutationKey: ['create'],\n mutationFn: async params => {\n return this.$fetch.post<any, void, EntityCreate>(\n this.sys.util.apiActionPathTranslate(this.resourceApi),\n params,\n this.sys.util.apiActionConfigPrepare(),\n );\n },\n onSuccess: () => {\n this.$invalidateQueries({ queryKey: ['select'] });\n },\n });\n }\n\n mutationItem<TData = void, TVariables = void>(options: IModelResourceMutationItemOptions<TData, TVariables>) {\n const { id, action, mutationFn, onSuccess, invalidateSelect = true } = options;\n if (isNil(id)) throw new Error('row id cannot empty');\n return this.$useMutationData<TData, TVariables>({\n mutationKey: [...this.keyItem(id, action), 'mutation'],\n mutationFn,\n onSuccess: async (data, variables, context) => {\n if (invalidateSelect) {\n this.$invalidateQueries({ queryKey: ['select'] });\n }\n this.$invalidateQueries({ queryKey: this.keyItemRoot(id) });\n await onSuccess?.(data, variables, context);\n },\n });\n }\n\n update(id: TableIdentity) {\n return this.mutationItem<void, EntityUpdate>({\n id,\n action: 'update',\n mutationFn: async params => {\n return this.$fetch.patch<any, void, EntityUpdate>(\n this.sys.util.apiActionPathTranslate(`${this.resourceApi}/:id`, { id }),\n params,\n this.sys.util.apiActionConfigPrepare(),\n );\n },\n });\n }\n\n delete(id: TableIdentity) {\n return this.mutationItem<void, void>({\n id,\n action: 'delete',\n mutationFn: async () => {\n return this.$fetch.delete<any, void, void>(\n this.sys.util.apiActionPathTranslate(`${this.resourceApi}/:id`, { id }),\n this.sys.util.apiActionConfigPrepare(),\n );\n },\n });\n }\n\n public get apiSchemasSelect() {\n return this.$sdk.createApiSchemas(this.resourceApi, 'get');\n }\n\n public get apiSchemasView() {\n return this.$sdk.createApiSchemas(`${this.resourceApi}/:id`, 'get');\n }\n\n public get apiSchemasCreate() {\n return this.$sdk.createApiSchemas(this.resourceApi, 'post');\n }\n\n public get apiSchemasUpdate() {\n return this.$sdk.createApiSchemas(`${this.resourceApi}/:id`, 'patch');\n }\n\n public getFormSchema(formMeta: IFormMeta) {\n const formScene = formMeta.formScene ?? formSceneFromFormMeta(formMeta);\n if (formScene === 'view') return this.schemaView;\n if (formScene === 'create') return this.schemaCreate;\n if (formScene === 'edit') return this.schemaUpdate;\n }\n\n public getFormApiSchemas(formMeta: IFormMeta) {\n const formScene = formMeta.formScene ?? formSceneFromFormMeta(formMeta);\n if (formScene === 'view') return this.apiSchemasView;\n if (formScene === 'create') return this.apiSchemasCreate;\n if (formScene === 'edit') return this.apiSchemasUpdate;\n throw new Error('invalid parameters');\n }\n\n public getFormMutationSubmit(formMeta: IFormMeta, id?: TableIdentity): DataMutation | undefined {\n if (formMeta.formMode !== 'edit') return;\n if (formMeta.editMode === 'create') {\n return this.create() as any;\n } else if (formMeta.editMode === 'update') {\n return this.update(id!) as any;\n }\n }\n\n public getFormData(\n formMeta: IFormMeta,\n id?: TableIdentity,\n ): Entity | EntityCreate | EntityUpdate | undefined {\n if (formMeta.formMode === 'edit' && formMeta.editMode === 'create') {\n return this.getQueryDataDefaultValue(this.schemaCreate);\n }\n if (isNil(id)) return undefined;\n return this.view(id).data as Entity | EntityUpdate | undefined;\n }\n\n public getQueryDataDefaultValue(schemaName?: SchemaObject | string): EntityCreate | undefined {\n if (!schemaName) return;\n if (typeof schemaName === 'object') {\n schemaName = schemaName[SymbolOpenapiSchemaName] as string;\n }\n return this.$sdk.getSchemaDefaultValue(schemaName) as EntityCreate | undefined;\n }\n\n protected keySelect(actionPath?: string, query?: ITableQuery) {\n return ['select', actionPath ?? '', hashkey(query)] as const;\n }\n\n protected keyItemRoot(id: TableIdentity) {\n if (isNil(id)) throw new Error('row id cannot empty');\n return ['item', id] as const;\n }\n\n protected keyItem(id: TableIdentity, action: string) {\n if (isNil(id)) throw new Error('row id cannot empty');\n return ['item', id, action] as const;\n }\n\n private async _bootstrap() {\n const queryBootstrap = await $QueryAutoLoad(() => this.$sdk.getBootstrap(this.resource));\n if (!queryBootstrap?.data) {\n throw new Error(`not found sdk of resource: ${this.resource}`);\n }\n this.resourceApi = this.sys.util.parseResourceApi(this.resource, queryBootstrap.data.apiPath);\n }\n}\n","import type {\n IFormMeta,\n IFormProvider,\n ISchemaObjectExtensionField,\n TypeFormScene,\n} from 'zova-module-a-openapi';\n\nimport { isNil } from '@cabloy/utils';\nimport { VNode } from 'vue';\nimport { z } from 'zod';\nimport { BeanControllerPageBase, deepExtend, Use, usePrepareArg } from 'zova';\nimport { ZovaJsx } from 'zova-jsx';\nimport { Controller } from 'zova-module-a-bean';\nimport { formMetaFromFormScene } from 'zova-module-a-form';\nimport { $QueryAutoLoad } from 'zova-module-a-model';\nimport { ZPage } from 'zova-module-home-base';\n\nimport type { ModelResource } from '../../model/resource.js';\n\nexport const ControllerPageEntrySchemaParams = z.object({\n resource: z.string(),\n id: z.string().optional(),\n formScene: z.string().optional(),\n});\n\n@Controller()\nexport class ControllerPageEntry extends BeanControllerPageBase {\n formMeta: IFormMeta;\n formProvider: IFormProvider;\n formSchema?: ISchemaObjectExtensionField;\n jsxZova: ZovaJsx;\n\n @Use({ beanFullName: 'rest-resource.model.resource' })\n get $$modelResource(): ModelResource {\n return usePrepareArg(this.$params.resource, true);\n }\n\n get resource() {\n return this.$params.resource;\n }\n\n get entryId() {\n return this.$params.id;\n }\n\n get formScene() {\n return (\n (this.$params.formScene as TypeFormScene | undefined) ??\n (isNil(this.entryId) ? 'create' : 'view')\n );\n }\n\n protected async __init__() {\n this.formMeta = this.$computed(() => {\n const formScene = this.formScene;\n return { ...formMetaFromFormScene(formScene), formScene };\n });\n this.formProvider = this.$computed(() => {\n return this.$$modelResource.formProvider;\n });\n this.formSchema = this.$computed(() => {\n return this.$$modelResource.getFormSchema(this.formMeta);\n });\n // jsx\n this._prepareJsx();\n // load schema\n await $QueryAutoLoad(() => this.$$modelResource.getFormApiSchemas(this.formMeta)?.sdk);\n }\n\n private _prepareJsx() {\n this.jsxZova = this.bean._newBeanSimple(ZovaJsx, false, this.formProvider.components);\n }\n\n protected render() {\n const blocks = this.formSchema?.rest?.blocks;\n if (!blocks || blocks.length === 0) return;\n const domBlocks: VNode[] = [];\n blocks.forEach((block, index) => {\n const options = deepExtend(\n { key: index },\n {\n resource: this.resource,\n id: this.entryId,\n formScene: this.formScene,\n },\n block.options,\n );\n const domBlock = this.jsxZova.render(block.render!, options);\n if (!domBlock) return;\n if (Array.isArray(domBlock)) {\n domBlocks.push(...domBlock);\n } else {\n domBlocks.push(domBlock);\n }\n });\n return <ZPage>{domBlocks}</ZPage>;\n }\n}\n","import { Virtual } from 'zova-core';\nimport { Controller } from 'zova-module-a-bean';\n\nimport { ControllerPageEntry, ControllerPageEntrySchemaParams } from '../entry/controller.jsx';\n\nexport const ControllerPageEntryCreateSchemaParams = ControllerPageEntrySchemaParams;\n\n@Controller()\n@Virtual()\nexport class ControllerPageEntryCreate extends ControllerPageEntry {}\n","import { VNode } from 'vue';\nimport { z } from 'zod';\nimport { BeanControllerPageBase, deepExtend, Use, usePrepareArg } from 'zova';\nimport { ZovaJsx } from 'zova-jsx';\nimport { Controller } from 'zova-module-a-bean';\nimport { $QueryAutoLoad } from 'zova-module-a-model';\nimport { ZPage } from 'zova-module-home-base';\n\nimport type { ModelResource } from '../../model/resource.js';\n\nexport const ControllerPageResourceSchemaParams = z.object({\n resource: z.string(),\n});\n\n@Controller()\nexport class ControllerPageResource extends BeanControllerPageBase {\n jsxZova: ZovaJsx;\n\n @Use({ beanFullName: 'rest-resource.model.resource' })\n get $$modelResource(): ModelResource {\n return usePrepareArg(this.$params.resource, true);\n }\n\n get resource() {\n return this.$params.resource;\n }\n\n protected async __init__() {\n // jsx\n this._prepareJsx();\n // load schema/data\n await $QueryAutoLoad(() => this.$$modelResource.apiSchemasSelect.sdk);\n }\n\n private _prepareJsx() {\n this.jsxZova = this.bean._newBeanSimple(ZovaJsx, false);\n }\n\n get schemaRow() {\n return this.$$modelResource.schemaRow;\n }\n\n public render() {\n const blocks = this.schemaRow?.rest?.blocks;\n if (!blocks || blocks.length === 0) return;\n const domBlocks: VNode[] = [];\n blocks.forEach((block, index) => {\n const options = deepExtend(\n { key: index },\n {\n resource: this.resource,\n },\n block.options,\n );\n const domBlock = this.jsxZova.render(block.render!, options);\n if (!domBlock) return;\n if (Array.isArray(domBlock)) {\n domBlocks.push(...domBlock);\n } else {\n domBlocks.push(domBlock);\n }\n });\n return <ZPage>{domBlocks}</ZPage>;\n }\n}\n","import { z } from 'zod';\nimport { createZovaComponentPage } from 'zova';\n\nimport { ControllerPageEntry } from '../../page/entry/controller.jsx';\nimport { ControllerPageEntrySchemaParams } from '../../page/entry/controller.jsx';\nexport namespace NSControllerPageEntry {\n export const paramsSchema = ControllerPageEntrySchemaParams;\n export type ParamsInput = z.input<typeof ControllerPageEntrySchemaParams>;\n export type ParamsOutput = z.output<typeof ControllerPageEntrySchemaParams>;\n}\n\nexport const ZPageEntry = createZovaComponentPage(ControllerPageEntry, undefined, undefined);\n","import { z } from 'zod';\nimport { createZovaComponentPage } from 'zova';\n\nimport { ControllerPageEntryCreate } from '../../page/entryCreate/controller.jsx';\nimport { ControllerPageEntryCreateSchemaParams } from '../../page/entryCreate/controller.jsx';\nexport namespace NSControllerPageEntryCreate {\n export const paramsSchema = ControllerPageEntryCreateSchemaParams;\n export type ParamsInput = z.input<typeof ControllerPageEntryCreateSchemaParams>;\n export type ParamsOutput = z.output<typeof ControllerPageEntryCreateSchemaParams>;\n}\n\nexport const ZPageEntryCreate = createZovaComponentPage(\n ControllerPageEntryCreate,\n undefined,\n undefined,\n);\n","import { z } from 'zod';\nimport { createZovaComponentPage } from 'zova';\n\nimport { ControllerPageResource } from '../../page/resource/controller.jsx';\nimport { ControllerPageResourceSchemaParams } from '../../page/resource/controller.jsx';\nexport namespace NSControllerPageResource {\n export const paramsSchema = ControllerPageResourceSchemaParams;\n export type ParamsInput = z.input<typeof ControllerPageResourceSchemaParams>;\n export type ParamsOutput = z.output<typeof ControllerPageResourceSchemaParams>;\n}\n\nexport const ZPageResource = createZovaComponentPage(ControllerPageResource, undefined, undefined);\n","import type { IModuleRoute } from 'zova-module-a-router';\n\nimport { ZPageEntry } from './.metadata/page/entry.js';\nimport { ZPageEntryCreate } from './.metadata/page/entryCreate.js';\nimport { ZPageResource } from './.metadata/page/resource.js';\n\nexport const routes: IModuleRoute[] = [\n {\n name: 'resource',\n path: ':resource',\n component: ZPageResource,\n meta: {\n tabKey,\n },\n },\n {\n name: 'entryCreate',\n path: ':resource/create',\n component: ZPageEntryCreate,\n meta: {\n tabKey,\n },\n },\n {\n name: 'entry',\n path: ':resource/:id/:formScene?',\n component: ZPageEntry,\n meta: {\n tabKey,\n },\n },\n];\n\nfunction tabKey(route) {\n return `/rest/resource/${encodeURIComponent(route.params.resource)}`;\n}\n","// eslint-disable\n/** model: begin */\nexport * from '../model/resource.js';\nimport { IModelOptionsResource } from '../model/resource.js';\nimport 'zova-module-a-model';\ndeclare module 'zova-module-a-model' {\n \n export interface IModelRecord {\n 'rest-resource:resource': IModelOptionsResource;\n }\n\n \n}\ndeclare module 'zova-module-rest-resource' {\n \n export interface ModelResource {\n /** @internal */\n get scope(): ScopeModuleRestResource;\n }\n\n export interface ModelResource {\n get $beanFullName(): 'rest-resource.model.resource';\n get $onionName(): 'rest-resource:resource';\n get $onionOptions(): IModelOptionsResource;\n } \n}\n/** model: end */\n/** model: begin */\nimport { ModelResource } from '../model/resource.js';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordGeneral {\n 'rest-resource.model.resource': ModelResource;\n }\n}\n/** model: end */\n/** controller: begin */\nexport * from '../page/entry/controller.jsx';\nexport * from '../page/entryCreate/controller.jsx';\nexport * from '../page/resource/controller.jsx';\n\nimport 'zova';\ndeclare module 'zova' {\n \n \n}\ndeclare module 'zova-module-rest-resource' {\n \n export interface ControllerPageEntry {\n /** @internal */\n get scope(): ScopeModuleRestResource;\n }\n\n export interface ControllerPageResource {\n /** @internal */\n get scope(): ScopeModuleRestResource;\n } \n}\n/** controller: end */\n/** controller: begin */\nimport { ControllerPageEntry } from '../page/entry/controller.jsx';\nimport { ControllerPageEntryCreate } from '../page/entryCreate/controller.jsx';\nimport { ControllerPageResource } from '../page/resource/controller.jsx';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordLocal {\n 'rest-resource.controller.pageEntry': ControllerPageEntry;\n'rest-resource.controller.pageEntryCreate': ControllerPageEntryCreate;\n'rest-resource.controller.pageResource': ControllerPageResource;\n }\n}\n/** controller: end */\n/** pages: begin */\nexport * from './page/entry.js';\nimport { NSControllerPageEntry } from './page/entry.js';\nexport * from './page/entryCreate.js';\nimport { NSControllerPageEntryCreate } from './page/entryCreate.js';\nexport * from './page/resource.js';\nimport { NSControllerPageResource } from './page/resource.js';\nexport * from '../routes.js';\nimport { TypePagePathSchema } from 'zova-module-a-router';\nimport 'zova';\ndeclare module 'zova-module-a-router' {\nexport interface IPagePathRecord {\n '/rest/resource/:resource/:id/:formScene?': TypePagePathSchema<NSControllerPageEntry.ParamsInput,undefined>;\n'/rest/resource/:resource/create': TypePagePathSchema<NSControllerPageEntryCreate.ParamsInput,undefined>;\n'/rest/resource/:resource': TypePagePathSchema<NSControllerPageResource.ParamsInput,undefined>;\n}\nexport interface IPageNameRecord {\n 'rest-resource:entry': undefined;\n'rest-resource:entryCreate': undefined;\n'rest-resource:resource': undefined;\n}\n}\nexport const pagePathSchemas = {\n\n};\nexport const pageNameSchemas = {\n'rest-resource:entry': {\n params: NSControllerPageEntry.paramsSchema,\n \n },\n'rest-resource:entryCreate': {\n params: NSControllerPageEntryCreate.paramsSchema,\n \n },\n'rest-resource:resource': {\n params: NSControllerPageResource.paramsSchema,\n \n },\n};\ndeclare module 'zova-module-rest-resource' {\n export interface ControllerPageEntry {\n $params: NSControllerPageEntry.ParamsOutput;\n }\nexport interface ControllerPageEntryCreate {\n $params: NSControllerPageEntryCreate.ParamsOutput;\n }\nexport interface ControllerPageResource {\n $params: NSControllerPageResource.ParamsOutput;\n }\n}\n/** pages: end */\n\n/** scope: begin */\nimport { BeanScopeBase, type BeanScopeUtil } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\n\n@Scope()\nexport class ScopeModuleRestResource extends BeanScopeBase {}\n\nexport interface ScopeModuleRestResource {\n util: BeanScopeUtil;\n}\n\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanScopeRecord {\n 'rest-resource': ScopeModuleRestResource;\n }\n \n \n\n \n\n \n}\n \n/** scope: end */\n"],"mappings":";;;;;;;;;;;AAAA,IAAA,QAAO,SAAO,SAAA,SAAgB,UAAM,WAAM;AAC1C,SAAO,2BAAqB,GAAA,GAAA,GAAA,GAAA;CAAsB,KAAG,OAAM,eAAc,GAAM,GAAA;EAAA,YAAA,EAAA;EAAA,cAAA,EAAA;EAAA,UAAA,EAAA;EAAA,OAAA,EAAA,cAAA,EAAA,YAAA,KAAA,CAAA,IAAA,KAAA;CAAA,CAAA;AAAA;AAC/E,SAAO,4BAAK,GAAA,GAAA,GAAA,GAAA,GAAA;CAAA,IAAA,IAAA,CAAA;CAAA,OAAA,OAAA,KAAA,CAAA,EAAA,QAAA,SAAA,GAAA;EAAA,EAAA,KAAA,EAAA;CAAA,CAAA,GAAA,EAAA,aAAA,CAAA,CAAA,EAAA,YAAA,EAAA,eAAA,CAAA,CAAA,EAAA,eAAA,WAAA,KAAA,EAAA,iBAAA,EAAA,WAAA,CAAA,IAAA,IAAA,EAAA,MAAA,EAAA,QAAA,EAAA,OAAA,SAAA,GAAA,GAAA;EAAA,OAAA,EAAA,GAAA,GAAA,CAAA,KAAA;CAAA,GAAA,CAAA,GAAA,KAAA,KAAA,MAAA,EAAA,gBAAA,EAAA,QAAA,EAAA,cAAA,EAAA,YAAA,KAAA,C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C,EACD,OACA;CACF;CAAG;EACD,MAAE;EACF,MAAM;EACN,WAAU;EACV,MAAG,EACF,OACD;CACF;AAAC;AACD,SAAS,OAAG,OAAU;CACpB,OAAE,kBAAqB,mBAAA,MAAA,OAAA,QAAA;AACzB;;;;;AC3BA,IAAG,MAAO,OAAA;AAgCV,IAAU,kBAAe,CAAA;AACzB,IAAE,kBAAA;CACF,uBAAA,EACI,QAAO,sBAAK,aACd;CACF,6BAA6B,EAC7B,QAAS,4BAA0B,aACnC;6BAEA,QAAY,yBAAC,aACb;AACA;AAMA,IAAW,2BAAc,OAAA,MAAA,GAAA,QAAA,SAAA,EACvB,QAAQ,gBACV,CAAC,GAAG,KAAI,SAAA,MAAA,SAAA,MAAA,gCAAA,cAAA,CAAA,CAAA,KAAA,MAAA,KAAA"}
|
package/dist/model/resource.d.ts
CHANGED
|
@@ -6,6 +6,21 @@ import { BeanModelBase } from 'zova-module-a-model';
|
|
|
6
6
|
import { ScopeModuleAOpenapi } from 'zova-module-a-openapi';
|
|
7
7
|
export interface IModelOptionsResource extends IDecoratorModelOptions {
|
|
8
8
|
}
|
|
9
|
+
interface IModelResourceQueryItemOptions<TData> {
|
|
10
|
+
id: TableIdentity;
|
|
11
|
+
action: string;
|
|
12
|
+
queryFn: () => Promise<TData>;
|
|
13
|
+
meta?: {
|
|
14
|
+
disableSuspenseOnInit?: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
interface IModelResourceMutationItemOptions<TData = void, TVariables = void> {
|
|
18
|
+
id: TableIdentity;
|
|
19
|
+
action: string;
|
|
20
|
+
mutationFn: (params: TVariables) => Promise<TData>;
|
|
21
|
+
onSuccess?: (data: TData, variables: TVariables, context: unknown) => void | Promise<void>;
|
|
22
|
+
invalidateSelect?: boolean;
|
|
23
|
+
}
|
|
9
24
|
export declare class ModelResource<Entity = any, EntityCreate = Partial<Entity>, EntityUpdate = Partial<Entity>> extends BeanModelBase {
|
|
10
25
|
resource: string;
|
|
11
26
|
resourceApi: string;
|
|
@@ -21,8 +36,10 @@ export declare class ModelResource<Entity = any, EntityCreate = Partial<Entity>,
|
|
|
21
36
|
protected __init__(resource: string): Promise<void>;
|
|
22
37
|
selectGeneral(actionPath?: string, query?: ITableQuery): import("vue").UnwrapNestedRefs<import("@tanstack/vue-query").UseQueryReturnType<ITableRes<Entity>, Error>>;
|
|
23
38
|
select(query?: ITableQuery): import("vue").UnwrapNestedRefs<import("@tanstack/vue-query").UseQueryReturnType<ITableRes<Entity>, Error>>;
|
|
24
|
-
|
|
39
|
+
queryItem<TData>(options: IModelResourceQueryItemOptions<TData>): import("vue").UnwrapNestedRefs<import("@tanstack/vue-query").UseQueryReturnType<TData, Error>>;
|
|
40
|
+
view(id: TableIdentity): import("vue").UnwrapNestedRefs<import("@tanstack/vue-query").UseQueryReturnType<Entity | null, Error>>;
|
|
25
41
|
create(): import("vue").UnwrapNestedRefs<import("@tanstack/vue-query").UseMutationReturnType<void, Error, EntityCreate, unknown>>;
|
|
42
|
+
mutationItem<TData = void, TVariables = void>(options: IModelResourceMutationItemOptions<TData, TVariables>): import("vue").UnwrapNestedRefs<import("@tanstack/vue-query").UseMutationReturnType<TData, Error, TVariables, unknown>>;
|
|
26
43
|
update(id: TableIdentity): import("vue").UnwrapNestedRefs<import("@tanstack/vue-query").UseMutationReturnType<void, Error, EntityUpdate, unknown>>;
|
|
27
44
|
delete(id: TableIdentity): import("vue").UnwrapNestedRefs<import("@tanstack/vue-query").UseMutationReturnType<void, Error, void, unknown>>;
|
|
28
45
|
get apiSchemasSelect(): import("zova-module-a-openapi").IOpenapiSchemas;
|
|
@@ -34,6 +51,10 @@ export declare class ModelResource<Entity = any, EntityCreate = Partial<Entity>,
|
|
|
34
51
|
getFormMutationSubmit(formMeta: IFormMeta, id?: TableIdentity): DataMutation | undefined;
|
|
35
52
|
getFormData(formMeta: IFormMeta, id?: TableIdentity): Entity | EntityCreate | EntityUpdate | undefined;
|
|
36
53
|
getQueryDataDefaultValue(schemaName?: SchemaObject | string): EntityCreate | undefined;
|
|
54
|
+
protected keySelect(actionPath?: string, query?: ITableQuery): readonly ["select", string, string];
|
|
55
|
+
protected keyItemRoot(id: TableIdentity): readonly ["item", TableIdentity];
|
|
56
|
+
protected keyItem(id: TableIdentity, action: string): readonly ["item", TableIdentity, string];
|
|
37
57
|
private _bootstrap;
|
|
38
58
|
}
|
|
59
|
+
export {};
|
|
39
60
|
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/model/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,2BAA2B,EAC3B,WAAW,EACX,SAAS,EACT,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAkB,aAAa,EAAS,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAA2B,MAAM,uBAAuB,CAAC;AAErF,MAAM,WAAW,qBAAsB,SAAQ,sBAAsB;CAAG;AAExE,qBAGa,aAAa,CACxB,MAAM,GAAG,GAAG,EACZ,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,EAC9B,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAC9B,SAAQ,aAAa;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,YAAY,EAAE,aAAa,CAAC;IAC5B,UAAU,CAAC,EAAE,2BAA2B,CAAC;IACzC,YAAY,CAAC,EAAE,2BAA2B,CAAC;IAC3C,YAAY,CAAC,EAAE,2BAA2B,CAAC;IAC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,IAAW,cAAc,oDAExB;IAED,IAAW,gBAAgB,oDAE1B;IAED,IAAW,gBAAgB,oDAE1B;IAEM,aAAa,CAAC,QAAQ,EAAE,SAAS;IAOjC,iBAAiB,CAAC,QAAQ,EAAE,SAAS;IAQrC,qBAAqB,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,CAAC,EAAE,aAAa,GAAG,YAAY,GAAG,SAAS;IASxF,WAAW,CAChB,QAAQ,EAAE,SAAS,EACnB,EAAE,CAAC,EAAE,aAAa,GACjB,MAAM,GAAG,YAAY,GAAG,YAAY,GAAG,SAAS;IAQ5C,wBAAwB,CAAC,UAAU,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,YAAY,GAAG,SAAS;IAQ7F,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW;IAI5D,SAAS,CAAC,WAAW,CAAC,EAAE,EAAE,aAAa;IAKvC,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM;YAKrC,UAAU;CAOzB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zova-module-rest-resource",
|
|
3
|
-
"version": "5.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "5.1.36",
|
|
4
|
+
"gitHead": "ca10457f38716ad28bf5918dd67c85dd1f7dc9d0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Zova Module"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"clean": "rimraf dist tsconfig.build.tsbuildinfo",
|
|
27
|
-
"tsc:publish": "npm run clean && zova :bin:buildModule --sourcemap && tsc -p tsconfig.build.json",
|
|
27
|
+
"tsc:publish": "npm run clean && node ../../../../../packages-cli/cli/src/bin/zova.ts :bin:buildModule --sourcemap && tsc -p tsconfig.build.json",
|
|
28
28
|
"prepublishOnly": "npm run tsc:publish",
|
|
29
29
|
"prepack": "clean-package",
|
|
30
30
|
"postpack": "clean-package restore && npm run clean"
|
package/src/model/resource.ts
CHANGED
|
@@ -18,6 +18,23 @@ import { ScopeModuleAOpenapi, SymbolOpenapiSchemaName } from 'zova-module-a-open
|
|
|
18
18
|
|
|
19
19
|
export interface IModelOptionsResource extends IDecoratorModelOptions {}
|
|
20
20
|
|
|
21
|
+
interface IModelResourceQueryItemOptions<TData> {
|
|
22
|
+
id: TableIdentity;
|
|
23
|
+
action: string;
|
|
24
|
+
queryFn: () => Promise<TData>;
|
|
25
|
+
meta?: {
|
|
26
|
+
disableSuspenseOnInit?: boolean;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface IModelResourceMutationItemOptions<TData = void, TVariables = void> {
|
|
31
|
+
id: TableIdentity;
|
|
32
|
+
action: string;
|
|
33
|
+
mutationFn: (params: TVariables) => Promise<TData>;
|
|
34
|
+
onSuccess?: (data: TData, variables: TVariables, context: unknown) => void | Promise<void>;
|
|
35
|
+
invalidateSelect?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
21
38
|
@Model<IModelOptionsResource>({
|
|
22
39
|
enableSelector: true,
|
|
23
40
|
})
|
|
@@ -74,9 +91,8 @@ export class ModelResource<
|
|
|
74
91
|
}
|
|
75
92
|
|
|
76
93
|
selectGeneral(actionPath?: string, query?: ITableQuery) {
|
|
77
|
-
const queryHash = hashkey(query);
|
|
78
94
|
return this.$useStateData({
|
|
79
|
-
queryKey:
|
|
95
|
+
queryKey: this.keySelect(actionPath, query),
|
|
80
96
|
queryFn: async () => {
|
|
81
97
|
const apiPath = actionPath ? `${this.resourceApi}/${actionPath}` : this.resourceApi;
|
|
82
98
|
return this.$fetch.get<any, ITableRes<Entity>>(
|
|
@@ -91,10 +107,20 @@ export class ModelResource<
|
|
|
91
107
|
return this.selectGeneral(undefined, query);
|
|
92
108
|
}
|
|
93
109
|
|
|
94
|
-
|
|
110
|
+
queryItem<TData>(options: IModelResourceQueryItemOptions<TData>) {
|
|
111
|
+
const { id, action, queryFn, meta } = options;
|
|
95
112
|
if (isNil(id)) throw new Error('row id cannot empty');
|
|
96
113
|
return this.$useStateData({
|
|
97
|
-
queryKey:
|
|
114
|
+
queryKey: this.keyItem(id, action),
|
|
115
|
+
queryFn,
|
|
116
|
+
meta,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
view(id: TableIdentity) {
|
|
121
|
+
return this.queryItem<Entity | null>({
|
|
122
|
+
id,
|
|
123
|
+
action: 'view',
|
|
98
124
|
queryFn: async () => {
|
|
99
125
|
const res = await this.$fetch.get<any, Entity>(
|
|
100
126
|
this.sys.util.apiActionPathTranslate(`${this.resourceApi}/:id`, { id }),
|
|
@@ -121,9 +147,26 @@ export class ModelResource<
|
|
|
121
147
|
});
|
|
122
148
|
}
|
|
123
149
|
|
|
150
|
+
mutationItem<TData = void, TVariables = void>(options: IModelResourceMutationItemOptions<TData, TVariables>) {
|
|
151
|
+
const { id, action, mutationFn, onSuccess, invalidateSelect = true } = options;
|
|
152
|
+
if (isNil(id)) throw new Error('row id cannot empty');
|
|
153
|
+
return this.$useMutationData<TData, TVariables>({
|
|
154
|
+
mutationKey: [...this.keyItem(id, action), 'mutation'],
|
|
155
|
+
mutationFn,
|
|
156
|
+
onSuccess: async (data, variables, context) => {
|
|
157
|
+
if (invalidateSelect) {
|
|
158
|
+
this.$invalidateQueries({ queryKey: ['select'] });
|
|
159
|
+
}
|
|
160
|
+
this.$invalidateQueries({ queryKey: this.keyItemRoot(id) });
|
|
161
|
+
await onSuccess?.(data, variables, context);
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
124
166
|
update(id: TableIdentity) {
|
|
125
|
-
return this
|
|
126
|
-
|
|
167
|
+
return this.mutationItem<void, EntityUpdate>({
|
|
168
|
+
id,
|
|
169
|
+
action: 'update',
|
|
127
170
|
mutationFn: async params => {
|
|
128
171
|
return this.$fetch.patch<any, void, EntityUpdate>(
|
|
129
172
|
this.sys.util.apiActionPathTranslate(`${this.resourceApi}/:id`, { id }),
|
|
@@ -131,26 +174,19 @@ export class ModelResource<
|
|
|
131
174
|
this.sys.util.apiActionConfigPrepare(),
|
|
132
175
|
);
|
|
133
176
|
},
|
|
134
|
-
onSuccess: () => {
|
|
135
|
-
this.$invalidateQueries({ queryKey: ['select'] });
|
|
136
|
-
this.$invalidateQueries({ queryKey: ['get', id] });
|
|
137
|
-
},
|
|
138
177
|
});
|
|
139
178
|
}
|
|
140
179
|
|
|
141
180
|
delete(id: TableIdentity) {
|
|
142
|
-
return this
|
|
143
|
-
|
|
181
|
+
return this.mutationItem<void, void>({
|
|
182
|
+
id,
|
|
183
|
+
action: 'delete',
|
|
144
184
|
mutationFn: async () => {
|
|
145
185
|
return this.$fetch.delete<any, void, void>(
|
|
146
186
|
this.sys.util.apiActionPathTranslate(`${this.resourceApi}/:id`, { id }),
|
|
147
187
|
this.sys.util.apiActionConfigPrepare(),
|
|
148
188
|
);
|
|
149
189
|
},
|
|
150
|
-
onSuccess: () => {
|
|
151
|
-
this.$invalidateQueries({ queryKey: ['select'] });
|
|
152
|
-
this.$invalidateQueries({ queryKey: ['get', id] });
|
|
153
|
-
},
|
|
154
190
|
});
|
|
155
191
|
}
|
|
156
192
|
|
|
@@ -213,6 +249,20 @@ export class ModelResource<
|
|
|
213
249
|
return this.$sdk.getSchemaDefaultValue(schemaName) as EntityCreate | undefined;
|
|
214
250
|
}
|
|
215
251
|
|
|
252
|
+
protected keySelect(actionPath?: string, query?: ITableQuery) {
|
|
253
|
+
return ['select', actionPath ?? '', hashkey(query)] as const;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
protected keyItemRoot(id: TableIdentity) {
|
|
257
|
+
if (isNil(id)) throw new Error('row id cannot empty');
|
|
258
|
+
return ['item', id] as const;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
protected keyItem(id: TableIdentity, action: string) {
|
|
262
|
+
if (isNil(id)) throw new Error('row id cannot empty');
|
|
263
|
+
return ['item', id, action] as const;
|
|
264
|
+
}
|
|
265
|
+
|
|
216
266
|
private async _bootstrap() {
|
|
217
267
|
const queryBootstrap = await $QueryAutoLoad(() => this.$sdk.getBootstrap(this.resource));
|
|
218
268
|
if (!queryBootstrap?.data) {
|