@kywi-software/core 0.10.0 → 0.12.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 (248) hide show
  1. package/AGENT-PATTERNS.md +111 -23
  2. package/README.md +67 -0
  3. package/dist/admin/content-form.d.ts.map +1 -1
  4. package/dist/admin/content-form.js +97 -10
  5. package/dist/admin/content-form.js.map +1 -1
  6. package/dist/admin/layout-editor/component-actions.d.ts +219 -22
  7. package/dist/admin/layout-editor/component-actions.d.ts.map +1 -1
  8. package/dist/admin/layout-editor/component-actions.js +356 -36
  9. package/dist/admin/layout-editor/component-actions.js.map +1 -1
  10. package/dist/admin/layout-editor/component-fork.d.ts +224 -0
  11. package/dist/admin/layout-editor/component-fork.d.ts.map +1 -0
  12. package/dist/admin/layout-editor/component-fork.js +342 -0
  13. package/dist/admin/layout-editor/component-fork.js.map +1 -0
  14. package/dist/admin/layout-editor/editor-canvas.d.ts +28 -7
  15. package/dist/admin/layout-editor/editor-canvas.d.ts.map +1 -1
  16. package/dist/admin/layout-editor/editor-canvas.js +145 -32
  17. package/dist/admin/layout-editor/editor-canvas.js.map +1 -1
  18. package/dist/admin/layout-editor/editor-dialog.d.ts +164 -0
  19. package/dist/admin/layout-editor/editor-dialog.d.ts.map +1 -0
  20. package/dist/admin/layout-editor/editor-dialog.js +195 -0
  21. package/dist/admin/layout-editor/editor-dialog.js.map +1 -0
  22. package/dist/admin/layout-editor/editor-state.d.ts +76 -0
  23. package/dist/admin/layout-editor/editor-state.d.ts.map +1 -1
  24. package/dist/admin/layout-editor/editor-state.js +47 -1
  25. package/dist/admin/layout-editor/editor-state.js.map +1 -1
  26. package/dist/admin/layout-editor/editor.css +366 -4
  27. package/dist/admin/layout-editor/index.d.ts +10 -1
  28. package/dist/admin/layout-editor/index.d.ts.map +1 -1
  29. package/dist/admin/layout-editor/index.js +11 -1
  30. package/dist/admin/layout-editor/index.js.map +1 -1
  31. package/dist/admin/layout-editor/inline-text.d.ts +56 -4
  32. package/dist/admin/layout-editor/inline-text.d.ts.map +1 -1
  33. package/dist/admin/layout-editor/inline-text.js +134 -11
  34. package/dist/admin/layout-editor/inline-text.js.map +1 -1
  35. package/dist/admin/layout-editor/layout-editor.d.ts +58 -1
  36. package/dist/admin/layout-editor/layout-editor.d.ts.map +1 -1
  37. package/dist/admin/layout-editor/layout-editor.js +160 -190
  38. package/dist/admin/layout-editor/layout-editor.js.map +1 -1
  39. package/dist/admin/layout-editor/linked-component.d.ts +39 -0
  40. package/dist/admin/layout-editor/linked-component.d.ts.map +1 -0
  41. package/dist/admin/layout-editor/linked-component.js +42 -0
  42. package/dist/admin/layout-editor/linked-component.js.map +1 -0
  43. package/dist/admin/layout-editor/module-overlay.d.ts +36 -14
  44. package/dist/admin/layout-editor/module-overlay.d.ts.map +1 -1
  45. package/dist/admin/layout-editor/module-overlay.js +233 -25
  46. package/dist/admin/layout-editor/module-overlay.js.map +1 -1
  47. package/dist/admin/layout-editor/node-lookup.d.ts +35 -0
  48. package/dist/admin/layout-editor/node-lookup.d.ts.map +1 -1
  49. package/dist/admin/layout-editor/node-lookup.js +91 -0
  50. package/dist/admin/layout-editor/node-lookup.js.map +1 -1
  51. package/dist/admin/layout-editor/overlay-shell.d.ts.map +1 -1
  52. package/dist/admin/layout-editor/overlay-shell.js +150 -32
  53. package/dist/admin/layout-editor/overlay-shell.js.map +1 -1
  54. package/dist/admin/layout-editor/props-panel.d.ts +54 -1
  55. package/dist/admin/layout-editor/props-panel.d.ts.map +1 -1
  56. package/dist/admin/layout-editor/props-panel.js +119 -10
  57. package/dist/admin/layout-editor/props-panel.js.map +1 -1
  58. package/dist/admin/layout-editor/section-overlay.d.ts +16 -1
  59. package/dist/admin/layout-editor/section-overlay.d.ts.map +1 -1
  60. package/dist/admin/layout-editor/section-overlay.js +21 -11
  61. package/dist/admin/layout-editor/section-overlay.js.map +1 -1
  62. package/dist/admin/layout-editor/section-template-picker.d.ts +27 -1
  63. package/dist/admin/layout-editor/section-template-picker.d.ts.map +1 -1
  64. package/dist/admin/layout-editor/section-template-picker.js +71 -17
  65. package/dist/admin/layout-editor/section-template-picker.js.map +1 -1
  66. package/dist/admin/layout-editor/section-variant-container-config.js +5 -5
  67. package/dist/admin/layout-editor/section-variant-container-config.js.map +1 -1
  68. package/dist/admin/layout-editor/use-chrome-flip.d.ts +111 -11
  69. package/dist/admin/layout-editor/use-chrome-flip.d.ts.map +1 -1
  70. package/dist/admin/layout-editor/use-chrome-flip.js +233 -33
  71. package/dist/admin/layout-editor/use-chrome-flip.js.map +1 -1
  72. package/dist/admin/layout-editor/use-component-connect.d.ts +61 -0
  73. package/dist/admin/layout-editor/use-component-connect.d.ts.map +1 -0
  74. package/dist/admin/layout-editor/use-component-connect.js +292 -0
  75. package/dist/admin/layout-editor/use-component-connect.js.map +1 -0
  76. package/dist/admin/layout-editor/use-component-fork.d.ts +123 -0
  77. package/dist/admin/layout-editor/use-component-fork.d.ts.map +1 -0
  78. package/dist/admin/layout-editor/use-component-fork.js +346 -0
  79. package/dist/admin/layout-editor/use-component-fork.js.map +1 -0
  80. package/dist/admin/layout-editor/use-component-library.d.ts +94 -0
  81. package/dist/admin/layout-editor/use-component-library.d.ts.map +1 -0
  82. package/dist/admin/layout-editor/use-component-library.js +55 -0
  83. package/dist/admin/layout-editor/use-component-library.js.map +1 -0
  84. package/dist/admin/registry.d.ts +11 -2
  85. package/dist/admin/registry.d.ts.map +1 -1
  86. package/dist/admin/registry.js +40 -4
  87. package/dist/admin/registry.js.map +1 -1
  88. package/dist/admin/server.d.ts +1 -0
  89. package/dist/admin/server.d.ts.map +1 -1
  90. package/dist/admin/server.js +5 -0
  91. package/dist/admin/server.js.map +1 -1
  92. package/dist/admin/styles/admin.css +57 -1
  93. package/dist/admin/surfaces/components/component-edit.d.ts +3 -0
  94. package/dist/admin/surfaces/components/component-edit.d.ts.map +1 -0
  95. package/dist/admin/surfaces/components/component-edit.js +235 -0
  96. package/dist/admin/surfaces/components/component-edit.js.map +1 -0
  97. package/dist/admin/surfaces/components/components-data.d.ts +153 -0
  98. package/dist/admin/surfaces/components/components-data.d.ts.map +1 -0
  99. package/dist/admin/surfaces/components/components-data.js +154 -0
  100. package/dist/admin/surfaces/components/components-data.js.map +1 -0
  101. package/dist/admin/surfaces/components/components-list.d.ts +3 -0
  102. package/dist/admin/surfaces/components/components-list.d.ts.map +1 -0
  103. package/dist/admin/surfaces/components/components-list.js +196 -0
  104. package/dist/admin/surfaces/components/components-list.js.map +1 -0
  105. package/dist/admin/surfaces/components/definition-canvas.d.ts +73 -0
  106. package/dist/admin/surfaces/components/definition-canvas.d.ts.map +1 -0
  107. package/dist/admin/surfaces/components/definition-canvas.js +207 -0
  108. package/dist/admin/surfaces/components/definition-canvas.js.map +1 -0
  109. package/dist/admin/surfaces/layouts/layout-editor-client.d.ts.map +1 -1
  110. package/dist/admin/surfaces/layouts/layout-editor-client.js +14 -2
  111. package/dist/admin/surfaces/layouts/layout-editor-client.js.map +1 -1
  112. package/dist/admin/surfaces/layouts/layouts-data.d.ts +3 -14
  113. package/dist/admin/surfaces/layouts/layouts-data.d.ts.map +1 -1
  114. package/dist/admin/surfaces/layouts/layouts-data.js +4 -7
  115. package/dist/admin/surfaces/layouts/layouts-data.js.map +1 -1
  116. package/dist/admin/surfaces/layouts/layouts-list.d.ts.map +1 -1
  117. package/dist/admin/surfaces/layouts/layouts-list.js +16 -22
  118. package/dist/admin/surfaces/layouts/layouts-list.js.map +1 -1
  119. package/dist/admin/surfaces/settings/admin-features.d.ts.map +1 -1
  120. package/dist/admin/surfaces/settings/admin-features.js +1 -0
  121. package/dist/admin/surfaces/settings/admin-features.js.map +1 -1
  122. package/dist/api/bulk-routes.d.ts.map +1 -1
  123. package/dist/api/bulk-routes.js +25 -0
  124. package/dist/api/bulk-routes.js.map +1 -1
  125. package/dist/api/changeset-routes.d.ts.map +1 -1
  126. package/dist/api/changeset-routes.js +17 -3
  127. package/dist/api/changeset-routes.js.map +1 -1
  128. package/dist/api/component-routes.d.ts.map +1 -1
  129. package/dist/api/component-routes.js +228 -8
  130. package/dist/api/component-routes.js.map +1 -1
  131. package/dist/api/content-routes.d.ts.map +1 -1
  132. package/dist/api/content-routes.js +64 -0
  133. package/dist/api/content-routes.js.map +1 -1
  134. package/dist/api/feed-routes.d.ts +6 -6
  135. package/dist/api/graphql/resolvers.d.ts +4 -4
  136. package/dist/api/layout-routes.d.ts.map +1 -1
  137. package/dist/api/layout-routes.js +4 -17
  138. package/dist/api/layout-routes.js.map +1 -1
  139. package/dist/api/layout-write-guard.d.ts +80 -0
  140. package/dist/api/layout-write-guard.d.ts.map +1 -0
  141. package/dist/api/layout-write-guard.js +88 -0
  142. package/dist/api/layout-write-guard.js.map +1 -0
  143. package/dist/api/section-template-routes.d.ts.map +1 -1
  144. package/dist/api/section-template-routes.js +11 -0
  145. package/dist/api/section-template-routes.js.map +1 -1
  146. package/dist/api/translation-routes.d.ts.map +1 -1
  147. package/dist/api/translation-routes.js +8 -0
  148. package/dist/api/translation-routes.js.map +1 -1
  149. package/dist/api/version-routes.d.ts.map +1 -1
  150. package/dist/api/version-routes.js +20 -8
  151. package/dist/api/version-routes.js.map +1 -1
  152. package/dist/api/workflow-routes.d.ts.map +1 -1
  153. package/dist/api/workflow-routes.js +53 -8
  154. package/dist/api/workflow-routes.js.map +1 -1
  155. package/dist/db/analytics-queries.d.ts +3 -3
  156. package/dist/db/apply-snapshot.d.ts +75 -8
  157. package/dist/db/apply-snapshot.d.ts.map +1 -1
  158. package/dist/db/apply-snapshot.js +104 -8
  159. package/dist/db/apply-snapshot.js.map +1 -1
  160. package/dist/db/audit-queries.d.ts +12 -12
  161. package/dist/db/category-queries.d.ts +3 -3
  162. package/dist/db/changeset-audit-queries.d.ts +4 -4
  163. package/dist/db/changeset-queries.d.ts +7 -7
  164. package/dist/db/comment-queries.d.ts +8 -8
  165. package/dist/db/comment-subscription-queries.d.ts +2 -2
  166. package/dist/db/component-instance-queries.d.ts +197 -0
  167. package/dist/db/component-instance-queries.d.ts.map +1 -0
  168. package/dist/db/component-instance-queries.js +405 -0
  169. package/dist/db/component-instance-queries.js.map +1 -0
  170. package/dist/db/content-queries.d.ts.map +1 -1
  171. package/dist/db/content-queries.js +39 -2
  172. package/dist/db/content-queries.js.map +1 -1
  173. package/dist/db/extension-queries.d.ts +7 -7
  174. package/dist/db/feed-queries.d.ts +3 -3
  175. package/dist/db/index.d.ts +1 -0
  176. package/dist/db/index.d.ts.map +1 -1
  177. package/dist/db/index.js +1 -0
  178. package/dist/db/index.js.map +1 -1
  179. package/dist/db/layout-queries.d.ts +13 -1
  180. package/dist/db/layout-queries.d.ts.map +1 -1
  181. package/dist/db/layout-queries.js +52 -7
  182. package/dist/db/layout-queries.js.map +1 -1
  183. package/dist/db/locale-queries.d.ts.map +1 -1
  184. package/dist/db/locale-queries.js +0 -0
  185. package/dist/db/locale-queries.js.map +1 -1
  186. package/dist/db/media-queries.d.ts +12 -12
  187. package/dist/db/revision-queries.d.ts +3 -3
  188. package/dist/db/site-admin-queries.d.ts +2 -2
  189. package/dist/db/site-membership-queries.d.ts +3 -3
  190. package/dist/db/site-plugin-queries.d.ts +2 -2
  191. package/dist/db/site-queries.d.ts +6 -6
  192. package/dist/db/version-queries.d.ts +12 -12
  193. package/dist/db/webhook-queries.d.ts +11 -11
  194. package/dist/db/workflow-queries.d.ts +6 -6
  195. package/dist/db/workflow-queries.d.ts.map +1 -1
  196. package/dist/db/workflow-queries.js +11 -2
  197. package/dist/db/workflow-queries.js.map +1 -1
  198. package/dist/layout/comments-module.d.ts.map +1 -1
  199. package/dist/layout/comments-module.js +6 -2
  200. package/dist/layout/comments-module.js.map +1 -1
  201. package/dist/layout/component-refs.d.ts +465 -0
  202. package/dist/layout/component-refs.d.ts.map +1 -0
  203. package/dist/layout/component-refs.js +848 -0
  204. package/dist/layout/component-refs.js.map +1 -0
  205. package/dist/layout/index.d.ts +2 -1
  206. package/dist/layout/index.d.ts.map +1 -1
  207. package/dist/layout/index.js +1 -0
  208. package/dist/layout/index.js.map +1 -1
  209. package/dist/layout/module-permissions.d.ts +49 -1
  210. package/dist/layout/module-permissions.d.ts.map +1 -1
  211. package/dist/layout/module-permissions.js +117 -6
  212. package/dist/layout/module-permissions.js.map +1 -1
  213. package/dist/layout/module-render-context.d.ts +32 -0
  214. package/dist/layout/module-render-context.d.ts.map +1 -1
  215. package/dist/layout/module-render-context.js +32 -1
  216. package/dist/layout/module-render-context.js.map +1 -1
  217. package/dist/layout/modules-extended.d.ts.map +1 -1
  218. package/dist/layout/modules-extended.js +21 -11
  219. package/dist/layout/modules-extended.js.map +1 -1
  220. package/dist/layout/modules.d.ts.map +1 -1
  221. package/dist/layout/modules.js +15 -10
  222. package/dist/layout/modules.js.map +1 -1
  223. package/dist/layout/renderer.d.ts +51 -4
  224. package/dist/layout/renderer.d.ts.map +1 -1
  225. package/dist/layout/renderer.js +36 -38
  226. package/dist/layout/renderer.js.map +1 -1
  227. package/dist/layout/types.d.ts +42 -0
  228. package/dist/layout/types.d.ts.map +1 -1
  229. package/dist/layout/types.js +54 -11
  230. package/dist/layout/types.js.map +1 -1
  231. package/dist/schema/base.d.ts +1 -1
  232. package/dist/schema/components.d.ts +150 -0
  233. package/dist/schema/components.d.ts.map +1 -1
  234. package/dist/schema/components.js +50 -4
  235. package/dist/schema/components.js.map +1 -1
  236. package/dist/scope/inline-editing.d.ts.map +1 -1
  237. package/dist/scope/inline-editing.js +10 -0
  238. package/dist/scope/inline-editing.js.map +1 -1
  239. package/dist/scope/sticky-offset.d.ts +185 -0
  240. package/dist/scope/sticky-offset.d.ts.map +1 -0
  241. package/dist/scope/sticky-offset.js +432 -0
  242. package/dist/scope/sticky-offset.js.map +1 -0
  243. package/dist/site/styles.css +41 -3
  244. package/dist/versioning/scheduler.d.ts +8 -0
  245. package/dist/versioning/scheduler.d.ts.map +1 -1
  246. package/dist/versioning/scheduler.js +21 -7
  247. package/dist/versioning/scheduler.js.map +1 -1
  248. package/package.json +1 -1
