@mulmoclaude/core 3.15.0 → 4.0.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.
@@ -4,8 +4,7 @@ const require_root = require("./root-rPH6FGDT.cjs");
4
4
  const require_relPath = require("./relPath-CTAjGdCL.cjs");
5
5
  const require_itemId = require("./itemId-Dzrr3vs5.cjs");
6
6
  const require_promptSafety = require("./promptSafety-CWqYq-NS.cjs");
7
- const require_discovery = require("./discovery-BsXiDZBR.cjs");
8
- const require_templatePath = require("./templatePath-27vUZowm.cjs");
7
+ const require_discovery = require("./discovery-C_3gXoin.cjs");
9
8
  const require_feeds_paths = require("./feeds/paths.cjs");
10
9
  const require_skill_bridge_index = require("./skill-bridge/index.cjs");
11
10
  let node_path = require("node:path");
@@ -13,1584 +12,6 @@ node_path = require_rolldown_runtime.__toESM(node_path, 1);
13
12
  let node_crypto = require("node:crypto");
14
13
  let node_fs_promises = require("node:fs/promises");
15
14
  let zod = require("zod");
16
- //#region src/collection/server/appViews.ts
17
- /** The audiences a view may be written for. A CLOSED set: each one names a
18
- * tier with a rule behind it, so an unknown value has nowhere to be
19
- * published to and is refused before it gets there. */
20
- var VIEW_AUDIENCES = [
21
- "public",
22
- "member",
23
- "participant"
24
- ];
25
- /** Where each audience's documents live under `apps/{aid}`. `public` is not
26
- * here: it keeps `config/public` + `config/view`, which are already published
27
- * and already read by a deployed runtime. */
28
- var VIEW_TIER = {
29
- member: "member",
30
- participant: "roster"
31
- };
32
- /** The id `public.view` normalizes to. Fixed rather than derived, so two
33
- * implementations of the same normalization cannot pick different ones. */
34
- var PUBLIC_VIEW_ID = "public";
35
- /** `config` is the projection's own document in every tier (`live:config`),
36
- * so a view may not be called that — the two would be the same document. */
37
- var RESERVED_VIEW_IDS = ["config"];
38
- /** What an id may be.
39
- *
40
- * Narrow on purpose: this value is written by the author, and it becomes a
41
- * Firestore document id under a `live:` / `staged:` prefix. Excluding `:`
42
- * keeps the prefix and the id from running together; excluding `/`, `.` and
43
- * `__…__` keeps it a legal document id that addresses the path it says. */
44
- var VIEW_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,63}$/;
45
- var VIEW_ID_SHAPE = "must be lowercase letters, digits and hyphens, start with a letter or digit, and be at most 64 characters (e.g. front-desk)";
46
- /** Both declarations of the same thing, in one file.
47
- *
48
- * Refused rather than merged or preferred: whichever way it were resolved,
49
- * the author would have written two answers and been shown neither. */
50
- var BOTH_FORMS = "app.json declares both `views` and `public.view`. These are the same thing — `public.view` is the older spelling — and publishing would have to choose one silently. Move the `public.view` entry into `views` as { id: \"public\", audience: \"public\", … } and delete it.";
51
- /** The two declarations, as one list, or the refusal that they are both there.
52
- *
53
- * `public.view` becomes an entry under the reserved id, so everything
54
- * downstream reads one shape and "which spelling was used" is decided once. */
55
- function declaredViews(app) {
56
- const legacy = app.public?.view;
57
- const authored = app.views;
58
- if (legacy !== void 0 && authored !== void 0) return {
59
- ok: false,
60
- problems: [BOTH_FORMS]
61
- };
62
- const views = (authored ?? []).map((view, index) => ({
63
- id: view.id,
64
- audience: view.audience,
65
- path: view.path,
66
- collections: view.collections,
67
- where: `views[${index}]`
68
- }));
69
- if (legacy === void 0) return {
70
- ok: true,
71
- views
72
- };
73
- if (views.some((view) => view.id === "public")) return {
74
- ok: false,
75
- problems: [`views declares id '${PUBLIC_VIEW_ID}', which is reserved for the older \`public.view\` spelling. ${BOTH_FORMS}`]
76
- };
77
- return {
78
- ok: true,
79
- views: [...views, {
80
- id: PUBLIC_VIEW_ID,
81
- audience: "public",
82
- path: legacy.path,
83
- collections: legacy.collections,
84
- where: "public.view"
85
- }]
86
- };
87
- }
88
- /** Whether one id may be used, and what to say when it may not. */
89
- function viewIdProblems(view) {
90
- if (RESERVED_VIEW_IDS.includes(view.id)) return [`${view.where}.id is '${view.id}', which is reserved: each audience's own declaration is published at that document id.`];
91
- if (!VIEW_ID_PATTERN.test(view.id)) return [`${view.where}.id is '${view.id}': a view id ${VIEW_ID_SHAPE}. It becomes the document id this view is published at.`];
92
- if (view.id === "public" && view.audience !== "public") return [`${view.where}.id is '${PUBLIC_VIEW_ID}' with audience '${view.audience}': that id belongs to the public page.`];
93
- return [];
94
- }
95
- /** ONE public page per app, and the reason is the wire rather than taste.
96
- *
97
- * The public runtime reads a single `config/view` document and a single
98
- * `config/public.view` declaration beside it. A second `audience: "public"`
99
- * entry would pass every other check and then be published nowhere — and
100
- * which of the two became the live page would depend on declaration order,
101
- * silently. The member tiers have no such limit: `id` is their address, and
102
- * each one gets its own document.
103
- *
104
- * The refusal is here rather than "one day we will support it" precisely
105
- * because the failure is invisible: nothing errors, and the author sees a
106
- * successful publish of a page nobody is served. */
107
- function singlePublicProblems(views) {
108
- const [first, ...rest] = views.filter((view) => view.audience === "public");
109
- if (first === void 0) return [];
110
- return rest.map((view) => `${view.where} is a second audience "public" view, after ${first.where}. The public page is published at ONE document (config/view), so only one of them could ever be served — and which, would depend on the order they were written in. Give the others audience "member" or "participant", which are addressed by id and may have as many as the app needs.`);
111
- }
112
- /** The one shape everything downstream reads.
113
- *
114
- * Every caller — the publish gate, the projection, the host that writes the
115
- * documents — goes through this, so "which declaration was used" is decided
116
- * exactly once. */
117
- function normalizeViews(app) {
118
- const declared = declaredViews(app);
119
- if (!declared.ok) return declared;
120
- const problems = [...singlePublicProblems(declared.views)];
121
- const seen = /* @__PURE__ */ new Map();
122
- for (const view of declared.views) {
123
- problems.push(...viewIdProblems(view));
124
- const first = seen.get(view.id);
125
- if (first === void 0) {
126
- seen.set(view.id, view.where);
127
- continue;
128
- }
129
- problems.push(`${view.where}.id is '${view.id}', which ${first} already uses. The id is the document a view is published at, so two of them are one page — whichever was written second would silently replace the first, in staging and again at publish.`);
130
- }
131
- return problems.length > 0 ? {
132
- ok: false,
133
- problems
134
- } : {
135
- ok: true,
136
- views: declared.views
137
- };
138
- }
139
- /** How a participant reaches `cid`, or null if they cannot.
140
- *
141
- * Mirrors the rules' read branches for someone holding no role:
142
- * `partRead` (the whole collection) and `ownRow` (their own record, found
143
- * by the submit declaration's `emailField` or by a uid-derived id).
144
- *
145
- * `participantRead` is a PARAMETER rather than read off the manifest, and
146
- * that is the whole point of the signature. Publish does not promote the
147
- * manifest's value: `projectPublish` overwrites `participantRead` with what
148
- * the STAGED schemas carry, so a cid added since the last deploy is in the
149
- * manifest and not in the rules. Deriving the scope from the manifest would
150
- * publish `scope: "all"` for a collection the promoted rules then deny —
151
- * and removing one gives the mirror-image false refusal. The caller passes
152
- * the set that will actually be in force. */
153
- function participantScope(app, cid, participantRead) {
154
- if (participantRead.includes(cid)) return {
155
- cid,
156
- scope: "all"
157
- };
158
- const submit = app.public?.submit?.[cid];
159
- if (submit?.emailField !== void 0) return {
160
- cid,
161
- scope: "own",
162
- emailField: submit.emailField
163
- };
164
- if (submit?.idFrom === "auth.uid") return {
165
- cid,
166
- scope: "own",
167
- ownDocId: "auth.uid"
168
- };
169
- return null;
170
- }
171
- /** The document ids one tier uses. `live:` and `staged:` are the only two
172
- * prefixes, so a single `match` covers the projection and every view. */
173
- var viewDocId = (stage, viewId) => `${stage}:${viewId}`;
174
- var VIEW_CONFIG_ID = "config";
175
- /** The role a member holds on one collection, by the rules' own resolution:
176
- * the per-collection entry, else the `*` fallback, else none. */
177
- function roleOn(app, address, cid) {
178
- const held = app.members[address];
179
- if (held === void 0) return void 0;
180
- return held[cid] ?? held["*"];
181
- }
182
- /** The addresses holding one of `roles` on `cid`.
183
- *
184
- * Sorted, for the same reason `memberEmails` is: a second publish of an
185
- * unchanged declaration must produce an unchanged document. */
186
- function holdersOf(app, cid, roles) {
187
- return Object.keys(app.members).filter((address) => roles.includes(roleOn(app, address, cid) ?? "")).sort();
188
- }
189
- /** Who may write every row of `cid`, and who may write only their own.
190
- *
191
- * WHY ADDRESSES ARE PUBLISHED AT ALL. One `member/config` document is read by
192
- * everyone the tier admits, and the tier only establishes that somebody holds
193
- * SOME role SOMEWHERE — so a `viewer`, or a stylist scoped to another
194
- * collection, reads the same entry as the front desk. Without these lists the
195
- * page would draw approve and reassign for all of them and the rules would
196
- * refuse when pressed, which is the declaration/enforcement mismatch this
197
- * whole mechanism exists to prevent.
198
- *
199
- * It cannot be answered per principal instead: the document is written once
200
- * at publish and read by many, and the reader cannot look their own role up —
201
- * `apps/{aid}` is `readerOf(a, '*')`, and a stylist carrying only
202
- * `{bookings: "editor"}` holds no `*` role. So the ROSTER'S ANSWER travels
203
- * with the declaration and the page compares its own address to it.
204
- *
205
- * The cost is that staff addresses are visible to staff. That is already true
206
- * of the approval mail they send each other, and participants read the
207
- * `roster` tier, which never carries these.
208
- *
209
- * A SNAPSHOT, like everything else published: a member added since the last
210
- * publish is absent until the next one. The rules are the authority either
211
- * way — this only decides which buttons are drawn. */
212
- function writersOf(app, cid) {
213
- return holdersOf(app, cid, ["owner", "editor"]);
214
- }
215
- /** The transition half: which table applies, and the field it moves.
216
- *
217
- * Both halves or neither. A status field with no table would offer every
218
- * value; a table with no field has nothing to write it to. */
219
- function transitionPart(app, audience, cid) {
220
- const config = app.collections?.[cid];
221
- const transitions = audience === "member" ? config?.transitions : app.public?.submit?.[cid]?.selfTransitions;
222
- if (config?.statusField === void 0 || transitions === void 0) return {};
223
- const part = {
224
- statusField: config.statusField,
225
- transitions
226
- };
227
- if (audience === "member" && config.mail !== void 0) part.mail = config.mail;
228
- return part;
229
- }
230
- /** The assignment half. `member` only — see {@link writersOf}.
231
- *
232
- * `rowWriters` rides here rather than beside `writers`, because the
233
- * `assignee` role grants nothing at all without a field to compare against
234
- * (`isAssigned` in the rules requires one, and publish refuses the pair). */
235
- function assignPart(app, audience, cid) {
236
- const assigneeField = app.collections?.[cid]?.assigneeField;
237
- if (audience !== "member" || assigneeField === void 0) return {};
238
- return {
239
- assigneeField,
240
- rowWriters: holdersOf(app, cid, ["assignee"])
241
- };
242
- }
243
- /** What `audience` may change about `cid`, or null when the answer is nothing.
244
- *
245
- * The two audiences differ in WHICH transition table applies, in whether
246
- * assignment exists at all, and in whether the roster's answer travels with
247
- * it; they agree that the status field is the collection's, since the rules
248
- * read one field either way. */
249
- function writeFor(app, audience, cid) {
250
- const write = {
251
- cid,
252
- ...transitionPart(app, audience, cid),
253
- ...assignPart(app, audience, cid)
254
- };
255
- if (Object.keys(write).length === 1) return null;
256
- if (audience === "member") write.writers = writersOf(app, cid);
257
- return write;
258
- }
259
- //#endregion
260
- //#region src/collection/server/publishManifest.ts
261
- /** A collection id / app id, held to the one name rule (`SAFE_SLUG_PATTERN`)
262
- * that `sharedCollectionKey` applies. Stated once so a path built later
263
- * cannot be a way around it. */
264
- var NameZ = zod.z.string().refine(require_itemId.isValidCollectionName, { message: "is not a valid id (letters, digits, '-' and '_' only)" });
265
- /** An address on the roster. Not validated as an email beyond "has an @":
266
- * the rules compare it to `request.auth.token.email` verbatim, so any
267
- * narrowing here would refuse addresses Firebase itself accepts. */
268
- var EmailZ = zod.z.string().trim().min(3).includes("@");
269
- /** The roles the deployed rules understand.
270
- *
271
- * Two of them are row-scoped, in opposite directions, and the pair is what
272
- * the four-way split could not express:
273
- *
274
- * `participant` — the layer that is NAMED but reads only its OWN rows (the
275
- * rows it submitted). See `readerOf` vs `listedIn`.
276
- *
277
- * `assignee` — reads EVERY row and writes only the rows ASSIGNED to it. The
278
- * stylist who approves their own bookings and not a colleague's; the marker
279
- * who grades their own students. Which rows are theirs is
280
- * `collections[cid].assigneeField`, a field on the record holding the
281
- * member's address. Reads are deliberately unscoped: a stylist needs the
282
- * whole day's schedule, and scoping the read makes the app unusable.
283
- *
284
- * The names are permanent. The deployed rules compare these strings directly
285
- * and they are written into `app.json` files people commit, so a rename is a
286
- * migration over published apps rather than an edit. */
287
- var APP_ROLES = [
288
- "owner",
289
- "editor",
290
- "viewer",
291
- "participant",
292
- "assignee"
293
- ];
294
- var RoleZ = zod.z.enum(APP_ROLES);
295
- /** `{ email: { "*" | cid: role } }`. The `"*"` key is the app-wide role; a
296
- * member may hold per-collection roles only (the stylist who is editor of
297
- * bookings and viewer of everything else). */
298
- var MembersZ = zod.z.record(EmailZ, zod.z.record(zod.z.union([zod.z.literal("*"), NameZ]), RoleZ));
299
- /** The declarative mail queue, as the rules re-derive it: a transition of the
300
- * status field, a recipient read off the RECORD, and a fixed template. */
301
- var MailZ = zod.z.object({
302
- toField: zod.z.string().trim().min(1),
303
- on: zod.z.record(zod.z.string().trim().min(1), zod.z.object({
304
- from: zod.z.array(zod.z.string().trim().min(1)).min(1),
305
- to: zod.z.string().trim().min(1)
306
- }).strict()),
307
- dataFields: zod.z.array(zod.z.string().trim().min(1)).optional()
308
- }).strict();
309
- /** What the rules read out of `collections[cid]`. NOT the schema — the schema
310
- * is published beside it, untouched, for clients to render from. */
311
- var CollectionConfigZ = zod.z.object({
312
- statusField: zod.z.string().trim().min(1).optional(),
313
- /** `{ initial: [...], <status>: [<status>...] }`. Binds writers too, and
314
- * binds `create` — that is the point of publishing it. */
315
- transitions: zod.z.record(zod.z.string().trim().min(1), zod.z.array(zod.z.string().trim().min(1))).optional(),
316
- immutable: zod.z.boolean().optional(),
317
- submitOnly: zod.z.boolean().optional(),
318
- /** The field naming the member a row belongs to, for the `assignee` role.
319
- *
320
- * Holds an ADDRESS, because that is the only thing the rules can compare
321
- * a member against (`request.auth.token.email`). A `ref` to a staff
322
- * collection stores the target's primary-key slug, not an address, so it
323
- * cannot be this field — declare a plain field beside the ref and let the
324
- * ref stay the thing the UI renders. The alternative, having the rules
325
- * `get()` the staff record to read an address off it, costs a document
326
- * access on every write and puts a second document between an
327
- * authorization decision and its answer.
328
- *
329
- * Only meaningful with a member holding `assignee` on this cid; a
330
- * declaration with the role and no field is refused (`assigneeProblems`),
331
- * because that member would silently hold nothing. */
332
- assigneeField: zod.z.string().trim().min(1).optional(),
333
- /** This collection is the public projection of `mirrorOf` — the other
334
- * half of `public.submit[...].mirror`, declared here because the rules
335
- * read it when the PROJECTION is written rather than when the record is.
336
- *
337
- * What it buys: `state` may be written by anybody, and only to the value
338
- * the authority actually says, so a visitor who was refused a slot can
339
- * repair the stale row that offered it to them. */
340
- mirrorOf: NameZ.optional(),
341
- peerVisibility: zod.z.enum(["public", "hidden"]).optional(),
342
- revealGated: zod.z.boolean().optional(),
343
- gatedFrom: NameZ.optional(),
344
- revealBy: zod.z.string().trim().min(1).optional(),
345
- mail: MailZ.optional(),
346
- /** Which fields an aggregate groups by. Declared here rather than in the
347
- * schema for the same reason as everything else in this file — the schema
348
- * has no `aggregate` key yet — and it is here at all because the
349
- * invariant that guards it ("every aggregation key is a CHECKED field")
350
- * is about `public.submit`, which is an app-level declaration. Published
351
- * as-is; the rules never read it. */
352
- aggregate: zod.z.object({ by: zod.z.array(zod.z.string().trim().min(1)).min(1) }).strict().optional()
353
- }).strict();
354
- /** An authored submit window. ISO strings, because `app.json` is JSON and a
355
- * Firestore `Timestamp` has no JSON form. Publish lowers it to epoch millis —
356
- * the rules do not coerce strings, so an ISO string reaching Firestore is a
357
- * type error that fails CLOSED (`inWindow` refuses every submission and the
358
- * author sees "nobody can submit", not an error). */
359
- /** A window bound that lives on ANOTHER record, read at write time.
360
- *
361
- * `window.from` is one absolute instant for the whole collection, which is
362
- * enough for a survey and useless for anything recurring: "each class opens
363
- * three days before it starts, at 08:00" is a bound PER RECORD. So the bound
364
- * is not computed in the rules — they have no usable date arithmetic and
365
- * `request.time` is UTC, which is the wrong answer for "08:00" — it is
366
- * computed by whoever schedules the class, stored on the class record as
367
- * epoch millis, and merely COMPARED here.
368
- *
369
- * `ref` is the field on the record being written that names the target
370
- * (`classId`); `collection` is the cid the target lives in, fixed in the
371
- * declaration so that a path is never built out of a value a submitter wrote;
372
- * `field` is the epoch-millis field on the target.
373
- *
374
- * Not spelled `in` — that is an operator in the rules language, and
375
- * `w.fromField.in` does not parse there. */
376
- var WindowRefZ = zod.z.object({
377
- ref: zod.z.string().trim().min(1),
378
- collection: NameZ,
379
- field: zod.z.string().trim().min(1)
380
- }).strict();
381
- /** The closing bound's per-record twin, and it ships WITH `fromField` rather
382
- * than as a symmetric extra: a booking desk that opens per slot and never
383
- * closes is not a booking desk. Same shape, opposite comparison — and
384
- * EXCLUSIVE where `fromField` is inclusive, so one slot's closing instant and
385
- * the next one's opening instant may be the same number. */
386
- var WindowZ = zod.z.object({
387
- from: zod.z.iso.datetime().optional(),
388
- until: zod.z.iso.datetime().optional(),
389
- fromField: WindowRefZ.optional(),
390
- untilField: WindowRefZ.optional()
391
- }).strict();
392
- /** Which record a `field` document id must name, and what state it must be in.
393
- *
394
- * `idFrom: "field"` alone only stops the same string being written twice —
395
- * nothing stops a client bypassing the page and inventing a slot, so the
396
- * rules check the referenced record themselves. `exists()` is a FLOOR: a
397
- * cancelled slot and a slot nobody may book any more exist too, which is what
398
- * `where` is for.
399
- *
400
- * Always the object form, never a bare collection name. Two shapes for one
401
- * key is the kind of thing a generator gets right once and wrong afterwards,
402
- * and the rules read `s.idIn.collection` either way. */
403
- var IdInZ = zod.z.object({
404
- collection: NameZ,
405
- where: zod.z.object({
406
- field: zod.z.string().trim().min(1),
407
- equals: zod.z.union([
408
- zod.z.string(),
409
- zod.z.number(),
410
- zod.z.boolean()
411
- ])
412
- }).strict().optional()
413
- }).strict();
414
- var ValidateZ = zod.z.object({
415
- required: zod.z.array(zod.z.string().trim().min(1)).optional(),
416
- /** Capped at two by the rules themselves: rules have no iteration, so
417
- * `keyFieldsOk` is unrolled. A third would be accepted here and silently
418
- * unchecked there. */
419
- keyFields: zod.z.array(zod.z.object({
420
- field: zod.z.string().trim().min(1),
421
- values: zod.z.array(zod.z.union([
422
- zod.z.string(),
423
- zod.z.number(),
424
- zod.z.boolean()
425
- ])).min(1)
426
- }).strict()).optional()
427
- }).strict();
428
- var SubmitZ = zod.z.object({
429
- auth: zod.z.enum([
430
- "none",
431
- "anonymous",
432
- "verifiedEmail"
433
- ]),
434
- emailField: zod.z.string().trim().min(1).optional(),
435
- createFields: zod.z.array(zod.z.string().trim().min(1)).min(1),
436
- initialStatus: zod.z.string().trim().min(1).optional(),
437
- /** `field` is the mode that makes a CONTESTED resource exclusive: the
438
- * booking's document id IS the slot's id, so the second person to want
439
- * that slot is writing a document that already exists — an update, which
440
- * the public submission path never allows. Firestore decides that
441
- * atomically, so unlike a countable capacity (see `stampField`) this is
442
- * first-come ENFORCED rather than first-come read off a rank. */
443
- idFrom: zod.z.enum([
444
- "auto",
445
- "auth.uid",
446
- "auth.uid+field",
447
- "field"
448
- ]).optional(),
449
- idField: zod.z.string().trim().min(1).optional(),
450
- /** Required by `idFrom: "field"` — see {@link IdInZ}. */
451
- idIn: IdInZ.optional(),
452
- /** The collection holding this record's PUBLIC PROJECTION, one row per
453
- * contested thing, sharing its document id.
454
- *
455
- * A booking carries a name, an address and a phone number, and Firestore
456
- * rules cannot hide a field, so the public page must not read bookings at
457
- * all. It reads the projection instead, whose `state` is a copy of "does
458
- * a booking with this id exist" — and the rules accept the two writes
459
- * only as one batch, in both directions, so the copy cannot drift into
460
- * advertising a slot that is gone. */
461
- mirror: NameZ.optional(),
462
- validate: ValidateZ.optional(),
463
- window: WindowZ.optional(),
464
- /** A field the rules PIN to the server clock on create: the record must
465
- * carry `request.time` in it, and may never change it afterwards.
466
- *
467
- * What it buys is an order nobody can jump. A first-come app takes its
468
- * capacity from rank rather than from a count — the rules cannot count
469
- * documents, so "the first 8" can only ever be a reading of the rows —
470
- * and a rank is only as honest as the timestamp it sorts by. `idFrom`
471
- * stops a person holding two places; nothing else stops them writing
472
- * yesterday's date into the field that decides who got there first.
473
- *
474
- * Binds EVERY create, the writer branch included, so a staff-entered row
475
- * cannot be back-dated into the queue either. */
476
- stampField: zod.z.string().trim().min(1).optional(),
477
- /** Per CURRENT STATUS, never a flat list: a flat list lets a customer move
478
- * an approved booking's `startAt` without anyone re-approving it. */
479
- selfUpdate: zod.z.record(zod.z.string().trim().min(1), zod.z.array(zod.z.string().trim().min(1))).optional(),
480
- selfTransitions: zod.z.record(zod.z.string().trim().min(1), zod.z.array(zod.z.string().trim().min(1))).optional(),
481
- finalize: zod.z.boolean().optional(),
482
- audience: zod.z.literal("participant").optional(),
483
- gateOn: zod.z.object({
484
- phase: zod.z.string().trim().min(1),
485
- match: zod.z.string().trim().min(1)
486
- }).strict().optional()
487
- }).strict();
488
- var PublicZ = zod.z.object({
489
- /** The master switch. Anonymous submission (`auth: "none"`) needs it as
490
- * well as its own declaration. */
491
- enabled: zod.z.boolean().optional(),
492
- read: zod.z.array(NameZ).optional(),
493
- /** The page the public sees, instead of the generated form.
494
- *
495
- * A form is enough to ANSWER something and not enough to CHOOSE from
496
- * what is available — a stylist-by-hour grid is not the far end of a
497
- * table. So the app may name one HTML file, which the host publishes to
498
- * `config/view` and the public page renders in a sandboxed iframe.
499
- *
500
- * `submit` stays declared alongside: the view sends an INTENT, and the
501
- * page it is embedded in performs the write against these rules.
502
- *
503
- * `collections` is declared rather than inferred from `read`. Inferring
504
- * it produces the worst failure this feature has — the view renders, the
505
- * data it wanted was never sent, and it draws an empty grid with no error
506
- * anywhere. */
507
- view: zod.z.object({
508
- path: zod.z.string().trim().min(1),
509
- collections: zod.z.array(NameZ).min(1)
510
- }).strict().optional(),
511
- submit: zod.z.record(NameZ, SubmitZ).optional()
512
- }).strict();
513
- /** One page the app shows, and who it is for.
514
- *
515
- * Generalised from `public.view` (which is still accepted, and normalizes
516
- * into this — see `appViews.ts`). The audience is what decides which document
517
- * the HTML is published to, and therefore who may read it: a rule cannot hide
518
- * a field, so "the front desk sees this" is a place, not a filter.
519
- *
520
- * `id` is not decoration. It becomes the document id the page is published
521
- * at, which is what lets one audience have more than one page — the front
522
- * desk and the stock room — and what lets a withdrawn view be found and
523
- * deleted. Its grammar is enforced at the gate, not here, so the refusal can
524
- * say what the value is used for.
525
- *
526
- * `collections` is declared rather than inferred, for the reason `public.view`
527
- * gives: an inferred list renders a perfect page with no data in it, and
528
- * nothing anywhere says why. */
529
- var ViewZ = zod.z.object({
530
- id: zod.z.string().trim().min(1),
531
- audience: zod.z.enum(VIEW_AUDIENCES),
532
- path: zod.z.string().trim().min(1),
533
- collections: zod.z.array(NameZ).min(1)
534
- }).strict();
535
- /** The URL name an app is handed out under: `https://<host>/{slug}`.
536
- *
537
- * A SEPARATE name from the `aid`, and that separation is the point (design
538
- * D2b). `apps/{aid}` is a shelf every user of the deployment shares and the
539
- * rules' `allow create` asks only that you name yourself owner — so a
540
- * memorable aid is first-come-first-served, cannot be checked for
541
- * availability, and frees up again when an app is deleted. The aid is
542
- * therefore a UUID, and the thing people can fight over is moved to the name
543
- * that costs nothing to change.
544
- *
545
- * Declared here rather than kept beside `app.json` because a RESERVATION has
546
- * to travel with the repository: `appSlugs/{slug}` is unreadable until the app
547
- * is published (`allow read: if resource.data.published == true`), so nothing
548
- * can recover which slug an app holds by asking Firestore. A second file to
549
- * keep in step with the declaration is the alternative, and it is the kind of
550
- * pair that goes out of step silently.
551
- *
552
- * The shape is stricter than `NameZ` on purpose: it is BOTH a URL path
553
- * segment people read aloud and a Firestore document id. Lowercase
554
- * alphanumerics separated by single hyphens covers both without a case rule
555
- * that would make two slugs collide in one place and not the other.
556
- *
557
- * Which slug an app ended up with is the HOST's business — a wanted slug can
558
- * be taken, and the host writes the one it reserved back here. Nothing in this
559
- * package reads the key; it is declared so that writing it back does not make
560
- * the file unparseable. */
561
- var SLUG_SHAPE = "must be lowercase letters, digits and single hyphens, and must not start or end with one (e.g. sakura-hair)";
562
- var SlugZ = zod.z.string().trim().max(64).regex(/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/, SLUG_SHAPE).refine((slug) => !slug.includes("--"), SLUG_SHAPE);
563
- /** The whole authored declaration.
564
- *
565
- * `owner` is accepted but is NOT the published value — publish stamps the
566
- * publisher's uid (or carries the existing one forward, which is what the
567
- * rules require on update) and refuses a declaration that disagrees. It is
568
- * accepted rather than banned because the sample app.json in the design note
569
- * shows it, and a hard refusal on a key the samples contain would be a worse
570
- * first experience than a message naming the mismatch. */
571
- var AuthoredAppZ = zod.z.object({
572
- aid: NameZ,
573
- name: zod.z.string().trim().min(1).optional(),
574
- /** The wanted (or reserved) URL name — see {@link SlugZ}. */
575
- slug: SlugZ.optional(),
576
- /** Per-worktree app id (design D6, implementation order 7). Accepted so a
577
- * repository already carrying it parses; nothing reads it yet. */
578
- aidEnv: zod.z.string().trim().min(1).optional(),
579
- owner: zod.z.string().trim().min(1).optional(),
580
- members: MembersZ,
581
- collections: zod.z.record(NameZ, CollectionConfigZ).optional(),
582
- participantRead: zod.z.array(NameZ).optional(),
583
- public: PublicZ.optional(),
584
- /** The app's pages, per audience. See {@link ViewZ}; `public.view` is the
585
- * older spelling of the `public` one and normalizes into this list. */
586
- views: zod.z.array(ViewZ).optional()
587
- }).strict();
588
- /** Parse the authored declaration out of `app.json`'s text.
589
- *
590
- * Returns a LIST of problems rather than throwing, for the same reason
591
- * `loadAppManifest` returns a failure: the caller is a gate whose entire job
592
- * is to hand the author something to act on. Every problem is reported at
593
- * once — publish is a manual step, and a parser that stops at the first key
594
- * makes it N round trips. */
595
- function parseAuthoredApp(raw) {
596
- const manifest = require_discovery.parseAppManifest(raw);
597
- if (!manifest.ok) return {
598
- ok: false,
599
- problems: [manifest.kind === "missing" ? "app.json is missing" : manifest.detail]
600
- };
601
- const parsed = AuthoredAppZ.safeParse(JSON.parse(raw));
602
- if (!parsed.success) return {
603
- ok: false,
604
- problems: authoredProblems(parsed.error)
605
- };
606
- return {
607
- ok: true,
608
- app: parsed.data
609
- };
610
- }
611
- /** zod issues as one actionable line each: `public.submit.responses.auth: …`. */
612
- function authoredProblems(error) {
613
- return error.issues.map((issue) => {
614
- return `${issue.path.length > 0 ? issue.path.join(".") : "app.json"}: ${issue.message}`;
615
- });
616
- }
617
- //#endregion
618
- //#region src/collection/server/publishProject.ts
619
- /** The document id under `apps/{aid}/config`. One document, named, rather than
620
- * a spread of them: a second public document is a second thing to keep in
621
- * step, and nothing yet needs one. */
622
- var PUBLIC_CONFIG_DOC = "public";
623
- /** Drop keys whose value is `undefined`. Firestore rejects an undefined field
624
- * value outright, and `"k" in c` — which every optional key in the rules is
625
- * read through — must mean "the author declared it". */
626
- function compact(entries) {
627
- return Object.fromEntries(Object.entries(entries).filter(([, value]) => value !== void 0));
628
- }
629
- /** ISO → epoch millis, the one conversion the rules cannot do for themselves.
630
- * The caller has already refused an unparseable string (the authored parser
631
- * requires `z.iso.datetime()`), so a NaN here would be a programming error;
632
- * it is still checked, because a NaN written to Firestore fails closed in the
633
- * same silent way an ISO string does. */
634
- function windowMillis(window) {
635
- if (!window) return void 0;
636
- const out = {};
637
- if (window.from !== void 0) out.fromMs = Date.parse(window.from);
638
- if (window.until !== void 0) out.untilMs = Date.parse(window.until);
639
- if (Object.values(out).some((value) => !Number.isFinite(value))) throw new Error(`publish: window bound is not a parseable timestamp (${JSON.stringify(window)})`);
640
- const projected = {
641
- ...out,
642
- ...window.fromField === void 0 ? {} : { fromField: window.fromField },
643
- ...window.untilField === void 0 ? {} : { untilField: window.untilField }
644
- };
645
- return Object.keys(projected).length > 0 ? projected : void 0;
646
- }
647
- /** One `public.submit[cid]`, with its window lowered. Everything else passes
648
- * through: the rules read these keys by the names the author wrote. */
649
- function projectSubmit(submit) {
650
- const { window, ...rest } = submit;
651
- return compact({
652
- ...rest,
653
- window: windowMillis(window)
654
- });
655
- }
656
- /** The roster's addresses as a set, in a stable order.
657
- *
658
- * Sorted so two publishes of the same declaration produce the same document
659
- * — idempotence is a property this step is tested for, and Firestore compares
660
- * arrays by ORDER. `membersConsistent()` compares as sets and would accept
661
- * any order; the test that would notice is the one asserting a second publish
662
- * changes nothing but `publishedAt`. */
663
- function memberEmailsOf(members) {
664
- return Object.keys(members).sort();
665
- }
666
- /** The previous document, kept for rollback, with its OWN `previousPublished`
667
- * stripped.
668
- *
669
- * One level, deliberately. Chaining would make every publish carry the entire
670
- * history of the app inside a single document, which grows without bound and
671
- * meets Firestore's 1 MiB document limit as a permission-shaped failure at
672
- * some unpredictable publish. One level answers the question rollback
673
- * actually asks — "put back what was there before I broke it" — and the
674
- * further history is in git, which is where the declaration came from. */
675
- function previousOf(existing) {
676
- if (!existing) return void 0;
677
- const { previousPublished: __dropped, ...rest } = existing;
678
- return rest;
679
- }
680
- /** Project the authored declaration into the documents publish writes.
681
- *
682
- * `existing` is the app document as it is in Firestore right now, or null on
683
- * a first publish. Two things need it, both required by the rules:
684
- * - `owner` must be UNCHANGED on update. Re-stamping the publisher's uid
685
- * would be refused for any app whose owner ever signed in as a different
686
- * account, and would silently transfer ownership if it were not.
687
- * - `previousPublished` is that document, so a rollback has something to
688
- * put back.
689
- *
690
- * Pure: no clock, no filesystem, no Firestore. Everything variable arrives as
691
- * a parameter, which is what makes the conversion table testable as a table. */
692
- function projectApp(authored, schemas, stamp, existing) {
693
- const owner = typeof existing?.owner === "string" ? existing.owner : stamp.uid;
694
- const submit = Object.fromEntries(Object.entries(authored.public?.submit ?? {}).map(([cid, spec]) => [cid, projectSubmit(spec)]));
695
- const publicBlock = authored.public ? compact({
696
- enabled: authored.public.enabled,
697
- read: authored.public.read,
698
- submit: Object.keys(submit).length > 0 ? submit : void 0
699
- }) : void 0;
700
- const app = compact({
701
- aid: authored.aid,
702
- name: authored.name,
703
- owner,
704
- members: authored.members,
705
- memberEmails: memberEmailsOf(authored.members),
706
- collections: authored.collections,
707
- participantRead: authored.participantRead,
708
- public: publicBlock,
709
- publishedAt: stamp.publishedAt,
710
- publishedBy: stamp.email,
711
- publishedCommit: stamp.commit,
712
- publishedDirty: stamp.dirty === true ? true : void 0,
713
- previousPublished: previousOf(existing)
714
- });
715
- const normalized = normalizeViews(authored);
716
- if (!normalized.ok) throw new Error(`publish: views declaration is not publishable (${normalized.problems.join(" ")})`);
717
- const publicView = normalized.views.find((view) => view.audience === "public");
718
- const config = {
719
- enabled: authored.public?.enabled === true,
720
- read: authored.public?.read ?? [],
721
- submit,
722
- ...publicView === void 0 ? {} : { view: { collections: publicView.collections } },
723
- publishedAt: stamp.publishedAt
724
- };
725
- if (authored.name !== void 0) config.name = authored.name;
726
- return {
727
- app,
728
- schemas: schemas.map(({ cid, schema }) => ({
729
- cid,
730
- doc: schemaDoc(schema, stamp)
731
- })),
732
- config
733
- };
734
- }
735
- /** Keys on the app document that publish owns: what is PUBLIC right now, and
736
- * the rule-facing configuration anonymous access is judged against. Deploy
737
- * carries them through from the existing document and never authors them. */
738
- var PUBLISH_OWNED_KEYS = [
739
- "public",
740
- "collections",
741
- "participantRead",
742
- "publishedAt",
743
- "publishedBy",
744
- "publishedCommit",
745
- "publishedDirty",
746
- "previousPublished"
747
- ];
748
- var isPublishOwned = (key) => PUBLISH_OWNED_KEYS.includes(key);
749
- function projectDeploy(authored, schemas, stamp, existing) {
750
- const { app } = projectApp(authored, schemas, stamp, existing);
751
- const deployed = Object.fromEntries(Object.entries(app).filter(([key]) => !isPublishOwned(key)));
752
- for (const key of PUBLISH_OWNED_KEYS) {
753
- const live = existing?.[key];
754
- if (live !== void 0) deployed[key] = live;
755
- }
756
- deployed.deployedAt = stamp.publishedAt;
757
- deployed.deployedBy = stamp.email;
758
- if (stamp.commit !== void 0) deployed.deployedCommit = stamp.commit;
759
- return {
760
- app: deployed,
761
- staging: schemas.map(({ cid, schema }) => ({
762
- cid,
763
- doc: stagedDoc(schema, stamp, authored, cid)
764
- }))
765
- };
766
- }
767
- /** One staged schema document, carrying this cid's rule-facing configuration
768
- * alongside the schema so publish can promote them together. */
769
- function stagedDoc(schema, stamp, authored, cid) {
770
- const doc = {
771
- publishedSchema: schema,
772
- deployedAt: stamp.publishedAt,
773
- deployedBy: stamp.email
774
- };
775
- const config = authored.collections?.[cid];
776
- if (config !== void 0) doc.config = config;
777
- if (authored.participantRead?.includes(cid) === true) doc.participantRead = true;
778
- if (stamp.commit !== void 0) doc.deployedCommit = stamp.commit;
779
- return doc;
780
- }
781
- /** The rule-facing configuration to promote, read from the STAGED documents
782
- * rather than from the manifest as it reads right now.
783
- *
784
- * Otherwise: deploy revision A, edit `app.json` to revision B, publish — and
785
- * the promoted schema is A's while the authorization behaviour is B's, a
786
- * combination nobody exercised through `/staging/{aid}`.
787
- *
788
- * (`public` is deliberately NOT part of this: it is not staged, because it is
789
- * the decision being made AT publish rather than something under test.) */
790
- function stagedRuleConfig(staged) {
791
- const entries = [];
792
- const participantRead = [];
793
- for (const entry of staged) {
794
- const { config } = entry.doc;
795
- if (config !== void 0) entries.push([entry.cid, config]);
796
- if (entry.doc.participantRead === true) participantRead.push(entry.cid);
797
- }
798
- return {
799
- collections: entries.length > 0 ? Object.fromEntries(entries) : void 0,
800
- participantRead: participantRead.length > 0 ? participantRead : void 0
801
- };
802
- }
803
- function projectPublish(authored, staged, stamp, existing) {
804
- const { app, config } = projectApp(authored, [], stamp, existing);
805
- const staging = stagedRuleConfig(staged);
806
- app.collections = staging.collections;
807
- app.participantRead = staging.participantRead;
808
- const published = Object.fromEntries(Object.entries(existing ?? app).filter(([key]) => !isPublishOwned(key)));
809
- for (const key of PUBLISH_OWNED_KEYS) if (key !== "public" && app[key] !== void 0) published[key] = app[key];
810
- const publicBlock = app.public;
811
- return {
812
- app: published,
813
- config,
814
- public: require_dist.isRecord(publicBlock) ? publicBlock : void 0
815
- };
816
- }
817
- /** Re-stamp a staged schema document as it is promoted to `collections/{cid}`.
818
- *
819
- * The stamp answers "which version is PUBLIC right now, and who made it so",
820
- * so it is written by the operation that changes the answer — publish — not
821
- * carried over from the deploy that staged it. */
822
- function promoteSchema(staged, stamp) {
823
- const doc = {
824
- publishedSchema: staged.publishedSchema,
825
- publishedAt: stamp.publishedAt,
826
- publishedBy: stamp.email
827
- };
828
- if (stamp.commit !== void 0) doc.publishedCommit = stamp.commit;
829
- return doc;
830
- }
831
- /** One published schema document. Written key by key rather than through
832
- * `compact`, so the declared type is the type — an optional commit is the
833
- * only variable part. */
834
- function schemaDoc(schema, stamp) {
835
- const doc = {
836
- publishedSchema: schema,
837
- publishedAt: stamp.publishedAt,
838
- publishedBy: stamp.email
839
- };
840
- if (stamp.commit !== void 0) doc.publishedCommit = stamp.commit;
841
- return doc;
842
- }
843
- /** The app documents' parent path — the `FirestoreDocs` seam takes a
844
- * collection path plus a document id, and the app document's id is the aid. */
845
- var APPS_COLLECTION = "apps";
846
- /** The collection (schema) documents' parent path — what the PUBLIC page
847
- * reads, written only by publish (promotion). */
848
- var appSchemasPath = (aid) => `apps/${aid}/collections`;
849
- /** The URL-slug reservations — `appSlugs/{slug}` → `{ aid, published }`.
850
- *
851
- * A TOP-LEVEL collection, not a field on the app: the public page resolves a
852
- * slug to an aid BEFORE it can read anything under `apps/{aid}`, and a slug
853
- * has to be claimable atomically (create-if-absent) so two apps cannot hold
854
- * the same URL.
855
- *
856
- * `published` is what makes the reservation invisible until publish. The slug
857
- * is human-readable, so a readable reservation would let anyone guess the URL
858
- * and get the aid — and the aid is the `/staging/{aid}` entrance. The rule is
859
- * `allow read: if resource.data.published == true`, which needs no `get()` and
860
- * so costs nothing against the rules' expression budget. */
861
- var APP_SLUGS_COLLECTION = "appSlugs";
862
- var appSlugDoc = (aid, published) => ({
863
- aid,
864
- published
865
- });
866
- /** The staged schema documents' parent path — what `/staging/{aid}` reads,
867
- * written by deploy. A separate DOCUMENT rather than a field beside
868
- * `publishedSchema`, because the rules cannot hide a field: anything inside a
869
- * document the public page may read is public. */
870
- var appStagingPath = (aid) => `apps/${aid}/staging`;
871
- /** The public-config documents' parent path. */
872
- var appConfigPath = (aid) => `apps/${aid}/config`;
873
- /** Where one audience's pages live. `member` is read by anyone holding a role;
874
- * `roster` by anyone on the roster, participants included. */
875
- var appViewTierPath = (aid, tier) => `apps/${aid}/${tier}`;
876
- /** What one audience may see of one collection.
877
- *
878
- * For `member` this is always the whole collection: every read branch a role
879
- * opens (`readerOf`) is unscoped. Whether THIS member holds the role is not
880
- * knowable here — one projection is read by every member of the tier — and is
881
- * settled where it can be, by the entrance trying the read.
882
- *
883
- * For `participant` it is the rules' own answer, which is why it can be null:
884
- * a participant with neither `participantRead` nor an own-row submit path
885
- * cannot read the collection at all, and a page handed it would fail rather
886
- * than render less. */
887
- function scopeFor(authored, audience, cid, participantRead) {
888
- return audience === "member" ? {
889
- cid,
890
- scope: "all"
891
- } : participantScope(authored, cid, participantRead);
892
- }
893
- /** What this audience may CHANGE, per collection it draws.
894
- *
895
- * The `collections` config is the PROMOTED one where there is one: at publish
896
- * the rules run against what deploy staged, so projecting the manifest's
897
- * would advertise transitions the live rules deny. */
898
- function tierWrites(authored, audience, cids, promoted) {
899
- const effective = promoted.collections === void 0 ? authored : {
900
- ...authored,
901
- collections: promoted.collections
902
- };
903
- return cids.map((cid) => writeFor(effective, audience, cid)).filter((entry) => entry !== null);
904
- }
905
- /** What this audience may READ, and how to query for it.
906
- *
907
- * A collection with no scope is dropped rather than published as unreachable:
908
- * the gate has already refused the declaration, so reaching here with one is
909
- * a programming error, and a page that queries it is denied. */
910
- function tierViews(authored, audience, views, participantRead) {
911
- return views.map((view) => ({
912
- id: view.id,
913
- collections: view.collections.map((cid) => scopeFor(authored, audience, cid, participantRead)).filter((scope) => scope !== null)
914
- }));
915
- }
916
- /** One tier's projection: what this audience may read, and what it may change. */
917
- function tierConfig(authored, audience, views, stamp, promoted) {
918
- const cids = [...new Set(views.flatMap((view) => view.collections))];
919
- const config = {
920
- write: tierWrites(authored, audience, cids, promoted),
921
- views: tierViews(authored, audience, views, promoted.participantRead ?? authored.participantRead ?? []),
922
- submit: tierSubmit(authored, cids),
923
- publishedAt: stamp.publishedAt
924
- };
925
- if (authored.name !== void 0) config.name = authored.name;
926
- return config;
927
- }
928
- /** The submit declarations for the collections these views draw, so a page can
929
- * show what may be sent rather than discovering it from a denial. */
930
- function tierSubmit(authored, cids) {
931
- const declared = authored.public?.submit ?? {};
932
- return Object.fromEntries(cids.flatMap((cid) => {
933
- const spec = declared[cid];
934
- return spec === void 0 ? [] : [[cid, projectSubmit(spec)]];
935
- }));
936
- }
937
- function projectAppViews(authored, stamp, promoted = {}) {
938
- const normalized = normalizeViews(authored);
939
- if (!normalized.ok) throw new Error(`publish: views declaration is not publishable (${normalized.problems.join(" ")})`);
940
- return ["member", "participant"].map((audience) => {
941
- const views = normalized.views.filter((view) => view.audience === audience);
942
- return {
943
- tier: VIEW_TIER[audience],
944
- audience,
945
- config: tierConfig(authored, audience, views, stamp, promoted),
946
- views
947
- };
948
- });
949
- }
950
- /** The document a tier's projection is published at. Beside the views
951
- * themselves, under one `match` — see `firestore.rules`. */
952
- var viewConfigDocId = (stage) => viewDocId(stage, VIEW_CONFIG_ID);
953
- //#endregion
954
- //#region src/collection/server/publishChecks.ts
955
- /** Does this submit declaration bind a record to the submitter's identity?
956
- *
957
- * The condition for requiring `submitOnly`, and deliberately NOT "declares an
958
- * `audience`": `audience` appears only in the rules' public-create branch, so
959
- * an owner or editor never meets it and can add records freely. `immutable`
960
- * is the wrong condition too — a survey's responses are not immutable and
961
- * can be padded exactly the same way.
962
- *
963
- * What these four have in common is that each one makes the record MEAN "the
964
- * person who submitted it said this": a per-uid id, a per-uid+field id, a
965
- * row stamped with the submitter's verified address, or a submission
966
- * restricted to a named participant. A record created through the writer
967
- * branch carries the same shape and none of that meaning. */
968
- function bindsSubmitterIdentity(submit) {
969
- return submit.idFrom === "auth.uid" || submit.idFrom === "auth.uid+field" || submit.emailField !== void 0 || submit.audience === "participant";
970
- }
971
- /** The fields a rule actually CHECKS the value of, for one collection.
972
- *
973
- * `keyFields` pins a value against a declared set, `gateOn.match` pins it
974
- * against the session's current question, and the status field is pinned by
975
- * the transition machine. An aggregation grouped by anything else is grouped
976
- * by a field any submitter may write anything into — so the published
977
- * aggregate is whatever the noisiest respondent decided it should be. */
978
- function checkedFields(collection, submit) {
979
- const fields = /* @__PURE__ */ new Set();
980
- for (const keyField of submit?.validate?.keyFields ?? []) fields.add(keyField.field);
981
- if (submit?.gateOn) fields.add(submit.gateOn.match);
982
- if (collection?.statusField) fields.add(collection.statusField);
983
- return fields;
984
- }
985
- /** INVARIANT 1 — a submission bound to its submitter needs `submitOnly`. */
986
- function submitOnlyProblems(app) {
987
- const problems = [];
988
- for (const [cid, submit] of Object.entries(app.public?.submit ?? {})) {
989
- if (!bindsSubmitterIdentity(submit)) continue;
990
- if (app.collections?.[cid]?.submitOnly === true) continue;
991
- problems.push(`collections.${cid}.submitOnly must be true: public.submit.${cid} binds each record to its submitter (${identityBindings(submit).join(", ")}), so a record created any other way would carry that meaning without having earned it. Without submitOnly the rules let an owner or editor write rows directly into ${cid}.`);
992
- }
993
- return problems;
994
- }
995
- function identityBindings(submit) {
996
- const bindings = [];
997
- if (submit.idFrom === "auth.uid" || submit.idFrom === "auth.uid+field") bindings.push(`idFrom: "${submit.idFrom}"`);
998
- if (submit.emailField !== void 0) bindings.push(`emailField: "${submit.emailField}"`);
999
- if (submit.audience === "participant") bindings.push(`audience: "participant"`);
1000
- return bindings;
1001
- }
1002
- /** INVARIANT 2 — every aggregation key is a field some rule checks. */
1003
- function aggregateProblems(app) {
1004
- const problems = [];
1005
- for (const [cid, collection] of Object.entries(app.collections ?? {})) {
1006
- const keys = collection.aggregate?.by;
1007
- if (!keys) continue;
1008
- const checked = checkedFields(collection, app.public?.submit?.[cid]);
1009
- const loose = keys.filter((field) => !checked.has(field));
1010
- const spelled = loose.map((field) => `'${field}'`).join(", ");
1011
- if (loose.length > 0) problems.push(`collections.${cid}.aggregate.by names ${spelled}, which no rule checks the value of. An aggregation key must appear in public.submit.${cid}.validate.keyFields, in gateOn.match, or be the statusField — otherwise a submitter chooses their own bucket and the published aggregate is not a count of anything.`);
1012
- }
1013
- return problems;
1014
- }
1015
- /** INVARIANT 3 — `auth: "verifiedEmail"` only.
1016
- *
1017
- * A product decision, not a rules limitation: the rules keep all three stages
1018
- * and the emulator tests keep exercising them, because deleting a stage from
1019
- * the rules turns a change of mind into a cross-repo deploy. Publish is where
1020
- * the current decision is expressed, and it is one line to move. */
1021
- function authProblems(app) {
1022
- return Object.entries(app.public?.submit ?? {}).filter(([, submit]) => submit.auth !== "verifiedEmail").map(([cid, submit]) => `public.submit.${cid}.auth is "${submit.auth}": only "verifiedEmail" may be published. The rules still implement "none" and "anonymous" — this is a product decision, and lifting it is a change here, not a rules deploy.`);
1023
- }
1024
- /** INVARIANT 5 — a mail transition's origins and destination must be disjoint.
1025
- *
1026
- * Overlap means the same write can satisfy the same template twice over, and
1027
- * the deterministic mail id is the only other thing stopping a duplicate
1028
- * send. The rules also require the status to have CHANGED, so an overlapping
1029
- * declaration is not merely redundant: `from` containing `to` is a transition
1030
- * that can never fire, which is a mail nobody ever receives. */
1031
- function mailProblems(app) {
1032
- return Object.entries(app.collections ?? {}).flatMap(([cid, collection]) => collectionMailProblems(cid, collection));
1033
- }
1034
- function collectionMailProblems(cid, collection) {
1035
- const { mail } = collection;
1036
- if (!mail) return [];
1037
- const problems = [];
1038
- if (!collection.statusField) problems.push(`collections.${cid}.mail needs collections.${cid}.statusField: the rules read the status before and after the write to decide the mail is warranted.`);
1039
- for (const [template, transition] of Object.entries(mail.on)) problems.push(...templateMailProblems(cid, collection, template, transition));
1040
- return problems;
1041
- }
1042
- function templateMailProblems(cid, collection, template, transition) {
1043
- const problems = [];
1044
- if (transition.from.includes(transition.to)) problems.push(`collections.${cid}.mail.on.${template} lists "${transition.to}" in both \`from\` and \`to\`. The rules require the status to CHANGE in the same write, so this template can never send.`);
1045
- const allowed = collection.transitions;
1046
- if (allowed) {
1047
- const unreachable = transition.from.filter((from) => !(allowed[from] ?? []).includes(transition.to));
1048
- const spelled = unreachable.map((from) => `'${from}' -> '${transition.to}'`).join(", ");
1049
- if (unreachable.length > 0) problems.push(`collections.${cid}.mail.on.${template} sends on ${spelled}, which collections.${cid}.transitions does not allow. The record write is refused first, so the mail never fires.`);
1050
- }
1051
- return problems;
1052
- }
1053
- /** INVARIANTS 6 and 7 — the window is a real interval, and `keyFields` fits
1054
- * the unrolled check in the rules. */
1055
- function submitShapeProblems(app) {
1056
- return Object.entries(app.public?.submit ?? {}).flatMap(([cid, submit]) => [...windowProblems(cid, submit), ...keyFieldCountProblems(cid, submit)]);
1057
- }
1058
- function windowProblems(cid, submit) {
1059
- const { window } = submit;
1060
- if (window?.from === void 0 || window.until === void 0) return [];
1061
- if (Date.parse(window.until) > Date.parse(window.from)) return [];
1062
- return [`public.submit.${cid}.window closes at or before it opens (${window.from} -> ${window.until}): nothing could ever be submitted.`];
1063
- }
1064
- function keyFieldCountProblems(cid, submit) {
1065
- const keyFields = submit.validate?.keyFields ?? [];
1066
- if (keyFields.length <= 2) return [];
1067
- return [`public.submit.${cid}.validate.keyFields declares ${keyFields.length}; the rules check at most 2. Rules have no iteration, so the check is unrolled — a third would be published and never enforced.`];
1068
- }
1069
- /** The fail-closed traps: declarations the rules read together, where the
1070
- * missing half denies every write instead of loosening one. */
1071
- function coherenceProblems(app) {
1072
- const fromSubmits = Object.entries(app.public?.submit ?? {}).flatMap(([cid, submit]) => submitCoherenceProblems(app, cid, submit));
1073
- const fromCollections = Object.entries(app.collections ?? {}).flatMap(([cid, collection]) => gateCoherenceProblems(cid, collection));
1074
- return [...fromSubmits, ...fromCollections];
1075
- }
1076
- /** `initialStatus` is read together with the collection's `statusField` and
1077
- * with `createFields`; miss either and every submission is refused. */
1078
- function statusCoherenceProblems(cid, submit, collection) {
1079
- if (submit.initialStatus === void 0) return [];
1080
- if (!collection?.statusField) return [`public.submit.${cid}.initialStatus needs collections.${cid}.statusField: the rules look the status up by that name, and refuse every submission without it.`];
1081
- if (new Set(submit.createFields).has(collection.statusField)) return [];
1082
- return [`public.submit.${cid}.createFields must include "${collection.statusField}": a submission may carry ONLY the createFields, and the rules also require the status field to be present and equal to initialStatus. As written, every submission is refused.`];
1083
- }
1084
- /** Every field a RULE reads off a submitted record, other than the status
1085
- * field (which `statusCoherenceProblems` words for itself).
1086
- *
1087
- * `emailField` and `idField` belong here for exactly the reason `required`
1088
- * and `keyFields` do, and forgetting them was the same oversight twice: the
1089
- * rules read `request.resource.data[s.emailField]` and rebuild the document
1090
- * id from `s.idField`, while `hasOnly(createFields)` decides what a
1091
- * submission may carry at all. A field in one list and not the other is a
1092
- * contradiction the submitter cannot resolve — including it is refused,
1093
- * omitting it fails the check. */
1094
- function ruleReadFields(submit) {
1095
- const fields = [];
1096
- if (submit.emailField !== void 0) fields.push({
1097
- field: submit.emailField,
1098
- why: `public.submit.<cid>.emailField — the rules compare it to the submitter's verified address`
1099
- });
1100
- if ((submit.idFrom === "auth.uid+field" || submit.idFrom === "field") && submit.idField !== void 0) fields.push({
1101
- field: submit.idField,
1102
- why: `public.submit.<cid>.idField — the rules rebuild the document id from it`
1103
- });
1104
- return fields;
1105
- }
1106
- /** A checked field a submission is not allowed to carry can never be
1107
- * satisfied: carrying it fails `hasOnly`, omitting it fails the check. */
1108
- function createFieldProblems(cid, submit) {
1109
- const createFields = new Set(submit.createFields);
1110
- const ruleRead = ruleReadFields(submit).filter((entry) => !createFields.has(entry.field)).map((entry) => `public.submit.${cid}.createFields must include "${entry.field}" (${entry.why.replace("<cid>", cid)}): a submission may carry only the createFields, so as written every submission is refused whether or not it carries the field.`);
1111
- const required = (submit.validate?.required ?? []).filter((field) => !createFields.has(field)).map((field) => `public.submit.${cid}.validate.required names "${field}", which is not in createFields: a submission may carry only the createFields, so the requirement can never be met.`);
1112
- const keyFields = (submit.validate?.keyFields ?? []).filter((keyField) => !createFields.has(keyField.field)).map((keyField) => `public.submit.${cid}.validate.keyFields checks "${keyField.field}", which is not in createFields: a submission carrying it is refused, and one omitting it fails the check.`);
1113
- return [
1114
- ...ruleRead,
1115
- ...required,
1116
- ...keyFields
1117
- ];
1118
- }
1119
- function submitCoherenceProblems(app, cid, submit) {
1120
- const collection = app.collections?.[cid];
1121
- const problems = [...statusCoherenceProblems(cid, submit, collection), ...createFieldProblems(cid, submit)];
1122
- if (submit.idFrom === "auth.uid+field" && submit.idField === void 0) problems.push(`public.submit.${cid}.idFrom is "auth.uid+field" but no idField is declared: the rules rebuild the document id from that field and refuse every create.`);
1123
- problems.push(...fieldIdProblems(cid, submit));
1124
- if ((submit.selfUpdate !== void 0 || submit.selfTransitions !== void 0) && !collection?.statusField) problems.push(`public.submit.${cid}.selfUpdate / selfTransitions are declared per CURRENT STATUS, but collections.${cid} declares no statusField: the rules read the current status first and refuse every self-edit without it.`);
1125
- if (submit.audience === "participant" && Object.keys(app.members).length === 0) problems.push(`public.submit.${cid}.audience is "participant" but the roster is empty: the rules resolve the submitter's role from members, so every submission is refused.`);
1126
- return problems;
1127
- }
1128
- /** `idFrom: "field"` makes the document id a CLAIM ABOUT ANOTHER RECORD, and
1129
- * the claim is only worth what is checked.
1130
- *
1131
- * `idIn` is required rather than optional, and that is the whole point of
1132
- * refusing here: without it the id is any string a stranger likes, so the app
1133
- * quietly accepts bookings for slots that do not exist. Nothing downstream
1134
- * ever notices — the booking is real, its slot is not — which is exactly the
1135
- * kind of hole a gate is for and a rule cannot state.
1136
- *
1137
- * `idIn` without the mode is refused for the opposite reason: the rules read
1138
- * it only in that branch, so an author who wrote it believes a check is
1139
- * running that is not. */
1140
- function fieldIdProblems(cid, submit) {
1141
- const problems = [];
1142
- if (submit.idFrom === "field") {
1143
- if (submit.idField === void 0) problems.push(`public.submit.${cid}.idFrom is "field" but no idField is declared: the rules take the document id from that field and refuse every create.`);
1144
- if (submit.idIn === void 0) problems.push(`public.submit.${cid}.idFrom is "field" but no idIn is declared: the document id is then any string a submitter chooses, so the app accepts records pointing at things that do not exist. Name the collection the id must be found in — and, when only some of those records may be claimed, the state they must be in: "idIn": { "collection": "slots", "where": { "field": "state", "equals": "open" } }.`);
1145
- } else if (submit.idIn !== void 0) {
1146
- const mode = submit.idFrom === void 0 ? "absent" : JSON.stringify(submit.idFrom);
1147
- problems.push(`public.submit.${cid}.idIn is declared but idFrom is ${mode}: the rules read idIn only for idFrom "field", so as written nothing checks the referenced record and the declaration promises a check it does not perform.`);
1148
- }
1149
- return problems;
1150
- }
1151
- /** Every `idIn` target, checked against the collections this repository has.
1152
- *
1153
- * Separate from {@link fieldIdProblems} for the reason the file is split at
1154
- * all: that one reads the declaration alone, this one needs to know what
1155
- * exists. */
1156
- function idTargetProblems(app, collections) {
1157
- const known = new Set(collections.map((collection) => collection.cid));
1158
- const names = known.size > 0 ? [...known].sort().join(", ") : "(none)";
1159
- return Object.entries(app.public?.submit ?? {}).flatMap(([cid, submit]) => idInTargetProblems(cid, submit, known, names));
1160
- }
1161
- /** Where a `field` id says its record must be found.
1162
- *
1163
- * A typo passes every other check: the rules look the record up in a
1164
- * collection that does not exist, the lookup can never succeed, and every
1165
- * submission is refused with no explanation anywhere. A collection pointing
1166
- * at ITSELF is worse than a typo — on a create the document being written
1167
- * does not exist yet, so it is a declaration that can never accept anything. */
1168
- function idInTargetProblems(cid, submit, known, names) {
1169
- const target = submit.idIn?.collection;
1170
- if (target === void 0) return [];
1171
- if (target === cid) return [`public.submit.${cid}.idIn.collection names '${cid}' itself: a create writes a document that does not exist yet, so the record can never be found and every submission is refused. Name the collection of the thing being claimed (the slots, the seats, the assets).`];
1172
- if (!known.has(target)) return [`public.submit.${cid}.idIn.collection names '${target}', which is not a shared collection in this repository. The rules look the record up there, so nothing can ever be submitted. Shared collections here: ${names}.`];
1173
- return [];
1174
- }
1175
- /** The staged reveal reads its flag off the PARENT record, so the path to that
1176
- * parent is not optional decoration — without it the gate never opens. */
1177
- function gateCoherenceProblems(cid, collection) {
1178
- if (collection.revealGated !== true) return [];
1179
- if (collection.gatedFrom !== void 0 && collection.revealBy !== void 0) return [];
1180
- return [`collections.${cid}.revealGated needs both gatedFrom and revealBy: the flag is read off the PARENT record, and without the path the gate never opens.`];
1181
- }
1182
- /** The publisher must be able to write what they are about to write.
1183
- *
1184
- * On a first publish the rules require the creator to name themselves owner,
1185
- * in the roster, under `'*'`. Getting this wrong produces a bare permission
1186
- * error from Firestore with nothing in it about rosters — worth one line
1187
- * here instead. */
1188
- function publisherProblems(app, publisherEmail) {
1189
- if (app.members[publisherEmail]?.["*"] === "owner") return [];
1190
- return [`members must give you app-wide owner: add "${publisherEmail}": { "*": "owner" }. The rules require the publisher to hold that role (and to name themselves owner when the app is first created); otherwise the write is refused with no explanation.`];
1191
- }
1192
- /** Every cid the declaration mentions must be a collection that exists.
1193
- *
1194
- * A typo'd cid is not an error anywhere else: the app document simply carries
1195
- * a configuration for a collection nobody publishes, and the collection the
1196
- * author meant is published with no configuration at all — i.e. with the
1197
- * status machine and the submit path silently absent. */
1198
- function unknownCidProblems(app, collections) {
1199
- const known = new Set(collections.map((collection) => collection.cid));
1200
- return [
1201
- ["collections", Object.keys(app.collections ?? {})],
1202
- ["public.read", app.public?.read ?? []],
1203
- ["public.submit", Object.keys(app.public?.submit ?? {})],
1204
- ["participantRead", app.participantRead ?? []],
1205
- ["members", [...new Set(Object.values(app.members).flatMap((roles) => Object.keys(roles)))].filter((key) => key !== "*")]
1206
- ].flatMap(([where, cids]) => cids.filter((cid) => !known.has(cid)).map((cid) => `${where} names '${cid}', which is not a shared collection in this repository. Shared collections here: ${known.size > 0 ? [...known].sort().join(", ") : "(none - a schema needs storage.type \"firestore\")"}.`));
1207
- }
1208
- /** Everything publish refuses, as lines the author can act on.
1209
- *
1210
- * All of them, every time. Publish is a manual step with a human waiting on
1211
- * it; stopping at the first problem turns one review into five. */
1212
- function publishProblems(app, collections, publisherEmail) {
1213
- return [
1214
- ...unknownCidProblems(app, collections),
1215
- ...publisherProblems(app, publisherEmail),
1216
- ...submitOnlyProblems(app),
1217
- ...aggregateProblems(app),
1218
- ...authProblems(app),
1219
- ...mailProblems(app),
1220
- ...submitShapeProblems(app),
1221
- ...coherenceProblems(app),
1222
- ...primaryKeyProblems(app, collections),
1223
- ...assigneeProblems(app),
1224
- ...stampProblems(app),
1225
- ...windowRefProblems(app, collections),
1226
- ...idTargetProblems(app, collections),
1227
- ...mirrorProblems(app, collections),
1228
- ...viewProblems(app, collections)
1229
- ];
1230
- }
1231
- /** A public submission must NOT be allowed to name its own primary key.
1232
- *
1233
- * The rules constrain the DOCUMENT ID (`idFrom`) and cannot constrain the
1234
- * value of a field — nothing compares `request.resource.data[primaryKey]`
1235
- * with the path being written. So a submit path that accepts the primary key
1236
- * as a `createField` lets a submitter write at their one permitted document
1237
- * id while CLAIMING another record's identity, or a duplicate.
1238
- *
1239
- * It is refused rather than tolerated because there is nothing for the field
1240
- * to do: `firestoreStore` takes a shared record's identity from the document
1241
- * id and overwrites the field on read, so a submitted value is either equal
1242
- * to the id (noise) or a lie (silently discarded). Publishing a form field
1243
- * whose value is thrown away is worse than not having it — the author will
1244
- * believe submitters choose their ids.
1245
- *
1246
- * This is the second answer to the same question. The first was the reverse —
1247
- * REQUIRE the key, because a record without one was rejected by every reader
1248
- * — and it was right about the symptom and wrong about the cure: the identity
1249
- * belongs to the id the rules can pin, not to a field they cannot. */
1250
- function primaryKeyProblems(app, collections) {
1251
- const primaryKeyOf = new Map(collections.map((collection) => [collection.cid, collection.primaryKey]));
1252
- return Object.entries(app.public?.submit ?? {}).flatMap(([cid, submit]) => {
1253
- const primaryKey = primaryKeyOf.get(cid);
1254
- if (primaryKey === void 0 || !submit.createFields.includes(primaryKey)) return [];
1255
- return [`public.submit.${cid}.createFields must NOT include "${primaryKey}", the schema's primaryKey: the rules can pin the document id but not the value of a field, so a submitter could write at their own id while claiming another record's. A shared record's identity is its document id — the store fills the field from it, and a submitted value is either the same thing or a lie that is thrown away.`];
1256
- });
1257
- }
1258
- /** `assignee` without the field that says which rows are theirs.
1259
- *
1260
- * A FAIL-CLOSED trap of the worst kind, because it fails closed for one
1261
- * person and nobody else: the rules ask `collections[cid].assigneeField` for
1262
- * the field to compare, find nothing, and refuse every write that member
1263
- * makes. The app works for the owner who set it up, and the member it was set
1264
- * up for is told only "permission denied".
1265
- *
1266
- * `'*': "assignee"` is refused outright rather than checked against every
1267
- * collection. The role means "the rows assigned to you", and what counts as
1268
- * assigned is per collection — an app-wide one would need the same field name
1269
- * to be right everywhere, and where it is missing it silently means "no
1270
- * access to this collection" rather than "no scoping here".
1271
- */
1272
- function assigneeProblems(app) {
1273
- return Object.entries(app.members).flatMap(([email, roles]) => Object.entries(roles).flatMap(([cid, role]) => {
1274
- if (role !== "assignee") return [];
1275
- if (cid === "*") return [`members["${email}"] holds "assignee" under "*", and the role cannot be app-wide: which rows are yours is declared per collection (\`collections.<cid>.assigneeField\`). Name the collections instead — { "bookings": "assignee" }.`];
1276
- if (app.collections?.[cid]?.assigneeField !== void 0) return [];
1277
- return [`members["${email}"] holds "assignee" on '${cid}', but collections.${cid}.assigneeField does not say which field names the member a row belongs to. Add it (assigneeField: "<a field holding an address>"), or give a role that is not row-scoped. Without it the rules have nothing to compare and refuse every write that member makes, while the app keeps working for everybody else.`];
1278
- }));
1279
- }
1280
- /** A server-stamped field the submitter cannot write, or can rewrite later.
1281
- *
1282
- * Both failures are silent in opposite directions. Left out of
1283
- * `createFields`, the rules refuse every submission (`hasOnly(createFields)`
1284
- * rejects the key the stamp check requires) — an app nobody can use. Left IN
1285
- * a `selfUpdate` list, the field the queue is ordered by becomes editable by
1286
- * the person standing in the queue. */
1287
- function stampProblems(app) {
1288
- return Object.entries(app.public?.submit ?? {}).flatMap(([cid, submit]) => {
1289
- const stamp = submit.stampField;
1290
- if (stamp === void 0) return [];
1291
- const problems = [];
1292
- if (!submit.createFields.includes(stamp)) problems.push(`public.submit.${cid}.stampField names '${stamp}', which is not in createFields. The rules require the record to CARRY the server time in that field, and refuse any key outside createFields — so every submission is denied. Add it to createFields; the page fills it in, not the person.`);
1293
- for (const [status, fields] of Object.entries(submit.selfUpdate ?? {})) {
1294
- if (!fields.includes(stamp)) continue;
1295
- problems.push(`public.submit.${cid}.selfUpdate.${status} lets the submitter write '${stamp}', which is the field stampField pins to the server clock. Whatever that field orders — a first-come queue, an audit trail — could then be rewritten by the person it ranks. Remove it from selfUpdate.`);
1296
- }
1297
- return problems;
1298
- });
1299
- }
1300
- /** A per-record window bound pointing at a collection or a field the submitter
1301
- * never writes.
1302
- *
1303
- * `fromField` makes the rules read another record, and every part of that
1304
- * read is fail-closed: an unknown collection, or a `ref` the submission does
1305
- * not carry, means the bound can never be satisfied and the form is shut for
1306
- * good. */
1307
- function windowRefProblems(app, collections) {
1308
- const known = new Set(collections.map((collection) => collection.cid));
1309
- return Object.entries(app.public?.submit ?? {}).flatMap(([cid, submit]) => [...windowBoundProblems(cid, submit, known, "fromField", submit.window?.fromField, "opening"), ...windowBoundProblems(cid, submit, known, "untilField", submit.window?.untilField, "closing")]);
1310
- }
1311
- /** Both bounds, checked identically. `untilField` arrived with the booking
1312
- * desk and reads exactly like its twin, so a check that knew only about
1313
- * `fromField` would let the closing half through unchecked — and a closing
1314
- * bound that names nothing does not leave the door ajar, it refuses every
1315
- * submission with no explanation. */
1316
- function windowBoundProblems(cid, submit, known, key, ref, which) {
1317
- if (ref === void 0) return [];
1318
- const problems = [];
1319
- if (!known.has(ref.collection)) problems.push(`public.submit.${cid}.window.${key}.collection names '${ref.collection}', which is not a shared collection in this repository. The rules read the ${which} time off a record there, so nothing can ever be submitted. Shared collections here: ${known.size > 0 ? [...known].sort().join(", ") : "(none)"}.`);
1320
- if (!submit.createFields.includes(ref.ref)) problems.push(`public.submit.${cid}.window.${key}.ref names '${ref.ref}', which is not in createFields. The rules take the target record's id from that field ON THE SUBMISSION — if the submitter never writes it, there is nothing to look up and every submission is refused.`);
1321
- return problems;
1322
- }
1323
- /** The two halves of a mirror, checked as the pair they only work as.
1324
- *
1325
- * `mirror` on the submission and `mirrorOf` on the projection are separate
1326
- * keys in separate places, and each is inert without the other: a booking
1327
- * whose slot declares no `mirrorOf` can never be created (the rules demand a
1328
- * paired write that the projection's own rule will refuse), and a projection
1329
- * whose authority declares no `mirror` drifts unbounded because nothing makes
1330
- * the two move together. Both failures are silent, and one of them —
1331
- * advertising a slot somebody already holds — is the exact thing the mirror
1332
- * exists to prevent.
1333
- *
1334
- * Also refuses a collection mirroring ITSELF, which reads as a typo and
1335
- * behaves as an unwritable collection: every create would have to prove its
1336
- * own document is simultaneously taken and open. */
1337
- function mirrorProblems(app, collections) {
1338
- const known = new Set(collections.map((collection) => collection.cid));
1339
- const names = known.size > 0 ? [...known].sort().join(", ") : "(none)";
1340
- return [...Object.entries(app.public?.submit ?? {}).flatMap(([cid, submit]) => mirrorClaimProblems(app, cid, submit, known, names)), ...Object.entries(app.collections ?? {}).flatMap(([cid, collection]) => mirrorOfProblems(app, cid, collection, known, names))];
1341
- }
1342
- /** The submission side: `public.submit[cid].mirror`. */
1343
- function mirrorClaimProblems(app, cid, submit, known, names) {
1344
- const { mirror } = submit;
1345
- if (mirror === void 0) return [];
1346
- if (mirror === cid) return [`public.submit.${cid}.mirror names its own collection: the projection is a SEPARATE record, and as written no create can satisfy the rules.`];
1347
- if (!known.has(mirror)) return [`public.submit.${cid}.mirror names '${mirror}', which is not a shared collection in this repository. The rules require the projection to move in the same write, so every submission is refused. Shared collections here: ${names}.`];
1348
- if (app.collections?.[mirror]?.mirrorOf !== cid) return [`public.submit.${cid}.mirror names '${mirror}', but collections.${mirror} does not declare mirrorOf: "${cid}". The two halves only work as a pair — the submission side demands the projection move with it, and the projection side is what allows that move — so as written every submission is refused.`];
1349
- return [];
1350
- }
1351
- /** The projection side: `collections[cid].mirrorOf`. */
1352
- function mirrorOfProblems(app, cid, collection, known, names) {
1353
- const authority = collection.mirrorOf;
1354
- if (authority === void 0) return [];
1355
- if (!known.has(authority)) return [`collections.${cid}.mirrorOf names '${authority}', which is not a shared collection in this repository. Nothing can then be true of it, so the projection's state may never be written. Shared collections here: ${names}.`];
1356
- if (app.public?.submit?.[authority]?.mirror !== cid) return [`collections.${cid}.mirrorOf names '${authority}', but public.submit.${authority} does not declare mirror: "${cid}". Only the pair keeps the projection honest: without the other half a record can be created without moving this one, and the public page goes on offering something that is already taken.`];
1357
- return [];
1358
- }
1359
- /** What each view is handed, and whether its audience can actually read it.
1360
- *
1361
- * Declared, never inferred — a view whose datasets were guessed from
1362
- * `public.read` renders perfectly and draws an empty grid, with nothing in
1363
- * the page, the rules or the log to say why.
1364
- *
1365
- * The reachability check below is that same failure, once per audience. A
1366
- * `public` view naming a collection outside `public.read` draws nothing; a
1367
- * `participant` view naming one the participant reaches by neither
1368
- * `participantRead` nor their own row is worse, because an unscoped list on
1369
- * an own-row collection is DENIED rather than narrowed — the page does not
1370
- * render less, it fails.
1371
- *
1372
- * There is deliberately no such check for `member`. Every read a role opens
1373
- * is unscoped, and WHICH role a given member holds is not a property of the
1374
- * declaration: a stylist scoped to `bookings` and an owner read the same
1375
- * projection. That one is settled at the entrance, by trying the read. */
1376
- /** The path, for one view. The SAME validator the host's own custom views use,
1377
- * rather than a second opinion about what a safe view path is.
1378
- *
1379
- * Two ad-hoc attempts were wrong here in the same afternoon: a prefix-and-
1380
- * suffix test let `views/../../secrets.html` through, and `views/[^/]+\.html`
1381
- * still let `views/..\..\secrets.html` through, because a backslash is not a
1382
- * slash on this side of the check and IS a separator on Windows. This one
1383
- * rejects `..`, backslashes, leading slashes and anything outside
1384
- * `[A-Za-z0-9._-]` per segment.
1385
- *
1386
- * It matters more here than for a host view: the host reads this path to
1387
- * decide which file to copy onto a document other people read — for a public
1388
- * view, a document whose rule is `allow read: if true`, so the blast radius of
1389
- * a bad path is the world rather than the author's own iframe. Nested paths
1390
- * ARE allowed by the shared validator; the extra `views/<one name>.html` shape
1391
- * is this publisher's own narrowing, kept because there is no reason for a
1392
- * published view to live in a subdirectory. */
1393
- function viewPathProblems(view) {
1394
- if (require_templatePath.isSafeCustomViewPath(view.path) && view.path.split("/").length === 2) return [];
1395
- return [`${view.where}.path is '${view.path}': a published view is exactly one HTML file directly inside the collection's own views/ directory (e.g. views/booking.html) — no sub-directories, and no segments that climb out of it. The host reads this as a file to publish.`];
1396
- }
1397
- /** One dataset, for one view: does it exist here, and can the audience it is
1398
- * handed to actually read it? */
1399
- function viewCollectionProblems(app, view, cid, known) {
1400
- if (!known.has(cid)) return [`${view.where}.collections names '${cid}', which is not a shared collection in this repository. Shared collections here: ${known.size > 0 ? [...known].sort().join(", ") : "(none)"}.`];
1401
- if (view.audience === "public" && !(app.public?.read ?? []).includes(cid)) return [`${view.where}.collections names '${cid}', which is not in public.read: the page reads these with the VISITOR's permissions, so the rules refuse the read and the view draws an empty page. Nothing errors — this is the failure that looks like a working view with no data.`];
1402
- return [];
1403
- }
1404
- function viewProblems(app, collections) {
1405
- const normalized = normalizeViews(app);
1406
- if (!normalized.ok) return normalized.problems;
1407
- const known = new Set(collections.map((collection) => collection.cid));
1408
- return normalized.views.flatMap((view) => [...viewPathProblems(view), ...view.collections.flatMap((cid) => viewCollectionProblems(app, view, cid, known))]);
1409
- }
1410
- /** What publish will actually promote, checked as the PAIR it becomes.
1411
- *
1412
- * `publishProblems` reads the manifest, where `members` and `collections` sit
1413
- * side by side and agree. Publish does not write that pair. It writes the
1414
- * roster from the manifest and the collection configuration from what DEPLOY
1415
- * staged, so the app that lands is one half of each — and no check has ever
1416
- * looked at that combination.
1417
- *
1418
- * The sequence that gets through: deploy revision A with no `assigneeField`,
1419
- * add the field AND the member in revision B, publish without redeploying.
1420
- * Every manifest-level check passes on a declaration that is internally sound,
1421
- * while what lands is A's field-less configuration beside B's roster — an
1422
- * assignee with nothing to be compared against, refused every write, in an app
1423
- * that keeps working for everybody else. That is the precise trap
1424
- * `assigneeProblems` exists to prevent, reached by the one route it cannot
1425
- * see.
1426
- *
1427
- * Separate from `publishProblems` because it needs what deploy staged, which
1428
- * is a Firestore read the host makes and this package does not. It is checked
1429
- * against `stagedRuleConfig` — the same function the projection uses — rather
1430
- * than against a re-derivation, so the value validated is the value written.
1431
- *
1432
- * Only the staged half can be stale, so only that half is named and the fix is
1433
- * "deploy again" rather than "fix the declaration". */
1434
- function promotedRoleProblems(app, staged) {
1435
- const promoted = stagedRuleConfig(staged).collections ?? {};
1436
- const stagedCids = new Set(staged.map((entry) => entry.cid));
1437
- return [
1438
- ...promotedAssigneeProblems(app, promoted, stagedCids),
1439
- ...promotedMirrorProblems(app, promoted, stagedCids),
1440
- ...promotedRefFieldProblems(app, staged),
1441
- ...promotedParticipantViewProblems(app, staged)
1442
- ];
1443
- }
1444
- /** A participant's page, checked against the `participantRead` publish will
1445
- * actually PROMOTE.
1446
- *
1447
- * Not against the manifest's. `projectPublish` overwrites `participantRead`
1448
- * with what the staged schemas carry, so a cid added to the manifest since the
1449
- * last deploy is not in the rules — and a page written for it would be
1450
- * published, offered, and then refused the read. The manifest half of this
1451
- * file cannot see that; the promoted half can, which is why the check lives
1452
- * here rather than beside the other view checks. */
1453
- function promotedParticipantViewProblems(app, staged) {
1454
- const normalized = normalizeViews(app);
1455
- if (!normalized.ok) return [];
1456
- const participantRead = stagedRuleConfig(staged).participantRead ?? [];
1457
- return normalized.views.filter((view) => view.audience === "participant").flatMap((view) => view.collections.filter((cid) => participantScope(app, cid, participantRead) === null).map((cid) => `${view.where}.collections names '${cid}', which a participant cannot read once this publishes: it is not in the participantRead that DEPLOY staged, and public.submit.${cid} declares neither an emailField nor idFrom "auth.uid", so there is no row the rules would call theirs. The page would be refused the read, not handed fewer records. (Adding it to participantRead in app.json is not enough — deploy first.)`));
1458
- }
1459
- /** The FIELDS a rule reads off another record — `idIn.where.field` and the two
1460
- * window bounds — checked against the schema publish is about to promote.
1461
- *
1462
- * These are checked here rather than in `publishProblems` because that gate
1463
- * is given a cid and a primary key per collection and nothing else, on
1464
- * purpose: it reads the DECLARATION. A field name can only be judged against
1465
- * a schema, and the schema that matters is the STAGED one — the version
1466
- * publish promotes — not whatever the working tree says now.
1467
- *
1468
- * What a typo costs: `where: { field: "staet" }` publishes cleanly, the
1469
- * rules' comparison can never match, and every submission is denied with no
1470
- * message. The author's own app looks broken with nothing to read.
1471
- *
1472
- * Only fields the schema DECLARES are accepted. A record may carry more than
1473
- * its schema does, but a shared collection's records are written through it,
1474
- * and "the field exists on some rows" is not something a gate can promise. */
1475
- function promotedRefFieldProblems(app, staged) {
1476
- const schemaOf = new Map(staged.map((entry) => [entry.cid, entry.doc.publishedSchema]));
1477
- return Object.entries(app.public?.submit ?? {}).flatMap(([cid, submit]) => submitRefProblems(schemaOf, cid, submit));
1478
- }
1479
- function submitRefProblems(schemaOf, cid, submit) {
1480
- return [
1481
- ...idInRefProblems(schemaOf, cid, submit),
1482
- ...boundRefProblems(schemaOf, cid, "fromField", submit.window?.fromField),
1483
- ...boundRefProblems(schemaOf, cid, "untilField", submit.window?.untilField)
1484
- ];
1485
- }
1486
- function idInRefProblems(schemaOf, cid, submit) {
1487
- const where = submit.idIn?.where;
1488
- if (where === void 0) return [];
1489
- return [...refFieldProblem(schemaOf, cid, "idIn.where.field", submit.idIn?.collection, where.field), ...comparableProblem(schemaOf, cid, submit.idIn?.collection, where)];
1490
- }
1491
- function boundRefProblems(schemaOf, cid, key, ref) {
1492
- if (ref === void 0) return [];
1493
- return [...refFieldProblem(schemaOf, cid, `window.${key}.field`, ref.collection, ref.field), ...millisProblem(schemaOf, cid, `window.${key}.field`, ref)];
1494
- }
1495
- /** The field spec a reference points at, or undefined when there is nothing
1496
- * staged to judge it against (the host refuses that separately, naming every
1497
- * missing collection at once). */
1498
- function referencedField(schemaOf, target, field) {
1499
- if (target === void 0 || field === void 0) return void 0;
1500
- return schemaOf.get(target)?.fields?.[field];
1501
- }
1502
- /** An enum's domain, or undefined for every other kind. Narrowed by the key
1503
- * rather than asserted: `fields` is a discriminated union and only some of
1504
- * its members carry `values`. */
1505
- function enumValues(spec) {
1506
- return spec.type === "enum" ? spec.values : void 0;
1507
- }
1508
- function refFieldProblem(schemaOf, cid, key, target, field) {
1509
- if (target === void 0 || field === void 0) return [];
1510
- const schema = schemaOf.get(target);
1511
- if (schema === void 0 || referencedField(schemaOf, target, field) !== void 0) return [];
1512
- const known = Object.keys(schema.fields ?? {}).sort().join(", ");
1513
- return [`public.submit.${cid}.${key} names '${field}', which the STAGED schema of '${target}' — the one publish promotes — does not declare. The rules read that field off the record and compare it, so as written every submission is refused with nothing to explain it. Fields on '${target}': ${known.length > 0 ? known : "(none)"}.`];
1514
- }
1515
- /** A comparison the rules can never satisfy is as dead as a missing field, and
1516
- * looks even more correct on the page: an `enum` whose domain does not contain
1517
- * the value, or a boolean field compared with a string. */
1518
- function comparableProblem(schemaOf, cid, target, where) {
1519
- const spec = referencedField(schemaOf, target, where.field);
1520
- if (spec === void 0) return [];
1521
- const said = JSON.stringify(where.equals);
1522
- const values = enumValues(spec);
1523
- if (values !== void 0) {
1524
- if (values.includes(String(where.equals))) return [];
1525
- return [`public.submit.${cid}.idIn.where.equals is ${said}, which is not one of the values '${where.field}' can hold on '${String(target)}' (${values.join(", ") || "(none)"}). The comparison can never be true, so every submission is refused.`];
1526
- }
1527
- const wanted = spec.type === "number" ? "number" : spec.type === "boolean" ? "boolean" : "string";
1528
- if (typeof where.equals === wanted) return [];
1529
- return [`public.submit.${cid}.idIn.where.equals is ${said}, and '${where.field}' on '${String(target)}' is a ${spec.type} field. The rules compare the stored value with this one and never coerce, so the comparison can never be true and every submission is refused.`];
1530
- }
1531
- /** A per-record window bound is EPOCH MILLIS, because the rules have no date
1532
- * arithmetic and do not coerce: they compare `request.time.toMillis()` with
1533
- * whatever is stored. A `datetime` field holds an ISO string, which is a type
1534
- * error that fails closed — the window never opens, and nothing says so. */
1535
- function millisProblem(schemaOf, cid, key, ref) {
1536
- const spec = referencedField(schemaOf, ref?.collection, ref?.field);
1537
- if (spec === void 0 || spec.type === "number") return [];
1538
- return [`public.submit.${cid}.${key} names '${String(ref?.field)}' on '${String(ref?.collection)}', which is a ${spec.type} field. A per-record bound is EPOCH MILLIS: the rules compare it with request.time.toMillis() and never coerce, so anything else is a type error that refuses every submission — the window simply never opens. Store the instant as a number.`];
1539
- }
1540
- function promotedAssigneeProblems(app, promoted, stagedCids) {
1541
- return Object.entries(app.members).flatMap(([email, roles]) => Object.entries(roles).flatMap(([cid, role]) => {
1542
- if (role !== "assignee" || cid === "*" || !stagedCids.has(cid)) return [];
1543
- if (promoted[cid]?.assigneeField !== void 0) return [];
1544
- return [`members["${email}"] holds "assignee" on '${cid}', and the STAGED version of '${cid}' — the one publish promotes — carries no assigneeField, even if app.json declares one now. Publish writes the roster from app.json and the collection configuration from the deploy, so that member would land with nothing to be compared against: refused every write, while the app keeps working for everybody else. Run deploy again, so the version being published is the one the declaration describes.`];
1545
- }));
1546
- }
1547
- /** The mirror's other half, checked against what publish will actually
1548
- * promote — the same trap as the assignee's field, reached by the same route.
1549
- *
1550
- * `mirror` is published from the MANIFEST (it lives in `public.submit`) while
1551
- * `mirrorOf` is promoted from what DEPLOY staged. Add both halves to
1552
- * `app.json` and publish without redeploying, and what lands is a submission
1553
- * demanding a paired projection write beside a projection whose rule config
1554
- * does not allow it: every booking is refused, and the declaration on disk
1555
- * looks perfectly sound.
1556
- *
1557
- * Refused in the reverse direction too. Removing `mirrorOf` from a live app
1558
- * and publishing without a deploy leaves the projection accepting nothing —
1559
- * and removing it FROM the staged side while the submission still demands it
1560
- * is the drift this pair exists to prevent. */
1561
- function promotedMirrorProblems(app, promoted, stagedCids) {
1562
- return [...addedMirrorProblems(app, promoted, stagedCids), ...strandedMirrorProblems(app, promoted)];
1563
- }
1564
- /** The manifest asks for a projection the promoted configuration will not
1565
- * allow: every submission denied, and nothing on the page to say why. */
1566
- function addedMirrorProblems(app, promoted, stagedCids) {
1567
- return Object.entries(app.public?.submit ?? {}).flatMap(([cid, submit]) => {
1568
- const { mirror } = submit;
1569
- if (mirror === void 0 || !stagedCids.has(mirror)) return [];
1570
- if (promoted[mirror]?.mirrorOf === cid) return [];
1571
- return [`public.submit.${cid}.mirror names '${mirror}', and the STAGED version of '${mirror}' — the one publish promotes — does not declare mirrorOf: "${cid}", even if app.json declares it now. Publish writes the submission side from app.json and the collection side from the deploy, so what lands is a booking that must move its projection beside a projection that refuses to move: every submission is denied, with nothing on the page to say why. Run deploy again, so the version being published is the one the declaration describes.`];
1572
- });
1573
- }
1574
- /** The other direction, and the DANGEROUS one.
1575
- *
1576
- * Take a live pair, delete BOTH halves from `app.json`, and publish without
1577
- * redeploying. The submission side comes from the manifest, so nothing
1578
- * requires the projection to move any more; the collection side comes from
1579
- * staging, which still says `mirrorOf`, so the projection stays writable.
1580
- * Bookings are then created while the public row goes on saying `open` — the
1581
- * precise failure the pair exists to prevent, arrived at by removing it.
1582
- *
1583
- * Refused rather than tolerated because the app keeps WORKING: submissions
1584
- * succeed. Only the public page is wrong, and only to the people reading it. */
1585
- function strandedMirrorProblems(app, promoted) {
1586
- return Object.entries(promoted).flatMap(([cid, config]) => {
1587
- const authority = config.mirrorOf;
1588
- if (authority === void 0) return [];
1589
- if (app.public?.submit?.[authority]?.mirror === cid) return [];
1590
- return [`the STAGED version of '${cid}' — the one publish promotes — declares mirrorOf: "${authority}", and app.json no longer declares public.submit.${authority}.mirror: "${cid}". What lands is a projection that is still writable beside submissions that no longer have to move it, so records can be created while '${cid}' goes on advertising them as available. Nothing fails: the app works and the public page lies. Run deploy again, so the version being published is the one the declaration describes.`];
1591
- });
1592
- }
1593
- //#endregion
1594
15
  //#region src/collection/server/skillAssets.ts
