@marktiderman/genesis-core 2.5.0 → 2.6.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 (47) hide show
  1. package/dist/{chunk-227N654S.js → chunk-BIIENNTW.js} +2 -2
  2. package/dist/chunk-BIIENNTW.js.map +1 -0
  3. package/dist/{chunk-XMC4EJUE.js → chunk-EHFYSJJA.js} +6 -3
  4. package/dist/chunk-EHFYSJJA.js.map +1 -0
  5. package/dist/chunk-LZVU5NGV.js +82 -0
  6. package/dist/chunk-LZVU5NGV.js.map +1 -0
  7. package/dist/{chunk-X6EO3XBB.js → chunk-OKCSGNCU.js} +9 -4
  8. package/dist/chunk-OKCSGNCU.js.map +1 -0
  9. package/dist/{chunk-H2RGMX6L.js → chunk-OWYX4BEI.js} +3 -3
  10. package/dist/{chunk-H2RGMX6L.js.map → chunk-OWYX4BEI.js.map} +1 -1
  11. package/dist/csv.d.ts +1 -3
  12. package/dist/dates.d.ts +27 -1
  13. package/dist/dates.js +1 -1
  14. package/dist/form-types.d.ts +1 -70
  15. package/dist/hooks/index.d.ts +3 -4
  16. package/dist/hooks/index.js +6 -5
  17. package/dist/hooks/mutation-mode.d.ts +1 -3
  18. package/dist/hooks/related-keys.d.ts +1 -3
  19. package/dist/hooks/use-capabilities.d.ts +1 -2
  20. package/dist/hooks/use-infinite-resource.d.ts +1 -3
  21. package/dist/hooks/use-link-options.d.ts +58 -0
  22. package/dist/hooks/use-link-options.js +10 -0
  23. package/dist/hooks/use-link-options.js.map +1 -0
  24. package/dist/hooks/use-live.d.ts +1 -3
  25. package/dist/hooks/use-one.d.ts +1 -3
  26. package/dist/hooks/use-relation-label.d.ts +8 -4
  27. package/dist/hooks/use-relation-label.js +1 -1
  28. package/dist/hooks/use-resource-form.d.ts +1 -3
  29. package/dist/hooks/use-resource-form.js +2 -2
  30. package/dist/hooks/use-resource.d.ts +1 -3
  31. package/dist/hooks/use-write.d.ts +1 -3
  32. package/dist/index.d.ts +5 -6
  33. package/dist/index.js +6 -5
  34. package/dist/provider/index.d.ts +4 -6
  35. package/dist/resource-view/index.d.ts +85 -4
  36. package/dist/resource-view/index.js +122 -34
  37. package/dist/resource-view/index.js.map +1 -1
  38. package/dist/schema/index.d.ts +3 -5
  39. package/dist/testing/index.d.ts +2 -4
  40. package/dist/types-r_Rlw7BB.d.ts +800 -0
  41. package/dist/{write-outcome-CFnpciUI.d.ts → write-outcome-BWV34wh5.d.ts} +1 -1
  42. package/package.json +1 -1
  43. package/dist/chunk-227N654S.js.map +0 -1
  44. package/dist/chunk-X6EO3XBB.js.map +0 -1
  45. package/dist/chunk-XMC4EJUE.js.map +0 -1
  46. package/dist/types-CXhqXPN1.d.ts +0 -367
  47. package/dist/types-o8j7g6O6.d.ts +0 -331
@@ -1,9 +1,7 @@
1
- import { D as DataRow, e as ResourceContract, j as RowOf, i as RowAction, F as FieldSchema } from '../types-o8j7g6O6.js';
1
+ import { h as DataRow, x as ResourceContract, O as RowOf, K as RowAction, F as FieldSchema, a as FilterParam, b as Identifier } from '../types-r_Rlw7BB.js';
2
2
  import { C as ChipTone, R as Readiness } from '../status-BXRokZD9.js';
3
3
  import { V as Viewer, R as ResourceScope } from '../viewer-scope-bthEYSOB.js';
