From 2f14d7a2fecd6bf3f2f4acf96b7d3c6db07f9f13 Mon Sep 17 00:00:00 2001 From: Anton Kosyakov Date: Wed, 29 Nov 2023 09:36:06 +0100 Subject: [PATCH] decouple gitpod-protocol from public-api (#19151) to prevent rebuilding of components which dependent on gitpod-protocol, but not public-api on an API change --- .gitignore | 1 + components/dashboard/BUILD.yaml | 1 + components/dashboard/package.json | 1 + .../src/service/json-rpc-workspace-client.ts | 2 +- components/dashboard/src/service/metrics.ts | 2 +- .../dashboard/src/service/public-api.ts | 4 +-- .../src/user-settings/Integrations.tsx | 3 +- components/gitpod-protocol/BUILD.yaml | 2 -- components/gitpod-protocol/package.json | 2 +- components/gitpod-protocol/src/index.ts | 1 - .../gitpod-protocol/src/messaging/error.ts | 25 ------------- .../src/metrics.ts | 2 ++ .../public-api/typescript-common/BUILD.yaml | 17 +++++++++ .../public-api/typescript-common/package.json | 36 +++++++++++++++++++ .../typescript-common}/src/auth-providers.ts | 0 .../src/public-api-converter.spec.ts | 17 +++++---- .../src/public-api-converter.ts | 19 ++++------ .../src/public-api-errors.ts | 32 +++++++++++++++++ .../src/public-api-pagination.spec.ts | 0 .../src/public-api-pagination.ts | 0 .../typescript-common/tsconfig.json | 31 ++++++++++++++++ components/public-api/typescript/package.json | 22 ++---------- components/server/BUILD.yaml | 1 + components/server/package.json | 1 + .../src/api/auth-provider-service-api.ts | 2 +- .../src/api/configuration-service-api.ts | 2 +- .../server/src/api/envvar-service-api.ts | 2 +- .../src/api/organization-service-api.ts | 2 +- .../server/src/api/prebuild-service-api.ts | 2 +- components/server/src/api/scm-service-api.ts | 2 +- components/server/src/api/server.ts | 2 +- components/server/src/api/ssh-service-api.ts | 2 +- .../server/src/api/workspace-service-api.ts | 4 +-- components/server/src/errors/index.ts | 2 +- .../server/src/workspace/config-provider.ts | 2 +- .../src/workspace/context-parser-service.ts | 2 +- components/supervisor/frontend/BUILD.yaml | 1 - components/supervisor/frontend/package.json | 1 - .../src/ide/ide-metrics-service-client.ts | 2 +- yarn.lock | 24 ++++--------- 40 files changed, 167 insertions(+), 109 deletions(-) rename components/{public-api/typescript => gitpod-protocol}/src/metrics.ts (99%) create mode 100644 components/public-api/typescript-common/BUILD.yaml create mode 100644 components/public-api/typescript-common/package.json rename components/{gitpod-protocol => public-api/typescript-common}/src/auth-providers.ts (100%) rename components/{gitpod-protocol => public-api/typescript-common}/src/public-api-converter.spec.ts (99%) rename components/{gitpod-protocol => public-api/typescript-common}/src/public-api-converter.ts (98%) create mode 100644 components/public-api/typescript-common/src/public-api-errors.ts rename components/{gitpod-protocol => public-api/typescript-common}/src/public-api-pagination.spec.ts (100%) rename components/{gitpod-protocol => public-api/typescript-common}/src/public-api-pagination.ts (100%) create mode 100644 components/public-api/typescript-common/tsconfig.json diff --git a/.gitignore b/.gitignore index 3ba2c0c3b782e2..038db2a24a1dbf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ dist/ components/*/lib/ components/ee/*/lib/ components/*/typescript/lib/ +components/*/typescript-*/lib/ components/local-app-api/*/lib/ components/supervisor/frontend/lib/ src-gen/ diff --git a/components/dashboard/BUILD.yaml b/components/dashboard/BUILD.yaml index 920211525274de..33a03847ee5e45 100644 --- a/components/dashboard/BUILD.yaml +++ b/components/dashboard/BUILD.yaml @@ -20,6 +20,7 @@ packages: deps: - components/gitpod-protocol:lib - components/public-api/typescript:lib + - components/public-api/typescript-common:lib config: commands: build: diff --git a/components/dashboard/package.json b/components/dashboard/package.json index 0e722aeb564da8..258b0a0667714c 100644 --- a/components/dashboard/package.json +++ b/components/dashboard/package.json @@ -9,6 +9,7 @@ "@connectrpc/connect-web": "1.1.2", "@gitpod/gitpod-protocol": "0.1.5", "@gitpod/public-api": "0.1.5", + "@gitpod/public-api-common": "0.1.5", "@radix-ui/react-dropdown-menu": "^2.0.6", "@radix-ui/react-label": "^2.0.2", "@radix-ui/react-popover": "^1.0.7", diff --git a/components/dashboard/src/service/json-rpc-workspace-client.ts b/components/dashboard/src/service/json-rpc-workspace-client.ts index 29a621139bd45e..51de57128bec62 100644 --- a/components/dashboard/src/service/json-rpc-workspace-client.ts +++ b/components/dashboard/src/service/json-rpc-workspace-client.ts @@ -24,7 +24,7 @@ import { getGitpodService } from "./service"; import { PaginationResponse } from "@gitpod/public-api/lib/gitpod/v1/pagination_pb"; import { generateAsyncGenerator } from "@gitpod/gitpod-protocol/lib/generate-async-generator"; import { WorkspaceInstance } from "@gitpod/gitpod-protocol"; -import { parsePagination } from "@gitpod/gitpod-protocol/lib/public-api-pagination"; +import { parsePagination } from "@gitpod/public-api-common/lib/public-api-pagination"; import { validate as uuidValidate } from "uuid"; import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error"; diff --git a/components/dashboard/src/service/metrics.ts b/components/dashboard/src/service/metrics.ts index 1c1d16e4fb5e35..ae22766d7c582e 100644 --- a/components/dashboard/src/service/metrics.ts +++ b/components/dashboard/src/service/metrics.ts @@ -4,7 +4,7 @@ * See License.AGPL.txt in the project root for license information. */ -import { MetricsReporter } from "@gitpod/public-api/lib/metrics"; +import { MetricsReporter } from "@gitpod/gitpod-protocol/lib/metrics"; import { getExperimentsClient } from "../experiments/client"; import { v4 } from "uuid"; const commit = require("./config.json").commit; diff --git a/components/dashboard/src/service/public-api.ts b/components/dashboard/src/service/public-api.ts index 98af53c83cc6a7..b06c203e2d0943 100644 --- a/components/dashboard/src/service/public-api.ts +++ b/components/dashboard/src/service/public-api.ts @@ -9,7 +9,7 @@ import { MethodKind, ServiceType } from "@bufbuild/protobuf"; import { CallOptions, Code, ConnectError, PromiseClient, createPromiseClient } from "@connectrpc/connect"; import { createConnectTransport } from "@connectrpc/connect-web"; import { Disposable, User } from "@gitpod/gitpod-protocol"; -import { PublicAPIConverter } from "@gitpod/gitpod-protocol/lib/public-api-converter"; +import { PublicAPIConverter } from "@gitpod/public-api-common/lib/public-api-converter"; import { Project as ProtocolProject } from "@gitpod/gitpod-protocol/lib/teams-projects-protocol"; import { HelloService } from "@gitpod/public-api/lib/gitpod/experimental/v1/dummy_connect"; import { OIDCService } from "@gitpod/public-api/lib/gitpod/experimental/v1/oidc_connect"; @@ -21,7 +21,7 @@ import { OrganizationService } from "@gitpod/public-api/lib/gitpod/v1/organizati import { WorkspaceService } from "@gitpod/public-api/lib/gitpod/v1/workspace_connect"; import { ConfigurationService } from "@gitpod/public-api/lib/gitpod/v1/configuration_connect"; import { PrebuildService } from "@gitpod/public-api/lib/gitpod/v1/prebuild_connect"; -import { getMetricsInterceptor } from "@gitpod/public-api/lib/metrics"; +import { getMetricsInterceptor } from "@gitpod/gitpod-protocol/lib/metrics"; import { getExperimentsClient } from "../experiments/client"; import { JsonRpcOrganizationClient } from "./json-rpc-organization-client"; import { JsonRpcWorkspaceClient } from "./json-rpc-workspace-client"; diff --git a/components/dashboard/src/user-settings/Integrations.tsx b/components/dashboard/src/user-settings/Integrations.tsx index 2b3b517969090b..2443e7fec442d2 100644 --- a/components/dashboard/src/user-settings/Integrations.tsx +++ b/components/dashboard/src/user-settings/Integrations.tsx @@ -4,7 +4,8 @@ * See License.AGPL.txt in the project root for license information. */ -import { User, getScopesForAuthProviderType } from "@gitpod/gitpod-protocol"; +import { User } from "@gitpod/gitpod-protocol"; +import { getScopesForAuthProviderType } from "@gitpod/public-api-common/lib/auth-providers"; import { SelectAccountPayload } from "@gitpod/gitpod-protocol/lib/auth"; import { useQuery } from "@tanstack/react-query"; import React, { useCallback, useContext, useEffect, useMemo, useState } from "react"; diff --git a/components/gitpod-protocol/BUILD.yaml b/components/gitpod-protocol/BUILD.yaml index 54d0f6c6062f0b..9882d407b221e3 100644 --- a/components/gitpod-protocol/BUILD.yaml +++ b/components/gitpod-protocol/BUILD.yaml @@ -14,8 +14,6 @@ packages: - .eslintrc - mocha.opts - package.json - deps: - - components/public-api/typescript:lib config: packaging: library yarnLock: ${coreYarnLockBase}/yarn.lock diff --git a/components/gitpod-protocol/package.json b/components/gitpod-protocol/package.json index 32b3708a6eaefd..33801c3c5c4f46 100644 --- a/components/gitpod-protocol/package.json +++ b/components/gitpod-protocol/package.json @@ -59,8 +59,8 @@ "exit": true }, "dependencies": { + "@bufbuild/protobuf": "^1.3.3", "@connectrpc/connect": "1.1.2", - "@gitpod/public-api": "0.1.5", "@types/react": "17.0.32", "abort-controller-x": "^0.4.0", "ajv": "^6.5.4", diff --git a/components/gitpod-protocol/src/index.ts b/components/gitpod-protocol/src/index.ts index f46bb9687720fb..6c6edaa2af2589 100644 --- a/components/gitpod-protocol/src/index.ts +++ b/components/gitpod-protocol/src/index.ts @@ -18,4 +18,3 @@ export * from "./teams-projects-protocol"; export * from "./snapshot-url"; export * from "./webhook-event"; export * from "./redis"; -export * from "./auth-providers"; diff --git a/components/gitpod-protocol/src/messaging/error.ts b/components/gitpod-protocol/src/messaging/error.ts index 0ed66687f80cdd..bb8e57efecfc9e 100644 --- a/components/gitpod-protocol/src/messaging/error.ts +++ b/components/gitpod-protocol/src/messaging/error.ts @@ -5,12 +5,6 @@ */ import { scrubber } from "../util/scrubbing"; -import { PlainMessage } from "@bufbuild/protobuf"; -import { - InvalidGitpodYMLError as InvalidGitpodYMLErrorData, - RepositoryNotFoundError as RepositoryNotFoundErrorData, - RepositoryUnauthorizedError as RepositoryUnauthorizedErrorData, -} from "@gitpod/public-api/lib/gitpod/v1/error_pb"; export class ApplicationError extends Error { constructor(readonly code: ErrorCode, readonly message: string, readonly data?: any) { @@ -27,25 +21,6 @@ export class ApplicationError extends Error { } } -export class RepositoryNotFoundError extends ApplicationError { - constructor(readonly info: PlainMessage) { - // on gRPC we remap to PRECONDITION_FAILED, all error code for backwards compatibility with the dashboard - super(ErrorCodes.NOT_FOUND, "Repository not found.", info); - } -} -export class UnauthorizedRepositoryAccessError extends ApplicationError { - constructor(readonly info: PlainMessage) { - // on gRPC we remap to PRECONDITION_FAILED, all error code for backwards compatibility with the dashboard - super(ErrorCodes.NOT_AUTHENTICATED, "Repository unauthorized.", info); - } -} -export class InvalidGitpodYMLError extends ApplicationError { - constructor(readonly info: PlainMessage) { - // on gRPC we remap to PRECONDITION_FAILED, all error code for backwards compatibility with the dashboard - super(ErrorCodes.INVALID_GITPOD_YML, "Invalid gitpod.yml: " + info.violations.join(","), info); - } -} - export namespace ApplicationError { export function hasErrorCode(e: any): e is Error & { code: ErrorCode; data?: any } { return ErrorCode.is(e["code"]); diff --git a/components/public-api/typescript/src/metrics.ts b/components/gitpod-protocol/src/metrics.ts similarity index 99% rename from components/public-api/typescript/src/metrics.ts rename to components/gitpod-protocol/src/metrics.ts index de0506e818f785..52ea09a95092e0 100644 --- a/components/public-api/typescript/src/metrics.ts +++ b/components/gitpod-protocol/src/metrics.ts @@ -331,6 +331,7 @@ export class MetricsReporter { while (this.pendingRequests.length) { const request = this.pendingRequests.shift(); if (request) { + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.send(request); } } @@ -393,6 +394,7 @@ export class MetricsReporter { [key: string]: string | undefined; }, ): void { + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.asyncReportError(error, data); } diff --git a/components/public-api/typescript-common/BUILD.yaml b/components/public-api/typescript-common/BUILD.yaml new file mode 100644 index 00000000000000..bf7877e032bc1f --- /dev/null +++ b/components/public-api/typescript-common/BUILD.yaml @@ -0,0 +1,17 @@ +packages: + - name: lib + type: yarn + srcs: + - src/** + - package.json + - tsconfig.json + deps: + - components/gitpod-protocol:lib + - components/public-api/typescript:lib + config: + packaging: library + commands: + # leeway executes the build and test step in the wrong order, so we need to call a special script that builds before testing + test: ["yarn", "test:leeway"] + yarnLock: ${coreYarnLockBase}/../yarn.lock + tsconfig: tsconfig.json diff --git a/components/public-api/typescript-common/package.json b/components/public-api/typescript-common/package.json new file mode 100644 index 00000000000000..9a9e5fc9d5b231 --- /dev/null +++ b/components/public-api/typescript-common/package.json @@ -0,0 +1,36 @@ +{ + "name": "@gitpod/public-api-common", + "version": "0.1.5", + "license": "AGPL-3.0", + "files": [ + "lib" + ], + "exports": { + "./lib/*": { + "types": "./lib/*.d.ts", + "import": "./lib/esm/*.js", + "require": "./lib/*.js" + } + }, + "scripts": { + "build": "yarn run build:cjs && yarn run build:esm", + "build:cjs": "tsc", + "build:esm": "tsc --module es2015 --outDir ./lib/esm", + "test": "mocha './**/*.spec.js' --exclude './node_modules/**' --exclude './lib/esm/**' --exit", + "test:leeway": "yarn build && yarn test" + }, + "dependencies": { + "@gitpod/gitpod-protocol": "0.1.5", + "@gitpod/public-api": "0.1.5", + "@connectrpc/connect": "1.1.2", + "@bufbuild/protobuf": "^1.3.3" + }, + "devDependencies": { + "@types/chai-subset": "^1.3.3", + "@types/mocha": "^10.0.1", + "@types/node": "^16.11.6", + "chai": "^4.3.4", + "mocha": "^10.2.0", + "typescript": "~4.4.2" + } +} diff --git a/components/gitpod-protocol/src/auth-providers.ts b/components/public-api/typescript-common/src/auth-providers.ts similarity index 100% rename from components/gitpod-protocol/src/auth-providers.ts rename to components/public-api/typescript-common/src/auth-providers.ts diff --git a/components/gitpod-protocol/src/public-api-converter.spec.ts b/components/public-api/typescript-common/src/public-api-converter.spec.ts similarity index 99% rename from components/gitpod-protocol/src/public-api-converter.spec.ts rename to components/public-api/typescript-common/src/public-api-converter.spec.ts index 3aefe7ec26c5c6..e637e281d6d515 100644 --- a/components/gitpod-protocol/src/public-api-converter.spec.ts +++ b/components/public-api/typescript-common/src/public-api-converter.spec.ts @@ -15,7 +15,11 @@ import { } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb"; import { expect } from "chai"; import { PartialConfiguration, PublicAPIConverter } from "./public-api-converter"; -import { OrgMemberInfo, Project, PrebuildSettings as PrebuildSettingsProtocol } from "./teams-projects-protocol"; +import { + OrgMemberInfo, + Project, + PrebuildSettings as PrebuildSettingsProtocol, +} from "@gitpod/gitpod-protocol/lib/teams-projects-protocol"; import { OrganizationRole } from "@gitpod/public-api/lib/gitpod/v1/organization_pb"; import { BranchMatchingStrategy, @@ -31,7 +35,7 @@ import { UserEnvVarValue, UserSSHPublicKey, WithEnvvarsContext, -} from "./protocol"; +} from "@gitpod/gitpod-protocol/lib/protocol"; import { AuthProvider, AuthProviderDescription, @@ -42,13 +46,8 @@ import { EnvironmentVariableAdmission, UserEnvironmentVariable, } from "@gitpod/public-api/lib/gitpod/v1/envvar_pb"; -import { - ApplicationError, - ErrorCodes, - InvalidGitpodYMLError, - RepositoryNotFoundError, - UnauthorizedRepositoryAccessError, -} from "./messaging/error"; +import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error"; +import { InvalidGitpodYMLError, RepositoryNotFoundError, UnauthorizedRepositoryAccessError } from "./public-api-errors"; import { Code, ConnectError } from "@connectrpc/connect"; import { FailedPreconditionDetails, diff --git a/components/gitpod-protocol/src/public-api-converter.ts b/components/public-api/typescript-common/src/public-api-converter.ts similarity index 98% rename from components/gitpod-protocol/src/public-api-converter.ts rename to components/public-api/typescript-common/src/public-api-converter.ts index eab5c8105bb58b..a33d6ec1adeba5 100644 --- a/components/gitpod-protocol/src/public-api-converter.ts +++ b/components/public-api/typescript-common/src/public-api-converter.ts @@ -58,20 +58,15 @@ import { UserEnvironmentVariable, } from "@gitpod/public-api/lib/gitpod/v1/envvar_pb"; import { SCMToken, SuggestedRepository } from "@gitpod/public-api/lib/gitpod/v1/scm_pb"; -import { ContextURL } from "./context-url"; +import { ContextURL } from "@gitpod/gitpod-protocol/lib/context-url"; import { Prebuild, PrebuildStatus, PrebuildPhase, PrebuildPhase_Phase, } from "@gitpod/public-api/lib/gitpod/v1/prebuild_pb"; -import { - ApplicationError, - ErrorCodes, - InvalidGitpodYMLError, - RepositoryNotFoundError, - UnauthorizedRepositoryAccessError, -} from "./messaging/error"; +import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error"; +import { InvalidGitpodYMLError, RepositoryNotFoundError, UnauthorizedRepositoryAccessError } from "./public-api-errors"; import { AuthProviderEntry as AuthProviderProtocol, AuthProviderInfo, @@ -89,7 +84,7 @@ import { Token, SuggestedRepository as SuggestedRepositoryProtocol, UserSSHPublicKeyValue, -} from "./protocol"; +} from "@gitpod/gitpod-protocol/lib//protocol"; import { OrgMemberInfo, OrgMemberRole, @@ -99,16 +94,16 @@ import { PrebuildWithStatus, Project, Organization as ProtocolOrganization, -} from "./teams-projects-protocol"; +} from "@gitpod/gitpod-protocol/lib//teams-projects-protocol"; import { ConfigurationIdeConfig, PortProtocol, WorkspaceInstance, WorkspaceInstanceConditions, WorkspaceInstancePort, -} from "./workspace-instance"; +} from "@gitpod/gitpod-protocol/lib//workspace-instance"; import { Author, Commit } from "@gitpod/public-api/lib/gitpod/v1/scm_pb"; -import type { DeepPartial } from "./util/deep-partial"; +import type { DeepPartial } from "@gitpod/gitpod-protocol/lib/util/deep-partial"; export type PartialConfiguration = DeepPartial & Pick; diff --git a/components/public-api/typescript-common/src/public-api-errors.ts b/components/public-api/typescript-common/src/public-api-errors.ts new file mode 100644 index 00000000000000..ed6f2dc988a50d --- /dev/null +++ b/components/public-api/typescript-common/src/public-api-errors.ts @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2023 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License.AGPL.txt in the project root for license information. + */ + +import { PlainMessage } from "@bufbuild/protobuf"; +import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error"; +import { + InvalidGitpodYMLError as InvalidGitpodYMLErrorData, + RepositoryNotFoundError as RepositoryNotFoundErrorData, + RepositoryUnauthorizedError as RepositoryUnauthorizedErrorData, +} from "@gitpod/public-api/lib/gitpod/v1/error_pb"; + +export class RepositoryNotFoundError extends ApplicationError { + constructor(readonly info: PlainMessage) { + // on gRPC we remap to PRECONDITION_FAILED, all error code for backwards compatibility with the dashboard + super(ErrorCodes.NOT_FOUND, "Repository not found.", info); + } +} +export class UnauthorizedRepositoryAccessError extends ApplicationError { + constructor(readonly info: PlainMessage) { + // on gRPC we remap to PRECONDITION_FAILED, all error code for backwards compatibility with the dashboard + super(ErrorCodes.NOT_AUTHENTICATED, "Repository unauthorized.", info); + } +} +export class InvalidGitpodYMLError extends ApplicationError { + constructor(readonly info: PlainMessage) { + // on gRPC we remap to PRECONDITION_FAILED, all error code for backwards compatibility with the dashboard + super(ErrorCodes.INVALID_GITPOD_YML, "Invalid gitpod.yml: " + info.violations.join(","), info); + } +} diff --git a/components/gitpod-protocol/src/public-api-pagination.spec.ts b/components/public-api/typescript-common/src/public-api-pagination.spec.ts similarity index 100% rename from components/gitpod-protocol/src/public-api-pagination.spec.ts rename to components/public-api/typescript-common/src/public-api-pagination.spec.ts diff --git a/components/gitpod-protocol/src/public-api-pagination.ts b/components/public-api/typescript-common/src/public-api-pagination.ts similarity index 100% rename from components/gitpod-protocol/src/public-api-pagination.ts rename to components/public-api/typescript-common/src/public-api-pagination.ts diff --git a/components/public-api/typescript-common/tsconfig.json b/components/public-api/typescript-common/tsconfig.json new file mode 100644 index 00000000000000..847b7b462c489b --- /dev/null +++ b/components/public-api/typescript-common/tsconfig.json @@ -0,0 +1,31 @@ +{ + "compilerOptions": { + "rootDir": "src", + "experimentalDecorators": true, + "outDir": "lib", + "declarationDir": "lib", + "lib": [ + "es6", + "esnext.asynciterable", + "DOM" + ], + "strict": true, + "noEmitOnError": false, + "noUnusedLocals": true, + "emitDecoratorMetadata": true, + "strictPropertyInitialization": false, + "downlevelIteration": true, + "module": "CommonJS", + "moduleResolution": "node", + "target": "es6", + "jsx": "react", + "sourceMap": true, + "declaration": true, + "declarationMap": true, + "skipLibCheck": true, + "useUnknownInCatchVariables": false + }, + "include": [ + "src" + ] +} diff --git a/components/public-api/typescript/package.json b/components/public-api/typescript/package.json index f8b985aaa8f8d4..db846cd06f7e6a 100644 --- a/components/public-api/typescript/package.json +++ b/components/public-api/typescript/package.json @@ -28,34 +28,16 @@ "scripts": { "build": "yarn run build:cjs && yarn run build:esm", "build:cjs": "tsc", - "build:esm": "tsc --module es2015 --outDir ./lib/esm", - "watch": "leeway exec --package .:lib --transitive-dependencies --filter-type yarn --components --parallel -- tsc -w --preserveWatchOutput", - "test": "mocha './**/*.spec.ts' --exclude './node_modules/**' --exit", - "test:brk": "yarn test --inspect-brk" - }, - "mocha": { - "require": [ - "ts-node/register", - "reflect-metadata/Reflect", - "source-map-support/register" - ], - "extensions": [ - "ts" - ], - "exit": true + "build:esm": "tsc --module es2015 --outDir ./lib/esm" }, "dependencies": { "@connectrpc/connect-node": "1.1.2", "@connectrpc/connect": "1.1.2", - "@bufbuild/protobuf": "^1.3.3", - "prom-client": "^14.2.0" + "@bufbuild/protobuf": "^1.3.3" }, "devDependencies": { "@connectrpc/protoc-gen-connect-es": "1.1.2", "@bufbuild/protoc-gen-es": "1.3.3", - "@testdeck/mocha": "0.1.2", - "@types/chai": "^4.1.2", - "@types/node": "^16.11.0", "typescript": "~4.4.2" } } diff --git a/components/server/BUILD.yaml b/components/server/BUILD.yaml index 6aba7302a342bf..e11e8c03ff99d4 100644 --- a/components/server/BUILD.yaml +++ b/components/server/BUILD.yaml @@ -17,6 +17,7 @@ packages: - components/usage-api/typescript:lib - components/ide-service-api/typescript:lib - components/public-api/typescript:lib + - components/public-api/typescript-common:lib - components/gitpod-db:dbtest-init - components/spicedb:lib - components/spicedb/typescript:lib diff --git a/components/server/package.json b/components/server/package.json index 7c3030297a861b..d929a3f0ea1cee 100644 --- a/components/server/package.json +++ b/components/server/package.json @@ -55,6 +55,7 @@ "@gitpod/ide-service-api": "0.1.5", "@gitpod/image-builder": "0.1.5", "@gitpod/public-api": "0.1.5", + "@gitpod/public-api-common": "0.1.5", "@gitpod/supervisor-api-grpcweb": "0.1.5", "@gitpod/usage-api": "0.1.5", "@gitpod/ws-manager": "0.1.5", diff --git a/components/server/src/api/auth-provider-service-api.ts b/components/server/src/api/auth-provider-service-api.ts index 9c8749052e587d..a15ceeb0b27926 100644 --- a/components/server/src/api/auth-provider-service-api.ts +++ b/components/server/src/api/auth-provider-service-api.ts @@ -7,7 +7,7 @@ import { HandlerContext, ServiceImpl } from "@connectrpc/connect"; import { AuthProviderService as AuthProviderServiceInterface } from "@gitpod/public-api/lib/gitpod/v1/authprovider_connect"; import { inject, injectable } from "inversify"; -import { PublicAPIConverter } from "@gitpod/gitpod-protocol/lib/public-api-converter"; +import { PublicAPIConverter } from "@gitpod/public-api-common/lib/public-api-converter"; import { CreateAuthProviderRequest, CreateAuthProviderResponse, diff --git a/components/server/src/api/configuration-service-api.ts b/components/server/src/api/configuration-service-api.ts index 1a1891315e6751..731081738a2636 100644 --- a/components/server/src/api/configuration-service-api.ts +++ b/components/server/src/api/configuration-service-api.ts @@ -7,7 +7,7 @@ import { HandlerContext, ServiceImpl } from "@connectrpc/connect"; import { inject, injectable } from "inversify"; import { ConfigurationService as ConfigurationServiceInterface } from "@gitpod/public-api/lib/gitpod/v1/configuration_connect"; -import { PublicAPIConverter, PartialConfiguration } from "@gitpod/gitpod-protocol/lib/public-api-converter"; +import { PublicAPIConverter, PartialConfiguration } from "@gitpod/public-api-common/lib/public-api-converter"; import { ProjectsService } from "../projects/projects-service"; import { CreateConfigurationRequest, diff --git a/components/server/src/api/envvar-service-api.ts b/components/server/src/api/envvar-service-api.ts index a4d4b0a50a3c1a..e1a0207d3753a8 100644 --- a/components/server/src/api/envvar-service-api.ts +++ b/components/server/src/api/envvar-service-api.ts @@ -30,7 +30,7 @@ import { } from "@gitpod/public-api/lib/gitpod/v1/envvar_pb"; import { inject, injectable } from "inversify"; import { EnvVarService } from "../user/env-var-service"; -import { PublicAPIConverter } from "@gitpod/gitpod-protocol/lib/public-api-converter"; +import { PublicAPIConverter } from "@gitpod/public-api-common/lib/public-api-converter"; import { ProjectEnvVarWithValue, UserEnvVarValue } from "@gitpod/gitpod-protocol"; import { WorkspaceService } from "../workspace/workspace-service"; import { ctxUserId } from "../util/request-context"; diff --git a/components/server/src/api/organization-service-api.ts b/components/server/src/api/organization-service-api.ts index c5d44fa7569463..bc164d38b573fd 100644 --- a/components/server/src/api/organization-service-api.ts +++ b/components/server/src/api/organization-service-api.ts @@ -36,7 +36,7 @@ import { UpdateOrganizationSettingsResponse, ListOrganizationsRequest_Scope, } from "@gitpod/public-api/lib/gitpod/v1/organization_pb"; -import { PublicAPIConverter } from "@gitpod/gitpod-protocol/lib/public-api-converter"; +import { PublicAPIConverter } from "@gitpod/public-api-common/lib/public-api-converter"; import { OrganizationService } from "../orgs/organization-service"; import { OrganizationSettings as ProtocolOrganizationSettings } from "@gitpod/gitpod-protocol"; import { PaginationResponse } from "@gitpod/public-api/lib/gitpod/v1/pagination_pb"; diff --git a/components/server/src/api/prebuild-service-api.ts b/components/server/src/api/prebuild-service-api.ts index 6550b7aae785a2..99f05f67da7fc3 100644 --- a/components/server/src/api/prebuild-service-api.ts +++ b/components/server/src/api/prebuild-service-api.ts @@ -5,7 +5,7 @@ */ import { ServiceImpl } from "@connectrpc/connect"; -import { PublicAPIConverter } from "@gitpod/gitpod-protocol/lib/public-api-converter"; +import { PublicAPIConverter } from "@gitpod/public-api-common/lib/public-api-converter"; import { PrebuildService as PrebuildServiceInterface } from "@gitpod/public-api/lib/gitpod/v1/prebuild_connect"; import { GetPrebuildRequest, diff --git a/components/server/src/api/scm-service-api.ts b/components/server/src/api/scm-service-api.ts index 5e1488add0b7fb..87e3e961924ff9 100644 --- a/components/server/src/api/scm-service-api.ts +++ b/components/server/src/api/scm-service-api.ts @@ -7,7 +7,7 @@ import { HandlerContext, ServiceImpl } from "@connectrpc/connect"; import { SCMService as ScmServiceInterface } from "@gitpod/public-api/lib/gitpod/v1/scm_connect"; import { inject, injectable } from "inversify"; -import { PublicAPIConverter } from "@gitpod/gitpod-protocol/lib/public-api-converter"; +import { PublicAPIConverter } from "@gitpod/public-api-common/lib/public-api-converter"; import { ScmService } from "../scm/scm-service"; import { GuessTokenScopesRequest, diff --git a/components/server/src/api/server.ts b/components/server/src/api/server.ts index 16f6d00cad4b0e..9003aa067dcc52 100644 --- a/components/server/src/api/server.ts +++ b/components/server/src/api/server.ts @@ -8,7 +8,7 @@ import { MethodKind, ServiceType } from "@bufbuild/protobuf"; import { Code, ConnectError, ConnectRouter, HandlerContext, ServiceImpl } from "@connectrpc/connect"; import { expressConnectMiddleware } from "@connectrpc/connect-express"; import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error"; -import { PublicAPIConverter } from "@gitpod/gitpod-protocol/lib/public-api-converter"; +import { PublicAPIConverter } from "@gitpod/public-api-common/lib/public-api-converter"; import { log } from "@gitpod/gitpod-protocol/lib/util/logging"; import { HelloService } from "@gitpod/public-api/lib/gitpod/experimental/v1/dummy_connect"; import { StatsService } from "@gitpod/public-api/lib/gitpod/experimental/v1/stats_connect"; diff --git a/components/server/src/api/ssh-service-api.ts b/components/server/src/api/ssh-service-api.ts index f7a84dfdeb5477..b22d5522ddf7ea 100644 --- a/components/server/src/api/ssh-service-api.ts +++ b/components/server/src/api/ssh-service-api.ts @@ -8,7 +8,7 @@ import { HandlerContext, ServiceImpl } from "@connectrpc/connect"; import { SSHService as SSHServiceInterface } from "@gitpod/public-api/lib/gitpod/v1/ssh_connect"; import { inject, injectable } from "inversify"; import { SSHKeyService } from "../user/sshkey-service"; -import { PublicAPIConverter } from "@gitpod/gitpod-protocol/lib/public-api-converter"; +import { PublicAPIConverter } from "@gitpod/public-api-common/lib/public-api-converter"; import { CreateSSHPublicKeyRequest, CreateSSHPublicKeyResponse, diff --git a/components/server/src/api/workspace-service-api.ts b/components/server/src/api/workspace-service-api.ts index 59b9d5ad27aa45..5c6a5440f63e6a 100644 --- a/components/server/src/api/workspace-service-api.ts +++ b/components/server/src/api/workspace-service-api.ts @@ -20,9 +20,9 @@ import { } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb"; import { inject, injectable } from "inversify"; import { WorkspaceService } from "../workspace/workspace-service"; -import { PublicAPIConverter } from "@gitpod/gitpod-protocol/lib/public-api-converter"; +import { PublicAPIConverter } from "@gitpod/public-api-common/lib/public-api-converter"; import { ctxClientRegion, ctxSignal, ctxUserId } from "../util/request-context"; -import { parsePagination } from "@gitpod/gitpod-protocol/lib/public-api-pagination"; +import { parsePagination } from "@gitpod/public-api-common/lib/public-api-pagination"; import { PaginationResponse } from "@gitpod/public-api/lib/gitpod/v1/pagination_pb"; import { validate as uuidValidate } from "uuid"; import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error"; diff --git a/components/server/src/errors/index.ts b/components/server/src/errors/index.ts index 9d85b7d1edbccc..9e1b9468cf4c79 100644 --- a/components/server/src/errors/index.ts +++ b/components/server/src/errors/index.ts @@ -8,7 +8,7 @@ import { User, Token } from "@gitpod/gitpod-protocol"; import { RepositoryNotFoundError, UnauthorizedRepositoryAccessError, -} from "@gitpod/gitpod-protocol/lib/messaging/error"; +} from "@gitpod/public-api-common/lib/public-api-errors"; export namespace NotFoundError { export async function create(token: Token | undefined, user: User, host: string, owner: string, repoName: string) { diff --git a/components/server/src/workspace/config-provider.ts b/components/server/src/workspace/config-provider.ts index 141288ec528189..b5993acecc73b5 100644 --- a/components/server/src/workspace/config-provider.ts +++ b/components/server/src/workspace/config-provider.ts @@ -32,7 +32,7 @@ import { TraceContext } from "@gitpod/gitpod-protocol/lib/util/tracing"; import { Config } from "../config"; import { EntitlementService } from "../billing/entitlement-service"; import { TeamDB } from "@gitpod/gitpod-db/lib"; -import { InvalidGitpodYMLError } from "@gitpod/gitpod-protocol/lib/messaging/error"; +import { InvalidGitpodYMLError } from "@gitpod/public-api-common/lib/public-api-errors"; const POD_PATH_WORKSPACE_BASE = "/workspace"; diff --git a/components/server/src/workspace/context-parser-service.ts b/components/server/src/workspace/context-parser-service.ts index c44aba962094ba..f25cef37a85a84 100644 --- a/components/server/src/workspace/context-parser-service.ts +++ b/components/server/src/workspace/context-parser-service.ts @@ -10,7 +10,7 @@ import { HostContextProvider } from "../auth/host-context-provider"; import { IPrefixContextParser, IContextParser } from "./context-parser"; import { TraceContext } from "@gitpod/gitpod-protocol/lib/util/tracing"; import { ConfigProvider } from "./config-provider"; -import { InvalidGitpodYMLError } from "@gitpod/gitpod-protocol/lib/messaging/error"; +import { InvalidGitpodYMLError } from "@gitpod/public-api-common/lib/public-api-errors"; @injectable() export class ContextParser { diff --git a/components/supervisor/frontend/BUILD.yaml b/components/supervisor/frontend/BUILD.yaml index 68d7404b6e08c2..832d0fe9136c3b 100644 --- a/components/supervisor/frontend/BUILD.yaml +++ b/components/supervisor/frontend/BUILD.yaml @@ -12,7 +12,6 @@ packages: - components/gitpod-protocol:lib - components/supervisor-api/typescript-grpc:lib - components/ide-metrics-api/typescript-grpcweb:lib - - components/public-api/typescript:lib config: dontTest: true yarnLock: ${coreYarnLockBase}/../yarn.lock diff --git a/components/supervisor/frontend/package.json b/components/supervisor/frontend/package.json index 1d687900a46219..6951b6ff39c39c 100644 --- a/components/supervisor/frontend/package.json +++ b/components/supervisor/frontend/package.json @@ -5,7 +5,6 @@ "version": "0.0.0", "dependencies": { "@gitpod/gitpod-protocol": "0.1.5", - "@gitpod/public-api": "0.1.5", "@gitpod/supervisor-api-grpc": "0.1.5", "buffer": "^4.3.0", "crypto-browserify": "3.12.0", diff --git a/components/supervisor/frontend/src/ide/ide-metrics-service-client.ts b/components/supervisor/frontend/src/ide/ide-metrics-service-client.ts index 5cf652ae0c8ac5..5509ddafc91839 100644 --- a/components/supervisor/frontend/src/ide/ide-metrics-service-client.ts +++ b/components/supervisor/frontend/src/ide/ide-metrics-service-client.ts @@ -8,7 +8,7 @@ import { serverUrl, workspaceUrl } from "../shared/urls"; const commit = require("../../config.json").commit; import { v4 } from "uuid"; -import { MetricsReporter } from "@gitpod/public-api/lib/metrics"; +import { MetricsReporter } from "@gitpod/gitpod-protocol/lib/metrics"; export const metricsReporter = new MetricsReporter({ gitpodUrl: serverUrl.toString(), diff --git a/yarn.lock b/yarn.lock index 00f040be3d8f56..9a3adfa8008cae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1511,9 +1511,9 @@ integrity sha512-P6omY1zv5MItm93kLM8s2vr1HICJH8v0dvddDhysbIuZ+vcjOHg5Zbkf1mTkcmi2JA9oBG2anOkRnW8WJTS8Og== "@fastify/busboy@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.0.0.tgz#f22824caff3ae506b18207bad4126dbc6ccdb6b8" - integrity sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ== + version "2.1.0" + resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.0.tgz#0709e9f4cb252351c609c6e6d8d6779a8d25edff" + integrity sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA== "@floating-ui/core@^1.4.2": version "1.5.0" @@ -3129,23 +3129,11 @@ "@tanstack/query-core" "4.29.19" use-sync-external-store "^1.2.0" -"@testdeck/core@^0.1.2": - version "0.1.2" - resolved "https://registry.npmjs.org/@testdeck/core/-/core-0.1.2.tgz" - integrity sha512-rggcFQqSejqtkqK1JcwZE/utD4oNsM1JMHwrYxH1PKYx0uL2cMs0Q4zMVLKw0oacIASCfkIUSdXx7rDNdCDlvA== - "@testdeck/core@^0.3.3": version "0.3.3" resolved "https://registry.yarnpkg.com/@testdeck/core/-/core-0.3.3.tgz#0e0fad0de65c661dbb26d61726b0950a1c3bbaa4" integrity sha512-yu1yh7yluqnNDLe6Z18/y7kcmxBBEdfZAg3msG8covKkYPRbsCVr1+HmxReqJMKgeoh/UoEW1pi9Sz0fb/GYVQ== -"@testdeck/mocha@0.1.2": - version "0.1.2" - resolved "https://registry.npmjs.org/@testdeck/mocha/-/mocha-0.1.2.tgz" - integrity sha512-yn3OkFUlO9EkdBkDV08bPV0r26U2FC/8KvU9FdiS0ligOsjB5Ry4sp3eUQJAFxjrGJBpih0t7rZ/GzdsgCv/EQ== - dependencies: - "@testdeck/core" "^0.1.2" - "@testdeck/mocha@^0.3.3": version "0.3.3" resolved "https://registry.yarnpkg.com/@testdeck/mocha/-/mocha-0.3.3.tgz#e671495b9ce4c2813140313eae22508b9e5e13d8" @@ -15035,9 +15023,9 @@ undici-types@~5.26.4: integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== undici@^5.25.4: - version "5.25.4" - resolved "https://registry.yarnpkg.com/undici/-/undici-5.25.4.tgz#7d8ef81d94f84cd384986271e5e5599b6dff4296" - integrity sha512-450yJxT29qKMf3aoudzFpIciqpx6Pji3hEWaXqXmanbXF58LTAGCKxcJjxMXWu3iG+Mudgo3ZUfDB6YDFd/dAw== + version "5.28.1" + resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.1.tgz#1052d37bd1a2e8cf3e188d7caebff833fdc06fa7" + integrity sha512-xcIIvj1LOQH9zAL54iWFkuDEaIVEjLrru7qRpa3GrEEHk6OBhb/LycuUY2m7VCcTuDeLziXCxobQVyKExyGeIA== dependencies: "@fastify/busboy" "^2.0.0"