@jam-overture/loom 0.2.0 → 0.3.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/audience/compose.d.ts +112 -0
- package/dist/audience/compose.js +134 -0
- package/dist/audience/memory.d.ts +14 -0
- package/dist/audience/memory.js +71 -0
- package/dist/audience/overlay-store.d.ts +343 -0
- package/dist/audience/overlay-store.js +217 -0
- package/dist/audience/rule.d.ts +121 -0
- package/dist/audience/rule.js +78 -0
- package/dist/cli/index.d.ts +3 -4
- package/dist/cli/index.js +3 -4
- package/dist/data/adapter.d.ts +9 -1
- package/dist/data/adapter.js +2 -0
- package/dist/data/resolve.d.ts +1 -1
- package/dist/interpretation/anthropic.d.ts +1 -1
- package/dist/interpretation/anthropic.js +2 -22
- package/dist/interpretation/client.d.ts +1 -1
- package/dist/interpretation/materialize.js +67 -22
- package/dist/interpretation/openai-compatible.d.ts +36 -0
- package/dist/interpretation/openai-compatible.js +79 -0
- package/dist/interpretation/status.d.ts +19 -0
- package/dist/interpretation/status.js +26 -0
- package/dist/live/index.d.ts +73 -0
- package/dist/live/index.js +73 -0
- package/dist/live/pages.d.ts +187 -0
- package/dist/live/pages.js +161 -0
- package/dist/live/pull.d.ts +147 -0
- package/dist/live/pull.js +398 -0
- package/dist/live/pulling.d.ts +79 -0
- package/dist/live/pulling.js +117 -0
- package/dist/live/window.d.ts +129 -0
- package/dist/live/window.js +132 -0
- package/dist/render/addressed.d.ts +35 -0
- package/dist/render/addressed.js +79 -0
- package/dist/render/document-theme.d.ts +70 -0
- package/dist/render/document-theme.js +139 -0
- package/dist/render/editable.d.ts +15 -1
- package/dist/render/editable.js +13 -1
- package/dist/render/expected.d.ts +98 -0
- package/dist/render/expected.js +88 -0
- package/dist/render/index.d.ts +2 -0
- package/dist/render/index.js +2 -0
- package/dist/render/render.d.ts +11 -0
- package/dist/render/render.js +192 -46
- package/dist/render/request.d.ts +8 -1
- package/dist/render/request.js +1 -0
- package/dist/runtime/auto-apply-ceiling.d.ts +54 -0
- package/dist/runtime/auto-apply-ceiling.js +66 -0
- package/dist/runtime/gate.js +69 -10
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/nesting.d.ts +13 -1
- package/dist/runtime/nesting.js +41 -24
- package/dist/runtime/policy-change.js +8 -2
- package/dist/runtime/policy-log.d.ts +5 -5
- package/dist/runtime/policy.d.ts +8 -6
- package/dist/runtime/policy.js +5 -2
- package/dist/runtime/repointing.js +0 -0
- package/dist/sdk/definition.d.ts +65 -6
- package/dist/sdk/definition.js +44 -0
- package/dist/sdk/registry.d.ts +17 -1
- package/dist/sdk/registry.js +39 -0
- package/dist/signals/acted.contract.d.ts +21 -0
- package/dist/signals/acted.contract.js +236 -0
- package/dist/signals/acted.d.ts +359 -0
- package/dist/signals/acted.js +135 -0
- package/dist/signals/agenda.d.ts +585 -0
- package/dist/signals/agenda.js +295 -0
- package/dist/signals/arrivals.contract.d.ts +21 -0
- package/dist/signals/arrivals.contract.js +180 -0
- package/dist/signals/arrivals.d.ts +375 -0
- package/dist/signals/arrivals.js +254 -0
- package/dist/signals/broadcast.d.ts +25 -15
- package/dist/signals/broadcast.js +209 -36
- package/dist/signals/collect.d.ts +137 -43
- package/dist/signals/collect.js +103 -36
- package/dist/signals/conversion.d.ts +348 -0
- package/dist/signals/conversion.js +235 -0
- package/dist/signals/correlated.contract.d.ts +24 -0
- package/dist/signals/correlated.contract.js +94 -0
- package/dist/signals/counters.d.ts +51 -0
- package/dist/signals/counters.js +58 -0
- package/dist/signals/deployment-change.d.ts +28 -4
- package/dist/signals/deployment-change.js +57 -16
- package/dist/signals/deployment.d.ts +18 -5
- package/dist/signals/deployment.js +37 -11
- package/dist/signals/door.d.ts +34 -12
- package/dist/signals/door.js +37 -13
- package/dist/signals/expire.d.ts +192 -0
- package/dist/signals/expire.js +213 -0
- package/dist/signals/frontier.d.ts +268 -0
- package/dist/signals/frontier.js +145 -0
- package/dist/signals/funnel-hours.contract.d.ts +21 -0
- package/dist/signals/funnel-hours.contract.js +221 -0
- package/dist/signals/funnel-hours.d.ts +293 -0
- package/dist/signals/funnel-hours.js +99 -0
- package/dist/signals/funnel.d.ts +60 -0
- package/dist/signals/funnel.js +35 -20
- package/dist/signals/health.d.ts +201 -4
- package/dist/signals/health.js +214 -2
- package/dist/signals/index.d.ts +19 -0
- package/dist/signals/index.js +19 -0
- package/dist/signals/inside.d.ts +190 -0
- package/dist/signals/inside.js +263 -0
- package/dist/signals/join.d.ts +56 -0
- package/dist/signals/join.js +60 -0
- package/dist/signals/journal.d.ts +112 -9
- package/dist/signals/kept.contract.d.ts +22 -0
- package/dist/signals/kept.contract.js +111 -0
- package/dist/signals/library-agenda-change.d.ts +324 -0
- package/dist/signals/library-agenda-change.js +199 -0
- package/dist/signals/library-agenda.d.ts +258 -0
- package/dist/signals/library-agenda.js +167 -0
- package/dist/signals/library-reach-change.d.ts +10 -0
- package/dist/signals/library-reach-change.js +11 -3
- package/dist/signals/library-senders-change.d.ts +457 -0
- package/dist/signals/library-senders-change.js +367 -0
- package/dist/signals/library-senders-reach-change.d.ts +486 -0
- package/dist/signals/library-senders-reach-change.js +538 -0
- package/dist/signals/library-senders-reach.d.ts +340 -0
- package/dist/signals/library-senders-reach.js +252 -0
- package/dist/signals/library-senders.d.ts +271 -0
- package/dist/signals/library-senders.js +180 -0
- package/dist/signals/library-word-reach-change.js +2 -6
- package/dist/signals/memory.js +142 -1
- package/dist/signals/migrate.d.ts +6 -5
- package/dist/signals/migrate.js +150 -6
- package/dist/signals/notice.d.ts +88 -33
- package/dist/signals/notice.js +38 -16
- package/dist/signals/part-pace.d.ts +378 -0
- package/dist/signals/part-pace.js +333 -0
- package/dist/signals/parts.d.ts +25 -15
- package/dist/signals/parts.js +32 -73
- package/dist/signals/postgres.js +400 -26
- package/dist/signals/region.d.ts +1 -1
- package/dist/signals/retention.d.ts +43 -21
- package/dist/signals/retention.js +25 -8
- package/dist/signals/rhythm.d.ts +302 -0
- package/dist/signals/rhythm.js +262 -0
- package/dist/signals/rollup.d.ts +127 -1
- package/dist/signals/rollup.js +211 -24
- package/dist/signals/schema.d.ts +640 -3
- package/dist/signals/schema.js +239 -3
- package/dist/signals/silences.d.ts +310 -11
- package/dist/signals/silences.js +243 -0
- package/dist/signals/subtrees.d.ts +123 -0
- package/dist/signals/subtrees.js +102 -0
- package/dist/signals/tally.d.ts +125 -4
- package/dist/signals/unread.d.ts +292 -0
- package/dist/signals/unread.js +137 -0
- package/dist/signals/window-agenda.d.ts +276 -0
- package/dist/signals/window-agenda.js +83 -0
- package/dist/signals/window-funnels.d.ts +88 -0
- package/dist/signals/window-funnels.js +47 -0
- package/dist/store/cache.d.ts +101 -0
- package/dist/store/cache.js +149 -0
- package/dist/store/history.d.ts +82 -0
- package/dist/store/history.js +36 -0
- package/dist/store/index.d.ts +11 -0
- package/dist/store/index.js +11 -0
- package/dist/store/migrate.d.ts +26 -0
- package/dist/store/migrate.js +64 -0
- package/dist/store/postgres-audience.d.ts +14 -0
- package/dist/store/postgres-audience.js +272 -0
- package/dist/store/postgres.d.ts +1 -0
- package/dist/store/postgres.js +1 -0
- package/dist/store/schema.d.ts +312 -0
- package/dist/store/schema.js +77 -0
- package/dist/store/source.d.ts +57 -1
- package/dist/store/source.js +65 -1
- package/dist/submit/resolve.d.ts +1 -1
- package/dist/telemetry/index.d.ts +1 -0
- package/dist/telemetry/index.js +1 -0
- package/dist/telemetry/journal.d.ts +32 -0
- package/dist/telemetry/memory.js +10 -1
- package/dist/telemetry/postgres.js +18 -2
- package/dist/telemetry/window.d.ts +135 -0
- package/dist/telemetry/window.js +101 -0
- package/dist/testing/audience-overlay-contract.d.ts +31 -0
- package/dist/testing/audience-overlay-contract.js +354 -0
- package/dist/testing/contracts.d.ts +1 -0
- package/dist/testing/contracts.js +1 -0
- package/dist/testing/journal-contract.js +158 -5
- package/dist/theme/contrast.d.ts +19 -14
- package/dist/theme/contrast.js +181 -17
- package/dist/tree/apply.js +13 -0
- package/dist/tree/mutation.d.ts +18 -0
- package/dist/tree/mutation.js +24 -12
- package/dist/tree/navigation.d.ts +5 -0
- package/dist/tree/navigation.js +32 -10
- package/dist/tree/outline.d.ts +7 -0
- package/dist/tree/outline.js +9 -5
- package/package.json +39 -96
- package/dist/runtime/inverse-interpreter.d.ts +0 -90
- package/dist/runtime/inverse-interpreter.js +0 -56
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { and, desc, eq } from "drizzle-orm";
|
|
2
|
+
import { DEFAULT_APPLICATION_ID } from "../application/application.js";
|
|
3
|
+
import { audienceFormListingsOf, audienceOverlayOf, audienceRulesOutcomeOf, clampAudienceRuleHistoryLimit, parseAudienceRuleRevision, parseStoredAudienceForm, servedFormsOf, withdrawnFormOf, } from "../audience/overlay-store.js";
|
|
4
|
+
import { err, ok } from "../result.js";
|
|
5
|
+
import { isUniqueViolation, unavailable } from "./driver.js";
|
|
6
|
+
import { loomAudienceForms, loomAudienceRules } from "./schema.js";
|
|
7
|
+
/**
|
|
8
|
+
* The audience dimension, backed by Postgres (0022). It is the table that
|
|
9
|
+
* `AudienceOverlaySource` was declared as a seam in place of, and it is the
|
|
10
|
+
* store dimension a page served per audience has been waiting on (0263, 0359).
|
|
11
|
+
*
|
|
12
|
+
* **There is no transaction here, and that is the point of the composite primary
|
|
13
|
+
* key.** `recordRules` reads the head, computes the next revision and inserts
|
|
14
|
+
* it; two editors racing at the same head both compute `N + 1` and the database
|
|
15
|
+
* refuses the second. `loom_revisions` and `loom_policy_revisions` get their
|
|
16
|
+
* ordering guarantee the same way, and a `SELECT … FOR UPDATE` could not serve
|
|
17
|
+
* here anyway: the first revision of a page's rules has no row to lock.
|
|
18
|
+
*
|
|
19
|
+
* A refused insert is reported as `out-of-date` against the head as it is *now*,
|
|
20
|
+
* which is the truth the caller needs rather than the one it raced against.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Rows come back as `unknown` and are parsed, never cast — storage is a boundary
|
|
24
|
+
* like any other, and it is the one where the data outlives the code that wrote
|
|
25
|
+
* it. A rule is edited rarely and read on every request for as long as the page
|
|
26
|
+
* is published, so of everything in this schema it is among the likeliest to be
|
|
27
|
+
* read back by code that did not write it.
|
|
28
|
+
*/
|
|
29
|
+
const toRevision = (row, treeId) => parseAudienceRuleRevision({
|
|
30
|
+
treeId: row.treeId,
|
|
31
|
+
revision: row.revision,
|
|
32
|
+
rules: row.rules,
|
|
33
|
+
actor: row.actor,
|
|
34
|
+
recordedAt: row.recordedAt,
|
|
35
|
+
}, treeId);
|
|
36
|
+
/**
|
|
37
|
+
* **Two columns become one field or none**, which is where the backend's
|
|
38
|
+
* spelling of *not withdrawn* stops: `NULL` is mapped to an absent key here, so
|
|
39
|
+
* what the parser and every caller downstream see is the single shape
|
|
40
|
+
* `StoredAudienceForm` declares. A half-set pair — `withdrawn_at` with no
|
|
41
|
+
* `withdrawn_by` — is no write this module makes, and reaches the parser as a
|
|
42
|
+
* withdrawal missing its actor, which `unreadable` is for.
|
|
43
|
+
*/
|
|
44
|
+
const toForm = (row, treeId) => parseStoredAudienceForm({
|
|
45
|
+
treeId: row.treeId,
|
|
46
|
+
audienceId: row.audienceId,
|
|
47
|
+
delta: row.delta,
|
|
48
|
+
actor: row.actor,
|
|
49
|
+
authoredAt: row.authoredAt,
|
|
50
|
+
...(row.withdrawnBy === null && row.withdrawnAt === null
|
|
51
|
+
? {}
|
|
52
|
+
: { withdrawn: { actor: row.withdrawnBy, at: row.withdrawnAt } }),
|
|
53
|
+
}, treeId);
|
|
54
|
+
/**
|
|
55
|
+
* Every query is filtered by the application this handle speaks for (0260), and
|
|
56
|
+
* every write sets it.
|
|
57
|
+
*
|
|
58
|
+
* Without it a page's rules would be read across applications, and two
|
|
59
|
+
* deployments that happened to name their trees alike would serve each other's
|
|
60
|
+
* forms — which is the one thing a dimension that decides *who sees what* cannot
|
|
61
|
+
* get wrong.
|
|
62
|
+
*/
|
|
63
|
+
export const postgresAudienceOverlayStore = (db, scope = {}) => {
|
|
64
|
+
const application = scope.application ?? DEFAULT_APPLICATION_ID;
|
|
65
|
+
const head = async (treeId) => {
|
|
66
|
+
try {
|
|
67
|
+
const rows = await db
|
|
68
|
+
.select()
|
|
69
|
+
.from(loomAudienceRules)
|
|
70
|
+
.where(mineRules(application, eq(loomAudienceRules.treeId, treeId)))
|
|
71
|
+
.orderBy(desc(loomAudienceRules.revision))
|
|
72
|
+
.limit(1);
|
|
73
|
+
const row = rows[0];
|
|
74
|
+
return row === undefined ? ok(undefined) : toRevision(row, treeId);
|
|
75
|
+
}
|
|
76
|
+
catch (cause) {
|
|
77
|
+
return err(unavailable(cause, `could not read ${treeId}'s audience rules`));
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const storedForms = async (treeId) => {
|
|
81
|
+
try {
|
|
82
|
+
const rows = await db
|
|
83
|
+
.select()
|
|
84
|
+
.from(loomAudienceForms)
|
|
85
|
+
.where(mineForms(application, eq(loomAudienceForms.treeId, treeId)))
|
|
86
|
+
.orderBy(loomAudienceForms.audienceId);
|
|
87
|
+
const forms = [];
|
|
88
|
+
for (const row of rows) {
|
|
89
|
+
const form = toForm(row, treeId);
|
|
90
|
+
if (!form.ok)
|
|
91
|
+
return form;
|
|
92
|
+
forms.push(form.value);
|
|
93
|
+
}
|
|
94
|
+
return ok(forms);
|
|
95
|
+
}
|
|
96
|
+
catch (cause) {
|
|
97
|
+
return err(unavailable(cause, `could not read ${treeId}'s audience forms`));
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
overlay: async (treeId) => {
|
|
102
|
+
const rules = await head(treeId);
|
|
103
|
+
if (!rules.ok)
|
|
104
|
+
return rules;
|
|
105
|
+
const forms = await storedForms(treeId);
|
|
106
|
+
if (!forms.ok)
|
|
107
|
+
return forms;
|
|
108
|
+
return ok(audienceOverlayOf(rules.value, servedFormsOf(forms.value)));
|
|
109
|
+
},
|
|
110
|
+
rules: async (treeId) => head(treeId),
|
|
111
|
+
history: async (treeId, request) => {
|
|
112
|
+
try {
|
|
113
|
+
const rows = await db
|
|
114
|
+
.select()
|
|
115
|
+
.from(loomAudienceRules)
|
|
116
|
+
.where(mineRules(application, eq(loomAudienceRules.treeId, treeId)))
|
|
117
|
+
.orderBy(desc(loomAudienceRules.revision))
|
|
118
|
+
.limit(clampAudienceRuleHistoryLimit(request?.limit));
|
|
119
|
+
const revisions = [];
|
|
120
|
+
for (const row of rows) {
|
|
121
|
+
const revision = toRevision(row, treeId);
|
|
122
|
+
if (!revision.ok)
|
|
123
|
+
return revision;
|
|
124
|
+
revisions.push(revision.value);
|
|
125
|
+
}
|
|
126
|
+
return ok(revisions);
|
|
127
|
+
}
|
|
128
|
+
catch (cause) {
|
|
129
|
+
return err(unavailable(cause, `could not read ${treeId}'s audience rule history`));
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
forms: async (treeId) => {
|
|
133
|
+
const forms = await storedForms(treeId);
|
|
134
|
+
return forms.ok ? ok(audienceFormListingsOf(forms.value)) : forms;
|
|
135
|
+
},
|
|
136
|
+
recordRules: async (treeId, request) => {
|
|
137
|
+
/**
|
|
138
|
+
* Outside the `try`, because `head` is total: the only statement here that
|
|
139
|
+
* can collide is the insert, and a narrow `try` is what lets the `catch`
|
|
140
|
+
* say *a unique violation on this insert means somebody else recorded*
|
|
141
|
+
* rather than guessing which of two statements threw.
|
|
142
|
+
*/
|
|
143
|
+
const current = await head(treeId);
|
|
144
|
+
if (!current.ok)
|
|
145
|
+
return current;
|
|
146
|
+
const outcome = audienceRulesOutcomeOf(treeId, request, current.value);
|
|
147
|
+
if (!outcome.ok || outcome.value.outcome === "unchanged")
|
|
148
|
+
return outcome;
|
|
149
|
+
const revision = outcome.value.revision;
|
|
150
|
+
try {
|
|
151
|
+
await db.insert(loomAudienceRules).values({
|
|
152
|
+
applicationId: application,
|
|
153
|
+
treeId: revision.treeId,
|
|
154
|
+
revision: revision.revision,
|
|
155
|
+
rules: revision.rules,
|
|
156
|
+
actor: revision.actor,
|
|
157
|
+
recordedAt: revision.recordedAt,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
catch (cause) {
|
|
161
|
+
if (!isUniqueViolation(cause)) {
|
|
162
|
+
return err(unavailable(cause, `could not record ${treeId}'s audience rules`));
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Somebody else took this revision between the read and the insert. The
|
|
166
|
+
* head is re-read rather than guessed at, so the number reported is the
|
|
167
|
+
* one the caller now has to edit from.
|
|
168
|
+
*/
|
|
169
|
+
const raced = await head(treeId);
|
|
170
|
+
return err({
|
|
171
|
+
code: "out-of-date",
|
|
172
|
+
treeId,
|
|
173
|
+
expected: request.expectedRevision ?? current.value?.revision ?? 0,
|
|
174
|
+
current: raced.ok ? (raced.value?.revision ?? 0) : revision.revision,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return outcome;
|
|
178
|
+
},
|
|
179
|
+
setForm: async (treeId, request) => {
|
|
180
|
+
if (request.delta.treeId !== treeId) {
|
|
181
|
+
return err({
|
|
182
|
+
code: "tree-mismatch",
|
|
183
|
+
treeId,
|
|
184
|
+
delta: request.delta.treeId,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
const stored = { treeId, ...request, withdrawn: undefined };
|
|
188
|
+
try {
|
|
189
|
+
await db
|
|
190
|
+
.insert(loomAudienceForms)
|
|
191
|
+
.values({
|
|
192
|
+
applicationId: application,
|
|
193
|
+
treeId,
|
|
194
|
+
audienceId: request.audienceId,
|
|
195
|
+
delta: request.delta,
|
|
196
|
+
baseRevision: request.delta.baseRevision,
|
|
197
|
+
actor: request.actor,
|
|
198
|
+
authoredAt: request.authoredAt,
|
|
199
|
+
withdrawnBy: null,
|
|
200
|
+
withdrawnAt: null,
|
|
201
|
+
})
|
|
202
|
+
/**
|
|
203
|
+
* The rebase, as one statement. A form replaced by reading it, deciding
|
|
204
|
+
* it has moved and writing it back is a form two editors can lose half
|
|
205
|
+
* of; the key is already the identity, so the database can be asked to
|
|
206
|
+
* do it in one.
|
|
207
|
+
*/
|
|
208
|
+
.onConflictDoUpdate({
|
|
209
|
+
target: [
|
|
210
|
+
loomAudienceForms.applicationId,
|
|
211
|
+
loomAudienceForms.treeId,
|
|
212
|
+
loomAudienceForms.audienceId,
|
|
213
|
+
],
|
|
214
|
+
set: {
|
|
215
|
+
delta: request.delta,
|
|
216
|
+
baseRevision: request.delta.baseRevision,
|
|
217
|
+
actor: request.actor,
|
|
218
|
+
authoredAt: request.authoredAt,
|
|
219
|
+
/**
|
|
220
|
+
* Writing a form puts it back into service (0403). Left out of
|
|
221
|
+
* the `set`, a form withdrawn and then written again would keep
|
|
222
|
+
* its withdrawal and go on not being served — the work rebuilt
|
|
223
|
+
* and the segment still getting the base, with nothing naming
|
|
224
|
+
* the reason.
|
|
225
|
+
*/
|
|
226
|
+
withdrawnBy: null,
|
|
227
|
+
withdrawnAt: null,
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
catch (cause) {
|
|
232
|
+
return err(unavailable(cause, `could not store ${request.audienceId}'s form of ${treeId}`));
|
|
233
|
+
}
|
|
234
|
+
return ok(stored);
|
|
235
|
+
},
|
|
236
|
+
/**
|
|
237
|
+
* **Read, then a conditional update, and no transaction**, which is the
|
|
238
|
+
* shape the rest of this module earns the right to: the row is read to
|
|
239
|
+
* answer with it and to tell *withdrew one* from *there was none*, and the
|
|
240
|
+
* `UPDATE`'s own `WHERE` is what makes the write safe rather than the read
|
|
241
|
+
* being fresh. A `setForm` racing it either lands first — and is withdrawn,
|
|
242
|
+
* which is what the caller asked — or lands after and puts the form back,
|
|
243
|
+
* which is the later of two acts winning.
|
|
244
|
+
*/
|
|
245
|
+
withdrawForm: async (treeId, request) => {
|
|
246
|
+
const forms = await storedForms(treeId);
|
|
247
|
+
if (!forms.ok)
|
|
248
|
+
return forms;
|
|
249
|
+
const held = forms.value.find((form) => form.audienceId === request.audienceId);
|
|
250
|
+
if (held === undefined)
|
|
251
|
+
return ok(undefined);
|
|
252
|
+
try {
|
|
253
|
+
await db
|
|
254
|
+
.update(loomAudienceForms)
|
|
255
|
+
.set({ withdrawnBy: request.actor, withdrawnAt: request.withdrawnAt })
|
|
256
|
+
.where(mineForms(application, eq(loomAudienceForms.treeId, treeId), eq(loomAudienceForms.audienceId, request.audienceId)));
|
|
257
|
+
}
|
|
258
|
+
catch (cause) {
|
|
259
|
+
return err(unavailable(cause, `could not withdraw ${request.audienceId}'s form of ${treeId}`));
|
|
260
|
+
}
|
|
261
|
+
return ok(withdrawnFormOf(held, request));
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Every read starts at one of these, so a query cannot forget the application by
|
|
267
|
+
* omission — the device `postgresTreeStore` and `postgresPolicyLog` both use,
|
|
268
|
+
* written per table because the two tables are two sets of columns.
|
|
269
|
+
*/
|
|
270
|
+
const mineRules = (application, ...rest) => and(eq(loomAudienceRules.applicationId, application), ...rest);
|
|
271
|
+
const mineForms = (application, ...rest) => and(eq(loomAudienceForms.applicationId, application), ...rest);
|
|
272
|
+
//# sourceMappingURL=postgres-audience.js.map
|
package/dist/store/postgres.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { LoomDatabase } from "./database.js";
|
|
|
3
3
|
import { type TreeStore } from "./store.js";
|
|
4
4
|
export * from "./database.js";
|
|
5
5
|
export * from "./migrate.js";
|
|
6
|
+
export * from "./postgres-audience.js";
|
|
6
7
|
export * from "./postgres-holds.js";
|
|
7
8
|
export * from "./postgres-policy-log.js";
|
|
8
9
|
export * from "./postgres-applications.js";
|
package/dist/store/postgres.js
CHANGED
|
@@ -13,6 +13,7 @@ import { loomRevisions, loomTrees } from "./schema.js";
|
|
|
13
13
|
import { anchorBound, anchorResumes, clampListingLimit, clampRevisionLimit, } from "./store.js";
|
|
14
14
|
export * from "./database.js";
|
|
15
15
|
export * from "./migrate.js";
|
|
16
|
+
export * from "./postgres-audience.js";
|
|
16
17
|
export * from "./postgres-holds.js";
|
|
17
18
|
export * from "./postgres-policy-log.js";
|
|
18
19
|
export * from "./postgres-applications.js";
|
package/dist/store/schema.d.ts
CHANGED
|
@@ -816,4 +816,316 @@ export declare const loomProjects: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
816
816
|
};
|
|
817
817
|
dialect: "pg";
|
|
818
818
|
}>;
|
|
819
|
+
/**
|
|
820
|
+
* A page's audience rules, as an append-only log of the whole ordered list.
|
|
821
|
+
*
|
|
822
|
+
* The composite primary key is load-bearing exactly as `loom_revisions`' and
|
|
823
|
+
* `loom_policy_revisions`' are: it makes the *database* enforce the sequence, so
|
|
824
|
+
* two people editing one page's rules cannot both commit even if both read the
|
|
825
|
+
* head before either wrote. `overlay-store.ts` says the same from the other
|
|
826
|
+
* side.
|
|
827
|
+
*
|
|
828
|
+
* `rules` is the whole ordered list as JSON rather than a row per rule, and that
|
|
829
|
+
* is the decision this table exists to carry. 0359 clause 3 makes the order the
|
|
830
|
+
* precedence — the last matching rule wins a contested node — and an order
|
|
831
|
+
* expressed as a `position` column is an order a reorder half-applies: several
|
|
832
|
+
* row updates, with a reader arriving between two of them served a precedence
|
|
833
|
+
* nobody authored. One value, written once, is the only shape that cannot do
|
|
834
|
+
* that. It is also the reason `loom_trees.document` is one column.
|
|
835
|
+
*
|
|
836
|
+
* `recorded_at` is text rather than a timestamp to match
|
|
837
|
+
* `loom_revisions.applied_at` and `loom_policy_revisions.recorded_at` — an
|
|
838
|
+
* ISO-8601 UTC instant orders lexicographically exactly as it orders in time, and
|
|
839
|
+
* what the runtime holds above this boundary is a string.
|
|
840
|
+
*/
|
|
841
|
+
export declare const loomAudienceRules: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
842
|
+
name: "loom_audience_rules";
|
|
843
|
+
schema: undefined;
|
|
844
|
+
columns: {
|
|
845
|
+
applicationId: import("drizzle-orm/pg-core").PgColumn<{
|
|
846
|
+
name: "application_id";
|
|
847
|
+
tableName: "loom_audience_rules";
|
|
848
|
+
dataType: "string";
|
|
849
|
+
columnType: "PgText";
|
|
850
|
+
data: string;
|
|
851
|
+
driverParam: string;
|
|
852
|
+
notNull: true;
|
|
853
|
+
hasDefault: true;
|
|
854
|
+
isPrimaryKey: false;
|
|
855
|
+
isAutoincrement: false;
|
|
856
|
+
hasRuntimeDefault: false;
|
|
857
|
+
enumValues: [string, ...string[]];
|
|
858
|
+
baseColumn: never;
|
|
859
|
+
identity: undefined;
|
|
860
|
+
generated: undefined;
|
|
861
|
+
}, {}, {}>;
|
|
862
|
+
treeId: import("drizzle-orm/pg-core").PgColumn<{
|
|
863
|
+
name: "tree_id";
|
|
864
|
+
tableName: "loom_audience_rules";
|
|
865
|
+
dataType: "string";
|
|
866
|
+
columnType: "PgText";
|
|
867
|
+
data: string;
|
|
868
|
+
driverParam: string;
|
|
869
|
+
notNull: true;
|
|
870
|
+
hasDefault: false;
|
|
871
|
+
isPrimaryKey: false;
|
|
872
|
+
isAutoincrement: false;
|
|
873
|
+
hasRuntimeDefault: false;
|
|
874
|
+
enumValues: [string, ...string[]];
|
|
875
|
+
baseColumn: never;
|
|
876
|
+
identity: undefined;
|
|
877
|
+
generated: undefined;
|
|
878
|
+
}, {}, {}>;
|
|
879
|
+
revision: import("drizzle-orm/pg-core").PgColumn<{
|
|
880
|
+
name: "revision";
|
|
881
|
+
tableName: "loom_audience_rules";
|
|
882
|
+
dataType: "number";
|
|
883
|
+
columnType: "PgInteger";
|
|
884
|
+
data: number;
|
|
885
|
+
driverParam: string | number;
|
|
886
|
+
notNull: true;
|
|
887
|
+
hasDefault: false;
|
|
888
|
+
isPrimaryKey: false;
|
|
889
|
+
isAutoincrement: false;
|
|
890
|
+
hasRuntimeDefault: false;
|
|
891
|
+
enumValues: undefined;
|
|
892
|
+
baseColumn: never;
|
|
893
|
+
identity: undefined;
|
|
894
|
+
generated: undefined;
|
|
895
|
+
}, {}, {}>;
|
|
896
|
+
rules: import("drizzle-orm/pg-core").PgColumn<{
|
|
897
|
+
name: "rules";
|
|
898
|
+
tableName: "loom_audience_rules";
|
|
899
|
+
dataType: "json";
|
|
900
|
+
columnType: "PgJsonb";
|
|
901
|
+
data: unknown;
|
|
902
|
+
driverParam: unknown;
|
|
903
|
+
notNull: true;
|
|
904
|
+
hasDefault: false;
|
|
905
|
+
isPrimaryKey: false;
|
|
906
|
+
isAutoincrement: false;
|
|
907
|
+
hasRuntimeDefault: false;
|
|
908
|
+
enumValues: undefined;
|
|
909
|
+
baseColumn: never;
|
|
910
|
+
identity: undefined;
|
|
911
|
+
generated: undefined;
|
|
912
|
+
}, {}, {}>;
|
|
913
|
+
actor: import("drizzle-orm/pg-core").PgColumn<{
|
|
914
|
+
name: "actor";
|
|
915
|
+
tableName: "loom_audience_rules";
|
|
916
|
+
dataType: "string";
|
|
917
|
+
columnType: "PgText";
|
|
918
|
+
data: string;
|
|
919
|
+
driverParam: string;
|
|
920
|
+
notNull: true;
|
|
921
|
+
hasDefault: false;
|
|
922
|
+
isPrimaryKey: false;
|
|
923
|
+
isAutoincrement: false;
|
|
924
|
+
hasRuntimeDefault: false;
|
|
925
|
+
enumValues: [string, ...string[]];
|
|
926
|
+
baseColumn: never;
|
|
927
|
+
identity: undefined;
|
|
928
|
+
generated: undefined;
|
|
929
|
+
}, {}, {}>;
|
|
930
|
+
recordedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
931
|
+
name: "recorded_at";
|
|
932
|
+
tableName: "loom_audience_rules";
|
|
933
|
+
dataType: "string";
|
|
934
|
+
columnType: "PgText";
|
|
935
|
+
data: string;
|
|
936
|
+
driverParam: string;
|
|
937
|
+
notNull: true;
|
|
938
|
+
hasDefault: false;
|
|
939
|
+
isPrimaryKey: false;
|
|
940
|
+
isAutoincrement: false;
|
|
941
|
+
hasRuntimeDefault: false;
|
|
942
|
+
enumValues: [string, ...string[]];
|
|
943
|
+
baseColumn: never;
|
|
944
|
+
identity: undefined;
|
|
945
|
+
generated: undefined;
|
|
946
|
+
}, {}, {}>;
|
|
947
|
+
};
|
|
948
|
+
dialect: "pg";
|
|
949
|
+
}>;
|
|
950
|
+
/**
|
|
951
|
+
* The delta each audience earns, one row per audience per page.
|
|
952
|
+
*
|
|
953
|
+
* Rows rather than a second log, and the asymmetry with the table above is
|
|
954
|
+
* deliberate: a rule decides *who sees which form* and is therefore a decision
|
|
955
|
+
* to be attributed, where a form is a document being worked on and rebased onto
|
|
956
|
+
* a base that has moved. A log of every edit of a form would be a record of
|
|
957
|
+
* drafting rather than of deciding, and the record of how a form came to say
|
|
958
|
+
* what it says is the proposal that produced it.
|
|
959
|
+
*
|
|
960
|
+
* One row per audience rather than one row per page holding every form: two
|
|
961
|
+
* audiences' forms are then independent writes, which is what a deployment with
|
|
962
|
+
* four audiences and two editors needs.
|
|
963
|
+
*
|
|
964
|
+
* `base_revision` is the one denormalised value here, and it is a column for the
|
|
965
|
+
* query it exists for — the same argument `loom_policy_revisions.fingerprint` is
|
|
966
|
+
* a column on. A screen listing a page's audiences asks *which of these forms is
|
|
967
|
+
* behind the page*, and answering it from `delta` means loading every delta to
|
|
968
|
+
* read one integer off each. The write takes it from the delta beside it and
|
|
969
|
+
* never from a caller, so the two cannot disagree.
|
|
970
|
+
*/
|
|
971
|
+
export declare const loomAudienceForms: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
972
|
+
name: "loom_audience_forms";
|
|
973
|
+
schema: undefined;
|
|
974
|
+
columns: {
|
|
975
|
+
applicationId: import("drizzle-orm/pg-core").PgColumn<{
|
|
976
|
+
name: "application_id";
|
|
977
|
+
tableName: "loom_audience_forms";
|
|
978
|
+
dataType: "string";
|
|
979
|
+
columnType: "PgText";
|
|
980
|
+
data: string;
|
|
981
|
+
driverParam: string;
|
|
982
|
+
notNull: true;
|
|
983
|
+
hasDefault: true;
|
|
984
|
+
isPrimaryKey: false;
|
|
985
|
+
isAutoincrement: false;
|
|
986
|
+
hasRuntimeDefault: false;
|
|
987
|
+
enumValues: [string, ...string[]];
|
|
988
|
+
baseColumn: never;
|
|
989
|
+
identity: undefined;
|
|
990
|
+
generated: undefined;
|
|
991
|
+
}, {}, {}>;
|
|
992
|
+
treeId: import("drizzle-orm/pg-core").PgColumn<{
|
|
993
|
+
name: "tree_id";
|
|
994
|
+
tableName: "loom_audience_forms";
|
|
995
|
+
dataType: "string";
|
|
996
|
+
columnType: "PgText";
|
|
997
|
+
data: string;
|
|
998
|
+
driverParam: string;
|
|
999
|
+
notNull: true;
|
|
1000
|
+
hasDefault: false;
|
|
1001
|
+
isPrimaryKey: false;
|
|
1002
|
+
isAutoincrement: false;
|
|
1003
|
+
hasRuntimeDefault: false;
|
|
1004
|
+
enumValues: [string, ...string[]];
|
|
1005
|
+
baseColumn: never;
|
|
1006
|
+
identity: undefined;
|
|
1007
|
+
generated: undefined;
|
|
1008
|
+
}, {}, {}>;
|
|
1009
|
+
audienceId: import("drizzle-orm/pg-core").PgColumn<{
|
|
1010
|
+
name: "audience_id";
|
|
1011
|
+
tableName: "loom_audience_forms";
|
|
1012
|
+
dataType: "string";
|
|
1013
|
+
columnType: "PgText";
|
|
1014
|
+
data: string;
|
|
1015
|
+
driverParam: string;
|
|
1016
|
+
notNull: true;
|
|
1017
|
+
hasDefault: false;
|
|
1018
|
+
isPrimaryKey: false;
|
|
1019
|
+
isAutoincrement: false;
|
|
1020
|
+
hasRuntimeDefault: false;
|
|
1021
|
+
enumValues: [string, ...string[]];
|
|
1022
|
+
baseColumn: never;
|
|
1023
|
+
identity: undefined;
|
|
1024
|
+
generated: undefined;
|
|
1025
|
+
}, {}, {}>;
|
|
1026
|
+
delta: import("drizzle-orm/pg-core").PgColumn<{
|
|
1027
|
+
name: "delta";
|
|
1028
|
+
tableName: "loom_audience_forms";
|
|
1029
|
+
dataType: "json";
|
|
1030
|
+
columnType: "PgJsonb";
|
|
1031
|
+
data: unknown;
|
|
1032
|
+
driverParam: unknown;
|
|
1033
|
+
notNull: true;
|
|
1034
|
+
hasDefault: false;
|
|
1035
|
+
isPrimaryKey: false;
|
|
1036
|
+
isAutoincrement: false;
|
|
1037
|
+
hasRuntimeDefault: false;
|
|
1038
|
+
enumValues: undefined;
|
|
1039
|
+
baseColumn: never;
|
|
1040
|
+
identity: undefined;
|
|
1041
|
+
generated: undefined;
|
|
1042
|
+
}, {}, {}>;
|
|
1043
|
+
baseRevision: import("drizzle-orm/pg-core").PgColumn<{
|
|
1044
|
+
name: "base_revision";
|
|
1045
|
+
tableName: "loom_audience_forms";
|
|
1046
|
+
dataType: "number";
|
|
1047
|
+
columnType: "PgInteger";
|
|
1048
|
+
data: number;
|
|
1049
|
+
driverParam: string | number;
|
|
1050
|
+
notNull: true;
|
|
1051
|
+
hasDefault: false;
|
|
1052
|
+
isPrimaryKey: false;
|
|
1053
|
+
isAutoincrement: false;
|
|
1054
|
+
hasRuntimeDefault: false;
|
|
1055
|
+
enumValues: undefined;
|
|
1056
|
+
baseColumn: never;
|
|
1057
|
+
identity: undefined;
|
|
1058
|
+
generated: undefined;
|
|
1059
|
+
}, {}, {}>;
|
|
1060
|
+
actor: import("drizzle-orm/pg-core").PgColumn<{
|
|
1061
|
+
name: "actor";
|
|
1062
|
+
tableName: "loom_audience_forms";
|
|
1063
|
+
dataType: "string";
|
|
1064
|
+
columnType: "PgText";
|
|
1065
|
+
data: string;
|
|
1066
|
+
driverParam: string;
|
|
1067
|
+
notNull: true;
|
|
1068
|
+
hasDefault: false;
|
|
1069
|
+
isPrimaryKey: false;
|
|
1070
|
+
isAutoincrement: false;
|
|
1071
|
+
hasRuntimeDefault: false;
|
|
1072
|
+
enumValues: [string, ...string[]];
|
|
1073
|
+
baseColumn: never;
|
|
1074
|
+
identity: undefined;
|
|
1075
|
+
generated: undefined;
|
|
1076
|
+
}, {}, {}>;
|
|
1077
|
+
authoredAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
1078
|
+
name: "authored_at";
|
|
1079
|
+
tableName: "loom_audience_forms";
|
|
1080
|
+
dataType: "string";
|
|
1081
|
+
columnType: "PgText";
|
|
1082
|
+
data: string;
|
|
1083
|
+
driverParam: string;
|
|
1084
|
+
notNull: true;
|
|
1085
|
+
hasDefault: false;
|
|
1086
|
+
isPrimaryKey: false;
|
|
1087
|
+
isAutoincrement: false;
|
|
1088
|
+
hasRuntimeDefault: false;
|
|
1089
|
+
enumValues: [string, ...string[]];
|
|
1090
|
+
baseColumn: never;
|
|
1091
|
+
identity: undefined;
|
|
1092
|
+
generated: undefined;
|
|
1093
|
+
}, {}, {}>;
|
|
1094
|
+
withdrawnBy: import("drizzle-orm/pg-core").PgColumn<{
|
|
1095
|
+
name: "withdrawn_by";
|
|
1096
|
+
tableName: "loom_audience_forms";
|
|
1097
|
+
dataType: "string";
|
|
1098
|
+
columnType: "PgText";
|
|
1099
|
+
data: string;
|
|
1100
|
+
driverParam: string;
|
|
1101
|
+
notNull: false;
|
|
1102
|
+
hasDefault: false;
|
|
1103
|
+
isPrimaryKey: false;
|
|
1104
|
+
isAutoincrement: false;
|
|
1105
|
+
hasRuntimeDefault: false;
|
|
1106
|
+
enumValues: [string, ...string[]];
|
|
1107
|
+
baseColumn: never;
|
|
1108
|
+
identity: undefined;
|
|
1109
|
+
generated: undefined;
|
|
1110
|
+
}, {}, {}>;
|
|
1111
|
+
withdrawnAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
1112
|
+
name: "withdrawn_at";
|
|
1113
|
+
tableName: "loom_audience_forms";
|
|
1114
|
+
dataType: "string";
|
|
1115
|
+
columnType: "PgText";
|
|
1116
|
+
data: string;
|
|
1117
|
+
driverParam: string;
|
|
1118
|
+
notNull: false;
|
|
1119
|
+
hasDefault: false;
|
|
1120
|
+
isPrimaryKey: false;
|
|
1121
|
+
isAutoincrement: false;
|
|
1122
|
+
hasRuntimeDefault: false;
|
|
1123
|
+
enumValues: [string, ...string[]];
|
|
1124
|
+
baseColumn: never;
|
|
1125
|
+
identity: undefined;
|
|
1126
|
+
generated: undefined;
|
|
1127
|
+
}, {}, {}>;
|
|
1128
|
+
};
|
|
1129
|
+
dialect: "pg";
|
|
1130
|
+
}>;
|
|
819
1131
|
//# sourceMappingURL=schema.d.ts.map
|
package/dist/store/schema.js
CHANGED
|
@@ -211,4 +211,81 @@ export const loomProjects = pgTable("loom_projects", {
|
|
|
211
211
|
*/
|
|
212
212
|
closedAt: text("closed_at"),
|
|
213
213
|
});
|
|
214
|
+
/**
|
|
215
|
+
* A page's audience rules, as an append-only log of the whole ordered list.
|
|
216
|
+
*
|
|
217
|
+
* The composite primary key is load-bearing exactly as `loom_revisions`' and
|
|
218
|
+
* `loom_policy_revisions`' are: it makes the *database* enforce the sequence, so
|
|
219
|
+
* two people editing one page's rules cannot both commit even if both read the
|
|
220
|
+
* head before either wrote. `overlay-store.ts` says the same from the other
|
|
221
|
+
* side.
|
|
222
|
+
*
|
|
223
|
+
* `rules` is the whole ordered list as JSON rather than a row per rule, and that
|
|
224
|
+
* is the decision this table exists to carry. 0359 clause 3 makes the order the
|
|
225
|
+
* precedence — the last matching rule wins a contested node — and an order
|
|
226
|
+
* expressed as a `position` column is an order a reorder half-applies: several
|
|
227
|
+
* row updates, with a reader arriving between two of them served a precedence
|
|
228
|
+
* nobody authored. One value, written once, is the only shape that cannot do
|
|
229
|
+
* that. It is also the reason `loom_trees.document` is one column.
|
|
230
|
+
*
|
|
231
|
+
* `recorded_at` is text rather than a timestamp to match
|
|
232
|
+
* `loom_revisions.applied_at` and `loom_policy_revisions.recorded_at` — an
|
|
233
|
+
* ISO-8601 UTC instant orders lexicographically exactly as it orders in time, and
|
|
234
|
+
* what the runtime holds above this boundary is a string.
|
|
235
|
+
*/
|
|
236
|
+
export const loomAudienceRules = pgTable("loom_audience_rules", {
|
|
237
|
+
/** See `loomTrees.applicationId`. */
|
|
238
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
239
|
+
treeId: text("tree_id").notNull(),
|
|
240
|
+
revision: integer("revision").notNull(),
|
|
241
|
+
rules: jsonb("rules").notNull(),
|
|
242
|
+
/** Who made these the rules (0200). Never null, for the reason `loom_policy_revisions.actor` is not. */
|
|
243
|
+
actor: text("actor").notNull(),
|
|
244
|
+
recordedAt: text("recorded_at").notNull(),
|
|
245
|
+
}, (table) => [primaryKey({ columns: [table.applicationId, table.treeId, table.revision] })]);
|
|
246
|
+
/**
|
|
247
|
+
* The delta each audience earns, one row per audience per page.
|
|
248
|
+
*
|
|
249
|
+
* Rows rather than a second log, and the asymmetry with the table above is
|
|
250
|
+
* deliberate: a rule decides *who sees which form* and is therefore a decision
|
|
251
|
+
* to be attributed, where a form is a document being worked on and rebased onto
|
|
252
|
+
* a base that has moved. A log of every edit of a form would be a record of
|
|
253
|
+
* drafting rather than of deciding, and the record of how a form came to say
|
|
254
|
+
* what it says is the proposal that produced it.
|
|
255
|
+
*
|
|
256
|
+
* One row per audience rather than one row per page holding every form: two
|
|
257
|
+
* audiences' forms are then independent writes, which is what a deployment with
|
|
258
|
+
* four audiences and two editors needs.
|
|
259
|
+
*
|
|
260
|
+
* `base_revision` is the one denormalised value here, and it is a column for the
|
|
261
|
+
* query it exists for — the same argument `loom_policy_revisions.fingerprint` is
|
|
262
|
+
* a column on. A screen listing a page's audiences asks *which of these forms is
|
|
263
|
+
* behind the page*, and answering it from `delta` means loading every delta to
|
|
264
|
+
* read one integer off each. The write takes it from the delta beside it and
|
|
265
|
+
* never from a caller, so the two cannot disagree.
|
|
266
|
+
*/
|
|
267
|
+
export const loomAudienceForms = pgTable("loom_audience_forms", {
|
|
268
|
+
/** See `loomTrees.applicationId`. */
|
|
269
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
270
|
+
treeId: text("tree_id").notNull(),
|
|
271
|
+
audienceId: text("audience_id").notNull(),
|
|
272
|
+
delta: jsonb("delta").notNull(),
|
|
273
|
+
baseRevision: integer("base_revision").notNull(),
|
|
274
|
+
actor: text("actor").notNull(),
|
|
275
|
+
authoredAt: text("authored_at").notNull(),
|
|
276
|
+
/**
|
|
277
|
+
* Who took this form out of service and when, both `NULL` while it is the
|
|
278
|
+
* form its audience is served (0403).
|
|
279
|
+
*
|
|
280
|
+
* **Two nullable columns and not a delete**, which is what keeps the
|
|
281
|
+
* no-delete rule (0376): the row stays, carrying the delta it held, so the
|
|
282
|
+
* day the change is wanted again the work is there and `setForm` is the one
|
|
283
|
+
* call that puts it back. They are set and cleared together — `withdrawnAt`
|
|
284
|
+
* without `withdrawnBy` is a state no write here produces.
|
|
285
|
+
*/
|
|
286
|
+
withdrawnBy: text("withdrawn_by"),
|
|
287
|
+
withdrawnAt: text("withdrawn_at"),
|
|
288
|
+
}, (table) => [
|
|
289
|
+
primaryKey({ columns: [table.applicationId, table.treeId, table.audienceId] }),
|
|
290
|
+
]);
|
|
214
291
|
//# sourceMappingURL=schema.js.map
|