@empireaiorg/econnect 1.0.0 → 1.1.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.
- package/README.md +18 -0
- package/index.js +53 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -69,6 +69,24 @@ await eConnect.music.getDevices(userId, 'spotify');
|
|
|
69
69
|
| `getDevices(userId, app)` | spotify |
|
|
70
70
|
| `addToQueue(userId, uri, app)` | spotify |
|
|
71
71
|
|
|
72
|
+
## Google methods
|
|
73
|
+
|
|
74
|
+
One "Connect Google" grant covers Gmail (via `messaging.sendEmail`), plus:
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
await eConnect.google.calendar.listEvents(userId, { maxResults: 10 });
|
|
78
|
+
await eConnect.google.calendar.createEvent(userId, {
|
|
79
|
+
summary: 'Team sync',
|
|
80
|
+
start: '2026-08-01T10:00:00-04:00',
|
|
81
|
+
end: '2026-08-01T10:30:00-04:00',
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
await eConnect.google.contacts.list(userId);
|
|
85
|
+
await eConnect.google.contacts.create(userId, { givenName: 'Ada', email: 'ada@example.com' });
|
|
86
|
+
|
|
87
|
+
await eConnect.google.youtube.getMyChannel(userId);
|
|
88
|
+
```
|
|
89
|
+
|
|
72
90
|
## Full docs
|
|
73
91
|
|
|
74
92
|
See [empireunion.xyz/docs](https://empireunion.xyz/docs) for the full guide,
|
package/index.js
CHANGED
|
@@ -59,6 +59,34 @@ class EConnectSDK {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
// --- GOOGLE BLUEPRINT (Calendar, Contacts, YouTube account) ---
|
|
63
|
+
// Gmail stays under .messaging.sendEmail(userId, 'gmail', ...) since
|
|
64
|
+
// it's conceptually messaging — this covers what the unified Google
|
|
65
|
+
// connection additionally unlocks.
|
|
66
|
+
get google() {
|
|
67
|
+
const sdk = this;
|
|
68
|
+
return {
|
|
69
|
+
calendar: {
|
|
70
|
+
listEvents: async (userId, { timeMin, maxResults } = {}) =>
|
|
71
|
+
sdk.executeGoogleAction(userId, 'list_events', { timeMin, maxResults }, 'calendar'),
|
|
72
|
+
|
|
73
|
+
createEvent: async (userId, { summary, description, start, end, timeZone } = {}) =>
|
|
74
|
+
sdk.executeGoogleAction(userId, 'create_event', { summary, description, start, end, timeZone }, 'calendar'),
|
|
75
|
+
},
|
|
76
|
+
contacts: {
|
|
77
|
+
list: async (userId) =>
|
|
78
|
+
sdk.executeGoogleAction(userId, 'list_contacts', {}, 'contacts'),
|
|
79
|
+
|
|
80
|
+
create: async (userId, { givenName, familyName, email, phone } = {}) =>
|
|
81
|
+
sdk.executeGoogleAction(userId, 'create_contact', { givenName, familyName, email, phone }, 'contacts'),
|
|
82
|
+
},
|
|
83
|
+
youtube: {
|
|
84
|
+
getMyChannel: async (userId) =>
|
|
85
|
+
sdk.executeGoogleAction(userId, 'get_my_channel', {}, 'youtube_account'),
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
62
90
|
// --- MUSIC BLUEPRINT ---
|
|
63
91
|
get music() {
|
|
64
92
|
const sdk = this;
|
|
@@ -123,6 +151,31 @@ class EConnectSDK {
|
|
|
123
151
|
}
|
|
124
152
|
}
|
|
125
153
|
|
|
154
|
+
// --- INTERNAL HELPER: Google (Calendar, Contacts, YouTube account) ---
|
|
155
|
+
async executeGoogleAction(userId, action, payload, targetApp) {
|
|
156
|
+
try {
|
|
157
|
+
const response = await fetch(`${this.apiBaseUrl}/v1/google/execute`, {
|
|
158
|
+
method: 'POST',
|
|
159
|
+
headers: {
|
|
160
|
+
'Content-Type': 'application/json',
|
|
161
|
+
'Authorization': `Bearer ${this.developerApiKey}`
|
|
162
|
+
},
|
|
163
|
+
body: JSON.stringify({
|
|
164
|
+
user_id: userId,
|
|
165
|
+
action: action,
|
|
166
|
+
payload: payload,
|
|
167
|
+
target_app: targetApp
|
|
168
|
+
})
|
|
169
|
+
});
|
|
170
|
+
const data = await response.json();
|
|
171
|
+
if (!response.ok) throw new Error(data.error || 'Unknown eConnect error');
|
|
172
|
+
return data;
|
|
173
|
+
} catch (error) {
|
|
174
|
+
console.error("❌ eConnect SDK Error:", error.message);
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
126
179
|
// --- APP DIRECTORY BLUEPRINT ---
|
|
127
180
|
get apps() {
|
|
128
181
|
return {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empireaiorg/econnect",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Official Node.js SDK for eConnect
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Official Node.js SDK for eConnect \u2014 one API for messaging (Telegram, Discord, Slack, Gmail, GitHub, Twilio) and music (Spotify, YouTube Music, Deezer) platforms.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"index.js",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"spotify",
|
|
21
21
|
"twilio"
|
|
22
22
|
],
|
|
23
|
-
"author": "David
|
|
23
|
+
"author": "David Imanuel",
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|
|
27
27
|
"url": "https://github.com/davidmaximimanuel/eConnect.git"
|
|
28
28
|
},
|
|
29
|
-
"homepage": "https://empireunion.xyz",
|
|
29
|
+
"homepage": "https://econnect.empireunion.xyz",
|
|
30
30
|
"engines": {
|
|
31
31
|
"node": ">=18"
|
|
32
32
|
}
|