@kernhq/module-quire 0.11.1 → 0.13.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.
Files changed (52) hide show
  1. package/dist/contract/models.d.ts +46 -0
  2. package/dist/contract/models.d.ts.map +1 -1
  3. package/dist/contract/models.js +73 -0
  4. package/dist/contract/models.js.map +1 -1
  5. package/dist/contract/permissions.d.ts +17 -1
  6. package/dist/contract/permissions.d.ts.map +1 -1
  7. package/dist/contract/permissions.js +35 -0
  8. package/dist/contract/permissions.js.map +1 -1
  9. package/dist/contract/router.d.ts +756 -0
  10. package/dist/contract/router.d.ts.map +1 -1
  11. package/dist/contract/router.js +346 -2
  12. package/dist/contract/router.js.map +1 -1
  13. package/dist/server/_impl.d.ts +826 -0
  14. package/dist/server/_impl.d.ts.map +1 -1
  15. package/dist/server/_impl.js +336 -2
  16. package/dist/server/_impl.js.map +1 -1
  17. package/dist/server/schema.d.ts +318 -1
  18. package/dist/server/schema.d.ts.map +1 -1
  19. package/dist/server/schema.js +86 -0
  20. package/dist/server/schema.js.map +1 -1
  21. package/dist/server/services/access.d.ts +1 -0
  22. package/dist/server/services/access.d.ts.map +1 -1
  23. package/dist/server/services/index.d.ts +3 -0
  24. package/dist/server/services/index.d.ts.map +1 -1
  25. package/dist/server/services/index.js +5 -1
  26. package/dist/server/services/index.js.map +1 -1
  27. package/dist/server/services/pages.d.ts.map +1 -1
  28. package/dist/server/services/pages.js +6 -0
  29. package/dist/server/services/pages.js.map +1 -1
  30. package/dist/server/services/publications.d.ts +191 -0
  31. package/dist/server/services/publications.d.ts.map +1 -0
  32. package/dist/server/services/publications.js +772 -0
  33. package/dist/server/services/publications.js.map +1 -0
  34. package/dist/server/services/versions.d.ts +26 -1
  35. package/dist/server/services/versions.d.ts.map +1 -1
  36. package/dist/server/services/versions.js +44 -15
  37. package/dist/server/services/versions.js.map +1 -1
  38. package/migrations/0008_publications.sql +140 -0
  39. package/migrations/0009_public_asset_references.sql +35 -0
  40. package/migrations/meta/_journal.json +14 -0
  41. package/package.json +1 -1
  42. package/src/client/components/PublishDialog.svelte +920 -0
  43. package/src/client/components/SidebarRecents.svelte +17 -1
  44. package/src/client/i18n.ts +448 -0
  45. package/src/client/index.ts +21 -0
  46. package/src/client/mock.ts +436 -2
  47. package/src/client/pages/PageView.svelte +139 -0
  48. package/src/client/public-url.ts +76 -0
  49. package/src/client/query.ts +16 -0
  50. package/src/contract/models.ts +77 -0
  51. package/src/contract/permissions.ts +54 -1
  52. package/src/contract/router.ts +380 -1
@@ -51,6 +51,155 @@ export declare const WatchState: z.ZodObject<{
51
51
  watchers: z.ZodArray<z.core.$ZodBranded<z.ZodUUID, "UserId", "out">>;
52
52
  }, z.core.$strip>;
53
53
  export type WatchState = z.infer<typeof WatchState>;
