dtsgenerator 3.19.2 → 4.0.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/.husky/pre-commit +0 -3
- package/.nycrc +1 -1
- package/README.md +2 -1
- package/dist/commandOptions.js +4 -3
- package/dist/core/astBuilder.js +24 -25
- package/dist/core/config.js +3 -4
- package/dist/core/index.js +1 -1
- package/dist/core/jsonSchema.js +6 -7
- package/dist/core/schemaId.d.ts +0 -1
- package/dist/core/type.js +7 -8
- package/dist/core/typeTree.js +1 -2
- package/dist/core/utils.js +4 -5
- package/dist/core/validateIdentifier.js +3 -4
- package/dist/jsonPointer.js +4 -5
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +16 -18
- package/docs/dependency-modernization.md +189 -0
- package/docs/npm-trusted-publishing.md +60 -0
- package/eslint.config.cjs +24 -0
- package/package.json +29 -28
- package/src/commandOptions.ts +2 -1
- package/src/core/dtsGenerator.ts +0 -2
- package/src/core/jsonSchema.ts +3 -4
- package/src/core/jsonSchemaDraft04.ts +2 -4
- package/src/core/jsonSchemaDraft07.ts +1 -2
- package/src/core/openApiV2.ts +11 -12
- package/src/core/openApiV3.ts +3 -8
- package/src/core/type.ts +3 -7
- package/src/core/utils.ts +1 -0
- package/src/utils.ts +11 -11
- package/tsconfig.json +1 -1
- package/.eslintignore +0 -1
- package/.eslintrc.json +0 -30
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Dependency modernization
|
|
2
|
+
|
|
3
|
+
## Scope and responsibilities
|
|
4
|
+
|
|
5
|
+
Update `horiuchi/dtsgenerator` and the six repositories under the `dtsgenerator`
|
|
6
|
+
organization: `eslint-config`, `do-nothing`, `replace-namespace`, `single-quote`,
|
|
7
|
+
`decorate-typename`, and `create`, including the latter's generated templates.
|
|
8
|
+
|
|
9
|
+
Astra specifies the changes, coordinates implementation, reviews the resulting
|
|
10
|
+
diffs, and verifies integration. Sol and Luna implement the changes.
|
|
11
|
+
|
|
12
|
+
## Compatibility requirements
|
|
13
|
+
|
|
14
|
+
- Support Node.js 22 and 24. The common engine range is
|
|
15
|
+
`^22.22.2 || >=24.15.0`, accommodating the latest package-name validator and
|
|
16
|
+
development tools. CI tests both supported LTS lines.
|
|
17
|
+
- Preserve generated declarations byte for byte, including whitespace, comments,
|
|
18
|
+
ordering, quoting, and namespace transformations. Existing snapshots must not
|
|
19
|
+
be regenerated to hide dependency-induced differences.
|
|
20
|
+
- Preserve CLI options, stdin/file/URL inputs, help output, exit behavior,
|
|
21
|
+
configuration precedence, and public CommonJS entry points.
|
|
22
|
+
- Preserve plugin pre/post-processing contracts and the public `ts` re-export.
|
|
23
|
+
- Retain centralized lint rules in `@dtsgenerator/eslint-config`; consumer files
|
|
24
|
+
contain only project-specific configuration and exceptions.
|
|
25
|
+
- Preserve existing unrelated working-tree changes.
|
|
26
|
+
|
|
27
|
+
## Dependency selection
|
|
28
|
+
|
|
29
|
+
Use current stable versions compatible with the above contracts, updating the
|
|
30
|
+
lockfiles as well as manifest ranges. Registry metadata was checked on
|
|
31
|
+
2026-09-08. Do not use `--force` or `--legacy-peer-deps` to bypass incompatibility.
|
|
32
|
+
|
|
33
|
+
TypeScript 7.0.2 is the current latest release, but does not provide the Compiler
|
|
34
|
+
API required by this library and its plugins. Use the current JavaScript API
|
|
35
|
+
release, `typescript@^6.0.3`, consistently across the ecosystem. The published
|
|
36
|
+
`@typescript/typescript6` compatibility wrapper is unnecessary while the regular
|
|
37
|
+
6.x package remains available. Keep `@types/node` on the latest 22.x release to
|
|
38
|
+
avoid accidentally relying on APIs missing from the lower supported runtime.
|
|
39
|
+
|
|
40
|
+
Keep the runtime YAML parser on `js-yaml@^4.3.2`, the current compatible 4.x
|
|
41
|
+
release. Version 5.4.1 changes the default schema: merge keys stop expanding and
|
|
42
|
+
timestamps stop becoming Dates (and therefore ISO strings after the existing
|
|
43
|
+
deep-copy step). Its YAML 1.1 schema is not a drop-in replacement either: scalar
|
|
44
|
+
syntax, sets, and complex mapping keys differ. Reimplementing the old parser's
|
|
45
|
+
semantics would exceed this behavior-preserving update. Regression tests cover
|
|
46
|
+
the observed merge and timestamp cases. A 5.x parser used internally by updated
|
|
47
|
+
development tools does not change this library's runtime parser selection.
|
|
48
|
+
|
|
49
|
+
The shared ESLint package migrates to a CommonJS-exported flat-config array.
|
|
50
|
+
Consumers spread that array and append their overrides. Parser project discovery
|
|
51
|
+
must work from each consumer's tsconfig. Retired rules are replaced by equivalent
|
|
52
|
+
rules or explicit compatibility settings; dependency updates must not cause
|
|
53
|
+
unrelated semantic refactors. New `lint`/format checks are separated from commands
|
|
54
|
+
that intentionally fix files, so verification cannot rewrite source code.
|
|
55
|
+
|
|
56
|
+
## Implementation sequence
|
|
57
|
+
|
|
58
|
+
1. Capture the existing build/test results in isolated copies. Distinguish
|
|
59
|
+
installation or external-service failures from update regressions.
|
|
60
|
+
2. Modernize and test the shared ESLint package using actual TypeScript fixtures.
|
|
61
|
+
3. Update the main package and four plugins, including CI, release workflows,
|
|
62
|
+
Husky invocation, compiler configuration, and necessary compatibility edits.
|
|
63
|
+
4. Update `create` and its templates; generate a fresh project and verify the
|
|
64
|
+
generated package, lint, build, tests, and hooks.
|
|
65
|
+
5. Test both published dependency contracts and the locally packed updated
|
|
66
|
+
packages together before reflecting reviewed changes into the source repos.
|
|
67
|
+
|
|
68
|
+
## Acceptance checks
|
|
69
|
+
|
|
70
|
+
- Clean installation from the intended dependency graph; no invalid peers.
|
|
71
|
+
- Build/type checks, lint checks, and existing test/coverage commands on Node.js
|
|
72
|
+
22 and 24, with exact pass/fail/skip counts recorded.
|
|
73
|
+
- Existing generated-output snapshots remain unchanged.
|
|
74
|
+
- Focused tests for actual dependency migration risks, particularly CLI parsing,
|
|
75
|
+
YAML semantics, file matching, URL handling, and plugin transformations.
|
|
76
|
+
- Pack/install smoke tests load the CommonJS API and execute the CLI.
|
|
77
|
+
- All four updated plugins run against the updated main package, not merely the
|
|
78
|
+
previously published package accidentally resolved from npm.
|
|
79
|
+
- A freshly generated plugin can install, lint, build, and test.
|
|
80
|
+
- CI uses the lockfile reproducibly via `npm ci`, with no subsequent unpinned
|
|
81
|
+
global npm update or redundant `npm install`.
|
|
82
|
+
|
|
83
|
+
## Release boundary
|
|
84
|
+
|
|
85
|
+
No tags are pushed as part of this change. `eslint-config` targeted 1.0.0
|
|
86
|
+
because its configuration interface changes. `do-nothing` originally targeted
|
|
87
|
+
3.0.0: its published 2.6.0 package requires exactly
|
|
88
|
+
`dtsgenerator@3.19.0`, while the local repository already declares 3.19.2. The
|
|
89
|
+
published peer constraint conflicts with the other test plugins and prevents a
|
|
90
|
+
clean baseline installation. The corrected contract was published as 3.0.1
|
|
91
|
+
rather than overriding an incompatible peer or reusing published metadata.
|
|
92
|
+
Other package version fields remain unchanged pending a coordinated release;
|
|
93
|
+
dropping old Node.js support must be called out when selecting release versions.
|
|
94
|
+
|
|
95
|
+
Consumers' normal dependency ranges target the new shared configuration release.
|
|
96
|
+
Before that release is published, integration checks must install its locally
|
|
97
|
+
packed artifact in a temporary validation environment. Do not commit temporary
|
|
98
|
+
absolute paths, localhost registry addresses, or pretend that an unpublished
|
|
99
|
+
artifact was downloaded from the public registry. The main package also needs the
|
|
100
|
+
new `do-nothing` artifact. The release notes must identify
|
|
101
|
+
any installation prerequisite and the exact validation method used.
|
|
102
|
+
|
|
103
|
+
After publishing each prerequisite package, refresh every consumer lockfile entry
|
|
104
|
+
for that exact package from the artifact actually served by the public registry.
|
|
105
|
+
Confirm that its version, dependency and peer metadata match the package being
|
|
106
|
+
released, and that its `resolved` URL and `integrity` match the downloaded artifact
|
|
107
|
+
and published `dist` metadata. Then run `npm ci` from a fresh cache in an isolated
|
|
108
|
+
copy. A locally packed artifact
|
|
109
|
+
may be used for pre-release integration testing, but its integrity must not be
|
|
110
|
+
copied into a registry URL entry, and preloading it into an npm cache does not
|
|
111
|
+
count as a public-registry installation check. As of 2026-09-18,
|
|
112
|
+
`@dtsgenerator/eslint-config@1.0.0` and `@dtsgenerator/do-nothing@3.0.1` are
|
|
113
|
+
published, and the consumer lockfiles have been refreshed from the public
|
|
114
|
+
registry artifacts. The main lockfile entry for `do-nothing` records the
|
|
115
|
+
published tarball URL and integrity.
|
|
116
|
+
|
|
117
|
+
The main repository's test-plugin peers also cause npm to install the published
|
|
118
|
+
`dtsgenerator@3.19.2` as a development dependency, with its older transitive
|
|
119
|
+
dependencies (including TypeScript 5). This is distinct from the updated main
|
|
120
|
+
package's runtime graph. Standard repository tests therefore do not alone prove
|
|
121
|
+
that plugins use the updated main package or its TypeScript instance. A separate
|
|
122
|
+
consumer installs the locally packed updated main and all four updated plugins,
|
|
123
|
+
then runs their actual snapshot suites against that single installed main.
|
|
124
|
+
Future coordinated version bumps must update these peer/development ranges
|
|
125
|
+
together; do not remove this distinction by masking peer conflicts.
|
|
126
|
+
|
|
127
|
+
## Baseline evidence
|
|
128
|
+
|
|
129
|
+
The untouched working-tree source was built with the existing installed
|
|
130
|
+
dependencies in an isolated directory. Node.js 22.23.2 and 24.20.0 each produced
|
|
131
|
+
186 passing tests and one failing test. All 26 declaration-generation snapshots
|
|
132
|
+
passed. The failing assertion hard-codes older plugin version strings in the
|
|
133
|
+
configuration information output; it must be updated to verify the same format
|
|
134
|
+
using the installed package metadata.
|
|
135
|
+
|
|
136
|
+
Two setup limitations were isolated: the original lockfile cannot be cleanly
|
|
137
|
+
installed due to the published `do-nothing` peer conflict described above, and
|
|
138
|
+
plugins need the built main package resolvable from their module search path.
|
|
139
|
+
Baseline verification used the existing dependencies and an isolated `NODE_PATH`
|
|
140
|
+
mapping to the built baseline package. Network access was enabled for the existing
|
|
141
|
+
external JSON Schema references. These results do not claim a successful baseline
|
|
142
|
+
`npm ci`.
|
|
143
|
+
|
|
144
|
+
## Verification results
|
|
145
|
+
|
|
146
|
+
Verified with Node.js 22.23.2 and 24.20.0:
|
|
147
|
+
|
|
148
|
+
| Package / scenario | Result on each runtime |
|
|
149
|
+
| --- | --- |
|
|
150
|
+
| Main package | Build, lint, format, 189 tests, coverage report pass; 93.21% line coverage |
|
|
151
|
+
| Shared ESLint config | Configuration inspection and real TypeScript fixtures pass |
|
|
152
|
+
| `do-nothing` | Build, lint, format, 4 tests and coverage pass |
|
|
153
|
+
| `replace-namespace` | Build, lint, format, 3 tests and coverage pass |
|
|
154
|
+
| `single-quote` | Build, lint, format, 1 test and coverage pass |
|
|
155
|
+
| `decorate-typename` | Build, lint, format, 2 tests and coverage pass |
|
|
156
|
+
| `create` CLI | 7 tests pass, including help, argument errors, naming and existing directories |
|
|
157
|
+
| Freshly generated plugin | Install, format, lint, build and 4 tests pass; 100% coverage |
|
|
158
|
+
|
|
159
|
+
All 40 pre-existing expected fixture files across the seven repositories are
|
|
160
|
+
byte-identical. All 19 public declaration files emitted by the main package are
|
|
161
|
+
also byte-identical to the baseline. Additional comparisons confirmed identical
|
|
162
|
+
declarations and AST JSON for object, array and union schemas, and identical YAML
|
|
163
|
+
parsing for merge keys, timestamps, scalar values, sets and complex keys.
|
|
164
|
+
|
|
165
|
+
The generated project's actual Git configuration points `core.hooksPath` to
|
|
166
|
+
`.husky/_`. Test-only npm wrappers supply local package artifacts during generated
|
|
167
|
+
project integration; the production CLI has no new environment-variable switches
|
|
168
|
+
for skipping installation or overriding its dependency specifications.
|
|
169
|
+
|
|
170
|
+
Before the prerequisite releases, integration was checked using ordinary manifest
|
|
171
|
+
ranges and registry URLs in the lockfiles, with the exact unpublished artifacts
|
|
172
|
+
first added to an isolated npm cache. `npm ls --all` checked the resulting
|
|
173
|
+
dependency graph. This was a pre-release graph check, not a successful
|
|
174
|
+
public-registry-only installation. For the main package, npm regenerated the final
|
|
175
|
+
lockfile after changing local artifact specs back to normal ranges, ensuring the
|
|
176
|
+
published main package required by test-plugin peers and its transitive
|
|
177
|
+
dependencies are recorded as well.
|
|
178
|
+
|
|
179
|
+
These checks did not mean that a fresh public-registry-only install was possible
|
|
180
|
+
before the prerequisite packages were published. After each publication, the
|
|
181
|
+
consumer lockfiles and fresh-cache `npm ci` result must be verified again against
|
|
182
|
+
the public registry. GitHub Actions workflows were updated but had not been
|
|
183
|
+
executed on GitHub as part of the original local verification.
|
|
184
|
+
|
|
185
|
+
Sources: [TypeScript 7 announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/),
|
|
186
|
+
[ESLint 10 migration](https://eslint.org/docs/latest/use/migrate-to-10.0.0),
|
|
187
|
+
[js-yaml 5 migration](https://github.com/nodeca/js-yaml/blob/master/docs/migrate_v4_to_v5.md),
|
|
188
|
+
[Node.js releases](https://nodejs.org/en/about/previous-releases), and the npm
|
|
189
|
+
registry metadata for each selected version.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# npm trusted publishing への移行
|
|
2
|
+
|
|
3
|
+
リリースworkflowは、npmの長期トークンを使う方式からGitHub ActionsのOIDCを使うtrusted publishingへ移行する。GitHub Actions側に`NPM_TOKEN`などの新しいsecretを追加する必要はない。Node.js 24系に同梱されるnpm 11.5.1以降を使用し、`id-token: write`権限でnpmへ短時間だけ有効な認証情報を要求する。
|
|
4
|
+
|
|
5
|
+
## npmでの設定
|
|
6
|
+
|
|
7
|
+
各パッケージのnpmページで `Settings` → `Trusted Publisher` を開き、publisherとして `GitHub Actions` を選択する。次の値を登録する。
|
|
8
|
+
|
|
9
|
+
| npmパッケージ | GitHub owner/repository | Workflow filename | Environment |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| `@dtsgenerator/eslint-config` | `dtsgenerator/eslint-config` | `release.yml` | 空欄 |
|
|
12
|
+
| `@dtsgenerator/do-nothing` | `dtsgenerator/do-nothing` | `workflow-release.yaml` | 空欄 |
|
|
13
|
+
| `@dtsgenerator/replace-namespace` | `dtsgenerator/replace-namespace` | `workflow-release.yaml` | 空欄 |
|
|
14
|
+
| `@dtsgenerator/single-quote` | `dtsgenerator/single-quote` | `workflow-release.yaml` | 空欄 |
|
|
15
|
+
| `@dtsgenerator/decorate-typename` | `dtsgenerator/decorate-typename` | `workflow-release.yaml` | 空欄 |
|
|
16
|
+
| `dtsgenerator` | `horiuchi/dtsgenerator` | `workflow-release.yaml` | 空欄 |
|
|
17
|
+
| `@dtsgenerator/create` | `dtsgenerator/create` | なし(手動リリース) | 対象外 |
|
|
18
|
+
|
|
19
|
+
`create`が生成したプラグインでは、生成先の実際のGitHub owner/repositoryと`workflow-release.yaml`を登録し、Environmentは空欄にする。trusted publisherを登録できるのはnpmレジストリにすでに存在するパッケージだけなので、新規パッケージは最初にnpmへログインし、buildとtestを確認してから`npm publish --ignore-scripts`で一度だけ手動公開する。
|
|
20
|
+
|
|
21
|
+
npmのtrusted publisher設定にある `Allow direct npm publish` を明示的に有効にする。新規設定ではstage publishが既定のため、この設定が無効なままでは現在のworkflowにある`npm publish`を実行できない。
|
|
22
|
+
|
|
23
|
+
## 公開順序
|
|
24
|
+
|
|
25
|
+
1. `@dtsgenerator/eslint-config`
|
|
26
|
+
2. `@dtsgenerator/do-nothing`
|
|
27
|
+
3. `@dtsgenerator/replace-namespace`、`@dtsgenerator/single-quote`、`@dtsgenerator/decorate-typename`、`dtsgenerator`
|
|
28
|
+
4. `@dtsgenerator/create`(必要な場合は手動公開)
|
|
29
|
+
|
|
30
|
+
`@dtsgenerator/eslint-config@1.0.0`と`@dtsgenerator/do-nothing@3.0.1`は
|
|
31
|
+
2026-09-18時点で公開済みであり、両方のconsumer lockfileを公開registryの
|
|
32
|
+
artifactから更新済みである。`dtsgenerator`を公開する前提パッケージの公開と
|
|
33
|
+
lockfile更新は完了している。
|
|
34
|
+
|
|
35
|
+
## 公開後のlockfile更新
|
|
36
|
+
|
|
37
|
+
前提パッケージを公開するたびに、そのパッケージを参照するすべての
|
|
38
|
+
`package-lock.json`を公開registryの実体に合わせて更新する。registryの
|
|
39
|
+
version、dependencies、peerDependenciesが公開対象と一致することを確認する。
|
|
40
|
+
さらに`dist.tarball`を取得して実体のhashを検証し、lockfileの`resolved`と
|
|
41
|
+
`integrity`がそのartifactおよび`dist` metadataと一致することを確認する。
|
|
42
|
+
その後、作業ツリーとは別のコピーと空のnpm cacheを使って`npm ci`を実行する。
|
|
43
|
+
|
|
44
|
+
公開前の結合確認にローカルでpackしたartifactを使用しても、そのintegrityを
|
|
45
|
+
registry URLのlock entryへ転記しない。ローカルartifactをcacheへ事前投入した
|
|
46
|
+
検証は、公開registryだけを使ったinstall確認として扱わない。main lockfileの
|
|
47
|
+
`@dtsgenerator/do-nothing` entryは、公開された3.0.1のtarball URLとintegrityに
|
|
48
|
+
更新済みである。
|
|
49
|
+
|
|
50
|
+
## workflowを実行する前の注意
|
|
51
|
+
|
|
52
|
+
変更したworkflowを含むコミットを先にGitHubへpushする。失敗した古いrunを再実行しても、そのrunが参照していた古いYAMLが使われるためOIDCへの移行確認にはならない。タグで起動するworkflowでは、タグが移行済みコミットを指していることを確認してからpushする。
|
|
53
|
+
|
|
54
|
+
ローカルで確認できるのはYAMLの構文と設定内容までである。npm UIでtrusted publisherを登録した後、GitHub Actionsから実際に公開し、OIDC認証が成功することを確認する。
|
|
55
|
+
|
|
56
|
+
参考資料:
|
|
57
|
+
|
|
58
|
+
- [npm trusted publishing](https://docs.npmjs.com/trusted-publishers/)
|
|
59
|
+
- [npm trust](https://docs.npmjs.com/cli/v11/commands/npm-trust/)
|
|
60
|
+
- [actions/setup-node advanced usage](https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const shared = require('@dtsgenerator/eslint-config');
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
...shared,
|
|
5
|
+
{ ignores: ['test/snapshots/**'] },
|
|
6
|
+
{ rules: { '@typescript-eslint/no-explicit-any': 'off' } },
|
|
7
|
+
{
|
|
8
|
+
files: ['**/*_test.ts'],
|
|
9
|
+
rules: {
|
|
10
|
+
'@typescript-eslint/ban-ts-comment': 'off',
|
|
11
|
+
'@typescript-eslint/no-empty-object-type': 'off',
|
|
12
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
13
|
+
'@typescript-eslint/no-floating-promises': 'off',
|
|
14
|
+
'@typescript-eslint/no-implied-eval': 'off',
|
|
15
|
+
'@typescript-eslint/no-misused-promises': 'off',
|
|
16
|
+
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
17
|
+
'@typescript-eslint/no-unsafe-call': 'off',
|
|
18
|
+
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
19
|
+
'@typescript-eslint/no-unsafe-return': 'off',
|
|
20
|
+
'@typescript-eslint/no-require-imports': 'off',
|
|
21
|
+
'@typescript-eslint/unbound-method': 'off',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtsgenerator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "TypeScript d.ts file generator for JSON Schema file",
|
|
5
5
|
"bin": {
|
|
6
6
|
"dtsgen": "bin/dtsgen"
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
"build": "tsc -p ./tsconfig-build.json",
|
|
12
12
|
"clean": "rimraf dist/ build/ {src,test}/**/*.{js,js.map} *.tsbuildinfo",
|
|
13
13
|
"compile": "tsc -p .",
|
|
14
|
-
"lint": "eslint --
|
|
15
|
-
"
|
|
14
|
+
"lint": "eslint --report-unused-disable-directives src/ test/",
|
|
15
|
+
"lint:fix": "npm run lint -- --fix",
|
|
16
|
+
"format": "prettier --check 'src/**/*.ts' 'test/*.ts' 'test/core/*.ts'",
|
|
17
|
+
"format:fix": "prettier --cache --write 'src/**/*.ts' 'test/*.ts' 'test/core/*.ts'",
|
|
16
18
|
"precompile": "npm run lint && npm run format",
|
|
17
19
|
"prepublishOnly": "npm run build",
|
|
18
20
|
"pretest": "npm run compile",
|
|
@@ -20,7 +22,7 @@
|
|
|
20
22
|
"test": "nyc npm run do-test",
|
|
21
23
|
"test:update-snapshot": "UPDATE_SNAPSHOT=1 npm run test",
|
|
22
24
|
"coverage": "nyc report --reporter=lcov",
|
|
23
|
-
"prepare": "husky
|
|
25
|
+
"prepare": "husky"
|
|
24
26
|
},
|
|
25
27
|
"directories": {
|
|
26
28
|
"test": "test/"
|
|
@@ -41,38 +43,37 @@
|
|
|
41
43
|
"url": "https://github.com/horiuchi/dtsgenerator/issues"
|
|
42
44
|
},
|
|
43
45
|
"engines": {
|
|
44
|
-
"node": ">=
|
|
46
|
+
"node": "^22.22.2 || >=24.15.0"
|
|
45
47
|
},
|
|
46
48
|
"dependencies": {
|
|
47
|
-
"commander": "^
|
|
48
|
-
"cross-fetch": "^4.
|
|
49
|
-
"debug": "^4.3
|
|
50
|
-
"glob": "^
|
|
51
|
-
"http-proxy-agent": "^
|
|
52
|
-
"https-proxy-agent": "^
|
|
53
|
-
"js-yaml": "^4.
|
|
54
|
-
"tslib": "^2.
|
|
55
|
-
"typescript": "^
|
|
49
|
+
"commander": "^15.0.0",
|
|
50
|
+
"cross-fetch": "^4.1.0",
|
|
51
|
+
"debug": "^4.4.3",
|
|
52
|
+
"glob": "^13.0.6",
|
|
53
|
+
"http-proxy-agent": "^9.1.0",
|
|
54
|
+
"https-proxy-agent": "^9.1.0",
|
|
55
|
+
"js-yaml": "^4.3.2",
|
|
56
|
+
"tslib": "^2.8.1",
|
|
57
|
+
"typescript": "^6.0.3"
|
|
56
58
|
},
|
|
57
59
|
"devDependencies": {
|
|
58
|
-
"@dtsgenerator/do-nothing": "^
|
|
59
|
-
"@dtsgenerator/eslint-config": "^0.
|
|
60
|
+
"@dtsgenerator/do-nothing": "^3.0.1",
|
|
61
|
+
"@dtsgenerator/eslint-config": "^1.0.0",
|
|
60
62
|
"@dtsgenerator/replace-namespace": "^1.6.0",
|
|
61
63
|
"@dtsgenerator/single-quote": "^1.7.0",
|
|
62
64
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
63
|
-
"@types/debug": "^4.1.
|
|
64
|
-
"@types/glob": "^8.1.0",
|
|
65
|
+
"@types/debug": "^4.1.13",
|
|
65
66
|
"@types/js-yaml": "^4.0.9",
|
|
66
|
-
"@types/mocha": "^10.0.
|
|
67
|
-
"@types/node": "^
|
|
68
|
-
"cross-env": "^
|
|
69
|
-
"eslint": "^
|
|
70
|
-
"husky": "^9.
|
|
71
|
-
"lint-staged": "^
|
|
72
|
-
"mocha": "^
|
|
73
|
-
"nyc": "^
|
|
74
|
-
"prettier": "^3.
|
|
75
|
-
"rimraf": "^
|
|
67
|
+
"@types/mocha": "^10.0.10",
|
|
68
|
+
"@types/node": "^22.20.1",
|
|
69
|
+
"cross-env": "^10.1.0",
|
|
70
|
+
"eslint": "^10.10.0",
|
|
71
|
+
"husky": "^9.1.7",
|
|
72
|
+
"lint-staged": "^17.5.0",
|
|
73
|
+
"mocha": "^12.0.0",
|
|
74
|
+
"nyc": "^18.0.0",
|
|
75
|
+
"prettier": "^3.9.6",
|
|
76
|
+
"rimraf": "^6.1.3",
|
|
76
77
|
"source-map-support": "^0.5.21",
|
|
77
78
|
"ts-node": "^10.9.2"
|
|
78
79
|
},
|
package/src/commandOptions.ts
CHANGED
|
@@ -40,7 +40,7 @@ function parse(options: CommandOptions, argv: string[]): commander.Command {
|
|
|
40
40
|
return memo;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-assignment
|
|
44
44
|
const pkg: { name: string; version: string } = require('../package.json');
|
|
45
45
|
|
|
46
46
|
// <hoge> is required, [hoge] is optional
|
|
@@ -66,6 +66,7 @@ function parse(options: CommandOptions, argv: string[]): commander.Command {
|
|
|
66
66
|
'for developer mode. output loaded config and plugin details only.',
|
|
67
67
|
)
|
|
68
68
|
.option('--output-ast', 'output TypeScript AST instead of d.ts file.')
|
|
69
|
+
.allowExcessArguments(true)
|
|
69
70
|
.addHelpText(
|
|
70
71
|
'afterAll',
|
|
71
72
|
`
|
package/src/core/dtsGenerator.ts
CHANGED
|
@@ -263,12 +263,10 @@ export default class DtsGenerator {
|
|
|
263
263
|
): ts.DeclarationStatement {
|
|
264
264
|
const content = schema.content;
|
|
265
265
|
if (
|
|
266
|
-
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
|
|
267
266
|
content.$ref ||
|
|
268
267
|
content.oneOf ||
|
|
269
268
|
content.anyOf ||
|
|
270
269
|
content.enum ||
|
|
271
|
-
/* eslint-enable @typescript-eslint/prefer-nullish-coalescing */
|
|
272
270
|
'const' in content ||
|
|
273
271
|
content.type !== 'object'
|
|
274
272
|
) {
|
package/src/core/jsonSchema.ts
CHANGED
|
@@ -322,8 +322,7 @@ export function searchAllSubSchema(
|
|
|
322
322
|
) => setSubIdToAnyObject(setSubIdToResponseV2, responses, keys);
|
|
323
323
|
function setSubIdToResponseV2(
|
|
324
324
|
response:
|
|
325
|
-
|
|
326
|
-
| undefined,
|
|
325
|
+
OpenApisV2.SchemaJson.Definitions.ResponseValue | undefined,
|
|
327
326
|
keys: string[],
|
|
328
327
|
): void {
|
|
329
328
|
if (response == null) {
|
|
@@ -331,10 +330,10 @@ export function searchAllSubSchema(
|
|
|
331
330
|
}
|
|
332
331
|
if ('schema' in response) {
|
|
333
332
|
const s = response.schema;
|
|
334
|
-
if (s
|
|
333
|
+
if (s?.type === 'file') {
|
|
335
334
|
return;
|
|
336
335
|
}
|
|
337
|
-
setSubId(s
|
|
336
|
+
setSubId(s, keys);
|
|
338
337
|
}
|
|
339
338
|
}
|
|
340
339
|
function setSubIdToOperationV2(
|
|
@@ -36,8 +36,7 @@ export namespace JsonSchemaDraft04 {
|
|
|
36
36
|
dependencies?: Record<string, Schema | Schema.Definitions.StringArray>;
|
|
37
37
|
enum?: any[];
|
|
38
38
|
type?:
|
|
39
|
-
| Schema.Definitions.SimpleTypes
|
|
40
|
-
| Schema.Definitions.SimpleTypes[];
|
|
39
|
+
Schema.Definitions.SimpleTypes | Schema.Definitions.SimpleTypes[];
|
|
41
40
|
format?: string;
|
|
42
41
|
allOf?: Schema.Definitions.SchemaArray;
|
|
43
42
|
anyOf?: Schema.Definitions.SchemaArray;
|
|
@@ -80,8 +79,7 @@ export namespace JsonSchemaDraft04 {
|
|
|
80
79
|
export type Required = Definitions.StringArray;
|
|
81
80
|
export type Title = string;
|
|
82
81
|
export type Type =
|
|
83
|
-
| Definitions.SimpleTypes
|
|
84
|
-
| Definitions.SimpleTypes[];
|
|
82
|
+
Definitions.SimpleTypes | Definitions.SimpleTypes[];
|
|
85
83
|
export type UniqueItems = boolean;
|
|
86
84
|
}
|
|
87
85
|
}
|
|
@@ -38,8 +38,7 @@ export namespace JsonSchemaDraft07 {
|
|
|
38
38
|
const?: any;
|
|
39
39
|
enum?: any[];
|
|
40
40
|
type?:
|
|
41
|
-
| Schema.Definitions.SimpleTypes
|
|
42
|
-
| Schema.Definitions.SimpleTypes[];
|
|
41
|
+
Schema.Definitions.SimpleTypes | Schema.Definitions.SimpleTypes[];
|
|
43
42
|
format?: string;
|
|
44
43
|
contentMediaType?: string;
|
|
45
44
|
contentEncoding?: string;
|
package/src/core/openApiV2.ts
CHANGED
|
@@ -70,11 +70,7 @@ export namespace OpenApisV2 {
|
|
|
70
70
|
}
|
|
71
71
|
export type CollectionFormat = 'csv' | 'ssv' | 'tsv' | 'pipes';
|
|
72
72
|
export type CollectionFormatWithMulti =
|
|
73
|
-
| '
|
|
74
|
-
| 'ssv'
|
|
75
|
-
| 'tsv'
|
|
76
|
-
| 'pipes'
|
|
77
|
-
| 'multi';
|
|
73
|
+
'csv' | 'ssv' | 'tsv' | 'pipes' | 'multi';
|
|
78
74
|
/**
|
|
79
75
|
* Contact information for the owners of the API.
|
|
80
76
|
*/
|
|
@@ -403,7 +399,7 @@ export namespace OpenApisV2 {
|
|
|
403
399
|
*/
|
|
404
400
|
export type Paths = Record<string, PathItem>;
|
|
405
401
|
export type Pattern =
|
|
406
|
-
JsonSchemaDraft04.Schema.Properties.Pattern /* regex
|
|
402
|
+
JsonSchemaDraft04.Schema.Properties.Pattern; /* regex */
|
|
407
403
|
export interface PrimitivesItems {
|
|
408
404
|
type?: 'string' | 'number' | 'integer' | 'boolean' | 'array';
|
|
409
405
|
format?: string;
|
|
@@ -464,8 +460,9 @@ export namespace OpenApisV2 {
|
|
|
464
460
|
}
|
|
465
461
|
export interface Response {
|
|
466
462
|
description: string;
|
|
467
|
-
schema?:
|
|
468
|
-
|
|
463
|
+
schema?:
|
|
464
|
+
/* A deterministic version of a JSON Schema object. */
|
|
465
|
+
| Schema
|
|
469
466
|
| /* A deterministic version of a JSON Schema object. */ FileSchema;
|
|
470
467
|
headers?: Headers;
|
|
471
468
|
examples?: Examples;
|
|
@@ -503,11 +500,13 @@ export namespace OpenApisV2 {
|
|
|
503
500
|
minProperties?: JsonSchemaDraft04.Schema.Definitions.PositiveIntegerDefault0;
|
|
504
501
|
required?: JsonSchemaDraft04.Schema.Definitions.StringArray;
|
|
505
502
|
enum?: JsonSchemaDraft04.Schema.Properties.Enum;
|
|
506
|
-
additionalProperties?:
|
|
507
|
-
|
|
503
|
+
additionalProperties?:
|
|
504
|
+
/* A deterministic version of a JSON Schema object. */
|
|
505
|
+
Schema | boolean;
|
|
508
506
|
type?: JsonSchemaDraft04.Schema.Properties.Type;
|
|
509
|
-
items?:
|
|
510
|
-
|
|
507
|
+
items?:
|
|
508
|
+
/* A deterministic version of a JSON Schema object. */
|
|
509
|
+
| Schema
|
|
511
510
|
| [
|
|
512
511
|
/* A deterministic version of a JSON Schema object. */ Schema,
|
|
513
512
|
.../* A deterministic version of a JSON Schema object. */ Schema[],
|
package/src/core/openApiV3.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-empty-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
2
2
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
4
4
|
import { JsonSchemaDraft07 } from './jsonSchemaDraft07';
|
|
@@ -272,8 +272,7 @@ export namespace OpenApisV3 {
|
|
|
272
272
|
ResponseOrReference
|
|
273
273
|
>;
|
|
274
274
|
export type SchemaOrReference =
|
|
275
|
-
|
|
276
|
-
| Reference;
|
|
275
|
+
JsonSchemaDraft07.SchemaObject | Reference;
|
|
277
276
|
export type SchemasOrReferences = Record<string, SchemaOrReference>;
|
|
278
277
|
/**
|
|
279
278
|
* Lists the required security schemes to execute this operation. The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the Components Object. Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized. This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information. When a list of Security Requirement Objects is defined on the Open API object or Operation Object, only one of Security Requirement Objects in the list needs to be satisfied to authorize the request.
|
|
@@ -318,11 +317,7 @@ export namespace OpenApisV3 {
|
|
|
318
317
|
* Any property starting with x- is valid.
|
|
319
318
|
*/
|
|
320
319
|
export type SpecificationExtension =
|
|
321
|
-
|
|
|
322
|
-
| number
|
|
323
|
-
| boolean
|
|
324
|
-
| string
|
|
325
|
-
| any[];
|
|
320
|
+
null | number | boolean | string | any[];
|
|
326
321
|
export type Strings = Record<string, string>;
|
|
327
322
|
/**
|
|
328
323
|
* Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag defined in the Operation Object instances.
|
package/src/core/type.ts
CHANGED
|
@@ -13,20 +13,16 @@ import SchemaId from './schemaId';
|
|
|
13
13
|
|
|
14
14
|
// export `ts` for using the same version of TypeScript in all plugins.
|
|
15
15
|
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
16
17
|
export import ts = require('typescript');
|
|
17
18
|
|
|
18
19
|
// Schema types
|
|
19
20
|
|
|
20
21
|
export type JsonSchema = JsonSchemaDraft04.Schema | JsonSchemaDraft07.Schema;
|
|
21
22
|
export type JsonSchemaObject =
|
|
22
|
-
|
|
|
23
|
-
| JsonSchemaDraft07.SchemaObject;
|
|
23
|
+
JsonSchemaDraft04.Schema | JsonSchemaDraft07.SchemaObject;
|
|
24
24
|
export type SchemaType =
|
|
25
|
-
| '
|
|
26
|
-
| 'Draft07'
|
|
27
|
-
| '2019-09'
|
|
28
|
-
| '2020-12'
|
|
29
|
-
| 'Latest';
|
|
25
|
+
'Draft04' | 'Draft07' | '2019-09' | '2020-12' | 'Latest';
|
|
30
26
|
export function isJsonSchemaDraft04(
|
|
31
27
|
_content: JsonSchemaObject,
|
|
32
28
|
type: SchemaType,
|
package/src/core/utils.ts
CHANGED
|
@@ -80,6 +80,7 @@ export function checkValidMIMEType(mime: string): boolean {
|
|
|
80
80
|
|
|
81
81
|
export function mergeSchema(a: any, b: any): boolean {
|
|
82
82
|
if ('$ref' in a || '$ref' in b) {
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
83
84
|
a.$ref = b.$ref || a.$ref;
|
|
84
85
|
return false;
|
|
85
86
|
}
|
package/src/utils.ts
CHANGED
|
@@ -16,6 +16,8 @@ export function readStream(
|
|
|
16
16
|
let data = '';
|
|
17
17
|
stream.on('data', (chunk) => (data += chunk));
|
|
18
18
|
stream.on('end', () => resolve(data));
|
|
19
|
+
// Preserve the stream's original error object for callers.
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
19
21
|
stream.on('error', (error) => reject(error));
|
|
20
22
|
});
|
|
21
23
|
}
|
|
@@ -88,22 +90,20 @@ export function readConfig(options: CommandOptions): PartialConfig {
|
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
};
|
|
97
|
-
}
|
|
93
|
+
pc.input ??= {
|
|
94
|
+
files: [],
|
|
95
|
+
urls: [],
|
|
96
|
+
stdin: false,
|
|
97
|
+
};
|
|
98
98
|
if (options.files.length > 0) {
|
|
99
99
|
pc.input.files = options.files;
|
|
100
|
-
} else
|
|
101
|
-
pc.input.files
|
|
100
|
+
} else {
|
|
101
|
+
pc.input.files ??= [];
|
|
102
102
|
}
|
|
103
103
|
if (options.urls.length > 0) {
|
|
104
104
|
pc.input.urls = options.urls;
|
|
105
|
-
} else
|
|
106
|
-
pc.input.urls
|
|
105
|
+
} else {
|
|
106
|
+
pc.input.urls ??= [];
|
|
107
107
|
}
|
|
108
108
|
if (options.stdin != null) {
|
|
109
109
|
pc.input.stdin = options.stdin;
|
package/tsconfig.json
CHANGED
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
// "removeComments": true, /* Do not emit comments to output. */
|
|
20
20
|
// "noEmit": true, /* Do not emit outputs. */
|
|
21
21
|
"importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
22
|
-
"downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
23
22
|
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
24
23
|
|
|
25
24
|
/* Strict Type-Checking Options */
|
|
@@ -46,6 +45,7 @@
|
|
|
46
45
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
47
46
|
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
48
47
|
// "types": [], /* Type declaration files to be included in compilation. */
|
|
48
|
+
"types": ["node", "mocha"],
|
|
49
49
|
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
50
50
|
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
51
51
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
package/.eslintignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/test/snapshots
|