@medusajs/http-types-generator 2.13.6-preview-20260402101111
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/README.md +135 -0
- package/dist/__tests__/compatibility-checker.spec.d.ts +2 -0
- package/dist/__tests__/compatibility-checker.spec.d.ts.map +1 -0
- package/dist/__tests__/compatibility-checker.spec.js +231 -0
- package/dist/__tests__/compatibility-checker.spec.js.map +1 -0
- package/dist/__tests__/config.spec.d.ts +2 -0
- package/dist/__tests__/config.spec.d.ts.map +1 -0
- package/dist/__tests__/config.spec.js +78 -0
- package/dist/__tests__/config.spec.js.map +1 -0
- package/dist/__tests__/import-tracker.spec.d.ts +2 -0
- package/dist/__tests__/import-tracker.spec.d.ts.map +1 -0
- package/dist/__tests__/import-tracker.spec.js +25 -0
- package/dist/__tests__/import-tracker.spec.js.map +1 -0
- package/dist/__tests__/name-classifier.spec.d.ts +2 -0
- package/dist/__tests__/name-classifier.spec.d.ts.map +1 -0
- package/dist/__tests__/name-classifier.spec.js +77 -0
- package/dist/__tests__/name-classifier.spec.js.map +1 -0
- package/dist/__tests__/name-registry.spec.d.ts +2 -0
- package/dist/__tests__/name-registry.spec.d.ts.map +1 -0
- package/dist/__tests__/name-registry.spec.js +67 -0
- package/dist/__tests__/name-registry.spec.js.map +1 -0
- package/dist/__tests__/path-mapper.spec.d.ts +2 -0
- package/dist/__tests__/path-mapper.spec.d.ts.map +1 -0
- package/dist/__tests__/path-mapper.spec.js +98 -0
- package/dist/__tests__/path-mapper.spec.js.map +1 -0
- package/dist/__tests__/type-emitter.spec.d.ts +2 -0
- package/dist/__tests__/type-emitter.spec.d.ts.map +1 -0
- package/dist/__tests__/type-emitter.spec.js +173 -0
- package/dist/__tests__/type-emitter.spec.js.map +1 -0
- package/dist/__tests__/type-pipeline.spec.d.ts +2 -0
- package/dist/__tests__/type-pipeline.spec.d.ts.map +1 -0
- package/dist/__tests__/type-pipeline.spec.js +239 -0
- package/dist/__tests__/type-pipeline.spec.js.map +1 -0
- package/dist/__tests__/utils/ts-utils.d.ts +22 -0
- package/dist/__tests__/utils/ts-utils.d.ts.map +1 -0
- package/dist/__tests__/utils/ts-utils.js +66 -0
- package/dist/__tests__/utils/ts-utils.js.map +1 -0
- package/dist/commands/generate.d.ts +10 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +215 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/validate.d.ts +14 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +201 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/config/index.d.ts +52 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +119 -0
- package/dist/config/index.js.map +1 -0
- package/dist/core/compatibility-checker.d.ts +92 -0
- package/dist/core/compatibility-checker.d.ts.map +1 -0
- package/dist/core/compatibility-checker.js +415 -0
- package/dist/core/compatibility-checker.js.map +1 -0
- package/dist/core/import-tracker.d.ts +11 -0
- package/dist/core/import-tracker.d.ts.map +1 -0
- package/dist/core/import-tracker.js +17 -0
- package/dist/core/import-tracker.js.map +1 -0
- package/dist/core/program-factory.d.ts +23 -0
- package/dist/core/program-factory.d.ts.map +1 -0
- package/dist/core/program-factory.js +80 -0
- package/dist/core/program-factory.js.map +1 -0
- package/dist/core/schema-extractor.d.ts +73 -0
- package/dist/core/schema-extractor.d.ts.map +1 -0
- package/dist/core/schema-extractor.js +205 -0
- package/dist/core/schema-extractor.js.map +1 -0
- package/dist/core/type-emitter.d.ts +73 -0
- package/dist/core/type-emitter.d.ts.map +1 -0
- package/dist/core/type-emitter.js +246 -0
- package/dist/core/type-emitter.js.map +1 -0
- package/dist/core/type-resolver.d.ts +64 -0
- package/dist/core/type-resolver.d.ts.map +1 -0
- package/dist/core/type-resolver.js +163 -0
- package/dist/core/type-resolver.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/mapping/name-classifier.d.ts +34 -0
- package/dist/mapping/name-classifier.d.ts.map +1 -0
- package/dist/mapping/name-classifier.js +72 -0
- package/dist/mapping/name-classifier.js.map +1 -0
- package/dist/mapping/name-registry.d.ts +54 -0
- package/dist/mapping/name-registry.d.ts.map +1 -0
- package/dist/mapping/name-registry.js +251 -0
- package/dist/mapping/name-registry.js.map +1 -0
- package/dist/mapping/path-mapper.d.ts +62 -0
- package/dist/mapping/path-mapper.d.ts.map +1 -0
- package/dist/mapping/path-mapper.js +116 -0
- package/dist/mapping/path-mapper.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/file-merger.d.ts +47 -0
- package/dist/utils/file-merger.d.ts.map +1 -0
- package/dist/utils/file-merger.js +164 -0
- package/dist/utils/file-merger.js.map +1 -0
- package/dist/utils/formatter.d.ts +12 -0
- package/dist/utils/formatter.d.ts.map +1 -0
- package/dist/utils/formatter.js +31 -0
- package/dist/utils/formatter.js.map +1 -0
- package/dist/utils/fs-helpers.d.ts +21 -0
- package/dist/utils/fs-helpers.d.ts.map +1 -0
- package/dist/utils/fs-helpers.js +42 -0
- package/dist/utils/fs-helpers.js.map +1 -0
- package/dist/utils/index-manager.d.ts +24 -0
- package/dist/utils/index-manager.d.ts.map +1 -0
- package/dist/utils/index-manager.js +95 -0
- package/dist/utils/index-manager.js.map +1 -0
- package/dist/utils/ts-helpers.d.ts +87 -0
- package/dist/utils/ts-helpers.d.ts.map +1 -0
- package/dist/utils/ts-helpers.js +216 -0
- package/dist/utils/ts-helpers.js.map +1 -0
- package/package.json +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# @medusajs/http-types-generator
|
|
2
|
+
|
|
3
|
+
CLI tool that generates and validates TypeScript HTTP types from Zod validator schemas.
|
|
4
|
+
|
|
5
|
+
## How it works
|
|
6
|
+
|
|
7
|
+
The tool scans validator files, extracts exported Zod schemas, resolves their TypeScript types, and emits `interface` declarations into output files. It can also check whether existing HTTP type files are structurally compatible with their corresponding Zod schemas.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Usage in the Medusa monorepo
|
|
12
|
+
|
|
13
|
+
Run from the repo root using the workspace scripts:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Generate types for a domain
|
|
17
|
+
yarn generate:http-types --domain products --dry-run
|
|
18
|
+
yarn generate:http-types --domain products
|
|
19
|
+
|
|
20
|
+
# Validate all types
|
|
21
|
+
yarn validate:http-types
|
|
22
|
+
|
|
23
|
+
# Validate a single domain
|
|
24
|
+
yarn validate:http-types --domain products --verbose
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The repo root's `http-types.config.json` configures the Medusa-specific paths automatically — no additional setup is needed.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Commands
|
|
32
|
+
|
|
33
|
+
### `generate`
|
|
34
|
+
|
|
35
|
+
Generates TypeScript interface files from Zod schemas.
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
yarn generate:http-types [options]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
| Option | Description | Default |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| `--area <area>` | Area to process. Must match a key in `validatorGlobs` (`store` or `admin` for monorepo), or `all` for every area. | `all` |
|
|
44
|
+
| `--domain <domain>` | Limit to a specific domain (route directory name). | — |
|
|
45
|
+
| `--dry-run` | Print what would be generated without writing files. | `false` |
|
|
46
|
+
| `--force` | Overwrite existing files instead of merging. | `false` |
|
|
47
|
+
| `--verbose` | Print each processed schema. | `false` |
|
|
48
|
+
|
|
49
|
+
### `validate`
|
|
50
|
+
|
|
51
|
+
Checks that existing HTTP types are structurally compatible with their Zod schemas.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
yarn validate:http-types [options]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
| Option | Description | Default |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| `--area <area>` | Area to validate. | `all` |
|
|
60
|
+
| `--domain <domain>` | Limit to a specific domain. | — |
|
|
61
|
+
| `--changed-files <paths>` | Comma-separated list of changed validator files (CI optimisation). | — |
|
|
62
|
+
| `--lenient` | Treat `T \| null \| undefined` as compatible with `T \| undefined`. | `false` |
|
|
63
|
+
| `--ci` | Exit with code 1 if any failures are found. | `false` |
|
|
64
|
+
| `--verbose` | Show passing types in addition to failures. | `false` |
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## General usage
|
|
69
|
+
|
|
70
|
+
### Installation
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npm install --save-dev @medusajs/http-types-generator
|
|
74
|
+
# or run without installing:
|
|
75
|
+
npx @medusajs/http-types-generator generate
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Configuration
|
|
79
|
+
|
|
80
|
+
Place an `http-types.config.json` file in your project root. All fields are optional and are deep-merged over the defaults.
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"validatorGlobs": {
|
|
85
|
+
"admin": "src/api/admin/*/validators.ts",
|
|
86
|
+
"store": "src/api/store/*/validators.ts"
|
|
87
|
+
},
|
|
88
|
+
"outputBase": "src/types/http",
|
|
89
|
+
"tsconfig": "tsconfig.json",
|
|
90
|
+
"importSources": {
|
|
91
|
+
"commonRequest": "@medusajs/framework/types",
|
|
92
|
+
"dal": "@medusajs/framework/types"
|
|
93
|
+
},
|
|
94
|
+
"validatorPathPattern": "/api/([^/]+)/([^/]+)/validators\\.ts$",
|
|
95
|
+
"publicPrefixes": ["Admin", "Store"]
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
| Field | Description | Default |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| `validatorGlobs` | Glob patterns (relative to project root) keyed by area name. | `{ admin: "**/api/admin/*/validators.ts", store: "**/api/store/*/validators.ts" }` |
|
|
102
|
+
| `outputBase` | Root directory for generated files, relative to project root. | `"src/types/http"` |
|
|
103
|
+
| `tsconfig` | tsconfig filename at the project root used when creating the TypeScript program. | `"tsconfig.json"` |
|
|
104
|
+
| `importSources.commonRequest` | Module that exports `FindParams` and `SelectParams`. | `"@medusajs/framework/types"` |
|
|
105
|
+
| `importSources.dal` | Module that exports `BaseFilterable` and `OperatorMap`. | `"@medusajs/framework/types"` |
|
|
106
|
+
| `validatorPathPattern` | Regex (no surrounding `/`) with two capture groups: `(area, routeDir)`. | `"/api/([^/]+)/([^/]+)/validators\\.ts$"` |
|
|
107
|
+
| `publicPrefixes` | Only schemas whose name starts with one of these prefixes are processed. | `["Admin", "Store"]` |
|
|
108
|
+
|
|
109
|
+
The config file is found by searching upward from the working directory, so it works whether the CLI is invoked from the project root or a subdirectory.
|
|
110
|
+
|
|
111
|
+
### Validator file conventions
|
|
112
|
+
|
|
113
|
+
Schemas must be exported from a `validators.ts` file whose path matches `validatorPathPattern`. The pattern must have two capture groups: area and route directory.
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
src/api/admin/products/validators.ts → area=admin, routeDir=products
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Export names must start with one of the `publicPrefixes`. The suffix determines the output file:
|
|
120
|
+
|
|
121
|
+
- Matches `Params`, `Filters` → `queries.ts`
|
|
122
|
+
- Matches `Create`, `Update`, `Batch`, etc. → `payloads.ts`
|
|
123
|
+
- Everything else defaults to `payloads.ts`
|
|
124
|
+
|
|
125
|
+
### Running with npx
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Generate
|
|
129
|
+
npx @medusajs/http-types-generator generate --dry-run
|
|
130
|
+
npx @medusajs/http-types-generator generate --domain products
|
|
131
|
+
|
|
132
|
+
# Validate
|
|
133
|
+
npx @medusajs/http-types-generator validate
|
|
134
|
+
npx @medusajs/http-types-generator validate --ci
|
|
135
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility-checker.spec.d.ts","sourceRoot":"","sources":["../../src/__tests__/compatibility-checker.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const compatibility_checker_1 = require("../core/compatibility-checker");
|
|
4
|
+
const ts_utils_1 = require("./utils/ts-utils");
|
|
5
|
+
function runCheck(zodSource, zodTypeName, httpSource, httpTypeName, lenient = false) {
|
|
6
|
+
const zodFile = "zod.ts";
|
|
7
|
+
const httpFile = "http.ts";
|
|
8
|
+
const { program, checker, getType } = (0, ts_utils_1.createTestProgram)({
|
|
9
|
+
[zodFile]: zodSource,
|
|
10
|
+
[httpFile]: httpSource,
|
|
11
|
+
});
|
|
12
|
+
const zodType = getType(zodFile, zodTypeName);
|
|
13
|
+
const pairs = [
|
|
14
|
+
{
|
|
15
|
+
validatorName: zodTypeName,
|
|
16
|
+
validatorFile: zodFile,
|
|
17
|
+
httpTypeName,
|
|
18
|
+
resolvedZodType: zodType,
|
|
19
|
+
httpTypeFile: httpFile,
|
|
20
|
+
hasFindParams: false,
|
|
21
|
+
hasSelectParams: false,
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
const compatChecker = new compatibility_checker_1.CompatibilityChecker(program, checker);
|
|
25
|
+
const results = compatChecker.check(pairs, [httpFile], lenient);
|
|
26
|
+
return results[0];
|
|
27
|
+
}
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
// CompatibilityChecker.formatResult
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
describe("CompatibilityChecker.formatResult", () => {
|
|
32
|
+
it("returns empty string for passing results when not verbose", () => {
|
|
33
|
+
const result = {
|
|
34
|
+
httpTypeName: "AdminCreateProduct",
|
|
35
|
+
httpTypeFile: "packages/core/types/src/http/product/admin/payloads.ts",
|
|
36
|
+
validatorName: "AdminCreateProduct",
|
|
37
|
+
validatorFile: "packages/medusa/src/api/admin/products/validators.ts",
|
|
38
|
+
passed: true,
|
|
39
|
+
typeNotFound: false,
|
|
40
|
+
missingFields: [],
|
|
41
|
+
typeMismatchFields: [],
|
|
42
|
+
extraFields: [],
|
|
43
|
+
};
|
|
44
|
+
expect(compatibility_checker_1.CompatibilityChecker.formatResult(result, false)).toBe("");
|
|
45
|
+
});
|
|
46
|
+
it("shows PASS line for passing results in verbose mode", () => {
|
|
47
|
+
const result = {
|
|
48
|
+
httpTypeName: "AdminCreateProduct",
|
|
49
|
+
httpTypeFile: "packages/core/types/src/http/product/admin/payloads.ts",
|
|
50
|
+
validatorName: "AdminCreateProduct",
|
|
51
|
+
validatorFile: "packages/medusa/src/api/admin/products/validators.ts",
|
|
52
|
+
passed: true,
|
|
53
|
+
typeNotFound: false,
|
|
54
|
+
missingFields: [],
|
|
55
|
+
typeMismatchFields: [],
|
|
56
|
+
extraFields: [],
|
|
57
|
+
};
|
|
58
|
+
expect(compatibility_checker_1.CompatibilityChecker.formatResult(result, true)).toContain("PASS");
|
|
59
|
+
expect(compatibility_checker_1.CompatibilityChecker.formatResult(result, true)).toContain("AdminCreateProduct");
|
|
60
|
+
});
|
|
61
|
+
it("shows FAIL line with missing fields for failures", () => {
|
|
62
|
+
const result = {
|
|
63
|
+
httpTypeName: "AdminUpdateCustomer",
|
|
64
|
+
httpTypeFile: "packages/core/types/src/http/customer/admin/payloads.ts",
|
|
65
|
+
validatorName: "AdminUpdateCustomer",
|
|
66
|
+
validatorFile: "packages/medusa/src/api/admin/customers/validators.ts",
|
|
67
|
+
passed: false,
|
|
68
|
+
typeNotFound: false,
|
|
69
|
+
missingFields: [
|
|
70
|
+
{ fieldName: "email", expectedType: "string | null | undefined" },
|
|
71
|
+
],
|
|
72
|
+
typeMismatchFields: [],
|
|
73
|
+
extraFields: [],
|
|
74
|
+
};
|
|
75
|
+
const output = compatibility_checker_1.CompatibilityChecker.formatResult(result, false);
|
|
76
|
+
expect(output).toContain("FAIL");
|
|
77
|
+
expect(output).toContain("AdminUpdateCustomer");
|
|
78
|
+
expect(output).toContain("Missing field: email");
|
|
79
|
+
expect(output).toContain("string | null | undefined");
|
|
80
|
+
});
|
|
81
|
+
it("shows type mismatch details for mismatch failures", () => {
|
|
82
|
+
const result = {
|
|
83
|
+
httpTypeName: "AdminCreateOrder",
|
|
84
|
+
httpTypeFile: "packages/core/types/src/http/order/admin/payloads.ts",
|
|
85
|
+
validatorName: "AdminCreateOrder",
|
|
86
|
+
validatorFile: "packages/medusa/src/api/admin/orders/validators.ts",
|
|
87
|
+
passed: false,
|
|
88
|
+
typeNotFound: false,
|
|
89
|
+
missingFields: [],
|
|
90
|
+
typeMismatchFields: [
|
|
91
|
+
{
|
|
92
|
+
fieldName: "status",
|
|
93
|
+
expectedType: "string",
|
|
94
|
+
actualType: "OrderStatus",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
extraFields: [],
|
|
98
|
+
};
|
|
99
|
+
const output = compatibility_checker_1.CompatibilityChecker.formatResult(result, false);
|
|
100
|
+
expect(output).toContain("Type mismatch: status");
|
|
101
|
+
expect(output).toContain("string");
|
|
102
|
+
expect(output).toContain("OrderStatus");
|
|
103
|
+
});
|
|
104
|
+
it("always shows HTTP-only fields in failing results", () => {
|
|
105
|
+
const result = {
|
|
106
|
+
httpTypeName: "AdminCreateProduct",
|
|
107
|
+
httpTypeFile: "packages/core/types/src/http/product/admin/payloads.ts",
|
|
108
|
+
validatorName: "AdminCreateProduct",
|
|
109
|
+
validatorFile: "packages/medusa/src/api/admin/products/validators.ts",
|
|
110
|
+
passed: false,
|
|
111
|
+
typeNotFound: false,
|
|
112
|
+
missingFields: [],
|
|
113
|
+
typeMismatchFields: [],
|
|
114
|
+
extraFields: [{ fieldName: "legacy_field", actualType: "string" }],
|
|
115
|
+
};
|
|
116
|
+
expect(compatibility_checker_1.CompatibilityChecker.formatResult(result, false)).toContain("legacy_field");
|
|
117
|
+
expect(compatibility_checker_1.CompatibilityChecker.formatResult(result, true)).toContain("legacy_field");
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
// CompatibilityChecker.check — structural diffing
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
describe("CompatibilityChecker.check", () => {
|
|
124
|
+
describe("passing cases", () => {
|
|
125
|
+
it("passes when Zod type exactly matches the HTTP type", () => {
|
|
126
|
+
const result = runCheck(`interface ZodShape { name: string; age: number }`, "ZodShape", `export interface HttpType { name: string; age: number }`, "HttpType");
|
|
127
|
+
expect(result.passed).toBe(true);
|
|
128
|
+
expect(result.missingFields).toHaveLength(0);
|
|
129
|
+
});
|
|
130
|
+
it("passes when Zod optional fields match HTTP optional fields", () => {
|
|
131
|
+
const result = runCheck(`interface ZodShape { name: string; description?: string }`, "ZodShape", `export interface HttpType { name: string; description?: string }`, "HttpType");
|
|
132
|
+
expect(result.passed).toBe(true);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
describe("extra fields", () => {
|
|
136
|
+
it("fails when HTTP type has a field not present in the Zod type", () => {
|
|
137
|
+
const result = runCheck(`interface ZodShape { name: string }`, "ZodShape", `export interface HttpType { name: string; extra?: string }`, "HttpType");
|
|
138
|
+
expect(result.passed).toBe(false);
|
|
139
|
+
expect(result.extraFields.map((f) => f.fieldName)).toContain("extra");
|
|
140
|
+
});
|
|
141
|
+
it("reports all HTTP-only fields when there are multiple", () => {
|
|
142
|
+
const result = runCheck(`interface ZodShape { name: string }`, "ZodShape", `export interface HttpType { name: string; fieldA: string; fieldB: number }`, "HttpType");
|
|
143
|
+
expect(result.passed).toBe(false);
|
|
144
|
+
const names = result.extraFields.map((f) => f.fieldName);
|
|
145
|
+
expect(names).toContain("fieldA");
|
|
146
|
+
expect(names).toContain("fieldB");
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
describe("type not found", () => {
|
|
150
|
+
it("fails with 'type not found' when the HTTP type doesn't exist", () => {
|
|
151
|
+
const result = runCheck(`interface ZodShape { name: string }`, "ZodShape", `export interface SomethingElse { name: string }`, "NonExistentType");
|
|
152
|
+
expect(result.passed).toBe(false);
|
|
153
|
+
expect(result.typeNotFound).toBe(true);
|
|
154
|
+
expect(result.missingFields).toHaveLength(0);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
describe("missing fields", () => {
|
|
158
|
+
it("reports fields present in Zod but missing from HTTP type", () => {
|
|
159
|
+
const result = runCheck(`interface ZodShape { name: string; email: string; age: number }`, "ZodShape", `export interface HttpType { name: string }`, "HttpType");
|
|
160
|
+
expect(result.passed).toBe(false);
|
|
161
|
+
const names = result.missingFields.map((f) => f.fieldName);
|
|
162
|
+
expect(names).toContain("email");
|
|
163
|
+
expect(names).toContain("age");
|
|
164
|
+
});
|
|
165
|
+
it("does not report Zod internal underscore-prefixed properties as missing", () => {
|
|
166
|
+
const result = runCheck(`interface ZodShape { name: string; _type: string; _output: unknown }`, "ZodShape", `export interface HttpType { name: string }`, "HttpType");
|
|
167
|
+
expect(result.passed).toBe(true);
|
|
168
|
+
expect(result.missingFields).toHaveLength(0);
|
|
169
|
+
});
|
|
170
|
+
it("does not report dollar-prefixed properties ($and, $or) as missing", () => {
|
|
171
|
+
const result = runCheck(`interface ZodShape { name: string; $and?: unknown; $or?: unknown }`, "ZodShape", `export interface HttpType { name: string }`, "HttpType");
|
|
172
|
+
expect(result.passed).toBe(true);
|
|
173
|
+
});
|
|
174
|
+
it("does not report fields with 'unknown' type as missing (unresolvable Zod constructs)", () => {
|
|
175
|
+
const result = runCheck(`interface ZodShape { name: string; preprocessed: unknown }`, "ZodShape", `export interface HttpType { name: string }`, "HttpType");
|
|
176
|
+
expect(result.passed).toBe(true);
|
|
177
|
+
const names = result.missingFields.map((f) => f.fieldName);
|
|
178
|
+
expect(names).not.toContain("preprocessed");
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
describe("type mismatches", () => {
|
|
182
|
+
it("reports type mismatch when field types are incompatible", () => {
|
|
183
|
+
const result = runCheck(`interface ZodShape { count: string }`, "ZodShape", `export interface HttpType { count: number }`, "HttpType");
|
|
184
|
+
expect(result.passed).toBe(false);
|
|
185
|
+
expect(result.typeMismatchFields[0]?.fieldName).toBe("count");
|
|
186
|
+
});
|
|
187
|
+
it("passes when Zod type is assignable to HTTP type (subtype)", () => {
|
|
188
|
+
const result = runCheck(`interface ZodShape { status: "active" }`, "ZodShape", `export interface HttpType { status: string }`, "HttpType");
|
|
189
|
+
expect(result.passed).toBe(true);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
describe("lenient mode", () => {
|
|
193
|
+
it("passes T|null|undefined vs T|undefined in lenient mode", () => {
|
|
194
|
+
const result = runCheck(`interface ZodShape { name: string | null | undefined }`, "ZodShape", `export interface HttpType { name?: string }`, "HttpType", true);
|
|
195
|
+
expect(result.passed).toBe(true);
|
|
196
|
+
});
|
|
197
|
+
it("still fails hard type mismatches even in lenient mode", () => {
|
|
198
|
+
const result = runCheck(`interface ZodShape { count: string | null | undefined }`, "ZodShape", `export interface HttpType { count?: number }`, "HttpType", true);
|
|
199
|
+
expect(result.passed).toBe(false);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
describe("string enum compatibility", () => {
|
|
203
|
+
it("passes when Zod has plain string and HTTP has a string literal union", () => {
|
|
204
|
+
const result = runCheck(`interface ZodShape { status: string }`, "ZodShape", `export interface HttpType { status: "active" | "inactive" }`, "HttpType");
|
|
205
|
+
expect(result.passed).toBe(true);
|
|
206
|
+
});
|
|
207
|
+
it("passes when Zod has string literal union and HTTP has plain string", () => {
|
|
208
|
+
const result = runCheck(`interface ZodShape { status: "active" | "inactive" }`, "ZodShape", `export interface HttpType { status: string }`, "HttpType");
|
|
209
|
+
expect(result.passed).toBe(true);
|
|
210
|
+
});
|
|
211
|
+
it("fails when Zod has values not present in the HTTP enum", () => {
|
|
212
|
+
const result = runCheck(`interface ZodShape { status: "a" | "b" | "c" }`, "ZodShape", `export interface HttpType { status: "a" | "b" }`, "HttpType");
|
|
213
|
+
expect(result.passed).toBe(false);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
describe("OperatorMap compatibility", () => {
|
|
217
|
+
it("passes when both sides have OperatorMap shape ($eq property)", () => {
|
|
218
|
+
const zodSource = `
|
|
219
|
+
interface OperatorMapLike { $eq?: string; $ne?: string; $in?: string[]; $nin?: string[]; $gt?: string; $gte?: string; $lt?: string; $lte?: string }
|
|
220
|
+
interface ZodShape { id: string | OperatorMapLike }
|
|
221
|
+
`;
|
|
222
|
+
const httpSource = `
|
|
223
|
+
interface OperatorMapLike { $eq?: string; $ne?: string; $in?: string[]; $nin?: string[]; $gt?: string; $gte?: string; $lt?: string; $lte?: string; $fulltext?: string }
|
|
224
|
+
export interface HttpType { id: string | OperatorMapLike }
|
|
225
|
+
`;
|
|
226
|
+
const result = runCheck(zodSource, "ZodShape", httpSource, "HttpType");
|
|
227
|
+
expect(result.passed).toBe(true);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
//# sourceMappingURL=compatibility-checker.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility-checker.spec.js","sourceRoot":"","sources":["../../src/__tests__/compatibility-checker.spec.ts"],"names":[],"mappings":";;AAAA,yEAIsC;AACtC,+CAAoD;AAEpD,SAAS,QAAQ,CACf,SAAiB,EACjB,WAAmB,EACnB,UAAkB,EAClB,YAAoB,EACpB,OAAO,GAAG,KAAK;IAEf,MAAM,OAAO,GAAG,QAAQ,CAAA;IACxB,MAAM,QAAQ,GAAG,SAAS,CAAA;IAE1B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAA,4BAAiB,EAAC;QACtD,CAAC,OAAO,CAAC,EAAE,SAAS;QACpB,CAAC,QAAQ,CAAC,EAAE,UAAU;KACvB,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;IAE7C,MAAM,KAAK,GAAgB;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"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_1 = require("../config");
|
|
4
|
+
describe("Config", () => {
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
config_1.Config.reset();
|
|
7
|
+
});
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
config_1.Config.reset();
|
|
10
|
+
});
|
|
11
|
+
describe("load() with override (bypasses file reading)", () => {
|
|
12
|
+
it("returns package defaults when called with an empty override", () => {
|
|
13
|
+
const config = config_1.Config.load({});
|
|
14
|
+
expect(config.tsconfig).toBe("tsconfig.json");
|
|
15
|
+
expect(config.publicPrefixes).toEqual(["Admin", "Store"]);
|
|
16
|
+
expect(config.importSources.commonRequest).toBe("@medusajs/framework/types");
|
|
17
|
+
expect(config.importSources.dal).toBe("@medusajs/framework/types");
|
|
18
|
+
expect(config.outputBase).toBe("src/types/http");
|
|
19
|
+
});
|
|
20
|
+
it("deep-merges a partial override over defaults", () => {
|
|
21
|
+
const config = config_1.Config.load({
|
|
22
|
+
outputBase: "packages/core/types/src/http",
|
|
23
|
+
tsconfig: "_tsconfig.base.json",
|
|
24
|
+
importSources: {
|
|
25
|
+
commonRequest: "packages/core/types/src/http/common",
|
|
26
|
+
dal: "packages/core/types/src/dal",
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
expect(config.outputBase).toBe("packages/core/types/src/http");
|
|
30
|
+
expect(config.tsconfig).toBe("_tsconfig.base.json");
|
|
31
|
+
expect(config.importSources.commonRequest).toBe("packages/core/types/src/http/common");
|
|
32
|
+
expect(config.importSources.dal).toBe("packages/core/types/src/dal");
|
|
33
|
+
// Unchanged defaults
|
|
34
|
+
expect(config.publicPrefixes).toEqual(["Admin", "Store"]);
|
|
35
|
+
});
|
|
36
|
+
it("deep-merges validatorGlobs over defaults", () => {
|
|
37
|
+
const config = config_1.Config.load({
|
|
38
|
+
validatorGlobs: {
|
|
39
|
+
admin: "packages/medusa/src/api/admin/*/validators.ts",
|
|
40
|
+
store: "packages/medusa/src/api/store/*/validators.ts",
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
expect(config.validatorGlobs.admin).toBe("packages/medusa/src/api/admin/*/validators.ts");
|
|
44
|
+
expect(config.validatorGlobs.store).toBe("packages/medusa/src/api/store/*/validators.ts");
|
|
45
|
+
});
|
|
46
|
+
it("sets projectRoot to process.cwd() when using an override", () => {
|
|
47
|
+
const config = config_1.Config.load({});
|
|
48
|
+
expect(config.projectRoot).toBe(process.cwd());
|
|
49
|
+
});
|
|
50
|
+
it("load() with override replaces the cached instance returned by get()", () => {
|
|
51
|
+
config_1.Config.load({}); // prime the cache with defaults
|
|
52
|
+
const overridden = config_1.Config.load({ outputBase: "overridden/path" });
|
|
53
|
+
expect(config_1.Config.get()).toBe(overridden);
|
|
54
|
+
expect(config_1.Config.get().outputBase).toBe("overridden/path");
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe("get() / reset()", () => {
|
|
58
|
+
it("get() returns the same cached instance on repeated calls", () => {
|
|
59
|
+
const a = config_1.Config.get();
|
|
60
|
+
const b = config_1.Config.get();
|
|
61
|
+
expect(a).toBe(b);
|
|
62
|
+
});
|
|
63
|
+
it("reset() clears the singleton so the next call reloads", () => {
|
|
64
|
+
const first = config_1.Config.load({ outputBase: "custom/path" });
|
|
65
|
+
config_1.Config.reset();
|
|
66
|
+
const second = config_1.Config.load({});
|
|
67
|
+
expect(first.outputBase).toBe("custom/path");
|
|
68
|
+
expect(second.outputBase).toBe("src/types/http");
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe("DEFAULTS", () => {
|
|
72
|
+
it("exposes the package-level default values", () => {
|
|
73
|
+
expect(config_1.Config.DEFAULTS.tsconfig).toBe("tsconfig.json");
|
|
74
|
+
expect(config_1.Config.DEFAULTS.publicPrefixes).toEqual(["Admin", "Store"]);
|
|
75
|
+
});
|
|
76
|
+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AAC,QAAQ,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;YACtD,MAAM,CAAC,eAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;QACpE,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-tracker.spec.d.ts","sourceRoot":"","sources":["../../src/__tests__/import-tracker.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const import_tracker_1 = require("../core/import-tracker");
|
|
4
|
+
describe("ImportTracker", () => {
|
|
5
|
+
it("initializes with all flags set to false", () => {
|
|
6
|
+
const tracker = new import_tracker_1.ImportTracker();
|
|
7
|
+
expect(tracker.needsFindParams).toBe(false);
|
|
8
|
+
expect(tracker.needsSelectParams).toBe(false);
|
|
9
|
+
expect(tracker.needsBaseFilterable).toBe(false);
|
|
10
|
+
expect(tracker.needsOperatorMap).toBe(false);
|
|
11
|
+
});
|
|
12
|
+
it("allows mutation of individual flags", () => {
|
|
13
|
+
const tracker = new import_tracker_1.ImportTracker();
|
|
14
|
+
tracker.needsFindParams = true;
|
|
15
|
+
expect(tracker.needsFindParams).toBe(true);
|
|
16
|
+
expect(tracker.needsSelectParams).toBe(false);
|
|
17
|
+
});
|
|
18
|
+
it("each instance is independent", () => {
|
|
19
|
+
const t1 = new import_tracker_1.ImportTracker();
|
|
20
|
+
const t2 = new import_tracker_1.ImportTracker();
|
|
21
|
+
t1.needsOperatorMap = true;
|
|
22
|
+
expect(t2.needsOperatorMap).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=import-tracker.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"name-classifier.spec.d.ts","sourceRoot":"","sources":["../../src/__tests__/name-classifier.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const name_classifier_1 = require("../mapping/name-classifier");
|
|
4
|
+
describe("NameClassifier.classify", () => {
|
|
5
|
+
describe("skip cases", () => {
|
|
6
|
+
it("skips names without Admin or Store prefix", () => {
|
|
7
|
+
expect(name_classifier_1.NameClassifier.classify("CreateProduct")).toBe("skip");
|
|
8
|
+
expect(name_classifier_1.NameClassifier.classify("GetOrdersParams")).toBe("skip");
|
|
9
|
+
expect(name_classifier_1.NameClassifier.classify("someHelper")).toBe("skip");
|
|
10
|
+
});
|
|
11
|
+
it("skips intermediate helper schemas ending with ParamsFields", () => {
|
|
12
|
+
expect(name_classifier_1.NameClassifier.classify("AdminGetProductsParamsFields")).toBe("skip");
|
|
13
|
+
expect(name_classifier_1.NameClassifier.classify("AdminCustomersParamsFields")).toBe("skip");
|
|
14
|
+
expect(name_classifier_1.NameClassifier.classify("StoreGetProductsParamsFields")).toBe("skip");
|
|
15
|
+
});
|
|
16
|
+
it("skips schemas ending with ParamsDirectFields", () => {
|
|
17
|
+
expect(name_classifier_1.NameClassifier.classify("AdminGetProductsParamsDirectFields")).toBe("skip");
|
|
18
|
+
});
|
|
19
|
+
it("skips schemas ending with ParamsBase", () => {
|
|
20
|
+
expect(name_classifier_1.NameClassifier.classify("AdminGetOrdersParamsBase")).toBe("skip");
|
|
21
|
+
});
|
|
22
|
+
it("skips schemas ending with ParamsTransform", () => {
|
|
23
|
+
expect(name_classifier_1.NameClassifier.classify("AdminGetOrdersParamsTransform")).toBe("skip");
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
describe("queries", () => {
|
|
27
|
+
it("classifies *Params as queries", () => {
|
|
28
|
+
expect(name_classifier_1.NameClassifier.classify("AdminGetProductsParams")).toBe("queries");
|
|
29
|
+
expect(name_classifier_1.NameClassifier.classify("AdminCustomerFilters")).toBe("queries");
|
|
30
|
+
expect(name_classifier_1.NameClassifier.classify("StoreGetOrdersParams")).toBe("queries");
|
|
31
|
+
expect(name_classifier_1.NameClassifier.classify("AdminGetOrderParams")).toBe("queries");
|
|
32
|
+
});
|
|
33
|
+
it("classifies *Filters / *Filter as queries", () => {
|
|
34
|
+
expect(name_classifier_1.NameClassifier.classify("AdminOrderFilters")).toBe("queries");
|
|
35
|
+
expect(name_classifier_1.NameClassifier.classify("StoreRegionFilters")).toBe("queries");
|
|
36
|
+
expect(name_classifier_1.NameClassifier.classify("AdminPaymentFilter")).toBe("queries");
|
|
37
|
+
});
|
|
38
|
+
it("classifies *ListParams as queries", () => {
|
|
39
|
+
expect(name_classifier_1.NameClassifier.classify("AdminProductListParams")).toBe("queries");
|
|
40
|
+
expect(name_classifier_1.NameClassifier.classify("StoreCollectionListParams")).toBe("queries");
|
|
41
|
+
});
|
|
42
|
+
it("classifies *FilterFields as queries", () => {
|
|
43
|
+
expect(name_classifier_1.NameClassifier.classify("AdminOrderFilterFields")).toBe("queries");
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe("payloads", () => {
|
|
47
|
+
it("classifies Create* as payloads", () => {
|
|
48
|
+
expect(name_classifier_1.NameClassifier.classify("AdminCreateProduct")).toBe("payloads");
|
|
49
|
+
expect(name_classifier_1.NameClassifier.classify("StoreCreateCart")).toBe("payloads");
|
|
50
|
+
});
|
|
51
|
+
it("classifies Update* as payloads", () => {
|
|
52
|
+
expect(name_classifier_1.NameClassifier.classify("AdminUpdateOrder")).toBe("payloads");
|
|
53
|
+
expect(name_classifier_1.NameClassifier.classify("StoreUpdateCart")).toBe("payloads");
|
|
54
|
+
});
|
|
55
|
+
it("classifies Batch* as payloads", () => {
|
|
56
|
+
expect(name_classifier_1.NameClassifier.classify("AdminBatchUpdateProducts")).toBe("payloads");
|
|
57
|
+
});
|
|
58
|
+
it("classifies Import* as payloads", () => {
|
|
59
|
+
expect(name_classifier_1.NameClassifier.classify("AdminImportProducts")).toBe("payloads");
|
|
60
|
+
});
|
|
61
|
+
it("classifies Export* as payloads", () => {
|
|
62
|
+
expect(name_classifier_1.NameClassifier.classify("AdminExportProducts")).toBe("payloads");
|
|
63
|
+
});
|
|
64
|
+
it("classifies *Request as payloads", () => {
|
|
65
|
+
expect(name_classifier_1.NameClassifier.classify("AdminBatchProductRequest")).toBe("payloads");
|
|
66
|
+
});
|
|
67
|
+
it("classifies *Payload as payloads", () => {
|
|
68
|
+
expect(name_classifier_1.NameClassifier.classify("AdminOrderPayload")).toBe("payloads");
|
|
69
|
+
});
|
|
70
|
+
it("classifies unrecognized Admin/Store names as payloads by default", () => {
|
|
71
|
+
expect(name_classifier_1.NameClassifier.classify("AdminTransferOrder")).toBe("payloads");
|
|
72
|
+
expect(name_classifier_1.NameClassifier.classify("AdminInviteAccept")).toBe("payloads");
|
|
73
|
+
expect(name_classifier_1.NameClassifier.classify("StoreCompleteCart")).toBe("payloads");
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=name-classifier.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"name-classifier.spec.js","sourceRoot":"","sources":["../../src/__tests__/name-classifier.spec.ts"],"names":[],"mappings":";;AAAA,gEAA2D;AAE3D,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;YACnD,MAAM,CAAC,gCAAc,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAC7D,MAAM,CAAC,gCAAc,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CA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