@btst/plugin-cms 0.0.0-stage → 1.0.0-beta.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 (204) hide show
  1. package/LICENSE.md +17 -0
  2. package/dist/api/getters.cjs +328 -0
  3. package/dist/api/getters.mjs +314 -0
  4. package/dist/api/index.cjs +29 -0
  5. package/dist/api/index.d.cts +209 -0
  6. package/dist/api/index.d.mts +209 -0
  7. package/dist/api/index.d.ts +209 -0
  8. package/dist/api/index.mjs +7 -0
  9. package/dist/api/lifecycle-migrations.cjs +13 -0
  10. package/dist/api/lifecycle-migrations.mjs +11 -0
  11. package/dist/api/mutations.cjs +59 -0
  12. package/dist/api/mutations.mjs +57 -0
  13. package/dist/api/operations.cjs +1769 -0
  14. package/dist/api/operations.mjs +1762 -0
  15. package/dist/api/plugin.cjs +337 -0
  16. package/dist/api/plugin.mjs +331 -0
  17. package/dist/api/query-key-defs.cjs +44 -0
  18. package/dist/api/query-key-defs.mjs +39 -0
  19. package/dist/api/relations.cjs +76 -0
  20. package/dist/api/relations.mjs +70 -0
  21. package/dist/client/components/forms/content-form.cjs +286 -0
  22. package/dist/client/components/forms/content-form.mjs +284 -0
  23. package/dist/client/components/forms/file-upload.cjs +160 -0
  24. package/dist/client/components/forms/file-upload.mjs +158 -0
  25. package/dist/client/components/forms/relation-field.cjs +237 -0
  26. package/dist/client/components/forms/relation-field.mjs +235 -0
  27. package/dist/client/components/index.cjs +14 -0
  28. package/dist/client/components/index.d.cts +20 -0
  29. package/dist/client/components/index.d.mts +20 -0
  30. package/dist/client/components/index.d.ts +20 -0
  31. package/dist/client/components/index.mjs +10 -0
  32. package/dist/client/components/inverse-relations-panel.cjs +272 -0
  33. package/dist/client/components/inverse-relations-panel.mjs +270 -0
  34. package/dist/client/components/loading/dashboard-skeleton.cjs +18 -0
  35. package/dist/client/components/loading/dashboard-skeleton.mjs +16 -0
  36. package/dist/client/components/loading/editor-skeleton.cjs +32 -0
  37. package/dist/client/components/loading/editor-skeleton.mjs +30 -0
  38. package/dist/client/components/loading/list-skeleton.cjs +32 -0
  39. package/dist/client/components/loading/list-skeleton.mjs +30 -0
  40. package/dist/client/components/pages/404-page.cjs +26 -0
  41. package/dist/client/components/pages/404-page.mjs +24 -0
  42. package/dist/client/components/pages/content-editor-page.cjs +84 -0
  43. package/dist/client/components/pages/content-editor-page.internal.cjs +170 -0
  44. package/dist/client/components/pages/content-editor-page.internal.mjs +168 -0
  45. package/dist/client/components/pages/content-editor-page.mjs +82 -0
  46. package/dist/client/components/pages/content-list-page.cjs +49 -0
  47. package/dist/client/components/pages/content-list-page.internal.cjs +334 -0
  48. package/dist/client/components/pages/content-list-page.internal.mjs +332 -0
  49. package/dist/client/components/pages/content-list-page.mjs +47 -0
  50. package/dist/client/components/pages/dashboard-page.cjs +42 -0
  51. package/dist/client/components/pages/dashboard-page.internal.cjs +102 -0
  52. package/dist/client/components/pages/dashboard-page.internal.mjs +100 -0
  53. package/dist/client/components/pages/dashboard-page.mjs +40 -0
  54. package/dist/client/components/shared/default-error.cjs +17 -0
  55. package/dist/client/components/shared/default-error.mjs +15 -0
  56. package/dist/client/components/shared/empty-state.cjs +16 -0
  57. package/dist/client/components/shared/empty-state.mjs +14 -0
  58. package/dist/client/components/shared/page-wrapper.cjs +29 -0
  59. package/dist/client/components/shared/page-wrapper.mjs +27 -0
  60. package/dist/client/constants.cjs +5 -0
  61. package/dist/client/constants.mjs +3 -0
  62. package/dist/client/hooks/cms-hooks.cjs +300 -0
  63. package/dist/client/hooks/cms-hooks.mjs +280 -0
  64. package/dist/client/hooks/cms-resource.cjs +13 -0
  65. package/dist/client/hooks/cms-resource.mjs +11 -0
  66. package/dist/client/hooks/index.cjs +25 -0
  67. package/dist/client/hooks/index.d.cts +693 -0
  68. package/dist/client/hooks/index.d.mts +693 -0
  69. package/dist/client/hooks/index.d.ts +693 -0
  70. package/dist/client/hooks/index.mjs +1 -0
  71. package/dist/client/index.cjs +15 -0
  72. package/dist/client/index.d.cts +654 -0
  73. package/dist/client/index.d.mts +654 -0
  74. package/dist/client/index.d.ts +654 -0
  75. package/dist/client/index.mjs +3 -0
  76. package/dist/client/overrides.cjs +26 -0
  77. package/dist/client/overrides.mjs +24 -0
  78. package/dist/client/plugin.cjs +316 -0
  79. package/dist/client/plugin.mjs +314 -0
  80. package/dist/client.css +3 -0
  81. package/dist/db.cjs +118 -0
  82. package/dist/db.mjs +116 -0
  83. package/dist/permissions.cjs +46 -0
  84. package/dist/permissions.d.cts +42 -0
  85. package/dist/permissions.d.mts +42 -0
  86. package/dist/permissions.d.ts +42 -0
  87. package/dist/permissions.mjs +44 -0
  88. package/dist/query-keys.cjs +229 -0
  89. package/dist/query-keys.d.cts +8 -0
  90. package/dist/query-keys.d.mts +8 -0
  91. package/dist/query-keys.d.ts +8 -0
  92. package/dist/query-keys.mjs +225 -0
  93. package/dist/schemas.cjs +81 -0
  94. package/dist/schemas.mjs +72 -0
  95. package/dist/shared/plugin-cms.BBshPRkb.d.cts +6 -0
  96. package/dist/shared/plugin-cms.BBshPRkb.d.mts +6 -0
  97. package/dist/shared/plugin-cms.BBshPRkb.d.ts +6 -0
  98. package/dist/shared/plugin-cms.Bptwe33B.d.cts +1749 -0
  99. package/dist/shared/plugin-cms.Csx7tNDO.d.mts +1749 -0
  100. package/dist/shared/plugin-cms.eNW9_FO5.d.ts +1749 -0
  101. package/dist/style.css +6 -0
  102. package/dist/types.cjs +2 -0
  103. package/dist/types.d.cts +406 -0
  104. package/dist/types.d.mts +406 -0
  105. package/dist/types.d.ts +406 -0
  106. package/dist/types.mjs +1 -0
  107. package/dist/ui/src/components/accordion.cjs +81 -0
  108. package/dist/ui/src/components/accordion.mjs +62 -0
  109. package/dist/ui/src/components/alert-dialog.cjs +157 -0
  110. package/dist/ui/src/components/alert-dialog.mjs +132 -0
  111. package/dist/ui/src/components/auto-form/common/label.cjs +18 -0
  112. package/dist/ui/src/components/auto-form/common/label.mjs +16 -0
  113. package/dist/ui/src/components/auto-form/common/tooltip.cjs +9 -0
  114. package/dist/ui/src/components/auto-form/common/tooltip.mjs +7 -0
  115. package/dist/ui/src/components/auto-form/config.cjs +40 -0
  116. package/dist/ui/src/components/auto-form/config.mjs +37 -0
  117. package/dist/ui/src/components/auto-form/dependencies.cjs +48 -0
  118. package/dist/ui/src/components/auto-form/dependencies.mjs +46 -0
  119. package/dist/ui/src/components/auto-form/fields/array.cjs +266 -0
  120. package/dist/ui/src/components/auto-form/fields/array.mjs +264 -0
  121. package/dist/ui/src/components/auto-form/fields/checkbox.cjs +38 -0
  122. package/dist/ui/src/components/auto-form/fields/checkbox.mjs +36 -0
  123. package/dist/ui/src/components/auto-form/fields/date.cjs +67 -0
  124. package/dist/ui/src/components/auto-form/fields/date.mjs +65 -0
  125. package/dist/ui/src/components/auto-form/fields/enum.cjs +73 -0
  126. package/dist/ui/src/components/auto-form/fields/enum.mjs +71 -0
  127. package/dist/ui/src/components/auto-form/fields/input.cjs +32 -0
  128. package/dist/ui/src/components/auto-form/fields/input.mjs +30 -0
  129. package/dist/ui/src/components/auto-form/fields/number.cjs +31 -0
  130. package/dist/ui/src/components/auto-form/fields/number.mjs +29 -0
  131. package/dist/ui/src/components/auto-form/fields/object.cjs +233 -0
  132. package/dist/ui/src/components/auto-form/fields/object.mjs +217 -0
  133. package/dist/ui/src/components/auto-form/fields/radio-group.cjs +67 -0
  134. package/dist/ui/src/components/auto-form/fields/radio-group.mjs +65 -0
  135. package/dist/ui/src/components/auto-form/fields/switch.cjs +38 -0
  136. package/dist/ui/src/components/auto-form/fields/switch.mjs +36 -0
  137. package/dist/ui/src/components/auto-form/fields/textarea.cjs +31 -0
  138. package/dist/ui/src/components/auto-form/fields/textarea.mjs +29 -0
  139. package/dist/ui/src/components/auto-form/helpers.cjs +270 -0
  140. package/dist/ui/src/components/auto-form/helpers.mjs +259 -0
  141. package/dist/ui/src/components/auto-form/index.cjs +92 -0
  142. package/dist/ui/src/components/auto-form/index.mjs +86 -0
  143. package/dist/ui/src/components/auto-form/stepped-auto-form.cjs +374 -0
  144. package/dist/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
  145. package/dist/ui/src/components/auto-form/types.cjs +11 -0
  146. package/dist/ui/src/components/auto-form/types.mjs +9 -0
  147. package/dist/ui/src/components/badge.cjs +42 -0
  148. package/dist/ui/src/components/badge.mjs +39 -0
  149. package/dist/ui/src/components/button.cjs +56 -0
  150. package/dist/ui/src/components/button.mjs +53 -0
  151. package/dist/ui/src/components/calendar.cjs +207 -0
  152. package/dist/ui/src/components/calendar.mjs +190 -0
  153. package/dist/ui/src/components/card.cjs +56 -0
  154. package/dist/ui/src/components/card.mjs +51 -0
  155. package/dist/ui/src/components/checkbox.cjs +48 -0
  156. package/dist/ui/src/components/checkbox.mjs +32 -0
  157. package/dist/ui/src/components/command.cjs +78 -0
  158. package/dist/ui/src/components/command.mjs +73 -0
  159. package/dist/ui/src/components/date-picker.cjs +41 -0
  160. package/dist/ui/src/components/date-picker.mjs +39 -0
  161. package/dist/ui/src/components/dialog.cjs +119 -0
  162. package/dist/ui/src/components/dialog.mjs +97 -0
  163. package/dist/ui/src/components/form.cjs +120 -0
  164. package/dist/ui/src/components/form.mjs +98 -0
  165. package/dist/ui/src/components/input.cjs +23 -0
  166. package/dist/ui/src/components/input.mjs +21 -0
  167. package/dist/ui/src/components/label.cjs +39 -0
  168. package/dist/ui/src/components/label.mjs +23 -0
  169. package/dist/ui/src/components/multi-select.cjs +555 -0
  170. package/dist/ui/src/components/multi-select.mjs +540 -0
  171. package/dist/ui/src/components/page-layout.cjs +25 -0
  172. package/dist/ui/src/components/page-layout.mjs +23 -0
  173. package/dist/ui/src/components/page-wrapper.cjs +20 -0
  174. package/dist/ui/src/components/page-wrapper.mjs +18 -0
  175. package/dist/ui/src/components/popover.cjs +60 -0
  176. package/dist/ui/src/components/popover.mjs +42 -0
  177. package/dist/ui/src/components/radio-group.cjs +62 -0
  178. package/dist/ui/src/components/radio-group.mjs +45 -0
  179. package/dist/ui/src/components/select.cjs +161 -0
  180. package/dist/ui/src/components/select.mjs +139 -0
  181. package/dist/ui/src/components/separator.cjs +43 -0
  182. package/dist/ui/src/components/separator.mjs +27 -0
  183. package/dist/ui/src/components/skeleton.cjs +17 -0
  184. package/dist/ui/src/components/skeleton.mjs +15 -0
  185. package/dist/ui/src/components/stack-attribution.cjs +24 -0
  186. package/dist/ui/src/components/stack-attribution.mjs +22 -0
  187. package/dist/ui/src/components/switch.cjs +48 -0
  188. package/dist/ui/src/components/switch.mjs +32 -0
  189. package/dist/ui/src/components/table.cjs +89 -0
  190. package/dist/ui/src/components/table.mjs +82 -0
  191. package/dist/ui/src/components/textarea.cjs +20 -0
  192. package/dist/ui/src/components/textarea.mjs +18 -0
  193. package/dist/ui/src/hooks/use-debounce.cjs +16 -0
  194. package/dist/ui/src/hooks/use-debounce.mjs +14 -0
  195. package/dist/ui/src/hooks/use-route-lifecycle.cjs +31 -0
  196. package/dist/ui/src/hooks/use-route-lifecycle.mjs +29 -0
  197. package/dist/ui/src/lib/schema-converter.cjs +133 -0
  198. package/dist/ui/src/lib/schema-converter.mjs +127 -0
  199. package/dist/ui/src/lib/utils.cjs +10 -0
  200. package/dist/ui/src/lib/utils.mjs +8 -0
  201. package/dist/utils.cjs +19 -0
  202. package/dist/utils.mjs +12 -0
  203. package/package.json +170 -3
  204. package/README.md +0 -3
