@attraccess/plugins-backend-sdk 1.10.0 → 1.11.0-beta.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/package.json +8 -3
- package/src/index.d.ts +5 -0
- package/src/index.js +5 -0
- package/src/index.js.map +1 -1
- package/src/lib/plugin-audit.d.ts +33 -33
- package/src/lib/plugin-audit.js +11 -11
- package/src/lib/plugin-audit.js.map +1 -1
- package/src/lib/plugin-backend-module.d.ts +66 -0
- package/src/lib/plugin-backend-module.js +3 -0
- package/src/lib/plugin-backend-module.js.map +1 -0
- package/src/lib/plugin-context.d.ts +52 -54
- package/src/lib/plugin-context.js +6 -6
- package/src/lib/plugin-context.js.map +1 -1
- package/src/lib/plugin-flow-node.d.ts +52 -3
- package/src/lib/plugin-live-updates.d.ts +21 -0
- package/src/lib/plugin-live-updates.js +3 -0
- package/src/lib/plugin-live-updates.js.map +1 -0
- package/src/lib/plugin-notifications.d.ts +83 -0
- package/src/lib/plugin-notifications.js +3 -0
- package/src/lib/plugin-notifications.js.map +1 -0
- package/src/lib/plugin-resource-access.d.ts +89 -0
- package/src/lib/plugin-resource-access.js +3 -0
- package/src/lib/plugin-resource-access.js.map +1 -0
- package/src/lib/plugin.interface.d.ts +74 -5
- package/src/lib/plugin.interface.js +20 -1
- package/src/lib/plugin.interface.js.map +1 -1
- package/src/lib/reader-ui.d.ts +317 -0
- package/src/lib/reader-ui.js +115 -0
- package/src/lib/reader-ui.js.map +1 -0
- package/src/lib/shared-live-sampler.d.ts +11 -0
- package/src/lib/shared-live-sampler.js +33 -0
- package/src/lib/shared-live-sampler.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@attraccess/plugins-backend-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0-beta.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/Attraccess/Attraccess.git",
|
|
7
|
+
"directory": "libs/plugins-backend-sdk"
|
|
8
|
+
},
|
|
4
9
|
"type": "commonjs",
|
|
5
10
|
"main": "./src/index.js",
|
|
6
11
|
"types": "./src/index.d.ts",
|
|
@@ -21,14 +26,14 @@
|
|
|
21
26
|
],
|
|
22
27
|
"dependencies": {
|
|
23
28
|
"tslib": "^2.8.1",
|
|
24
|
-
"@attraccess/database-entities": "
|
|
29
|
+
"@attraccess/database-entities": "1.11.0-beta.0",
|
|
25
30
|
"@nestjs/common": "^11.1.0",
|
|
26
31
|
"@nestjs/event-emitter": "^3.1.0",
|
|
27
32
|
"rxjs": "^7.8.2",
|
|
28
33
|
"@nestjs/core": "^11.1.0",
|
|
29
34
|
"typeorm": "0.3.31",
|
|
30
35
|
"@nestjs/swagger": "^11.2.0",
|
|
31
|
-
"express": "4.22.
|
|
36
|
+
"express": "4.22.3",
|
|
32
37
|
"@nestjs/passport": "^11.0.5",
|
|
33
38
|
"@attraccess/shared": "*"
|
|
34
39
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
export * from './lib/plugin.interface';
|
|
2
2
|
export * from './lib/plugin-flow-node';
|
|
3
3
|
export * from './lib/plugin-context';
|
|
4
|
+
export * from './lib/plugin-live-updates';
|
|
5
|
+
export * from './lib/shared-live-sampler';
|
|
4
6
|
export * from './lib/plugin-audit';
|
|
5
7
|
export * from './lib/mqtt-credential-provisioning';
|
|
6
8
|
export * from './lib/plugin-migrations';
|
|
7
9
|
export * from './lib/entity';
|
|
8
10
|
export * from './lib/semver';
|
|
11
|
+
export * from './lib/reader-ui';
|
|
12
|
+
export * from './lib/plugin-notifications';
|
|
13
|
+
export * from './lib/plugin-resource-access';
|
|
9
14
|
export * from './lib/auth-decorator';
|
|
10
15
|
export * from '@attraccess/database-entities';
|
|
11
16
|
export * as entities from '@attraccess/database-entities';
|
package/src/index.js
CHANGED
|
@@ -5,11 +5,16 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
tslib_1.__exportStar(require("./lib/plugin.interface"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./lib/plugin-flow-node"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./lib/plugin-context"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./lib/plugin-live-updates"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./lib/shared-live-sampler"), exports);
|
|
8
10
|
tslib_1.__exportStar(require("./lib/plugin-audit"), exports);
|
|
9
11
|
tslib_1.__exportStar(require("./lib/mqtt-credential-provisioning"), exports);
|
|
10
12
|
tslib_1.__exportStar(require("./lib/plugin-migrations"), exports);
|
|
11
13
|
tslib_1.__exportStar(require("./lib/entity"), exports);
|
|
12
14
|
tslib_1.__exportStar(require("./lib/semver"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./lib/reader-ui"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./lib/plugin-notifications"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./lib/plugin-resource-access"), exports);
|
|
13
18
|
tslib_1.__exportStar(require("./lib/auth-decorator"), exports);
|
|
14
19
|
tslib_1.__exportStar(require("@attraccess/database-entities"), exports);
|
|
15
20
|
exports.entities = tslib_1.__importStar(require("@attraccess/database-entities"));
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/plugins-backend-sdk/src/index.ts"],"names":[],"mappings":";;;;AAAA,iEAAuC;AACvC,iEAAuC;AACvC,+DAAqC;AACrC,6DAAmC;AACnC,6EAAmD;AACnD,kEAAwC;AACxC,uDAA6B;AAC7B,uDAA6B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/plugins-backend-sdk/src/index.ts"],"names":[],"mappings":";;;;AAAA,iEAAuC;AACvC,iEAAuC;AACvC,+DAAqC;AACrC,oEAA0C;AAC1C,oEAA0C;AAC1C,6DAAmC;AACnC,6EAAmD;AACnD,kEAAwC;AACxC,uDAA6B;AAC7B,uDAA6B;AAC7B,0DAAgC;AAChC,qEAA2C;AAC3C,uEAA6C;AAE7C,+DAAqC;AACrC,wEAA8C;AAC9C,kFAA0D;AAC1D,2DAAiC;AACjC,gEAAsC"}
|
|
@@ -1,36 +1,3 @@
|
|
|
1
|
-
/** Implemented by the generic audit foundation, not by individual plugins. */
|
|
2
|
-
export declare const PLUGIN_AUDIT_HOST_PROVIDER: unique symbol;
|
|
3
|
-
export interface PluginAuditPrincipal {
|
|
4
|
-
userId: number;
|
|
5
|
-
authenticationMethod: 'session' | 'api-token';
|
|
6
|
-
apiTokenId?: number;
|
|
7
|
-
}
|
|
8
|
-
export interface PluginAuditEvent {
|
|
9
|
-
action: string;
|
|
10
|
-
operationId: string;
|
|
11
|
-
principal: PluginAuditPrincipal;
|
|
12
|
-
outcome: 'attempted' | 'succeeded' | 'failed';
|
|
13
|
-
subject: {
|
|
14
|
-
type: string;
|
|
15
|
-
id: number;
|
|
16
|
-
};
|
|
17
|
-
/** Callers must project domain data through an explicit allowlist. */
|
|
18
|
-
details: Readonly<Record<string, string | number | boolean | null>>;
|
|
19
|
-
}
|
|
20
|
-
/** Only `recorded` means the host durably accepted the event. */
|
|
21
|
-
export type PluginAuditReceipt = {
|
|
22
|
-
status: 'recorded';
|
|
23
|
-
} | {
|
|
24
|
-
status: 'unavailable';
|
|
25
|
-
};
|
|
26
|
-
export interface PluginAuditContext {
|
|
27
|
-
record(event: PluginAuditEvent): Promise<PluginAuditReceipt>;
|
|
28
|
-
}
|
|
29
|
-
export interface PluginAuditHostProvider {
|
|
30
|
-
record(event: PluginAuditEvent & {
|
|
31
|
-
pluginId: string;
|
|
32
|
-
}): Promise<PluginAuditReceipt>;
|
|
33
|
-
}
|
|
34
1
|
/**
|
|
35
2
|
* Declarative audit policy a plugin contributes through `PluginBackendModule.auditDomains`.
|
|
36
3
|
* The host registers the declaration, then enforces it on every event the plugin records:
|
|
@@ -86,6 +53,39 @@ export interface PluginAuditDomainDeclaration {
|
|
|
86
53
|
readonly labels?: Readonly<Record<string, string>>;
|
|
87
54
|
readonly actions: readonly PluginAuditActionPolicy[];
|
|
88
55
|
}
|
|
56
|
+
/** Implemented by the generic audit foundation, not by individual plugins. */
|
|
57
|
+
export declare const PLUGIN_AUDIT_HOST_PROVIDER: unique symbol;
|
|
58
|
+
export interface PluginAuditPrincipal {
|
|
59
|
+
userId: number;
|
|
60
|
+
authenticationMethod: 'session' | 'api-token';
|
|
61
|
+
apiTokenId?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface PluginAuditEvent {
|
|
64
|
+
action: string;
|
|
65
|
+
operationId: string;
|
|
66
|
+
principal: PluginAuditPrincipal;
|
|
67
|
+
outcome: 'attempted' | 'succeeded' | 'failed';
|
|
68
|
+
subject: {
|
|
69
|
+
type: string;
|
|
70
|
+
id: number;
|
|
71
|
+
};
|
|
72
|
+
/** Callers must project domain data through an explicit allowlist. */
|
|
73
|
+
details: Readonly<Record<string, string | number | boolean | null>>;
|
|
74
|
+
}
|
|
75
|
+
/** Only `recorded` means the host durably accepted the event. */
|
|
76
|
+
export type PluginAuditReceipt = {
|
|
77
|
+
status: 'recorded';
|
|
78
|
+
} | {
|
|
79
|
+
status: 'unavailable';
|
|
80
|
+
};
|
|
81
|
+
export interface PluginAuditContext {
|
|
82
|
+
record(event: PluginAuditEvent): Promise<PluginAuditReceipt>;
|
|
83
|
+
}
|
|
84
|
+
export interface PluginAuditHostProvider {
|
|
85
|
+
record(event: PluginAuditEvent & {
|
|
86
|
+
pluginId: string;
|
|
87
|
+
}): Promise<PluginAuditReceipt>;
|
|
88
|
+
}
|
|
89
89
|
/**
|
|
90
90
|
* Validates one plugin-contributed audit domain declaration and returns it unchanged.
|
|
91
91
|
* Throws a descriptive error on any violation; hosts quarantine the plugin in that case.
|
package/src/lib/plugin-audit.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PLUGIN_AUDIT_LIMITS = exports.PLUGIN_AUDIT_FIELD_PATTERN = exports.PLUGIN_AUDIT_SEGMENT_PATTERN = exports.PLUGIN_AUDIT_DOMAIN_PATTERN = exports.PLUGIN_AUDIT_HOST_PROVIDER = void 0;
|
|
4
|
-
exports.validatePluginAuditDomainDeclaration = validatePluginAuditDomainDeclaration;
|
|
5
|
-
/** Implemented by the generic audit foundation, not by individual plugins. */
|
|
6
|
-
exports.PLUGIN_AUDIT_HOST_PROVIDER = Symbol.for('attraccess.plugin.auditHostProvider');
|
|
7
2
|
/**
|
|
8
3
|
* Declarative audit policy a plugin contributes through `PluginBackendModule.auditDomains`.
|
|
9
4
|
* The host registers the declaration, then enforces it on every event the plugin records:
|
|
@@ -12,6 +7,9 @@ exports.PLUGIN_AUDIT_HOST_PROVIDER = Symbol.for('attraccess.plugin.auditHostProv
|
|
|
12
7
|
* bounds (identifier shapes, detail size) and rejects events whose pluginId does not own
|
|
13
8
|
* the domain.
|
|
14
9
|
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.PLUGIN_AUDIT_HOST_PROVIDER = exports.PLUGIN_AUDIT_LIMITS = exports.PLUGIN_AUDIT_FIELD_PATTERN = exports.PLUGIN_AUDIT_SEGMENT_PATTERN = exports.PLUGIN_AUDIT_DOMAIN_PATTERN = void 0;
|
|
12
|
+
exports.validatePluginAuditDomainDeclaration = validatePluginAuditDomainDeclaration;
|
|
15
13
|
/** Domain identifiers are lowercase snake_case and prefix every action and subject type. */
|
|
16
14
|
exports.PLUGIN_AUDIT_DOMAIN_PATTERN = /^[a-z][a-z_]{0,31}$/;
|
|
17
15
|
/** One dot-separated segment of an action or subject type name. */
|
|
@@ -36,12 +34,6 @@ const isPlainRecord = (value) => {
|
|
|
36
34
|
const prototype = Object.getPrototypeOf(value);
|
|
37
35
|
return prototype === Object.prototype || prototype === null;
|
|
38
36
|
};
|
|
39
|
-
const dottedName = (prefix, value, maxLength) => {
|
|
40
|
-
if (typeof value !== 'string' || value.length > maxLength || !value.startsWith(`${prefix}.`))
|
|
41
|
-
return false;
|
|
42
|
-
const segments = value.slice(prefix.length + 1).split('.');
|
|
43
|
-
return segments.length > 0 && segments.every((segment) => exports.PLUGIN_AUDIT_SEGMENT_PATTERN.test(segment));
|
|
44
|
-
};
|
|
45
37
|
function validateFieldChoices(path, policy, declared) {
|
|
46
38
|
if (policy.pattern !== undefined) {
|
|
47
39
|
if (declared !== 'string')
|
|
@@ -93,6 +85,14 @@ function validateFieldPolicy(path, policy) {
|
|
|
93
85
|
throw new Error(`${path}: maxLength requires an integer 1-${exports.PLUGIN_AUDIT_LIMITS.maxLengthCeiling} and type 'string'`);
|
|
94
86
|
}
|
|
95
87
|
}
|
|
88
|
+
/** Implemented by the generic audit foundation, not by individual plugins. */
|
|
89
|
+
exports.PLUGIN_AUDIT_HOST_PROVIDER = Symbol.for('attraccess.plugin.auditHostProvider');
|
|
90
|
+
const dottedName = (prefix, value, maxLength) => {
|
|
91
|
+
if (typeof value !== 'string' || value.length > maxLength || !value.startsWith(`${prefix}.`))
|
|
92
|
+
return false;
|
|
93
|
+
const segments = value.slice(prefix.length + 1).split('.');
|
|
94
|
+
return segments.length > 0 && segments.every((segment) => exports.PLUGIN_AUDIT_SEGMENT_PATTERN.test(segment));
|
|
95
|
+
};
|
|
96
96
|
function validateDomainLabels(declaration, prefix) {
|
|
97
97
|
if (declaration.labels !== undefined) {
|
|
98
98
|
if (!isPlainRecord(declaration.labels))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-audit.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/plugin-audit.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"plugin-audit.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/plugin-audit.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAgLH,oFAyD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AO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { PluginContext } from './plugin-context';
|
|
2
|
+
import { DynamicModule } from '@nestjs/common';
|
|
3
|
+
import type { PluginEntityClass } from './entity';
|
|
4
|
+
import type { MqttCredentialProvisioningProviderFactory } from './mqtt-credential-provisioning';
|
|
5
|
+
import type { PluginAuditDomainDeclaration } from './plugin-audit';
|
|
6
|
+
import type { PluginFlowNodeDefinition } from './plugin-flow-node';
|
|
7
|
+
import type { PluginEmailTemplate, PluginNotificationCategory } from './plugin-notifications';
|
|
8
|
+
import type { PreStartHook, ReaderUiProvider, SessionEndHook, StartBlockedQuery } from './reader-ui';
|
|
9
|
+
/**
|
|
10
|
+
* Shape every backend plugin's default export must satisfy. The host calls
|
|
11
|
+
* register(context) at load time to obtain the plugin's Nest module definition.
|
|
12
|
+
*/
|
|
13
|
+
export interface PluginBackendModule {
|
|
14
|
+
register(context: PluginContext): DynamicModule;
|
|
15
|
+
/**
|
|
16
|
+
* Optional TypeORM entity classes this plugin owns. The host registers their
|
|
17
|
+
* metadata into the shared DataSource at load time so the plugin can query
|
|
18
|
+
* them through {@link PluginContext.getRepository}. The schema itself is owned
|
|
19
|
+
* by the plugin's migrations (the host runs with `synchronize: false`), so an
|
|
20
|
+
* entity here describes an existing table rather than creating one. Requires
|
|
21
|
+
* the DATABASE_ACCESS permission. See `docs/en/plugins/database-migrations.md`.
|
|
22
|
+
*/
|
|
23
|
+
entities?: PluginEntityClass[];
|
|
24
|
+
/**
|
|
25
|
+
* Optional custom flow node types this plugin contributes. The host registers
|
|
26
|
+
* them into the flow engine so they appear in the frontend node catalog and
|
|
27
|
+
* can be executed like built-in node types. No extra permission is required.
|
|
28
|
+
*
|
|
29
|
+
* Type naming convention: "plugin.<pluginName>.<nodeName>".
|
|
30
|
+
*/
|
|
31
|
+
flowNodes?: PluginFlowNodeDefinition[] | ((context: PluginContext) => PluginFlowNodeDefinition[]);
|
|
32
|
+
/**
|
|
33
|
+
* Optional audit domains this plugin contributes. The host registers the
|
|
34
|
+
* declarations at load time and enforces them on every event the plugin
|
|
35
|
+
* records through {@link PluginContext.audit}: only declared actions, subject
|
|
36
|
+
* types and detail fields are accepted, and events are stored under the
|
|
37
|
+
* declared domain. Domains must not collide with host domains or with other
|
|
38
|
+
* plugins. No extra permission is required.
|
|
39
|
+
*/
|
|
40
|
+
auditDomains?: PluginAuditDomainDeclaration[] | ((context: PluginContext) => PluginAuditDomainDeclaration[]);
|
|
41
|
+
/** Optional broker credential provider offered to other integrations by this plugin. */
|
|
42
|
+
credentialProvisioningProvider?: MqttCredentialProvisioningProviderFactory;
|
|
43
|
+
/** Optional reader UI slot provider. Requires the READER_UI permission. */
|
|
44
|
+
readerUi?: ReaderUiProvider | ((context: PluginContext) => ReaderUiProvider);
|
|
45
|
+
/** Optional pre-start hook (allow / confirm / block). Requires ACCESS_HOOKS. */
|
|
46
|
+
preStartHook?: PreStartHook;
|
|
47
|
+
/**
|
|
48
|
+
* Optional query-side counterpart of `preStartHook`: reports a "start currently blocked" state the resource UI
|
|
49
|
+
* shows in place of the start button. Informational; the pre-start hook stays the gate. Requires ACCESS_HOOKS.
|
|
50
|
+
*/
|
|
51
|
+
startBlockedQuery?: StartBlockedQuery;
|
|
52
|
+
/** Optional advisory hook after a session ended. Requires ACCESS_HOOKS. */
|
|
53
|
+
sessionEndHook?: SessionEndHook;
|
|
54
|
+
/**
|
|
55
|
+
* Optional notification categories this plugin dispatches under. They appear in user notification
|
|
56
|
+
* preferences grouped under the plugin name as `plugin.<pluginName>.<id>`. Dispatching requires the
|
|
57
|
+
* SEND_NOTIFICATIONS permission; declaring categories without it quarantines the plugin.
|
|
58
|
+
*/
|
|
59
|
+
notificationCategories?: PluginNotificationCategory[];
|
|
60
|
+
/**
|
|
61
|
+
* Optional email templates, stored and edited like core templates (key `plugin.<pluginName>.<id>`) and sent
|
|
62
|
+
* through `notifications.dispatch({ email: { template, variables } })`. Declaring them requires the
|
|
63
|
+
* SEND_NOTIFICATIONS permission; without it the plugin is quarantined.
|
|
64
|
+
*/
|
|
65
|
+
emailTemplates?: PluginEmailTemplate[];
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-backend-module.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/plugin-backend-module.ts"],"names":[],"mappings":""}
|
|
@@ -1,27 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { PluginFlowNodeDefinition } from './plugin-flow-node';
|
|
1
|
+
import { LoggerService, Type } from '@nestjs/common';
|
|
3
2
|
import { EventEmitter2 } from '@nestjs/event-emitter';
|
|
4
|
-
import { DataSource, EntityTarget, ObjectLiteral, Repository } from 'typeorm';
|
|
5
|
-
import { SystemEvent, SystemEventHandler, SystemEventPayload, SystemEventSubscription } from './plugin.interface';
|
|
6
|
-
import type { PluginEntityClass } from './entity';
|
|
7
|
-
import type { MqttCredentialProvisioningProviderFactory } from './mqtt-credential-provisioning';
|
|
3
|
+
import { DataSource, EntityManager, EntityTarget, ObjectLiteral, Repository } from 'typeorm';
|
|
8
4
|
import type { MqttCredentialProvisioningHostProvider } from './mqtt-credential-provisioning';
|
|
9
|
-
import type { PluginAuditContext
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Subset of the host manifest exposed to a plugin at runtime. The host's
|
|
17
|
-
* LoadedPluginManifest structurally satisfies this shape.
|
|
18
|
-
*/
|
|
19
|
-
export interface PluginManifestInfo {
|
|
20
|
-
readonly id: string;
|
|
21
|
-
readonly name: string;
|
|
22
|
-
readonly version: string;
|
|
23
|
-
readonly pluginDirectory: string;
|
|
24
|
-
}
|
|
5
|
+
import type { PluginAuditContext } from './plugin-audit';
|
|
6
|
+
import type { PluginReaderUiApi, PluginStartBlockedApi } from './reader-ui';
|
|
7
|
+
import type { PluginNotificationsContext } from './plugin-notifications';
|
|
8
|
+
import type { PluginResourceAccessContext } from './plugin-resource-access';
|
|
9
|
+
import type { PluginLiveUpdatesContext } from './plugin-live-updates';
|
|
10
|
+
import { SystemEvent, SystemEventHandler, SystemEventPayload, SystemEventSubscription } from './plugin.interface';
|
|
25
11
|
/**
|
|
26
12
|
* DI token under which the host registers its MqttServerHostProvider
|
|
27
13
|
* implementation. The plugin context resolves the provider through this token;
|
|
@@ -84,6 +70,25 @@ export interface PluginMqttClient {
|
|
|
84
70
|
qos?: 0 | 1 | 2;
|
|
85
71
|
retain?: boolean;
|
|
86
72
|
}): Promise<void>;
|
|
73
|
+
/** Reconnect using current configured settings and restore shared topic
|
|
74
|
+
* registrations. Optional for compatibility with older host runtimes.
|
|
75
|
+
*/
|
|
76
|
+
refreshConnection?(serverId: number): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* DI token under which a plugin's own services can inject the PluginContext.
|
|
80
|
+
* The host publishes the context as a module-scoped provider with this token.
|
|
81
|
+
*/
|
|
82
|
+
export declare const PLUGIN_CONTEXT: unique symbol;
|
|
83
|
+
/**
|
|
84
|
+
* Subset of the host manifest exposed to a plugin at runtime. The host's
|
|
85
|
+
* LoadedPluginManifest structurally satisfies this shape.
|
|
86
|
+
*/
|
|
87
|
+
export interface PluginManifestInfo {
|
|
88
|
+
readonly id: string;
|
|
89
|
+
readonly name: string;
|
|
90
|
+
readonly version: string;
|
|
91
|
+
readonly pluginDirectory: string;
|
|
87
92
|
}
|
|
88
93
|
/** Host flow functionality available to plugins with the TRIGGER_FLOWS permission. */
|
|
89
94
|
export interface PluginFlowsContext {
|
|
@@ -104,8 +109,17 @@ export interface PluginSecretsContext {
|
|
|
104
109
|
* a minor SDK bump; removing/changing one is a major bump.
|
|
105
110
|
*/
|
|
106
111
|
export interface PluginContext {
|
|
112
|
+
/**
|
|
113
|
+
* Version of the running Attraccess host (the one plugin compatibility is checked against). Optional for hosts
|
|
114
|
+
* predating this field, so a plugin that needs it must handle its absence.
|
|
115
|
+
*/
|
|
116
|
+
readonly hostVersion?: string;
|
|
117
|
+
/** Shared authenticated UI transport. Optional for hosts predating this capability. */
|
|
118
|
+
readonly liveUpdates?: PluginLiveUpdatesContext;
|
|
107
119
|
/** Optional for compatibility with hosts predating generic plugin audit support. */
|
|
108
120
|
readonly audit?: PluginAuditContext;
|
|
121
|
+
/** Reader UI helpers. Guarded getter: throws PluginPermissionError without READER_UI. */
|
|
122
|
+
readonly readerUi?: PluginReaderUiApi;
|
|
109
123
|
/** This plugin's own manifest (name, version, directory, id). */
|
|
110
124
|
readonly manifest: PluginManifestInfo;
|
|
111
125
|
/** Shared application event bus — the same EventEmitter2 instance the host uses. */
|
|
@@ -148,39 +162,23 @@ export interface PluginContext {
|
|
|
148
162
|
readonly flows: PluginFlowsContext;
|
|
149
163
|
/** Encrypt and decrypt this plugin's secret material. Requires MANAGE_SECRETS. */
|
|
150
164
|
readonly secrets: PluginSecretsContext;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
|
-
register(context: PluginContext): DynamicModule;
|
|
158
|
-
/**
|
|
159
|
-
* Optional TypeORM entity classes this plugin owns. The host registers their
|
|
160
|
-
* metadata into the shared DataSource at load time so the plugin can query
|
|
161
|
-
* them through {@link PluginContext.getRepository}. The schema itself is owned
|
|
162
|
-
* by the plugin's migrations (the host runs with `synchronize: false`), so an
|
|
163
|
-
* entity here describes an existing table rather than creating one. Requires
|
|
164
|
-
* the DATABASE_ACCESS permission. See `docs/en/plugins/database-migrations.md`.
|
|
165
|
-
*/
|
|
166
|
-
entities?: PluginEntityClass[];
|
|
165
|
+
/** Notify users under plugin-declared categories. Requires SEND_NOTIFICATIONS. */
|
|
166
|
+
readonly notifications: PluginNotificationsContext;
|
|
167
|
+
/** Tells the host UI that this plugin's `startBlockedQuery` answer changed. Requires ACCESS_HOOKS. */
|
|
168
|
+
readonly startBlocked: PluginStartBlockedApi;
|
|
169
|
+
/** Read-only authorization, maintenance and session queries. Requires ACCESS_RESOURCES. */
|
|
170
|
+
readonly resourceAccess: PluginResourceAccessContext;
|
|
167
171
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
172
|
+
* Run `fn` in a serialized database transaction. Concurrent callers (core lifecycle writes included)
|
|
173
|
+
* run one at a time on SQLite, so check-then-write sequences such as overlap checks are race-free.
|
|
174
|
+
* The transaction commits when `fn` resolves and rolls back when it throws. Requires DATABASE_ACCESS.
|
|
171
175
|
*
|
|
172
|
-
*
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
*
|
|
177
|
-
* declarations at load time and enforces them on every event the plugin
|
|
178
|
-
* records through {@link PluginContext.audit}: only declared actions, subject
|
|
179
|
-
* types and detail fields are accepted, and events are stored under the
|
|
180
|
-
* declared domain. Domains must not collide with host domains or with other
|
|
181
|
-
* plugins. No extra permission is required.
|
|
176
|
+
* The queue is shared with every core session start and end, so keep `fn` short and limited to database
|
|
177
|
+
* work through the given manager: no HTTP, MQTT, email or other I/O inside. Do not nest calls: a
|
|
178
|
+
* runSerialized started inside `fn` would wait for `fn` itself, so the host rejects it with an error;
|
|
179
|
+
* pass the manager down instead. Core services that write through the same queue (session start/end)
|
|
180
|
+
* must not be awaited inside `fn` either.
|
|
182
181
|
*/
|
|
183
|
-
|
|
184
|
-
/** Optional broker credential provider offered to other integrations by this plugin. */
|
|
185
|
-
credentialProvisioningProvider?: MqttCredentialProvisioningProviderFactory;
|
|
182
|
+
runSerialized<T>(fn: (manager: EntityManager) => Promise<T>): Promise<T>;
|
|
186
183
|
}
|
|
184
|
+
export { PluginBackendModule } from './plugin-backend-module';
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
/**
|
|
5
|
-
* DI token under which a plugin's own services can inject the PluginContext.
|
|
6
|
-
* The host publishes the context as a module-scoped provider with this token.
|
|
7
|
-
*/
|
|
8
|
-
exports.PLUGIN_CONTEXT = Symbol.for('attraccess.plugin.context');
|
|
3
|
+
exports.PLUGIN_CONTEXT = exports.MQTT_SERVER_HOST_PROVIDER = void 0;
|
|
9
4
|
/**
|
|
10
5
|
* DI token under which the host registers its MqttServerHostProvider
|
|
11
6
|
* implementation. The plugin context resolves the provider through this token;
|
|
12
7
|
* plugins never reference it directly — they call getMqttServerConfig instead.
|
|
13
8
|
*/
|
|
14
9
|
exports.MQTT_SERVER_HOST_PROVIDER = Symbol.for('attraccess.plugin.mqttServerHostProvider');
|
|
10
|
+
/**
|
|
11
|
+
* DI token under which a plugin's own services can inject the PluginContext.
|
|
12
|
+
* The host publishes the context as a module-scoped provider with this token.
|
|
13
|
+
*/
|
|
14
|
+
exports.PLUGIN_CONTEXT = Symbol.for('attraccess.plugin.context');
|
|
15
15
|
//# sourceMappingURL=plugin-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-context.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/plugin-context.ts"],"names":[],"mappings":";;;AAUA
|
|
1
|
+
{"version":3,"file":"plugin-context.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/plugin-context.ts"],"names":[],"mappings":";;;AAUA;;;;GAIG;AACU,QAAA,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;AA4EhG;;;GAGG;AACU,QAAA,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC"}
|
|
@@ -19,6 +19,26 @@ export interface PluginNodeExecutionContext {
|
|
|
19
19
|
* ({{resource.id}}, {{payload.*}}, etc.).
|
|
20
20
|
*/
|
|
21
21
|
compileTemplate(template: string, data: object): string;
|
|
22
|
+
/**
|
|
23
|
+
* The resource the run acts on: the node's own resource in a resource flow, the triggering resource in a global
|
|
24
|
+
* flow. `null` (or undefined) when the run was not started by a resource event.
|
|
25
|
+
*/
|
|
26
|
+
readonly resourceId?: number | null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The kinds of flow a node can be used in: a flow bound to one resource, or a global flow that reacts to
|
|
30
|
+
* events of every resource.
|
|
31
|
+
*/
|
|
32
|
+
export type PluginFlowScope = 'resource' | 'global';
|
|
33
|
+
/** Context passed to `resolveConfigSchema` while the editor or the canvas asks for a node's schema. */
|
|
34
|
+
export interface PluginFlowNodeSchemaContext {
|
|
35
|
+
/** The kind of flow that contains the node. */
|
|
36
|
+
flowScope: PluginFlowScope;
|
|
37
|
+
/** The resource of a resource flow; `null` in a global flow. */
|
|
38
|
+
resourceId: number | null;
|
|
39
|
+
/** The global flow the node belongs to; `null` in a resource flow. */
|
|
40
|
+
flowId: number | null;
|
|
41
|
+
purpose?: 'editor' | 'preview';
|
|
22
42
|
}
|
|
23
43
|
export type PluginFlowFailureKind = 'transport-dispatch' | 'acknowledgement-timeout' | 'controller-rejection' | 'node-failure';
|
|
24
44
|
export type PluginFlowFailureBehavior = 'fail-flow' | 'failure-output' | 'log-and-continue';
|
|
@@ -27,6 +47,16 @@ export interface PluginFlowNodeValidationError {
|
|
|
27
47
|
message: string;
|
|
28
48
|
value?: unknown;
|
|
29
49
|
}
|
|
50
|
+
/** Plain-text canvas summary with optional BCP 47 locale overrides. */
|
|
51
|
+
export interface PluginFlowNodePreviewRow {
|
|
52
|
+
label: string;
|
|
53
|
+
value: string;
|
|
54
|
+
/** Exact locale, then base language, then the default label/value are used. */
|
|
55
|
+
translations?: Record<string, {
|
|
56
|
+
label: string;
|
|
57
|
+
value: string;
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
30
60
|
/** Request-scoped storage shared while validating all nodes in a flow. */
|
|
31
61
|
export type PluginFlowNodeValidationContext = Map<string, unknown>;
|
|
32
62
|
/**
|
|
@@ -56,16 +86,25 @@ interface PluginFlowNodeDefinitionBase {
|
|
|
56
86
|
* { selectFromEntity: 'mqttServer', entityProperty: 'id' }
|
|
57
87
|
* { stringVariant: 'multiline' }
|
|
58
88
|
* { helpText: '...' }
|
|
89
|
+
*
|
|
90
|
+
* Canvas summaries use a top-level `preview: PluginFlowNodePreviewRow[]`
|
|
91
|
+
* (at most four plain-text rows). Include only the essential, non-secret fields.
|
|
92
|
+
* Optional `translations: { de: { label: 'Gerät', value: 'Nicht ausgewählt' } }`
|
|
93
|
+
* localizes each row; the host selects its current UI locale without another request.
|
|
94
|
+
* Default label/value strings remain required as the fallback for unsupported locales.
|
|
95
|
+
* Dynamic nodes opt in with `configSchema: { dynamic: true, properties: {}, preview: [] }`
|
|
96
|
+
* and return the summary from resolveConfigSchema for the selected configuration.
|
|
59
97
|
*/
|
|
60
98
|
readonly configSchema?: Record<string, unknown>;
|
|
61
99
|
/**
|
|
62
100
|
* Builds a configuration schema from the values selected so far. The returned
|
|
63
101
|
* schema must set `dynamic: true`; fields that should trigger a refresh set
|
|
64
102
|
* `refreshesSchema: true`.
|
|
103
|
+
* Canvas requests set `context.purpose` to `preview`: return only the preview
|
|
104
|
+
* extension and skip editor-only lookups/validation. The host refreshes visible
|
|
105
|
+
* dynamic summaries every minute so asynchronously applied changes are reflected.
|
|
65
106
|
*/
|
|
66
|
-
resolveConfigSchema?(currentConfig: Record<string, unknown>, context:
|
|
67
|
-
resourceId: number;
|
|
68
|
-
}): Promise<Record<string, unknown>>;
|
|
107
|
+
resolveConfigSchema?(currentConfig: Record<string, unknown>, context: PluginFlowNodeSchemaContext): Promise<Record<string, unknown>>;
|
|
69
108
|
/** Handle IDs accepted as inputs (e.g. ['input']). Empty for trigger nodes. */
|
|
70
109
|
readonly inputs: readonly string[];
|
|
71
110
|
/** Handle IDs produced as outputs (e.g. ['output']). Empty for terminal nodes. */
|
|
@@ -75,6 +114,16 @@ interface PluginFlowNodeDefinitionBase {
|
|
|
75
114
|
* Defaults to true. Set false to hide it from the catalog for all resources.
|
|
76
115
|
*/
|
|
77
116
|
readonly supportedByAllResources?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* The flow scopes this node can be used in. Defaults to `['resource']`, so a node only appears in global
|
|
119
|
+
* flows once it opts in with `['resource', 'global']` (or `['global']`).
|
|
120
|
+
*
|
|
121
|
+
* In a global flow there is no fixed resource: the `resolveConfigSchema` context
|
|
122
|
+
* (`{ flowScope, resourceId, flowId, purpose? }`) has `resourceId: null`, and a run has a triggering
|
|
123
|
+
* resource only when a resource event started it. Opt in only when the node copes with that.
|
|
124
|
+
* `supportedByAllResources` filters resource flows only.
|
|
125
|
+
*/
|
|
126
|
+
readonly flowScopes?: readonly PluginFlowScope[];
|
|
78
127
|
/**
|
|
79
128
|
* Set to true for nodes that terminate a flow branch (no further chaining
|
|
80
129
|
* expected). Controls the direction indicator in the catalog UI.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Observable } from 'rxjs';
|
|
2
|
+
import type { AuthenticatedUser } from './auth.types';
|
|
3
|
+
export interface PluginLiveSubscription {
|
|
4
|
+
/** Plugin-local topic name; the host adds the plugin namespace. */
|
|
5
|
+
topic: string;
|
|
6
|
+
identifier?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PluginLiveTopic<T extends object = object> {
|
|
9
|
+
topic: string;
|
|
10
|
+
identifier: 'none' | 'required' | 'optional';
|
|
11
|
+
/** Required. Throw to reject. Runs on every subscription set/lease renewal. */
|
|
12
|
+
authorize(subscription: PluginLiveSubscription, user: AuthenticatedUser): void | Promise<void>;
|
|
13
|
+
/** Identity always comes from the authenticated session. Release sources on unsubscribe. */
|
|
14
|
+
source(subscription: PluginLiveSubscription, user: AuthenticatedUser): Observable<{
|
|
15
|
+
data: T;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
export interface PluginLiveUpdatesContext {
|
|
19
|
+
/** Register during onModuleInit. Returns an idempotent unregister function. */
|
|
20
|
+
register<T extends object>(definition: PluginLiveTopic<T>): () => void;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-live-updates.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/plugin-live-updates.ts"],"names":[],"mappings":""}
|