@tearleads/client-sdk 0.1.36 → 0.1.37
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/client/Tearleads.d.ts +4 -3
- package/client/Tearleads.js +4 -3
- package/client/Tearleads.js.map +1 -1
- package/internal/api-client/ApiClient.d.ts +3 -0
- package/internal/api-client/ApiClient.js +10 -7
- package/internal/api-client/ApiClient.js.map +1 -1
- package/internal/api-client/webSocketTickets.js +45 -0
- package/internal/api-client/webSocketTickets.js.map +1 -0
- package/internal/validators/operation/auth.d.ts +20 -0
- package/internal/validators/realtime/index.js +2 -2
- package/internal/validators/realtime/index.js.map +1 -1
- package/internal/validators/realtime/wsServerFrames.js +3 -8
- package/internal/validators/realtime/wsServerFrames.js.map +1 -1
- package/internal/validators/realtime/wsShared.js +6 -0
- package/internal/validators/realtime/wsShared.js.map +1 -1
- package/internal/validators/response/auth/verify.d.ts +8 -0
- package/internal/validators/response/auth/verify.js +3 -0
- package/internal/validators/response/auth/verify.js.map +1 -1
- package/package.json +1 -1
- package/stores/documents/documentStore.js +3 -3
- package/stores/documents/documentStore.js.map +1 -1
- package/sync/reconciliation/service.js +22 -12
- package/sync/reconciliation/service.js.map +1 -1
- package/sync/reconciliation/serviceTypes.d.ts +10 -1
- package/sync/reconciliation/serviceTypes.js.map +1 -1
- package/workflows/runtimeInput.d.ts +4 -3
- package/workflows/runtimeInput.js.map +1 -1
|
@@ -124,6 +124,7 @@ export declare const verifyOperation: Omit<{
|
|
|
124
124
|
rootContainerId?: undefined;
|
|
125
125
|
token?: undefined;
|
|
126
126
|
userId?: undefined;
|
|
127
|
+
wsTicket?: undefined;
|
|
127
128
|
}, {
|
|
128
129
|
authenticated: false;
|
|
129
130
|
error?: string | undefined;
|
|
@@ -132,6 +133,7 @@ export declare const verifyOperation: Omit<{
|
|
|
132
133
|
rootContainerId?: undefined;
|
|
133
134
|
token?: undefined;
|
|
134
135
|
userId?: undefined;
|
|
136
|
+
wsTicket?: undefined;
|
|
135
137
|
}, z.core.$ZodTypeInternals<{
|
|
136
138
|
authenticated: false;
|
|
137
139
|
error?: string | undefined;
|
|
@@ -140,6 +142,7 @@ export declare const verifyOperation: Omit<{
|
|
|
140
142
|
rootContainerId?: undefined;
|
|
141
143
|
token?: undefined;
|
|
142
144
|
userId?: undefined;
|
|
145
|
+
wsTicket?: undefined;
|
|
143
146
|
}, {
|
|
144
147
|
authenticated: false;
|
|
145
148
|
error?: string | undefined;
|
|
@@ -148,6 +151,7 @@ export declare const verifyOperation: Omit<{
|
|
|
148
151
|
rootContainerId?: undefined;
|
|
149
152
|
token?: undefined;
|
|
150
153
|
userId?: undefined;
|
|
154
|
+
wsTicket?: undefined;
|
|
151
155
|
}>>;
|
|
152
156
|
readonly 404: z.ZodType<{
|
|
153
157
|
authenticated: false;
|
|
@@ -157,6 +161,7 @@ export declare const verifyOperation: Omit<{
|
|
|
157
161
|
rootContainerId?: undefined;
|
|
158
162
|
token?: undefined;
|
|
159
163
|
userId?: undefined;
|
|
164
|
+
wsTicket?: undefined;
|
|
160
165
|
}, {
|
|
161
166
|
authenticated: false;
|
|
162
167
|
error?: string | undefined;
|
|
@@ -165,6 +170,7 @@ export declare const verifyOperation: Omit<{
|
|
|
165
170
|
rootContainerId?: undefined;
|
|
166
171
|
token?: undefined;
|
|
167
172
|
userId?: undefined;
|
|
173
|
+
wsTicket?: undefined;
|
|
168
174
|
}, z.core.$ZodTypeInternals<{
|
|
169
175
|
authenticated: false;
|
|
170
176
|
error?: string | undefined;
|
|
@@ -173,6 +179,7 @@ export declare const verifyOperation: Omit<{
|
|
|
173
179
|
rootContainerId?: undefined;
|
|
174
180
|
token?: undefined;
|
|
175
181
|
userId?: undefined;
|
|
182
|
+
wsTicket?: undefined;
|
|
176
183
|
}, {
|
|
177
184
|
authenticated: false;
|
|
178
185
|
error?: string | undefined;
|
|
@@ -181,6 +188,7 @@ export declare const verifyOperation: Omit<{
|
|
|
181
188
|
rootContainerId?: undefined;
|
|
182
189
|
token?: undefined;
|
|
183
190
|
userId?: undefined;
|
|
191
|
+
wsTicket?: undefined;
|
|
184
192
|
}>>;
|
|
185
193
|
readonly 500: z.ZodType<{
|
|
186
194
|
error: string;
|
|
@@ -205,6 +213,7 @@ export declare const verifyOperation: Omit<{
|
|
|
205
213
|
rootContainerId: string | null;
|
|
206
214
|
token: string;
|
|
207
215
|
userId: string;
|
|
216
|
+
wsTicket: string;
|
|
208
217
|
error?: undefined;
|
|
209
218
|
}, {
|
|
210
219
|
authenticated: true;
|
|
@@ -213,6 +222,7 @@ export declare const verifyOperation: Omit<{
|
|
|
213
222
|
rootContainerId: string | null;
|
|
214
223
|
token: string;
|
|
215
224
|
userId: string;
|
|
225
|
+
wsTicket: string;
|
|
216
226
|
error?: undefined;
|
|
217
227
|
}, z.core.$ZodTypeInternals<{
|
|
218
228
|
authenticated: true;
|
|
@@ -221,6 +231,7 @@ export declare const verifyOperation: Omit<{
|
|
|
221
231
|
rootContainerId: string | null;
|
|
222
232
|
token: string;
|
|
223
233
|
userId: string;
|
|
234
|
+
wsTicket: string;
|
|
224
235
|
error?: undefined;
|
|
225
236
|
}, {
|
|
226
237
|
authenticated: true;
|
|
@@ -229,6 +240,7 @@ export declare const verifyOperation: Omit<{
|
|
|
229
240
|
rootContainerId: string | null;
|
|
230
241
|
token: string;
|
|
231
242
|
userId: string;
|
|
243
|
+
wsTicket: string;
|
|
232
244
|
error?: undefined;
|
|
233
245
|
}>>;
|
|
234
246
|
};
|
|
@@ -251,6 +263,7 @@ export declare const verifyOperation: Omit<{
|
|
|
251
263
|
rootContainerId?: undefined;
|
|
252
264
|
token?: undefined;
|
|
253
265
|
userId?: undefined;
|
|
266
|
+
wsTicket?: undefined;
|
|
254
267
|
}, {
|
|
255
268
|
authenticated: false;
|
|
256
269
|
error?: string | undefined;
|
|
@@ -259,6 +272,7 @@ export declare const verifyOperation: Omit<{
|
|
|
259
272
|
rootContainerId?: undefined;
|
|
260
273
|
token?: undefined;
|
|
261
274
|
userId?: undefined;
|
|
275
|
+
wsTicket?: undefined;
|
|
262
276
|
}, z.core.$ZodTypeInternals<{
|
|
263
277
|
authenticated: false;
|
|
264
278
|
error?: string | undefined;
|
|
@@ -267,6 +281,7 @@ export declare const verifyOperation: Omit<{
|
|
|
267
281
|
rootContainerId?: undefined;
|
|
268
282
|
token?: undefined;
|
|
269
283
|
userId?: undefined;
|
|
284
|
+
wsTicket?: undefined;
|
|
270
285
|
}, {
|
|
271
286
|
authenticated: false;
|
|
272
287
|
error?: string | undefined;
|
|
@@ -275,6 +290,7 @@ export declare const verifyOperation: Omit<{
|
|
|
275
290
|
rootContainerId?: undefined;
|
|
276
291
|
token?: undefined;
|
|
277
292
|
userId?: undefined;
|
|
293
|
+
wsTicket?: undefined;
|
|
278
294
|
}>>;
|
|
279
295
|
readonly 404: z.ZodType<{
|
|
280
296
|
authenticated: false;
|
|
@@ -284,6 +300,7 @@ export declare const verifyOperation: Omit<{
|
|
|
284
300
|
rootContainerId?: undefined;
|
|
285
301
|
token?: undefined;
|
|
286
302
|
userId?: undefined;
|
|
303
|
+
wsTicket?: undefined;
|
|
287
304
|
}, {
|
|
288
305
|
authenticated: false;
|
|
289
306
|
error?: string | undefined;
|
|
@@ -292,6 +309,7 @@ export declare const verifyOperation: Omit<{
|
|
|
292
309
|
rootContainerId?: undefined;
|
|
293
310
|
token?: undefined;
|
|
294
311
|
userId?: undefined;
|
|
312
|
+
wsTicket?: undefined;
|
|
295
313
|
}, z.core.$ZodTypeInternals<{
|
|
296
314
|
authenticated: false;
|
|
297
315
|
error?: string | undefined;
|
|
@@ -300,6 +318,7 @@ export declare const verifyOperation: Omit<{
|
|
|
300
318
|
rootContainerId?: undefined;
|
|
301
319
|
token?: undefined;
|
|
302
320
|
userId?: undefined;
|
|
321
|
+
wsTicket?: undefined;
|
|
303
322
|
}, {
|
|
304
323
|
authenticated: false;
|
|
305
324
|
error?: string | undefined;
|
|
@@ -308,6 +327,7 @@ export declare const verifyOperation: Omit<{
|
|
|
308
327
|
rootContainerId?: undefined;
|
|
309
328
|
token?: undefined;
|
|
310
329
|
userId?: undefined;
|
|
330
|
+
wsTicket?: undefined;
|
|
311
331
|
}>>;
|
|
312
332
|
readonly 500: z.ZodType<{
|
|
313
333
|
error: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { MAX_WS_CLIENT_MESSAGE_BYTES, MAX_WS_INTEREST_CONTAINER_IDS, parseWsClientDeclaration, serializeWsClientDeclaration, WsClientDeclarationSchema, WsKnownContainersAddSchema, WsKnownContainersRemoveSchema, WsKnownContainersReplaceSchema, WsKnownOrganizationsReplaceSchema, } from "./wsClientDeclarations.js";
|
|
2
2
|
export { WsContainerMutationCreatedHintSchema, WsDocumentMutationCreatedHintSchema, WsDocumentUpdateCreatedHintSchema, WsInvalidationHintSchema, WsSharedWithYouHintSchema, WsUserRegisteredHintSchema, } from "./wsInvalidationHints.js";
|
|
3
|
-
export { parseWsServerMessage, serializeWsServerMessage,
|
|
4
|
-
export { MAX_WS_DECLARATION_ID_LENGTH } from "./wsShared.js";
|
|
3
|
+
export { parseWsServerMessage, serializeWsServerMessage, WsKnownContainersAckFrameSchema, WsKnownOrganizationsAckFrameSchema, WsOrganizationReadModelAccessRevokedFrameSchema, WsOrganizationReadModelChangedFrameSchema, WsResyncRequiredFrameSchema, WsServerControlFrameSchema, WsServerMessageSchema, } from "./wsServerFrames.js";
|
|
4
|
+
export { MAX_WS_DECLARATION_ID_LENGTH, WS_TICKET_TTL_SECONDS, } from "./wsShared.js";
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,wBAAwB,EACxB,4BAA4B,EAE5B,yBAAyB,EACzB,0BAA0B,EAC1B,6BAA6B,EAC7B,8BAA8B,EAC9B,iCAAiC,GAClC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,oCAAoC,EACpC,mCAAmC,EACnC,iCAAiC,EAEjC,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,wBAAwB,EACxB,4BAA4B,EAE5B,yBAAyB,EACzB,0BAA0B,EAC1B,6BAA6B,EAC7B,8BAA8B,EAC9B,iCAAiC,GAClC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,oCAAoC,EACpC,mCAAmC,EACnC,iCAAiC,EAEjC,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,+BAA+B,EAC/B,kCAAkC,EAClC,+CAA+C,EAC/C,yCAAyC,EACzC,2BAA2B,EAE3B,0BAA0B,EAE1B,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,YAAY,CAAC","sourcesContent":["export {\n MAX_WS_CLIENT_MESSAGE_BYTES,\n MAX_WS_INTEREST_CONTAINER_IDS,\n parseWsClientDeclaration,\n serializeWsClientDeclaration,\n type WsClientDeclaration,\n WsClientDeclarationSchema,\n WsKnownContainersAddSchema,\n WsKnownContainersRemoveSchema,\n WsKnownContainersReplaceSchema,\n WsKnownOrganizationsReplaceSchema,\n} from \"./wsClientDeclarations\";\nexport {\n WsContainerMutationCreatedHintSchema,\n WsDocumentMutationCreatedHintSchema,\n WsDocumentUpdateCreatedHintSchema,\n type WsInvalidationHint,\n WsInvalidationHintSchema,\n WsSharedWithYouHintSchema,\n WsUserRegisteredHintSchema,\n} from \"./wsInvalidationHints\";\nexport {\n parseWsServerMessage,\n serializeWsServerMessage,\n WsKnownContainersAckFrameSchema,\n WsKnownOrganizationsAckFrameSchema,\n WsOrganizationReadModelAccessRevokedFrameSchema,\n WsOrganizationReadModelChangedFrameSchema,\n WsResyncRequiredFrameSchema,\n type WsServerControlFrame,\n WsServerControlFrameSchema,\n type WsServerMessage,\n WsServerMessageSchema,\n} from \"./wsServerFrames\";\nexport {\n MAX_WS_DECLARATION_ID_LENGTH,\n WS_TICKET_TTL_SECONDS,\n} from \"./wsShared\";\n"]}
|
|
@@ -8,13 +8,9 @@ import { parseWsJson, wsDeclarationIdSchema } from "./wsShared.js";
|
|
|
8
8
|
* routed server events. Together with the hints they form the complete set of
|
|
9
9
|
* frames a client may receive; anything else fails closed on both sides.
|
|
10
10
|
*/
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
export const WsInterestStateFrameSchema = z.object({
|
|
15
|
-
type: z.literal("interest_state"),
|
|
16
|
-
containerIds: z.array(z.string().min(1)),
|
|
17
|
-
});
|
|
11
|
+
// A socket opens with no container interest. The acknowledgement of its first
|
|
12
|
+
// authoritative declaration is the client's ordering barrier for closing the
|
|
13
|
+
// lossy reconnect interval.
|
|
18
14
|
export const WsKnownContainersAckFrameSchema = z.object({
|
|
19
15
|
type: z.literal("known_containers_ack"),
|
|
20
16
|
containerIds: z.array(z.string().min(1)),
|
|
@@ -42,7 +38,6 @@ export const WsOrganizationReadModelAccessRevokedFrameSchema = z.object({
|
|
|
42
38
|
organizationId: uuidV4StringSchema,
|
|
43
39
|
});
|
|
44
40
|
export const WsServerControlFrameSchema = z.discriminatedUnion("type", [
|
|
45
|
-
WsInterestStateFrameSchema,
|
|
46
41
|
WsKnownContainersAckFrameSchema,
|
|
47
42
|
WsKnownOrganizationsAckFrameSchema,
|
|
48
43
|
WsResyncRequiredFrameSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsServerFrames.js","sourceRoot":"","sources":["wsServerFrames.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idationHintSchema,\n} from \"./wsInvalidationHints\";\nimport { parseWsJson, wsDeclarationIdSchema } from \"./wsShared\";\n\n/**\n * Server→client websocket control frames: connection/interest lifecycle and\n * resync signals, as opposed to the invalidation hints that fan out interest-\n * routed server events. Together with the hints they form the complete set of\n * frames a client may receive; anything else fails closed on both sides.\n */\n\n// A socket opens with no container interest. The acknowledgement of its first\n// authoritative declaration is the client's ordering barrier for closing the\n// lossy reconnect interval.\nexport const WsKnownContainersAckFrameSchema = z.object({\n type: z.literal(\"known_containers_ack\"),\n containerIds: z.array(z.string().min(1)),\n declarationId: wsDeclarationIdSchema,\n});\n\nexport const WsKnownOrganizationsAckFrameSchema = z.object({\n type: z.literal(\"known_organizations_ack\"),\n declarationId: wsDeclarationIdSchema,\n organizationId: uuidV4StringSchema.nullable(),\n authorized: z.boolean(),\n});\n\n// A container's access changed; the client must reconcile it over HTTP and, if\n// still authorized, re-declare interest.\nexport const WsResyncRequiredFrameSchema = z.object({\n type: z.literal(\"resync_required\"),\n containerIds: z.array(z.string().min(1)).min(1),\n});\n\nexport const WsOrganizationReadModelChangedFrameSchema = z.object({\n type: z.literal(\"organization_read_model_changed\"),\n organizationId: uuidV4StringSchema,\n originatedFromSession: z.boolean(),\n});\n\nexport const WsOrganizationReadModelAccessRevokedFrameSchema = z.object({\n type: z.literal(\"organization_read_model_access_revoked\"),\n organizationId: uuidV4StringSchema,\n});\n\nexport const WsServerControlFrameSchema = z.discriminatedUnion(\"type\", [\n WsKnownContainersAckFrameSchema,\n WsKnownOrganizationsAckFrameSchema,\n WsResyncRequiredFrameSchema,\n WsOrganizationReadModelChangedFrameSchema,\n WsOrganizationReadModelAccessRevokedFrameSchema,\n]);\n\nexport type WsServerControlFrame = z.infer<typeof WsServerControlFrameSchema>;\n\nexport const WsServerMessageSchema = z.discriminatedUnion(\"type\", [\n ...WsServerControlFrameSchema.options,\n ...WsInvalidationHintSchema.options,\n]);\n\nexport type WsServerMessage = WsServerControlFrame | WsInvalidationHint;\n\n/** The single typed egress: the server cannot serialize an undeclared frame. */\nexport function serializeWsServerMessage(message: WsServerMessage): string {\n return JSON.stringify(message);\n}\n\n/** Malformed and unknown-tag server frames fail closed to null. */\nexport function parseWsServerMessage(\n rawMessage: string,\n): WsServerMessage | null {\n return parseWsJson(WsServerMessageSchema, rawMessage);\n}\n"]}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export const MAX_WS_DECLARATION_ID_LENGTH = 128;
|
|
3
|
+
/**
|
|
4
|
+
* Lifetime of a single-use websocket upgrade ticket. `POST /auth/verify`
|
|
5
|
+
* returns one for the first connect after login; later connects mint their own
|
|
6
|
+
* through `POST /auth/ws-ticket`.
|
|
7
|
+
*/
|
|
8
|
+
export const WS_TICKET_TTL_SECONDS = 60;
|
|
3
9
|
export const wsDeclarationIdSchema = z
|
|
4
10
|
.string()
|
|
5
11
|
.min(1)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsShared.js","sourceRoot":"","sources":["wsShared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAEhD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC;KACnC,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAErC,MAAM,UAAU,WAAW,CACzB,MAAc,EACd,UAAkB;IAElB,IAAI,KAAc,CAAC;IACnB,IAAI,CAAC;QACH,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC","sourcesContent":["import { z } from \"zod\";\n\nexport const MAX_WS_DECLARATION_ID_LENGTH = 128;\n\nexport const wsDeclarationIdSchema = z\n .string()\n .min(1)\n .max(MAX_WS_DECLARATION_ID_LENGTH);\n\nexport function parseWsJson<Schema extends z.ZodType>(\n schema: Schema,\n rawMessage: string,\n): z.output<Schema> | null {\n let value: unknown;\n try {\n value = JSON.parse(rawMessage);\n } catch {\n return null;\n }\n const parsed = schema.safeParse(value);\n return parsed.success ? parsed.data : null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"wsShared.js","sourceRoot":"","sources":["wsShared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAExC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC;KACnC,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAErC,MAAM,UAAU,WAAW,CACzB,MAAc,EACd,UAAkB;IAElB,IAAI,KAAc,CAAC;IACnB,IAAI,CAAC;QACH,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC","sourcesContent":["import { z } from \"zod\";\n\nexport const MAX_WS_DECLARATION_ID_LENGTH = 128;\n\n/**\n * Lifetime of a single-use websocket upgrade ticket. `POST /auth/verify`\n * returns one for the first connect after login; later connects mint their own\n * through `POST /auth/ws-ticket`.\n */\nexport const WS_TICKET_TTL_SECONDS = 60;\n\nexport const wsDeclarationIdSchema = z\n .string()\n .min(1)\n .max(MAX_WS_DECLARATION_ID_LENGTH);\n\nexport function parseWsJson<Schema extends z.ZodType>(\n schema: Schema,\n rawMessage: string,\n): z.output<Schema> | null {\n let value: unknown;\n try {\n value = JSON.parse(rawMessage);\n } catch {\n return null;\n }\n const parsed = schema.safeParse(value);\n return parsed.success ? parsed.data : null;\n}\n"]}
|
|
@@ -6,6 +6,7 @@ export declare const VerifySuccessResponseSchema: z.ZodType<{
|
|
|
6
6
|
rootContainerId: string | null;
|
|
7
7
|
token: string;
|
|
8
8
|
userId: string;
|
|
9
|
+
wsTicket: string;
|
|
9
10
|
error?: undefined;
|
|
10
11
|
}, {
|
|
11
12
|
authenticated: true;
|
|
@@ -14,6 +15,7 @@ export declare const VerifySuccessResponseSchema: z.ZodType<{
|
|
|
14
15
|
rootContainerId: string | null;
|
|
15
16
|
token: string;
|
|
16
17
|
userId: string;
|
|
18
|
+
wsTicket: string;
|
|
17
19
|
error?: undefined;
|
|
18
20
|
}, z.core.$ZodTypeInternals<{
|
|
19
21
|
authenticated: true;
|
|
@@ -22,6 +24,7 @@ export declare const VerifySuccessResponseSchema: z.ZodType<{
|
|
|
22
24
|
rootContainerId: string | null;
|
|
23
25
|
token: string;
|
|
24
26
|
userId: string;
|
|
27
|
+
wsTicket: string;
|
|
25
28
|
error?: undefined;
|
|
26
29
|
}, {
|
|
27
30
|
authenticated: true;
|
|
@@ -30,6 +33,7 @@ export declare const VerifySuccessResponseSchema: z.ZodType<{
|
|
|
30
33
|
rootContainerId: string | null;
|
|
31
34
|
token: string;
|
|
32
35
|
userId: string;
|
|
36
|
+
wsTicket: string;
|
|
33
37
|
error?: undefined;
|
|
34
38
|
}>>;
|
|
35
39
|
export declare const VerifyFailureResponseSchema: z.ZodType<{
|
|
@@ -40,6 +44,7 @@ export declare const VerifyFailureResponseSchema: z.ZodType<{
|
|
|
40
44
|
rootContainerId?: undefined;
|
|
41
45
|
token?: undefined;
|
|
42
46
|
userId?: undefined;
|
|
47
|
+
wsTicket?: undefined;
|
|
43
48
|
}, {
|
|
44
49
|
authenticated: false;
|
|
45
50
|
error?: string | undefined;
|
|
@@ -48,6 +53,7 @@ export declare const VerifyFailureResponseSchema: z.ZodType<{
|
|
|
48
53
|
rootContainerId?: undefined;
|
|
49
54
|
token?: undefined;
|
|
50
55
|
userId?: undefined;
|
|
56
|
+
wsTicket?: undefined;
|
|
51
57
|
}, z.core.$ZodTypeInternals<{
|
|
52
58
|
authenticated: false;
|
|
53
59
|
error?: string | undefined;
|
|
@@ -56,6 +62,7 @@ export declare const VerifyFailureResponseSchema: z.ZodType<{
|
|
|
56
62
|
rootContainerId?: undefined;
|
|
57
63
|
token?: undefined;
|
|
58
64
|
userId?: undefined;
|
|
65
|
+
wsTicket?: undefined;
|
|
59
66
|
}, {
|
|
60
67
|
authenticated: false;
|
|
61
68
|
error?: string | undefined;
|
|
@@ -64,6 +71,7 @@ export declare const VerifyFailureResponseSchema: z.ZodType<{
|
|
|
64
71
|
rootContainerId?: undefined;
|
|
65
72
|
token?: undefined;
|
|
66
73
|
userId?: undefined;
|
|
74
|
+
wsTicket?: undefined;
|
|
67
75
|
}>>;
|
|
68
76
|
export type VerifySuccessResponse = z.infer<typeof VerifySuccessResponseSchema>;
|
|
69
77
|
export type VerifyFailureResponse = z.infer<typeof VerifyFailureResponseSchema>;
|
|
@@ -9,6 +9,8 @@ export const VerifySuccessResponseSchema = loosePlainObject({
|
|
|
9
9
|
rootContainerId: nonEmptyStringSchema.nullable(),
|
|
10
10
|
token: nonEmptyStringSchema,
|
|
11
11
|
userId: nonEmptyStringSchema,
|
|
12
|
+
/** Single-use upgrade ticket for this session's first websocket connect. */
|
|
13
|
+
wsTicket: nonEmptyStringSchema,
|
|
12
14
|
});
|
|
13
15
|
export const VerifyFailureResponseSchema = loosePlainObject({
|
|
14
16
|
authenticated: z.literal(false),
|
|
@@ -18,6 +20,7 @@ export const VerifyFailureResponseSchema = loosePlainObject({
|
|
|
18
20
|
rootContainerId: z.never().optional(),
|
|
19
21
|
token: z.never().optional(),
|
|
20
22
|
userId: z.never().optional(),
|
|
23
|
+
wsTicket: z.never().optional(),
|
|
21
24
|
});
|
|
22
25
|
export function isVerifyResponse(value) {
|
|
23
26
|
return (VerifySuccessResponseSchema.safeParse(value).success ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.js","sourceRoot":"","sources":["verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,CAAC,MAAM,2BAA2B,GAAG,gBAAgB,CAAC;IAC1D,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;IAC9B,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;IAC3B,4EAA4E;IAC5E,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;IACnB,cAAc,EAAE,oBAAoB;IACpC,eAAe,EAAE,oBAAoB,CAAC,QAAQ,EAAE;IAChD,KAAK,EAAE,oBAAoB;IAC3B,MAAM,EAAE,oBAAoB;
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,CAAC,MAAM,2BAA2B,GAAG,gBAAgB,CAAC;IAC1D,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;IAC9B,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;IAC3B,4EAA4E;IAC5E,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;IACnB,cAAc,EAAE,oBAAoB;IACpC,eAAe,EAAE,oBAAoB,CAAC,QAAQ,EAAE;IAChD,KAAK,EAAE,oBAAoB;IAC3B,MAAM,EAAE,oBAAoB;IAC5B,4EAA4E;IAC5E,QAAQ,EAAE,oBAAoB;CAC/B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG,gBAAgB,CAAC;IAC1D,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAC/B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;IAC5B,cAAc,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;IACpC,eAAe,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;IACrC,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;IAC3B,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;IAC5B,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC;AAMH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,CACL,2BAA2B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO;QACpD,2BAA2B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CACrD,CAAC;AACJ,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { loosePlainObject, nonEmptyStringSchema } from \"../../schema\";\n\nexport const VerifySuccessResponseSchema = loosePlainObject({\n authenticated: z.literal(true),\n error: z.never().optional(),\n /** Platform-operator flag; gates the root console, enforced server-side. */\n isRoot: z.boolean(),\n organizationId: nonEmptyStringSchema,\n rootContainerId: nonEmptyStringSchema.nullable(),\n token: nonEmptyStringSchema,\n userId: nonEmptyStringSchema,\n /** Single-use upgrade ticket for this session's first websocket connect. */\n wsTicket: nonEmptyStringSchema,\n});\n\nexport const VerifyFailureResponseSchema = loosePlainObject({\n authenticated: z.literal(false),\n error: z.string().optional(),\n isRoot: z.never().optional(),\n organizationId: z.never().optional(),\n rootContainerId: z.never().optional(),\n token: z.never().optional(),\n userId: z.never().optional(),\n wsTicket: z.never().optional(),\n});\n\nexport type VerifySuccessResponse = z.infer<typeof VerifySuccessResponseSchema>;\nexport type VerifyFailureResponse = z.infer<typeof VerifyFailureResponseSchema>;\nexport type VerifyResponse = VerifySuccessResponse | VerifyFailureResponse;\n\nexport function isVerifyResponse(value: unknown): value is VerifyResponse {\n return (\n VerifySuccessResponseSchema.safeParse(value).success ||\n VerifyFailureResponseSchema.safeParse(value).success\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -57,9 +57,9 @@ function updateDocumentStoreRuntime(state, nextRuntime, scheduleSync) {
|
|
|
57
57
|
if (state.snapshot.ready) {
|
|
58
58
|
if (serverEventsReconnected) {
|
|
59
59
|
// The invalidation stream is lossy while disconnected. Once the server
|
|
60
|
-
// has
|
|
61
|
-
// remote document needs one HTTP probe to cover peer
|
|
62
|
-
// the gap. This also closes iOS background/resume reconnects where the
|
|
60
|
+
// has acknowledged this socket's authoritative interest declaration,
|
|
61
|
+
// every already-open remote document needs one HTTP probe to cover peer
|
|
62
|
+
// writes made during the gap. This also closes iOS background/resume reconnects where the
|
|
63
63
|
// native network source remained online throughout.
|
|
64
64
|
requestRemoteDocumentStoreSync(state, scheduleSync);
|
|
65
65
|
logRevalidationScheduled(state.runtime, "reconnect");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentStore.js","sourceRoot":"","sources":["documentStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAG/E,OAAO,EACL,uCAAuC,EAEvC,2BAA2B,EAC3B,qCAAqC,EACrC,0BAA0B,EAC1B,8BAA8B,GAC/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CAAC,OAAO,CAAC,CAAC;IAC7B,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { DEFAULT_DOCUMENT_KIND } from \"../../data/documents/documentConstants\";\nimport type { StoredDocumentKind } from \"../../data/documents/documentKinds\";\nimport type { DomainScope } from \"../../data/domainScope\";\nimport {\n createDocumentProjectionUserKeyResolver,\n type DocumentsPersistence,\n defaultDocumentsPersistence,\n didDocumentProjectionKeyRuntimeChange,\n didRegainSyncPrerequisites,\n requestDocumentSyncLaneAndWait,\n} from \"../../workflows/documents\";\nimport { removeAttachmentFromDocumentStore } from \"./documentStore/attachmentRemoval\";\nimport {\n attachFilesToDocumentStore,\n replaceAttachmentInDocumentStore,\n} from \"./documentStore/attachments\";\nimport { discardDocumentStoreLocalState } from \"./documentStore/discard\";\nimport {\n ensureDocumentStoreInitialized,\n ensureDocumentStoreReady,\n relinkDocumentStore,\n} from \"./documentStore/initialization\";\nimport { registerInternalDocumentRelink } from \"./documentStore/internalRelink\";\nimport {\n setDocumentStructuredFields,\n setDocumentText,\n} from \"./documentStore/mutations\";\nimport { logRevalidationScheduled } from \"./documentStore/remoteRevalidationTelemetry\";\nimport { assertDocumentStoreCanRotateContentKey } from \"./documentStore/rotation\";\nimport {\n addRowToDocumentStore,\n removeRowFromDocumentStore,\n updateRowInDocumentStore,\n} from \"./documentStore/rows\";\nimport {\n createDocumentStoreState,\n type DocumentStoreState,\n refreshAttachabilitySnapshot,\n resetDocumentStore,\n subscribeToDocumentStore,\n} from \"./documentStore/state\";\nimport { registerDocumentStoreSyncLane } from \"./documentStore/sync\";\nimport {\n allowDocumentStoreRemoteSync,\n captureDocumentStoreRemoteSyncRequestGeneration,\n captureDocumentStoreSyncLaneGeneration,\n type DocumentStoreRemoteSyncRequestGeneration,\n type DocumentStoreSyncLaneGeneration,\n didDocumentStoreRemoteSyncRequestComplete,\n hasPendingIndependentDocumentStoreRemoteSync,\n invalidateDocumentStoreRemoteSync,\n invalidateDocumentStoreSyncLane,\n isDocumentStoreRemoteSyncBlocked,\n isDocumentStoreRemoteSyncRequestGenerationCurrent,\n markDocumentStoreRemoteSyncPending,\n registerDocumentStoreRemoteSyncWaiter,\n} from \"./documentStore/syncGeneration\";\nimport { handleDocumentRemoteEvents } from \"./documentStore/syncRemoteSignals\";\nimport {\n createDocumentStoreFacade,\n emitPersistedDocument,\n getOrCreateDocumentStoreRegistry,\n registerDocumentStore,\n registerDocumentStoreIdentity,\n requestDocumentStoreSync,\n resolveDocumentStoreKey,\n} from \"./registry\";\nimport type {\n DocumentAttachmentUpload,\n DocumentStore,\n DocumentStoreFacade,\n DocumentStoreOpenOptions,\n DocumentsRuntime,\n} from \"./types\";\n\nexport {\n discardRegisteredDocumentLocalState,\n requestDomainDocumentSync,\n subscribeToPersistedDocuments,\n} from \"./registry\";\n\nfunction refreshDocumentStoreSyncLane(\n state: DocumentStoreState,\n force = false,\n): void {\n if (!force && state.syncLane && !state.syncLane.isDisposed?.()) {\n return;\n }\n if (state.syncLane) {\n invalidateDocumentStoreSyncLane(state);\n }\n let syncLaneGeneration: DocumentStoreSyncLaneGeneration | null = null;\n state.syncLane = registerDocumentStoreSyncLane(\n state,\n () => syncLaneGeneration,\n );\n syncLaneGeneration = captureDocumentStoreSyncLaneGeneration(state);\n}\n\nfunction updateDocumentStoreRuntime(\n state: DocumentStoreState,\n nextRuntime: DocumentsRuntime,\n scheduleSync: () => void,\n) {\n const previousRuntime = state.runtime;\n const serverEventsReconnected =\n (nextRuntime.state.serverEventsConnectionGeneration ?? 0) >\n (previousRuntime.state.serverEventsConnectionGeneration ?? 0);\n const domainScopeChanged =\n previousRuntime.state.domainScope !== nextRuntime.state.domainScope;\n const projectionKeyRuntimeChanged = didDocumentProjectionKeyRuntimeChange(\n previousRuntime,\n nextRuntime,\n );\n if (projectionKeyRuntimeChanged) {\n state.resolveProjectionUserKey =\n createDocumentProjectionUserKeyResolver(nextRuntime);\n state.writerProjection = null;\n }\n state.runtime = nextRuntime;\n refreshDocumentStoreSyncLane(state, domainScopeChanged);\n if (domainScopeChanged) {\n state.locallyAcceptedUpdateIds = new Set();\n state.remoteUpdatePending = false;\n state.writerProjection = null;\n }\n\n if (nextRuntime.infra.dbStatus !== \"ready\") {\n if (state.snapshot.ready || state.initialized || state.initializePromise) {\n resetDocumentStore(state);\n }\n state.lastEventCount = nextRuntime.state.events.length;\n return;\n }\n\n refreshAttachabilitySnapshot(state);\n ensureDocumentStoreInitialized(state, scheduleSync);\n handleDocumentRemoteEvents(state, scheduleSync);\n\n if (state.snapshot.ready) {\n if (serverEventsReconnected) {\n // The invalidation stream is lossy while disconnected. Once the server\n // has restored this session's interest baseline, every already-open\n // remote document needs one HTTP probe to cover peer writes made during\n // the gap. This also closes iOS background/resume reconnects where the\n // native network source remained online throughout.\n requestRemoteDocumentStoreSync(state, scheduleSync);\n logRevalidationScheduled(state.runtime, \"reconnect\");\n } else if (didRegainSyncPrerequisites(previousRuntime, state.runtime)) {\n scheduleSync();\n }\n }\n}\n\nfunction requestRemoteDocumentStoreSync(\n state: DocumentStoreState,\n scheduleSync: () => void,\n owner: \"independent\" | \"waiter\" = \"independent\",\n): number {\n allowDocumentStoreRemoteSync(state);\n const signalSequence = markDocumentStoreRemoteSyncPending(state, owner);\n scheduleSync();\n return signalSequence;\n}\n\nfunction requestOrdinaryDocumentStoreSync(\n state: DocumentStoreState,\n scheduleSync: () => void,\n): void {\n // A normal UI reopen is a fresh owner for remote-only work. It may recover\n // a probe that an earlier, now-unmounted owner aborted.\n if (isDocumentStoreRemoteSyncBlocked(state)) {\n requestRemoteDocumentStoreSync(state, scheduleSync);\n return;\n }\n scheduleSync();\n}\n\nfunction requestRemoteDocumentStoreSyncAndWait(\n state: DocumentStoreState,\n scheduleSync: () => void,\n signal?: AbortSignal,\n): Promise<boolean> {\n let requestGeneration: DocumentStoreRemoteSyncRequestGeneration | null = null;\n let requestedSignalSequence = 0;\n let releaseWaiter: (() => boolean) | null = null;\n const releaseRemoteSyncWaiter = (invalidate: boolean) => {\n const releasedLastWaiter = releaseWaiter?.() ?? false;\n if (\n invalidate &&\n releasedLastWaiter &&\n requestGeneration !== null &&\n isDocumentStoreRemoteSyncRequestGenerationCurrent(\n state,\n requestGeneration,\n ) &&\n !hasPendingIndependentDocumentStoreRemoteSync(state)\n ) {\n invalidateDocumentStoreRemoteSync(state);\n }\n };\n // A coordinator can be disposed and recreated while this same-scope store\n // remains registered. Refresh its handle before requesting work.\n refreshDocumentStoreSyncLane(state);\n return requestDocumentSyncLaneAndWait({\n didCompleteRequest: () =>\n requestGeneration !== null &&\n didDocumentStoreRemoteSyncRequestComplete(\n state,\n requestGeneration,\n requestedSignalSequence,\n ),\n domainScope: state.runtime.state.domainScope,\n localId: state.localId,\n request: () => {\n requestGeneration =\n captureDocumentStoreRemoteSyncRequestGeneration(state);\n releaseWaiter = registerDocumentStoreRemoteSyncWaiter(\n state,\n requestGeneration,\n );\n requestedSignalSequence = requestRemoteDocumentStoreSync(\n state,\n scheduleSync,\n \"waiter\",\n );\n },\n onInvalidated: () => releaseRemoteSyncWaiter(true),\n signal,\n }).then(\n (completed) => {\n releaseRemoteSyncWaiter(!completed);\n return completed;\n },\n (error: unknown) => {\n releaseRemoteSyncWaiter(true);\n throw error;\n },\n );\n}\n\nasync function assertBackingDocumentStoreCanRotate(\n state: DocumentStoreState,\n scheduleSync: () => void,\n) {\n if (!(await ensureDocumentStoreReady(state, scheduleSync)) || !state.doc) {\n throw new Error(\n \"Document must finish loading before its content key can rotate\",\n );\n }\n return assertDocumentStoreCanRotateContentKey(state);\n}\n\nasync function discardBackingDocumentStoreLocalState(\n state: DocumentStoreState,\n scheduleSync: () => void,\n expectedDocumentId: string,\n) {\n try {\n return await discardDocumentStoreLocalState(state, expectedDocumentId);\n } finally {\n // Restart hydration whenever the attempt reset the store. This runs outside\n // its identity-chained task because initialization also chains writes.\n ensureDocumentStoreInitialized(state, scheduleSync);\n scheduleSync();\n }\n}\n\nfunction createLiveSyncLaneRequest(state: DocumentStoreState) {\n return <Result>(request: () => Result): Result => {\n refreshDocumentStoreSyncLane(state);\n return request();\n };\n}\n\nfunction registerBackingStoreInternalRelink(input: {\n scheduleSync: () => void;\n state: DocumentStoreState;\n store: DocumentStore;\n withLiveSyncLane: ReturnType<typeof createLiveSyncLaneRequest>;\n}): DocumentStore {\n registerInternalDocumentRelink(input.store, (relinkInput, commitSideEffect) =>\n input.withLiveSyncLane(() =>\n relinkDocumentStore(\n input.state,\n relinkInput,\n input.scheduleSync,\n commitSideEffect,\n ),\n ),\n );\n return input.store;\n}\n\nfunction createBackingStoreContext(\n localId: string,\n runtime: DocumentsRuntime,\n persistence: DocumentsPersistence,\n documentId: string | null,\n text: string,\n documentKind: StoredDocumentKind,\n options: DocumentStoreOpenOptions,\n) {\n const state = createDocumentStoreState(\n localId,\n runtime,\n persistence,\n {\n emitPersistedDocument,\n registerDocumentIdentity: registerDocumentStoreIdentity,\n },\n documentId,\n text,\n documentKind,\n (options.remoteSyncMode ?? \"startup\") === \"startup\",\n );\n if (options.deferInitialUpdate) state.deferInitialUpdate = true;\n refreshDocumentStoreSyncLane(state);\n const scheduleSync = () => requestDocumentStoreSync(state);\n return {\n scheduleSync,\n state,\n withLiveSyncLane: createLiveSyncLaneRequest(state),\n };\n}\n\nfunction createBackingDocumentStore(\n localId: string,\n initialRuntime: DocumentsRuntime,\n persistence: DocumentsPersistence = defaultDocumentsPersistence,\n initialDocumentId: string | null = null,\n initialText = \"\",\n initialDocumentKind: StoredDocumentKind = DEFAULT_DOCUMENT_KIND,\n openOptions: DocumentStoreOpenOptions = {},\n): DocumentStore {\n const { scheduleSync, state, withLiveSyncLane } = createBackingStoreContext(\n localId,\n initialRuntime,\n persistence,\n initialDocumentId,\n initialText,\n initialDocumentKind,\n openOptions,\n );\n\n const store: DocumentStore = {\n addRow: (fields) =>\n withLiveSyncLane(() =>\n addRowToDocumentStore(state, scheduleSync, fields),\n ),\n assertCanRotateContentKey: () =>\n withLiveSyncLane(() =>\n assertBackingDocumentStoreCanRotate(state, scheduleSync),\n ),\n attachFiles: (files: ReadonlyArray<DocumentAttachmentUpload>) =>\n withLiveSyncLane(() =>\n attachFilesToDocumentStore(state, scheduleSync, files),\n ),\n discardLocalState: (expectedDocumentId: string) =>\n withLiveSyncLane(() =>\n discardBackingDocumentStoreLocalState(\n state,\n scheduleSync,\n expectedDocumentId,\n ),\n ),\n ensureInitialized: () =>\n withLiveSyncLane(() => ensureDocumentStoreReady(state, scheduleSync)),\n getSnapshot: () => state.snapshot,\n removeAttachment: (slotId: string) =>\n withLiveSyncLane(() =>\n removeAttachmentFromDocumentStore(state, scheduleSync, slotId),\n ),\n removeRow: (id) =>\n withLiveSyncLane(() =>\n removeRowFromDocumentStore(state, scheduleSync, id),\n ),\n replaceAttachment: (slotId: string, file: DocumentAttachmentUpload) =>\n withLiveSyncLane(() =>\n replaceAttachmentInDocumentStore(state, scheduleSync, slotId, file),\n ),\n requestRemoteSync: () =>\n withLiveSyncLane(() =>\n requestRemoteDocumentStoreSync(state, scheduleSync),\n ),\n requestRemoteSyncAndWait: (signal) =>\n requestRemoteDocumentStoreSyncAndWait(state, scheduleSync, signal),\n requestSync: () =>\n withLiveSyncLane(() =>\n requestOrdinaryDocumentStoreSync(state, scheduleSync),\n ),\n relink: (input) =>\n withLiveSyncLane(() => relinkDocumentStore(state, input, scheduleSync)),\n setStructuredFields: (kind, patch, options) =>\n withLiveSyncLane(() =>\n setDocumentStructuredFields(state, scheduleSync, kind, patch, options),\n ),\n setText: (value: string) =>\n withLiveSyncLane(() => setDocumentText(state, scheduleSync, value)),\n subscribe: (listener) => subscribeToDocumentStore(state, listener),\n updateRowFields: (id, patch) =>\n withLiveSyncLane(() =>\n updateRowInDocumentStore(state, scheduleSync, id, patch),\n ),\n updateRuntime: (runtime: DocumentsRuntime) =>\n updateDocumentStoreRuntime(state, runtime, scheduleSync),\n };\n return registerBackingStoreInternalRelink({\n scheduleSync,\n state,\n store,\n withLiveSyncLane,\n });\n}\n\nexport function createDocumentStore(\n localId: string,\n initialRuntime: DocumentsRuntime,\n persistence: DocumentsPersistence = defaultDocumentsPersistence,\n initialDocumentId: string | null = null,\n initialText = \"\",\n initialDocumentKind: StoredDocumentKind = DEFAULT_DOCUMENT_KIND,\n options: DocumentStoreOpenOptions = {},\n): DocumentStoreFacade {\n return createDocumentStoreFacade(\n createBackingDocumentStore(\n localId,\n initialRuntime,\n persistence,\n initialDocumentId,\n initialText,\n initialDocumentKind,\n options,\n ),\n );\n}\n\nexport function getOrCreateDocumentStore(\n domainScope: DomainScope,\n localId: string,\n runtime: DocumentsRuntime,\n initialDocumentId: string | null = null,\n initialText = \"\",\n initialDocumentKind: StoredDocumentKind = DEFAULT_DOCUMENT_KIND,\n options: DocumentStoreOpenOptions = {},\n): DocumentStore {\n const registry = getOrCreateDocumentStoreRegistry(domainScope);\n const existingStore = registry.storesByKey.get(\n resolveDocumentStoreKey(registry, localId, initialDocumentId),\n );\n if (existingStore) {\n registerDocumentStore(\n domainScope,\n localId,\n existingStore,\n initialDocumentId,\n );\n return existingStore;\n }\n\n const nextStore = createDocumentStore(\n localId,\n runtime,\n defaultDocumentsPersistence,\n initialDocumentId,\n initialText,\n initialDocumentKind,\n options,\n );\n registerDocumentStore(domainScope, localId, nextStore, initialDocumentId);\n return nextStore;\n}\n\nexport function openDocumentStore(\n domainScope: DomainScope,\n localId: string,\n runtime: DocumentsRuntime,\n initialDocumentId: string | null = null,\n initialText = \"\",\n initialDocumentKind: StoredDocumentKind = DEFAULT_DOCUMENT_KIND,\n options: DocumentStoreOpenOptions = {},\n): DocumentStore {\n const store = getOrCreateDocumentStore(\n domainScope,\n localId,\n runtime,\n initialDocumentId,\n initialText,\n initialDocumentKind,\n options,\n );\n store.updateRuntime(runtime);\n return store;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"documentStore.js","sourceRoot":"","sources":["documentStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAG/E,OAAO,EACL,uCAAu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ACjB,WAAW,EACX,mBAAmB,EACnB,OAAO,CACR,CAAC;IACF,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC7B,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { DEFAULT_DOCUMENT_KIND } from \"../../data/documents/documentConstants\";\nimport type { StoredDocumentKind } from \"../../data/documents/documentKinds\";\nimport type { DomainScope } from \"../../data/domainScope\";\nimport {\n createDocumentProjectionUserKeyResolver,\n type DocumentsPersistence,\n defaultDocumentsPersistence,\n didDocumentProjectionKeyRuntimeChange,\n didRegainSyncPrerequisites,\n requestDocumentSyncLaneAndWait,\n} from \"../../workflows/documents\";\nimport { removeAttachmentFromDocumentStore } from \"./documentStore/attachmentRemoval\";\nimport {\n attachFilesToDocumentStore,\n replaceAttachmentInDocumentStore,\n} from \"./documentStore/attachments\";\nimport { discardDocumentStoreLocalState } from \"./documentStore/discard\";\nimport {\n ensureDocumentStoreInitialized,\n ensureDocumentStoreReady,\n relinkDocumentStore,\n} from \"./documentStore/initialization\";\nimport { registerInternalDocumentRelink } from \"./documentStore/internalRelink\";\nimport {\n setDocumentStructuredFields,\n setDocumentText,\n} from \"./documentStore/mutations\";\nimport { logRevalidationScheduled } from \"./documentStore/remoteRevalidationTelemetry\";\nimport { assertDocumentStoreCanRotateContentKey } from \"./documentStore/rotation\";\nimport {\n addRowToDocumentStore,\n removeRowFromDocumentStore,\n updateRowInDocumentStore,\n} from \"./documentStore/rows\";\nimport {\n createDocumentStoreState,\n type DocumentStoreState,\n refreshAttachabilitySnapshot,\n resetDocumentStore,\n subscribeToDocumentStore,\n} from \"./documentStore/state\";\nimport { registerDocumentStoreSyncLane } from \"./documentStore/sync\";\nimport {\n allowDocumentStoreRemoteSync,\n captureDocumentStoreRemoteSyncRequestGeneration,\n captureDocumentStoreSyncLaneGeneration,\n type DocumentStoreRemoteSyncRequestGeneration,\n type DocumentStoreSyncLaneGeneration,\n didDocumentStoreRemoteSyncRequestComplete,\n hasPendingIndependentDocumentStoreRemoteSync,\n invalidateDocumentStoreRemoteSync,\n invalidateDocumentStoreSyncLane,\n isDocumentStoreRemoteSyncBlocked,\n isDocumentStoreRemoteSyncRequestGenerationCurrent,\n markDocumentStoreRemoteSyncPending,\n registerDocumentStoreRemoteSyncWaiter,\n} from \"./documentStore/syncGeneration\";\nimport { handleDocumentRemoteEvents } from \"./documentStore/syncRemoteSignals\";\nimport {\n createDocumentStoreFacade,\n emitPersistedDocument,\n getOrCreateDocumentStoreRegistry,\n registerDocumentStore,\n registerDocumentStoreIdentity,\n requestDocumentStoreSync,\n resolveDocumentStoreKey,\n} from \"./registry\";\nimport type {\n DocumentAttachmentUpload,\n DocumentStore,\n DocumentStoreFacade,\n DocumentStoreOpenOptions,\n DocumentsRuntime,\n} from \"./types\";\n\nexport {\n discardRegisteredDocumentLocalState,\n requestDomainDocumentSync,\n subscribeToPersistedDocuments,\n} from \"./registry\";\n\nfunction refreshDocumentStoreSyncLane(\n state: DocumentStoreState,\n force = false,\n): void {\n if (!force && state.syncLane && !state.syncLane.isDisposed?.()) {\n return;\n }\n if (state.syncLane) {\n invalidateDocumentStoreSyncLane(state);\n }\n let syncLaneGeneration: DocumentStoreSyncLaneGeneration | null = null;\n state.syncLane = registerDocumentStoreSyncLane(\n state,\n () => syncLaneGeneration,\n );\n syncLaneGeneration = captureDocumentStoreSyncLaneGeneration(state);\n}\n\nfunction updateDocumentStoreRuntime(\n state: DocumentStoreState,\n nextRuntime: DocumentsRuntime,\n scheduleSync: () => void,\n) {\n const previousRuntime = state.runtime;\n const serverEventsReconnected =\n (nextRuntime.state.serverEventsConnectionGeneration ?? 0) >\n (previousRuntime.state.serverEventsConnectionGeneration ?? 0);\n const domainScopeChanged =\n previousRuntime.state.domainScope !== nextRuntime.state.domainScope;\n const projectionKeyRuntimeChanged = didDocumentProjectionKeyRuntimeChange(\n previousRuntime,\n nextRuntime,\n );\n if (projectionKeyRuntimeChanged) {\n state.resolveProjectionUserKey =\n createDocumentProjectionUserKeyResolver(nextRuntime);\n state.writerProjection = null;\n }\n state.runtime = nextRuntime;\n refreshDocumentStoreSyncLane(state, domainScopeChanged);\n if (domainScopeChanged) {\n state.locallyAcceptedUpdateIds = new Set();\n state.remoteUpdatePending = false;\n state.writerProjection = null;\n }\n\n if (nextRuntime.infra.dbStatus !== \"ready\") {\n if (state.snapshot.ready || state.initialized || state.initializePromise) {\n resetDocumentStore(state);\n }\n state.lastEventCount = nextRuntime.state.events.length;\n return;\n }\n\n refreshAttachabilitySnapshot(state);\n ensureDocumentStoreInitialized(state, scheduleSync);\n handleDocumentRemoteEvents(state, scheduleSync);\n\n if (state.snapshot.ready) {\n if (serverEventsReconnected) {\n // The invalidation stream is lossy while disconnected. Once the server\n // has acknowledged this socket's authoritative interest declaration,\n // every already-open remote document needs one HTTP probe to cover peer\n // writes made during the gap. This also closes iOS background/resume reconnects where the\n // native network source remained online throughout.\n requestRemoteDocumentStoreSync(state, scheduleSync);\n logRevalidationScheduled(state.runtime, \"reconnect\");\n } else if (didRegainSyncPrerequisites(previousRuntime, state.runtime)) {\n scheduleSync();\n }\n }\n}\n\nfunction requestRemoteDocumentStoreSync(\n state: DocumentStoreState,\n scheduleSync: () => void,\n owner: \"independent\" | \"waiter\" = \"independent\",\n): number {\n allowDocumentStoreRemoteSync(state);\n const signalSequence = markDocumentStoreRemoteSyncPending(state, owner);\n scheduleSync();\n return signalSequence;\n}\n\nfunction requestOrdinaryDocumentStoreSync(\n state: DocumentStoreState,\n scheduleSync: () => void,\n): void {\n // A normal UI reopen is a fresh owner for remote-only work. It may recover\n // a probe that an earlier, now-unmounted owner aborted.\n if (isDocumentStoreRemoteSyncBlocked(state)) {\n requestRemoteDocumentStoreSync(state, scheduleSync);\n return;\n }\n scheduleSync();\n}\n\nfunction requestRemoteDocumentStoreSyncAndWait(\n state: DocumentStoreState,\n scheduleSync: () => void,\n signal?: AbortSignal,\n): Promise<boolean> {\n let requestGeneration: DocumentStoreRemoteSyncRequestGeneration | null = null;\n let requestedSignalSequence = 0;\n let releaseWaiter: (() => boolean) | null = null;\n const releaseRemoteSyncWaiter = (invalidate: boolean) => {\n const releasedLastWaiter = releaseWaiter?.() ?? false;\n if (\n invalidate &&\n releasedLastWaiter &&\n requestGeneration !== null &&\n isDocumentStoreRemoteSyncRequestGenerationCurrent(\n state,\n requestGeneration,\n ) &&\n !hasPendingIndependentDocumentStoreRemoteSync(state)\n ) {\n invalidateDocumentStoreRemoteSync(state);\n }\n };\n // A coordinator can be disposed and recreated while this same-scope store\n // remains registered. Refresh its handle before requesting work.\n refreshDocumentStoreSyncLane(state);\n return requestDocumentSyncLaneAndWait({\n didCompleteRequest: () =>\n requestGeneration !== null &&\n didDocumentStoreRemoteSyncRequestComplete(\n state,\n requestGeneration,\n requestedSignalSequence,\n ),\n domainScope: state.runtime.state.domainScope,\n localId: state.localId,\n request: () => {\n requestGeneration =\n captureDocumentStoreRemoteSyncRequestGeneration(state);\n releaseWaiter = registerDocumentStoreRemoteSyncWaiter(\n state,\n requestGeneration,\n );\n requestedSignalSequence = requestRemoteDocumentStoreSync(\n state,\n scheduleSync,\n \"waiter\",\n );\n },\n onInvalidated: () => releaseRemoteSyncWaiter(true),\n signal,\n }).then(\n (completed) => {\n releaseRemoteSyncWaiter(!completed);\n return completed;\n },\n (error: unknown) => {\n releaseRemoteSyncWaiter(true);\n throw error;\n },\n );\n}\n\nasync function assertBackingDocumentStoreCanRotate(\n state: DocumentStoreState,\n scheduleSync: () => void,\n) {\n if (!(await ensureDocumentStoreReady(state, scheduleSync)) || !state.doc) {\n throw new Error(\n \"Document must finish loading before its content key can rotate\",\n );\n }\n return assertDocumentStoreCanRotateContentKey(state);\n}\n\nasync function discardBackingDocumentStoreLocalState(\n state: DocumentStoreState,\n scheduleSync: () => void,\n expectedDocumentId: string,\n) {\n try {\n return await discardDocumentStoreLocalState(state, expectedDocumentId);\n } finally {\n // Restart hydration whenever the attempt reset the store. This runs outside\n // its identity-chained task because initialization also chains writes.\n ensureDocumentStoreInitialized(state, scheduleSync);\n scheduleSync();\n }\n}\n\nfunction createLiveSyncLaneRequest(state: DocumentStoreState) {\n return <Result>(request: () => Result): Result => {\n refreshDocumentStoreSyncLane(state);\n return request();\n };\n}\n\nfunction registerBackingStoreInternalRelink(input: {\n scheduleSync: () => void;\n state: DocumentStoreState;\n store: DocumentStore;\n withLiveSyncLane: ReturnType<typeof createLiveSyncLaneRequest>;\n}): DocumentStore {\n registerInternalDocumentRelink(input.store, (relinkInput, commitSideEffect) =>\n input.withLiveSyncLane(() =>\n relinkDocumentStore(\n input.state,\n relinkInput,\n input.scheduleSync,\n commitSideEffect,\n ),\n ),\n );\n return input.store;\n}\n\nfunction createBackingStoreContext(\n localId: string,\n runtime: DocumentsRuntime,\n persistence: DocumentsPersistence,\n documentId: string | null,\n text: string,\n documentKind: StoredDocumentKind,\n options: DocumentStoreOpenOptions,\n) {\n const state = createDocumentStoreState(\n localId,\n runtime,\n persistence,\n {\n emitPersistedDocument,\n registerDocumentIdentity: registerDocumentStoreIdentity,\n },\n documentId,\n text,\n documentKind,\n (options.remoteSyncMode ?? \"startup\") === \"startup\",\n );\n if (options.deferInitialUpdate) state.deferInitialUpdate = true;\n refreshDocumentStoreSyncLane(state);\n const scheduleSync = () => requestDocumentStoreSync(state);\n return {\n scheduleSync,\n state,\n withLiveSyncLane: createLiveSyncLaneRequest(state),\n };\n}\n\nfunction createBackingDocumentStore(\n localId: string,\n initialRuntime: DocumentsRuntime,\n persistence: DocumentsPersistence = defaultDocumentsPersistence,\n initialDocumentId: string | null = null,\n initialText = \"\",\n initialDocumentKind: StoredDocumentKind = DEFAULT_DOCUMENT_KIND,\n openOptions: DocumentStoreOpenOptions = {},\n): DocumentStore {\n const { scheduleSync, state, withLiveSyncLane } = createBackingStoreContext(\n localId,\n initialRuntime,\n persistence,\n initialDocumentId,\n initialText,\n initialDocumentKind,\n openOptions,\n );\n\n const store: DocumentStore = {\n addRow: (fields) =>\n withLiveSyncLane(() =>\n addRowToDocumentStore(state, scheduleSync, fields),\n ),\n assertCanRotateContentKey: () =>\n withLiveSyncLane(() =>\n assertBackingDocumentStoreCanRotate(state, scheduleSync),\n ),\n attachFiles: (files: ReadonlyArray<DocumentAttachmentUpload>) =>\n withLiveSyncLane(() =>\n attachFilesToDocumentStore(state, scheduleSync, files),\n ),\n discardLocalState: (expectedDocumentId: string) =>\n withLiveSyncLane(() =>\n discardBackingDocumentStoreLocalState(\n state,\n scheduleSync,\n expectedDocumentId,\n ),\n ),\n ensureInitialized: () =>\n withLiveSyncLane(() => ensureDocumentStoreReady(state, scheduleSync)),\n getSnapshot: () => state.snapshot,\n removeAttachment: (slotId: string) =>\n withLiveSyncLane(() =>\n removeAttachmentFromDocumentStore(state, scheduleSync, slotId),\n ),\n removeRow: (id) =>\n withLiveSyncLane(() =>\n removeRowFromDocumentStore(state, scheduleSync, id),\n ),\n replaceAttachment: (slotId: string, file: DocumentAttachmentUpload) =>\n withLiveSyncLane(() =>\n replaceAttachmentInDocumentStore(state, scheduleSync, slotId, file),\n ),\n requestRemoteSync: () =>\n withLiveSyncLane(() =>\n requestRemoteDocumentStoreSync(state, scheduleSync),\n ),\n requestRemoteSyncAndWait: (signal) =>\n requestRemoteDocumentStoreSyncAndWait(state, scheduleSync, signal),\n requestSync: () =>\n withLiveSyncLane(() =>\n requestOrdinaryDocumentStoreSync(state, scheduleSync),\n ),\n relink: (input) =>\n withLiveSyncLane(() => relinkDocumentStore(state, input, scheduleSync)),\n setStructuredFields: (kind, patch, options) =>\n withLiveSyncLane(() =>\n setDocumentStructuredFields(state, scheduleSync, kind, patch, options),\n ),\n setText: (value: string) =>\n withLiveSyncLane(() => setDocumentText(state, scheduleSync, value)),\n subscribe: (listener) => subscribeToDocumentStore(state, listener),\n updateRowFields: (id, patch) =>\n withLiveSyncLane(() =>\n updateRowInDocumentStore(state, scheduleSync, id, patch),\n ),\n updateRuntime: (runtime: DocumentsRuntime) =>\n updateDocumentStoreRuntime(state, runtime, scheduleSync),\n };\n return registerBackingStoreInternalRelink({\n scheduleSync,\n state,\n store,\n withLiveSyncLane,\n });\n}\n\nexport function createDocumentStore(\n localId: string,\n initialRuntime: DocumentsRuntime,\n persistence: DocumentsPersistence = defaultDocumentsPersistence,\n initialDocumentId: string | null = null,\n initialText = \"\",\n initialDocumentKind: StoredDocumentKind = DEFAULT_DOCUMENT_KIND,\n options: DocumentStoreOpenOptions = {},\n): DocumentStoreFacade {\n return createDocumentStoreFacade(\n createBackingDocumentStore(\n localId,\n initialRuntime,\n persistence,\n initialDocumentId,\n initialText,\n initialDocumentKind,\n options,\n ),\n );\n}\n\nexport function getOrCreateDocumentStore(\n domainScope: DomainScope,\n localId: string,\n runtime: DocumentsRuntime,\n initialDocumentId: string | null = null,\n initialText = \"\",\n initialDocumentKind: StoredDocumentKind = DEFAULT_DOCUMENT_KIND,\n options: DocumentStoreOpenOptions = {},\n): DocumentStore {\n const registry = getOrCreateDocumentStoreRegistry(domainScope);\n const existingStore = registry.storesByKey.get(\n resolveDocumentStoreKey(registry, localId, initialDocumentId),\n );\n if (existingStore) {\n registerDocumentStore(\n domainScope,\n localId,\n existingStore,\n initialDocumentId,\n );\n return existingStore;\n }\n\n const nextStore = createDocumentStore(\n localId,\n runtime,\n defaultDocumentsPersistence,\n initialDocumentId,\n initialText,\n initialDocumentKind,\n options,\n );\n registerDocumentStore(domainScope, localId, nextStore, initialDocumentId);\n return nextStore;\n}\n\nexport function openDocumentStore(\n domainScope: DomainScope,\n localId: string,\n runtime: DocumentsRuntime,\n initialDocumentId: string | null = null,\n initialText = \"\",\n initialDocumentKind: StoredDocumentKind = DEFAULT_DOCUMENT_KIND,\n options: DocumentStoreOpenOptions = {},\n): DocumentStore {\n const store = getOrCreateDocumentStore(\n domainScope,\n localId,\n runtime,\n initialDocumentId,\n initialText,\n initialDocumentKind,\n options,\n );\n store.updateRuntime(runtime);\n return store;\n}\n"]}
|
|
@@ -118,29 +118,37 @@ async function refreshAndReconcileContainers(input) {
|
|
|
118
118
|
}
|
|
119
119
|
// Sweeps share the queue and discovered set, so they must run serially.
|
|
120
120
|
// Root requests join either kind of sweep; a full request after a root sweep
|
|
121
|
-
// must wait for it and then refresh the whole tree.
|
|
121
|
+
// must wait for it and then refresh the whole tree. A fresh-listing request
|
|
122
|
+
// joins only a sweep that has not started: one already running may have listed
|
|
123
|
+
// before the event behind the request, so it queues a trailing sweep instead.
|
|
122
124
|
function requestContainerRefresh(input) {
|
|
123
125
|
const { state, scope } = input;
|
|
124
126
|
const pending = state.pendingRefresh;
|
|
125
|
-
if (pending &&
|
|
127
|
+
if (pending &&
|
|
128
|
+
(scope === "root" || pending.scope === "full") &&
|
|
129
|
+
!(input.freshListing && pending.started.value)) {
|
|
126
130
|
return pending.promise;
|
|
127
131
|
}
|
|
132
|
+
const started = { value: false };
|
|
128
133
|
const promise = (pending?.promise ?? Promise.resolve())
|
|
129
|
-
// A failed
|
|
134
|
+
// A failed earlier sweep must not prevent the queued refresh.
|
|
130
135
|
.catch(() => undefined)
|
|
131
|
-
.then(() =>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
.then(() => {
|
|
137
|
+
started.value = true;
|
|
138
|
+
return refreshAndReconcileContainers({
|
|
139
|
+
forceAllDocumentContentPulls: scope === "full",
|
|
140
|
+
host: input.host,
|
|
141
|
+
listContainerIds: input.listContainerIds,
|
|
142
|
+
refreshTree: input.refreshTree,
|
|
143
|
+
state,
|
|
144
|
+
});
|
|
145
|
+
})
|
|
138
146
|
.finally(() => {
|
|
139
147
|
if (state.pendingRefresh?.promise === promise) {
|
|
140
148
|
state.pendingRefresh = null;
|
|
141
149
|
}
|
|
142
150
|
});
|
|
143
|
-
state.pendingRefresh = { promise, scope };
|
|
151
|
+
state.pendingRefresh = { promise, scope, started };
|
|
144
152
|
return promise;
|
|
145
153
|
}
|
|
146
154
|
function listFullRefreshContainerIds(host, state) {
|
|
@@ -267,7 +275,8 @@ export function createReconciliationService(host) {
|
|
|
267
275
|
state.discoveredContainerIds.clear();
|
|
268
276
|
state.initialDocumentProbe.resetSkippedListings();
|
|
269
277
|
},
|
|
270
|
-
reconcileRootContainersNow: () => requestContainerRefresh({
|
|
278
|
+
reconcileRootContainersNow: (options) => requestContainerRefresh({
|
|
279
|
+
freshListing: options?.freshListing === true,
|
|
271
280
|
host,
|
|
272
281
|
state,
|
|
273
282
|
refreshTree: host.refreshRootTree,
|
|
@@ -275,6 +284,7 @@ export function createReconciliationService(host) {
|
|
|
275
284
|
scope: "root",
|
|
276
285
|
}),
|
|
277
286
|
reconcileNow: () => requestContainerRefresh({
|
|
287
|
+
freshListing: false,
|
|
278
288
|
host,
|
|
279
289
|
state,
|
|
280
290
|
refreshTree: host.refreshTree,
|