@tsed/scalar 8.11.1 → 8.11.2-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/ScalarModule.js +0 -1
- package/lib/esm/constants.js +0 -1
- package/lib/esm/exports.js +0 -1
- package/lib/esm/index.js +0 -1
- package/lib/esm/interfaces/ScalarSettings.js +0 -1
- package/lib/esm/middlewares/indexMiddleware.js +0 -1
- package/package.json +17 -14
- package/lib/esm/ScalarModule.js.map +0 -1
- package/lib/esm/constants.js.map +0 -1
- package/lib/esm/exports.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/interfaces/ScalarSettings.js.map +0 -1
- package/lib/esm/middlewares/indexMiddleware.js.map +0 -1
- package/src/ScalarModule.spec.ts +0 -60
- package/src/ScalarModule.ts +0 -45
- package/src/constants.ts +0 -5
- package/src/exports.ts +0 -1
- package/src/index.ts +0 -8
- package/src/interfaces/ScalarSettings.ts +0 -9
- package/src/middlewares/indexMiddleware.ts +0 -28
- package/vitest.config.mts +0 -21
package/lib/esm/ScalarModule.js
CHANGED
package/lib/esm/constants.js
CHANGED
package/lib/esm/exports.js
CHANGED
package/lib/esm/index.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/scalar",
|
|
3
3
|
"description": "Scalar package for Ts.ED framework",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.11.1",
|
|
5
|
+
"version": "8.11.2-rc.1",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -27,21 +27,21 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@scalar/types": "^0.0.23",
|
|
30
|
-
"@tsed/normalize-path": "8.11.1",
|
|
31
|
-
"@tsed/openapi-utils": "8.11.1",
|
|
32
|
-
"@tsed/openspec": "8.11.1",
|
|
30
|
+
"@tsed/normalize-path": "8.11.2-rc.1",
|
|
31
|
+
"@tsed/openapi-utils": "8.11.2-rc.1",
|
|
32
|
+
"@tsed/openspec": "8.11.2-rc.1",
|
|
33
33
|
"tslib": "2.7.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@tsed/barrels": "8.11.1",
|
|
37
|
-
"@tsed/core": "8.11.1",
|
|
38
|
-
"@tsed/di": "8.11.1",
|
|
39
|
-
"@tsed/json-mapper": "8.11.1",
|
|
40
|
-
"@tsed/openspec": "8.11.1",
|
|
41
|
-
"@tsed/platform-http": "8.11.1",
|
|
42
|
-
"@tsed/schema": "8.11.1",
|
|
43
|
-
"@tsed/swagger": "8.11.1",
|
|
44
|
-
"@tsed/typescript": "8.11.1",
|
|
36
|
+
"@tsed/barrels": "8.11.2-rc.1",
|
|
37
|
+
"@tsed/core": "8.11.2-rc.1",
|
|
38
|
+
"@tsed/di": "8.11.2-rc.1",
|
|
39
|
+
"@tsed/json-mapper": "8.11.2-rc.1",
|
|
40
|
+
"@tsed/openspec": "8.11.2-rc.1",
|
|
41
|
+
"@tsed/platform-http": "8.11.2-rc.1",
|
|
42
|
+
"@tsed/schema": "8.11.2-rc.1",
|
|
43
|
+
"@tsed/swagger": "8.11.2-rc.1",
|
|
44
|
+
"@tsed/typescript": "8.11.2-rc.1",
|
|
45
45
|
"eslint": "9.12.0",
|
|
46
46
|
"typescript": "5.4.5",
|
|
47
47
|
"vitest": "3.1.4"
|
|
@@ -60,5 +60,8 @@
|
|
|
60
60
|
},
|
|
61
61
|
"homepage": "https://github.com/tsedio/tsed/tree/production/packages/specs/scalar",
|
|
62
62
|
"author": "Romain Lenzotti",
|
|
63
|
-
"license": "MIT"
|
|
63
|
+
"license": "MIT",
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"tag": "rc"
|
|
66
|
+
}
|
|
64
67
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Scalar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,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,iBAAiB,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QACtE,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,UAAU,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC"}
|
package/lib/esm/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAE/B,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC"}
|
package/lib/esm/exports.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC"}
|
package/lib/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarSettings.js","sourceRoot":"","sources":["../../../src/interfaces/ScalarSettings.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"indexMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/indexMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAC,OAAO,EAAC,MAAM,UAAU,CAAC;AAIjC,MAAM,UAAU,eAAe,CAAC,QAAgB,EAAE,IAAoB;IACpE,OAAO,KAAK,IAAI,EAAE;QAChB,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;QACtB,MAAM,EAAC,IAAI,EAAE,OAAO,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAC,GAAG,IAAI,CAAC;QAE1D,MAAM,IAAI,GAAG;YACX,IAAI,EAAE;gBACJ,GAAG,EAAE,GAAG,IAAI,IAAI,QAAQ,EAAE;aAC3B;YACD,GAAG,OAAO;SACX,CAAC;QAEF,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,IAAI,CACxC,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE;YAClC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;YACtC,GAAG;YACH,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;YACjE,OAAO,EAAE,IAAI;SACd,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/src/ScalarModule.spec.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {logger} from "@tsed/di";
|
|
2
|
-
import {application} from "@tsed/platform-http";
|
|
3
|
-
import {PlatformTest} from "@tsed/platform-http/testing";
|
|
4
|
-
import {PlatformRouter} from "@tsed/platform-router";
|
|
5
|
-
|
|
6
|
-
import {ScalarModule} from "./ScalarModule.js";
|
|
7
|
-
|
|
8
|
-
vi.mock("node:fs/promises");
|
|
9
|
-
|
|
10
|
-
describe("SwaggerModule", () => {
|
|
11
|
-
beforeEach(() =>
|
|
12
|
-
PlatformTest.create({
|
|
13
|
-
httpPort: 8080,
|
|
14
|
-
httpsPort: 8081,
|
|
15
|
-
scalar: [
|
|
16
|
-
{
|
|
17
|
-
path: "/doc",
|
|
18
|
-
cssPath: "/cssPath/style.css",
|
|
19
|
-
jsPath: "/jsPath/script.js",
|
|
20
|
-
viewPath: "/viewsPath",
|
|
21
|
-
outFile: "/openapi.json"
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
})
|
|
25
|
-
);
|
|
26
|
-
afterEach(PlatformTest.reset);
|
|
27
|
-
|
|
28
|
-
describe("$onRoutesInit", () => {
|
|
29
|
-
it("should add middlewares", async () => {
|
|
30
|
-
const mod = await PlatformTest.invoke<ScalarModule>(ScalarModule);
|
|
31
|
-
|
|
32
|
-
vi.spyOn(application(), "get").mockReturnValue(undefined as never);
|
|
33
|
-
vi.spyOn(application(), "use").mockReturnValue(undefined as never);
|
|
34
|
-
vi.spyOn(PlatformRouter.prototype as any, "get").mockReturnValue(undefined);
|
|
35
|
-
vi.spyOn(PlatformRouter.prototype as any, "statics").mockReturnValue(undefined);
|
|
36
|
-
|
|
37
|
-
mod.$onRoutesInit();
|
|
38
|
-
mod.$onRoutesInit();
|
|
39
|
-
|
|
40
|
-
expect(application().use).toHaveBeenCalledWith("/doc", expect.any(Function));
|
|
41
|
-
expect(application().use).toHaveBeenCalledWith("/doc", expect.any(PlatformRouter));
|
|
42
|
-
expect(PlatformRouter.prototype.get).toHaveBeenCalledWith("/openapi.json", expect.any(Function));
|
|
43
|
-
expect(PlatformRouter.prototype.get).toHaveBeenCalledWith("/style.css", expect.any(Function));
|
|
44
|
-
expect(PlatformRouter.prototype.get).toHaveBeenCalledWith("/script.js", expect.any(Function));
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
describe("$onReady", () => {
|
|
49
|
-
it("should display the right log", async () => {
|
|
50
|
-
const mod = await PlatformTest.invoke<ScalarModule>(ScalarModule);
|
|
51
|
-
|
|
52
|
-
vi.spyOn(logger(), "info");
|
|
53
|
-
|
|
54
|
-
mod.$onReady();
|
|
55
|
-
|
|
56
|
-
expect(logger().info).toHaveBeenCalledWith("[default] OpenAPI JSON is available on https://0.0.0.0:8081/doc/openapi.json");
|
|
57
|
-
expect(logger().info).toHaveBeenCalledWith("[default] Scalar UI is available on https://0.0.0.0:8081/doc/");
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
});
|
package/src/ScalarModule.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import {join} from "node:path";
|
|
2
|
-
|
|
3
|
-
import {constant, injectable, ProviderType} from "@tsed/di";
|
|
4
|
-
import {OpenAPIBaseModule} from "@tsed/openapi-utils";
|
|
5
|
-
import {useContextHandler} from "@tsed/platform-router";
|
|
6
|
-
|
|
7
|
-
import {ROOT_DIR} from "./constants.js";
|
|
8
|
-
import {ScalarSettings} from "./interfaces/ScalarSettings.js";
|
|
9
|
-
import {indexMiddleware} from "./middlewares/indexMiddleware.js";
|
|
10
|
-
|
|
11
|
-
export class ScalarModule extends OpenAPIBaseModule {
|
|
12
|
-
readonly name = "Scalar";
|
|
13
|
-
readonly rootDir = ROOT_DIR;
|
|
14
|
-
|
|
15
|
-
get settings() {
|
|
16
|
-
const settings = constant<ScalarSettings[]>("scalar", []).filter((o) => !!o);
|
|
17
|
-
|
|
18
|
-
return settings.map((conf) => {
|
|
19
|
-
return Object.assign(
|
|
20
|
-
{
|
|
21
|
-
disableSpec: false,
|
|
22
|
-
cdn: "https://cdn.jsdelivr.net/npm/@scalar/api-reference",
|
|
23
|
-
path: "/",
|
|
24
|
-
fileName: "openapi.json",
|
|
25
|
-
cssPath: join(ROOT_DIR, "views/assets/scalar.css"),
|
|
26
|
-
viewPath: join(ROOT_DIR, "views/scalar.ejs")
|
|
27
|
-
},
|
|
28
|
-
conf
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
protected createRouter(conf: ScalarSettings) {
|
|
34
|
-
const {viewPath} = conf;
|
|
35
|
-
const router = super.createRouter(conf);
|
|
36
|
-
|
|
37
|
-
if (viewPath) {
|
|
38
|
-
router.get("/", useContextHandler(indexMiddleware(viewPath, conf)));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return router;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
injectable(ScalarModule).type(ProviderType.MODULE);
|
package/src/constants.ts
DELETED
package/src/exports.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {Docs} from "@tsed/openapi-utils";
|
package/src/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import type {ReferenceConfiguration} from "@scalar/types/legacy";
|
|
3
|
-
import type {OpenApiSettings} from "@tsed/openapi-utils";
|
|
4
|
-
|
|
5
|
-
export type ScalarSettings = OpenApiSettings &
|
|
6
|
-
ReferenceConfiguration & {
|
|
7
|
-
cdn?: string;
|
|
8
|
-
options?: ReferenceConfiguration;
|
|
9
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {basename, join} from "node:path";
|
|
2
|
-
|
|
3
|
-
import {context} from "@tsed/di";
|
|
4
|
-
|
|
5
|
-
import {ScalarSettings} from "../interfaces/ScalarSettings.js";
|
|
6
|
-
|
|
7
|
-
export function indexMiddleware(viewPath: string, conf: ScalarSettings) {
|
|
8
|
-
return async () => {
|
|
9
|
-
const ctx = context();
|
|
10
|
-
const {path, options = {}, cssPath, cdn, fileName} = conf;
|
|
11
|
-
|
|
12
|
-
const opts = {
|
|
13
|
-
spec: {
|
|
14
|
-
url: `${path}/${fileName}`
|
|
15
|
-
},
|
|
16
|
-
...options
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
ctx.response.contentType("text/html").body(
|
|
20
|
-
await ctx.response.render(viewPath, {
|
|
21
|
-
cssPath: join(path, basename(cssPath)),
|
|
22
|
-
cdn,
|
|
23
|
-
serializedOptions: JSON.stringify(opts).split('"').join("""),
|
|
24
|
-
options: opts
|
|
25
|
-
})
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
}
|
package/vitest.config.mts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import {presets} from "@tsed/vitest/presets";
|
|
3
|
-
import {defineConfig} from "vitest/config";
|
|
4
|
-
|
|
5
|
-
export default defineConfig(
|
|
6
|
-
{
|
|
7
|
-
...presets,
|
|
8
|
-
test: {
|
|
9
|
-
...presets.test,
|
|
10
|
-
coverage: {
|
|
11
|
-
...presets.test.coverage,
|
|
12
|
-
thresholds: {
|
|
13
|
-
statements: 0,
|
|
14
|
-
branches: 0,
|
|
15
|
-
functions: 0,
|
|
16
|
-
lines: 0
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
);
|