@object-ui/data-objectstack 13.2.0 → 14.0.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 CHANGED
@@ -1,5 +1,44 @@
1
1
  # @object-ui/data-objectstack
2
2
 
3
+ ## 14.0.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6a74160: Sharing-rule form: pick, don't type. Three new widget-hint field components make
8
+ the generic object form render pickers where an admin previously had to type
9
+ machine data (driven by the framework `widget` hints on `sys_sharing_rule`;
10
+ generalizes the `capability-multiselect` pattern). All degrade to the underlying
11
+ `type` renderer when a widget is unregistered.
12
+
13
+ - **`object-ref`** — choose a registered object by name (searchable `Combobox`),
14
+ backed by the new `DataSource.getObjects()` (`ObjectStackAdapter` lists code-
15
+ and DB-defined objects via `/api/v1/meta/object`), falling back to a
16
+ `sys_metadata` query. Stores the object's `name`.
17
+ - **`filter-condition`** — a visual criteria builder (`FilterBuilder`) scoped to
18
+ the fields of the object chosen in a sibling field (via `getObjectSchema`),
19
+ round-tripping the stored **MongoDB-style** FilterCondition JSON. Criteria the
20
+ builder can't represent (or invalid JSON) fall back to a raw-JSON editor, with
21
+ an always-available "Edit as JSON" toggle — nothing is hidden or lost.
22
+ - **`recipient-picker`** — a record picker whose target object follows a sibling
23
+ `recipient_type` (`user`→sys_user, `team`→sys_team, `business_unit`/
24
+ `unit_and_subordinates`→sys_business_unit, `position`→sys_position), storing the
25
+ value the evaluator matches on (a record id, or the position **name**). Resets
26
+ the stored id when the type changes.
27
+
28
+ Wiring: the three keys join `DATA_SOURCE_FIELD_TYPES` (form.tsx) so the form
29
+ threads `dataSource` + `dependentValues` to them, and `INLINE_EXCLUDED_FIELD_TYPES`
30
+ (they're authored in the record form, not a grid cell). `DataSource.getObjects()`
31
+ is optional on the interface; the ObjectStack adapter implements it.
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [443360a]
36
+ - Updated dependencies [86c69c3]
37
+ - Updated dependencies [05e56ca]
38
+ - Updated dependencies [6a74160]
39
+ - @object-ui/core@14.0.0
40
+ - @object-ui/types@14.0.0
41
+
3
42
  ## 13.2.0
4
43
 
5
44
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -2525,6 +2525,35 @@ var ObjectStackAdapter = class {
2525
2525
  const data = body && typeof body === "object" && "success" in body && "data" in body ? body.data : body;
2526
2526
  return data && typeof data === "object" && "item" in data ? data.item : data;
2527
2527
  }
2528
+ /**
2529
+ * List every registered object (code- and DB-defined) from the metadata
2530
+ * registry — `GET /api/v1/meta/object`. Returns lightweight `{ name, label }`
2531
+ * headers for object-picker widgets (e.g. the sharing-rule `object-ref`
2532
+ * field). The list endpoint is uncached server-side, so no cache-busting
2533
+ * dance is needed. Returns `[]` on any failure so callers degrade gracefully.
2534
+ */
2535
+ async getObjects() {
2536
+ try {
2537
+ await this.connect();
2538
+ const baseUrl = (this.baseUrl || "").replace(/\/$/, "");
2539
+ const hasApiVersionSuffix = /\/api\/v\d+$/i.test(baseUrl);
2540
+ const metaPath = hasApiVersionSuffix ? "/meta" : "/api/v1/meta";
2541
+ const url = `${baseUrl}${metaPath}/object`;
2542
+ const headers = { "Content-Type": "application/json" };
2543
+ if (this.token) headers["Authorization"] = `Bearer ${this.token}`;
2544
+ const res = await this.fetchImpl(url, { method: "GET", headers });
2545
+ if (!res.ok) return [];
2546
+ const body = await res.json();
2547
+ const data = body && typeof body === "object" && "success" in body && "data" in body ? body.data : body;
2548
+ const items = Array.isArray(data) ? data : Array.isArray(data?.items) ? data.items : [];
2549
+ return items.map((it) => ({
2550
+ name: String(it?.name ?? ""),
2551
+ label: it?.label != null ? String(it.label) : void 0
2552
+ })).filter((it) => it.name);
2553
+ } catch {
2554
+ return [];
2555
+ }
2556
+ }
2528
2557
  /**
2529
2558
  * Get access to the underlying ObjectStack client for advanced operations.
2530
2559
  */
package/dist/index.d.cts CHANGED
@@ -1557,6 +1557,17 @@ declare class ObjectStackAdapter<T = unknown> implements DataSource<T> {
1557
1557
  * not expose the request cache mode.
1558
1558
  */
1559
1559
  private fetchObjectSchemaFresh;
1560
+ /**
1561
+ * List every registered object (code- and DB-defined) from the metadata
1562
+ * registry — `GET /api/v1/meta/object`. Returns lightweight `{ name, label }`
1563
+ * headers for object-picker widgets (e.g. the sharing-rule `object-ref`
1564
+ * field). The list endpoint is uncached server-side, so no cache-busting
1565
+ * dance is needed. Returns `[]` on any failure so callers degrade gracefully.
1566
+ */
1567
+ getObjects(): Promise<Array<{
1568
+ name: string;
1569
+ label?: string;
1570
+ }>>;
1560
1571
  /**
1561
1572
  * Get access to the underlying ObjectStack client for advanced operations.
1562
1573
  */
package/dist/index.d.ts CHANGED
@@ -1557,6 +1557,17 @@ declare class ObjectStackAdapter<T = unknown> implements DataSource<T> {
1557
1557
  * not expose the request cache mode.
1558
1558
  */
1559
1559
  private fetchObjectSchemaFresh;
1560
+ /**
1561
+ * List every registered object (code- and DB-defined) from the metadata
1562
+ * registry — `GET /api/v1/meta/object`. Returns lightweight `{ name, label }`
1563
+ * headers for object-picker widgets (e.g. the sharing-rule `object-ref`
1564
+ * field). The list endpoint is uncached server-side, so no cache-busting
1565
+ * dance is needed. Returns `[]` on any failure so callers degrade gracefully.
1566
+ */
1567
+ getObjects(): Promise<Array<{
1568
+ name: string;
1569
+ label?: string;
1570
+ }>>;
1560
1571
  /**
1561
1572
  * Get access to the underlying ObjectStack client for advanced operations.
1562
1573
  */
package/dist/index.js CHANGED
@@ -2477,6 +2477,35 @@ var ObjectStackAdapter = class {
2477
2477
  const data = body && typeof body === "object" && "success" in body && "data" in body ? body.data : body;
2478
2478
  return data && typeof data === "object" && "item" in data ? data.item : data;
2479
2479
  }
2480
+ /**
2481
+ * List every registered object (code- and DB-defined) from the metadata
2482
+ * registry — `GET /api/v1/meta/object`. Returns lightweight `{ name, label }`
2483
+ * headers for object-picker widgets (e.g. the sharing-rule `object-ref`
2484
+ * field). The list endpoint is uncached server-side, so no cache-busting
2485
+ * dance is needed. Returns `[]` on any failure so callers degrade gracefully.
2486
+ */
2487
+ async getObjects() {
2488
+ try {
2489
+ await this.connect();
2490
+ const baseUrl = (this.baseUrl || "").replace(/\/$/, "");
2491
+ const hasApiVersionSuffix = /\/api\/v\d+$/i.test(baseUrl);
2492
+ const metaPath = hasApiVersionSuffix ? "/meta" : "/api/v1/meta";
2493
+ const url = `${baseUrl}${metaPath}/object`;
2494
+ const headers = { "Content-Type": "application/json" };
2495
+ if (this.token) headers["Authorization"] = `Bearer ${this.token}`;
2496
+ const res = await this.fetchImpl(url, { method: "GET", headers });
2497
+ if (!res.ok) return [];
2498
+ const body = await res.json();
2499
+ const data = body && typeof body === "object" && "success" in body && "data" in body ? body.data : body;
2500
+ const items = Array.isArray(data) ? data : Array.isArray(data?.items) ? data.items : [];
2501
+ return items.map((it) => ({
2502
+ name: String(it?.name ?? ""),
2503
+ label: it?.label != null ? String(it.label) : void 0
2504
+ })).filter((it) => it.name);
2505
+ } catch {
2506
+ return [];
2507
+ }
2508
+ }
2480
2509
  /**
2481
2510
  * Get access to the underlying ObjectStack client for advanced operations.
2482
2511
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/data-objectstack",
3
- "version": "13.2.0",
3
+ "version": "14.0.0",
4
4
  "description": "ObjectStack Data Adapter for Object UI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,9 +22,9 @@
22
22
  "LICENSE"
23
23
  ],
24
24
  "dependencies": {
25
- "@objectstack/client": "^14.3.0",
26
- "@object-ui/core": "13.2.0",
27
- "@object-ui/types": "13.2.0"
25
+ "@objectstack/client": "^14.6.0",
26
+ "@object-ui/core": "14.0.0",
27
+ "@object-ui/types": "14.0.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "tsup": "^8.5.1",
package/src/index.ts CHANGED
@@ -1725,6 +1725,49 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
1725
1725
  return data && typeof data === 'object' && 'item' in data ? data.item : data;
1726
1726
  }
1727
1727
 
1728
+ /**
1729
+ * List every registered object (code- and DB-defined) from the metadata
1730
+ * registry — `GET /api/v1/meta/object`. Returns lightweight `{ name, label }`
1731
+ * headers for object-picker widgets (e.g. the sharing-rule `object-ref`
1732
+ * field). The list endpoint is uncached server-side, so no cache-busting
1733
+ * dance is needed. Returns `[]` on any failure so callers degrade gracefully.
1734
+ */
1735
+ async getObjects(): Promise<Array<{ name: string; label?: string }>> {
1736
+ try {
1737
+ await this.connect();
1738
+ const baseUrl = (this.baseUrl || '').replace(/\/$/, '');
1739
+ // Avoid doubling /api/v1 when baseUrl already carries the version suffix
1740
+ // (mirrors fetchObjectSchemaFresh).
1741
+ const hasApiVersionSuffix = /\/api\/v\d+$/i.test(baseUrl);
1742
+ const metaPath = hasApiVersionSuffix ? '/meta' : '/api/v1/meta';
1743
+ const url = `${baseUrl}${metaPath}/object`;
1744
+
1745
+ const headers: Record<string, string> = { 'Content-Type': 'application/json' };
1746
+ if (this.token) headers['Authorization'] = `Bearer ${this.token}`;
1747
+
1748
+ const res = await this.fetchImpl(url, { method: 'GET', headers });
1749
+ if (!res.ok) return [];
1750
+ const body: any = await res.json();
1751
+ // Unwrap the `{ success, data }` envelope, the `{ type, items }` list
1752
+ // shape, or a bare array.
1753
+ const data =
1754
+ body && typeof body === 'object' && 'success' in body && 'data' in body ? body.data : body;
1755
+ const items: any[] = Array.isArray(data)
1756
+ ? data
1757
+ : Array.isArray(data?.items)
1758
+ ? data.items
1759
+ : [];
1760
+ return items
1761
+ .map((it: any) => ({
1762
+ name: String(it?.name ?? ''),
1763
+ label: it?.label != null ? String(it.label) : undefined,
1764
+ }))
1765
+ .filter((it) => it.name);
1766
+ } catch {
1767
+ return [];
1768
+ }
1769
+ }
1770
+
1728
1771
  /**
1729
1772
  * Get access to the underlying ObjectStack client for advanced operations.
1730
1773
  */