digital-tools 2.0.2 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/package.json +3 -4
- package/src/define.js +267 -0
- package/src/entities/advertising.js +999 -0
- package/src/entities/ai.js +756 -0
- package/src/entities/analytics.js +1588 -0
- package/src/entities/automation.js +601 -0
- package/src/entities/communication.js +1150 -0
- package/src/entities/crm.js +1386 -0
- package/src/entities/design.js +546 -0
- package/src/entities/development.js +2212 -0
- package/src/entities/document.js +874 -0
- package/src/entities/ecommerce.js +1429 -0
- package/src/entities/experiment.js +1039 -0
- package/src/entities/finance.js +3478 -0
- package/src/entities/forms.js +1892 -0
- package/src/entities/hr.js +661 -0
- package/src/entities/identity.js +997 -0
- package/src/entities/index.js +282 -0
- package/src/entities/infrastructure.js +1153 -0
- package/src/entities/knowledge.js +1438 -0
- package/src/entities/marketing.js +1610 -0
- package/src/entities/media.js +1634 -0
- package/src/entities/notification.js +1199 -0
- package/src/entities/presentation.js +1274 -0
- package/src/entities/productivity.js +1317 -0
- package/src/entities/project-management.js +1136 -0
- package/src/entities/recruiting.js +736 -0
- package/src/entities/shipping.js +509 -0
- package/src/entities/signature.js +1102 -0
- package/src/entities/site.js +222 -0
- package/src/entities/spreadsheet.js +1341 -0
- package/src/entities/storage.js +1198 -0
- package/src/entities/support.js +1166 -0
- package/src/entities/video-conferencing.js +1750 -0
- package/src/entities/video.js +950 -0
- package/src/entities.js +1663 -0
- package/src/index.js +74 -0
- package/src/providers/analytics/index.js +17 -0
- package/src/providers/analytics/mixpanel.js +255 -0
- package/src/providers/calendar/cal-com.js +303 -0
- package/src/providers/calendar/google-calendar.js +335 -0
- package/src/providers/calendar/index.js +20 -0
- package/src/providers/crm/hubspot.js +566 -0
- package/src/providers/crm/index.js +17 -0
- package/src/providers/development/github.js +472 -0
- package/src/providers/development/index.js +17 -0
- package/src/providers/ecommerce/index.js +17 -0
- package/src/providers/ecommerce/shopify.js +378 -0
- package/src/providers/email/index.js +20 -0
- package/src/providers/email/resend.js +258 -0
- package/src/providers/email/sendgrid.js +161 -0
- package/src/providers/finance/index.js +17 -0
- package/src/providers/finance/stripe.js +549 -0
- package/src/providers/forms/index.js +17 -0
- package/src/providers/forms/typeform.js +500 -0
- package/src/providers/index.js +123 -0
- package/src/providers/knowledge/index.js +17 -0
- package/src/providers/knowledge/notion.js +389 -0
- package/src/providers/marketing/index.js +17 -0
- package/src/providers/marketing/mailchimp.js +443 -0
- package/src/providers/media/cloudinary.js +318 -0
- package/src/providers/media/index.js +17 -0
- package/src/providers/messaging/index.js +20 -0
- package/src/providers/messaging/slack.js +393 -0
- package/src/providers/messaging/twilio-sms.js +249 -0
- package/src/providers/project-management/index.js +17 -0
- package/src/providers/project-management/linear.js +575 -0
- package/src/providers/registry.js +86 -0
- package/src/providers/spreadsheet/google-sheets.js +375 -0
- package/src/providers/spreadsheet/index.js +20 -0
- package/src/providers/spreadsheet/xlsx.js +423 -0
- package/src/providers/storage/index.js +24 -0
- package/src/providers/storage/s3.js +419 -0
- package/src/providers/support/index.js +17 -0
- package/src/providers/support/zendesk.js +373 -0
- package/src/providers/tasks/index.js +17 -0
- package/src/providers/tasks/todoist.js +286 -0
- package/src/providers/types.js +9 -0
- package/src/providers/video-conferencing/google-meet.js +286 -0
- package/src/providers/video-conferencing/index.js +31 -0
- package/src/providers/video-conferencing/jitsi.js +254 -0
- package/src/providers/video-conferencing/teams.js +270 -0
- package/src/providers/video-conferencing/zoom.js +332 -0
- package/src/registry.js +128 -0
- package/src/tools/communication.js +184 -0
- package/src/tools/data.js +205 -0
- package/src/tools/index.js +11 -0
- package/src/tools/web.js +137 -0
- package/src/types.js +10 -0
- package/test/define.test.js +306 -0
- package/test/registry.test.js +357 -0
- package/test/tools.test.js +363 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudinary Media Provider
|
|
3
|
+
*
|
|
4
|
+
* Concrete implementation of MediaProvider using Cloudinary API.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import { defineProvider } from '../registry.js';
|
|
9
|
+
const CLOUDINARY_API_VERSION = 'v1_1';
|
|
10
|
+
/**
|
|
11
|
+
* Cloudinary provider info
|
|
12
|
+
*/
|
|
13
|
+
export const cloudinaryInfo = {
|
|
14
|
+
id: 'media.cloudinary',
|
|
15
|
+
name: 'Cloudinary',
|
|
16
|
+
description: 'Cloud-based image and video management service',
|
|
17
|
+
category: 'media',
|
|
18
|
+
website: 'https://cloudinary.com',
|
|
19
|
+
docsUrl: 'https://cloudinary.com/documentation',
|
|
20
|
+
requiredConfig: ['cloudName', 'apiKey', 'apiSecret'],
|
|
21
|
+
optionalConfig: ['uploadPreset', 'secure'],
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Create Cloudinary media provider
|
|
25
|
+
*/
|
|
26
|
+
export function createCloudinaryProvider(config) {
|
|
27
|
+
let cloudName;
|
|
28
|
+
let apiKey;
|
|
29
|
+
let apiSecret;
|
|
30
|
+
let secure;
|
|
31
|
+
function getApiUrl() {
|
|
32
|
+
return `https://api.cloudinary.com/${CLOUDINARY_API_VERSION}/${cloudName}`;
|
|
33
|
+
}
|
|
34
|
+
function getAuthHeader() {
|
|
35
|
+
return 'Basic ' + Buffer.from(`${apiKey}:${apiSecret}`).toString('base64');
|
|
36
|
+
}
|
|
37
|
+
function buildTransformUrl(publicId, resourceType, transforms) {
|
|
38
|
+
const protocol = secure ? 'https' : 'http';
|
|
39
|
+
const baseUrl = `${protocol}://res.cloudinary.com/${cloudName}`;
|
|
40
|
+
if (!transforms) {
|
|
41
|
+
return `${baseUrl}/${resourceType}/upload/${publicId}`;
|
|
42
|
+
}
|
|
43
|
+
const parts = [];
|
|
44
|
+
if (transforms.width)
|
|
45
|
+
parts.push(`w_${transforms.width}`);
|
|
46
|
+
if (transforms.height)
|
|
47
|
+
parts.push(`h_${transforms.height}`);
|
|
48
|
+
if (transforms.crop)
|
|
49
|
+
parts.push(`c_${transforms.crop}`);
|
|
50
|
+
if (transforms.quality)
|
|
51
|
+
parts.push(`q_${transforms.quality}`);
|
|
52
|
+
if (transforms.format)
|
|
53
|
+
parts.push(`f_${transforms.format}`);
|
|
54
|
+
const transformation = parts.length > 0 ? parts.join(',') + '/' : '';
|
|
55
|
+
return `${baseUrl}/${resourceType}/upload/${transformation}${publicId}`;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
info: cloudinaryInfo,
|
|
59
|
+
async initialize(cfg) {
|
|
60
|
+
cloudName = cfg.cloudName;
|
|
61
|
+
apiKey = cfg.apiKey;
|
|
62
|
+
apiSecret = cfg.apiSecret;
|
|
63
|
+
secure = cfg.secure !== false;
|
|
64
|
+
if (!cloudName || !apiKey || !apiSecret) {
|
|
65
|
+
throw new Error('Cloudinary requires cloudName, apiKey, and apiSecret');
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
async healthCheck() {
|
|
69
|
+
const start = Date.now();
|
|
70
|
+
try {
|
|
71
|
+
const response = await fetch(`${getApiUrl()}/resources/image`, {
|
|
72
|
+
method: 'GET',
|
|
73
|
+
headers: {
|
|
74
|
+
Authorization: getAuthHeader(),
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
healthy: response.ok,
|
|
79
|
+
latencyMs: Date.now() - start,
|
|
80
|
+
message: response.ok ? 'Connected' : `HTTP ${response.status}`,
|
|
81
|
+
checkedAt: new Date(),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
return {
|
|
86
|
+
healthy: false,
|
|
87
|
+
latencyMs: Date.now() - start,
|
|
88
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
89
|
+
checkedAt: new Date(),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
async dispose() {
|
|
94
|
+
// No cleanup needed
|
|
95
|
+
},
|
|
96
|
+
async upload(file, options) {
|
|
97
|
+
const resourceType = options?.resourceType || 'auto';
|
|
98
|
+
const formData = new FormData();
|
|
99
|
+
if (typeof file === 'string') {
|
|
100
|
+
// URL or base64
|
|
101
|
+
formData.append('file', file);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// Buffer - convert to ArrayBuffer for Blob
|
|
105
|
+
const arrayBuffer = file.buffer.slice(file.byteOffset, file.byteOffset + file.byteLength);
|
|
106
|
+
const blob = new Blob([arrayBuffer]);
|
|
107
|
+
formData.append('file', blob);
|
|
108
|
+
}
|
|
109
|
+
if (options?.publicId) {
|
|
110
|
+
formData.append('public_id', options.publicId);
|
|
111
|
+
}
|
|
112
|
+
if (options?.folder) {
|
|
113
|
+
formData.append('folder', options.folder);
|
|
114
|
+
}
|
|
115
|
+
if (options?.tags?.length) {
|
|
116
|
+
formData.append('tags', options.tags.join(','));
|
|
117
|
+
}
|
|
118
|
+
if (options?.metadata) {
|
|
119
|
+
formData.append('context', Object.entries(options.metadata).map(([k, v]) => `${k}=${v}`).join('|'));
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
const response = await fetch(`${getApiUrl()}/${resourceType}/upload`, {
|
|
123
|
+
method: 'POST',
|
|
124
|
+
headers: {
|
|
125
|
+
Authorization: getAuthHeader(),
|
|
126
|
+
},
|
|
127
|
+
body: formData,
|
|
128
|
+
});
|
|
129
|
+
if (!response.ok) {
|
|
130
|
+
const errorData = await response.json().catch(() => ({}));
|
|
131
|
+
throw new Error(errorData?.error?.message || `Upload failed: HTTP ${response.status}`);
|
|
132
|
+
}
|
|
133
|
+
const data = await response.json();
|
|
134
|
+
return {
|
|
135
|
+
id: data.public_id,
|
|
136
|
+
publicId: data.public_id,
|
|
137
|
+
url: data.url,
|
|
138
|
+
secureUrl: data.secure_url,
|
|
139
|
+
resourceType: data.resource_type,
|
|
140
|
+
format: data.format,
|
|
141
|
+
bytes: data.bytes,
|
|
142
|
+
width: data.width,
|
|
143
|
+
height: data.height,
|
|
144
|
+
duration: data.duration,
|
|
145
|
+
createdAt: new Date(data.created_at),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
throw new Error(error instanceof Error ? error.message : 'Upload failed');
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
async get(assetId) {
|
|
153
|
+
try {
|
|
154
|
+
// Try image first
|
|
155
|
+
const response = await fetch(`${getApiUrl()}/resources/image/upload/${assetId}`, {
|
|
156
|
+
method: 'GET',
|
|
157
|
+
headers: {
|
|
158
|
+
Authorization: getAuthHeader(),
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
if (!response.ok) {
|
|
162
|
+
// Try video
|
|
163
|
+
const videoResponse = await fetch(`${getApiUrl()}/resources/video/upload/${assetId}`, {
|
|
164
|
+
method: 'GET',
|
|
165
|
+
headers: {
|
|
166
|
+
Authorization: getAuthHeader(),
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
if (!videoResponse.ok) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
const data = await videoResponse.json();
|
|
173
|
+
return {
|
|
174
|
+
id: data.public_id,
|
|
175
|
+
publicId: data.public_id,
|
|
176
|
+
url: data.url,
|
|
177
|
+
secureUrl: data.secure_url,
|
|
178
|
+
resourceType: data.resource_type,
|
|
179
|
+
format: data.format,
|
|
180
|
+
bytes: data.bytes,
|
|
181
|
+
width: data.width,
|
|
182
|
+
height: data.height,
|
|
183
|
+
duration: data.duration,
|
|
184
|
+
createdAt: new Date(data.created_at),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
const data = await response.json();
|
|
188
|
+
return {
|
|
189
|
+
id: data.public_id,
|
|
190
|
+
publicId: data.public_id,
|
|
191
|
+
url: data.url,
|
|
192
|
+
secureUrl: data.secure_url,
|
|
193
|
+
resourceType: data.resource_type,
|
|
194
|
+
format: data.format,
|
|
195
|
+
bytes: data.bytes,
|
|
196
|
+
width: data.width,
|
|
197
|
+
height: data.height,
|
|
198
|
+
duration: data.duration,
|
|
199
|
+
createdAt: new Date(data.created_at),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
async delete(assetId) {
|
|
207
|
+
try {
|
|
208
|
+
// Try deleting as image first
|
|
209
|
+
let response = await fetch(`${getApiUrl()}/resources/image/upload`, {
|
|
210
|
+
method: 'DELETE',
|
|
211
|
+
headers: {
|
|
212
|
+
'Content-Type': 'application/json',
|
|
213
|
+
Authorization: getAuthHeader(),
|
|
214
|
+
},
|
|
215
|
+
body: JSON.stringify({ public_ids: [assetId] }),
|
|
216
|
+
});
|
|
217
|
+
if (response.ok) {
|
|
218
|
+
const result = await response.json();
|
|
219
|
+
return result.deleted?.[assetId] === 'deleted';
|
|
220
|
+
}
|
|
221
|
+
// Try video if image failed
|
|
222
|
+
response = await fetch(`${getApiUrl()}/resources/video/upload`, {
|
|
223
|
+
method: 'DELETE',
|
|
224
|
+
headers: {
|
|
225
|
+
'Content-Type': 'application/json',
|
|
226
|
+
Authorization: getAuthHeader(),
|
|
227
|
+
},
|
|
228
|
+
body: JSON.stringify({ public_ids: [assetId] }),
|
|
229
|
+
});
|
|
230
|
+
if (response.ok) {
|
|
231
|
+
const result = await response.json();
|
|
232
|
+
return result.deleted?.[assetId] === 'deleted';
|
|
233
|
+
}
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
async list(options) {
|
|
241
|
+
try {
|
|
242
|
+
const resourceType = options?.resourceType || 'image';
|
|
243
|
+
const params = new URLSearchParams();
|
|
244
|
+
if (options?.limit)
|
|
245
|
+
params.append('max_results', options.limit.toString());
|
|
246
|
+
if (options?.cursor)
|
|
247
|
+
params.append('next_cursor', options.cursor);
|
|
248
|
+
if (options?.folder)
|
|
249
|
+
params.append('prefix', options.folder);
|
|
250
|
+
if (options?.tags?.length) {
|
|
251
|
+
params.append('tags', 'true');
|
|
252
|
+
}
|
|
253
|
+
const response = await fetch(`${getApiUrl()}/resources/${resourceType}?${params.toString()}`, {
|
|
254
|
+
method: 'GET',
|
|
255
|
+
headers: {
|
|
256
|
+
Authorization: getAuthHeader(),
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
if (!response.ok) {
|
|
260
|
+
throw new Error(`List failed: HTTP ${response.status}`);
|
|
261
|
+
}
|
|
262
|
+
const data = await response.json();
|
|
263
|
+
const items = (data.resources || []).map((resource) => ({
|
|
264
|
+
id: resource.public_id,
|
|
265
|
+
publicId: resource.public_id,
|
|
266
|
+
url: resource.url,
|
|
267
|
+
secureUrl: resource.secure_url,
|
|
268
|
+
resourceType: resource.resource_type,
|
|
269
|
+
format: resource.format,
|
|
270
|
+
bytes: resource.bytes,
|
|
271
|
+
width: resource.width,
|
|
272
|
+
height: resource.height,
|
|
273
|
+
duration: resource.duration,
|
|
274
|
+
createdAt: new Date(resource.created_at),
|
|
275
|
+
}));
|
|
276
|
+
return {
|
|
277
|
+
items,
|
|
278
|
+
hasMore: !!data.next_cursor,
|
|
279
|
+
nextCursor: data.next_cursor,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
throw new Error(error instanceof Error ? error.message : 'List failed');
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
async transform(assetId, transformations) {
|
|
287
|
+
// Get asset to determine resource type
|
|
288
|
+
const asset = await this.get(assetId);
|
|
289
|
+
if (!asset) {
|
|
290
|
+
throw new Error(`Asset not found: ${assetId}`);
|
|
291
|
+
}
|
|
292
|
+
return buildTransformUrl(assetId, asset.resourceType, transformations);
|
|
293
|
+
},
|
|
294
|
+
async getUrl(assetId, options) {
|
|
295
|
+
// Get asset to determine resource type
|
|
296
|
+
const asset = await this.get(assetId);
|
|
297
|
+
if (!asset) {
|
|
298
|
+
throw new Error(`Asset not found: ${assetId}`);
|
|
299
|
+
}
|
|
300
|
+
let url = buildTransformUrl(assetId, asset.resourceType, options?.transformation);
|
|
301
|
+
// Add signed URL parameters if requested
|
|
302
|
+
if (options?.signed) {
|
|
303
|
+
// For signed URLs, we'd need to implement signature generation
|
|
304
|
+
// This is a simplified version - production would need proper signing
|
|
305
|
+
const timestamp = options.expiration
|
|
306
|
+
? Math.floor(options.expiration.getTime() / 1000)
|
|
307
|
+
: Math.floor(Date.now() / 1000) + 3600; // 1 hour default
|
|
308
|
+
// Note: This would need proper signature generation in production
|
|
309
|
+
url += `?timestamp=${timestamp}`;
|
|
310
|
+
}
|
|
311
|
+
return url;
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Cloudinary provider definition
|
|
317
|
+
*/
|
|
318
|
+
export const cloudinaryProvider = defineProvider(cloudinaryInfo, async (config) => createCloudinaryProvider(config));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media Providers
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { cloudinaryInfo, cloudinaryProvider, createCloudinaryProvider } from './cloudinary.js';
|
|
7
|
+
import { cloudinaryProvider } from './cloudinary.js';
|
|
8
|
+
/**
|
|
9
|
+
* Register all media providers
|
|
10
|
+
*/
|
|
11
|
+
export function registerMediaProviders() {
|
|
12
|
+
cloudinaryProvider.register();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* All media providers
|
|
16
|
+
*/
|
|
17
|
+
export const mediaProviders = [cloudinaryProvider];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Messaging Providers
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { slackInfo, slackProvider, createSlackProvider } from './slack.js';
|
|
7
|
+
export { twilioSmsInfo, twilioSmsProvider, createTwilioSmsProvider } from './twilio-sms.js';
|
|
8
|
+
import { slackProvider } from './slack.js';
|
|
9
|
+
import { twilioSmsProvider } from './twilio-sms.js';
|
|
10
|
+
/**
|
|
11
|
+
* Register all messaging providers
|
|
12
|
+
*/
|
|
13
|
+
export function registerMessagingProviders() {
|
|
14
|
+
slackProvider.register();
|
|
15
|
+
twilioSmsProvider.register();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* All messaging providers
|
|
19
|
+
*/
|
|
20
|
+
export const messagingProviders = [slackProvider, twilioSmsProvider];
|