@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.d.mts
CHANGED
|
@@ -138,6 +138,21 @@ declare class SchemaRegistry {
|
|
|
138
138
|
private namespaceRegistry;
|
|
139
139
|
/** Type → Name/ID → MetadataItem */
|
|
140
140
|
private metadata;
|
|
141
|
+
/**
|
|
142
|
+
* Package ids that must be installed in a DISABLED state. Seeded once at
|
|
143
|
+
* boot (from persisted state) BEFORE any package registration so that every
|
|
144
|
+
* registration path — boot artifact, marketplace rehydrate, local import —
|
|
145
|
+
* honors persisted disable state uniformly without a fragile post-boot
|
|
146
|
+
* re-application hook. See {@link setInitialDisabledPackageIds} and
|
|
147
|
+
* {@link installPackage}.
|
|
148
|
+
*/
|
|
149
|
+
private initialDisabledPackageIds;
|
|
150
|
+
/**
|
|
151
|
+
* Seed the set of package ids that should be installed disabled. Call this
|
|
152
|
+
* before package registration begins; later `installPackage` calls for these
|
|
153
|
+
* ids land in the `disabled` state. Replaces any previously seeded set.
|
|
154
|
+
*/
|
|
155
|
+
setInitialDisabledPackageIds(ids: Iterable<string>): void;
|
|
141
156
|
/**
|
|
142
157
|
* Register a namespace for a package.
|
|
143
158
|
* Multiple packages can share the same namespace (e.g. 'sys').
|
|
@@ -226,6 +241,11 @@ declare class SchemaRegistry {
|
|
|
226
241
|
* Universal List Method
|
|
227
242
|
*/
|
|
228
243
|
listItems<T>(type: string, packageId?: string): T[];
|
|
244
|
+
/**
|
|
245
|
+
* Whether a package has been explicitly disabled. Unknown packages and
|
|
246
|
+
* items with no owning package are treated as enabled.
|
|
247
|
+
*/
|
|
248
|
+
isPackageDisabled(packageId?: string): boolean;
|
|
229
249
|
/**
|
|
230
250
|
* Get all registered metadata types (Kinds)
|
|
231
251
|
*/
|
|
@@ -977,6 +997,7 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
977
997
|
actor?: string;
|
|
978
998
|
force?: boolean;
|
|
979
999
|
mode?: 'draft' | 'publish';
|
|
1000
|
+
packageId?: string | null;
|
|
980
1001
|
}): Promise<{
|
|
981
1002
|
success: boolean;
|
|
982
1003
|
version: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -138,6 +138,21 @@ declare class SchemaRegistry {
|
|
|
138
138
|
private namespaceRegistry;
|
|
139
139
|
/** Type → Name/ID → MetadataItem */
|
|
140
140
|
private metadata;
|
|
141
|
+
/**
|
|
142
|
+
* Package ids that must be installed in a DISABLED state. Seeded once at
|
|
143
|
+
* boot (from persisted state) BEFORE any package registration so that every
|
|
144
|
+
* registration path — boot artifact, marketplace rehydrate, local import —
|
|
145
|
+
* honors persisted disable state uniformly without a fragile post-boot
|
|
146
|
+
* re-application hook. See {@link setInitialDisabledPackageIds} and
|
|
147
|
+
* {@link installPackage}.
|
|
148
|
+
*/
|
|
149
|
+
private initialDisabledPackageIds;
|
|
150
|
+
/**
|
|
151
|
+
* Seed the set of package ids that should be installed disabled. Call this
|
|
152
|
+
* before package registration begins; later `installPackage` calls for these
|
|
153
|
+
* ids land in the `disabled` state. Replaces any previously seeded set.
|
|
154
|
+
*/
|
|
155
|
+
setInitialDisabledPackageIds(ids: Iterable<string>): void;
|
|
141
156
|
/**
|
|
142
157
|
* Register a namespace for a package.
|
|
143
158
|
* Multiple packages can share the same namespace (e.g. 'sys').
|
|
@@ -226,6 +241,11 @@ declare class SchemaRegistry {
|
|
|
226
241
|
* Universal List Method
|
|
227
242
|
*/
|
|
228
243
|
listItems<T>(type: string, packageId?: string): T[];
|
|
244
|
+
/**
|
|
245
|
+
* Whether a package has been explicitly disabled. Unknown packages and
|
|
246
|
+
* items with no owning package are treated as enabled.
|
|
247
|
+
*/
|
|
248
|
+
isPackageDisabled(packageId?: string): boolean;
|
|
229
249
|
/**
|
|
230
250
|
* Get all registered metadata types (Kinds)
|
|
231
251
|
*/
|
|
@@ -977,6 +997,7 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
977
997
|
actor?: string;
|
|
978
998
|
force?: boolean;
|
|
979
999
|
mode?: 'draft' | 'publish';
|
|
1000
|
+
packageId?: string | null;
|
|
980
1001
|
}): Promise<{
|
|
981
1002
|
success: boolean;
|
|
982
1003
|
version: string;
|
package/dist/index.js
CHANGED
|
@@ -178,6 +178,15 @@ var SchemaRegistry = class {
|
|
|
178
178
|
// ==========================================
|
|
179
179
|
/** Type → Name/ID → MetadataItem */
|
|
180
180
|
this.metadata = /* @__PURE__ */ new Map();
|
|
181
|
+
/**
|
|
182
|
+
* Package ids that must be installed in a DISABLED state. Seeded once at
|
|
183
|
+
* boot (from persisted state) BEFORE any package registration so that every
|
|
184
|
+
* registration path — boot artifact, marketplace rehydrate, local import —
|
|
185
|
+
* honors persisted disable state uniformly without a fragile post-boot
|
|
186
|
+
* re-application hook. See {@link setInitialDisabledPackageIds} and
|
|
187
|
+
* {@link installPackage}.
|
|
188
|
+
*/
|
|
189
|
+
this.initialDisabledPackageIds = /* @__PURE__ */ new Set();
|
|
181
190
|
if (options.multiTenant !== void 0) {
|
|
182
191
|
this.multiTenant = options.multiTenant;
|
|
183
192
|
} else {
|
|
@@ -194,6 +203,14 @@ var SchemaRegistry = class {
|
|
|
194
203
|
if (this._logLevel === "silent" || this._logLevel === "error" || this._logLevel === "warn") return;
|
|
195
204
|
console.log(msg);
|
|
196
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Seed the set of package ids that should be installed disabled. Call this
|
|
208
|
+
* before package registration begins; later `installPackage` calls for these
|
|
209
|
+
* ids land in the `disabled` state. Replaces any previously seeded set.
|
|
210
|
+
*/
|
|
211
|
+
setInitialDisabledPackageIds(ids) {
|
|
212
|
+
this.initialDisabledPackageIds = new Set(ids);
|
|
213
|
+
}
|
|
197
214
|
// ==========================================
|
|
198
215
|
// Namespace Management
|
|
199
216
|
// ==========================================
|
|
@@ -519,10 +536,23 @@ var SchemaRegistry = class {
|
|
|
519
536
|
return this.getAllObjects(packageId);
|
|
520
537
|
}
|
|
521
538
|
const items = Array.from(this.metadata.get(type)?.values() || []);
|
|
539
|
+
let result = items;
|
|
522
540
|
if (packageId) {
|
|
523
|
-
|
|
541
|
+
result = result.filter((item) => item._packageId === packageId);
|
|
524
542
|
}
|
|
525
|
-
|
|
543
|
+
if (type !== "package") {
|
|
544
|
+
result = result.filter((item) => !this.isPackageDisabled(item?._packageId));
|
|
545
|
+
}
|
|
546
|
+
return result;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Whether a package has been explicitly disabled. Unknown packages and
|
|
550
|
+
* items with no owning package are treated as enabled.
|
|
551
|
+
*/
|
|
552
|
+
isPackageDisabled(packageId) {
|
|
553
|
+
if (!packageId) return false;
|
|
554
|
+
const pkg = this.getPackage(packageId);
|
|
555
|
+
return pkg?.enabled === false || pkg?.status === "disabled";
|
|
526
556
|
}
|
|
527
557
|
/**
|
|
528
558
|
* Get all registered metadata types (Kinds)
|
|
@@ -539,12 +569,14 @@ var SchemaRegistry = class {
|
|
|
539
569
|
// ==========================================
|
|
540
570
|
installPackage(manifest, settings) {
|
|
541
571
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
572
|
+
const disabled = this.initialDisabledPackageIds.has(manifest.id);
|
|
542
573
|
const pkg = {
|
|
543
574
|
manifest,
|
|
544
|
-
status: "installed",
|
|
545
|
-
enabled:
|
|
575
|
+
status: disabled ? "disabled" : "installed",
|
|
576
|
+
enabled: !disabled,
|
|
546
577
|
installedAt: now,
|
|
547
578
|
updatedAt: now,
|
|
579
|
+
...disabled ? { statusChangedAt: now } : {},
|
|
548
580
|
settings
|
|
549
581
|
};
|
|
550
582
|
if (manifest.namespace) {
|
|
@@ -830,6 +862,12 @@ var SysMetadataRepository = class {
|
|
|
830
862
|
version,
|
|
831
863
|
updated_at: now
|
|
832
864
|
};
|
|
865
|
+
if (existing) {
|
|
866
|
+
const existingPkg = existing.package_id ?? null;
|
|
867
|
+
parentRowData.package_id = existingPkg ?? opts.packageId ?? null;
|
|
868
|
+
} else {
|
|
869
|
+
parentRowData.package_id = opts.packageId ?? null;
|
|
870
|
+
}
|
|
833
871
|
if (existing) {
|
|
834
872
|
const existingId = existing.id;
|
|
835
873
|
if (existingId === void 0) {
|
|
@@ -2183,13 +2221,13 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
2183
2221
|
state: "active",
|
|
2184
2222
|
organization_id: oid
|
|
2185
2223
|
};
|
|
2186
|
-
if (packageId) whereClause.
|
|
2224
|
+
if (packageId) whereClause.package_id = packageId;
|
|
2187
2225
|
let rs = await this.engine.find("sys_metadata", { where: whereClause });
|
|
2188
2226
|
if (!rs || rs.length === 0) {
|
|
2189
2227
|
const alt = import_shared4.PLURAL_TO_SINGULAR[request.type] ?? import_shared4.SINGULAR_TO_PLURAL[request.type];
|
|
2190
2228
|
if (alt) {
|
|
2191
2229
|
const altWhere = { type: alt, state: "active", organization_id: oid };
|
|
2192
|
-
if (packageId) altWhere.
|
|
2230
|
+
if (packageId) altWhere.package_id = packageId;
|
|
2193
2231
|
rs = await this.engine.find("sys_metadata", { where: altWhere });
|
|
2194
2232
|
}
|
|
2195
2233
|
}
|
|
@@ -2212,6 +2250,10 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
2212
2250
|
for (const record of records) {
|
|
2213
2251
|
const data = typeof record.metadata === "string" ? JSON.parse(record.metadata) : record.metadata;
|
|
2214
2252
|
if (data && typeof data === "object" && "name" in data) {
|
|
2253
|
+
const recPkg = record.package_id ?? void 0;
|
|
2254
|
+
if (recPkg && data._packageId === void 0) {
|
|
2255
|
+
data._packageId = recPkg;
|
|
2256
|
+
}
|
|
2215
2257
|
byName.set(data.name, data);
|
|
2216
2258
|
}
|
|
2217
2259
|
if (this.environmentId === void 0) {
|
|
@@ -2251,6 +2293,11 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
2251
2293
|
}
|
|
2252
2294
|
} catch {
|
|
2253
2295
|
}
|
|
2296
|
+
if (request.type !== "package" && request.type !== "object" && request.type !== "objects") {
|
|
2297
|
+
items = items.filter(
|
|
2298
|
+
(it) => !this.engine.registry.isPackageDisabled(it?._packageId)
|
|
2299
|
+
);
|
|
2300
|
+
}
|
|
2254
2301
|
return {
|
|
2255
2302
|
type: request.type,
|
|
2256
2303
|
items: decorateMetadataItems(
|
|
@@ -2294,6 +2341,10 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
2294
2341
|
const record = (orgId ? await findOverlay(orgId) : void 0) ?? await findOverlay(null);
|
|
2295
2342
|
if (record) {
|
|
2296
2343
|
item = typeof record.metadata === "string" ? JSON.parse(record.metadata) : record.metadata;
|
|
2344
|
+
const recPkg = record.package_id ?? void 0;
|
|
2345
|
+
if (recPkg && item && typeof item === "object" && item._packageId === void 0) {
|
|
2346
|
+
item._packageId = recPkg;
|
|
2347
|
+
}
|
|
2297
2348
|
}
|
|
2298
2349
|
} catch {
|
|
2299
2350
|
}
|
|
@@ -3740,7 +3791,8 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
3740
3791
|
actor: request.actor ?? "system",
|
|
3741
3792
|
source: "protocol.saveMetaItem",
|
|
3742
3793
|
intent,
|
|
3743
|
-
state: mode === "draft" ? "draft" : "active"
|
|
3794
|
+
state: mode === "draft" ? "draft" : "active",
|
|
3795
|
+
...request.packageId !== void 0 ? { packageId: request.packageId } : {}
|
|
3744
3796
|
});
|
|
3745
3797
|
if (mode === "publish") {
|
|
3746
3798
|
this.applyObjectRegistryMutation(request);
|
|
@@ -3791,12 +3843,16 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
3791
3843
|
where: scopedWhere
|
|
3792
3844
|
});
|
|
3793
3845
|
if (existing) {
|
|
3794
|
-
|
|
3846
|
+
const updateRow = {
|
|
3795
3847
|
metadata: JSON.stringify(request.item),
|
|
3796
3848
|
updated_at: now,
|
|
3797
3849
|
version: (existing.version || 0) + 1,
|
|
3798
3850
|
state: "active"
|
|
3799
|
-
}
|
|
3851
|
+
};
|
|
3852
|
+
const existingPkg = existing.package_id ?? null;
|
|
3853
|
+
const nextPkg = existingPkg ?? request.packageId ?? null;
|
|
3854
|
+
if (nextPkg !== null) updateRow.package_id = nextPkg;
|
|
3855
|
+
await this.engine.update("sys_metadata", updateRow, {
|
|
3800
3856
|
where: { id: existing.id }
|
|
3801
3857
|
});
|
|
3802
3858
|
} else {
|
|
@@ -3816,6 +3872,7 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
3816
3872
|
updated_at: now,
|
|
3817
3873
|
organization_id: orgId
|
|
3818
3874
|
};
|
|
3875
|
+
if (request.packageId) row.package_id = request.packageId;
|
|
3819
3876
|
await this.engine.insert("sys_metadata", row);
|
|
3820
3877
|
}
|
|
3821
3878
|
return {
|
|
@@ -5793,6 +5850,8 @@ var _ObjectQL = class _ObjectQL {
|
|
|
5793
5850
|
"policies",
|
|
5794
5851
|
// AI Protocol
|
|
5795
5852
|
"agents",
|
|
5853
|
+
"tools",
|
|
5854
|
+
"skills",
|
|
5796
5855
|
"ragPipelines",
|
|
5797
5856
|
// API Protocol
|
|
5798
5857
|
"apis",
|