54
+ /**
55
+ * A published site addresses its pages by **path, never by id**, and that is a security decision
56
+ * rather than a matter of taste.
57
+ *
58
+ * Every id in a public response is a string somebody can try somewhere else, and the only way to be
59
+ * sure none of them opens a door is for there to be none. So the whole `public.*` surface below
60
+ * carries no page id, no space id, no version id, no user id and no workspace id — a nav entry, a
61
+ * breadcrumb, a search hit and a sitemap line are all `path`, and `path` is built from titles by the
62
+ * server. `publications.int.test.ts` walks every public response and fails on any uuid belonging to
63
+ * anything in the fixture, which is what keeps this true as the shapes grow.
64
+ *
65
+ * The root page's path is the empty string; a child's is its ancestors' slugs joined with `/`, each
66
+ * slug being its title reduced to letters, digits and dashes (Unicode letters, so a Persian title
67
+ * keeps a Persian slug) and suffixed `-2`, `-3` when two siblings would collide.
68
+ */
69
+ export declare const PublicNavEntry: z.ZodObject<{
70
+ path: z.ZodString;
71
+ parentPath: z.ZodNullable<z.ZodString>;
72
+ title: z.ZodString;
73
+ icon: z.ZodNullable<z.ZodString>;
74
+ }, z.core.$strip>;
75
+ export type PublicNavEntry = z.infer<typeof PublicNavEntry>;
76
+ /** What is worth saying about a published site once a reader is allowed to see it. */
77
+ export declare const PublicSiteDetail: z.ZodObject<{
78
+ title: z.ZodString;
79
+ description: z.ZodString;
80
+ ogImageUrl: z.ZodNullable<z.ZodString>;
81
+ indexable: z.ZodBoolean;
82
+ updatedAt: z.ZodISODateTime;
83
+ nav: z.ZodArray<z.ZodObject<{
84
+ path: z.ZodString;
85
+ parentPath: z.ZodNullable<z.ZodString>;
86
+ title: z.ZodString;
87
+ icon: z.ZodNullable<z.ZodString>;
88
+ }, z.core.$strip>>;
89
+ }, z.core.$strip>;
90
+ export type PublicSiteDetail = z.infer<typeof PublicSiteDetail>;
91
+ /**
92
+ * A published site, or the door to it.
93
+ *
94
+ * `locked` is the one thing a password-protected site admits before the password: that there is a
95
+ * door. Everything else — the title, the description, the shape of the tree — is behind it, because
96
+ * a nav tree is a table of contents and a table of contents is most of what a private handbook is.
97
+ * `theme` comes out anyway so the challenge screen is not white on a site that is not.
98
+ */
99
+ export declare const PublicSite: z.ZodObject<{
100
+ slug: z.ZodString;
101
+ theme: z.ZodEnum<{
102
+ auto: "auto";
103
+ light: "light";
104
+ dark: "dark";
105
+ }>;
106
+ locked: z.ZodBoolean;
107
+ site: z.ZodNullable<z.ZodObject<{
108
+ title: z.ZodString;
109
+ description: z.ZodString;
110
+ ogImageUrl: z.ZodNullable<z.ZodString>;
111
+ indexable: z.ZodBoolean;
112
+ updatedAt: z.ZodISODateTime;
113
+ nav: z.ZodArray<z.ZodObject<{
114
+ path: z.ZodString;
115
+ parentPath: z.ZodNullable<z.ZodString>;
116
+ title: z.ZodString;
117
+ icon: z.ZodNullable<z.ZodString>;
118
+ }, z.core.$strip>>;
119
+ }, z.core.$strip>>;
120
+ }, z.core.$strip>;
121
+ export type PublicSite = z.infer<typeof PublicSite>;
122
+ export declare const PublicBreadcrumb: z.ZodObject<{
123
+ path: z.ZodString;
124
+ title: z.ZodString;
125
+ }, z.core.$strip>;
126
+ export type PublicBreadcrumb = z.infer<typeof PublicBreadcrumb>;
127
+ export declare const PublicPage: z.ZodObject<{
128
+ path: z.ZodString;
129
+ title: z.ZodString;
130
+ icon: z.ZodNullable<z.ZodString>;
131
+ coverUrl: z.ZodNullable<z.ZodString>;
132
+ html: z.ZodString;
133
+ publishedAt: z.ZodISODateTime;
134
+ etag: z.ZodString;
135
+ breadcrumbs: z.ZodArray<z.ZodObject<{
136
+ path: z.ZodString;
137
+ title: z.ZodString;
138
+ }, z.core.$strip>>;
139
+ }, z.core.$strip>;
140
+ export type PublicPage = z.infer<typeof PublicPage>;
141
+ export declare const PublicSearchHit: z.ZodObject<{
142
+ path: z.ZodString;
143
+ title: z.ZodString;
144
+ snippet: z.ZodString;
145
+ }, z.core.$strip>;
146
+ export type PublicSearchHit = z.infer<typeof PublicSearchHit>;
147
+ export declare const PublicSitemapEntry: z.ZodObject<{
148
+ path: z.ZodString;
149
+ lastModified: z.ZodISODateTime;
150
+ }, z.core.$strip>;
151
+ /**
152
+ * One picture from a published page, **as bytes rather than as an address**.
153
+ *
154
+ * A published page used to carry its pictures as presigned storage URLs, written into the stored
155
+ * HTML at publish time. That was wrong twice over, and both halves were measured rather than
156
+ * argued. The URL is the storage key — `ws/<workspaceId>/<module>/<yyyy>/<mm>/<fileId>/<name>` —
157
+ * so every published page with a picture on it handed a stranger the tenant's workspace uuid and a
158
+ * file uuid, on the one surface whose whole rule is that no response carries an id; and a presigned
159
+ * GET expires in an hour while the HTML it was baked into is rendered once and stored for ever, so
160
+ * every image on every published site broke sixty minutes after it was published.
161
+ *
162
+ * So the HTML carries an opaque, workspace-sealed reference and the bytes come through here. The
163
+ * route layer fetches this from **its own server** and streams the body back under a URL of its
164
+ * own; nothing in the answer may reach a browser as-is, which is why it is bytes and not a link —
165
+ * there is no address in it to leak, and none to expire.
166
+ *
167
+ * Capped rather than streamed on purpose: a published handbook's illustration is tens of kilobytes,
168
+ * this path is anonymous, and an unbounded body on an unauthenticated endpoint is a way to spend
169
+ * somebody else's memory. Over the cap answers the same 404 as a picture that is not there.
170
+ */
171
+ export declare const PublicAsset: z.ZodObject<{
172
+ contentType: z.ZodString;
173
+ bytes: z.ZodString;
174
+ maxAge: z.ZodNumber;
175
+ }, z.core.$strip>;
176
+ export type PublicAsset = z.infer<typeof PublicAsset>;
177
+ /**
178
+ * The URL prefix the route layer serves this site under, so a link between two published pages is a
179
+ * link and not a dead mention.
180
+ *
181
+ * The module knows a page's path inside its publication and nothing about the address it is served
182
+ * at — one instance mounts a site at `/p/<workspace>/<slug>/`, another at the root of its own
183
+ * domain. Rather than guess, it takes the prefix and refuses anything that is not one: it has to
184
+ * start and end with `/`, and its segments are unreserved characters only. That refusal is the
185
+ * point. `//evil.example/` is a protocol-relative URL wearing the costume of a local path, and a
186
+ * caller that could set it would have every link on somebody's published site point off-site.
187
+ */
188
+ export declare const PublicBasePath: z.ZodDefault<z.ZodString>;
189
+ /**
190
+ * The one thing the module does ask of whatever serves a published site: a place for its pictures.
191
+ *
192
+ * `public.page` writes every `<img src>` as `<basePath><segment>/<reference>`, so the route layer
193
+ * has to answer that address by calling `public.asset` and streaming the bytes back. It is a
194
+ * constant rather than a convention because two sides have to agree on it and only one of them can
195
+ * be wrong quietly — a route layer that does not serve it renders a published page with no
196
+ * pictures, which looks like a rendering bug and is a missing route.
197
+ *
198
+ * The leading `__` is what keeps it out of the way: a page's own path segment is `slugifyTitle`'s
199
+ * output, which is Unicode letters and digits separated by hyphens, so no title can ever produce a
200
+ * segment starting with an underscore and no published page can be shadowed by this one.
201
+ */
202
+ export declare const PUBLIC_ASSET_SEGMENT = "__media";
54
203
  export declare const quireContract: {
55
204
  readonly spaces: {
56
205
  readonly list: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
@@ -309,6 +458,8 @@ export declare const quireContract: {
309
458
  icon: z.ZodNullable<z.ZodString>;
310
459
  hasChildren: z.ZodBoolean;
311
460
  archivedAt: z.ZodNullable<z.ZodISODateTime>;
461
+ excludedFromPublic: z.ZodDefault<z.ZodBoolean>;
462
+ hasPublishedVersion: z.ZodDefault<z.ZodBoolean>;
312
463
  }, z.core.$strip>>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
313
464
  BAD_REQUEST: {
314
465
  data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
@@ -3350,6 +3501,611 @@ export declare const quireContract: {
3350
3501
  };
3351
3502
  }>, Record<never, never>>;
3352
3503
  };
3504
+ /**
3505
+ * Who has published what, from the inside. Every procedure here is authenticated and asks
3506
+ * `quire.page.publish` about the **root page**, because that is the page whose subtree is being
3507
+ * handed to the internet.
3508
+ */
3509
+ readonly publications: {
3510
+ readonly list: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3511
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
3512
+ spaceId: z.ZodUUID;
3513
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
3514
+ id: z.ZodUUID;
3515
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
3516
+ rootPageId: z.ZodUUID;
3517
+ includeDescendants: z.ZodBoolean;
3518
+ slug: z.ZodString;
3519
+ hasPassword: z.ZodBoolean;
3520
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
3521
+ seoTitle: z.ZodString;
3522
+ seoDescription: z.ZodString;
3523
+ ogImageUrl: z.ZodNullable<z.ZodString>;
3524
+ indexable: z.ZodBoolean;
3525
+ theme: z.ZodEnum<{
3526
+ auto: "auto";
3527
+ light: "light";
3528
+ dark: "dark";
3529
+ }>;
3530
+ createdBy: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UserId", "out">>;
3531
+ createdAt: z.ZodISODateTime;
3532
+ updatedAt: z.ZodISODateTime;
3533
+ }, z.core.$strip>>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
3534
+ BAD_REQUEST: {
3535
+ data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
3536
+ };
3537
+ UNAUTHORIZED: {};
3538
+ FORBIDDEN: {
3539
+ data: z.ZodOptional<z.ZodObject<{
3540
+ permission: z.ZodOptional<z.ZodString>;
3541
+ }, z.core.$strip>>;
3542
+ };
3543
+ NOT_FOUND: {};
3544
+ CONFLICT: {
3545
+ data: z.ZodOptional<z.ZodObject<{
3546
+ reason: z.ZodOptional<z.ZodString>;
3547
+ }, z.core.$strip>>;
3548
+ };
3549
+ RATE_LIMITED: {};
3550
+ MODULE_DISABLED: {
3551
+ data: z.ZodObject<{
3552
+ module: z.ZodString;
3553
+ }, z.core.$strip>;
3554
+ };
3555
+ }>, Record<never, never>>;
3556
+ readonly get: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3557
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
3558
+ publicationId: z.ZodUUID;
3559
+ }, z.core.$strip>, z.ZodObject<{
3560
+ id: z.ZodUUID;
3561
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
3562
+ rootPageId: z.ZodUUID;
3563
+ includeDescendants: z.ZodBoolean;
3564
+ slug: z.ZodString;
3565
+ hasPassword: z.ZodBoolean;
3566
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
3567
+ seoTitle: z.ZodString;
3568
+ seoDescription: z.ZodString;
3569
+ ogImageUrl: z.ZodNullable<z.ZodString>;
3570
+ indexable: z.ZodBoolean;
3571
+ theme: z.ZodEnum<{
3572
+ auto: "auto";
3573
+ light: "light";
3574
+ dark: "dark";
3575
+ }>;
3576
+ createdBy: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UserId", "out">>;
3577
+ createdAt: z.ZodISODateTime;
3578
+ updatedAt: z.ZodISODateTime;
3579
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
3580
+ BAD_REQUEST: {
3581
+ data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
3582
+ };
3583
+ UNAUTHORIZED: {};
3584
+ FORBIDDEN: {
3585
+ data: z.ZodOptional<z.ZodObject<{
3586
+ permission: z.ZodOptional<z.ZodString>;
3587
+ }, z.core.$strip>>;
3588
+ };
3589
+ NOT_FOUND: {};
3590
+ CONFLICT: {
3591
+ data: z.ZodOptional<z.ZodObject<{
3592
+ reason: z.ZodOptional<z.ZodString>;
3593
+ }, z.core.$strip>>;
3594
+ };
3595
+ RATE_LIMITED: {};
3596
+ MODULE_DISABLED: {
3597
+ data: z.ZodObject<{
3598
+ module: z.ZodString;
3599
+ }, z.core.$strip>;
3600
+ };
3601
+ }>, Record<never, never>>;
3602
+ readonly create: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3603
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
3604
+ rootPageId: z.ZodUUID;
3605
+ slug: z.ZodString;
3606
+ includeDescendants: z.ZodDefault<z.ZodBoolean>;
3607
+ password: z.ZodDefault<z.ZodNullable<z.ZodString>>;
3608
+ expiresAt: z.ZodDefault<z.ZodNullable<z.ZodISODateTime>>;
3609
+ seoTitle: z.ZodDefault<z.ZodString>;
3610
+ seoDescription: z.ZodDefault<z.ZodString>;
3611
+ ogImageUrl: z.ZodDefault<z.ZodNullable<z.ZodString>>;
3612
+ indexable: z.ZodDefault<z.ZodBoolean>;
3613
+ theme: z.ZodDefault<z.ZodEnum<{
3614
+ auto: "auto";
3615
+ light: "light";
3616
+ dark: "dark";
3617
+ }>>;
3618
+ }, z.core.$strip>, z.ZodObject<{
3619
+ id: z.ZodUUID;
3620
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
3621
+ rootPageId: z.ZodUUID;
3622
+ includeDescendants: z.ZodBoolean;
3623
+ slug: z.ZodString;
3624
+ hasPassword: z.ZodBoolean;
3625
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
3626
+ seoTitle: z.ZodString;
3627
+ seoDescription: z.ZodString;
3628
+ ogImageUrl: z.ZodNullable<z.ZodString>;
3629
+ indexable: z.ZodBoolean;
3630
+ theme: z.ZodEnum<{
3631
+ auto: "auto";
3632
+ light: "light";
3633
+ dark: "dark";
3634
+ }>;
3635
+ createdBy: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UserId", "out">>;
3636
+ createdAt: z.ZodISODateTime;
3637
+ updatedAt: z.ZodISODateTime;
3638
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
3639
+ BAD_REQUEST: {
3640
+ data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
3641
+ };
3642
+ UNAUTHORIZED: {};
3643
+ FORBIDDEN: {
3644
+ data: z.ZodOptional<z.ZodObject<{
3645
+ permission: z.ZodOptional<z.ZodString>;
3646
+ }, z.core.$strip>>;
3647
+ };
3648
+ NOT_FOUND: {};
3649
+ CONFLICT: {
3650
+ data: z.ZodOptional<z.ZodObject<{
3651
+ reason: z.ZodOptional<z.ZodString>;
3652
+ }, z.core.$strip>>;
3653
+ };
3654
+ RATE_LIMITED: {};
3655
+ MODULE_DISABLED: {
3656
+ data: z.ZodObject<{
3657
+ module: z.ZodString;
3658
+ }, z.core.$strip>;
3659
+ };
3660
+ }>, Record<never, never>>;
3661
+ /**
3662
+ * `password` is three-valued on purpose: a string sets one, `null` removes it, and leaving the
3663
+ * key out changes nothing. A two-valued field would make every "rename the site" request also
3664
+ * an "unlock the site" request, which is the shape that quietly takes the door off a handbook.
3665
+ */
3666
+ readonly update: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3667
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
3668
+ publicationId: z.ZodUUID;
3669
+ slug: z.ZodOptional<z.ZodString>;
3670
+ includeDescendants: z.ZodOptional<z.ZodBoolean>;
3671
+ password: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3672
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
3673
+ seoTitle: z.ZodOptional<z.ZodString>;
3674
+ seoDescription: z.ZodOptional<z.ZodString>;
3675
+ ogImageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3676
+ indexable: z.ZodOptional<z.ZodBoolean>;
3677
+ theme: z.ZodOptional<z.ZodEnum<{
3678
+ auto: "auto";
3679
+ light: "light";
3680
+ dark: "dark";
3681
+ }>>;
3682
+ }, z.core.$strip>, z.ZodObject<{
3683
+ id: z.ZodUUID;
3684
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
3685
+ rootPageId: z.ZodUUID;
3686
+ includeDescendants: z.ZodBoolean;
3687
+ slug: z.ZodString;
3688
+ hasPassword: z.ZodBoolean;
3689
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
3690
+ seoTitle: z.ZodString;
3691
+ seoDescription: z.ZodString;
3692
+ ogImageUrl: z.ZodNullable<z.ZodString>;
3693
+ indexable: z.ZodBoolean;
3694
+ theme: z.ZodEnum<{
3695
+ auto: "auto";
3696
+ light: "light";
3697
+ dark: "dark";
3698
+ }>;
3699
+ createdBy: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UserId", "out">>;
3700
+ createdAt: z.ZodISODateTime;
3701
+ updatedAt: z.ZodISODateTime;
3702
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
3703
+ BAD_REQUEST: {
3704
+ data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
3705
+ };
3706
+ UNAUTHORIZED: {};
3707
+ FORBIDDEN: {
3708
+ data: z.ZodOptional<z.ZodObject<{
3709
+ permission: z.ZodOptional<z.ZodString>;
3710
+ }, z.core.$strip>>;
3711
+ };
3712
+ NOT_FOUND: {};
3713
+ CONFLICT: {
3714
+ data: z.ZodOptional<z.ZodObject<{
3715
+ reason: z.ZodOptional<z.ZodString>;
3716
+ }, z.core.$strip>>;
3717
+ };
3718
+ RATE_LIMITED: {};
3719
+ MODULE_DISABLED: {
3720
+ data: z.ZodObject<{
3721
+ module: z.ZodString;
3722
+ }, z.core.$strip>;
3723
+ };
3724
+ }>, Record<never, never>>;
3725
+ /** The row is the grant, so removing it takes the site down. Nothing else is deleted. */
3726
+ readonly remove: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3727
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
3728
+ publicationId: z.ZodUUID;
3729
+ }, z.core.$strip>, z.ZodObject<{
3730
+ ok: z.ZodLiteral<true>;
3731
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
3732
+ BAD_REQUEST: {
3733
+ data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
3734
+ };
3735
+ UNAUTHORIZED: {};
3736
+ FORBIDDEN: {
3737
+ data: z.ZodOptional<z.ZodObject<{
3738
+ permission: z.ZodOptional<z.ZodString>;
3739
+ }, z.core.$strip>>;
3740
+ };
3741
+ NOT_FOUND: {};
3742
+ CONFLICT: {
3743
+ data: z.ZodOptional<z.ZodObject<{
3744
+ reason: z.ZodOptional<z.ZodString>;
3745
+ }, z.core.$strip>>;
3746
+ };
3747
+ RATE_LIMITED: {};
3748
+ MODULE_DISABLED: {
3749
+ data: z.ZodObject<{
3750
+ module: z.ZodString;
3751
+ }, z.core.$strip>;
3752
+ };
3753
+ }>, Record<never, never>>;
3754
+ /**
3755
+ * Keep one page — and therefore everything under it — out of every publication, present and
3756
+ * future.
3757
+ *
3758
+ * Absolute rather than per-publication, and that is the whole reason it is a flag on the page:
3759
+ * an opt-out recorded against one publication says nothing about a publication somebody roots
3760
+ * above the page next month, and its author would never see it. This one holds against
3761
+ * publications that do not exist yet.
3762
+ */
3763
+ readonly optOut: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3764
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
3765
+ pageId: z.ZodUUID;
3766
+ excluded: z.ZodDefault<z.ZodBoolean>;
3767
+ }, z.core.$strip>, z.ZodObject<{
3768
+ pageId: z.ZodUUID;
3769
+ excluded: z.ZodBoolean;
3770
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
3771
+ BAD_REQUEST: {
3772
+ data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
3773
+ };
3774
+ UNAUTHORIZED: {};
3775
+ FORBIDDEN: {
3776
+ data: z.ZodOptional<z.ZodObject<{
3777
+ permission: z.ZodOptional<z.ZodString>;
3778
+ }, z.core.$strip>>;
3779
+ };
3780
+ NOT_FOUND: {};
3781
+ CONFLICT: {
3782
+ data: z.ZodOptional<z.ZodObject<{
3783
+ reason: z.ZodOptional<z.ZodString>;
3784
+ }, z.core.$strip>>;
3785
+ };
3786
+ RATE_LIMITED: {};
3787
+ MODULE_DISABLED: {
3788
+ data: z.ZodObject<{
3789
+ module: z.ZodString;
3790
+ }, z.core.$strip>;
3791
+ };
3792
+ }>, Record<never, never>>;
3793
+ };
3794
+ /**
3795
+ * The signed-out surface. **This is the only part of Kern with no principal behind it.**
3796
+ *
3797
+ * Five rules hold here, and each of them is a test in `publications.int.test.ts`:
3798
+ *
3799
+ * 1. A page is public only if it is inside the publication's subtree, not opted out, not
3800
+ * archived, not trashed, and has a published version that has been rendered. Failing any one
3801
+ * of those is **404, never 403** — a refusal that distinguishes "not yours" from "not there"
3802
+ * confirms the page exists to whoever is guessing.
3803
+ * 2. Guessing a sibling, a parent, a page in another space or another workspace gets 404 too,
3804
+ * which is free here because nothing is addressed by id: `path` names a place in *this*
3805
+ * publication's tree or it names nothing.
3806
+ * 3. No response carries a draft, a comment, an author, a version list, or any id.
3807
+ * 4. A password-protected publication answers a challenge and nothing else. `unlock` mints a
3808
+ * **capability token, not a session**: an AES-GCM envelope sealed with the instance secret,
3809
+ * bound by its associated data to this one publication, carrying an expiry and no identity.
3810
+ * The server keeps nothing. The route layer is expected to hold it in an HttpOnly cookie and
3811
+ * pass it back — never to put it in a link, because a token in a URL is a token in a referrer
3812
+ * header and in somebody's access log.
3813
+ * 5. An expired publication is 404, checked on the request rather than by a sweep.
3814
+ *
3815
+ * `workspaceId` is in the path because *anonymous means no principal, not no tenant*: the request
3816
+ * has to name a workspace before anything touches `mod_quire`, or row-level security has nothing
3817
+ * to fence with. See the note at the top of `migrations/0008_publications.sql`.
3818
+ */
3819
+ readonly public: {
3820
+ readonly site: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3821
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
3822
+ slug: z.ZodString;
3823
+ token: z.ZodDefault<z.ZodNullable<z.ZodString>>;
3824
+ }, z.core.$strip>, z.ZodObject<{
3825
+ slug: z.ZodString;
3826
+ theme: z.ZodEnum<{
3827
+ auto: "auto";
3828
+ light: "light";
3829
+ dark: "dark";
3830
+ }>;
3831
+ locked: z.ZodBoolean;
3832
+ site: z.ZodNullable<z.ZodObject<{
3833
+ title: z.ZodString;
3834
+ description: z.ZodString;
3835
+ ogImageUrl: z.ZodNullable<z.ZodString>;
3836
+ indexable: z.ZodBoolean;
3837
+ updatedAt: z.ZodISODateTime;
3838
+ nav: z.ZodArray<z.ZodObject<{
3839
+ path: z.ZodString;
3840
+ parentPath: z.ZodNullable<z.ZodString>;
3841
+ title: z.ZodString;
3842
+ icon: z.ZodNullable<z.ZodString>;
3843
+ }, z.core.$strip>>;
3844
+ }, z.core.$strip>>;
3845
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
3846
+ BAD_REQUEST: {
3847
+ data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
3848
+ };
3849
+ UNAUTHORIZED: {};
3850
+ FORBIDDEN: {
3851
+ data: z.ZodOptional<z.ZodObject<{
3852
+ permission: z.ZodOptional<z.ZodString>;
3853
+ }, z.core.$strip>>;
3854
+ };
3855
+ NOT_FOUND: {};
3856
+ CONFLICT: {
3857
+ data: z.ZodOptional<z.ZodObject<{
3858
+ reason: z.ZodOptional<z.ZodString>;
3859
+ }, z.core.$strip>>;
3860
+ };
3861
+ RATE_LIMITED: {};
3862
+ MODULE_DISABLED: {
3863
+ data: z.ZodObject<{
3864
+ module: z.ZodString;
3865
+ }, z.core.$strip>;
3866
+ };
3867
+ }>, Record<never, never>>;
3868
+ /**
3869
+ * One page of a published site.
3870
+ *
3871
+ * `path` is a query parameter rather than a path segment because it contains slashes: a nested
3872
+ * page's address is `guide/install`, and oRPC's route matcher takes one segment per parameter.
3873
+ */
3874
+ readonly page: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3875
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
3876
+ slug: z.ZodString;
3877
+ path: z.ZodDefault<z.ZodString>;
3878
+ basePath: z.ZodDefault<z.ZodString>;
3879
+ token: z.ZodDefault<z.ZodNullable<z.ZodString>>;
3880
+ }, z.core.$strip>, z.ZodObject<{
3881
+ path: z.ZodString;
3882
+ title: z.ZodString;
3883
+ icon: z.ZodNullable<z.ZodString>;
3884
+ coverUrl: z.ZodNullable<z.ZodString>;
3885
+ html: z.ZodString;
3886
+ publishedAt: z.ZodISODateTime;
3887
+ etag: z.ZodString;
3888
+ breadcrumbs: z.ZodArray<z.ZodObject<{
3889
+ path: z.ZodString;
3890
+ title: z.ZodString;
3891
+ }, z.core.$strip>>;
3892
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
3893
+ BAD_REQUEST: {
3894
+ data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
3895
+ };
3896
+ UNAUTHORIZED: {};
3897
+ FORBIDDEN: {
3898
+ data: z.ZodOptional<z.ZodObject<{
3899
+ permission: z.ZodOptional<z.ZodString>;
3900
+ }, z.core.$strip>>;
3901
+ };
3902
+ NOT_FOUND: {};
3903
+ CONFLICT: {
3904
+ data: z.ZodOptional<z.ZodObject<{
3905
+ reason: z.ZodOptional<z.ZodString>;
3906
+ }, z.core.$strip>>;
3907
+ };
3908
+ RATE_LIMITED: {};
3909
+ MODULE_DISABLED: {
3910
+ data: z.ZodObject<{
3911
+ module: z.ZodString;
3912
+ }, z.core.$strip>;
3913
+ };
3914
+ }>, Record<never, never>>;
3915
+ /**
3916
+ * Search inside this publication and nowhere else.
3917
+ *
3918
+ * It reads the **published version's** flattened text, not `pages.text`. That column mirrors the
3919
+ * live document, so searching it would put a sentence somebody has not published yet into a
3920
+ * snippet on the public internet — the one place in this module where the draft and the
3921
+ * published copy differ and the difference is the whole point.
3922
+ */
3923
+ readonly search: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3924
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
3925
+ slug: z.ZodString;
3926
+ q: z.ZodString;
3927
+ limit: z.ZodDefault<z.ZodNumber>;
3928
+ token: z.ZodDefault<z.ZodNullable<z.ZodString>>;
3929
+ }, z.core.$strip>, z.ZodObject<{
3930
+ items: z.ZodArray<z.ZodObject<{
3931
+ path: z.ZodString;
3932
+ title: z.ZodString;
3933
+ snippet: z.ZodString;
3934
+ }, z.core.$strip>>;
3935
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
3936
+ BAD_REQUEST: {
3937
+ data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
3938
+ };
3939
+ UNAUTHORIZED: {};
3940
+ FORBIDDEN: {
3941
+ data: z.ZodOptional<z.ZodObject<{
3942
+ permission: z.ZodOptional<z.ZodString>;
3943
+ }, z.core.$strip>>;
3944
+ };
3945
+ NOT_FOUND: {};
3946
+ CONFLICT: {
3947
+ data: z.ZodOptional<z.ZodObject<{
3948
+ reason: z.ZodOptional<z.ZodString>;
3949
+ }, z.core.$strip>>;
3950
+ };
3951
+ RATE_LIMITED: {};
3952
+ MODULE_DISABLED: {
3953
+ data: z.ZodObject<{
3954
+ module: z.ZodString;
3955
+ }, z.core.$strip>;
3956
+ };
3957
+ }>, Record<never, never>>;
3958
+ /**
3959
+ * What a crawler may index, which is not the same list as what a reader may open: a site behind
3960
+ * a password, or marked `indexable: false`, has an empty sitemap rather than a private one.
3961
+ */
3962
+ readonly sitemap: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3963
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
3964
+ slug: z.ZodString;
3965
+ }, z.core.$strip>, z.ZodObject<{
3966
+ entries: z.ZodArray<z.ZodObject<{
3967
+ path: z.ZodString;
3968
+ lastModified: z.ZodISODateTime;
3969
+ }, z.core.$strip>>;
3970
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
3971
+ BAD_REQUEST: {
3972
+ data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
3973
+ };
3974
+ UNAUTHORIZED: {};
3975
+ FORBIDDEN: {
3976
+ data: z.ZodOptional<z.ZodObject<{
3977
+ permission: z.ZodOptional<z.ZodString>;
3978
+ }, z.core.$strip>>;
3979
+ };
3980
+ NOT_FOUND: {};
3981
+ CONFLICT: {
3982
+ data: z.ZodOptional<z.ZodObject<{
3983
+ reason: z.ZodOptional<z.ZodString>;
3984
+ }, z.core.$strip>>;
3985
+ };
3986
+ RATE_LIMITED: {};
3987
+ MODULE_DISABLED: {
3988
+ data: z.ZodObject<{
3989
+ module: z.ZodString;
3990
+ }, z.core.$strip>;
3991
+ };
3992
+ }>, Record<never, never>>;
3993
+ /**
3994
+ * The one procedure here that never distinguishes one slug from another.
3995
+ *
3996
+ * A crawler asking about a slug that does not exist, one that has expired, and one behind a
3997
+ * password must all get the same answer, or `robots` becomes the oracle every other procedure
3998
+ * refuses to be. So it succeeds for all three and says "do not index". (A workspace with the
3999
+ * module switched off is still a 404, from the middleware — that is a statement about the
4000
+ * workspace, which the path already named, and not about any slug.)
4001
+ */
4002
+ readonly robots: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
4003
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
4004
+ slug: z.ZodString;
4005
+ }, z.core.$strip>, z.ZodObject<{
4006
+ indexable: z.ZodBoolean;
4007
+ sitemapPath: z.ZodNullable<z.ZodString>;
4008
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
4009
+ BAD_REQUEST: {
4010
+ data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
4011
+ };
4012
+ UNAUTHORIZED: {};
4013
+ FORBIDDEN: {
4014
+ data: z.ZodOptional<z.ZodObject<{
4015
+ permission: z.ZodOptional<z.ZodString>;
4016
+ }, z.core.$strip>>;
4017
+ };
4018
+ NOT_FOUND: {};
4019
+ CONFLICT: {
4020
+ data: z.ZodOptional<z.ZodObject<{
4021
+ reason: z.ZodOptional<z.ZodString>;
4022
+ }, z.core.$strip>>;
4023
+ };
4024
+ RATE_LIMITED: {};
4025
+ MODULE_DISABLED: {
4026
+ data: z.ZodObject<{
4027
+ module: z.ZodString;
4028
+ }, z.core.$strip>;
4029
+ };
4030
+ }>, Record<never, never>>;
4031
+ /**
4032
+ * The bytes of one picture on a published page.
4033
+ *
4034
+ * `asset` is the opaque reference the page's own HTML carries — an AES-GCM envelope sealed with
4035
+ * the instance secret and bound by its associated data to this workspace, so it names nothing
4036
+ * on its own and cannot be carried to another instance. Resolving it is not enough on its own:
4037
+ * the file has to be referenced by a version that is *currently* public in this publication, so
4038
+ * opting a page out stops its pictures resolving in the same breath as its prose.
4039
+ *
4040
+ * Everything unresolvable is the same 404 as everything else here — a reference that will not
4041
+ * decrypt, one for a file nothing public uses, a file that has been deleted, an object over the
4042
+ * cap. And a locked publication answers the door first: the pictures are behind the password
4043
+ * along with the pages they are on.
4044
+ */
4045
+ readonly asset: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
4046
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
4047
+ slug: z.ZodString;
4048
+ asset: z.ZodString;
4049
+ token: z.ZodDefault<z.ZodNullable<z.ZodString>>;
4050
+ }, z.core.$strip>, z.ZodObject<{
4051
+ contentType: z.ZodString;
4052
+ bytes: z.ZodString;
4053
+ maxAge: z.ZodNumber;
4054
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
4055
+ BAD_REQUEST: {
4056
+ data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
4057
+ };
4058
+ UNAUTHORIZED: {};
4059
+ FORBIDDEN: {
4060
+ data: z.ZodOptional<z.ZodObject<{
4061
+ permission: z.ZodOptional<z.ZodString>;
4062
+ }, z.core.$strip>>;
4063
+ };
4064
+ NOT_FOUND: {};
4065
+ CONFLICT: {
4066
+ data: z.ZodOptional<z.ZodObject<{
4067
+ reason: z.ZodOptional<z.ZodString>;
4068
+ }, z.core.$strip>>;
4069
+ };
4070
+ RATE_LIMITED: {};
4071
+ MODULE_DISABLED: {
4072
+ data: z.ZodObject<{
4073
+ module: z.ZodString;
4074
+ }, z.core.$strip>;
4075
+ };
4076
+ }>, Record<never, never>>;
4077
+ /** Present the password, get a token. A site with no password has no door, and answers 404. */
4078
+ readonly unlock: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
4079
+ workspaceId: z.core.$ZodBranded<z.ZodUUID, "WorkspaceId", "out">;
4080
+ slug: z.ZodString;
4081
+ password: z.ZodString;
4082
+ }, z.core.$strip>, z.ZodObject<{
4083
+ token: z.ZodString;
4084
+ expiresAt: z.ZodISODateTime;
4085
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
4086
+ BAD_REQUEST: {
4087
+ data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
4088
+ };
4089
+ UNAUTHORIZED: {};
4090
+ FORBIDDEN: {
4091
+ data: z.ZodOptional<z.ZodObject<{
4092
+ permission: z.ZodOptional<z.ZodString>;
4093
+ }, z.core.$strip>>;
4094
+ };
4095
+ NOT_FOUND: {};
4096
+ CONFLICT: {
4097
+ data: z.ZodOptional<z.ZodObject<{
4098
+ reason: z.ZodOptional<z.ZodString>;
4099
+ }, z.core.$strip>>;
4100
+ };
4101
+ RATE_LIMITED: {};
4102
+ MODULE_DISABLED: {
4103
+ data: z.ZodObject<{
4104
+ module: z.ZodString;
4105
+ }, z.core.$strip>;
4106
+ };
4107
+ }>, Record<never, never>>;
4108
+ };
3353
4109
  };
3354
4110
  export type QuireContract = typeof quireContract;
3355
4111
  export { Ok };