@synergenius/flow-weaver 0.26.7 → 0.27.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/dist/cli/commands/account.d.ts +4 -0
- package/dist/cli/commands/account.js +50 -0
- package/dist/cli/commands/ai-credentials.d.ts +12 -0
- package/dist/cli/commands/ai-credentials.js +95 -0
- package/dist/cli/commands/apikey.d.ts +4 -0
- package/dist/cli/commands/apikey.js +64 -0
- package/dist/cli/commands/auth.d.ts +1 -0
- package/dist/cli/commands/auth.js +15 -15
- package/dist/cli/commands/deploy.js +14 -37
- package/dist/cli/commands/org.d.ts +8 -0
- package/dist/cli/commands/org.js +136 -0
- package/dist/cli/config/platform-client.d.ts +87 -0
- package/dist/cli/config/platform-client.js +127 -1
- package/dist/cli/flow-weaver.mjs +7447 -14908
- package/dist/cli/index.js +111 -0
- package/dist/cli/utils/cli-helpers.d.ts +44 -0
- package/dist/cli/utils/cli-helpers.js +99 -0
- package/dist/generated-version.d.ts +1 -1
- package/dist/generated-version.js +1 -1
- package/package.json +6 -6
|
@@ -8,12 +8,15 @@ export class PlatformClient {
|
|
|
8
8
|
async fetch(path, opts = {}) {
|
|
9
9
|
const isApiKey = this.token.startsWith('fw_');
|
|
10
10
|
const headers = {
|
|
11
|
-
'Content-Type': 'application/json',
|
|
12
11
|
...(isApiKey
|
|
13
12
|
? { 'X-API-Key': this.token }
|
|
14
13
|
: { Authorization: `Bearer ${this.token}` }),
|
|
15
14
|
...(opts.headers ?? {}),
|
|
16
15
|
};
|
|
16
|
+
// Only set Content-Type for requests with a body (Fastify rejects empty body with application/json)
|
|
17
|
+
if (opts.body) {
|
|
18
|
+
headers['Content-Type'] = 'application/json';
|
|
19
|
+
}
|
|
17
20
|
return fetch(`${this.baseUrl}${path}`, { ...opts, headers });
|
|
18
21
|
}
|
|
19
22
|
// Auth
|
|
@@ -105,6 +108,129 @@ export class PlatformClient {
|
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
110
|
}
|
|
111
|
+
// API Keys
|
|
112
|
+
async createApiKey(name) {
|
|
113
|
+
const resp = await this.fetch('/api-keys', {
|
|
114
|
+
method: 'POST',
|
|
115
|
+
body: JSON.stringify({ name }),
|
|
116
|
+
});
|
|
117
|
+
if (!resp.ok) {
|
|
118
|
+
const err = await resp.json().catch(() => ({ error: resp.statusText }));
|
|
119
|
+
throw new Error(err.error ?? `Failed to create API key: ${resp.status}`);
|
|
120
|
+
}
|
|
121
|
+
const data = await resp.json();
|
|
122
|
+
return data.apiKey;
|
|
123
|
+
}
|
|
124
|
+
async listApiKeys() {
|
|
125
|
+
const resp = await this.fetch('/api-keys');
|
|
126
|
+
if (!resp.ok) {
|
|
127
|
+
throw new Error(`Failed to list API keys: ${resp.status}`);
|
|
128
|
+
}
|
|
129
|
+
const data = await resp.json().catch(() => ({ apiKeys: [] }));
|
|
130
|
+
return data.apiKeys ?? [];
|
|
131
|
+
}
|
|
132
|
+
async revokeApiKey(id) {
|
|
133
|
+
const resp = await this.fetch(`/api-keys/${id}`, { method: 'DELETE' });
|
|
134
|
+
if (resp.status === 404) {
|
|
135
|
+
throw new Error('API key not found or already revoked');
|
|
136
|
+
}
|
|
137
|
+
if (!resp.ok) {
|
|
138
|
+
throw new Error(`Failed to revoke API key: ${resp.status}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// AI Credentials
|
|
142
|
+
async createAiCredential(opts) {
|
|
143
|
+
const resp = await this.fetch('/ai-credentials', {
|
|
144
|
+
method: 'POST',
|
|
145
|
+
body: JSON.stringify(opts),
|
|
146
|
+
});
|
|
147
|
+
if (!resp.ok) {
|
|
148
|
+
const err = await resp.json().catch(() => ({ error: resp.statusText }));
|
|
149
|
+
throw new Error(err.error ?? `Failed to add credential: ${resp.status}`);
|
|
150
|
+
}
|
|
151
|
+
const data = await resp.json();
|
|
152
|
+
return data.credential;
|
|
153
|
+
}
|
|
154
|
+
async listAiCredentials() {
|
|
155
|
+
const resp = await this.fetch('/ai-credentials');
|
|
156
|
+
if (!resp.ok)
|
|
157
|
+
throw new Error(`Failed to list credentials: ${resp.status}`);
|
|
158
|
+
const data = await resp.json().catch(() => ({ credentials: [] }));
|
|
159
|
+
return data.credentials ?? [];
|
|
160
|
+
}
|
|
161
|
+
async revokeAiCredential(id) {
|
|
162
|
+
const resp = await this.fetch(`/ai-credentials/${id}`, { method: 'DELETE' });
|
|
163
|
+
if (resp.status === 404)
|
|
164
|
+
throw new Error('Credential not found');
|
|
165
|
+
if (!resp.ok)
|
|
166
|
+
throw new Error(`Failed to revoke credential: ${resp.status}`);
|
|
167
|
+
}
|
|
168
|
+
async testAiCredential(id) {
|
|
169
|
+
const resp = await this.fetch(`/ai-credentials/${id}/test`, { method: 'POST' });
|
|
170
|
+
if (!resp.ok) {
|
|
171
|
+
const err = await resp.json().catch(() => ({ error: resp.statusText }));
|
|
172
|
+
throw new Error(err.error ?? `Test failed: ${resp.status}`);
|
|
173
|
+
}
|
|
174
|
+
return await resp.json().catch(() => ({ success: true }));
|
|
175
|
+
}
|
|
176
|
+
// Billing / Usage
|
|
177
|
+
async getDetailedUsage() {
|
|
178
|
+
const resp = await this.fetch('/billing/usage');
|
|
179
|
+
if (!resp.ok)
|
|
180
|
+
throw new Error(`Failed to fetch usage: ${resp.status}`);
|
|
181
|
+
const data = await resp.json().catch(() => null);
|
|
182
|
+
if (!data?.usage)
|
|
183
|
+
throw new Error('Invalid usage response');
|
|
184
|
+
return data;
|
|
185
|
+
}
|
|
186
|
+
// Organizations
|
|
187
|
+
async listOrgs() {
|
|
188
|
+
const resp = await this.fetch('/organizations');
|
|
189
|
+
if (!resp.ok)
|
|
190
|
+
throw new Error(`Failed to list organizations: ${resp.status}`);
|
|
191
|
+
const data = await resp.json().catch(() => []);
|
|
192
|
+
return Array.isArray(data) ? data : [];
|
|
193
|
+
}
|
|
194
|
+
async createOrg(name) {
|
|
195
|
+
const resp = await this.fetch('/organizations', {
|
|
196
|
+
method: 'POST',
|
|
197
|
+
body: JSON.stringify({ name }),
|
|
198
|
+
});
|
|
199
|
+
if (!resp.ok) {
|
|
200
|
+
const err = await resp.json().catch(() => ({ error: resp.statusText }));
|
|
201
|
+
throw new Error(err.error ?? `Failed to create organization: ${resp.status}`);
|
|
202
|
+
}
|
|
203
|
+
const data = await resp.json().catch(() => null);
|
|
204
|
+
if (!data)
|
|
205
|
+
throw new Error('Invalid organization response');
|
|
206
|
+
return data;
|
|
207
|
+
}
|
|
208
|
+
async getOrg(orgId) {
|
|
209
|
+
const resp = await this.fetch(`/organizations/${orgId}`);
|
|
210
|
+
if (!resp.ok)
|
|
211
|
+
throw new Error(`Failed to get organization: ${resp.status}`);
|
|
212
|
+
const data = await resp.json().catch(() => null);
|
|
213
|
+
if (!data)
|
|
214
|
+
throw new Error('Invalid organization response');
|
|
215
|
+
return data;
|
|
216
|
+
}
|
|
217
|
+
async inviteOrgMember(orgId, email, role = 'editor') {
|
|
218
|
+
const resp = await this.fetch(`/organizations/${orgId}/members`, {
|
|
219
|
+
method: 'POST',
|
|
220
|
+
body: JSON.stringify({ email, role }),
|
|
221
|
+
});
|
|
222
|
+
if (!resp.ok) {
|
|
223
|
+
const err = await resp.json().catch(() => ({ error: resp.statusText }));
|
|
224
|
+
throw new Error(err.error ?? `Failed to invite member: ${resp.status}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
async removeOrgMember(orgId, userId) {
|
|
228
|
+
const resp = await this.fetch(`/organizations/${orgId}/members/${userId}`, { method: 'DELETE' });
|
|
229
|
+
if (!resp.ok) {
|
|
230
|
+
const err = await resp.json().catch(() => ({ error: resp.statusText }));
|
|
231
|
+
throw new Error(err.error ?? `Failed to remove member: ${resp.status}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
108
234
|
// Validate connection
|
|
109
235
|
async validate() {
|
|
110
236
|
try {
|