@bernierllc/social-media-manager 1.0.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.
Files changed (46) hide show
  1. package/README.md +407 -0
  2. package/dist/SocialMediaManager.d.ts +95 -0
  3. package/dist/SocialMediaManager.d.ts.map +1 -0
  4. package/dist/SocialMediaManager.js +265 -0
  5. package/dist/SocialMediaManager.js.map +1 -0
  6. package/dist/content-type/ContentTypeMatching.d.ts +26 -0
  7. package/dist/content-type/ContentTypeMatching.d.ts.map +1 -0
  8. package/dist/content-type/ContentTypeMatching.js +113 -0
  9. package/dist/content-type/ContentTypeMatching.js.map +1 -0
  10. package/dist/content-type/ContentTypeRegistry.d.ts +25 -0
  11. package/dist/content-type/ContentTypeRegistry.d.ts.map +1 -0
  12. package/dist/content-type/ContentTypeRegistry.js +113 -0
  13. package/dist/content-type/ContentTypeRegistry.js.map +1 -0
  14. package/dist/content-type/TransformationPipeline.d.ts +50 -0
  15. package/dist/content-type/TransformationPipeline.d.ts.map +1 -0
  16. package/dist/content-type/TransformationPipeline.js +169 -0
  17. package/dist/content-type/TransformationPipeline.js.map +1 -0
  18. package/dist/index.d.ts +12 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +17 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/orchestration/MultiPlatformOrchestrator.d.ts +37 -0
  23. package/dist/orchestration/MultiPlatformOrchestrator.d.ts.map +1 -0
  24. package/dist/orchestration/MultiPlatformOrchestrator.js +167 -0
  25. package/dist/orchestration/MultiPlatformOrchestrator.js.map +1 -0
  26. package/dist/platforms/ConnectionManager.d.ts +31 -0
  27. package/dist/platforms/ConnectionManager.d.ts.map +1 -0
  28. package/dist/platforms/ConnectionManager.js +136 -0
  29. package/dist/platforms/ConnectionManager.js.map +1 -0
  30. package/dist/platforms/PlatformRegistry.d.ts +73 -0
  31. package/dist/platforms/PlatformRegistry.d.ts.map +1 -0
  32. package/dist/platforms/PlatformRegistry.js +93 -0
  33. package/dist/platforms/PlatformRegistry.js.map +1 -0
  34. package/dist/scheduling/JitterCalculator.d.ts +37 -0
  35. package/dist/scheduling/JitterCalculator.d.ts.map +1 -0
  36. package/dist/scheduling/JitterCalculator.js +93 -0
  37. package/dist/scheduling/JitterCalculator.js.map +1 -0
  38. package/dist/scheduling/ScheduleManager.d.ts +48 -0
  39. package/dist/scheduling/ScheduleManager.d.ts.map +1 -0
  40. package/dist/scheduling/ScheduleManager.js +125 -0
  41. package/dist/scheduling/ScheduleManager.js.map +1 -0
  42. package/dist/types.d.ts +214 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/dist/types.js +9 -0
  45. package/dist/types.js.map +1 -0
  46. package/package.json +92 -0
