@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.
Files changed (49) hide show
  1. package/dist/SocialMediaManager.d.ts +104 -0
  2. package/dist/SocialMediaManager.d.ts.map +1 -0
  3. package/dist/SocialMediaManager.js +296 -0
  4. package/dist/SocialMediaManager.js.map +1 -0
  5. package/dist/content-type/ContentTypeMatching.d.ts +26 -0
  6. package/dist/content-type/ContentTypeMatching.d.ts.map +1 -0
  7. package/dist/content-type/ContentTypeMatching.js +113 -0
  8. package/dist/content-type/ContentTypeMatching.js.map +1 -0
  9. package/dist/content-type/ContentTypeRegistry.d.ts +25 -0
  10. package/dist/content-type/ContentTypeRegistry.d.ts.map +1 -0
  11. package/dist/content-type/ContentTypeRegistry.js +113 -0
  12. package/dist/content-type/ContentTypeRegistry.js.map +1 -0
  13. package/dist/content-type/TransformationPipeline.d.ts +50 -0
  14. package/dist/content-type/TransformationPipeline.d.ts.map +1 -0
  15. package/dist/content-type/TransformationPipeline.js +169 -0
  16. package/dist/content-type/TransformationPipeline.js.map +1 -0
  17. package/dist/errors.d.ts +12 -0
  18. package/dist/errors.d.ts.map +1 -0
  19. package/dist/errors.js +21 -0
  20. package/dist/errors.js.map +1 -0
  21. package/dist/index.d.ts +13 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +18 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/orchestration/MultiPlatformOrchestrator.d.ts +37 -0
  26. package/dist/orchestration/MultiPlatformOrchestrator.d.ts.map +1 -0
  27. package/dist/orchestration/MultiPlatformOrchestrator.js +167 -0
  28. package/dist/orchestration/MultiPlatformOrchestrator.js.map +1 -0
  29. package/dist/platforms/ConnectionManager.d.ts +31 -0
  30. package/dist/platforms/ConnectionManager.d.ts.map +1 -0
  31. package/dist/platforms/ConnectionManager.js +136 -0
  32. package/dist/platforms/ConnectionManager.js.map +1 -0
  33. package/dist/platforms/PlatformRegistry.d.ts +73 -0
  34. package/dist/platforms/PlatformRegistry.d.ts.map +1 -0
  35. package/dist/platforms/PlatformRegistry.js +93 -0
  36. package/dist/platforms/PlatformRegistry.js.map +1 -0
  37. package/dist/scheduling/JitterCalculator.d.ts +37 -0
  38. package/dist/scheduling/JitterCalculator.d.ts.map +1 -0
  39. package/dist/scheduling/JitterCalculator.js +93 -0
  40. package/dist/scheduling/JitterCalculator.js.map +1 -0
  41. package/dist/scheduling/ScheduleManager.d.ts +48 -0
  42. package/dist/scheduling/ScheduleManager.d.ts.map +1 -0
  43. package/dist/scheduling/ScheduleManager.js +125 -0
  44. package/dist/scheduling/ScheduleManager.js.map +1 -0
  45. package/dist/types.d.ts +214 -0
  46. package/dist/types.d.ts.map +1 -0
  47. package/dist/types.js +9 -0
  48. package/dist/types.js.map +1 -0
  49. package/package.json +7 -7
