@objectstack/objectql 7.7.0 → 7.9.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/dist/index.d.mts +207 -3
- package/dist/index.d.ts +207 -3
- package/dist/index.js +378 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +378 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { ServiceObject, ObjectOwnership, HookContext, QueryAST, EngineQueryOptio
|
|
|
2
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
|
-
import { ObjectStackProtocol, MetadataCacheRequest, MetadataCacheResponse, BatchUpdateRequest, BatchUpdateResponse, UpdateManyDataRequest, DeleteManyDataRequest } from '@objectstack/spec/api';
|
|
5
|
+
import { ObjectStackProtocol, MetadataCacheRequest, MetadataCacheResponse, BatchUpdateRequest, BatchUpdateResponse, UpdateManyDataRequest, DeleteManyDataRequest, InstallPackageRequest, InstallPackageResponse } from '@objectstack/spec/api';
|
|
6
6
|
import { IDataEngine, DriverInterface, Logger, Plugin, PluginContext, ObjectKernel } from '@objectstack/core';
|
|
7
7
|
import { IFeedService, IRealtimeService, ICryptoProvider } from '@objectstack/spec/contracts';
|
|
8
8
|
|
|
@@ -719,6 +719,7 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
719
719
|
type: string;
|
|
720
720
|
packageId?: string;
|
|
721
721
|
organizationId?: string;
|
|
722
|
+
previewDrafts?: boolean;
|
|
722
723
|
}): Promise<{
|
|
723
724
|
type: string;
|
|
724
725
|
items: any[];
|
|
@@ -729,10 +730,11 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
729
730
|
packageId?: string;
|
|
730
731
|
organizationId?: string;
|
|
731
732
|
state?: 'active' | 'draft';
|
|
733
|
+
previewDrafts?: boolean;
|
|
732
734
|
}): Promise<{
|
|
733
735
|
type: string;
|
|
734
736
|
name: string;
|
|
735
|
-
item:
|
|
737
|
+
item: any;
|
|
736
738
|
} | {
|
|
737
739
|
editable: boolean;
|
|
738
740
|
deletable: boolean;
|
|
@@ -860,7 +862,7 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
860
862
|
label: string | undefined;
|
|
861
863
|
required: boolean;
|
|
862
864
|
readonly: boolean;
|
|
863
|
-
type: "number" | "boolean" | "tags" | "date" | "record" | "file" | "code" | "datetime" | "signature" | "progress" | "url" | "currency" | "percent" | "password" | "secret" | "email" | "time" | "text" | "textarea" | "phone" | "markdown" | "html" | "richtext" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "
|
|
865
|
+
type: "number" | "boolean" | "tags" | "date" | "record" | "file" | "code" | "datetime" | "signature" | "progress" | "url" | "lookup" | "master_detail" | "currency" | "percent" | "password" | "secret" | "email" | "time" | "text" | "textarea" | "phone" | "markdown" | "html" | "richtext" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "tree" | "image" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "composite" | "repeater" | "location" | "address" | "json" | "color" | "rating" | "slider" | "qrcode" | "vector";
|
|
864
866
|
colSpan: number;
|
|
865
867
|
}[];
|
|
866
868
|
}[];
|
|
@@ -1144,6 +1146,34 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
1144
1146
|
* stale schema into the registry.
|
|
1145
1147
|
*/
|
|
1146
1148
|
private applyObjectRegistryMutation;
|
|
1149
|
+
/**
|
|
1150
|
+
* Ensure a just-PUBLISHED object's physical table exists so it is usable
|
|
1151
|
+
* for data CRUD immediately — without a server restart. Registering the
|
|
1152
|
+
* object (above) only updates the in-memory registry; the table is created
|
|
1153
|
+
* by the driver's schema sync, which otherwise only runs at boot. Without
|
|
1154
|
+
* this, inserting into a freshly-published object fails with "no such
|
|
1155
|
+
* table" (surfaced as `object_not_found`) until the next restart.
|
|
1156
|
+
* Best-effort + non-fatal: drivers without DDL (or read-only datasources)
|
|
1157
|
+
* simply no-op, and a sync failure must not abort the publish.
|
|
1158
|
+
*/
|
|
1159
|
+
private ensureObjectStorage;
|
|
1160
|
+
/**
|
|
1161
|
+
* Inverse of {@link ensureObjectStorage}: drop an object's physical table.
|
|
1162
|
+
* DESTRUCTIVE — deletes the table and all its rows. Only invoked when a
|
|
1163
|
+
* delete explicitly opts into storage teardown (see {@link deleteMetaItem}'s
|
|
1164
|
+
* `dropStorage`), so publishing an object solely to preview it can be undone
|
|
1165
|
+
* without leaving an orphan table. Best-effort: a failure is logged, not
|
|
1166
|
+
* thrown — the metadata delete already succeeded, and a stray table is
|
|
1167
|
+
* reclaimed by the next sync/drop rather than blocking the delete.
|
|
1168
|
+
*/
|
|
1169
|
+
private dropObjectStorage;
|
|
1170
|
+
/**
|
|
1171
|
+
* Guard for storage teardown on delete. Drops a physical table only when
|
|
1172
|
+
* the caller opted in AND it is safe: object types only (others have no
|
|
1173
|
+
* table), active state only (drafts were never materialised), and never a
|
|
1174
|
+
* `sys_`-prefixed platform table.
|
|
1175
|
+
*/
|
|
1176
|
+
private shouldDropStorage;
|
|
1147
1177
|
saveMetaItem(request: {
|
|
1148
1178
|
type: string;
|
|
1149
1179
|
name: string;
|
|
@@ -1203,6 +1233,118 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
1203
1233
|
seq: number;
|
|
1204
1234
|
message?: string;
|
|
1205
1235
|
}>;
|
|
1236
|
+
/**
|
|
1237
|
+
* List pending DRAFT metadata (ADR-0033) for the org, optionally narrowed
|
|
1238
|
+
* by `packageId` and/or `type`. The list reads of `getMetaItems` only see
|
|
1239
|
+
* the ACTIVE registry; this exposes what an AI authored but a human hasn't
|
|
1240
|
+
* published yet, so the console can show a "pending changes" surface and a
|
|
1241
|
+
* just-built app package isn't displayed as empty. No body is returned.
|
|
1242
|
+
*/
|
|
1243
|
+
listDrafts(request?: {
|
|
1244
|
+
packageId?: string;
|
|
1245
|
+
type?: string;
|
|
1246
|
+
organizationId?: string;
|
|
1247
|
+
}): Promise<{
|
|
1248
|
+
drafts: Array<{
|
|
1249
|
+
type: string;
|
|
1250
|
+
name: string;
|
|
1251
|
+
packageId: string | null;
|
|
1252
|
+
updatedAt: string | null;
|
|
1253
|
+
updatedBy: string | null;
|
|
1254
|
+
}>;
|
|
1255
|
+
}>;
|
|
1256
|
+
/**
|
|
1257
|
+
* Publish every pending DRAFT bound to a package in one shot (ADR-0033) —
|
|
1258
|
+
* the "publish whole app" action. Promotes each draft→active by reusing the
|
|
1259
|
+
* per-item {@link publishMetaItem} primitive (which runs the overridable /
|
|
1260
|
+
* lock guards and refreshes the runtime registry), so this needs NO
|
|
1261
|
+
* `metadata` service (unlike `MetadataService.publishPackage`, which reads
|
|
1262
|
+
* the in-memory registry and 503s when that service is absent). Per-item
|
|
1263
|
+
* failures are collected and do NOT abort the rest.
|
|
1264
|
+
*/
|
|
1265
|
+
publishPackageDrafts(request: {
|
|
1266
|
+
packageId: string;
|
|
1267
|
+
organizationId?: string;
|
|
1268
|
+
actor?: string;
|
|
1269
|
+
}): Promise<{
|
|
1270
|
+
success: boolean;
|
|
1271
|
+
publishedCount: number;
|
|
1272
|
+
failedCount: number;
|
|
1273
|
+
published: Array<{
|
|
1274
|
+
type: string;
|
|
1275
|
+
name: string;
|
|
1276
|
+
version: string;
|
|
1277
|
+
}>;
|
|
1278
|
+
failed: Array<{
|
|
1279
|
+
type: string;
|
|
1280
|
+
name: string;
|
|
1281
|
+
error: string;
|
|
1282
|
+
code?: string;
|
|
1283
|
+
}>;
|
|
1284
|
+
}>;
|
|
1285
|
+
/**
|
|
1286
|
+
* Discard every pending DRAFT bound to a package — the NON-destructive
|
|
1287
|
+
* inverse of {@link publishPackageDrafts}. Drops only `state='draft'` rows
|
|
1288
|
+
* (via the per-item delete primitive), reverting the package to its last
|
|
1289
|
+
* published baseline; active/published metadata and physical tables are
|
|
1290
|
+
* left untouched.
|
|
1291
|
+
*
|
|
1292
|
+
* Use case: "I edited this app for a while and it turned out worse than
|
|
1293
|
+
* before — abandon all my changes." Routes through the sys_metadata path
|
|
1294
|
+
* (no metadata-service dependency, unlike `POST /packages/:id/revert`).
|
|
1295
|
+
*/
|
|
1296
|
+
discardPackageDrafts(request: {
|
|
1297
|
+
packageId: string;
|
|
1298
|
+
organizationId?: string;
|
|
1299
|
+
actor?: string;
|
|
1300
|
+
}): Promise<{
|
|
1301
|
+
success: boolean;
|
|
1302
|
+
discardedCount: number;
|
|
1303
|
+
failedCount: number;
|
|
1304
|
+
discarded: Array<{
|
|
1305
|
+
type: string;
|
|
1306
|
+
name: string;
|
|
1307
|
+
}>;
|
|
1308
|
+
failed: Array<{
|
|
1309
|
+
type: string;
|
|
1310
|
+
name: string;
|
|
1311
|
+
error: string;
|
|
1312
|
+
code?: string;
|
|
1313
|
+
}>;
|
|
1314
|
+
}>;
|
|
1315
|
+
/**
|
|
1316
|
+
* Delete an ENTIRE package: every `sys_metadata` row bound to it (active
|
|
1317
|
+
* AND draft) and — by default — the physical table of each object it
|
|
1318
|
+
* defined. DESTRUCTIVE: removes the app and its data. Use case: "I don't
|
|
1319
|
+
* want this package anymore."
|
|
1320
|
+
*
|
|
1321
|
+
* Set `keepData: true` to remove the metadata but preserve object tables.
|
|
1322
|
+
* The `sys_`-table guard in {@link deleteMetaItem} still applies, so
|
|
1323
|
+
* platform storage is never dropped. Drafts are removed before active rows
|
|
1324
|
+
* so each object's table is torn down once. Per-item failures are collected
|
|
1325
|
+
* without aborting the rest.
|
|
1326
|
+
*/
|
|
1327
|
+
deletePackage(request: {
|
|
1328
|
+
packageId: string;
|
|
1329
|
+
organizationId?: string;
|
|
1330
|
+
actor?: string;
|
|
1331
|
+
keepData?: boolean;
|
|
1332
|
+
}): Promise<{
|
|
1333
|
+
success: boolean;
|
|
1334
|
+
deletedCount: number;
|
|
1335
|
+
failedCount: number;
|
|
1336
|
+
deleted: Array<{
|
|
1337
|
+
type: string;
|
|
1338
|
+
name: string;
|
|
1339
|
+
state: string;
|
|
1340
|
+
}>;
|
|
1341
|
+
failed: Array<{
|
|
1342
|
+
type: string;
|
|
1343
|
+
name: string;
|
|
1344
|
+
error: string;
|
|
1345
|
+
code?: string;
|
|
1346
|
+
}>;
|
|
1347
|
+
}>;
|
|
1206
1348
|
/**
|
|
1207
1349
|
* Restore the body recorded at history `toVersion` as the new
|
|
1208
1350
|
* live row. Writes a history event with `op='revert'`. 404
|
|
@@ -1271,6 +1413,13 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
1271
1413
|
parentVersion?: string | null;
|
|
1272
1414
|
actor?: string;
|
|
1273
1415
|
state?: 'active' | 'draft';
|
|
1416
|
+
/**
|
|
1417
|
+
* When true, also drop the object's physical table after the metadata
|
|
1418
|
+
* is removed (object + active only; never `sys_`). Default false keeps
|
|
1419
|
+
* delete non-destructive to data. Used by the "discard a previewed
|
|
1420
|
+
* object" flow so a publish-to-preview leaves no orphan table.
|
|
1421
|
+
*/
|
|
1422
|
+
dropStorage?: boolean;
|
|
1274
1423
|
}): Promise<{
|
|
1275
1424
|
success: boolean;
|
|
1276
1425
|
message?: string;
|
|
@@ -1328,6 +1477,24 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
1328
1477
|
getChangelog(request: any): Promise<any>;
|
|
1329
1478
|
feedSubscribe(request: any): Promise<any>;
|
|
1330
1479
|
feedUnsubscribe(request: any): Promise<any>;
|
|
1480
|
+
/**
|
|
1481
|
+
* Install a package from a manifest — the single canonical write primitive
|
|
1482
|
+
* for the package subsystem (ADR-0033 consolidation).
|
|
1483
|
+
*
|
|
1484
|
+
* It writes BOTH stores that the runtime keeps for packages, so a package
|
|
1485
|
+
* surfaces consistently no matter which read path is used:
|
|
1486
|
+
* 1. the in-memory `SchemaRegistry` (what the dispatcher's
|
|
1487
|
+
* `/api/v1/packages` list/detail and `getMetaItems({type:'package'})`
|
|
1488
|
+
* read — i.e. what Studio's package selector shows), and
|
|
1489
|
+
* 2. the durable `sys_packages` table via the optional `package` service
|
|
1490
|
+
* (so the package survives a restart; that service re-hydrates these
|
|
1491
|
+
* rows back into the registry on boot).
|
|
1492
|
+
*
|
|
1493
|
+
* The DB write is best-effort and non-fatal: when the `package` service is
|
|
1494
|
+
* absent (e.g. the `marketplace` capability is off) the package is still
|
|
1495
|
+
* registered in-memory and visible for the lifetime of the process.
|
|
1496
|
+
*/
|
|
1497
|
+
installPackage(request: InstallPackageRequest): Promise<InstallPackageResponse>;
|
|
1331
1498
|
}
|
|
1332
1499
|
|
|
1333
1500
|
/**
|
|
@@ -1498,6 +1665,23 @@ declare class SysMetadataRepository implements MetadataRepository {
|
|
|
1498
1665
|
item: MetadataItem;
|
|
1499
1666
|
}>;
|
|
1500
1667
|
list(filter: ListFilter): AsyncIterable<MetadataItemHeader>;
|
|
1668
|
+
/**
|
|
1669
|
+
* List pending DRAFT rows (ADR-0033) for this org, optionally narrowed by
|
|
1670
|
+
* `type` and/or `packageId`. Unlike {@link list} (which is hard-scoped to
|
|
1671
|
+
* `state='active'`), this reads `state='draft'` so the console can surface
|
|
1672
|
+
* what an AI authored but a human hasn't published yet. Returns a light
|
|
1673
|
+
* header projection (no body) suitable for a "pending changes" list.
|
|
1674
|
+
*/
|
|
1675
|
+
listDrafts(filter?: {
|
|
1676
|
+
type?: string;
|
|
1677
|
+
packageId?: string;
|
|
1678
|
+
}): Promise<Array<{
|
|
1679
|
+
type: string;
|
|
1680
|
+
name: string;
|
|
1681
|
+
packageId: string | null;
|
|
1682
|
+
updatedAt: string | null;
|
|
1683
|
+
updatedBy: string | null;
|
|
1684
|
+
}>>;
|
|
1501
1685
|
/**
|
|
1502
1686
|
* Yield every history event for `(org, type?, name?)` from the
|
|
1503
1687
|
* durable log, ordered by per-(type,name) `version` ascending. When
|
|
@@ -2058,6 +2242,26 @@ declare class ObjectQL implements IDataEngine {
|
|
|
2058
2242
|
* before inserting seed data.
|
|
2059
2243
|
*/
|
|
2060
2244
|
syncSchemas(): Promise<void>;
|
|
2245
|
+
/**
|
|
2246
|
+
* Sync a SINGLE object's physical storage (create/alter its table) on
|
|
2247
|
+
* demand. Boot-time {@link syncSchemas} runs once at startup, so an object
|
|
2248
|
+
* that becomes live at runtime (e.g. publishing a drafted object) has a
|
|
2249
|
+
* registry entry but no table — data CRUD then fails with "no such table"
|
|
2250
|
+
* until the next restart. Calling this right after the object is registered
|
|
2251
|
+
* makes it immediately usable. Idempotent: the SQL driver only creates the
|
|
2252
|
+
* table when absent (and alters to add new columns).
|
|
2253
|
+
*/
|
|
2254
|
+
syncObjectSchema(objectName: string): Promise<void>;
|
|
2255
|
+
/**
|
|
2256
|
+
* Drop the physical storage (table/collection) backing an object — the
|
|
2257
|
+
* inverse of {@link syncObjectSchema}. DESTRUCTIVE: deletes all rows in the
|
|
2258
|
+
* table. Used by the protocol delete path when the caller explicitly opts
|
|
2259
|
+
* into storage teardown (e.g. discarding an object that was published only
|
|
2260
|
+
* to preview it). No-op when the object's driver does not expose `dropTable`.
|
|
2261
|
+
* Resolves the physical table name from the registered definition, falling
|
|
2262
|
+
* back to the bare name if the def was already removed.
|
|
2263
|
+
*/
|
|
2264
|
+
dropObjectSchema(objectName: string): Promise<void>;
|
|
2061
2265
|
/**
|
|
2062
2266
|
* Get a registered driver by datasource name.
|
|
2063
2267
|
* Alias matching @objectql/core datasource() API.
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ServiceObject, ObjectOwnership, HookContext, QueryAST, EngineQueryOptio
|
|
|
2
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
|
-
import { ObjectStackProtocol, MetadataCacheRequest, MetadataCacheResponse, BatchUpdateRequest, BatchUpdateResponse, UpdateManyDataRequest, DeleteManyDataRequest } from '@objectstack/spec/api';
|
|
5
|
+
import { ObjectStackProtocol, MetadataCacheRequest, MetadataCacheResponse, BatchUpdateRequest, BatchUpdateResponse, UpdateManyDataRequest, DeleteManyDataRequest, InstallPackageRequest, InstallPackageResponse } from '@objectstack/spec/api';
|
|
6
6
|
import { IDataEngine, DriverInterface, Logger, Plugin, PluginContext, ObjectKernel } from '@objectstack/core';
|
|
7
7
|
import { IFeedService, IRealtimeService, ICryptoProvider } from '@objectstack/spec/contracts';
|
|
8
8
|
|
|
@@ -719,6 +719,7 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
719
719
|
type: string;
|
|
720
720
|
packageId?: string;
|
|
721
721
|
organizationId?: string;
|
|
722
|
+
previewDrafts?: boolean;
|
|
722
723
|
}): Promise<{
|
|
723
724
|
type: string;
|
|
724
725
|
items: any[];
|
|
@@ -729,10 +730,11 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
729
730
|
packageId?: string;
|
|
730
731
|
organizationId?: string;
|
|
731
732
|
state?: 'active' | 'draft';
|
|
733
|
+
previewDrafts?: boolean;
|
|
732
734
|
}): Promise<{
|
|
733
735
|
type: string;
|
|
734
736
|
name: string;
|
|
735
|
-
item:
|
|
737
|
+
item: any;
|
|
736
738
|
} | {
|
|
737
739
|
editable: boolean;
|
|
738
740
|
deletable: boolean;
|
|
@@ -860,7 +862,7 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
860
862
|
label: string | undefined;
|
|
861
863
|
required: boolean;
|
|
862
864
|
readonly: boolean;
|
|
863
|
-
type: "number" | "boolean" | "tags" | "date" | "record" | "file" | "code" | "datetime" | "signature" | "progress" | "url" | "currency" | "percent" | "password" | "secret" | "email" | "time" | "text" | "textarea" | "phone" | "markdown" | "html" | "richtext" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "
|
|
865
|
+
type: "number" | "boolean" | "tags" | "date" | "record" | "file" | "code" | "datetime" | "signature" | "progress" | "url" | "lookup" | "master_detail" | "currency" | "percent" | "password" | "secret" | "email" | "time" | "text" | "textarea" | "phone" | "markdown" | "html" | "richtext" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "tree" | "image" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "composite" | "repeater" | "location" | "address" | "json" | "color" | "rating" | "slider" | "qrcode" | "vector";
|
|
864
866
|
colSpan: number;
|
|
865
867
|
}[];
|
|
866
868
|
}[];
|
|
@@ -1144,6 +1146,34 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
1144
1146
|
* stale schema into the registry.
|
|
1145
1147
|
*/
|
|
1146
1148
|
private applyObjectRegistryMutation;
|
|
1149
|
+
/**
|
|
1150
|
+
* Ensure a just-PUBLISHED object's physical table exists so it is usable
|
|
1151
|
+
* for data CRUD immediately — without a server restart. Registering the
|
|
1152
|
+
* object (above) only updates the in-memory registry; the table is created
|
|
1153
|
+
* by the driver's schema sync, which otherwise only runs at boot. Without
|
|
1154
|
+
* this, inserting into a freshly-published object fails with "no such
|
|
1155
|
+
* table" (surfaced as `object_not_found`) until the next restart.
|
|
1156
|
+
* Best-effort + non-fatal: drivers without DDL (or read-only datasources)
|
|
1157
|
+
* simply no-op, and a sync failure must not abort the publish.
|
|
1158
|
+
*/
|
|
1159
|
+
private ensureObjectStorage;
|
|
1160
|
+
/**
|
|
1161
|
+
* Inverse of {@link ensureObjectStorage}: drop an object's physical table.
|
|
1162
|
+
* DESTRUCTIVE — deletes the table and all its rows. Only invoked when a
|
|
1163
|
+
* delete explicitly opts into storage teardown (see {@link deleteMetaItem}'s
|
|
1164
|
+
* `dropStorage`), so publishing an object solely to preview it can be undone
|
|
1165
|
+
* without leaving an orphan table. Best-effort: a failure is logged, not
|
|
1166
|
+
* thrown — the metadata delete already succeeded, and a stray table is
|
|
1167
|
+
* reclaimed by the next sync/drop rather than blocking the delete.
|
|
1168
|
+
*/
|
|
1169
|
+
private dropObjectStorage;
|
|
1170
|
+
/**
|
|
1171
|
+
* Guard for storage teardown on delete. Drops a physical table only when
|
|
1172
|
+
* the caller opted in AND it is safe: object types only (others have no
|
|
1173
|
+
* table), active state only (drafts were never materialised), and never a
|
|
1174
|
+
* `sys_`-prefixed platform table.
|
|
1175
|
+
*/
|
|
1176
|
+
private shouldDropStorage;
|
|
1147
1177
|
saveMetaItem(request: {
|
|
1148
1178
|
type: string;
|
|
1149
1179
|
name: string;
|
|
@@ -1203,6 +1233,118 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
1203
1233
|
seq: number;
|
|
1204
1234
|
message?: string;
|
|
1205
1235
|
}>;
|
|
1236
|
+
/**
|
|
1237
|
+
* List pending DRAFT metadata (ADR-0033) for the org, optionally narrowed
|
|
1238
|
+
* by `packageId` and/or `type`. The list reads of `getMetaItems` only see
|
|
1239
|
+
* the ACTIVE registry; this exposes what an AI authored but a human hasn't
|
|
1240
|
+
* published yet, so the console can show a "pending changes" surface and a
|
|
1241
|
+
* just-built app package isn't displayed as empty. No body is returned.
|
|
1242
|
+
*/
|
|
1243
|
+
listDrafts(request?: {
|
|
1244
|
+
packageId?: string;
|
|
1245
|
+
type?: string;
|
|
1246
|
+
organizationId?: string;
|
|
1247
|
+
}): Promise<{
|
|
1248
|
+
drafts: Array<{
|
|
1249
|
+
type: string;
|
|
1250
|
+
name: string;
|
|
1251
|
+
packageId: string | null;
|
|
1252
|
+
updatedAt: string | null;
|
|
1253
|
+
updatedBy: string | null;
|
|
1254
|
+
}>;
|
|
1255
|
+
}>;
|
|
1256
|
+
/**
|
|
1257
|
+
* Publish every pending DRAFT bound to a package in one shot (ADR-0033) —
|
|
1258
|
+
* the "publish whole app" action. Promotes each draft→active by reusing the
|
|
1259
|
+
* per-item {@link publishMetaItem} primitive (which runs the overridable /
|
|
1260
|
+
* lock guards and refreshes the runtime registry), so this needs NO
|
|
1261
|
+
* `metadata` service (unlike `MetadataService.publishPackage`, which reads
|
|
1262
|
+
* the in-memory registry and 503s when that service is absent). Per-item
|
|
1263
|
+
* failures are collected and do NOT abort the rest.
|
|
1264
|
+
*/
|
|
1265
|
+
publishPackageDrafts(request: {
|
|
1266
|
+
packageId: string;
|
|
1267
|
+
organizationId?: string;
|
|
1268
|
+
actor?: string;
|
|
1269
|
+
}): Promise<{
|
|
1270
|
+
success: boolean;
|
|
1271
|
+
publishedCount: number;
|
|
1272
|
+
failedCount: number;
|
|
1273
|
+
published: Array<{
|
|
1274
|
+
type: string;
|
|
1275
|
+
name: string;
|
|
1276
|
+
version: string;
|
|
1277
|
+
}>;
|
|
1278
|
+
failed: Array<{
|
|
1279
|
+
type: string;
|
|
1280
|
+
name: string;
|
|
1281
|
+
error: string;
|
|
1282
|
+
code?: string;
|
|
1283
|
+
}>;
|
|
1284
|
+
}>;
|
|
1285
|
+
/**
|
|
1286
|
+
* Discard every pending DRAFT bound to a package — the NON-destructive
|
|
1287
|
+
* inverse of {@link publishPackageDrafts}. Drops only `state='draft'` rows
|
|
1288
|
+
* (via the per-item delete primitive), reverting the package to its last
|
|
1289
|
+
* published baseline; active/published metadata and physical tables are
|
|
1290
|
+
* left untouched.
|
|
1291
|
+
*
|
|
1292
|
+
* Use case: "I edited this app for a while and it turned out worse than
|
|
1293
|
+
* before — abandon all my changes." Routes through the sys_metadata path
|
|
1294
|
+
* (no metadata-service dependency, unlike `POST /packages/:id/revert`).
|
|
1295
|
+
*/
|
|
1296
|
+
discardPackageDrafts(request: {
|
|
1297
|
+
packageId: string;
|
|
1298
|
+
organizationId?: string;
|
|
1299
|
+
actor?: string;
|
|
1300
|
+
}): Promise<{
|
|
1301
|
+
success: boolean;
|
|
1302
|
+
discardedCount: number;
|
|
1303
|
+
failedCount: number;
|
|
1304
|
+
discarded: Array<{
|
|
1305
|
+
type: string;
|
|
1306
|
+
name: string;
|
|
1307
|
+
}>;
|
|
1308
|
+
failed: Array<{
|
|
1309
|
+
type: string;
|
|
1310
|
+
name: string;
|
|
1311
|
+
error: string;
|
|
1312
|
+
code?: string;
|
|
1313
|
+
}>;
|
|
1314
|
+
}>;
|
|
1315
|
+
/**
|
|
1316
|
+
* Delete an ENTIRE package: every `sys_metadata` row bound to it (active
|
|
1317
|
+
* AND draft) and — by default — the physical table of each object it
|
|
1318
|
+
* defined. DESTRUCTIVE: removes the app and its data. Use case: "I don't
|
|
1319
|
+
* want this package anymore."
|
|
1320
|
+
*
|
|
1321
|
+
* Set `keepData: true` to remove the metadata but preserve object tables.
|
|
1322
|
+
* The `sys_`-table guard in {@link deleteMetaItem} still applies, so
|
|
1323
|
+
* platform storage is never dropped. Drafts are removed before active rows
|
|
1324
|
+
* so each object's table is torn down once. Per-item failures are collected
|
|
1325
|
+
* without aborting the rest.
|
|
1326
|
+
*/
|
|
1327
|
+
deletePackage(request: {
|
|
1328
|
+
packageId: string;
|
|
1329
|
+
organizationId?: string;
|
|
1330
|
+
actor?: string;
|
|
1331
|
+
keepData?: boolean;
|
|
1332
|
+
}): Promise<{
|
|
1333
|
+
success: boolean;
|
|
1334
|
+
deletedCount: number;
|
|
1335
|
+
failedCount: number;
|
|
1336
|
+
deleted: Array<{
|
|
1337
|
+
type: string;
|
|
1338
|
+
name: string;
|
|
1339
|
+
state: string;
|
|
1340
|
+
}>;
|
|
1341
|
+
failed: Array<{
|
|
1342
|
+
type: string;
|
|
1343
|
+
name: string;
|
|
1344
|
+
error: string;
|
|
1345
|
+
code?: string;
|
|
1346
|
+
}>;
|
|
1347
|
+
}>;
|
|
1206
1348
|
/**
|
|
1207
1349
|
* Restore the body recorded at history `toVersion` as the new
|
|
1208
1350
|
* live row. Writes a history event with `op='revert'`. 404
|
|
@@ -1271,6 +1413,13 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
1271
1413
|
parentVersion?: string | null;
|
|
1272
1414
|
actor?: string;
|
|
1273
1415
|
state?: 'active' | 'draft';
|
|
1416
|
+
/**
|
|
1417
|
+
* When true, also drop the object's physical table after the metadata
|
|
1418
|
+
* is removed (object + active only; never `sys_`). Default false keeps
|
|
1419
|
+
* delete non-destructive to data. Used by the "discard a previewed
|
|
1420
|
+
* object" flow so a publish-to-preview leaves no orphan table.
|
|
1421
|
+
*/
|
|
1422
|
+
dropStorage?: boolean;
|
|
1274
1423
|
}): Promise<{
|
|
1275
1424
|
success: boolean;
|
|
1276
1425
|
message?: string;
|
|
@@ -1328,6 +1477,24 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
1328
1477
|
getChangelog(request: any): Promise<any>;
|
|
1329
1478
|
feedSubscribe(request: any): Promise<any>;
|
|
1330
1479
|
feedUnsubscribe(request: any): Promise<any>;
|
|
1480
|
+
/**
|
|
1481
|
+
* Install a package from a manifest — the single canonical write primitive
|
|
1482
|
+
* for the package subsystem (ADR-0033 consolidation).
|
|
1483
|
+
*
|
|
1484
|
+
* It writes BOTH stores that the runtime keeps for packages, so a package
|
|
1485
|
+
* surfaces consistently no matter which read path is used:
|
|
1486
|
+
* 1. the in-memory `SchemaRegistry` (what the dispatcher's
|
|
1487
|
+
* `/api/v1/packages` list/detail and `getMetaItems({type:'package'})`
|
|
1488
|
+
* read — i.e. what Studio's package selector shows), and
|
|
1489
|
+
* 2. the durable `sys_packages` table via the optional `package` service
|
|
1490
|
+
* (so the package survives a restart; that service re-hydrates these
|
|
1491
|
+
* rows back into the registry on boot).
|
|
1492
|
+
*
|
|
1493
|
+
* The DB write is best-effort and non-fatal: when the `package` service is
|
|
1494
|
+
* absent (e.g. the `marketplace` capability is off) the package is still
|
|
1495
|
+
* registered in-memory and visible for the lifetime of the process.
|
|
1496
|
+
*/
|
|
1497
|
+
installPackage(request: InstallPackageRequest): Promise<InstallPackageResponse>;
|
|
1331
1498
|
}
|
|
1332
1499
|
|
|
1333
1500
|
/**
|
|
@@ -1498,6 +1665,23 @@ declare class SysMetadataRepository implements MetadataRepository {
|
|
|
1498
1665
|
item: MetadataItem;
|
|
1499
1666
|
}>;
|
|
1500
1667
|
list(filter: ListFilter): AsyncIterable<MetadataItemHeader>;
|
|
1668
|
+
/**
|
|
1669
|
+
* List pending DRAFT rows (ADR-0033) for this org, optionally narrowed by
|
|
1670
|
+
* `type` and/or `packageId`. Unlike {@link list} (which is hard-scoped to
|
|
1671
|
+
* `state='active'`), this reads `state='draft'` so the console can surface
|
|
1672
|
+
* what an AI authored but a human hasn't published yet. Returns a light
|
|
1673
|
+
* header projection (no body) suitable for a "pending changes" list.
|
|
1674
|
+
*/
|
|
1675
|
+
listDrafts(filter?: {
|
|
1676
|
+
type?: string;
|
|
1677
|
+
packageId?: string;
|
|
1678
|
+
}): Promise<Array<{
|
|
1679
|
+
type: string;
|
|
1680
|
+
name: string;
|
|
1681
|
+
packageId: string | null;
|
|
1682
|
+
updatedAt: string | null;
|
|
1683
|
+
updatedBy: string | null;
|
|
1684
|
+
}>>;
|
|
1501
1685
|
/**
|
|
1502
1686
|
* Yield every history event for `(org, type?, name?)` from the
|
|
1503
1687
|
* durable log, ordered by per-(type,name) `version` ascending. When
|
|
@@ -2058,6 +2242,26 @@ declare class ObjectQL implements IDataEngine {
|
|
|
2058
2242
|
* before inserting seed data.
|
|
2059
2243
|
*/
|
|
2060
2244
|
syncSchemas(): Promise<void>;
|
|
2245
|
+
/**
|
|
2246
|
+
* Sync a SINGLE object's physical storage (create/alter its table) on
|
|
2247
|
+
* demand. Boot-time {@link syncSchemas} runs once at startup, so an object
|
|
2248
|
+
* that becomes live at runtime (e.g. publishing a drafted object) has a
|
|
2249
|
+
* registry entry but no table — data CRUD then fails with "no such table"
|
|
2250
|
+
* until the next restart. Calling this right after the object is registered
|
|
2251
|
+
* makes it immediately usable. Idempotent: the SQL driver only creates the
|
|
2252
|
+
* table when absent (and alters to add new columns).
|
|
2253
|
+
*/
|
|
2254
|
+
syncObjectSchema(objectName: string): Promise<void>;
|
|
2255
|
+
/**
|
|
2256
|
+
* Drop the physical storage (table/collection) backing an object — the
|
|
2257
|
+
* inverse of {@link syncObjectSchema}. DESTRUCTIVE: deletes all rows in the
|
|
2258
|
+
* table. Used by the protocol delete path when the caller explicitly opts
|
|
2259
|
+
* into storage teardown (e.g. discarding an object that was published only
|
|
2260
|
+
* to preview it). No-op when the object's driver does not expose `dropTable`.
|
|
2261
|
+
* Resolves the physical table name from the registered definition, falling
|
|
2262
|
+
* back to the bare name if the def was already removed.
|
|
2263
|
+
*/
|
|
2264
|
+
dropObjectSchema(objectName: string): Promise<void>;
|
|
2061
2265
|
/**
|
|
2062
2266
|
* Get a registered driver by datasource name.
|
|
2063
2267
|
* Alias matching @objectql/core datasource() API.
|