@object-ui/data-objectstack 6.2.3 → 7.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 +144 -0
- package/dist/index.cjs +390 -22
- package/dist/index.d.cts +386 -5
- package/dist/index.d.ts +386 -5
- package/dist/index.js +390 -22
- package/package.json +5 -5
- package/src/getObjectSchema.test.ts +77 -0
- package/src/index.ts +279 -18
- package/src/listViews.test.ts +78 -0
- package/src/metadata-client.test.ts +141 -0
- package/src/metadata-client.ts +469 -11
- package/src/queryDataset.test.ts +83 -0
package/dist/index.d.cts
CHANGED
|
@@ -537,11 +537,32 @@ interface MetadataClientConfig {
|
|
|
537
537
|
fetch?: typeof fetch;
|
|
538
538
|
/** Additional headers (e.g. auth) included on every request. */
|
|
539
539
|
headers?: Record<string, string>;
|
|
540
|
+
/**
|
|
541
|
+
* ADR-0037 Live Canvas — render the world **as-if-published**. When true,
|
|
542
|
+
* `list()` and `get()` append `?preview=draft`, which the framework
|
|
543
|
+
* dispatcher maps to `getMetaItems/getMetaItem({ previewDrafts: true })`:
|
|
544
|
+
* pending ADR-0033 drafts overlay the active registry (draft wins by name,
|
|
545
|
+
* draft-only items surface). Reads only — writes are unaffected, and
|
|
546
|
+
* nothing the preview shows is live until Publish.
|
|
547
|
+
*/
|
|
548
|
+
previewDrafts?: boolean;
|
|
540
549
|
}
|
|
541
550
|
interface MetadataListOptions {
|
|
542
551
|
/** Filter by source package id (matches the `package` query param). */
|
|
543
552
|
packageId?: string;
|
|
544
553
|
}
|
|
554
|
+
/**
|
|
555
|
+
* A pending DRAFT metadata item (ADR-0033), as returned by {@link MetadataClient.listDrafts}.
|
|
556
|
+
* Light header — no body — carrying the owning package so the console can group
|
|
557
|
+
* pending changes by app package.
|
|
558
|
+
*/
|
|
559
|
+
interface MetadataDraftHeader {
|
|
560
|
+
type: string;
|
|
561
|
+
name: string;
|
|
562
|
+
packageId: string | null;
|
|
563
|
+
updatedAt: string | null;
|
|
564
|
+
updatedBy: string | null;
|
|
565
|
+
}
|
|
545
566
|
interface MetadataSaveOptions {
|
|
546
567
|
/**
|
|
547
568
|
* Optimistic concurrency token (the `checksum` returned by the last
|
|
@@ -558,6 +579,42 @@ interface MetadataSaveOptions {
|
|
|
558
579
|
* so the operator can confirm and proceed.
|
|
559
580
|
*/
|
|
560
581
|
force?: boolean;
|
|
582
|
+
/**
|
|
583
|
+
* Save mode — `'draft'` writes a pending draft row (invisible to the
|
|
584
|
+
* runtime until `publish()` is called); `'publish'` writes directly
|
|
585
|
+
* to the active overlay. Omit (or set `'publish'`) for the legacy
|
|
586
|
+
* "save = live" behaviour.
|
|
587
|
+
*/
|
|
588
|
+
mode?: 'draft' | 'publish';
|
|
589
|
+
/**
|
|
590
|
+
* Software-package id to bind the saved row to (sent as the `package`
|
|
591
|
+
* query param → `sys_metadata.package_id`). Set when authoring inside a
|
|
592
|
+
* Studio package workspace. Omit for an env-local overlay.
|
|
593
|
+
*/
|
|
594
|
+
packageId?: string;
|
|
595
|
+
}
|
|
596
|
+
interface MetadataGetOptions {
|
|
597
|
+
/**
|
|
598
|
+
* Read a specific overlay state. `'draft'` returns the pending draft
|
|
599
|
+
* body (no fallback to the published overlay or the registry); omit
|
|
600
|
+
* to read the active (published) value.
|
|
601
|
+
*/
|
|
602
|
+
state?: 'active' | 'draft';
|
|
603
|
+
/**
|
|
604
|
+
* Software-package id to scope resolution (sent as the `package` query
|
|
605
|
+
* param → server prefer-local, ADR-0048). Set when reading one item that
|
|
606
|
+
* may collide by name across installed packages (e.g. the Studio editor
|
|
607
|
+
* passes the edited item's owning package). Omit for context-free reads.
|
|
608
|
+
*/
|
|
609
|
+
packageId?: string;
|
|
610
|
+
}
|
|
611
|
+
interface MetadataDeleteOptions extends MetadataSaveOptions {
|
|
612
|
+
/**
|
|
613
|
+
* Target state. `'draft'` discards the pending draft (keeps the
|
|
614
|
+
* published overlay intact). Omit to reset the active overlay back
|
|
615
|
+
* to the artifact default (the legacy behaviour).
|
|
616
|
+
*/
|
|
617
|
+
state?: 'active' | 'draft';
|
|
561
618
|
}
|
|
562
619
|
/** Layered view of a metadata item — Phase 3a `?layers=true`. */
|
|
563
620
|
interface MetadataLayered<T = unknown> {
|
|
@@ -569,6 +626,126 @@ interface MetadataLayered<T = unknown> {
|
|
|
569
626
|
overlayScope: string | null;
|
|
570
627
|
/** Merged effective view — what the runtime actually sees. */
|
|
571
628
|
effective: T | null;
|
|
629
|
+
/**
|
|
630
|
+
* Load-time validation result for `effective` (server-computed via
|
|
631
|
+
* the same Zod registry used at save time). Undefined for types
|
|
632
|
+
* without a registered Zod schema. Surfaced by the Studio as a
|
|
633
|
+
* banner + inline field errors so operators can spot bad metadata
|
|
634
|
+
* without having to hit Save.
|
|
635
|
+
*/
|
|
636
|
+
_diagnostics?: MetadataDiagnostics;
|
|
637
|
+
/** 4-state lock: `none` / `no-overlay` / `no-delete` / `full`. */
|
|
638
|
+
lock?: 'none' | 'no-overlay' | 'no-delete' | 'full';
|
|
639
|
+
/** Human-readable reason for the lock (tooltip text). */
|
|
640
|
+
lockReason?: string;
|
|
641
|
+
/** Which layer set the lock: artifact / package / overlay / env-forced. */
|
|
642
|
+
lockSource?: 'artifact' | 'package' | 'overlay' | 'env-forced';
|
|
643
|
+
/** Optional docs URL for the lock reason (rendered as "View docs →"). */
|
|
644
|
+
lockDocsUrl?: string;
|
|
645
|
+
/** Origin of the item: `package` (loader) | `org` (tenant) | `env-forced`. */
|
|
646
|
+
provenance?: 'package' | 'org' | 'env-forced';
|
|
647
|
+
/** Owning package id (denormalised from the loader tag). */
|
|
648
|
+
packageId?: string;
|
|
649
|
+
/** Owning package version. */
|
|
650
|
+
packageVersion?: string;
|
|
651
|
+
/** True when the editor should allow Save (PUT). */
|
|
652
|
+
editable?: boolean;
|
|
653
|
+
/** True when the editor should allow Delete. */
|
|
654
|
+
deletable?: boolean;
|
|
655
|
+
/** True when "Reset to package default" applies (has overlay + artifact). */
|
|
656
|
+
resettable?: boolean;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* One row in the metadata protection-audit trail
|
|
660
|
+
* (ADR-0010 §3.6 / Phase 4.1). Mirrors `sys_metadata_audit` columns
|
|
661
|
+
* the API exposes.
|
|
662
|
+
*/
|
|
663
|
+
interface MetadataAuditEntry {
|
|
664
|
+
/** Stable audit-row id (uuid). */
|
|
665
|
+
id: unknown;
|
|
666
|
+
/** ISO timestamp when the attempt happened. */
|
|
667
|
+
occurredAt: string;
|
|
668
|
+
/** Who attempted the operation (`x-actor` header or `'system'`). */
|
|
669
|
+
actor: string;
|
|
670
|
+
/** Code path that recorded the row (e.g. `protocol.saveMetaItem`). */
|
|
671
|
+
source: string | null;
|
|
672
|
+
/** Which lifecycle op was attempted. */
|
|
673
|
+
operation: 'save' | 'publish' | 'rollback' | 'delete' | 'reset';
|
|
674
|
+
/** Decision: allowed / denied / forced (admin override). */
|
|
675
|
+
outcome: 'allowed' | 'denied' | 'forced';
|
|
676
|
+
/** Machine-readable reason code (`item_locked`, `ok`, …). */
|
|
677
|
+
code: string;
|
|
678
|
+
/** Effective lock at the moment of the attempt. */
|
|
679
|
+
lockState: 'none' | 'no-overlay' | 'no-delete' | 'full' | null;
|
|
680
|
+
/** True when admin forced the write through despite the lock. */
|
|
681
|
+
lockOverridden: boolean;
|
|
682
|
+
/** Request-id for trace correlation (if propagated). */
|
|
683
|
+
requestId: string | null;
|
|
684
|
+
/** Free-text note (often the lock reason). */
|
|
685
|
+
note: string | null;
|
|
686
|
+
}
|
|
687
|
+
/** Response shape for `MetadataClient.audit()`. */
|
|
688
|
+
interface MetadataAuditResponse {
|
|
689
|
+
events: MetadataAuditEntry[];
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Load-time validation envelope attached to metadata items by the
|
|
693
|
+
* framework. Mirrors `MetadataValidationResult` in the kernel spec.
|
|
694
|
+
*/
|
|
695
|
+
interface MetadataDiagnostics {
|
|
696
|
+
valid: boolean;
|
|
697
|
+
errors?: Array<{
|
|
698
|
+
path: string;
|
|
699
|
+
message: string;
|
|
700
|
+
code?: string;
|
|
701
|
+
}>;
|
|
702
|
+
warnings?: Array<{
|
|
703
|
+
path: string;
|
|
704
|
+
message: string;
|
|
705
|
+
}>;
|
|
706
|
+
}
|
|
707
|
+
/** Options for the cross-type `/meta/diagnostics` sweep call. */
|
|
708
|
+
interface MetadataDiagnosticsOptions {
|
|
709
|
+
/** Restrict the sweep to a single metadata type (e.g. `'view'`). */
|
|
710
|
+
type?: string;
|
|
711
|
+
/**
|
|
712
|
+
* `'error'` (default) returns only items that fail validation.
|
|
713
|
+
* `'warning'` also includes items whose only diagnostics are warnings.
|
|
714
|
+
*/
|
|
715
|
+
severity?: 'error' | 'warning';
|
|
716
|
+
/** Restrict to items owned by this package id. */
|
|
717
|
+
packageId?: string;
|
|
718
|
+
}
|
|
719
|
+
/** One row in the `/meta/diagnostics` response. */
|
|
720
|
+
interface MetadataDiagnosticsEntry {
|
|
721
|
+
type: string;
|
|
722
|
+
name: string;
|
|
723
|
+
diagnostics: MetadataDiagnostics;
|
|
724
|
+
}
|
|
725
|
+
/** Top-level envelope returned by `/meta/diagnostics`. */
|
|
726
|
+
interface MetadataDiagnosticsSummary {
|
|
727
|
+
entries: MetadataDiagnosticsEntry[];
|
|
728
|
+
/** Number of `entries` returned (post-filter). */
|
|
729
|
+
total: number;
|
|
730
|
+
/** How many metadata types the sweep visited. */
|
|
731
|
+
scannedTypes: number;
|
|
732
|
+
/** How many individual items were validated. */
|
|
733
|
+
scannedItems: number;
|
|
734
|
+
/**
|
|
735
|
+
* Per-type aggregate stats — count of items and the list of
|
|
736
|
+
* packages contributing to each type. Computed in the same sweep
|
|
737
|
+
* so a single call serves both the diagnostics governance page and
|
|
738
|
+
* the directory tile counts / package filter.
|
|
739
|
+
*
|
|
740
|
+
* Optional for backward compatibility with older framework
|
|
741
|
+
* versions that do not yet emit it; clients should fall back to
|
|
742
|
+
* an empty record.
|
|
743
|
+
*/
|
|
744
|
+
stats?: Record<string, {
|
|
745
|
+
count: number;
|
|
746
|
+
locked?: number;
|
|
747
|
+
packages: string[];
|
|
748
|
+
}>;
|
|
572
749
|
}
|
|
573
750
|
/** Reference back-pointer — Phase 3a `/references`. */
|
|
574
751
|
interface MetadataReference {
|
|
@@ -607,31 +784,101 @@ declare class MetadataClient {
|
|
|
607
784
|
private readonly base;
|
|
608
785
|
private readonly fetchImpl;
|
|
609
786
|
private readonly headers;
|
|
787
|
+
/** ADR-0037: when true, reads render the draft-overlaid world. */
|
|
788
|
+
readonly previewDrafts: boolean;
|
|
610
789
|
constructor(config: MetadataClientConfig);
|
|
611
790
|
/** Update the client's environment scope at runtime. */
|
|
612
791
|
withEnvironment(environmentId: string | undefined): MetadataClient;
|
|
792
|
+
/**
|
|
793
|
+
* Derive a client whose reads render the draft-overlaid world (or not).
|
|
794
|
+
* Same base/fetch/headers; used by the app-shell to switch the whole
|
|
795
|
+
* renderer tree into ADR-0037 preview mode off one URL flag.
|
|
796
|
+
*/
|
|
797
|
+
withPreviewDrafts(previewDrafts: boolean): MetadataClient;
|
|
613
798
|
/** List all registered metadata types (returns the registry rows). */
|
|
614
799
|
listTypes(): Promise<unknown[]>;
|
|
615
800
|
/** List items of a metadata type (e.g. `object`, `field`, `view`). */
|
|
616
801
|
list<T = unknown>(type: string, options?: MetadataListOptions): Promise<T[]>;
|
|
802
|
+
/**
|
|
803
|
+
* List pending DRAFT items (ADR-0033) — what an AI authored but nobody
|
|
804
|
+
* published yet. `list()` only sees published/active metadata, so a
|
|
805
|
+
* just-built app package looks empty there; this surfaces the drafts so the
|
|
806
|
+
* console can show a "pending changes" view and draft-aware package contents.
|
|
807
|
+
* Optionally narrow by `packageId` and/or `type`. Returns light headers
|
|
808
|
+
* (no body) carrying `packageId` for grouping.
|
|
809
|
+
*/
|
|
810
|
+
listDrafts(options?: {
|
|
811
|
+
packageId?: string;
|
|
812
|
+
type?: string;
|
|
813
|
+
}): Promise<MetadataDraftHeader[]>;
|
|
617
814
|
/**
|
|
618
815
|
* Get a single metadata item. Returns the unwrapped item content
|
|
619
816
|
* (matching the framework REST handler which calls `res.json(item)`).
|
|
620
817
|
* Returns `null` on 404 to keep the call-site ergonomic.
|
|
621
818
|
*/
|
|
622
|
-
get<T = unknown>(type: string, name: string): Promise<T | null>;
|
|
819
|
+
get<T = unknown>(type: string, name: string, options?: MetadataGetOptions): Promise<T | null>;
|
|
820
|
+
/**
|
|
821
|
+
* Read the pending draft body for an item (`?state=draft`). Returns
|
|
822
|
+
* `null` when there is no draft pending. Draft reads do NOT fall
|
|
823
|
+
* back to the published overlay or the artifact registry — a `null`
|
|
824
|
+
* unambiguously means "nothing to publish".
|
|
825
|
+
*
|
|
826
|
+
* Note: the framework wraps draft responses in an envelope
|
|
827
|
+
* `{ type, name, item }` (matching `getMetaItem`); callers should
|
|
828
|
+
* read `.item` to get the body. The legacy `get()` returns the
|
|
829
|
+
* unwrapped body, so this method preserves that asymmetry by
|
|
830
|
+
* returning whatever the server sent.
|
|
831
|
+
*/
|
|
832
|
+
getDraft<T = unknown>(type: string, name: string, options?: {
|
|
833
|
+
packageId?: string;
|
|
834
|
+
}): Promise<T | null>;
|
|
623
835
|
/**
|
|
624
836
|
* Save (PUT) a metadata item. The framework accepts both the bare
|
|
625
837
|
* item payload and the `{ item: ... }` / `{ metadata: ... }`
|
|
626
|
-
* envelopes; we send bare for consistency.
|
|
838
|
+
* envelopes; we send bare for consistency. Pass `mode: 'draft'` to
|
|
839
|
+
* stage the change without publishing (Studio's "Save" button).
|
|
627
840
|
*/
|
|
628
841
|
save<T = unknown>(type: string, name: string, item: unknown, options?: MetadataSaveOptions): Promise<T>;
|
|
842
|
+
/**
|
|
843
|
+
* Publish a single pending draft BY REFERENCE — promotes the draft row for
|
|
844
|
+
* `(type, name)` into the active overlay and drops the draft. Works for ANY
|
|
845
|
+
* draft, including ones with no `packageId` binding (which the package-scoped
|
|
846
|
+
* `/packages/:id/publish-drafts` flow cannot reach). Use this to publish the
|
|
847
|
+
* exact set returned by {@link listDrafts} without needing a package.
|
|
848
|
+
*
|
|
849
|
+
* Returns the server result. For `seed` drafts the protocol also materializes
|
|
850
|
+
* the rows and reports under `seedApplied` — a data problem never fails the
|
|
851
|
+
* publish, so callers should check `seedApplied?.success` and warn the user
|
|
852
|
+
* rather than assume the data went live.
|
|
853
|
+
*/
|
|
854
|
+
publishDraft(type: string, name: string): Promise<{
|
|
855
|
+
success?: boolean;
|
|
856
|
+
seedApplied?: {
|
|
857
|
+
success: boolean;
|
|
858
|
+
inserted?: number;
|
|
859
|
+
updated?: number;
|
|
860
|
+
error?: string;
|
|
861
|
+
errors?: unknown[];
|
|
862
|
+
};
|
|
863
|
+
} & Record<string, unknown>>;
|
|
629
864
|
/**
|
|
630
865
|
* Get the 3-state layered view of a metadata item (Phase 3a). Returns
|
|
631
866
|
* `code` (the artifact / fallback default), `overlay` (the saved
|
|
632
867
|
* customisation, if any), and `effective` (what the runtime sees).
|
|
633
868
|
*/
|
|
634
|
-
layered<T = unknown>(type: string, name: string
|
|
869
|
+
layered<T = unknown>(type: string, name: string, options?: {
|
|
870
|
+
packageId?: string;
|
|
871
|
+
}): Promise<MetadataLayered<T>>;
|
|
872
|
+
/**
|
|
873
|
+
* Cross-type sweep of load-time validation results — calls
|
|
874
|
+
* `GET /meta/diagnostics`. Returns every entry the framework
|
|
875
|
+
* considers invalid (or, when `severity: 'warning'`, also entries
|
|
876
|
+
* with only warnings).
|
|
877
|
+
*
|
|
878
|
+
* Used by the Studio's governance overview page and by the
|
|
879
|
+
* directory page to show "N invalid" badges per metadata type.
|
|
880
|
+
*/
|
|
881
|
+
diagnostics(options?: MetadataDiagnosticsOptions): Promise<MetadataDiagnosticsSummary>;
|
|
635
882
|
/**
|
|
636
883
|
* Find every metadata item that references this one (Phase 3a). Useful
|
|
637
884
|
* for pre-delete impact analysis: "Are any views pointing at this
|
|
@@ -641,10 +888,53 @@ declare class MetadataClient {
|
|
|
641
888
|
/**
|
|
642
889
|
* Reset a metadata customization overlay back to the artifact default.
|
|
643
890
|
* Idempotent: returns the result even when no overlay row existed.
|
|
891
|
+
* Pass `state: 'draft'` to discard the pending draft only (keeps the
|
|
892
|
+
* published overlay intact) — useful for a Studio "Discard draft" button.
|
|
893
|
+
*/
|
|
894
|
+
reset<T = unknown>(type: string, name: string, options?: MetadataDeleteOptions): Promise<T>;
|
|
895
|
+
/**
|
|
896
|
+
* Promote the pending draft of an item to the active overlay
|
|
897
|
+
* (POST `/meta/:type/:name/publish`). Returns
|
|
898
|
+
* `{ success, version, seq, message }`. Throws a `404 no_draft` if
|
|
899
|
+
* nothing is pending and `409 metadata_conflict` if the published
|
|
900
|
+
* overlay moved while the draft was sitting.
|
|
901
|
+
*/
|
|
902
|
+
publish<T = unknown>(type: string, name: string, options?: {
|
|
903
|
+
actor?: string;
|
|
904
|
+
message?: string;
|
|
905
|
+
}): Promise<T>;
|
|
906
|
+
/**
|
|
907
|
+
* Restore an item to a previous version (POST `/meta/:type/:name/rollback`).
|
|
908
|
+
* The server reads the history row at `toVersion`, writes its body back
|
|
909
|
+
* as the active overlay with `operation_type='revert'`. Returns
|
|
910
|
+
* `{ success, version, seq, restoredFromVersion, message }`. Throws
|
|
911
|
+
* `404 version_not_found` for unknown versions and `409 version_not_restorable`
|
|
912
|
+
* when the target version is a delete tombstone.
|
|
913
|
+
*/
|
|
914
|
+
rollback<T = unknown>(type: string, name: string, toVersion: number, options?: {
|
|
915
|
+
actor?: string;
|
|
916
|
+
message?: string;
|
|
917
|
+
}): Promise<T>;
|
|
918
|
+
/**
|
|
919
|
+
* Compute a structured top-level key diff between two history versions
|
|
920
|
+
* (GET `/meta/:type/:name/diff?from=&to=`). Returns
|
|
921
|
+
* `{ added, removed, changed }` where each entry carries a `path` and
|
|
922
|
+
* the relevant value(s). Useful for "what changed in this draft?" and
|
|
923
|
+
* pre-rollback previews.
|
|
644
924
|
*/
|
|
645
|
-
|
|
925
|
+
diff<T = unknown>(type: string, name: string, fromVersion?: number, toVersion?: number): Promise<T>;
|
|
646
926
|
/** Fetch the durable history (change log) for one metadata item. */
|
|
647
927
|
history<T = unknown>(type: string, name: string, options?: MetadataHistoryOptions): Promise<T>;
|
|
928
|
+
/**
|
|
929
|
+
* Fetch the protection-audit trail for one metadata item
|
|
930
|
+
* (ADR-0010 §3.6 / Phase 4.1). Shows every save/publish/rollback/
|
|
931
|
+
* delete/reset attempt — allowed, denied, or forced — so the
|
|
932
|
+
* Studio "审计日志 / Audit log" tab can render who tried what
|
|
933
|
+
* and whether a lock blocked it.
|
|
934
|
+
*/
|
|
935
|
+
audit(type: string, name: string, options?: {
|
|
936
|
+
limit?: number;
|
|
937
|
+
}): Promise<MetadataAuditResponse>;
|
|
648
938
|
}
|
|
649
939
|
|
|
650
940
|
/**
|
|
@@ -1127,6 +1417,20 @@ declare class ObjectStackAdapter<T = unknown> implements DataSource<T> {
|
|
|
1127
1417
|
* @param data - Array of records to process
|
|
1128
1418
|
* @returns Promise resolving to array of results
|
|
1129
1419
|
*/
|
|
1420
|
+
/**
|
|
1421
|
+
* Cross-object transactional batch (ObjectStack #1604). Runs the operations
|
|
1422
|
+
* in ONE server transaction — commit all or roll back all. A field value of
|
|
1423
|
+
* `{ $ref: <earlier op index> }` resolves to that op's created id, so a child
|
|
1424
|
+
* can reference its parent created earlier in the same batch (master-detail).
|
|
1425
|
+
*/
|
|
1426
|
+
batchTransaction(operations: Array<{
|
|
1427
|
+
object: string;
|
|
1428
|
+
action?: 'create' | 'update' | 'delete';
|
|
1429
|
+
data?: any;
|
|
1430
|
+
id?: string;
|
|
1431
|
+
}>): Promise<{
|
|
1432
|
+
results: any[];
|
|
1433
|
+
}>;
|
|
1130
1434
|
bulk(resource: string, operation: 'create' | 'update' | 'delete', data: Partial<T>[]): Promise<T[]>;
|
|
1131
1435
|
/**
|
|
1132
1436
|
* Normalize the result from data.find() or data.query() into a consistent QueryResult.
|
|
@@ -1152,6 +1456,24 @@ declare class ObjectStackAdapter<T = unknown> implements DataSource<T> {
|
|
|
1152
1456
|
* @returns Promise resolving to the object schema
|
|
1153
1457
|
*/
|
|
1154
1458
|
getObjectSchema(objectName: string): Promise<unknown>;
|
|
1459
|
+
/**
|
|
1460
|
+
* Fetch a single object's schema while always revalidating the browser cache.
|
|
1461
|
+
*
|
|
1462
|
+
* The server serves `GET /api/v1/meta/object/:name` with
|
|
1463
|
+
* `Cache-Control: public, max-age=3600`, so the default `fetch` the SDK uses
|
|
1464
|
+
* keeps returning the same response from the browser HTTP cache for up to an
|
|
1465
|
+
* hour without contacting the origin. Because the create/edit form reads the
|
|
1466
|
+
* object schema through {@link getObjectSchema}, a field added + published in
|
|
1467
|
+
* the same session never appears in the form even though it is live (the LIST
|
|
1468
|
+
* endpoint, `/meta/object`, is uncached — which is why list views update).
|
|
1469
|
+
*
|
|
1470
|
+
* Issuing the read with `cache: 'no-cache'` forces a conditional revalidation
|
|
1471
|
+
* (`If-None-Match`): a changed ETag returns the fresh schema, an unchanged one
|
|
1472
|
+
* still gets a cheap `304`. We go through `fetchImpl` (the adapter's
|
|
1473
|
+
* authenticated fetch) rather than `client.meta.getItem` because the SDK does
|
|
1474
|
+
* not expose the request cache mode.
|
|
1475
|
+
*/
|
|
1476
|
+
private fetchObjectSchemaFresh;
|
|
1155
1477
|
/**
|
|
1156
1478
|
* Get access to the underlying ObjectStack client for advanced operations.
|
|
1157
1479
|
*/
|
|
@@ -1286,6 +1608,65 @@ declare class ObjectStackAdapter<T = unknown> implements DataSource<T> {
|
|
|
1286
1608
|
* is not available.
|
|
1287
1609
|
*/
|
|
1288
1610
|
aggregate(resource: string, params: any): Promise<any[]>;
|
|
1611
|
+
/**
|
|
1612
|
+
* Run a semantic-layer `dataset` (ADR-0021) and return chart-ready rows.
|
|
1613
|
+
*
|
|
1614
|
+
* Posts to `POST /api/v1/analytics/dataset/query` (see `@objectstack/rest`
|
|
1615
|
+
* `registerAnalyticsEndpoints`). Accepts either a saved dataset name or an
|
|
1616
|
+
* inline draft definition — the inline form is what the Studio dataset
|
|
1617
|
+
* editor sends to preview an unsaved draft. The adapter's bearer token is
|
|
1618
|
+
* forwarded so tenant/RLS scoping (ADR-0021 D-C) is enforced server-side.
|
|
1619
|
+
*
|
|
1620
|
+
* Unlike {@link aggregate}, this does NOT fall back to client-side
|
|
1621
|
+
* aggregation: cross-object joins can only run on the server, so a failure
|
|
1622
|
+
* is surfaced to the caller (the preview panel shows the error) rather than
|
|
1623
|
+
* silently returning wrong numbers.
|
|
1624
|
+
*
|
|
1625
|
+
* @param dataset - An inline dataset definition (draft) OR a saved dataset name.
|
|
1626
|
+
* @param selection - Dimension/measure names to project + runtime directives.
|
|
1627
|
+
*/
|
|
1628
|
+
queryDataset(dataset: Record<string, unknown> | string, selection: {
|
|
1629
|
+
dimensions?: string[];
|
|
1630
|
+
measures: string[];
|
|
1631
|
+
runtimeFilter?: Record<string, unknown>;
|
|
1632
|
+
timeDimensions?: unknown[];
|
|
1633
|
+
compareTo?: {
|
|
1634
|
+
kind: 'previousPeriod' | 'previousYear';
|
|
1635
|
+
dimension: string;
|
|
1636
|
+
};
|
|
1637
|
+
order?: Record<string, 'asc' | 'desc'>;
|
|
1638
|
+
limit?: number;
|
|
1639
|
+
offset?: number;
|
|
1640
|
+
timezone?: string;
|
|
1641
|
+
/** Marginal-aggregate groupings (e.g. `[rows, [colDim], []]`) — server
|
|
1642
|
+
* computes each subtotal with the measure's TRUE aggregate (never client
|
|
1643
|
+
* re-derived). `[]` is the grand total. */
|
|
1644
|
+
totals?: {
|
|
1645
|
+
groupings: string[][];
|
|
1646
|
+
};
|
|
1647
|
+
}): Promise<{
|
|
1648
|
+
rows: Array<Record<string, unknown>>;
|
|
1649
|
+
/** Column metadata: a display `label` (dimensions and measures), and a
|
|
1650
|
+
* measure's numeral `format` + declared `currency` for value formatting. */
|
|
1651
|
+
fields: Array<{
|
|
1652
|
+
name: string;
|
|
1653
|
+
type: string;
|
|
1654
|
+
label?: string;
|
|
1655
|
+
format?: string;
|
|
1656
|
+
currency?: string;
|
|
1657
|
+
}>;
|
|
1658
|
+
/** ADR-0021 D2 drill-through: the dataset's base object (records to drill into). */
|
|
1659
|
+
object?: string;
|
|
1660
|
+
/** Drillable dimension NAME → underlying object FIELD name. */
|
|
1661
|
+
dimensionFields?: Record<string, string>;
|
|
1662
|
+
/** Raw grouped values per row (aligned to `rows` by index) for drill filters. */
|
|
1663
|
+
drillRawRows?: Array<Record<string, unknown>>;
|
|
1664
|
+
/** Server-computed marginal aggregates, one entry per requested grouping. */
|
|
1665
|
+
totals?: Array<{
|
|
1666
|
+
dimensions: string[];
|
|
1667
|
+
rows: Array<Record<string, unknown>>;
|
|
1668
|
+
}>;
|
|
1669
|
+
}>;
|
|
1289
1670
|
/** Client-side aggregation fallback */
|
|
1290
1671
|
private aggregateClientSide;
|
|
1291
1672
|
/**
|
|
@@ -1389,4 +1770,4 @@ declare function createObjectStackAdapter<T = unknown>(config: {
|
|
|
1389
1770
|
reconnectDelay?: number;
|
|
1390
1771
|
}): DataSource<T>;
|
|
1391
1772
|
|
|
1392
|
-
export { type AuditEventType, type AuditLogConfig, type AuditLogEntry, AuthenticationError, type BatchProgressEvent, type BatchProgressListener, BulkOperationError, type CSPConfig, type CacheStats, type CloudDeploymentConfig, type CloudHostingConfig, type CloudMarketplaceEntry, CloudOperations, ConcurrentUpdateError, ConnectionError, type ConnectionState, type ConnectionStateEvent, type ConnectionStateListener, type ContractValidationError, type ContractValidationResult, type DataMaskingConfig, type DataMaskingRule, type EmailIntegrationConfig, type IntegrationConfig, IntegrationManager, type IntegrationProvider, type IntegrationTrigger, MetadataClient, type MetadataClientConfig, type MetadataError, type MetadataHistoryOptions, type MetadataLayered, type MetadataListOptions, MetadataNotFoundError, type MetadataReference, type MetadataSaveOptions, ObjectStackAdapter, ObjectStackError, type ObjectStackUserStateAdapterOptions, type PluginAPIContract, type PluginContract, type PluginExport, SecurityManager, type SecurityPolicy, type SlackIntegrationConfig, type StudioCanvasConfig, type StudioColorPalette, type StudioPropertyEditor, type StudioShadowPreset, type StudioThemeBuilderConfig, type StudioTypographyPreset, type UserDataAdapter, ValidationError, type WebhookIntegrationConfig, calculateAutoLayout, clearSharedDiscoveryCache, createDefaultCanvasConfig, createErrorFromResponse, createObjectStackAdapter, createObjectStackUserStateAdapter, generateContractManifest, getSharedDiscovery, is404Error, isConcurrentUpdateError, isErrorType, isObjectStackError, normaliseClientError, snapToGrid, validatePluginContract };
|
|
1773
|
+
export { type AuditEventType, type AuditLogConfig, type AuditLogEntry, AuthenticationError, type BatchProgressEvent, type BatchProgressListener, BulkOperationError, type CSPConfig, type CacheStats, type CloudDeploymentConfig, type CloudHostingConfig, type CloudMarketplaceEntry, CloudOperations, ConcurrentUpdateError, ConnectionError, type ConnectionState, type ConnectionStateEvent, type ConnectionStateListener, type ContractValidationError, type ContractValidationResult, type DataMaskingConfig, type DataMaskingRule, type EmailIntegrationConfig, type IntegrationConfig, IntegrationManager, type IntegrationProvider, type IntegrationTrigger, type MetadataAuditEntry, type MetadataAuditResponse, MetadataClient, type MetadataClientConfig, type MetadataDeleteOptions, type MetadataDiagnostics, type MetadataDiagnosticsEntry, type MetadataDiagnosticsOptions, type MetadataDiagnosticsSummary, type MetadataDraftHeader, type MetadataError, type MetadataGetOptions, type MetadataHistoryOptions, type MetadataLayered, type MetadataListOptions, MetadataNotFoundError, type MetadataReference, type MetadataSaveOptions, ObjectStackAdapter, ObjectStackError, type ObjectStackUserStateAdapterOptions, type PluginAPIContract, type PluginContract, type PluginExport, SecurityManager, type SecurityPolicy, type SlackIntegrationConfig, type StudioCanvasConfig, type StudioColorPalette, type StudioPropertyEditor, type StudioShadowPreset, type StudioThemeBuilderConfig, type StudioTypographyPreset, type UserDataAdapter, ValidationError, type WebhookIntegrationConfig, calculateAutoLayout, clearSharedDiscoveryCache, createDefaultCanvasConfig, createErrorFromResponse, createObjectStackAdapter, createObjectStackUserStateAdapter, generateContractManifest, getSharedDiscovery, is404Error, isConcurrentUpdateError, isErrorType, isObjectStackError, normaliseClientError, snapToGrid, validatePluginContract };
|