4
4
  export { G as GenesisViewerRoles, N as NO_VIEWER } from '../viewer-scope-bthEYSOB.js';
5
- import { a as Identifier } from '../types-CXhqXPN1.js';
6
- import '../form-types.js';
7
5
  import 'react';
8
6
  import '@tanstack/react-query';
9
7
  import '../dates.js';
@@ -39,8 +37,27 @@ interface ViewField<Row extends DataRow = DataRow> {
39
37
  * `"Someone you can't see"`. Default: the catalogue's `common.hiddenLink`. Never the raw id.
40
38
  */
41
39
  missingLabel?: string;
40
+ /**
41
+ * For a link: edit it in the view's forms with a picker, and how the picker lists the rows it
42
+ * can point at. Setting it (`{}` is enough) opts the link in; without it (or the view's
43
+ * `editLinks`) a link stays read-only. `view` narrows it to the linked view's rules (its scope
44
+ * and default filter); `filter` adds more.
45
+ */
46
+ link?: ViewLink;
42
47
  /** Longest text a form accepts. Feeds the derived validation. */
43
48
  max?: number;
49
+ /**
50
+ * In a form: the browser's autofill token (`email`, `tel`, `given-name`, `one-time-code`,
51
+ * `off`, ...). Unset, the input carries no `autocomplete` attribute and gets no token from its
52
+ * type, so the browser applies its own heuristics (it may still offer to fill it). Set a token
53
+ * where the form is about the viewer, and `off` on a form about someone else (an admin editing
54
+ * a member) to ask the browser not to fill in the person at the keyboard.
55
+ */
56
+ autoComplete?: string;
57
+ /** In a form: which on-screen keyboard a phone shows. Unset, it follows the field's type. */
58
+ inputMode?: "none" | "text" | "decimal" | "numeric" | "tel" | "search" | "email" | "url";
59
+ /** In a form: the label on the keyboard's Return key (`next`, `done`, `go`, `search`, `send`). */
60
+ enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send";
44
61
  /** Shown read-only even where the server would accept a write. Never widens. */
45
62
  readOnly?: boolean;
46
63
  /**
@@ -60,6 +77,50 @@ interface ViewField<Row extends DataRow = DataRow> {
60
77
  */
61
78
  timeZone?: ViewTimeZone;
62
79
  }
80
+ /**
81
+ * A picker's filter: equality per field. `null` is "is empty", a list is "any of". Sent to the
82
+ * server with the list request, never applied to loaded rows.
83
+ */
84
+ type LinkFilter = Readonly<Record<string, string | number | boolean | null | readonly (string | number)[]>>;
85
+ /** The parts of the linked resource's view a picker reads. */
86
+ type LinkedView = Pick<ResourceView<any, any>, "resource" | "definition" | "labelField">;
87
+ /**
88
+ * How a link's picker lists the linked rows (`fields.owner_id.link`). The list always goes through
89
+ * the provider, so row-level security decides what the viewer can pick; these only narrow it.
90
+ */
91
+ interface ViewLink {
92
+ /**
93
+ * The linked resource's view. Its `scope` keys (read from the viewer's scope, as its own lists
94
+ * do), its `default` preset's filter (or `preset`'s) and its `labelField` apply to the picker.
95
+ * A function for two views that link each other (`() => usersView`).
96
+ */
97
+ view?: LinkedView | (() => LinkedView);
98
+ /** One of the linked view's presets whose filter the picker uses. Default: its `default` preset. */
99
+ preset?: string;
100
+ /**
101
+ * More filters: fixed, or from the form's values, for a picker that follows another field
102
+ * (`(values) => ({ project_id: values.project_id })`, the tasks of the chosen project).
103
+ */
104
+ filter?: LinkFilter | ((values: Readonly<Record<string, unknown>>) => LinkFilter);
105
+ /** The linked fields a search matches. Default: the naming field (`labelField`). */
106
+ searchFields?: readonly string[];
107
+ }
108
+ /** A link's picker, resolved: what to list, what names a row, and the filters to send. */
109
+ interface ResolvedLink {
110
+ /** The linked resource. */
111
+ resource: string;
112
+ /** The linked field the link stores (its key, usually `id`). */
113
+ field: string;
114
+ /** The linked field that names a row: the view field's, else the linked view's. Undefined: the provider's `describe`. */
115
+ readonly labelField: string | undefined;
116
+ /** The linked fields a search matches. Unset: the naming field. */
117
+ searchFields?: readonly string[];
118
+ /**
119
+ * The filters a picker sends: the linked view's scope keys from `scope` (as its own lists apply
120
+ * them), its preset's filter, then the link's own `filter` for these form values.
121
+ */
122
+ filters(scope?: ResourceScope | null, values?: Readonly<Record<string, unknown>>): FilterParam[];
123
+ }
63
124
  /**
64
125
  * An IANA zone name as written: `"UTC"`, `"GMT"` or `Area/Location` (`"Europe/Berlin"`). The
65
126
  * type keeps a bare word out; `defineView` checks the runtime knows the zone.
@@ -237,6 +298,11 @@ interface ViewDefinition<C extends ResourceContract, Row extends DataRow = RowOf
237
298
  presets?: Readonly<Record<string, ViewPreset<FieldNameOf<C>>>>;
238
299
  /** The record form. Default: every writable field, in contract order. */