package/dist/db.cjs ADDED
@@ -0,0 +1,118 @@
1
+ 'use strict';
2
+
3
+ const db = require('@btst/db');
4
+
5
+ const cmsSchema = db.createDbPlugin("cms", {
6
+ contentType: {
7
+ modelName: "contentType",
8
+ fields: {
9
+ name: {
10
+ type: "string",
11
+ required: true
12
+ },
13
+ slug: {
14
+ type: "string",
15
+ required: true,
16
+ unique: true
17
+ },
18
+ description: {
19
+ type: "string",
20
+ required: false
21
+ },
22
+ jsonSchema: {
23
+ type: "string",
24
+ required: true
25
+ },
26
+ fieldConfig: {
27
+ type: "string",
28
+ required: false
29
+ },
30
+ autoFormVersion: {
31
+ type: "number",
32
+ required: false
33
+ },
34
+ createdAt: {
35
+ type: "date",
36
+ defaultValue: () => /* @__PURE__ */ new Date()
37
+ },
38
+ updatedAt: {
39
+ type: "date",
40
+ defaultValue: () => /* @__PURE__ */ new Date()
41
+ }
42
+ }
43
+ },
44
+ contentItem: {
45
+ modelName: "contentItem",
46
+ fields: {
47
+ contentTypeId: {
48
+ type: "string",
49
+ required: true,
50
+ references: {
51
+ model: "contentType",
52
+ field: "id",
53
+ onDelete: "cascade"
54
+ }
55
+ },
56
+ slug: {
57
+ type: "string",
58
+ required: true
59
+ },
60
+ data: {
61
+ type: "string",
62
+ required: true
63
+ },
64
+ authorId: {
65
+ type: "string",
66
+ required: false
67
+ },
68
+ createdAt: {
69
+ type: "date",
70
+ defaultValue: () => /* @__PURE__ */ new Date()
71
+ },
72
+ updatedAt: {
73
+ type: "date",
74
+ defaultValue: () => /* @__PURE__ */ new Date()
75
+ }
76
+ }
77
+ },
78
+ /**
79
+ * Junction table for content item relationships
80
+ * Stores many-to-many and one-to-many relations between content items
81
+ */
82
+ contentRelation: {
83
+ modelName: "contentRelation",
84
+ fields: {
85
+ /** The content item that has the relation field */
86
+ sourceId: {
87
+ type: "string",
88
+ required: true,
89
+ references: {
90
+ model: "contentItem",
91
+ field: "id",
92
+ onDelete: "cascade"
93
+ }
94
+ },
95
+ /** The content item being referenced */
96
+ targetId: {
97
+ type: "string",
98
+ required: true,
99
+ references: {
100
+ model: "contentItem",
101
+ field: "id",
102
+ onDelete: "cascade"
103
+ }
104
+ },
105
+ /** The field name in the source content type schema (e.g., "categoryIds") */
106
+ fieldName: {
107
+ type: "string",
108
+ required: true
109
+ },
110
+ createdAt: {
111
+ type: "date",
112
+ defaultValue: () => /* @__PURE__ */ new Date()
113
+ }
114
+ }
115
+ }
116
+ });
117
+
118
+ exports.cmsSchema = cmsSchema;
package/dist/db.mjs ADDED
@@ -0,0 +1,116 @@
1
+ import { createDbPlugin } from '@btst/db';
2
+
3
+ const cmsSchema = createDbPlugin("cms", {
4
+ contentType: {
5
+ modelName: "contentType",
6
+ fields: {
7
+ name: {
8
+ type: "string",
9
+ required: true
10
+ },
11
+ slug: {
12
+ type: "string",
13
+ required: true,
14
+ unique: true
15
+ },
16
+ description: {
17
+ type: "string",
18
+ required: false
19
+ },
20
+ jsonSchema: {
21
+ type: "string",
22
+ required: true
23
+ },
24
+ fieldConfig: {
25
+ type: "string",
26
+ required: false
27
+ },
28
+ autoFormVersion: {
29
+ type: "number",
30
+ required: false
31
+ },
32
+ createdAt: {
33
+ type: "date",
34
+ defaultValue: () => /* @__PURE__ */ new Date()
35
+ },
36
+ updatedAt: {
37
+ type: "date",
38
+ defaultValue: () => /* @__PURE__ */ new Date()
39
+ }
40
+ }
41
+ },
42
+ contentItem: {
43
+ modelName: "contentItem",
44
+ fields: {
45
+ contentTypeId: {
46
+ type: "string",
47
+ required: true,
48
+ references: {
49
+ model: "contentType",
50
+ field: "id",
51
+ onDelete: "cascade"
52
+ }
53
+ },
54
+ slug: {
55
+ type: "string",
56
+ required: true
57
+ },
58
+ data: {
59
+ type: "string",
60
+ required: true
61
+ },
62
+ authorId: {
63
+ type: "string",
64
+ required: false
65
+ },
66
+ createdAt: {
67
+ type: "date",
68
+ defaultValue: () => /* @__PURE__ */ new Date()
69
+ },
70
+ updatedAt: {
71
+ type: "date",
72
+ defaultValue: () => /* @__PURE__ */ new Date()
73
+ }
74
+ }
75
+ },
76
+ /**
77
+ * Junction table for content item relationships
78
+ * Stores many-to-many and one-to-many relations between content items
79
+ */
80
+ contentRelation: {
81
+ modelName: "contentRelation",
82
+ fields: {
83
+ /** The content item that has the relation field */
84
+ sourceId: {
85
+ type: "string",
86
+ required: true,
87
+ references: {
88
+ model: "contentItem",
89
+ field: "id",
90
+ onDelete: "cascade"
91
+ }
92
+ },
93
+ /** The content item being referenced */
94
+ targetId: {
95
+ type: "string",
96
+ required: true,
97
+ references: {
98
+ model: "contentItem",
99
+ field: "id",
100
+ onDelete: "cascade"
101
+ }
102
+ },
103
+ /** The field name in the source content type schema (e.g., "categoryIds") */
104
+ fieldName: {
105
+ type: "string",
106
+ required: true
107
+ },
108
+ createdAt: {
109
+ type: "date",
110
+ defaultValue: () => /* @__PURE__ */ new Date()
111
+ }
112
+ }
113
+ }
114
+ });
115
+
116
+ export { cmsSchema };
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ const authorization = require('@btst/stack/authorization');
4
+ const z = require('zod');
5
+
6
+ const cmsPermissions = authorization.definePermissions("cms", {
7
+ contentType: {
8
+ /** Read the content-type catalog or one server-resolved content type. */
9
+ read: authorization.permission(
10
+ z.z.object({
11
+ contentType: z.z.string().optional()
12
+ })
13
+ )
14
+ },
15
+ record: {
16
+ /** Read a content-type collection or one server-resolved record. */
17
+ read: authorization.permission(
18
+ z.z.object({
19
+ contentType: z.z.string(),
20
+ scope: z.z.enum(["collection", "record"]),
21
+ recordId: z.z.string().optional(),
22
+ authorId: z.z.string().optional()
23
+ })
24
+ ),
25
+ /** Create a record for a server-resolved content type. */
26
+ create: authorization.permission(z.z.object({ contentType: z.z.string() })),
27
+ /** Update a server-resolved record. */
28
+ update: authorization.permission(
29
+ z.z.object({
30
+ contentType: z.z.string(),
31
+ recordId: z.z.string(),
32
+ authorId: z.z.string().optional()
33
+ })
34
+ ),
35
+ /** Delete a server-resolved record. */
36
+ delete: authorization.permission(
37
+ z.z.object({
38
+ contentType: z.z.string(),
39
+ recordId: z.z.string(),
40
+ authorId: z.z.string().optional()
41
+ })
42
+ )
43
+ }
44
+ });
45
+
46
+ exports.cmsPermissions = cmsPermissions;
@@ -0,0 +1,42 @@
1
+ import * as _btst_stack_authorization from '@btst/stack/authorization';
2
+ import { z } from 'zod';
3
+
4
+ /** Browser-safe, schema-backed permissions published by the CMS plugin. */
5
+ declare const cmsPermissions: _btst_stack_authorization.PermissionCatalog<"cms", {
6
+ readonly contentType: {
7
+ /** Read the content-type catalog or one server-resolved content type. */
8
+ readonly read: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
9
+ contentType: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strip>>;
11
+ };
12
+ readonly record: {
13
+ /** Read a content-type collection or one server-resolved record. */
14
+ readonly read: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
15
+ contentType: z.ZodString;
16
+ scope: z.ZodEnum<{
17
+ record: "record";
18
+ collection: "collection";
19
+ }>;
20
+ recordId: z.ZodOptional<z.ZodString>;
21
+ authorId: z.ZodOptional<z.ZodString>;
22
+ }, z.core.$strip>>;
23
+ /** Create a record for a server-resolved content type. */
24
+ readonly create: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
25
+ contentType: z.ZodString;
26
+ }, z.core.$strip>>;
27
+ /** Update a server-resolved record. */
28
+ readonly update: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
29
+ contentType: z.ZodString;
30
+ recordId: z.ZodString;
31
+ authorId: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$strip>>;
33
+ /** Delete a server-resolved record. */
34
+ readonly delete: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
35
+ contentType: z.ZodString;
36
+ recordId: z.ZodString;
37
+ authorId: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strip>>;
39
+ };
40
+ }>;
41
+
42
+ export { cmsPermissions };
@@ -0,0 +1,42 @@
1
+ import * as _btst_stack_authorization from '@btst/stack/authorization';
2
+ import { z } from 'zod';
3
+
4
+ /** Browser-safe, schema-backed permissions published by the CMS plugin. */
5
+ declare const cmsPermissions: _btst_stack_authorization.PermissionCatalog<"cms", {
6
+ readonly contentType: {
7
+ /** Read the content-type catalog or one server-resolved content type. */
8
+ readonly read: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
9
+ contentType: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strip>>;
11
+ };
12
+ readonly record: {
13
+ /** Read a content-type collection or one server-resolved record. */
14
+ readonly read: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
15
+ contentType: z.ZodString;
16
+ scope: z.ZodEnum<{
17
+ record: "record";
18
+ collection: "collection";
19
+ }>;
20
+ recordId: z.ZodOptional<z.ZodString>;
21
+ authorId: z.ZodOptional<z.ZodString>;
22
+ }, z.core.$strip>>;
23
+ /** Create a record for a server-resolved content type. */
24
+ readonly create: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
25
+ contentType: z.ZodString;
26
+ }, z.core.$strip>>;
27
+ /** Update a server-resolved record. */
28
+ readonly update: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
29
+ contentType: z.ZodString;
30
+ recordId: z.ZodString;
31
+ authorId: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$strip>>;
33
+ /** Delete a server-resolved record. */
34
+ readonly delete: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
35
+ contentType: z.ZodString;
36
+ recordId: z.ZodString;
37
+ authorId: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strip>>;
39
+ };
40
+ }>;
41
+
42
+ export { cmsPermissions };
@@ -0,0 +1,42 @@
1
+ import * as _btst_stack_authorization from '@btst/stack/authorization';
2
+ import { z } from 'zod';
3
+
4
+ /** Browser-safe, schema-backed permissions published by the CMS plugin. */
5
+ declare const cmsPermissions: _btst_stack_authorization.PermissionCatalog<"cms", {
6
+ readonly contentType: {
7
+ /** Read the content-type catalog or one server-resolved content type. */
8
+ readonly read: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
9
+ contentType: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strip>>;
11
+ };
12
+ readonly record: {
13
+ /** Read a content-type collection or one server-resolved record. */
14
+ readonly read: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
15
+ contentType: z.ZodString;
16
+ scope: z.ZodEnum<{
17
+ record: "record";
18
+ collection: "collection";
19
+ }>;
20
+ recordId: z.ZodOptional<z.ZodString>;
21
+ authorId: z.ZodOptional<z.ZodString>;
22
+ }, z.core.$strip>>;
23
+ /** Create a record for a server-resolved content type. */
24
+ readonly create: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
25
+ contentType: z.ZodString;
26
+ }, z.core.$strip>>;
27
+ /** Update a server-resolved record. */
28
+ readonly update: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
29
+ contentType: z.ZodString;
30
+ recordId: z.ZodString;
31
+ authorId: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$strip>>;
33
+ /** Delete a server-resolved record. */
34
+ readonly delete: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
35
+ contentType: z.ZodString;
36
+ recordId: z.ZodString;
37
+ authorId: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strip>>;
39
+ };
40
+ }>;
41
+
42
+ export { cmsPermissions };
@@ -0,0 +1,44 @@
1
+ import { definePermissions, permission } from '@btst/stack/authorization';
2
+ import { z } from 'zod';
3
+
4
+ const cmsPermissions = definePermissions("cms", {
5
+ contentType: {
6
+ /** Read the content-type catalog or one server-resolved content type. */
7
+ read: permission(
8
+ z.object({
9
+ contentType: z.string().optional()
10
+ })
11
+ )
12
+ },
13
+ record: {
14
+ /** Read a content-type collection or one server-resolved record. */
15
+ read: permission(
16
+ z.object({
17
+ contentType: z.string(),
18
+ scope: z.enum(["collection", "record"]),
19
+ recordId: z.string().optional(),
20
+ authorId: z.string().optional()
21
+ })
22
+ ),
23
+ /** Create a record for a server-resolved content type. */
24
+ create: permission(z.object({ contentType: z.string() })),
25
+ /** Update a server-resolved record. */
26
+ update: permission(
27
+ z.object({
28
+ contentType: z.string(),
29
+ recordId: z.string(),
30
+ authorId: z.string().optional()
31
+ })
32
+ ),
33
+ /** Delete a server-resolved record. */
34
+ delete: permission(
35
+ z.object({
36
+ contentType: z.string(),
37
+ recordId: z.string(),
38
+ authorId: z.string().optional()
39
+ })
40
+ )
41
+ }
42
+ });
43
+
44
+ export { cmsPermissions };
@@ -0,0 +1,229 @@
1
+ 'use strict';
2
+
3
+ const schemas = require('./schemas.cjs');
4
+ const client = require('@btst/stack/plugins/client');
5
+ const queryKeyDefs = require('./api/query-key-defs.cjs');
6
+
7
+ function normalizeSearch(search) {
8
+ return search !== void 0 && search.trim() === "" ? void 0 : search;
9
+ }
10
+ function contentReadQuery(options) {
11
+ return {
12
+ view: options?.view,
13
+ fields: options?.fields === void 0 ? void 0 : JSON.stringify(schemas.normalizeContentFields(options.fields))
14
+ };
15
+ }
16
+ function relationPageKey(params) {
17
+ const limit = params.limit ?? 20;
18
+ const offset = params.offset ?? 0;
19
+ return limit === 20 && offset === 0 && !params.view && params.fields === void 0 ? [] : [{ limit, offset, ...queryKeyDefs.contentReadDiscriminator(params) }];
20
+ }
21
+ function paginatedNextPageParam(lastPage, allPages, limit) {
22
+ const items = Array.isArray(lastPage?.items) ? lastPage.items : [];
23
+ if (items.length < limit) return void 0;
24
+ const loadedCount = allPages.reduce(
25
+ (sum, page) => sum + (Array.isArray(page?.items) ? page.items.length : 0),
26
+ 0
27
+ );
28
+ const total = lastPage?.total ?? 0;
29
+ if (loadedCount >= total) return void 0;
30
+ return loadedCount;
31
+ }
32
+ const cmsResources = {
33
+ cmsTypes: {
34
+ queries: {
35
+ list: {
36
+ path: "/content-types",
37
+ key: () => ["list"],
38
+ select: (data) => data ?? []
39
+ },
40
+ detail: {
41
+ path: "/content-types/:slug",
42
+ params: (slug) => ({ slug }),
43
+ key: (slug) => [slug],
44
+ select: (data, _slug) => data ?? null,
45
+ skip: (slug) => !slug
46
+ },
47
+ inverseRelations: {
48
+ path: "/content-types/:slug/inverse-relations",
49
+ params: (p) => ({ slug: p.slug }),
50
+ query: (p) => ({ itemId: p.itemId }),
51
+ key: (p) => [p.slug, p.itemId],
52
+ select: (data) => data?.inverseRelations ?? []
53
+ },
54
+ inverseRelationItems: {
55
+ path: "/content-types/:slug/inverse-relations/:sourceType",
56
+ params: (p) => ({
57
+ slug: p.slug,
58
+ sourceType: p.sourceType
59
+ }),
60
+ query: (p) => ({
61
+ ...contentReadQuery(p),
62
+ itemId: p.itemId,
63
+ fieldName: p.fieldName,
64
+ limit: p.limit ?? 20,
65
+ offset: p.offset ?? 0
66
+ }),
67
+ key: (p) => [
68
+ p.slug,
69
+ p.sourceType,
70
+ p.itemId,
71
+ p.fieldName,
72
+ ...relationPageKey(p)
73
+ ],
74
+ select: (data) => data ?? { items: [], total: 0 }
75
+ }
76
+ }
77
+ },
78
+ cmsContent: {
79
+ queries: {
80
+ list: {
81
+ path: "/content/:typeSlug",
82
+ params: (p) => ({ typeSlug: p.typeSlug }),
83
+ query: (p) => ({
84
+ ...contentReadQuery(p),
85
+ limit: p.limit ?? 20,
86
+ search: normalizeSearch(p.search)
87
+ }),
88
+ key: (p) => [queryKeyDefs.contentListDiscriminator(p)],
89
+ select: (data, _p) => data,
90
+ infinite: true,
91
+ pageSize: (p) => p.limit ?? 20,
92
+ nextPageParam: (lastPage, allPages, p) => paginatedNextPageParam(lastPage, allPages, p.limit ?? 20)
93
+ },
94
+ detail: {
95
+ path: "/content/:typeSlug/:id",
96
+ params: (typeSlug, id, _options) => ({
97
+ typeSlug,
98
+ id
99
+ }),
100
+ query: (_typeSlug, _id, options) => contentReadQuery(options),
101
+ key: (typeSlug, id, options) => [
102
+ typeSlug,
103
+ id,
104
+ ...queryKeyDefs.contentReadKey(options)
105
+ ],
106
+ select: (data, _typeSlug, _id, _options) => data ?? null,
107
+ skip: (typeSlug, id) => !typeSlug || !id
108
+ },
109
+ bySlug: {
110
+ path: "/content/:typeSlug",
111
+ params: (typeSlug, _slug, _options) => ({ typeSlug }),
112
+ query: (_typeSlug, slug, options) => ({
113
+ slug,
114
+ limit: 1,
115
+ ...contentReadQuery(options)
116
+ }),
117
+ key: (typeSlug, slug, options) => [
118
+ "bySlug",
119
+ typeSlug,
120
+ slug,
121
+ ...queryKeyDefs.contentReadKey(options)
122
+ ],
123
+ select: (data) => data?.items?.[0] ?? null,
124
+ skip: (typeSlug, slug) => !typeSlug || !slug
125
+ },
126
+ populated: {
127
+ path: "/content/:typeSlug/:id/populated",
128
+ params: (typeSlug, id) => ({ typeSlug, id }),
129
+ key: (typeSlug, id) => [typeSlug, id],
130
+ select: (data) => data ?? null,
131
+ skip: (typeSlug, id) => !typeSlug || !id
132
+ },
133
+ byRelation: {
134
+ path: "/content/:typeSlug/by-relation",
135
+ params: (p) => ({ typeSlug: p.typeSlug }),
136
+ query: (p) => ({
137
+ ...contentReadQuery(p),
138
+ field: p.field,
139
+ targetId: p.targetId,
140
+ limit: p.limit ?? 20
141
+ }),
142
+ key: (p) => [
143
+ p.typeSlug,
144
+ p.field,
145
+ p.targetId,
146
+ ...relationPageKey(p)
147
+ ],
148
+ select: (data, _p) => data,
149
+ infinite: true,
150
+ pageSize: (p) => p.limit ?? 20,
151
+ nextPageParam: (lastPage, allPages, p) => paginatedNextPageParam(lastPage, allPages, p.limit ?? 20)
152
+ },
153
+ // Non-infinite options query for relation pickers (useSelect)
154
+ options: {
155
+ path: "/content/:typeSlug",
156
+ params: (p) => ({ typeSlug: p.typeSlug }),
157
+ query: (p) => ({
158
+ ...contentReadQuery(p),
159
+ search: normalizeSearch(p.search),
160
+ limit: p.limit ?? 50
161
+ }),
162
+ key: (p) => [
163
+ "options",
164
+ p.typeSlug,
165
+ normalizeSearch(p.search),
166
+ p.limit ?? 50,
167
+ ...queryKeyDefs.contentReadKey(p)
168
+ ],
169
+ select: (data, _p) => data?.items ?? []
170
+ }
171
+ },
172
+ mutations: {
173
+ create: {
174
+ path: "@post/content/:typeSlug",
175
+ method: "POST",
176
+ input: (vars) => ({
177
+ params: { typeSlug: vars.typeSlug },
178
+ body: { slug: vars.slug, data: vars.data }
179
+ }),
180
+ select: (data) => data,
181
+ invalidates: [
182
+ "cmsContent",
183
+ "cmsTypes.list",
184
+ "cmsTypes.inverseRelationItems",
185
+ "cmsTypes.inverseRelations"
186
+ ]
187
+ },
188
+ update: {
189
+ path: "@put/content/:typeSlug/:id",
190
+ method: "PUT",
191
+ input: (vars) => ({
192
+ params: { typeSlug: vars.typeSlug, id: vars.id },
193
+ body: vars.data
194
+ }),
195
+ select: (data) => data,
196
+ invalidates: [
197
+ "cmsContent",
198
+ "cmsTypes.inverseRelationItems",
199
+ "cmsTypes.inverseRelations"
200
+ ],
201
+ setData: {
202
+ query: "detail",
203
+ args: (updated) => updated?.contentType?.slug ? [updated.contentType.slug, updated.id] : null
204
+ }
205
+ },
206
+ delete: {
207
+ path: "@delete/content/:typeSlug/:id",
208
+ method: "DELETE",
209
+ input: (vars) => ({
210
+ params: { typeSlug: vars.typeSlug, id: vars.id }
211
+ }),
212
+ select: (data) => data,
213
+ invalidates: [
214
+ "cmsContent",
215
+ "cmsTypes.list",
216
+ "cmsTypes.inverseRelationItems",
217
+ "cmsTypes.inverseRelations"
218
+ ]
219
+ }
220
+ }
221
+ }
222
+ };
223
+ function createCMSQueryKeys(client$1, headers) {
224
+ return client.createResourceQueryKeys(client$1, cmsResources, headers);
225
+ }
226
+
227
+ exports.contentListDiscriminator = queryKeyDefs.contentListDiscriminator;
228
+ exports.cmsResources = cmsResources;
229
+ exports.createCMSQueryKeys = createCMSQueryKeys;
@@ -0,0 +1,8 @@
1
+ export { e as ContentListDiscriminator, f as ContentListParams, g as cmsResources, h as contentListDiscriminator, d as createCMSQueryKeys } from './shared/plugin-cms.Bptwe33B.cjs';
2
+ import '@btst/stack/plugins/client';
3
+ import './types.cjs';
4
+ import '@btst/stack/authorization';
5
+ import '@btst/stack/plugins/api';
6
+ import 'better-call';
7
+ import '@tanstack/react-query';
8
+ import 'zod';
@@ -0,0 +1,8 @@
1
+ export { e as ContentListDiscriminator, f as ContentListParams, g as cmsResources, h as contentListDiscriminator, d as createCMSQueryKeys } from './shared/plugin-cms.Csx7tNDO.mjs';
2
+ import '@btst/stack/plugins/client';
3
+ import './types.mjs';
4
+ import '@btst/stack/authorization';
5
+ import '@btst/stack/plugins/api';
6
+ import 'better-call';
7
+ import '@tanstack/react-query';
8
+ import 'zod';