@btst/plugin-form-builder 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/LICENSE.md +17 -0
  2. package/dist/api/getters.cjs +154 -0
  3. package/dist/api/getters.mjs +145 -0
  4. package/dist/api/index.cjs +25 -0
  5. package/dist/api/index.d.cts +119 -0
  6. package/dist/api/index.d.mts +119 -0
  7. package/dist/api/index.d.ts +119 -0
  8. package/dist/api/index.mjs +6 -0
  9. package/dist/api/lifecycle-migrations.cjs +15 -0
  10. package/dist/api/lifecycle-migrations.mjs +13 -0
  11. package/dist/api/operations.cjs +1093 -0
  12. package/dist/api/operations.mjs +1082 -0
  13. package/dist/api/plugin.cjs +201 -0
  14. package/dist/api/plugin.mjs +192 -0
  15. package/dist/api/query-key-defs.cjs +43 -0
  16. package/dist/api/query-key-defs.mjs +39 -0
  17. package/dist/client/components/forms/form-renderer.cjs +193 -0
  18. package/dist/client/components/forms/form-renderer.mjs +191 -0
  19. package/dist/client/components/index.cjs +29 -0
  20. package/dist/client/components/index.d.cts +97 -0
  21. package/dist/client/components/index.d.mts +97 -0
  22. package/dist/client/components/index.d.ts +97 -0
  23. package/dist/client/components/index.mjs +18 -0
  24. package/dist/client/components/loading/form-builder-skeleton.cjs +32 -0
  25. package/dist/client/components/loading/form-builder-skeleton.mjs +30 -0
  26. package/dist/client/components/loading/form-list-skeleton.cjs +21 -0
  27. package/dist/client/components/loading/form-list-skeleton.mjs +19 -0
  28. package/dist/client/components/loading/submissions-skeleton.cjs +34 -0
  29. package/dist/client/components/loading/submissions-skeleton.mjs +32 -0
  30. package/dist/client/components/pages/404-page.cjs +28 -0
  31. package/dist/client/components/pages/404-page.mjs +26 -0
  32. package/dist/client/components/pages/form-builder-page.cjs +77 -0
  33. package/dist/client/components/pages/form-builder-page.internal.cjs +217 -0
  34. package/dist/client/components/pages/form-builder-page.internal.mjs +215 -0
  35. package/dist/client/components/pages/form-builder-page.mjs +75 -0
  36. package/dist/client/components/pages/form-list-page.cjs +44 -0
  37. package/dist/client/components/pages/form-list-page.internal.cjs +282 -0
  38. package/dist/client/components/pages/form-list-page.internal.mjs +280 -0
  39. package/dist/client/components/pages/form-list-page.mjs +42 -0
  40. package/dist/client/components/pages/submissions-page.cjs +64 -0
  41. package/dist/client/components/pages/submissions-page.internal.cjs +255 -0
  42. package/dist/client/components/pages/submissions-page.internal.mjs +253 -0
  43. package/dist/client/components/pages/submissions-page.mjs +62 -0
  44. package/dist/client/components/shared/default-error.cjs +17 -0
  45. package/dist/client/components/shared/default-error.mjs +15 -0
  46. package/dist/client/components/shared/empty-state.cjs +16 -0
  47. package/dist/client/components/shared/empty-state.mjs +14 -0
  48. package/dist/client/components/shared/page-wrapper.cjs +29 -0
  49. package/dist/client/components/shared/page-wrapper.mjs +27 -0
  50. package/dist/client/components/shared/pagination.cjs +49 -0
  51. package/dist/client/components/shared/pagination.mjs +47 -0
  52. package/dist/client/constants.cjs +5 -0
  53. package/dist/client/constants.mjs +3 -0
  54. package/dist/client/hooks/form-builder-hooks.cjs +203 -0
  55. package/dist/client/hooks/form-builder-hooks.mjs +186 -0
  56. package/dist/client/hooks/form-builder-resource.cjs +13 -0
  57. package/dist/client/hooks/form-builder-resource.mjs +11 -0
  58. package/dist/client/hooks/index.cjs +22 -0
  59. package/dist/client/hooks/index.d.cts +378 -0
  60. package/dist/client/hooks/index.d.mts +378 -0
  61. package/dist/client/hooks/index.d.ts +378 -0
  62. package/dist/client/hooks/index.mjs +1 -0
  63. package/dist/client/index.cjs +13 -0
  64. package/dist/client/index.d.cts +410 -0
  65. package/dist/client/index.d.mts +410 -0
  66. package/dist/client/index.d.ts +410 -0
  67. package/dist/client/index.mjs +2 -0
  68. package/dist/client/plugin.cjs +311 -0
  69. package/dist/client/plugin.mjs +309 -0
  70. package/dist/client.css +3 -0
  71. package/dist/db.cjs +99 -0
  72. package/dist/db.mjs +97 -0
  73. package/dist/permissions.cjs +95 -0
  74. package/dist/permissions.d.cts +94 -0
  75. package/dist/permissions.d.mts +94 -0
  76. package/dist/permissions.d.ts +94 -0
  77. package/dist/permissions.mjs +93 -0
  78. package/dist/query-keys.cjs +140 -0
  79. package/dist/query-keys.d.cts +392 -0
  80. package/dist/query-keys.d.mts +392 -0
  81. package/dist/query-keys.d.ts +392 -0
  82. package/dist/query-keys.mjs +137 -0
  83. package/dist/schemas.cjs +91 -0
  84. package/dist/schemas.mjs +82 -0
  85. package/dist/shared/plugin-form-builder.BZYGyFgT.d.mts +351 -0
  86. package/dist/shared/plugin-form-builder.Bbl9NufB.d.cts +408 -0
  87. package/dist/shared/plugin-form-builder.CSP5HR2O.d.ts +408 -0
  88. package/dist/shared/plugin-form-builder.Cmk083dA.d.cts +351 -0
  89. package/dist/shared/plugin-form-builder.D258Qpb8.d.ts +351 -0
  90. package/dist/shared/plugin-form-builder.DWrQ3lRX.d.cts +118 -0
  91. package/dist/shared/plugin-form-builder.DWrQ3lRX.d.mts +118 -0
  92. package/dist/shared/plugin-form-builder.DWrQ3lRX.d.ts +118 -0
  93. package/dist/shared/plugin-form-builder.lp98rFNl.d.mts +408 -0
  94. package/dist/style.css +6 -0
  95. package/dist/types.cjs +2 -0
  96. package/dist/types.d.cts +6 -0
  97. package/dist/types.d.mts +6 -0
  98. package/dist/types.d.ts +6 -0
  99. package/dist/types.mjs +1 -0
  100. package/dist/ui/src/components/accordion.cjs +81 -0
  101. package/dist/ui/src/components/accordion.mjs +62 -0
  102. package/dist/ui/src/components/alert-dialog.cjs +157 -0
  103. package/dist/ui/src/components/alert-dialog.mjs +132 -0
  104. package/dist/ui/src/components/auto-form/common/label.cjs +18 -0
  105. package/dist/ui/src/components/auto-form/common/label.mjs +16 -0
  106. package/dist/ui/src/components/auto-form/common/tooltip.cjs +9 -0
  107. package/dist/ui/src/components/auto-form/common/tooltip.mjs +7 -0
  108. package/dist/ui/src/components/auto-form/config.cjs +40 -0
  109. package/dist/ui/src/components/auto-form/config.mjs +37 -0
  110. package/dist/ui/src/components/auto-form/dependencies.cjs +48 -0
  111. package/dist/ui/src/components/auto-form/dependencies.mjs +46 -0
  112. package/dist/ui/src/components/auto-form/fields/array.cjs +266 -0
  113. package/dist/ui/src/components/auto-form/fields/array.mjs +264 -0
  114. package/dist/ui/src/components/auto-form/fields/checkbox.cjs +38 -0
  115. package/dist/ui/src/components/auto-form/fields/checkbox.mjs +36 -0
  116. package/dist/ui/src/components/auto-form/fields/date.cjs +67 -0
  117. package/dist/ui/src/components/auto-form/fields/date.mjs +65 -0
  118. package/dist/ui/src/components/auto-form/fields/enum.cjs +73 -0
  119. package/dist/ui/src/components/auto-form/fields/enum.mjs +71 -0
  120. package/dist/ui/src/components/auto-form/fields/input.cjs +32 -0
  121. package/dist/ui/src/components/auto-form/fields/input.mjs +30 -0
  122. package/dist/ui/src/components/auto-form/fields/number.cjs +31 -0
  123. package/dist/ui/src/components/auto-form/fields/number.mjs +29 -0
  124. package/dist/ui/src/components/auto-form/fields/object.cjs +233 -0
  125. package/dist/ui/src/components/auto-form/fields/object.mjs +217 -0
  126. package/dist/ui/src/components/auto-form/fields/radio-group.cjs +67 -0
  127. package/dist/ui/src/components/auto-form/fields/radio-group.mjs +65 -0
  128. package/dist/ui/src/components/auto-form/fields/switch.cjs +38 -0
  129. package/dist/ui/src/components/auto-form/fields/switch.mjs +36 -0
  130. package/dist/ui/src/components/auto-form/fields/textarea.cjs +31 -0
  131. package/dist/ui/src/components/auto-form/fields/textarea.mjs +29 -0
  132. package/dist/ui/src/components/auto-form/helpers.cjs +270 -0
  133. package/dist/ui/src/components/auto-form/helpers.mjs +259 -0
  134. package/dist/ui/src/components/auto-form/index.cjs +92 -0
  135. package/dist/ui/src/components/auto-form/index.mjs +86 -0
  136. package/dist/ui/src/components/auto-form/stepped-auto-form.cjs +374 -0
  137. package/dist/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
  138. package/dist/ui/src/components/auto-form/types.cjs +11 -0
  139. package/dist/ui/src/components/auto-form/types.mjs +9 -0
  140. package/dist/ui/src/components/button.cjs +56 -0
  141. package/dist/ui/src/components/button.mjs +53 -0
  142. package/dist/ui/src/components/calendar.cjs +207 -0
  143. package/dist/ui/src/components/calendar.mjs +190 -0
  144. package/dist/ui/src/components/checkbox.cjs +48 -0
  145. package/dist/ui/src/components/checkbox.mjs +32 -0
  146. package/dist/ui/src/components/date-picker.cjs +41 -0
  147. package/dist/ui/src/components/date-picker.mjs +39 -0
  148. package/dist/ui/src/components/dialog.cjs +141 -0
  149. package/dist/ui/src/components/dialog.mjs +118 -0
  150. package/dist/ui/src/components/dropdown-menu.cjs +81 -0
  151. package/dist/ui/src/components/dropdown-menu.mjs +62 -0
  152. package/dist/ui/src/components/form-builder/canvas.cjs +111 -0
  153. package/dist/ui/src/components/form-builder/canvas.mjs +109 -0
  154. package/dist/ui/src/components/form-builder/components/index.cjs +571 -0
  155. package/dist/ui/src/components/form-builder/components/index.mjs +554 -0
  156. package/dist/ui/src/components/form-builder/edit-field-dialog.cjs +131 -0
  157. package/dist/ui/src/components/form-builder/edit-field-dialog.mjs +129 -0
  158. package/dist/ui/src/components/form-builder/form-preview.cjs +73 -0
  159. package/dist/ui/src/components/form-builder/form-preview.mjs +71 -0
  160. package/dist/ui/src/components/form-builder/index.cjs +350 -0
  161. package/dist/ui/src/components/form-builder/index.mjs +344 -0
  162. package/dist/ui/src/components/form-builder/nested-field-editor-dialog.cjs +263 -0
  163. package/dist/ui/src/components/form-builder/nested-field-editor-dialog.mjs +261 -0
  164. package/dist/ui/src/components/form-builder/palette.cjs +52 -0
  165. package/dist/ui/src/components/form-builder/palette.mjs +49 -0
  166. package/dist/ui/src/components/form-builder/schema-utils.cjs +128 -0
  167. package/dist/ui/src/components/form-builder/schema-utils.mjs +122 -0
  168. package/dist/ui/src/components/form-builder/sortable-field.cjs +151 -0
  169. package/dist/ui/src/components/form-builder/sortable-field.mjs +148 -0
  170. package/dist/ui/src/components/form-builder/step-tabs.cjs +180 -0
  171. package/dist/ui/src/components/form-builder/step-tabs.mjs +178 -0
  172. package/dist/ui/src/components/form-builder/types.cjs +7 -0
  173. package/dist/ui/src/components/form-builder/types.mjs +5 -0
  174. package/dist/ui/src/components/form-builder/validation-schemas.cjs +67 -0
  175. package/dist/ui/src/components/form-builder/validation-schemas.mjs +56 -0
  176. package/dist/ui/src/components/form.cjs +120 -0
  177. package/dist/ui/src/components/form.mjs +98 -0
  178. package/dist/ui/src/components/input.cjs +23 -0
  179. package/dist/ui/src/components/input.mjs +21 -0
  180. package/dist/ui/src/components/label.cjs +39 -0
  181. package/dist/ui/src/components/label.mjs +23 -0
  182. package/dist/ui/src/components/page-layout.cjs +25 -0
  183. package/dist/ui/src/components/page-layout.mjs +23 -0
  184. package/dist/ui/src/components/page-wrapper.cjs +20 -0
  185. package/dist/ui/src/components/page-wrapper.mjs +18 -0
  186. package/dist/ui/src/components/popover.cjs +60 -0
  187. package/dist/ui/src/components/popover.mjs +42 -0
  188. package/dist/ui/src/components/radio-group.cjs +62 -0
  189. package/dist/ui/src/components/radio-group.mjs +45 -0
  190. package/dist/ui/src/components/select.cjs +161 -0
  191. package/dist/ui/src/components/select.mjs +139 -0
  192. package/dist/ui/src/components/separator.cjs +43 -0
  193. package/dist/ui/src/components/separator.mjs +27 -0
  194. package/dist/ui/src/components/skeleton.cjs +17 -0
  195. package/dist/ui/src/components/skeleton.mjs +15 -0
  196. package/dist/ui/src/components/stack-attribution.cjs +24 -0
  197. package/dist/ui/src/components/stack-attribution.mjs +22 -0
  198. package/dist/ui/src/components/switch.cjs +48 -0
  199. package/dist/ui/src/components/switch.mjs +32 -0
  200. package/dist/ui/src/components/table.cjs +89 -0
  201. package/dist/ui/src/components/table.mjs +82 -0
  202. package/dist/ui/src/components/tabs.cjs +84 -0
  203. package/dist/ui/src/components/tabs.mjs +65 -0
  204. package/dist/ui/src/components/textarea.cjs +20 -0
  205. package/dist/ui/src/components/textarea.mjs +18 -0
  206. package/dist/ui/src/lib/schema-converter.cjs +133 -0
  207. package/dist/ui/src/lib/schema-converter.mjs +127 -0
  208. package/dist/ui/src/lib/utils.cjs +10 -0
  209. package/dist/ui/src/lib/utils.mjs +8 -0
  210. package/dist/utils.cjs +41 -0
  211. package/dist/utils.mjs +32 -0
  212. package/package.json +175 -3
  213. package/README.md +0 -3
