@express-zod-api/migration 24.0.0-beta.1
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 +21 -0
- package/README.md +23 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +1 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Anna Bocharova
|
|
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/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Migration script for Express Zod API
|
|
2
|
+
|
|
3
|
+
ESLint plugin for migrating Express Zod API to its next major version.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- `eslint` v9;
|
|
8
|
+
- `typescript-eslint` v8.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
The minimal configuration to apply migrations automatically using `eslint --fix`:
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
// eslint.config.mjs
|
|
16
|
+
import parser from "@typescript-eslint/parser";
|
|
17
|
+
import migration from "@express-zod-api/migration";
|
|
18
|
+
|
|
19
|
+
export default [
|
|
20
|
+
{ languageOptions: { parser }, plugins: { migration } },
|
|
21
|
+
{ files: ["**/*.ts"], rules: { "migration/v24": "error" } },
|
|
22
|
+
];
|
|
23
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var f=(t,e)=>{for(var n in e)i(t,n,{get:e[n],enumerable:!0})},g=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of S(e))!d.call(t,o)&&o!==n&&i(t,o,{get:()=>e[o],enumerable:!(a=u(e,o))||a.enumerable});return t};var y=t=>g(i({},"__esModule",{value:!0}),t);var z={};f(z,{default:()=>b});module.exports=y(z);var r=require("@typescript-eslint/utils"),T={numericRange:`${r.AST_NODE_TYPES.NewExpression}[callee.name='Documentation'] > ${r.AST_NODE_TYPES.ObjectExpression} > ${r.AST_NODE_TYPES.Property}[key.name='numericRange']`,optionalPropStyle:`${r.AST_NODE_TYPES.NewExpression}[callee.name='Integration'] > ${r.AST_NODE_TYPES.ObjectExpression} > ${r.AST_NODE_TYPES.Property}[key.name='optionalPropStyle']`,depicter:`${r.AST_NODE_TYPES.VariableDeclarator}[id.typeAnnotation.typeAnnotation.typeName.name='Depicter'] > ${r.AST_NODE_TYPES.ArrowFunctionExpression}`,nextCall:`${r.AST_NODE_TYPES.VariableDeclarator}[id.typeAnnotation.typeAnnotation.typeName.name='Depicter'] > ${r.AST_NODE_TYPES.ArrowFunctionExpression} ${r.AST_NODE_TYPES.CallExpression}[callee.name='next']`,zod:`${r.AST_NODE_TYPES.ImportDeclaration}[source.value='zod']`,ezFile:`${r.AST_NODE_TYPES.CallExpression}[arguments.0.type='${r.AST_NODE_TYPES.Literal}']:has( ${r.AST_NODE_TYPES.MemberExpression}[object.name='ez'][property.name='file'] )`},E=t=>Object.keys(t).reduce((e,n)=>Object.assign(e,{[T[n]]:t[n]}),{}),l=(t,e)=>[t.range[0],t.range[1]+(e.sourceCode.getTokenAfter(t)?.value===","?1:0)],m=t=>e=>t.report({node:e,messageId:"remove",data:{subject:e.key.name},fix:n=>n.removeRange(l(e,t))}),x=r.ESLintUtils.RuleCreator.withoutDocs({meta:{type:"problem",fixable:"code",schema:[],messages:{change:"change {{ subject }} from {{ from }} to {{ to }}",add:"add {{ subject }} to {{ to }}",move:"move {{ subject }} to {{ to }}",remove:"remove {{ subject }}"}},defaultOptions:[],create:t=>E({numericRange:m(t),optionalPropStyle:m(t),depicter:e=>{let[n,a]=e.params;if(n?.type!==r.AST_NODE_TYPES.Identifier)return;let o=n.name;if(a?.type!==r.AST_NODE_TYPES.ObjectPattern)return;let p=a.properties.find(s=>s.type===r.AST_NODE_TYPES.Property&&s.key.type===r.AST_NODE_TYPES.Identifier&&s.key.name==="next");t.report({node:e,messageId:"change",data:{subject:"arguments",from:`[${o}, { next, ...rest }]`,to:`[{ zodSchema: ${o}, jsonSchema }, { ...rest }]`},fix:s=>{let c=[s.replaceText(n,`{ zodSchema: ${o}, jsonSchema }`)];return p&&c.push(s.removeRange(l(p,t))),c}})},nextCall:e=>t.report({node:e,messageId:"change",data:{subject:"statement",from:"next()",to:"jsonSchema"},fix:n=>n.replaceText(e,"jsonSchema")}),zod:e=>t.report({node:e.source,messageId:"change",data:{subject:"import",from:"zod",to:"zod/v4"},fix:n=>n.replaceText(e.source,'"zod/v4"')}),ezFile:e=>{let[n]=e.arguments,a=n.value==="buffer"?"ez.buffer()":n.value==="base64"?"z.base64()":n.value==="binary"?"ez.buffer().or(z.string())":"z.string()";t.report({node:e,messageId:"change",data:{subject:"schema",from:"ez.file()",to:a},fix:o=>o.replaceText(e,a)})}})}),b={rules:{v24:x}};
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @desc ESLint plugin for migrating to this version (from previous), requires eslint v9 and typescript-eslint v8
|
|
5
|
+
* @deprecated Single-use tool that can be removed and changed regardless SemVer. Remember to delete it after use.
|
|
6
|
+
* @example
|
|
7
|
+
* // eslint.config.mjs:
|
|
8
|
+
* import parser from "@typescript-eslint/parser";
|
|
9
|
+
* import migration from "express-zod-api/migration";
|
|
10
|
+
* export default [
|
|
11
|
+
* { languageOptions: {parser}, plugins: {migration} },
|
|
12
|
+
* { files: ["**\/*.ts"], rules: { "migration/v24": "error" } }
|
|
13
|
+
* ];
|
|
14
|
+
* */
|
|
15
|
+
declare const _default: {
|
|
16
|
+
rules: {
|
|
17
|
+
v24: ESLintUtils.RuleModule<"change" | "add" | "move" | "remove", [], unknown, ESLintUtils.RuleListener>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export = _default;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @desc ESLint plugin for migrating to this version (from previous), requires eslint v9 and typescript-eslint v8
|
|
5
|
+
* @deprecated Single-use tool that can be removed and changed regardless SemVer. Remember to delete it after use.
|
|
6
|
+
* @example
|
|
7
|
+
* // eslint.config.mjs:
|
|
8
|
+
* import parser from "@typescript-eslint/parser";
|
|
9
|
+
* import migration from "express-zod-api/migration";
|
|
10
|
+
* export default [
|
|
11
|
+
* { languageOptions: {parser}, plugins: {migration} },
|
|
12
|
+
* { files: ["**\/*.ts"], rules: { "migration/v24": "error" } }
|
|
13
|
+
* ];
|
|
14
|
+
* */
|
|
15
|
+
declare const _default: {
|
|
16
|
+
rules: {
|
|
17
|
+
v24: ESLintUtils.RuleModule<"change" | "add" | "move" | "remove", [], unknown, ESLintUtils.RuleListener>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { _default as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ESLintUtils as l,AST_NODE_TYPES as t}from"@typescript-eslint/utils";var u={numericRange:`${t.NewExpression}[callee.name='Documentation'] > ${t.ObjectExpression} > ${t.Property}[key.name='numericRange']`,optionalPropStyle:`${t.NewExpression}[callee.name='Integration'] > ${t.ObjectExpression} > ${t.Property}[key.name='optionalPropStyle']`,depicter:`${t.VariableDeclarator}[id.typeAnnotation.typeAnnotation.typeName.name='Depicter'] > ${t.ArrowFunctionExpression}`,nextCall:`${t.VariableDeclarator}[id.typeAnnotation.typeAnnotation.typeName.name='Depicter'] > ${t.ArrowFunctionExpression} ${t.CallExpression}[callee.name='next']`,zod:`${t.ImportDeclaration}[source.value='zod']`,ezFile:`${t.CallExpression}[arguments.0.type='${t.Literal}']:has( ${t.MemberExpression}[object.name='ez'][property.name='file'] )`},S=r=>Object.keys(r).reduce((e,n)=>Object.assign(e,{[u[n]]:r[n]}),{}),m=(r,e)=>[r.range[0],r.range[1]+(e.sourceCode.getTokenAfter(r)?.value===","?1:0)],c=r=>e=>r.report({node:e,messageId:"remove",data:{subject:e.key.name},fix:n=>n.removeRange(m(e,r))}),d=l.RuleCreator.withoutDocs({meta:{type:"problem",fixable:"code",schema:[],messages:{change:"change {{ subject }} from {{ from }} to {{ to }}",add:"add {{ subject }} to {{ to }}",move:"move {{ subject }} to {{ to }}",remove:"remove {{ subject }}"}},defaultOptions:[],create:r=>S({numericRange:c(r),optionalPropStyle:c(r),depicter:e=>{let[n,a]=e.params;if(n?.type!==t.Identifier)return;let s=n.name;if(a?.type!==t.ObjectPattern)return;let i=a.properties.find(o=>o.type===t.Property&&o.key.type===t.Identifier&&o.key.name==="next");r.report({node:e,messageId:"change",data:{subject:"arguments",from:`[${s}, { next, ...rest }]`,to:`[{ zodSchema: ${s}, jsonSchema }, { ...rest }]`},fix:o=>{let p=[o.replaceText(n,`{ zodSchema: ${s}, jsonSchema }`)];return i&&p.push(o.removeRange(m(i,r))),p}})},nextCall:e=>r.report({node:e,messageId:"change",data:{subject:"statement",from:"next()",to:"jsonSchema"},fix:n=>n.replaceText(e,"jsonSchema")}),zod:e=>r.report({node:e.source,messageId:"change",data:{subject:"import",from:"zod",to:"zod/v4"},fix:n=>n.replaceText(e.source,'"zod/v4"')}),ezFile:e=>{let[n]=e.arguments,a=n.value==="buffer"?"ez.buffer()":n.value==="base64"?"z.base64()":n.value==="binary"?"ez.buffer().or(z.string())":"z.string()";r.report({node:e,messageId:"change",data:{subject:"schema",from:"ez.file()",to:a},fix:s=>s.replaceText(e,a)})}})}),g={rules:{v24:d}};export{g as default};
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@express-zod-api/migration",
|
|
3
|
+
"version": "24.0.0-beta.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Migration scripts for express-zod-api",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/RobinTail/express-zod-api.git"
|
|
9
|
+
},
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Anna Bocharova",
|
|
12
|
+
"url": "https://robintail.cz",
|
|
13
|
+
"email": "me@robintail.cz"
|
|
14
|
+
},
|
|
15
|
+
"bugs": "https://github.com/RobinTail/express-zod-api/issues",
|
|
16
|
+
"funding": "https://github.com/sponsors/RobinTail",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "dist/index.cjs",
|
|
19
|
+
"types": "dist/index.d.cts",
|
|
20
|
+
"module": "dist/index.js",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"default": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"require": {
|
|
28
|
+
"types": "./dist/index.d.cts",
|
|
29
|
+
"default": "./dist/index.cjs"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"*.md"
|
|
36
|
+
],
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"typescript-eslint": "^8.0.0",
|
|
39
|
+
"eslint": "^9.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@typescript-eslint/rule-tester": "^8.34.0"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"pretest": "tsc --noEmit",
|
|
46
|
+
"test": "vitest run --globals",
|
|
47
|
+
"build": "tsup",
|
|
48
|
+
"postbuild": "attw --pack"
|
|
49
|
+
}
|
|
50
|
+
}
|