@@ -12,37 +12,37 @@ export declare function createAuditEntry(db: KywiDb, data: {
12
12
  }): Promise<{
13
13
  id: string;
14
14
  siteId: string;
15
- createdAt: Date;
16
15
  contentId: string;
17
- userId: string;
18
16
  action: string;
17
+ createdAt: Date;
18
+ userEmail: string;
19
+ userId: string;
20
+ changedFields: unknown;
19
21
  fromStatus: string | null;
20
22
  toStatus: string | null;
21
- changedFields: unknown;
22
- userEmail: string;
23
23
  }>;
24
24
  export declare function listAuditEntries(db: KywiDb, contentId: string, limit?: number): Promise<{
25
25
  id: string;
26
26
  siteId: string;
27
- createdAt: Date;
28
27
  contentId: string;
29
- userId: string;
30
28
  action: string;
29
+ createdAt: Date;
30
+ userEmail: string;
31
+ userId: string;
32
+ changedFields: unknown;
31
33
  fromStatus: string | null;
32
34
  toStatus: string | null;
33
- changedFields: unknown;
34
- userEmail: string;
35
35
  }[]>;
36
36
  export declare function listSiteAuditEntries(db: KywiDb, siteId: string, limit?: number): Promise<{
37
37
  id: string;
38
38
  siteId: string;
39
- createdAt: Date;
40
39
  contentId: string;
41
- userId: string;
42
40
  action: string;
41
+ createdAt: Date;
42
+ userEmail: string;
43
+ userId: string;
44
+ changedFields: unknown;
43
45
  fromStatus: string | null;
44
46
  toStatus: string | null;
45
- changedFields: unknown;
46
- userEmail: string;
47
47
  }[]>;
