@gitpod/gitpod-protocol 0.1.5-me-test04251.0 → 0.1.5-me-fixheader.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/data/gitpod-schema.json +73 -115
- package/lib/accounting-protocol.d.ts +9 -1
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +13 -2
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +8 -1
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +1 -1
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +1 -1
- package/lib/analytics.js +1 -1
- package/lib/attribution.d.ts +23 -0
- package/lib/attribution.d.ts.map +1 -0
- package/lib/attribution.js +50 -0
- package/lib/attribution.js.map +1 -0
- package/lib/auth.d.ts +1 -1
- package/lib/auth.js +1 -1
- package/lib/billing-mode.d.ts +41 -0
- package/lib/billing-mode.d.ts.map +1 -0
- package/lib/billing-mode.js +44 -0
- package/lib/billing-mode.js.map +1 -0
- package/lib/blocked-repositories-protocol.d.ts +13 -0
- package/lib/blocked-repositories-protocol.d.ts.map +1 -0
- package/lib/blocked-repositories-protocol.js +8 -0
- package/lib/blocked-repositories-protocol.js.map +1 -0
- package/lib/context-url.d.ts +1 -1
- package/lib/context-url.js +2 -2
- package/lib/context-url.js.map +1 -1
- package/lib/context-url.spec.d.ts +1 -1
- package/lib/context-url.spec.js +1 -1
- package/lib/encryption/container-module.d.ts +1 -1
- package/lib/encryption/container-module.js +1 -1
- package/lib/encryption/encryption-engine.d.ts +1 -1
- package/lib/encryption/encryption-engine.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.js +4 -4
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.d.ts +1 -1
- package/lib/encryption/encryption-engine.spec.js +2 -2
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.d.ts +1 -1
- package/lib/encryption/encryption-service.js +1 -1
- package/lib/encryption/key-provider.d.ts +1 -1
- package/lib/encryption/key-provider.js +2 -2
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +1 -1
- package/lib/env.js +1 -1
- package/lib/experiments/always-default.d.ts +8 -0
- package/lib/experiments/always-default.d.ts.map +1 -0
- package/lib/experiments/always-default.js +20 -0
- package/lib/experiments/always-default.js.map +1 -0
- package/lib/experiments/configcat-server.d.ts +10 -0
- package/lib/experiments/configcat-server.d.ts.map +1 -0
- package/lib/experiments/configcat-server.js +36 -0
- package/lib/experiments/configcat-server.js.map +1 -0
- package/lib/experiments/configcat.d.ts +21 -0
- package/lib/experiments/configcat.d.ts.map +1 -0
- package/lib/experiments/configcat.js +51 -0
- package/lib/experiments/configcat.js.map +1 -0
- package/lib/experiments/types.d.ts +22 -0
- package/lib/experiments/types.d.ts.map +1 -0
- package/lib/experiments/types.js +10 -0
- package/lib/experiments/types.js.map +1 -0
- package/lib/gitpod-file-parser.d.ts +1 -1
- package/lib/gitpod-file-parser.js +1 -1
- package/lib/gitpod-file-parser.spec.d.ts +1 -1
- package/lib/gitpod-file-parser.spec.js +1 -1
- package/lib/gitpod-service.d.ts +40 -22
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +22 -9
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +1 -1
- package/lib/headless-workspace-log.js +1 -1
- package/lib/ide-frontend-service.d.ts +1 -1
- package/lib/ide-frontend-service.js +1 -1
- package/lib/ide-protocol.d.ts +9 -1
- package/lib/ide-protocol.d.ts.map +1 -1
- package/lib/ide-protocol.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +4 -1
- package/lib/installation-admin-protocol.d.ts.map +1 -1
- package/lib/installation-admin-protocol.js +2 -1
- package/lib/installation-admin-protocol.js.map +1 -1
- package/lib/license-protocol.d.ts +8 -1
- package/lib/license-protocol.d.ts.map +1 -1
- package/lib/license-protocol.js +1 -1
- package/lib/license-protocol.js.map +1 -1
- package/lib/messaging/browser/window-connection.d.ts +1 -1
- package/lib/messaging/browser/window-connection.js +1 -1
- package/lib/messaging/client-call-metrics.d.ts +2 -18
- package/lib/messaging/client-call-metrics.d.ts.map +1 -1
- package/lib/messaging/client-call-metrics.js +2 -3
- package/lib/messaging/client-call-metrics.js.map +1 -1
- package/lib/messaging/error.d.ts +7 -2
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +14 -4
- package/lib/messaging/error.js.map +1 -1
- package/lib/oss-allowlist.d.ts +1 -1
- package/lib/oss-allowlist.js +1 -1
- package/lib/payment-protocol.d.ts +1 -1
- package/lib/payment-protocol.js +1 -1
- package/lib/permission.d.ts +1 -1
- package/lib/permission.js +1 -1
- package/lib/plans.d.ts +2 -1
- package/lib/plans.d.ts.map +1 -1
- package/lib/plans.js +7 -3
- package/lib/plans.js.map +1 -1
- package/lib/protocol.d.ts +112 -21
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +175 -12
- package/lib/protocol.js.map +1 -1
- package/lib/protocol.spec.d.ts +7 -0
- package/lib/protocol.spec.d.ts.map +1 -0
- package/lib/protocol.spec.js +127 -0
- package/lib/protocol.spec.js.map +1 -0
- package/lib/snapshot-url.d.ts +1 -1
- package/lib/snapshot-url.js +1 -1
- package/lib/snapshot-url.spec.d.ts +1 -1
- package/lib/snapshot-url.spec.js +1 -1
- package/lib/team-subscription-protocol.d.ts +18 -1
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +17 -2
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +15 -2
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js +1 -1
- package/lib/teams-projects-protocol.js.map +1 -1
- package/lib/typings/globals.d.ts +1 -1
- package/lib/typings/globals.js +1 -1
- package/lib/usage.d.ts +61 -0
- package/lib/usage.d.ts.map +1 -0
- package/lib/usage.js +14 -0
- package/lib/usage.js.map +1 -0
- package/lib/util/analytics.d.ts +1 -1
- package/lib/util/analytics.js +1 -1
- package/lib/util/async-iterator.d.ts +1 -1
- package/lib/util/async-iterator.js +1 -1
- package/lib/util/cancelable.d.ts +1 -1
- package/lib/util/cancelable.js +1 -1
- package/lib/util/date-time.d.ts +1 -1
- package/lib/util/date-time.js +1 -1
- package/lib/util/debug-app.d.ts +25 -0
- package/lib/util/debug-app.d.ts.map +1 -0
- package/lib/util/debug-app.js +100 -0
- package/lib/util/debug-app.js.map +1 -0
- package/lib/util/deep-partial.d.ts +1 -1
- package/lib/util/deep-partial.js +1 -1
- package/lib/util/deferred.d.ts +1 -1
- package/lib/util/deferred.js +1 -1
- package/lib/util/garbage-collected-cache.d.ts +1 -1
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +6 -1
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts +1 -1
- package/lib/util/generate-workspace-id.js +1 -1
- package/lib/util/generate-workspace-id.spec.d.ts +1 -1
- package/lib/util/generate-workspace-id.spec.js +1 -1
- package/lib/util/gitpod-cookie.d.ts +1 -1
- package/lib/util/gitpod-cookie.js +1 -1
- package/lib/util/gitpod-host-url.d.ts +4 -1
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +19 -1
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts +1 -1
- package/lib/util/gitpod-host-url.spec.js +1 -1
- package/lib/util/grpc.d.ts +20 -1
- package/lib/util/grpc.d.ts.map +1 -1
- package/lib/util/grpc.js +74 -2
- package/lib/util/grpc.js.map +1 -1
- package/lib/util/jaeger-client-types.d.ts +1 -1
- package/lib/util/jaeger-client-types.js +1 -1
- package/lib/util/logging.d.ts +1 -1
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +9 -2
- package/lib/util/logging.js.map +1 -1
- package/lib/util/logging.spec.d.ts +7 -0
- package/lib/util/logging.spec.d.ts.map +1 -0
- package/lib/util/logging.spec.js +52 -0
- package/lib/util/logging.spec.js.map +1 -0
- package/lib/util/make-link.d.ts +1 -1
- package/lib/util/make-link.js +1 -1
- package/lib/util/nice-grpc.d.ts +9 -0
- package/lib/util/nice-grpc.d.ts.map +1 -0
- package/lib/util/nice-grpc.js +119 -0
- package/lib/util/nice-grpc.js.map +1 -0
- package/lib/util/parse-workspace-id.d.ts +1 -1
- package/lib/util/parse-workspace-id.js +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +1 -1
- package/lib/util/parse-workspace-id.spec.js +1 -1
- package/lib/util/queue.d.ts +1 -1
- package/lib/util/queue.js +1 -1
- package/lib/util/queue.spec.d.ts +1 -1
- package/lib/util/queue.spec.js +1 -1
- package/lib/util/repeat.d.ts +1 -1
- package/lib/util/repeat.js +1 -1
- package/lib/util/semaphore.d.ts +1 -1
- package/lib/util/semaphore.js +1 -1
- package/lib/util/skip-if.d.ts +1 -1
- package/lib/util/skip-if.js +1 -1
- package/lib/util/timeutil.d.ts +3 -1
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +14 -2
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.d.ts +3 -1
- package/lib/util/timeutil.spec.d.ts.map +1 -1
- package/lib/util/timeutil.spec.js +35 -1
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +1 -1
- package/lib/util/tracing.js +1 -1
- package/lib/util/tracing.spec.d.ts +1 -1
- package/lib/util/tracing.spec.js +1 -1
- package/lib/util/workspace-port-authentication.d.ts +1 -1
- package/lib/util/workspace-port-authentication.js +1 -1
- package/lib/webhook-event.d.ts +44 -0
- package/lib/webhook-event.d.ts.map +1 -0
- package/lib/webhook-event.js +8 -0
- package/lib/webhook-event.js.map +1 -0
- package/lib/workspace-class.d.ts +14 -0
- package/lib/workspace-class.d.ts.map +1 -0
- package/lib/workspace-class.js +8 -0
- package/lib/workspace-class.js.map +1 -0
- package/lib/workspace-cluster.d.ts +7 -8
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +1 -1
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +14 -2
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/workspace-instance.js +1 -1
- package/lib/wsready.d.ts +1 -1
- package/lib/wsready.js +2 -2
- package/package.json +14 -6
- package/pkg-yarn.lock +10 -5
- package/provenance-bundle.jsonl +1 -1
- package/src/accounting-protocol.ts +14 -1
- package/src/admin-protocol.ts +11 -1
- package/src/analytics.ts +1 -1
- package/src/attribution.ts +59 -0
- package/src/auth.ts +1 -1
- package/src/billing-mode.ts +77 -0
- package/src/blocked-repositories-protocol.ts +13 -0
- package/src/context-url.spec.ts +1 -1
- package/src/context-url.ts +2 -2
- package/src/encryption/container-module.ts +1 -1
- package/src/encryption/encryption-engine.spec.ts +2 -2
- package/src/encryption/encryption-engine.ts +8 -4
- package/src/encryption/encryption-service.ts +1 -1
- package/src/encryption/key-provider.ts +2 -2
- package/src/env.ts +1 -1
- package/src/experiments/always-default.ts +24 -0
- package/src/experiments/configcat-server.ts +41 -0
- package/src/experiments/configcat.ts +56 -0
- package/src/experiments/types.ts +34 -0
- package/src/gitpod-file-parser.spec.ts +1 -1
- package/src/gitpod-file-parser.ts +1 -1
- package/src/gitpod-service.ts +76 -30
- package/src/headless-workspace-log.ts +1 -1
- package/src/ide-frontend-service.ts +1 -1
- package/src/ide-protocol.ts +11 -1
- package/src/index.ts +2 -2
- package/src/installation-admin-protocol.ts +4 -1
- package/src/license-protocol.ts +8 -1
- package/src/messaging/browser/window-connection.ts +1 -1
- package/src/messaging/client-call-metrics.ts +2 -21
- package/src/messaging/error.ts +20 -5
- package/src/oss-allowlist.ts +1 -1
- package/src/payment-protocol.ts +1 -1
- package/src/permission.ts +1 -1
- package/src/plans.ts +7 -3
- package/src/protocol.spec.ts +97 -0
- package/src/protocol.ts +270 -27
- package/src/snapshot-url.spec.ts +1 -1
- package/src/snapshot-url.ts +1 -1
- package/src/team-subscription-protocol.ts +28 -1
- package/src/teams-projects-protocol.ts +16 -2
- package/src/typings/globals.ts +1 -1
- package/src/usage.ts +71 -0
- package/src/util/analytics.ts +1 -1
- package/src/util/async-iterator.ts +1 -1
- package/src/util/cancelable.ts +1 -1
- package/src/util/date-time.ts +1 -1
- package/src/util/debug-app.ts +81 -0
- package/src/util/deep-partial.ts +1 -1
- package/src/util/deferred.ts +1 -1
- package/src/util/garbage-collected-cache.ts +6 -1
- package/src/util/generate-workspace-id.spec.ts +1 -1
- package/src/util/generate-workspace-id.ts +1 -1
- package/src/util/gitpod-cookie.ts +1 -1
- package/src/util/gitpod-host-url.spec.ts +1 -1
- package/src/util/gitpod-host-url.ts +22 -1
- package/src/util/grpc.ts +90 -1
- package/src/util/jaeger-client-types.ts +1 -1
- package/src/util/logging.spec.ts +23 -0
- package/src/util/logging.ts +12 -3
- package/src/util/make-link.ts +1 -1
- package/src/util/nice-grpc.ts +93 -0
- package/src/util/parse-workspace-id.spec.ts +1 -1
- package/src/util/parse-workspace-id.ts +1 -1
- package/src/util/queue.spec.ts +1 -1
- package/src/util/queue.ts +1 -1
- package/src/util/repeat.ts +1 -1
- package/src/util/semaphore.ts +1 -1
- package/src/util/skip-if.ts +1 -1
- package/src/util/timeutil.spec.ts +29 -2
- package/src/util/timeutil.ts +13 -1
- package/src/util/tracing.spec.ts +1 -1
- package/src/util/tracing.ts +1 -1
- package/src/util/workspace-port-authentication.ts +1 -1
- package/src/webhook-event.ts +55 -0
- package/src/workspace-class.ts +14 -0
- package/src/workspace-cluster.ts +7 -5
- package/src/workspace-instance.ts +26 -2
- package/src/wsready.ts +2 -2
- package/lib/email-protocol.d.ts +0 -49
- package/lib/email-protocol.d.ts.map +0 -1
- package/lib/email-protocol.js +0 -28
- package/lib/email-protocol.js.map +0 -1
- package/src/email-protocol.ts +0 -65
package/src/protocol.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { WorkspaceInstance, PortVisibility } from "./workspace-instance";
|
|
8
8
|
import { RoleOrPermission } from "./permission";
|
|
9
9
|
import { Project } from "./teams-projects-protocol";
|
|
10
10
|
import { createHash } from "crypto";
|
|
11
|
+
import { AttributionId } from "./attribution";
|
|
11
12
|
|
|
12
13
|
export interface UserInfo {
|
|
13
14
|
name?: string;
|
|
@@ -45,6 +46,15 @@ export interface User {
|
|
|
45
46
|
markedDeleted?: boolean;
|
|
46
47
|
|
|
47
48
|
additionalData?: AdditionalUserData;
|
|
49
|
+
|
|
50
|
+
// Identifies an explicit team or user ID to which all the user's workspace usage should be attributed to (e.g. for billing purposes)
|
|
51
|
+
usageAttributionId?: string;
|
|
52
|
+
|
|
53
|
+
// The last time this user got verified somehow. The user is not verified if this is empty.
|
|
54
|
+
lastVerificationTime?: string;
|
|
55
|
+
|
|
56
|
+
// The phone number used for the last phone verification.
|
|
57
|
+
verificationPhoneNumber?: string;
|
|
48
58
|
}
|
|
49
59
|
|
|
50
60
|
export namespace User {
|
|
@@ -70,11 +80,14 @@ export namespace User {
|
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
/**
|
|
73
|
-
*
|
|
83
|
+
* Returns the stored email or if it doesn't exist returns the primaryEmail of the first identity this user signed up with.
|
|
74
84
|
* @param user
|
|
75
85
|
* @returns A primaryEmail, or undefined if there is none.
|
|
76
86
|
*/
|
|
77
87
|
export function getPrimaryEmail(user: User): string | undefined {
|
|
88
|
+
if (user.additionalData?.profile?.emailAddress) {
|
|
89
|
+
return user.additionalData?.profile?.emailAddress;
|
|
90
|
+
}
|
|
78
91
|
const identities = user.identities.filter((i) => !!i.primaryEmail);
|
|
79
92
|
if (identities.length <= 0) {
|
|
80
93
|
return undefined;
|
|
@@ -95,6 +108,91 @@ export namespace User {
|
|
|
95
108
|
}
|
|
96
109
|
return undefined;
|
|
97
110
|
}
|
|
111
|
+
|
|
112
|
+
export function hasPreferredIde(user: User) {
|
|
113
|
+
return (
|
|
114
|
+
typeof user?.additionalData?.ideSettings?.defaultIde !== "undefined" ||
|
|
115
|
+
typeof user?.additionalData?.ideSettings?.useLatestVersion !== "undefined"
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function isOnboardingUser(user: User) {
|
|
120
|
+
return !hasPreferredIde(user);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function migrationIDESettings(user: User) {
|
|
124
|
+
if (
|
|
125
|
+
!user?.additionalData?.ideSettings ||
|
|
126
|
+
Object.keys(user.additionalData.ideSettings).length === 0 ||
|
|
127
|
+
user.additionalData.ideSettings.settingVersion === "2.0"
|
|
128
|
+
) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const newIDESettings: IDESettings = {
|
|
132
|
+
settingVersion: "2.0",
|
|
133
|
+
};
|
|
134
|
+
const ideSettings = user.additionalData.ideSettings;
|
|
135
|
+
if (ideSettings.useDesktopIde) {
|
|
136
|
+
if (ideSettings.defaultDesktopIde === "code-desktop") {
|
|
137
|
+
newIDESettings.defaultIde = "code-desktop";
|
|
138
|
+
} else if (ideSettings.defaultDesktopIde === "code-desktop-insiders") {
|
|
139
|
+
newIDESettings.defaultIde = "code-desktop";
|
|
140
|
+
newIDESettings.useLatestVersion = true;
|
|
141
|
+
} else {
|
|
142
|
+
newIDESettings.defaultIde = ideSettings.defaultDesktopIde;
|
|
143
|
+
newIDESettings.useLatestVersion = ideSettings.useLatestVersion;
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
const useLatest = ideSettings.defaultIde === "code-latest";
|
|
147
|
+
newIDESettings.defaultIde = "code";
|
|
148
|
+
newIDESettings.useLatestVersion = useLatest;
|
|
149
|
+
}
|
|
150
|
+
user.additionalData.ideSettings = newIDESettings;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function getProfile(user: User): Profile {
|
|
154
|
+
return {
|
|
155
|
+
name: User.getName(user!) || "",
|
|
156
|
+
email: User.getPrimaryEmail(user!) || "",
|
|
157
|
+
company: user?.additionalData?.profile?.companyName,
|
|
158
|
+
avatarURL: user?.avatarUrl,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function setProfile(user: User, profile: Profile): User {
|
|
163
|
+
user.fullName = profile.name;
|
|
164
|
+
user.avatarUrl = profile.avatarURL;
|
|
165
|
+
|
|
166
|
+
if (!user.additionalData) {
|
|
167
|
+
user.additionalData = {};
|
|
168
|
+
}
|
|
169
|
+
if (!user.additionalData.profile) {
|
|
170
|
+
user.additionalData.profile = {};
|
|
171
|
+
}
|
|
172
|
+
user.additionalData.profile.emailAddress = profile.email;
|
|
173
|
+
user.additionalData.profile.companyName = profile.company;
|
|
174
|
+
user.additionalData.profile.lastUpdatedDetailsNudge = new Date().toISOString();
|
|
175
|
+
|
|
176
|
+
return user;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// The actual Profile of a User
|
|
180
|
+
export interface Profile {
|
|
181
|
+
name: string;
|
|
182
|
+
email: string;
|
|
183
|
+
company?: string;
|
|
184
|
+
avatarURL?: string;
|
|
185
|
+
}
|
|
186
|
+
export namespace Profile {
|
|
187
|
+
export function hasChanges(before: Profile, after: Profile) {
|
|
188
|
+
return (
|
|
189
|
+
before.name !== after.name ||
|
|
190
|
+
before.email !== after.email ||
|
|
191
|
+
before.company !== after.company ||
|
|
192
|
+
before.avatarURL !== after.avatarURL
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
98
196
|
}
|
|
99
197
|
|
|
100
198
|
export interface AdditionalUserData {
|
|
@@ -109,9 +207,36 @@ export interface AdditionalUserData {
|
|
|
109
207
|
oauthClientsApproved?: { [key: string]: string };
|
|
110
208
|
// to remember GH Orgs the user installed/updated the GH App for
|
|
111
209
|
knownGitHubOrgs?: string[];
|
|
112
|
-
|
|
113
210
|
// Git clone URL pointing to the user's dotfile repo
|
|
114
211
|
dotfileRepo?: string;
|
|
212
|
+
// preferred workspace classes
|
|
213
|
+
workspaceClasses?: WorkspaceClasses;
|
|
214
|
+
// additional user profile data
|
|
215
|
+
profile?: ProfileDetails;
|
|
216
|
+
}
|
|
217
|
+
export namespace AdditionalUserData {
|
|
218
|
+
export function set(user: User, partialData: Partial<AdditionalUserData>): User {
|
|
219
|
+
if (!user.additionalData) {
|
|
220
|
+
user.additionalData = {
|
|
221
|
+
...partialData,
|
|
222
|
+
};
|
|
223
|
+
} else {
|
|
224
|
+
user.additionalData = {
|
|
225
|
+
...user.additionalData,
|
|
226
|
+
...partialData,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return user;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// The format in which we store User Profiles in
|
|
233
|
+
export interface ProfileDetails {
|
|
234
|
+
// when was the last time the user updated their profile information or has been nudged to do so.
|
|
235
|
+
lastUpdatedDetailsNudge?: string;
|
|
236
|
+
// the user's company name
|
|
237
|
+
companyName?: string;
|
|
238
|
+
// the user's email
|
|
239
|
+
emailAddress?: string;
|
|
115
240
|
}
|
|
116
241
|
|
|
117
242
|
export interface EmailNotificationSettings {
|
|
@@ -130,6 +255,11 @@ export type IDESettings = {
|
|
|
130
255
|
useLatestVersion?: boolean;
|
|
131
256
|
};
|
|
132
257
|
|
|
258
|
+
export interface WorkspaceClasses {
|
|
259
|
+
regular: string;
|
|
260
|
+
prebuild: string;
|
|
261
|
+
}
|
|
262
|
+
|
|
133
263
|
export interface UserPlatform {
|
|
134
264
|
uid: string;
|
|
135
265
|
userAgent: string;
|
|
@@ -156,16 +286,29 @@ export interface UserFeatureSettings {
|
|
|
156
286
|
permanentWSFeatureFlags?: NamedWorkspaceFeatureFlag[];
|
|
157
287
|
}
|
|
158
288
|
|
|
289
|
+
export type BillingTier = "paid" | "free";
|
|
290
|
+
|
|
159
291
|
/**
|
|
160
292
|
* The values of this type MUST MATCH enum values in WorkspaceFeatureFlag from ws-manager/client/core_pb.d.ts
|
|
161
293
|
* If they don't we'll break things during workspace startup.
|
|
162
294
|
*/
|
|
163
295
|
export const WorkspaceFeatureFlags = {
|
|
164
296
|
full_workspace_backup: undefined,
|
|
165
|
-
fixed_resources: undefined,
|
|
166
297
|
persistent_volume_claim: undefined,
|
|
298
|
+
protected_secrets: undefined,
|
|
299
|
+
workspace_class_limiting: undefined,
|
|
300
|
+
workspace_connection_limiting: undefined,
|
|
167
301
|
};
|
|
168
302
|
export type NamedWorkspaceFeatureFlag = keyof typeof WorkspaceFeatureFlags;
|
|
303
|
+
export namespace NamedWorkspaceFeatureFlag {
|
|
304
|
+
export const WORKSPACE_PERSISTED_FEATTURE_FLAGS: NamedWorkspaceFeatureFlag[] = [
|
|
305
|
+
"full_workspace_backup",
|
|
306
|
+
"persistent_volume_claim",
|
|
307
|
+
];
|
|
308
|
+
export function isWorkspacePersisted(ff: NamedWorkspaceFeatureFlag): boolean {
|
|
309
|
+
return WORKSPACE_PERSISTED_FEATTURE_FLAGS.includes(ff);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
169
312
|
|
|
170
313
|
export interface EnvVarWithValue {
|
|
171
314
|
name: string;
|
|
@@ -201,12 +344,18 @@ export namespace UserEnvVar {
|
|
|
201
344
|
if (name.trim() === "") {
|
|
202
345
|
return "Name must not be empty.";
|
|
203
346
|
}
|
|
347
|
+
if (name.length > 255) {
|
|
348
|
+
return "Name too long. Maximum name length is 255 characters.";
|
|
349
|
+
}
|
|
204
350
|
if (!/^[a-zA-Z_]+[a-zA-Z0-9_]*$/.test(name)) {
|
|
205
351
|
return "Name must match /^[a-zA-Z_]+[a-zA-Z0-9_]*$/.";
|
|
206
352
|
}
|
|
207
353
|
if (variable.value.trim() === "") {
|
|
208
354
|
return "Value must not be empty.";
|
|
209
355
|
}
|
|
356
|
+
if (variable.value.length > 32767) {
|
|
357
|
+
return "Value too long. Maximum value length is 32767 characters.";
|
|
358
|
+
}
|
|
210
359
|
if (pattern.trim() === "") {
|
|
211
360
|
return "Scope must not be empty.";
|
|
212
361
|
}
|
|
@@ -309,6 +458,68 @@ export namespace UserEnvVar {
|
|
|
309
458
|
}
|
|
310
459
|
}
|
|
311
460
|
|
|
461
|
+
export interface SSHPublicKeyValue {
|
|
462
|
+
name: string;
|
|
463
|
+
key: string;
|
|
464
|
+
}
|
|
465
|
+
export interface UserSSHPublicKey extends SSHPublicKeyValue {
|
|
466
|
+
id: string;
|
|
467
|
+
key: string;
|
|
468
|
+
userId: string;
|
|
469
|
+
fingerprint: string;
|
|
470
|
+
creationTime: string;
|
|
471
|
+
lastUsedTime?: string;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export type UserSSHPublicKeyValue = Omit<UserSSHPublicKey, "key" | "userId">;
|
|
475
|
+
|
|
476
|
+
export namespace SSHPublicKeyValue {
|
|
477
|
+
export function validate(value: SSHPublicKeyValue): string | undefined {
|
|
478
|
+
if (value.name.length === 0) {
|
|
479
|
+
return "Title must not be empty.";
|
|
480
|
+
}
|
|
481
|
+
if (value.name.length > 255) {
|
|
482
|
+
return "Title too long. Maximum value length is 255 characters.";
|
|
483
|
+
}
|
|
484
|
+
if (value.key.length === 0) {
|
|
485
|
+
return "Key must not be empty.";
|
|
486
|
+
}
|
|
487
|
+
try {
|
|
488
|
+
getData(value);
|
|
489
|
+
} catch (e) {
|
|
490
|
+
return "Key is invalid. You must supply a key in OpenSSH public key format.";
|
|
491
|
+
}
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export function getData(value: SSHPublicKeyValue) {
|
|
496
|
+
// Begins with 'ssh-rsa', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521', 'ssh-ed25519', 'sk-ecdsa-sha2-nistp256@openssh.com', or 'sk-ssh-ed25519@openssh.com'.
|
|
497
|
+
const regex =
|
|
498
|
+
/^(?<type>ssh-rsa|ecdsa-sha2-nistp256|ecdsa-sha2-nistp384|ecdsa-sha2-nistp521|ssh-ed25519|sk-ecdsa-sha2-nistp256@openssh\.com|sk-ssh-ed25519@openssh\.com) (?<key>.*?)( (?<email>.*?))?$/;
|
|
499
|
+
const resultGroup = regex.exec(value.key.trim());
|
|
500
|
+
if (!resultGroup) {
|
|
501
|
+
throw new Error("Key is invalid.");
|
|
502
|
+
}
|
|
503
|
+
return {
|
|
504
|
+
type: resultGroup.groups?.["type"] as string,
|
|
505
|
+
key: resultGroup.groups?.["key"] as string,
|
|
506
|
+
email: resultGroup.groups?.["email"] || undefined,
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
export function getFingerprint(value: SSHPublicKeyValue) {
|
|
511
|
+
const data = getData(value);
|
|
512
|
+
let buf = Buffer.from(data.key, "base64");
|
|
513
|
+
// gitlab style
|
|
514
|
+
// const hash = createHash("md5").update(buf).digest("hex");
|
|
515
|
+
// github style
|
|
516
|
+
const hash = createHash("sha256").update(buf).digest("base64");
|
|
517
|
+
return hash;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export const MAXIMUM_KEY_LENGTH = 5;
|
|
521
|
+
}
|
|
522
|
+
|
|
312
523
|
export interface GitpodToken {
|
|
313
524
|
/** Hash value (SHA256) of the token (primary key). */
|
|
314
525
|
tokenHash: string;
|
|
@@ -428,6 +639,7 @@ export interface PendingGithubEvent {
|
|
|
428
639
|
creationDate: Date;
|
|
429
640
|
type: string;
|
|
430
641
|
event: string;
|
|
642
|
+
deleted: boolean;
|
|
431
643
|
}
|
|
432
644
|
|
|
433
645
|
export interface Snapshot {
|
|
@@ -436,19 +648,19 @@ export interface Snapshot {
|
|
|
436
648
|
availableTime?: string;
|
|
437
649
|
originalWorkspaceId: string;
|
|
438
650
|
bucketId: string;
|
|
439
|
-
layoutData?: string;
|
|
440
651
|
state: SnapshotState;
|
|
441
652
|
message?: string;
|
|
442
653
|
}
|
|
443
654
|
|
|
444
|
-
export
|
|
445
|
-
|
|
446
|
-
export interface LayoutData {
|
|
655
|
+
export interface VolumeSnapshot {
|
|
656
|
+
id: string;
|
|
447
657
|
workspaceId: string;
|
|
448
|
-
|
|
449
|
-
|
|
658
|
+
creationTime: string;
|
|
659
|
+
volumeHandle: string;
|
|
450
660
|
}
|
|
451
661
|
|
|
662
|
+
export type SnapshotState = "pending" | "available" | "error";
|
|
663
|
+
|
|
452
664
|
export interface Workspace {
|
|
453
665
|
id: string;
|
|
454
666
|
creationTime: string;
|
|
@@ -510,7 +722,7 @@ export interface Workspace {
|
|
|
510
722
|
|
|
511
723
|
export type WorkspaceSoftDeletion = "user" | "gc";
|
|
512
724
|
|
|
513
|
-
export type WorkspaceType = "regular" | "prebuild"
|
|
725
|
+
export type WorkspaceType = "regular" | "prebuild";
|
|
514
726
|
|
|
515
727
|
export namespace Workspace {
|
|
516
728
|
export function getFullRepositoryName(ws: Workspace): string | undefined {
|
|
@@ -583,9 +795,12 @@ export interface JetBrainsConfig {
|
|
|
583
795
|
goland?: JetBrainsProductConfig;
|
|
584
796
|
pycharm?: JetBrainsProductConfig;
|
|
585
797
|
phpstorm?: JetBrainsProductConfig;
|
|
798
|
+
rubymine?: JetBrainsProductConfig;
|
|
799
|
+
webstorm?: JetBrainsProductConfig;
|
|
586
800
|
}
|
|
587
801
|
export interface JetBrainsProductConfig {
|
|
588
802
|
prebuilds?: JetBrainsPrebuilds;
|
|
803
|
+
vmoptions?: string;
|
|
589
804
|
}
|
|
590
805
|
export interface JetBrainsPrebuilds {
|
|
591
806
|
version?: "stable" | "latest" | "both";
|
|
@@ -596,6 +811,12 @@ export interface RepositoryCloneInformation {
|
|
|
596
811
|
checkoutLocation?: string;
|
|
597
812
|
}
|
|
598
813
|
|
|
814
|
+
export interface CoreDumpConfig {
|
|
815
|
+
enabled?: boolean;
|
|
816
|
+
softLimit?: number;
|
|
817
|
+
hardLimit?: number;
|
|
818
|
+
}
|
|
819
|
+
|
|
599
820
|
export interface WorkspaceConfig {
|
|
600
821
|
mainConfiguration?: string;
|
|
601
822
|
additionalRepositories?: RepositoryCloneInformation[];
|
|
@@ -608,6 +829,7 @@ export interface WorkspaceConfig {
|
|
|
608
829
|
github?: GithubAppConfig;
|
|
609
830
|
vscode?: VSCodeConfig;
|
|
610
831
|
jetbrains?: JetBrainsConfig;
|
|
832
|
+
coreDump?: CoreDumpConfig;
|
|
611
833
|
|
|
612
834
|
/** deprecated. Enabled by default **/
|
|
613
835
|
experimentalNetwork?: boolean;
|
|
@@ -616,13 +838,12 @@ export interface WorkspaceConfig {
|
|
|
616
838
|
* Where the config object originates from.
|
|
617
839
|
*
|
|
618
840
|
* repo - from the repository
|
|
619
|
-
* project-db - from the "Project" stored in the database
|
|
620
841
|
* definitly-gp - from github.com/gitpod-io/definitely-gp
|
|
621
842
|
* derived - computed based on analyzing the repository
|
|
622
843
|
* additional-content - config comes from additional content, usually provided through the project's configuration
|
|
623
844
|
* default - our static catch-all default config
|
|
624
845
|
*/
|
|
625
|
-
_origin?: "repo" | "
|
|
846
|
+
_origin?: "repo" | "definitely-gp" | "derived" | "additional-content" | "default";
|
|
626
847
|
|
|
627
848
|
/**
|
|
628
849
|
* Set of automatically infered feature flags. That's not something the user can set, but
|
|
@@ -701,7 +922,9 @@ export interface PrebuiltWorkspace {
|
|
|
701
922
|
|
|
702
923
|
export namespace PrebuiltWorkspace {
|
|
703
924
|
export function isDone(pws: PrebuiltWorkspace) {
|
|
704
|
-
return
|
|
925
|
+
return (
|
|
926
|
+
pws.state === "available" || pws.state === "timeout" || pws.state === "aborted" || pws.state === "failed"
|
|
927
|
+
);
|
|
705
928
|
}
|
|
706
929
|
|
|
707
930
|
export function isAvailable(pws: PrebuiltWorkspace) {
|
|
@@ -825,6 +1048,7 @@ export namespace ExternalImageConfigFile {
|
|
|
825
1048
|
|
|
826
1049
|
export interface WorkspaceContext {
|
|
827
1050
|
title: string;
|
|
1051
|
+
ref?: string;
|
|
828
1052
|
/** This contains the URL portion of the contextURL (which might contain other modifiers as well). It's optional because it's not set for older workspaces. */
|
|
829
1053
|
normalizedContextURL?: string;
|
|
830
1054
|
forceCreateNewWorkspace?: boolean;
|
|
@@ -887,13 +1111,16 @@ export namespace SnapshotContext {
|
|
|
887
1111
|
}
|
|
888
1112
|
}
|
|
889
1113
|
|
|
890
|
-
export interface
|
|
891
|
-
actual: WorkspaceContext;
|
|
1114
|
+
export interface WithCommitHistory {
|
|
892
1115
|
commitHistory?: string[];
|
|
893
1116
|
additionalRepositoryCommitHistories?: {
|
|
894
1117
|
cloneUrl: string;
|
|
895
1118
|
commitHistory: string[];
|
|
896
1119
|
}[];
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
export interface StartPrebuildContext extends WorkspaceContext, WithCommitHistory {
|
|
1123
|
+
actual: WorkspaceContext;
|
|
897
1124
|
project?: Project;
|
|
898
1125
|
branch?: string;
|
|
899
1126
|
}
|
|
@@ -937,17 +1164,6 @@ export namespace WithEnvvarsContext {
|
|
|
937
1164
|
}
|
|
938
1165
|
}
|
|
939
1166
|
|
|
940
|
-
export interface WorkspaceProbeContext extends WorkspaceContext {
|
|
941
|
-
responseURL: string;
|
|
942
|
-
responseToken: string;
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
export namespace WorkspaceProbeContext {
|
|
946
|
-
export function is(context: any): context is WorkspaceProbeContext {
|
|
947
|
-
return context && "responseURL" in context && "responseToken" in context;
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
|
|
951
1167
|
export type RefType = "branch" | "tag" | "revision";
|
|
952
1168
|
export namespace RefType {
|
|
953
1169
|
export const getRefType = (commit: Commit): RefType => {
|
|
@@ -987,6 +1203,16 @@ export namespace AdditionalContentContext {
|
|
|
987
1203
|
}
|
|
988
1204
|
}
|
|
989
1205
|
|
|
1206
|
+
export interface OpenPrebuildContext extends WorkspaceContext {
|
|
1207
|
+
openPrebuildID: string;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
export namespace OpenPrebuildContext {
|
|
1211
|
+
export function is(ctx: any): ctx is OpenPrebuildContext {
|
|
1212
|
+
return "openPrebuildID" in ctx;
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
|
|
990
1216
|
export interface CommitContext extends WorkspaceContext, GitCheckoutInfo {
|
|
991
1217
|
/** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
|
|
992
1218
|
cloneUrl?: string;
|
|
@@ -1159,6 +1385,8 @@ export enum CreateWorkspaceMode {
|
|
|
1159
1385
|
UsePrebuild = "use-prebuild",
|
|
1160
1386
|
// SelectIfRunning returns a list of currently running workspaces for the context URL if there are any, otherwise falls back to Default mode
|
|
1161
1387
|
SelectIfRunning = "select-if-running",
|
|
1388
|
+
// UseLastSuccessfulPrebuild returns ...
|
|
1389
|
+
UseLastSuccessfulPrebuild = "use-last-successful-prebuild",
|
|
1162
1390
|
}
|
|
1163
1391
|
|
|
1164
1392
|
export namespace WorkspaceCreationResult {
|
|
@@ -1293,3 +1521,18 @@ export interface Terms {
|
|
|
1293
1521
|
readonly content: string;
|
|
1294
1522
|
readonly formElements?: object;
|
|
1295
1523
|
}
|
|
1524
|
+
|
|
1525
|
+
export interface StripeConfig {
|
|
1526
|
+
individualUsagePriceIds: { [currency: string]: string };
|
|
1527
|
+
teamUsagePriceIds: { [currency: string]: string };
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
export type BillingStrategy = "other" | "stripe";
|
|
1531
|
+
export interface CostCenter {
|
|
1532
|
+
readonly id: AttributionId;
|
|
1533
|
+
/**
|
|
1534
|
+
* Unit: credits
|
|
1535
|
+
*/
|
|
1536
|
+
spendingLimit: number;
|
|
1537
|
+
billingStrategy: BillingStrategy;
|
|
1538
|
+
}
|
package/src/snapshot-url.spec.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { suite, test } from "mocha-typescript";
|
package/src/snapshot-url.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
export interface SnapshotUrl {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { v4 as uuidv4 } from "uuid";
|
|
@@ -33,6 +33,33 @@ export namespace TeamSubscription {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
export interface TeamSubscription2 {
|
|
37
|
+
id: string;
|
|
38
|
+
teamId: string;
|
|
39
|
+
planId: string;
|
|
40
|
+
startDate: string;
|
|
41
|
+
endDate?: string;
|
|
42
|
+
quantity: number;
|
|
43
|
+
/** The Chargebee subscription id */
|
|
44
|
+
paymentReference: string;
|
|
45
|
+
cancellationDate?: string;
|
|
46
|
+
excludeFromMoreResources: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export namespace TeamSubscription2 {
|
|
50
|
+
export const create = (ts2: Omit<TeamSubscription2, "id">): TeamSubscription2 => {
|
|
51
|
+
const withId = ts2 as TeamSubscription2;
|
|
52
|
+
withId.id = uuidv4();
|
|
53
|
+
return withId;
|
|
54
|
+
};
|
|
55
|
+
export const isActive = (ts2: TeamSubscription2, date: string): boolean => {
|
|
56
|
+
return ts2.startDate <= date && (ts2.endDate === undefined || date < ts2.endDate);
|
|
57
|
+
};
|
|
58
|
+
export function isCancelled(s: TeamSubscription2, date: string): boolean {
|
|
59
|
+
return (!!s.cancellationDate && s.cancellationDate < date) || (!!s.endDate && s.endDate < date); // This edge case is meant to handle bad data: If for whatever reason cancellationDate has not been set: treat endDate as such
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
36
63
|
/**
|
|
37
64
|
* A slot represents one unit of a TeamSubscription that gets assigned to one user at a time
|
|
38
65
|
*/
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { PrebuiltWorkspaceState } from "./protocol";
|
|
8
8
|
import { v4 as uuidv4 } from "uuid";
|
|
9
9
|
import { DeepPartial } from "./util/deep-partial";
|
|
10
|
+
import { WebhookEvent } from "./webhook-event";
|
|
10
11
|
|
|
11
12
|
export interface ProjectConfig {
|
|
12
13
|
".gitpod.yml": string;
|
|
@@ -14,6 +15,8 @@ export interface ProjectConfig {
|
|
|
14
15
|
|
|
15
16
|
export interface ProjectSettings {
|
|
16
17
|
useIncrementalPrebuilds?: boolean;
|
|
18
|
+
usePersistentVolumeClaim?: boolean;
|
|
19
|
+
keepOutdatedPrebuildsRunning?: boolean;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
export interface Project {
|
|
@@ -24,7 +27,6 @@ export interface Project {
|
|
|
24
27
|
teamId?: string;
|
|
25
28
|
userId?: string;
|
|
26
29
|
appInstallationId: string;
|
|
27
|
-
config?: ProjectConfig;
|
|
28
30
|
settings?: ProjectSettings;
|
|
29
31
|
creationTime: string;
|
|
30
32
|
/** This is a flag that triggers the HARD DELETION of this entity */
|
|
@@ -150,3 +152,15 @@ export interface TeamMembershipInvite {
|
|
|
150
152
|
/** This is a flag that triggers the HARD DELETION of this entity */
|
|
151
153
|
deleted?: boolean;
|
|
152
154
|
}
|
|
155
|
+
|
|
156
|
+
export interface PrebuildEvent {
|
|
157
|
+
id: string;
|
|
158
|
+
creationTime: string;
|
|
159
|
+
status: WebhookEvent.Status | WebhookEvent.PrebuildStatus;
|
|
160
|
+
message?: string;
|
|
161
|
+
prebuildId?: string;
|
|
162
|
+
projectId?: string;
|
|
163
|
+
cloneUrl?: string;
|
|
164
|
+
branch?: string;
|
|
165
|
+
commit?: string;
|
|
166
|
+
}
|
package/src/typings/globals.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
interface Window {
|
package/src/usage.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
|
|
3
|
+
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { WorkspaceType } from "./protocol";
|
|
8
|
+
|
|
9
|
+
// types below are copied over from components/usage-api/typescript/src/usage/v1/usage_pb.d.ts
|
|
10
|
+
export interface ListUsageRequest {
|
|
11
|
+
attributionId: string;
|
|
12
|
+
from?: number;
|
|
13
|
+
to?: number;
|
|
14
|
+
order: Ordering;
|
|
15
|
+
pagination?: PaginationRequest;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export enum Ordering {
|
|
19
|
+
ORDERING_DESCENDING = 0,
|
|
20
|
+
ORDERING_ASCENDING = 1,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface PaginationRequest {
|
|
24
|
+
perPage: number;
|
|
25
|
+
page: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ListUsageResponse {
|
|
29
|
+
usageEntriesList: Usage[];
|
|
30
|
+
pagination?: PaginationResponse;
|
|
31
|
+
creditsUsed: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface PaginationResponse {
|
|
35
|
+
perPage: number;
|
|
36
|
+
totalPages: number;
|
|
37
|
+
total: number;
|
|
38
|
+
page: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type UsageKind = "workspaceinstance" | "invoice";
|
|
42
|
+
export interface Usage {
|
|
43
|
+
id: string;
|
|
44
|
+
attributionId: string;
|
|
45
|
+
description: string;
|
|
46
|
+
credits: number;
|
|
47
|
+
effectiveTime?: number;
|
|
48
|
+
kind: UsageKind;
|
|
49
|
+
workspaceInstanceId: string;
|
|
50
|
+
draft: boolean;
|
|
51
|
+
metadata: WorkspaceInstanceUsageData | InvoiceUsageData;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// the equivalent golang shape is maintained in `/workspace/gitpod/`components/usage/pkg/db/usage.go`
|
|
55
|
+
export interface WorkspaceInstanceUsageData {
|
|
56
|
+
workspaceId: string;
|
|
57
|
+
workspaceType: WorkspaceType;
|
|
58
|
+
workspaceClass: string;
|
|
59
|
+
contextURL: string;
|
|
60
|
+
startTime: string;
|
|
61
|
+
endTime?: string;
|
|
62
|
+
userId: string;
|
|
63
|
+
userName: string;
|
|
64
|
+
userAvatarURL: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface InvoiceUsageData {
|
|
68
|
+
invoiceId: string;
|
|
69
|
+
startDate: string;
|
|
70
|
+
endDate: string;
|
|
71
|
+
}
|
package/src/util/analytics.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import Analytics = require("analytics-node");
|