zova-cli-set-front 1.2.41 → 1.2.43

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.
@@ -1,9 +1,15 @@
1
- import type { IJsxRenderContextPage, IResourceActionBulkOptionsBase } from 'zova-module-a-openapi';
1
+ import type { IJsxRenderContextPage, IResourceTableActionBulkOptionsBase } from 'zova-module-a-openapi';
2
2
 
3
- import { BeanControllerBase, IComponentOptions, Use } from 'zova';
3
+ import { BeanControllerBase, type IComponentOptions, Use } from 'zova';
4
4
  import { Controller } from 'zova-module-a-bean';
5
5
 
6
- export interface Controller<%=argv.nameMeta.fullCapitalize%>Props extends IResourceActionBulkOptionsBase {}
6
+ declare module 'zova-module-a-openapi' {
7
+ export interface IResourceTableActionBulkRecord {
8
+ '<%=argv.module%>:<%=argv.nameMeta.full%>'?: Controller<%=argv.nameMeta.fullCapitalize%>Props;
9
+ }
10
+ }
11
+
12
+ export interface Controller<%=argv.nameMeta.fullCapitalize%>Props extends IResourceTableActionBulkOptionsBase {}
7
13
 
8
14
  @Controller()
9
15
  export class Controller<%=argv.nameMeta.fullCapitalize%> extends BeanControllerBase {
@@ -1,9 +1,15 @@
1
- import type { IJsxRenderContextPageEntry, IResourceActionRowOptionsBase } from 'zova-module-a-openapi';
1
+ import type { IJsxRenderContextPageEntry, IResourceFormActionRowOptionsBase } from 'zova-module-a-openapi';
2
2
 
3
- import { BeanControllerBase, IComponentOptions, Use } from 'zova';
3
+ import { BeanControllerBase, type IComponentOptions, Use } from 'zova';
4
4
  import { Controller } from 'zova-module-a-bean';
5
5
 
6
- export interface Controller<%=argv.nameMeta.fullCapitalize%>Props extends IResourceActionRowOptionsBase {}
6
+ declare module 'zova-module-a-openapi' {
7
+ export interface IResourceFormActionRowRecord {
8
+ '<%=argv.module%>:<%=argv.nameMeta.full%>'?: Controller<%=argv.nameMeta.fullCapitalize%>Props;
9
+ }
10
+ }
11
+
12
+ export interface Controller<%=argv.nameMeta.fullCapitalize%>Props extends IResourceFormActionRowOptionsBase {}
7
13
 
8
14
  @Controller()
9
15
  export class Controller<%=argv.nameMeta.fullCapitalize%> extends BeanControllerBase {
@@ -1,8 +1,14 @@
1
1
  import type { IResourceBlockOptionsBase, IJsxRenderContextPage } from 'zova-module-a-openapi';
2
2
 
3
- import { BeanControllerBase, IComponentOptions, Use } from 'zova';
3
+ import { BeanControllerBase, type IComponentOptions, Use } from 'zova';
4
4
  import { Controller } from 'zova-module-a-bean';
5
5
 
6
+ declare module 'zova-module-a-openapi' {
7
+ export interface IResourceBlockRecord {
8
+ '<%=argv.module%>:<%=argv.nameMeta.full%>'?: Controller<%=argv.nameMeta.fullCapitalize%>Props;
9
+ }
10
+ }
11
+
6
12
  export interface Controller<%=argv.nameMeta.fullCapitalize%>Props extends IResourceBlockOptionsBase {}
7
13
 
8
14
  @Controller()
@@ -1,8 +1,14 @@
1
1
  import type { IResourceBlockOptionsBase, IJsxRenderContextPageEntry } from 'zova-module-a-openapi';
2
2
 
3
- import { BeanControllerBase, IComponentOptions, Use } from 'zova';
3
+ import { BeanControllerBase, type IComponentOptions, Use } from 'zova';
4
4
  import { Controller } from 'zova-module-a-bean';
5
5
 
6
+ declare module 'zova-module-a-openapi' {
7
+ export interface IResourceBlockRecord {
8
+ '<%=argv.module%>:<%=argv.nameMeta.full%>'?: Controller<%=argv.nameMeta.fullCapitalize%>Props;
9
+ }
10
+ }
11
+
6
12
  export interface Controller<%=argv.nameMeta.fullCapitalize%>Props extends IResourceBlockOptionsBase {}
7
13
 
8
14
  @Controller()
@@ -1,12 +1,21 @@
1
1
  import type { IComponentOptions } from 'zova';
2
- import type { IFormFieldPresetOptionsBase } from 'zova-module-a-form';
3
2
  import type { IResourceFormFieldOptionsBase } from 'zova-module-a-openapi';
4
3
 
5
4
  import { BeanControllerBase } from 'zova';
6
5
  import { Controller } from 'zova-module-a-bean';
7
- import { ZFormField } from 'zova-module-a-form';
6
+ import { ZFormField, type IFormFieldComponentOptions } from 'zova-module-a-form';
8
7
 
9
- export interface Controller<%=argv.nameMeta.fullCapitalize%>Props extends IFormFieldPresetOptionsBase<IResourceFormFieldOptionsBase> {}
8
+ declare module 'zova-module-a-openapi' {
9
+ export interface IResourceFormFieldRecord {
10
+ '<%=argv.module%>:<%=argv.nameMeta.full%>'?: IResource<%=argv.nameMeta.fullCapitalize%>Options;
11
+ }
12
+ }
13
+
14
+ export interface IResource<%=argv.nameMeta.fullCapitalize%>Options extends IResourceFormFieldOptionsBase {}
15
+
16
+ export interface Controller<%=argv.nameMeta.fullCapitalize%>Props extends IFormFieldComponentOptions {
17
+ options?: IResource<%=argv.nameMeta.fullCapitalize%>Options;
18
+ }
10
19
 
11
20
  @Controller()
12
21
  export class Controller<%=argv.nameMeta.fullCapitalize%> extends BeanControllerBase {
@@ -1,9 +1,9 @@
1
1
  import type z from 'zod';
2
2
  import type { TypeRenderComponentJsx } from 'zova-jsx';
3
3
  import type {
4
- IResourceComponentFormFieldRecord,
4
+ IResourceFormFieldRecord,
5
5
  TypeFormSchemaScene,
6
- IResourceComponentTableCellActionRowRecord,
6
+ IResourceTableActionRowRecordBoth,
7
7
  IResourceActionRowRecord,
8
8
  IResourceComponentActionRowOptionsAction,
9
9
  IResourceActionBulkRecord,
@@ -16,9 +16,9 @@ import { toUpperCaseFirstChar } from '@cabloy/word-utils';
16
16
 
17
17
  import { _generalSchemaRest } from './inner.ts';
18
18
 
19
- export function schemaRenderField<K extends keyof IResourceComponentFormFieldRecord, T extends z.ZodType>(
19
+ export function schemaRenderField<K extends keyof IResourceFormFieldRecord, T extends z.ZodType>(
20
20
  name: K,
21
- options?: IResourceComponentFormFieldRecord[K],
21
+ options?: IResourceFormFieldRecord[K],
22
22
  scene?: TypeFormSchemaScene,
23
23
  ) {
24
24
  return function (schema: T): T {
@@ -34,9 +34,9 @@ export function schemaRenderFieldJsx<T extends z.ZodType>(renderComponentJsx: Ty
34
34
  };
35
35
  }
36
36
 
37
- export function schemaRenderCell<K extends keyof IResourceComponentTableCellActionRowRecord, T extends z.ZodType>(
37
+ export function schemaRenderCell<K extends keyof IResourceTableActionRowRecordBoth, T extends z.ZodType>(
38
38
  name: K,
39
- options?: IResourceComponentTableCellActionRowRecord[K],
39
+ options?: IResourceTableActionRowRecordBoth[K],
40
40
  ) {
41
41
  return function (schema: T): T {
42
42
  const options2 = options !== undefined ? { render: name as never, columnProps: options } : { render: name as never };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { rolldown } from 'rolldown';
7
7
  import { dts } from 'rolldown-plugin-dts';
8
8
  import { build } from 'vite';
9
9
  import { createRequire } from 'node:module';
10
- import { camelToKebab, replaceTemplate, toUpperCaseFirstChar, toLowerCaseFirstChar, skipPrefix, stringToCapitalize } from '@cabloy/word-utils';
10
+ import { camelToKebab, toUpperCaseFirstChar, toLowerCaseFirstChar, skipPrefix, stringToCapitalize, replaceTemplate } from '@cabloy/word-utils';
11
11
  import fse from 'fs-extra';
12
12
  import { build as build$1 } from 'tsdown';
13
13
  import yaml from 'yaml';
@@ -192,21 +192,6 @@ function svgResolverPlugin() {
192
192
  }
193
193
  };
194
194
  }
195
- const __template_package = `{
196
- "name": "{{Name}}",
197
- "version": "{{Version}}",
198
- "type": "module",
199
- "exports": {
200
- ".": {
201
- "types": [
202
- "./index.d.mts"
203
- ],
204
- "import": "./index.mjs"
205
- },
206
- "./package.json": "./package.json"
207
- }
208
- }
209
- `;
210
195
  class CliBinBuildRest extends BeanCliBase {
211
196
  async execute() {
212
197
  const {
@@ -287,22 +272,6 @@ class CliBinBuildRest extends BeanCliBase {
287
272
  // render
288
273
  await this.template.renderDir(srcDir, templateDir);
289
274
  }
290
- async _prepareResources_(context) {
291
- // package.json
292
- await this._prepareResourcesPackage(context);
293
- // index.ts
294
- await this._prepareResourcesIndex(context);
295
- }
296
- _prepareBundleModules() {
297
- const modules = [];
298
- for (const module of this.modulesMeta.modulesArray) {
299
- const moduleRoot = module.root.replaceAll('\\', '/');
300
- if (moduleRoot.includes('/src/module/') || moduleRoot.includes('/src/suite/')) {
301
- modules.push(module.info.fullName);
302
- }
303
- }
304
- return modules;
305
- }
306
275
  async _buildTs({
307
276
  srcDir,
308
277
  outDir
@@ -385,124 +354,6 @@ class CliBinBuildRest extends BeanCliBase {
385
354
  // copy
386
355
  _copyToTarget(outDir, process.env.BUILD_REST_COPY_DIST, bundleNameCopy);
387
356
  }
388
- async _prepareResourcesPackage({
389
- projectPath,
390
- flavor,
391
- bundleName,
392
- srcDir
393
- }) {
394
- const mode = 'production';
395
- const appMode = 'ssr';
396
- const configMeta = {
397
- flavor,
398
- mode,
399
- appMode
400
- };
401
- const configOptions = {
402
- appDir: projectPath,
403
- runtimeDir: '.zova'
404
- };
405
- const configUtils = createConfigUtils(configMeta, configOptions);
406
- // env
407
- const env = configUtils.loadEnvs();
408
- // package.json
409
- const pkgContent = replaceTemplate(__template_package, {
410
- Name: bundleName,
411
- Version: env.APP_VERSION
412
- });
413
- await fse.writeFile(path.join(srcDir, 'package.json'), pkgContent);
414
- }
415
- async _prepareResourcesIndex({
416
- srcDir,
417
- projectPath
418
- }) {
419
- let indexContent = `import type { IIconRecord } from 'zova-module-a-icon';
420
- export type { IIconRecord } from 'zova-module-a-icon';
421
- import type { TypePagePathSchema } from 'zova-module-a-router';
422
- export type { IPagePathRecord } from 'zova-module-a-router';
423
- import type { IActionRecord, TypeActionOptions } from 'zova-module-a-action';
424
- export type { IActionRecord } from 'zova-module-a-action';
425
- import type { IVonaComponentRecord, TypeComponentOptions } from 'zova-module-a-bean';
426
- export type { IVonaComponentRecord } from 'zova-module-a-bean';
427
- export type {
428
- IResourceComponentActionBulkRecord,
429
- IResourceComponentActionRowRecord,
430
- IResourceComponentBlockRecord,
431
- IResourceComponentFormFieldRecord,
432
- IResourceComponentTableCellRecord,
433
- ISchemaRenderComponentLayoutOptions,
434
- } from 'zova-module-a-openapi';
435
- `;
436
- indexContent += await this._prepareResourcesIndex_rest(srcDir);
437
- indexContent += await this._prepareResourcesIndex_icons(srcDir);
438
- indexContent += await this._prepareResourcesIndex_pages(srcDir);
439
- indexContent += await this._prepareResourcesIndex_providers(srcDir, projectPath);
440
- await fse.writeFile(path.join(srcDir, 'index.ts'), indexContent);
441
- }
442
- async _prepareResourcesIndex_rest(srcDir) {
443
- let content = '';
444
- for (const module of this.modulesMeta.modulesArray) {
445
- const restDir = path.join(module.root, 'rest');
446
- if (!fse.existsSync(restDir)) continue;
447
- let tempDir;
448
- if (module.info.node_modules) {
449
- tempDir = path.join(srcDir, 'modules', module.info.relativeName, 'rest');
450
- await fse.copy(restDir, tempDir);
451
- } else {
452
- tempDir = path.join(module.root, 'rest');
453
- }
454
- const restIndexFile = path.join(tempDir, 'index.ts');
455
- let restIndexFileRelative = path.relative(srcDir, restIndexFile);
456
- if (!restIndexFileRelative.startsWith('.')) {
457
- restIndexFileRelative = `./${restIndexFileRelative}`;
458
- }
459
- content += `export * from '${restIndexFileRelative.replaceAll('\\', '/')}';\n`;
460
- }
461
- return content;
462
- }
463
- async _prepareResourcesIndex_icons(_srcDir) {
464
- const content = `export function $iconName<K extends keyof IIconRecord>(name: K): any {
465
- return name;
466
- }
467
- `;
468
- return content;
469
- }
470
- async _prepareResourcesIndex_providers(_srcDir, projectPath) {
471
- // openapi
472
- const dirBasicOpenapi = path.join(projectPath, './src/suite/cabloy-basic/modules/basic-openapi');
473
- const dirStartOpenapi = path.join(projectPath, './src/suite/cabloy-start/modules/start-openapi');
474
- let content = '';
475
- if (fse.existsSync(dirBasicOpenapi)) {
476
- content += `import 'zova-module-basic-openapi';\n`;
477
- } else if (fse.existsSync(dirStartOpenapi)) {
478
- content += `import 'zova-module-start-openapi';\n`;
479
- }
480
- // actions
481
- content += `export function Action<K extends keyof IActionRecord>(options: TypeActionOptions<K>) {
482
- if(!options.name) throw new Error('should specify the action name');
483
- return options.name.replace(':','.action.');
484
- }
485
- `;
486
- // components
487
- content += `export function Component<K extends keyof IVonaComponentRecord>(options: TypeComponentOptions<K>) {
488
- if (!options.name) throw new Error('should specify the component name');
489
- return options.name;
490
- }
491
- `;
492
- return content;
493
- }
494
- async _prepareResourcesIndex_pages(_srcDir) {
495
- const content = `declare module 'zova-module-a-router' {
496
- export interface IPagePathRecord {
497
- '/': TypePagePathSchema<undefined, undefined>;
498
- 'presetLogin': TypePagePathSchema<undefined, undefined>;
499
- 'presetErrorExpired': TypePagePathSchema<undefined, undefined>;
500
- 'presetResource': TypePagePathSchema<undefined, undefined>;
501
- }
502
- }
503
- `;
504
- return content;
505
- }
506
357
  }
507
358
  function _copyToTarget(outDir, target, bundleNameCopy) {
508
359
  if (!target) return;
@@ -20,16 +20,8 @@ interface IBinBuildRestContext {
20
20
  export declare class CliBinBuildRest extends BeanCliBase {
21
21
  execute(): Promise<void>;
22
22
  _prepareResources(context: IBinBuildRestContext): Promise<void>;
23
- _prepareResources_(context: IBinBuildRestContext): Promise<void>;
24
- _prepareBundleModules(): string[];
25
23
  _buildTs({ srcDir, outDir }: IBinBuildRestContext): Promise<void>;
26
24
  _buildDts({ srcDir, outDir, bundleModules }: IBinBuildRestContext): Promise<void>;
27
25
  _build(buildContext: IBinBuildRestContext): Promise<void>;
28
- _prepareResourcesPackage({ projectPath, flavor, bundleName, srcDir }: IBinBuildRestContext): Promise<void>;
29
- _prepareResourcesIndex({ srcDir, projectPath }: IBinBuildRestContext): Promise<void>;
30
- _prepareResourcesIndex_rest(srcDir: string): Promise<string>;
31
- _prepareResourcesIndex_icons(_srcDir: string): Promise<string>;
32
- _prepareResourcesIndex_providers(_srcDir: string, projectPath: string): Promise<string>;
33
- _prepareResourcesIndex_pages(_srcDir: string): Promise<string>;
34
26
  }
35
27
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zova-cli-set-front",
3
- "version": "1.2.41",
4
- "gitHead": "6c7a09c8f0a8a0f41c5090b544a1667dbc689f0e",
3
+ "version": "1.2.43",
4
+ "gitHead": "f5fbd410ec433943070bb60839f1e762f98593c6",
5
5
  "description": "zova cli-set-front",
6
6
  "keywords": [
7
7
  "framework",