@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.
Files changed (48) hide show
  1. package/dist/bootstrap.d.ts +90 -22
  2. package/dist/bootstrap.d.ts.map +1 -1
  3. package/dist/bootstrap.js +301 -52
  4. package/dist/bootstrap.js.map +1 -1
  5. package/dist/content-query.d.ts +29 -0
  6. package/dist/content-query.d.ts.map +1 -0
  7. package/dist/content-query.js +109 -0
  8. package/dist/content-query.js.map +1 -0
  9. package/dist/hook-registry.d.ts +21 -21
  10. package/dist/hook-registry.d.ts.map +1 -1
  11. package/dist/hook-registry.js +26 -26
  12. package/dist/hook-registry.js.map +1 -1
  13. package/dist/http.d.ts +50 -0
  14. package/dist/http.d.ts.map +1 -0
  15. package/dist/http.js +314 -0
  16. package/dist/http.js.map +1 -0
  17. package/dist/i18n.d.ts +16 -0
  18. package/dist/i18n.d.ts.map +1 -0
  19. package/dist/i18n.js +73 -0
  20. package/dist/i18n.js.map +1 -0
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/loader.d.ts +8 -0
  26. package/dist/loader.d.ts.map +1 -1
  27. package/dist/loader.js +98 -10
  28. package/dist/loader.js.map +1 -1
  29. package/dist/manifest.d.ts +11 -6
  30. package/dist/manifest.d.ts.map +1 -1
  31. package/dist/manifest.js +290 -17
  32. package/dist/manifest.js.map +1 -1
  33. package/dist/plugin-api.d.ts +194 -40
  34. package/dist/plugin-api.d.ts.map +1 -1
  35. package/dist/plugin-api.js +655 -13
  36. package/dist/plugin-api.js.map +1 -1
  37. package/dist/plugin-migrations.d.ts +15 -0
  38. package/dist/plugin-migrations.d.ts.map +1 -0
  39. package/dist/plugin-migrations.js +68 -0
  40. package/dist/plugin-migrations.js.map +1 -0
  41. package/dist/sandbox.d.ts +13 -11
  42. package/dist/sandbox.d.ts.map +1 -1
  43. package/dist/sandbox.js +11 -9
  44. package/dist/sandbox.js.map +1 -1
  45. package/dist/style-isolation.d.ts +3 -3
  46. package/dist/style-isolation.js +6 -6
  47. package/dist/style-isolation.js.map +1 -1
  48. package/package.json +6 -5
@@ -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
- /** Diretório de plugins (o chamador resolve — plugin-runtime não conhece o core). */
8
+ /** Plugins directory (the caller resolves it — plugin-runtime doesn't know the core). */
8
9
  pluginsDir: string;
9
- /** Cliente postgres para ler os habilitados; omitido = estado desconhecido (no-op). */
10
+ /** Postgres client to read enabled plugins; omitted = unknown state (no-op). */
10
11
  sql?: BootstrapPluginsSql;
11
- /** Registry alvo (default: registry do escopo — platform ou `tenantId`). */
12
+ /** Target registry (default: the scope registry — platform or `tenantId`). */
12
13
  registry?: HookRegistry;
13
- /** Statuses considerados habilitados (default: ACTIVATED, RUNNING). */
14
+ /** Statuses considered enabled (default: ACTIVATED, RUNNING). */
14
15
  enabledStatuses?: string[];
15
16
  /**
16
- * Escopo de carga: `null`/omitido → platform (`plugins.tenant_id IS NULL`);
17
- * string → tenant (`plugin_tenants` com status ENABLED).
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
- * Política de permissões concedidas (allowlist). Default: catálogo completo
22
- * de permissões do CMS. Nunca é preenchida com as permissões do manifesto.
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
- /** Timeout de callbacks de hook em ms (0 = sem timeout). Default 5000. */
26
+ /** Hook callback timeout in ms (0 = no timeout). Default 5000. */
26
27
  hookTimeoutMs?: number;
27
28
  /**
28
- * Dependências reais para a PluginAPI (settings, eventBus, db, etc.).
29
- * Se omitido, usa apenas o Hooks API legado (compatibilidade).
30
- * O core injeta isto com serviços reais.
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
- /** Registrados nesta sincronização. */
38
+ /** Loaded in this sync. */
38
39
  loaded: string[];
39
- /** Hooks removidos nesta sincronização (saíram dos habilitados). */
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
- /** Escopo com carga registrada (para inspeção/estado de runtime). */
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
- /** Obtém as rotas registradas pelos plugins em um escopo. */
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
- * Remove todos os hooks dos escopos carregados e limpa o estado.
60
- * Útil em testes e em shutdown. Quando `registry` é informado, os hooks são
61
- * removidos dele; caso contrário, do registry em que foram registrados.
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
- /** Descarrega um tenant (chave `tenant:<id>` ou o próprio id). */
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
- * após ativar/desativar pela API).
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
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAyC,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,KAAK,EAAE,qBAAqB,EAAqB,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEjG,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5D;AAED,MAAM,W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