@rool-dev/extension 0.3.13 → 0.4.0-dev.3612b32
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/publish.js
CHANGED
|
@@ -55,7 +55,7 @@ export async function publish() {
|
|
|
55
55
|
// Publish
|
|
56
56
|
console.log(` Publishing ${manifest.id} to ${env}...`);
|
|
57
57
|
const blob = new Blob([new Uint8Array(zipBuffer)], { type: 'application/zip' });
|
|
58
|
-
const result = await client.
|
|
58
|
+
const result = await client.uploadExtension(manifest.id, {
|
|
59
59
|
bundle: blob,
|
|
60
60
|
});
|
|
61
61
|
console.log(`\n Published: ${result.manifest.name}`);
|
|
@@ -227,7 +227,7 @@ export class DevHostController {
|
|
|
227
227
|
return;
|
|
228
228
|
try {
|
|
229
229
|
// Step 1: install extension (server applies manifest: name, systemInstruction, collections)
|
|
230
|
-
const channelId = await this.client.installExtension(this.currentSpaceId, extensionId);
|
|
230
|
+
const channelId = await this.client.installExtension(this.currentSpaceId, extensionId, extensionId);
|
|
231
231
|
// Step 2: open channel for live subscription
|
|
232
232
|
const ch = await this.client.openChannel(this.currentSpaceId, channelId);
|
|
233
233
|
this.channels[extensionId] = ch;
|
|
@@ -283,7 +283,7 @@ export class DevHostController {
|
|
|
283
283
|
// Step 2: publish via SDK
|
|
284
284
|
this.publishState = 'uploading';
|
|
285
285
|
this._onChange();
|
|
286
|
-
const result = await this.client.
|
|
286
|
+
const result = await this.client.uploadExtension(this.manifest.id, {
|
|
287
287
|
bundle: zipBlob,
|
|
288
288
|
});
|
|
289
289
|
// Step 3: update published extensions list
|
package/dist/dev/host-shell.js
CHANGED
|
@@ -5444,6 +5444,7 @@ var GraphQLClient = class {
|
|
|
5444
5444
|
createdByName
|
|
5445
5445
|
interactionCount
|
|
5446
5446
|
extensionUrl
|
|
5447
|
+
extensionId
|
|
5447
5448
|
}
|
|
5448
5449
|
}
|
|
5449
5450
|
}
|
|
@@ -5836,6 +5837,20 @@ var GraphQLClient = class {
|
|
|
5836
5837
|
channelId
|
|
5837
5838
|
})).installExtension;
|
|
5838
5839
|
}
|
|
5840
|
+
async publishExtensionToPublic(extensionId) {
|
|
5841
|
+
await this.request(`
|
|
5842
|
+
mutation PublishExtension($extensionId: String!) {
|
|
5843
|
+
publishExtension(extensionId: $extensionId)
|
|
5844
|
+
}
|
|
5845
|
+
`, { extensionId });
|
|
5846
|
+
}
|
|
5847
|
+
async unpublishExtensionFromPublic(extensionId) {
|
|
5848
|
+
await this.request(`
|
|
5849
|
+
mutation UnpublishExtension($extensionId: String!) {
|
|
5850
|
+
unpublishExtension(extensionId: $extensionId)
|
|
5851
|
+
}
|
|
5852
|
+
`, { extensionId });
|
|
5853
|
+
}
|
|
5839
5854
|
async setUserStorage(key, value) {
|
|
5840
5855
|
await this.request(`
|
|
5841
5856
|
mutation SetUserStorage($key: String!, $value: JSON) {
|
|
@@ -7260,81 +7275,65 @@ var ExtensionsClient = class {
|
|
|
7260
7275
|
constructor(config) {
|
|
7261
7276
|
this.config = config;
|
|
7262
7277
|
}
|
|
7263
|
-
|
|
7264
|
-
* List all published extensions for the current user.
|
|
7265
|
-
*/
|
|
7266
|
-
async list() {
|
|
7278
|
+
async getHeaders() {
|
|
7267
7279
|
const tokens = await this.config.authManager.getTokens();
|
|
7268
7280
|
if (!tokens) throw new Error("Not authenticated");
|
|
7269
|
-
|
|
7281
|
+
return {
|
|
7270
7282
|
Authorization: `Bearer ${tokens.accessToken}`,
|
|
7271
7283
|
"X-Rool-Token": tokens.roolToken
|
|
7272
7284
|
};
|
|
7285
|
+
}
|
|
7286
|
+
/**
|
|
7287
|
+
* List all user extensions.
|
|
7288
|
+
*/
|
|
7289
|
+
async list() {
|
|
7273
7290
|
const response = await fetch(this.config.extensionsUrl, {
|
|
7274
7291
|
method: "GET",
|
|
7275
|
-
headers
|
|
7292
|
+
headers: await this.getHeaders()
|
|
7276
7293
|
});
|
|
7277
7294
|
if (!response.ok) throw new Error(`Failed to list extensions: ${response.status} ${response.statusText}`);
|
|
7278
7295
|
return response.json();
|
|
7279
7296
|
}
|
|
7280
7297
|
/**
|
|
7281
|
-
* Get info for a specific
|
|
7298
|
+
* Get info for a specific user extension.
|
|
7282
7299
|
*/
|
|
7283
7300
|
async get(extensionId) {
|
|
7284
|
-
const tokens = await this.config.authManager.getTokens();
|
|
7285
|
-
if (!tokens) throw new Error("Not authenticated");
|
|
7286
|
-
const headers = {
|
|
7287
|
-
Authorization: `Bearer ${tokens.accessToken}`,
|
|
7288
|
-
"X-Rool-Token": tokens.roolToken
|
|
7289
|
-
};
|
|
7290
7301
|
const response = await fetch(`${this.config.extensionsUrl}/${encodeURIComponent(extensionId)}`, {
|
|
7291
7302
|
method: "GET",
|
|
7292
|
-
headers
|
|
7303
|
+
headers: await this.getHeaders()
|
|
7293
7304
|
});
|
|
7294
7305
|
if (response.status === 404) return null;
|
|
7295
7306
|
if (!response.ok) throw new Error(`Failed to get extension: ${response.status} ${response.statusText}`);
|
|
7296
7307
|
return response.json();
|
|
7297
7308
|
}
|
|
7298
7309
|
/**
|
|
7299
|
-
*
|
|
7310
|
+
* Upload or update a user extension bundle.
|
|
7300
7311
|
* @param extensionId - URL-safe identifier for the extension
|
|
7301
7312
|
* @param options - Bundle zip file (must include index.html and manifest.json)
|
|
7302
7313
|
*/
|
|
7303
|
-
async
|
|
7304
|
-
const tokens = await this.config.authManager.getTokens();
|
|
7305
|
-
if (!tokens) throw new Error("Not authenticated");
|
|
7306
|
-
const headers = {
|
|
7307
|
-
Authorization: `Bearer ${tokens.accessToken}`,
|
|
7308
|
-
"X-Rool-Token": tokens.roolToken
|
|
7309
|
-
};
|
|
7314
|
+
async upload(extensionId, options) {
|
|
7310
7315
|
const formData = new FormData();
|
|
7311
7316
|
formData.append("bundle", options.bundle);
|
|
7312
7317
|
const response = await fetch(`${this.config.extensionsUrl}/${encodeURIComponent(extensionId)}`, {
|
|
7313
7318
|
method: "POST",
|
|
7314
|
-
headers,
|
|
7319
|
+
headers: await this.getHeaders(),
|
|
7315
7320
|
body: formData
|
|
7316
7321
|
});
|
|
7317
7322
|
if (!response.ok) {
|
|
7318
7323
|
const errorMessage = (await response.json().catch(() => ({}))).error || `${response.status} ${response.statusText}`;
|
|
7319
|
-
throw new Error(`Failed to
|
|
7324
|
+
throw new Error(`Failed to upload extension: ${errorMessage}`);
|
|
7320
7325
|
}
|
|
7321
7326
|
return response.json();
|
|
7322
7327
|
}
|
|
7323
7328
|
/**
|
|
7324
|
-
*
|
|
7329
|
+
* Delete a user extension permanently.
|
|
7325
7330
|
*/
|
|
7326
|
-
async
|
|
7327
|
-
const tokens = await this.config.authManager.getTokens();
|
|
7328
|
-
if (!tokens) throw new Error("Not authenticated");
|
|
7329
|
-
const headers = {
|
|
7330
|
-
Authorization: `Bearer ${tokens.accessToken}`,
|
|
7331
|
-
"X-Rool-Token": tokens.roolToken
|
|
7332
|
-
};
|
|
7331
|
+
async delete(extensionId) {
|
|
7333
7332
|
const response = await fetch(`${this.config.extensionsUrl}/${encodeURIComponent(extensionId)}`, {
|
|
7334
7333
|
method: "DELETE",
|
|
7335
|
-
headers
|
|
7334
|
+
headers: await this.getHeaders()
|
|
7336
7335
|
});
|
|
7337
|
-
if (!response.ok && response.status !== 204) throw new Error(`Failed to
|
|
7336
|
+
if (!response.ok && response.status !== 204) throw new Error(`Failed to delete extension: ${response.status} ${response.statusText}`);
|
|
7338
7337
|
}
|
|
7339
7338
|
};
|
|
7340
7339
|
//#endregion
|
|
@@ -7499,6 +7498,12 @@ var RoolChannel = class extends EventEmitter {
|
|
|
7499
7498
|
return this._channel?.extensionUrl ?? null;
|
|
7500
7499
|
}
|
|
7501
7500
|
/**
|
|
7501
|
+
* Get the extension ID if this channel has an installed extension, or null.
|
|
7502
|
+
*/
|
|
7503
|
+
get extensionId() {
|
|
7504
|
+
return this._channel?.extensionId ?? null;
|
|
7505
|
+
}
|
|
7506
|
+
/**
|
|
7502
7507
|
* Get the active branch of the current conversation as a flat array (root → leaf).
|
|
7503
7508
|
* Walks from the active leaf up through parentId pointers.
|
|
7504
7509
|
*/
|
|
@@ -8574,7 +8579,7 @@ var RoolClient = class extends EventEmitter {
|
|
|
8574
8579
|
graphql: config.graphqlUrl ?? `${this.baseUrl}/graphql`,
|
|
8575
8580
|
media: config.mediaUrl ?? `${this.baseUrl}/media`,
|
|
8576
8581
|
auth: config.authUrl ?? `${this.baseUrl}/auth`,
|
|
8577
|
-
extensions: `${this.baseUrl}/extensions`
|
|
8582
|
+
extensions: `${this.baseUrl}/user-extensions`
|
|
8578
8583
|
};
|
|
8579
8584
|
this.authManager = new AuthManager({
|
|
8580
8585
|
authUrl: this.urls.auth,
|
|
@@ -8819,53 +8824,48 @@ var RoolClient = class extends EventEmitter {
|
|
|
8819
8824
|
return user;
|
|
8820
8825
|
}
|
|
8821
8826
|
/**
|
|
8822
|
-
*
|
|
8823
|
-
*
|
|
8824
|
-
*
|
|
8825
|
-
* @param extensionId - URL-safe identifier (alphanumeric, hyphens, underscores; case-insensitive, lowercased by server)
|
|
8827
|
+
* Upload or update a user extension bundle.
|
|
8828
|
+
* @param extensionId - URL-safe identifier (alphanumeric, hyphens, underscores)
|
|
8826
8829
|
* @param options - Bundle zip file (must include index.html and manifest.json)
|
|
8827
8830
|
*/
|
|
8828
|
-
async
|
|
8829
|
-
return this.extensionsClient.
|
|
8831
|
+
async uploadExtension(extensionId, options) {
|
|
8832
|
+
return this.extensionsClient.upload(extensionId, options);
|
|
8830
8833
|
}
|
|
8831
|
-
/**
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
async unpublishExtension(extensionId) {
|
|
8835
|
-
return this.extensionsClient.unpublish(extensionId);
|
|
8834
|
+
/** Delete a user extension permanently (removes files and DB row). */
|
|
8835
|
+
async deleteExtension(extensionId) {
|
|
8836
|
+
return this.extensionsClient.delete(extensionId);
|
|
8836
8837
|
}
|
|
8837
|
-
/**
|
|
8838
|
-
* List all published extensions for the current user.
|
|
8839
|
-
*/
|
|
8838
|
+
/** List the current user's extensions. */
|
|
8840
8839
|
async listExtensions() {
|
|
8841
8840
|
return this.extensionsClient.list();
|
|
8842
8841
|
}
|
|
8843
|
-
/**
|
|
8844
|
-
* Get info for a specific published extension.
|
|
8845
|
-
* Returns null if the extension doesn't exist.
|
|
8846
|
-
*/
|
|
8842
|
+
/** Get info for a specific user extension. Returns null if not found. */
|
|
8847
8843
|
async getExtensionInfo(extensionId) {
|
|
8848
8844
|
return this.extensionsClient.get(extensionId);
|
|
8849
8845
|
}
|
|
8850
8846
|
/**
|
|
8851
|
-
* Search
|
|
8852
|
-
* Without a query, returns all
|
|
8847
|
+
* Search published extensions. With a query, performs semantic search.
|
|
8848
|
+
* Without a query, returns all published extensions sorted by most recently updated.
|
|
8853
8849
|
*/
|
|
8854
8850
|
async findExtensions(options) {
|
|
8855
8851
|
return this.graphqlClient.findExtensions(options);
|
|
8856
8852
|
}
|
|
8857
8853
|
/**
|
|
8858
8854
|
* Install an extension into a space.
|
|
8859
|
-
*
|
|
8860
|
-
* and
|
|
8861
|
-
*
|
|
8862
|
-
* @param spaceId - The space to install the extension into
|
|
8863
|
-
* @param extensionId - The published extension ID
|
|
8864
|
-
* @param channelId - Channel ID for the extension (defaults to extensionId)
|
|
8855
|
+
* If extensionId is a user extension you own, wires it directly.
|
|
8856
|
+
* If it's a published extension, copies source and builds a new user extension.
|
|
8865
8857
|
* @returns The channel ID
|
|
8866
8858
|
*/
|
|
8867
8859
|
async installExtension(spaceId, extensionId, channelId) {
|
|
8868
|
-
return this.graphqlClient.installExtension(spaceId, extensionId, channelId
|
|
8860
|
+
return this.graphqlClient.installExtension(spaceId, extensionId, channelId);
|
|
8861
|
+
}
|
|
8862
|
+
/** Publish a user extension (make it publicly discoverable). */
|
|
8863
|
+
async publishToPublic(extensionId) {
|
|
8864
|
+
return this.graphqlClient.publishExtensionToPublic(extensionId);
|
|
8865
|
+
}
|
|
8866
|
+
/** Unpublish an extension (remove from public listing). */
|
|
8867
|
+
async unpublishFromPublic(extensionId) {
|
|
8868
|
+
return this.graphqlClient.unpublishExtensionFromPublic(extensionId);
|
|
8869
8869
|
}
|
|
8870
8870
|
/**
|
|
8871
8871
|
* Get a value from user storage (sync read from local cache).
|
|
@@ -9022,7 +9022,8 @@ var RoolClient = class extends EventEmitter {
|
|
|
9022
9022
|
createdBy: event.channelCreatedBy ?? "",
|
|
9023
9023
|
createdByName: event.channelCreatedByName ?? null,
|
|
9024
9024
|
interactionCount: 0,
|
|
9025
|
-
extensionUrl: event.channelExtensionUrl ?? null
|
|
9025
|
+
extensionUrl: event.channelExtensionUrl ?? null,
|
|
9026
|
+
extensionId: event.channelExtensionId ?? null
|
|
9026
9027
|
});
|
|
9027
9028
|
break;
|
|
9028
9029
|
case "channel_renamed":
|
|
@@ -9463,7 +9464,7 @@ var DevHostController = class {
|
|
|
9463
9464
|
if (!this.currentSpaceId) return;
|
|
9464
9465
|
if (this.installedExtensionIds.includes(extensionId)) return;
|
|
9465
9466
|
try {
|
|
9466
|
-
const channelId = await this.client.installExtension(this.currentSpaceId, extensionId);
|
|
9467
|
+
const channelId = await this.client.installExtension(this.currentSpaceId, extensionId, extensionId);
|
|
9467
9468
|
const ch = await this.client.openChannel(this.currentSpaceId, channelId);
|
|
9468
9469
|
this.channels[extensionId] = ch;
|
|
9469
9470
|
this.installedExtensionIds = [...this.installedExtensionIds, extensionId];
|
|
@@ -9508,7 +9509,7 @@ var DevHostController = class {
|
|
|
9508
9509
|
const zipBlob = await buildRes.blob();
|
|
9509
9510
|
this.publishState = "uploading";
|
|
9510
9511
|
this._onChange();
|
|
9511
|
-
const result = await this.client.
|
|
9512
|
+
const result = await this.client.uploadExtension(this.manifest.id, { bundle: zipBlob });
|
|
9512
9513
|
const existingIdx = this.publishedExtensions.findIndex((a) => a.extensionId === result.extensionId);
|
|
9513
9514
|
if (existingIdx >= 0) this.publishedExtensions = [
|
|
9514
9515
|
...this.publishedExtensions.slice(0, existingIdx),
|