@objectstack/core 4.0.1 → 4.0.3
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/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +13 -0
- package/dist/index.cjs +66 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/fallbacks/fallbacks.test.ts +2 -2
- package/src/fallbacks/index.ts +3 -0
- package/src/fallbacks/memory-metadata.ts +50 -0
- package/src/kernel.ts +28 -0
package/dist/index.d.cts
CHANGED
|
@@ -222,6 +222,13 @@ declare class ObjectKernel {
|
|
|
222
222
|
* Register a service factory with lifecycle management
|
|
223
223
|
*/
|
|
224
224
|
registerServiceFactory<T>(name: string, factory: ServiceFactory<T>, lifecycle?: ServiceLifecycle, dependencies?: string[]): this;
|
|
225
|
+
/**
|
|
226
|
+
* Pre-inject in-memory fallbacks for 'core' services that were not registered
|
|
227
|
+
* by plugins during Phase 1. Called before Phase 2 so that all core services
|
|
228
|
+
* (e.g. 'metadata', 'cache', 'queue') are resolvable via ctx.getService()
|
|
229
|
+
* when plugin start() methods execute.
|
|
230
|
+
*/
|
|
231
|
+
private preInjectCoreFallbacks;
|
|
225
232
|
/**
|
|
226
233
|
* Validate Critical System Requirements
|
|
227
234
|
*/
|
|
@@ -1681,6 +1688,26 @@ declare function createMemoryI18n(): {
|
|
|
1681
1688
|
setDefaultLocale(locale: string): void;
|
|
1682
1689
|
};
|
|
1683
1690
|
|
|
1691
|
+
/**
|
|
1692
|
+
* In-memory metadata service fallback.
|
|
1693
|
+
*
|
|
1694
|
+
* Implements the IMetadataService contract with a simple Map-of-Maps store.
|
|
1695
|
+
* Used by ObjectKernel as an automatic fallback when no real metadata plugin
|
|
1696
|
+
* (e.g. MetadataPlugin with file-system persistence) is registered.
|
|
1697
|
+
*/
|
|
1698
|
+
declare function createMemoryMetadata(): {
|
|
1699
|
+
_fallback: boolean;
|
|
1700
|
+
_serviceName: string;
|
|
1701
|
+
register(type: string, name: string, data: any): Promise<void>;
|
|
1702
|
+
get(type: string, name: string): Promise<any>;
|
|
1703
|
+
list(type: string): Promise<any[]>;
|
|
1704
|
+
unregister(type: string, name: string): Promise<void>;
|
|
1705
|
+
exists(type: string, name: string): Promise<boolean>;
|
|
1706
|
+
listNames(type: string): Promise<string[]>;
|
|
1707
|
+
getObject(name: string): Promise<any>;
|
|
1708
|
+
listObjects(): Promise<any[]>;
|
|
1709
|
+
};
|
|
1710
|
+
|
|
1684
1711
|
/**
|
|
1685
1712
|
* Map of core-criticality service names to their in-memory fallback factories.
|
|
1686
1713
|
* Used by ObjectKernel.validateSystemRequirements() to auto-inject fallbacks
|
|
@@ -2113,4 +2140,4 @@ declare class PackageManager {
|
|
|
2113
2140
|
getSnapshot(packageId: string): PackageSnapshot | undefined;
|
|
2114
2141
|
}
|
|
2115
2142
|
|
|
2116
|
-
export { ApiRegistry, type ApiRegistryPluginConfig, CORE_FALLBACK_FACTORIES, DependencyResolver, HotReloadManager, type InstallResult, type InstalledPackageRecord, type KernelState, LiteKernel, type NamespaceCheckResult, type NamespaceConflict, type NamespaceEntry, NamespaceResolver, ObjectKernel, ObjectKernelBase, type ObjectKernelConfig, ObjectLogger, PackageManager, type PackageSnapshot, type PermissionCheckResult$1 as PermissionCheckResult, type PermissionGrant, type Plugin, PluginConfigValidator, type PluginContext, PluginHealthMonitor, type PluginHealthStatus, type PluginLoadResult, PluginLoader, type PluginMetadata, type PermissionCheckResult as PluginPermissionCheckResult, PluginPermissionEnforcer, PluginPermissionManager, type PluginPermissions, PluginSandboxRuntime, PluginSecurityScanner, type PluginSignatureConfig, PluginSignatureVerifier, type PluginStartupResult, index as QA, type ResourceUsage, type RollbackResult, type SandboxContext, type ScanTarget, SecurePluginContext, type SecurityIssue, SemanticVersionManager, type ServiceFactory, ServiceLifecycle, type ServiceRegistration, type SignatureVerificationResult, type UpgradeResult, type VersionCompatibility, createApiRegistryPlugin, createLogger, createMemoryCache, createMemoryI18n, createMemoryJob, createMemoryQueue, createPluginConfigValidator, createPluginPermissionEnforcer, getEnv, getMemoryUsage, isNode, resolveLocale, safeExit };
|
|
2143
|
+
export { ApiRegistry, type ApiRegistryPluginConfig, CORE_FALLBACK_FACTORIES, DependencyResolver, HotReloadManager, type InstallResult, type InstalledPackageRecord, type KernelState, LiteKernel, type NamespaceCheckResult, type NamespaceConflict, type NamespaceEntry, NamespaceResolver, ObjectKernel, ObjectKernelBase, type ObjectKernelConfig, ObjectLogger, PackageManager, type PackageSnapshot, type PermissionCheckResult$1 as PermissionCheckResult, type PermissionGrant, type Plugin, PluginConfigValidator, type PluginContext, PluginHealthMonitor, type PluginHealthStatus, type PluginLoadResult, PluginLoader, type PluginMetadata, type PermissionCheckResult as PluginPermissionCheckResult, PluginPermissionEnforcer, PluginPermissionManager, type PluginPermissions, PluginSandboxRuntime, PluginSecurityScanner, type PluginSignatureConfig, PluginSignatureVerifier, type PluginStartupResult, index as QA, type ResourceUsage, type RollbackResult, type SandboxContext, type ScanTarget, SecurePluginContext, type SecurityIssue, SemanticVersionManager, type ServiceFactory, ServiceLifecycle, type ServiceRegistration, type SignatureVerificationResult, type UpgradeResult, type VersionCompatibility, createApiRegistryPlugin, createLogger, createMemoryCache, createMemoryI18n, createMemoryJob, createMemoryMetadata, createMemoryQueue, createPluginConfigValidator, createPluginPermissionEnforcer, getEnv, getMemoryUsage, isNode, resolveLocale, safeExit };
|
package/dist/index.d.ts
CHANGED
|
@@ -222,6 +222,13 @@ declare class ObjectKernel {
|
|
|
222
222
|
* Register a service factory with lifecycle management
|
|
223
223
|
*/
|
|
224
224
|
registerServiceFactory<T>(name: string, factory: ServiceFactory<T>, lifecycle?: ServiceLifecycle, dependencies?: string[]): this;
|
|
225
|
+
/**
|
|
226
|
+
* Pre-inject in-memory fallbacks for 'core' services that were not registered
|
|
227
|
+
* by plugins during Phase 1. Called before Phase 2 so that all core services
|
|
228
|
+
* (e.g. 'metadata', 'cache', 'queue') are resolvable via ctx.getService()
|
|
229
|
+
* when plugin start() methods execute.
|
|
230
|
+
*/
|
|
231
|
+
private preInjectCoreFallbacks;
|
|
225
232
|
/**
|
|
226
233
|
* Validate Critical System Requirements
|
|
227
234
|
*/
|
|
@@ -1681,6 +1688,26 @@ declare function createMemoryI18n(): {
|
|
|
1681
1688
|
setDefaultLocale(locale: string): void;
|
|
1682
1689
|
};
|
|
1683
1690
|
|
|
1691
|
+
/**
|
|
1692
|
+
* In-memory metadata service fallback.
|
|
1693
|
+
*
|
|
1694
|
+
* Implements the IMetadataService contract with a simple Map-of-Maps store.
|
|
1695
|
+
* Used by ObjectKernel as an automatic fallback when no real metadata plugin
|
|
1696
|
+
* (e.g. MetadataPlugin with file-system persistence) is registered.
|
|
1697
|
+
*/
|
|
1698
|
+
declare function createMemoryMetadata(): {
|
|
1699
|
+
_fallback: boolean;
|
|
1700
|
+
_serviceName: string;
|
|
1701
|
+
register(type: string, name: string, data: any): Promise<void>;
|
|
1702
|
+
get(type: string, name: string): Promise<any>;
|
|
1703
|
+
list(type: string): Promise<any[]>;
|
|
1704
|
+
unregister(type: string, name: string): Promise<void>;
|
|
1705
|
+
exists(type: string, name: string): Promise<boolean>;
|
|
1706
|
+
listNames(type: string): Promise<string[]>;
|
|
1707
|
+
getObject(name: string): Promise<any>;
|
|
1708
|
+
listObjects(): Promise<any[]>;
|
|
1709
|
+
};
|
|
1710
|
+
|
|
1684
1711
|
/**
|
|
1685
1712
|
* Map of core-criticality service names to their in-memory fallback factories.
|
|
1686
1713
|
* Used by ObjectKernel.validateSystemRequirements() to auto-inject fallbacks
|
|
@@ -2113,4 +2140,4 @@ declare class PackageManager {
|
|
|
2113
2140
|
getSnapshot(packageId: string): PackageSnapshot | undefined;
|
|
2114
2141
|
}
|
|
2115
2142
|
|
|
2116
|
-
export { ApiRegistry, type ApiRegistryPluginConfig, CORE_FALLBACK_FACTORIES, DependencyResolver, HotReloadManager, type InstallResult, type InstalledPackageRecord, type KernelState, LiteKernel, type NamespaceCheckResult, type NamespaceConflict, type NamespaceEntry, NamespaceResolver, ObjectKernel, ObjectKernelBase, type ObjectKernelConfig, ObjectLogger, PackageManager, type PackageSnapshot, type PermissionCheckResult$1 as PermissionCheckResult, type PermissionGrant, type Plugin, PluginConfigValidator, type PluginContext, PluginHealthMonitor, type PluginHealthStatus, type PluginLoadResult, PluginLoader, type PluginMetadata, type PermissionCheckResult as PluginPermissionCheckResult, PluginPermissionEnforcer, PluginPermissionManager, type PluginPermissions, PluginSandboxRuntime, PluginSecurityScanner, type PluginSignatureConfig, PluginSignatureVerifier, type PluginStartupResult, index as QA, type ResourceUsage, type RollbackResult, type SandboxContext, type ScanTarget, SecurePluginContext, type SecurityIssue, SemanticVersionManager, type ServiceFactory, ServiceLifecycle, type ServiceRegistration, type SignatureVerificationResult, type UpgradeResult, type VersionCompatibility, createApiRegistryPlugin, createLogger, createMemoryCache, createMemoryI18n, createMemoryJob, createMemoryQueue, createPluginConfigValidator, createPluginPermissionEnforcer, getEnv, getMemoryUsage, isNode, resolveLocale, safeExit };
|
|
2143
|
+
export { ApiRegistry, type ApiRegistryPluginConfig, CORE_FALLBACK_FACTORIES, DependencyResolver, HotReloadManager, type InstallResult, type InstalledPackageRecord, type KernelState, LiteKernel, type NamespaceCheckResult, type NamespaceConflict, type NamespaceEntry, NamespaceResolver, ObjectKernel, ObjectKernelBase, type ObjectKernelConfig, ObjectLogger, PackageManager, type PackageSnapshot, type PermissionCheckResult$1 as PermissionCheckResult, type PermissionGrant, type Plugin, PluginConfigValidator, type PluginContext, PluginHealthMonitor, type PluginHealthStatus, type PluginLoadResult, PluginLoader, type PluginMetadata, type PermissionCheckResult as PluginPermissionCheckResult, PluginPermissionEnforcer, PluginPermissionManager, type PluginPermissions, PluginSandboxRuntime, PluginSecurityScanner, type PluginSignatureConfig, PluginSignatureVerifier, type PluginStartupResult, index as QA, type ResourceUsage, type RollbackResult, type SandboxContext, type ScanTarget, SecurePluginContext, type SecurityIssue, SemanticVersionManager, type ServiceFactory, ServiceLifecycle, type ServiceRegistration, type SignatureVerificationResult, type UpgradeResult, type VersionCompatibility, createApiRegistryPlugin, createLogger, createMemoryCache, createMemoryI18n, createMemoryJob, createMemoryMetadata, createMemoryQueue, createPluginConfigValidator, createPluginPermissionEnforcer, getEnv, getMemoryUsage, isNode, resolveLocale, safeExit };
|
package/dist/index.js
CHANGED
|
@@ -1091,8 +1091,50 @@ function createMemoryI18n() {
|
|
|
1091
1091
|
};
|
|
1092
1092
|
}
|
|
1093
1093
|
|
|
1094
|
+
// src/fallbacks/memory-metadata.ts
|
|
1095
|
+
function createMemoryMetadata() {
|
|
1096
|
+
const store = /* @__PURE__ */ new Map();
|
|
1097
|
+
function getTypeMap(type) {
|
|
1098
|
+
let map = store.get(type);
|
|
1099
|
+
if (!map) {
|
|
1100
|
+
map = /* @__PURE__ */ new Map();
|
|
1101
|
+
store.set(type, map);
|
|
1102
|
+
}
|
|
1103
|
+
return map;
|
|
1104
|
+
}
|
|
1105
|
+
return {
|
|
1106
|
+
_fallback: true,
|
|
1107
|
+
_serviceName: "metadata",
|
|
1108
|
+
async register(type, name, data) {
|
|
1109
|
+
getTypeMap(type).set(name, data);
|
|
1110
|
+
},
|
|
1111
|
+
async get(type, name) {
|
|
1112
|
+
return getTypeMap(type).get(name);
|
|
1113
|
+
},
|
|
1114
|
+
async list(type) {
|
|
1115
|
+
return Array.from(getTypeMap(type).values());
|
|
1116
|
+
},
|
|
1117
|
+
async unregister(type, name) {
|
|
1118
|
+
getTypeMap(type).delete(name);
|
|
1119
|
+
},
|
|
1120
|
+
async exists(type, name) {
|
|
1121
|
+
return getTypeMap(type).has(name);
|
|
1122
|
+
},
|
|
1123
|
+
async listNames(type) {
|
|
1124
|
+
return Array.from(getTypeMap(type).keys());
|
|
1125
|
+
},
|
|
1126
|
+
async getObject(name) {
|
|
1127
|
+
return getTypeMap("object").get(name);
|
|
1128
|
+
},
|
|
1129
|
+
async listObjects() {
|
|
1130
|
+
return Array.from(getTypeMap("object").values());
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1094
1135
|
// src/fallbacks/index.ts
|
|
1095
1136
|
var CORE_FALLBACK_FACTORIES = {
|
|
1137
|
+
metadata: createMemoryMetadata,
|
|
1096
1138
|
cache: createMemoryCache,
|
|
1097
1139
|
queue: createMemoryQueue,
|
|
1098
1140
|
job: createMemoryJob,
|
|
@@ -1229,6 +1271,27 @@ var ObjectKernel = class {
|
|
|
1229
1271
|
});
|
|
1230
1272
|
return this;
|
|
1231
1273
|
}
|
|
1274
|
+
/**
|
|
1275
|
+
* Pre-inject in-memory fallbacks for 'core' services that were not registered
|
|
1276
|
+
* by plugins during Phase 1. Called before Phase 2 so that all core services
|
|
1277
|
+
* (e.g. 'metadata', 'cache', 'queue') are resolvable via ctx.getService()
|
|
1278
|
+
* when plugin start() methods execute.
|
|
1279
|
+
*/
|
|
1280
|
+
preInjectCoreFallbacks() {
|
|
1281
|
+
if (this.config.skipSystemValidation) return;
|
|
1282
|
+
for (const [serviceName, criticality] of Object.entries(ServiceRequirementDef)) {
|
|
1283
|
+
if (criticality !== "core") continue;
|
|
1284
|
+
const hasService = this.services.has(serviceName) || this.pluginLoader.hasService(serviceName);
|
|
1285
|
+
if (!hasService) {
|
|
1286
|
+
const factory = CORE_FALLBACK_FACTORIES[serviceName];
|
|
1287
|
+
if (factory) {
|
|
1288
|
+
const fallback = factory();
|
|
1289
|
+
this.registerService(serviceName, fallback);
|
|
1290
|
+
this.logger.debug(`[Kernel] Pre-injected in-memory fallback for '${serviceName}' before Phase 2`);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1232
1295
|
/**
|
|
1233
1296
|
* Validate Critical System Requirements
|
|
1234
1297
|
*/
|
|
@@ -1290,6 +1353,7 @@ var ObjectKernel = class {
|
|
|
1290
1353
|
for (const plugin of orderedPlugins) {
|
|
1291
1354
|
await this.initPluginWithTimeout(plugin);
|
|
1292
1355
|
}
|
|
1356
|
+
this.preInjectCoreFallbacks();
|
|
1293
1357
|
this.logger.info("Phase 2: Start plugins");
|
|
1294
1358
|
this.state = "running";
|
|
1295
1359
|
for (const plugin of orderedPlugins) {
|
|
@@ -4920,6 +4984,7 @@ export {
|
|
|
4920
4984
|
createMemoryCache,
|
|
4921
4985
|
createMemoryI18n,
|
|
4922
4986
|
createMemoryJob,
|
|
4987
|
+
createMemoryMetadata,
|
|
4923
4988
|
createMemoryQueue,
|
|
4924
4989
|
createPluginConfigValidator,
|
|
4925
4990
|
createPluginPermissionEnforcer,
|