@@ -0,0 +1,169 @@
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 { ContentTypeMatching } from './ContentTypeMatching.js';
9
+ export class ContentTransformationPipeline {
10
+ contentTypeMatching;
11
+ constructor() {
12
+ this.contentTypeMatching = new ContentTypeMatching();
13
+ }
14
+ /**
15
+ * Transform generic content to platform-specific format
16
+ */
17
+ async transform(source, targetPlatform) {
18
+ // Get transformation pipeline for target
19
+ const pipeline = await this.contentTypeMatching.getTransformationPipeline('generic-social-content', `social-media-content:${targetPlatform}`);
20
+ // Apply transformations sequentially
21
+ let transformed = { ...source };
22
+ for (const transformation of pipeline) {
23
+ transformed = await this.applyTransformation(transformed, transformation, targetPlatform);
24
+ }
25
+ // Validate against platform constraints
26
+ const validation = await this.contentTypeMatching.validateForPlatform(transformed, targetPlatform);
27
+ if (!validation.valid) {
28
+ throw new Error(`Content validation failed for ${targetPlatform}: ${validation.errors.join(', ')}`);
29
+ }
30
+ return transformed;
31
+ }
32
+ /**
33
+ * Apply a single transformation to content
34
+ */
35
+ async applyTransformation(content, transformation, platform) {
36
+ // Type guard to ensure content is an object
37
+ if (typeof content !== 'object' || content === null) {
38
+ return content;
39
+ }
40
+ const contentObj = content;
41
+ switch (transformation) {
42
+ case 'thread-splitting':
43
+ return this.splitIntoThread(contentObj, platform);
44
+ case 'article-conversion':
45
+ return this.convertToArticle(contentObj);
46
+ case 'media-resize':
47
+ return this.resizeMedia(contentObj, platform);
48
+ case 'hashtag-optimization':
49
+ return this.optimizeHashtags(contentObj, platform);
50
+ case 'character-counting':
51
+ return this.enforceCharacterLimit(contentObj, platform);
52
+ case 'text-formatting':
53
+ return this.formatText(contentObj);
54
+ case 'link-preview':
55
+ return this.enableLinkPreview(contentObj);
56
+ case 'professional-tone':
57
+ return this.adjustToProfessionalTone(contentObj);
58
+ default:
59
+ return content;
60
+ }
61
+ }
62
+ /**
63
+ * Split long text into a thread (Twitter)
64
+ */
65
+ async splitIntoThread(content, platform) {
66
+ if (typeof content.text !== 'string') {
67
+ return content;
68
+ }
69
+ const maxLength = platform === 'twitter' ? 280 : 300;
70
+ if (content.text.length <= maxLength) {
71
+ return content;
72
+ }
73
+ // For simplicity, just truncate - real implementation would split intelligently
74
+ return {
75
+ ...content,
76
+ text: content.text.substring(0, maxLength - 3) + '...',
77
+ isThread: true,
78
+ };
79
+ }
80
+ /**
81
+ * Convert to article format (LinkedIn)
82
+ */
83
+ async convertToArticle(content) {
84
+ return {
85
+ ...content,
86
+ articleFormat: true,
87
+ };
88
+ }
89
+ /**
90
+ * Resize media for platform requirements
91
+ */
92
+ async resizeMedia(content, platform) {
93
+ // Mark that media should be resized - actual resizing would happen in platform service
94
+ return {
95
+ ...content,
96
+ mediaResized: true,
97
+ targetPlatform: platform,
98
+ };
99
+ }
100
+ /**
101
+ * Optimize hashtags for platform
102
+ */
103
+ async optimizeHashtags(content, platform) {
104
+ if (!Array.isArray(content.hashtags)) {
105
+ return content;
106
+ }
107
+ const maxHashtags = platform === 'instagram' || platform === 'linkedin' ? 30 : 10;
108
+ const optimizedHashtags = content.hashtags.slice(0, maxHashtags);
109
+ return {
110
+ ...content,
111
+ hashtags: optimizedHashtags,
112
+ };
113
+ }
114
+ /**
115
+ * Enforce character limit for platform
116
+ */
117
+ async enforceCharacterLimit(content, platform) {
118
+ if (typeof content.text !== 'string') {
119
+ return content;
120
+ }
121
+ const limits = {
122
+ twitter: 280,
123
+ bluesky: 300,
124
+ mastodon: 500,
125
+ };
126
+ const limit = limits[platform];
127
+ if (!limit || content.text.length <= limit) {
128
+ return content;
129
+ }
130
+ return {
131
+ ...content,
132
+ text: content.text.substring(0, limit - 3) + '...',
133
+ };
134
+ }
135
+ /**
136
+ * Format text for better readability
137
+ */
138
+ async formatText(content) {
139
+ return {
140
+ ...content,
141
+ textFormatted: true,
142
+ };
143
+ }
144
+ /**
145
+ * Enable link preview (Facebook)
146
+ */
147
+ async enableLinkPreview(content) {
148
+ return {
149
+ ...content,
150
+ linkPreviewEnabled: true,
151
+ };
152
+ }
153
+ /**
154
+ * Adjust tone to be more professional (LinkedIn)
155
+ */
156
+ async adjustToProfessionalTone(content) {
157
+ return {
158
+ ...content,
159
+ professionalTone: true,
160
+ };
161
+ }
162
+ /**
163
+ * Validate content for platform without transforming
164
+ */
165
+ async validate(content, platform) {
166
+ return this.contentTypeMatching.validateForPlatform(content, platform);
167
+ }
168
+ }
169
+ //# sourceMappingURL=TransformationPipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransformationPipeline.js","sourceRoot":"","sources":["../../src/content-type/TransformationPipeline.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,MAAM,OAAO,6BAA6B;IAChC,mBAAmB,CAAsB;IAEjD;QACE,IAAI,CAAC,mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,MAA4B,EAAE,cAAsB;QAClE,yCAAyC;QACzC,MAAM,QA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IACJ,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,iBAAiB,CAAC,OAAgC;QAC9D,OAAO;YACL,GAAG,OAAO;YACV,kBAAkB,EAAE,IAAI;SACzB,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,wBAAwB,CAAC,OAAgC;QACrE,OAAO;YACL,GAAG,OAAO;YACV,gBAAgB,EAAE,IAAI;SACvB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,OAA6B,EAAE,QAAgB;QAC5D,OAAO,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzE,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ export { SocialMediaManager } from './SocialMediaManager.js';
2
+ export { ContentTypeRegistry, CONTENT_TYPE_REGISTRY } from './content-type/ContentTypeRegistry.js';
3
+ export { ContentTypeMatching } from './content-type/ContentTypeMatching.js';
4
+ export { ContentTransformationPipeline } from './content-type/TransformationPipeline.js';
5
+ export { JitterCalculator } from './scheduling/JitterCalculator.js';
6
+ export { ScheduleManager } from './scheduling/ScheduleManager.js';
7
+ export { PlatformRegistry } from './platforms/PlatformRegistry.js';
8
+ export { ConnectionManager } from './platforms/ConnectionManager.js';
9
+ export { MultiPlatformOrchestrator } from './orchestration/MultiPlatformOrchestrator.js';
10
+ export type { SocialMediaManagerConfig, PlatformConfigs, PlatformConfig, SchedulerConfig, TransformationConfig, SecretManagerConfig, NeverhubConfig, LoggerConfig, MultiPlatformPostRequest, GenericSocialContent, GenericImage, GenericVideo, GenericLocation, PostOptions, SchedulePostRequest, JitterConfig, MultiPlatformPostResult, PostSummary, PlatformPostResult, SchedulePostResult, PlatformConnection, PlatformConnectionTest, ScheduledPost, ScheduleFilters, PlatformStatus, RateLimitStatus, BatchPostRequest, BatchPostResult, BatchScheduleResult, ValidationResult, ContentTypeRegistryEntry, TransformationPipelineStep, } from './types.js';
11
+ export type { PlatformAdapter } from './platforms/PlatformRegistry.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAEzF,YAAY,EACV,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,wBAAwB,EACxB,oBAAoB,EACpB,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,uBAAuB,EACvB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
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 { SocialMediaManager } from './SocialMediaManager.js';
9
+ export { ContentTypeRegistry, CONTENT_TYPE_REGISTRY } from './content-type/ContentTypeRegistry.js';
10
+ export { ContentTypeMatching } from './content-type/ContentTypeMatching.js';
11
+ export { ContentTransformationPipeline } from './content-type/TransformationPipeline.js';
12
+ export { JitterCalculator } from './scheduling/JitterCalculator.js';
13
+ export { ScheduleManager } from './scheduling/ScheduleManager.js';
14
+ export { PlatformRegistry } from './platforms/PlatformRegistry.js';
15
+ export { ConnectionManager } from './platforms/ConnectionManager.js';
16
+ export { MultiPlatformOrchestrator } from './orchestration/MultiPlatformOrchestrator.js';
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { PlatformRegistry } from '../platforms/PlatformRegistry.js';
2
+ import { ContentTransformationPipeline } from '../content-type/TransformationPipeline.js';
3
+ import type { MultiPlatformPostRequest, MultiPlatformPostResult } from '../types.js';
4
+ export declare class MultiPlatformOrchestrator {
5
+ private registry;
6
+ private transformationPipeline;
7
+ constructor(registry: PlatformRegistry, transformationPipeline: ContentTransformationPipeline);
8
+ /**
9
+ * Post to all connected platforms
10
+ */
11
+ postToAll(request: MultiPlatformPostRequest): Promise<MultiPlatformPostResult>;
12
+ /**
13
+ * Post to specific platforms
14
+ */
15
+ postToPlatforms(platforms: string[], request: MultiPlatformPostRequest): Promise<MultiPlatformPostResult>;
16
+ /**
17
+ * Post to a single platform
18
+ */
19
+ private postToPlatform;
20
+ /**
21
+ * Calculate summary from results
22
+ */
23
+ private calculateSummary;
24
+ /**
25
+ * Retry failed platforms from a previous post
26
+ */
27
+ retryFailed(previousResult: MultiPlatformPostResult, request: MultiPlatformPostRequest, maxRetries?: number): Promise<MultiPlatformPostResult>;
28
+ /**
29
+ * Merge two post results
30
+ */
31
+ private mergeResults;
32
+ /**
33
+ * Delay helper for retries
34
+ */
35
+ private delay;
36
+ }
37
+ //# sourceMappingURL=MultiPlatformOrchestrator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultiPlatformOrchestrator.d.ts","sourceRoot":"","sources":["../../src/orchestration/MultiPlatformOrchestrator.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAC;AAC1F,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EAGxB,MAAM,aAAa,CAAC;AAErB,qBAAa,yBAAyB;IAElC,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,sBAAsB;gBADtB,QAAQ,EAAE,gBAAgB,EAC1B,sBAAsB,EAAE,6BAA6B;IAG/D;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAKpF;;OAEG;IACG,eAAe,CACnB,SAAS,EAAE,MAAM,EAAE,EACnB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC;IAiCnC;;OAEG;YACW,cAAc;IA2C5B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAqBxB;;OAEG;IACG,WAAW,CACf,cAAc,EAAE,uBAAuB,EACvC,OAAO,EAAE,wBAAwB,EACjC,UAAU,SAAI,GACb,OAAO,CAAC,uBAAuB,CAAC;IAmCnC;;OAEG;IACH,OAAO,CAAC,YAAY;IAoBpB;;OAEG;IACH,OAAO,CAAC,KAAK;CAGd"}
@@ -0,0 +1,167 @@
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 class MultiPlatformOrchestrator {
9
+ registry;
10
+ transformationPipeline;
11
+ constructor(registry, transformationPipeline) {
12
+ this.registry = registry;
13
+ this.transformationPipeline = transformationPipeline;
14
+ }
15
+ /**
16
+ * Post to all connected platforms
17
+ */
18
+ async postToAll(request) {
19
+ const connectedPlatforms = this.registry.getConnectedPlatforms();
20
+ return this.postToPlatforms(connectedPlatforms, request);
21
+ }
22
+ /**
23
+ * Post to specific platforms
24
+ */
25
+ async postToPlatforms(platforms, request) {
26
+ const results = {};
27
+ const errors = {};
28
+ // Post to each platform in parallel
29
+ const postPromises = platforms.map(async (platform) => {
30
+ try {
31
+ const result = await this.postToPlatform(platform, request);
32
+ results[platform] = result;
33
+ }
34
+ catch (error) {
35
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
36
+ results[platform] = {
37
+ platform,
38
+ success: false,
39
+ error: errorMessage,
40
+ };
41
+ errors[platform] = errorMessage;
42
+ }
43
+ });
44
+ await Promise.allSettled(postPromises);
45
+ // Calculate summary
46
+ const summary = this.calculateSummary(results);
47
+ return {
48
+ success: summary.successCount > 0 && summary.failureCount === 0,
49
+ results,
50
+ summary,
51
+ errors: Object.keys(errors).length > 0 ? errors : undefined,
52
+ };
53
+ }
54
+ /**
55
+ * Post to a single platform
56
+ */
57
+ async postToPlatform(platform, request) {
58
+ const adapter = this.registry.getPlatform(platform);
59
+ if (!adapter) {
60
+ throw new Error(`Platform '${platform}' is not registered`);
61
+ }
62
+ const isConnected = await adapter.isConnected();
63
+ if (!isConnected) {
64
+ throw new Error(`Platform '${platform}' is not connected`);
65
+ }
66
+ // Get platform-specific content or transform generic content
67
+ let content;
68
+ if (request.platformSpecificContent && request.platformSpecificContent[platform]) {
69
+ content = request.platformSpecificContent[platform];
70
+ }
71
+ else {
72
+ content = await this.transformationPipeline.transform(request.content, platform);
73
+ }
74
+ // Validate before posting if requested
75
+ if (request.options?.validateBeforePost) {
76
+ const validation = await this.transformationPipeline.validate(request.content, platform);
77
+ if (!validation.valid) {
78
+ throw new Error(`Validation failed: ${validation.errors.join(', ')}`);
79
+ }
80
+ }
81
+ // Post to platform
82
+ const startTime = Date.now();
83
+ const postResult = await adapter.post(content);
84
+ return {
85
+ platform,
86
+ success: true,
87
+ postId: postResult.postId,
88
+ url: postResult.url,
89
+ postedAt: new Date(startTime),
90
+ };
91
+ }
92
+ /**
93
+ * Calculate summary from results
94
+ */
95
+ calculateSummary(results) {
96
+ const totalPlatforms = Object.keys(results).length;
97
+ let successCount = 0;
98
+ let failureCount = 0;
99
+ for (const result of Object.values(results)) {
100
+ if (result.success) {
101
+ successCount++;
102
+ }
103
+ else {
104
+ failureCount++;
105
+ }
106
+ }
107
+ return {
108
+ totalPlatforms,
109
+ successCount,
110
+ failureCount,
111
+ partialSuccess: successCount > 0 && failureCount > 0,
112
+ };
113
+ }
114
+ /**
115
+ * Retry failed platforms from a previous post
116
+ */
117
+ async retryFailed(previousResult, request, maxRetries = 3) {
118
+ const failedPlatforms = Object.entries(previousResult.results)
119
+ .filter(([_, result]) => !result.success)
120
+ .map(([platform]) => platform);
121
+ if (failedPlatforms.length === 0) {
122
+ return previousResult;
123
+ }
124
+ // Retry with exponential backoff
125
+ let retryCount = 0;
126
+ let currentResult = previousResult;
127
+ while (retryCount < maxRetries && failedPlatforms.length > 0) {
128
+ await this.delay(Math.pow(2, retryCount) * 1000);
129
+ const retryResult = await this.postToPlatforms(failedPlatforms, request);
130
+ // Merge results
131
+ currentResult = this.mergeResults(currentResult, retryResult);
132
+ // Update failed platforms list
133
+ failedPlatforms.length = 0;
134
+ for (const [platform, result] of Object.entries(currentResult.results)) {
135
+ if (!result.success) {
136
+ failedPlatforms.push(platform);
137
+ }
138
+ }
139
+ retryCount++;
140
+ }
141
+ return currentResult;
142
+ }
143
+ /**
144
+ * Merge two post results
145
+ */
146
+ mergeResults(result1, result2) {
147
+ const mergedResults = { ...result1.results, ...result2.results };
148
+ const summary = this.calculateSummary(mergedResults);
149
+ const mergedErrors = {
150
+ ...result1.errors,
151
+ ...result2.errors,
152
+ };
153
+ return {
154
+ success: summary.successCount > 0 && summary.failureCount === 0,
155
+ results: mergedResults,
156
+ summary,
157
+ errors: Object.keys(mergedErrors).length > 0 ? mergedErrors : undefined,
158
+ };
159
+ }
160
+ /**
161
+ * Delay helper for retries
162
+ */
163
+ delay(ms) {
164
+ return new Promise((resolve) => setTimeout(resolve, ms));
165
+ }
166
+ }
167
+ //# sourceMappingURL=MultiPlatformOrchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultiPlatformOrchestrator.js","sourceRoot":"","sources":["../../src/orchestration/MultiPlatformOrchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAWF,MAAM,OAAO,yBAAyB;IAE1B;IACA;IAFV,YACU,QAA0B,EAC1B,sBAAqD;QADrD,aAAQ,GAAR,QAAQ,CAAkB;QAC1B,2BAAsB,GAAtB,sBAAsB,CAA+B;IAC5D,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,OAAiC;QAC/C,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,CAAC,qBAAqB,EAAE,CAAC;QACjE,OAAO,IA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,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;SACxE,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF"}
@@ -0,0 +1,31 @@
1
+ import { PlatformRegistry } from './PlatformRegistry.js';
2
+ import type { PlatformConnection, PlatformConnectionTest } from '../types.js';
3
+ export declare class ConnectionManager {
4
+ private registry;
5
+ constructor(registry: PlatformRegistry);
6
+ /**
7
+ * Connect to a platform
8
+ */
9
+ connectPlatform(platform: string, credentials: unknown): Promise<PlatformConnection>;
10
+ /**
11
+ * Disconnect from a platform
12
+ */
13
+ disconnectPlatform(platform: string): Promise<boolean>;
14
+ /**
15
+ * Test platform connection
16
+ */
17
+ testPlatformConnection(platform: string): Promise<PlatformConnectionTest>;
18
+ /**
19
+ * List all connected platforms
20
+ */
21
+ listConnectedPlatforms(): Promise<PlatformConnection[]>;
22
+ /**
23
+ * Refresh connection status for all platforms
24
+ */
25
+ refreshAllConnections(): Promise<Map<string, boolean>>;
26
+ /**
27
+ * Get connection for a platform
28
+ */
29
+ getConnection(platform: string): PlatformConnection | undefined;
30
+ }
31
+ //# sourceMappingURL=ConnectionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionManager.d.ts","sourceRoot":"","sources":["../../src/platforms/ConnectionManager.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE9E,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,gBAAgB;IAE9C;;OAEG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAyB1F;;OAEG;IACG,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgB5D;;OAEG;IACG,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA0C/E;;OAEG;IACG,sBAAsB,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAI7D;;OAEG;IACG,qBAAqB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IA2B5D;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;CAGhE"}
@@ -0,0 +1,136 @@
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 class ConnectionManager {
9
+ registry;
10
+ constructor(registry) {
11
+ this.registry = registry;
12
+ }
13
+ /**
14
+ * Connect to a platform
15
+ */
16
+ async connectPlatform(platform, credentials) {
17
+ const adapter = this.registry.getPlatform(platform);
18
+ if (!adapter) {
19
+ throw new Error(`Platform '${platform}' is not registered`);
20
+ }
21
+ // Connect using adapter
22
+ await adapter.connect(credentials);
23
+ // Get account info
24
+ const accountInfo = await adapter.getAccountInfo();
25
+ // Create connection record
26
+ const connection = {
27
+ platform,
28
+ connected: true,
29
+ username: accountInfo.username,
30
+ accountId: accountInfo.accountId,
31
+ connectedAt: new Date(),
32
+ };
33
+ this.registry.setConnection(connection);
34
+ return connection;
35
+ }
36
+ /**
37
+ * Disconnect from a platform
38
+ */
39
+ async disconnectPlatform(platform) {
40
+ const adapter = this.registry.getPlatform(platform);
41
+ if (!adapter) {
42
+ return false;
43
+ }
44
+ try {
45
+ await adapter.disconnect();
46
+ this.registry.removeConnection(platform);
47
+ return true;
48
+ }
49
+ catch (_error) {
50
+ // Silently handle disconnect errors
51
+ return false;
52
+ }
53
+ }
54
+ /**
55
+ * Test platform connection
56
+ */
57
+ async testPlatformConnection(platform) {
58
+ const adapter = this.registry.getPlatform(platform);
59
+ if (!adapter) {
60
+ return {
61
+ platform,
62
+ connected: false,
63
+ healthy: false,
64
+ error: 'Platform not registered',
65
+ };
66
+ }
67
+ try {
68
+ const isConnected = await adapter.isConnected();
69
+ if (!isConnected) {
70
+ return {
71
+ platform,
72
+ connected: false,
73
+ healthy: false,
74
+ error: 'Not connected',
75
+ };
76
+ }
77
+ const startTime = Date.now();
78
+ const testResult = await adapter.testConnection();
79
+ const responseTime = Date.now() - startTime;
80
+ return {
81
+ platform,
82
+ connected: true,
83
+ healthy: testResult.healthy,
84
+ responseTime: testResult.responseTime ?? responseTime,
85
+ };
86
+ }
87
+ catch (error) {
88
+ return {
89
+ platform,
90
+ connected: false,
91
+ healthy: false,
92
+ error: error instanceof Error ? error.message : 'Unknown error',
93
+ };
94
+ }
95
+ }
96
+ /**
97
+ * List all connected platforms
98
+ */
99
+ async listConnectedPlatforms() {
100
+ return this.registry.getAllConnections();
101
+ }
102
+ /**
103
+ * Refresh connection status for all platforms
104
+ */
105
+ async refreshAllConnections() {
106
+ const results = new Map();
107
+ const connections = this.registry.getAllConnections();
108
+ for (const connection of connections) {
109
+ const adapter = this.registry.getPlatform(connection.platform);
110
+ if (adapter) {
111
+ try {
112
+ const isConnected = await adapter.isConnected();
113
+ results.set(connection.platform, isConnected);
114
+ // Update connection status
115
+ if (!isConnected) {
116
+ this.registry.setConnection({
117
+ ...connection,
118
+ connected: false,
119
+ });
120
+ }
121
+ }
122
+ catch (error) {
123
+ results.set(connection.platform, false);
124
+ }
125
+ }
126
+ }
127
+ return results;
128
+ }
129
+ /**
130
+ * Get connection for a platform
131
+ */
132
+ getConnection(platform) {
133
+ return this.registry.getConnection(platform);
134
+ }
135
+ }
136
+ //# sourceMappingURL=ConnectionManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionManager.js","sourceRoot":"","sources":["../../src/platforms/ConnectionManager.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAKF,MAAM,OAAO,iBAAiB;IACR;IAApB,YAAoB,QAA0B;QAA1B,aAAQ,GAAR,QAAQ,CAAkB;IAAG,CAAC;IAElD;;OAEG;IACH,KAAK,CAAC,eAAe,CAAC,QAAgB,EAAE,WAAoB;QAC1D,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACpD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,aAAa,QAAQ,qBAAqB,CAAC,CAAC;QAC9D,CAAC;QAED,wBAAwB;QACxB,MAAM,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAEnC,mBAAmB;QACnB,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC;QAEnD,2BAA2B;QAC3B,MAAM,UAAU,GAAuB;YACrC,QAAQ;YACR,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,SAAS,EAAE,WAAW,CAAC,SAAS;YAChC,WAAW,EAAE,IAAI,IAAI,EAAE;SACxB,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QACxC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB,CAAC,QAAgB;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACpD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;YAC3B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