javonet-nodejs-sdk 2.6.13 → 2.6.15

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 (100) hide show
  1. package/dist/core/handler/ArraySetItemHandler.cjs +9 -8
  2. package/dist/core/handler/AsDtoHandler.cjs +36 -0
  3. package/dist/core/handler/AsKwargsHandler.cjs +1 -1
  4. package/dist/core/handler/DtoPropertyHandler.cjs +36 -0
  5. package/dist/core/handler/Handler.cjs +14 -9
  6. package/dist/core/handler/PassDelegateHandler.cjs +1 -1
  7. package/dist/core/handler/ProjectResultAsDtoHandler.cjs +66 -0
  8. package/dist/core/handler/SetInstanceFieldHandler.cjs +1 -1
  9. package/dist/core/handler/SetStaticFieldHandler.cjs +6 -6
  10. package/dist/core/interpreter/Interpreter.cjs +14 -2
  11. package/dist/core/protocol/CommandDeserializer.cjs +8 -0
  12. package/dist/core/protocol/TypeDeserializer.cjs +4 -0
  13. package/dist/core/protocol/TypeSerializer.cjs +10 -5
  14. package/dist/core/webSocketClient/WebSocketClient.cjs +23 -5
  15. package/dist/core/webSocketClient/WebSocketClientBrowser.cjs +23 -5
  16. package/dist/plugins/PluginImplementationRegistry.cjs +214 -0
  17. package/dist/plugins/PluginPayloadBuilder.cjs +76 -0
  18. package/dist/plugins/PluginRegistry.cjs +255 -0
  19. package/dist/plugins/index.cjs +51 -0
  20. package/dist/plugins/interfaces/ICommunityPlugin.cjs +44 -0
  21. package/dist/plugins/interfaces/ICommunityReceivingPlugin.cjs +62 -0
  22. package/dist/plugins/interfaces/ICommunitySendingPlugin.cjs +59 -0
  23. package/dist/plugins/settings/BasePluginSettings.cjs +67 -0
  24. package/dist/plugins/settings/JwtGraftocodePluginSettings.cjs +40 -0
  25. package/dist/sdk/InvocationContext.cjs +133 -12
  26. package/dist/sdk/RuntimeContext.cjs +27 -9
  27. package/dist/sdk/configuration/configResolvers/ConfigResolver.cjs +7 -6
  28. package/dist/sdk/configuration/configResolvers/ConnectionStringConfigResolver.cjs +2 -2
  29. package/dist/sdk/configuration/configResolvers/JsonConfigResolver.cjs +2 -2
  30. package/dist/sdk/configuration/configResolvers/YamlConfigResolver.cjs +3 -3
  31. package/dist/sdk/tools/DtoHelper.cjs +100 -0
  32. package/dist/types/core/handler/ArraySetItemHandler.d.ts +1 -1
  33. package/dist/types/core/handler/AsDtoHandler.d.ts +7 -0
  34. package/dist/types/core/handler/AsKwargsHandler.d.ts +1 -1
  35. package/dist/types/core/handler/DtoPropertyHandler.d.ts +7 -0
  36. package/dist/types/core/handler/ProjectResultAsDtoHandler.d.ts +9 -0
  37. package/dist/types/core/handler/SetInstanceFieldHandler.d.ts +1 -1
  38. package/dist/types/core/handler/SetStaticFieldHandler.d.ts +1 -1
  39. package/dist/types/core/interpreter/Interpreter.d.ts +3 -3
  40. package/dist/types/core/protocol/CommandDeserializer.d.ts +1 -0
  41. package/dist/types/core/protocol/TypeDeserializer.d.ts +1 -0
  42. package/dist/types/core/protocol/TypeSerializer.d.ts +1 -0
  43. package/dist/types/plugins/PluginImplementationRegistry.d.ts +121 -0
  44. package/dist/types/plugins/PluginPayloadBuilder.d.ts +32 -0
  45. package/dist/types/plugins/PluginRegistry.d.ts +157 -0
  46. package/dist/types/plugins/index.d.ts +8 -0
  47. package/dist/types/plugins/interfaces/ICommunityPlugin.d.ts +14 -0
  48. package/dist/types/plugins/interfaces/ICommunityReceivingPlugin.d.ts +50 -0
  49. package/dist/types/plugins/interfaces/ICommunitySendingPlugin.d.ts +27 -0
  50. package/dist/types/plugins/settings/BasePluginSettings.d.ts +45 -0
  51. package/dist/types/plugins/settings/JwtGraftocodePluginSettings.d.ts +32 -0
  52. package/dist/types/sdk/InvocationContext.d.ts +20 -2
  53. package/dist/types/sdk/RuntimeContext.d.ts +6 -0
  54. package/dist/types/sdk/configuration/configResolvers/ConfigResolver.d.ts +3 -6
  55. package/dist/types/sdk/configuration/configResolvers/YamlConfigResolver.d.ts +2 -1
  56. package/dist/types/sdk/tools/DtoHelper.d.ts +35 -0
  57. package/dist/types/utils/Command.d.ts +5 -0
  58. package/dist/types/utils/CommandType.d.ts +3 -0
  59. package/dist/types/utils/Type.d.ts +2 -1
  60. package/dist/utils/Command.cjs +40 -0
  61. package/dist/utils/CommandType.cjs +4 -1
  62. package/dist/utils/Type.cjs +2 -1
  63. package/lib/core/handler/ArraySetItemHandler.js +11 -10
  64. package/lib/core/handler/AsDtoHandler.js +11 -0
  65. package/lib/core/handler/AsKwargsHandler.js +1 -1
  66. package/lib/core/handler/DtoPropertyHandler.js +11 -0
  67. package/lib/core/handler/Handler.js +16 -7
  68. package/lib/core/handler/PassDelegateHandler.js +2 -1
  69. package/lib/core/handler/ProjectResultAsDtoHandler.js +47 -0
  70. package/lib/core/handler/SetInstanceFieldHandler.js +1 -1
  71. package/lib/core/handler/SetStaticFieldHandler.js +6 -6
  72. package/lib/core/interpreter/Interpreter.js +18 -4
  73. package/lib/core/protocol/CommandDeserializer.js +9 -0
  74. package/lib/core/protocol/TypeDeserializer.js +5 -0
  75. package/lib/core/protocol/TypeSerializer.js +11 -8
  76. package/lib/core/webSocketClient/WebSocketClient.js +30 -5
  77. package/lib/core/webSocketClient/WebSocketClientBrowser.js +29 -5
  78. package/lib/plugins/PluginImplementationRegistry.js +231 -0
  79. package/lib/plugins/PluginPayloadBuilder.js +60 -0
  80. package/lib/plugins/PluginRegistry.js +295 -0
  81. package/lib/plugins/index.js +29 -0
  82. package/lib/plugins/interfaces/ICommunityPlugin.js +25 -0
  83. package/lib/plugins/interfaces/ICommunityReceivingPlugin.js +57 -0
  84. package/lib/plugins/interfaces/ICommunitySendingPlugin.js +42 -0
  85. package/lib/plugins/settings/BasePluginSettings.js +79 -0
  86. package/lib/plugins/settings/JwtGraftocodePluginSettings.js +43 -0
  87. package/lib/sdk/InvocationContext.js +149 -14
  88. package/lib/sdk/RuntimeContext.js +33 -9
  89. package/lib/sdk/configuration/configResolvers/ConfigResolver.js +14 -8
  90. package/lib/sdk/configuration/configResolvers/ConnectionStringConfigResolver.js +2 -2
  91. package/lib/sdk/configuration/configResolvers/JsonConfigResolver.js +2 -2
  92. package/lib/sdk/configuration/configResolvers/YamlConfigResolver.js +5 -5
  93. package/lib/sdk/tools/DtoHelper.js +90 -0
  94. package/lib/utils/Command.js +47 -0
  95. package/lib/utils/CommandType.js +3 -0
  96. package/lib/utils/Type.js +2 -1
  97. package/package.json +5 -1
  98. package/dist/sdk/tools/ActivationHelper.cjs +0 -66
  99. package/dist/types/sdk/tools/ActivationHelper.d.ts +0 -20
  100. package/lib/sdk/tools/ActivationHelper.js +0 -51
