@substrat-run/contract-tests 0.139.0 → 0.140.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/capability-suite.d.ts.map +1 -1
- package/dist/capability-suite.js +5 -0
- package/dist/capability-suite.js.map +1 -1
- package/dist/caused-by-suite.d.ts.map +1 -1
- package/dist/caused-by-suite.js +54 -10
- package/dist/caused-by-suite.js.map +1 -1
- package/dist/connect-link-suite.d.ts +19 -0
- package/dist/connect-link-suite.d.ts.map +1 -0
- package/dist/connect-link-suite.js +215 -0
- package/dist/connect-link-suite.js.map +1 -0
- package/dist/entity-state-migration-suite.d.ts +16 -0
- package/dist/entity-state-migration-suite.d.ts.map +1 -0
- package/dist/entity-state-migration-suite.js +305 -0
- package/dist/entity-state-migration-suite.js.map +1 -0
- package/dist/entity-state-module.d.ts +183 -0
- package/dist/entity-state-module.d.ts.map +1 -1
- package/dist/entity-state-module.js +139 -1
- package/dist/entity-state-module.js.map +1 -1
- package/dist/entity-state-suite.d.ts.map +1 -1
- package/dist/entity-state-suite.js +35 -12
- package/dist/entity-state-suite.js.map +1 -1
- package/dist/entity-trash-module.d.ts +439 -0
- package/dist/entity-trash-module.d.ts.map +1 -0
- package/dist/entity-trash-module.js +287 -0
- package/dist/entity-trash-module.js.map +1 -0
- package/dist/entity-trash-suite.d.ts +59 -0
- package/dist/entity-trash-suite.d.ts.map +1 -0
- package/dist/entity-trash-suite.js +568 -0
- package/dist/entity-trash-suite.js.map +1 -0
- package/dist/erasure-module.d.ts +259 -0
- package/dist/erasure-module.d.ts.map +1 -0
- package/dist/erasure-module.js +251 -0
- package/dist/erasure-module.js.map +1 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/list-suite.d.ts.map +1 -1
- package/dist/list-suite.js +101 -1
- package/dist/list-suite.js.map +1 -1
- package/dist/membership-executor-suite.d.ts.map +1 -1
- package/dist/membership-executor-suite.js +60 -9
- package/dist/membership-executor-suite.js.map +1 -1
- package/dist/migration-comments-suite.d.ts +3 -0
- package/dist/migration-comments-suite.d.ts.map +1 -0
- package/dist/migration-comments-suite.js +92 -0
- package/dist/migration-comments-suite.js.map +1 -0
- package/dist/migration-comments.d.ts +3 -0
- package/dist/migration-comments.d.ts.map +1 -0
- package/dist/migration-comments.js +50 -0
- package/dist/migration-comments.js.map +1 -0
- package/dist/migration-digest-suite.d.ts +3 -0
- package/dist/migration-digest-suite.d.ts.map +1 -0
- package/dist/migration-digest-suite.js +175 -0
- package/dist/migration-digest-suite.js.map +1 -0
- package/dist/modules.d.ts +542 -0
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js +155 -7
- package/dist/modules.js.map +1 -1
- package/dist/peer-suite.d.ts +2 -1
- package/dist/peer-suite.d.ts.map +1 -1
- package/dist/peer-suite.js +103 -1
- package/dist/peer-suite.js.map +1 -1
- package/dist/permission-suite.d.ts.map +1 -1
- package/dist/permission-suite.js +515 -2
- package/dist/permission-suite.js.map +1 -1
- package/dist/scope-host-suite.d.ts.map +1 -1
- package/dist/scope-host-suite.js +54 -1
- package/dist/scope-host-suite.js.map +1 -1
- package/dist/split-cases.d.ts +12 -0
- package/dist/split-cases.d.ts.map +1 -0
- package/dist/split-cases.js +59 -0
- package/dist/split-cases.js.map +1 -0
- package/dist/subject-erasure-suite.d.ts +6 -0
- package/dist/subject-erasure-suite.d.ts.map +1 -0
- package/dist/subject-erasure-suite.js +287 -0
- package/dist/subject-erasure-suite.js.map +1 -0
- package/dist/switch-audit-fault.d.ts +48 -0
- package/dist/switch-audit-fault.d.ts.map +1 -0
- package/dist/switch-audit-fault.js +80 -0
- package/dist/switch-audit-fault.js.map +1 -0
- package/dist/system-switch-suite.d.ts +2 -1
- package/dist/system-switch-suite.d.ts.map +1 -1
- package/dist/system-switch-suite.js +90 -0
- package/dist/system-switch-suite.js.map +1 -1
- package/dist/vertical-events-suite.d.ts +41 -0
- package/dist/vertical-events-suite.d.ts.map +1 -1
- package/dist/vertical-events-suite.js +55 -0
- package/dist/vertical-events-suite.js.map +1 -1
- package/package.json +3 -3
|
@@ -52,6 +52,9 @@ export declare const stateModManifest: {
|
|
|
52
52
|
};
|
|
53
53
|
input?: Record<string, unknown> | undefined;
|
|
54
54
|
permissions: (string & import("zod").$brand<"PermissionKey">)[];
|
|
55
|
+
purge?: {
|
|
56
|
+
entityType: string;
|
|
57
|
+
} | undefined;
|
|
55
58
|
}[] | undefined;
|
|
56
59
|
peers?: {
|
|
57
60
|
vertical: string;
|
|
@@ -98,10 +101,24 @@ export declare const stateModManifest: {
|
|
|
98
101
|
entityStates?: {
|
|
99
102
|
archivePermission?: (string & import("zod").$brand<"PermissionKey">) | undefined;
|
|
100
103
|
trashPermission?: (string & import("zod").$brand<"PermissionKey">) | undefined;
|
|
104
|
+
purgeAfterDays?: number | undefined;
|
|
101
105
|
table?: string | undefined;
|
|
102
106
|
idColumn?: string | undefined;
|
|
103
107
|
entityType: string;
|
|
104
108
|
}[] | undefined;
|
|
109
|
+
erasure?: {
|
|
110
|
+
tables: string[];
|
|
111
|
+
entities: {
|
|
112
|
+
entityType: string;
|
|
113
|
+
table: string;
|
|
114
|
+
mode: "blank" | "custom" | "delete" | "unreached";
|
|
115
|
+
subjects?: string[] | undefined;
|
|
116
|
+
fields: {
|
|
117
|
+
name: string;
|
|
118
|
+
blank: "" | null;
|
|
119
|
+
}[];
|
|
120
|
+
}[];
|
|
121
|
+
} | undefined;
|
|
105
122
|
ui?: {
|
|
106
123
|
routes?: {
|
|
107
124
|
path: string;
|
|
@@ -131,4 +148,170 @@ export declare const stateModManifest: {
|
|
|
131
148
|
} | undefined;
|
|
132
149
|
};
|
|
133
150
|
export declare const stateMod: ModuleRegistration;
|
|
151
|
+
/**
|
|
152
|
+
* The fixture behind `entityStateMigrationContractSuite` (#2090): authored migrations that
|
|
153
|
+
* REBUILD a table, the create-copy-rename SQLite needs for a column type change or a dropped
|
|
154
|
+
* constraint.
|
|
155
|
+
*
|
|
156
|
+
* On a fresh scope every rebuild runs before the derived state migrations, so it is harmless
|
|
157
|
+
* there. The suite makes the scope forget one and runs the pass again — what a redeploy that
|
|
158
|
+
* added it to a scope already carrying the columns, the triggers and the list indexes does.
|
|
159
|
+
*
|
|
160
|
+
* - `0002` rebuilds `rb_notes` (archive and trash) keeping every column.
|
|
161
|
+
* - `0003` rebuilds `rb_cut` (trash) WITHOUT its state column.
|
|
162
|
+
* - `0004` rebuilds `rb_plain`, which declares no state, keeping every column.
|
|
163
|
+
* - `0005` + `0006` rebuild `rb_split` (trash) over TWO migrations: the first moves the table
|
|
164
|
+
* aside and creates the new one, the second copies the rows — binned ones included — across.
|
|
165
|
+
* - `0007` rebuilds `rb_search`, which is searchable: its index is kept in step by triggers on
|
|
166
|
+
* the table, which subject erasure relies on to take rewritten text out of it.
|
|
167
|
+
*/
|
|
168
|
+
export declare const rebuildModManifest: {
|
|
169
|
+
id: string & import("zod").$brand<"ModuleId">;
|
|
170
|
+
version: string;
|
|
171
|
+
kernelContract: string;
|
|
172
|
+
permissions: {
|
|
173
|
+
key: string & import("zod").$brand<"PermissionKey">;
|
|
174
|
+
description: string;
|
|
175
|
+
}[];
|
|
176
|
+
events: {
|
|
177
|
+
emits: {
|
|
178
|
+
type: string;
|
|
179
|
+
schemaVersion: number;
|
|
180
|
+
}[];
|
|
181
|
+
consumes: {
|
|
182
|
+
type: string;
|
|
183
|
+
schemaVersion: number;
|
|
184
|
+
from?: string | undefined;
|
|
185
|
+
}[];
|
|
186
|
+
exports?: {
|
|
187
|
+
type: string;
|
|
188
|
+
schemaVersion: number;
|
|
189
|
+
readPermission: string & import("zod").$brand<"PermissionKey">;
|
|
190
|
+
}[] | undefined;
|
|
191
|
+
};
|
|
192
|
+
migrations: {
|
|
193
|
+
journalDir: string;
|
|
194
|
+
compatibleFrom: string;
|
|
195
|
+
};
|
|
196
|
+
attachmentTargets: {
|
|
197
|
+
entityType: string;
|
|
198
|
+
readPermission: string & import("zod").$brand<"PermissionKey">;
|
|
199
|
+
writePermission?: (string & import("zod").$brand<"PermissionKey">) | undefined;
|
|
200
|
+
}[];
|
|
201
|
+
liveTargets?: {
|
|
202
|
+
entityType: string;
|
|
203
|
+
readPermission: string & import("zod").$brand<"PermissionKey">;
|
|
204
|
+
}[] | undefined;
|
|
205
|
+
entityRelations?: {
|
|
206
|
+
entityType: string;
|
|
207
|
+
parentType: string;
|
|
208
|
+
}[] | undefined;
|
|
209
|
+
guards?: {
|
|
210
|
+
before: string;
|
|
211
|
+
predicate: string;
|
|
212
|
+
config: Record<string, unknown>;
|
|
213
|
+
}[] | undefined;
|
|
214
|
+
schedules?: {
|
|
215
|
+
operation: string;
|
|
216
|
+
cadence: {
|
|
217
|
+
everyMinutes: number;
|
|
218
|
+
};
|
|
219
|
+
input?: Record<string, unknown> | undefined;
|
|
220
|
+
permissions: (string & import("zod").$brand<"PermissionKey">)[];
|
|
221
|
+
purge?: {
|
|
222
|
+
entityType: string;
|
|
223
|
+
} | undefined;
|
|
224
|
+
}[] | undefined;
|
|
225
|
+
peers?: {
|
|
226
|
+
vertical: string;
|
|
227
|
+
operations: string[];
|
|
228
|
+
permissions: (string & import("zod").$brand<"PermissionKey">)[];
|
|
229
|
+
}[] | undefined;
|
|
230
|
+
freshness?: {
|
|
231
|
+
eventType: string;
|
|
232
|
+
within: {
|
|
233
|
+
hours: number;
|
|
234
|
+
};
|
|
235
|
+
}[] | undefined;
|
|
236
|
+
withdraws?: string[] | undefined;
|
|
237
|
+
entitlementKey: string;
|
|
238
|
+
envSpec?: {
|
|
239
|
+
key: string;
|
|
240
|
+
label?: string | undefined;
|
|
241
|
+
description: string;
|
|
242
|
+
placeholder?: string | undefined;
|
|
243
|
+
required: boolean;
|
|
244
|
+
secret: boolean;
|
|
245
|
+
default?: string | undefined;
|
|
246
|
+
group?: string | undefined;
|
|
247
|
+
}[] | undefined;
|
|
248
|
+
ownerGrants?: (string & import("zod").$brand<"PermissionKey">)[] | undefined;
|
|
249
|
+
entitlements?: string[] | undefined;
|
|
250
|
+
provides?: string[] | undefined;
|
|
251
|
+
requires?: string[] | undefined;
|
|
252
|
+
api?: string | undefined;
|
|
253
|
+
searchables?: {
|
|
254
|
+
entityType: string;
|
|
255
|
+
fields: string[];
|
|
256
|
+
table?: string | undefined;
|
|
257
|
+
idColumn?: string | undefined;
|
|
258
|
+
tokenizer?: "prefix" | "substring" | undefined;
|
|
259
|
+
}[] | undefined;
|
|
260
|
+
lists?: {
|
|
261
|
+
entityType: string;
|
|
262
|
+
sortable: string[];
|
|
263
|
+
filterable?: string[] | undefined;
|
|
264
|
+
table?: string | undefined;
|
|
265
|
+
idColumn?: string | undefined;
|
|
266
|
+
}[] | undefined;
|
|
267
|
+
entityStates?: {
|
|
268
|
+
archivePermission?: (string & import("zod").$brand<"PermissionKey">) | undefined;
|
|
269
|
+
trashPermission?: (string & import("zod").$brand<"PermissionKey">) | undefined;
|
|
270
|
+
purgeAfterDays?: number | undefined;
|
|
271
|
+
table?: string | undefined;
|
|
272
|
+
idColumn?: string | undefined;
|
|
273
|
+
entityType: string;
|
|
274
|
+
}[] | undefined;
|
|
275
|
+
erasure?: {
|
|
276
|
+
tables: string[];
|
|
277
|
+
entities: {
|
|
278
|
+
entityType: string;
|
|
279
|
+
table: string;
|
|
280
|
+
mode: "blank" | "custom" | "delete" | "unreached";
|
|
281
|
+
subjects?: string[] | undefined;
|
|
282
|
+
fields: {
|
|
283
|
+
name: string;
|
|
284
|
+
blank: "" | null;
|
|
285
|
+
}[];
|
|
286
|
+
}[];
|
|
287
|
+
} | undefined;
|
|
288
|
+
ui?: {
|
|
289
|
+
routes?: {
|
|
290
|
+
path: string;
|
|
291
|
+
screen: string;
|
|
292
|
+
permission: string & import("zod").$brand<"PermissionKey">;
|
|
293
|
+
}[] | undefined;
|
|
294
|
+
nav?: {
|
|
295
|
+
label: string;
|
|
296
|
+
icon?: string | undefined;
|
|
297
|
+
to: string;
|
|
298
|
+
permission: string & import("zod").$brand<"PermissionKey">;
|
|
299
|
+
}[] | undefined;
|
|
300
|
+
entityViews?: {
|
|
301
|
+
entityType: string;
|
|
302
|
+
view: string;
|
|
303
|
+
}[] | undefined;
|
|
304
|
+
widgets?: {
|
|
305
|
+
slot: string;
|
|
306
|
+
component: string;
|
|
307
|
+
permission: string & import("zod").$brand<"PermissionKey">;
|
|
308
|
+
}[] | undefined;
|
|
309
|
+
settingsPanels?: {
|
|
310
|
+
label: string;
|
|
311
|
+
component: string;
|
|
312
|
+
permission: string & import("zod").$brand<"PermissionKey">;
|
|
313
|
+
}[] | undefined;
|
|
314
|
+
} | undefined;
|
|
315
|
+
};
|
|
316
|
+
export declare const rebuildMod: ModuleRegistration;
|
|
134
317
|
//# sourceMappingURL=entity-state-module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-state-module.d.ts","sourceRoot":"","sources":["../src/entity-state-module.ts"],"names":[],"mappings":"AAaA,OAAO,EAIL,KAAK,kBAAkB,EAExB,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"entity-state-module.d.ts","sourceRoot":"","sources":["../src/entity-state-module.ts"],"names":[],"mappings":"AAaA,OAAO,EAIL,KAAK,kBAAkB,EAExB,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6B3B,CAAC;AAQH,eAAO,MAAM,QAAQ,EAAE,kBA2FtB,CAAC;AAWF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyB7B,CAAC;AAQH,eAAO,MAAM,UAAU,EAAE,kBAgFxB,CAAC"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* Every operation is a thin pass-through to the verb or read under test, and checks nothing
|
|
11
11
|
* itself: the KERNEL's check of the declared key is what the suite is asserting on.
|
|
12
12
|
*/
|
|
13
|
-
import { moduleManifest } from '@substrat-run/contracts';
|
|
13
|
+
import { moduleManifest, operationInputsOf } from '@substrat-run/contracts';
|
|
14
14
|
import { listIndexPlans, listQuery, readHistory, } from '@substrat-run/kernel';
|
|
15
15
|
export const stateModManifest = moduleManifest.parse({
|
|
16
16
|
id: '@test/state',
|
|
@@ -137,4 +137,142 @@ export const stateMod = {
|
|
|
137
137
|
}),
|
|
138
138
|
},
|
|
139
139
|
};
|
|
140
|
+
/**
|
|
141
|
+
* #119 PR 2: every operation above declared, each with no input and no entity-narrowed check. They
|
|
142
|
+
* reach the entity through a raw `id`, deliberately, so the verbs' and readers' own refusals are
|
|
143
|
+
* what `entityStateContractSuite` sees — the host's refusal is `entityTrashContractSuite`'s. A
|
|
144
|
+
* trashable module must declare everything it binds, so this one says, in the host's terms, that
|
|
145
|
+
* none of them addresses an entity by id.
|
|
146
|
+
*/
|
|
147
|
+
stateMod.operationInputs = operationInputsOf(Object.fromEntries(Object.keys(stateMod.operations).map((name) => [name, {}])));
|
|
148
|
+
/**
|
|
149
|
+
* The fixture behind `entityStateMigrationContractSuite` (#2090): authored migrations that
|
|
150
|
+
* REBUILD a table, the create-copy-rename SQLite needs for a column type change or a dropped
|
|
151
|
+
* constraint.
|
|
152
|
+
*
|
|
153
|
+
* On a fresh scope every rebuild runs before the derived state migrations, so it is harmless
|
|
154
|
+
* there. The suite makes the scope forget one and runs the pass again — what a redeploy that
|
|
155
|
+
* added it to a scope already carrying the columns, the triggers and the list indexes does.
|
|
156
|
+
*
|
|
157
|
+
* - `0002` rebuilds `rb_notes` (archive and trash) keeping every column.
|
|
158
|
+
* - `0003` rebuilds `rb_cut` (trash) WITHOUT its state column.
|
|
159
|
+
* - `0004` rebuilds `rb_plain`, which declares no state, keeping every column.
|
|
160
|
+
* - `0005` + `0006` rebuild `rb_split` (trash) over TWO migrations: the first moves the table
|
|
161
|
+
* aside and creates the new one, the second copies the rows — binned ones included — across.
|
|
162
|
+
* - `0007` rebuilds `rb_search`, which is searchable: its index is kept in step by triggers on
|
|
163
|
+
* the table, which subject erasure relies on to take rewritten text out of it.
|
|
164
|
+
*/
|
|
165
|
+
export const rebuildModManifest = moduleManifest.parse({
|
|
166
|
+
id: '@test/rebuild',
|
|
167
|
+
version: '1.0.0',
|
|
168
|
+
kernelContract: '^0.0.1',
|
|
169
|
+
permissions: [
|
|
170
|
+
{ key: 'rb:use', description: 'use the rebuilt tables' },
|
|
171
|
+
{ key: 'rb:archive', description: 'archive a row' },
|
|
172
|
+
{ key: 'rb:trash', description: 'bin a row or restore it' },
|
|
173
|
+
],
|
|
174
|
+
events: { emits: [], consumes: [] },
|
|
175
|
+
migrations: { journalDir: './migrations', compatibleFrom: '1.0.0' },
|
|
176
|
+
attachmentTargets: [],
|
|
177
|
+
entitlementKey: 'rebuild',
|
|
178
|
+
searchables: [{ entityType: 'rbsearch', fields: ['title'], table: 'rb_search', idColumn: 'id' }],
|
|
179
|
+
lists: [
|
|
180
|
+
{ entityType: 'rbnote', sortable: ['title'], table: 'rb_notes', idColumn: 'id' },
|
|
181
|
+
{ entityType: 'rbcut', sortable: ['title'], table: 'rb_cut', idColumn: 'id' },
|
|
182
|
+
{ entityType: 'rbplain', sortable: ['title'], table: 'rb_plain', idColumn: 'id' },
|
|
183
|
+
{ entityType: 'rbsplit', sortable: ['title'], table: 'rb_split', idColumn: 'id' },
|
|
184
|
+
],
|
|
185
|
+
entityStates: [
|
|
186
|
+
{ entityType: 'rbnote', archivePermission: 'rb:archive', trashPermission: 'rb:trash', table: 'rb_notes', idColumn: 'id' },
|
|
187
|
+
{ entityType: 'rbcut', trashPermission: 'rb:trash', table: 'rb_cut', idColumn: 'id' },
|
|
188
|
+
{ entityType: 'rbsplit', trashPermission: 'rb:trash', table: 'rb_split', idColumn: 'id' },
|
|
189
|
+
],
|
|
190
|
+
});
|
|
191
|
+
const RB_TABLES = { rbnote: 'rb_notes', rbcut: 'rb_cut', rbplain: 'rb_plain', rbsplit: 'rb_split', rbsearch: 'rb_search' };
|
|
192
|
+
const rbRef = (input) => {
|
|
193
|
+
const i = input;
|
|
194
|
+
return { entityType: i.entityType, entityId: i.id };
|
|
195
|
+
};
|
|
196
|
+
export const rebuildMod = {
|
|
197
|
+
manifest: rebuildModManifest,
|
|
198
|
+
migrations: [
|
|
199
|
+
{
|
|
200
|
+
version: '0001-init',
|
|
201
|
+
sql: `CREATE TABLE rb_notes (id TEXT PRIMARY KEY, title TEXT NOT NULL);
|
|
202
|
+
CREATE TABLE rb_cut (id TEXT PRIMARY KEY, title TEXT NOT NULL);
|
|
203
|
+
CREATE TABLE rb_plain (id TEXT PRIMARY KEY, title TEXT NOT NULL);
|
|
204
|
+
CREATE TABLE rb_split (id TEXT PRIMARY KEY, title TEXT NOT NULL);
|
|
205
|
+
CREATE TABLE rb_search (id TEXT PRIMARY KEY, title TEXT NOT NULL);`,
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
version: '0002-rebuild-notes',
|
|
209
|
+
sql: `CREATE TABLE rb_notes_new AS SELECT * FROM rb_notes;
|
|
210
|
+
DROP TABLE rb_notes;
|
|
211
|
+
ALTER TABLE rb_notes_new RENAME TO rb_notes;`,
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
version: '0003-rebuild-cut',
|
|
215
|
+
sql: `CREATE TABLE rb_cut_new AS SELECT id, title FROM rb_cut;
|
|
216
|
+
DROP TABLE rb_cut;
|
|
217
|
+
ALTER TABLE rb_cut_new RENAME TO rb_cut;`,
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
version: '0004-rebuild-plain',
|
|
221
|
+
sql: `CREATE TABLE rb_plain_new AS SELECT * FROM rb_plain;
|
|
222
|
+
DROP TABLE rb_plain;
|
|
223
|
+
ALTER TABLE rb_plain_new RENAME TO rb_plain;`,
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
version: '0005-split-aside',
|
|
227
|
+
sql: `ALTER TABLE rb_split RENAME TO rb_split_old;
|
|
228
|
+
CREATE TABLE rb_split AS SELECT * FROM rb_split_old WHERE 0;`,
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
version: '0006-split-copy',
|
|
232
|
+
sql: `INSERT INTO rb_split SELECT * FROM rb_split_old;
|
|
233
|
+
DROP TABLE rb_split_old;`,
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
version: '0007-rebuild-search',
|
|
237
|
+
sql: `CREATE TABLE rb_search_new AS SELECT * FROM rb_search ORDER BY id DESC;
|
|
238
|
+
DROP TABLE rb_search;
|
|
239
|
+
ALTER TABLE rb_search_new RENAME TO rb_search;`,
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
operations: {
|
|
243
|
+
'rb/add': (async (ctx, input) => {
|
|
244
|
+
const i = input;
|
|
245
|
+
ctx.sql.exec(`INSERT INTO ${RB_TABLES[i.entityType]} (id, title) VALUES (?, ?)`, [i.id, i.title]);
|
|
246
|
+
return { id: i.id };
|
|
247
|
+
}),
|
|
248
|
+
'rb/trash': (async (ctx, input) => ctx.trash(rbRef(input))),
|
|
249
|
+
'rb/restore': (async (ctx, input) => ctx.restore(rbRef(input))),
|
|
250
|
+
'rb/state': (async (ctx, input) => ctx.entityState(rbRef(input))),
|
|
251
|
+
// Erasure's shape: the row's text rewritten in place, or the row gone.
|
|
252
|
+
'rb/retitle': (async (ctx, input) => {
|
|
253
|
+
const i = input;
|
|
254
|
+
ctx.sql.exec('UPDATE rb_search SET title = ? WHERE id = ?', [i.title, i.id]);
|
|
255
|
+
return null;
|
|
256
|
+
}),
|
|
257
|
+
'rb/remove': (async (ctx, input) => {
|
|
258
|
+
ctx.sql.exec('DELETE FROM rb_search WHERE id = ?', [input.id]);
|
|
259
|
+
return null;
|
|
260
|
+
}),
|
|
261
|
+
'rb/search': (async (ctx, input) => (await ctx.search('rbsearch', input.term)).map((h) => h.id)),
|
|
262
|
+
// A module's own runtime DDL (#1811), statement by statement through `ctx.sql`.
|
|
263
|
+
'rb/ddl': (async (ctx, input) => {
|
|
264
|
+
for (const statement of input.statements)
|
|
265
|
+
ctx.sql.exec(statement);
|
|
266
|
+
return null;
|
|
267
|
+
}),
|
|
268
|
+
// Several statements in ONE `ctx.sql` call — the rows of the last one.
|
|
269
|
+
'rb/batch': (async (ctx, input) => ctx.sql.query(input.sql)),
|
|
270
|
+
'rb/ddl-bound': (async (ctx) => ctx.sql.exec('ALTER TABLE rb_plain ADD COLUMN extra TEXT; UPDATE rb_plain SET extra = ?', ['x'])),
|
|
271
|
+
'rb/titles': (async (ctx, input) => ctx.sql
|
|
272
|
+
.query(`SELECT title FROM ${RB_TABLES[input.entityType]} ORDER BY title`)
|
|
273
|
+
.map((r) => r.title)),
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
/** Its operations declared the same way as `stateMod`'s, so a trashable module registers (#119). */
|
|
277
|
+
rebuildMod.operationInputs = operationInputsOf(Object.fromEntries(Object.keys(rebuildMod.operations).map((name) => [name, {}])));
|
|
140
278
|
//# sourceMappingURL=entity-state-module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-state-module.js","sourceRoot":"","sources":["../src/entity-state-module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,cAAc,EAAkB,MAAM,yBAAyB,CAAC;AACzE,OAAO,EACL,cAAc,EACd,SAAS,EACT,WAAW,GAGZ,MAAM,sBAAsB,CAAC;AAE9B,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC,KAAK,CAAC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L,KAAK,OAAO,EACZ,KAAK,QAAQ,EACd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAS9D;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAExH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,EAC5C,GAAG,EAAE,WAAW,GACf,IAAI,
|
|
1
|
+
{"version":3,"file":"entity-state-suite.d.ts","sourceRoot":"","sources":["../src/entity-state-suite.ts"],"names":[],"mappings":"AAYA,OAAO,EAYL,KAAK,OAAO,EACZ,KAAK,QAAQ,EACd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAS9D;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAExH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,EAC5C,GAAG,EAAE,WAAW,GACf,IAAI,CA4mBN"}
|
|
@@ -237,8 +237,6 @@ export function entityStateContractSuite(adapterName, makeFixture, raw) {
|
|
|
237
237
|
expect(seen).toEqual([carolsDoc]);
|
|
238
238
|
await as.alice.invoke('state/restore', { id: carolsDoc });
|
|
239
239
|
});
|
|
240
|
-
/** A cursor's envelope (K-44): base64url JSON naming the row it continues from. */
|
|
241
|
-
const decode = (cursor) => JSON.parse(new TextDecoder().decode(Uint8Array.from(atob(cursor.replace(/-/g, '+').replace(/_/g, '/')), (c) => c.charCodeAt(0))));
|
|
242
240
|
it('hands a caller denied every binned row an empty bin and NO cursor — no position of a hidden row leaks', async () => {
|
|
243
241
|
const hidden = await doc('hidden from bob');
|
|
244
242
|
await as.alice.invoke('state/trash', { id: hidden });
|
|
@@ -247,16 +245,44 @@ export function entityStateContractSuite(adapterName, makeFixture, raw) {
|
|
|
247
245
|
}
|
|
248
246
|
await as.alice.invoke('state/restore', { id: hidden });
|
|
249
247
|
});
|
|
250
|
-
it('
|
|
248
|
+
it('seals a bin cursor and binds it to the caller, including across both adapters', async () => {
|
|
251
249
|
const others = [await doc('aaa other'), await doc('zzz other')];
|
|
252
250
|
for (const id of [...others, carolsDoc])
|
|
253
251
|
await as.alice.invoke('state/trash', { id });
|
|
254
252
|
const first = await as.carol.invoke('state/page-trashed', { limit: 1 });
|
|
255
253
|
expect(ids(first)).toEqual([carolsDoc]);
|
|
256
254
|
expect(first.nextCursor).not.toBeNull();
|
|
257
|
-
|
|
258
|
-
expect(
|
|
259
|
-
expect(
|
|
255
|
+
expect(first.nextCursor).toMatch(/^sc1\./);
|
|
256
|
+
expect(first.nextCursor).not.toContain(carolsDoc);
|
|
257
|
+
expect(first.nextCursor).not.toContain('carol owns this');
|
|
258
|
+
// Both adapters keep the key outside the scope SQL module code can read.
|
|
259
|
+
expect(await as.carol.invoke('state/sql', {
|
|
260
|
+
sql: "SELECT name FROM sqlite_master WHERE name LIKE 'private_continuation_%'",
|
|
261
|
+
})).toEqual([]);
|
|
262
|
+
expect(await errOf(as.carol.invoke('state/sql', {
|
|
263
|
+
sql: 'SELECT keyring FROM private_continuation_keys',
|
|
264
|
+
}))).toBeTruthy();
|
|
265
|
+
if (adapterName === 'adapter-cloudflare') {
|
|
266
|
+
// DO KV shares workerd's SQLite internals. The module SQL wrapper must
|
|
267
|
+
// refuse their names before workerd can hand the keyring back.
|
|
268
|
+
const internal = await errOf(as.carol.invoke('state/sql', { sql: 'SELECT * FROM _cf_KV' }));
|
|
269
|
+
expect(errorCodeOf(internal)).toBe('forbidden');
|
|
270
|
+
expect(await as.carol.invoke('state/sql', { sql: 'SELECT 1 AS ok /* _cf_KV */' })).toEqual([{ ok: 1 }]);
|
|
271
|
+
const consoleRead = await errOf(host.admin.queryScope(staff, t1, scope, { sql: 'SELECT * FROM _cf_KV' }));
|
|
272
|
+
expect(errorCodeOf(consoleRead)).toBe('forbidden');
|
|
273
|
+
await expect(host.admin.readScopeTable(staff, t1, scope, { table: '_cf_KV', limit: 1, offset: 0 }))
|
|
274
|
+
.rejects.toBeTruthy();
|
|
275
|
+
expect((await host.admin.listScopeTables(staff, t1, scope)).some((table) => table.name.startsWith('_cf_'))).toBe(false);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
// The private directory database is a distinct file, unreachable through the
|
|
279
|
+
// scope console as well as the module SQL seam.
|
|
280
|
+
await expect(host.admin.queryScope(staff, t1, scope, {
|
|
281
|
+
sql: 'SELECT keyring FROM private_continuation_keys',
|
|
282
|
+
})).rejects.toBeTruthy();
|
|
283
|
+
}
|
|
284
|
+
const replay = await errOf(as.bob.invoke('state/page-trashed', { limit: 1, cursor: first.nextCursor }));
|
|
285
|
+
expect(replay).toMatchObject({ extensions: { reason: PAGE_CURSOR_RESTART } });
|
|
260
286
|
expect(await as.carol.invoke('state/page-trashed', { limit: 1, cursor: first.nextCursor })).toEqual({
|
|
261
287
|
entries: [],
|
|
262
288
|
nextCursor: null,
|
|
@@ -505,16 +531,13 @@ export function entityStateContractSuite(adapterName, makeFixture, raw) {
|
|
|
505
531
|
}
|
|
506
532
|
expect(await as.alice.invoke('state/restore', { id })).toBe('active');
|
|
507
533
|
});
|
|
508
|
-
it('
|
|
534
|
+
it('repairs, in the same operation, a guard trigger missing when runtime DDL runs (#2090)', async () => {
|
|
509
535
|
// Past the guard, take one derived trigger away — what a form nobody foresaw would do.
|
|
510
536
|
await raw(t1, scope, 'DROP TRIGGER _substrat_state_state_docs_born');
|
|
511
537
|
const t = `rt_${ulid().toLowerCase()}`;
|
|
512
|
-
const err = await errOf(as.alice.invoke('state/sql', { sql: `CREATE TABLE ${t} (id TEXT)` }));
|
|
513
|
-
expect(String(err.message)).toMatch(/without its born trigger/);
|
|
514
|
-
expect(await as.alice.invoke('state/sql', { sql: `SELECT name FROM sqlite_master WHERE name = '${t}'` })).toEqual([]);
|
|
515
|
-
// Put it back exactly as the kernel derives it, and the same DDL runs.
|
|
516
|
-
await raw(t1, scope, `CREATE TRIGGER _substrat_state_state_docs_born BEFORE INSERT ON state_docs WHEN NEW._substrat_archived_at IS NOT NULL OR NEW._substrat_trashed_at IS NOT NULL BEGIN SELECT RAISE(ABORT, 'a row is never inserted archived or trashed - ctx.archive and ctx.trash move it (#119)'); END`);
|
|
517
538
|
await as.alice.invoke('state/sql', { sql: `CREATE TABLE ${t} (id TEXT)` });
|
|
539
|
+
// The trigger is back as the kernel derives it: a row is never born binned again.
|
|
540
|
+
await expect(raw(t1, scope, `INSERT INTO state_docs (id, title, owner, _substrat_trashed_at) VALUES ('${ulid()}', 't', 'o', '2026')`)).rejects.toThrow(/never inserted archived or trashed/);
|
|
518
541
|
await as.alice.invoke('state/sql', { sql: `DROP TABLE ${t}` });
|
|
519
542
|
});
|
|
520
543
|
// -- the indexes -------------------------------------------------------------------------
|