zova-module-a-zod 5.0.0 → 5.1.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016-present Zova
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js ADDED
@@ -0,0 +1,48 @@
1
+ import { BeanBase, BeanInfo, BeanScopeBase, useApp, useComputed } from "zova";
2
+ import z from "zod";
3
+ import { Scope, Tool } from "zova-module-a-bean";
4
+ //#region src/bean/tool.v.ts
5
+ var _dec$1, _dec2$1, _class$1;
6
+ var ToolV = (_dec$1 = Tool(), _dec2$1 = BeanInfo({ module: "a-zod" }), _dec$1(_class$1 = _dec2$1(_class$1 = class ToolV extends BeanBase {
7
+ async __init__() {}
8
+ required(schema, params) {
9
+ params = params || this.scope.locale.ZodErrorRequired();
10
+ schema._zod.def.error = z.util.normalizeParams(params).error;
11
+ return schema;
12
+ }
13
+ }) || _class$1) || _class$1);
14
+ //#endregion
15
+ //#region src/.metadata/index.ts
16
+ /** tool: end */
17
+ /** locale: begin */
18
+ /** locale: end */
19
+ /** scope: begin */
20
+ var _dec, _dec2, _class;
21
+ var ScopeModuleAZod = (_dec = Scope(), _dec2 = BeanInfo({ module: "a-zod" }), _dec(_class = _dec2(_class = class ScopeModuleAZod extends BeanScopeBase {}) || _class) || _class);
22
+ function locale(key) {
23
+ return `a-zod::${key}`;
24
+ }
25
+ /** scope: end */
26
+ //#endregion
27
+ //#region src/config/locale/en-us.ts
28
+ var en_us_default = { ZodErrorRequired: "Required" };
29
+ //#endregion
30
+ //#region src/config/locale/zh-cn.ts
31
+ var zh_cn_default = { ZodErrorRequired: "必填项" };
32
+ //#endregion
33
+ //#region src/.metadata/locales.ts
34
+ var locales = {
35
+ "en-us": en_us_default,
36
+ "zh-cn": zh_cn_default
37
+ };
38
+ function $useLocale(key, ...args) {
39
+ const app = useApp();
40
+ const str = `a-zod::${key}`;
41
+ return useComputed(() => {
42
+ return app.meta.text(str, ...args);
43
+ });
44
+ }
45
+ //#endregion
46
+ export { $useLocale, ScopeModuleAZod, ToolV, locale, locales };
47
+
48
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/bean/tool.v.ts","../src/.metadata/index.ts","../src/config/locale/en-us.ts","../src/config/locale/zh-cn.ts","../src/.metadata/locales.ts"],"sourcesContent":["import z from 'zod';\nimport { BeanBase } from 'zova';\nimport { Tool } from 'zova-module-a-bean';\n\n@Tool()\nexport class ToolV extends BeanBase {\n protected async __init__() {}\n\n required<T extends z.ZodType>(schema: T, params?: string | z.core.$ZodStringParams): T {\n params = params || this.scope.locale.ZodErrorRequired();\n schema._zod.def.error = z.util.normalizeParams(params).error;\n return schema;\n }\n}\n","// eslint-disable\n/** tool: begin */\nexport * from '../bean/tool.v.js';\n\nimport 'zova';\ndeclare module 'zova' {\n \n \n}\ndeclare module 'zova-module-a-zod' {\n \n export interface ToolV {\n /** @internal */\n get scope(): ScopeModuleAZod;\n }\n\n export interface ToolV {\n get $beanFullName(): 'a-zod.tool.v';\n get $onionName(): 'a-zod:v';\n \n } \n}\n/** tool: end */\n/** tool: begin */\nimport { ToolV } from '../bean/tool.v.js';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordGeneral {\n 'a-zod.tool.v': ToolV;\n }\n}\n/** tool: end */\n/** locale: begin */\nimport { locales } from './locales.js';\n/** locale: end */\n/** scope: begin */\nimport { BeanScopeBase, type BeanScopeUtil, TypeModuleLocales, TypeLocaleBase } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\n\n@Scope()\nexport class ScopeModuleAZod extends BeanScopeBase {}\n\nexport interface ScopeModuleAZod {\n util: BeanScopeUtil;\nlocale: TypeModuleLocales<(typeof locales)[TypeLocaleBase]>;\n}\n\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanScopeRecord {\n 'a-zod': ScopeModuleAZod;\n }\n \n \n\n export interface IBeanScopeLocale {\n 'a-zod': (typeof locales)[TypeLocaleBase];\n }\n\n \n}\n\nexport function locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K): `a-zod::${K}` {\n return `a-zod::${key}`;\n} \n/** scope: end */\n","export default {\n ZodErrorRequired: 'Required',\n};\n","export default {\n ZodErrorRequired: '必填项',\n};\n","import type { TypeLocaleBase } from 'zova';\nimport { useApp, useComputed } from 'zova';\nimport locale_en_us from '../config/locale/en-us.js';\nimport locale_zh_cn from '../config/locale/zh-cn.js';\n\nexport const locales = {\n 'en-us': locale_en_us,\n 'zh-cn': locale_zh_cn,\n};\n\nexport function $useLocale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K, ...args: any[]) {\n const app = useApp();\n const str = `a-zod::${key}`;\n return useComputed(() => {\n return app.meta.text(str, ...args);\n });\n}\n"],"mappings":";;;;AAAA,IAAA,QAAS,SAAM;AAKf,IAAO,SAAY,SAAQ,MAAA,EAAQ,UAAC,SAAA,EAClC,QAAA,SAAA,CAAA,EAAA,OAAA,WAAA,QAAA,WAAA,MAAA,cAAA,SAAA;CAEA,MAAA,WAAW;CACX,SAAS,QAAQ,QAAQ;AACvB,WAAO,UAAS,KAAQ,MAAM,OAAC,kBAAwB;AACvD,SAAO,KAAA,IAAM,QAAA,EAAA,KAAA,gBAAA,OAAA,CAAA;AACf,SAAA;;;;;;;;;ACZF,IAAG,MAAO,OAAA;AAiBV,IAAU,mBAAoB,OAAO,OAAO,EAAC,QAAA,SAAA,EAC3C,QAAQ,SACT,CAAC,EAAE,KAAK,SAAA,MAAA,SAAA,MAAA,wBAAA,cAAA,GAAA,IAAA,OAAA,IAAA;AAET,SAAA,OAAA,KAAA;AACE,QAAO,UAAM;;;;;ACtBf,IAAA,gBAAe,EACb,kBAAkB,YACnB;;;ACFD,IAAA,gBAAe,EACb,kBAAkB,OACnB;;;ACCD,IAAO,UAAa;;CAEpB,SAAO;CACN;AACD,SAAW,WAAY,KAAA,GAAA,MAAA;CACtB,MAAA,MAAA,QAAA;;AAED,QAAO,kBAAoB;AACzB,SAAS,IAAG,KAAM,KAAE,KAAA,GAAA,KAAA;GACpB"}
package/package.json CHANGED
@@ -1,37 +1,64 @@
1
1
  {
2
2
  "name": "zova-module-a-zod",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
+ "description": "",
5
+ "keywords": [
6
+ "Zova Module"
7
+ ],
8
+ "author": "",
9
+ "files": [
10
+ "dist",
11
+ "mock",
12
+ "src",
13
+ "icons",
14
+ "assets",
15
+ "rest"
16
+ ],
4
17
  "type": "module",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
18
  "exports": {
9
19
  ".": {
10
20
  "types": [
11
21
  "./src/index.ts",
12
22
  "./dist/index.d.ts"
13
23
  ],
14
- "development": "./src/index.ts",
15
- "import": "./dist/index.js",
16
- "default": "./src/index.ts"
24
+ "default": "./dist/index.js"
17
25
  },
18
- "./package.json": "./package.json"
26
+ "./*": "./*"
19
27
  },
20
- "description": "",
21
- "files": [
22
- "dist",
23
- "static",
24
- "typings"
25
- ],
26
28
  "scripts": {
27
- "build:front": "node ../../../../../scripts/egg-born-bin.js front-build-module",
28
- "build:backend": "node ../../../../../scripts/egg-born-bin.js backend-build-module",
29
- "build:all": "npm run build:front && npm run build:backend",
30
- "preversion": "npm run build:all && git add ."
29
+ "clean": "rimraf dist tsconfig.build.tsbuildinfo",
30
+ "tsc:publish": "npm run clean && zova :bin:buildModule --sourcemap",
31
+ "prepublishOnly": "npm run tsc:publish",
32
+ "prepack": "clean-package",
33
+ "postpack": "clean-package restore && npm run clean"
31
34
  },
32
- "keywords": [
33
- "Cabloy Module"
34
- ],
35
- "author": "zhennann",
36
- "dependencies": {}
35
+ "dependencies": {
36
+ "@cabloy/zod-errors-custom": "^2.0.3",
37
+ "@cabloy/zod-openapi": "^1.0.10",
38
+ "@cabloy/zod-query": "^2.0.3",
39
+ "zod": "^4.1.5"
40
+ },
41
+ "title": "a-zod",
42
+ "zovaModule": {
43
+ "globalDependencies": {
44
+ "@cabloy/zod-openapi": true,
45
+ "zod": true
46
+ },
47
+ "bundle": {
48
+ "vendors": [
49
+ {
50
+ "match": [
51
+ "@cabloy/zod-errors-custom",
52
+ "@cabloy/zod-openapi",
53
+ "@cabloy/zod-query",
54
+ "zod/locales",
55
+ "zod/v4",
56
+ "~node_modules/zod/index.js"
57
+ ],
58
+ "output": "zod"
59
+ }
60
+ ]
61
+ }
62
+ },
63
+ "gitHead": "bf1ceb4582381c74ba41ccf11b89d3b9e7b73628"
37
64
  }
