mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-10 22:32:15 +00:00
chore!: use buf v2 generators
This commit is contained in:
@@ -45,8 +45,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@zitadel/proto": "workspace:*",
|
||||
"@bufbuild/protobuf": "^1.10.0",
|
||||
"@connectrpc/connect": "^1.4.0"
|
||||
"@bufbuild/protobuf": "^2.0.0",
|
||||
"@connectrpc/connect": "2.0.0-alpha.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@zitadel/tsconfig": "workspace:*",
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import type { DescService } from "@bufbuild/protobuf";
|
||||
import { Timestamp, timestampDate } from "@bufbuild/protobuf/wkt";
|
||||
import { createPromiseClient, Transport } from "@connectrpc/connect";
|
||||
import type { ServiceType } from "@bufbuild/protobuf";
|
||||
|
||||
export function createClientFor<TService extends ServiceType>(
|
||||
service: TService,
|
||||
) {
|
||||
export function createClientFor<TService extends DescService>(service: TService) {
|
||||
return (transport: Transport) => createPromiseClient(service, transport);
|
||||
}
|
||||
|
||||
export function toDate(timestamp: Timestamp | undefined): Date | undefined {
|
||||
return timestamp ? timestampDate(timestamp) : undefined;
|
||||
}
|
||||
|
||||
@@ -1,2 +1,7 @@
|
||||
export { toDate } from "./helpers";
|
||||
export { NewAuthorizationBearerInterceptor } from "./interceptors";
|
||||
export type { PartialMessage, PlainMessage } from "@bufbuild/protobuf";
|
||||
|
||||
// TODO: Move this to `./protobuf.ts` and export it from there
|
||||
export { create as createMessage, fromJson, toJson } from "@bufbuild/protobuf";
|
||||
export { TimestampSchema, timestampDate } from "@bufbuild/protobuf/wkt";
|
||||
export type { Timestamp } from "@bufbuild/protobuf/wkt";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, test, vitest } from "vitest";
|
||||
import { Int32Value, MethodKind, StringValue } from "@bufbuild/protobuf";
|
||||
import { createRouterTransport, HandlerContext } from "@connectrpc/connect";
|
||||
import { describe, expect, test, vitest } from "vitest";
|
||||
import { NewAuthorizationBearerInterceptor } from "./interceptors";
|
||||
|
||||
const TestService = {
|
||||
@@ -21,11 +21,9 @@ describe("NewAuthorizationBearerInterceptor", () => {
|
||||
};
|
||||
|
||||
test("injects the authorization token", async () => {
|
||||
const handler = vitest.fn(
|
||||
(request: Int32Value, context: HandlerContext) => {
|
||||
return { value: request.value.toString() };
|
||||
},
|
||||
);
|
||||
const handler = vitest.fn((request: Int32Value, context: HandlerContext) => {
|
||||
return { value: request.value.toString() };
|
||||
});
|
||||
|
||||
const service = createRouterTransport(
|
||||
({ service }) => {
|
||||
@@ -34,27 +32,16 @@ describe("NewAuthorizationBearerInterceptor", () => {
|
||||
{ transport },
|
||||
);
|
||||
|
||||
await service.unary(
|
||||
TestService,
|
||||
TestService.methods.unary,
|
||||
undefined,
|
||||
undefined,
|
||||
{},
|
||||
{ value: 9001 },
|
||||
);
|
||||
await service.unary(TestService, TestService.methods.unary, undefined, undefined, {}, { value: 9001 });
|
||||
|
||||
expect(handler).toBeCalled();
|
||||
expect(handler.mock.calls[0][1].requestHeader.get("Authorization")).toBe(
|
||||
"Bearer mytoken",
|
||||
);
|
||||
expect(handler.mock.calls[0][1].requestHeader.get("Authorization")).toBe("Bearer mytoken");
|
||||
});
|
||||
|
||||
test("do not overwrite the previous authorization token", async () => {
|
||||
const handler = vitest.fn(
|
||||
(request: Int32Value, context: HandlerContext) => {
|
||||
return { value: request.value.toString() };
|
||||
},
|
||||
);
|
||||
const handler = vitest.fn((request: Int32Value, context: HandlerContext) => {
|
||||
return { value: request.value.toString() };
|
||||
});
|
||||
|
||||
const service = createRouterTransport(
|
||||
({ service }) => {
|
||||
@@ -73,8 +60,6 @@ describe("NewAuthorizationBearerInterceptor", () => {
|
||||
);
|
||||
|
||||
expect(handler).toBeCalled();
|
||||
expect(handler.mock.calls[0][1].requestHeader.get("Authorization")).toBe(
|
||||
"Bearer somethingelse",
|
||||
);
|
||||
expect(handler.mock.calls[0][1].requestHeader.get("Authorization")).toBe("Bearer somethingelse");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createClientFor } from "./helpers";
|
||||
|
||||
import { AdminService } from "@zitadel/proto/zitadel/admin_connect";
|
||||
import { AuthService } from "@zitadel/proto/zitadel/auth_connect";
|
||||
import { ManagementService } from "@zitadel/proto/zitadel/management_connect";
|
||||
import { SystemService } from "@zitadel/proto/zitadel/system_connect";
|
||||
import { AdminService } from "@zitadel/proto/zitadel/admin_pb";
|
||||
import { AuthService } from "@zitadel/proto/zitadel/auth_pb";
|
||||
import { ManagementService } from "@zitadel/proto/zitadel/management_pb";
|
||||
import { SystemService } from "@zitadel/proto/zitadel/system_pb";
|
||||
|
||||
export const createAdminServiceClient = createClientFor(AdminService);
|
||||
export const createAuthServiceClient = createClientFor(AuthService);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { FeatureService } from "@zitadel/proto/zitadel/feature/v2/feature_service_connect";
|
||||
import { IdentityProviderService } from "@zitadel/proto/zitadel/idp/v2/idp_service_connect";
|
||||
import { FeatureService } from "@zitadel/proto/zitadel/feature/v2/feature_service_pb";
|
||||
import { IdentityProviderService } from "@zitadel/proto/zitadel/idp/v2/idp_service_pb";
|
||||
import { RequestContext } from "@zitadel/proto/zitadel/object/v2/object_pb";
|
||||
import { OIDCService } from "@zitadel/proto/zitadel/oidc/v2/oidc_service_connect";
|
||||
import { OrganizationService } from "@zitadel/proto/zitadel/org/v2/org_service_connect";
|
||||
import { SessionService } from "@zitadel/proto/zitadel/session/v2/session_service_connect";
|
||||
import { SettingsService } from "@zitadel/proto/zitadel/settings/v2/settings_service_connect";
|
||||
import { UserService } from "@zitadel/proto/zitadel/user/v2/user_service_connect";
|
||||
import { OIDCService } from "@zitadel/proto/zitadel/oidc/v2/oidc_service_pb";
|
||||
import { OrganizationService } from "@zitadel/proto/zitadel/org/v2/org_service_pb";
|
||||
import { SessionService } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
||||
import { SettingsService } from "@zitadel/proto/zitadel/settings/v2/settings_service_pb";
|
||||
import { UserService } from "@zitadel/proto/zitadel/user/v2/user_service_pb";
|
||||
|
||||
import { createClientFor } from "./helpers";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UserSchemaService } from "@zitadel/proto/zitadel/user/schema/v3alpha/user_schema_service_connect";
|
||||
import { UserService } from "@zitadel/proto/zitadel/user/v3alpha/user_service_connect";
|
||||
import { UserSchemaService } from "@zitadel/proto/zitadel/user/schema/v3alpha/user_schema_service_pb";
|
||||
import { UserService } from "@zitadel/proto/zitadel/user/v3alpha/user_service_pb";
|
||||
import { createClientFor } from "./helpers";
|
||||
|
||||
export const createUserSchemaServiceClient = createClientFor(UserSchemaService);
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
"@zitadel/client": "workspace:*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@connectrpc/connect-node": "^1.4.0",
|
||||
"@connectrpc/connect-web": "^1.4.0",
|
||||
"@connectrpc/connect-node": "^2.0.0-alpha.1",
|
||||
"@connectrpc/connect-web": "^2.0.0-alpha.1",
|
||||
"jose": "^5.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
5
packages/zitadel-proto/.gitignore
vendored
5
packages/zitadel-proto/.gitignore
vendored
@@ -1 +1,4 @@
|
||||
zitadel
|
||||
zitadel
|
||||
google
|
||||
protoc-gen-openapiv2
|
||||
validate
|
||||
|
||||
@@ -2,7 +2,6 @@ version: v2
|
||||
managed:
|
||||
enabled: true
|
||||
plugins:
|
||||
- remote: buf.build/connectrpc/es:v1.4.0
|
||||
out: .
|
||||
- remote: buf.build/bufbuild/es:v1.7.2
|
||||
- remote: buf.build/bufbuild/es:v2.0.0
|
||||
out: .
|
||||
include_imports: true
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"clean": "rm -rf zitadel && rm -rf .turbo && rm -rf node_modules"
|
||||
},
|
||||
"dependencies": {
|
||||
"@bufbuild/protobuf": "^1.10.0"
|
||||
"@bufbuild/protobuf": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@bufbuild/buf": "^1.36.0"
|
||||
|
||||
9923
pnpm-lock.yaml
generated
9923
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user