@xpert-ai/plugin-sdk 3.13.0 → 3.15.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/CHANGELOG.md +22 -0
- package/index.cjs.js +78 -33
- package/index.esm.js +74 -34
- package/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/src/lib/managed-queue/index.d.ts +106 -0
- package/src/lib/strategy.d.ts +3 -2
- package/src/lib/types.d.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @xpert-ai/plugin-sdk
|
|
2
2
|
|
|
3
|
+
## 3.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c1e4da2: managed queue
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [c1e4da2]
|
|
12
|
+
- @xpert-ai/contracts@3.15.1
|
|
13
|
+
|
|
14
|
+
## 3.14.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- 6f679b8: fix plugin tenant scope & human chat files types
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [6f679b8]
|
|
23
|
+
- @xpert-ai/contracts@3.15.0
|
|
24
|
+
|
|
3
25
|
## 3.13.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/index.cjs.js
CHANGED
|
@@ -91,6 +91,7 @@ var _axios__namespace = /*#__PURE__*/_interopNamespaceDefault(_axios);
|
|
|
91
91
|
const ORGANIZATION_METADATA_KEY = 'xpert:organizationId';
|
|
92
92
|
const PLUGIN_METADATA_KEY = 'xpert:pluginName';
|
|
93
93
|
const GLOBAL_ORGANIZATION_SCOPE = 'global';
|
|
94
|
+
const BUILTIN_GLOBAL_SCOPE = 'builtin:global';
|
|
94
95
|
const TENANT_GLOBAL_SCOPE_PREFIX = 'tenant:';
|
|
95
96
|
const TENANT_GLOBAL_SCOPE_SUFFIX = ':global';
|
|
96
97
|
const STRATEGY_META_KEY = 'XPERT_STRATEGY_META_KEY';
|
|
@@ -513,14 +514,14 @@ class BaseStrategyRegistry {
|
|
|
513
514
|
if (type) {
|
|
514
515
|
var _instance_metatype;
|
|
515
516
|
const target = (_instance_metatype = instance.metatype) != null ? _instance_metatype : instance.constructor;
|
|
517
|
+
const pluginName = this.reflector.get(PLUGIN_METADATA_KEY, target);
|
|
516
518
|
var _this_reflector_get;
|
|
517
|
-
const organizationId = (_this_reflector_get = this.reflector.get(ORGANIZATION_METADATA_KEY, target)) != null ? _this_reflector_get : GLOBAL_ORGANIZATION_SCOPE;
|
|
519
|
+
const organizationId = (_this_reflector_get = this.reflector.get(ORGANIZATION_METADATA_KEY, target)) != null ? _this_reflector_get : pluginName ? GLOBAL_ORGANIZATION_SCOPE : BUILTIN_GLOBAL_SCOPE;
|
|
518
520
|
var _this_strategies_get;
|
|
519
521
|
const orgMap = (_this_strategies_get = this.strategies.get(organizationId)) != null ? _this_strategies_get : new Map();
|
|
520
522
|
orgMap.set(type, instance);
|
|
521
523
|
this.strategies.set(organizationId, orgMap);
|
|
522
|
-
|
|
523
|
-
this.logger.debug(`Registered strategy of type ${type} for organization ${organizationId} from plugin ${pluginName}`);
|
|
524
|
+
this.logger.debug(`Registered strategy of type ${type} for scope ${organizationId} from plugin ${pluginName}`);
|
|
524
525
|
if (pluginName) {
|
|
525
526
|
var _this_pluginStrategies_get;
|
|
526
527
|
const pluginStrategies = (_this_pluginStrategies_get = this.pluginStrategies.get(pluginName)) != null ? _this_pluginStrategies_get : new Set();
|
|
@@ -530,7 +531,7 @@ class BaseStrategyRegistry {
|
|
|
530
531
|
}
|
|
531
532
|
}
|
|
532
533
|
/**
|
|
533
|
-
* Remove all strategies registered by the given plugin for the given
|
|
534
|
+
* Remove all strategies registered by the given plugin for the given scope.
|
|
534
535
|
*/ remove(organizationId, pluginName) {
|
|
535
536
|
const strategies = this.pluginStrategies.get(pluginName);
|
|
536
537
|
const orgMap = this.strategies.get(organizationId);
|
|
@@ -539,7 +540,7 @@ class BaseStrategyRegistry {
|
|
|
539
540
|
}
|
|
540
541
|
}
|
|
541
542
|
/**
|
|
542
|
-
* Resolve
|
|
543
|
+
* Resolve the primary scope key, falling back to request context org or tenant-global scope.
|
|
543
544
|
*/ resolveOrganization(organizationId) {
|
|
544
545
|
var _RequestContext_getScope;
|
|
545
546
|
var _RequestContext_getScope_tenantId;
|
|
@@ -553,6 +554,20 @@ class BaseStrategyRegistry {
|
|
|
553
554
|
const tenantId = (_RequestContext_getScope_tenantId = (_RequestContext_getScope = RequestContext.getScope()) == null ? void 0 : _RequestContext_getScope.tenantId) != null ? _RequestContext_getScope_tenantId : RequestContext.currentTenantId();
|
|
554
555
|
return resolveTenantGlobalScopeKey(tenantId);
|
|
555
556
|
}
|
|
557
|
+
resolveStrategyScopeKeys(organizationId) {
|
|
558
|
+
const orgKey = this.resolveOrganization(organizationId);
|
|
559
|
+
const globalKey = this.resolveGlobalFallbackOrganization();
|
|
560
|
+
const scopeKeys = [
|
|
561
|
+
orgKey
|
|
562
|
+
];
|
|
563
|
+
if (orgKey !== globalKey) {
|
|
564
|
+
scopeKeys.push(globalKey);
|
|
565
|
+
}
|
|
566
|
+
if (!scopeKeys.includes(BUILTIN_GLOBAL_SCOPE)) {
|
|
567
|
+
scopeKeys.push(BUILTIN_GLOBAL_SCOPE);
|
|
568
|
+
}
|
|
569
|
+
return scopeKeys;
|
|
570
|
+
}
|
|
556
571
|
/**
|
|
557
572
|
* Get strategy by type from the given organization including global strategies as fallback.
|
|
558
573
|
*
|
|
@@ -560,12 +575,11 @@ class BaseStrategyRegistry {
|
|
|
560
575
|
* @param organizationId
|
|
561
576
|
* @returns
|
|
562
577
|
*/ get(type, organizationId) {
|
|
563
|
-
var _this_strategies_get, _this_strategies_get1;
|
|
564
578
|
organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
579
|
+
const strategy = this.resolveStrategyScopeKeys(organizationId).map((scopeKey)=>{
|
|
580
|
+
var _this_strategies_get;
|
|
581
|
+
return (_this_strategies_get = this.strategies.get(scopeKey)) == null ? void 0 : _this_strategies_get.get(type);
|
|
582
|
+
}).find((item)=>!!item);
|
|
569
583
|
if (!strategy) {
|
|
570
584
|
throw new Error(`No strategy found for type '${type}' for strategy '${this.strategyKey}'`);
|
|
571
585
|
}
|
|
@@ -577,19 +591,12 @@ class BaseStrategyRegistry {
|
|
|
577
591
|
* @param organizationId
|
|
578
592
|
* @returns
|
|
579
593
|
*/ list(organizationId) {
|
|
580
|
-
var _this_strategies_get;
|
|
581
594
|
organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
|
|
582
|
-
const orgKey = this.resolveOrganization(organizationId);
|
|
583
|
-
const globalKey = this.resolveGlobalFallbackOrganization();
|
|
584
595
|
const effective = new Map();
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
if (orgKey !== globalKey) {
|
|
590
|
-
var _this_strategies_get1;
|
|
591
|
-
var _this_strategies_get_entries1;
|
|
592
|
-
for (const [type, strategy] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(globalKey)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
|
|
596
|
+
for (const scopeKey of this.resolveStrategyScopeKeys(organizationId)){
|
|
597
|
+
var _this_strategies_get;
|
|
598
|
+
var _this_strategies_get_entries;
|
|
599
|
+
for (const [type, strategy] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(scopeKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
|
|
593
600
|
if (!effective.has(type)) {
|
|
594
601
|
effective.set(type, strategy);
|
|
595
602
|
}
|
|
@@ -599,7 +606,7 @@ class BaseStrategyRegistry {
|
|
|
599
606
|
}
|
|
600
607
|
constructor(strategyKey, discoveryService, reflector){
|
|
601
608
|
this.logger = new common.Logger(BaseStrategyRegistry.name);
|
|
602
|
-
// Map<
|
|
609
|
+
// Map<scopeKey, Map<type, strategy>>
|
|
603
610
|
this.strategies = new Map();
|
|
604
611
|
this.pluginStrategies = new Map();
|
|
605
612
|
this.strategyKey = strategyKey;
|
|
@@ -4108,23 +4115,56 @@ function resolveSandboxTerminalAdapter(sandbox) {
|
|
|
4108
4115
|
const MANAGED_CONNECTION_REGISTRY_TOKEN = 'XPERT_MANAGED_CONNECTION_REGISTRY';
|
|
4109
4116
|
const CONNECTION_COMMAND_ROUTER_TOKEN = 'XPERT_CONNECTION_COMMAND_ROUTER';
|
|
4110
4117
|
|
|
4118
|
+
const MANAGED_QUEUE_SERVICE_TOKEN = 'XPERT_MANAGED_QUEUE_SERVICE';
|
|
4119
|
+
const MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN = 'XPERT_MANAGED_QUEUE_HANDLER_REGISTRY';
|
|
4120
|
+
const PLUGIN_JOB_PROCESSOR_METADATA = 'XPERT_PLUGIN_JOB_PROCESSOR_METADATA';
|
|
4121
|
+
function PluginJobProcessor(options) {
|
|
4122
|
+
return (target)=>{
|
|
4123
|
+
const metadata = normalizePluginJobProcessorMetadata(options);
|
|
4124
|
+
var _Reflect_getMetadata;
|
|
4125
|
+
const existing = (_Reflect_getMetadata = Reflect.getMetadata(PLUGIN_JOB_PROCESSOR_METADATA, target)) != null ? _Reflect_getMetadata : [];
|
|
4126
|
+
Reflect.defineMetadata(PLUGIN_JOB_PROCESSOR_METADATA, [
|
|
4127
|
+
metadata,
|
|
4128
|
+
...existing
|
|
4129
|
+
], target);
|
|
4130
|
+
};
|
|
4131
|
+
}
|
|
4132
|
+
function normalizePluginJobProcessorMetadata(options) {
|
|
4133
|
+
const pluginName = requireManagedQueueDecoratorValue(options.pluginName, 'pluginName');
|
|
4134
|
+
var _options_queueName;
|
|
4135
|
+
const queueName = requireManagedQueueDecoratorValue((_options_queueName = options.queueName) != null ? _options_queueName : options.queue, 'queueName');
|
|
4136
|
+
var _options_jobName;
|
|
4137
|
+
const jobName = requireManagedQueueDecoratorValue((_options_jobName = options.jobName) != null ? _options_jobName : options.jobType, 'jobName');
|
|
4138
|
+
const concurrency = options.concurrency;
|
|
4139
|
+
if (concurrency !== undefined && (!Number.isFinite(concurrency) || concurrency <= 0)) {
|
|
4140
|
+
throw new Error('PluginJobProcessor concurrency must be a positive number');
|
|
4141
|
+
}
|
|
4142
|
+
return _extends({
|
|
4143
|
+
pluginName,
|
|
4144
|
+
queueName,
|
|
4145
|
+
jobName
|
|
4146
|
+
}, concurrency === undefined ? {} : {
|
|
4147
|
+
concurrency: Math.trunc(concurrency)
|
|
4148
|
+
});
|
|
4149
|
+
}
|
|
4150
|
+
function requireManagedQueueDecoratorValue(value, field) {
|
|
4151
|
+
const normalized = `${value != null ? value : ''}`.trim();
|
|
4152
|
+
if (!normalized) {
|
|
4153
|
+
throw new Error(`PluginJobProcessor ${field} is required`);
|
|
4154
|
+
}
|
|
4155
|
+
return normalized;
|
|
4156
|
+
}
|
|
4157
|
+
|
|
4111
4158
|
const VIEW_EXTENSION_PROVIDER = 'VIEW_EXTENSION_PROVIDER';
|
|
4112
4159
|
const ViewExtensionProvider = (providerKey)=>common.applyDecorators(common.SetMetadata(VIEW_EXTENSION_PROVIDER, providerKey), common.SetMetadata(STRATEGY_META_KEY, VIEW_EXTENSION_PROVIDER));
|
|
4113
4160
|
|
|
4114
4161
|
exports.ViewExtensionProviderRegistry = class ViewExtensionProviderRegistry extends BaseStrategyRegistry {
|
|
4115
4162
|
listEntries(organizationId) {
|
|
4116
|
-
var _this_strategies_get;
|
|
4117
|
-
const orgKey = this.resolveOrganization(organizationId);
|
|
4118
|
-
const globalKey = this.resolveGlobalFallbackOrganization();
|
|
4119
4163
|
const entries = new Map();
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
if (orgKey !== globalKey) {
|
|
4125
|
-
var _this_strategies_get1;
|
|
4126
|
-
var _this_strategies_get_entries1;
|
|
4127
|
-
for (const [providerKey, provider] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(globalKey)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
|
|
4164
|
+
for (const scopeKey of this.resolveStrategyScopeKeys(organizationId)){
|
|
4165
|
+
var _this_strategies_get;
|
|
4166
|
+
var _this_strategies_get_entries;
|
|
4167
|
+
for (const [providerKey, provider] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(scopeKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
|
|
4128
4168
|
if (!entries.has(providerKey)) {
|
|
4129
4169
|
entries.set(providerKey, provider);
|
|
4130
4170
|
}
|
|
@@ -4583,6 +4623,7 @@ exports.AgentMiddlewareStrategy = AgentMiddlewareStrategy;
|
|
|
4583
4623
|
exports.AiModelNotFoundException = AiModelNotFoundException;
|
|
4584
4624
|
exports.AssistantTaskRuntimeCapability = AssistantTaskRuntimeCapability;
|
|
4585
4625
|
exports.BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN = BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN;
|
|
4626
|
+
exports.BUILTIN_GLOBAL_SCOPE = BUILTIN_GLOBAL_SCOPE;
|
|
4586
4627
|
exports.BaseHTTPQueryRunner = BaseHTTPQueryRunner;
|
|
4587
4628
|
exports.BaseQueryRunner = BaseQueryRunner;
|
|
4588
4629
|
exports.BaseSQLQueryRunner = BaseSQLQueryRunner;
|
|
@@ -4643,10 +4684,13 @@ exports.KnowledgebaseRuntimeCapability = KnowledgebaseRuntimeCapability;
|
|
|
4643
4684
|
exports.LLMUsage = LLMUsage;
|
|
4644
4685
|
exports.LargeLanguageModel = LargeLanguageModel;
|
|
4645
4686
|
exports.MANAGED_CONNECTION_REGISTRY_TOKEN = MANAGED_CONNECTION_REGISTRY_TOKEN;
|
|
4687
|
+
exports.MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN = MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN;
|
|
4688
|
+
exports.MANAGED_QUEUE_SERVICE_TOKEN = MANAGED_QUEUE_SERVICE_TOKEN;
|
|
4646
4689
|
exports.ORGANIZATION_METADATA_KEY = ORGANIZATION_METADATA_KEY;
|
|
4647
4690
|
exports.OpenAICompatibleReranker = OpenAICompatibleReranker;
|
|
4648
4691
|
exports.PERMISSION_OPERATION_METADATA_KEY = PERMISSION_OPERATION_METADATA_KEY;
|
|
4649
4692
|
exports.PLUGIN_CONFIG_RESOLVER_TOKEN = PLUGIN_CONFIG_RESOLVER_TOKEN;
|
|
4693
|
+
exports.PLUGIN_JOB_PROCESSOR_METADATA = PLUGIN_JOB_PROCESSOR_METADATA;
|
|
4650
4694
|
exports.PLUGIN_METADATA = PLUGIN_METADATA;
|
|
4651
4695
|
exports.PLUGIN_METADATA_KEY = PLUGIN_METADATA_KEY;
|
|
4652
4696
|
exports.PLUGIN_WEBHOOK_AUTH_METADATA_KEY = PLUGIN_WEBHOOK_AUTH_METADATA_KEY;
|
|
@@ -4657,6 +4701,7 @@ exports.PROVIDE_AI_MODEL_RERANK = PROVIDE_AI_MODEL_RERANK;
|
|
|
4657
4701
|
exports.PROVIDE_AI_MODEL_SPEECH2TEXT = PROVIDE_AI_MODEL_SPEECH2TEXT;
|
|
4658
4702
|
exports.PROVIDE_AI_MODEL_TEXT_EMBEDDING = PROVIDE_AI_MODEL_TEXT_EMBEDDING;
|
|
4659
4703
|
exports.PROVIDE_AI_MODEL_TTS = PROVIDE_AI_MODEL_TTS;
|
|
4704
|
+
exports.PluginJobProcessor = PluginJobProcessor;
|
|
4660
4705
|
exports.PluginWebhookAuth = PluginWebhookAuth;
|
|
4661
4706
|
exports.RETRIEVER_STRATEGY = RETRIEVER_STRATEGY;
|
|
4662
4707
|
exports.RequestContext = RequestContext;
|
package/index.esm.js
CHANGED
|
@@ -71,6 +71,7 @@ import { getModelContextSize as getModelContextSize$1 } from '@langchain/core/la
|
|
|
71
71
|
const ORGANIZATION_METADATA_KEY = 'xpert:organizationId';
|
|
72
72
|
const PLUGIN_METADATA_KEY = 'xpert:pluginName';
|
|
73
73
|
const GLOBAL_ORGANIZATION_SCOPE = 'global';
|
|
74
|
+
const BUILTIN_GLOBAL_SCOPE = 'builtin:global';
|
|
74
75
|
const TENANT_GLOBAL_SCOPE_PREFIX = 'tenant:';
|
|
75
76
|
const TENANT_GLOBAL_SCOPE_SUFFIX = ':global';
|
|
76
77
|
const STRATEGY_META_KEY = 'XPERT_STRATEGY_META_KEY';
|
|
@@ -493,14 +494,14 @@ class BaseStrategyRegistry {
|
|
|
493
494
|
if (type) {
|
|
494
495
|
var _instance_metatype;
|
|
495
496
|
const target = (_instance_metatype = instance.metatype) != null ? _instance_metatype : instance.constructor;
|
|
497
|
+
const pluginName = this.reflector.get(PLUGIN_METADATA_KEY, target);
|
|
496
498
|
var _this_reflector_get;
|
|
497
|
-
const organizationId = (_this_reflector_get = this.reflector.get(ORGANIZATION_METADATA_KEY, target)) != null ? _this_reflector_get : GLOBAL_ORGANIZATION_SCOPE;
|
|
499
|
+
const organizationId = (_this_reflector_get = this.reflector.get(ORGANIZATION_METADATA_KEY, target)) != null ? _this_reflector_get : pluginName ? GLOBAL_ORGANIZATION_SCOPE : BUILTIN_GLOBAL_SCOPE;
|
|
498
500
|
var _this_strategies_get;
|
|
499
501
|
const orgMap = (_this_strategies_get = this.strategies.get(organizationId)) != null ? _this_strategies_get : new Map();
|
|
500
502
|
orgMap.set(type, instance);
|
|
501
503
|
this.strategies.set(organizationId, orgMap);
|
|
502
|
-
|
|
503
|
-
this.logger.debug(`Registered strategy of type ${type} for organization ${organizationId} from plugin ${pluginName}`);
|
|
504
|
+
this.logger.debug(`Registered strategy of type ${type} for scope ${organizationId} from plugin ${pluginName}`);
|
|
504
505
|
if (pluginName) {
|
|
505
506
|
var _this_pluginStrategies_get;
|
|
506
507
|
const pluginStrategies = (_this_pluginStrategies_get = this.pluginStrategies.get(pluginName)) != null ? _this_pluginStrategies_get : new Set();
|
|
@@ -510,7 +511,7 @@ class BaseStrategyRegistry {
|
|
|
510
511
|
}
|
|
511
512
|
}
|
|
512
513
|
/**
|
|
513
|
-
* Remove all strategies registered by the given plugin for the given
|
|
514
|
+
* Remove all strategies registered by the given plugin for the given scope.
|
|
514
515
|
*/ remove(organizationId, pluginName) {
|
|
515
516
|
const strategies = this.pluginStrategies.get(pluginName);
|
|
516
517
|
const orgMap = this.strategies.get(organizationId);
|
|
@@ -519,7 +520,7 @@ class BaseStrategyRegistry {
|
|
|
519
520
|
}
|
|
520
521
|
}
|
|
521
522
|
/**
|
|
522
|
-
* Resolve
|
|
523
|
+
* Resolve the primary scope key, falling back to request context org or tenant-global scope.
|
|
523
524
|
*/ resolveOrganization(organizationId) {
|
|
524
525
|
var _RequestContext_getScope;
|
|
525
526
|
var _RequestContext_getScope_tenantId;
|
|
@@ -533,6 +534,20 @@ class BaseStrategyRegistry {
|
|
|
533
534
|
const tenantId = (_RequestContext_getScope_tenantId = (_RequestContext_getScope = RequestContext.getScope()) == null ? void 0 : _RequestContext_getScope.tenantId) != null ? _RequestContext_getScope_tenantId : RequestContext.currentTenantId();
|
|
534
535
|
return resolveTenantGlobalScopeKey(tenantId);
|
|
535
536
|
}
|
|
537
|
+
resolveStrategyScopeKeys(organizationId) {
|
|
538
|
+
const orgKey = this.resolveOrganization(organizationId);
|
|
539
|
+
const globalKey = this.resolveGlobalFallbackOrganization();
|
|
540
|
+
const scopeKeys = [
|
|
541
|
+
orgKey
|
|
542
|
+
];
|
|
543
|
+
if (orgKey !== globalKey) {
|
|
544
|
+
scopeKeys.push(globalKey);
|
|
545
|
+
}
|
|
546
|
+
if (!scopeKeys.includes(BUILTIN_GLOBAL_SCOPE)) {
|
|
547
|
+
scopeKeys.push(BUILTIN_GLOBAL_SCOPE);
|
|
548
|
+
}
|
|
549
|
+
return scopeKeys;
|
|
550
|
+
}
|
|
536
551
|
/**
|
|
537
552
|
* Get strategy by type from the given organization including global strategies as fallback.
|
|
538
553
|
*
|
|
@@ -540,12 +555,11 @@ class BaseStrategyRegistry {
|
|
|
540
555
|
* @param organizationId
|
|
541
556
|
* @returns
|
|
542
557
|
*/ get(type, organizationId) {
|
|
543
|
-
var _this_strategies_get, _this_strategies_get1;
|
|
544
558
|
organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
559
|
+
const strategy = this.resolveStrategyScopeKeys(organizationId).map((scopeKey)=>{
|
|
560
|
+
var _this_strategies_get;
|
|
561
|
+
return (_this_strategies_get = this.strategies.get(scopeKey)) == null ? void 0 : _this_strategies_get.get(type);
|
|
562
|
+
}).find((item)=>!!item);
|
|
549
563
|
if (!strategy) {
|
|
550
564
|
throw new Error(`No strategy found for type '${type}' for strategy '${this.strategyKey}'`);
|
|
551
565
|
}
|
|
@@ -557,19 +571,12 @@ class BaseStrategyRegistry {
|
|
|
557
571
|
* @param organizationId
|
|
558
572
|
* @returns
|
|
559
573
|
*/ list(organizationId) {
|
|
560
|
-
var _this_strategies_get;
|
|
561
574
|
organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
|
|
562
|
-
const orgKey = this.resolveOrganization(organizationId);
|
|
563
|
-
const globalKey = this.resolveGlobalFallbackOrganization();
|
|
564
575
|
const effective = new Map();
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
if (orgKey !== globalKey) {
|
|
570
|
-
var _this_strategies_get1;
|
|
571
|
-
var _this_strategies_get_entries1;
|
|
572
|
-
for (const [type, strategy] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(globalKey)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
|
|
576
|
+
for (const scopeKey of this.resolveStrategyScopeKeys(organizationId)){
|
|
577
|
+
var _this_strategies_get;
|
|
578
|
+
var _this_strategies_get_entries;
|
|
579
|
+
for (const [type, strategy] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(scopeKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
|
|
573
580
|
if (!effective.has(type)) {
|
|
574
581
|
effective.set(type, strategy);
|
|
575
582
|
}
|
|
@@ -579,7 +586,7 @@ class BaseStrategyRegistry {
|
|
|
579
586
|
}
|
|
580
587
|
constructor(strategyKey, discoveryService, reflector){
|
|
581
588
|
this.logger = new Logger(BaseStrategyRegistry.name);
|
|
582
|
-
// Map<
|
|
589
|
+
// Map<scopeKey, Map<type, strategy>>
|
|
583
590
|
this.strategies = new Map();
|
|
584
591
|
this.pluginStrategies = new Map();
|
|
585
592
|
this.strategyKey = strategyKey;
|
|
@@ -4088,23 +4095,56 @@ function resolveSandboxTerminalAdapter(sandbox) {
|
|
|
4088
4095
|
const MANAGED_CONNECTION_REGISTRY_TOKEN = 'XPERT_MANAGED_CONNECTION_REGISTRY';
|
|
4089
4096
|
const CONNECTION_COMMAND_ROUTER_TOKEN = 'XPERT_CONNECTION_COMMAND_ROUTER';
|
|
4090
4097
|
|
|
4098
|
+
const MANAGED_QUEUE_SERVICE_TOKEN = 'XPERT_MANAGED_QUEUE_SERVICE';
|
|
4099
|
+
const MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN = 'XPERT_MANAGED_QUEUE_HANDLER_REGISTRY';
|
|
4100
|
+
const PLUGIN_JOB_PROCESSOR_METADATA = 'XPERT_PLUGIN_JOB_PROCESSOR_METADATA';
|
|
4101
|
+
function PluginJobProcessor(options) {
|
|
4102
|
+
return (target)=>{
|
|
4103
|
+
const metadata = normalizePluginJobProcessorMetadata(options);
|
|
4104
|
+
var _Reflect_getMetadata;
|
|
4105
|
+
const existing = (_Reflect_getMetadata = Reflect.getMetadata(PLUGIN_JOB_PROCESSOR_METADATA, target)) != null ? _Reflect_getMetadata : [];
|
|
4106
|
+
Reflect.defineMetadata(PLUGIN_JOB_PROCESSOR_METADATA, [
|
|
4107
|
+
metadata,
|
|
4108
|
+
...existing
|
|
4109
|
+
], target);
|
|
4110
|
+
};
|
|
4111
|
+
}
|
|
4112
|
+
function normalizePluginJobProcessorMetadata(options) {
|
|
4113
|
+
const pluginName = requireManagedQueueDecoratorValue(options.pluginName, 'pluginName');
|
|
4114
|
+
var _options_queueName;
|
|
4115
|
+
const queueName = requireManagedQueueDecoratorValue((_options_queueName = options.queueName) != null ? _options_queueName : options.queue, 'queueName');
|
|
4116
|
+
var _options_jobName;
|
|
4117
|
+
const jobName = requireManagedQueueDecoratorValue((_options_jobName = options.jobName) != null ? _options_jobName : options.jobType, 'jobName');
|
|
4118
|
+
const concurrency = options.concurrency;
|
|
4119
|
+
if (concurrency !== undefined && (!Number.isFinite(concurrency) || concurrency <= 0)) {
|
|
4120
|
+
throw new Error('PluginJobProcessor concurrency must be a positive number');
|
|
4121
|
+
}
|
|
4122
|
+
return _extends({
|
|
4123
|
+
pluginName,
|
|
4124
|
+
queueName,
|
|
4125
|
+
jobName
|
|
4126
|
+
}, concurrency === undefined ? {} : {
|
|
4127
|
+
concurrency: Math.trunc(concurrency)
|
|
4128
|
+
});
|
|
4129
|
+
}
|
|
4130
|
+
function requireManagedQueueDecoratorValue(value, field) {
|
|
4131
|
+
const normalized = `${value != null ? value : ''}`.trim();
|
|
4132
|
+
if (!normalized) {
|
|
4133
|
+
throw new Error(`PluginJobProcessor ${field} is required`);
|
|
4134
|
+
}
|
|
4135
|
+
return normalized;
|
|
4136
|
+
}
|
|
4137
|
+
|
|
4091
4138
|
const VIEW_EXTENSION_PROVIDER = 'VIEW_EXTENSION_PROVIDER';
|
|
4092
4139
|
const ViewExtensionProvider = (providerKey)=>applyDecorators(SetMetadata(VIEW_EXTENSION_PROVIDER, providerKey), SetMetadata(STRATEGY_META_KEY, VIEW_EXTENSION_PROVIDER));
|
|
4093
4140
|
|
|
4094
4141
|
let ViewExtensionProviderRegistry = class ViewExtensionProviderRegistry extends BaseStrategyRegistry {
|
|
4095
4142
|
listEntries(organizationId) {
|
|
4096
|
-
var _this_strategies_get;
|
|
4097
|
-
const orgKey = this.resolveOrganization(organizationId);
|
|
4098
|
-
const globalKey = this.resolveGlobalFallbackOrganization();
|
|
4099
4143
|
const entries = new Map();
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
if (orgKey !== globalKey) {
|
|
4105
|
-
var _this_strategies_get1;
|
|
4106
|
-
var _this_strategies_get_entries1;
|
|
4107
|
-
for (const [providerKey, provider] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(globalKey)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
|
|
4144
|
+
for (const scopeKey of this.resolveStrategyScopeKeys(organizationId)){
|
|
4145
|
+
var _this_strategies_get;
|
|
4146
|
+
var _this_strategies_get_entries;
|
|
4147
|
+
for (const [providerKey, provider] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(scopeKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
|
|
4108
4148
|
if (!entries.has(providerKey)) {
|
|
4109
4149
|
entries.set(providerKey, provider);
|
|
4110
4150
|
}
|
|
@@ -4543,4 +4583,4 @@ function escapeHtmlAttribute(value) {
|
|
|
4543
4583
|
|
|
4544
4584
|
const VIEW_EXTENSION_CACHE_SERVICE_TOKEN = 'XPERT_PLUGIN_VIEW_EXTENSION_CACHE_SERVICE';
|
|
4545
4585
|
|
|
4546
|
-
export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ANALYTICS_PERMISSION_SERVICE_TOKEN, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BaseTool, BaseToolset, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, CONNECTION_COMMAND_ROUTER_TOKEN, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CommonParameterRules, CreateModelClientCommand, CredentialsValidateFailedError, DATASOURCE_STRATEGY, DBCreateTableMode, DBProtocolEnum, DBSyntaxEnum, DBTableAction, DBTableDataAction, DEFAULT_EXECUTION_CONFIG, DEFAULT_SANDBOX_EXECUTION_MAX_OUTPUT_BYTES, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_SEC, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_SEC, DEFAULT_SANDBOX_SHELL_EXECUTION_OPTIONS, DEFAULT_SANDBOX_SHELL_TIMEOUT_MS, DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC, DOCUMENT_SOURCE_STRATEGY, DOCUMENT_TRANSFORMER_STRATEGY, DataSourceStrategy, DataSourceStrategyRegistry, DefaultRuntimeCapabilityRegistry as DefaultAgentMiddlewareRuntimeCapabilityRegistry, DefaultRuntimeCapabilityRegistry, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, FILE_STORAGE_PROVIDER, FILE_UPLOAD_TARGET_STRATEGY, FileRuntimeCapability, FileStorageProvider, FileStorageProviderRegistry, FileUploadTargetRegistry, FileUploadTargetStrategy, GLOBAL_ORGANIZATION_SCOPE, HANDOFF_PERMISSION_SERVICE_TOKEN, HANDOFF_PROCESSOR_STRATEGY, HANDOFF_QUEUE_SERVICE_TOKEN, HandoffProcessorRegistry, HandoffProcessorStrategy, IMAGE_UNDERSTANDING_STRATEGY, INTEGRATION_PERMISSION_SERVICE_TOKEN, INTEGRATION_STRATEGY, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, KnowledgebaseDocumentsRuntimeCapability, KnowledgebaseRuntimeCapability, LLMUsage, LargeLanguageModel, MANAGED_CONNECTION_REGISTRY_TOKEN, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN, PROVIDE_AI_MODEL_LLM, PROVIDE_AI_MODEL_MODERATION, PROVIDE_AI_MODEL_RERANK, PROVIDE_AI_MODEL_SPEECH2TEXT, PROVIDE_AI_MODEL_TEXT_EMBEDDING, PROVIDE_AI_MODEL_TTS, PluginWebhookAuth, PluginWebhookAuthGuard, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, RetrieverRegistry, RetrieverStrategy, SANDBOX_PROVIDER, SANDBOX_SHELL_TIMEOUT_LIMITS_SEC, SKILL_SOURCE_PROVIDER, SPEECH_TO_TEXT_PERMISSION_SERVICE_TOKEN, SPEECH_TO_TEXT_SERVICE_TOKEN, SSOProviderRegistry, SSOProviderStrategyKey, SSO_BINDING_PERMISSION_SERVICE_TOKEN, SSO_PROVIDER, STRATEGY_META_KEY, SandboxProviderRegistry, SandboxProviderStrategy, SkillSourceProviderRegistry, SkillSourceProviderStrategy, Speech2TextChatModel, SpeechToTextModel, StrategyBus, TENANT_GLOBAL_SCOPE_PREFIX, TENANT_GLOBAL_SCOPE_SUFFIX, TEXT_SPLITTER_STRATEGY, TOOLSET_STRATEGY, TextEmbeddingModelManager, TextSplitterRegistry, TextSplitterStrategy, TextToSpeechModel, ToolsetRegistry, ToolsetStrategy, USER_PERMISSION_SERVICE_TOKEN, VECTOR_STORE_STRATEGY, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WorkspaceFilesRuntimeCapability, WrapWorkflowNodeExecutionCommand, XPERT_RUNTIME_CAPABILITIES_TOKEN, XpFileSystem, XpertServerPlugin, als, appendSandboxMessage, buildSandboxTimeoutMessage, calcTokenUsage, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, downloadRemoteFile, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStructuredMessageType, isTenantGlobalScopeKey, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, renderRemoteReactIframeHtml, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveTenantGlobalScopeKey, runWithRequestContext, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage };
|
|
4586
|
+
export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ANALYTICS_PERMISSION_SERVICE_TOKEN, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BaseTool, BaseToolset, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, CONNECTION_COMMAND_ROUTER_TOKEN, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CommonParameterRules, CreateModelClientCommand, CredentialsValidateFailedError, DATASOURCE_STRATEGY, DBCreateTableMode, DBProtocolEnum, DBSyntaxEnum, DBTableAction, DBTableDataAction, DEFAULT_EXECUTION_CONFIG, DEFAULT_SANDBOX_EXECUTION_MAX_OUTPUT_BYTES, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_SEC, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_SEC, DEFAULT_SANDBOX_SHELL_EXECUTION_OPTIONS, DEFAULT_SANDBOX_SHELL_TIMEOUT_MS, DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC, DOCUMENT_SOURCE_STRATEGY, DOCUMENT_TRANSFORMER_STRATEGY, DataSourceStrategy, DataSourceStrategyRegistry, DefaultRuntimeCapabilityRegistry as DefaultAgentMiddlewareRuntimeCapabilityRegistry, DefaultRuntimeCapabilityRegistry, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, FILE_STORAGE_PROVIDER, FILE_UPLOAD_TARGET_STRATEGY, FileRuntimeCapability, FileStorageProvider, FileStorageProviderRegistry, FileUploadTargetRegistry, FileUploadTargetStrategy, GLOBAL_ORGANIZATION_SCOPE, HANDOFF_PERMISSION_SERVICE_TOKEN, HANDOFF_PROCESSOR_STRATEGY, HANDOFF_QUEUE_SERVICE_TOKEN, HandoffProcessorRegistry, HandoffProcessorStrategy, IMAGE_UNDERSTANDING_STRATEGY, INTEGRATION_PERMISSION_SERVICE_TOKEN, INTEGRATION_STRATEGY, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, KnowledgebaseDocumentsRuntimeCapability, KnowledgebaseRuntimeCapability, LLMUsage, LargeLanguageModel, MANAGED_CONNECTION_REGISTRY_TOKEN, MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN, MANAGED_QUEUE_SERVICE_TOKEN, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_JOB_PROCESSOR_METADATA, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN, PROVIDE_AI_MODEL_LLM, PROVIDE_AI_MODEL_MODERATION, PROVIDE_AI_MODEL_RERANK, PROVIDE_AI_MODEL_SPEECH2TEXT, PROVIDE_AI_MODEL_TEXT_EMBEDDING, PROVIDE_AI_MODEL_TTS, PluginJobProcessor, PluginWebhookAuth, PluginWebhookAuthGuard, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, RetrieverRegistry, RetrieverStrategy, SANDBOX_PROVIDER, SANDBOX_SHELL_TIMEOUT_LIMITS_SEC, SKILL_SOURCE_PROVIDER, SPEECH_TO_TEXT_PERMISSION_SERVICE_TOKEN, SPEECH_TO_TEXT_SERVICE_TOKEN, SSOProviderRegistry, SSOProviderStrategyKey, SSO_BINDING_PERMISSION_SERVICE_TOKEN, SSO_PROVIDER, STRATEGY_META_KEY, SandboxProviderRegistry, SandboxProviderStrategy, SkillSourceProviderRegistry, SkillSourceProviderStrategy, Speech2TextChatModel, SpeechToTextModel, StrategyBus, TENANT_GLOBAL_SCOPE_PREFIX, TENANT_GLOBAL_SCOPE_SUFFIX, TEXT_SPLITTER_STRATEGY, TOOLSET_STRATEGY, TextEmbeddingModelManager, TextSplitterRegistry, TextSplitterStrategy, TextToSpeechModel, ToolsetRegistry, ToolsetStrategy, USER_PERMISSION_SERVICE_TOKEN, VECTOR_STORE_STRATEGY, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WorkspaceFilesRuntimeCapability, WrapWorkflowNodeExecutionCommand, XPERT_RUNTIME_CAPABILITIES_TOKEN, XpFileSystem, XpertServerPlugin, als, appendSandboxMessage, buildSandboxTimeoutMessage, calcTokenUsage, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, downloadRemoteFile, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStructuredMessageType, isTenantGlobalScopeKey, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, renderRemoteReactIframeHtml, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveTenantGlobalScopeKey, runWithRequestContext, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage };
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export declare const MANAGED_QUEUE_SERVICE_TOKEN = "XPERT_MANAGED_QUEUE_SERVICE";
|
|
2
|
+
export declare const MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN = "XPERT_MANAGED_QUEUE_HANDLER_REGISTRY";
|
|
3
|
+
export declare const PLUGIN_JOB_PROCESSOR_METADATA = "XPERT_PLUGIN_JOB_PROCESSOR_METADATA";
|
|
4
|
+
export type PluginJobProcessorOptions = {
|
|
5
|
+
pluginName: string;
|
|
6
|
+
queueName?: string;
|
|
7
|
+
queue?: string;
|
|
8
|
+
jobName?: string;
|
|
9
|
+
jobType?: string;
|
|
10
|
+
concurrency?: number;
|
|
11
|
+
};
|
|
12
|
+
export type PluginJobProcessorMetadata = {
|
|
13
|
+
pluginName: string;
|
|
14
|
+
queueName: string;
|
|
15
|
+
jobName: string;
|
|
16
|
+
concurrency?: number;
|
|
17
|
+
};
|
|
18
|
+
export type ManagedQueueRemoveOption = boolean | number | {
|
|
19
|
+
age?: number;
|
|
20
|
+
count?: number;
|
|
21
|
+
};
|
|
22
|
+
export type ManagedQueueBackoffInput = number | {
|
|
23
|
+
type?: 'fixed' | 'exponential';
|
|
24
|
+
delay: number;
|
|
25
|
+
};
|
|
26
|
+
export type ManagedQueueRedis = {
|
|
27
|
+
get(key: string): Promise<string | null>;
|
|
28
|
+
set(key: string, value: string, mode?: string, ttlMode?: string | number, ttlOrMode?: number | string): Promise<string | null>;
|
|
29
|
+
del(...keys: string[]): Promise<number>;
|
|
30
|
+
incr(key: string): Promise<number>;
|
|
31
|
+
expire(key: string, seconds: number): Promise<number>;
|
|
32
|
+
ttl(key: string): Promise<number>;
|
|
33
|
+
eval(script: string, numKeys: number, ...args: Array<string | number>): Promise<unknown>;
|
|
34
|
+
};
|
|
35
|
+
export type ManagedQueueEnqueueInput<TPayload = unknown> = {
|
|
36
|
+
pluginName: string;
|
|
37
|
+
queueName: string;
|
|
38
|
+
jobName: string;
|
|
39
|
+
payload: TPayload;
|
|
40
|
+
tenantId?: string | null;
|
|
41
|
+
organizationId?: string | null;
|
|
42
|
+
scopeKey?: string | null;
|
|
43
|
+
userId?: string | null;
|
|
44
|
+
jobId?: string;
|
|
45
|
+
delayMs?: number;
|
|
46
|
+
attempts?: number;
|
|
47
|
+
backoffMs?: ManagedQueueBackoffInput;
|
|
48
|
+
removeOnComplete?: ManagedQueueRemoveOption;
|
|
49
|
+
removeOnFail?: ManagedQueueRemoveOption;
|
|
50
|
+
};
|
|
51
|
+
export type ManagedQueueEnqueueResult = {
|
|
52
|
+
jobId: string;
|
|
53
|
+
};
|
|
54
|
+
export type ManagedQueueCancelInput = {
|
|
55
|
+
jobId: string;
|
|
56
|
+
};
|
|
57
|
+
export type ManagedQueueCancelResult = {
|
|
58
|
+
success: boolean;
|
|
59
|
+
jobId: string;
|
|
60
|
+
state?: string;
|
|
61
|
+
reason?: 'not_found' | 'active' | 'completed' | 'failed' | 'locked' | 'not_removable';
|
|
62
|
+
error?: string;
|
|
63
|
+
};
|
|
64
|
+
export type ManagedQueueJob<TPayload = unknown> = {
|
|
65
|
+
id?: string;
|
|
66
|
+
name: string;
|
|
67
|
+
data: TPayload;
|
|
68
|
+
attemptsMade: number;
|
|
69
|
+
opts?: Record<string, unknown>;
|
|
70
|
+
};
|
|
71
|
+
export type ManagedQueueJobContext = {
|
|
72
|
+
pluginName: string;
|
|
73
|
+
queueName: string;
|
|
74
|
+
jobName: string;
|
|
75
|
+
scopeKey?: string | null;
|
|
76
|
+
};
|
|
77
|
+
export type ManagedQueueJobSnapshot<TPayload = unknown> = ManagedQueueJob<TPayload> & {
|
|
78
|
+
state?: string;
|
|
79
|
+
timestamp?: number;
|
|
80
|
+
processedOn?: number;
|
|
81
|
+
finishedOn?: number;
|
|
82
|
+
};
|
|
83
|
+
export type ManagedQueueJobHandler<TPayload = unknown> = (job: ManagedQueueJob<TPayload>) => Promise<void> | void;
|
|
84
|
+
export interface ManagedQueueJobProcessor<TPayload = unknown> {
|
|
85
|
+
handle(job: ManagedQueueJob<TPayload>, context: ManagedQueueJobContext): Promise<void> | void;
|
|
86
|
+
}
|
|
87
|
+
export type ManagedQueueHandlerRegistration<TPayload = unknown> = {
|
|
88
|
+
pluginName: string;
|
|
89
|
+
queueName: string;
|
|
90
|
+
jobName: string;
|
|
91
|
+
scopeKey?: string | null;
|
|
92
|
+
concurrency?: number;
|
|
93
|
+
handler: ManagedQueueJobHandler<TPayload>;
|
|
94
|
+
};
|
|
95
|
+
export interface ManagedQueueHandlerRegistry {
|
|
96
|
+
register<TPayload = unknown>(registration: ManagedQueueHandlerRegistration<TPayload>): () => void;
|
|
97
|
+
}
|
|
98
|
+
export interface ManagedQueueService {
|
|
99
|
+
enqueue<TPayload = unknown>(input: ManagedQueueEnqueueInput<TPayload>): Promise<ManagedQueueEnqueueResult>;
|
|
100
|
+
cancel(input: ManagedQueueCancelInput): Promise<ManagedQueueCancelResult>;
|
|
101
|
+
getJob<TPayload = unknown>(input: {
|
|
102
|
+
jobId: string;
|
|
103
|
+
}): Promise<ManagedQueueJobSnapshot<TPayload> | null>;
|
|
104
|
+
getRedis(): Promise<ManagedQueueRedis>;
|
|
105
|
+
}
|
|
106
|
+
export declare function PluginJobProcessor(options: PluginJobProcessorOptions): ClassDecorator;
|
package/src/lib/strategy.d.ts
CHANGED
|
@@ -13,14 +13,15 @@ export declare class BaseStrategyRegistry<S> implements OnModuleInit {
|
|
|
13
13
|
onModuleInit(): void;
|
|
14
14
|
upsert(instance: any): void;
|
|
15
15
|
/**
|
|
16
|
-
* Remove all strategies registered by the given plugin for the given
|
|
16
|
+
* Remove all strategies registered by the given plugin for the given scope.
|
|
17
17
|
*/
|
|
18
18
|
remove(organizationId: string, pluginName: string): void;
|
|
19
19
|
/**
|
|
20
|
-
* Resolve
|
|
20
|
+
* Resolve the primary scope key, falling back to request context org or tenant-global scope.
|
|
21
21
|
*/
|
|
22
22
|
protected resolveOrganization(organizationId?: string): string;
|
|
23
23
|
protected resolveGlobalFallbackOrganization(): string;
|
|
24
|
+
protected resolveStrategyScopeKeys(organizationId?: string): string[];
|
|
24
25
|
/**
|
|
25
26
|
* Get strategy by type from the given organization including global strategies as fallback.
|
|
26
27
|
*
|
package/src/lib/types.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { Permissions } from './core/permissions';
|
|
|
6
6
|
export declare const ORGANIZATION_METADATA_KEY = "xpert:organizationId";
|
|
7
7
|
export declare const PLUGIN_METADATA_KEY = "xpert:pluginName";
|
|
8
8
|
export declare const GLOBAL_ORGANIZATION_SCOPE = "global";
|
|
9
|
+
export declare const BUILTIN_GLOBAL_SCOPE = "builtin:global";
|
|
9
10
|
export declare const TENANT_GLOBAL_SCOPE_PREFIX = "tenant:";
|
|
10
11
|
export declare const TENANT_GLOBAL_SCOPE_SUFFIX = ":global";
|
|
11
12
|
export declare const STRATEGY_META_KEY = "XPERT_STRATEGY_META_KEY";
|
|
@@ -86,6 +87,9 @@ export interface PluginContext<TConfig extends object = any> {
|
|
|
86
87
|
app?: INestApplicationContext;
|
|
87
88
|
logger: PluginLogger;
|
|
88
89
|
config: TConfig;
|
|
90
|
+
tenantId?: string | null;
|
|
91
|
+
organizationId?: string | null;
|
|
92
|
+
scopeKey?: string | null;
|
|
89
93
|
/** Helper method to access other Providers in the container */
|
|
90
94
|
resolve<TInput = any, TResult = TInput>(token: any): TResult;
|
|
91
95
|
}
|