48
48
  //# sourceMappingURL=audit-queries.d.ts.map
@@ -24,9 +24,9 @@ export declare function listCategories(db: KywiDb, siteId: string, parentId?: st
24
24
  sortOrder: number;
25
25
  updatedAt: Date;
26
26
  name: string;
27
+ description: string | null;
27
28
  createdAt: Date;
28
29
  isActive: boolean;
29
- description: string | null;
30
30
  isInterestGroup: boolean;
31
31
  notes: string | null;
32
32
  }[]>;
@@ -38,9 +38,9 @@ export declare function getCategoryById(db: KywiDb, id: string, siteId?: string)
38
38
  sortOrder: number;
39
39
  updatedAt: Date;
40
40
  name: string;
41
+ description: string | null;
41
42
  createdAt: Date;
42
43
  isActive: boolean;
43
- description: string | null;
44
44
  isInterestGroup: boolean;
45
45
  notes: string | null;
46
46
  } | null>;
@@ -62,9 +62,9 @@ export declare function createCategory(db: KywiDb, data: {
62
62
  sortOrder: number;
63
63
  updatedAt: Date;
64
64
  name: string;
65
+ description: string | null;
65
66
  createdAt: Date;
66
67
  isActive: boolean;
67
- description: string | null;
68
68
  isInterestGroup: boolean;
69
69
  notes: string | null;
70
70
  }>;
@@ -13,20 +13,20 @@ export declare function createChangesetAuditEntry(db: KywiDb, data: {
13
13
  }): Promise<{
14
14
  id: string;
15
15
  siteId: string;
16
+ action: string;
16
17
  createdAt: Date;
17
18
  userId: string;
18
- action: string;
19
- changesetId: string;
20
19
  detail: unknown;
20
+ changesetId: string;
21
21
  }>;
22
22
  /** List a changeset's audit trail, newest first. */
23
23
  export declare function listChangesetAudit(db: KywiDb, changesetId: string, limit?: number): Promise<{
24
24
  id: string;
25
25
  siteId: string;
26
+ action: string;
26
27
  createdAt: Date;
27
28
  userId: string;
28
- action: string;
29
- changesetId: string;
30
29
  detail: unknown;
30
+ changesetId: string;
31
31
  }[]>;
32
32
  //# sourceMappingURL=changeset-audit-queries.d.ts.map
@@ -37,9 +37,9 @@ export declare function createChangeset(db: KywiDb, data: {
37
37
  publishedAt: Date | null;
38
38
  updatedAt: Date;
39
39
  name: string;
40
+ description: string | null;
40
41
  createdAt: Date;
41
42
  createdBy: string;
42
- description: string | null;
43
43
  scheduledPublishAt: Date | null;
44
44
  publishedBy: string | null;
45
45
  }>;
@@ -50,9 +50,9 @@ export declare function getChangeset(db: KywiDb, id: string, siteId?: string): P
50
50
  publishedAt: Date | null;
51
51
  updatedAt: Date;
52
52
  name: string;
53
+ description: string | null;
53
54
  createdAt: Date;
54
55
  createdBy: string;
55
- description: string | null;
56
56
  scheduledPublishAt: Date | null;
57
57
  publishedBy: string | null;
58
58
  } | null>;
@@ -63,9 +63,9 @@ export declare function listChangesets(db: KywiDb, siteId: string, status?: stri
63
63
  publishedAt: Date | null;
64
64
  updatedAt: Date;
65
65
  name: string;
66
+ description: string | null;
66
67
  createdAt: Date;
67
68
  createdBy: string;
68
- description: string | null;
69
69
  scheduledPublishAt: Date | null;
70
70
  publishedBy: string | null;
71
71
  }[]>;
@@ -93,20 +93,20 @@ export declare function addChangesetItem(db: KywiDb, data: {
93
93
  action: string;
94
94
  }): Promise<{
95
95
  id: string;
96
- createdAt: Date;
97
96
  contentId: string;
98
97
  action: string;
99
- changesetId: string;
98
+ createdAt: Date;
100
99
  versionId: string | null;
100
+ changesetId: string;
101
101
  }>;
102
102
  export declare function removeChangesetItem(db: KywiDb, itemId: string): Promise<void>;
103
103
  export declare function listChangesetItems(db: KywiDb, changesetId: string): Promise<{
104
104
  id: string;
105
- createdAt: Date;
106
105
  contentId: string;
107
106
  action: string;
108
- changesetId: string;
107
+ createdAt: Date;
109
108
  versionId: string | null;
109
+ changesetId: string;
110
110
  }[]>;
111
111
  export declare function publishChangeset(db: KywiDb, changesetId: string, publishedBy: string, opts?: PublishChangesetOptions): Promise<any>;
112
112
  export declare function rollbackChangeset(db: KywiDb, changesetId: string): Promise<any>;
@@ -6,11 +6,11 @@ export declare function listComments(db: KywiDb, contentId: string, status?: str
6
6
  status: string;
7
7
  body: string;
8
8
  updatedAt: Date;
9
- createdAt: Date;
10
9
  contentId: string;
11
- authorId: string | null;
10
+ createdAt: Date;
12
11
  authorName: string | null;
13
12
  authorEmail: string | null;
13
+ authorId: string | null;
14
14
  }[]>;
15
15
  export declare function listSiteComments(db: KywiDb, siteId: string, status?: string, limit?: number): Promise<{
16
16
  id: string;
@@ -19,11 +19,11 @@ export declare function listSiteComments(db: KywiDb, siteId: string, status?: st
19
19
  status: string;
20
20
  body: string;
21
21
  updatedAt: Date;
22
- createdAt: Date;
23
22
  contentId: string;
24
- authorId: string | null;
23
+ createdAt: Date;
25
24
  authorName: string | null;
26
25
  authorEmail: string | null;
26
+ authorId: string | null;
27
27
  }[]>;
28
28
  export declare function getCommentById(db: KywiDb, id: string, siteId?: string): Promise<{
29
29
  id: string;
@@ -32,11 +32,11 @@ export declare function getCommentById(db: KywiDb, id: string, siteId?: string):
32
32
  status: string;
33
33
  body: string;
34
34
  updatedAt: Date;
35
- createdAt: Date;
36
35
  contentId: string;
37
- authorId: string | null;
36
+ createdAt: Date;
38
37
  authorName: string | null;
39
38
  authorEmail: string | null;
39
+ authorId: string | null;
40
40
  } | null>;
41
41
  export declare function createComment(db: KywiDb, data: {
42
42
  siteId: string;
@@ -54,11 +54,11 @@ export declare function createComment(db: KywiDb, data: {
54
54
  status: string;
55
55
  body: string;
56
56
  updatedAt: Date;
57
- createdAt: Date;
58
57
  contentId: string;
59
- authorId: string | null;
58
+ createdAt: Date;
60
59
  authorName: string | null;
61
60
  authorEmail: string | null;
61
+ authorId: string | null;
62
62
  }>;
63
63
  export declare function updateComment(db: KywiDb, id: string, data: {
64
64
  body?: string;
@@ -2,8 +2,8 @@ import type { KywiDb } from './client.js';
2
2
  export declare function subscribe(db: KywiDb, contentId: string, email: string, userId?: string): Promise<{
3
3
  id: string;
4
4
  email: string;
5
- createdAt: Date;
6
5
  contentId: string;
6
+ createdAt: Date;
7
7
  isActive: boolean;
8
8
  userId: string | null;
9
9
  }>;
@@ -11,8 +11,8 @@ export declare function unsubscribe(db: KywiDb, contentId: string, email: string
11
11
  export declare function listSubscribers(db: KywiDb, contentId: string): Promise<{
12
12
  id: string;
13
13
  email: string;
14
- createdAt: Date;
15
14
  contentId: string;
15
+ createdAt: Date;
16
16
  isActive: boolean;
17
17
  userId: string | null;
18
18
  }[]>;
@@ -0,0 +1,197 @@
1
+ import type { KywiComponentRow } from '../schema/components.js';
2
+ import type { KywiDb } from './client.js';
3
+ import type { LayoutDocument } from '../layout/types.js';
4
+ import type { ComponentDefinitionLookup } from '../layout/module-permissions.js';
5
+ /**
6
+ * Component ids reach us from layout JSONB, which is user data — a hand-edited
7
+ * or imported layout can carry a `componentId` that is not a UUID at all.
8
+ * Passing one to a `uuid` column comparison is a driver error ("invalid input
9
+ * syntax for type uuid") that would fail the whole layout save, so non-UUID
10
+ * links are simply not indexable (the renderer already treats them as
11
+ * unresolvable).
12
+ *
13
+ * Canonical (lower-case) form is required, deliberately. Postgres renders a
14
+ * `uuid` column lower-case and the renderer matches links against those strings
15
+ * byte-for-byte, so an upper-case link resolves to nothing on the page. Postgres
16
+ * would happily match it in a `uuid` comparison, though — indexing it would
17
+ * count an instance that no visitor can see and that the layout scan (a text
18
+ * `LIKE` on the canonical id) could never find again. What is indexed is exactly
19
+ * what the renderer can resolve.
20
+ */
21
+ export declare function isIndexableComponentId(componentId: string): boolean;
22
+ /**
23
+ * The definitions behind the `componentId` links a write ADDS, in the shape the
24
+ * admin-only-module gate reads. Returns undefined when the write adds no link —
25
+ * the common case, which then costs no query at all.
26
+ *
27
+ * ONE loader for every door that writes a layout: `PUT .../layout`, the content
28
+ * `PUT`/`PATCH` that carries a `layout` field, and `detachComponentEverywhere`.
29
+ * Linking a component introduces whatever modules its definition contains, so a
30
+ * door that gates modules but not links is not a gate; having each door build its
31
+ * own lookup is how one of them ends up not building it.
32
+ *
33
+ * Links whose id is not a canonical UUID are skipped: the renderer cannot resolve
34
+ * them either (and a `uuid` comparison against such a string is a driver error,
35
+ * not a miss), so they contribute nothing but a failed request.
36
+ */
37
+ export declare function buildAddedComponentLookup(db: KywiDb, incoming: LayoutDocument, stored: LayoutDocument | null | undefined, siteId: string | undefined): Promise<ComponentDefinitionLookup | undefined>;
38
+ export interface SyncComponentInstancesParams {
39
+ siteId: string;
40
+ contentId: string;
41
+ /** `kywi_content.content_type_name`, denormalised onto each row. */
42
+ contentType: string;
43
+ before: LayoutDocument | null | undefined;
44
+ after: LayoutDocument | null | undefined;
45
+ }
46
+ export interface SyncComponentInstancesResult {
47
+ added: number;
48
+ removed: number;
49
+ }
50
+ /**
51
+ * Bring the index rows for one content document in line with its new layout.
52
+ *
53
+ * Only the difference is written: moving a linked node around a page is not a
54
+ * change of placement, so a save that reshuffles a layout writes nothing here.
55
+ * Added links are filtered to components that actually exist in the SAME site —
56
+ * a link to a deleted or foreign component is left unindexed rather than
57
+ * blowing up the save on a foreign-key violation (the renderer degrades to the
58
+ * node's own inline copy for exactly those links).
59
+ */
60
+ export declare function syncComponentInstances(db: KywiDb, params: SyncComponentInstancesParams): Promise<SyncComponentInstancesResult>;
61
+ export interface ComponentUsageItem {
62
+ contentId: string;
63
+ contentType: string;
64
+ title: string | null;
65
+ nodeIds: string[];
66
+ }
67
+ export interface ComponentUsage {
68
+ /** Total placements on LIVE (not soft-deleted) documents. */
69
+ instances: number;
70
+ /** Distinct live documents holding at least one placement. */
71
+ pages: number;
72
+ /** Live documents only — what a "N instances across M pages" dialog names. */
73
+ items: ComponentUsageItem[];
74
+ /**
75
+ * Placements held by soft-deleted (trashed) documents, counted separately.
76
+ *
77
+ * A trashed page still holds the link, and restoring it brings the link back,
78
+ * so these are NOT zero-cost: the delete gate has to add them in (otherwise
79
+ * deleting the component leaves a restored page pointing at nothing), and
80
+ * detach-all rewrites trashed documents along with live ones. They are kept
81
+ * out of `instances`/`pages`/`items` because a user reading "this appears on
82
+ * 4 pages" means four pages they can navigate to.
83
+ */
84
+ trashedInstances: number;
85
+ trashedPages: number;
86
+ }
87
+ /**
88
+ * Where a component is placed, with the page titles the confirm dialogs name.
89
+ * One indexed read plus a join — the shape both the admin library and the save
90
+ * fork consume.
91
+ *
92
+ * Trashed documents are partitioned out of the headline numbers rather than
93
+ * dropped: see {@link ComponentUsage.trashedInstances}.
94
+ */
95
+ export declare function getComponentUsage(db: KywiDb, componentId: string, siteId: string): Promise<ComponentUsage>;
96
+ export interface ComponentUsageCount {
97
+ componentId: string;
98
+ instances: number;
99
+ pages: number;
100
+ trashedInstances: number;
101
+ }
102
+ /**
103
+ * Per-component placement counts for a whole site — one grouped read, so the
104
+ * library list doesn't fan out into a usage query per row.
105
+ *
106
+ * The live/trashed split matches {@link getComponentUsage} exactly, so the
107
+ * number in the library list is the same number the component's own usage
108
+ * dialog shows.
109
+ */
110
+ export declare function listComponentUsageCounts(db: KywiDb, siteId: string): Promise<ComponentUsageCount[]>;
111
+ /** Why one document was left alone by {@link detachComponentEverywhere}. */
112
+ export type DetachSkipReason = 'invalidLayout' | 'adminOnlyModule';
113
+ export interface DetachSkippedPage {
114
+ contentId: string;
115
+ contentType: string;
116
+ reason: DetachSkipReason;
117
+ detail: string;
118
+ }
119
+ export interface DetachEverywhereResult {
120
+ /** Documents rewritten. */
121
+ pages: number;
122
+ /** Placements materialised into independent copies. */
123
+ instances: number;
124
+ /**
125
+ * Documents deliberately left untouched, each with the reason. Empty on the
126
+ * happy path; when it is not empty the component still has instances and
127
+ * must not be deleted.
128
+ */
129
+ skipped: DetachSkippedPage[];
130
+ }
131
+ export interface DetachEverywhereOptions {
132
+ /**
133
+ * The role of the caller on whose behalf this rewrite happens. Materialising
134
+ * a component definition writes real module nodes into pages, so the same
135
+ * admin-only-module gate the layout PUT applies has to apply here — otherwise
136
+ * detach-all is a way to place an `html` module on every page in the site
137
+ * without ever passing that gate.
138
+ */
139
+ actorRole: string;
140
+ }
141
+ /**
142
+ * Materialise every placement of a component into an independent copy, so the
143
+ * component can be deleted without any page changing what it renders.
144
+ *
145
+ * Candidate documents come from a scan of the site's layouts (a `::text LIKE`
146
+ * on the component's own UUID), NOT from the instance index. The index is a
147
+ * derived cache; if it ever drifted, trusting it here would leave a page
148
+ * pointing at a component that is about to disappear. The scan is bounded by
149
+ * the site and only materialises rows that actually contain the id. Trashed
150
+ * (soft-deleted) documents are included deliberately: they still hold the link
151
+ * and restoring one must not resurrect a dangling reference.
152
+ *
153
+ * Two guards run per document, and BOTH are per-document skips rather than a
154
+ * failure of the whole operation:
155
+ *
156
+ * - the rewritten document must pass `validateLayoutDocument`. A malformed
157
+ * component definition would otherwise be copied into every referencing page
158
+ * and make each of them permanently un-editable (every later layout PUT
159
+ * would 400 on a document the user cannot repair through the UI). A page
160
+ * whose layout was ALREADY invalid before the rewrite is skipped by the same
161
+ * rule — it needs fixing regardless, and knowingly writing an invalid
162
+ * document is never the better option;
163
+ * - the rewritten document must not introduce an admin-only module the caller
164
+ * could not have added by hand — the same differential check
165
+ * `PUT .../layout` applies, with the same role.
166
+ *
167
+ * Skipping is the honest choice over failing everything: one bad page must not
168
+ * make the component undetachable — and so undeletable — everywhere else. The
169
+ * caller is told exactly which documents were left and why, the skipped pages
170
+ * keep their (still working) links, and the delete gate still sees those
171
+ * instances, so a component can never be deleted out from under a page.
172
+ *
173
+ * Everything — the layout rewrites, the index updates, and the sweep of any
174
+ * leftover index rows — happens in one transaction, and each layout is re-read
175
+ * `FOR UPDATE` inside it so a concurrent editor save can't be silently
176
+ * overwritten (it waits, then the detach sees its result).
177
+ */
178
+ export declare function detachComponentEverywhere(db: KywiDb, component: Pick<KywiComponentRow, 'id' | 'siteId' | 'type' | 'moduleType' | 'definition'>, options: DetachEverywhereOptions): Promise<DetachEverywhereResult>;
179
+ export interface ReindexResult {
180
+ documentsScanned: number;
181
+ instances: number;
182
+ }
183
+ /**
184
+ * Rebuild the instance index from the layouts themselves.
185
+ *
186
+ * This is what makes the index safe on an upgrade: the table ships empty while
187
+ * existing installs already have layouts full of `componentId` links, and
188
+ * `kywi migrate` runs this as a post-step so no operator has to know it exists.
189
+ * It is idempotent (it clears the scope it is about to rebuild) and doubles as
190
+ * the repair path if the index is ever suspected of drift.
191
+ *
192
+ * Only documents whose layout mentions a known component id are parsed, so the
193
+ * cost is one indexed-free scan plus a parse of the pages that actually use
194
+ * components — not a parse of every layout in the database.
195
+ */
196
+ export declare function reindexComponentInstances(db: KywiDb, siteId?: string): Promise<ReindexResult>;
197
+ //# sourceMappingURL=component-instance-queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-instance-queries.d.ts","sourceRoot":"","sources":["../../src/db/component-instance-queries.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,c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