@@ -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;;OA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CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,QAAgB;QAC5B,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;CACF"}
@@ -0,0 +1,73 @@
1
+ import type { PlatformConnection, PlatformConfig } from '../types.js';
2
+ export interface PlatformAdapter {
3
+ platform: string;
4
+ isConnected(): Promise<boolean>;
5
+ connect(credentials: unknown): Promise<void>;
6
+ disconnect(): Promise<void>;
7
+ post(content: unknown): Promise<{
8
+ postId: string;
9
+ url: string;
10
+ }>;
11
+ testConnection(): Promise<{
12
+ healthy: boolean;
13
+ responseTime?: number;
14
+ }>;
15
+ getAccountInfo(): Promise<{
16
+ username?: string;
17
+ accountId?: string;
18
+ }>;
19
+ }
20
+ export declare class PlatformRegistry {
21
+ private platforms;
22
+ private connections;
23
+ private configs;
24
+ /**
25
+ * Register a platform adapter
26
+ */
27
+ registerPlatform(adapter: PlatformAdapter, config?: PlatformConfig): void;
28
+ /**
29
+ * Get a platform adapter
30
+ */
31
+ getPlatform(platform: string): PlatformAdapter | undefined;
32
+ /**
33
+ * Check if a platform is registered
34
+ */
35
+ hasPlatform(platform: string): boolean;
36
+ /**
37
+ * Get all registered platforms
38
+ */
39
+ getRegisteredPlatforms(): string[];
40
+ /**
41
+ * Get platform configuration
42
+ */
43
+ getPlatformConfig(platform: string): PlatformConfig | undefined;
44
+ /**
45
+ * Set platform connection info
46
+ */
47
+ setConnection(connection: PlatformConnection): void;
48
+ /**
49
+ * Get platform connection info
50
+ */
51
+ getConnection(platform: string): PlatformConnection | undefined;
52
+ /**
53
+ * Remove platform connection
54
+ */
55
+ removeConnection(platform: string): boolean;
56
+ /**
57
+ * Get all connections
58
+ */
59
+ getAllConnections(): PlatformConnection[];
60
+ /**
61
+ * Check if platform is connected
62
+ */
63
+ isConnected(platform: string): boolean;
64
+ /**
65
+ * Get connected platforms
66
+ */
67
+ getConnectedPlatforms(): string[];
68
+ /**
69
+ * Get enabled platforms from config
70
+ */
71
+ getEnabledPlatforms(): string[];
72
+ }
73
+ //# sourceMappingURL=PlatformRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformRegistry.d.ts","sourceRoot":"","sources":["../../src/platforms/PlatformRegistry.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEtE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjE,cAAc,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvE,cAAc,IAAI,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtE;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAA2C;IAC5D,OAAO,CAAC,WAAW,CAA8C;IACjE,OAAO,CAAC,OAAO,CAA0C;IAEzD;;OAEG;IACH,gBAAgB,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI;IAOzE;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAI1D;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAItC;;OAEG;IACH,sBAAsB,IAAI,MAAM,EAAE;IAIlC;;OAEG;IACH,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI/D;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,kBAAkB,GAAG,IAAI;IAInD;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAI/D;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI3C;;OAEG;IACH,iBAAiB,IAAI,kBAAkB,EAAE;IAIzC;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAKtC;;OAEG;IACH,qBAAqB,IAAI,MAAM,EAAE;IAMjC;;OAEG;IACH,mBAAmB,IAAI,MAAM,EAAE;CAKhC"}
@@ -0,0 +1,93 @@
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 PlatformRegistry {
9
+ platforms = new Map();
10
+ connections = new Map();
11
+ configs = new Map();
12
+ /**
13
+ * Register a platform adapter
14
+ */
15
+ registerPlatform(adapter, config) {
16
+ this.platforms.set(adapter.platform, adapter);
17
+ if (config) {
18
+ this.configs.set(adapter.platform, config);
19
+ }
20
+ }
21
+ /**
22
+ * Get a platform adapter
23
+ */
24
+ getPlatform(platform) {
25
+ return this.platforms.get(platform);
26
+ }
27
+ /**
28
+ * Check if a platform is registered
29
+ */
30
+ hasPlatform(platform) {
31
+ return this.platforms.has(platform);
32
+ }
33
+ /**
34
+ * Get all registered platforms
35
+ */
36
+ getRegisteredPlatforms() {
37
+ return Array.from(this.platforms.keys());
38
+ }
39
+ /**
40
+ * Get platform configuration
41
+ */
42
+ getPlatformConfig(platform) {
43
+ return this.configs.get(platform);
44
+ }
45
+ /**
46
+ * Set platform connection info
47
+ */
48
+ setConnection(connection) {
49
+ this.connections.set(connection.platform, connection);
50
+ }
51
+ /**
52
+ * Get platform connection info
53
+ */
54
+ getConnection(platform) {
55
+ return this.connections.get(platform);
56
+ }
57
+ /**
58
+ * Remove platform connection
59
+ */
60
+ removeConnection(platform) {
61
+ return this.connections.delete(platform);
62
+ }
63
+ /**
64
+ * Get all connections
65
+ */
66
+ getAllConnections() {
67
+ return Array.from(this.connections.values());
68
+ }
69
+ /**
70
+ * Check if platform is connected
71
+ */
72
+ isConnected(platform) {
73
+ const connection = this.connections.get(platform);
74
+ return connection?.connected ?? false;
75
+ }
76
+ /**
77
+ * Get connected platforms
78
+ */
79
+ getConnectedPlatforms() {
80
+ return Array.from(this.connections.values())
81
+ .filter((conn) => conn.connected)
82
+ .map((conn) => conn.platform);
83
+ }
84
+ /**
85
+ * Get enabled platforms from config
86
+ */
87
+ getEnabledPlatforms() {
88
+ return Array.from(this.configs.entries())
89
+ .filter(([_, config]) => config.enabled)
90
+ .map(([platform]) => platform);
91
+ }
92
+ }
93
+ //# sourceMappingURL=PlatformRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformRegistry.js","sourceRoot":"","sources":["../../src/platforms/PlatformRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAcF,MAAM,OAAO,gBAAgB;IACnB,SAAS,GAAiC,IAAI,GAAG,EAAE,CAAC;IACpD,WAAW,GAAoC,IAAI,GAAG,EAAE,CAAC;IACzD,OAAO,GAAgC,IAAI,GAAG,EAAE,CAAC;IAEzD;;OAEG;IACH,gBAAgB,CAAC,OAAwB,EAAE,MAAuB;QAChE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9C,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM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AAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;aACzC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC;aAChC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;aACtC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;aACvC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;CACF"}
@@ -0,0 +1,37 @@
1
+ import type { JitterConfig } from '../types.js';
2
+ export declare class JitterCalculator {
3
+ /**
4
+ * Calculate jittered time based on configuration
5
+ */
6
+ calculateJitteredTime(baseTime: Date, jitter: JitterConfig): Date;
7
+ /**
8
+ * Generate jitter in milliseconds based on distribution
9
+ */
10
+ private generateJitter;
11
+ /**
12
+ * Generate uniform distribution jitter
13
+ */
14
+ private uniformJitter;
15
+ /**
16
+ * Generate normal distribution jitter using Box-Muller transform
17
+ */
18
+ private normalJitter;
19
+ /**
20
+ * Generate exponential distribution jitter
21
+ */
22
+ private exponentialJitter;
23
+ /**
24
+ * Calculate multiple jittered times for different platforms
25
+ */
26
+ calculateMultipleJitteredTimes(baseTime: Date, jitter: JitterConfig, count: number): Date[];
27
+ /**
28
+ * Get jitter statistics (for testing/debugging)
29
+ */
30
+ getJitterStatistics(jitter: JitterConfig, samples?: number): {
31
+ mean: number;
32
+ min: number;
33
+ max: number;
34
+ stdDev: number;
35
+ };
36
+ }
37
+ //# sourceMappingURL=JitterCalculator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JitterCalculator.d.ts","sourceRoot":"","sources":["../../src/scheduling/JitterCalculator.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,qBAAa,gBAAgB;IAC3B;;OAEG;IACH,qBAAqB,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;IASjE;;OAEG;IACH,OAAO,CAAC,cAAc;IAgBtB;;OAEG;IACH,OAAO,CAAC,aAAa;IAIrB;;OAEG;IACH,OAAO,CAAC,YAAY;IAgBpB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAWzB;;OAEG;IACH,8BAA8B,CAC5B,QAAQ,EAAE,IAAI,EACd,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,GACZ,IAAI,EAAE;IAQT;;OAEG;IACH,mBAAmB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,SAAO,GAAG;QACzD,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;KAChB;CAgBF"}
@@ -0,0 +1,93 @@
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 JitterCalculator {
9
+ /**
10
+ * Calculate jittered time based on configuration
11
+ */
12
+ calculateJitteredTime(baseTime, jitter) {
13
+ if (!jitter.enabled) {
14
+ return baseTime;
15
+ }
16
+ const jitterMs = this.generateJitter(jitter);
17
+ return new Date(baseTime.getTime() + jitterMs);
18
+ }
19
+ /**
20
+ * Generate jitter in milliseconds based on distribution
21
+ */
22
+ generateJitter(jitter) {
23
+ const minMs = jitter.minMinutes * 60 * 1000;
24
+ const maxMs = jitter.maxMinutes * 60 * 1000;
25
+ switch (jitter.distribution) {
26
+ case 'uniform':
27
+ return this.uniformJitter(minMs, maxMs);
28
+ case 'normal':
29
+ return this.normalJitter(minMs, maxMs);
30
+ case 'exponential':
31
+ return this.exponentialJitter(minMs, maxMs);
32
+ default:
33
+ return 0;
34
+ }
35
+ }
36
+ /**
37
+ * Generate uniform distribution jitter
38
+ */
39
+ uniformJitter(minMs, maxMs) {
40
+ return Math.random() * (maxMs - minMs) + minMs;
41
+ }
42
+ /**
43
+ * Generate normal distribution jitter using Box-Muller transform
44
+ */
45
+ normalJitter(minMs, maxMs) {
46
+ const u1 = Math.random();
47
+ const u2 = Math.random();
48
+ const z = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);
49
+ const mean = (minMs + maxMs) / 2;
50
+ const stdDev = (maxMs - minMs) / 6; // 99.7% within range
51
+ let result = mean + z * stdDev;
52
+ // Clamp to min/max range
53
+ result = Math.max(minMs, Math.min(maxMs, result));
54
+ return result;
55
+ }
56
+ /**
57
+ * Generate exponential distribution jitter
58
+ */
59
+ exponentialJitter(minMs, maxMs) {
60
+ const range = maxMs - minMs;
61
+ const lambda = 1 / (range / 2);
62
+ let result = minMs + -Math.log(Math.random()) / lambda;
63
+ // Clamp to min/max range
64
+ result = Math.max(minMs, Math.min(maxMs, result));
65
+ return result;
66
+ }
67
+ /**
68
+ * Calculate multiple jittered times for different platforms
69
+ */
70
+ calculateMultipleJitteredTimes(baseTime, jitter, count) {
71
+ const times = [];
72
+ for (let i = 0; i < count; i++) {
73
+ times.push(this.calculateJitteredTime(baseTime, jitter));
74
+ }
75
+ return times;
76
+ }
77
+ /**
78
+ * Get jitter statistics (for testing/debugging)
79
+ */
80
+ getJitterStatistics(jitter, samples = 1000) {
81
+ const jitters = [];
82
+ for (let i = 0; i < samples; i++) {
83
+ jitters.push(this.generateJitter(jitter));
84
+ }
85
+ const mean = jitters.reduce((a, b) => a + b, 0) / jitters.length;
86
+ const min = Math.min(...jitters);
87
+ const max = Math.max(...jitters);
88
+ const variance = jitters.reduce((acc, val) => acc + Math.pow(val - mean, 2), 0) / jitters.length;
89
+ const stdDev = Math.sqrt(variance);
90
+ return { mean, min, max, stdDev };
91
+ }
92
+ }
93
+ //# sourceMappingURL=JitterCalculator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JitterCalculator.js","sourceRoot":"","sources":["../../src/scheduling/JitterCalculator.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAIF,MAAM,OAAO,gBAAgB;IAC3B;;OAEG;IACH,qBAAqB,CAAC,QAAc,EAAE,MAAoB;QACxD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC7C,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACK,cAAc,CAAC,MAAoB;QACzC,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,GAAG,EAAE,GAAG,IAAI,CAAC;QAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,GAAG,EAAE,GAAG,IAAI,CAAC;QAE5C,QAAQ,MAAM,CAAC,YAAY,EAAE,CAAC;YAC5B,KAAK,SAAS;gBACZ,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAC1C,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACzC,KAAK,aAAa;gBAChB,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAC9C;gBACE,OAAO,CAAC,CAAC;QACb,CAAC;IACH,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,KAAa,EAAE,KAAa;QAChD,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG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AAM,EAAE,CAAC;IACpC,CAAC;CACF"}
@@ -0,0 +1,48 @@
1
+ import type { ScheduledPost, ScheduleFilters } from '../types.js';
2
+ export declare class ScheduleManager {
3
+ private scheduledPosts;
4
+ /**
5
+ * Add a scheduled post
6
+ */
7
+ addScheduledPost(post: Omit<ScheduledPost, 'scheduleId' | 'createdAt' | 'updatedAt'>): string;
8
+ /**
9
+ * Get a scheduled post by ID
10
+ */
11
+ getScheduledPost(scheduleId: string): ScheduledPost | undefined;
12
+ /**
13
+ * Update a scheduled post
14
+ */
15
+ updateScheduledPost(scheduleId: string, updates: Partial<Omit<ScheduledPost, 'scheduleId' | 'createdAt'>>): boolean;
16
+ /**
17
+ * Cancel a scheduled post
18
+ */
19
+ cancelScheduledPost(scheduleId: string): boolean;
20
+ /**
21
+ * List scheduled posts with optional filters
22
+ */
23
+ listScheduledPosts(filters?: ScheduleFilters): ScheduledPost[];
24
+ /**
25
+ * Get all scheduled posts for a platform
26
+ */
27
+ getScheduledPostsByPlatform(platform: string): ScheduledPost[];
28
+ /**
29
+ * Get pending scheduled posts
30
+ */
31
+ getPendingPosts(): ScheduledPost[];
32
+ /**
33
+ * Clean up old completed/cancelled posts
34
+ */
35
+ cleanupOldPosts(olderThanDays?: number): number;
36
+ /**
37
+ * Get statistics about scheduled posts
38
+ */
39
+ getStatistics(): {
40
+ total: number;
41
+ pending: number;
42
+ posted: number;
43
+ partial: number;
44
+ failed: number;
45
+ cancelled: number;
46
+ };
47
+ }
48
+ //# sourceMappingURL=ScheduleManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduleManager.d.ts","sourceRoot":"","sources":["../../src/scheduling/ScheduleManager.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAElE,qBAAa,eAAe;IAC1B,OAAO,CAAC,cAAc,CAAyC;IAE/D;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,WAAW,GAAG,WAAW,CAAC,GAAG,MAAM;IAe7F;;OAEG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAI/D;;OAEG;IACH,mBAAmB,CACjB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,WAAW,CAAC,CAAC,GAChE,OAAO;IAgBV;;OAEG;IACH,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAIhD;;OAEG;IACH,kBAAkB,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,aAAa,EAAE;IA+B9D;;OAEG;IACH,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,EAAE;IAI9D;;OAEG;IACH,eAAe,IAAI,aAAa,EAAE;IAIlC;;OAEG;IACH,eAAe,CAAC,aAAa,SAAK,GAAG,MAAM;IAmB3C;;OAEG;IACH,aAAa,IAAI;QACf,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB;CAgBF"}
@@ -0,0 +1,125 @@
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 { v4 as uuidv4 } from 'uuid';
9
+ export class ScheduleManager {
10
+ scheduledPosts = new Map();
11
+ /**
12
+ * Add a scheduled post
13
+ */
14
+ addScheduledPost(post) {
15
+ const scheduleId = uuidv4();
16
+ const now = new Date();
17
+ const scheduledPost = {
18
+ ...post,
19
+ scheduleId,
20
+ createdAt: now,
21
+ updatedAt: now,
22
+ };
23
+ this.scheduledPosts.set(scheduleId, scheduledPost);
24
+ return scheduleId;
25
+ }
26
+ /**
27
+ * Get a scheduled post by ID
28
+ */
29
+ getScheduledPost(scheduleId) {
30
+ return this.scheduledPosts.get(scheduleId);
31
+ }
32
+ /**
33
+ * Update a scheduled post
34
+ */
35
+ updateScheduledPost(scheduleId, updates) {
36
+ const post = this.scheduledPosts.get(scheduleId);
37
+ if (!post) {
38
+ return false;
39
+ }
40
+ const updatedPost = {
41
+ ...post,
42
+ ...updates,
43
+ updatedAt: new Date(),
44
+ };
45
+ this.scheduledPosts.set(scheduleId, updatedPost);
46
+ return true;
47
+ }
48
+ /**
49
+ * Cancel a scheduled post
50
+ */
51
+ cancelScheduledPost(scheduleId) {
52
+ return this.updateScheduledPost(scheduleId, { status: 'cancelled' });
53
+ }
54
+ /**
55
+ * List scheduled posts with optional filters
56
+ */
57
+ listScheduledPosts(filters) {
58
+ let posts = Array.from(this.scheduledPosts.values());
59
+ if (!filters) {
60
+ return posts;
61
+ }
62
+ // Filter by status
63
+ if (filters.status && filters.status.length > 0) {
64
+ posts = posts.filter((post) => filters.status.includes(post.status));
65
+ }
66
+ // Filter by platforms
67
+ if (filters.platforms && filters.platforms.length > 0) {
68
+ posts = posts.filter((post) => post.platforms.some((platform) => filters.platforms.includes(platform)));
69
+ }
70
+ // Filter by date range
71
+ if (filters.startDate) {
72
+ posts = posts.filter((post) => post.scheduledTime >= filters.startDate);
73
+ }
74
+ if (filters.endDate) {
75
+ posts = posts.filter((post) => post.scheduledTime <= filters.endDate);
76
+ }
77
+ return posts;
78
+ }
79
+ /**
80
+ * Get all scheduled posts for a platform
81
+ */
82
+ getScheduledPostsByPlatform(platform) {
83
+ return this.listScheduledPosts({ platforms: [platform] });
84
+ }
85
+ /**
86
+ * Get pending scheduled posts
87
+ */
88
+ getPendingPosts() {
89
+ return this.listScheduledPosts({ status: ['pending'] });
90
+ }
91
+ /**
92
+ * Clean up old completed/cancelled posts
93
+ */
94
+ cleanupOldPosts(olderThanDays = 30) {
95
+ const cutoffDate = new Date();
96
+ cutoffDate.setDate(cutoffDate.getDate() - olderThanDays);
97
+ let removedCount = 0;
98
+ for (const [scheduleId, post] of this.scheduledPosts.entries()) {
99
+ if ((post.status === 'posted' || post.status === 'cancelled' || post.status === 'failed') &&
100
+ post.updatedAt < cutoffDate) {
101
+ this.scheduledPosts.delete(scheduleId);
102
+ removedCount++;
103
+ }
104
+ }
105
+ return removedCount;
106
+ }
107
+ /**
108
+ * Get statistics about scheduled posts
109
+ */
110
+ getStatistics() {
111
+ const stats = {
112
+ total: this.scheduledPosts.size,
113
+ pending: 0,
114
+ posted: 0,
115
+ partial: 0,
116
+ failed: 0,
117
+ cancelled: 0,
118
+ };
119
+ for (const post of this.scheduledPosts.values()) {
120
+ stats[post.status]++;
121
+ }
122
+ return stats;
123
+ }
124
+ }
125
+ //# sourceMappingURL=ScheduleManager.js.map