@bernierllc/social-media-manager 1.7.3 → 1.7.5
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/dist/SocialMediaManager.d.ts +104 -0
- package/dist/SocialMediaManager.d.ts.map +1 -0
- package/dist/SocialMediaManager.js +296 -0
- package/dist/SocialMediaManager.js.map +1 -0
- package/dist/content-type/ContentTypeMatching.d.ts +26 -0
- package/dist/content-type/ContentTypeMatching.d.ts.map +1 -0
- package/dist/content-type/ContentTypeMatching.js +113 -0
- package/dist/content-type/ContentTypeMatching.js.map +1 -0
- package/dist/content-type/ContentTypeRegistry.d.ts +25 -0
- package/dist/content-type/ContentTypeRegistry.d.ts.map +1 -0
- package/dist/content-type/ContentTypeRegistry.js +113 -0
- package/dist/content-type/ContentTypeRegistry.js.map +1 -0
- package/dist/content-type/TransformationPipeline.d.ts +50 -0
- package/dist/content-type/TransformationPipeline.d.ts.map +1 -0
- package/dist/content-type/TransformationPipeline.js +169 -0
- package/dist/content-type/TransformationPipeline.js.map +1 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +21 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestration/MultiPlatformOrchestrator.d.ts +37 -0
- package/dist/orchestration/MultiPlatformOrchestrator.d.ts.map +1 -0
- package/dist/orchestration/MultiPlatformOrchestrator.js +167 -0
- package/dist/orchestration/MultiPlatformOrchestrator.js.map +1 -0
- package/dist/platforms/ConnectionManager.d.ts +31 -0
- package/dist/platforms/ConnectionManager.d.ts.map +1 -0
- package/dist/platforms/ConnectionManager.js +136 -0
- package/dist/platforms/ConnectionManager.js.map +1 -0
- package/dist/platforms/PlatformRegistry.d.ts +73 -0
- package/dist/platforms/PlatformRegistry.d.ts.map +1 -0
- package/dist/platforms/PlatformRegistry.js +93 -0
- package/dist/platforms/PlatformRegistry.js.map +1 -0
- package/dist/scheduling/JitterCalculator.d.ts +37 -0
- package/dist/scheduling/JitterCalculator.d.ts.map +1 -0
- package/dist/scheduling/JitterCalculator.js +93 -0
- package/dist/scheduling/JitterCalculator.js.map +1 -0
- package/dist/scheduling/ScheduleManager.d.ts +48 -0
- package/dist/scheduling/ScheduleManager.d.ts.map +1 -0
- package/dist/scheduling/ScheduleManager.js +125 -0
- package/dist/scheduling/ScheduleManager.js.map +1 -0
- package/dist/types.d.ts +214 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,113 @@
|
|
|
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 const CONTENT_TYPE_REGISTRY = {
|
|
9
|
+
'generic-social-content': {
|
|
10
|
+
accepts: ['blog-post-content', 'article-content', 'text-content'],
|
|
11
|
+
produces: ['social-media-content:*'],
|
|
12
|
+
transformations: ['text-extraction', 'media-optimization', 'link-shortening'],
|
|
13
|
+
},
|
|
14
|
+
'social-media-content:twitter': {
|
|
15
|
+
accepts: ['generic-social-content', 'blog-post-content'],
|
|
16
|
+
produces: ['social-media-content:twitter'],
|
|
17
|
+
constraints: {
|
|
18
|
+
maxTextLength: 280,
|
|
19
|
+
maxImages: 4,
|
|
20
|
+
maxVideos: 1,
|
|
21
|
+
maxHashtags: 10,
|
|
22
|
+
},
|
|
23
|
+
transformations: ['thread-splitting', 'character-counting', 'media-resize'],
|
|
24
|
+
},
|
|
25
|
+
'social-media-content:linkedin': {
|
|
26
|
+
accepts: ['generic-social-content', 'blog-post-content', 'article-content'],
|
|
27
|
+
produces: ['social-media-content:linkedin'],
|
|
28
|
+
constraints: {
|
|
29
|
+
maxTextLength: 3000,
|
|
30
|
+
maxImages: 20,
|
|
31
|
+
maxVideos: 1,
|
|
32
|
+
maxHashtags: 30,
|
|
33
|
+
},
|
|
34
|
+
transformations: ['article-conversion', 'professional-tone', 'hashtag-optimization'],
|
|
35
|
+
},
|
|
36
|
+
'social-media-content:facebook': {
|
|
37
|
+
accepts: ['generic-social-content', 'blog-post-content'],
|
|
38
|
+
produces: ['social-media-content:facebook'],
|
|
39
|
+
constraints: {
|
|
40
|
+
maxTextLength: 63206,
|
|
41
|
+
maxImages: 10,
|
|
42
|
+
maxVideos: 1,
|
|
43
|
+
},
|
|
44
|
+
transformations: ['text-formatting', 'link-preview'],
|
|
45
|
+
},
|
|
46
|
+
'social-media-content:instagram': {
|
|
47
|
+
accepts: ['generic-social-content'],
|
|
48
|
+
produces: ['social-media-content:instagram'],
|
|
49
|
+
constraints: {
|
|
50
|
+
maxTextLength: 2200,
|
|
51
|
+
maxImages: 10,
|
|
52
|
+
maxVideos: 1,
|
|
53
|
+
maxHashtags: 30,
|
|
54
|
+
requiresMedia: true,
|
|
55
|
+
},
|
|
56
|
+
transformations: ['media-resize', 'hashtag-optimization'],
|
|
57
|
+
},
|
|
58
|
+
'social-media-content:mastodon': {
|
|
59
|
+
accepts: ['generic-social-content', 'blog-post-content'],
|
|
60
|
+
produces: ['social-media-content:mastodon'],
|
|
61
|
+
constraints: {
|
|
62
|
+
maxTextLength: 500,
|
|
63
|
+
maxImages: 4,
|
|
64
|
+
maxVideos: 1,
|
|
65
|
+
},
|
|
66
|
+
transformations: ['character-counting', 'media-resize'],
|
|
67
|
+
},
|
|
68
|
+
'social-media-content:bluesky': {
|
|
69
|
+
accepts: ['generic-social-content', 'blog-post-content'],
|
|
70
|
+
produces: ['social-media-content:bluesky'],
|
|
71
|
+
constraints: {
|
|
72
|
+
maxTextLength: 300,
|
|
73
|
+
maxImages: 4,
|
|
74
|
+
maxVideos: 1,
|
|
75
|
+
},
|
|
76
|
+
transformations: ['character-counting', 'media-resize'],
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
export class ContentTypeRegistry {
|
|
80
|
+
/**
|
|
81
|
+
* Get registry entry for a content type
|
|
82
|
+
*/
|
|
83
|
+
getEntry(contentType) {
|
|
84
|
+
return CONTENT_TYPE_REGISTRY[contentType];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get all registered content types
|
|
88
|
+
*/
|
|
89
|
+
getAllTypes() {
|
|
90
|
+
return Object.keys(CONTENT_TYPE_REGISTRY);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Check if a content type exists in the registry
|
|
94
|
+
*/
|
|
95
|
+
hasType(contentType) {
|
|
96
|
+
return contentType in CONTENT_TYPE_REGISTRY;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get constraints for a platform
|
|
100
|
+
*/
|
|
101
|
+
getConstraints(platform) {
|
|
102
|
+
const contentType = `social-media-content:${platform}`;
|
|
103
|
+
return CONTENT_TYPE_REGISTRY[contentType]?.constraints;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get transformations for a platform
|
|
107
|
+
*/
|
|
108
|
+
getTransformations(platform) {
|
|
109
|
+
const contentType = `social-media-content:${platform}`;
|
|
110
|
+
return CONTENT_TYPE_REGISTRY[contentType]?.transformations || [];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=ContentTypeRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentTypeRegistry.js","sourceRoot":"","sources":["../../src/content-type/ContentTypeRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAIF,MAAM,CAAC,MAAM,qBAAqB,GAA6C;IAC7E,wBAAwB,EAAE;QACxB,OAAO,EAAE,CAAC,mBAAmB,EAAE,iBAAiB,EAAE,cAAc,CAAC;QACjE,QAAQ,EAAE,CAAC,wB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,50 @@
|
|
|
1
|
+
import type { GenericSocialContent, ValidationResult } from '../types.js';
|
|
2
|
+
export declare class ContentTransformationPipeline {
|
|
3
|
+
private contentTypeMatching;
|
|
4
|
+
constructor();
|
|
5
|
+
/**
|
|
6
|
+
* Transform generic content to platform-specific format
|
|
7
|
+
*/
|
|
8
|
+
transform(source: GenericSocialContent, targetPlatform: string): Promise<unknown>;
|
|
9
|
+
/**
|
|
10
|
+
* Apply a single transformation to content
|
|
11
|
+
*/
|
|
12
|
+
private applyTransformation;
|
|
13
|
+
/**
|
|
14
|
+
* Split long text into a thread (Twitter)
|
|
15
|
+
*/
|
|
16
|
+
private splitIntoThread;
|
|
17
|
+
/**
|
|
18
|
+
* Convert to article format (LinkedIn)
|
|
19
|
+
*/
|
|
20
|
+
private convertToArticle;
|
|
21
|
+
/**
|
|
22
|
+
* Resize media for platform requirements
|
|
23
|
+
*/
|
|
24
|
+
private resizeMedia;
|
|
25
|
+
/**
|
|
26
|
+
* Optimize hashtags for platform
|
|
27
|
+
*/
|
|
28
|
+
private optimizeHashtags;
|
|
29
|
+
/**
|
|
30
|
+
* Enforce character limit for platform
|
|
31
|
+
*/
|
|
32
|
+
private enforceCharacterLimit;
|
|
33
|
+
/**
|
|
34
|
+
* Format text for better readability
|
|
35
|
+
*/
|
|
36
|
+
private formatText;
|
|
37
|
+
/**
|
|
38
|
+
* Enable link preview (Facebook)
|
|
39
|
+
*/
|
|
40
|
+
private enableLinkPreview;
|
|
41
|
+
/**
|
|
42
|
+
* Adjust tone to be more professional (LinkedIn)
|
|
43
|
+
*/
|
|
44
|
+
private adjustToProfessionalTone;
|
|
45
|
+
/**
|
|
46
|
+
* Validate content for platform without transforming
|
|
47
|
+
*/
|
|
48
|
+
validate(content: GenericSocialContent, platform: string): Promise<ValidationResult>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=TransformationPipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransformationPipeline.d.ts","sourceRoot":"","sources":["../../src/content-type/TransformationPipeline.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1E,qBAAa,6BAA6B;IACxC,OAAO,CAAC,mBAAmB,CAAsB;;IAMjD;;OAEG;IACG,SAAS,CAAC,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA4BvF;;OAEG;YACW,mBAAmB;IAkCjC;;OAEG;YACW,eAAe;IAqB7B;;OAEG;YACW,gBAAgB;IAO9B;;OAEG;YACW,WAAW;IAYzB;;OAEG;YACW,gBAAgB;IAiB9B;;OAEG;YACW,qBAAqB;IAyBnC;;OAEG;YACW,UAAU;IAOxB;;OAEG;YACW,iBAAiB;IAO/B;;OAEG;YACW,wBAAwB;IAOtC;;OAEG;IACG,QAAQ,CAAC,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAG3F"}
|
|
@@ -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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AE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK;SACnD,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,UAAU,CAAC,OAAgC;QACvD,OAAO;YACL,GAAG,OAAO;YACV,aAAa,EAAE,IAAI;SACpB,CAAC;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"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type SocialMediaManagerErrorCode = 'SOCIAL_MEDIA_MANAGER_ERROR' | 'INVALID_INPUT' | 'OPERATION_FAILED';
|
|
2
|
+
export interface SocialMediaManagerErrorOptions {
|
|
3
|
+
cause?: Error;
|
|
4
|
+
code?: SocialMediaManagerErrorCode;
|
|
5
|
+
context?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export declare class SocialMediaManagerError extends Error {
|
|
8
|
+
readonly code: SocialMediaManagerErrorCode;
|
|
9
|
+
readonly context?: Record<string, unknown>;
|
|
10
|
+
constructor(message: string, options?: SocialMediaManagerErrorOptions);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,2BAA2B,GACnC,4BAA4B,GAC5B,eAAe,GACf,kBAAkB,CAAC;AAEvB,MAAM,WAAW,8BAA8B;IAC7C,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,2BAA2B,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,EAAE,2BAA2B,CAAC;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAE/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,8BAA8B;CAStE"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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 SocialMediaManagerError extends Error {
|
|
9
|
+
code;
|
|
10
|
+
context;
|
|
11
|
+
constructor(message, options) {
|
|
12
|
+
super(message, options?.cause ? { cause: options.cause } : undefined);
|
|
13
|
+
this.name = 'SocialMediaManagerError';
|
|
14
|
+
this.code = options?.code ?? 'SOCIAL_MEDIA_MANAGER_ERROR';
|
|
15
|
+
if (options?.context !== undefined) {
|
|
16
|
+
this.context = options.context;
|
|
17
|
+
}
|
|
18
|
+
Error.captureStackTrace?.(this, this.constructor);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAaF,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACvC,IAAI,CAA8B;IAClC,OAAO,CAA2B;IAE3C,YAAY,OAAe,EAAE,OAAwC;QACnE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACtE,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,4BAA4B,CAAC;QAC1D,IAAI,OAAO,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;YACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QACjC,CAAC;QACD,KAAK,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
export { SocialMediaManagerError, type SocialMediaManagerErrorCode, type SocialMediaManagerErrorOptions } from './errors.js';
|
|
13
|
+
//# 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;AAEvE,OAAO,EAAE,uBAAuB,EAAE,KAAK,2BAA2B,EAAE,KAAK,8BAA8B,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
export { SocialMediaManagerError } from './errors.js';
|
|
18
|
+
//# 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;AAuCzF,OAAO,EAAE,uBAAuB,EAAyE,MAAM,aAAa,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,IAAI,CAAC,eAAe,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe,CACnB,SAAmB,EACnB,OAAiC;QAEjC,MAAM,OAAO,GAAuC,EAAE,CAAC;QACvD,MAAM,MAAM,GAA2B,EAAE,CAAC;QAE1C,oCAAoC;QACpC,MAA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