@deveye/types 0.18.1 → 0.18.2
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/package.json +1 -1
- package/src/domain/feedback.ts +1 -1
- package/src/domain/live.ts +2 -7
- package/src/domain/user.ts +11 -0
- package/src/features/user.ts +18 -2
- package/src/http/auth.ts +2 -6
- package/src/index.ts +3 -1
- package/src/sdk/client-ambient.d.ts +6 -0
- package/src/sdk/client.ts +23 -10
- package/src/sdk/move.test.ts +7 -6
- package/src/sdk/providers.ts +38 -26
- package/src/sdk/server.ts +19 -7
package/package.json
CHANGED
package/src/domain/feedback.ts
CHANGED
|
@@ -60,7 +60,7 @@ export type FeedbackErrorTrace = z.infer<typeof feedbackErrorTraceSchema>;
|
|
|
60
60
|
/** A view the user opened, in order: the shortest path to a reproduction. */
|
|
61
61
|
export const feedbackViewTraceSchema = z.object({
|
|
62
62
|
ago: z.number().int().nonnegative(),
|
|
63
|
-
/** View id (`logs`, `x-audit`, `
|
|
63
|
+
/** View id (`logs`, `x-audit`, `devices`), or `home` when it closed. */
|
|
64
64
|
view: z.string().max(64)
|
|
65
65
|
});
|
|
66
66
|
export type FeedbackViewTrace = z.infer<typeof feedbackViewTraceSchema>;
|
package/src/domain/live.ts
CHANGED
|
@@ -21,8 +21,8 @@ import {
|
|
|
21
21
|
*
|
|
22
22
|
* Le `kind` identifie le **niveau** (`view`, `account`, `folder`…), la valeur
|
|
23
23
|
* identifie le nœud à ce niveau. La valeur peut elle-même contenir des
|
|
24
|
-
* deux-points
|
|
25
|
-
* au premier deux-points, jamais avec un `split` complet.**
|
|
24
|
+
* deux-points : la coquille de réglages d'un élément est `settings:item:devices`,
|
|
25
|
+
* donc **on découpe au premier deux-points, jamais avec un `split` complet.**
|
|
26
26
|
*/
|
|
27
27
|
export const livePathSegmentSchema = z
|
|
28
28
|
.string()
|
|
@@ -213,8 +213,6 @@ export const TOPIC_FEATURE: Record<NativeLiveTopic, WorkspaceFeatureId | null> =
|
|
|
213
213
|
*/
|
|
214
214
|
export type LivePathGate = FeatureId | 'public' | 'private';
|
|
215
215
|
|
|
216
|
-
const DEVICE_VIEW_PREFIX = 'device:';
|
|
217
|
-
|
|
218
216
|
export function livePathGate(rootSegment: string | undefined): LivePathGate {
|
|
219
217
|
if (!rootSegment) return 'public';
|
|
220
218
|
if (segmentKind(rootSegment) !== 'view') return 'private';
|
|
@@ -224,8 +222,5 @@ export function livePathGate(rootSegment: string | undefined): LivePathGate {
|
|
|
224
222
|
// Une vue de module externe est gardée par le droit du module, comme une
|
|
225
223
|
// feature native : même règle, reconnue au préfixe plutôt qu'à l'enum.
|
|
226
224
|
if (isExternalFeatureId(viewId)) return viewId;
|
|
227
|
-
// La page Appareils et chaque vue d'appareil relèvent du même droit — miroir
|
|
228
|
-
// exact de `featureBehind` côté client.
|
|
229
|
-
if (viewId === 'clients' || viewId.startsWith(DEVICE_VIEW_PREFIX)) return 'devices';
|
|
230
225
|
return 'private';
|
|
231
226
|
}
|
package/src/domain/user.ts
CHANGED
|
@@ -41,6 +41,17 @@ export function defaultUserColor(userId: number): UserColor {
|
|
|
41
41
|
return USER_COLORS[Math.abs(userId) % USER_COLORS.length];
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* The account name: what one logs in with, and what the other members see.
|
|
46
|
+
* Unique across the site (`users.username` carries a UNIQUE index), and narrow
|
|
47
|
+
* enough to travel through a URL, a log line or a shell without escaping.
|
|
48
|
+
*/
|
|
49
|
+
export const usernameSchema = z
|
|
50
|
+
.string()
|
|
51
|
+
.min(3)
|
|
52
|
+
.max(64)
|
|
53
|
+
.regex(/^[a-zA-Z0-9_.-]+$/, 'username may only contain letters, digits, _ . -');
|
|
54
|
+
|
|
44
55
|
export const minimalUserSchema = z.object({
|
|
45
56
|
id: z.number().int().nonnegative(),
|
|
46
57
|
email: z.string().email(),
|
package/src/features/user.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { userColorSchema, userSettingFlagSchema } from '../domain/user';
|
|
2
|
+
import { usernameSchema, userColorSchema, userSettingFlagSchema } from '../domain/user';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Upper bound on the avatar data URL length (characters ≈ bytes for base64
|
|
@@ -83,4 +83,20 @@ export const userSetSetting = {
|
|
|
83
83
|
output: z.object({ settings: z.array(z.string()) })
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Renames the account. Same rule as registration (`usernameSchema`), and the
|
|
88
|
+
* same uniqueness: the server rejects a name another account already holds.
|
|
89
|
+
*/
|
|
90
|
+
export const userSetUsername = {
|
|
91
|
+
command: 'user.setUsername' as const,
|
|
92
|
+
input: z.object({ username: usernameSchema }),
|
|
93
|
+
output: z.object({ username: usernameSchema })
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const userCommands = [
|
|
97
|
+
userSetAvatar,
|
|
98
|
+
userSetTheme,
|
|
99
|
+
userSetColor,
|
|
100
|
+
userSetSetting,
|
|
101
|
+
userSetUsername
|
|
102
|
+
] as const;
|
package/src/http/auth.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { homeLayoutSchema } from '../domain/home';
|
|
3
|
-
import { userSchema } from '../domain/user';
|
|
3
|
+
import { usernameSchema, userSchema } from '../domain/user';
|
|
4
4
|
import { workspaceSchema } from '../domain/workspace';
|
|
5
5
|
import { workspacePermissionsSchema } from '../domain/workspaceRole';
|
|
6
6
|
import { themeStateSchema } from '../features/user';
|
|
@@ -41,11 +41,7 @@ export type LoginRequest = z.infer<typeof loginRequestSchema>;
|
|
|
41
41
|
/** L'inscription exige un jeton d'invitation émis par un administrateur. */
|
|
42
42
|
export const registerRequestSchema = z.object({
|
|
43
43
|
inviteToken: z.string().min(1),
|
|
44
|
-
username:
|
|
45
|
-
.string()
|
|
46
|
-
.min(3)
|
|
47
|
-
.max(64)
|
|
48
|
-
.regex(/^[a-zA-Z0-9_.-]+$/, 'username may only contain letters, digits, _ . -'),
|
|
44
|
+
username: usernameSchema,
|
|
49
45
|
email: z.string().email().max(320),
|
|
50
46
|
password: z.string().min(8).max(512)
|
|
51
47
|
});
|
package/src/index.ts
CHANGED
|
@@ -488,6 +488,7 @@ export {
|
|
|
488
488
|
minimalUserSchema,
|
|
489
489
|
USER_COLORS,
|
|
490
490
|
userColorSchema,
|
|
491
|
+
usernameSchema,
|
|
491
492
|
userSchema,
|
|
492
493
|
userSecuritySchema,
|
|
493
494
|
userSettingFlagSchema,
|
|
@@ -754,7 +755,8 @@ export {
|
|
|
754
755
|
userSetAvatar,
|
|
755
756
|
userSetColor,
|
|
756
757
|
userSetSetting,
|
|
757
|
-
userSetTheme
|
|
758
|
+
userSetTheme,
|
|
759
|
+
userSetUsername
|
|
758
760
|
} from './features/user';
|
|
759
761
|
export type { ThemeStateDTO } from './features/user';
|
|
760
762
|
export {
|
|
@@ -185,6 +185,12 @@ declare module 'deveye-sdk-client' {
|
|
|
185
185
|
* nothing else announces the item. The shell never declares the level.
|
|
186
186
|
*/
|
|
187
187
|
onOpenChange?: (open: boolean) => void;
|
|
188
|
+
/**
|
|
189
|
+
* The item was deleted or moved to another workspace from inside the
|
|
190
|
+
* shell, which has closed: the view that mounted the button leaves the
|
|
191
|
+
* item (the same handler as its back button).
|
|
192
|
+
*/
|
|
193
|
+
onGone?: () => void;
|
|
188
194
|
}>;
|
|
189
195
|
/**
|
|
190
196
|
* One provider of a feature and the key it wants. The row carries the state
|
package/src/sdk/client.ts
CHANGED
|
@@ -23,12 +23,18 @@ export interface SettingsPanelProps {
|
|
|
23
23
|
/** Caller has `write` on the feature. Render read-only when false. */
|
|
24
24
|
canWrite: boolean;
|
|
25
25
|
/**
|
|
26
|
-
* Closes the settings dialog. For a
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* Not a substitute for saving — every other change applies in place.
|
|
26
|
+
* Closes the settings dialog, nothing more. For a gesture best followed on
|
|
27
|
+
* the screen underneath (a full resync whose progress the item's view
|
|
28
|
+
* draws). Not a substitute for saving: every other change applies in place.
|
|
30
29
|
*/
|
|
31
30
|
close(): void;
|
|
31
|
+
/**
|
|
32
|
+
* The item being configured no longer exists here (deleted, moved to
|
|
33
|
+
* another workspace): the shell closes, then the view that opened it
|
|
34
|
+
* leaves the item. The scope it was opened on is gone, and the shell would
|
|
35
|
+
* otherwise fall back to the feature's own tabs under the item's name.
|
|
36
|
+
*/
|
|
37
|
+
gone(): void;
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
export interface FeatureViewProps {
|
|
@@ -101,6 +107,8 @@ export interface UptimeLinkedService {
|
|
|
101
107
|
name: string;
|
|
102
108
|
url: string;
|
|
103
109
|
enabled: boolean;
|
|
110
|
+
/** Projected here from another workspace. */
|
|
111
|
+
foreign?: boolean;
|
|
104
112
|
status: string;
|
|
105
113
|
lastCheckedAt: number | null;
|
|
106
114
|
ratio24h: number | null;
|
|
@@ -122,9 +130,8 @@ export type UptimeHistoryResolution = 'raw' | 'hour' | 'day';
|
|
|
122
130
|
|
|
123
131
|
/**
|
|
124
132
|
* What the Devices module offers the app's own screens (`DEVICES_CLIENT_PROVIDER`):
|
|
125
|
-
* the workspace's devices as a live store, the
|
|
126
|
-
*
|
|
127
|
-
* module the home places no device and the topbar counts none.
|
|
133
|
+
* the workspace's devices as a live store, and the compact tile of one of them.
|
|
134
|
+
* Without the module the home places no device and the topbar counts none.
|
|
128
135
|
*/
|
|
129
136
|
export interface DevicesClientProvider {
|
|
130
137
|
/** The active workspace's devices, refreshed by the `devices` live topic. */
|
|
@@ -132,7 +139,6 @@ export interface DevicesClientProvider {
|
|
|
132
139
|
refreshDevices(): void;
|
|
133
140
|
/** Forgets every loaded device (the app calls it when the session ends). */
|
|
134
141
|
resetDevices(): void;
|
|
135
|
-
DevicePanel: ComponentType<{ deviceId: string }>;
|
|
136
142
|
DeviceWidget: ComponentType<{ deviceId: string; hideStatus?: boolean }>;
|
|
137
143
|
}
|
|
138
144
|
|
|
@@ -177,10 +183,9 @@ export interface UptimeClientProvider {
|
|
|
177
183
|
}>;
|
|
178
184
|
/** The three-window availability ratios of a service. */
|
|
179
185
|
Ratios: ComponentType<{ service: UptimeLinkedService; compact?: boolean }>;
|
|
180
|
-
/** The feature's service form
|
|
186
|
+
/** The feature's service form, to declare a new service from a project. */
|
|
181
187
|
ServiceDialog: ComponentType<{
|
|
182
188
|
open: boolean;
|
|
183
|
-
service: UptimeLinkedService | null;
|
|
184
189
|
onClose: () => void;
|
|
185
190
|
onSaved: (service: UptimeLinkedService) => void;
|
|
186
191
|
}>;
|
|
@@ -194,6 +199,8 @@ export interface UptimeClientProvider {
|
|
|
194
199
|
export interface DatabaseLinkedCandidate {
|
|
195
200
|
id: number;
|
|
196
201
|
name: string;
|
|
202
|
+
/** Projected here from another workspace. */
|
|
203
|
+
foreign?: boolean;
|
|
197
204
|
/** The engine as the module labels it (« MySQL », « PostgreSQL »). */
|
|
198
205
|
engineLabel: string;
|
|
199
206
|
/** How many projects of the workspace already use it. */
|
|
@@ -231,6 +238,8 @@ export interface DatabaseClientProvider {
|
|
|
231
238
|
export interface DeployLinkedCandidate {
|
|
232
239
|
id: number;
|
|
233
240
|
name: string;
|
|
241
|
+
/** Projected here from another workspace. */
|
|
242
|
+
foreign?: boolean;
|
|
234
243
|
/** The instance host, as the module labels it (« dokploy.example.com »). */
|
|
235
244
|
host: string;
|
|
236
245
|
}
|
|
@@ -271,6 +280,8 @@ export interface GitLinkedCandidate {
|
|
|
271
280
|
id: number;
|
|
272
281
|
owner: string;
|
|
273
282
|
repo: string;
|
|
283
|
+
/** Projected here from another workspace. */
|
|
284
|
+
foreign?: boolean;
|
|
274
285
|
}
|
|
275
286
|
|
|
276
287
|
/**
|
|
@@ -300,6 +311,8 @@ export interface GitClientProvider {
|
|
|
300
311
|
export interface AudienceLinkedCandidate {
|
|
301
312
|
id: number;
|
|
302
313
|
name: string;
|
|
314
|
+
/** Projected here from another workspace. */
|
|
315
|
+
foreign?: boolean;
|
|
303
316
|
}
|
|
304
317
|
|
|
305
318
|
/**
|
package/src/sdk/move.test.ts
CHANGED
|
@@ -79,17 +79,18 @@ describe('resealCells', () => {
|
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
assert.equal(await resealCells(q, CELLS, 7, ciphers), 3);
|
|
82
|
+
// Une écriture par colonne, toutes ses lignes en un paquet.
|
|
82
83
|
assert.deepEqual(
|
|
83
84
|
writes.map((w) => w.params),
|
|
84
85
|
[
|
|
85
|
-
['B:corps', 7, 7],
|
|
86
|
-
['B:un', 1, 7]
|
|
87
|
-
['B:deux', 2, 7]
|
|
86
|
+
[7, 'B:corps', 7, 7],
|
|
87
|
+
[1, 'B:un', 2, 'B:deux', 1, 2, 7]
|
|
88
88
|
]
|
|
89
89
|
);
|
|
90
90
|
// La ligne se cible par son identifiant ET son propriétaire : une
|
|
91
91
|
// conversion ne peut pas déborder sur un voisin.
|
|
92
|
-
assert.match(writes[1]!.sql, /
|
|
92
|
+
assert.match(writes[1]!.sql, /CASE id WHEN \? THEN \? WHEN \? THEN \? END/);
|
|
93
|
+
assert.match(writes[1]!.sql, /WHERE id IN \(\?, \?\) AND item_id = \?/);
|
|
93
94
|
});
|
|
94
95
|
|
|
95
96
|
it('annule tout sur une cellule illisible, sans avoir écrit une seule ligne', async () => {
|
|
@@ -121,9 +122,9 @@ describe('resealCells', () => {
|
|
|
121
122
|
await resealCells(q, indirect, 7, ciphers);
|
|
122
123
|
assert.match(
|
|
123
124
|
writes[0]!.sql,
|
|
124
|
-
/WHERE id
|
|
125
|
+
/WHERE id IN \(\?\) AND child_id IN \(SELECT id FROM ft_x_children WHERE item_id = \?\)/
|
|
125
126
|
);
|
|
126
|
-
assert.deepEqual(writes[0]!.params, ['B:feuille', 5, 7]);
|
|
127
|
+
assert.deepEqual(writes[0]!.params, [5, 'B:feuille', 5, 7]);
|
|
127
128
|
});
|
|
128
129
|
|
|
129
130
|
it('compte ce qu’il y aurait à convertir sans rien convertir', async () => {
|
package/src/sdk/providers.ts
CHANGED
|
@@ -97,12 +97,14 @@ export interface DatabaseBackupProvider {
|
|
|
97
97
|
export const DATABASE_ITEMS_PROVIDER = 'database.items' as const;
|
|
98
98
|
|
|
99
99
|
export interface DatabaseItemsProvider {
|
|
100
|
-
/**
|
|
100
|
+
/** Is this database visible from this workspace: its home, or one it is projected into? */
|
|
101
101
|
exists(databaseId: number, workspaceId: number): Promise<boolean>;
|
|
102
102
|
/**
|
|
103
|
-
* The item's display name
|
|
104
|
-
*
|
|
105
|
-
*
|
|
103
|
+
* The item's display name as seen from `workspaceId` (its home, or a
|
|
104
|
+
* workspace it is projected into): the provider resolves the home and its
|
|
105
|
+
* OPEN cipher itself. `null` when it is gone or unreadable. What a window
|
|
106
|
+
* onto a projected project shows for a link it cannot open: a name, never
|
|
107
|
+
* an id.
|
|
106
108
|
*/
|
|
107
109
|
labelOf(databaseId: number, workspaceId: number): Promise<string | null>;
|
|
108
110
|
}
|
|
@@ -156,12 +158,14 @@ export const MAIL_CLIENT_PROVIDER = 'mail.client' as const;
|
|
|
156
158
|
export const AUDIENCE_ITEMS_PROVIDER = 'audience.items' as const;
|
|
157
159
|
|
|
158
160
|
export interface AudienceItemsProvider {
|
|
159
|
-
/**
|
|
161
|
+
/** Is this site visible from this workspace: its home, or one it is projected into? */
|
|
160
162
|
exists(siteId: number, workspaceId: number): Promise<boolean>;
|
|
161
163
|
/**
|
|
162
|
-
* The item's display name
|
|
163
|
-
*
|
|
164
|
-
*
|
|
164
|
+
* The item's display name as seen from `workspaceId` (its home, or a
|
|
165
|
+
* workspace it is projected into): the provider resolves the home and its
|
|
166
|
+
* OPEN cipher itself. `null` when it is gone or unreadable. What a window
|
|
167
|
+
* onto a projected project shows for a link it cannot open: a name, never
|
|
168
|
+
* an id.
|
|
165
169
|
*/
|
|
166
170
|
labelOf(siteId: number, workspaceId: number): Promise<string | null>;
|
|
167
171
|
}
|
|
@@ -182,12 +186,14 @@ export const AUDIENCE_CLIENT_PROVIDER = 'audience.client' as const;
|
|
|
182
186
|
export const GIT_ITEMS_PROVIDER = 'git.items' as const;
|
|
183
187
|
|
|
184
188
|
export interface GitItemsProvider {
|
|
185
|
-
/**
|
|
189
|
+
/** Is this repository visible from this workspace: its home, or one it is projected into? */
|
|
186
190
|
exists(repoId: number, workspaceId: number): Promise<boolean>;
|
|
187
191
|
/**
|
|
188
|
-
* The item's display name
|
|
189
|
-
*
|
|
190
|
-
*
|
|
192
|
+
* The item's display name as seen from `workspaceId` (its home, or a
|
|
193
|
+
* workspace it is projected into): the provider resolves the home and its
|
|
194
|
+
* OPEN cipher itself. `null` when it is gone or unreadable. What a window
|
|
195
|
+
* onto a projected project shows for a link it cannot open: a name, never
|
|
196
|
+
* an id.
|
|
191
197
|
*/
|
|
192
198
|
labelOf(repoId: number, workspaceId: number): Promise<string | null>;
|
|
193
199
|
}
|
|
@@ -208,12 +214,14 @@ export const GIT_CLIENT_PROVIDER = 'git.client' as const;
|
|
|
208
214
|
export const DEPLOY_ITEMS_PROVIDER = 'deploy.items' as const;
|
|
209
215
|
|
|
210
216
|
export interface DeployItemsProvider {
|
|
211
|
-
/**
|
|
217
|
+
/** Is this target visible from this workspace: its home, or one it is projected into? */
|
|
212
218
|
exists(targetId: number, workspaceId: number): Promise<boolean>;
|
|
213
219
|
/**
|
|
214
|
-
* The item's display name
|
|
215
|
-
*
|
|
216
|
-
*
|
|
220
|
+
* The item's display name as seen from `workspaceId` (its home, or a
|
|
221
|
+
* workspace it is projected into): the provider resolves the home and its
|
|
222
|
+
* OPEN cipher itself. `null` when it is gone or unreadable. What a window
|
|
223
|
+
* onto a projected project shows for a link it cannot open: a name, never
|
|
224
|
+
* an id.
|
|
217
225
|
*/
|
|
218
226
|
labelOf(targetId: number, workspaceId: number): Promise<string | null>;
|
|
219
227
|
}
|
|
@@ -262,13 +270,15 @@ export interface ProjectsUsageProvider {
|
|
|
262
270
|
/** How many projects of the workspace link each item of this feature (absent = zero). */
|
|
263
271
|
countByItem(feature: string, workspaceId: number): Promise<ReadonlyMap<number, number>>;
|
|
264
272
|
/**
|
|
265
|
-
* The item
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
273
|
+
* The item is no longer visible from the workspace (deleted, moved away,
|
|
274
|
+
* or its projection withdrawn): drop every link pointing at it from there,
|
|
275
|
+
* and answer how many projects lost one. A link lives in the project's
|
|
276
|
+
* workspace and points at an item visible there, so an item that leaves
|
|
277
|
+
* takes none with it; left alone the rows would keep naming an item that
|
|
278
|
+
* is not there any more.
|
|
269
279
|
*
|
|
270
|
-
* Called by the app
|
|
271
|
-
*
|
|
280
|
+
* Called by the app, never by the module that owns the item. Idempotent,
|
|
281
|
+
* and zero for a feature that links nothing.
|
|
272
282
|
*/
|
|
273
283
|
detach(feature: string, itemId: number, workspaceId: number): Promise<number>;
|
|
274
284
|
/**
|
|
@@ -306,12 +316,14 @@ export interface ProjectsUsageProvider {
|
|
|
306
316
|
export const UPTIME_ITEMS_PROVIDER = 'uptime.items' as const;
|
|
307
317
|
|
|
308
318
|
export interface UptimeItemsProvider {
|
|
309
|
-
/**
|
|
319
|
+
/** Is this service visible from this workspace: its home, or one it is projected into? */
|
|
310
320
|
exists(serviceId: number, workspaceId: number): Promise<boolean>;
|
|
311
321
|
/**
|
|
312
|
-
* The item's display name
|
|
313
|
-
*
|
|
314
|
-
*
|
|
322
|
+
* The item's display name as seen from `workspaceId` (its home, or a
|
|
323
|
+
* workspace it is projected into): the provider resolves the home and its
|
|
324
|
+
* OPEN cipher itself. `null` when it is gone or unreadable. What a window
|
|
325
|
+
* onto a projected project shows for a link it cannot open: a name, never
|
|
326
|
+
* an id.
|
|
315
327
|
*/
|
|
316
328
|
labelOf(serviceId: number, workspaceId: number): Promise<string | null>;
|
|
317
329
|
}
|
package/src/sdk/server.ts
CHANGED
|
@@ -981,6 +981,9 @@ function ownerFilter(cell: MovableCell): string {
|
|
|
981
981
|
: `${cell.ownerColumn} = ?`;
|
|
982
982
|
}
|
|
983
983
|
|
|
984
|
+
/** Rows rewritten per `UPDATE` by {@link resealCells}. */
|
|
985
|
+
const RESEAL_BATCH = 100;
|
|
986
|
+
|
|
984
987
|
/** How many cells {@link resealCells} would convert: a `plan`'s `rows`. */
|
|
985
988
|
export async function countMovableCells(
|
|
986
989
|
q: SdkQueryable,
|
|
@@ -1035,13 +1038,22 @@ export async function resealCells(
|
|
|
1035
1038
|
}
|
|
1036
1039
|
}
|
|
1037
1040
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1041
|
+
// Par paquets et non ligne à ligne : un dépôt de quelques milliers de
|
|
1042
|
+
// commits vaut autant d'allers-retours, et le geste doit tenir en secondes.
|
|
1043
|
+
for (const cell of cells) {
|
|
1044
|
+
const mine = pending.filter((p) => p.cell === cell);
|
|
1045
|
+
for (let at = 0; at < mine.length; at += RESEAL_BATCH) {
|
|
1046
|
+
const batch = mine.slice(at, at + RESEAL_BATCH);
|
|
1047
|
+
const cases = batch.map(() => 'WHEN ? THEN ?').join(' ');
|
|
1048
|
+
const ids = batch.map(() => '?').join(', ');
|
|
1049
|
+
// La garde du propriétaire dans le `WHERE` même quand l'identifiant
|
|
1050
|
+
// suffit : une conversion ne peut alors pas déborder sur un voisin.
|
|
1051
|
+
await q.execute(
|
|
1052
|
+
`UPDATE ${cell.table} SET ${cell.column} = CASE ${cell.idColumn} ${cases} END
|
|
1053
|
+
WHERE ${cell.idColumn} IN (${ids}) AND ${ownerFilter(cell)}`,
|
|
1054
|
+
[...batch.flatMap((p) => [p.id, p.value]), ...batch.map((p) => p.id), ownerId]
|
|
1055
|
+
);
|
|
1056
|
+
}
|
|
1045
1057
|
}
|
|
1046
1058
|
return pending.length;
|
|
1047
1059
|
}
|