nucleus-core-ts 0.9.836 → 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",
@@ -202,6 +202,7 @@ export function MappingEditor({ mapping, targets, targetsLoading, endpoints, fre
202
202
  referenceChecks: rows
203
203
  }),
204
204
  rows: draft.referenceChecks,
205
+ sourceFields: sourceFields,
205
206
  targetFields: targetFields,
206
207
  targets: targets
207
208
  }),
@@ -4,9 +4,18 @@ export type ReferenceCheckRowsProps = {
4
4
  rows: ReferenceCheckValue[];
5
5
  /** Columns of the entity being written into. */
6
6
  targetFields: string[];
7
+ /**
8
+ * Field names the source really sends.
9
+ *
10
+ * A value being created is usually described by fields the mapping had no
11
+ * reason to write onto the record — the source sends
12
+ * `{code, value}` and the record keeps only the value. The engine reads the
13
+ * SOURCE first, so this offers what it can actually reach.
14
+ */
15
+ sourceFields?: string[];
7
16
  /** Every entity an import may read or write, with its columns. */
8
17
  targets: MappingTarget[];
9
18
  disabled?: boolean;
10
19
  onChange: (rows: ReferenceCheckValue[]) => void;
11
20
  };
12
- export declare function ReferenceCheckRows({ rows, targetFields, targets, disabled, onChange, }: ReferenceCheckRowsProps): import("react/jsx-runtime").JSX.Element;
21
+ export declare function ReferenceCheckRows({ rows, targetFields, sourceFields, targets, disabled, onChange, }: ReferenceCheckRowsProps): import("react/jsx-runtime").JSX.Element;
@@ -36,8 +36,9 @@ const EMPTY = {
36
36
  entityColumn: '',
37
37
  onMissing: 'skipRecord'
38
38
  };
39
- export function ReferenceCheckRows({ rows, targetFields, targets, disabled, onChange }) {
39
+ export function ReferenceCheckRows({ rows, targetFields, sourceFields = [], targets, disabled, onChange }) {
40
40
  const uid = useId();
41
+ const fromListId = `${uid}-from-fields`;
41
42
  const patch = (index, next)=>{
42
43
  const current = rows[index];
43
44
  if (!current) return;
@@ -68,6 +69,15 @@ export function ReferenceCheckRows({ rows, targetFields, targets, disabled, onCh
68
69
  })
69
70
  ]
70
71
  }),
72
+ /*#__PURE__*/ _jsx("datalist", {
73
+ id: fromListId,
74
+ children: [
75
+ ...sourceFields,
76
+ ...targetFields
77
+ ].map((field)=>/*#__PURE__*/ _jsx("option", {
78
+ value: field
79
+ }, field))
80
+ }),
71
81
  rows.length === 0 ? /*#__PURE__*/ _jsx("p", {
72
82
  className: theme.list.empty,
73
83
  children: "Nothing is checked. A record whose department or location does not exist here yet will be written pointing at nothing."
@@ -246,26 +256,18 @@ export function ReferenceCheckRows({ rows, targetFields, targets, disabled, onCh
246
256
  }, field))
247
257
  ]
248
258
  }),
249
- /*#__PURE__*/ _jsxs("select", {
259
+ /*#__PURE__*/ _jsx("input", {
250
260
  className: theme.field.input,
251
261
  disabled: disabled,
262
+ list: fromListId,
252
263
  onChange: (event)=>patch(index, {
253
264
  createValues: (row.createValues ?? []).with(pairIndex, {
254
265
  ...pair,
255
266
  from: event.target.value
256
267
  })
257
268
  }),
258
- value: pair.from,
259
- children: [
260
- /*#__PURE__*/ _jsx("option", {
261
- value: "",
262
- children: "…from this record's"
263
- }),
264
- targetFields.map((field)=>/*#__PURE__*/ _jsx("option", {
265
- value: field,
266
- children: field
267
- }, field))
268
- ]
269
+ placeholder: "…from the source, e.g. type.code",
270
+ value: pair.from
269
271
  }),
270
272
  /*#__PURE__*/ _jsx("button", {
271
273
  className: theme.button.ghost,
@@ -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;