Skip to content

Commit

Permalink
fix: bump Ts.ED dependencies to v8.0.0-beta.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Oct 12, 2024
1 parent 68b6c5d commit d1763bf
Show file tree
Hide file tree
Showing 38 changed files with 107 additions and 111 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
},
"homepage": "https://github.com/tsedio/tsed-cli",
"dependencies": {
"@tsed/core": ">=8.0.0-beta.2",
"@tsed/di": ">=8.0.0-beta.2",
"@tsed/core": ">=8.0.0-beta.3",
"@tsed/di": ">=8.0.0-beta.3",
"@tsed/logger": ">=6.2.1",
"@tsed/normalize-path": ">=8.0.0-beta.2",
"@tsed/openspec": ">=8.0.0-beta.2",
"@tsed/schema": ">=8.0.0-beta.2",
"@tsed/normalize-path": ">=8.0.0-beta.3",
"@tsed/openspec": ">=8.0.0-beta.3",
"@tsed/schema": ">=8.0.0-beta.3",
"axios": "^1.7.7",
"chalk": "^5.3.0",
"commander": "^12.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"vitest": "2.1.1"
},
"peerDependencies": {
"@tsed/core": ">=8.0.0-beta.2",
"@tsed/di": ">=8.0.0-beta.2"
"@tsed/core": ">=8.0.0-beta.3",
"@tsed/di": ">=8.0.0-beta.3"
}
}
2 changes: 1 addition & 1 deletion packages/cli-generate-http-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"vitest": "2.1.1"
},
"peerDependencies": {
"@tsed/common": ">=7.14.2",
"@tsed/platform-http": ">=7.14.2",
"@tsed/swagger": ">=7.14.2",
"swagger-typescript-api": "^9.3.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-generate-swagger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"vitest": "2.1.1"
},
"peerDependencies": {
"@tsed/common": ">=7.14.2",
"@tsed/platform-http": ">=7.14.2",
"@tsed/swagger": ">=7.14.2"
},
"peerDependenciesMeta": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PlatformTest } from "@tsed/common";
import { PlatformTest } from "@tsed/platform-http";
import SuperTest from "supertest";
import { {{symbolName}} } from "./{{symbolPathBasename}}.js";
import { Server } from "{{relativeSrcPath}}/Server.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PlatformTest } from "@tsed/common";
import { PlatformTest } from "@tsed/platform-http";
import { {{symbolName}} } from "./{{symbolPathBasename}}.js";

describe("{{symbolName}}", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PlatformTest } from "@tsed/common";
import { PlatformTest } from "@tsed/platform-http";
import SuperTest from "supertest";
import { {{symbolName}} } from "./{{symbolPathBasename}}.js";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("Generate Controller", () => {
]);

const result = FakeCliFs.entries.get("project-name/src/controllers/TestController.integration.spec.ts");
expect(result).toContain('import { PlatformTest } from "@tsed/common";');
expect(result).toContain('import { PlatformTest } from "@tsed/platform-http";');
expect(result).toContain('import SuperTest from "supertest";');
expect(result).toContain('import { Server } from "../Server.js";');
expect(result).toContain('import { TestController } from "./TestController.js";');
Expand Down Expand Up @@ -67,7 +67,7 @@ describe("Generate Controller", () => {
]);

