@objectstack/objectql 5.1.0 → 6.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/dist/index.d.mts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1191,7 +1191,7 @@ var SERVICE_CONFIG = {
|
|
|
1191
1191
|
search: { route: "/api/v1/search", plugin: "plugin-search" }
|
|
1192
1192
|
};
|
|
1193
1193
|
var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementation {
|
|
1194
|
-
constructor(engine, getServicesRegistry, getFeedService,
|
|
1194
|
+
constructor(engine, getServicesRegistry, getFeedService, environmentId) {
|
|
1195
1195
|
/**
|
|
1196
1196
|
* Lazily-instantiated SysMetadataRepository per organization. Keyed by
|
|
1197
1197
|
* `${organizationId ?? '__env__'}`. Repositories are stateful — they
|
|
@@ -1202,7 +1202,7 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
1202
1202
|
/**
|
|
1203
1203
|
* One-time guard for ensuring the overlay-uniqueness UNIQUE INDEX exists
|
|
1204
1204
|
* on `sys_metadata`. ADR-0005: scopes overlays by
|
|
1205
|
-
* `(type, name, organization_id,
|
|
1205
|
+
* `(type, name, organization_id, environment_id, scope)` for active rows only.
|
|
1206
1206
|
* Idempotent SQL — safe to attempt on every protocol instance.
|
|
1207
1207
|
*
|
|
1208
1208
|
* Inlined here (rather than importing from @objectstack/metadata/migrations)
|
|
@@ -1212,7 +1212,7 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
1212
1212
|
this.engine = engine;
|
|
1213
1213
|
this.getServicesRegistry = getServicesRegistry;
|
|
1214
1214
|
this.getFeedService = getFeedService;
|
|
1215
|
-
this.
|
|
1215
|
+
this.environmentId = environmentId;
|
|
1216
1216
|
}
|
|
1217
1217
|
/**
|
|
1218
1218
|
* Lazily obtain a SysMetadataRepository for the given organization.
|
|
@@ -1280,10 +1280,10 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
1280
1280
|
* Exposes the project scope the protocol is bound to. Consumers like
|
|
1281
1281
|
* the HTTP dispatcher use this to decide whether to trust the process-
|
|
1282
1282
|
* wide SchemaRegistry or whether they must route a read through the
|
|
1283
|
-
* protocol's
|
|
1283
|
+
* protocol's environment_id-filtered lookup.
|
|
1284
1284
|
*/
|
|
1285
1285
|
getProjectId() {
|
|
1286
|
-
return this.
|
|
1286
|
+
return this.environmentId;
|
|
1287
1287
|
}
|
|
1288
1288
|
requireFeedService() {
|
|
1289
1289
|
const svc = this.getFeedService?.();
|
|
@@ -1396,7 +1396,7 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
1396
1396
|
async getMetaItems(request) {
|
|
1397
1397
|
const { packageId } = request;
|
|
1398
1398
|
let items = [];
|
|
1399
|
-
if (this.
|
|
1399
|
+
if (this.environmentId === void 0) {
|
|
1400
1400
|
items = [...this.engine.registry.listItems(request.type, packageId)];
|
|
1401
1401
|
if (items.length === 0) {
|
|
1402
1402
|
const alt = PLURAL_TO_SINGULAR[request.type] ?? SINGULAR_TO_PLURAL[request.type];
|
|
@@ -1448,7 +1448,7 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
1448
1448
|
if (data && typeof data === "object" && "name" in data) {
|
|
1449
1449
|
byName.set(data.name, data);
|
|
1450
1450
|
}
|
|
1451
|
-
if (this.
|
|
1451
|
+
if (this.environmentId === void 0) {
|
|
1452
1452
|
this.engine.registry.registerItem(request.type, data, "name");
|
|
1453
1453
|
}
|
|
1454
1454
|
}
|
|
@@ -2456,7 +2456,7 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
2456
2456
|
if (!request.item) {
|
|
2457
2457
|
throw new Error("Item data is required");
|
|
2458
2458
|
}
|
|
2459
|
-
if (this.
|
|
2459
|
+
if (this.environmentId !== void 0 && !_ObjectStackProtocolImplementation.isOverlayAllowed(request.type)) {
|
|
2460
2460
|
const allowed = Array.from(_ObjectStackProtocolImplementation.OVERLAY_ALLOWED_TYPES).join(", ");
|
|
2461
2461
|
const err = new Error(
|
|
2462
2462
|
`[not_overridable] Metadata type '${request.type}' has not opted into per-org overlay writes. Set allowOrgOverride: true on its DEFAULT_METADATA_TYPE_REGISTRY entry to enable. Currently allowed: ${allowed}. See docs/adr/0005-metadata-customization-overlay.md.`
|
|
@@ -2623,7 +2623,7 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
2623
2623
|
* with {@link saveMetaItem}.
|
|
2624
2624
|
*/
|
|
2625
2625
|
async deleteMetaItem(request) {
|
|
2626
|
-
if (this.
|
|
2626
|
+
if (this.environmentId !== void 0 && !_ObjectStackProtocolImplementation.isOverlayAllowed(request.type)) {
|
|
2627
2627
|
const err = new Error(
|
|
2628
2628
|
`[not_overridable] Metadata type '${request.type}' has not opted into per-org overlay writes. See docs/adr/0005-metadata-customization-overlay.md.`
|
|
2629
2629
|
);
|
|
@@ -2656,7 +2656,7 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
2656
2656
|
actor: request.actor ?? "system",
|
|
2657
2657
|
source: "protocol.deleteMetaItem"
|
|
2658
2658
|
});
|
|
2659
|
-
if (this.
|
|
2659
|
+
if (this.environmentId === void 0) {
|
|
2660
2660
|
try {
|
|
2661
2661
|
const services = this.getServicesRegistry?.();
|
|
2662
2662
|
const metadataService = services?.get("metadata");
|
|
@@ -2706,7 +2706,7 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
2706
2706
|
};
|
|
2707
2707
|
}
|
|
2708
2708
|
await this.engine.delete("sys_metadata", { where: { id: existing.id } });
|
|
2709
|
-
if (this.
|
|
2709
|
+
if (this.environmentId === void 0) {
|
|
2710
2710
|
try {
|
|
2711
2711
|
const services = this.getServicesRegistry?.();
|
|
2712
2712
|
const metadataService = services?.get("metadata");
|
|
@@ -2737,7 +2737,7 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
2737
2737
|
*
|
|
2738
2738
|
* Per ADR-0005, project-kernel mode ALSO hydrates from sys_metadata —
|
|
2739
2739
|
* customization overlay rows must survive restart. Scope filter
|
|
2740
|
-
* (`
|
|
2740
|
+
* (`environment_id = this.environmentId ?? null`) keeps tenants isolated.
|
|
2741
2741
|
*/
|
|
2742
2742
|
async loadMetaFromDb() {
|
|
2743
2743
|
let loaded = 0;
|
|
@@ -3709,7 +3709,7 @@ var _ObjectQL = class _ObjectQL {
|
|
|
3709
3709
|
// Per-engine SchemaRegistry instance.
|
|
3710
3710
|
//
|
|
3711
3711
|
// Historically SchemaRegistry was a process-wide singleton of static state,
|
|
3712
|
-
// which broke multi-
|
|
3712
|
+
// which broke multi-environment servers: a project kernel would inherit every
|
|
3713
3713
|
// object registered by the control plane (e.g. sys_metadata), and
|
|
3714
3714
|
// getDriver()'s owner lookup would route CRUD to the wrong database. Each
|
|
3715
3715
|
// engine now owns its registry so kernels are fully isolated.
|
|
@@ -3740,7 +3740,7 @@ var _ObjectQL = class _ObjectQL {
|
|
|
3740
3740
|
* Expose the SchemaRegistry for plugins to register metadata.
|
|
3741
3741
|
*
|
|
3742
3742
|
* Returns the per-engine instance, NOT the class. Each ObjectQL engine
|
|
3743
|
-
* owns its registry so multi-
|
|
3743
|
+
* owns its registry so multi-environment kernels remain isolated.
|
|
3744
3744
|
*/
|
|
3745
3745
|
get registry() {
|
|
3746
3746
|
return this._registry;
|
|
@@ -5526,7 +5526,7 @@ var ObjectQLPlugin = class {
|
|
|
5526
5526
|
this.ql,
|
|
5527
5527
|
() => ctx.getServices ? ctx.getServices() : /* @__PURE__ */ new Map(),
|
|
5528
5528
|
void 0,
|
|
5529
|
-
this.
|
|
5529
|
+
this.environmentId
|
|
5530
5530
|
);
|
|
5531
5531
|
ctx.registerService("protocol", protocolShim);
|
|
5532
5532
|
ctx.logger.info("Protocol service registered");
|
|
@@ -5588,7 +5588,7 @@ var ObjectQLPlugin = class {
|
|
|
5588
5588
|
} else {
|
|
5589
5589
|
await this.syncRegisteredSchemas(ctx);
|
|
5590
5590
|
}
|
|
5591
|
-
if (this.
|
|
5591
|
+
if (this.environmentId === void 0) {
|
|
5592
5592
|
await this.restoreMetadataFromDb(ctx);
|
|
5593
5593
|
} else {
|
|
5594
5594
|
ctx.logger.info("Project kernel \u2014 skipping sys_metadata hydration (metadata sourced from artifact)");
|
|
@@ -5596,7 +5596,7 @@ var ObjectQLPlugin = class {
|
|
|
5596
5596
|
if (!this.skipSchemaSync) {
|
|
5597
5597
|
await this.syncRegisteredSchemas(ctx);
|
|
5598
5598
|
}
|
|
5599
|
-
if (this.
|
|
5599
|
+
if (this.environmentId === void 0) {
|
|
5600
5600
|
await this.bridgeObjectsToMetadataService(ctx);
|
|
5601
5601
|
}
|
|
5602
5602
|
this.registerAuditHooks(ctx);
|
|
@@ -5625,7 +5625,7 @@ var ObjectQLPlugin = class {
|
|
|
5625
5625
|
this.ql = opts.ql;
|
|
5626
5626
|
}
|
|
5627
5627
|
this.hostContext = opts.hostContext ?? hostContext;
|
|
5628
|
-
this.
|
|
5628
|
+
this.environmentId = opts.environmentId;
|
|
5629
5629
|
if (typeof opts.startupTimeout === "number" && opts.startupTimeout > 0) {
|
|
5630
5630
|
this.startupTimeout = opts.startupTimeout;
|
|
5631
5631
|
}
|