@@ -0,0 +1,295 @@
1
+ /**
2
+ * A thread-safe registry for managing plugins.
3
+ * Provides access to registered plugin instances and their typed variants,
4
+ * allowing for dynamic plugin resolution at runtime.
5
+ *
6
+ * Note: JavaScript is single-threaded (event loop), so thread-safety considerations
7
+ * from the .NET implementation are not needed here. However, the freeze pattern
8
+ * is still used to prevent modifications after the registration phase.
9
+ */
10
+ export class PluginRegistry {
11
+ // Private static fields (ES2022 private fields)
12
+
13
+ /** @type {Map<string, object>} Map of runtime context IDs to sending plugin instances */
14
+ static #sendingPlugins = new Map()
15
+
16
+ /** @type {Map<string, object> | null} Immutable snapshot of sending plugins after freeze */
17
+ static #sendingSnapshot = null
18
+
19
+ /** @type {SendingPluginCacheEntry | null} Hot cache for last accessed plugin */
20
+ static #sendingCache = null
21
+
22
+ /** @type {object | null} The receiving plugin instance */
23
+ static #receivingPlugin = null
24
+
25
+ /** @type {Function | null} The receiving plugin constructor/class */
26
+ static #receivingPluginType = null
27
+
28
+ /** @type {string[] | null} Array of registered runtime context IDs for fast lookup */
29
+ static #registeredKeys = null
30
+
31
+ /** @type {boolean} Whether to create new plugin instances on each resolve */
32
+ static #useTransientPlugins = false
33
+
34
+ /** @type {boolean} Whether the registry has been frozen */
35
+ static #isFrozen = false
36
+
37
+ /**
38
+ * Checks if a receiving plugin has been registered
39
+ * @returns {boolean} True if a receiving plugin exists
40
+ */
41
+ static get hasReceivingPlugin() {
42
+ return PluginRegistry.#receivingPlugin !== null
43
+ }
44
+
45
+ /**
46
+ * Registers a sending plugin implementation for a specific runtime context.
47
+ * The plugin is stored as a singleton instance and can later be resolved using the runtime context ID.
48
+ *
49
+ * @param {string} runtimeContextId - The UUID of the runtime context
50
+ * @param {object} plugin - Plugin instance that implements ICommunitySendingPlugin interface
51
+ * @throws {Error} If registry is already frozen
52
+ * @throws {TypeError} If plugin doesn't have required execute method
53
+ *
54
+ * @example
55
+ * const plugin = new JwtPlugin('token123')
56
+ * PluginRegistry.registerSendingPlugin(runtimeCtx.runtimeContextId, plugin)
57
+ */
58
+ static registerSendingPlugin(runtimeContextId, plugin) {
59
+ if (PluginRegistry.#isFrozen) {
60
+ throw new Error('Cannot register plugins after registry has been frozen. Call reset() first.')
61
+ }
62
+
63
+ if (!plugin || typeof plugin.execute !== 'function') {
64
+ throw new TypeError('Plugin must have an execute() method')
65
+ }
66
+
67
+ if (!plugin.pluginId) {
68
+ throw new TypeError('Plugin must have a pluginId property')
69
+ }
70
+
71
+ if (!runtimeContextId || typeof runtimeContextId !== 'string') {
72
+ throw new TypeError('runtimeContextId must be a non-empty string')
73
+ }
74
+
75
+ PluginRegistry.#sendingPlugins.set(runtimeContextId, plugin)
76
+
77
+ // Update cache with the newly registered plugin
78
+ PluginRegistry.#sendingCache = {
79
+ key: runtimeContextId,
80
+ value: plugin,
81
+ hasValue: true,
82
+ type: plugin.constructor
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Registers a receiving plugin implementation.
88
+ * The plugin is stored as a singleton instance and executed on the receiving side.
89
+ * Only one receiving plugin can be registered per application.
90
+ *
91
+ * @param {object} plugin - Plugin instance that implements ICommunityReceivingPlugin interface
92
+ * @throws {Error} If a receiving plugin is already registered
93
+ * @throws {Error} If registry is already frozen
94
+ * @throws {TypeError} If plugin doesn't have required execute method
95
+ *
96
+ * @example
97
+ * const plugin = new ValidationPlugin()
98
+ * PluginRegistry.registerReceivingPlugin(plugin)
99
+ */
100
+ static registerReceivingPlugin(plugin) {
101
+ if (PluginRegistry.#isFrozen) {
102
+ throw new Error('Cannot register plugins after registry has been frozen. Call reset() first.')
103
+ }
104
+
105
+ if (PluginRegistry.#receivingPlugin !== null) {
106
+ throw new Error('A receiving plugin is already registered. Only one receiving plugin is allowed.')
107
+ }
108
+
109
+ if (!plugin || typeof plugin.execute !== 'function') {
110
+ throw new TypeError('Plugin must have an execute(commandPayload, executionTarget) method')
111
+ }
112
+
113
+ if (!plugin.pluginId) {
114
+ throw new TypeError('Plugin must have a pluginId property')
115
+ }
116
+
117
+ PluginRegistry.#receivingPlugin = plugin
118
+ PluginRegistry.#receivingPluginType = plugin.constructor
119
+ }
120
+
121
+ /**
122
+ * Resolves and returns the registered receiving plugin instance.
123
+ * If transient mode is enabled, creates a new instance.
124
+ *
125
+ * @returns {object} The receiving plugin instance
126
+ * @throws {Error} If no receiving plugin has been registered
127
+ *
128
+ * @example
129
+ * const plugin = PluginRegistry.resolveReceivingPlugin()
130
+ * const result = plugin.execute(payload, target)
131
+ */
132
+ static resolveReceivingPlugin() {
133
+ if (PluginRegistry.#useTransientPlugins && PluginRegistry.#receivingPluginType) {
134
+ return new PluginRegistry.#receivingPluginType()
135
+ }
136
+
137
+ if (PluginRegistry.#receivingPlugin === null) {
138
+ throw new Error('No receiving plugin has been registered')
139
+ }
140
+
141
+ return PluginRegistry.#receivingPlugin
142
+ }
143
+
144
+ /**
145
+ * Attempts to retrieve a sending plugin registered for the specified runtime context.
146
+ * First checks a single-entry hot cache for the last accessed plugin,
147
+ * and if not found, falls back to the map of registered plugins.
148
+ * On a successful map lookup, the cache is updated with the resolved entry
149
+ * for faster access in subsequent calls.
150
+ *
151
+ * @param {string} runtimeContextId - The identifier of the runtime context
152
+ * @returns {{success: boolean, plugin: object | null}} Object with success flag and plugin instance
153
+ *
154
+ * @example
155
+ * const result = PluginRegistry.tryGetSendingPlugin(runtimeContextId)
156
+ * if (result.success) {
157
+ * const payload = result.plugin.execute()
158
+ * }
159
+ */
160
+ static tryGetSendingPlugin(runtimeContextId) {
161
+ const localCache = PluginRegistry.#sendingCache
162
+
163
+ // If using transient plugins, create a new instance
164
+ if (PluginRegistry.#useTransientPlugins && localCache && localCache.hasValue && localCache.key === runtimeContextId) {
165
+ return {
166
+ success: true,
167
+ plugin: new localCache.type()
168
+ }
169
+ }
170
+
171
+ // Check hot cache first
172
+ if (localCache && localCache.hasValue && localCache.key === runtimeContextId) {
173
+ return {
174
+ success: true,
175
+ plugin: localCache.value
176
+ }
177
+ }
178
+
179
+ // Fall back to snapshot/map
180
+ const snapshot = PluginRegistry.#sendingSnapshot
181
+ if (snapshot && snapshot.has(runtimeContextId)) {
182
+ const plugin = snapshot.get(runtimeContextId)
183
+
184
+ // Update cache for next access
185
+ PluginRegistry.#sendingCache = {
186
+ key: runtimeContextId,
187
+ value: plugin,
188
+ hasValue: true,
189
+ type: plugin.constructor
190
+ }
191
+
192
+ return {
193
+ success: true,
194
+ plugin: plugin
195
+ }
196
+ }
197
+
198
+ return {
199
+ success: false,
200
+ plugin: null
201
+ }
202
+ }
203
+
204
+ /**
205
+ * Checks whether any plugins have been registered for given RuntimeContext ID.
206
+ *
207
+ * @param {string} runtimeContextId - The identifier of the runtime context
208
+ * @returns {boolean} True if at least one plugin is registered for the runtime context
209
+ *
210
+ * @example
211
+ * if (PluginRegistry.arePluginsRegisteredForRuntime(runtimeContextId)) {
212
+ * // Build and wrap command with plugin payload
213
+ * }
214
+ */
215
+ static arePluginsRegisteredForRuntime(runtimeContextId) {
216
+ const keys = PluginRegistry.#registeredKeys
217
+
218
+ if (!keys || keys.length === 0) {
219
+ return false
220
+ }
221
+
222
+ // Fast array lookup
223
+ return keys.includes(runtimeContextId)
224
+ }
225
+
226
+ /**
227
+ * Finalizes the plugin registration phase by creating a compact snapshot of all registered keys.
228
+ * This snapshot is stored to allow extremely fast lookups on the hot path.
229
+ * After calling freeze(), no more plugins can be registered unless reset() is called.
230
+ *
231
+ * @param {boolean} useTransientPlugins - If true, creates new plugin instances on each resolve
232
+ *
233
+ * @example
234
+ * // Register all plugins
235
+ * PluginRegistry.registerSendingPlugin(rtmCtx.runtimeContextId, plugin1)
236
+ * PluginRegistry.registerSendingPlugin(rtmCtx2.runtimeContextId, plugin2)
237
+ *
238
+ * // Freeze the registry
239
+ * PluginRegistry.freeze()
240
+ *
241
+ * // Or freeze with transient mode
242
+ * PluginRegistry.freeze(true)
243
+ */
244
+ static freeze(useTransientPlugins = false) {
245
+ PluginRegistry.#useTransientPlugins = useTransientPlugins
246
+
247
+ // Create array of registered keys for fast lookup
248
+ PluginRegistry.#registeredKeys = Array.from(PluginRegistry.#sendingPlugins.keys())
249
+
250
+ // Create immutable snapshot
251
+ PluginRegistry.#sendingSnapshot = new Map(PluginRegistry.#sendingPlugins)
252
+
253
+ // Clear the mutable map to prevent accidental modifications
254
+ PluginRegistry.#sendingPlugins.clear()
255
+
256
+ // Mark as frozen
257
+ PluginRegistry.#isFrozen = true
258
+ }
259
+
260
+ /**
261
+ * Resets the entire plugin registry to its initial state.
262
+ * Clears all registered plugins and unfreezes the registry.
263
+ * Useful for testing or reconfiguration scenarios.
264
+ *
265
+ * @example
266
+ * PluginRegistry.reset()
267
+ * // Can now register new plugins
268
+ */
269
+ static reset() {
270
+ PluginRegistry.#sendingPlugins.clear()
271
+ PluginRegistry.#sendingSnapshot = null
272
+ PluginRegistry.#sendingCache = null
273
+ PluginRegistry.#receivingPlugin = null
274
+ PluginRegistry.#receivingPluginType = null
275
+ PluginRegistry.#registeredKeys = null
276
+ PluginRegistry.#useTransientPlugins = false
277
+ PluginRegistry.#isFrozen = false
278
+ }
279
+
280
+ /**
281
+ * Checks if the registry has been frozen
282
+ * @returns {boolean} True if the registry is frozen
283
+ */
284
+ static get isFrozen() {
285
+ return PluginRegistry.#isFrozen
286
+ }
287
+ }
288
+
289
+ /**
290
+ * @typedef {Object} SendingPluginCacheEntry
291
+ * @property {string} key - The runtime context ID
292
+ * @property {object} value - The plugin instance
293
+ * @property {boolean} hasValue - Whether the entry has a value
294
+ * @property {Function} type - The plugin constructor/class
295
+ */
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Javonet Plugin System
3
+ *
4
+ * This module exports all plugin-related classes and interfaces for easy importing.
5
+ *
6
+ * @example
7
+ * import { PluginRegistry, ICommunitySendingPlugin } from 'javonet-nodejs-sdk/plugins'
8
+ *
9
+ * @module plugins
10
+ */
11
+
12
+ // Plugin Registry
13
+ export { PluginRegistry } from './PluginRegistry.js'
14
+
15
+ // Plugin Payload Builder
16
+ export { PluginPayloadBuilder } from './PluginPayloadBuilder.js'
17
+
18
+ // Plugin Interfaces
19
+ export { ICommunityPlugin } from './interfaces/ICommunityPlugin.js'
20
+ export { ICommunitySendingPlugin } from './interfaces/ICommunitySendingPlugin.js'
21
+ export { ICommunityReceivingPlugin } from './interfaces/ICommunityReceivingPlugin.js'
22
+
23
+
24
+ // Plugin Implementation Registry
25
+ export { PluginImplementationRegistry } from './PluginImplementationRegistry.js'
26
+
27
+ // Plugin Settings
28
+ export { BasePluginSettings, PluginLangType } from './settings/BasePluginSettings.js'
29
+ export { JwtGraftocodePluginSettings } from './settings/JwtGraftocodePluginSettings.js'
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Represents a plugin that can be registered, configured, and executed within the system.
3
+ * This is the base interface that all plugins must implement.
4
+ *
5
+ * @interface ICommunityPlugin
6
+ */
7
+ export class ICommunityPlugin {
8
+ /**
9
+ * Unique identifier for the plugin.
10
+ * This should be a string that uniquely identifies the plugin across the system.
11
+ * @type {string}
12
+ */
13
+ pluginId
14
+
15
+ /**
16
+ * Creates an instance of ICommunityPlugin
17
+ * This is a base class and should not be instantiated directly.
18
+ */
19
+ constructor() {
20
+ if (new.target === ICommunityPlugin) {
21
+ throw new TypeError('Cannot construct ICommunityPlugin instances directly')
22
+ }
23
+ }
24
+ }
25
+
@@ -0,0 +1,57 @@
1
+ import { ICommunityPlugin } from './ICommunityPlugin.js'
2
+
3
+ /**
4
+ * Represents a receiving plugin that executes after commands are received from the target runtime.
5
+ * Receiving plugins can validate responses, decrypt data, or perform audit logging.
6
+ *
7
+ * @interface ICommunityReceivingPlugin
8
+ * @extends {ICommunityPlugin}
9
+ */
10
+ export class ICommunityReceivingPlugin extends ICommunityPlugin {
11
+ /**
12
+ * Creates an instance of ICommunityReceivingPlugin
13
+ * This is a base class and should not be instantiated directly.
14
+ */
15
+ constructor() {
16
+ super()
17
+ if (new.target === ICommunityReceivingPlugin) {
18
+ throw new TypeError('Cannot construct ICommunityReceivingPlugin instances directly')
19
+ }
20
+ }
21
+
22
+ /**
23
+ * Executes the plugin using the provided payload as input.
24
+ * This method is called after receiving commands from the target runtime.
25
+ *
26
+ * @abstract
27
+ * @param {object} commandPayload - The input payload used during execution.
28
+ * @param {ExecutionTarget} executionTarget - Defines the execution target, including the target type name
29
+ * and the method name that will be invoked just before execution.
30
+ * @returns {IExecutionContext} An execution context representing the execution result.
31
+ * @throws {Error} If not implemented by derived class
32
+ *
33
+ * @example
34
+ * class ValidationPlugin extends ICommunityReceivingPlugin {
35
+ * execute(commandPayload, executionTarget) {
36
+ * console.log('Validating:', executionTarget)
37
+ * return { isValid: true, result: commandPayload }
38
+ * }
39
+ * }
40
+ */
41
+ execute(commandPayload, executionTarget) {
42
+ throw new Error('Method execute(commandPayload, executionTarget) must be implemented by derived class')
43
+ }
44
+ }
45
+
46
+ /**
47
+ * @typedef {Object} ExecutionTarget
48
+ * @property {string} typeName - The name of the target type
49
+ * @property {string} methodName - The name of the method being invoked
50
+ */
51
+
52
+ /**
53
+ * @typedef {Object} IExecutionContext
54
+ * @property {boolean} isValid - Indicates if the execution was valid
55
+ * @property {*} result - The result of the execution
56
+ */
57
+
@@ -0,0 +1,42 @@
1
+ import { ICommunityPlugin } from './ICommunityPlugin.js'
2
+
3
+ /**
4
+ * Represents a sending plugin that executes before commands are sent to the target runtime.
5
+ * Sending plugins can add authentication tokens, modify payloads, or inject custom data.
6
+ *
7
+ * @interface ICommunitySendingPlugin
8
+ * @extends {ICommunityPlugin}
9
+ */
10
+ export class ICommunitySendingPlugin extends ICommunityPlugin {
11
+ /**
12
+ * Creates an instance of ICommunitySendingPlugin
13
+ * This is a base class and should not be instantiated directly.
14
+ */
15
+ constructor() {
16
+ super()
17
+ if (new.target === ICommunitySendingPlugin) {
18
+ throw new TypeError('Cannot construct ICommunitySendingPlugin instances directly')
19
+ }
20
+ }
21
+
22
+ /**
23
+ * Executes the plugin and returns the result.
24
+ * This method is called before sending commands to the target runtime.
25
+ * The returned object will be serialized and included in the command payload.
26
+ *
27
+ * @abstract
28
+ * @returns {object} The result of plugin execution as an object.
29
+ * @throws {Error} If not implemented by derived class
30
+ *
31
+ * @example
32
+ * class JwtPlugin extends ICommunitySendingPlugin {
33
+ * execute() {
34
+ * return { token: 'abc123', timestamp: Date.now() }
35
+ * }
36
+ * }
37
+ */
38
+ execute() {
39
+ throw new Error('Method execute() must be implemented by derived class')
40
+ }
41
+ }
42
+
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Represents the base configuration model shared by all plugins.
3
+ * This class contains common metadata such as plugin ID, path, and language type.
4
+ *
5
+ * @abstract
6
+ * @class BasePluginSettings
7
+ */
8
+ export class BasePluginSettings {
9
+ /**
10
+ * Creates an instance of BasePluginSettings.
11
+ * This is a base class and should not be instantiated directly.
12
+ */
13
+ constructor() {
14
+ if (new.target === BasePluginSettings) {
15
+ throw new TypeError('Cannot construct BasePluginSettings instances directly')
16
+ }
17
+
18
+ /**
19
+ * A unique identifier assigned by the developer using a predefined plugin.
20
+ * Used to reference or distinguish plugin instances during registration or execution.
21
+ * @type {string}
22
+ */
23
+ this.pluginId = ''
24
+
25
+ /**
26
+ * The file system path to the plugin code.
27
+ * This may point to a DLL (for .NET) or other file (for external languages).
28
+ * Should remain empty if the plugin is executed directly from a referenced package.
29
+ * @type {string}
30
+ */
31
+ this.pluginPath = ''
32
+
33
+ /**
34
+ * Defines the language or technology in which the plugin is implemented.
35
+ * Used to determine how the plugin should be loaded or invoked.
36
+ * @type {PluginLangType}
37
+ */
38
+ this.pluginLangType = null
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Specifies the programming language or runtime environment used to implement a plugin.
44
+ * @enum {number}
45
+ */
46
+ export const PluginLangType = {
47
+ /** .NET Framework (legacy) implementation */
48
+ Clr: 0,
49
+
50
+ /** Go implementation */
51
+ Go: 1,
52
+
53
+ /** Java class or JAR-based plugin */
54
+ Jvm: 2,
55
+
56
+ /** .NET Core / .NET 5+ implementation */
57
+ Netcore: 3,
58
+
59
+ /** Perl script or module */
60
+ Perl: 4,
61
+
62
+ /** Python script or module */
63
+ Python: 5,
64
+
65
+ /** Ruby script or library */
66
+ Ruby: 6,
67
+
68
+ /** Node.js JavaScript module */
69
+ Nodejs: 7,
70
+
71
+ /** C++ script or class-based plugin */
72
+ Cpp: 8,
73
+
74
+ /** PHP script or class-based plugin */
75
+ Php: 9,
76
+
77
+ /** Python 2.7 script or class-based plugin */
78
+ Python27: 10
79
+ }
@@ -0,0 +1,43 @@
1
+ import { BasePluginSettings } from './BasePluginSettings.js'
2
+
3
+ /**
4
+ * Represents configuration settings specific to JWT plugins,
5
+ * including user identity and authorization logic class information.
6
+ * Inherits shared properties from BasePluginSettings.
7
+ *
8
+ * @class JwtGraftocodePluginSettings
9
+ * @extends {BasePluginSettings}
10
+ */
11
+ export class JwtGraftocodePluginSettings extends BasePluginSettings {
12
+ /**
13
+ * Creates an instance of JwtGraftocodePluginSettings.
14
+ */
15
+ constructor() {
16
+ super()
17
+
18
+ /**
19
+ * Username for JWT token generation.
20
+ * @type {string}
21
+ */
22
+ this.username = ''
23
+
24
+ /**
25
+ * Secret key used for JWT token signing and validation.
26
+ * @type {string}
27
+ */
28
+ this.secretKey = ''
29
+
30
+ /**
31
+ * Whether to use attributes for authorization checks.
32
+ * @type {boolean}
33
+ */
34
+ this.useAttributes = false
35
+
36
+ /**
37
+ * JWT authorization class implementation.
38
+ * In Node.js, this is typically a class constructor/function rather than a Type.
39
+ * @type {Function | null}
40
+ */
41
+ this.jwtAuthorizeClass = null
42
+ }
43
+ }