1595
16
  /** Read a collection's custom-view HTML, path-safely. `viewFile` is a
1596
17
  * schema-validated `views/*.html` path, resolved with realpath containment.
@@ -3660,30 +2081,6 @@ function makeManageCollectionTool(deps = {}) {
3660
2081
  };
3661
2082
  }
3662
2083
  //#endregion
3663
- Object.defineProperty(exports, "APPS_COLLECTION", {
3664
- enumerable: true,
3665
- get: function() {
3666
- return APPS_COLLECTION;
3667
- }
3668
- });
3669
- Object.defineProperty(exports, "APP_ROLES", {
3670
- enumerable: true,
3671
- get: function() {
3672
- return APP_ROLES;
3673
- }
3674
- });
3675
- Object.defineProperty(exports, "APP_SLUGS_COLLECTION", {
3676
- enumerable: true,
3677
- get: function() {
3678
- return APP_SLUGS_COLLECTION;
3679
- }
3680
- });
3681
- Object.defineProperty(exports, "AuthoredAppZ", {
3682
- enumerable: true,
3683
- get: function() {
3684
- return AuthoredAppZ;
3685
- }
3686
- });
3687
2084
  Object.defineProperty(exports, "MAX_RECORD_ISSUES", {
3688
2085
  enumerable: true,
3689
2086
  get: function() {
@@ -3708,102 +2105,24 @@ Object.defineProperty(exports, "ONE_SECOND_MS", {
3708
2105
  return ONE_SECOND_MS;
3709
2106
  }
3710
2107
  });
3711
- Object.defineProperty(exports, "PUBLIC_CONFIG_DOC", {
3712
- enumerable: true,
3713
- get: function() {
3714
- return PUBLIC_CONFIG_DOC;
3715
- }
3716
- });
3717
- Object.defineProperty(exports, "PUBLIC_VIEW_ID", {
3718
- enumerable: true,
3719
- get: function() {
3720
- return PUBLIC_VIEW_ID;
3721
- }
3722
- });
3723
- Object.defineProperty(exports, "RESERVED_VIEW_IDS", {
3724
- enumerable: true,
3725
- get: function() {
3726
- return RESERVED_VIEW_IDS;
3727
- }
3728
- });
3729
2108
  Object.defineProperty(exports, "STORE_UNREADABLE", {
3730
2109
  enumerable: true,
3731
2110
  get: function() {
3732
2111
  return STORE_UNREADABLE;
3733
2112
  }
3734
2113
  });
3735
- Object.defineProperty(exports, "VIEW_AUDIENCES", {
3736
- enumerable: true,
3737
- get: function() {
3738
- return VIEW_AUDIENCES;
3739
- }
3740
- });
3741
- Object.defineProperty(exports, "VIEW_CONFIG_ID", {
3742
- enumerable: true,
3743
- get: function() {
3744
- return VIEW_CONFIG_ID;
3745
- }
3746
- });
3747
- Object.defineProperty(exports, "VIEW_ID_PATTERN", {
3748
- enumerable: true,
3749
- get: function() {
3750
- return VIEW_ID_PATTERN;
3751
- }
3752
- });
3753
- Object.defineProperty(exports, "VIEW_TIER", {
3754
- enumerable: true,
3755
- get: function() {
3756
- return VIEW_TIER;
3757
- }
3758
- });
3759
2114
  Object.defineProperty(exports, "advanceTriggerDate", {
3760
2115
  enumerable: true,
3761
2116
  get: function() {
3762
2117
  return advanceTriggerDate;
3763
2118
  }
3764
2119
  });
3765
- Object.defineProperty(exports, "appConfigPath", {
3766
- enumerable: true,
3767
- get: function() {
3768
- return appConfigPath;
3769
- }
3770
- });
3771
- Object.defineProperty(exports, "appSchemasPath", {
3772
- enumerable: true,
3773
- get: function() {
3774
- return appSchemasPath;
3775
- }
3776
- });
3777
- Object.defineProperty(exports, "appSlugDoc", {
3778
- enumerable: true,
3779
- get: function() {
3780
- return appSlugDoc;
3781
- }
3782
- });
3783
- Object.defineProperty(exports, "appStagingPath", {
3784
- enumerable: true,
3785
- get: function() {
3786
- return appStagingPath;
3787
- }
3788
- });
3789
- Object.defineProperty(exports, "appViewTierPath", {
3790
- enumerable: true,
3791
- get: function() {
3792
- return appViewTierPath;
3793
- }
3794
- });
3795
2120
  Object.defineProperty(exports, "applyMutateAction", {
3796
2121
  enumerable: true,
3797
2122
  get: function() {
3798
2123
  return applyMutateAction;
3799
2124
  }
3800
2125
  });
3801
- Object.defineProperty(exports, "bindsSubmitterIdentity", {
3802
- enumerable: true,
3803
- get: function() {
3804
- return bindsSubmitterIdentity;
3805
- }
3806
- });
3807
2126
  Object.defineProperty(exports, "buildActionSeedPrompt", {
3808
2127
  enumerable: true,
3809
2128
  get: function() {
@@ -3900,78 +2219,18 @@ Object.defineProperty(exports, "maybeSpawnSuccessor", {
3900
2219
  return maybeSpawnSuccessor;
3901
2220
  }
3902
2221
  });
3903
- Object.defineProperty(exports, "normalizeViews", {
3904
- enumerable: true,
3905
- get: function() {
3906
- return normalizeViews;
3907
- }
3908
- });
3909
- Object.defineProperty(exports, "parseAuthoredApp", {
3910
- enumerable: true,
3911
- get: function() {
3912
- return parseAuthoredApp;
3913
- }
3914
- });
3915
2222
  Object.defineProperty(exports, "parseCivil", {
3916
2223
  enumerable: true,
3917
2224
  get: function() {
3918
2225
  return parseCivil;
3919
2226
  }
3920
2227
  });
3921
- Object.defineProperty(exports, "participantScope", {
3922
- enumerable: true,
3923
- get: function() {
3924
- return participantScope;
3925
- }
3926
- });
3927
- Object.defineProperty(exports, "projectApp", {
3928
- enumerable: true,
3929
- get: function() {
3930
- return projectApp;
3931
- }
3932
- });
3933
- Object.defineProperty(exports, "projectAppViews", {
3934
- enumerable: true,
3935
- get: function() {
3936
- return projectAppViews;
3937
- }
3938
- });
3939
- Object.defineProperty(exports, "projectDeploy", {
3940
- enumerable: true,
3941
- get: function() {
3942
- return projectDeploy;
3943
- }
3944
- });
3945
- Object.defineProperty(exports, "projectPublish", {
3946
- enumerable: true,
3947
- get: function() {
3948
- return projectPublish;
3949
- }
3950
- });
3951
- Object.defineProperty(exports, "promoteSchema", {
3952
- enumerable: true,
3953
- get: function() {
3954
- return promoteSchema;
3955
- }
3956
- });
3957
- Object.defineProperty(exports, "promotedRoleProblems", {
3958
- enumerable: true,
3959
- get: function() {
3960
- return promotedRoleProblems;
3961
- }
3962
- });
3963
2228
  Object.defineProperty(exports, "promptPathsFor", {
3964
2229
  enumerable: true,
3965
2230
  get: function() {
3966
2231
  return promptPathsFor;
3967
2232
  }
3968
2233
  });
3969
- Object.defineProperty(exports, "publishProblems", {
3970
- enumerable: true,
3971
- get: function() {
3972
- return publishProblems;
3973
- }
3974
- });
3975
2234
  Object.defineProperty(exports, "readCustomViewHtml", {
3976
2235
  enumerable: true,
3977
2236
  get: function() {
@@ -4020,12 +2279,6 @@ Object.defineProperty(exports, "schemaRelations", {
4020
2279
  return schemaRelations;
4021
2280
  }
4022
2281
  });
4023
- Object.defineProperty(exports, "stagedRuleConfig", {
4024
- enumerable: true,
4025
- get: function() {
4026
- return stagedRuleConfig;
4027
- }
4028
- });
4029
2282
  Object.defineProperty(exports, "successorId", {
4030
2283
  enumerable: true,
4031
2284
  get: function() {
@@ -4044,23 +2297,5 @@ Object.defineProperty(exports, "validateRecordObject", {
4044
2297
  return validateRecordObject;
4045
2298
  }
4046
2299
  });
4047
- Object.defineProperty(exports, "viewConfigDocId", {
4048
- enumerable: true,
4049
- get: function() {
4050
- return viewConfigDocId;
4051
- }
4052
- });
4053
- Object.defineProperty(exports, "viewDocId", {
4054
- enumerable: true,
4055
- get: function() {
4056
- return viewDocId;
4057
- }
4058
- });
4059
- Object.defineProperty(exports, "writeFor", {
4060
- enumerable: true,
4061
- get: function() {
4062
- return writeFor;
4063
- }
4064
- });
4065
2300
 
4066
- //# sourceMappingURL=server-DLzQ4jFu.cjs.map
2301
+ //# sourceMappingURL=server-CF_tGCGP.cjs.map