@object-ui/core 16.1.0 → 17.1.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.
- package/CHANGELOG.md +1355 -4
- package/dist/actions/ActionRunner.d.ts +82 -14
- package/dist/actions/ActionRunner.js +164 -81
- package/dist/actions/actionKeys.d.ts +118 -0
- package/dist/actions/actionKeys.js +243 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +1 -0
- package/dist/adapters/ApiDataSource.js +10 -1
- package/dist/adapters/ValueDataSource.d.ts +2 -2
- package/dist/evaluator/fieldRules.d.ts +0 -2
- package/dist/evaluator/fieldRules.js +3 -2
- package/dist/evaluator/optionLint.js +5 -2
- package/dist/evaluator/optionRules.d.ts +13 -6
- package/dist/evaluator/optionRules.js +0 -23
- package/dist/index.d.ts +4 -0
- package/dist/index.js +7 -0
- package/dist/registry/Registry.d.ts +81 -2
- package/dist/registry/Registry.js +102 -2
- package/dist/registry/public-blocks.js +52 -1
- package/dist/theme/ThemeEngine.js +0 -12
- package/dist/utils/chart-series.d.ts +28 -0
- package/dist/utils/chart-series.js +55 -0
- package/dist/utils/column-identity.d.ts +110 -0
- package/dist/utils/column-identity.js +210 -0
- package/dist/utils/dashboard-filters.d.ts +2 -2
- package/dist/utils/expand-fields.js +8 -8
- package/dist/utils/filter-converter.d.ts +47 -0
- package/dist/utils/filter-converter.js +94 -7
- package/dist/utils/filter-tokens.d.ts +101 -0
- package/dist/utils/filter-tokens.js +173 -0
- package/dist/utils/managedBy.d.ts +21 -3
- package/dist/utils/managedBy.js +45 -4
- package/dist/utils/normalize-list-view.d.ts +99 -0
- package/dist/utils/normalize-list-view.js +255 -0
- package/dist/utils/sort-values.d.ts +52 -0
- package/dist/utils/sort-values.js +125 -0
- package/dist/validation/index.d.ts +9 -1
- package/dist/validation/index.js +9 -1
- package/dist/validation/validators/index.d.ts +7 -1
- package/dist/validation/validators/index.js +7 -1
- package/dist/validation/validators/object-validation-engine.d.ts +151 -31
- package/dist/validation/validators/object-validation-engine.js +275 -142
- package/package.json +4 -4
|
@@ -31,6 +31,19 @@ export class Registry {
|
|
|
31
31
|
writable: true,
|
|
32
32
|
value: new Set()
|
|
33
33
|
});
|
|
34
|
+
/**
|
|
35
|
+
* Bumped whenever the set of KNOWN types changes — a registration, an
|
|
36
|
+
* unregistration, or a new lazy stub. A cheap cache key for consumers that
|
|
37
|
+
* derive something from the whole registry (whitelists, manifests, palettes)
|
|
38
|
+
* and need to rebuild when it grows. Counting types is not a substitute: a
|
|
39
|
+
* registration paired with an unregistration leaves the count untouched.
|
|
40
|
+
*/
|
|
41
|
+
Object.defineProperty(this, "version", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
value: 0
|
|
46
|
+
});
|
|
34
47
|
}
|
|
35
48
|
/**
|
|
36
49
|
* Register a component with optional namespace support.
|
|
@@ -144,6 +157,10 @@ export class Registry {
|
|
|
144
157
|
if (meta?.namespace && !meta?.skipFallback) {
|
|
145
158
|
this.lazyEntries.set(type, entry);
|
|
146
159
|
}
|
|
160
|
+
// Bump the version but do NOT notify: the set of KNOWN types grew, so
|
|
161
|
+
// whitelists and manifests must rebuild, but nothing new can render yet —
|
|
162
|
+
// waking every subscriber for each stub at boot would be pure churn.
|
|
163
|
+
this.version++;
|
|
147
164
|
}
|
|
148
165
|
/**
|
|
149
166
|
* Returns true if `type` (or its namespaced form) has a registered lazy
|
|
@@ -186,6 +203,7 @@ export class Registry {
|
|
|
186
203
|
};
|
|
187
204
|
}
|
|
188
205
|
notify() {
|
|
206
|
+
this.version++;
|
|
189
207
|
for (const listener of this.listeners) {
|
|
190
208
|
try {
|
|
191
209
|
listener();
|
|
@@ -195,6 +213,13 @@ export class Registry {
|
|
|
195
213
|
}
|
|
196
214
|
}
|
|
197
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Monotonic counter of changes to the set of known types. Rebuild anything
|
|
218
|
+
* derived from the whole registry when this moves — see {@link getKnownTypes}.
|
|
219
|
+
*/
|
|
220
|
+
getVersion() {
|
|
221
|
+
return this.version;
|
|
222
|
+
}
|
|
198
223
|
/**
|
|
199
224
|
* Get a component by type. Supports both namespaced and non-namespaced lookups.
|
|
200
225
|
*
|
|
@@ -226,6 +251,13 @@ export class Registry {
|
|
|
226
251
|
/**
|
|
227
252
|
* Get component configuration by type with namespace support.
|
|
228
253
|
*
|
|
254
|
+
* LOADED registrations only — a type that exists solely as a `registerLazy`
|
|
255
|
+
* stub returns `undefined` here, because callers read `.component` off the
|
|
256
|
+
* result and a stub has no renderer until its loader runs. The *contract*
|
|
257
|
+
* question ("is this tag part of the public surface?") must not depend on
|
|
258
|
+
* load order, so {@link getPublicConfigs} resolves lazy stubs separately
|
|
259
|
+
* (objectui#2953). Use {@link hasLazy} / {@link loadLazy} to reach a stub.
|
|
260
|
+
*
|
|
229
261
|
* @param type - Component type (e.g., 'button' or 'ui:button')
|
|
230
262
|
* @param namespace - Optional namespace for lookup priority
|
|
231
263
|
* @returns Component configuration or undefined
|
|
@@ -256,13 +288,47 @@ export class Registry {
|
|
|
256
288
|
return this.components.has(type);
|
|
257
289
|
}
|
|
258
290
|
/**
|
|
259
|
-
* Get all
|
|
291
|
+
* Get all LOADED component types — what can be rendered right now.
|
|
292
|
+
*
|
|
293
|
+
* Pending `registerLazy` stubs are not included; use {@link getKnownTypes}
|
|
294
|
+
* for the question "is this a type this app knows about", which is what a
|
|
295
|
+
* whitelist or manifest wants (objectui#2953).
|
|
260
296
|
*
|
|
261
297
|
* @returns Array of all component type identifiers
|
|
262
298
|
*/
|
|
263
299
|
getAllTypes() {
|
|
264
300
|
return Array.from(this.components.keys());
|
|
265
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Every type the registry can resolve — loaded registrations PLUS pending
|
|
304
|
+
* lazy stubs, deduped. Both the bare and namespaced keys are included, as
|
|
305
|
+
* they are in {@link getAllTypes}.
|
|
306
|
+
*
|
|
307
|
+
* This is the set to build a whitelist or a manifest from. Keying one off
|
|
308
|
+
* `getAllTypes()` instead makes it depend on which plugin chunks happen to
|
|
309
|
+
* have loaded: a lazily-registered block gets rejected as unknown, and
|
|
310
|
+
* whether it does varies by session (objectui#2953).
|
|
311
|
+
*/
|
|
312
|
+
getKnownTypes() {
|
|
313
|
+
return Array.from(new Set([...this.components.keys(), ...this.lazyEntries.keys()]));
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Metadata for `type` — from the loaded registration when there is one,
|
|
317
|
+
* otherwise from a pending `registerLazy` stub.
|
|
318
|
+
*
|
|
319
|
+
* Use this when you need to know what a type IS (namespace, container-ness,
|
|
320
|
+
* declared inputs). {@link getConfig} answers a different question — "can I
|
|
321
|
+
* render this right now" — and is deliberately loaded-only, since callers
|
|
322
|
+
* read `.component` off it.
|
|
323
|
+
*
|
|
324
|
+
* A stub carries only what `registerLazy` was given, so `inputs` is usually
|
|
325
|
+
* absent until the chunk loads. Consumers should treat that as "not yet
|
|
326
|
+
* known", not as "declares no props".
|
|
327
|
+
*/
|
|
328
|
+
getMeta(type, namespace) {
|
|
329
|
+
const key = namespace ? `${namespace}:${type}` : type;
|
|
330
|
+
return this.components.get(key) ?? this.lazyEntries.get(key)?.meta;
|
|
331
|
+
}
|
|
266
332
|
/**
|
|
267
333
|
* Get all registered component configurations.
|
|
268
334
|
*
|
|
@@ -271,10 +337,39 @@ export class Registry {
|
|
|
271
337
|
getAllConfigs() {
|
|
272
338
|
return Array.from(this.components.values());
|
|
273
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Resolve `tag` for the CONTRACT surface: the loaded registration when the
|
|
342
|
+
* component is already in the registry, otherwise the metadata of a pending
|
|
343
|
+
* `registerLazy` stub.
|
|
344
|
+
*
|
|
345
|
+
* A block registered lazily is a first-class member of the contract — the
|
|
346
|
+
* loader is recorded at boot and the plugin chunk is imported on first use —
|
|
347
|
+
* so contract membership must not hinge on whether that import happened to
|
|
348
|
+
* have run yet (objectui#2953).
|
|
349
|
+
*/
|
|
350
|
+
getContractConfig(tag) {
|
|
351
|
+
const loaded = this.components.get(tag);
|
|
352
|
+
if (loaded)
|
|
353
|
+
return loaded;
|
|
354
|
+
const entry = this.lazyEntries.get(tag);
|
|
355
|
+
if (!entry)
|
|
356
|
+
return undefined;
|
|
357
|
+
// Mirror registerLazy's key derivation so the canonical `type` matches the
|
|
358
|
+
// one `register()` will store once the loader runs — that keeps the dedupe
|
|
359
|
+
// below stable across the load. `tag` may already carry the namespace
|
|
360
|
+
// (lazyEntries holds both keys; curated tags like `record:details` are
|
|
361
|
+
// themselves colon-shaped), so don't prefix it twice.
|
|
362
|
+
const ns = entry.meta?.namespace;
|
|
363
|
+
const canonical = ns && !tag.startsWith(`${ns}:`) ? `${ns}:${tag}` : tag;
|
|
364
|
+
return { ...entry.meta, type: canonical, lazy: true };
|
|
365
|
+
}
|
|
274
366
|
/**
|
|
275
367
|
* Get the curated PUBLIC-tier component configs (ADR-0080) — those registered
|
|
276
368
|
* with `tier: 'public'`. This is the contract/AI-vocabulary surface, a subset
|
|
277
369
|
* of the full rendering capability returned by {@link getAllConfigs}.
|
|
370
|
+
*
|
|
371
|
+
* Includes blocks that are only lazily registered so far; those come back
|
|
372
|
+
* with `lazy: true` and no `component` (see {@link PublicComponentConfig}).
|
|
278
373
|
*/
|
|
279
374
|
getPublicConfigs() {
|
|
280
375
|
// Dedupe by the config's canonical (namespaced) `type` — a component is
|
|
@@ -292,12 +387,17 @@ export class Registry {
|
|
|
292
387
|
};
|
|
293
388
|
// Curated contract list first (stable, reviewable order) …
|
|
294
389
|
for (const tag of PUBLIC_BLOCKS)
|
|
295
|
-
add(tag, this.
|
|
390
|
+
add(tag, this.getContractConfig(tag));
|
|
296
391
|
// … plus any bare registration that opted in explicitly via `tier: 'public'`.
|
|
297
392
|
for (const [key, cfg] of this.components.entries()) {
|
|
298
393
|
if (cfg.tier === 'public' && !key.includes(':'))
|
|
299
394
|
add(key, cfg);
|
|
300
395
|
}
|
|
396
|
+
// … and the same opt-in for stubs whose loader has not run yet.
|
|
397
|
+
for (const [key, entry] of this.lazyEntries.entries()) {
|
|
398
|
+
if (entry.meta?.tier === 'public' && !key.includes(':'))
|
|
399
|
+
add(key, this.getContractConfig(key));
|
|
400
|
+
}
|
|
301
401
|
return out;
|
|
302
402
|
}
|
|
303
403
|
/**
|
|
@@ -42,7 +42,58 @@ export const PUBLIC_BLOCKS = [
|
|
|
42
42
|
'record:highlights',
|
|
43
43
|
'record:related_list',
|
|
44
44
|
'record:path',
|
|
45
|
-
|
|
45
|
+
// `record:`-prefixed, like its four siblings above. @object-ui/plugin-form
|
|
46
|
+
// registers this one with `skipFallback: true`, so the bare `line_items` key
|
|
47
|
+
// it was listed under here never existed — the block has shipped all along
|
|
48
|
+
// but could never resolve through the contract (objectui#2953 follow-up).
|
|
49
|
+
'record:line_items',
|
|
50
|
+
// Configurable as of objectui#3023 follow-up: these shipped with renderers
|
|
51
|
+
// but no declared `inputs`, so a model could only emit them bare — which is
|
|
52
|
+
// why they sat outside the contract. Their inputs now mirror what the
|
|
53
|
+
// renderers actually read, so they are authorable and belong here.
|
|
54
|
+
//
|
|
55
|
+
// `record:chatter` is deliberately NOT in this list: it is the same renderer
|
|
56
|
+
// as `record:discussion` under a Salesforce-familiar name, kept for schemas
|
|
57
|
+
// already in the wild. Two spellings of one block is ambiguity an authoring
|
|
58
|
+
// model has no way to resolve, so the vocabulary carries the spec's name.
|
|
59
|
+
'record:activity',
|
|
60
|
+
'record:discussion',
|
|
61
|
+
'record:history',
|
|
62
|
+
'record:quick_actions',
|
|
63
|
+
'record:reference_rail',
|
|
64
|
+
'record:alert',
|
|
65
|
+
// ── Tier A, continued — page-semantic blocks (the spec ui/page vocabulary) ─
|
|
66
|
+
// The `page:` / `element:` / `action:` families the Studio page designer
|
|
67
|
+
// offers and @objectstack/spec's page schema enumerates. Same standing as
|
|
68
|
+
// the `record:` family above: semantic page blocks, not primitives.
|
|
69
|
+
//
|
|
70
|
+
// Deliberately NOT here (each guarded, with its reason, by the console's
|
|
71
|
+
// reverse-coverage test):
|
|
72
|
+
// action:bar record:quick_actions covers the record action
|
|
73
|
+
// strip, and the spec blesses button/group/icon/
|
|
74
|
+
// menu but not bar
|
|
75
|
+
// element:image duplicates the curated `image` primitive below —
|
|
76
|
+
// one spelling per concept
|
|
77
|
+
// element:record_picker record picking is a field widget, not a page
|
|
78
|
+
// block (Studio palette exclusion)
|
|
79
|
+
// element:text_input bare inputs belong to a form, not a page block
|
|
80
|
+
// (Studio palette exclusion)
|
|
81
|
+
// element:metadata_viewer internal metadata debugging surface
|
|
82
|
+
'page:tabs',
|
|
83
|
+
'page:card',
|
|
84
|
+
'page:accordion',
|
|
85
|
+
'page:section',
|
|
86
|
+
'page:footer',
|
|
87
|
+
'page:sidebar',
|
|
88
|
+
'element:text',
|
|
89
|
+
'element:number',
|
|
90
|
+
'element:button',
|
|
91
|
+
'element:definition-list',
|
|
92
|
+
'element:repeater',
|
|
93
|
+
'action:button',
|
|
94
|
+
'action:group',
|
|
95
|
+
'action:menu',
|
|
96
|
+
'action:icon',
|
|
46
97
|
// ── Tier B — layout / content primitives ──────────────────────────────────
|
|
47
98
|
'flex',
|
|
48
99
|
'grid',
|
|
@@ -316,10 +316,6 @@ export function mergeThemes(parent, child) {
|
|
|
316
316
|
shadows: child.shadows || parent.shadows
|
|
317
317
|
? { ...parent.shadows, ...child.shadows }
|
|
318
318
|
: undefined,
|
|
319
|
-
// Deep-merge breakpoints
|
|
320
|
-
breakpoints: child.breakpoints || parent.breakpoints
|
|
321
|
-
? { ...parent.breakpoints, ...child.breakpoints }
|
|
322
|
-
: undefined,
|
|
323
319
|
// Deep-merge animation
|
|
324
320
|
animation: child.animation || parent.animation
|
|
325
321
|
? {
|
|
@@ -339,18 +335,10 @@ export function mergeThemes(parent, child) {
|
|
|
339
335
|
zIndex: child.zIndex || parent.zIndex
|
|
340
336
|
? { ...parent.zIndex, ...child.zIndex }
|
|
341
337
|
: undefined,
|
|
342
|
-
// Deep-merge spacing
|
|
343
|
-
spacing: child.spacing || parent.spacing
|
|
344
|
-
? { ...parent.spacing, ...child.spacing }
|
|
345
|
-
: undefined,
|
|
346
338
|
// Deep-merge customVars
|
|
347
339
|
customVars: child.customVars || parent.customVars
|
|
348
340
|
? { ...parent.customVars, ...child.customVars }
|
|
349
341
|
: undefined,
|
|
350
|
-
// Deep-merge logo
|
|
351
|
-
logo: child.logo || parent.logo
|
|
352
|
-
? { ...parent.logo, ...child.logo }
|
|
353
|
-
: undefined,
|
|
354
342
|
};
|
|
355
343
|
}
|
|
356
344
|
/**
|
|
@@ -89,6 +89,34 @@ export declare function findChartSeriesRow(rows: Array<Record<string, unknown>>
|
|
|
89
89
|
* paint identically across the chart view and dashboard widgets.
|
|
90
90
|
*/
|
|
91
91
|
export declare function buildOptionColorMap(options: unknown): Record<string, string> | null;
|
|
92
|
+
/**
|
|
93
|
+
* Build the DECLARED category order from a select field's `options` — the
|
|
94
|
+
* sequence the author wrote them in on the object (framework#3588).
|
|
95
|
+
*
|
|
96
|
+
* A picklist's option order is already the domain order: a sales `stage` field
|
|
97
|
+
* lists Qualification → Needs Analysis → Proposal → Negotiation because that IS
|
|
98
|
+
* the pipeline. Analytics groups by that field and returns buckets in whatever
|
|
99
|
+
* order the GROUP BY produced (usually alphabetical), which for an
|
|
100
|
+
* ordered-sequence chart — a funnel above all — draws a shape that reads as a
|
|
101
|
+
* pipeline but isn't one.
|
|
102
|
+
*
|
|
103
|
+
* Emits BOTH the stored `value` and its display `label` per option, adjacent
|
|
104
|
+
* and in declared order, for the same reason {@link buildOptionColorMap} keys
|
|
105
|
+
* by both: a chart row's category may carry either, depending on whether the
|
|
106
|
+
* server resolved the dimension's labels. Rank is "index of first match", so
|
|
107
|
+
* either key ranks the option identically.
|
|
108
|
+
*
|
|
109
|
+
* Returns `null` for a field with no options, so callers keep their existing
|
|
110
|
+
* ordering (a funnel falls back to descending by value).
|
|
111
|
+
*/
|
|
112
|
+
export declare function buildCategoryOrder(options: unknown): string[] | null;
|
|
113
|
+
/**
|
|
114
|
+
* Rank map for {@link buildCategoryOrder} keys — `category → position`, first
|
|
115
|
+
* occurrence wins. Categories absent from the declared order get no entry; the
|
|
116
|
+
* caller decides where those sort (see `AdvancedChartImpl`, which keeps them
|
|
117
|
+
* after the declared ones rather than dropping them).
|
|
118
|
+
*/
|
|
119
|
+
export declare function buildCategoryRank(order: string[] | null | undefined): Map<string, number> | null;
|
|
92
120
|
/**
|
|
93
121
|
* Build a `{ value → label }` map from a select/enum field's `options`, for
|
|
94
122
|
* resolving a grouped dimension's stored value to its display label (fed to
|
|
@@ -147,6 +147,61 @@ export function buildOptionColorMap(options) {
|
|
|
147
147
|
}
|
|
148
148
|
return Object.keys(map).length > 0 ? map : null;
|
|
149
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Build the DECLARED category order from a select field's `options` — the
|
|
152
|
+
* sequence the author wrote them in on the object (framework#3588).
|
|
153
|
+
*
|
|
154
|
+
* A picklist's option order is already the domain order: a sales `stage` field
|
|
155
|
+
* lists Qualification → Needs Analysis → Proposal → Negotiation because that IS
|
|
156
|
+
* the pipeline. Analytics groups by that field and returns buckets in whatever
|
|
157
|
+
* order the GROUP BY produced (usually alphabetical), which for an
|
|
158
|
+
* ordered-sequence chart — a funnel above all — draws a shape that reads as a
|
|
159
|
+
* pipeline but isn't one.
|
|
160
|
+
*
|
|
161
|
+
* Emits BOTH the stored `value` and its display `label` per option, adjacent
|
|
162
|
+
* and in declared order, for the same reason {@link buildOptionColorMap} keys
|
|
163
|
+
* by both: a chart row's category may carry either, depending on whether the
|
|
164
|
+
* server resolved the dimension's labels. Rank is "index of first match", so
|
|
165
|
+
* either key ranks the option identically.
|
|
166
|
+
*
|
|
167
|
+
* Returns `null` for a field with no options, so callers keep their existing
|
|
168
|
+
* ordering (a funnel falls back to descending by value).
|
|
169
|
+
*/
|
|
170
|
+
export function buildCategoryOrder(options) {
|
|
171
|
+
if (!Array.isArray(options) || options.length === 0)
|
|
172
|
+
return null;
|
|
173
|
+
const keys = [];
|
|
174
|
+
for (const opt of options) {
|
|
175
|
+
if (typeof opt === 'string' || typeof opt === 'number' || typeof opt === 'boolean') {
|
|
176
|
+
keys.push(String(opt));
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (opt && typeof opt === 'object') {
|
|
180
|
+
const o = opt;
|
|
181
|
+
if (o.value != null)
|
|
182
|
+
keys.push(String(o.value));
|
|
183
|
+
if (o.label != null && String(o.label) !== String(o.value))
|
|
184
|
+
keys.push(String(o.label));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return keys.length > 0 ? keys : null;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Rank map for {@link buildCategoryOrder} keys — `category → position`, first
|
|
191
|
+
* occurrence wins. Categories absent from the declared order get no entry; the
|
|
192
|
+
* caller decides where those sort (see `AdvancedChartImpl`, which keeps them
|
|
193
|
+
* after the declared ones rather than dropping them).
|
|
194
|
+
*/
|
|
195
|
+
export function buildCategoryRank(order) {
|
|
196
|
+
if (!Array.isArray(order) || order.length === 0)
|
|
197
|
+
return null;
|
|
198
|
+
const rank = new Map();
|
|
199
|
+
order.forEach((key, i) => {
|
|
200
|
+
if (!rank.has(key))
|
|
201
|
+
rank.set(key, i);
|
|
202
|
+
});
|
|
203
|
+
return rank.size > 0 ? rank : null;
|
|
204
|
+
}
|
|
150
205
|
/**
|
|
151
206
|
* Build a `{ value → label }` map from a select/enum field's `options`, for
|
|
152
207
|
* resolving a grouped dimension's stored value to its display label (fed to
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI — column identity canonicalization
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The spec's canonical key for "which object field this column shows".
|
|
10
|
+
* `ListColumnSchema` (`@objectstack/spec/view`) declares `field: z.ZodString`
|
|
11
|
+
* as its ONLY required key — there is no `name`, no `fieldName`, no
|
|
12
|
+
* `accessorKey` on it. So `field` is not one dialect among several: it is the
|
|
13
|
+
* contract, and everything else is objectui-side legacy (AGENTS.md #0).
|
|
14
|
+
*
|
|
15
|
+
* Note this is the exact opposite of the FORM layer, where the runtime key is
|
|
16
|
+
* `name` (objectui#3090). The two surfaces sit next to each other and mean the
|
|
17
|
+
* opposite thing by the same pair of key names, which is why copy-paste between
|
|
18
|
+
* them keeps producing the defect this module exists to close.
|
|
19
|
+
*/
|
|
20
|
+
export declare const CANONICAL_COLUMN_IDENTITY_KEY = "field";
|
|
21
|
+
/**
|
|
22
|
+
* Legacy identity spellings, in the order a canonicalizing read falls back
|
|
23
|
+
* through them. `field` wins over both, always.
|
|
24
|
+
*
|
|
25
|
+
* `fieldName` is here for defence, not because objectui emits it: as of
|
|
26
|
+
* objectui#3104 a repo-wide scan finds NO writer of a column-level `fieldName`
|
|
27
|
+
* — every `fieldName:` occurrence in the tree is a function parameter or an
|
|
28
|
+
* unrelated interface member (`AIFieldSuggestion.fieldName`). It survives
|
|
29
|
+
* purely in READERS that were written defensively, and stored host metadata
|
|
30
|
+
* could still carry it, so the fold accepts it and the ratchet counts it.
|
|
31
|
+
*/
|
|
32
|
+
export declare const LEGACY_COLUMN_IDENTITY_KEYS: readonly ["name", "fieldName"];
|
|
33
|
+
/**
|
|
34
|
+
* NOT an identity key — deliberately excluded from everything in this module.
|
|
35
|
+
*
|
|
36
|
+
* `accessorKey` is TanStack Table's own column key (`TableColumn.accessorKey`,
|
|
37
|
+
* `packages/types/src/data-display.ts`, "Data accessor key"). It names a slot in
|
|
38
|
+
* the table LIBRARY's column model, not a field in ObjectStack metadata. Reads
|
|
39
|
+
* like `RelatedList`'s `accessorKey || field || name` therefore merge two
|
|
40
|
+
* different vocabularies in one expression; canonicalizing across that boundary
|
|
41
|
+
* would fossilize the merge, which is precisely the mistake this battle exists
|
|
42
|
+
* to undo. The fold neither reads nor writes it.
|
|
43
|
+
*/
|
|
44
|
+
export declare const TABLE_ADAPTER_COLUMN_KEY = "accessorKey";
|
|
45
|
+
/**
|
|
46
|
+
* Read a column entry's field identity — the ONE reader every consumer should
|
|
47
|
+
* converge onto (objectui#3104 PR2).
|
|
48
|
+
*
|
|
49
|
+
* Accepts the three shapes a `columns` array actually holds: a bare string
|
|
50
|
+
* (`'stage'`), a spec column (`{ field: 'stage' }`), and the legacy objectui
|
|
51
|
+
* shapes (`{ name }` / `{ fieldName }`). Resolution is canonical-first, so it
|
|
52
|
+
* agrees with `buildExpandFields` and with the `$select` projection rather than
|
|
53
|
+
* with whichever half of a mixed-key column happened to be read.
|
|
54
|
+
*
|
|
55
|
+
* Returns `undefined` — not `''` — when nothing is resolvable, so callers can
|
|
56
|
+
* tell "no identity" from "identity is the empty string" and drop the entry
|
|
57
|
+
* instead of requesting a nameless column.
|
|
58
|
+
*/
|
|
59
|
+
export declare function columnIdentity(entry: unknown): string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* True when a column entry carries more than one identity key AND they
|
|
62
|
+
* disagree — the shape that makes the renderer and the data request resolve
|
|
63
|
+
* two different fields. Exported for the "say who wins, loudly" step
|
|
64
|
+
* (objectui#3104 PR3) and used by the tests to name the defect precisely.
|
|
65
|
+
*/
|
|
66
|
+
export declare function hasConflictingColumnIdentity(entry: unknown): boolean;
|
|
67
|
+
/** Reset the warn-once memo. Exported for tests. */
|
|
68
|
+
export declare function resetColumnIdentityWarnings(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Stamp the canonical identity onto one column entry.
|
|
71
|
+
*
|
|
72
|
+
* The transitional strategy (objectui#3104 PR1) is **mirror, don't delete**:
|
|
73
|
+
*
|
|
74
|
+
* - `field` is written with the resolved identity, so the request path — which
|
|
75
|
+
* reads `field` and ONLY `field` in `ListView`'s `$expand`/`$select`
|
|
76
|
+
* builders and in `ObjectGrid.getSelectFields` — always finds one.
|
|
77
|
+
* - a legacy key that is ALREADY PRESENT is overwritten with that same
|
|
78
|
+
* identity, so the name-first read sites still standing (`ListView` ×8,
|
|
79
|
+
* `ObjectGrid`, `ObjectTree`, the detail renderers) resolve to exactly what
|
|
80
|
+
* the request asked for.
|
|
81
|
+
* - a legacy key that is ABSENT is never invented. A spec-clean
|
|
82
|
+
* `{ field: 'stage' }` comes back untouched, by reference; the fold does not
|
|
83
|
+
* manufacture the legacy vocabulary it is trying to retire.
|
|
84
|
+
*
|
|
85
|
+
* This differs on purpose from `normalizeListViewSchema`'s other folds, which
|
|
86
|
+
* DELETE the legacy key so a missed read-site fails loudly. Deleting works
|
|
87
|
+
* inside this repo — every name-first read here falls through to `field` — but
|
|
88
|
+
* `columns` entries cross the package boundary into host applications and
|
|
89
|
+
* third-party renderers, and dropping `name` from under them is a breaking
|
|
90
|
+
* change we have no inventory for. Mirroring is behaviour-preserving for every
|
|
91
|
+
* reader, in or out of the repo; the deletion is PR3's call to make once the
|
|
92
|
+
* in-repo consumers have converged onto {@link columnIdentity}.
|
|
93
|
+
*
|
|
94
|
+
* The result: for any single-key column the resolved identity is unchanged at
|
|
95
|
+
* every read site. The only entries whose behaviour moves are the ones where
|
|
96
|
+
* two sites already disagreed — which is the defect, not a regression.
|
|
97
|
+
*/
|
|
98
|
+
export declare function normalizeColumnIdentity<T>(entry: T): T;
|
|
99
|
+
/**
|
|
100
|
+
* Stamp the canonical identity across a `columns` array.
|
|
101
|
+
*
|
|
102
|
+
* Non-mutating and allocation-frugal in the same way as
|
|
103
|
+
* `normalizeListViewSchema`: when every entry is already canonical the INPUT
|
|
104
|
+
* array is returned by reference, so `ListView`'s downstream `useMemo`s keep a
|
|
105
|
+
* stable dependency identity on the common path and nothing re-renders.
|
|
106
|
+
*
|
|
107
|
+
* String entries pass through untouched — a bare `'stage'` is unambiguous and
|
|
108
|
+
* every consumer already special-cases it.
|
|
109
|
+
*/
|
|
110
|
+
export declare function normalizeColumnIdentities<T>(columns: T): T;
|