mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-11 21:52:32 +00:00
chore!: use buf v2 generators
This commit is contained in:
@@ -45,8 +45,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@zitadel/proto": "workspace:*",
|
"@zitadel/proto": "workspace:*",
|
||||||
"@bufbuild/protobuf": "^1.10.0",
|
"@bufbuild/protobuf": "^2.0.0",
|
||||||
"@connectrpc/connect": "^1.4.0"
|
"@connectrpc/connect": "2.0.0-alpha.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@zitadel/tsconfig": "workspace:*",
|
"@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 { createPromiseClient, Transport } from "@connectrpc/connect";
|
||||||
import type { ServiceType } from "@bufbuild/protobuf";
|
|
||||||
|
|
||||||
export function createClientFor<TService extends ServiceType>(
|
export function createClientFor<TService extends DescService>(service: TService) {
|
||||||
service: TService,
|
|
||||||
) {
|
|
||||||
return (transport: Transport) => createPromiseClient(service, transport);
|
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 { 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 { Int32Value, MethodKind, StringValue } from "@bufbuild/protobuf";
|
||||||
import { createRouterTransport, HandlerContext } from "@connectrpc/connect";
|
import { createRouterTransport, HandlerContext } from "@connectrpc/connect";
|
||||||
|
import { describe, expect, test, vitest } from "vitest";
|
||||||
import { NewAuthorizationBearerInterceptor } from "./interceptors";
|
import { NewAuthorizationBearerInterceptor } from "./interceptors";
|
||||||
|
|
||||||
const TestService = {
|
const TestService = {
|
||||||
@@ -21,11 +21,9 @@ describe("NewAuthorizationBearerInterceptor", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test("injects the authorization token", async () => {
|
test("injects the authorization token", async () => {
|
||||||
const handler = vitest.fn(
|
const handler = vitest.fn((request: Int32Value, context: HandlerContext) => {
|
||||||
(request: Int32Value, context: HandlerContext) => {
|
return { value: request.value.toString() };
|
||||||
return { value: request.value.toString() };
|
});
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
const service = createRouterTransport(
|
const service = createRouterTransport(
|
||||||
({ service }) => {
|
({ service }) => {
|
||||||
@@ -34,27 +32,16 @@ describe("NewAuthorizationBearerInterceptor", () => {
|
|||||||
{ transport },
|
{ transport },
|
||||||
);
|
);
|
||||||
|
|
||||||
await service.unary(
|
await service.unary(TestService, TestService.methods.unary, undefined, undefined, {}, { value: 9001 });
|
||||||
TestService,
|
|
||||||
TestService.methods.unary,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
{},
|
|
||||||
{ value: 9001 },
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(handler).toBeCalled();
|
expect(handler).toBeCalled();
|
||||||
expect(handler.mock.calls[0][1].requestHeader.get("Authorization")).toBe(
|
expect(handler.mock.calls[0][1].requestHeader.get("Authorization")).toBe("Bearer mytoken");
|
||||||
"Bearer mytoken",
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("do not overwrite the previous authorization token", async () => {
|
test("do not overwrite the previous authorization token", async () => {
|
||||||
const handler = vitest.fn(
|
const handler = vitest.fn((request: Int32Value, context: HandlerContext) => {
|
||||||
(request: Int32Value, context: HandlerContext) => {
|
return { value: request.value.toString() };
|
||||||
return { value: request.value.toString() };
|
});
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
const service = createRouterTransport(
|
const service = createRouterTransport(
|
||||||
({ service }) => {
|
({ service }) => {
|
||||||
@@ -73,8 +60,6 @@ describe("NewAuthorizationBearerInterceptor", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(handler).toBeCalled();
|
expect(handler).toBeCalled();
|
||||||
expect(handler.mock.calls[0][1].requestHeader.get("Authorization")).toBe(
|
expect(handler.mock.calls[0][1].requestHeader.get("Authorization")).toBe("Bearer somethingelse");
|
||||||
"Bearer somethingelse",
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { createClientFor } from "./helpers";
|
import { createClientFor } from "./helpers";
|
||||||
|
|
||||||
import { AdminService } from "@zitadel/proto/zitadel/admin_connect";
|
import { AdminService } from "@zitadel/proto/zitadel/admin_pb";
|
||||||
import { AuthService } from "@zitadel/proto/zitadel/auth_connect";
|
import { AuthService } from "@zitadel/proto/zitadel/auth_pb";
|
||||||
import { ManagementService } from "@zitadel/proto/zitadel/management_connect";
|
import { ManagementService } from "@zitadel/proto/zitadel/management_pb";
|
||||||
import { SystemService } from "@zitadel/proto/zitadel/system_connect";
|
import { SystemService } from "@zitadel/proto/zitadel/system_pb";
|
||||||
|
|
||||||
export const createAdminServiceClient = createClientFor(AdminService);
|
export const createAdminServiceClient = createClientFor(AdminService);
|
||||||
export const createAuthServiceClient = createClientFor(AuthService);
|
export const createAuthServiceClient = createClientFor(AuthService);
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { FeatureService } from "@zitadel/proto/zitadel/feature/v2/feature_service_connect";
|
import { FeatureService } from "@zitadel/proto/zitadel/feature/v2/feature_service_pb";
|
||||||
import { IdentityProviderService } from "@zitadel/proto/zitadel/idp/v2/idp_service_connect";
|
import { IdentityProviderService } from "@zitadel/proto/zitadel/idp/v2/idp_service_pb";
|
||||||
import { RequestContext } from "@zitadel/proto/zitadel/object/v2/object_pb";
|
import { RequestContext } from "@zitadel/proto/zitadel/object/v2/object_pb";
|
||||||
import { OIDCService } from "@zitadel/proto/zitadel/oidc/v2/oidc_service_connect";
|
import { OIDCService } from "@zitadel/proto/zitadel/oidc/v2/oidc_service_pb";
|
||||||
import { OrganizationService } from "@zitadel/proto/zitadel/org/v2/org_service_connect";
|
import { OrganizationService } from "@zitadel/proto/zitadel/org/v2/org_service_pb";
|
||||||
import { SessionService } from "@zitadel/proto/zitadel/session/v2/session_service_connect";
|
import { SessionService } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
||||||
import { SettingsService } from "@zitadel/proto/zitadel/settings/v2/settings_service_connect";
|
import { SettingsService } from "@zitadel/proto/zitadel/settings/v2/settings_service_pb";
|
||||||
import { UserService } from "@zitadel/proto/zitadel/user/v2/user_service_connect";
|
import { UserService } from "@zitadel/proto/zitadel/user/v2/user_service_pb";
|
||||||
|
|
||||||
import { createClientFor } from "./helpers";
|
import { createClientFor } from "./helpers";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { UserSchemaService } from "@zitadel/proto/zitadel/user/schema/v3alpha/user_schema_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_connect";
|
import { UserService } from "@zitadel/proto/zitadel/user/v3alpha/user_service_pb";
|
||||||
import { createClientFor } from "./helpers";
|
import { createClientFor } from "./helpers";
|
||||||
|
|
||||||
export const createUserSchemaServiceClient = createClientFor(UserSchemaService);
|
export const createUserSchemaServiceClient = createClientFor(UserSchemaService);
|
||||||
|
|||||||
@@ -31,8 +31,8 @@
|
|||||||
"@zitadel/client": "workspace:*"
|
"@zitadel/client": "workspace:*"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@connectrpc/connect-node": "^1.4.0",
|
"@connectrpc/connect-node": "^2.0.0-alpha.1",
|
||||||
"@connectrpc/connect-web": "^1.4.0",
|
"@connectrpc/connect-web": "^2.0.0-alpha.1",
|
||||||
"jose": "^5.3.0"
|
"jose": "^5.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"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:
|
managed:
|
||||||
enabled: true
|
enabled: true
|
||||||
plugins:
|
plugins:
|
||||||
- remote: buf.build/connectrpc/es:v1.4.0
|
- remote: buf.build/bufbuild/es:v2.0.0
|
||||||
out: .
|
|
||||||
- remote: buf.build/bufbuild/es:v1.7.2
|
|
||||||
out: .
|
out: .
|
||||||
|
include_imports: true
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
"clean": "rm -rf zitadel && rm -rf .turbo && rm -rf node_modules"
|
"clean": "rm -rf zitadel && rm -rf .turbo && rm -rf node_modules"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@bufbuild/protobuf": "^1.10.0"
|
"@bufbuild/protobuf": "^2.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@bufbuild/buf": "^1.36.0"
|
"@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