@indigoai-us/hq-cloud 6.18.2-alpha.0 → 6.18.3-alpha.0
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/dist/bin/sync-runner-watch-loop.d.ts +6 -7
- package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
- package/dist/bin/sync-runner-watch-loop.js +11 -10
- package/dist/bin/sync-runner-watch-loop.js.map +1 -1
- package/dist/bin/sync-runner-watch-loop.test.js +63 -5
- package/dist/bin/sync-runner-watch-loop.test.js.map +1 -1
- package/dist/bin/sync-runner.d.ts.map +1 -1
- package/dist/bin/sync-runner.js +7 -0
- package/dist/bin/sync-runner.js.map +1 -1
- package/dist/bin/sync-runner.test.js +2 -0
- package/dist/bin/sync-runner.test.js.map +1 -1
- package/dist/cli/reindex.d.ts +6 -0
- package/dist/cli/reindex.d.ts.map +1 -1
- package/dist/cli/reindex.js +3 -3
- package/dist/cli/reindex.js.map +1 -1
- package/dist/cli/share.d.ts +2 -8
- package/dist/cli/share.d.ts.map +1 -1
- package/dist/cli/share.js +13 -83
- package/dist/cli/share.js.map +1 -1
- package/dist/cli/share.test.js +0 -189
- package/dist/cli/share.test.js.map +1 -1
- package/dist/object-io.d.ts +5 -0
- package/dist/object-io.d.ts.map +1 -1
- package/dist/object-io.js +29 -2
- package/dist/object-io.js.map +1 -1
- package/dist/object-io.test.js +117 -0
- package/dist/object-io.test.js.map +1 -1
- package/dist/session-log-capture.d.ts +15 -1
- package/dist/session-log-capture.d.ts.map +1 -1
- package/dist/session-log-capture.js +46 -2
- package/dist/session-log-capture.js.map +1 -1
- package/dist/session-log-capture.test.js +59 -0
- package/dist/session-log-capture.test.js.map +1 -1
- package/dist/sync/event-sync.d.ts +2 -0
- package/dist/sync/event-sync.d.ts.map +1 -1
- package/dist/sync/event-sync.js +46 -0
- package/dist/sync/event-sync.js.map +1 -1
- package/dist/sync/event-sync.test.js +224 -33
- package/dist/sync/event-sync.test.js.map +1 -1
- package/dist/sync/push-receiver.d.ts +9 -0
- package/dist/sync/push-receiver.d.ts.map +1 -1
- package/dist/sync/push-receiver.js +96 -6
- package/dist/sync/push-receiver.js.map +1 -1
- package/dist/sync/push-receiver.test.js +462 -0
- package/dist/sync/push-receiver.test.js.map +1 -1
- package/dist/sync/receiver-origin-config.test.d.ts +2 -0
- package/dist/sync/receiver-origin-config.test.d.ts.map +1 -0
- package/dist/sync/receiver-origin-config.test.js +39 -0
- package/dist/sync/receiver-origin-config.test.js.map +1 -0
- package/dist/sync/sync-contract.d.ts +6 -0
- package/dist/sync/sync-contract.d.ts.map +1 -0
- package/dist/sync/sync-contract.js +11 -0
- package/dist/sync/sync-contract.js.map +1 -0
- package/dist/sync/sync-contract.test.d.ts +2 -0
- package/dist/sync/sync-contract.test.d.ts.map +1 -0
- package/dist/sync/sync-contract.test.js +141 -0
- package/dist/sync/sync-contract.test.js.map +1 -0
- package/dist/sync-contract.json +9 -0
- package/package.json +4 -2
- package/dist/lib/ontology-entity-push.d.ts +0 -51
- package/dist/lib/ontology-entity-push.d.ts.map +0 -1
- package/dist/lib/ontology-entity-push.js +0 -125
- package/dist/lib/ontology-entity-push.js.map +0 -1
- package/dist/lib/ontology-entity-push.test.d.ts +0 -2
- package/dist/lib/ontology-entity-push.test.d.ts.map +0 -1
- package/dist/lib/ontology-entity-push.test.js +0 -149
- package/dist/lib/ontology-entity-push.test.js.map +0 -1
package/dist/cli/share.test.js
CHANGED
|
@@ -3260,195 +3260,6 @@ describe("share", () => {
|
|
|
3260
3260
|
});
|
|
3261
3261
|
expect(events.some((event) => event.type === "reconciled")).toBe(false);
|
|
3262
3262
|
});
|
|
3263
|
-
describe("checkpoint ontology entity push (flag checkpoint.ontology)", () => {
|
|
3264
|
-
const entityRel = "ontology/entities/person/maria-khan.md";
|
|
3265
|
-
const entityBody = "---\nid: abc\ntype: person\ncanonical_name: Maria Khan\n---\n";
|
|
3266
|
-
const fence412 = () => Object.assign(new Error("Precondition failed"), { name: "PreconditionFailed" });
|
|
3267
|
-
function writeEntity(body = entityBody) {
|
|
3268
|
-
const file = path.join(tmpDir, "companies", "acme", ...entityRel.split("/"));
|
|
3269
|
-
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
3270
|
-
fs.writeFileSync(file, body);
|
|
3271
|
-
return file;
|
|
3272
|
-
}
|
|
3273
|
-
function seedEntityJournal(remoteEtag, hash = "journal-hash") {
|
|
3274
|
-
const syncedAt = new Date(Date.now() - 60_000).toISOString();
|
|
3275
|
-
seedJournalAt(path.join(stateDir, "sync-journal.acme.json"), {
|
|
3276
|
-
version: "1",
|
|
3277
|
-
lastSync: syncedAt,
|
|
3278
|
-
files: {
|
|
3279
|
-
[entityRel]: { hash, size: 10, syncedAt, direction: "down", remoteEtag },
|
|
3280
|
-
},
|
|
3281
|
-
});
|
|
3282
|
-
}
|
|
3283
|
-
it("flag off: the entity file is still refused as server-owned", async () => {
|
|
3284
|
-
const file = writeEntity();
|
|
3285
|
-
await expect(share({
|
|
3286
|
-
paths: [file],
|
|
3287
|
-
company: "acme",
|
|
3288
|
-
vaultConfig: mockConfig,
|
|
3289
|
-
hqRoot: tmpDir,
|
|
3290
|
-
ontologyEntityPush: false,
|
|
3291
|
-
})).rejects.toThrow(ServerOwnedPushPathsError);
|
|
3292
|
-
expect(uploadFile).not.toHaveBeenCalled();
|
|
3293
|
-
});
|
|
3294
|
-
it("flag on: a new entity file is created with If-None-Match:*", async () => {
|
|
3295
|
-
const file = writeEntity();
|
|
3296
|
-
const result = await share({
|
|
3297
|
-
paths: [file],
|
|
3298
|
-
company: "acme",
|
|
3299
|
-
vaultConfig: mockConfig,
|
|
3300
|
-
hqRoot: tmpDir,
|
|
3301
|
-
ontologyEntityPush: true,
|
|
3302
|
-
});
|
|
3303
|
-
expect(result.filesUploaded).toBe(1);
|
|
3304
|
-
expect(uploadFile).toHaveBeenCalledWith(expect.anything(), file, entityRel, undefined, { ifNoneMatch: "*" });
|
|
3305
|
-
});
|
|
3306
|
-
it("flag on: the rest of ontology/ stays server-owned", async () => {
|
|
3307
|
-
const companyRoot = path.join(tmpDir, "companies", "acme");
|
|
3308
|
-
const others = [
|
|
3309
|
-
path.join(companyRoot, "ontology", ".last-run"),
|
|
3310
|
-
path.join(companyRoot, "ontology", "merge-proposals.json"),
|
|
3311
|
-
path.join(companyRoot, "ontology", "facts", "f1.md"),
|
|
3312
|
-
path.join(companyRoot, "ontology", "entities", "person", "nested", "x.md"),
|
|
3313
|
-
path.join(companyRoot, "ontology", "entities", "person", "x.json"),
|
|
3314
|
-
];
|
|
3315
|
-
for (const file of others) {
|
|
3316
|
-
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
3317
|
-
fs.writeFileSync(file, "x");
|
|
3318
|
-
}
|
|
3319
|
-
await expect(share({
|
|
3320
|
-
paths: others,
|
|
3321
|
-
company: "acme",
|
|
3322
|
-
vaultConfig: mockConfig,
|
|
3323
|
-
hqRoot: tmpDir,
|
|
3324
|
-
ontologyEntityPush: true,
|
|
3325
|
-
})).rejects.toThrow(ServerOwnedPushPathsError);
|
|
3326
|
-
expect(uploadFile).not.toHaveBeenCalled();
|
|
3327
|
-
});
|
|
3328
|
-
it("flag on: a local edit over an unchanged remote is fenced on the journal etag", async () => {
|
|
3329
|
-
const file = writeEntity();
|
|
3330
|
-
seedEntityJournal("synced-etag");
|
|
3331
|
-
vi.mocked(headRemoteFile).mockResolvedValueOnce({
|
|
3332
|
-
lastModified: new Date(Date.now() - 120_000),
|
|
3333
|
-
etag: '"synced-etag"',
|
|
3334
|
-
size: 10,
|
|
3335
|
-
});
|
|
3336
|
-
const result = await share({
|
|
3337
|
-
paths: [file],
|
|
3338
|
-
company: "acme",
|
|
3339
|
-
vaultConfig: mockConfig,
|
|
3340
|
-
hqRoot: tmpDir,
|
|
3341
|
-
ontologyEntityPush: true,
|
|
3342
|
-
});
|
|
3343
|
-
expect(result.filesUploaded).toBe(1);
|
|
3344
|
-
expect(uploadFile).toHaveBeenCalledWith(expect.anything(), file, entityRel, undefined, { ifMatch: "synced-etag" });
|
|
3345
|
-
});
|
|
3346
|
-
it("flag on: a two-sided conflict adopts the cloud body even under --on-conflict overwrite", async () => {
|
|
3347
|
-
const file = writeEntity("---\nlocal: checkpoint\n---\n");
|
|
3348
|
-
seedEntityJournal("old-etag");
|
|
3349
|
-
vi.mocked(headRemoteFile).mockResolvedValueOnce({
|
|
3350
|
-
lastModified: new Date(),
|
|
3351
|
-
etag: '"server-etag"',
|
|
3352
|
-
size: 22,
|
|
3353
|
-
});
|
|
3354
|
-
vi.mocked(downloadFile).mockImplementationOnce(async (_ctx, _key, dest) => {
|
|
3355
|
-
fs.writeFileSync(dest, "---\nserver: gardener\n---\n");
|
|
3356
|
-
return undefined;
|
|
3357
|
-
});
|
|
3358
|
-
const events = [];
|
|
3359
|
-
const result = await share({
|
|
3360
|
-
paths: [file],
|
|
3361
|
-
company: "acme",
|
|
3362
|
-
vaultConfig: mockConfig,
|
|
3363
|
-
hqRoot: tmpDir,
|
|
3364
|
-
onConflict: "overwrite",
|
|
3365
|
-
ontologyEntityPush: true,
|
|
3366
|
-
onEvent: (e) => events.push(e),
|
|
3367
|
-
});
|
|
3368
|
-
expect(uploadFile).not.toHaveBeenCalled();
|
|
3369
|
-
expect(result.filesUploaded).toBe(0);
|
|
3370
|
-
expect(result.conflictPaths).toEqual([entityRel]);
|
|
3371
|
-
expect(fs.readFileSync(file, "utf-8")).toBe("---\nserver: gardener\n---\n");
|
|
3372
|
-
expect(fs.readFileSync(sidecarIn(path.dirname(file)), "utf-8")).toBe("---\nlocal: checkpoint\n---\n");
|
|
3373
|
-
expect(events).toContainEqual(expect.objectContaining({ type: "conflict", path: entityRel, resolution: "keep" }));
|
|
3374
|
-
});
|
|
3375
|
-
it("flag on: a 412 never retries unfenced and adopts the cloud body", async () => {
|
|
3376
|
-
const file = writeEntity("---\nlocal: checkpoint\n---\n");
|
|
3377
|
-
vi.mocked(headRemoteFile)
|
|
3378
|
-
.mockResolvedValueOnce(null)
|
|
3379
|
-
.mockResolvedValueOnce({ lastModified: new Date(), etag: '"raced-etag"', size: 22 });
|
|
3380
|
-
vi.mocked(uploadFile).mockRejectedValueOnce(fence412());
|
|
3381
|
-
vi.mocked(downloadFile).mockImplementationOnce(async (_ctx, _key, dest) => {
|
|
3382
|
-
fs.writeFileSync(dest, "---\nserver: raced\n---\n");
|
|
3383
|
-
return undefined;
|
|
3384
|
-
});
|
|
3385
|
-
const result = await share({
|
|
3386
|
-
paths: [file],
|
|
3387
|
-
company: "acme",
|
|
3388
|
-
vaultConfig: mockConfig,
|
|
3389
|
-
hqRoot: tmpDir,
|
|
3390
|
-
onConflict: "overwrite",
|
|
3391
|
-
ontologyEntityPush: true,
|
|
3392
|
-
});
|
|
3393
|
-
expect(uploadFile).toHaveBeenCalledTimes(1);
|
|
3394
|
-
expect(vi.mocked(uploadFile).mock.calls[0][4]).toEqual({ ifNoneMatch: "*" });
|
|
3395
|
-
expect(result.filesUploaded).toBe(0);
|
|
3396
|
-
expect(result.conflictPaths).toEqual([entityRel]);
|
|
3397
|
-
expect(fs.readFileSync(file, "utf-8")).toBe("---\nserver: raced\n---\n");
|
|
3398
|
-
});
|
|
3399
|
-
it("flag on: never recreates a journaled entity the server removed", async () => {
|
|
3400
|
-
const file = writeEntity();
|
|
3401
|
-
seedEntityJournal("merged-away-etag");
|
|
3402
|
-
vi.mocked(headRemoteFile).mockResolvedValueOnce(null);
|
|
3403
|
-
const result = await share({
|
|
3404
|
-
paths: [file],
|
|
3405
|
-
company: "acme",
|
|
3406
|
-
vaultConfig: mockConfig,
|
|
3407
|
-
hqRoot: tmpDir,
|
|
3408
|
-
onConflict: "overwrite",
|
|
3409
|
-
ontologyEntityPush: true,
|
|
3410
|
-
});
|
|
3411
|
-
expect(uploadFile).not.toHaveBeenCalled();
|
|
3412
|
-
expect(result.filesUploaded).toBe(0);
|
|
3413
|
-
expect(fs.readFileSync(file, "utf-8")).toBe(entityBody);
|
|
3414
|
-
});
|
|
3415
|
-
it("unset option: reads the flag, and the local override turns the push on", async () => {
|
|
3416
|
-
const file = writeEntity();
|
|
3417
|
-
process.env.HQ_FLAG_CHECKPOINT_ONTOLOGY = "true";
|
|
3418
|
-
try {
|
|
3419
|
-
const result = await share({
|
|
3420
|
-
paths: [file],
|
|
3421
|
-
company: "acme",
|
|
3422
|
-
vaultConfig: mockConfig,
|
|
3423
|
-
hqRoot: tmpDir,
|
|
3424
|
-
});
|
|
3425
|
-
expect(result.filesUploaded).toBe(1);
|
|
3426
|
-
}
|
|
3427
|
-
finally {
|
|
3428
|
-
delete process.env.HQ_FLAG_CHECKPOINT_ONTOLOGY;
|
|
3429
|
-
}
|
|
3430
|
-
});
|
|
3431
|
-
it("unset option: a personal-vault push never reads the flag or pushes entities", async () => {
|
|
3432
|
-
const file = path.join(tmpDir, ...entityRel.split("/"));
|
|
3433
|
-
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
3434
|
-
fs.writeFileSync(file, entityBody);
|
|
3435
|
-
process.env.HQ_FLAG_CHECKPOINT_ONTOLOGY = "true";
|
|
3436
|
-
try {
|
|
3437
|
-
await share({
|
|
3438
|
-
paths: [file],
|
|
3439
|
-
company: "acme",
|
|
3440
|
-
vaultConfig: mockConfig,
|
|
3441
|
-
hqRoot: tmpDir,
|
|
3442
|
-
personalMode: true,
|
|
3443
|
-
serverOwnedPathPolicy: "skip",
|
|
3444
|
-
});
|
|
3445
|
-
}
|
|
3446
|
-
finally {
|
|
3447
|
-
delete process.env.HQ_FLAG_CHECKPOINT_ONTOLOGY;
|
|
3448
|
-
}
|
|
3449
|
-
expect(uploadFile).not.toHaveBeenCalled();
|
|
3450
|
-
});
|
|
3451
|
-
});
|
|
3452
3263
|
it("watch push collapses 32k server-owned refusals to one exact-count event while board.json still uploads", async () => {
|
|
3453
3264
|
const companyRoot = path.join(tmpDir, "companies", "acme");
|
|
3454
3265
|
const sourceRoot = path.join(companyRoot, "sources", "meetings");
|