@objectstack/objectql 7.1.0 → 7.2.1
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/dist/index.d.mts +109 -3
- package/dist/index.d.ts +109 -3
- package/dist/index.js +399 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +363 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServiceObject, ObjectOwnership, HookContext, QueryAST, EngineQueryOptions, DataEngineInsertOptions, EngineUpdateOptions, EngineDeleteOptions, EngineCountOptions, EngineAggregateOptions, DateGranularityValue, Hook } from '@objectstack/spec/data';
|
|
2
|
-
import { ObjectStackManifest, InstalledPackage, MetadataValidationResult, ExecutionContext } from '@objectstack/spec/kernel';
|
|
2
|
+
import { ObjectStackManifest, InstalledPackage, MetadataValidationResult, MetadataLock, MetadataProvenance, ExecutionContext } from '@objectstack/spec/kernel';
|
|
3
3
|
import * as _objectstack_metadata_core from '@objectstack/metadata-core';
|
|
4
4
|
import { MetadataRepository, MetaRef, MetadataItem, PutOptions, PutResult, DeleteOptions, DeleteResult, MetadataWriteIntent, ListFilter, MetadataItemHeader, HistoryOptions, MetadataEvent, WatchFilter } from '@objectstack/metadata-core';
|
|
5
5
|
import { ObjectStackProtocol, MetadataCacheRequest, MetadataCacheResponse, BatchUpdateRequest, BatchUpdateResponse, UpdateManyDataRequest, DeleteManyDataRequest } from '@objectstack/spec/api';
|
|
@@ -528,6 +528,17 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
528
528
|
total: number;
|
|
529
529
|
scannedTypes: number;
|
|
530
530
|
scannedItems: number;
|
|
531
|
+
/**
|
|
532
|
+
* Per-type aggregate stats — count of items and the list of
|
|
533
|
+
* packages contributing to each type. Computed in the same
|
|
534
|
+
* sweep so the Studio directory page can render tile counts
|
|
535
|
+
* and a package filter in one round-trip.
|
|
536
|
+
*/
|
|
537
|
+
stats: Record<string, {
|
|
538
|
+
count: number;
|
|
539
|
+
locked: number;
|
|
540
|
+
packages: string[];
|
|
541
|
+
}>;
|
|
531
542
|
}>;
|
|
532
543
|
getMetaItems(request: {
|
|
533
544
|
type: string;
|
|
@@ -544,9 +555,23 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
544
555
|
organizationId?: string;
|
|
545
556
|
state?: 'active' | 'draft';
|
|
546
557
|
}): Promise<{
|
|
558
|
+
type: string;
|
|
559
|
+
name: string;
|
|
560
|
+
item: {} | null;
|
|
561
|
+
} | {
|
|
562
|
+
editable: boolean;
|
|
563
|
+
deletable: boolean;
|
|
564
|
+
resettable: boolean;
|
|
565
|
+
packageVersion?: string | undefined;
|
|
566
|
+
packageId?: string | undefined;
|
|
567
|
+
provenance?: "package" | "env-forced" | "org" | undefined;
|
|
568
|
+
lockDocsUrl?: string | undefined;
|
|
569
|
+
lockSource?: "artifact" | "package" | "env-forced" | undefined;
|
|
570
|
+
lockReason?: string | undefined;
|
|
547
571
|
type: string;
|
|
548
572
|
name: string;
|
|
549
573
|
item: unknown;
|
|
574
|
+
lock: "full" | "none" | "no-overlay" | "no-delete";
|
|
550
575
|
}>;
|
|
551
576
|
/**
|
|
552
577
|
* Phase 3a-layered-get: return the 3 layers of a metadata item
|
|
@@ -583,6 +608,50 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
583
608
|
* without a second round-trip.
|
|
584
609
|
*/
|
|
585
610
|
_diagnostics?: MetadataDiagnostics;
|
|
611
|
+
lock: MetadataLock;
|
|
612
|
+
lockReason?: string;
|
|
613
|
+
lockSource?: 'artifact' | 'package' | 'env-forced' | 'overlay';
|
|
614
|
+
lockDocsUrl?: string;
|
|
615
|
+
provenance?: MetadataProvenance;
|
|
616
|
+
packageId?: string;
|
|
617
|
+
packageVersion?: string;
|
|
618
|
+
editable: boolean;
|
|
619
|
+
deletable: boolean;
|
|
620
|
+
resettable: boolean;
|
|
621
|
+
}>;
|
|
622
|
+
/**
|
|
623
|
+
* ADR-0010 §3.6 / Phase 4.1 — read the metadata-protection audit log
|
|
624
|
+
* for a single item. Returns the most-recent rows of
|
|
625
|
+
* `sys_metadata_audit` for this (type, name) tuple, sorted newest
|
|
626
|
+
* first. Refused (`denied`) and forced (`forced`) writes both appear
|
|
627
|
+
* here — they never reach the `history` endpoint, which only tracks
|
|
628
|
+
* successful body snapshots.
|
|
629
|
+
*
|
|
630
|
+
* The table is provisioned by `platform-objects` and is the
|
|
631
|
+
* compliance surface for the lock-enforcement story. When the
|
|
632
|
+
* environment has not yet provisioned the table (legacy install
|
|
633
|
+
* prior to ADR-0010) the call returns `{ events: [] }` instead of
|
|
634
|
+
* raising, keeping the Studio tab harmless.
|
|
635
|
+
*/
|
|
636
|
+
auditMetaItem(request: {
|
|
637
|
+
type: string;
|
|
638
|
+
name: string;
|
|
639
|
+
organizationId?: string | null;
|
|
640
|
+
limit?: number;
|
|
641
|
+
}): Promise<{
|
|
642
|
+
events: Array<{
|
|
643
|
+
id: unknown;
|
|
644
|
+
occurredAt: string;
|
|
645
|
+
actor: string;
|
|
646
|
+
source: string | null;
|
|
647
|
+
operation: 'save' | 'publish' | 'rollback' | 'delete' | 'reset';
|
|
648
|
+
outcome: 'allowed' | 'denied' | 'forced';
|
|
649
|
+
code: string;
|
|
650
|
+
lockState: MetadataLock | null;
|
|
651
|
+
lockOverridden: boolean;
|
|
652
|
+
requestId: string | null;
|
|
653
|
+
note: string | null;
|
|
654
|
+
}>;
|
|
586
655
|
}>;
|
|
587
656
|
getUiView(request: {
|
|
588
657
|
object: string;
|
|
@@ -799,7 +868,7 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
799
868
|
*/
|
|
800
869
|
private static readonly OVERLAY_ALLOWED_TYPES;
|
|
801
870
|
/**
|
|
802
|
-
* Phase 3a-env-writable: parse `
|
|
871
|
+
* Phase 3a-env-writable: parse `OS_METADATA_WRITABLE` once.
|
|
803
872
|
* Comma-separated singular type names. When the env var is set, the
|
|
804
873
|
* listed types get treated as `allowOrgOverride: true` regardless of
|
|
805
874
|
* their static registry entry. This is the runtime escape hatch admins
|
|
@@ -851,6 +920,43 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
851
920
|
* "authoring a DB-only item" (requires only `allowRuntimeCreate`).
|
|
852
921
|
*/
|
|
853
922
|
private isArtifactBacked;
|
|
923
|
+
/**
|
|
924
|
+
* Look up an item from the artifact registry across both the requested
|
|
925
|
+
* type and its singular/plural twin. Returns `undefined` when the
|
|
926
|
+
* registry is unavailable or the item is not artifact-backed.
|
|
927
|
+
*/
|
|
928
|
+
private lookupArtifactItem;
|
|
929
|
+
/**
|
|
930
|
+
* Resolve the effective `_lock` for an item by consulting the
|
|
931
|
+
* artifact registry first, then the persisted overlay row. Artifact
|
|
932
|
+
* always wins — by design, an overlay cannot loosen a packaged
|
|
933
|
+
* lock (ADR-0010 §3.3).
|
|
934
|
+
*
|
|
935
|
+
* Returns `'none'` when nothing is locked, which is the common
|
|
936
|
+
* case. Safe to call when `environmentId` is undefined (control-
|
|
937
|
+
* plane bootstrap) — the lock check is only meaningful in tenant
|
|
938
|
+
* scope and the caller is expected to also gate on `environmentId`.
|
|
939
|
+
*/
|
|
940
|
+
private getEffectiveLock;
|
|
941
|
+
/**
|
|
942
|
+
* Best-effort audit-row writer (ADR-0010 §3.6). Failures here are
|
|
943
|
+
* logged but never block the underlying decision: an environment
|
|
944
|
+
* without the audit table provisioned (legacy installs before this
|
|
945
|
+
* ADR landed) still answers normal API calls, just without the
|
|
946
|
+
* compliance trail. Phase 2 will make the audit table a hard
|
|
947
|
+
* dependency.
|
|
948
|
+
*/
|
|
949
|
+
private recordMetadataAudit;
|
|
950
|
+
/**
|
|
951
|
+
* Phase 1 L3 enforcement for write operations (save / publish /
|
|
952
|
+
* rollback). Returns null on allow. Returns the structured `Error`
|
|
953
|
+
* the caller should `throw` on deny — also records the denial in
|
|
954
|
+
* the audit log so refused attempts are visible in compliance
|
|
955
|
+
* reports (refused writes never reach sys_metadata_history).
|
|
956
|
+
*/
|
|
957
|
+
private assertLockAllowsWrite;
|
|
958
|
+
/** Counterpart of {@link assertLockAllowsWrite} for delete. */
|
|
959
|
+
private assertLockAllowsDelete;
|
|
854
960
|
/**
|
|
855
961
|
* Mirror an object-type overlay write into the in-memory engine
|
|
856
962
|
* registry so subsequent CRUD finds the new schema. Idempotent and
|
|
@@ -1243,7 +1349,7 @@ declare class SysMetadataRepository implements MetadataRepository {
|
|
|
1243
1349
|
* at `(type, name)`. In that case we accept types with
|
|
1244
1350
|
* `allowRuntimeCreate: true`, even when `allowOrgOverride` is false.
|
|
1245
1351
|
*
|
|
1246
|
-
* The env-var escape hatch (`
|
|
1352
|
+
* The env-var escape hatch (`OS_METADATA_WRITABLE`) still
|
|
1247
1353
|
* applies to BOTH intents, so operators can opt into artifact
|
|
1248
1354
|
* overrides at runtime for emergency fixes.
|
|
1249
1355
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServiceObject, ObjectOwnership, HookContext, QueryAST, EngineQueryOptions, DataEngineInsertOptions, EngineUpdateOptions, EngineDeleteOptions, EngineCountOptions, EngineAggregateOptions, DateGranularityValue, Hook } from '@objectstack/spec/data';
|
|
2
|
-
import { ObjectStackManifest, InstalledPackage, MetadataValidationResult, ExecutionContext } from '@objectstack/spec/kernel';
|
|
2
|
+
import { ObjectStackManifest, InstalledPackage, MetadataValidationResult, MetadataLock, MetadataProvenance, ExecutionContext } from '@objectstack/spec/kernel';
|
|
3
3
|
import * as _objectstack_metadata_core from '@objectstack/metadata-core';
|
|
4
4
|
import { MetadataRepository, MetaRef, MetadataItem, PutOptions, PutResult, DeleteOptions, DeleteResult, MetadataWriteIntent, ListFilter, MetadataItemHeader, HistoryOptions, MetadataEvent, WatchFilter } from '@objectstack/metadata-core';
|
|
5
5
|
import { ObjectStackProtocol, MetadataCacheRequest, MetadataCacheResponse, BatchUpdateRequest, BatchUpdateResponse, UpdateManyDataRequest, DeleteManyDataRequest } from '@objectstack/spec/api';
|
|
@@ -528,6 +528,17 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
528
528
|
total: number;
|
|
529
529
|
scannedTypes: number;
|
|
530
530
|
scannedItems: number;
|
|
531
|
+
/**
|
|
532
|
+
* Per-type aggregate stats — count of items and the list of
|
|
533
|
+
* packages contributing to each type. Computed in the same
|
|
534
|
+
* sweep so the Studio directory page can render tile counts
|
|
535
|
+
* and a package filter in one round-trip.
|
|
536
|
+
*/
|
|
537
|
+
stats: Record<string, {
|
|
538
|
+
count: number;
|
|
539
|
+
locked: number;
|
|
540
|
+
packages: string[];
|
|
541
|
+
}>;
|
|
531
542
|
}>;
|
|
532
543
|
getMetaItems(request: {
|
|
533
544
|
type: string;
|
|
@@ -544,9 +555,23 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
544
555
|
organizationId?: string;
|
|
545
556
|
state?: 'active' | 'draft';
|
|
546
557
|
}): Promise<{
|
|
558
|
+
type: string;
|
|
559
|
+
name: string;
|
|
560
|
+
item: {} | null;
|
|
561
|
+
} | {
|
|
562
|
+
editable: boolean;
|
|
563
|
+
deletable: boolean;
|
|
564
|
+
resettable: boolean;
|
|
565
|
+
packageVersion?: string | undefined;
|
|
566
|
+
packageId?: string | undefined;
|
|
567
|
+
provenance?: "package" | "env-forced" | "org" | undefined;
|
|
568
|
+
lockDocsUrl?: string | undefined;
|
|
569
|
+
lockSource?: "artifact" | "package" | "env-forced" | undefined;
|
|
570
|
+
lockReason?: string | undefined;
|
|
547
571
|
type: string;
|
|
548
572
|
name: string;
|
|
549
573
|
item: unknown;
|
|
574
|
+
lock: "full" | "none" | "no-overlay" | "no-delete";
|
|
550
575
|
}>;
|
|
551
576
|
/**
|
|
552
577
|
* Phase 3a-layered-get: return the 3 layers of a metadata item
|
|
@@ -583,6 +608,50 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
583
608
|
* without a second round-trip.
|
|
584
609
|
*/
|
|
585
610
|
_diagnostics?: MetadataDiagnostics;
|
|
611
|
+
lock: MetadataLock;
|
|
612
|
+
lockReason?: string;
|
|
613
|
+
lockSource?: 'artifact' | 'package' | 'env-forced' | 'overlay';
|
|
614
|
+
lockDocsUrl?: string;
|
|
615
|
+
provenance?: MetadataProvenance;
|
|
616
|
+
packageId?: string;
|
|
617
|
+
packageVersion?: string;
|
|
618
|
+
editable: boolean;
|
|
619
|
+
deletable: boolean;
|
|
620
|
+
resettable: boolean;
|
|
621
|
+
}>;
|
|
622
|
+
/**
|
|
623
|
+
* ADR-0010 §3.6 / Phase 4.1 — read the metadata-protection audit log
|
|
624
|
+
* for a single item. Returns the most-recent rows of
|
|
625
|
+
* `sys_metadata_audit` for this (type, name) tuple, sorted newest
|
|
626
|
+
* first. Refused (`denied`) and forced (`forced`) writes both appear
|
|
627
|
+
* here — they never reach the `history` endpoint, which only tracks
|
|
628
|
+
* successful body snapshots.
|
|
629
|
+
*
|
|
630
|
+
* The table is provisioned by `platform-objects` and is the
|
|
631
|
+
* compliance surface for the lock-enforcement story. When the
|
|
632
|
+
* environment has not yet provisioned the table (legacy install
|
|
633
|
+
* prior to ADR-0010) the call returns `{ events: [] }` instead of
|
|
634
|
+
* raising, keeping the Studio tab harmless.
|
|
635
|
+
*/
|
|
636
|
+
auditMetaItem(request: {
|
|
637
|
+
type: string;
|
|
638
|
+
name: string;
|
|
639
|
+
organizationId?: string | null;
|
|
640
|
+
limit?: number;
|
|
641
|
+
}): Promise<{
|
|
642
|
+
events: Array<{
|
|
643
|
+
id: unknown;
|
|
644
|
+
occurredAt: string;
|
|
645
|
+
actor: string;
|
|
646
|
+
source: string | null;
|
|
647
|
+
operation: 'save' | 'publish' | 'rollback' | 'delete' | 'reset';
|
|
648
|
+
outcome: 'allowed' | 'denied' | 'forced';
|
|
649
|
+
code: string;
|
|
650
|
+
lockState: MetadataLock | null;
|
|
651
|
+
lockOverridden: boolean;
|
|
652
|
+
requestId: string | null;
|
|
653
|
+
note: string | null;
|
|
654
|
+
}>;
|
|
586
655
|
}>;
|
|
587
656
|
getUiView(request: {
|
|
588
657
|
object: string;
|
|
@@ -799,7 +868,7 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
799
868
|
*/
|
|
800
869
|
private static readonly OVERLAY_ALLOWED_TYPES;
|
|
801
870
|
/**
|
|
802
|
-
* Phase 3a-env-writable: parse `
|
|
871
|
+
* Phase 3a-env-writable: parse `OS_METADATA_WRITABLE` once.
|
|
803
872
|
* Comma-separated singular type names. When the env var is set, the
|
|
804
873
|
* listed types get treated as `allowOrgOverride: true` regardless of
|
|
805
874
|
* their static registry entry. This is the runtime escape hatch admins
|
|
@@ -851,6 +920,43 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
851
920
|
* "authoring a DB-only item" (requires only `allowRuntimeCreate`).
|
|
852
921
|
*/
|
|
853
922
|
private isArtifactBacked;
|
|
923
|
+
/**
|
|
924
|
+
* Look up an item from the artifact registry across both the requested
|
|
925
|
+
* type and its singular/plural twin. Returns `undefined` when the
|
|
926
|
+
* registry is unavailable or the item is not artifact-backed.
|
|
927
|
+
*/
|
|
928
|
+
private lookupArtifactItem;
|
|
929
|
+
/**
|
|
930
|
+
* Resolve the effective `_lock` for an item by consulting the
|
|
931
|
+
* artifact registry first, then the persisted overlay row. Artifact
|
|
932
|
+
* always wins — by design, an overlay cannot loosen a packaged
|
|
933
|
+
* lock (ADR-0010 §3.3).
|
|
934
|
+
*
|
|
935
|
+
* Returns `'none'` when nothing is locked, which is the common
|
|
936
|
+
* case. Safe to call when `environmentId` is undefined (control-
|
|
937
|
+
* plane bootstrap) — the lock check is only meaningful in tenant
|
|
938
|
+
* scope and the caller is expected to also gate on `environmentId`.
|
|
939
|
+
*/
|
|
940
|
+
private getEffectiveLock;
|
|
941
|
+
/**
|
|
942
|
+
* Best-effort audit-row writer (ADR-0010 §3.6). Failures here are
|
|
943
|
+
* logged but never block the underlying decision: an environment
|
|
944
|
+
* without the audit table provisioned (legacy installs before this
|
|
945
|
+
* ADR landed) still answers normal API calls, just without the
|
|
946
|
+
* compliance trail. Phase 2 will make the audit table a hard
|
|
947
|
+
* dependency.
|
|
948
|
+
*/
|
|
949
|
+
private recordMetadataAudit;
|
|
950
|
+
/**
|
|
951
|
+
* Phase 1 L3 enforcement for write operations (save / publish /
|
|
952
|
+
* rollback). Returns null on allow. Returns the structured `Error`
|
|
953
|
+
* the caller should `throw` on deny — also records the denial in
|
|
954
|
+
* the audit log so refused attempts are visible in compliance
|
|
955
|
+
* reports (refused writes never reach sys_metadata_history).
|
|
956
|
+
*/
|
|
957
|
+
private assertLockAllowsWrite;
|
|
958
|
+
/** Counterpart of {@link assertLockAllowsWrite} for delete. */
|
|
959
|
+
private assertLockAllowsDelete;
|
|
854
960
|
/**
|
|
855
961
|
* Mirror an object-type overlay write into the in-memory engine
|
|
856
962
|
* registry so subsequent CRUD finds the new schema. Idempotent and
|
|
@@ -1243,7 +1349,7 @@ declare class SysMetadataRepository implements MetadataRepository {
|
|
|
1243
1349
|
* at `(type, name)`. In that case we accept types with
|
|
1244
1350
|
* `allowRuntimeCreate: true`, even when `allowOrgOverride` is false.
|
|
1245
1351
|
*
|
|
1246
|
-
* The env-var escape hatch (`
|
|
1352
|
+
* The env-var escape hatch (`OS_METADATA_WRITABLE`) still
|
|
1247
1353
|
* applies to BOTH intents, so operators can opt into artifact
|
|
1248
1354
|
* overrides at runtime for emergency fixes.
|
|
1249
1355
|
*/
|