nucleus-core-ts 0.9.837 → 0.9.838

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.
@@ -199,6 +199,136 @@ export function MappingAccountFields({ value, targetFields, targets, disabled, o
199
199
  })
200
200
  ]
201
201
  }),
202
+ /*#__PURE__*/ _jsxs("section", {
203
+ className: "flex flex-col gap-2",
204
+ children: [
205
+ /*#__PURE__*/ _jsxs("div", {
206
+ className: "flex flex-wrap items-center justify-between gap-2",
207
+ children: [
208
+ /*#__PURE__*/ _jsx("span", {
209
+ className: theme.field.label,
210
+ children: "What each new account is a member of"
211
+ }),
212
+ /*#__PURE__*/ _jsx("button", {
213
+ className: theme.button.ghost,
214
+ disabled: disabled,
215
+ onClick: ()=>patch({
216
+ joins: [
217
+ ...value.joins ?? [],
218
+ {
219
+ entity: '',
220
+ accountColumn: '',
221
+ values: {}
222
+ }
223
+ ]
224
+ }),
225
+ type: "button",
226
+ children: "Add a membership"
227
+ })
228
+ ]
229
+ }),
230
+ (value.joins ?? []).length === 0 ? /*#__PURE__*/ _jsx("p", {
231
+ className: theme.field.hint,
232
+ children: "Nothing. An account with no role can sign in and do nothing — every screen it reaches refuses it. A role usually lives in its own table, joined to the account, which is what this adds."
233
+ }) : null,
234
+ (value.joins ?? []).map((join, joinIndex)=>{
235
+ const joinEntity = targets.find((target)=>target.entity === join.entity);
236
+ const pair = Object.entries(join.values)[0] ?? [
237
+ '',
238
+ ''
239
+ ];
240
+ const setJoin = (next)=>patch({
241
+ joins: (value.joins ?? []).with(joinIndex, {
242
+ ...join,
243
+ ...next
244
+ })
245
+ });
246
+ return /*#__PURE__*/ _jsxs("div", {
247
+ className: "grid grid-cols-1 gap-2 sm:grid-cols-[1fr_1fr_1fr_1fr_auto]",
248
+ children: [
249
+ /*#__PURE__*/ _jsxs("select", {
250
+ className: theme.field.input,
251
+ disabled: disabled,
252
+ onChange: (event)=>setJoin({
253
+ entity: event.target.value,
254
+ accountColumn: '',
255
+ values: {}
256
+ }),
257
+ value: join.entity,
258
+ children: [
259
+ /*#__PURE__*/ _jsx("option", {
260
+ value: "",
261
+ children: "Membership table…"
262
+ }),
263
+ targets.map((target)=>/*#__PURE__*/ _jsx("option", {
264
+ value: target.entity,
265
+ children: target.label
266
+ }, target.entity))
267
+ ]
268
+ }),
269
+ /*#__PURE__*/ _jsxs("select", {
270
+ className: theme.field.input,
271
+ disabled: disabled || !joinEntity,
272
+ onChange: (event)=>setJoin({
273
+ accountColumn: event.target.value
274
+ }),
275
+ value: join.accountColumn,
276
+ children: [
277
+ /*#__PURE__*/ _jsx("option", {
278
+ value: "",
279
+ children: "…account id column"
280
+ }),
281
+ (joinEntity?.fields ?? []).map((field)=>/*#__PURE__*/ _jsx("option", {
282
+ value: field,
283
+ children: field
284
+ }, field))
285
+ ]
286
+ }),
287
+ /*#__PURE__*/ _jsxs("select", {
288
+ className: theme.field.input,
289
+ disabled: disabled || !joinEntity,
290
+ onChange: (event)=>setJoin({
291
+ values: {
292
+ [event.target.value]: pair[1] ?? ''
293
+ }
294
+ }),
295
+ value: pair[0],
296
+ children: [
297
+ /*#__PURE__*/ _jsx("option", {
298
+ value: "",
299
+ children: "…and this column"
300
+ }),
301
+ (joinEntity?.fields ?? []).map((field)=>/*#__PURE__*/ _jsx("option", {
302
+ value: field,
303
+ children: field
304
+ }, field))
305
+ ]
306
+ }),
307
+ /*#__PURE__*/ _jsx("input", {
308
+ className: theme.field.input,
309
+ disabled: disabled || !pair[0],
310
+ onChange: (event)=>setJoin({
311
+ values: {
312
+ [pair[0]]: event.target.value
313
+ }
314
+ }),
315
+ placeholder: "…set to this value",
316
+ value: String(pair[1] ?? '')
317
+ }),
318
+ /*#__PURE__*/ _jsx("button", {
319
+ className: theme.button.ghost,
320
+ disabled: disabled,
321
+ onClick: ()=>patch({
322
+ joins: (value.joins ?? []).toSpliced(joinIndex, 1)
323
+ }),
324
+ type: "button",
325
+ children: "Remove"
326
+ })
327
+ ]
328
+ }, joinIndex);
329
+ })
330
+ ]
331
+ }),
202
332
  /*#__PURE__*/ _jsx(Notice, {
203
333
  title: "One password, typed on the import screen",
204
334
  tone: "info",
@@ -144,6 +144,17 @@ export type AccountRuleValue = {
144
144
  column: string;
145
145
  from: string;
146
146
  }[];
147
+ /**
148
+ * Rows added in another table for each account — a role, usually.
149
+ *
150
+ * An account with no role can sign in and do nothing. A membership is not a
151
+ * column on the account, so it cannot be expressed as one.
152
+ */
153
+ joins?: {
154
+ entity: string;
155
+ accountColumn: string;
156
+ values: Record<string, unknown>;
157
+ }[];
147
158
  };
148
159
  export type IntegrationMapping = {
149
160
  id: string;