@mulmoclaude/core 3.13.0 → 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collection/registry/server/index.cjs +1 -1
- package/dist/collection/registry/server/index.js +1 -1
- package/dist/collection/server/appViews.d.ts +97 -0
- package/dist/collection/server/index.cjs +13 -1
- package/dist/collection/server/index.d.ts +2 -1
- package/dist/collection/server/index.js +2 -2
- package/dist/collection/server/publishManifest.d.ts +11 -1
- package/dist/collection/server/publishProject.d.ts +33 -0
- package/dist/collection-watchers/index.cjs +1 -1
- package/dist/collection-watchers/index.js +1 -1
- package/dist/feeds/server/index.cjs +1 -1
- package/dist/feeds/server/index.js +1 -1
- package/dist/{server-DGjmK9vU.js → server-CQSF5fHe.js} +317 -23
- package/dist/server-CQSF5fHe.js.map +1 -0
- package/dist/{server-_g1rW-Uc.cjs → server-DknYbXBo.cjs} +388 -22
- package/dist/server-DknYbXBo.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/server-DGjmK9vU.js.map +0 -1
- package/dist/server-_g1rW-Uc.cjs.map +0 -1
|
@@ -13,6 +13,166 @@ node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
|
13
13
|
let node_crypto = require("node:crypto");
|
|
14
14
|
let node_fs_promises = require("node:fs/promises");
|
|
15
15
|
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
|
+
//#endregion
|
|
16
176
|
//#region src/collection/server/publishManifest.ts
|
|
17
177
|
/** A collection id / app id, held to the one name rule (`SAFE_SLUG_PATTERN`)
|
|
18
178
|
* that `sharedCollectionKey` applies. Stated once so a path built later
|
|
@@ -266,6 +426,28 @@ var PublicZ = zod.z.object({
|
|
|
266
426
|
}).strict().optional(),
|
|
267
427
|
submit: zod.z.record(NameZ, SubmitZ).optional()
|
|
268
428
|
}).strict();
|
|
429
|
+
/** One page the app shows, and who it is for.
|
|
430
|
+
*
|
|
431
|
+
* Generalised from `public.view` (which is still accepted, and normalizes
|
|
432
|
+
* into this — see `appViews.ts`). The audience is what decides which document
|
|
433
|
+
* the HTML is published to, and therefore who may read it: a rule cannot hide
|
|
434
|
+
* a field, so "the front desk sees this" is a place, not a filter.
|
|
435
|
+
*
|
|
436
|
+
* `id` is not decoration. It becomes the document id the page is published
|
|
437
|
+
* at, which is what lets one audience have more than one page — the front
|
|
438
|
+
* desk and the stock room — and what lets a withdrawn view be found and
|
|
439
|
+
* deleted. Its grammar is enforced at the gate, not here, so the refusal can
|
|
440
|
+
* say what the value is used for.
|
|
441
|
+
*
|
|
442
|
+
* `collections` is declared rather than inferred, for the reason `public.view`
|
|
443
|
+
* gives: an inferred list renders a perfect page with no data in it, and
|
|
444
|
+
* nothing anywhere says why. */
|
|
445
|
+
var ViewZ = zod.z.object({
|
|
446
|
+
id: zod.z.string().trim().min(1),
|
|
447
|
+
audience: zod.z.enum(VIEW_AUDIENCES),
|
|
448
|
+
path: zod.z.string().trim().min(1),
|
|
449
|
+
collections: zod.z.array(NameZ).min(1)
|
|
450
|
+
}).strict();
|
|
269
451
|
/** The URL name an app is handed out under: `https://<host>/{slug}`.
|
|
270
452
|
*
|
|
271
453
|
* A SEPARATE name from the `aid`, and that separation is the point (design
|
|
@@ -314,7 +496,10 @@ var AuthoredAppZ = zod.z.object({
|
|
|
314
496
|
members: MembersZ,
|
|
315
497
|
collections: zod.z.record(NameZ, CollectionConfigZ).optional(),
|
|
316
498
|
participantRead: zod.z.array(NameZ).optional(),
|
|
317
|
-
public: PublicZ.optional()
|
|
499
|
+
public: PublicZ.optional(),
|
|
500
|
+
/** The app's pages, per audience. See {@link ViewZ}; `public.view` is the
|
|
501
|
+
* older spelling of the `public` one and normalizes into this list. */
|
|
502
|
+
views: zod.z.array(ViewZ).optional()
|
|
318
503
|
}).strict();
|
|
319
504
|
/** Parse the authored declaration out of `app.json`'s text.
|
|
320
505
|
*
|
|
@@ -443,11 +628,14 @@ function projectApp(authored, schemas, stamp, existing) {
|
|
|
443
628
|
publishedDirty: stamp.dirty === true ? true : void 0,
|
|
444
629
|
previousPublished: previousOf(existing)
|
|
445
630
|
});
|
|
631
|
+
const normalized = normalizeViews(authored);
|
|
632
|
+
if (!normalized.ok) throw new Error(`publish: views declaration is not publishable (${normalized.problems.join(" ")})`);
|
|
633
|
+
const publicView = normalized.views.find((view) => view.audience === "public");
|
|
446
634
|
const config = {
|
|
447
635
|
enabled: authored.public?.enabled === true,
|
|
448
636
|
read: authored.public?.read ?? [],
|
|
449
637
|
submit,
|
|
450
|
-
...
|
|
638
|
+
...publicView === void 0 ? {} : { view: { collections: publicView.collections } },
|
|
451
639
|
publishedAt: stamp.publishedAt
|
|
452
640
|
};
|
|
453
641
|
if (authored.name !== void 0) config.name = authored.name;
|
|
@@ -598,6 +786,64 @@ var appSlugDoc = (aid, published) => ({
|
|
|
598
786
|
var appStagingPath = (aid) => `apps/${aid}/staging`;
|
|
599
787
|
/** The public-config documents' parent path. */
|
|
600
788
|
var appConfigPath = (aid) => `apps/${aid}/config`;
|
|
789
|
+
/** Where one audience's pages live. `member` is read by anyone holding a role;
|
|
790
|
+
* `roster` by anyone on the roster, participants included. */
|
|
791
|
+
var appViewTierPath = (aid, tier) => `apps/${aid}/${tier}`;
|
|
792
|
+
/** What one audience may see of one collection.
|
|
793
|
+
*
|
|
794
|
+
* For `member` this is always the whole collection: every read branch a role
|
|
795
|
+
* opens (`readerOf`) is unscoped. Whether THIS member holds the role is not
|
|
796
|
+
* knowable here — one projection is read by every member of the tier — and is
|
|
797
|
+
* settled where it can be, by the entrance trying the read.
|
|
798
|
+
*
|
|
799
|
+
* For `participant` it is the rules' own answer, which is why it can be null:
|
|
800
|
+
* a participant with neither `participantRead` nor an own-row submit path
|
|
801
|
+
* cannot read the collection at all, and a page handed it would fail rather
|
|
802
|
+
* than render less. */
|
|
803
|
+
function scopeFor(authored, audience, cid, participantRead) {
|
|
804
|
+
return audience === "member" ? {
|
|
805
|
+
cid,
|
|
806
|
+
scope: "all"
|
|
807
|
+
} : participantScope(authored, cid, participantRead);
|
|
808
|
+
}
|
|
809
|
+
/** Project the declaration into the per-audience documents.
|
|
810
|
+
*
|
|
811
|
+
* Pure, like `projectApp`: the HTML is not here (the host reads the files),
|
|
812
|
+
* and neither is the clock. What is here is the answer to "what may this
|
|
813
|
+
* audience read, and how" — computed once, so the page never has to guess and
|
|
814
|
+
* never has to discover it from a denial. */
|
|
815
|
+
function projectAppViews(authored, stamp, promoted) {
|
|
816
|
+
const participantRead = promoted?.participantRead ?? authored.participantRead ?? [];
|
|
817
|
+
const normalized = normalizeViews(authored);
|
|
818
|
+
if (!normalized.ok) throw new Error(`publish: views declaration is not publishable (${normalized.problems.join(" ")})`);
|
|
819
|
+
return ["member", "participant"].map((audience) => {
|
|
820
|
+
const views = normalized.views.filter((view) => view.audience === audience);
|
|
821
|
+
const cids = [...new Set(views.flatMap((view) => view.collections))];
|
|
822
|
+
const declaredSubmit = authored.public?.submit ?? {};
|
|
823
|
+
const submit = Object.fromEntries(cids.flatMap((cid) => {
|
|
824
|
+
const spec = declaredSubmit[cid];
|
|
825
|
+
return spec === void 0 ? [] : [[cid, projectSubmit(spec)]];
|
|
826
|
+
}));
|
|
827
|
+
const config = {
|
|
828
|
+
views: views.map((view) => ({
|
|
829
|
+
id: view.id,
|
|
830
|
+
collections: view.collections.map((cid) => scopeFor(authored, audience, cid, participantRead)).filter((scope) => scope !== null)
|
|
831
|
+
})),
|
|
832
|
+
submit,
|
|
833
|
+
publishedAt: stamp.publishedAt
|
|
834
|
+
};
|
|
835
|
+
if (authored.name !== void 0) config.name = authored.name;
|
|
836
|
+
return {
|
|
837
|
+
tier: VIEW_TIER[audience],
|
|
838
|
+
audience,
|
|
839
|
+
config,
|
|
840
|
+
views
|
|
841
|
+
};
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
/** The document a tier's projection is published at. Beside the views
|
|
845
|
+
* themselves, under one `match` — see `firestore.rules`. */
|
|
846
|
+
var viewConfigDocId = (stage) => viewDocId(stage, VIEW_CONFIG_ID);
|
|
601
847
|
//#endregion
|
|
602
848
|
//#region src/collection/server/publishChecks.ts
|
|
603
849
|
/** Does this submit declaration bind a record to the submitter's identity?
|
|
@@ -873,7 +1119,7 @@ function publishProblems(app, collections, publisherEmail) {
|
|
|
873
1119
|
...windowRefProblems(app, collections),
|
|
874
1120
|
...idTargetProblems(app, collections),
|
|
875
1121
|
...mirrorProblems(app, collections),
|
|
876
|
-
...
|
|
1122
|
+
...viewProblems(app, collections)
|
|
877
1123
|
];
|
|
878
1124
|
}
|
|
879
1125
|
/** A public submission must NOT be allowed to name its own primary key.
|
|
@@ -1004,24 +1250,56 @@ function mirrorOfProblems(app, cid, collection, known, names) {
|
|
|
1004
1250
|
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.`];
|
|
1005
1251
|
return [];
|
|
1006
1252
|
}
|
|
1007
|
-
/** What
|
|
1008
|
-
*
|
|
1009
|
-
*
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1253
|
+
/** What each view is handed, and whether its audience can actually read it.
|
|
1254
|
+
*
|
|
1255
|
+
* Declared, never inferred — a view whose datasets were guessed from
|
|
1256
|
+
* `public.read` renders perfectly and draws an empty grid, with nothing in
|
|
1257
|
+
* the page, the rules or the log to say why.
|
|
1258
|
+
*
|
|
1259
|
+
* The reachability check below is that same failure, once per audience. A
|
|
1260
|
+
* `public` view naming a collection outside `public.read` draws nothing; a
|
|
1261
|
+
* `participant` view naming one the participant reaches by neither
|
|
1262
|
+
* `participantRead` nor their own row is worse, because an unscoped list on
|
|
1263
|
+
* an own-row collection is DENIED rather than narrowed — the page does not
|
|
1264
|
+
* render less, it fails.
|
|
1265
|
+
*
|
|
1266
|
+
* There is deliberately no such check for `member`. Every read a role opens
|
|
1267
|
+
* is unscoped, and WHICH role a given member holds is not a property of the
|
|
1268
|
+
* declaration: a stylist scoped to `bookings` and an owner read the same
|
|
1269
|
+
* projection. That one is settled at the entrance, by trying the read. */
|
|
1270
|
+
/** The path, for one view. The SAME validator the host's own custom views use,
|
|
1271
|
+
* rather than a second opinion about what a safe view path is.
|
|
1272
|
+
*
|
|
1273
|
+
* Two ad-hoc attempts were wrong here in the same afternoon: a prefix-and-
|
|
1274
|
+
* suffix test let `views/../../secrets.html` through, and `views/[^/]+\.html`
|
|
1275
|
+
* still let `views/..\..\secrets.html` through, because a backslash is not a
|
|
1276
|
+
* slash on this side of the check and IS a separator on Windows. This one
|
|
1277
|
+
* rejects `..`, backslashes, leading slashes and anything outside
|
|
1278
|
+
* `[A-Za-z0-9._-]` per segment.
|
|
1279
|
+
*
|
|
1280
|
+
* It matters more here than for a host view: the host reads this path to
|
|
1281
|
+
* decide which file to copy onto a document other people read — for a public
|
|
1282
|
+
* view, a document whose rule is `allow read: if true`, so the blast radius of
|
|
1283
|
+
* a bad path is the world rather than the author's own iframe. Nested paths
|
|
1284
|
+
* ARE allowed by the shared validator; the extra `views/<one name>.html` shape
|
|
1285
|
+
* is this publisher's own narrowing, kept because there is no reason for a
|
|
1286
|
+
* published view to live in a subdirectory. */
|
|
1287
|
+
function viewPathProblems(view) {
|
|
1288
|
+
if (require_templatePath.isSafeCustomViewPath(view.path) && view.path.split("/").length === 2) return [];
|
|
1289
|
+
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.`];
|
|
1290
|
+
}
|
|
1291
|
+
/** One dataset, for one view: does it exist here, and can the audience it is
|
|
1292
|
+
* handed to actually read it? */
|
|
1293
|
+
function viewCollectionProblems(app, view, cid, known) {
|
|
1294
|
+
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)"}.`];
|
|
1295
|
+
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.`];
|
|
1296
|
+
return [];
|
|
1297
|
+
}
|
|
1298
|
+
function viewProblems(app, collections) {
|
|
1299
|
+
const normalized = normalizeViews(app);
|
|
1300
|
+
if (!normalized.ok) return normalized.problems;
|
|
1013
1301
|
const known = new Set(collections.map((collection) => collection.cid));
|
|
1014
|
-
|
|
1015
|
-
const problems = [];
|
|
1016
|
-
if (!require_templatePath.isSafeCustomViewPath(view.path) || view.path.split("/").length !== 2) problems.push(`public.view.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, and what it publishes is world-readable.`);
|
|
1017
|
-
for (const cid of view.collections) {
|
|
1018
|
-
if (!known.has(cid)) {
|
|
1019
|
-
problems.push(`public.view.collections names '${cid}', which is not a shared collection in this repository. Shared collections here: ${known.size > 0 ? [...known].sort().join(", ") : "(none)"}.`);
|
|
1020
|
-
continue;
|
|
1021
|
-
}
|
|
1022
|
-
if (!readable.has(cid)) problems.push(`public.view.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.`);
|
|
1023
|
-
}
|
|
1024
|
-
return problems;
|
|
1302
|
+
return normalized.views.flatMap((view) => [...viewPathProblems(view), ...view.collections.flatMap((cid) => viewCollectionProblems(app, view, cid, known))]);
|
|
1025
1303
|
}
|
|
1026
1304
|
/** What publish will actually promote, checked as the PAIR it becomes.
|
|
1027
1305
|
*
|
|
@@ -1053,9 +1331,25 @@ function promotedRoleProblems(app, staged) {
|
|
|
1053
1331
|
return [
|
|
1054
1332
|
...promotedAssigneeProblems(app, promoted, stagedCids),
|
|
1055
1333
|
...promotedMirrorProblems(app, promoted, stagedCids),
|
|
1056
|
-
...promotedRefFieldProblems(app, staged)
|
|
1334
|
+
...promotedRefFieldProblems(app, staged),
|
|
1335
|
+
...promotedParticipantViewProblems(app, staged)
|
|
1057
1336
|
];
|
|
1058
1337
|
}
|
|
1338
|
+
/** A participant's page, checked against the `participantRead` publish will
|
|
1339
|
+
* actually PROMOTE.
|
|
1340
|
+
*
|
|
1341
|
+
* Not against the manifest's. `projectPublish` overwrites `participantRead`
|
|
1342
|
+
* with what the staged schemas carry, so a cid added to the manifest since the
|
|
1343
|
+
* last deploy is not in the rules — and a page written for it would be
|
|
1344
|
+
* published, offered, and then refused the read. The manifest half of this
|
|
1345
|
+
* file cannot see that; the promoted half can, which is why the check lives
|
|
1346
|
+
* here rather than beside the other view checks. */
|
|
1347
|
+
function promotedParticipantViewProblems(app, staged) {
|
|
1348
|
+
const normalized = normalizeViews(app);
|
|
1349
|
+
if (!normalized.ok) return [];
|
|
1350
|
+
const participantRead = stagedRuleConfig(staged).participantRead ?? [];
|
|
1351
|
+
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.)`));
|
|
1352
|
+
}
|
|
1059
1353
|
/** The FIELDS a rule reads off another record — `idIn.where.field` and the two
|
|
1060
1354
|
* window bounds — checked against the schema publish is about to promote.
|
|
1061
1355
|
*
|
|
@@ -3314,12 +3608,48 @@ Object.defineProperty(exports, "PUBLIC_CONFIG_DOC", {
|
|
|
3314
3608
|
return PUBLIC_CONFIG_DOC;
|
|
3315
3609
|
}
|
|
3316
3610
|
});
|
|
3611
|
+
Object.defineProperty(exports, "PUBLIC_VIEW_ID", {
|
|
3612
|
+
enumerable: true,
|
|
3613
|
+
get: function() {
|
|
3614
|
+
return PUBLIC_VIEW_ID;
|
|
3615
|
+
}
|
|
3616
|
+
});
|
|
3617
|
+
Object.defineProperty(exports, "RESERVED_VIEW_IDS", {
|
|
3618
|
+
enumerable: true,
|
|
3619
|
+
get: function() {
|
|
3620
|
+
return RESERVED_VIEW_IDS;
|
|
3621
|
+
}
|
|
3622
|
+
});
|
|
3317
3623
|
Object.defineProperty(exports, "STORE_UNREADABLE", {
|
|
3318
3624
|
enumerable: true,
|
|
3319
3625
|
get: function() {
|
|
3320
3626
|
return STORE_UNREADABLE;
|
|
3321
3627
|
}
|
|
3322
3628
|
});
|
|
3629
|
+
Object.defineProperty(exports, "VIEW_AUDIENCES", {
|
|
3630
|
+
enumerable: true,
|
|
3631
|
+
get: function() {
|
|
3632
|
+
return VIEW_AUDIENCES;
|
|
3633
|
+
}
|
|
3634
|
+
});
|
|
3635
|
+
Object.defineProperty(exports, "VIEW_CONFIG_ID", {
|
|
3636
|
+
enumerable: true,
|
|
3637
|
+
get: function() {
|
|
3638
|
+
return VIEW_CONFIG_ID;
|
|
3639
|
+
}
|
|
3640
|
+
});
|
|
3641
|
+
Object.defineProperty(exports, "VIEW_ID_PATTERN", {
|
|
3642
|
+
enumerable: true,
|
|
3643
|
+
get: function() {
|
|
3644
|
+
return VIEW_ID_PATTERN;
|
|
3645
|
+
}
|
|
3646
|
+
});
|
|
3647
|
+
Object.defineProperty(exports, "VIEW_TIER", {
|
|
3648
|
+
enumerable: true,
|
|
3649
|
+
get: function() {
|
|
3650
|
+
return VIEW_TIER;
|
|
3651
|
+
}
|
|
3652
|
+
});
|
|
3323
3653
|
Object.defineProperty(exports, "advanceTriggerDate", {
|
|
3324
3654
|
enumerable: true,
|
|
3325
3655
|
get: function() {
|
|
@@ -3350,6 +3680,12 @@ Object.defineProperty(exports, "appStagingPath", {
|
|
|
3350
3680
|
return appStagingPath;
|
|
3351
3681
|
}
|
|
3352
3682
|
});
|
|
3683
|
+
Object.defineProperty(exports, "appViewTierPath", {
|
|
3684
|
+
enumerable: true,
|
|
3685
|
+
get: function() {
|
|
3686
|
+
return appViewTierPath;
|
|
3687
|
+
}
|
|
3688
|
+
});
|
|
3353
3689
|
Object.defineProperty(exports, "applyMutateAction", {
|
|
3354
3690
|
enumerable: true,
|
|
3355
3691
|
get: function() {
|
|
@@ -3458,6 +3794,12 @@ Object.defineProperty(exports, "maybeSpawnSuccessor", {
|
|
|
3458
3794
|
return maybeSpawnSuccessor;
|
|
3459
3795
|
}
|
|
3460
3796
|
});
|
|
3797
|
+
Object.defineProperty(exports, "normalizeViews", {
|
|
3798
|
+
enumerable: true,
|
|
3799
|
+
get: function() {
|
|
3800
|
+
return normalizeViews;
|
|
3801
|
+
}
|
|
3802
|
+
});
|
|
3461
3803
|
Object.defineProperty(exports, "parseAuthoredApp", {
|
|
3462
3804
|
enumerable: true,
|
|
3463
3805
|
get: function() {
|
|
@@ -3470,12 +3812,24 @@ Object.defineProperty(exports, "parseCivil", {
|
|
|
3470
3812
|
return parseCivil;
|
|
3471
3813
|
}
|
|
3472
3814
|
});
|
|
3815
|
+
Object.defineProperty(exports, "participantScope", {
|
|
3816
|
+
enumerable: true,
|
|
3817
|
+
get: function() {
|
|
3818
|
+
return participantScope;
|
|
3819
|
+
}
|
|
3820
|
+
});
|
|
3473
3821
|
Object.defineProperty(exports, "projectApp", {
|
|
3474
3822
|
enumerable: true,
|
|
3475
3823
|
get: function() {
|
|
3476
3824
|
return projectApp;
|
|
3477
3825
|
}
|
|
3478
3826
|
});
|
|
3827
|
+
Object.defineProperty(exports, "projectAppViews", {
|
|
3828
|
+
enumerable: true,
|
|
3829
|
+
get: function() {
|
|
3830
|
+
return projectAppViews;
|
|
3831
|
+
}
|
|
3832
|
+
});
|
|
3479
3833
|
Object.defineProperty(exports, "projectDeploy", {
|
|
3480
3834
|
enumerable: true,
|
|
3481
3835
|
get: function() {
|
|
@@ -3584,5 +3938,17 @@ Object.defineProperty(exports, "validateRecordObject", {
|
|
|
3584
3938
|
return validateRecordObject;
|
|
3585
3939
|
}
|
|
3586
3940
|
});
|
|
3941
|
+
Object.defineProperty(exports, "viewConfigDocId", {
|
|
3942
|
+
enumerable: true,
|
|
3943
|
+
get: function() {
|
|
3944
|
+
return viewConfigDocId;
|
|
3945
|
+
}
|
|
3946
|
+
});
|
|
3947
|
+
Object.defineProperty(exports, "viewDocId", {
|
|
3948
|
+
enumerable: true,
|
|
3949
|
+
get: function() {
|
|
3950
|
+
return viewDocId;
|
|
3951
|
+
}
|
|
3952
|
+
});
|
|
3587
3953
|
|
|
3588
|
-
//# sourceMappingURL=server-
|
|
3954
|
+
//# sourceMappingURL=server-DknYbXBo.cjs.map
|