@nodestackapp/server 2.5.0 → 2.7.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/README.md +42 -28
- package/dist/NodeStack.d.ts +5 -1
- package/dist/NodeStack.d.ts.map +1 -1
- package/dist/NodeStack.js +117 -18
- package/dist/NodeStack.js.map +1 -1
- package/dist/admin/AdminUIBundler.d.ts.map +1 -1
- package/dist/admin/AdminUIBundler.js +2 -0
- package/dist/admin/AdminUIBundler.js.map +1 -1
- package/dist/admin/ui/css/main.css +40 -3
- package/dist/admin/ui/css/webhooks.css +8 -0
- package/dist/admin/ui/index.html +21479 -17251
- package/dist/admin/ui/js/api-keys.js +1381 -0
- package/dist/admin/ui/js/api.js +8 -0
- package/dist/admin/ui/js/app.js +698 -641
- package/dist/admin/ui/js/apps.js +514 -489
- package/dist/admin/ui/js/collections.js +486 -484
- package/dist/admin/ui/js/command-palette.js +693 -673
- package/dist/admin/ui/js/cron.js +1706 -0
- package/dist/admin/ui/js/database.js +10 -0
- package/dist/admin/ui/js/flows-designer.js +1219 -1076
- package/dist/admin/ui/js/flows.js +947 -890
- package/dist/admin/ui/js/functions-tester.js +1 -1
- package/dist/admin/ui/js/functions-workbench.js +1162 -1101
- package/dist/admin/ui/js/functions.js +983 -979
- package/dist/admin/ui/js/rules.js +1080 -775
- package/dist/admin/ui/js/schema.js +346 -304
- package/dist/admin/ui/js/snapshots.js +338 -0
- package/dist/admin/ui/js/views.js +1 -1
- package/dist/apps/AppManager.d.ts +1 -1
- package/dist/apps/AppManager.d.ts.map +1 -1
- package/dist/apps/AppManager.js +11 -21
- package/dist/apps/AppManager.js.map +1 -1
- package/dist/apps/AppRegistry.d.ts +1 -0
- package/dist/apps/AppRegistry.d.ts.map +1 -1
- package/dist/apps/AppRegistry.js +78 -23
- package/dist/apps/AppRegistry.js.map +1 -1
- package/dist/apps/AppScope.d.ts +2 -1
- package/dist/apps/AppScope.d.ts.map +1 -1
- package/dist/apps/AppScope.js +27 -17
- package/dist/apps/AppScope.js.map +1 -1
- package/dist/auth/ApiKeyService.d.ts +63 -2
- package/dist/auth/ApiKeyService.d.ts.map +1 -1
- package/dist/auth/ApiKeyService.js +518 -8
- package/dist/auth/ApiKeyService.js.map +1 -1
- package/dist/auth/AuthService.d.ts +30 -1
- package/dist/auth/AuthService.d.ts.map +1 -1
- package/dist/auth/AuthService.js +468 -65
- package/dist/auth/AuthService.js.map +1 -1
- package/dist/auth/oauth/AppleProvider.d.ts +2 -0
- package/dist/auth/oauth/AppleProvider.d.ts.map +1 -1
- package/dist/auth/oauth/AppleProvider.js +40 -3
- package/dist/auth/oauth/AppleProvider.js.map +1 -1
- package/dist/auth/oauth/BaseOAuthProvider.d.ts +3 -2
- package/dist/auth/oauth/BaseOAuthProvider.d.ts.map +1 -1
- package/dist/auth/oauth/BaseOAuthProvider.js +29 -3
- package/dist/auth/oauth/BaseOAuthProvider.js.map +1 -1
- package/dist/auth/oauth/DiscordProvider.d.ts.map +1 -1
- package/dist/auth/oauth/DiscordProvider.js +4 -1
- package/dist/auth/oauth/DiscordProvider.js.map +1 -1
- package/dist/auth/oauth/GitHubProvider.d.ts.map +1 -1
- package/dist/auth/oauth/GitHubProvider.js +4 -1
- package/dist/auth/oauth/GitHubProvider.js.map +1 -1
- package/dist/auth/oauth/GoogleProvider.d.ts.map +1 -1
- package/dist/auth/oauth/GoogleProvider.js +4 -1
- package/dist/auth/oauth/GoogleProvider.js.map +1 -1
- package/dist/auth/oauth/MicrosoftProvider.d.ts.map +1 -1
- package/dist/auth/oauth/MicrosoftProvider.js +4 -1
- package/dist/auth/oauth/MicrosoftProvider.js.map +1 -1
- package/dist/auth/oauth/OAuthProviderRegistry.d.ts +6 -2
- package/dist/auth/oauth/OAuthProviderRegistry.d.ts.map +1 -1
- package/dist/auth/oauth/OAuthProviderRegistry.js +25 -10
- package/dist/auth/oauth/OAuthProviderRegistry.js.map +1 -1
- package/dist/auth/oauth/types.d.ts +4 -2
- package/dist/auth/oauth/types.d.ts.map +1 -1
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +228 -12
- package/dist/cli/cli.js.map +1 -1
- package/dist/core/config/ConfigService.d.ts.map +1 -1
- package/dist/core/config/ConfigService.js +5 -3
- package/dist/core/config/ConfigService.js.map +1 -1
- package/dist/core/config/EnvLoader.d.ts +14 -0
- package/dist/core/config/EnvLoader.d.ts.map +1 -1
- package/dist/core/config/EnvLoader.js +44 -0
- package/dist/core/config/EnvLoader.js.map +1 -1
- package/dist/core/container/Container.d.ts +14 -0
- package/dist/core/container/Container.d.ts.map +1 -1
- package/dist/core/container/Container.js +32 -0
- package/dist/core/container/Container.js.map +1 -1
- package/dist/core/container/Tokens.d.ts +2 -0
- package/dist/core/container/Tokens.d.ts.map +1 -1
- package/dist/core/container/Tokens.js +2 -0
- package/dist/core/container/Tokens.js.map +1 -1
- package/dist/core/errors/AppError.d.ts +7 -7
- package/dist/core/errors/AppError.d.ts.map +1 -1
- package/dist/core/errors/AppError.js +18 -14
- package/dist/core/errors/AppError.js.map +1 -1
- package/dist/core/events/EventBus.d.ts.map +1 -1
- package/dist/core/events/EventBus.js +36 -6
- package/dist/core/events/EventBus.js.map +1 -1
- package/dist/core/maintenance/MaintenanceGate.d.ts +47 -0
- package/dist/core/maintenance/MaintenanceGate.d.ts.map +1 -1
- package/dist/core/maintenance/MaintenanceGate.js +265 -7
- package/dist/core/maintenance/MaintenanceGate.js.map +1 -1
- package/dist/core/plugins/PluginManager.d.ts +20 -1
- package/dist/core/plugins/PluginManager.d.ts.map +1 -1
- package/dist/core/plugins/PluginManager.js +231 -146
- package/dist/core/plugins/PluginManager.js.map +1 -1
- package/dist/core/plugins/types.d.ts +48 -31
- package/dist/core/plugins/types.d.ts.map +1 -1
- package/dist/cron/CronParser.d.ts +83 -0
- package/dist/cron/CronParser.d.ts.map +1 -0
- package/dist/cron/CronParser.js +538 -0
- package/dist/cron/CronParser.js.map +1 -0
- package/dist/cron/CronService.d.ts +74 -0
- package/dist/cron/CronService.d.ts.map +1 -0
- package/dist/cron/CronService.js +1254 -0
- package/dist/cron/CronService.js.map +1 -0
- package/dist/cron/types.d.ts +98 -0
- package/dist/cron/types.d.ts.map +1 -0
- package/dist/cron/types.js +3 -0
- package/dist/cron/types.js.map +1 -0
- package/dist/database/DatabaseService.d.ts +4 -1
- package/dist/database/DatabaseService.d.ts.map +1 -1
- package/dist/database/DatabaseService.js +34 -9
- package/dist/database/DatabaseService.js.map +1 -1
- package/dist/database/config/DatabaseConfigService.d.ts +1 -0
- package/dist/database/config/DatabaseConfigService.d.ts.map +1 -1
- package/dist/database/config/DatabaseConfigService.js +4 -2
- package/dist/database/config/DatabaseConfigService.js.map +1 -1
- package/dist/database/drivers/DriverPackageLoader.d.ts +11 -0
- package/dist/database/drivers/DriverPackageLoader.d.ts.map +1 -0
- package/dist/database/drivers/DriverPackageLoader.js +112 -0
- package/dist/database/drivers/DriverPackageLoader.js.map +1 -0
- package/dist/database/drivers/DriverRegistry.d.ts +1 -0
- package/dist/database/drivers/DriverRegistry.d.ts.map +1 -1
- package/dist/database/drivers/DriverRegistry.js +29 -0
- package/dist/database/drivers/DriverRegistry.js.map +1 -1
- package/dist/database/drivers/IDatabaseDriver.d.ts +1 -0
- package/dist/database/drivers/IDatabaseDriver.d.ts.map +1 -1
- package/dist/database/drivers/MssqlDriver.d.ts.map +1 -1
- package/dist/database/drivers/MssqlDriver.js +10 -5
- package/dist/database/drivers/MssqlDriver.js.map +1 -1
- package/dist/database/drivers/NodeSqliteDriver.d.ts.map +1 -1
- package/dist/database/drivers/NodeSqliteDriver.js +15 -1
- package/dist/database/drivers/NodeSqliteDriver.js.map +1 -1
- package/dist/database/drivers/PostgresDriver.d.ts.map +1 -1
- package/dist/database/drivers/PostgresDriver.js +4 -5
- package/dist/database/drivers/PostgresDriver.js.map +1 -1
- package/dist/database/migration/DatabaseMigrationService.d.ts +1 -0
- package/dist/database/migration/DatabaseMigrationService.d.ts.map +1 -1
- package/dist/database/migration/DatabaseMigrationService.js +51 -0
- package/dist/database/migration/DatabaseMigrationService.js.map +1 -1
- package/dist/database/migrations/SystemMigrations.d.ts.map +1 -1
- package/dist/database/migrations/SystemMigrations.js +200 -5
- package/dist/database/migrations/SystemMigrations.js.map +1 -1
- package/dist/flows/FlowEngine.js.map +1 -1
- package/dist/flows/FlowService.d.ts +10 -1
- package/dist/flows/FlowService.d.ts.map +1 -1
- package/dist/flows/FlowService.js +227 -14
- package/dist/flows/FlowService.js.map +1 -1
- package/dist/flows/FlowValidator.d.ts +2 -1
- package/dist/flows/FlowValidator.d.ts.map +1 -1
- package/dist/flows/FlowValidator.js +89 -4
- package/dist/flows/FlowValidator.js.map +1 -1
- package/dist/flows/types.d.ts +20 -3
- package/dist/flows/types.d.ts.map +1 -1
- package/dist/functions/FunctionService.d.ts +10 -2
- package/dist/functions/FunctionService.d.ts.map +1 -1
- package/dist/functions/FunctionService.js +271 -37
- package/dist/functions/FunctionService.js.map +1 -1
- package/dist/functions/runtime/QuickJsWasmRuntime.d.ts.map +1 -1
- package/dist/functions/runtime/QuickJsWasmRuntime.js +189 -177
- package/dist/functions/runtime/QuickJsWasmRuntime.js.map +1 -1
- package/dist/functions/types.d.ts +31 -2
- package/dist/functions/types.d.ts.map +1 -1
- package/dist/http/HttpServer.d.ts +7 -1
- package/dist/http/HttpServer.d.ts.map +1 -1
- package/dist/http/HttpServer.js +187 -8
- package/dist/http/HttpServer.js.map +1 -1
- package/dist/http/controllers/ApiKeyController.d.ts +1 -0
- package/dist/http/controllers/ApiKeyController.d.ts.map +1 -1
- package/dist/http/controllers/ApiKeyController.js +47 -1
- package/dist/http/controllers/ApiKeyController.js.map +1 -1
- package/dist/http/controllers/AuthController.d.ts +12 -0
- package/dist/http/controllers/AuthController.d.ts.map +1 -1
- package/dist/http/controllers/AuthController.js +40 -2
- package/dist/http/controllers/AuthController.js.map +1 -1
- package/dist/http/controllers/CronController.d.ts +63 -0
- package/dist/http/controllers/CronController.d.ts.map +1 -0
- package/dist/http/controllers/CronController.js +92 -0
- package/dist/http/controllers/CronController.js.map +1 -0
- package/dist/http/controllers/DatabaseController.d.ts.map +1 -1
- package/dist/http/controllers/DatabaseController.js +53 -0
- package/dist/http/controllers/DatabaseController.js.map +1 -1
- package/dist/http/controllers/FlowController.d.ts.map +1 -1
- package/dist/http/controllers/FlowController.js +45 -4
- package/dist/http/controllers/FlowController.js.map +1 -1
- package/dist/http/controllers/FunctionController.d.ts.map +1 -1
- package/dist/http/controllers/FunctionController.js +16 -2
- package/dist/http/controllers/FunctionController.js.map +1 -1
- package/dist/http/controllers/HealthController.js +2 -2
- package/dist/http/middleware/AppResolutionMiddleware.d.ts +1 -1
- package/dist/http/middleware/AppResolutionMiddleware.d.ts.map +1 -1
- package/dist/http/middleware/AppResolutionMiddleware.js +2 -3
- package/dist/http/middleware/AppResolutionMiddleware.js.map +1 -1
- package/dist/http/middleware/AuthMiddleware.d.ts.map +1 -1
- package/dist/http/middleware/AuthMiddleware.js +6 -3
- package/dist/http/middleware/AuthMiddleware.js.map +1 -1
- package/dist/http/middleware/ChaosMiddleware.js +6 -6
- package/dist/http/middleware/ChaosMiddleware.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/queue/QueueService.d.ts +9 -0
- package/dist/queue/QueueService.d.ts.map +1 -1
- package/dist/queue/QueueService.js +143 -60
- package/dist/queue/QueueService.js.map +1 -1
- package/dist/queue/drivers/SqliteQueueDriver.d.ts +3 -0
- package/dist/queue/drivers/SqliteQueueDriver.d.ts.map +1 -1
- package/dist/queue/drivers/SqliteQueueDriver.js +315 -255
- package/dist/queue/drivers/SqliteQueueDriver.js.map +1 -1
- package/dist/records/FtsService.d.ts +7 -3
- package/dist/records/FtsService.d.ts.map +1 -1
- package/dist/records/FtsService.js +69 -5
- package/dist/records/FtsService.js.map +1 -1
- package/dist/records/QueryFilterParser.d.ts.map +1 -1
- package/dist/records/QueryFilterParser.js +58 -20
- package/dist/records/QueryFilterParser.js.map +1 -1
- package/dist/records/RecordSanitizer.d.ts.map +1 -1
- package/dist/records/RecordSanitizer.js +32 -4
- package/dist/records/RecordSanitizer.js.map +1 -1
- package/dist/records/RecordService.d.ts +6 -0
- package/dist/records/RecordService.d.ts.map +1 -1
- package/dist/records/RecordService.js +95 -14
- package/dist/records/RecordService.js.map +1 -1
- package/dist/records/RecordValidator.d.ts +10 -0
- package/dist/records/RecordValidator.d.ts.map +1 -1
- package/dist/records/RecordValidator.js +110 -2
- package/dist/records/RecordValidator.js.map +1 -1
- package/dist/records/fts/IFtsDriver.d.ts +7 -6
- package/dist/records/fts/IFtsDriver.d.ts.map +1 -1
- package/dist/records/fts/MssqlFtsDriver.d.ts +5 -1
- package/dist/records/fts/MssqlFtsDriver.d.ts.map +1 -1
- package/dist/records/fts/MssqlFtsDriver.js +35 -3
- package/dist/records/fts/MssqlFtsDriver.js.map +1 -1
- package/dist/records/fts/PostgresFtsDriver.d.ts +9 -2
- package/dist/records/fts/PostgresFtsDriver.d.ts.map +1 -1
- package/dist/records/fts/PostgresFtsDriver.js +116 -11
- package/dist/records/fts/PostgresFtsDriver.js.map +1 -1
- package/dist/records/fts/SqliteFts5Driver.d.ts +7 -1
- package/dist/records/fts/SqliteFts5Driver.d.ts.map +1 -1
- package/dist/records/fts/SqliteFts5Driver.js +66 -6
- package/dist/records/fts/SqliteFts5Driver.js.map +1 -1
- package/dist/schema/OpenApiGenerator.d.ts.map +1 -1
- package/dist/schema/OpenApiGenerator.js +103 -3
- package/dist/schema/OpenApiGenerator.js.map +1 -1
- package/dist/schema/models/Field.d.ts +1 -0
- package/dist/schema/models/Field.d.ts.map +1 -1
- package/dist/snapshots/SnapshotService.d.ts.map +1 -1
- package/dist/snapshots/SnapshotService.js +21 -9
- package/dist/snapshots/SnapshotService.js.map +1 -1
- package/dist/snapshots/drivers/LogicalSnapshotDriver.d.ts.map +1 -1
- package/dist/snapshots/drivers/LogicalSnapshotDriver.js +2 -0
- package/dist/snapshots/drivers/LogicalSnapshotDriver.js.map +1 -1
- package/dist/templates/definitions/ecommerce.js +6 -6
- package/dist/templates/definitions/ecommerce.js.map +1 -1
- package/dist/webhooks/WebhookService.js +1 -1
- package/package.json +5 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginManager.d.ts","sourceRoot":"","sources":["../../../src/core/plugins/PluginManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,YAAY,EAAE,cAAc,EAAsB,MAAM,SAAS,CAAC;AAE5F,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"PluginManager.d.ts","sourceRoot":"","sources":["../../../src/core/plugins/PluginManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,YAAY,EAAE,cAAc,EAAsB,MAAM,SAAS,CAAC;AAE5F,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAU,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EAItB,cAAc,EAId,kBAAkB,EAGlB,YAAY,EACb,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAQ/C,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO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ACF"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PluginManager = exports.OFFICIAL_PLUGINS = void 0;
|
|
6
|
+
exports.PluginManager = exports.ALLOWED_CORE_SERVICE_TOKENS = exports.OFFICIAL_PLUGINS = void 0;
|
|
7
7
|
const find_my_way_1 = __importDefault(require("find-my-way"));
|
|
8
8
|
const Tokens_1 = require("../container/Tokens");
|
|
9
9
|
const AppError_1 = require("../errors/AppError");
|
|
@@ -74,6 +74,13 @@ exports.OFFICIAL_PLUGINS = [
|
|
|
74
74
|
factory: () => (0, algolia_1.algoliaPlugin)(),
|
|
75
75
|
},
|
|
76
76
|
];
|
|
77
|
+
const CORE_TOKENS_SET = new Set(Object.values(Tokens_1.TOKENS));
|
|
78
|
+
exports.ALLOWED_CORE_SERVICE_TOKENS = new Set([
|
|
79
|
+
Tokens_1.TOKENS.DatabaseService,
|
|
80
|
+
Tokens_1.TOKENS.SchemaService,
|
|
81
|
+
Tokens_1.TOKENS.RecordService,
|
|
82
|
+
Tokens_1.TOKENS.ConfigService,
|
|
83
|
+
]);
|
|
77
84
|
class PluginManager {
|
|
78
85
|
app;
|
|
79
86
|
container;
|
|
@@ -128,6 +135,12 @@ class PluginManager {
|
|
|
128
135
|
}
|
|
129
136
|
});
|
|
130
137
|
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Load any auto-enabled plugins on startup. Must be invoked after core service tokens
|
|
141
|
+
* are locked in the IoC container to enforce least privilege.
|
|
142
|
+
*/
|
|
143
|
+
loadAutoEnabledPluginsOnStartup() {
|
|
131
144
|
if (this.app.db.dialect.name === 'sqlite') {
|
|
132
145
|
this.loadAutoEnabledPluginsSync();
|
|
133
146
|
}
|
|
@@ -136,52 +149,157 @@ class PluginManager {
|
|
|
136
149
|
}
|
|
137
150
|
}
|
|
138
151
|
/**
|
|
139
|
-
*
|
|
152
|
+
* Build a secure, restricted PluginContext API for plugin lifecycle execution.
|
|
153
|
+
* In accordance with the Principle of Least Privilege:
|
|
154
|
+
* - No raw DI Container access
|
|
155
|
+
* - No raw Fastify instance access (router.raw removed)
|
|
156
|
+
* - No internal core DI tokens leaked
|
|
157
|
+
* - No raw admin UI engine leaked
|
|
158
|
+
* - Safe application facade (records, db, schema, config, etc.) without host lifecycle (stop, start, maintenanceGate)
|
|
159
|
+
* - Safe EventBus without destructive clear()
|
|
160
|
+
* - Read-only getService() and custom plugin bindService() (core tokens sealed)
|
|
140
161
|
*/
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
this.registeredFunctions.add(pluginOrFn);
|
|
166
|
-
}
|
|
167
|
-
// 3. Validate dependencies
|
|
168
|
-
if (plugin.dependencies && plugin.dependencies.length > 0) {
|
|
169
|
-
for (const dep of plugin.dependencies) {
|
|
170
|
-
if (!this.plugins.has(dep)) {
|
|
171
|
-
throw new Error(`[PluginManager] Plugin "${plugin.name}" requires dependent plugin "${dep}" which has not been registered.`);
|
|
162
|
+
createPluginContext(pluginName, targetScope) {
|
|
163
|
+
const isDefaultScope = !targetScope ||
|
|
164
|
+
targetScope === this.app.defaultApp ||
|
|
165
|
+
targetScope.app.slug === 'default' ||
|
|
166
|
+
targetScope.db === this.app.db;
|
|
167
|
+
const targetDb = targetScope ? targetScope.db : this.app.db;
|
|
168
|
+
const targetSchema = targetScope ? targetScope.schema : this.app.schema;
|
|
169
|
+
const targetRecords = targetScope ? targetScope.records : this.app.records;
|
|
170
|
+
const targetConfig = targetScope ? targetScope.config : this.app.config;
|
|
171
|
+
const targetEventBus = targetScope ? targetScope.eventBus : this.app.eventBus;
|
|
172
|
+
// 1. Safe PluginManagerFacade: Exposes ONLY own effective configuration (or justified alias), NOT container, app, use, disposeScope, or arbitrary plugin secrets
|
|
173
|
+
const allowedConfigPluginNames = new Set([pluginName]);
|
|
174
|
+
if (pluginName === 'chat-notifications')
|
|
175
|
+
allowedConfigPluginNames.add('webhooks');
|
|
176
|
+
if (pluginName === 'webhooks')
|
|
177
|
+
allowedConfigPluginNames.add('chat-notifications');
|
|
178
|
+
const pluginManagerFacade = {
|
|
179
|
+
getEffectiveConfig: (name, db) => {
|
|
180
|
+
const targetName = name || pluginName;
|
|
181
|
+
if (!allowedConfigPluginNames.has(targetName)) {
|
|
182
|
+
throw new Error(`[PluginManager] Unauthorized configuration access: Plugin "${pluginName}" is not permitted to access configuration for "${targetName}".`);
|
|
183
|
+
}
|
|
184
|
+
if (!isDefaultScope && db && db !== targetDb) {
|
|
185
|
+
throw new Error(`[PluginManager] Unauthorized database access: Scoped plugins cannot query configuration outside their assigned application scope.`);
|
|
172
186
|
}
|
|
187
|
+
const effectiveDb = db || targetDb;
|
|
188
|
+
return this.getEffectiveConfig(targetName, effectiveDb);
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
// 2. Safe PluginAppFacade: Exposes ONLY domain data services, NOT container, server, stop(), or maintenanceGate
|
|
192
|
+
const appFacade = {
|
|
193
|
+
db: targetDb,
|
|
194
|
+
schema: targetSchema,
|
|
195
|
+
records: targetRecords,
|
|
196
|
+
config: targetConfig,
|
|
197
|
+
plugins: pluginManagerFacade,
|
|
198
|
+
};
|
|
199
|
+
// 2. Safe PluginEventBus: Exposes ONLY emit and on, NO destructive clear()
|
|
200
|
+
const safeEventBus = {
|
|
201
|
+
emit: (event, data) => targetEventBus.emit(event, data),
|
|
202
|
+
on: (event, handler) => targetEventBus.on(event, handler),
|
|
203
|
+
};
|
|
204
|
+
// 3. DI helpers: getService (restricted to safe capabilities and custom tokens) and bindService (custom tokens only, core tokens locked)
|
|
205
|
+
const getService = (token) => {
|
|
206
|
+
if (CORE_TOKENS_SET.has(token)) {
|
|
207
|
+
if (!exports.ALLOWED_CORE_SERVICE_TOKENS.has(token)) {
|
|
208
|
+
const tokenName = typeof token === 'symbol' ? (token.description || token.toString()) : String(token);
|
|
209
|
+
throw new Error(`[PluginManager] Access to restricted service token is not permitted: ${tokenName}`);
|
|
210
|
+
}
|
|
211
|
+
if (token === Tokens_1.TOKENS.DatabaseService)
|
|
212
|
+
return targetDb;
|
|
213
|
+
if (token === Tokens_1.TOKENS.SchemaService)
|
|
214
|
+
return targetSchema;
|
|
215
|
+
if (token === Tokens_1.TOKENS.RecordService)
|
|
216
|
+
return targetRecords;
|
|
217
|
+
if (token === Tokens_1.TOKENS.ConfigService)
|
|
218
|
+
return targetConfig;
|
|
219
|
+
}
|
|
220
|
+
return this.container.get(token);
|
|
221
|
+
};
|
|
222
|
+
const bindService = (token, instance) => {
|
|
223
|
+
if (this.container.isLocked(token)) {
|
|
224
|
+
const tokenName = typeof token === 'symbol' ? (token.description || token.toString()) : String(token);
|
|
225
|
+
throw new Error(`[PluginManager] Cannot override core service token: ${tokenName}`);
|
|
173
226
|
}
|
|
227
|
+
this.container.bindInstance(token, instance);
|
|
228
|
+
};
|
|
229
|
+
if (!isDefaultScope && targetScope) {
|
|
230
|
+
const scopedContext = {
|
|
231
|
+
app: appFacade,
|
|
232
|
+
config: targetConfig,
|
|
233
|
+
db: targetDb,
|
|
234
|
+
schema: targetSchema,
|
|
235
|
+
records: targetRecords,
|
|
236
|
+
eventBus: safeEventBus,
|
|
237
|
+
auth: {
|
|
238
|
+
requireAdmin: () => this.app.authMiddleware.requireAdmin(),
|
|
239
|
+
requireAdminOrInitial: () => this.app.authMiddleware.requireAdminOrInitialSetup(),
|
|
240
|
+
requireAuth: () => this.app.authMiddleware.requireAuth(),
|
|
241
|
+
},
|
|
242
|
+
router: {
|
|
243
|
+
get: () => { },
|
|
244
|
+
post: () => { },
|
|
245
|
+
patch: () => { },
|
|
246
|
+
delete: () => { },
|
|
247
|
+
put: () => { },
|
|
248
|
+
},
|
|
249
|
+
registerRoute: () => { },
|
|
250
|
+
registerAdminNav: () => { },
|
|
251
|
+
registerSystemCollection: (dto) => targetSchema.registerSystemCollection(dto),
|
|
252
|
+
registerHook: (event, handler, collection) => {
|
|
253
|
+
const guardedHandler = async (...args) => {
|
|
254
|
+
if (!this.isPluginEnabledInDb(pluginName, targetScope.db)) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
return handler(...args);
|
|
258
|
+
};
|
|
259
|
+
let unsubscribe;
|
|
260
|
+
switch (event) {
|
|
261
|
+
case 'beforeCreate':
|
|
262
|
+
unsubscribe = targetScope.eventBus.onRecordBeforeCreate(collection ? collection : guardedHandler, collection ? guardedHandler : undefined);
|
|
263
|
+
break;
|
|
264
|
+
case 'afterCreate':
|
|
265
|
+
unsubscribe = targetScope.eventBus.onRecordAfterCreate(collection ? collection : guardedHandler, collection ? guardedHandler : undefined);
|
|
266
|
+
break;
|
|
267
|
+
case 'beforeUpdate':
|
|
268
|
+
unsubscribe = targetScope.eventBus.onRecordBeforeUpdate(collection ? collection : guardedHandler, collection ? guardedHandler : undefined);
|
|
269
|
+
break;
|
|
270
|
+
case 'afterUpdate':
|
|
271
|
+
unsubscribe = targetScope.eventBus.onRecordAfterUpdate(collection ? collection : guardedHandler, collection ? guardedHandler : undefined);
|
|
272
|
+
break;
|
|
273
|
+
case 'beforeDelete':
|
|
274
|
+
unsubscribe = targetScope.eventBus.onRecordBeforeDelete(collection ? collection : guardedHandler, collection ? guardedHandler : undefined);
|
|
275
|
+
break;
|
|
276
|
+
case 'afterDelete':
|
|
277
|
+
unsubscribe = targetScope.eventBus.onRecordAfterDelete(collection ? collection : guardedHandler, collection ? guardedHandler : undefined);
|
|
278
|
+
break;
|
|
279
|
+
case 'beforeServe':
|
|
280
|
+
unsubscribe = targetScope.eventBus.onBeforeServe(guardedHandler);
|
|
281
|
+
break;
|
|
282
|
+
case 'afterServe':
|
|
283
|
+
unsubscribe = targetScope.eventBus.onAfterServe(guardedHandler);
|
|
284
|
+
break;
|
|
285
|
+
default:
|
|
286
|
+
unsubscribe = targetScope.eventBus.on(event, guardedHandler);
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
this.addScopedHookUnsubscriber(targetScope.app.slug, pluginName, unsubscribe);
|
|
290
|
+
},
|
|
291
|
+
getService,
|
|
292
|
+
bindService: () => { },
|
|
293
|
+
};
|
|
294
|
+
return scopedContext;
|
|
174
295
|
}
|
|
175
|
-
// 4. Build Plugin Context
|
|
176
296
|
const context = {
|
|
177
|
-
app:
|
|
178
|
-
container: this.container,
|
|
179
|
-
tokens: Tokens_1.TOKENS,
|
|
297
|
+
app: appFacade,
|
|
180
298
|
config: this.app.config,
|
|
181
299
|
db: this.app.db,
|
|
182
300
|
schema: this.app.schema,
|
|
183
|
-
|
|
184
|
-
|
|
301
|
+
records: this.app.records,
|
|
302
|
+
eventBus: safeEventBus,
|
|
185
303
|
auth: {
|
|
186
304
|
requireAdmin: () => this.app.authMiddleware.requireAdmin(),
|
|
187
305
|
requireAdminOrInitial: () => this.app.authMiddleware.requireAdminOrInitialSetup(),
|
|
@@ -193,13 +311,12 @@ class PluginManager {
|
|
|
193
311
|
patch: (path, handler, options) => context.registerRoute('PATCH', path, handler, options),
|
|
194
312
|
delete: (path, handler, options) => context.registerRoute('DELETE', path, handler, options),
|
|
195
313
|
put: (path, handler, options) => context.registerRoute('PUT', path, handler, options),
|
|
196
|
-
raw: this.app.server.app,
|
|
197
314
|
},
|
|
198
315
|
registerRoute: (method, path, handler, options = {}) => {
|
|
199
316
|
const fastify = this.app.server.app;
|
|
200
317
|
const resolvedOptions = this.resolveRouteOptions(options);
|
|
201
318
|
const routeHandler = async (req, reply) => {
|
|
202
|
-
if (!this.plugins.has(
|
|
319
|
+
if (!this.plugins.has(pluginName)) {
|
|
203
320
|
return reply.status(404).send({
|
|
204
321
|
statusCode: 404,
|
|
205
322
|
error: 'Not Found',
|
|
@@ -209,7 +326,7 @@ class PluginManager {
|
|
|
209
326
|
return handler.call(this.app.server.app, req, reply);
|
|
210
327
|
};
|
|
211
328
|
const registerBoth = (p) => {
|
|
212
|
-
this.registerDynamicRoute(method, p, routeHandler, resolvedOptions,
|
|
329
|
+
this.registerDynamicRoute(method, p, routeHandler, resolvedOptions, pluginName);
|
|
213
330
|
const isBooted = this.isFastifyBooted(fastify);
|
|
214
331
|
if (!isBooted) {
|
|
215
332
|
try {
|
|
@@ -237,9 +354,8 @@ class PluginManager {
|
|
|
237
354
|
}
|
|
238
355
|
},
|
|
239
356
|
registerHook: (event, handler, collection) => {
|
|
240
|
-
// Guard handler with the plugin's active status
|
|
241
357
|
const guardedHandler = async (...args) => {
|
|
242
|
-
if (!this.plugins.has(
|
|
358
|
+
if (!this.plugins.has(pluginName)) {
|
|
243
359
|
return;
|
|
244
360
|
}
|
|
245
361
|
return handler(...args);
|
|
@@ -274,10 +390,10 @@ class PluginManager {
|
|
|
274
390
|
unsubscribe = this.app.eventBus.on(event, guardedHandler);
|
|
275
391
|
break;
|
|
276
392
|
}
|
|
277
|
-
if (!this.pluginHookUnsubscribers.has(
|
|
278
|
-
this.pluginHookUnsubscribers.set(
|
|
393
|
+
if (!this.pluginHookUnsubscribers.has(pluginName)) {
|
|
394
|
+
this.pluginHookUnsubscribers.set(pluginName, []);
|
|
279
395
|
}
|
|
280
|
-
this.pluginHookUnsubscribers.get(
|
|
396
|
+
this.pluginHookUnsubscribers.get(pluginName).push(unsubscribe);
|
|
281
397
|
},
|
|
282
398
|
registerSystemCollection: (dto) => {
|
|
283
399
|
return this.app.schema.registerSystemCollection(dto);
|
|
@@ -285,13 +401,50 @@ class PluginManager {
|
|
|
285
401
|
registerAdminNav: (item) => {
|
|
286
402
|
this.app.adminUi.registerNavItem(item);
|
|
287
403
|
},
|
|
288
|
-
getService
|
|
289
|
-
|
|
290
|
-
},
|
|
291
|
-
bindService: (token, instance) => {
|
|
292
|
-
this.container.bindInstance(token, instance);
|
|
293
|
-
},
|
|
404
|
+
getService,
|
|
405
|
+
bindService,
|
|
294
406
|
};
|
|
407
|
+
return context;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Install/use a plugin on the NodeStack instance
|
|
411
|
+
*/
|
|
412
|
+
use(pluginOrFn, targetScope) {
|
|
413
|
+
// 1. Normalize plugin
|
|
414
|
+
let plugin;
|
|
415
|
+
if (typeof pluginOrFn === 'function') {
|
|
416
|
+
if (this.registeredFunctions.has(pluginOrFn)) {
|
|
417
|
+
throw new Error('[PluginManager] This plugin function is already registered.');
|
|
418
|
+
}
|
|
419
|
+
const fnName = pluginOrFn.name || `plugin_${this.anonymousCounter++}`;
|
|
420
|
+
plugin = {
|
|
421
|
+
name: fnName,
|
|
422
|
+
register: pluginOrFn,
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
plugin = pluginOrFn;
|
|
427
|
+
}
|
|
428
|
+
if (!plugin || typeof plugin !== 'object' || !plugin.name) {
|
|
429
|
+
throw new Error('[PluginManager] Invalid plugin provided: must have a valid name');
|
|
430
|
+
}
|
|
431
|
+
// 2. Check duplicate registration
|
|
432
|
+
if (this.plugins.has(plugin.name)) {
|
|
433
|
+
throw new Error(`[PluginManager] Plugin "${plugin.name}" is already registered. Duplicate plugin registrations are not permitted.`);
|
|
434
|
+
}
|
|
435
|
+
if (typeof pluginOrFn === 'function') {
|
|
436
|
+
this.registeredFunctions.add(pluginOrFn);
|
|
437
|
+
}
|
|
438
|
+
// 3. Validate dependencies
|
|
439
|
+
if (plugin.dependencies && plugin.dependencies.length > 0) {
|
|
440
|
+
for (const dep of plugin.dependencies) {
|
|
441
|
+
if (!this.plugins.has(dep)) {
|
|
442
|
+
throw new Error(`[PluginManager] Plugin "${plugin.name}" requires dependent plugin "${dep}" which has not been registered.`);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
// 4. Build Plugin Context
|
|
447
|
+
const context = this.createPluginContext(plugin.name);
|
|
295
448
|
// 5. Execute Declarative Registrations
|
|
296
449
|
const scopeToProvision = targetScope || this.app.defaultApp;
|
|
297
450
|
if (scopeToProvision) {
|
|
@@ -312,7 +465,20 @@ class PluginManager {
|
|
|
312
465
|
}
|
|
313
466
|
}
|
|
314
467
|
// 6. Execute Lifecycle Hooks
|
|
315
|
-
if (typeof plugin.
|
|
468
|
+
if (typeof plugin.onRegister === 'function') {
|
|
469
|
+
const regRes = plugin.onRegister(context);
|
|
470
|
+
if (regRes instanceof Promise) {
|
|
471
|
+
this.pendingInits.push(regRes.catch((err) => {
|
|
472
|
+
const record = this.plugins.get(plugin.name);
|
|
473
|
+
if (record) {
|
|
474
|
+
record.status = 'error';
|
|
475
|
+
record.error = err;
|
|
476
|
+
}
|
|
477
|
+
console.error(`[PluginManager] Error in onRegister hook for "${plugin.name}":`, err);
|
|
478
|
+
}));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (typeof plugin.register === 'function' && plugin.register !== plugin.onRegister) {
|
|
316
482
|
const regRes = plugin.register(context);
|
|
317
483
|
if (regRes instanceof Promise) {
|
|
318
484
|
this.pendingInits.push(regRes.catch((err) => {
|
|
@@ -986,104 +1152,23 @@ class PluginManager {
|
|
|
986
1152
|
}
|
|
987
1153
|
}
|
|
988
1154
|
wireScopedPluginLifecycle(plugin, scope) {
|
|
989
|
-
if (typeof plugin.register !== 'function')
|
|
1155
|
+
if (typeof plugin.register !== 'function' && typeof plugin.onRegister !== 'function')
|
|
990
1156
|
return;
|
|
991
1157
|
try {
|
|
992
1158
|
const def = exports.OFFICIAL_PLUGINS.find((p) => p.name === plugin.name || p.id === plugin.name);
|
|
993
1159
|
const scopedPlugin = def ? def.factory() : plugin;
|
|
994
|
-
const
|
|
995
|
-
get(target, prop, receiver) {
|
|
996
|
-
if (prop === 'db')
|
|
997
|
-
return scope.db;
|
|
998
|
-
if (prop === 'schema')
|
|
999
|
-
return scope.schema;
|
|
1000
|
-
if (prop === 'records')
|
|
1001
|
-
return scope.records;
|
|
1002
|
-
if (prop === 'eventBus')
|
|
1003
|
-
return scope.eventBus;
|
|
1004
|
-
if (prop === 'files')
|
|
1005
|
-
return scope.files;
|
|
1006
|
-
if (prop === 'fts')
|
|
1007
|
-
return scope.fts;
|
|
1008
|
-
if (prop === 'analytics')
|
|
1009
|
-
return scope.analytics;
|
|
1010
|
-
if (prop === 'auditLogs')
|
|
1011
|
-
return scope.auditLogs;
|
|
1012
|
-
if (prop === 'webhooks')
|
|
1013
|
-
return scope.webhooks;
|
|
1014
|
-
return Reflect.get(target, prop, receiver);
|
|
1015
|
-
},
|
|
1016
|
-
});
|
|
1017
|
-
const scopedContext = {
|
|
1018
|
-
app: scopedApp,
|
|
1019
|
-
container: this.container,
|
|
1020
|
-
tokens: Tokens_1.TOKENS,
|
|
1021
|
-
config: scope.config,
|
|
1022
|
-
db: scope.db,
|
|
1023
|
-
schema: scope.schema,
|
|
1024
|
-
eventBus: scope.eventBus,
|
|
1025
|
-
adminUi: this.app.adminUi,
|
|
1026
|
-
auth: {
|
|
1027
|
-
requireAdmin: () => this.app.authMiddleware.requireAdmin(),
|
|
1028
|
-
requireAdminOrInitial: () => this.app.authMiddleware.requireAdminOrInitialSetup(),
|
|
1029
|
-
requireAuth: () => this.app.authMiddleware.requireAuth(),
|
|
1030
|
-
},
|
|
1031
|
-
router: {
|
|
1032
|
-
get: () => { },
|
|
1033
|
-
post: () => { },
|
|
1034
|
-
patch: () => { },
|
|
1035
|
-
delete: () => { },
|
|
1036
|
-
put: () => { },
|
|
1037
|
-
raw: this.app.server?.app,
|
|
1038
|
-
},
|
|
1039
|
-
registerRoute: () => { },
|
|
1040
|
-
registerAdminNav: () => { },
|
|
1041
|
-
registerSystemCollection: (dto) => scope.schema.registerSystemCollection(dto),
|
|
1042
|
-
registerHook: (event, handler, collection) => {
|
|
1043
|
-
const guardedHandler = async (...args) => {
|
|
1044
|
-
if (!this.isPluginEnabledInDb(scopedPlugin.name, scope.db)) {
|
|
1045
|
-
return;
|
|
1046
|
-
}
|
|
1047
|
-
return handler(...args);
|
|
1048
|
-
};
|
|
1049
|
-
let unsubscribe;
|
|
1050
|
-
switch (event) {
|
|
1051
|
-
case 'beforeCreate':
|
|
1052
|
-
unsubscribe = scope.eventBus.onRecordBeforeCreate(collection ? collection : guardedHandler, collection ? guardedHandler : undefined);
|
|
1053
|
-
break;
|
|
1054
|
-
case 'afterCreate':
|
|
1055
|
-
unsubscribe = scope.eventBus.onRecordAfterCreate(collection ? collection : guardedHandler, collection ? guardedHandler : undefined);
|
|
1056
|
-
break;
|
|
1057
|
-
case 'beforeUpdate':
|
|
1058
|
-
unsubscribe = scope.eventBus.onRecordBeforeUpdate(collection ? collection : guardedHandler, collection ? guardedHandler : undefined);
|
|
1059
|
-
break;
|
|
1060
|
-
case 'afterUpdate':
|
|
1061
|
-
unsubscribe = scope.eventBus.onRecordAfterUpdate(collection ? collection : guardedHandler, collection ? guardedHandler : undefined);
|
|
1062
|
-
break;
|
|
1063
|
-
case 'beforeDelete':
|
|
1064
|
-
unsubscribe = scope.eventBus.onRecordBeforeDelete(collection ? collection : guardedHandler, collection ? guardedHandler : undefined);
|
|
1065
|
-
break;
|
|
1066
|
-
case 'afterDelete':
|
|
1067
|
-
unsubscribe = scope.eventBus.onRecordAfterDelete(collection ? collection : guardedHandler, collection ? guardedHandler : undefined);
|
|
1068
|
-
break;
|
|
1069
|
-
case 'beforeServe':
|
|
1070
|
-
unsubscribe = scope.eventBus.onBeforeServe(guardedHandler);
|
|
1071
|
-
break;
|
|
1072
|
-
case 'afterServe':
|
|
1073
|
-
unsubscribe = scope.eventBus.onAfterServe(guardedHandler);
|
|
1074
|
-
break;
|
|
1075
|
-
default:
|
|
1076
|
-
unsubscribe = scope.eventBus.on(event, guardedHandler);
|
|
1077
|
-
break;
|
|
1078
|
-
}
|
|
1079
|
-
this.addScopedHookUnsubscriber(scope.app.slug, scopedPlugin.name, unsubscribe);
|
|
1080
|
-
},
|
|
1081
|
-
getService: (token) => this.container.get(token),
|
|
1082
|
-
bindService: () => { },
|
|
1083
|
-
};
|
|
1160
|
+
const scopedContext = this.createPluginContext(scopedPlugin.name, scope);
|
|
1084
1161
|
const key = this.getScopedHookKey(scope.app.slug, scopedPlugin.name);
|
|
1085
1162
|
this.scopedPlugins.set(key, { plugin: scopedPlugin, context: scopedContext });
|
|
1086
|
-
if (typeof scopedPlugin.
|
|
1163
|
+
if (typeof scopedPlugin.onRegister === 'function') {
|
|
1164
|
+
const regRes = scopedPlugin.onRegister(scopedContext);
|
|
1165
|
+
if (regRes instanceof Promise) {
|
|
1166
|
+
this.pendingInits.push(regRes.catch((err) => {
|
|
1167
|
+
console.error(`[PluginManager] Scoped onRegister error for "${scopedPlugin.name}" in app "${scope.app.slug}":`, err);
|
|
1168
|
+
}));
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
if (typeof scopedPlugin.register === 'function' && scopedPlugin.register !== scopedPlugin.onRegister) {
|
|
1087
1172
|
const regRes = scopedPlugin.register(scopedContext);
|
|
1088
1173
|
if (regRes instanceof Promise) {
|
|
1089
1174
|
this.pendingInits.push(regRes.catch((err) => {
|