@@ -0,0 +1,66 @@
1
+ // eslint-disable
2
+ /** tool: begin */
3
+ export * from '../bean/tool.v.js';
4
+
5
+ import 'zova';
6
+ declare module 'zova' {
7
+
8
+
9
+ }
10
+ declare module 'zova-module-a-zod' {
11
+
12
+ export interface ToolV {
13
+ /** @internal */
14
+ get scope(): ScopeModuleAZod;
15
+ }
16
+
17
+ export interface ToolV {
18
+ get $beanFullName(): 'a-zod.tool.v';
19
+ get $onionName(): 'a-zod:v';
20
+
21
+ }
22
+ }
23
+ /** tool: end */
24
+ /** tool: begin */
25
+ import { ToolV } from '../bean/tool.v.js';
26
+ import 'zova';
27
+ declare module 'zova' {
28
+ export interface IBeanRecordGeneral {
29
+ 'a-zod.tool.v': ToolV;
30
+ }
31
+ }
32
+ /** tool: end */
33
+ /** locale: begin */
34
+ import { locales } from './locales.js';
35
+ /** locale: end */
36
+ /** scope: begin */
37
+ import { BeanScopeBase, type BeanScopeUtil, TypeModuleLocales, TypeLocaleBase } from 'zova';
38
+ import { Scope } from 'zova-module-a-bean';
39
+
40
+ @Scope()
41
+ export class ScopeModuleAZod extends BeanScopeBase {}
42
+
43
+ export interface ScopeModuleAZod {
44
+ util: BeanScopeUtil;
45
+ locale: TypeModuleLocales<(typeof locales)[TypeLocaleBase]>;
46
+ }
47
+
48
+ import 'zova';
49
+ declare module 'zova' {
50
+ export interface IBeanScopeRecord {
51
+ 'a-zod': ScopeModuleAZod;
52
+ }
53
+
54
+
55
+
56
+ export interface IBeanScopeLocale {
57
+ 'a-zod': (typeof locales)[TypeLocaleBase];
58
+ }
59
+
60
+
61
+ }
62
+
63
+ export function locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K): `a-zod::${K}` {
64
+ return `a-zod::${key}`;
65
+ }
66
+ /** scope: end */
@@ -0,0 +1,17 @@
1
+ import type { TypeLocaleBase } from 'zova';
2
+ import { useApp, useComputed } from 'zova';
3
+ import locale_en_us from '../config/locale/en-us.js';
4
+ import locale_zh_cn from '../config/locale/zh-cn.js';
5
+
6
+ export const locales = {
7
+ 'en-us': locale_en_us,
8
+ 'zh-cn': locale_zh_cn,
9
+ };
10
+
11
+ export function $useLocale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K, ...args: any[]) {
12
+ const app = useApp();
13
+ const str = `a-zod::${key}`;
14
+ return useComputed(() => {
15
+ return app.meta.text(str, ...args);
16
+ });
17
+ }
@@ -0,0 +1,2 @@
1
+ export const __ThisModule__ = 'a-zod';
2
+ export { ScopeModuleAZod as ScopeModule } from './index.js';
@@ -0,0 +1,14 @@
1
+ import z from 'zod';
2
+ import { BeanBase } from 'zova';
3
+ import { Tool } from 'zova-module-a-bean';
4
+
5
+ @Tool()
6
+ export class ToolV extends BeanBase {
7
+ protected async __init__() {}
8
+
9
+ required<T extends z.ZodType>(schema: T, params?: string | z.core.$ZodStringParams): T {
10
+ params = params || this.scope.locale.ZodErrorRequired();
11
+ schema._zod.def.error = z.util.normalizeParams(params).error;
12
+ return schema;
13
+ }
14
+ }
@@ -0,0 +1,3 @@
1
+ export default {
2
+ ZodErrorRequired: 'Required',
3
+ };
@@ -0,0 +1,3 @@
1
+ export default {
2
+ ZodErrorRequired: '必填项',
3
+ };
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './.metadata/index.js';
2
+ export * from './.metadata/locales.js';
package/README.md DELETED
@@ -1 +0,0 @@
1
- # @cabloy/set