239
300
  form?: readonly ViewFormItem<FieldNameOf<C>>[];
301
+ /**
302
+ * Edit every link in this view's forms with a picker. Default false: a link is read-only (and
303
+ * never sent) unless its `fields.<link>.link` is set (`{}` is enough). The default flips in 3.0.
304
+ */
305
+ editLinks?: boolean;
240
306
  can?: ViewGuards<Row>;
241
307
  /** Named operations on one row, in the order a menu shows them. Names are unique. */
242
308
  actions?: readonly ViewAction<Row>[];
@@ -283,6 +349,12 @@ interface ResolvedFormField {
283
349
  required: boolean;
284
350
  readOnly: boolean;
285
351
  max?: number;
352
+ /** The input's autofill token (`ViewField.autoComplete`). */
353
+ autoComplete?: string;
354
+ /** The keyboard a phone shows (`ViewField.inputMode`). */
355
+ inputMode?: ViewField["inputMode"];
356
+ /** The Return key's label (`ViewField.enterKeyHint`). */
357
+ enterKeyHint?: ViewField["enterKeyHint"];
286
358
  /** For a link: the linked row's field that names it (`ViewField.labelField`). */
287
359
  labelField?: string;
288
360
  /** For a link: the words when its row is hidden or gone (`ViewField.missingLabel`). */
@@ -292,6 +364,8 @@ interface ResolvedFormField {
292
364
  value: string;
293
365
  label: string;
294
366
  }[];
367
+ /** For a link the view opted in (`fields.<link>.link`, `editLinks`): how its picker lists the linked rows. */
368
+ link?: ResolvedLink;
295
369
  /** The heading it sits under, or null for none. */
296
370
  section: string | null;
297
371
  sectionTitle: string | null;
@@ -340,6 +414,7 @@ declare class ViewDefinitionError extends Error {
340
414
  readonly problems: readonly string[];
341
415
  constructor(resource: string, problems: readonly string[]);
342
416
  }
417
+
343
418
  /** The display a field gets when the view doesn't name one. */
344
419
  declare function deriveDisplay(field: FieldSchema): DisplayHint;
345
420
  /** A table name's singular, for the default noun. A wrong guess is fixed with `@genesis {"noun"}`. */
@@ -417,6 +492,12 @@ declare function scopeValues(view: Pick<ResourceView<any, any>, "resource" | "de
417
492
  */
418
493
  declare function scopeFilter(view: Pick<ResourceView<any, any>, "definition">, scope: ResourceScope | null | undefined): Readonly<Record<string, ScopeValue | readonly (string | number)[]>>;
419
494
 
495
+ /**
496
+ * A screen's or a picker's filter as provider filters: a single value is `eq`, `null` is
497
+ * `is_null` and a list is `in`.
498
+ */
499
+ declare function filterParams(filter: LinkFilter | null | undefined): FilterParam[];
500
+
420
501
  /**
421
502
  * A screen's `tree` (`<ResourceView tree={{ getParentId }} />`): rows nest under the row
422
503
  * `getParentId` names. Client-side data only: every row is loaded, and children are never
@@ -682,4 +763,4 @@ type WorkspaceSection<Row extends DataRow = DataRow, Name extends string = strin
682
763
  /** @deprecated Renamed `RecordViewHeaderAction`. */
683
764
  type WorkspaceHeaderAction = RecordViewHeaderAction;
684
765
 
685
- export { type Allowed, type ComputedColumn, type DisplayHint, type FieldNameOf, type RecordView, type RecordViewDefinition, type RecordViewFilter, type RecordViewHeader, type RecordViewHeaderAction, type RecordViewHeaderOptions, type RecordViewListSection, type RecordViewReadinessItem, type RecordViewSection, type RecordViewSettingsSection, type RecordViewSlotSection, type ResolvedColumn, type ResolvedFormField, type ResolvedReadinessItem, type ResolvedRecordViewSection, type ResolvedViewAction, type ResourceTree, type ResourceView, type ResourceWorkspace, type RowImage, RowOf, type RowPicture, type RowSummary, type TimeZoneName, type TreeNode, type TreeOptions, type TreeResult, type ViewAction, type ViewCalendar, type ViewCalendarLayout, type ViewColumn, type ViewCopy, type ViewDefinition, ViewDefinitionError, type ViewField, type ViewFormItem, type ViewGuards, type ViewPreset, type ViewTimeZone, type ViewTone, Viewer, type WorkspaceDefinition, type WorkspaceHeaderAction, type WorkspaceSection, calendarProblems, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
766
+ export { type Allowed, type ComputedColumn, type DisplayHint, type FieldNameOf, type LinkFilter, type LinkedView, type RecordView, type RecordViewDefinition, type RecordViewFilter, type RecordViewHeader, type RecordViewHeaderAction, type RecordViewHeaderOptions, type RecordViewListSection, type RecordViewReadinessItem, type RecordViewSection, type RecordViewSettingsSection, type RecordViewSlotSection, type ResolvedColumn, type ResolvedFormField, type ResolvedLink, type ResolvedReadinessItem, type ResolvedRecordViewSection, type ResolvedViewAction, type ResourceTree, type ResourceView, type ResourceWorkspace, type RowImage, RowOf, type RowPicture, type RowSummary, type TimeZoneName, type TreeNode, type TreeOptions, type TreeResult, type ViewAction, type ViewCalendar, type ViewCalendarLayout, type ViewColumn, type ViewCopy, type ViewDefinition, ViewDefinitionError, type ViewField, type ViewFormItem, type ViewGuards, type ViewLink, type ViewPreset, type ViewTimeZone, type ViewTone, Viewer, type WorkspaceDefinition, type WorkspaceHeaderAction, type WorkspaceSection, calendarProblems, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, filterParams, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
@@ -2,11 +2,15 @@ import { readinessOf } from '../chunk-PP3XFFQM.js';
2
2
  import { keyFields, encodeRecordKey } from '../chunk-KV2HW4G4.js';
3
3
  import { NO_VIEWER } from '../chunk-OZYF55E3.js';
4
4
  export { NO_VIEWER } from '../chunk-OZYF55E3.js';
5
- import { isTimeZone } from '../chunk-227N654S.js';
5
+ import { isTimeZone } from '../chunk-BIIENNTW.js';
6
+ import { isDevelopment, reportError } from '../chunk-37RWGNIO.js';
7
+ import '../chunk-PA6WJE5E.js';
8
+ import '../chunk-HUNGCTRA.js';
6
9
  import { titleCase } from '../chunk-RYEXWQFD.js';
10
+ import '../chunk-LG6TUBVM.js';
7
11
  import { isSafeUrl } from '../chunk-YDDPFSQ6.js';
8
12
 
9
- // src/resource-view/define-view.ts
13
+ // src/resource-view/errors.ts
10
14
  var ViewDefinitionError = class extends Error {
11
15
  problems;
12
16
  constructor(resource, problems) {
@@ -15,6 +19,105 @@ var ViewDefinitionError = class extends Error {
15
19
  this.problems = problems;
16
20
  }
17
21
  };
22
+
23
+ // src/resource-view/scope.ts
24
+ var camel = (key) => key.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
25
+ function scopeValues(view, scope) {
26
+ const out = {};
27
+ const missing = [];
28
+ for (const key of view.definition.scope ?? []) {
29
+ const value = scope && Object.hasOwn(scope, key) ? scope[key] : scope?.[camel(key)];
30
+ if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") out[key] = value;
31
+ else missing.push(key);
32
+ }
33
+ if (missing.length && process.env.NODE_ENV !== "production") {
34
+ throw new ViewDefinitionError(
35
+ view.resource,
36
+ missing.map((key) => `scope "${key}" has no single value in ViewerScope's scope`)
37
+ );
38
+ }
39
+ return Object.freeze(out);
40
+ }
41
+ function scopeFilter(view, scope) {
42
+ const out = {};
43
+ if (!scope) return out;
44
+ for (const key of view.definition.scope ?? []) {
45
+ const value = Object.hasOwn(scope, key) ? scope[key] : scope[camel(key)];
46
+ if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") out[key] = value;
47
+ else if (Array.isArray(value) && value.every((v) => typeof v === "string" || typeof v === "number")) out[key] = value;
48
+ }
49
+ return Object.freeze(out);
50
+ }
51
+
52
+ // src/resource-view/link.ts
53
+ function filterParams(filter) {
54
+ return Object.entries(filter ?? {}).map(
55
+ ([field, value]) => value === null ? { field, operator: "is_null" } : Array.isArray(value) ? { field, operator: "in", value: [...value] } : { field, operator: "eq", value }
56
+ );
57
+ }
58
+ function linkProblems(name, link, reference) {
59
+ if (link === void 0) return [];
60
+ const where = `fields.${name}.link`;
61
+ if (!reference) return [`${where} is set, but "${name}" isn't a link`];
62
+ if (!link || typeof link !== "object" || Array.isArray(link)) return [`${where} isn't an object`];
63
+ const l = link;
64
+ const problems = [];
65
+ if (l.view !== void 0 && typeof l.view !== "function") problems.push(...linkedViewProblems(where, l.view, reference, l.preset));
66
+ else if (l.view === void 0 && l.preset !== void 0) problems.push(`${where}.preset needs a view`);
67
+ if (l.preset !== void 0 && typeof l.preset !== "string") problems.push(`${where}.preset isn't a preset name`);
68
+ if (l.filter !== void 0 && typeof l.filter !== "function" && (!l.filter || typeof l.filter !== "object" || Array.isArray(l.filter))) {
69
+ problems.push(`${where}.filter isn't a filter or a function`);
70
+ }
71
+ if (l.searchFields !== void 0 && (!Array.isArray(l.searchFields) || l.searchFields.some((f) => typeof f !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(f)))) {
72
+ problems.push(`${where}.searchFields isn't a list of field names`);
73
+ }
74
+ return problems;
75
+ }
76
+ function linkedViewProblems(where, view, reference, preset) {
77
+ const v = view;
78
+ if (!v || typeof v !== "object" || typeof v.resource !== "string") return [`${where}.view isn't a view`];
79
+ if (v.resource !== reference.resource) return [`${where}.view is a view of "${v.resource}", but the link points at "${reference.resource}"`];
80
+ if (preset !== void 0 && !Object.hasOwn(v.definition.presets ?? {}, preset)) {
81
+ return [`${where}.preset "${preset}" isn't one of ${v.resource}'s presets`];
82
+ }
83
+ return [];
84
+ }
85
+ function resolveLink(owner, name, reference, link, labelField) {
86
+ let linked;
87
+ let read = false;
88
+ const linkedView = () => {
89
+ if (read) return linked;
90
+ read = true;
91
+ linked = typeof link?.view === "function" ? link.view() : link?.view;
92
+ if (linked && typeof link?.view === "function") {
93
+ const problems = linkedViewProblems(`fields.${name}.link`, linked, reference, link.preset);
94
+ if (problems.length) {
95
+ const error = new ViewDefinitionError(owner, problems);
96
+ if (isDevelopment()) throw error;
97
+ reportError(error, { source: "core:resource-view-link", tags: { resource: owner } });
98
+ linked = void 0;
99
+ }
100
+ }
101
+ return linked;
102
+ };
103
+ return Object.freeze({
104
+ resource: reference.resource,
105
+ field: reference.field,
106
+ // Read when asked: a view given as a function may not exist yet while this one is defined.
107
+ get labelField() {
108
+ return labelField ?? linkedView()?.labelField;
109
+ },
110
+ ...link?.searchFields ? { searchFields: Object.freeze([...link.searchFields]) } : {},
111
+ filters(scope, values = {}) {
112
+ const view = linkedView();
113
+ const preset = view ? view.definition.presets?.[link?.preset ?? "default"]?.filter : void 0;
114
+ const own2 = typeof link?.filter === "function" ? link.filter(values) : link?.filter;
115
+ return filterParams({ ...view ? scopeFilter(view, scope) : {}, ...preset, ...own2 });
116
+ }
117
+ });
118
+ }
119
+
120
+ // src/resource-view/define-view.ts
18
121
  function deriveDisplay(field) {
19
122
  if (field.references) return "relation";
20
123
  switch (field.widget) {
@@ -177,6 +280,8 @@ function defineView(contract, definition = {}) {
177
280
  if (typeof v.missingLabel !== "string" || !v.missingLabel.trim()) problems.push(`fields.${name}.missingLabel isn't text`);
178
281
  else if (!byName.get(name)?.references) problems.push(`fields.${name}.missingLabel is set, but "${name}" isn't a link`);
179
282
  }
283
+ for (const [name, v] of Object.entries(viewFields)) problems.push(...linkProblems(name, v?.link, byName.get(name)?.references));
284
+ if (definition.editLinks !== void 0 && typeof definition.editLinks !== "boolean") problems.push("editLinks isn't true or false");
180
285
  for (const [name, v] of Object.entries(viewFields)) {
181
286
  if (v?.labelField === void 0) continue;
182
287
  if (typeof v.labelField !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(v.labelField)) {
@@ -250,10 +355,13 @@ function defineView(contract, definition = {}) {
250
355
  };
251
356
  const valueLabel = (name, value) => valueText(own(viewFields, name)?.labels, value);
252
357
  const readable = (name) => byName.get(name)?.permissions?.read !== false;
358
+ const editLinks = definition.editLinks === true;
359
+ const linkEditable = (f) => Boolean(f.references) && (editLinks || own(viewFields, f.name)?.link !== void 0);
253
360
  const readOnly = (field) => Boolean(
254
- field.generated || field.readOnly || field.references || field.permissions?.update === false || own(viewFields, field.name)?.readOnly
361
+ field.generated || field.readOnly || field.references && !linkEditable(field) || field.permissions?.update === false || own(viewFields, field.name)?.readOnly
255
362
  );
256
363
  const quiet = (f) => keys.has(f.name) || scope.has(f.name) || Boolean(f.sensitive) || Boolean(f.references);
364
+ const neededLink = (f) => linkEditable(f) && !f.nullable && !f.optional && !f.hasDefault && !scope.has(f.name);
257
365
  const defaultColumns = own(columnLists, "default") ?? fields.filter((f) => !quiet(f)).map((f) => f.name);
258
366
  const presetNames = Object.freeze(["default", ...Object.keys(columnLists).filter((p) => p !== "default")]);
259
367
  const resolvedColumns = /* @__PURE__ */ new Map();
@@ -286,9 +394,14 @@ function defineView(contract, definition = {}) {
286
394
  resolvedColumns.set(preset, out);
287
395
  return out;
288
396
  };
397
+ const links = new Map(
398
+ fields.filter((f) => linkEditable(f)).map((f) => [f.name, resolveLink(contract.name, f.name, f.references, own(viewFields, f.name)?.link, own(viewFields, f.name)?.labelField)])
399
+ );
289
400
  const placed = definition.form ? formItems.flatMap(
290
401
  (item) => typeof item === "string" ? [{ name: item, section: null, sectionTitle: null }] : item.fields.map((name) => ({ name, section: item.section, sectionTitle: item.title ?? titleCase(item.section) }))
291
- ) : fields.filter((f) => !readOnly(f) && (!quiet(f) || keys.has(f.name) && !f.hasDefault && !f.sensitive) && f.type !== "json" && !f.array).map((f) => ({ name: f.name, section: null, sectionTitle: null }));
402
+ ) : fields.filter(
403
+ (f) => !readOnly(f) && (!quiet(f) || keys.has(f.name) && !f.hasDefault && !f.sensitive || neededLink(f) && !f.sensitive) && f.type !== "json" && !f.array
404
+ ).map((f) => ({ name: f.name, section: null, sectionTitle: null }));
292
405
  const serverKey = (f, mode) => keys.has(f.name) && (mode === "edit" || Boolean(f.hasDefault));
293
406
  const resolvedForms = /* @__PURE__ */ new Map();
294
407
  const form = (mode) => {
@@ -307,9 +420,13 @@ function defineView(contract, definition = {}) {
307
420
  section,
308
421
  sectionTitle,
309
422
  ...v?.max !== void 0 ? { max: v.max } : {},
423
+ ...v?.autoComplete ? { autoComplete: v.autoComplete } : {},
424
+ ...v?.inputMode ? { inputMode: v.inputMode } : {},
425
+ ...v?.enterKeyHint ? { enterKeyHint: v.enterKeyHint } : {},
310
426
  ...v?.labelField ? { labelField: v.labelField } : {},
311
427
  ...v?.missingLabel ? { missingLabel: v.missingLabel } : {},
312
428
  ...field.enumValues?.length ? { options: Object.freeze(field.enumValues.map((value) => Object.freeze({ value, label: valueLabel(name, value) }))) } : {},
429
+ ...links.has(name) ? { link: links.get(name) } : {},
313
430
  ...v?.visible ? { visible: v.visible } : {}
314
431
  });
315
432
  }));
@@ -411,35 +528,6 @@ function rowPicture(summary) {
411
528
  return initials ? { kind: "initials", text: initials } : null;
412
529
  }
413
530
 
414
- // src/resource-view/scope.ts
415
- var camel = (key) => key.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
416
- function scopeValues(view, scope) {
417
- const out = {};
418
- const missing = [];
419
- for (const key of view.definition.scope ?? []) {
420
- const value = scope && Object.hasOwn(scope, key) ? scope[key] : scope?.[camel(key)];
421
- if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") out[key] = value;
422
- else missing.push(key);
423
- }
424
- if (missing.length && process.env.NODE_ENV !== "production") {
425
- throw new ViewDefinitionError(
426
- view.resource,
427
- missing.map((key) => `scope "${key}" has no single value in ViewerScope's scope`)
428
- );
429
- }
430
- return Object.freeze(out);
431
- }
432
- function scopeFilter(view, scope) {
433
- const out = {};
434
- if (!scope) return out;
435
- for (const key of view.definition.scope ?? []) {
436
- const value = Object.hasOwn(scope, key) ? scope[key] : scope[camel(key)];
437
- if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") out[key] = value;
438
- else if (Array.isArray(value) && value.every((v) => typeof v === "string" || typeof v === "number")) out[key] = value;
439
- }
440
- return Object.freeze(out);
441
- }
442
-
443
531
  // src/resource-view/tree.ts
444
532
  var rootish = (parent) => parent == null || parent === "";
445
533
  function treeRows(rows, options) {
@@ -763,6 +851,6 @@ function defineRecordView(view, definition) {
763
851
  var defineWorkspace = defineRecordView;
764
852
  var isWorkspace = isRecordView;
765
853
 
766
- export { ViewDefinitionError, calendarProblems, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
854
+ export { ViewDefinitionError, calendarProblems, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, filterParams, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
767
855
  //# sourceMappingURL=index.js.map
768
856
  //# sourceMappingURL=index.js.map