@bernierllc/email-manager 0.12.1 → 0.12.2
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 +12 -12
- package/dist/capabilities/degradation-logger.d.ts +0 -59
- package/dist/capabilities/degradation-logger.d.ts.map +0 -1
- package/dist/capabilities/degradation-logger.js +0 -106
- package/dist/capabilities/degradation-logger.js.map +0 -1
- package/dist/capabilities/feature-router.d.ts +0 -55
- package/dist/capabilities/feature-router.d.ts.map +0 -1
- package/dist/capabilities/feature-router.js +0 -143
- package/dist/capabilities/feature-router.js.map +0 -1
- package/dist/capabilities/in-memory-resolver.d.ts +0 -27
- package/dist/capabilities/in-memory-resolver.d.ts.map +0 -1
- package/dist/capabilities/in-memory-resolver.js +0 -79
- package/dist/capabilities/in-memory-resolver.js.map +0 -1
- package/dist/capabilities/index.d.ts +0 -13
- package/dist/capabilities/index.d.ts.map +0 -1
- package/dist/capabilities/index.js +0 -21
- package/dist/capabilities/index.js.map +0 -1
- package/dist/capabilities/matrix.d.ts +0 -67
- package/dist/capabilities/matrix.d.ts.map +0 -1
- package/dist/capabilities/matrix.js +0 -312
- package/dist/capabilities/matrix.js.map +0 -1
- package/dist/capabilities/redis-resolver.d.ts +0 -95
- package/dist/capabilities/redis-resolver.d.ts.map +0 -1
- package/dist/capabilities/redis-resolver.js +0 -227
- package/dist/capabilities/redis-resolver.js.map +0 -1
- package/dist/capabilities/resolver-factory.d.ts +0 -30
- package/dist/capabilities/resolver-factory.d.ts.map +0 -1
- package/dist/capabilities/resolver-factory.js +0 -70
- package/dist/capabilities/resolver-factory.js.map +0 -1
- package/dist/capabilities/resolver.d.ts +0 -40
- package/dist/capabilities/resolver.d.ts.map +0 -1
- package/dist/capabilities/resolver.js +0 -18
- package/dist/capabilities/resolver.js.map +0 -1
- package/dist/capabilities/routing-metadata.d.ts +0 -16
- package/dist/capabilities/routing-metadata.d.ts.map +0 -1
- package/dist/capabilities/routing-metadata.js +0 -17
- package/dist/capabilities/routing-metadata.js.map +0 -1
- package/dist/capabilities/safe-resolver.d.ts +0 -24
- package/dist/capabilities/safe-resolver.d.ts.map +0 -1
- package/dist/capabilities/safe-resolver.js +0 -48
- package/dist/capabilities/safe-resolver.js.map +0 -1
- package/dist/config/loadConfiguration.d.ts +0 -60
- package/dist/config/loadConfiguration.d.ts.map +0 -1
- package/dist/config/loadConfiguration.js +0 -468
- package/dist/config/loadConfiguration.js.map +0 -1
- package/dist/config/schema.d.ts +0 -962
- package/dist/config/schema.d.ts.map +0 -1
- package/dist/config/schema.js +0 -318
- package/dist/config/schema.js.map +0 -1
- package/dist/config/types.d.ts +0 -826
- package/dist/config/types.d.ts.map +0 -1
- package/dist/config/types.js +0 -9
- package/dist/config/types.js.map +0 -1
- package/dist/email-manager.d.ts +0 -143
- package/dist/email-manager.d.ts.map +0 -1
- package/dist/email-manager.js +0 -365
- package/dist/email-manager.js.map +0 -1
- package/dist/enhanced-email-manager.d.ts +0 -349
- package/dist/enhanced-email-manager.d.ts.map +0 -1
- package/dist/enhanced-email-manager.js +0 -1396
- package/dist/enhanced-email-manager.js.map +0 -1
- package/dist/errors.d.ts +0 -154
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -251
- package/dist/errors.js.map +0 -1
- package/dist/index.d.ts +0 -25
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -30
- package/dist/index.js.map +0 -1
- package/dist/managers/email-analytics.d.ts +0 -92
- package/dist/managers/email-analytics.d.ts.map +0 -1
- package/dist/managers/email-analytics.js +0 -375
- package/dist/managers/email-analytics.js.map +0 -1
- package/dist/managers/email-scheduler.d.ts +0 -81
- package/dist/managers/email-scheduler.d.ts.map +0 -1
- package/dist/managers/email-scheduler.js +0 -288
- package/dist/managers/email-scheduler.js.map +0 -1
- package/dist/managers/provider-manager.d.ts +0 -152
- package/dist/managers/provider-manager.d.ts.map +0 -1
- package/dist/managers/provider-manager.js +0 -592
- package/dist/managers/provider-manager.js.map +0 -1
- package/dist/managers/template-manager.d.ts +0 -65
- package/dist/managers/template-manager.d.ts.map +0 -1
- package/dist/managers/template-manager.js +0 -314
- package/dist/managers/template-manager.js.map +0 -1
- package/dist/types.d.ts +0 -1029
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -62
- package/dist/types.js.map +0 -1
- package/dist/utils/simple-template-engine.d.ts +0 -27
- package/dist/utils/simple-template-engine.d.ts.map +0 -1
- package/dist/utils/simple-template-engine.js +0 -61
- package/dist/utils/simple-template-engine.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bernierllc/email-manager",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "Complete email management suite with template management, scheduling, analytics, and provider orchestration (Node.js only - use @bernierllc/email-manager-client for browser)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,29 +30,29 @@
|
|
|
30
30
|
"cosmiconfig": "^8.0.0",
|
|
31
31
|
"uuid": "^11.1.1",
|
|
32
32
|
"zod": "^3.22.4",
|
|
33
|
-
"@bernierllc/crypto-utils": "^1.4.0",
|
|
34
33
|
"@bernierllc/email-attachments": "^0.6.0",
|
|
35
34
|
"@bernierllc/email-batch-sender": "^0.4.8",
|
|
35
|
+
"@bernierllc/email-calendar": "^0.6.0",
|
|
36
36
|
"@bernierllc/email-capture": "^1.3.0",
|
|
37
37
|
"@bernierllc/email-headers": "^0.6.0",
|
|
38
|
-
"@bernierllc/email-
|
|
39
|
-
"@bernierllc/email-mitm-masking": "^1.6.9",
|
|
38
|
+
"@bernierllc/email-mitm-masking": "^1.6.10",
|
|
40
39
|
"@bernierllc/email-parser": "^0.7.0",
|
|
41
40
|
"@bernierllc/email-sender": "^5.13.0",
|
|
42
41
|
"@bernierllc/email-sender-manager": "^1.6.0",
|
|
43
|
-
"@bernierllc/email-sendgrid-plugin": "^1.8.
|
|
44
|
-
"@bernierllc/email-service": "^6.0.
|
|
42
|
+
"@bernierllc/email-sendgrid-plugin": "^1.8.2",
|
|
43
|
+
"@bernierllc/email-service": "^6.0.9",
|
|
44
|
+
"@bernierllc/crypto-utils": "^1.4.0",
|
|
45
45
|
"@bernierllc/email-subscription": "^0.4.0",
|
|
46
|
-
"@bernierllc/email-template-service": "^3.0.
|
|
46
|
+
"@bernierllc/email-template-service": "^3.0.10",
|
|
47
47
|
"@bernierllc/email-validator": "^3.4.0",
|
|
48
48
|
"@bernierllc/file-handler": "^0.8.0",
|
|
49
|
-
"@bernierllc/inbound-email-parse": "^3.0.
|
|
50
|
-
"@bernierllc/logger": "^
|
|
51
|
-
"@bernierllc/neverhub-adapter": "^0.4.1",
|
|
49
|
+
"@bernierllc/inbound-email-parse": "^3.0.3",
|
|
50
|
+
"@bernierllc/logger": "^2.0.0",
|
|
52
51
|
"@bernierllc/retry-policy": "^0.7.0",
|
|
53
|
-
"@bernierllc/template-engine": "^0.7.0",
|
|
54
52
|
"@bernierllc/template-variable-registry": "^1.5.0",
|
|
55
|
-
"@bernierllc/webhook-receiver": "^1.5.0"
|
|
53
|
+
"@bernierllc/webhook-receiver": "^1.5.0",
|
|
54
|
+
"@bernierllc/template-engine": "^0.7.0",
|
|
55
|
+
"@bernierllc/neverhub-adapter": "^0.4.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/jest": "^29.5.5",
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export type LogLevel = 'silent' | 'info' | 'warn' | 'error';
|
|
2
|
-
export interface DegradationLoggerConfig {
|
|
3
|
-
logger: {
|
|
4
|
-
warn: Function;
|
|
5
|
-
info: Function;
|
|
6
|
-
error: Function;
|
|
7
|
-
};
|
|
8
|
-
logLevel: LogLevel;
|
|
9
|
-
includeDocLinks: boolean;
|
|
10
|
-
docsBaseUrl?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface DegradationEvent {
|
|
13
|
-
provider: string;
|
|
14
|
-
feature: string;
|
|
15
|
-
strategy: string;
|
|
16
|
-
description: string;
|
|
17
|
-
docUrl: string;
|
|
18
|
-
}
|
|
19
|
-
export interface UnsupportedEvent {
|
|
20
|
-
provider: string;
|
|
21
|
-
feature: string;
|
|
22
|
-
message: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* DegradationLogger provides structured logging for feature degradation
|
|
26
|
-
* and unsupported feature events across email providers. It respects
|
|
27
|
-
* configurable log levels and optionally includes documentation links.
|
|
28
|
-
*/
|
|
29
|
-
export declare class DegradationLogger {
|
|
30
|
-
private readonly config;
|
|
31
|
-
constructor(config: DegradationLoggerConfig);
|
|
32
|
-
/**
|
|
33
|
-
* Log a degradation event when a provider does not natively support a feature
|
|
34
|
-
* and a fallback strategy is being used.
|
|
35
|
-
*/
|
|
36
|
-
logDegradation(event: DegradationEvent): void;
|
|
37
|
-
/**
|
|
38
|
-
* Log an unsupported feature event. These are always logged at error level
|
|
39
|
-
* (unless log level is silent).
|
|
40
|
-
*/
|
|
41
|
-
logUnsupported(event: UnsupportedEvent): void;
|
|
42
|
-
/**
|
|
43
|
-
* Check whether a message at the given severity should be logged
|
|
44
|
-
* based on the configured log level.
|
|
45
|
-
*
|
|
46
|
-
* The configured logLevel sets the minimum severity that gets logged:
|
|
47
|
-
* - 'silent': nothing is logged
|
|
48
|
-
* - 'error': only error-level messages
|
|
49
|
-
* - 'warn': error + warn messages
|
|
50
|
-
* - 'info': everything (error + warn + info)
|
|
51
|
-
*/
|
|
52
|
-
private shouldLog;
|
|
53
|
-
/**
|
|
54
|
-
* Resolve a doc URL, prepending the docsBaseUrl if the path is relative
|
|
55
|
-
* and includeDocLinks is enabled.
|
|
56
|
-
*/
|
|
57
|
-
private resolveDocUrl;
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=degradation-logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"degradation-logger.d.ts","sourceRoot":"","sources":["../../src/capabilities/degradation-logger.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5D,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAC;QAAC,KAAK,EAAE,QAAQ,CAAA;KAAE,CAAC;IAC5D,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAaD;;;;GAIG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;gBAErC,MAAM,EAAE,uBAAuB;IAI3C;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAwB7C;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAgB7C;;;;;;;;;OASG;IACH,OAAO,CAAC,SAAS;IAUjB;;;OAGG;IACH,OAAO,CAAC,aAAa;CAqBtB"}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2025 Bernier LLC
|
|
3
|
-
|
|
4
|
-
This file is licensed to the client under a limited-use license.
|
|
5
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
6
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Severity ranking for log levels, used for filtering.
|
|
10
|
-
* Higher numbers mean more severe / less filtered.
|
|
11
|
-
*/
|
|
12
|
-
const LOG_LEVEL_SEVERITY = {
|
|
13
|
-
silent: -1,
|
|
14
|
-
info: 0,
|
|
15
|
-
warn: 1,
|
|
16
|
-
error: 2,
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* DegradationLogger provides structured logging for feature degradation
|
|
20
|
-
* and unsupported feature events across email providers. It respects
|
|
21
|
-
* configurable log levels and optionally includes documentation links.
|
|
22
|
-
*/
|
|
23
|
-
export class DegradationLogger {
|
|
24
|
-
constructor(config) {
|
|
25
|
-
this.config = config;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Log a degradation event when a provider does not natively support a feature
|
|
29
|
-
* and a fallback strategy is being used.
|
|
30
|
-
*/
|
|
31
|
-
logDegradation(event) {
|
|
32
|
-
if (!this.shouldLog('warn')) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const fullDocUrl = this.resolveDocUrl(event.docUrl);
|
|
36
|
-
const message = `${event.provider.toUpperCase()} does not support native ${event.feature}. ` +
|
|
37
|
-
`Using ${event.strategy}: ${event.description}. ` +
|
|
38
|
-
`Docs: ${fullDocUrl}. ` +
|
|
39
|
-
`Override: set featureOverrides.${event.feature}.behavior = 'error' to disable degradation.`;
|
|
40
|
-
const metadata = {
|
|
41
|
-
provider: event.provider,
|
|
42
|
-
feature: event.feature,
|
|
43
|
-
strategy: event.strategy,
|
|
44
|
-
description: event.description,
|
|
45
|
-
docUrl: fullDocUrl,
|
|
46
|
-
};
|
|
47
|
-
this.config.logger.warn(message, metadata);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Log an unsupported feature event. These are always logged at error level
|
|
51
|
-
* (unless log level is silent).
|
|
52
|
-
*/
|
|
53
|
-
logUnsupported(event) {
|
|
54
|
-
if (!this.shouldLog('error')) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const message = `${event.provider.toUpperCase()} does not support ${event.feature}: ${event.message}`;
|
|
58
|
-
const metadata = {
|
|
59
|
-
provider: event.provider,
|
|
60
|
-
feature: event.feature,
|
|
61
|
-
};
|
|
62
|
-
this.config.logger.error(message, metadata);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Check whether a message at the given severity should be logged
|
|
66
|
-
* based on the configured log level.
|
|
67
|
-
*
|
|
68
|
-
* The configured logLevel sets the minimum severity that gets logged:
|
|
69
|
-
* - 'silent': nothing is logged
|
|
70
|
-
* - 'error': only error-level messages
|
|
71
|
-
* - 'warn': error + warn messages
|
|
72
|
-
* - 'info': everything (error + warn + info)
|
|
73
|
-
*/
|
|
74
|
-
shouldLog(messageSeverity) {
|
|
75
|
-
const configuredLevel = this.config.logLevel;
|
|
76
|
-
if (configuredLevel === 'silent') {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
// The configured level is the minimum severity we show.
|
|
80
|
-
// A message is shown if its severity >= the configured threshold.
|
|
81
|
-
return LOG_LEVEL_SEVERITY[messageSeverity] >= LOG_LEVEL_SEVERITY[configuredLevel];
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Resolve a doc URL, prepending the docsBaseUrl if the path is relative
|
|
85
|
-
* and includeDocLinks is enabled.
|
|
86
|
-
*/
|
|
87
|
-
resolveDocUrl(docUrl) {
|
|
88
|
-
if (!this.config.includeDocLinks) {
|
|
89
|
-
return docUrl;
|
|
90
|
-
}
|
|
91
|
-
// If it's already an absolute URL, return as-is
|
|
92
|
-
if (docUrl.startsWith('http://') || docUrl.startsWith('https://')) {
|
|
93
|
-
return docUrl;
|
|
94
|
-
}
|
|
95
|
-
// Prepend docsBaseUrl for relative paths
|
|
96
|
-
if (this.config.docsBaseUrl) {
|
|
97
|
-
const base = this.config.docsBaseUrl.endsWith('/')
|
|
98
|
-
? this.config.docsBaseUrl.slice(0, -1)
|
|
99
|
-
: this.config.docsBaseUrl;
|
|
100
|
-
const path = docUrl.startsWith('/') ? docUrl : `/${docUrl}`;
|
|
101
|
-
return `${base}${path}`;
|
|
102
|
-
}
|
|
103
|
-
return docUrl;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=degradation-logger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"degradation-logger.js","sourceRoot":"","sources":["../../src/capabilities/degradation-logger.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAyBF;;;GAGG;AACH,MAAM,kBAAkB,GAA6B;IACnD,MAAM,EAAE,CAAC,CAAC;IACV,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACT,CAAC;AAEF;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAG5B,YAAY,MAA+B;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,KAAuB;QACpC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,OAAO;QACT,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEpD,MAAM,OAAO,GACX,GAAG,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE,4BAA4B,KAAK,CAAC,OAAO,IAAI;YAC5E,SAAS,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,WAAW,IAAI;YACjD,SAAS,UAAU,IAAI;YACvB,kCAAkC,KAAK,CAAC,OAAO,6CAA6C,CAAC;QAE/F,MAAM,QAAQ,GAAG;YACf,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9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AW,EAAE,CAAC;YAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAChD,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACtC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;YAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC;YAC5D,OAAO,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;QAC1B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { CapabilityResolver } from './resolver.js';
|
|
2
|
-
export interface ProviderInfo {
|
|
3
|
-
id: string;
|
|
4
|
-
name: string;
|
|
5
|
-
type: 'sendgrid' | 'mailgun' | 'postmark' | 'ses' | 'smtp' | 'mandrill' | 'smtp2go';
|
|
6
|
-
isActive: boolean;
|
|
7
|
-
priority: number;
|
|
8
|
-
}
|
|
9
|
-
export interface RoutingResult {
|
|
10
|
-
provider: ProviderInfo;
|
|
11
|
-
source: 'provider' | 'platform' | 'enhanced' | 'unsupported';
|
|
12
|
-
degraded: boolean;
|
|
13
|
-
degradation: {
|
|
14
|
-
strategy: string;
|
|
15
|
-
description: string;
|
|
16
|
-
docUrl: string;
|
|
17
|
-
} | null;
|
|
18
|
-
attemptedProviders: string[];
|
|
19
|
-
}
|
|
20
|
-
export interface FeatureOverride {
|
|
21
|
-
behavior: 'native-first' | 'platform-always' | 'error';
|
|
22
|
-
}
|
|
23
|
-
export interface FeatureRouterConfig {
|
|
24
|
-
resolver: CapabilityResolver;
|
|
25
|
-
fallbackResolver?: CapabilityResolver;
|
|
26
|
-
featureOverrides?: Record<string, FeatureOverride>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Smart routing engine that decides which provider handles a feature request.
|
|
30
|
-
*
|
|
31
|
-
* The router inspects the capability matrix (via a {@link CapabilityResolver})
|
|
32
|
-
* to find the best active provider for a given feature, respecting priority
|
|
33
|
-
* ordering and feature overrides.
|
|
34
|
-
*/
|
|
35
|
-
export declare class FeatureRouter {
|
|
36
|
-
private readonly resolver;
|
|
37
|
-
private readonly fallbackResolver;
|
|
38
|
-
private readonly featureOverrides;
|
|
39
|
-
constructor(config: FeatureRouterConfig);
|
|
40
|
-
/**
|
|
41
|
-
* Find the best provider for a given feature.
|
|
42
|
-
*
|
|
43
|
-
* @throws {FeatureUnsupportedError} when no provider can handle the feature
|
|
44
|
-
*/
|
|
45
|
-
findProviderForFeature(feature: string, providers: ProviderInfo[]): Promise<RoutingResult>;
|
|
46
|
-
private handlePlatformAlways;
|
|
47
|
-
private handleErrorOverride;
|
|
48
|
-
private handleNativeFirst;
|
|
49
|
-
/**
|
|
50
|
-
* Resolve a capability entry, falling back to the fallback resolver on error.
|
|
51
|
-
* Returns `undefined` when the capability cannot be resolved at all.
|
|
52
|
-
*/
|
|
53
|
-
private resolveCapability;
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=feature-router.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"feature-router.d.ts","sourceRoot":"","sources":["../../src/capabilities/feature-router.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAMxD,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IACpF,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,YAAY,CAAC;IACvB,MAAM,EAAE,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC;IAC7D,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9E,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,cAAc,GAAG,iBAAiB,GAAG,OAAO,CAAC;CACxD;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,gBAAgB,CAAC,EAAE,kBAAkB,CAAC;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CACpD;AAMD;;;;;;GAMG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAiC;IAClE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkC;gBAEvD,MAAM,EAAE,mBAAmB;IAMvC;;;;OAIG;IACG,sBAAsB,CAC1B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,YAAY,EAAE,GACxB,OAAO,CAAC,aAAa,CAAC;YAiCX,oBAAoB;YAgBpB,mBAAmB;YA4BnB,iBAAiB;IAuD/B;;;OAGG;YACW,iBAAiB;CAmBhC"}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2025 Bernier LLC
|
|
3
|
-
|
|
4
|
-
This file is licensed to the client under a limited-use license.
|
|
5
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
6
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
7
|
-
*/
|
|
8
|
-
import { FeatureUnsupportedError } from '../errors.js';
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// FeatureRouter
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
/**
|
|
13
|
-
* Smart routing engine that decides which provider handles a feature request.
|
|
14
|
-
*
|
|
15
|
-
* The router inspects the capability matrix (via a {@link CapabilityResolver})
|
|
16
|
-
* to find the best active provider for a given feature, respecting priority
|
|
17
|
-
* ordering and feature overrides.
|
|
18
|
-
*/
|
|
19
|
-
export class FeatureRouter {
|
|
20
|
-
constructor(config) {
|
|
21
|
-
this.resolver = config.resolver;
|
|
22
|
-
this.fallbackResolver = config.fallbackResolver;
|
|
23
|
-
this.featureOverrides = config.featureOverrides ?? {};
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Find the best provider for a given feature.
|
|
27
|
-
*
|
|
28
|
-
* @throws {FeatureUnsupportedError} when no provider can handle the feature
|
|
29
|
-
*/
|
|
30
|
-
async findProviderForFeature(feature, providers) {
|
|
31
|
-
// 1. Filter to active providers only
|
|
32
|
-
const activeProviders = providers.filter((p) => p.isActive);
|
|
33
|
-
if (activeProviders.length === 0) {
|
|
34
|
-
throw new FeatureUnsupportedError(feature, providers.map((p) => p.id));
|
|
35
|
-
}
|
|
36
|
-
// 2. Sort by priority (lowest number = highest priority)
|
|
37
|
-
const sorted = [...activeProviders].sort((a, b) => a.priority - b.priority);
|
|
38
|
-
// 3. Check for feature override
|
|
39
|
-
const override = this.featureOverrides[feature];
|
|
40
|
-
if (override?.behavior === 'platform-always') {
|
|
41
|
-
return this.handlePlatformAlways(feature, sorted);
|
|
42
|
-
}
|
|
43
|
-
if (override?.behavior === 'error') {
|
|
44
|
-
return this.handleErrorOverride(feature, sorted, providers);
|
|
45
|
-
}
|
|
46
|
-
// 4. Default: native-first -- iterate providers in priority order
|
|
47
|
-
return this.handleNativeFirst(feature, sorted, providers);
|
|
48
|
-
}
|
|
49
|
-
// -------------------------------------------------------------------------
|
|
50
|
-
// Override handlers
|
|
51
|
-
// -------------------------------------------------------------------------
|
|
52
|
-
async handlePlatformAlways(feature, sorted) {
|
|
53
|
-
const first = sorted[0];
|
|
54
|
-
const capability = await this.resolveCapability(first.type, feature);
|
|
55
|
-
return {
|
|
56
|
-
provider: first,
|
|
57
|
-
source: 'platform',
|
|
58
|
-
degraded: true,
|
|
59
|
-
degradation: capability?.degradation ?? null,
|
|
60
|
-
attemptedProviders: [first.id],
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
async handleErrorOverride(feature, sorted, allProviders) {
|
|
64
|
-
const attemptedProviders = [];
|
|
65
|
-
for (const provider of sorted) {
|
|
66
|
-
attemptedProviders.push(provider.id);
|
|
67
|
-
const capability = await this.resolveCapability(provider.type, feature);
|
|
68
|
-
if (capability && (capability.source === 'provider' || capability.source === 'enhanced')) {
|
|
69
|
-
return {
|
|
70
|
-
provider,
|
|
71
|
-
source: capability.source,
|
|
72
|
-
degraded: false,
|
|
73
|
-
degradation: null,
|
|
74
|
-
attemptedProviders,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
throw new FeatureUnsupportedError(feature, allProviders.map((p) => p.id));
|
|
79
|
-
}
|
|
80
|
-
async handleNativeFirst(feature, sorted, allProviders) {
|
|
81
|
-
const attemptedProviders = [];
|
|
82
|
-
let platformFallback;
|
|
83
|
-
for (const provider of sorted) {
|
|
84
|
-
attemptedProviders.push(provider.id);
|
|
85
|
-
const capability = await this.resolveCapability(provider.type, feature);
|
|
86
|
-
if (!capability) {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
// Native or enhanced -- return immediately
|
|
90
|
-
if (capability.source === 'provider' || capability.source === 'enhanced') {
|
|
91
|
-
return {
|
|
92
|
-
provider,
|
|
93
|
-
source: capability.source,
|
|
94
|
-
degraded: false,
|
|
95
|
-
degradation: null,
|
|
96
|
-
attemptedProviders,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
// Track first platform fallback
|
|
100
|
-
if (capability.source === 'platform' && !platformFallback) {
|
|
101
|
-
platformFallback = { provider, capability };
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
// 5. No native/enhanced found -- try platform degradation
|
|
105
|
-
if (platformFallback) {
|
|
106
|
-
return {
|
|
107
|
-
provider: platformFallback.provider,
|
|
108
|
-
source: 'platform',
|
|
109
|
-
degraded: true,
|
|
110
|
-
degradation: platformFallback.capability.degradation ?? null,
|
|
111
|
-
attemptedProviders,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
// 6. Completely unsupported
|
|
115
|
-
throw new FeatureUnsupportedError(feature, allProviders.map((p) => p.id));
|
|
116
|
-
}
|
|
117
|
-
// -------------------------------------------------------------------------
|
|
118
|
-
// Resolver helper
|
|
119
|
-
// -------------------------------------------------------------------------
|
|
120
|
-
/**
|
|
121
|
-
* Resolve a capability entry, falling back to the fallback resolver on error.
|
|
122
|
-
* Returns `undefined` when the capability cannot be resolved at all.
|
|
123
|
-
*/
|
|
124
|
-
async resolveCapability(providerType, feature) {
|
|
125
|
-
try {
|
|
126
|
-
return await this.resolver.getCapability(providerType, feature);
|
|
127
|
-
}
|
|
128
|
-
catch (primaryError) {
|
|
129
|
-
if (this.fallbackResolver) {
|
|
130
|
-
try {
|
|
131
|
-
return await this.fallbackResolver.getCapability(providerType, feature);
|
|
132
|
-
}
|
|
133
|
-
catch {
|
|
134
|
-
// Both resolvers failed -- treat as unresolvable
|
|
135
|
-
return undefined;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
// No fallback -- propagate error
|
|
139
|
-
throw primaryError;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=feature-router.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"feature-router.js","sourceRoot":"","sources":["../../src/capabilities/feature-router.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAIF,OAAO,EAAE,uB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A4B;QAC5B,MAAM,IAAI,uBAAuB,CAC/B,OAAO,EACP,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC9B,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,kBAAkB;IAClB,4EAA4E;IAE5E;;;OAGG;IACK,KAAK,CAAC,iBAAiB,CAC7B,YAAoB,EACpB,OAAe;QAEf,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAClE,CAAC;QAAC,OAAO,YAAY,EAAE,CAAC;YACtB,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC1B,IAAI,CAAC;oBACH,OAAO,MAAM,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;gBAC1E,CAAC;gBAAC,MAAM,CAAC;oBACP,iDAAiD;oBACjD,OAAO,SAAS,CAAC;gBACnB,CAAC;YACH,CAAC;YACD,iCAAiC;YACjC,MAAM,YAAY,CAAC;QACrB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { CapabilityEntry } from '@bernierllc/email-sender';
|
|
2
|
-
import type { CapabilityResolverAdmin } from './resolver.js';
|
|
3
|
-
/**
|
|
4
|
-
* In-memory implementation of {@link CapabilityResolverAdmin}.
|
|
5
|
-
*
|
|
6
|
-
* Initialised with a deep clone of the canonical {@link CAPABILITY_MATRIX} so
|
|
7
|
-
* that mutations made through the admin interface never affect the original
|
|
8
|
-
* static data.
|
|
9
|
-
*/
|
|
10
|
-
export declare class InMemoryCapabilityResolver implements CapabilityResolverAdmin {
|
|
11
|
-
private readonly data;
|
|
12
|
-
constructor();
|
|
13
|
-
getCapability(provider: string, feature: string): Promise<CapabilityEntry>;
|
|
14
|
-
getProviderCapabilities(provider: string): Promise<Record<string, CapabilityEntry>>;
|
|
15
|
-
setCapability(provider: string, feature: string, entry: CapabilityEntry): Promise<void>;
|
|
16
|
-
setProviderCapabilities(provider: string, capabilities: Record<string, CapabilityEntry>): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Resolves the capability map for a known provider or throws.
|
|
19
|
-
*/
|
|
20
|
-
private resolveProvider;
|
|
21
|
-
/**
|
|
22
|
-
* Validates a capability entry against the Zod schema, throwing a
|
|
23
|
-
* {@link CapabilityResolverError} with code `INVALID_ENTRY` on failure.
|
|
24
|
-
*/
|
|
25
|
-
private validateEntry;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=in-memory-resolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory-resolver.d.ts","sourceRoot":"","sources":["../../src/capabilities/in-memory-resolver.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAKhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;;;GAMG;AACH,qBAAa,0BAA2B,YAAW,uBAAuB;IACxE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAuB;;IAUtC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAY1E,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAQnF,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAWvF,uBAAuB,CAC3B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAC5C,OAAO,CAAC,IAAI,CAAC;IAahB;;OAEG;IACH,OAAO,CAAC,eAAe;IAWvB;;;OAGG;IACH,OAAO,CAAC,aAAa;CAUtB"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2025 Bernier LLC
|
|
3
|
-
|
|
4
|
-
This file is licensed to the client under a limited-use license.
|
|
5
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
6
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
7
|
-
*/
|
|
8
|
-
import { capabilityEntrySchema } from '@bernierllc/email-sender';
|
|
9
|
-
import { CAPABILITY_MATRIX } from './matrix.js';
|
|
10
|
-
import { CapabilityResolverError } from './resolver.js';
|
|
11
|
-
/**
|
|
12
|
-
* In-memory implementation of {@link CapabilityResolverAdmin}.
|
|
13
|
-
*
|
|
14
|
-
* Initialised with a deep clone of the canonical {@link CAPABILITY_MATRIX} so
|
|
15
|
-
* that mutations made through the admin interface never affect the original
|
|
16
|
-
* static data.
|
|
17
|
-
*/
|
|
18
|
-
export class InMemoryCapabilityResolver {
|
|
19
|
-
constructor() {
|
|
20
|
-
this.data = structuredClone(CAPABILITY_MATRIX);
|
|
21
|
-
}
|
|
22
|
-
// -----------------------------------------------------------------------
|
|
23
|
-
// Read operations
|
|
24
|
-
// -----------------------------------------------------------------------
|
|
25
|
-
async getCapability(provider, feature) {
|
|
26
|
-
const providerCaps = this.resolveProvider(provider);
|
|
27
|
-
const entry = providerCaps[feature];
|
|
28
|
-
if (!entry) {
|
|
29
|
-
throw new CapabilityResolverError(`Unknown feature "${feature}" for provider "${provider}"`, 'UNKNOWN_FEATURE');
|
|
30
|
-
}
|
|
31
|
-
return entry;
|
|
32
|
-
}
|
|
33
|
-
async getProviderCapabilities(provider) {
|
|
34
|
-
return { ...this.resolveProvider(provider) };
|
|
35
|
-
}
|
|
36
|
-
// -----------------------------------------------------------------------
|
|
37
|
-
// Write operations
|
|
38
|
-
// -----------------------------------------------------------------------
|
|
39
|
-
async setCapability(provider, feature, entry) {
|
|
40
|
-
this.validateEntry(entry);
|
|
41
|
-
// Ensure provider bucket exists (create on demand for admin use-cases)
|
|
42
|
-
if (!this.data.providers[provider]) {
|
|
43
|
-
this.data.providers[provider] = {};
|
|
44
|
-
}
|
|
45
|
-
this.data.providers[provider][feature] = entry;
|
|
46
|
-
}
|
|
47
|
-
async setProviderCapabilities(provider, capabilities) {
|
|
48
|
-
// Validate every entry before committing any of them
|
|
49
|
-
for (const [feature, entry] of Object.entries(capabilities)) {
|
|
50
|
-
this.validateEntry(entry, feature);
|
|
51
|
-
}
|
|
52
|
-
this.data.providers[provider] = { ...capabilities };
|
|
53
|
-
}
|
|
54
|
-
// -----------------------------------------------------------------------
|
|
55
|
-
// Internal helpers
|
|
56
|
-
// -----------------------------------------------------------------------
|
|
57
|
-
/**
|
|
58
|
-
* Resolves the capability map for a known provider or throws.
|
|
59
|
-
*/
|
|
60
|
-
resolveProvider(provider) {
|
|
61
|
-
const caps = this.data.providers[provider];
|
|
62
|
-
if (!caps) {
|
|
63
|
-
throw new CapabilityResolverError(`Unknown provider "${provider}"`, 'UNKNOWN_PROVIDER');
|
|
64
|
-
}
|
|
65
|
-
return caps;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Validates a capability entry against the Zod schema, throwing a
|
|
69
|
-
* {@link CapabilityResolverError} with code `INVALID_ENTRY` on failure.
|
|
70
|
-
*/
|
|
71
|
-
validateEntry(entry, label) {
|
|
72
|
-
const result = capabilityEntrySchema.safeParse(entry);
|
|
73
|
-
if (!result.success) {
|
|
74
|
-
const prefix = label ? `Invalid entry for "${label}": ` : 'Invalid capability entry: ';
|
|
75
|
-
throw new CapabilityResolverError(prefix + result.error.issues.map((i) => i.message).join('; '), 'INVALID_ENTRY');
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=in-memory-resolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory-resolver.js","sourceRoot":"","sources":["../../src/capabilities/in-mem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
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export { FEATURE_DEFINITIONS, FEATURE_NAMES, PROVIDER_NAMES, CAPABILITY_MATRIX, getCapabilityMatrix, } from './matrix.js';
|
|
2
|
-
export type { FeatureName, ProviderName, ProviderCapabilityMap, CapabilityMatrixData, } from './matrix.js';
|
|
3
|
-
export { CapabilityResolverError } from './resolver.js';
|
|
4
|
-
export type { CapabilityResolver, CapabilityResolverAdmin } from './resolver.js';
|
|
5
|
-
export { InMemoryCapabilityResolver } from './in-memory-resolver.js';
|
|
6
|
-
export { RedisCapabilityResolver } from './redis-resolver.js';
|
|
7
|
-
export type { RedisLike, RedisPipelineLike, RedisCapabilityResolverOptions, } from './redis-resolver.js';
|
|
8
|
-
export { SafeCapabilityResolver } from './safe-resolver.js';
|
|
9
|
-
export { createCapabilityResolver } from './resolver-factory.js';
|
|
10
|
-
export type { ResolverFactoryOptions, ResolverFactoryLogger } from './resolver-factory.js';
|
|
11
|
-
export { FeatureRouter } from './feature-router.js';
|
|
12
|
-
export type { ProviderInfo, RoutingResult, FeatureOverride, FeatureRouterConfig, } from './feature-router.js';
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/capabilities/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAGrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,8BAA8B,GAC/B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,YAAY,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG3F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,mBAAmB,GACpB,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2025 Bernier LLC
|
|
3
|
-
|
|
4
|
-
This file is licensed to the client under a limited-use license.
|
|
5
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
6
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
7
|
-
*/
|
|
8
|
-
export { FEATURE_DEFINITIONS, FEATURE_NAMES, PROVIDER_NAMES, CAPABILITY_MATRIX, getCapabilityMatrix, } from './matrix.js';
|
|
9
|
-
// Capability resolver interfaces and error class
|
|
10
|
-
export { CapabilityResolverError } from './resolver.js';
|
|
11
|
-
// In-memory resolver implementation
|
|
12
|
-
export { InMemoryCapabilityResolver } from './in-memory-resolver.js';
|
|
13
|
-
// Redis-backed resolver implementation
|
|
14
|
-
export { RedisCapabilityResolver } from './redis-resolver.js';
|
|
15
|
-
// Safe fallback wrapper
|
|
16
|
-
export { SafeCapabilityResolver } from './safe-resolver.js';
|
|
17
|
-
// Factory function for auto-detecting resolver
|
|
18
|
-
export { createCapabilityResolver } from './resolver-factory.js';
|
|
19
|
-
// Feature router
|
|
20
|
-
export { FeatureRouter } from './feature-router.js';
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/capabilities/index.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AASrB,iDAAiD;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGxD,oCAAoC;AACpC,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAErE,uCAAuC;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAO9D,wBAAwB;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,+CAA+C;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAGjE,iBAAiB;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
|