@columnus/shared 0.1.47

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 (206) hide show
  1. package/LICENSE +21 -0
  2. package/dist/apiProfile.d.ts +1072 -0
  3. package/dist/apiProfile.js +4210 -0
  4. package/dist/apiProfile.js.map +1 -0
  5. package/dist/apiProfileSlug.d.ts +11 -0
  6. package/dist/apiProfileSlug.js +39 -0
  7. package/dist/apiProfileSlug.js.map +1 -0
  8. package/dist/apiToken.d.ts +6 -0
  9. package/dist/apiToken.js +35 -0
  10. package/dist/apiToken.js.map +1 -0
  11. package/dist/betterAuthSession.d.ts +8 -0
  12. package/dist/betterAuthSession.js +57 -0
  13. package/dist/betterAuthSession.js.map +1 -0
  14. package/dist/bffHost.d.ts +36 -0
  15. package/dist/bffHost.js +74 -0
  16. package/dist/bffHost.js.map +1 -0
  17. package/dist/bffProtocol.d.ts +1357 -0
  18. package/dist/bffProtocol.js +4362 -0
  19. package/dist/bffProtocol.js.map +1 -0
  20. package/dist/bffRedact.d.ts +30 -0
  21. package/dist/bffRedact.js +55 -0
  22. package/dist/bffRedact.js.map +1 -0
  23. package/dist/ciPreviewEnv.d.ts +49 -0
  24. package/dist/ciPreviewEnv.js +143 -0
  25. package/dist/ciPreviewEnv.js.map +1 -0
  26. package/dist/clipboardTransfer.d.ts +25 -0
  27. package/dist/clipboardTransfer.js +4862 -0
  28. package/dist/clipboardTransfer.js.map +1 -0
  29. package/dist/convexSiteUrl.d.ts +73 -0
  30. package/dist/convexSiteUrl.js +137 -0
  31. package/dist/convexSiteUrl.js.map +1 -0
  32. package/dist/csv.d.ts +54 -0
  33. package/dist/csv.js +5499 -0
  34. package/dist/csv.js.map +1 -0
  35. package/dist/dataTransfer.d.ts +21 -0
  36. package/dist/dataTransfer.js +74 -0
  37. package/dist/dataTransfer.js.map +1 -0
  38. package/dist/dateValues.d.ts +18 -0
  39. package/dist/dateValues.js +73 -0
  40. package/dist/dateValues.js.map +1 -0
  41. package/dist/deployOutput.d.ts +3 -0
  42. package/dist/deployOutput.js +23 -0
  43. package/dist/deployOutput.js.map +1 -0
  44. package/dist/displayLabel.d.ts +13 -0
  45. package/dist/displayLabel.js +4342 -0
  46. package/dist/displayLabel.js.map +1 -0
  47. package/dist/displayTemplateGenerator.d.ts +11 -0
  48. package/dist/displayTemplateGenerator.js +98 -0
  49. package/dist/displayTemplateGenerator.js.map +1 -0
  50. package/dist/displayTypes.d.ts +10 -0
  51. package/dist/displayTypes.js +3 -0
  52. package/dist/displayTypes.js.map +1 -0
  53. package/dist/dotenv.d.ts +8 -0
  54. package/dist/dotenv.js +61 -0
  55. package/dist/dotenv.js.map +1 -0
  56. package/dist/erdLayout.d.ts +27 -0
  57. package/dist/erdLayout.js +78 -0
  58. package/dist/erdLayout.js.map +1 -0
  59. package/dist/fieldTypeFormat.d.ts +5 -0
  60. package/dist/fieldTypeFormat.js +63 -0
  61. package/dist/fieldTypeFormat.js.map +1 -0
  62. package/dist/fieldTypeMeta.d.ts +50 -0
  63. package/dist/fieldTypeMeta.js +84 -0
  64. package/dist/fieldTypeMeta.js.map +1 -0
  65. package/dist/fieldValueEqual.d.ts +4 -0
  66. package/dist/fieldValueEqual.js +58 -0
  67. package/dist/fieldValueEqual.js.map +1 -0
  68. package/dist/importMatch.d.ts +80 -0
  69. package/dist/importMatch.js +5643 -0
  70. package/dist/importMatch.js.map +1 -0
  71. package/dist/index.d.ts +58 -0
  72. package/dist/index.js +10647 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/inferIdentifier.d.ts +18 -0
  75. package/dist/inferIdentifier.js +49 -0
  76. package/dist/inferIdentifier.js.map +1 -0
  77. package/dist/keyboard.d.ts +16 -0
  78. package/dist/keyboard.js +71 -0
  79. package/dist/keyboard.js.map +1 -0
  80. package/dist/manifestDeploy.d.ts +27 -0
  81. package/dist/manifestDeploy.js +16 -0
  82. package/dist/manifestDeploy.js.map +1 -0
  83. package/dist/manifestHash.d.ts +11 -0
  84. package/dist/manifestHash.js +35 -0
  85. package/dist/manifestHash.js.map +1 -0
  86. package/dist/previewDeployName.d.ts +26 -0
  87. package/dist/previewDeployName.js +77 -0
  88. package/dist/previewDeployName.js.map +1 -0
  89. package/dist/proposePolicy.d.ts +17 -0
  90. package/dist/proposePolicy.js +33 -0
  91. package/dist/proposePolicy.js.map +1 -0
  92. package/dist/queryBetween.d.ts +20 -0
  93. package/dist/queryBetween.js +28 -0
  94. package/dist/queryBetween.js.map +1 -0
  95. package/dist/queryExecution.d.ts +5 -0
  96. package/dist/queryExecution.js +58 -0
  97. package/dist/queryExecution.js.map +1 -0
  98. package/dist/queryFieldOps.d.ts +66 -0
  99. package/dist/queryFieldOps.js +138 -0
  100. package/dist/queryFieldOps.js.map +1 -0
  101. package/dist/queryMerge.d.ts +29 -0
  102. package/dist/queryMerge.js +4277 -0
  103. package/dist/queryMerge.js.map +1 -0
  104. package/dist/queryPlan.d.ts +97 -0
  105. package/dist/queryPlan.js +4564 -0
  106. package/dist/queryPlan.js.map +1 -0
  107. package/dist/queryStudio.d.ts +25 -0
  108. package/dist/queryStudio.js +4658 -0
  109. package/dist/queryStudio.js.map +1 -0
  110. package/dist/queryTypes.d.ts +402 -0
  111. package/dist/queryTypes.js +4239 -0
  112. package/dist/queryTypes.js.map +1 -0
  113. package/dist/queryValidators.d.ts +99 -0
  114. package/dist/queryValidators.js +76 -0
  115. package/dist/queryValidators.js.map +1 -0
  116. package/dist/readApiQuery.d.ts +10 -0
  117. package/dist/readApiQuery.js +24 -0
  118. package/dist/readApiQuery.js.map +1 -0
  119. package/dist/recordTableColumns.d.ts +21 -0
  120. package/dist/recordTableColumns.js +4469 -0
  121. package/dist/recordTableColumns.js.map +1 -0
  122. package/dist/refDisplayRequests.d.ts +17 -0
  123. package/dist/refDisplayRequests.js +4877 -0
  124. package/dist/refDisplayRequests.js.map +1 -0
  125. package/dist/refGraph.d.ts +23 -0
  126. package/dist/refGraph.js +102 -0
  127. package/dist/refGraph.js.map +1 -0
  128. package/dist/refsRecompute.d.ts +8 -0
  129. package/dist/refsRecompute.js +12 -0
  130. package/dist/refsRecompute.js.map +1 -0
  131. package/dist/richDoc.d.ts +67 -0
  132. package/dist/richDoc.js +4408 -0
  133. package/dist/richDoc.js.map +1 -0
  134. package/dist/schemaGenerator.d.ts +31 -0
  135. package/dist/schemaGenerator.js +198 -0
  136. package/dist/schemaGenerator.js.map +1 -0
  137. package/dist/schemaShrink.d.ts +74 -0
  138. package/dist/schemaShrink.js +132 -0
  139. package/dist/schemaShrink.js.map +1 -0
  140. package/dist/schemaShrinkValidators.d.ts +72 -0
  141. package/dist/schemaShrinkValidators.js +31 -0
  142. package/dist/schemaShrinkValidators.js.map +1 -0
  143. package/dist/schemaTypes.d.ts +454 -0
  144. package/dist/schemaTypes.js +4557 -0
  145. package/dist/schemaTypes.js.map +1 -0
  146. package/dist/share.d.ts +8 -0
  147. package/dist/share.js +4755 -0
  148. package/dist/share.js.map +1 -0
  149. package/dist/shareApiBridge.d.ts +18 -0
  150. package/dist/shareApiBridge.js +4283 -0
  151. package/dist/shareApiBridge.js.map +1 -0
  152. package/dist/shareGuestPolicy.d.ts +14 -0
  153. package/dist/shareGuestPolicy.js +90 -0
  154. package/dist/shareGuestPolicy.js.map +1 -0
  155. package/dist/shareProposal.d.ts +113 -0
  156. package/dist/shareProposal.js +4810 -0
  157. package/dist/shareProposal.js.map +1 -0
  158. package/dist/shareProposalDiff.d.ts +13 -0
  159. package/dist/shareProposalDiff.js +91 -0
  160. package/dist/shareProposalDiff.js.map +1 -0
  161. package/dist/shareScopes.d.ts +14 -0
  162. package/dist/shareScopes.js +223 -0
  163. package/dist/shareScopes.js.map +1 -0
  164. package/dist/shareTokenCrypto.d.ts +9 -0
  165. package/dist/shareTokenCrypto.js +87 -0
  166. package/dist/shareTokenCrypto.js.map +1 -0
  167. package/dist/shareTokens.d.ts +6 -0
  168. package/dist/shareTokens.js +26 -0
  169. package/dist/shareTokens.js.map +1 -0
  170. package/dist/shareTypes.d.ts +107 -0
  171. package/dist/shareTypes.js +3 -0
  172. package/dist/shareTypes.js.map +1 -0
  173. package/dist/shareValidators.d.ts +168 -0
  174. package/dist/shareValidators.js +124 -0
  175. package/dist/shareValidators.js.map +1 -0
  176. package/dist/shareWizard.d.ts +14 -0
  177. package/dist/shareWizard.js +200 -0
  178. package/dist/shareWizard.js.map +1 -0
  179. package/dist/spaceBundle.d.ts +67 -0
  180. package/dist/spaceBundle.js +4664 -0
  181. package/dist/spaceBundle.js.map +1 -0
  182. package/dist/storageFieldValues.d.ts +10 -0
  183. package/dist/storageFieldValues.js +4421 -0
  184. package/dist/storageFieldValues.js.map +1 -0
  185. package/dist/studioBoot.d.ts +49 -0
  186. package/dist/studioBoot.js +167 -0
  187. package/dist/studioBoot.js.map +1 -0
  188. package/dist/syncClampMembership.d.ts +22 -0
  189. package/dist/syncClampMembership.js +74 -0
  190. package/dist/syncClampMembership.js.map +1 -0
  191. package/dist/tenantHosts.d.ts +30 -0
  192. package/dist/tenantHosts.js +60 -0
  193. package/dist/tenantHosts.js.map +1 -0
  194. package/dist/tenantSecretsCrypto.d.ts +31 -0
  195. package/dist/tenantSecretsCrypto.js +145 -0
  196. package/dist/tenantSecretsCrypto.js.map +1 -0
  197. package/dist/useDebouncedCommit.d.ts +11 -0
  198. package/dist/useDebouncedCommit.js +34 -0
  199. package/dist/useDebouncedCommit.js.map +1 -0
  200. package/dist/useDebouncedValue.d.ts +1 -0
  201. package/dist/useDebouncedValue.js +15 -0
  202. package/dist/useDebouncedValue.js.map +1 -0
  203. package/dist/useModifierHeld.d.ts +2 -0
  204. package/dist/useModifierHeld.js +28 -0
  205. package/dist/useModifierHeld.js.map +1 -0
  206. package/package.json +36 -0