package/dist/db.cjs ADDED
@@ -0,0 +1,99 @@
1
+ 'use strict';
2
+
3
+ const db = require('@btst/db');
4
+
5
+ const formBuilderSchema = db.createDbPlugin("form-builder", {
6
+ form: {
7
+ modelName: "form",
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
+ // JSON Schema stored as string (includes steps, fieldType, stepGroup, etc.)
23
+ schema: {
24
+ type: "string",
25
+ required: true
26
+ },
27
+ // Optional custom success message after submission
28
+ successMessage: {
29
+ type: "string",
30
+ required: false
31
+ },
32
+ // Optional redirect URL after submission
33
+ redirectUrl: {
34
+ type: "string",
35
+ required: false
36
+ },
37
+ // Form status: active, inactive, archived
38
+ status: {
39
+ type: "string",
40
+ defaultValue: "active"
41
+ },
42
+ // User who created the form
43
+ createdBy: {
44
+ type: "string",
45
+ required: false
46
+ },
47
+ createdAt: {
48
+ type: "date",
49
+ defaultValue: () => /* @__PURE__ */ new Date()
50
+ },
51
+ updatedAt: {
52
+ type: "date",
53
+ defaultValue: () => /* @__PURE__ */ new Date()
54
+ }
55
+ }
56
+ },
57
+ formSubmission: {
58
+ modelName: "formSubmission",
59
+ fields: {
60
+ formId: {
61
+ type: "string",
62
+ required: true,
63
+ // Database reference for efficient joins
64
+ references: {
65
+ model: "form",
66
+ field: "id",
67
+ onDelete: "cascade"
68
+ }
69
+ },
70
+ // Submitted data as JSON string
71
+ data: {
72
+ type: "string",
73
+ required: true
74
+ },
75
+ // Submission timestamp
76
+ submittedAt: {
77
+ type: "date",
78
+ defaultValue: () => /* @__PURE__ */ new Date()
79
+ },
80
+ // Optional user ID if authenticated
81
+ submittedBy: {
82
+ type: "string",
83
+ required: false
84
+ },
85
+ // IP address for rate limiting and spam protection
86
+ ipAddress: {
87
+ type: "string",
88
+ required: false
89
+ },
90
+ // User agent for analytics
91
+ userAgent: {
92
+ type: "string",
93
+ required: false
94
+ }
95
+ }
96
+ }
97
+ });
98
+
99
+ exports.formBuilderSchema = formBuilderSchema;
package/dist/db.mjs ADDED
@@ -0,0 +1,97 @@
1
+ import { createDbPlugin } from '@btst/db';
2
+
3
+ const formBuilderSchema = createDbPlugin("form-builder", {
4
+ form: {
5
+ modelName: "form",
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
+ // JSON Schema stored as string (includes steps, fieldType, stepGroup, etc.)
21
+ schema: {
22
+ type: "string",
23
+ required: true
24
+ },
25
+ // Optional custom success message after submission
26
+ successMessage: {
27
+ type: "string",
28
+ required: false
29
+ },
30
+ // Optional redirect URL after submission
31
+ redirectUrl: {
32
+ type: "string",
33
+ required: false
34
+ },
35
+ // Form status: active, inactive, archived
36
+ status: {
37
+ type: "string",
38
+ defaultValue: "active"
39
+ },
40
+ // User who created the form
41
+ createdBy: {
42
+ type: "string",
43
+ required: false
44
+ },
45
+ createdAt: {
46
+ type: "date",
47
+ defaultValue: () => /* @__PURE__ */ new Date()
48
+ },
49
+ updatedAt: {
50
+ type: "date",
51
+ defaultValue: () => /* @__PURE__ */ new Date()
52
+ }
53
+ }
54
+ },
55
+ formSubmission: {
56
+ modelName: "formSubmission",
57
+ fields: {
58
+ formId: {
59
+ type: "string",
60
+ required: true,
61
+ // Database reference for efficient joins
62
+ references: {
63
+ model: "form",
64
+ field: "id",
65
+ onDelete: "cascade"
66
+ }
67
+ },
68
+ // Submitted data as JSON string
69
+ data: {
70
+ type: "string",
71
+ required: true
72
+ },
73
+ // Submission timestamp
74
+ submittedAt: {
75
+ type: "date",
76
+ defaultValue: () => /* @__PURE__ */ new Date()
77
+ },
78
+ // Optional user ID if authenticated
79
+ submittedBy: {
80
+ type: "string",
81
+ required: false
82
+ },
83
+ // IP address for rate limiting and spam protection
84
+ ipAddress: {
85
+ type: "string",
86
+ required: false
87
+ },
88
+ // User agent for analytics
89
+ userAgent: {
90
+ type: "string",
91
+ required: false
92
+ }
93
+ }
94
+ }
95
+ });
96
+
97
+ export { formBuilderSchema };
@@ -0,0 +1,95 @@
1
+ 'use strict';
2
+
3
+ const authorization = require('@btst/stack/authorization');
4
+ const z = require('zod');
5
+
6
+ const formStatusSchema = z.z.enum(["active", "inactive", "archived"]);
7
+ const resolvedFormFacts = {
8
+ formId: z.z.string(),
9
+ ownerId: z.z.string().optional(),
10
+ status: formStatusSchema
11
+ };
12
+ const formBuilderPermissions = authorization.definePermissions("forms", {
13
+ form: {
14
+ /** Read the admin collection or one admin record. */
15
+ read: authorization.permission(
16
+ z.z.discriminatedUnion("scope", [
17
+ z.z.object({ scope: z.z.literal("collection") }),
18
+ z.z.object({
19
+ scope: z.z.literal("record"),
20
+ formId: z.z.string(),
21
+ exists: z.z.boolean(),
22
+ ownerId: z.z.string().optional(),
23
+ status: formStatusSchema.optional()
24
+ })
25
+ ])
26
+ ),
27
+ /** Render one public form resolved by slug. */
28
+ render: authorization.permission(
29
+ z.z.object({
30
+ slug: z.z.string(),
31
+ exists: z.z.boolean(),
32
+ formId: z.z.string().optional(),
33
+ ownerId: z.z.string().optional(),
34
+ status: formStatusSchema.optional()
35
+ })
36
+ ),
37
+ /** Create a form. */
38
+ create: authorization.permission(),
39
+ /** Update a server-resolved form. */
40
+ update: authorization.permission(
41
+ z.z.object({
42
+ ...resolvedFormFacts
43
+ })
44
+ ),
45
+ /** Delete a server-resolved form and its submissions. */
46
+ delete: authorization.permission(
47
+ z.z.object({
48
+ ...resolvedFormFacts
49
+ })
50
+ )
51
+ },
52
+ submission: {
53
+ /** Submit to a public, server-resolved form. */
54
+ create: authorization.permission(
55
+ z.z.object({
56
+ slug: z.z.string(),
57
+ exists: z.z.boolean(),
58
+ formId: z.z.string().optional(),
59
+ ownerId: z.z.string().optional(),
60
+ status: formStatusSchema.optional()
61
+ })
62
+ ),
63
+ /** Read a form's collection or one server-resolved submission. */
64
+ read: authorization.permission(
65
+ z.z.discriminatedUnion("scope", [
66
+ z.z.object({
67
+ scope: z.z.literal("collection"),
68
+ formId: z.z.string(),
69
+ formExists: z.z.boolean(),
70
+ ownerId: z.z.string().optional()
71
+ }),
72
+ z.z.object({
73
+ scope: z.z.literal("record"),
74
+ formId: z.z.string(),
75
+ submissionId: z.z.string(),
76
+ exists: z.z.boolean(),
77
+ ownerId: z.z.string().optional(),
78
+ submittedBy: z.z.string().optional()
79
+ })
80
+ ])
81
+ ),
82
+ /** Delete a server-resolved submission. */
83
+ delete: authorization.permission(
84
+ z.z.object({
85
+ formId: z.z.string(),
86
+ submissionId: z.z.string(),
87
+ exists: z.z.boolean(),
88
+ ownerId: z.z.string().optional(),
89
+ submittedBy: z.z.string().optional()
90
+ })
91
+ )
92
+ }
93
+ });
94
+
95
+ exports.formBuilderPermissions = formBuilderPermissions;
@@ -0,0 +1,94 @@
1
+ import * as _btst_stack_authorization from '@btst/stack/authorization';
2
+ import { z } from 'zod';
3
+
4
+ /** Browser-safe, schema-backed permissions published by Form Builder. */
5
+ declare const formBuilderPermissions: _btst_stack_authorization.PermissionCatalog<"forms", {
6
+ readonly form: {
7
+ /** Read the admin collection or one admin record. */
8
+ readonly read: _btst_stack_authorization.PermissionSeed<z.ZodDiscriminatedUnion<[z.ZodObject<{
9
+ scope: z.ZodLiteral<"collection">;
10
+ }, z.core.$strip>, z.ZodObject<{
11
+ scope: z.ZodLiteral<"record">;
12
+ formId: z.ZodString;
13
+ exists: z.ZodBoolean;
14
+ ownerId: z.ZodOptional<z.ZodString>;
15
+ status: z.ZodOptional<z.ZodEnum<{
16
+ active: "active";
17
+ inactive: "inactive";
18
+ archived: "archived";
19
+ }>>;
20
+ }, z.core.$strip>], "scope">>;
21
+ /** Render one public form resolved by slug. */
22
+ readonly render: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
23
+ slug: z.ZodString;
24
+ exists: z.ZodBoolean;
25
+ formId: z.ZodOptional<z.ZodString>;
26
+ ownerId: z.ZodOptional<z.ZodString>;
27
+ status: z.ZodOptional<z.ZodEnum<{
28
+ active: "active";
29
+ inactive: "inactive";
30
+ archived: "archived";
31
+ }>>;
32
+ }, z.core.$strip>>;
33
+ /** Create a form. */
34
+ readonly create: _btst_stack_authorization.PermissionSeed<undefined>;
35
+ /** Update a server-resolved form. */
36
+ readonly update: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
37
+ formId: z.ZodString;
38
+ ownerId: z.ZodOptional<z.ZodString>;
39
+ status: z.ZodEnum<{
40
+ active: "active";
41
+ inactive: "inactive";
42
+ archived: "archived";
43
+ }>;
44
+ }, z.core.$strip>>;
45
+ /** Delete a server-resolved form and its submissions. */
46
+ readonly delete: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
47
+ formId: z.ZodString;
48
+ ownerId: z.ZodOptional<z.ZodString>;
49
+ status: z.ZodEnum<{
50
+ active: "active";
51
+ inactive: "inactive";
52
+ archived: "archived";
53
+ }>;
54
+ }, z.core.$strip>>;
55
+ };
56
+ readonly submission: {
57
+ /** Submit to a public, server-resolved form. */
58
+ readonly create: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
59
+ slug: z.ZodString;
60
+ exists: z.ZodBoolean;
61
+ formId: z.ZodOptional<z.ZodString>;
62
+ ownerId: z.ZodOptional<z.ZodString>;
63
+ status: z.ZodOptional<z.ZodEnum<{
64
+ active: "active";
65
+ inactive: "inactive";
66
+ archived: "archived";
67
+ }>>;
68
+ }, z.core.$strip>>;
69
+ /** Read a form's collection or one server-resolved submission. */
70
+ readonly read: _btst_stack_authorization.PermissionSeed<z.ZodDiscriminatedUnion<[z.ZodObject<{
71
+ scope: z.ZodLiteral<"collection">;
72
+ formId: z.ZodString;
73
+ formExists: z.ZodBoolean;
74
+ ownerId: z.ZodOptional<z.ZodString>;
75
+ }, z.core.$strip>, z.ZodObject<{
76
+ scope: z.ZodLiteral<"record">;
77
+ formId: z.ZodString;
78
+ submissionId: z.ZodString;
79
+ exists: z.ZodBoolean;
80
+ ownerId: z.ZodOptional<z.ZodString>;
81
+ submittedBy: z.ZodOptional<z.ZodString>;
82
+ }, z.core.$strip>], "scope">>;
83
+ /** Delete a server-resolved submission. */
84
+ readonly delete: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
85
+ formId: z.ZodString;
86
+ submissionId: z.ZodString;
87
+ exists: z.ZodBoolean;
88
+ ownerId: z.ZodOptional<z.ZodString>;
89
+ submittedBy: z.ZodOptional<z.ZodString>;
90
+ }, z.core.$strip>>;
91
+ };
92
+ }>;
93
+
94
+ export { formBuilderPermissions };
@@ -0,0 +1,94 @@
1
+ import * as _btst_stack_authorization from '@btst/stack/authorization';
2
+ import { z } from 'zod';
3
+
4
+ /** Browser-safe, schema-backed permissions published by Form Builder. */
5
+ declare const formBuilderPermissions: _btst_stack_authorization.PermissionCatalog<"forms", {
6
+ readonly form: {
7
+ /** Read the admin collection or one admin record. */
8
+ readonly read: _btst_stack_authorization.PermissionSeed<z.ZodDiscriminatedUnion<[z.ZodObject<{
9
+ scope: z.ZodLiteral<"collection">;
10
+ }, z.core.$strip>, z.ZodObject<{
11
+ scope: z.ZodLiteral<"record">;
12
+ formId: z.ZodString;
13
+ exists: z.ZodBoolean;
14
+ ownerId: z.ZodOptional<z.ZodString>;
15
+ status: z.ZodOptional<z.ZodEnum<{
16
+ active: "active";
17
+ inactive: "inactive";
18
+ archived: "archived";
19
+ }>>;
20
+ }, z.core.$strip>], "scope">>;
21
+ /** Render one public form resolved by slug. */
22
+ readonly render: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
23
+ slug: z.ZodString;
24
+ exists: z.ZodBoolean;
25
+ formId: z.ZodOptional<z.ZodString>;
26
+ ownerId: z.ZodOptional<z.ZodString>;
27
+ status: z.ZodOptional<z.ZodEnum<{
28
+ active: "active";
29
+ inactive: "inactive";
30
+ archived: "archived";
31
+ }>>;
32
+ }, z.core.$strip>>;
33
+ /** Create a form. */
34
+ readonly create: _btst_stack_authorization.PermissionSeed<undefined>;
35
+ /** Update a server-resolved form. */
36
+ readonly update: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
37
+ formId: z.ZodString;
38
+ ownerId: z.ZodOptional<z.ZodString>;
39
+ status: z.ZodEnum<{
40
+ active: "active";
41
+ inactive: "inactive";
42
+ archived: "archived";
43
+ }>;
44
+ }, z.core.$strip>>;
45
+ /** Delete a server-resolved form and its submissions. */
46
+ readonly delete: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
47
+ formId: z.ZodString;
48
+ ownerId: z.ZodOptional<z.ZodString>;
49
+ status: z.ZodEnum<{
50
+ active: "active";
51
+ inactive: "inactive";
52
+ archived: "archived";
53
+ }>;
54
+ }, z.core.$strip>>;
55
+ };
56
+ readonly submission: {
57
+ /** Submit to a public, server-resolved form. */
58
+ readonly create: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
59
+ slug: z.ZodString;
60
+ exists: z.ZodBoolean;
61
+ formId: z.ZodOptional<z.ZodString>;
62
+ ownerId: z.ZodOptional<z.ZodString>;
63
+ status: z.ZodOptional<z.ZodEnum<{
64
+ active: "active";
65
+ inactive: "inactive";
66
+ archived: "archived";
67
+ }>>;
68
+ }, z.core.$strip>>;
69
+ /** Read a form's collection or one server-resolved submission. */
70
+ readonly read: _btst_stack_authorization.PermissionSeed<z.ZodDiscriminatedUnion<[z.ZodObject<{
71
+ scope: z.ZodLiteral<"collection">;
72
+ formId: z.ZodString;
73
+ formExists: z.ZodBoolean;
74
+ ownerId: z.ZodOptional<z.ZodString>;
75
+ }, z.core.$strip>, z.ZodObject<{
76
+ scope: z.ZodLiteral<"record">;
77
+ formId: z.ZodString;
78
+ submissionId: z.ZodString;
79
+ exists: z.ZodBoolean;
80
+ ownerId: z.ZodOptional<z.ZodString>;
81
+ submittedBy: z.ZodOptional<z.ZodString>;
82
+ }, z.core.$strip>], "scope">>;
83
+ /** Delete a server-resolved submission. */
84
+ readonly delete: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
85
+ formId: z.ZodString;
86
+ submissionId: z.ZodString;
87
+ exists: z.ZodBoolean;
88
+ ownerId: z.ZodOptional<z.ZodString>;
89
+ submittedBy: z.ZodOptional<z.ZodString>;
90
+ }, z.core.$strip>>;
91
+ };
92
+ }>;
93
+
94
+ export { formBuilderPermissions };
@@ -0,0 +1,94 @@
1
+ import * as _btst_stack_authorization from '@btst/stack/authorization';
2
+ import { z } from 'zod';
3
+
4
+ /** Browser-safe, schema-backed permissions published by Form Builder. */
5
+ declare const formBuilderPermissions: _btst_stack_authorization.PermissionCatalog<"forms", {
6
+ readonly form: {
7
+ /** Read the admin collection or one admin record. */
8
+ readonly read: _btst_stack_authorization.PermissionSeed<z.ZodDiscriminatedUnion<[z.ZodObject<{
9
+ scope: z.ZodLiteral<"collection">;
10
+ }, z.core.$strip>, z.ZodObject<{
11
+ scope: z.ZodLiteral<"record">;
12
+ formId: z.ZodString;
13
+ exists: z.ZodBoolean;
14
+ ownerId: z.ZodOptional<z.ZodString>;
15
+ status: z.ZodOptional<z.ZodEnum<{
16
+ active: "active";
17
+ inactive: "inactive";
18
+ archived: "archived";
19
+ }>>;
20
+ }, z.core.$strip>], "scope">>;
21
+ /** Render one public form resolved by slug. */
22
+ readonly render: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
23
+ slug: z.ZodString;
24
+ exists: z.ZodBoolean;
25
+ formId: z.ZodOptional<z.ZodString>;
26
+ ownerId: z.ZodOptional<z.ZodString>;
27
+ status: z.ZodOptional<z.ZodEnum<{
28
+ active: "active";
29
+ inactive: "inactive";
30
+ archived: "archived";
31
+ }>>;
32
+ }, z.core.$strip>>;
33
+ /** Create a form. */
34
+ readonly create: _btst_stack_authorization.PermissionSeed<undefined>;
35
+ /** Update a server-resolved form. */
36
+ readonly update: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
37
+ formId: z.ZodString;
38
+ ownerId: z.ZodOptional<z.ZodString>;
39
+ status: z.ZodEnum<{
40
+ active: "active";
41
+ inactive: "inactive";
42
+ archived: "archived";
43
+ }>;
44
+ }, z.core.$strip>>;
45
+ /** Delete a server-resolved form and its submissions. */
46
+ readonly delete: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
47
+ formId: z.ZodString;
48
+ ownerId: z.ZodOptional<z.ZodString>;
49
+ status: z.ZodEnum<{
50
+ active: "active";
51
+ inactive: "inactive";
52
+ archived: "archived";
53
+ }>;
54
+ }, z.core.$strip>>;
55
+ };
56
+ readonly submission: {
57
+ /** Submit to a public, server-resolved form. */
58
+ readonly create: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
59
+ slug: z.ZodString;
60
+ exists: z.ZodBoolean;
61
+ formId: z.ZodOptional<z.ZodString>;
62
+ ownerId: z.ZodOptional<z.ZodString>;
63
+ status: z.ZodOptional<z.ZodEnum<{
64
+ active: "active";
65
+ inactive: "inactive";
66
+ archived: "archived";
67
+ }>>;
68
+ }, z.core.$strip>>;
69
+ /** Read a form's collection or one server-resolved submission. */
70
+ readonly read: _btst_stack_authorization.PermissionSeed<z.ZodDiscriminatedUnion<[z.ZodObject<{
71
+ scope: z.ZodLiteral<"collection">;
72
+ formId: z.ZodString;
73
+ formExists: z.ZodBoolean;
74
+ ownerId: z.ZodOptional<z.ZodString>;
75
+ }, z.core.$strip>, z.ZodObject<{
76
+ scope: z.ZodLiteral<"record">;
77
+ formId: z.ZodString;
78
+ submissionId: z.ZodString;
79
+ exists: z.ZodBoolean;
80
+ ownerId: z.ZodOptional<z.ZodString>;
81
+ submittedBy: z.ZodOptional<z.ZodString>;
82
+ }, z.core.$strip>], "scope">>;
83
+ /** Delete a server-resolved submission. */
84
+ readonly delete: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
85
+ formId: z.ZodString;
86
+ submissionId: z.ZodString;
87
+ exists: z.ZodBoolean;
88
+ ownerId: z.ZodOptional<z.ZodString>;
89
+ submittedBy: z.ZodOptional<z.ZodString>;
90
+ }, z.core.$strip>>;
91
+ };
92
+ }>;
93
+
94
+ export { formBuilderPermissions };
@@ -0,0 +1,93 @@
1
+ import { definePermissions, permission } from '@btst/stack/authorization';
2
+ import { z } from 'zod';
3
+
4
+ const formStatusSchema = z.enum(["active", "inactive", "archived"]);
5
+ const resolvedFormFacts = {
6
+ formId: z.string(),
7
+ ownerId: z.string().optional(),
8
+ status: formStatusSchema
9
+ };
10
+ const formBuilderPermissions = definePermissions("forms", {
11
+ form: {
12
+ /** Read the admin collection or one admin record. */
13
+ read: permission(
14
+ z.discriminatedUnion("scope", [
15
+ z.object({ scope: z.literal("collection") }),
16
+ z.object({
17
+ scope: z.literal("record"),
18
+ formId: z.string(),
19
+ exists: z.boolean(),
20
+ ownerId: z.string().optional(),
21
+ status: formStatusSchema.optional()
22
+ })
23
+ ])
24
+ ),
25
+ /** Render one public form resolved by slug. */
26
+ render: permission(
27
+ z.object({
28
+ slug: z.string(),
29
+ exists: z.boolean(),
30
+ formId: z.string().optional(),
31
+ ownerId: z.string().optional(),
32
+ status: formStatusSchema.optional()
33
+ })
34
+ ),
35
+ /** Create a form. */
36
+ create: permission(),
37
+ /** Update a server-resolved form. */
38
+ update: permission(
39
+ z.object({
40
+ ...resolvedFormFacts
41
+ })
42
+ ),
43
+ /** Delete a server-resolved form and its submissions. */
44
+ delete: permission(
45
+ z.object({
46
+ ...resolvedFormFacts
47
+ })
48
+ )
49
+ },
50
+ submission: {
51
+ /** Submit to a public, server-resolved form. */
52
+ create: permission(
53
+ z.object({
54
+ slug: z.string(),
55
+ exists: z.boolean(),
56
+ formId: z.string().optional(),
57
+ ownerId: z.string().optional(),
58
+ status: formStatusSchema.optional()
59
+ })
60
+ ),
61
+ /** Read a form's collection or one server-resolved submission. */
62
+ read: permission(
63
+ z.discriminatedUnion("scope", [
64
+ z.object({
65
+ scope: z.literal("collection"),
66
+ formId: z.string(),
67
+ formExists: z.boolean(),
68
+ ownerId: z.string().optional()
69
+ }),
70
+ z.object({
71
+ scope: z.literal("record"),
72
+ formId: z.string(),
73
+ submissionId: z.string(),
74
+ exists: z.boolean(),
75
+ ownerId: z.string().optional(),
76
+ submittedBy: z.string().optional()
77
+ })
78
+ ])
79
+ ),
80
+ /** Delete a server-resolved submission. */
81
+ delete: permission(
82
+ z.object({
83
+ formId: z.string(),
84
+ submissionId: z.string(),
85
+ exists: z.boolean(),
86
+ ownerId: z.string().optional(),
87
+ submittedBy: z.string().optional()
88
+ })
89
+ )
90
+ }
91
+ });
92
+
93
+ export { formBuilderPermissions };