const result = FakeCliFs.entries.get("project-name/src/controllers/users/UserController.integration.spec.ts");
expect(result).toContain('import { PlatformTest } from "@tsed/common";');
expect(result).toContain('import { PlatformTest } from "@tsed/platform-http";');
expect(result).toContain('import SuperTest from "supertest";');
expect(result).toContain('import { Server } from "../../Server.js";');
expect(result).toContain('import { UserController } from "./UserController.js";');
Expand Down
4 changes: 2 additions & 2 deletions packages/cli-plugin-mongoose/src/CliPluginMongooseModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export class CliPluginMongooseModule {
@OnAdd("@tsed/cli-plugin-mongoose")
install() {
this.packageJson.addDependencies({
"@tsed/mongoose": this.packageJson.dependencies["@tsed/common"],
"@tsed/mongoose": this.packageJson.dependencies["@tsed/platform-http"],
mongoose: "latest"
});

this.packageJson.addDevDependencies({
"@tsed/testing-mongoose": this.packageJson.dependencies["@tsed/common"]
"@tsed/testing-mongoose": this.packageJson.dependencies["@tsed/platform-http"]
});
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PlatformTest } from "@tsed/common";
import {PlatformTest} from "@tsed/platform-http";

import { getOidcContextFixture } from "../../interactions/__mock__/oidcContext.fixture.js";
import { InteractionsController } from "./InteractionsController.js";
import {getOidcContextFixture} from "../../interactions/__mock__/oidcContext.fixture.js";
import {InteractionsController} from "./InteractionsController.js";

describe("InteractionsController", () => {
beforeEach(() => PlatformTest.create());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Get, PathParams} from "@tsed/common";
import {Get, PathParams} from "@tsed/platform-http";
import {Interactions, OidcCtx} from "@tsed/oidc-provider";
import {Name} from "@tsed/schema";
import * as interactions from "../../interactions/index.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Inject} from "@tsed/common";
import {Inject} from "@tsed/platform-http";
import {Interaction, OidcCtx, OidcProvider, InteractionMethods} from "@tsed/oidc-provider";
import {View} from "@tsed/platform-views";
import {Name} from "@tsed/schema";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { PlatformTest } from "@tsed/common";
import {PlatformTest} from "@tsed/platform-http";

import { getOidcContextFixture } from "./__mock__/oidcContext.fixture.js";
import { ConsentInteraction } from "./ConsentInteraction.js";
import {getOidcContextFixture} from "./__mock__/oidcContext.fixture.js";
import {ConsentInteraction} from "./ConsentInteraction.js";

async function createInteractionFixture() {
const interaction = await PlatformTest.invoke<ConsentInteraction>(ConsentInteraction, []);

return { interaction };
return {interaction};
}

describe("ConsentInteraction", () => {
Expand All @@ -15,7 +15,7 @@ describe("ConsentInteraction", () => {

describe("$prompt()", () => {
it("should return consent context", async () => {
const { interaction } = await createInteractionFixture();
const {interaction} = await createInteractionFixture();
const oidcContext = getOidcContextFixture();

const result = await interaction.$prompt(oidcContext);
Expand All @@ -36,7 +36,7 @@ describe("ConsentInteraction", () => {
});
describe("confirm()", () => {
it("should control all consentement", async () => {
const { interaction } = await createInteractionFixture();
const {interaction} = await createInteractionFixture();
const oidcContext = getOidcContextFixture();
oidcContext.prompt.name = "consent";

Expand Down Expand Up @@ -65,7 +65,7 @@ describe("ConsentInteraction", () => {
expect(grant.addOIDCClaims).toHaveBeenCalledWith(["claims"]);
expect(grant.addResourceScope).toHaveBeenCalledWith("indicator", "scopes");
expect(grant.save).toHaveBeenCalledWith();
expect(oidcContext.interactionFinished).toHaveBeenCalledWith({ consent: { grantId: "grantId" } }, { mergeWithLastSubmission: true });
expect(oidcContext.interactionFinished).toHaveBeenCalledWith({consent: {grantId: "grantId"}}, {mergeWithLastSubmission: true});
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Inject, Post, View} from "@tsed/common";
import {Post, View, Name} from "@tsed/schema";
import {Inject} from "@tsed/di";
import {Interaction, OidcCtx, OidcProvider} from "@tsed/oidc-provider";
import {Name} from "@tsed/schema";

@Interaction({
name: "consent",
Expand Down Expand Up @@ -32,7 +32,7 @@ export class ConsentInteraction {
missingOIDClaims: string[];
};

const { missingOIDCScope, missingOIDClaims, missingResourceScopes } = details;
const {missingOIDCScope, missingOIDClaims, missingResourceScopes} = details;

if (missingOIDCScope) {
grant.addOIDCScope(missingOIDCScope.join(" "));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {View} from "@tsed/common";
import {Env} from "@tsed/core";
import {Constant} from "@tsed/di";
import {Interaction, InteractionMethods, OidcCtx, OidcSession, Params, Prompt, Uid} from "@tsed/oidc-provider";
import {Name} from "@tsed/schema";
import {Name, View} from "@tsed/schema";
import {interactionPolicy, KoaContextWithOIDC} from "oidc-provider";
import Check = interactionPolicy.Check;

Expand All @@ -15,16 +14,15 @@ export class CustomInteraction implements InteractionMethods {
@Constant("env")
env: Env;

$onCreate() {
}
$onCreate() {}

/**
* return checks conditions. See: https://github.com/panva/node-oidc-provider/blob/main/docs/README.md#interactionspolicy
*/
checks() {
return [
new Check("no_session", "End-User authentication is required", (ctx) => {
const { oidc } = ctx;
const {oidc} = ctx;

if (oidc.session?.accountId) {
// @ts-ignore
Expand All @@ -41,12 +39,12 @@ export class CustomInteraction implements InteractionMethods {
* return checks conditions. See: https://github.com/panva/node-oidc-provider/blob/main/docs/README.md#interactionspolicy
*/
details(ctx: KoaContextWithOIDC) {
const { oidc } = ctx;
const {oidc} = ctx;

return {
...(oidc.params?.max_age === undefined ? undefined : { max_age: oidc.params.max_age }),
...(oidc.params?.login_hint === undefined ? undefined : { login_hint: oidc.params.login_hint }),
...(oidc.params?.id_token_hint === undefined ? undefined : { id_token_hint: oidc.params.id_token_hint })
...(oidc.params?.max_age === undefined ? undefined : {max_age: oidc.params.max_age}),
...(oidc.params?.login_hint === undefined ? undefined : {login_hint: oidc.params.login_hint}),
...(oidc.params?.id_token_hint === undefined ? undefined : {id_token_hint: oidc.params.id_token_hint})
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PlatformTest } from "@tsed/common";
import { catchAsyncError } from "@tsed/core";
import { BadRequest } from "@tsed/exceptions";
import {PlatformTest} from "@tsed/platform-http";
import {catchAsyncError} from "@tsed/core";
import {BadRequest} from "@tsed/exceptions";

import { Accounts } from "../services/Accounts.js";
import { getOidcContextFixture } from "./__mock__/oidcContext.fixture.js";
import { LoginInteraction } from "./LoginInteraction.js";
import {Accounts} from "../services/Accounts.js";
import {getOidcContextFixture} from "./__mock__/oidcContext.fixture.js";
import {LoginInteraction} from "./LoginInteraction.js";

async function createInteractionFixture() {
const accounts = {
Expand All @@ -18,7 +18,7 @@ async function createInteractionFixture() {
}
]);

return { interaction, accounts };
return {interaction, accounts};
}

describe("LoginInteraction", () => {
Expand All @@ -30,7 +30,7 @@ describe("LoginInteraction", () => {

describe("$prompt()", () => {
it("should return the prompt login context", async () => {
const { interaction } = await createInteractionFixture();
const {interaction} = await createInteractionFixture();
const oidcContext = getOidcContextFixture();

const result = await interaction.$prompt(oidcContext);
Expand All @@ -51,7 +51,7 @@ describe("LoginInteraction", () => {
});
});
it("should throw error when the Client is unauthorized", async () => {
const { interaction } = await createInteractionFixture();
const {interaction} = await createInteractionFixture();
const oidcContext = getOidcContextFixture();

(oidcContext.checkClientId as vi.Mock).mockRejectedValue(new Error("Unknown given client_id: client_id"));
Expand All @@ -64,10 +64,10 @@ describe("LoginInteraction", () => {
});
describe("submit()", () => {
it("should find account", async () => {
const { interaction, accounts } = await createInteractionFixture();
const {interaction, accounts} = await createInteractionFixture();
const oidcContext = getOidcContextFixture();

const payload = { email: "[email protected]", password: "pwd" };
const payload = {email: "[email protected]", password: "pwd"};

accounts.authenticate.mockResolvedValue({
accountId: "id"
Expand All @@ -77,13 +77,13 @@ describe("LoginInteraction", () => {

expect(result).toEqual(undefined);
expect(oidcContext.checkInteractionName).toHaveBeenCalledWith("login");
expect(oidcContext.interactionFinished).toHaveBeenCalledWith({ login: { accountId: "id" } });
expect(oidcContext.interactionFinished).toHaveBeenCalledWith({login: {accountId: "id"}});
});
it("should return to the login page and return the right context page", async () => {
const { interaction, accounts } = await createInteractionFixture();
const {interaction, accounts} = await createInteractionFixture();
const oidcContext = getOidcContextFixture();

const payload = { email: "[email protected]", password: "pwd" };
const payload = {email: "[email protected]", password: "pwd"};

accounts.authenticate.mockResolvedValue(null);

Expand All @@ -106,15 +106,15 @@ describe("LoginInteraction", () => {
expect(oidcContext.interactionFinished).not.toHaveBeenCalled();
});
it("should fail if the prompt name is incorrect", async () => {
const { interaction } = await createInteractionFixture();
const {interaction} = await createInteractionFixture();
const oidcContext = getOidcContextFixture();
oidcContext.prompt.name = "unknown";

oidcContext.checkInteractionName.mockImplementation(() => {
throw new BadRequest("Bad interaction name");
});

const payload = { email: "[email protected]", password: "pwd" };
const payload = {email: "[email protected]", password: "pwd"};

const error = await catchAsyncError<any>(() => interaction.submit(payload, oidcContext));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {BodyParams, Inject, Post, View} from "@tsed/common";
import {BodyParams} from "@tsed/platform-params";
import {Env} from "@tsed/core";
import {Constant} from "@tsed/di";
import {Constant, Inject} from "@tsed/di";
import {Interaction, OidcCtx} from "@tsed/oidc-provider";
import {Name} from "@tsed/schema";
import {Name, Post, View} from "@tsed/schema";
import {Accounts} from "../services/Accounts.js";

@Interaction({
Expand All @@ -20,9 +20,7 @@ export class LoginInteraction {
$onCreate() {}

@View("login")
async $prompt(
@OidcCtx() oidcCtx: OidcCtx
): Promise<any> {
async $prompt(@OidcCtx() oidcCtx: OidcCtx): Promise<any> {
await oidcCtx.checkClientId();

return oidcCtx.interactionPrompt({
Expand All @@ -33,10 +31,7 @@ export class LoginInteraction {

@Post("/login")
@View("login")
async submit(
@BodyParams() payload: any,
@OidcCtx() oidcCtx: OidcCtx
) {
async submit(@BodyParams() payload: any, @OidcCtx() oidcCtx: OidcCtx) {
oidcCtx.checkInteractionName("login");

const account = await this.accounts.authenticate(payload.email, payload.password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ exports[`Init OIDC Provider project > should generate a project with oidc 1`] =
exports[`Init OIDC Provider project > should generate a project with oidc 2`] = `
"import {join} from "path";
import {Configuration, Inject} from "@tsed/di";
import {PlatformApplication} from "@tsed/common";
import {PlatformApplication} from "@tsed/platform-http";
import "@tsed/platform-log-request"; // remove this import if you don&#x27;t want log request
import "@tsed/platform-express"; // /!\\ keep this import
import "@tsed/ajv";
Expand Down Expand Up @@ -179,7 +179,7 @@ exports[`Init OIDC Provider project > should generate a project with oidc and sw
exports[`Init OIDC Provider project > should generate a project with oidc and swagger 2`] = `
"import {join} from "path";
import {Configuration, Inject} from "@tsed/di";
import {PlatformApplication} from "@tsed/common";
import {PlatformApplication} from "@tsed/platform-http";
import "@tsed/platform-log-request"; // remove this import if you don&#x27;t want log request
import "@tsed/platform-express"; // /!\\ keep this import
import "@tsed/ajv";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class CliPluginPassportModule {
@OnAdd("@tsed/cli-plugin-passport")
install() {
this.packageJson.addDependencies({
"@tsed/passport": this.packageJson.dependencies["@tsed/common"],
"@tsed/passport": this.packageJson.dependencies["@tsed/platform-http"],
passport: "latest"
});

Expand Down
3 changes: 2 additions & 1 deletion packages/cli-plugin-passport/templates/generic.protocol.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {BodyParams, Req} from "@tsed/common";
import {Req} from "@tsed/platform-http";
import {BodyParams} from "@tsed/platform-params";
import {OnInstall, OnVerify, Protocol, Args} from "@tsed/passport";
import {Strategy} from "{{passportPackage}}";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {BodyParams, Req} from "@tsed/common";
import {Req} from "@tsed/platform-http";
import {BodyParams} from "@tsed/platform-params";
import {OnInstall, OnVerify, Protocol} from "@tsed/passport";
import {BasicStrategy} from "passport-http";

Expand Down
Loading

0 comments on commit d1763bf

Please sign in to comment.