@objectstack/objectql 7.2.1 → 7.3.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 +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +68 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -128,6 +128,15 @@ var SchemaRegistry = class {
|
|
|
128
128
|
// ==========================================
|
|
129
129
|
/** Type → Name/ID → MetadataItem */
|
|
130
130
|
this.metadata = /* @__PURE__ */ new Map();
|
|
131
|
+
/**
|
|
132
|
+
* Package ids that must be installed in a DISABLED state. Seeded once at
|
|
133
|
+
* boot (from persisted state) BEFORE any package registration so that every
|
|
134
|
+
* registration path — boot artifact, marketplace rehydrate, local import —
|
|
135
|
+
* honors persisted disable state uniformly without a fragile post-boot
|
|
136
|
+
* re-application hook. See {@link setInitialDisabledPackageIds} and
|
|
137
|
+
* {@link installPackage}.
|
|
138
|
+
*/
|
|
139
|
+
this.initialDisabledPackageIds = /* @__PURE__ */ new Set();
|
|
131
140
|
if (options.multiTenant !== void 0) {
|
|
132
141
|
this.multiTenant = options.multiTenant;
|
|
133
142
|
} else {
|
|
@@ -144,6 +153,14 @@ var SchemaRegistry = class {
|
|
|
144
153
|
if (this._logLevel === "silent" || this._logLevel === "error" || this._logLevel === "warn") return;
|
|
145
154
|
console.log(msg);
|
|
146
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Seed the set of package ids that should be installed disabled. Call this
|
|
158
|
+
* before package registration begins; later `installPackage` calls for these
|
|
159
|
+
* ids land in the `disabled` state. Replaces any previously seeded set.
|
|
160
|
+
*/
|
|
161
|
+
setInitialDisabledPackageIds(ids) {
|
|
162
|
+
this.initialDisabledPackageIds = new Set(ids);
|
|
163
|
+
}
|
|
147
164
|
// ==========================================
|
|
148
165
|
// Namespace Management
|
|
149
166
|
// ==========================================
|
|
@@ -469,10 +486,23 @@ var SchemaRegistry = class {
|
|
|
469
486
|
return this.getAllObjects(packageId);
|
|
470
487
|
}
|
|
471
488
|
const items = Array.from(this.metadata.get(type)?.values() || []);
|
|
489
|
+
let result = items;
|
|
472
490
|
if (packageId) {
|
|
473
|
-
|
|
491
|
+
result = result.filter((item) => item._packageId === packageId);
|
|
474
492
|
}
|
|
475
|
-
|
|
493
|
+
if (type !== "package") {
|
|
494
|
+
result = result.filter((item) => !this.isPackageDisabled(item?._packageId));
|
|
495
|
+
}
|
|
496
|
+
return result;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Whether a package has been explicitly disabled. Unknown packages and
|
|
500
|
+
* items with no owning package are treated as enabled.
|
|
501
|
+
*/
|
|
502
|
+
isPackageDisabled(packageId) {
|
|
503
|
+
if (!packageId) return false;
|
|
504
|
+
const pkg = this.getPackage(packageId);
|
|
505
|
+
return pkg?.enabled === false || pkg?.status === "disabled";
|
|
476
506
|
}
|
|
477
507
|
/**
|
|
478
508
|
* Get all registered metadata types (Kinds)
|
|
@@ -489,12 +519,14 @@ var SchemaRegistry = class {
|
|
|
489
519
|
// ==========================================
|
|
490
520
|
installPackage(manifest, settings) {
|
|
491
521
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
522
|
+
const disabled = this.initialDisabledPackageIds.has(manifest.id);
|
|
492
523
|
const pkg = {
|
|
493
524
|
manifest,
|
|
494
|
-
status: "installed",
|
|
495
|
-
enabled:
|
|
525
|
+
status: disabled ? "disabled" : "installed",
|
|
526
|
+
enabled: !disabled,
|
|
496
527
|
installedAt: now,
|
|
497
528
|
updatedAt: now,
|
|
529
|
+
...disabled ? { statusChangedAt: now } : {},
|
|
498
530
|
settings
|
|
499
531
|
};
|
|
500
532
|
if (manifest.namespace) {
|
|
@@ -780,6 +812,12 @@ var SysMetadataRepository = class {
|
|
|
780
812
|
version,
|
|
781
813
|
updated_at: now
|
|
782
814
|
};
|
|
815
|
+
if (existing) {
|
|
816
|
+
const existingPkg = existing.package_id ?? null;
|
|
817
|
+
parentRowData.package_id = existingPkg ?? opts.packageId ?? null;
|
|
818
|
+
} else {
|
|
819
|
+
parentRowData.package_id = opts.packageId ?? null;
|
|
820
|
+
}
|
|
783
821
|
if (existing) {
|
|
784
822
|
const existingId = existing.id;
|
|
785
823
|
if (existingId === void 0) {
|
|
@@ -2138,13 +2176,13 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
2138
2176
|
state: "active",
|
|
2139
2177
|
organization_id: oid
|
|
2140
2178
|
};
|
|
2141
|
-
if (packageId) whereClause.
|
|
2179
|
+
if (packageId) whereClause.package_id = packageId;
|
|
2142
2180
|
let rs = await this.engine.find("sys_metadata", { where: whereClause });
|
|
2143
2181
|
if (!rs || rs.length === 0) {
|
|
2144
2182
|
const alt = PLURAL_TO_SINGULAR3[request.type] ?? SINGULAR_TO_PLURAL2[request.type];
|
|
2145
2183
|
if (alt) {
|
|
2146
2184
|
const altWhere = { type: alt, state: "active", organization_id: oid };
|
|
2147
|
-
if (packageId) altWhere.
|
|
2185
|
+
if (packageId) altWhere.package_id = packageId;
|
|
2148
2186
|
rs = await this.engine.find("sys_metadata", { where: altWhere });
|
|
2149
2187
|
}
|
|
2150
2188
|
}
|
|
@@ -2167,6 +2205,10 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
2167
2205
|
for (const record of records) {
|
|
2168
2206
|
const data = typeof record.metadata === "string" ? JSON.parse(record.metadata) : record.metadata;
|
|
2169
2207
|
if (data && typeof data === "object" && "name" in data) {
|
|
2208
|
+
const recPkg = record.package_id ?? void 0;
|
|
2209
|
+
if (recPkg && data._packageId === void 0) {
|
|
2210
|
+
data._packageId = recPkg;
|
|
2211
|
+
}
|
|
2170
2212
|
byName.set(data.name, data);
|
|
2171
2213
|
}
|
|
2172
2214
|
if (this.environmentId === void 0) {
|
|
@@ -2206,6 +2248,11 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
2206
2248
|
}
|
|
2207
2249
|
} catch {
|
|
2208
2250
|
}
|
|
2251
|
+
if (request.type !== "package" && request.type !== "object" && request.type !== "objects") {
|
|
2252
|
+
items = items.filter(
|
|
2253
|
+
(it) => !this.engine.registry.isPackageDisabled(it?._packageId)
|
|
2254
|
+
);
|
|
2255
|
+
}
|
|
2209
2256
|
return {
|
|
2210
2257
|
type: request.type,
|
|
2211
2258
|
items: decorateMetadataItems(
|
|
@@ -2249,6 +2296,10 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
2249
2296
|
const record = (orgId ? await findOverlay(orgId) : void 0) ?? await findOverlay(null);
|
|
2250
2297
|
if (record) {
|
|
2251
2298
|
item = typeof record.metadata === "string" ? JSON.parse(record.metadata) : record.metadata;
|
|
2299
|
+
const recPkg = record.package_id ?? void 0;
|
|
2300
|
+
if (recPkg && item && typeof item === "object" && item._packageId === void 0) {
|
|
2301
|
+
item._packageId = recPkg;
|
|
2302
|
+
}
|
|
2252
2303
|
}
|
|
2253
2304
|
} catch {
|
|
2254
2305
|
}
|
|
@@ -3695,7 +3746,8 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
3695
3746
|
actor: request.actor ?? "system",
|
|
3696
3747
|
source: "protocol.saveMetaItem",
|
|
3697
3748
|
intent,
|
|
3698
|
-
state: mode === "draft" ? "draft" : "active"
|
|
3749
|
+
state: mode === "draft" ? "draft" : "active",
|
|
3750
|
+
...request.packageId !== void 0 ? { packageId: request.packageId } : {}
|
|
3699
3751
|
});
|
|
3700
3752
|
if (mode === "publish") {
|
|
3701
3753
|
this.applyObjectRegistryMutation(request);
|
|
@@ -3746,12 +3798,16 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
3746
3798
|
where: scopedWhere
|
|
3747
3799
|
});
|
|
3748
3800
|
if (existing) {
|
|
3749
|
-
|
|
3801
|
+
const updateRow = {
|
|
3750
3802
|
metadata: JSON.stringify(request.item),
|
|
3751
3803
|
updated_at: now,
|
|
3752
3804
|
version: (existing.version || 0) + 1,
|
|
3753
3805
|
state: "active"
|
|
3754
|
-
}
|
|
3806
|
+
};
|
|
3807
|
+
const existingPkg = existing.package_id ?? null;
|
|
3808
|
+
const nextPkg = existingPkg ?? request.packageId ?? null;
|
|
3809
|
+
if (nextPkg !== null) updateRow.package_id = nextPkg;
|
|
3810
|
+
await this.engine.update("sys_metadata", updateRow, {
|
|
3755
3811
|
where: { id: existing.id }
|
|
3756
3812
|
});
|
|
3757
3813
|
} else {
|
|
@@ -3771,6 +3827,7 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
3771
3827
|
updated_at: now,
|
|
3772
3828
|
organization_id: orgId
|
|
3773
3829
|
};
|
|
3830
|
+
if (request.packageId) row.package_id = request.packageId;
|
|
3774
3831
|
await this.engine.insert("sys_metadata", row);
|
|
3775
3832
|
}
|
|
3776
3833
|
return {
|
|
@@ -5748,6 +5805,8 @@ var _ObjectQL = class _ObjectQL {
|
|
|
5748
5805
|
"policies",
|
|
5749
5806
|
// AI Protocol
|
|
5750
5807
|
"agents",
|
|
5808
|
+
"tools",
|
|
5809
|
+
"skills",
|
|
5751
5810
|
"ragPipelines",
|
|
5752
5811
|
// API Protocol
|
|
5753
5812
|
"apis",
|