@groton/canvas-api.swagger-renderer 0.1.2 → 0.1.4
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/CHANGELOG.md +24 -0
- package/dist/Download.js +24 -9
- package/dist/Render/Operations.js +34 -4
- package/dist/Render/Overrides.js +6 -4
- package/dist/Render/Render.js +14 -14
- package/dist/Render/TypeScript.js +32 -5
- package/dist/Render/index.js +2 -2
- package/dist/Render/writePrettier.js +3 -3
- package/dist/index.js +1 -1
- package/package.json +18 -15
- package/dist/Download.d.ts +0 -13
- package/dist/Render/Annotation.d.ts +0 -46
- package/dist/Render/Models.d.ts +0 -14
- package/dist/Render/Operations.d.ts +0 -16
- package/dist/Render/Overrides.d.ts +0 -16
- package/dist/Render/Render.d.ts +0 -19
- package/dist/Render/TSAnnotation.d.ts +0 -19
- package/dist/Render/TypeScript.d.ts +0 -10
- package/dist/Render/importPath.d.ts +0 -2
- package/dist/Render/index.d.ts +0 -1
- package/dist/Render/writePrettier.d.ts +0 -2
- package/dist/index.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [0.1.4](https://github.com/groton-school/canvas-cli/compare/swagger-renderer/0.1.3...swagger-renderer/0.1.4) (2026-01-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* convert wild card path param to regular path param ([7ba5107](https://github.com/groton-school/canvas-cli/commit/7ba5107cf9f7fb07c4a69977efff3c57a94a4829))
|
|
11
|
+
|
|
12
|
+
## [0.1.3](https://github.com/groton-school/canvas-cli/compare/swagger-renderer/0.1.2...swagger-renderer/0.1.3) (2026-01-05)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* handle types that are represented as an array of possible types ([7de3d69](https://github.com/groton-school/canvas-cli/commit/7de3d6968e65b2f6506ab635d21bfc6718d831b9))
|
|
18
|
+
* look for INSTANCE_URL in environment with 1Password support ([37b2372](https://github.com/groton-school/canvas-cli/commit/37b23724d4ba926d1fd933bb07680e080cec605a))
|
|
19
|
+
* update Node target to active v24 ([5ecece1](https://github.com/groton-school/canvas-cli/commit/5ecece144945861343f008c0d9043ac631b08c34))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* ignore references that have neither a package nor a file path ([25b33b1](https://github.com/groton-school/canvas-cli/commit/25b33b1698b2431334451dd7dfcfdb62a9dd4067))
|
|
25
|
+
* remove unnecessary interdependency between Render and Download ([faae357](https://github.com/groton-school/canvas-cli/commit/faae357c72c97ff882520f79c6346957a691730e))
|
|
26
|
+
* treat (frequently incorrect) `void` return type as returning an unknown JSON value ([dc43fc0](https://github.com/groton-school/canvas-cli/commit/dc43fc029666722aaa5920f23b429d901c4a91cf))
|
|
27
|
+
* treat `unknown` as specifically an unknown _JSON vallue_ ([0ff1575](https://github.com/groton-school/canvas-cli/commit/0ff15755ccfafcbf1f0762de61dfb637204ef7ff))
|
|
28
|
+
|
|
5
29
|
## [0.1.2](https://github.com/groton-school/canvas-cli/compare/swagger-renderer/0.1.1...swagger-renderer/0.1.2) (2025-09-02)
|
|
6
30
|
|
|
7
31
|
|
package/dist/Download.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Colors } from '@
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import { Colors } from '@qui-cli/colors';
|
|
2
|
+
import '@qui-cli/env-1password';
|
|
3
|
+
import { Env } from '@qui-cli/env-1password';
|
|
4
|
+
import { Log } from '@qui-cli/log';
|
|
5
|
+
import * as Plugin from '@qui-cli/plugin';
|
|
6
|
+
import { Root } from '@qui-cli/root';
|
|
5
7
|
import fetch from 'node-fetch';
|
|
6
8
|
import fs from 'node:fs';
|
|
7
9
|
import path from 'node:path';
|
|
@@ -10,7 +12,7 @@ import PQueue from 'p-queue';
|
|
|
10
12
|
Root.configure({ root: process.cwd() });
|
|
11
13
|
export const name = 'download';
|
|
12
14
|
export const src = import.meta.dirname;
|
|
13
|
-
let instanceUrl =
|
|
15
|
+
let instanceUrl = undefined;
|
|
14
16
|
let specPath = './spec';
|
|
15
17
|
export function configure(config = {}) {
|
|
16
18
|
instanceUrl = Plugin.hydrate(config.instanceUrl, instanceUrl);
|
|
@@ -18,22 +20,32 @@ export function configure(config = {}) {
|
|
|
18
20
|
}
|
|
19
21
|
export function options() {
|
|
20
22
|
return {
|
|
23
|
+
man: [{ level: 1, text: 'Download Options' }],
|
|
21
24
|
opt: {
|
|
22
25
|
instanceUrl: {
|
|
23
|
-
description: `URL of the Canvas instance from which to download the
|
|
26
|
+
description: `URL of the Canvas instance from which to download the ` +
|
|
27
|
+
`Swagger API spec, using the environment variable ` +
|
|
28
|
+
`${Colors.varName('INSTANCE_URL')} if present`,
|
|
24
29
|
default: instanceUrl
|
|
25
30
|
},
|
|
26
31
|
specPath: {
|
|
27
|
-
description: `Path to store the downloaded spec files
|
|
32
|
+
description: `Path to store the downloaded spec files`,
|
|
28
33
|
default: specPath
|
|
29
34
|
}
|
|
30
35
|
}
|
|
31
36
|
};
|
|
32
37
|
}
|
|
33
|
-
export function init(
|
|
34
|
-
configure(
|
|
38
|
+
export async function init({ values }) {
|
|
39
|
+
configure({
|
|
40
|
+
instanceUrl: (await Env.get({ key: 'INSTANCE_URL' })) ||
|
|
41
|
+
'https://canvas.instructure.com',
|
|
42
|
+
...values
|
|
43
|
+
});
|
|
35
44
|
}
|
|
36
45
|
export async function run() {
|
|
46
|
+
if (!instanceUrl) {
|
|
47
|
+
throw new Error('An instance URL must be provided.');
|
|
48
|
+
}
|
|
37
49
|
const spinner = ora(`Downloading Swagger API definition`).start();
|
|
38
50
|
const queue = new PQueue({ interval: 1000 });
|
|
39
51
|
instanceUrl = path.join(instanceUrl, 'doc/api');
|
|
@@ -45,6 +57,9 @@ export async function run() {
|
|
|
45
57
|
const result = [];
|
|
46
58
|
do {
|
|
47
59
|
await queue.add(async () => {
|
|
60
|
+
if (!instanceUrl) {
|
|
61
|
+
throw new Error('An instance URL must be provided.');
|
|
62
|
+
}
|
|
48
63
|
const url = new URL(instanceUrl + paths.pop());
|
|
49
64
|
spinner.text = Colors.url(url);
|
|
50
65
|
const response = await fetch(url);
|
|
@@ -25,6 +25,17 @@ export function annotateOperations({ outputPath, ...annotation }) {
|
|
|
25
25
|
const tsImports = [{ ...clientReference }];
|
|
26
26
|
const tsName = toTSMethodName(operation);
|
|
27
27
|
let tsType = toTSType(operation);
|
|
28
|
+
if (tsType.type === 'void') {
|
|
29
|
+
tsType = {
|
|
30
|
+
type: 'JSONValue',
|
|
31
|
+
tsReferences: [
|
|
32
|
+
{
|
|
33
|
+
type: 'JSONValue',
|
|
34
|
+
packagePath: '@battis/typescript-tricks'
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
28
39
|
if (tsType.type === 'unknown' && operation.type) {
|
|
29
40
|
tsType = {
|
|
30
41
|
type: operation.type,
|
|
@@ -49,17 +60,22 @@ export function annotateOperations({ outputPath, ...annotation }) {
|
|
|
49
60
|
packagePath: '@groton/canvas-api.client.base'
|
|
50
61
|
});
|
|
51
62
|
}
|
|
52
|
-
//
|
|
63
|
+
// TODO $ref typing
|
|
64
|
+
// @ts-expect-error 2322
|
|
53
65
|
const annotatedOperation = Overrides.operation({
|
|
54
66
|
...operation,
|
|
55
67
|
specPath,
|
|
56
68
|
tsImports,
|
|
57
69
|
tsType,
|
|
58
|
-
tsEndpoint: decodeURIComponent(new URL(spec.basePath + endpoint.path).pathname),
|
|
70
|
+
tsEndpoint: decodeURIComponent(new URL(spec.basePath + endpoint.path).pathname.replace(/\/\*([^/]+\/?)/, '/{$1}')),
|
|
59
71
|
tsName,
|
|
60
72
|
tsUpload,
|
|
61
73
|
tsPaginated
|
|
62
74
|
});
|
|
75
|
+
const wildcardParam = identifyWildcardParam(endpoint.path);
|
|
76
|
+
if (wildcardParam) {
|
|
77
|
+
annotatedOperation.parameters.push(wildcardParam);
|
|
78
|
+
}
|
|
63
79
|
annotatedOperation.tsFilePath = path.join(outputPath, toOperationPath(endpoint.path, annotatedOperation), annotatedOperation.tsName + '.ts');
|
|
64
80
|
for (const parameter of operation.parameters) {
|
|
65
81
|
const annotatedParameter = {
|
|
@@ -85,7 +101,8 @@ export function annotateOperations({ outputPath, ...annotation }) {
|
|
|
85
101
|
annotatedOperation[paramType] = [];
|
|
86
102
|
}
|
|
87
103
|
if (Array.isArray(annotatedOperation[paramType])) {
|
|
88
|
-
//
|
|
104
|
+
// TODO fix wonky annotation typing
|
|
105
|
+
// @ts-expect-error 2345
|
|
89
106
|
annotatedOperation[paramType].push(annotatedParameter);
|
|
90
107
|
}
|
|
91
108
|
// force path params to accept numbers too
|
|
@@ -137,7 +154,7 @@ function toOperationPath(endpointPath, operation) {
|
|
|
137
154
|
return operation.parameters
|
|
138
155
|
.reduce((tsFilePath, parameter) => {
|
|
139
156
|
if (parameter.paramType === 'path') {
|
|
140
|
-
return tsFilePath.replace(new RegExp(`{${parameter.name}}/?`), '');
|
|
157
|
+
return tsFilePath.replace(new RegExp(`{${parameter.name}}/?|\\*${parameter.name}/?`), '');
|
|
141
158
|
}
|
|
142
159
|
return tsFilePath;
|
|
143
160
|
}, endpointPath)
|
|
@@ -150,6 +167,19 @@ function toOperationPath(endpointPath, operation) {
|
|
|
150
167
|
: undefined)
|
|
151
168
|
.join('/');
|
|
152
169
|
}
|
|
170
|
+
function identifyWildcardParam(endpointPath) {
|
|
171
|
+
const [, name] = endpointPath.match(/\/\*([^/]+)\/?/) || [];
|
|
172
|
+
if (name) {
|
|
173
|
+
return {
|
|
174
|
+
paramType: 'path',
|
|
175
|
+
name,
|
|
176
|
+
description: `Identified by @groton/canvas-api.swagger-renderer from the endpoint path: ${endpointPath}`,
|
|
177
|
+
type: 'string',
|
|
178
|
+
required: true
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
153
183
|
function toTSMethodName(operation) {
|
|
154
184
|
switch (operation.method) {
|
|
155
185
|
case 'GET':
|
package/dist/Render/Overrides.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Colors } from '@
|
|
2
|
-
import { Log } from '@
|
|
1
|
+
import { Colors } from '@qui-cli/colors';
|
|
2
|
+
import { Log } from '@qui-cli/log';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
let _overrides = {};
|
|
5
5
|
let _outputPath = undefined;
|
|
@@ -80,7 +80,8 @@ export function operation(operation) {
|
|
|
80
80
|
'tsBodyParameters'
|
|
81
81
|
]) {
|
|
82
82
|
if (paramType in result) {
|
|
83
|
-
//
|
|
83
|
+
// TODO paramType typing
|
|
84
|
+
// @ts-expect-error 7053
|
|
84
85
|
result[paramType] = result[paramType].reduce((params, param) => {
|
|
85
86
|
const i = params.findIndex((p) => p.tsName === param.tsName);
|
|
86
87
|
if (i >= 0) {
|
|
@@ -117,7 +118,8 @@ function merge(a, b) {
|
|
|
117
118
|
...Object.getOwnPropertyNames(b)
|
|
118
119
|
]))
|
|
119
120
|
]) {
|
|
120
|
-
//
|
|
121
|
+
// TODO setting previously unset property
|
|
122
|
+
// @ts-expect-error 2322
|
|
121
123
|
result[key] = merge(a[key], b[key]);
|
|
122
124
|
}
|
|
123
125
|
return result;
|
package/dist/Render/Render.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { Colors } from '@
|
|
2
|
-
import { Log } from '@
|
|
3
|
-
import * as Plugin from '@
|
|
4
|
-
import { Root } from '@
|
|
1
|
+
import { Colors } from '@qui-cli/colors';
|
|
2
|
+
import { Log } from '@qui-cli/log';
|
|
3
|
+
import * as Plugin from '@qui-cli/plugin';
|
|
4
|
+
import { Root } from '@qui-cli/root';
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import ora from 'ora';
|
|
8
|
-
import * as Download from '../Download.js';
|
|
9
8
|
import * as Models from './Models.js';
|
|
10
9
|
import * as Operations from './Operations.js';
|
|
11
10
|
import * as Overrides from './Overrides.js';
|
|
@@ -32,35 +31,36 @@ export function configure(config = {}) {
|
|
|
32
31
|
}
|
|
33
32
|
export function options() {
|
|
34
33
|
return {
|
|
34
|
+
man: [{ level: 1, text: 'Rendering Options' }],
|
|
35
35
|
flag: {
|
|
36
36
|
map: {
|
|
37
|
-
description: `Output the annotated code map
|
|
37
|
+
description: `Output the annotated code map`,
|
|
38
38
|
default: map
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
opt: {
|
|
42
42
|
specPath: {
|
|
43
|
-
description: `Path to Swagger spec file or directory
|
|
43
|
+
description: `Path to Swagger spec file or directory`,
|
|
44
44
|
default: specPath
|
|
45
45
|
},
|
|
46
46
|
overridePath: {
|
|
47
|
-
description: `Path to TypeScript types override JSON file
|
|
47
|
+
description: `Path to TypeScript types override JSON file`,
|
|
48
48
|
default: overridePath
|
|
49
49
|
},
|
|
50
50
|
templatePath: {
|
|
51
|
-
description: `Path to Handlebars template directory
|
|
51
|
+
description: `Path to Handlebars template directory`,
|
|
52
52
|
default: templatePath
|
|
53
53
|
},
|
|
54
54
|
outputPath: {
|
|
55
|
-
description: `Path to output directory
|
|
55
|
+
description: `Path to output directory`,
|
|
56
56
|
default: outputPath
|
|
57
57
|
},
|
|
58
58
|
modelDirName: {
|
|
59
|
-
description: `Name of resource definitions directory
|
|
59
|
+
description: `Name of resource definitions directory`,
|
|
60
60
|
default: modelDirName
|
|
61
61
|
},
|
|
62
62
|
operationsDirName: {
|
|
63
|
-
description: `Name of endpoint definitions directory
|
|
63
|
+
description: `Name of endpoint definitions directory`,
|
|
64
64
|
default: operationsDirName
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -73,8 +73,8 @@ export async function run(results) {
|
|
|
73
73
|
const spinner = ora(`Looking for specs`).start();
|
|
74
74
|
let specPaths = undefined;
|
|
75
75
|
specPath = path.resolve(Root.path(), specPath);
|
|
76
|
-
if (results && results[
|
|
77
|
-
specPaths = results[
|
|
76
|
+
if (results && results['download']) {
|
|
77
|
+
specPaths = results['download'];
|
|
78
78
|
spinner.text = `Using specs provided by download`;
|
|
79
79
|
}
|
|
80
80
|
else if (fs.lstatSync(specPath).isDirectory()) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Colors } from '@battis/qui-cli.colors';
|
|
2
|
-
import { Log } from '@battis/qui-cli.log';
|
|
3
1
|
import * as Swagger from '@groton/swagger-spec-ts';
|
|
2
|
+
import { Colors } from '@qui-cli/colors';
|
|
3
|
+
import { Log } from '@qui-cli/log';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import * as Overrides from './Overrides.js';
|
|
6
6
|
export function toTSDeprecation(obj) {
|
|
@@ -34,6 +34,22 @@ export function toTSNamespace(filePath) {
|
|
|
34
34
|
}
|
|
35
35
|
return tsNamespace;
|
|
36
36
|
}
|
|
37
|
+
function toTSTypeUnion(...tsTypes) {
|
|
38
|
+
return {
|
|
39
|
+
type: tsTypes.map((tsType) => tsType.type).join(' | '),
|
|
40
|
+
tsReferences: tsTypes.reduce((tsReferences, tsType) => {
|
|
41
|
+
if (tsType.tsReferences) {
|
|
42
|
+
if (tsReferences) {
|
|
43
|
+
return tsReferences.concat(tsType.tsReferences);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return tsType.tsReferences;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return tsReferences;
|
|
50
|
+
}, undefined)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
37
53
|
export function toTSType(property) {
|
|
38
54
|
if (Swagger.v1p2.isRefType(property)) {
|
|
39
55
|
return {
|
|
@@ -43,7 +59,12 @@ export function toTSType(property) {
|
|
|
43
59
|
}
|
|
44
60
|
let tsType = Overrides.tsType(property.type);
|
|
45
61
|
if (!tsType) {
|
|
46
|
-
tsType = {
|
|
62
|
+
tsType = {
|
|
63
|
+
type: 'JSONValue',
|
|
64
|
+
tsReferences: [
|
|
65
|
+
{ type: 'JSONValue', packagePath: '@battis/typescript-tricks' }
|
|
66
|
+
]
|
|
67
|
+
};
|
|
47
68
|
switch (property.type) {
|
|
48
69
|
case 'boolean':
|
|
49
70
|
case 'number':
|
|
@@ -51,6 +72,7 @@ export function toTSType(property) {
|
|
|
51
72
|
tsType.type = `${property.type} | string`;
|
|
52
73
|
break;
|
|
53
74
|
case 'void':
|
|
75
|
+
case 'null':
|
|
54
76
|
case 'string':
|
|
55
77
|
tsType.type = property.type;
|
|
56
78
|
break;
|
|
@@ -73,8 +95,13 @@ export function toTSType(property) {
|
|
|
73
95
|
}
|
|
74
96
|
break;
|
|
75
97
|
default:
|
|
76
|
-
|
|
77
|
-
|
|
98
|
+
if (Array.isArray(property.type)) {
|
|
99
|
+
return toTSTypeUnion(...property.type.map((type) => toTSType({ type })));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
Log.debug(`Interpretting ${Colors.value('type')}: ${Colors.quotedValue(`"${property.type}"`)} as ${Colors.value('RefType')}`);
|
|
103
|
+
return toTSType({ $ref: property.type });
|
|
104
|
+
}
|
|
78
105
|
}
|
|
79
106
|
}
|
|
80
107
|
if ('format' in property && property.format != null) {
|
package/dist/Render/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Core } from '@
|
|
2
|
-
import { register } from '@
|
|
1
|
+
import { Core } from '@qui-cli/core';
|
|
2
|
+
import { register } from '@qui-cli/plugin';
|
|
3
3
|
import * as Render from './Render.js';
|
|
4
4
|
await register(Render);
|
|
5
5
|
await Core.run();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Colors } from '@
|
|
2
|
-
import { Log } from '@
|
|
3
|
-
import { Root } from '@
|
|
1
|
+
import { Colors } from '@qui-cli/colors';
|
|
2
|
+
import { Log } from '@qui-cli/log';
|
|
3
|
+
import { Root } from '@qui-cli/root';
|
|
4
4
|
import fs from 'node:fs';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import * as prettier from 'prettier';
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@groton/canvas-api.swagger-renderer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Render Canvas LMS Swagger 1.0 API documentation as TypeScript client",
|
|
5
5
|
"homepage": "https://github.com/groton-school/canvas-cli/tree/main/packages/api/swagger-renderer#readme",
|
|
6
6
|
"repository": {
|
|
@@ -19,29 +19,32 @@
|
|
|
19
19
|
"bin": "./bin"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
22
|
+
"@qui-cli/colors": "^3.2.1",
|
|
23
|
+
"@qui-cli/core": "^5.0.2",
|
|
24
|
+
"@qui-cli/env-1password": "^1.2.5",
|
|
25
|
+
"@qui-cli/log": "^4.0.2",
|
|
26
|
+
"@qui-cli/plugin": "^4.0.0",
|
|
27
|
+
"@qui-cli/root": "^3.0.6",
|
|
28
|
+
"@qui-cli/shell": "^3.1.1",
|
|
29
|
+
"@qui-cli/structured": "^2.0.4",
|
|
28
30
|
"handlebars": "^4.7.8",
|
|
29
31
|
"node-fetch": "^3.3.2",
|
|
30
32
|
"ora": "^8.2.0",
|
|
31
|
-
"p-queue": "^8.1.
|
|
33
|
+
"p-queue": "^8.1.1",
|
|
32
34
|
"prettier": "3.5.3",
|
|
33
|
-
"prettier-plugin-jsdoc": "^1.
|
|
34
|
-
"prettier-plugin-organize-imports": "^4.
|
|
35
|
+
"prettier-plugin-jsdoc": "^1.8.0",
|
|
36
|
+
"prettier-plugin-organize-imports": "^4.3.0"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
|
-
"@battis/descriptive-types": "^0.2.
|
|
38
|
-
"@battis/typescript-tricks": "^0.7.
|
|
39
|
-
"@tsconfig/
|
|
40
|
-
"
|
|
39
|
+
"@battis/descriptive-types": "^0.2.6",
|
|
40
|
+
"@battis/typescript-tricks": "^0.7.6",
|
|
41
|
+
"@tsconfig/node24": "^24.0.3",
|
|
42
|
+
"@types/node": "^24.10.4",
|
|
43
|
+
"commit-and-tag-version": "^12.6.1",
|
|
41
44
|
"del-cli": "^6.0.0",
|
|
42
45
|
"npm-run-all": "^4.1.5",
|
|
43
46
|
"typescript": "~5.8.3",
|
|
44
|
-
"@groton/swagger-spec-ts": "0.1.
|
|
47
|
+
"@groton/swagger-spec-ts": "0.1.1"
|
|
45
48
|
},
|
|
46
49
|
"scripts": {
|
|
47
50
|
"clean": "del ./dist",
|
package/dist/Download.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { PathString, URLString } from '@battis/descriptive-types';
|
|
2
|
-
import * as Plugin from '@battis/qui-cli.plugin';
|
|
3
|
-
type Configuration = Plugin.Configuration & {
|
|
4
|
-
instanceUrl?: URLString;
|
|
5
|
-
specPath?: PathString;
|
|
6
|
-
};
|
|
7
|
-
export declare const name = "download";
|
|
8
|
-
export declare const src: string;
|
|
9
|
-
export declare function configure(config?: Configuration): void;
|
|
10
|
-
export declare function options(): Plugin.Options;
|
|
11
|
-
export declare function init(args: Plugin.ExpectedArguments<typeof options>): void;
|
|
12
|
-
export declare function run(): Promise<string[]>;
|
|
13
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { PathString } from '@battis/descriptive-types';
|
|
2
|
-
import * as Swagger from '@groton/swagger-spec-ts';
|
|
3
|
-
import { TSDeprecation, TSExport, TSName, TSReference, TSType } from './TSAnnotation.js';
|
|
4
|
-
export type AnnotatedApiObject = Swagger.v1p2.ApiObject & {
|
|
5
|
-
operations: AnnotatedOperation[];
|
|
6
|
-
};
|
|
7
|
-
export type AnnotatedOperation = Swagger.v1p2.OperationObject & {
|
|
8
|
-
specPath: PathString;
|
|
9
|
-
tsFilePath: PathString;
|
|
10
|
-
tsImports?: TSReference[];
|
|
11
|
-
tsEndpoint?: PathString;
|
|
12
|
-
tsName: TSName;
|
|
13
|
-
tsType: TSType;
|
|
14
|
-
tsPathParameters?: (AnnotatedParameter & {
|
|
15
|
-
paramType: 'path';
|
|
16
|
-
})[];
|
|
17
|
-
tsQueryParameters?: (AnnotatedParameter & {
|
|
18
|
-
paramType: 'query';
|
|
19
|
-
})[];
|
|
20
|
-
tsBodyParameters?: (AnnotatedParameter & {
|
|
21
|
-
paramType: 'body';
|
|
22
|
-
})[];
|
|
23
|
-
tsFormParameters?: (AnnotatedParameter & {
|
|
24
|
-
paramType: 'form';
|
|
25
|
-
})[];
|
|
26
|
-
tsPaginated?: boolean;
|
|
27
|
-
tsUpload?: boolean;
|
|
28
|
-
};
|
|
29
|
-
export type AnnotatedParameter = Swagger.v1p2.ParameterObject & {
|
|
30
|
-
tsDeprecation?: TSDeprecation;
|
|
31
|
-
tsName: TSName;
|
|
32
|
-
tsType: TSType;
|
|
33
|
-
};
|
|
34
|
-
export type AnnotatedModel = Omit<Swagger.v1p2.ModelsObject, 'properties'> & {
|
|
35
|
-
specPath: PathString;
|
|
36
|
-
tsImports?: TSReference[];
|
|
37
|
-
tsDeprecation?: TSDeprecation;
|
|
38
|
-
tsExport?: TSExport;
|
|
39
|
-
tsName: TSName;
|
|
40
|
-
properties: AnnotatedProperty[];
|
|
41
|
-
};
|
|
42
|
-
export type AnnotatedProperty = Swagger.v1p2.DataTypeBase & {
|
|
43
|
-
tsDeprecation?: TSDeprecation;
|
|
44
|
-
tsName: TSName;
|
|
45
|
-
tsType: TSType;
|
|
46
|
-
};
|
package/dist/Render/Models.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { PathString } from '@battis/descriptive-types';
|
|
2
|
-
import * as Swagger from '@groton/swagger-spec-ts';
|
|
3
|
-
import { AnnotatedModel } from './Annotation.js';
|
|
4
|
-
type GenerateOptions = {
|
|
5
|
-
specPaths: PathString[];
|
|
6
|
-
templatePath: PathString;
|
|
7
|
-
outputPath: PathString;
|
|
8
|
-
};
|
|
9
|
-
export type Annotation = {
|
|
10
|
-
spec: Record<PathString, Swagger.v1p2.ApiDeclaration[]>;
|
|
11
|
-
models: Record<PathString, AnnotatedModel[]>;
|
|
12
|
-
};
|
|
13
|
-
export declare function generate(options: GenerateOptions): Promise<Annotation>;
|
|
14
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { PathString } from '@battis/descriptive-types';
|
|
2
|
-
import { AnnotatedOperation } from './Annotation.js';
|
|
3
|
-
import * as Models from './Models.js';
|
|
4
|
-
type GenerateOptions = Models.Annotation & {
|
|
5
|
-
outputPath: PathString;
|
|
6
|
-
templatePath: PathString;
|
|
7
|
-
};
|
|
8
|
-
type AnnotateOptions = Models.Annotation & {
|
|
9
|
-
outputPath: PathString;
|
|
10
|
-
};
|
|
11
|
-
type Annotation = Models.Annotation & {
|
|
12
|
-
operations: Record<PathString, AnnotatedOperation>;
|
|
13
|
-
};
|
|
14
|
-
export declare function generate({ spec, models, outputPath, templatePath }: GenerateOptions): Promise<Annotation>;
|
|
15
|
-
export declare function annotateOperations({ outputPath, ...annotation }: AnnotateOptions): Annotation;
|
|
16
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { PathString } from '@battis/descriptive-types';
|
|
2
|
-
import { AnnotatedOperation } from './Annotation.js';
|
|
3
|
-
import { TSName, TSReference, TSType } from './TSAnnotation.js';
|
|
4
|
-
export type Collection = {
|
|
5
|
-
/** Import paths for ambiguously specified types */
|
|
6
|
-
tsReferences?: TSReference[];
|
|
7
|
-
/** Hash of non-standard type values to TSType definitions */
|
|
8
|
-
tsTypes?: Record<string, TSType>;
|
|
9
|
-
/** Hash of OperationObject.nickname to partial OperationObject definitions */
|
|
10
|
-
operations?: Record<string, Partial<AnnotatedOperation>>;
|
|
11
|
-
};
|
|
12
|
-
export declare function setOverrides(overrides: Collection): void;
|
|
13
|
-
export declare function setOutputPath(outputPath: PathString): void;
|
|
14
|
-
export declare function tsReference(type: TSName): TSReference | undefined;
|
|
15
|
-
export declare function tsType(type: string): TSType | undefined;
|
|
16
|
-
export declare function operation(operation: AnnotatedOperation): AnnotatedOperation;
|
package/dist/Render/Render.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { PathString } from '@battis/descriptive-types';
|
|
2
|
-
import * as Plugin from '@battis/qui-cli.plugin';
|
|
3
|
-
type Configuration = Plugin.Configuration & {
|
|
4
|
-
specPath?: PathString;
|
|
5
|
-
overridePath?: PathString;
|
|
6
|
-
templatePath?: PathString;
|
|
7
|
-
outputPath?: PathString;
|
|
8
|
-
modelDirName?: string;
|
|
9
|
-
operationsDirName?: string;
|
|
10
|
-
prettierConfigPath?: PathString;
|
|
11
|
-
map?: boolean;
|
|
12
|
-
};
|
|
13
|
-
export declare const name = "render";
|
|
14
|
-
export declare const src: string;
|
|
15
|
-
export declare function configure(config?: Configuration): void;
|
|
16
|
-
export declare function options(): Plugin.Options;
|
|
17
|
-
export declare function init(args: Plugin.ExpectedArguments<typeof options>): void;
|
|
18
|
-
export declare function run(results?: Plugin.AccumulatedResults): Promise<void>;
|
|
19
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { PathString } from '@battis/descriptive-types';
|
|
2
|
-
export type TSDeprecation = string | undefined;
|
|
3
|
-
export type TSExport = 'export' | '' | undefined;
|
|
4
|
-
export type TSName = string;
|
|
5
|
-
export type TSType = {
|
|
6
|
-
type: string;
|
|
7
|
-
tsReferences?: TSReference[];
|
|
8
|
-
optional?: '?';
|
|
9
|
-
description?: string;
|
|
10
|
-
};
|
|
11
|
-
export type TSReference = {
|
|
12
|
-
type: string;
|
|
13
|
-
} & ({
|
|
14
|
-
filePath?: PathString;
|
|
15
|
-
packagePath?: never;
|
|
16
|
-
} | {
|
|
17
|
-
packagePath: string;
|
|
18
|
-
filePath?: never;
|
|
19
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { PathString } from '@battis/descriptive-types';
|
|
2
|
-
import * as Swagger from '@groton/swagger-spec-ts';
|
|
3
|
-
import { AnnotatedModel } from './Annotation.js';
|
|
4
|
-
import { TSDeprecation, TSExport, TSName, TSType } from './TSAnnotation.js';
|
|
5
|
-
export declare function toTSDeprecation(obj: object): TSDeprecation;
|
|
6
|
-
export declare function toTSExport(_: AnnotatedModel): TSExport;
|
|
7
|
-
export declare function toTSPropertyName(id: string): TSName;
|
|
8
|
-
export declare function toTSTypeName(id: string): TSName;
|
|
9
|
-
export declare function toTSNamespace(filePath: PathString): TSName;
|
|
10
|
-
export declare function toTSType(property: Swagger.v1p2.DataType): TSType;
|
package/dist/Render/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|