@quereus/quereus 0.4.0 → 0.4.6
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/src/core/database.d.ts +1 -2
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +2 -3
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/parser/ast.d.ts +0 -1
- package/dist/src/parser/ast.d.ts.map +1 -1
- package/dist/src/parser/lexer.d.ts +0 -1
- package/dist/src/parser/lexer.d.ts.map +1 -1
- package/dist/src/parser/lexer.js +0 -2
- package/dist/src/parser/lexer.js.map +1 -1
- package/dist/src/parser/parser.d.ts.map +1 -1
- package/dist/src/parser/parser.js +2 -14
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/planner/building/transaction.js +4 -4
- package/dist/src/planner/building/transaction.js.map +1 -1
- package/dist/src/planner/nodes/transaction-node.d.ts +1 -3
- package/dist/src/planner/nodes/transaction-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/transaction-node.js +2 -7
- package/dist/src/planner/nodes/transaction-node.js.map +1 -1
- package/dist/src/runtime/emit/transaction.js +1 -1
- package/dist/src/runtime/emit/transaction.js.map +1 -1
- package/dist/src/util/ast-stringify.d.ts.map +1 -1
- package/dist/src/util/ast-stringify.js +1 -6
- package/dist/src/util/ast-stringify.js.map +1 -1
- package/dist/src/util/plugin-loader.d.ts +0 -2
- package/dist/src/util/plugin-loader.d.ts.map +1 -1
- package/dist/src/util/plugin-loader.js +44 -3
- package/dist/src/util/plugin-loader.js.map +1 -1
- package/package.json +1 -1
- package/src/core/database.ts +2 -3
- package/src/parser/ast.ts +0 -1
- package/src/parser/lexer.ts +0 -2
- package/src/parser/parser.ts +2 -13
- package/src/planner/building/transaction.ts +4 -4
- package/src/planner/nodes/transaction-node.ts +1 -7
- package/src/runtime/emit/transaction.ts +1 -1
- package/src/util/ast-stringify.ts +1 -6
- package/src/util/plugin-loader.ts +50 -9
|
@@ -10,13 +10,29 @@ const log = createLogger('util:plugin-loader');
|
|
|
10
10
|
* Plugin module interface - what we expect from a plugin module
|
|
11
11
|
*/
|
|
12
12
|
export interface PluginModule {
|
|
13
|
-
/** Plugin manifest with metadata */
|
|
14
|
-
manifest?: PluginManifest;
|
|
15
|
-
|
|
16
13
|
/** Default export - the plugin registration function */
|
|
17
14
|
default: (db: Database, config: Record<string, SqlValue>) => Promise<PluginRegistrations> | PluginRegistrations;
|
|
18
15
|
}
|
|
19
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Extracts plugin manifest from package.json metadata
|
|
19
|
+
* Looks for metadata in package.json root fields and quereus.provides/settings
|
|
20
|
+
*/
|
|
21
|
+
function extractManifestFromPackageJson(pkg: any): PluginManifest {
|
|
22
|
+
const quereus = pkg.quereus || {};
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
name: pkg.name || 'Unknown Plugin',
|
|
26
|
+
version: pkg.version || '0.0.0',
|
|
27
|
+
author: pkg.author,
|
|
28
|
+
description: pkg.description,
|
|
29
|
+
pragmaPrefix: quereus.pragmaPrefix,
|
|
30
|
+
settings: quereus.settings,
|
|
31
|
+
provides: quereus.provides,
|
|
32
|
+
capabilities: quereus.capabilities
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
20
36
|
/**
|
|
21
37
|
* Dynamically loads and registers a plugin module
|
|
22
38
|
*
|
|
@@ -53,7 +69,7 @@ export async function dynamicLoadModule(
|
|
|
53
69
|
|
|
54
70
|
log('Successfully loaded plugin from %s', url);
|
|
55
71
|
if (registrations.vtables?.length) {
|
|
56
|
-
log(' Registered %d vtable module(s): %s', registrations.vtables.length,
|
|
72
|
+
log(' Registered %d vtable module(s): %s', registrations.vtables.length,
|
|
57
73
|
registrations.vtables.map(v => v.name).join(', '));
|
|
58
74
|
}
|
|
59
75
|
if (registrations.functions?.length) {
|
|
@@ -65,8 +81,21 @@ export async function dynamicLoadModule(
|
|
|
65
81
|
registrations.collations.map(c => c.name).join(', '));
|
|
66
82
|
}
|
|
67
83
|
|
|
68
|
-
//
|
|
69
|
-
|
|
84
|
+
// Try to extract manifest from package.json
|
|
85
|
+
let manifest: PluginManifest | undefined;
|
|
86
|
+
try {
|
|
87
|
+
const packageJsonUrl = new URL('package.json', moduleUrl);
|
|
88
|
+
const packageJsonResponse = await fetch(packageJsonUrl.toString());
|
|
89
|
+
if (packageJsonResponse.ok) {
|
|
90
|
+
const pkg = await packageJsonResponse.json();
|
|
91
|
+
manifest = extractManifestFromPackageJson(pkg);
|
|
92
|
+
}
|
|
93
|
+
} catch {
|
|
94
|
+
// package.json not found or not accessible - that's okay
|
|
95
|
+
log('Could not load package.json for plugin at %s', url);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return manifest;
|
|
70
99
|
} catch (error) {
|
|
71
100
|
const message = error instanceof Error ? error.message : String(error);
|
|
72
101
|
quereusError(`Failed to load plugin from ${url}: ${message}`);
|
|
@@ -75,7 +104,7 @@ export async function dynamicLoadModule(
|
|
|
75
104
|
|
|
76
105
|
/**
|
|
77
106
|
* Registers all items provided by a plugin
|
|
78
|
-
*
|
|
107
|
+
*
|
|
79
108
|
* @param db Database instance to register with
|
|
80
109
|
* @param registrations The items to register
|
|
81
110
|
*/
|
|
@@ -215,7 +244,7 @@ export async function loadPlugin(
|
|
|
215
244
|
await registerPluginItems(db, registrations);
|
|
216
245
|
log('Successfully loaded plugin from package %s', npm.name);
|
|
217
246
|
if (registrations.vtables?.length) {
|
|
218
|
-
log(' Registered %d vtable module(s): %s', registrations.vtables.length,
|
|
247
|
+
log(' Registered %d vtable module(s): %s', registrations.vtables.length,
|
|
219
248
|
registrations.vtables.map(v => v.name).join(', '));
|
|
220
249
|
}
|
|
221
250
|
if (registrations.functions?.length) {
|
|
@@ -226,7 +255,19 @@ export async function loadPlugin(
|
|
|
226
255
|
log(' Registered %d collation(s): %s', registrations.collations.length,
|
|
227
256
|
registrations.collations.map(c => c.name).join(', '));
|
|
228
257
|
}
|
|
229
|
-
|
|
258
|
+
|
|
259
|
+
// Try to extract manifest from package.json
|
|
260
|
+
let manifest: PluginManifest | undefined;
|
|
261
|
+
try {
|
|
262
|
+
// Try to import package.json directly
|
|
263
|
+
const pkg = await import(`${npm.name}/package.json`, { assert: { type: 'json' } });
|
|
264
|
+
manifest = extractManifestFromPackageJson(pkg.default);
|
|
265
|
+
} catch {
|
|
266
|
+
// package.json not found - that's okay
|
|
267
|
+
log('Could not load package.json for plugin %s', npm.name);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return manifest;
|
|
230
271
|
}
|
|
231
272
|
|
|
232
273
|
// Browser path: npm spec requires CDN; only if explicitly allowed
|