@oktis-works/plugin-runtime 0.6.1 → 0.7.1
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/bootstrap.d.ts +90 -22
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +301 -52
- package/dist/bootstrap.js.map +1 -1
- package/dist/content-query.d.ts +29 -0
- package/dist/content-query.d.ts.map +1 -0
- package/dist/content-query.js +109 -0
- package/dist/content-query.js.map +1 -0
- package/dist/hook-registry.d.ts +21 -21
- package/dist/hook-registry.d.ts.map +1 -1
- package/dist/hook-registry.js +26 -26
- package/dist/hook-registry.js.map +1 -1
- package/dist/http.d.ts +50 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +314 -0
- package/dist/http.js.map +1 -0
- package/dist/i18n.d.ts +16 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +73 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +8 -0
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +98 -10
- package/dist/loader.js.map +1 -1
- package/dist/manifest.d.ts +11 -6
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +290 -17
- package/dist/manifest.js.map +1 -1
- package/dist/plugin-api.d.ts +194 -40
- package/dist/plugin-api.d.ts.map +1 -1
- package/dist/plugin-api.js +655 -13
- package/dist/plugin-api.js.map +1 -1
- package/dist/plugin-migrations.d.ts +15 -0
- package/dist/plugin-migrations.d.ts.map +1 -0
- package/dist/plugin-migrations.js +68 -0
- package/dist/plugin-migrations.js.map +1 -0
- package/dist/sandbox.d.ts +13 -11
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +11 -9
- package/dist/sandbox.js.map +1 -1
- package/dist/style-isolation.d.ts +3 -3
- package/dist/style-isolation.js +6 -6
- package/dist/style-isolation.js.map +1 -1
- package/package.json +6 -5
package/dist/bootstrap.d.ts
CHANGED
|
@@ -1,42 +1,43 @@
|
|
|
1
|
+
import { type PluginJobHandler, type AdminExtensionsState, type PluginBlockManifest, type PluginPatternManifest, type EnqueuedAsset, type PluginHealthCheck } from '@oktis-works/plugin-sdk';
|
|
1
2
|
import { type HookRegistry } from './hook-registry.js';
|
|
2
|
-
import type { PluginApiDependencies, RouteDefinition } from './plugin-api.js';
|
|
3
|
+
import type { PluginApiDependencies, PluginAPI, RouteDefinition } from './plugin-api.js';
|
|
3
4
|
export interface BootstrapPluginsSql {
|
|
4
5
|
unsafe(text: string, params?: unknown[]): Promise<unknown>;
|
|
5
6
|
}
|
|
6
7
|
export interface BootstrapPluginsOptions {
|
|
7
|
-
/**
|
|
8
|
+
/** Plugins directory (the caller resolves it — plugin-runtime doesn't know the core). */
|
|
8
9
|
pluginsDir: string;
|
|
9
|
-
/**
|
|
10
|
+
/** Postgres client to read enabled plugins; omitted = unknown state (no-op). */
|
|
10
11
|
sql?: BootstrapPluginsSql;
|
|
11
|
-
/**
|
|
12
|
+
/** Target registry (default: the scope registry — platform or `tenantId`). */
|
|
12
13
|
registry?: HookRegistry;
|
|
13
|
-
/** Statuses
|
|
14
|
+
/** Statuses considered enabled (default: ACTIVATED, RUNNING). */
|
|
14
15
|
enabledStatuses?: string[];
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
-
* string → tenant (`plugin_tenants`
|
|
17
|
+
* Load scope: `null`/omitted → platform (`plugins.tenant_id IS NULL`);
|
|
18
|
+
* string → tenant (`plugin_tenants` with ENABLED status).
|
|
18
19
|
*/
|
|
19
20
|
tenantId?: string | null;
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
22
|
+
* Granted permission policy (allowlist). Default: the full CMS permission
|
|
23
|
+
* catalog. Never filled with the manifest's own permissions.
|
|
23
24
|
*/
|
|
24
25
|
permissionPolicy?: string[];
|
|
25
|
-
/**
|
|
26
|
+
/** Hook callback timeout in ms (0 = no timeout). Default 5000. */
|
|
26
27
|
hookTimeoutMs?: number;
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* Real dependencies for the PluginAPI (settings, eventBus, db, etc.).
|
|
30
|
+
* When omitted, only the legacy Hooks API is used (compatibility).
|
|
31
|
+
* The core injects this with real services.
|
|
31
32
|
*/
|
|
32
33
|
apiDeps?: Partial<PluginApiDependencies>;
|
|
33
34
|
}
|
|
34
35
|
export interface PluginBootstrapResult {
|
|
35
36
|
/** Nomes habilitados no banco (vazio quando o banco falhou = estado desconhecido). */
|
|
36
37
|
enabled: string[];
|
|
37
|
-
/**
|
|
38
|
+
/** Loaded in this sync. */
|
|
38
39
|
loaded: string[];
|
|
39
|
-
/** Hooks
|
|
40
|
+
/** Hooks removed in this sync (left the enabled list). */
|
|
40
41
|
unloaded: string[];
|
|
41
42
|
/** Falhas isoladas por plugin (nunca abortam o lote). */
|
|
42
43
|
failed: Array<{
|
|
@@ -44,31 +45,98 @@ export interface PluginBootstrapResult {
|
|
|
44
45
|
error: string;
|
|
45
46
|
}>;
|
|
46
47
|
}
|
|
47
|
-
/**
|
|
48
|
+
/** Scope with registered loads (for inspection/runtime state). */
|
|
48
49
|
export declare function listLoadedScopes(): Array<{
|
|
49
50
|
scope: string;
|
|
50
51
|
registry: HookRegistry;
|
|
51
52
|
plugins: string[];
|
|
52
53
|
}>;
|
|
53
|
-
/**
|
|
54
|
+
/** Gets the routes registered by plugins in a scope. */
|
|
54
55
|
export declare function getLoadedPluginRoutes(scopeKey: string): Array<{
|
|
55
56
|
pluginName: string;
|
|
56
57
|
routes: RouteDefinition[];
|
|
58
|
+
api: PluginAPI;
|
|
59
|
+
scope: string;
|
|
60
|
+
tenantId: string | null;
|
|
61
|
+
/** Route rate-limit rpm (manifest rateLimit.rpm, Item 17). */
|
|
62
|
+
rpm?: number;
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Handlers de jobs dos plugins em um escopo (dispatch pelo worker:
|
|
66
|
+
* `plugin:{tenant}:{plugin}:{jobName}` → handler).
|
|
67
|
+
*/
|
|
68
|
+
export declare function getLoadedPluginJobHandlers(scopeKey: string): Array<{
|
|
69
|
+
pluginName: string;
|
|
70
|
+
handlers: Map<string, PluginJobHandler>;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Runtime `api.admin` state of the plugins loaded in a scope (slots
|
|
74
|
+
* registered at runtime) — consumed by GET /api/v1/plugins/extensions, which
|
|
75
|
+
* merges it with `manifest.admin`. Only states with at least one entry are
|
|
76
|
+
* returned.
|
|
77
|
+
*/
|
|
78
|
+
export declare function getLoadedPluginAdminExtensions(scopeKey: string): Array<{
|
|
79
|
+
pluginName: string;
|
|
80
|
+
state: AdminExtensionsState;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Blocks registered at runtime via `api.registerBlock` by the plugins loaded
|
|
84
|
+
* in a scope — consumed by GET /api/v1/blocks, which merges them with
|
|
85
|
+
* `manifest.blocks`. Only plugins with at least one block are returned.
|
|
86
|
+
*/
|
|
87
|
+
export declare function getLoadedPluginBlocks(scopeKey: string): Array<{
|
|
88
|
+
pluginName: string;
|
|
89
|
+
blocks: Array<PluginBlockManifest & {
|
|
90
|
+
pluginName: string;
|
|
91
|
+
}>;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Patterns registered at runtime via `api.registerPattern` by the plugins
|
|
95
|
+
* loaded in a scope — consumed by GET /api/v1/patterns, which merges them
|
|
96
|
+
* with `manifest.patterns`. Only plugins with at least one pattern are
|
|
97
|
+
* returned.
|
|
98
|
+
*/
|
|
99
|
+
export declare function getLoadedPluginPatterns(scopeKey: string): Array<{
|
|
100
|
+
pluginName: string;
|
|
101
|
+
patterns: Array<PluginPatternManifest & {
|
|
102
|
+
pluginName: string;
|
|
103
|
+
}>;
|
|
104
|
+
}>;
|
|
105
|
+
/**
|
|
106
|
+
* Assets enqueued at runtime via `api.assets` by the plugins loaded in a
|
|
107
|
+
* scope — consumed by the public renderer (theme:head pipeline, Item 8).
|
|
108
|
+
* Only plugins with at least one asset are returned.
|
|
109
|
+
*/
|
|
110
|
+
export declare function getLoadedPluginAssets(scopeKey: string): Array<{
|
|
111
|
+
pluginName: string;
|
|
112
|
+
assets: EnqueuedAsset[];
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Health checks registered at runtime via `api.health` by the plugins loaded
|
|
116
|
+
* in a scope — aggregated by GET /api/v1/health (Item 14). Only plugins with
|
|
117
|
+
* at least one check are returned.
|
|
118
|
+
*/
|
|
119
|
+
export declare function getLoadedPluginHealthChecks(scopeKey: string): Array<{
|
|
120
|
+
pluginName: string;
|
|
121
|
+
checks: Array<{
|
|
122
|
+
name: string;
|
|
123
|
+
check: PluginHealthCheck;
|
|
124
|
+
}>;
|
|
57
125
|
}>;
|
|
58
126
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
127
|
+
* Removes all hooks from the loaded scopes and clears the state.
|
|
128
|
+
* Useful in tests and shutdown. When `registry` is given, hooks are removed
|
|
129
|
+
* from it; otherwise from the registry where they were registered.
|
|
62
130
|
*/
|
|
63
131
|
export declare function resetLoadedPlugins(registry?: HookRegistry): void;
|
|
64
132
|
/** Descarrega todos os plugins de um escopo (tenant desativado / LRU). */
|
|
65
133
|
export declare function unloadScope(scopeKey: string): boolean;
|
|
66
|
-
/**
|
|
134
|
+
/** Unloads a tenant (key `tenant:<id>` or the id itself). */
|
|
67
135
|
export declare function unloadTenant(tenantId: string): boolean;
|
|
68
136
|
/**
|
|
69
137
|
* Sincroniza o registry de um escopo com os plugins habilitados no banco.
|
|
70
138
|
* Seguro para chamar no boot de qualquer processo e em re-syncs (ex.: logo
|
|
71
|
-
*
|
|
139
|
+
* after enabling/disabling through the API).
|
|
72
140
|
*/
|
|
73
141
|
export declare function bootstrapPlugins(options: BootstrapPluginsOptions): Promise<PluginBootstrapResult>;
|
|
74
142
|
//# sourceMappingURL=bootstrap.d.ts.map
|
package/dist/bootstrap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAoBA,OAAO,EAA+C,KAAK,gBAAgB,EAAE,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,KAAK,qBAAqB,EAAE,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAA2C,MAAM,yBAAyB,CAAC;AAInR,OAAO,EAAyC,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,KAAK,EAAE,qBAAqB,EAAqB,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE5G,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,uBAAuB;IACtC,yFAAyF;IACzF,UAAU,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,GAAG,CAAC,EAAE,mBAAmB,CAAC;IAC1B,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,iEAAiE;IACjE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,qBA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