@@ -0,0 +1,107 @@
1
+ import type { ClampQuery } from "./queryTypes.ts";
2
+ export type SharePermission = "view" | "propose";
3
+ export type ShareAccess = "full" | "referenced";
4
+ export type ShareOperation = "insert" | "update" | "delete";
5
+ export type ShareOps = {
6
+ insert: boolean;
7
+ update: boolean;
8
+ delete: boolean;
9
+ };
10
+ export type ShareFormAccess = {
11
+ submit: boolean;
12
+ searchReferences: boolean;
13
+ createReferences: boolean;
14
+ };
15
+ export type ShareScope = {
16
+ table: string;
17
+ /** Explicit guest-navigation membership. Normalization fills legacy omissions. */
18
+ primary?: boolean;
19
+ access: ShareAccess;
20
+ recordIds?: string[];
21
+ permission: SharePermission;
22
+ ops: ShareOps;
23
+ allowCreate?: boolean;
24
+ /** Optional form allowlist. Omitted means every non-system manifest field. */
25
+ allowedFields?: string[];
26
+ /** Submit and reference-picker capabilities for form and propose links. */
27
+ formAccess?: ShareFormAccess;
28
+ /** Opaque row clamp AND-merged with optional guest Query on full-table lists. */
29
+ rowQuery?: ClampQuery;
30
+ /** Scan ceiling for this scope; guest maxScan may only lower. */
31
+ maxScanLimit?: number;
32
+ };
33
+ export type ShareInviteKind = "recipient" | "public";
34
+ export type ShareInviteAuth = "token" | "email";
35
+ export type ShareScopeAccessMode = "full" | "selected" | "referenced";
36
+ export type ShareLinkType = "form" | "view" | "propose";
37
+ export type ShareGuestViewMode = "grid" | "detail";
38
+ export type ShareWizardTableInput = {
39
+ table: string;
40
+ recordIds?: string[];
41
+ allowedFields?: string[];
42
+ };
43
+ export type ShareWizardReferenceInput = {
44
+ table: string;
45
+ searchReferences: boolean;
46
+ createReferences: boolean;
47
+ };
48
+ export type ShareWizardInput = {
49
+ tables: ShareWizardTableInput[];
50
+ ops?: Partial<ShareOps>;
51
+ references?: ShareWizardReferenceInput[];
52
+ };
53
+ export type ShareRefChoice = "pick" | "create" | "hide";
54
+ export type ShareConfiguratorState = {
55
+ tables: string[];
56
+ allowedFields: Record<string, string[]>;
57
+ recordIds: Record<string, string>;
58
+ refChoices: Record<string, ShareRefChoice>;
59
+ ops: ShareOps;
60
+ };
61
+ export type GuestCapabilityInput = {
62
+ link: {
63
+ type: ShareLinkType;
64
+ };
65
+ invite: {
66
+ kind: ShareInviteKind;
67
+ };
68
+ };
69
+ export type GuestLinkCapabilities = {
70
+ formMode: boolean;
71
+ canBrowseRows: boolean;
72
+ canListProposals: boolean;
73
+ canUpsertPatches: boolean;
74
+ canToggleViewMode: boolean;
75
+ };
76
+ export type GuestScopeCapabilities = {
77
+ visibleInNav: boolean;
78
+ canReadDisplay: boolean;
79
+ canSearchReferences: boolean;
80
+ canCreateReferences: boolean;
81
+ canProposeInsert: boolean;
82
+ canProposeUpdate: boolean;
83
+ canProposeDelete: boolean;
84
+ };
85
+ export type GuestCapabilities = {
86
+ link: GuestLinkCapabilities;
87
+ scope?: GuestScopeCapabilities;
88
+ };
89
+ export type ShareScopeConflictPatch = {
90
+ table: string;
91
+ rowId: string;
92
+ op: ShareOperation;
93
+ fields: Record<string, unknown>;
94
+ };
95
+ export type ProposalFieldDiff = {
96
+ field: string;
97
+ before: unknown;
98
+ after: unknown;
99
+ };
100
+ /** Full-record proposal review row (schema field order, including unchanged). */
101
+ export type ProposalRecordFieldDiff = {
102
+ field: string;
103
+ before: unknown;
104
+ after: unknown;
105
+ changed: boolean;
106
+ };
107
+ export type ProposalDiffViewMode = "diff" | "table";
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=shareTypes.js.map
3
+ //# sourceMappingURL=shareTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"shareTypes.js"}
@@ -0,0 +1,168 @@
1
+ /** Convex boundary validators shared by the share component and host facade. */
2
+ export declare const shareScopeValidator: import("convex/values").VObject<{
3
+ allowedFields?: string[] | undefined;
4
+ recordIds?: string[] | undefined;
5
+ rowQuery?: {
6
+ predicates?: any[] | undefined;
7
+ order?: {
8
+ field: string;
9
+ direction: "asc" | "desc";
10
+ } | undefined;
11
+ search?: {
12
+ index: string;
13
+ query: string;
14
+ } | undefined;
15
+ } | undefined;
16
+ maxScanLimit?: number | undefined;
17
+ primary?: boolean | undefined;
18
+ allowCreate?: boolean | undefined;
19
+ formAccess?: {
20
+ submit: boolean;
21
+ searchReferences: boolean;
22
+ createReferences: boolean;
23
+ } | undefined;
24
+ ops: {
25
+ insert: boolean;
26
+ update: boolean;
27
+ delete: boolean;
28
+ };
29
+ table: string;
30
+ access: "full" | "referenced";
31
+ permission: "propose" | "view";
32
+ }, {
33
+ table: import("convex/values").VString<string, "required">;
34
+ primary: import("convex/values").VBoolean<boolean | undefined, "optional">;
35
+ access: import("convex/values").VUnion<"full" | "referenced", [import("convex/values").VLiteral<"full", "required">, import("convex/values").VLiteral<"referenced", "required">], "required", never>;
36
+ recordIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
37
+ permission: import("convex/values").VUnion<"propose" | "view", [import("convex/values").VLiteral<"view", "required">, import("convex/values").VLiteral<"propose", "required">], "required", never>;
38
+ ops: import("convex/values").VObject<{
39
+ insert: boolean;
40
+ update: boolean;
41
+ delete: boolean;
42
+ }, {
43
+ insert: import("convex/values").VBoolean<boolean, "required">;
44
+ update: import("convex/values").VBoolean<boolean, "required">;
45
+ delete: import("convex/values").VBoolean<boolean, "required">;
46
+ }, "required", "insert" | "update" | "delete">;
47
+ allowCreate: import("convex/values").VBoolean<boolean | undefined, "optional">;
48
+ allowedFields: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
49
+ formAccess: import("convex/values").VObject<{
50
+ submit: boolean;
51
+ searchReferences: boolean;
52
+ createReferences: boolean;
53
+ } | undefined, {
54
+ submit: import("convex/values").VBoolean<boolean, "required">;
55
+ searchReferences: import("convex/values").VBoolean<boolean, "required">;
56
+ createReferences: import("convex/values").VBoolean<boolean, "required">;
57
+ }, "optional", "submit" | "searchReferences" | "createReferences">;
58
+ rowQuery: import("convex/values").VObject<{
59
+ predicates?: any[] | undefined;
60
+ order?: {
61
+ field: string;
62
+ direction: "asc" | "desc";
63
+ } | undefined;
64
+ search?: {
65
+ index: string;
66
+ query: string;
67
+ } | undefined;
68
+ } | undefined, {
69
+ predicates: import("convex/values").VArray<any[] | undefined, import("convex/values").VUnion<any, [import("convex/values").GenericValidator, import("convex/values").GenericValidator, ...import("convex/values").GenericValidator[]], "required", any>, "optional">;
70
+ order: import("convex/values").VObject<{
71
+ field: string;
72
+ direction: "asc" | "desc";
73
+ } | undefined, {
74
+ field: import("convex/values").VString<string, "required">;
75
+ direction: import("convex/values").VUnion<"asc" | "desc", [import("convex/values").VLiteral<"asc", "required">, import("convex/values").VLiteral<"desc", "required">], "required", never>;
76
+ }, "optional", "field" | "direction">;
77
+ search: import("convex/values").VObject<{
78
+ index: string;
79
+ query: string;
80
+ } | undefined, {
81
+ index: import("convex/values").VString<string, "required">;
82
+ query: import("convex/values").VString<string, "required">;
83
+ }, "optional", "index" | "query">;
84
+ }, "optional", "predicates" | "order" | "search" | "order.field" | "order.direction" | "search.index" | "search.query">;
85
+ maxScanLimit: import("convex/values").VFloat64<number | undefined, "optional">;
86
+ }, "required", "ops" | "table" | "access" | "allowedFields" | "recordIds" | "rowQuery" | "maxScanLimit" | "primary" | "permission" | "allowCreate" | "formAccess" | "ops.insert" | "ops.update" | "ops.delete" | "rowQuery.predicates" | "rowQuery.order" | "rowQuery.search" | "rowQuery.order.field" | "rowQuery.order.direction" | "rowQuery.search.index" | "rowQuery.search.query" | "formAccess.submit" | "formAccess.searchReferences" | "formAccess.createReferences">;
87
+ export declare const shareWizardTableValidator: import("convex/values").VObject<{
88
+ allowedFields?: string[] | undefined;
89
+ recordIds?: string[] | undefined;
90
+ table: string;
91
+ }, {
92
+ table: import("convex/values").VString<string, "required">;
93
+ recordIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
94
+ allowedFields: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
95
+ }, "required", "table" | "allowedFields" | "recordIds">;
96
+ export declare const shareWizardReferenceValidator: import("convex/values").VObject<{
97
+ table: string;
98
+ searchReferences: boolean;
99
+ createReferences: boolean;
100
+ }, {
101
+ table: import("convex/values").VString<string, "required">;
102
+ searchReferences: import("convex/values").VBoolean<boolean, "required">;
103
+ createReferences: import("convex/values").VBoolean<boolean, "required">;
104
+ }, "required", "table" | "searchReferences" | "createReferences">;
105
+ export declare const shareWizardInputValidator: import("convex/values").VObject<{
106
+ ops?: {
107
+ insert: boolean;
108
+ update: boolean;
109
+ delete: boolean;
110
+ } | undefined;
111
+ references?: {
112
+ table: string;
113
+ searchReferences: boolean;
114
+ createReferences: boolean;
115
+ }[] | undefined;
116
+ tables: {
117
+ allowedFields?: string[] | undefined;
118
+ recordIds?: string[] | undefined;
119
+ table: string;
120
+ }[];
121
+ }, {
122
+ tables: import("convex/values").VArray<{
123
+ allowedFields?: string[] | undefined;
124
+ recordIds?: string[] | undefined;
125
+ table: string;
126
+ }[], import("convex/values").VObject<{
127
+ allowedFields?: string[] | undefined;
128
+ recordIds?: string[] | undefined;
129
+ table: string;
130
+ }, {
131
+ table: import("convex/values").VString<string, "required">;
132
+ recordIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
133
+ allowedFields: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
134
+ }, "required", "table" | "allowedFields" | "recordIds">, "required">;
135
+ ops: import("convex/values").VObject<{
136
+ insert: boolean;
137
+ update: boolean;
138
+ delete: boolean;
139
+ } | undefined, {
140
+ insert: import("convex/values").VBoolean<boolean, "required">;
141
+ update: import("convex/values").VBoolean<boolean, "required">;
142
+ delete: import("convex/values").VBoolean<boolean, "required">;
143
+ }, "optional", "insert" | "update" | "delete">;
144
+ references: import("convex/values").VArray<{
145
+ table: string;
146
+ searchReferences: boolean;
147
+ createReferences: boolean;
148
+ }[] | undefined, import("convex/values").VObject<{
149
+ table: string;
150
+ searchReferences: boolean;
151
+ createReferences: boolean;
152
+ }, {
153
+ table: import("convex/values").VString<string, "required">;
154
+ searchReferences: import("convex/values").VBoolean<boolean, "required">;
155
+ createReferences: import("convex/values").VBoolean<boolean, "required">;
156
+ }, "required", "table" | "searchReferences" | "createReferences">, "optional">;
157
+ }, "required", "ops" | "tables" | "ops.insert" | "ops.update" | "ops.delete" | "references">;
158
+ export declare const sharePatchValidator: import("convex/values").VObject<{
159
+ rowId?: string | undefined;
160
+ op: "insert" | "update" | "delete";
161
+ table: string;
162
+ fields: any;
163
+ }, {
164
+ table: import("convex/values").VString<string, "required">;
165
+ rowId: import("convex/values").VString<string | undefined, "optional">;
166
+ op: import("convex/values").VUnion<"insert" | "update" | "delete", [import("convex/values").VLiteral<"update", "required">, import("convex/values").VLiteral<"insert", "required">, import("convex/values").VLiteral<"delete", "required">], "required", never>;
167
+ fields: import("convex/values").VAny<any, "required", string>;
168
+ }, "required", "op" | "table" | "fields" | "rowId" | `fields.${string}`>;
@@ -0,0 +1,124 @@
1
+ import { v } from 'convex/values';
2
+
3
+ // packages/@columnus/shared/src/shareValidators.ts
4
+
5
+ // packages/@columnus/shared/src/queryFieldOps.ts
6
+ var PREDICATE_VARIANTS = [
7
+ {
8
+ value: "unknown",
9
+ ops: [
10
+ { op: "eq", label: "=" },
11
+ { op: "neq", label: "\u2260" }
12
+ ]
13
+ },
14
+ { value: "unknownArray", ops: [{ op: "in", label: "in" }] },
15
+ {
16
+ value: "unknown",
17
+ ops: [
18
+ { op: "gt", label: ">" },
19
+ { op: "gte", label: "\u2265" },
20
+ { op: "lt", label: "<" },
21
+ { op: "lte", label: "\u2264" }
22
+ ]
23
+ },
24
+ { value: "between", ops: [{ op: "between", label: "between" }] },
25
+ {
26
+ value: "unknownArray",
27
+ ops: [{ op: "containsAll", label: "contains all" }]
28
+ }
29
+ ];
30
+ PREDICATE_VARIANTS.flatMap(
31
+ (variant) => variant.ops.map(({ op }) => op)
32
+ );
33
+ new Map(
34
+ PREDICATE_VARIANTS.flatMap((variant) => variant.ops.map(({ op, label }) => [op, label]))
35
+ );
36
+
37
+ // packages/@columnus/shared/src/queryValidators.ts
38
+ var predicateValidators = PREDICATE_VARIANTS.flatMap(
39
+ (variant) => variant.ops.map(
40
+ ({ op }) => v.object({
41
+ field: v.string(),
42
+ op: v.literal(op),
43
+ value: variant.value === "unknownArray" ? v.array(v.any()) : variant.value === "between" ? v.object({ min: v.any(), max: v.any() }) : v.any()
44
+ })
45
+ )
46
+ );
47
+ var predicateValidator = v.union(
48
+ ...predicateValidators
49
+ );
50
+ var queryOrderValidator = v.object({
51
+ field: v.string(),
52
+ direction: v.union(v.literal("asc"), v.literal("desc"))
53
+ });
54
+ var querySearchValidator = v.object({
55
+ index: v.string(),
56
+ query: v.string()
57
+ });
58
+ var queryValidator = v.object({
59
+ predicates: v.optional(v.array(predicateValidator)),
60
+ order: v.optional(queryOrderValidator),
61
+ search: v.optional(querySearchValidator),
62
+ maxScan: v.optional(v.number()),
63
+ indexHint: v.optional(v.string()),
64
+ vector: v.optional(v.any())
65
+ });
66
+ var clampQueryValidator = v.object({
67
+ predicates: v.optional(v.array(predicateValidator)),
68
+ order: v.optional(queryOrderValidator),
69
+ search: v.optional(querySearchValidator)
70
+ });
71
+ v.optional(queryValidator);
72
+ var maxScanLimitValidator = v.optional(v.number());
73
+
74
+ // packages/@columnus/shared/src/shareValidators.ts
75
+ var shareScopeValidator = v.object({
76
+ table: v.string(),
77
+ primary: v.optional(v.boolean()),
78
+ access: v.union(v.literal("full"), v.literal("referenced")),
79
+ recordIds: v.optional(v.array(v.string())),
80
+ permission: v.union(v.literal("view"), v.literal("propose")),
81
+ ops: v.object({ insert: v.boolean(), update: v.boolean(), delete: v.boolean() }),
82
+ allowCreate: v.optional(v.boolean()),
83
+ allowedFields: v.optional(v.array(v.string())),
84
+ formAccess: v.optional(
85
+ v.object({
86
+ submit: v.boolean(),
87
+ searchReferences: v.boolean(),
88
+ createReferences: v.boolean()
89
+ })
90
+ ),
91
+ rowQuery: v.optional(clampQueryValidator),
92
+ maxScanLimit: maxScanLimitValidator
93
+ });
94
+ var shareWizardTableValidator = v.object({
95
+ table: v.string(),
96
+ recordIds: v.optional(v.array(v.string())),
97
+ allowedFields: v.optional(v.array(v.string()))
98
+ });
99
+ var shareWizardReferenceValidator = v.object({
100
+ table: v.string(),
101
+ searchReferences: v.boolean(),
102
+ createReferences: v.boolean()
103
+ });
104
+ var shareWizardInputValidator = v.object({
105
+ tables: v.array(shareWizardTableValidator),
106
+ ops: v.optional(
107
+ v.object({
108
+ insert: v.boolean(),
109
+ update: v.boolean(),
110
+ delete: v.boolean()
111
+ })
112
+ ),
113
+ references: v.optional(v.array(shareWizardReferenceValidator))
114
+ });
115
+ var sharePatchValidator = v.object({
116
+ table: v.string(),
117
+ rowId: v.optional(v.string()),
118
+ op: v.union(v.literal("update"), v.literal("insert"), v.literal("delete")),
119
+ fields: v.any()
120
+ });
121
+
122
+ export { sharePatchValidator, shareScopeValidator, shareWizardInputValidator, shareWizardReferenceValidator, shareWizardTableValidator };
123
+ //# sourceMappingURL=shareValidators.js.map
124
+ //# sourceMappingURL=shareValidators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/queryFieldOps.ts","../src/queryValidators.ts","../src/shareValidators.ts"],"names":["v"],"mappings":";;;;;AAGO,IAAM,kBAAA,GAAqB;AAAA,EAChC;AAAA,IACE,KAAA,EAAO,SAAA;AAAA,IACP,GAAA,EAAK;AAAA,MACH,EAAE,EAAA,EAAI,IAAA,EAAM,KAAA,EAAO,GAAA,EAAI;AAAA,MACvB,EAAE,EAAA,EAAI,KAAA,EAAO,KAAA,EAAO,QAAA;AAAI;AAC1B,GACF;AAAA,EACA,EAAE,KAAA,EAAO,cAAA,EAAgB,GAAA,EAAK,CAAC,EAAE,EAAA,EAAI,IAAA,EAAM,KAAA,EAAO,IAAA,EAAM,CAAA,EAAE;AAAA,EAC1D;AAAA,IACE,KAAA,EAAO,SAAA;AAAA,IACP,GAAA,EAAK;AAAA,MACH,EAAE,EAAA,EAAI,IAAA,EAAM,KAAA,EAAO,GAAA,EAAI;AAAA,MACvB,EAAE,EAAA,EAAI,KAAA,EAAO,KAAA,EAAO,QAAA,EAAI;AAAA,MACxB,EAAE,EAAA,EAAI,IAAA,EAAM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AAA,CAAE,KAAA,CAAMA,CAAAA,CAAE,QAAQ,QAAQ,CAAA,EAAGA,CAAAA,CAAE,OAAA,CAAQ,QAAQ,CAAA,EAAGA,CAAAA,CAAE,OAAA,CAAQ,QAAQ,CAAC,CAAA;AAAA,EACzE,MAAA,EAAQA,EAAE,GAAA;AACZ,CAAC","file":"shareValidators.js","sourcesContent":["import type { FieldType, Table } from \"./schemaTypes.ts\";\n\n/** One edit surface for each predicate operation's wire shape and UI label. */\nexport const PREDICATE_VARIANTS = [\n {\n value: \"unknown\",\n ops: [\n { op: \"eq\", label: \"=\" },\n { op: \"neq\", label: \"≠\" },\n ],\n },\n { value: \"unknownArray\", ops: [{ op: \"in\", label: \"in\" }] },\n {\n value: \"unknown\",\n ops: [\n { op: \"gt\", label: \">\" },\n { op: \"gte\", label: \"≥\" },\n { op: \"lt\", label: \"<\" },\n { op: \"lte\", label: \"≤\" },\n ],\n },\n { value: \"between\", ops: [{ op: \"between\", label: \"between\" }] },\n {\n value: \"unknownArray\",\n ops: [{ op: \"containsAll\", label: \"contains all\" }],\n },\n] as const;\n\ntype PredicateOperator = (typeof PREDICATE_VARIANTS)[number][\"ops\"][number];\nexport type PredicateOp = PredicateOperator[\"op\"];\nexport const PREDICATE_OPS = PREDICATE_VARIANTS.flatMap((variant) =>\n variant.ops.map(({ op }) => op),\n) as PredicateOp[];\n\nconst PREDICATE_OP_LABELS = new Map<PredicateOp, string>(\n PREDICATE_VARIANTS.flatMap((variant) => variant.ops.map(({ op, label }) => [op, label] as const)),\n);\n\nexport function predicateOpLabel(op: PredicateOp): string {\n return PREDICATE_OP_LABELS.get(op) ?? op;\n}\n\nexport type FieldOpSupport = {\n eq: boolean;\n neq: boolean;\n in: boolean;\n ranges: boolean;\n sort: boolean;\n containsAll: boolean;\n};\n\nconst NONE: FieldOpSupport = {\n eq: false,\n neq: false,\n in: false,\n ranges: false,\n sort: false,\n containsAll: false,\n};\n\nconst SCALAR_ORDERED: FieldOpSupport = {\n eq: true,\n neq: true,\n in: true,\n ranges: true,\n sort: true,\n containsAll: false,\n};\n\nconst SCALAR_EQ: FieldOpSupport = {\n eq: true,\n neq: true,\n in: true,\n ranges: false,\n sort: true,\n containsAll: false,\n};\n\n/** Resolve field type for user fields and system fields (`_id`, `_creationTime`). */\nexport function resolveQueryFieldType(\n table: Pick<Table, \"name\" | \"fields\">,\n field: string,\n): FieldType | null {\n if (field === \"_id\") return { kind: \"id\", table: table.name };\n if (field === \"_creationTime\") return { kind: \"number\" };\n return table.fields.find((f) => f.name === field)?.type ?? null;\n}\n\nfunction comparableUnionKind(t: FieldType): FieldType | null {\n if (t.kind !== \"union\" || t.options.length === 0) return null;\n const first = t.options[0]!;\n if (!t.options.every((o) => o.kind === first.kind)) return null;\n if (\n first.kind === \"string\" ||\n first.kind === \"number\" ||\n first.kind === \"bigint\" ||\n first.kind === \"boolean\" ||\n first.kind === \"date\" ||\n first.kind === \"datetime\" ||\n first.kind === \"id\"\n ) {\n return first;\n }\n if (first.kind === \"literal\") {\n const v = first.value;\n if (typeof v === \"string\") return { kind: \"string\" };\n if (typeof v === \"number\") return { kind: \"number\" };\n if (typeof v === \"boolean\") return { kind: \"boolean\" };\n }\n return null;\n}\n\n/** Effective type used for operator eligibility (unwraps homogeneous unions). */\nexport function effectiveQueryFieldType(t: FieldType): FieldType | null {\n if (t.kind === \"union\") return comparableUnionKind(t);\n return t;\n}\n\nexport function fieldOpSupport(type: FieldType): FieldOpSupport {\n const t = effectiveQueryFieldType(type);\n if (!t) return NONE;\n\n switch (t.kind) {\n case \"string\":\n case \"number\":\n case \"bigint\":\n case \"date\":\n case \"datetime\":\n return SCALAR_ORDERED;\n case \"boolean\":\n case \"id\":\n case \"literal\":\n return SCALAR_EQ;\n case \"array\":\n if (\n t.element.kind === \"id\" ||\n t.element.kind === \"string\" ||\n t.element.kind === \"number\" ||\n t.element.kind === \"boolean\" ||\n t.element.kind === \"literal\"\n ) {\n return { ...NONE, containsAll: true };\n }\n return NONE;\n default:\n return NONE;\n }\n}\n\nexport function opAllowedForType(type: FieldType, op: PredicateOp): boolean {\n const support = fieldOpSupport(type);\n switch (op) {\n case \"eq\":\n return support.eq;\n case \"neq\":\n return support.neq;\n case \"in\":\n return support.in;\n case \"gt\":\n case \"gte\":\n case \"lt\":\n case \"lte\":\n case \"between\":\n return support.ranges;\n case \"containsAll\":\n return support.containsAll;\n default: {\n const _exhaustive: never = op;\n return _exhaustive;\n }\n }\n}\n\nexport function fieldSupportsSort(type: FieldType): boolean {\n return fieldOpSupport(type).sort;\n}\n\nexport function isRangeOp(op: PredicateOp): boolean {\n return op === \"gt\" || op === \"gte\" || op === \"lt\" || op === \"lte\" || op === \"between\";\n}\n","import { type GenericValidator, v } from \"convex/values\";\nimport { PREDICATE_VARIANTS } from \"./queryFieldOps.ts\";\n\nconst predicateValidators = PREDICATE_VARIANTS.flatMap((variant) =>\n variant.ops.map(({ op }) =>\n v.object({\n field: v.string(),\n op: v.literal(op),\n value:\n variant.value === \"unknownArray\"\n ? v.array(v.any())\n : variant.value === \"between\"\n ? v.object({ min: v.any(), max: v.any() })\n : v.any(),\n }),\n ),\n);\n\nexport const predicateValidator = v.union(\n ...(predicateValidators as unknown as [\n GenericValidator,\n GenericValidator,\n ...GenericValidator[],\n ]),\n);\n\nconst queryOrderValidator = v.object({\n field: v.string(),\n direction: v.union(v.literal(\"asc\"), v.literal(\"desc\")),\n});\n\nconst querySearchValidator = v.object({\n index: v.string(),\n query: v.string(),\n});\n\n/** Canonical Convex validator for caller-supplied Query values. */\nexport const queryValidator = v.object({\n predicates: v.optional(v.array(predicateValidator)),\n order: v.optional(queryOrderValidator),\n search: v.optional(querySearchValidator),\n maxScan: v.optional(v.number()),\n indexHint: v.optional(v.string()),\n vector: v.optional(v.any()),\n});\n\n/** Convex validator for profile/share clamp Query (predicates + optional defaults). */\nexport const clampQueryValidator = v.object({\n predicates: v.optional(v.array(predicateValidator)),\n order: v.optional(queryOrderValidator),\n search: v.optional(querySearchValidator),\n});\n\n/** Optional Query arg for list endpoints (`query?`). */\nexport const queryArgValidator = v.optional(queryValidator);\n\nexport const maxScanLimitValidator = v.optional(v.number());\n","import { v } from \"convex/values\";\nimport { clampQueryValidator, maxScanLimitValidator } from \"./queryValidators.ts\";\n\n/** Convex boundary validators shared by the share component and host facade. */\nexport const shareScopeValidator = v.object({\n table: v.string(),\n primary: v.optional(v.boolean()),\n access: v.union(v.literal(\"full\"), v.literal(\"referenced\")),\n recordIds: v.optional(v.array(v.string())),\n permission: v.union(v.literal(\"view\"), v.literal(\"propose\")),\n ops: v.object({ insert: v.boolean(), update: v.boolean(), delete: v.boolean() }),\n allowCreate: v.optional(v.boolean()),\n allowedFields: v.optional(v.array(v.string())),\n formAccess: v.optional(\n v.object({\n submit: v.boolean(),\n searchReferences: v.boolean(),\n createReferences: v.boolean(),\n }),\n ),\n rowQuery: v.optional(clampQueryValidator),\n maxScanLimit: maxScanLimitValidator,\n});\n\nexport const shareWizardTableValidator = v.object({\n table: v.string(),\n recordIds: v.optional(v.array(v.string())),\n allowedFields: v.optional(v.array(v.string())),\n});\n\nexport const shareWizardReferenceValidator = v.object({\n table: v.string(),\n searchReferences: v.boolean(),\n createReferences: v.boolean(),\n});\n\nexport const shareWizardInputValidator = v.object({\n tables: v.array(shareWizardTableValidator),\n ops: v.optional(\n v.object({\n insert: v.boolean(),\n update: v.boolean(),\n delete: v.boolean(),\n }),\n ),\n references: v.optional(v.array(shareWizardReferenceValidator)),\n});\n\nexport const sharePatchValidator = v.object({\n table: v.string(),\n rowId: v.optional(v.string()),\n op: v.union(v.literal(\"update\"), v.literal(\"insert\"), v.literal(\"delete\")),\n fields: v.any(),\n});\n"]}
@@ -0,0 +1,14 @@
1
+ import type { Manifest } from "./schemaTypes.ts";
2
+ import type { ShareConfiguratorState, ShareLinkType, ShareOps, ShareRefChoice, ShareScope, ShareWizardInput } from "./shareTypes.ts";
3
+ export declare function shareTypeDefaultScopes(type: ShareLinkType, input: ShareWizardInput): ShareScope[];
4
+ export declare function isPrimaryShareScope(_type: ShareLinkType, scope: ShareScope): boolean;
5
+ export declare function scopesToWizardInput(type: ShareLinkType, rawScopes: ShareScope[], manifest: Manifest): ShareConfiguratorState;
6
+ export declare function buildShareWizardInput(args: {
7
+ type: ShareLinkType;
8
+ manifest: Manifest;
9
+ tables: string[];
10
+ allowedFields: Record<string, string[]>;
11
+ recordIds: Record<string, string>;
12
+ refChoices: Record<string, ShareRefChoice>;
13
+ ops?: ShareOps;
14
+ }): ShareWizardInput;
@@ -0,0 +1,200 @@
1
+ // packages/@columnus/shared/src/refGraph.ts
2
+ function refEdgesForType(type) {
3
+ switch (type.kind) {
4
+ case "id":
5
+ return [{ field: "", targetTable: type.table, array: false }];
6
+ case "array":
7
+ if (type.element.kind === "id") {
8
+ return [{ field: "", targetTable: type.element.table, array: true }];
9
+ }
10
+ return [];
11
+ default:
12
+ return [];
13
+ }
14
+ }
15
+ function refFieldsForTable(table) {
16
+ const edges = [];
17
+ for (const field of table.fields) {
18
+ for (const template of refEdgesForType(field.type)) {
19
+ edges.push({ ...template, field: field.name });
20
+ }
21
+ }
22
+ return edges.sort(
23
+ (a, b) => a.field.localeCompare(b.field) || a.targetTable.localeCompare(b.targetTable)
24
+ );
25
+ }
26
+
27
+ // packages/@columnus/shared/src/shareScopes.ts
28
+ function inferLegacyPrimary(scope) {
29
+ const access = scope.formAccess;
30
+ return !(access && !access.submit && (access.searchReferences || access.createReferences));
31
+ }
32
+ function normalizeShareScopes(scopes) {
33
+ const tables = /* @__PURE__ */ new Set();
34
+ return scopes.map((scope) => {
35
+ const table = scope.table.trim();
36
+ if (!table) throw new Error("Every share scope needs a table");
37
+ if (tables.has(table)) throw new Error(`Duplicate share scope for ${table}`);
38
+ tables.add(table);
39
+ const recordIds = scope.recordIds ? [...new Set(scope.recordIds.map((id) => id.trim()).filter(Boolean))] : void 0;
40
+ const allowedFields = scope.allowedFields ? [...new Set(scope.allowedFields.map((field) => field.trim()).filter(Boolean))] : void 0;
41
+ if (scope.access === "referenced" && recordIds) {
42
+ throw new Error(`Referenced scope ${table} cannot specify recordIds`);
43
+ }
44
+ if (recordIds && scope.permission === "propose" && scope.ops.insert) {
45
+ throw new Error(`Record-picked scope ${table} cannot allow inserts`);
46
+ }
47
+ if (scope.allowCreate && (scope.access !== "referenced" || scope.permission !== "propose" || !scope.ops.insert)) {
48
+ throw new Error(`allowCreate requires referenced propose insert access for ${table}`);
49
+ }
50
+ return {
51
+ ...scope,
52
+ table,
53
+ primary: scope.primary ?? inferLegacyPrimary(scope),
54
+ recordIds,
55
+ allowedFields,
56
+ ops: scope.permission === "view" ? { insert: false, update: false, delete: false } : { ...scope.ops }
57
+ };
58
+ });
59
+ }
60
+ function mergeReferenceScopes(scopes, references) {
61
+ const next = normalizeShareScopes(scopes);
62
+ for (const reference of references) {
63
+ const existing = next.find((scope) => scope.table === reference.table.trim());
64
+ const formAccess = {
65
+ submit: existing?.formAccess?.submit ?? false,
66
+ searchReferences: (existing?.formAccess?.searchReferences ?? false) || reference.searchReferences,
67
+ createReferences: (existing?.formAccess?.createReferences ?? false) || reference.createReferences
68
+ };
69
+ if (existing) {
70
+ existing.formAccess = formAccess;
71
+ if (formAccess.createReferences && !existing.primary) {
72
+ existing.permission = "propose";
73
+ existing.ops = { insert: true, update: false, delete: false };
74
+ }
75
+ continue;
76
+ }
77
+ next.push({
78
+ table: reference.table,
79
+ primary: false,
80
+ access: "full",
81
+ permission: formAccess.createReferences ? "propose" : "view",
82
+ ops: formAccess.createReferences ? { insert: true, update: false, delete: false } : { insert: false, update: false, delete: false },
83
+ formAccess
84
+ });
85
+ }
86
+ return next;
87
+ }
88
+
89
+ // packages/@columnus/shared/src/shareWizard.ts
90
+ function shareTypeDefaultScopes(type, input) {
91
+ const scopes = input.tables.map(({ table, recordIds, allowedFields }) => {
92
+ if (type === "form") {
93
+ return {
94
+ table,
95
+ primary: true,
96
+ access: "full",
97
+ permission: "propose",
98
+ ops: { insert: true, update: false, delete: false },
99
+ allowedFields,
100
+ formAccess: { submit: true, searchReferences: false, createReferences: false }
101
+ };
102
+ }
103
+ if (type === "view") {
104
+ return {
105
+ table,
106
+ primary: true,
107
+ access: "full",
108
+ recordIds,
109
+ permission: "view",
110
+ ops: { insert: false, update: false, delete: false },
111
+ allowedFields
112
+ };
113
+ }
114
+ return {
115
+ table,
116
+ primary: true,
117
+ access: "full",
118
+ permission: "propose",
119
+ ops: {
120
+ insert: input.ops?.insert ?? true,
121
+ update: input.ops?.update ?? true,
122
+ delete: input.ops?.delete ?? false
123
+ },
124
+ allowedFields
125
+ };
126
+ });
127
+ return type === "form" || type === "propose" ? normalizeShareScopes(mergeReferenceScopes(scopes, input.references ?? [])) : normalizeShareScopes(scopes);
128
+ }
129
+ function isPrimaryShareScope(_type, scope) {
130
+ return scope.primary === true;
131
+ }
132
+ function scopesToWizardInput(type, rawScopes, manifest) {
133
+ const scopes = normalizeShareScopes(rawScopes);
134
+ const primaryScopes = scopes.filter((scope) => isPrimaryShareScope(type, scope));
135
+ const tables = primaryScopes.map((scope) => scope.table);
136
+ const allowedFields = {};
137
+ const recordIds = {};
138
+ const refChoices = {};
139
+ for (const scope of primaryScopes) {
140
+ const manifestTable = manifest.tables.find((candidate) => candidate.name === scope.table);
141
+ if (!manifestTable) continue;
142
+ allowedFields[scope.table] = scope.allowedFields ?? manifestTable.fields.map((field) => field.name);
143
+ if (type === "view" && scope.recordIds?.length)
144
+ recordIds[scope.table] = scope.recordIds.join(", ");
145
+ for (const ref of refFieldsForTable(manifestTable)) {
146
+ const key = `${scope.table}:${ref.field}`;
147
+ if (!allowedFields[scope.table].includes(ref.field)) {
148
+ refChoices[key] = "hide";
149
+ continue;
150
+ }
151
+ const access = scopes.find((candidate) => candidate.table === ref.targetTable)?.formAccess;
152
+ refChoices[key] = access?.createReferences ? "create" : "pick";
153
+ }
154
+ }
155
+ const ops = type === "propose" && primaryScopes[0] ? { ...primaryScopes[0].ops } : { insert: true, update: true, delete: false };
156
+ return { tables, allowedFields, recordIds, refChoices, ops };
157
+ }
158
+ function buildShareWizardInput(args) {
159
+ const { type, manifest, tables, allowedFields, recordIds, refChoices, ops } = args;
160
+ const selectedTables = tables.flatMap((name) => {
161
+ const table = manifest.tables.find((candidate) => candidate.name === name);
162
+ return table ? [table] : [];
163
+ });
164
+ const references = /* @__PURE__ */ new Map();
165
+ const wizardTables = selectedTables.map((table) => {
166
+ let fields = allowedFields[table.name] ?? table.fields.map((field) => field.name);
167
+ if (type === "form" || type === "propose") {
168
+ for (const ref of refFieldsForTable(table)) {
169
+ const choice = refChoices[`${table.name}:${ref.field}`] ?? "pick";
170
+ if (choice === "hide") fields = fields.filter((field) => field !== ref.field);
171
+ else if (fields.includes(ref.field)) {
172
+ const current = references.get(ref.targetTable) ?? {
173
+ searchReferences: false,
174
+ createReferences: false
175
+ };
176
+ references.set(ref.targetTable, {
177
+ searchReferences: current.searchReferences || choice === "pick",
178
+ createReferences: current.createReferences || choice === "create"
179
+ });
180
+ }
181
+ }
182
+ }
183
+ const ids = recordIds[table.name]?.split(",").map((id) => id.trim()).filter(Boolean);
184
+ const usesAllowlist = type === "form" || type === "propose" && fields.length < table.fields.length;
185
+ return {
186
+ table: table.name,
187
+ allowedFields: usesAllowlist ? fields : void 0,
188
+ recordIds: type === "view" && ids?.length ? [...new Set(ids)] : void 0
189
+ };
190
+ });
191
+ return {
192
+ tables: wizardTables,
193
+ ops: type === "propose" ? ops : void 0,
194
+ references: type === "form" || type === "propose" ? [...references].map(([table, access]) => ({ table, ...access })) : void 0
195
+ };
196
+ }
197
+
198
+ export { buildShareWizardInput, isPrimaryShareScope, scopesToWizardInput, shareTypeDefaultScopes };
199
+ //# sourceMappingURL=shareWizard.js.map
200
+ //# sourceMappingURL=shareWizard.js.map