@myrialabs/clopen 0.4.40 → 0.4.42
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/.env.example +1 -1
- package/backend/artifacts/detect.ts +15 -3
- package/backend/artifacts/generate.ts +2 -2
- package/backend/artifacts/index.ts +12 -4
- package/backend/artifacts/markers.ts +24 -1
- package/backend/artifacts/matrix.ts +47 -3
- package/backend/artifacts/sync.test.ts +3 -3
- package/backend/artifacts/sync.ts +8 -20
- package/backend/artifacts/types.ts +9 -3
- package/backend/auth/permissions.ts +6 -11
- package/backend/auth/session-cleanup.ts +10 -1
- package/backend/auth/tokens.ts +9 -1
- package/backend/chat/stream-manager.ts +50 -0
- package/backend/database/crypto/secret-columns.ts +5 -1
- package/backend/database/index.ts +18 -0
- package/backend/database/migrations/079_merge_commands_into_skills.ts +222 -0
- package/backend/database/migrations/080_create_file_shares.ts +111 -0
- package/backend/database/migrations/081_create_push_subscriptions.ts +32 -0
- package/backend/database/migrations/082_create_git_identities.test.ts +186 -0
- package/backend/database/migrations/082_create_git_identities.ts +122 -0
- package/backend/database/migrations/index.ts +28 -0
- package/backend/database/queries/file-share-queries.ts +163 -0
- package/backend/database/queries/git-identity-queries.ts +290 -0
- package/backend/database/queries/index.ts +8 -4
- package/backend/database/queries/profile-queries.ts +5 -3
- package/backend/database/queries/push-subscription-queries.test.ts +90 -0
- package/backend/database/queries/push-subscription-queries.ts +99 -0
- package/backend/database/queries/skill-queries.ts +96 -18
- package/backend/engine/adapters/claude/environment.ts +11 -1
- package/backend/engine/adapters/claude/stream.ts +3 -2
- package/backend/engine/adapters/cline/stream.ts +3 -3
- package/backend/engine/adapters/codex/stream.ts +38 -6
- package/backend/engine/adapters/copilot/stream.ts +3 -3
- package/backend/engine/adapters/cursor/stream.ts +25 -3
- package/backend/engine/adapters/opencode/server.ts +26 -2
- package/backend/engine/adapters/opencode/stream.ts +8 -7
- package/backend/engine/adapters/pi/stream.ts +2 -2
- package/backend/engine/adapters/qwen/stream.ts +5 -3
- package/backend/engine/artifact-sync.ts +26 -20
- package/backend/engine/docs/artifacts.md +81 -22
- package/backend/engine/docs/quick-reference.md +2 -1
- package/backend/engine/resolve-model.test.ts +108 -0
- package/backend/engine/resolve-model.ts +53 -10
- package/backend/engine/structured-helpers.ts +22 -0
- package/backend/engine/types.ts +10 -0
- package/backend/files/file-shares.ts +369 -0
- package/backend/files/path-browsing.ts +27 -21
- package/backend/git/git-executor.ts +28 -2
- package/backend/git/git-service.ts +59 -40
- package/backend/git/identity/cli.test.ts +58 -0
- package/backend/git/identity/cli.ts +201 -0
- package/backend/git/identity/credential-helper.test.ts +242 -0
- package/backend/git/identity/env.test.ts +214 -0
- package/backend/git/identity/env.ts +193 -0
- package/backend/git/identity/import-local.test.ts +199 -0
- package/backend/git/identity/import-local.ts +141 -0
- package/backend/git/identity/index.ts +78 -0
- package/backend/git/identity/keys.ts +183 -0
- package/backend/git/identity/resolve.ts +140 -0
- package/backend/git/identity/scope-config.test.ts +145 -0
- package/backend/git/identity/scope-config.ts +175 -0
- package/backend/git/identity/service.ts +297 -0
- package/backend/http/files-shared.test.ts +505 -0
- package/backend/http/files-shared.ts +351 -0
- package/backend/http/push.ts +150 -0
- package/backend/index.ts +24 -0
- package/backend/instructions/index.ts +1 -1
- package/backend/instructions/sync.ts +30 -6
- package/backend/memory/compose.ts +2 -2
- package/backend/memory/consolidate.ts +2 -2
- package/backend/memory/extract/episodic.ts +2 -2
- package/backend/memory/judge.ts +2 -2
- package/backend/preview/browser/browser-console-manager.ts +214 -34
- package/backend/preview/browser/browser-pool.ts +526 -123
- package/backend/preview/browser/browser-preview-service.ts +192 -8
- package/backend/preview/browser/browser-tab-lifecycle.test.ts +240 -0
- package/backend/preview/browser/browser-tab-lifecycle.ts +495 -0
- package/backend/preview/browser/browser-tab-manager.ts +291 -65
- package/backend/preview/browser/capture-profile.ts +15 -1
- package/backend/preview/browser/types.ts +26 -1
- package/backend/profiles/service.ts +7 -6
- package/backend/push/sender.ts +172 -0
- package/backend/push/tags.ts +25 -0
- package/backend/push/vapid-keys.ts +77 -0
- package/backend/push/webpush-crypto.test.ts +200 -0
- package/backend/push/webpush-crypto.ts +231 -0
- package/backend/skills/detect.ts +28 -0
- package/backend/skills/index.ts +22 -4
- package/backend/skills/invoke.test.ts +114 -0
- package/backend/skills/invoke.ts +222 -0
- package/backend/skills/service.ts +194 -44
- package/backend/skills/spec.ts +35 -0
- package/backend/skills/sync.ts +85 -55
- package/backend/subagents/detect.ts +2 -3
- package/backend/subagents/sync.ts +15 -8
- package/backend/terminal/ptykit.ts +24 -0
- package/backend/work/pull-requests.ts +2 -2
- package/backend/ws/chat/stream.ts +100 -8
- package/backend/ws/files/index.ts +4 -0
- package/backend/ws/files/share.ts +95 -0
- package/backend/ws/git/branch-name.ts +2 -2
- package/backend/ws/git/branch.ts +17 -6
- package/backend/ws/git/commit-message.ts +2 -2
- package/backend/ws/git/commit.ts +6 -5
- package/backend/ws/git/conflict.ts +3 -2
- package/backend/ws/git/identity-context.ts +91 -0
- package/backend/ws/git/identity.ts +200 -0
- package/backend/ws/git/index.ts +3 -1
- package/backend/ws/git/remote.ts +57 -11
- package/backend/ws/index.ts +3 -4
- package/backend/ws/preview/browser/data.ts +60 -0
- package/backend/ws/preview/browser/interact.ts +6 -0
- package/backend/ws/preview/browser/tab-info.ts +9 -1
- package/backend/ws/preview/browser/tab.ts +64 -8
- package/backend/ws/preview/index.ts +21 -0
- package/backend/ws/profiles/crud.ts +2 -3
- package/backend/ws/skills/catalog.ts +5 -1
- package/backend/ws/skills/crud.ts +128 -22
- package/backend/ws/skills/index.ts +4 -1
- package/backend/ws/user/crud.ts +12 -3
- package/bin/clopen.ts +9 -0
- package/dist/assets/{index-D4igjF6e.js → index-BynqyvF4.js} +1 -1
- package/dist/assets/{index-DONNwiXm.js → index-DLoJsmNQ.js} +1 -1
- package/dist/assets/{main-BrfXH1bL.js → main-CUyZAmqt.js} +601 -592
- package/dist/assets/main-DVCW3cfr.css +1 -0
- package/dist/index.html +7 -2
- package/dist/sw.js +112 -0
- package/package.json +2 -2
- package/shared/constants/engine-tools.ts +31 -6
- package/shared/constants/notification-messages.ts +142 -0
- package/shared/types/git-identity.ts +112 -0
- package/shared/types/unified/stream.ts +7 -0
- package/backend/commands/detect.ts +0 -25
- package/backend/commands/index.ts +0 -9
- package/backend/commands/service.ts +0 -178
- package/backend/commands/store.ts +0 -45
- package/backend/commands/sync.ts +0 -94
- package/backend/database/queries/command-queries.ts +0 -82
- package/backend/ws/commands/crud.ts +0 -157
- package/backend/ws/commands/index.ts +0 -8
- package/dist/assets/main-CT1PygsW.css +0 -1
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The git identity service — CRUD, key materialisation, and the DTO boundary.
|
|
3
|
+
*
|
|
4
|
+
* One rule governs this module: A SECRET NEVER LEAVES IT. `toDTO` reduces the
|
|
5
|
+
* private key, its passphrase, and the HTTPS token to booleans, so no code path
|
|
6
|
+
* above this file can accidentally serialise one to a browser. The public key
|
|
7
|
+
* is the deliberate exception — it is public, and the user needs to copy it.
|
|
8
|
+
*
|
|
9
|
+
* Key material on disk is kept in step with the row here rather than in the
|
|
10
|
+
* query layer: writing a file is not part of storing a row, and a failed write
|
|
11
|
+
* must not leave a saved identity whose key silently does not exist.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { randomUUID } from 'node:crypto';
|
|
15
|
+
import {
|
|
16
|
+
gitIdentityQueries,
|
|
17
|
+
gitIdentityBindingQueries,
|
|
18
|
+
parseHosts,
|
|
19
|
+
type GitIdentityRow
|
|
20
|
+
} from '$backend/database/queries';
|
|
21
|
+
import { debug } from '$shared/utils/logger';
|
|
22
|
+
import type {
|
|
23
|
+
GeneratedSshKey,
|
|
24
|
+
GitIdentityDTO,
|
|
25
|
+
GitIdentityInput
|
|
26
|
+
} from '$shared/types/git-identity';
|
|
27
|
+
import { derivePublicKey, generateKeyPair, identityKeyPath, removeKeyFiles, writeKeyFile } from './keys';
|
|
28
|
+
import { syncLocalMachineIdentity } from './import-local';
|
|
29
|
+
import { refreshScopeConfigsForUser, writeScopeConfig } from './scope-config';
|
|
30
|
+
|
|
31
|
+
/** Strip a row down to what a client may see. */
|
|
32
|
+
export function toDTO(row: GitIdentityRow): GitIdentityDTO {
|
|
33
|
+
return {
|
|
34
|
+
id: row.id,
|
|
35
|
+
label: row.label,
|
|
36
|
+
name: row.name,
|
|
37
|
+
email: row.email,
|
|
38
|
+
authMethod: row.auth_method,
|
|
39
|
+
hosts: parseHosts(row.hosts),
|
|
40
|
+
sshPublicKey: row.ssh_public_key,
|
|
41
|
+
hasSshKey: !!row.ssh_private_key,
|
|
42
|
+
hasSshPassphrase: !!row.ssh_passphrase,
|
|
43
|
+
hasHttpsToken: !!row.https_token,
|
|
44
|
+
httpsUsername: row.https_username,
|
|
45
|
+
integrationAccountId: row.integration_account_id,
|
|
46
|
+
isDefault: row.is_default === 1,
|
|
47
|
+
source: row.source,
|
|
48
|
+
// Mirrored rows are not deletable: the machine's config still exists, so a
|
|
49
|
+
// delete would only be undone by the next list read.
|
|
50
|
+
canDelete: row.source !== 'local-machine',
|
|
51
|
+
createdAt: row.created_at,
|
|
52
|
+
updatedAt: row.updated_at
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function assertValid(input: GitIdentityInput): void {
|
|
57
|
+
if (!input.label.trim()) throw new Error('An identity needs a label');
|
|
58
|
+
if (!input.name.trim()) throw new Error('An identity needs a name');
|
|
59
|
+
const email = input.email.trim();
|
|
60
|
+
// Deliberately loose. Git accepts anything without whitespace or angle
|
|
61
|
+
// brackets as an email, and rejecting an address a host does accept would be
|
|
62
|
+
// the more annoying failure.
|
|
63
|
+
if (!email || /[\s<>]/.test(email)) throw new Error('That email is not usable in a git commit');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Keep the key file in step with the row.
|
|
68
|
+
*
|
|
69
|
+
* Called after every write. Reads the stored (already unsealed) key rather than
|
|
70
|
+
* the input, so an edit that leaves the key untouched still guarantees the file
|
|
71
|
+
* exists — which matters after a restore onto a machine that has the database
|
|
72
|
+
* but not the key files.
|
|
73
|
+
*/
|
|
74
|
+
async function syncKeyFile(row: GitIdentityRow): Promise<GitIdentityRow> {
|
|
75
|
+
if (row.auth_method !== 'ssh-key' || !row.ssh_private_key) {
|
|
76
|
+
await removeKeyFiles(row.id);
|
|
77
|
+
return row;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const { strictPermissions } = await writeKeyFile(row.id, row.ssh_private_key);
|
|
81
|
+
if (!strictPermissions) {
|
|
82
|
+
// Said once, loudly, rather than left for the user to decode out of an
|
|
83
|
+
// ssh error at push time.
|
|
84
|
+
debug.warn(
|
|
85
|
+
'git',
|
|
86
|
+
`Key for identity ${row.id} could not be given strict permissions; ssh may refuse it`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// A user who pasted only a private key still gets something to copy into
|
|
91
|
+
// GitHub. Skipped for passphrased keys, which cannot be read unattended.
|
|
92
|
+
if (!row.ssh_public_key && !row.ssh_passphrase) {
|
|
93
|
+
const derived = await derivePublicKey(identityKeyPath(row.id));
|
|
94
|
+
if (derived) {
|
|
95
|
+
const updated = gitIdentityQueries.update(row.id, {
|
|
96
|
+
label: row.label,
|
|
97
|
+
name: row.name,
|
|
98
|
+
email: row.email,
|
|
99
|
+
authMethod: row.auth_method,
|
|
100
|
+
hosts: parseHosts(row.hosts),
|
|
101
|
+
sshPublicKey: derived,
|
|
102
|
+
httpsUsername: row.https_username,
|
|
103
|
+
integrationAccountId: row.integration_account_id
|
|
104
|
+
});
|
|
105
|
+
if (updated) return updated;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return row;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export const gitIdentityService = {
|
|
113
|
+
/**
|
|
114
|
+
* Every identity this user owns, mirroring the machine's git config first.
|
|
115
|
+
*
|
|
116
|
+
* Done on the read rather than at startup so it also covers a user who joins
|
|
117
|
+
* later, and because it is the moment the result is actually about to be
|
|
118
|
+
* shown. It is idempotent and only writes on the first call per user.
|
|
119
|
+
*/
|
|
120
|
+
async list(userId: string): Promise<GitIdentityDTO[]> {
|
|
121
|
+
await syncLocalMachineIdentity(userId);
|
|
122
|
+
return gitIdentityQueries.listByUser(userId).map(toDTO);
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
get(userId: string, id: string): GitIdentityDTO | null {
|
|
126
|
+
const row = gitIdentityQueries.getById(id);
|
|
127
|
+
if (!row || row.owner_user_id !== userId) return null;
|
|
128
|
+
return toDTO(row);
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
async create(userId: string, input: GitIdentityInput): Promise<GitIdentityDTO> {
|
|
132
|
+
assertValid(input);
|
|
133
|
+
if (gitIdentityQueries.labelTaken(userId, input.label.trim())) {
|
|
134
|
+
throw new Error(`You already have an identity called "${input.label.trim()}"`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const id = randomUUID();
|
|
138
|
+
let row = gitIdentityQueries.create(id, userId, {
|
|
139
|
+
label: input.label.trim(),
|
|
140
|
+
name: input.name.trim(),
|
|
141
|
+
email: input.email.trim(),
|
|
142
|
+
authMethod: input.authMethod,
|
|
143
|
+
hosts: input.hosts,
|
|
144
|
+
sshPrivateKey: input.sshPrivateKey ?? null,
|
|
145
|
+
sshPublicKey: input.sshPublicKey ?? null,
|
|
146
|
+
sshPassphrase: input.sshPassphrase ?? null,
|
|
147
|
+
httpsUsername: input.httpsUsername ?? null,
|
|
148
|
+
httpsToken: input.httpsToken ?? null,
|
|
149
|
+
integrationAccountId: input.integrationAccountId ?? null
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
row = await syncKeyFile(row);
|
|
153
|
+
|
|
154
|
+
// The first identity a user creates becomes their default — otherwise it
|
|
155
|
+
// would sit there doing nothing until they found the toggle, which reads
|
|
156
|
+
// as the feature being broken.
|
|
157
|
+
if (input.isDefault || gitIdentityQueries.listByUser(userId).length === 1) {
|
|
158
|
+
gitIdentityQueries.setDefault(userId, id);
|
|
159
|
+
row = gitIdentityQueries.getById(id)!;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Terminals that are already open read their identity from a file, so it is
|
|
163
|
+
// rewritten here — otherwise the new account would only reach tabs opened
|
|
164
|
+
// after this point.
|
|
165
|
+
await refreshScopeConfigsForUser(userId);
|
|
166
|
+
|
|
167
|
+
debug.log('git', `Created git identity "${row.label}" for user ${userId}`);
|
|
168
|
+
return toDTO(row);
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
async update(userId: string, id: string, input: GitIdentityInput): Promise<GitIdentityDTO> {
|
|
172
|
+
assertValid(input);
|
|
173
|
+
const existing = gitIdentityQueries.getById(id);
|
|
174
|
+
if (!existing || existing.owner_user_id !== userId) throw new Error('Identity not found');
|
|
175
|
+
if (gitIdentityQueries.labelTaken(userId, input.label.trim(), id)) {
|
|
176
|
+
throw new Error(`You already have an identity called "${input.label.trim()}"`);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
let row = gitIdentityQueries.update(id, {
|
|
180
|
+
label: input.label.trim(),
|
|
181
|
+
name: input.name.trim(),
|
|
182
|
+
email: input.email.trim(),
|
|
183
|
+
authMethod: input.authMethod,
|
|
184
|
+
hosts: input.hosts,
|
|
185
|
+
// `undefined` keeps the stored secret, `null` clears it — the
|
|
186
|
+
// distinction the query layer depends on.
|
|
187
|
+
sshPrivateKey: input.sshPrivateKey,
|
|
188
|
+
sshPublicKey: input.sshPublicKey ?? existing.ssh_public_key,
|
|
189
|
+
sshPassphrase: input.sshPassphrase,
|
|
190
|
+
httpsUsername: input.httpsUsername ?? null,
|
|
191
|
+
httpsToken: input.httpsToken,
|
|
192
|
+
integrationAccountId: input.integrationAccountId ?? null
|
|
193
|
+
// `source` is deliberately absent: the update statement does not touch
|
|
194
|
+
// that column, so an edited mirror stays a mirror — and stays
|
|
195
|
+
// undeletable, because the machine config it reflects is still there.
|
|
196
|
+
});
|
|
197
|
+
if (!row) throw new Error('Identity not found');
|
|
198
|
+
|
|
199
|
+
row = await syncKeyFile(row);
|
|
200
|
+
|
|
201
|
+
if (input.isDefault && row.is_default !== 1) {
|
|
202
|
+
gitIdentityQueries.setDefault(userId, id);
|
|
203
|
+
row = gitIdentityQueries.getById(id)!;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
await refreshScopeConfigsForUser(userId);
|
|
207
|
+
|
|
208
|
+
debug.log('git', `Updated git identity "${row.label}"`);
|
|
209
|
+
return toDTO(row);
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
async remove(userId: string, id: string): Promise<void> {
|
|
213
|
+
const row = gitIdentityQueries.getById(id);
|
|
214
|
+
if (!row || row.owner_user_id !== userId) throw new Error('Identity not found');
|
|
215
|
+
if (row.source === 'local-machine') {
|
|
216
|
+
throw new Error(
|
|
217
|
+
"This account mirrors the machine's own git config, so it cannot be deleted. Edit it instead."
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
gitIdentityQueries.remove(id);
|
|
222
|
+
await removeKeyFiles(id);
|
|
223
|
+
|
|
224
|
+
// Deleting the default leaves the user with none, so the next one in the
|
|
225
|
+
// list takes over rather than every project silently losing its identity.
|
|
226
|
+
if (row.is_default === 1) {
|
|
227
|
+
const remaining = gitIdentityQueries.listByUser(userId);
|
|
228
|
+
if (remaining.length > 0) gitIdentityQueries.setDefault(userId, remaining[0]!.id);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
await refreshScopeConfigsForUser(userId);
|
|
232
|
+
|
|
233
|
+
debug.log('git', `Removed git identity "${row.label}"`);
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
async setDefault(userId: string, id: string): Promise<GitIdentityDTO> {
|
|
237
|
+
const row = gitIdentityQueries.getById(id);
|
|
238
|
+
if (!row || row.owner_user_id !== userId) throw new Error('Identity not found');
|
|
239
|
+
gitIdentityQueries.setDefault(userId, id);
|
|
240
|
+
// Every project that inherits the default is affected, not just one.
|
|
241
|
+
await refreshScopeConfigsForUser(userId);
|
|
242
|
+
return toDTO(gitIdentityQueries.getById(id)!);
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Generate a keypair for an identity and store the private half.
|
|
247
|
+
*
|
|
248
|
+
* Returns only the public key and its fingerprint; the private key goes
|
|
249
|
+
* straight into the sealed column and the 0600 file.
|
|
250
|
+
*/
|
|
251
|
+
async generateKey(userId: string, id: string): Promise<GeneratedSshKey> {
|
|
252
|
+
const row = gitIdentityQueries.getById(id);
|
|
253
|
+
if (!row || row.owner_user_id !== userId) throw new Error('Identity not found');
|
|
254
|
+
|
|
255
|
+
const { privateKey, publicKey, fingerprint } = await generateKeyPair(
|
|
256
|
+
id,
|
|
257
|
+
`${row.email} (clopen)`
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
gitIdentityQueries.update(id, {
|
|
261
|
+
label: row.label,
|
|
262
|
+
name: row.name,
|
|
263
|
+
email: row.email,
|
|
264
|
+
authMethod: 'ssh-key',
|
|
265
|
+
hosts: parseHosts(row.hosts),
|
|
266
|
+
sshPrivateKey: privateKey,
|
|
267
|
+
sshPublicKey: publicKey,
|
|
268
|
+
// A generated key has no passphrase, so any stored one is now wrong.
|
|
269
|
+
sshPassphrase: null,
|
|
270
|
+
httpsUsername: row.https_username,
|
|
271
|
+
integrationAccountId: row.integration_account_id
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
await refreshScopeConfigsForUser(userId);
|
|
275
|
+
|
|
276
|
+
debug.log('git', `Generated SSH key for identity "${row.label}"`);
|
|
277
|
+
return { publicKey, fingerprint };
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
/** Bind a project to an identity, for this user. */
|
|
281
|
+
async bind(userId: string, projectId: string, identityId: string | null): Promise<void> {
|
|
282
|
+
if (identityId === null) {
|
|
283
|
+
gitIdentityBindingQueries.clear(projectId, userId);
|
|
284
|
+
} else {
|
|
285
|
+
const row = gitIdentityQueries.getById(identityId);
|
|
286
|
+
if (!row || row.owner_user_id !== userId) throw new Error('Identity not found');
|
|
287
|
+
gitIdentityBindingQueries.set(projectId, userId, identityId);
|
|
288
|
+
}
|
|
289
|
+
// Only this project's file can have changed, so only it is rewritten.
|
|
290
|
+
await writeScopeConfig(userId, projectId);
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
/** How many projects would lose their binding if this identity went away. */
|
|
294
|
+
bindingCount(identityId: string): number {
|
|
295
|
+
return gitIdentityBindingQueries.countForIdentity(identityId);
|
|
296
|
+
}
|
|
297
|
+
};
|