@crombolo/data 0.77.0 → 0.78.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.78.0",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. SQLite and Postgres storage for crombolo: schema, migrations and repositories.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@crombolo/core": "0.
|
|
32
|
+
"@crombolo/core": "0.78.0",
|
|
33
33
|
"kysely": "0.29.6"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -357,6 +357,40 @@ export class ChangeRepository {
|
|
|
357
357
|
await this.#touch(id, now)
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
+
/**
|
|
361
|
+
* Story 413: a person's newest change that holds a page, made by their own edits or by
|
|
362
|
+
* the merge of their own workspace, closed if it was still open.
|
|
363
|
+
*/
|
|
364
|
+
async closeHolding(
|
|
365
|
+
madeBy: string,
|
|
366
|
+
pageKey: string,
|
|
367
|
+
now = new Date(),
|
|
368
|
+
): Promise<{ id: string; key: string; name: string | null; merged: boolean } | undefined> {
|
|
369
|
+
const row = await this.#db.q
|
|
370
|
+
.selectFrom('content_transfer_change as c')
|
|
371
|
+
.innerJoin('content_transfer_run as r', 'r.id', 'c.run_id')
|
|
372
|
+
.select(['r.id', 'r.change_kind', 'r.closed_at'])
|
|
373
|
+
.where('c.node_key', '=', normaliseUuid(pageKey))
|
|
374
|
+
.where('r.made_by', '=', normaliseUuid(madeBy))
|
|
375
|
+
.where('r.change_kind', 'in', ['edit', 'merge'])
|
|
376
|
+
.orderBy('r.started_at', 'desc')
|
|
377
|
+
.executeTakeFirst()
|
|
378
|
+
if (!row) return undefined
|
|
379
|
+
const id = String(row.id)
|
|
380
|
+
const merged = row.change_kind === 'merge'
|
|
381
|
+
if (!merged && row.closed_at === null) {
|
|
382
|
+
const closed = await this.#close(id, now)
|
|
383
|
+
return { id, ...closed, merged }
|
|
384
|
+
}
|
|
385
|
+
const run = await this.byId(id)
|
|
386
|
+
return run ? { id, key: run.key, name: run.name, merged } : undefined
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/** Story 413: a page's schedule set by an approval, kept in the change that holds the page. */
|
|
390
|
+
async scheduleIn(changeId: string, pageKey: string, entries: readonly unknown[]): Promise<void> {
|
|
391
|
+
await this.#keepItem(changeId, `${SCHEDULE_PREFIX}${normaliseUuid(pageKey)}`, null, entries)
|
|
392
|
+
}
|
|
393
|
+
|
|
360
394
|
/** Closes a person's open change (story 411): finished, to be passed on. */
|
|
361
395
|
async closeOpen(
|
|
362
396
|
madeBy: string,
|
|
@@ -3129,8 +3129,15 @@ export class DocumentRepository {
|
|
|
3129
3129
|
const languages = await this.#languages()
|
|
3130
3130
|
const workspace = this.#workspace ?? null
|
|
3131
3131
|
await this.#db.transaction(async (tx) => {
|
|
3132
|
-
// Story 414: the first time a workspace sets one, Shared's as it was then
|
|
3133
|
-
|
|
3132
|
+
// Story 414: the first time a workspace sets one, Shared's as it was then; a publish
|
|
3133
|
+
// that names no time, and finds none to clear, sets none.
|
|
3134
|
+
const timed = entries.some((e) => e.publishTime !== null || e.unpublishTime !== null)
|
|
3135
|
+
const clears =
|
|
3136
|
+
!timed &&
|
|
3137
|
+
workspace !== null &&
|
|
3138
|
+
((await scheduleEntriesOf(tx, node.id, workspace)).length > 0 ||
|
|
3139
|
+
(await scheduleEntriesOf(tx, node.id, null)).length > 0)
|
|
3140
|
+
if (workspace !== null && (timed || clears)) {
|
|
3134
3141
|
const held = await tx.q
|
|
3135
3142
|
.selectFrom('workspace_schedule')
|
|
3136
3143
|
.select('node_id')
|