@lobehub/market-sdk 0.42.0 → 0.43.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/index.d.mts +62 -3
- package/dist/index.mjs +268 -199
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2102,7 +2102,7 @@ var MarketAdmin = class extends BaseSDK {
|
|
|
2102
2102
|
|
|
2103
2103
|
// src/market/market-sdk.ts
|
|
2104
2104
|
import { getAssetImagePath, getAssetInitialPath } from "@lobehub/market-types";
|
|
2105
|
-
import
|
|
2105
|
+
import debug39 from "debug";
|
|
2106
2106
|
|
|
2107
2107
|
// src/market/services/AgentProfileService.ts
|
|
2108
2108
|
import debug15 from "debug";
|
|
@@ -4660,13 +4660,64 @@ var PluginsService = class extends BaseSDK {
|
|
|
4660
4660
|
}
|
|
4661
4661
|
};
|
|
4662
4662
|
|
|
4663
|
-
// src/market/services/
|
|
4663
|
+
// src/market/services/SandboxService.ts
|
|
4664
4664
|
import debug25 from "debug";
|
|
4665
|
-
var log25 = debug25("lobe-market-sdk:sandbox
|
|
4665
|
+
var log25 = debug25("lobe-market-sdk:sandbox");
|
|
4666
|
+
function encodeBase642(input) {
|
|
4667
|
+
if (typeof Buffer !== "undefined") {
|
|
4668
|
+
return Buffer.from(input, "utf8").toString("base64");
|
|
4669
|
+
}
|
|
4670
|
+
const bytes = new TextEncoder().encode(input);
|
|
4671
|
+
let binary = "";
|
|
4672
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
4673
|
+
return btoa(binary);
|
|
4674
|
+
}
|
|
4675
|
+
var SandboxService = class extends BaseSDK {
|
|
4676
|
+
/**
|
|
4677
|
+
* Run a script once in a fresh sandbox and return its output.
|
|
4678
|
+
*
|
|
4679
|
+
* A non-zero `exitCode` or `timedOut: true` is a normal result, not an error.
|
|
4680
|
+
* Non-2xx responses (validation, `rate_limited`, `sandbox_unavailable`, …)
|
|
4681
|
+
* throw like every other SDK call.
|
|
4682
|
+
*
|
|
4683
|
+
* @example
|
|
4684
|
+
* ```typescript
|
|
4685
|
+
* const result = await sdk.sandbox.run({
|
|
4686
|
+
* egress: {
|
|
4687
|
+
* allow: ['api.github.com'],
|
|
4688
|
+
* inject: [{ header: 'Authorization', host: 'api.github.com', prefix: 'Bearer ', secretRef: { key: 'github' } }],
|
|
4689
|
+
* },
|
|
4690
|
+
* runtime: 'node',
|
|
4691
|
+
* script: 'const r = await fetch("https://api.github.com/user"); console.log(JSON.stringify(await r.json()))',
|
|
4692
|
+
* subject: { id: widgetId, kind: 'widget' },
|
|
4693
|
+
* timeoutMs: 20_000,
|
|
4694
|
+
* });
|
|
4695
|
+
* ```
|
|
4696
|
+
*/
|
|
4697
|
+
async run(params, options) {
|
|
4698
|
+
const { script, ...rest } = params;
|
|
4699
|
+
log25(
|
|
4700
|
+
"Running %s sandbox script for %s %s",
|
|
4701
|
+
params.runtime,
|
|
4702
|
+
params.subject.kind,
|
|
4703
|
+
params.subject.id
|
|
4704
|
+
);
|
|
4705
|
+
return this.request("/v1/sandbox/runs", {
|
|
4706
|
+
body: JSON.stringify({ ...rest, scriptB64: encodeBase642(script), scriptEncoding: "base64" }),
|
|
4707
|
+
headers: { "Content-Type": "application/json" },
|
|
4708
|
+
method: "POST",
|
|
4709
|
+
...options
|
|
4710
|
+
});
|
|
4711
|
+
}
|
|
4712
|
+
};
|
|
4713
|
+
|
|
4714
|
+
// src/market/services/SandboxStorageService.ts
|
|
4715
|
+
import debug26 from "debug";
|
|
4716
|
+
var log26 = debug26("lobe-market-sdk:sandbox-storage");
|
|
4666
4717
|
var SandboxStorageService2 = class extends BaseSDK {
|
|
4667
4718
|
/** Storage directory, quota and the last measured usage. */
|
|
4668
4719
|
async getStorage(key = "current", options) {
|
|
4669
|
-
|
|
4720
|
+
log26("Getting sandbox storage: %s", key);
|
|
4670
4721
|
const result = await this.request(
|
|
4671
4722
|
`/v1/sandbox/storages/${encodeURIComponent(key)}`,
|
|
4672
4723
|
{ ...options, method: "GET" }
|
|
@@ -4678,7 +4729,7 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4678
4729
|
* whole directory, so call it on demand rather than on every render.
|
|
4679
4730
|
*/
|
|
4680
4731
|
async refreshUsage(key = "current", context2 = {}, options) {
|
|
4681
|
-
|
|
4732
|
+
log26("Refreshing sandbox storage usage: %s", key);
|
|
4682
4733
|
const result = await this.request(
|
|
4683
4734
|
`/v1/sandbox/storages/${encodeURIComponent(key)}/usage`,
|
|
4684
4735
|
{ ...options, body: JSON.stringify(context2), method: "POST" }
|
|
@@ -4687,7 +4738,7 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4687
4738
|
}
|
|
4688
4739
|
async listFiles(params = {}, options) {
|
|
4689
4740
|
const { key = "current", path, recursive, topicId } = params;
|
|
4690
|
-
|
|
4741
|
+
log26("Listing sandbox storage files: %s/%s", key, path != null ? path : "");
|
|
4691
4742
|
const query = new URLSearchParams();
|
|
4692
4743
|
if (path) query.set("path", path);
|
|
4693
4744
|
if (recursive) query.set("recursive", "true");
|
|
@@ -4700,7 +4751,7 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4700
4751
|
}
|
|
4701
4752
|
async readFile(params, options) {
|
|
4702
4753
|
const { key = "current", path, topicId } = params;
|
|
4703
|
-
|
|
4754
|
+
log26("Reading sandbox storage file: %s/%s", key, path);
|
|
4704
4755
|
const query = new URLSearchParams({ path });
|
|
4705
4756
|
if (topicId) query.set("topicId", topicId);
|
|
4706
4757
|
const result = await this.request(
|
|
@@ -4711,7 +4762,7 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4711
4762
|
}
|
|
4712
4763
|
async writeFile(params, options) {
|
|
4713
4764
|
const { content, key = "current", path, topicId } = params;
|
|
4714
|
-
|
|
4765
|
+
log26("Writing sandbox storage file: %s/%s (%d bytes)", key, path, content.length);
|
|
4715
4766
|
const result = await this.request(
|
|
4716
4767
|
`/v1/sandbox/storages/${encodeURIComponent(key)}/file`,
|
|
4717
4768
|
{
|
|
@@ -4764,6 +4815,23 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4764
4815
|
);
|
|
4765
4816
|
return result.data;
|
|
4766
4817
|
}
|
|
4818
|
+
/**
|
|
4819
|
+
* Stop the sandbox holding an instance and release it, instead of waiting for
|
|
4820
|
+
* the idle sweep. The sandbox is snapshotted first.
|
|
4821
|
+
*
|
|
4822
|
+
* Refused retryably with 503 `SNAPSHOT_IN_PROGRESS` while that snapshot is
|
|
4823
|
+
* still packing, and with 409 `INSTANCE_STARTING`, `INSTANCE_BUILDING` or
|
|
4824
|
+
* `INSTANCE_BUSY` while what holds it cannot be stopped yet. `stopped: false`
|
|
4825
|
+
* means nothing held the instance.
|
|
4826
|
+
*/
|
|
4827
|
+
async stopInstance(params, options) {
|
|
4828
|
+
const { key = "current", name } = params;
|
|
4829
|
+
const result = await this.request(
|
|
4830
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}/instances/${encodeURIComponent(name)}/stop`,
|
|
4831
|
+
{ ...options, method: "POST" }
|
|
4832
|
+
);
|
|
4833
|
+
return result.data;
|
|
4834
|
+
}
|
|
4767
4835
|
/**
|
|
4768
4836
|
* Delete an instance.
|
|
4769
4837
|
*
|
|
@@ -4788,7 +4856,7 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4788
4856
|
*/
|
|
4789
4857
|
async createDirectory(params, options) {
|
|
4790
4858
|
const { key = "current", path, topicId } = params;
|
|
4791
|
-
|
|
4859
|
+
log26("Creating sandbox storage directory: %s/%s", key, path);
|
|
4792
4860
|
const result = await this.request(
|
|
4793
4861
|
`/v1/sandbox/storages/${encodeURIComponent(key)}/directory`,
|
|
4794
4862
|
{
|
|
@@ -4801,7 +4869,7 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4801
4869
|
}
|
|
4802
4870
|
async deleteFile(params, options) {
|
|
4803
4871
|
const { key = "current", path, recursive, topicId } = params;
|
|
4804
|
-
|
|
4872
|
+
log26("Deleting sandbox storage path: %s/%s", key, path);
|
|
4805
4873
|
const query = new URLSearchParams({ path });
|
|
4806
4874
|
if (recursive) query.set("recursive", "true");
|
|
4807
4875
|
if (topicId) query.set("topicId", topicId);
|
|
@@ -4814,8 +4882,8 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4814
4882
|
};
|
|
4815
4883
|
|
|
4816
4884
|
// src/market/services/SkillService.ts
|
|
4817
|
-
import
|
|
4818
|
-
var
|
|
4885
|
+
import debug27 from "debug";
|
|
4886
|
+
var log27 = debug27("lobe-market-sdk:skill");
|
|
4819
4887
|
var SkillService2 = class extends BaseSDK {
|
|
4820
4888
|
/**
|
|
4821
4889
|
* Lists all available skill providers
|
|
@@ -4828,9 +4896,9 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4828
4896
|
*/
|
|
4829
4897
|
async listProviders(options) {
|
|
4830
4898
|
var _a;
|
|
4831
|
-
|
|
4899
|
+
log27("Listing skill providers");
|
|
4832
4900
|
const result = await this.request("/v1/skill/providers", options);
|
|
4833
|
-
|
|
4901
|
+
log27("Found %d skill providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
4834
4902
|
return result;
|
|
4835
4903
|
}
|
|
4836
4904
|
/**
|
|
@@ -4845,12 +4913,12 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4845
4913
|
*/
|
|
4846
4914
|
async listTools(provider, options) {
|
|
4847
4915
|
var _a;
|
|
4848
|
-
|
|
4916
|
+
log27("Listing tools for provider: %s", provider);
|
|
4849
4917
|
const result = await this.request(
|
|
4850
4918
|
`/v1/skill/${encodeURIComponent(provider)}/tools`,
|
|
4851
4919
|
options
|
|
4852
4920
|
);
|
|
4853
|
-
|
|
4921
|
+
log27("Found %d tools for provider %s", ((_a = result.tools) == null ? void 0 : _a.length) || 0, provider);
|
|
4854
4922
|
return result;
|
|
4855
4923
|
}
|
|
4856
4924
|
/**
|
|
@@ -4867,12 +4935,12 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4867
4935
|
*/
|
|
4868
4936
|
async listLiveTools(provider, options) {
|
|
4869
4937
|
var _a;
|
|
4870
|
-
|
|
4938
|
+
log27("Listing live tools for provider: %s", provider);
|
|
4871
4939
|
const result = await this.request(
|
|
4872
4940
|
`/v1/skill/${encodeURIComponent(provider)}/tools/live`,
|
|
4873
4941
|
options
|
|
4874
4942
|
);
|
|
4875
|
-
|
|
4943
|
+
log27("Found %d live tools for provider %s", ((_a = result.tools) == null ? void 0 : _a.length) || 0, provider);
|
|
4876
4944
|
return result;
|
|
4877
4945
|
}
|
|
4878
4946
|
/**
|
|
@@ -4888,12 +4956,12 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4888
4956
|
*/
|
|
4889
4957
|
async getTool(provider, toolName, options) {
|
|
4890
4958
|
var _a;
|
|
4891
|
-
|
|
4959
|
+
log27("Getting tool %s from provider %s", toolName, provider);
|
|
4892
4960
|
const result = await this.request(
|
|
4893
4961
|
`/v1/skill/${encodeURIComponent(provider)}/tool/${encodeURIComponent(toolName)}`,
|
|
4894
4962
|
options
|
|
4895
4963
|
);
|
|
4896
|
-
|
|
4964
|
+
log27("Retrieved tool: %s", (_a = result.tool) == null ? void 0 : _a.name);
|
|
4897
4965
|
return result;
|
|
4898
4966
|
}
|
|
4899
4967
|
/**
|
|
@@ -4907,12 +4975,12 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4907
4975
|
* @returns Promise resolving to the connection status
|
|
4908
4976
|
*/
|
|
4909
4977
|
async getStatus(provider, options) {
|
|
4910
|
-
|
|
4978
|
+
log27("Getting status for provider: %s", provider);
|
|
4911
4979
|
const result = await this.request(
|
|
4912
4980
|
`/v1/skill/${encodeURIComponent(provider)}/status`,
|
|
4913
4981
|
options
|
|
4914
4982
|
);
|
|
4915
|
-
|
|
4983
|
+
log27("Provider %s status: connected=%s", provider, result.connected);
|
|
4916
4984
|
return result;
|
|
4917
4985
|
}
|
|
4918
4986
|
/**
|
|
@@ -4940,7 +5008,7 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4940
5008
|
* ```
|
|
4941
5009
|
*/
|
|
4942
5010
|
async callTool(provider, params, options) {
|
|
4943
|
-
|
|
5011
|
+
log27("Calling tool %s on provider %s", params.tool, provider);
|
|
4944
5012
|
const { args, tool, ...rest } = params;
|
|
4945
5013
|
const result = await this.request(
|
|
4946
5014
|
`/v1/skill/${encodeURIComponent(provider)}/call`,
|
|
@@ -4957,14 +5025,14 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4957
5025
|
...options
|
|
4958
5026
|
}
|
|
4959
5027
|
);
|
|
4960
|
-
|
|
5028
|
+
log27("Tool %s call completed: success=%s", params.tool, result.success);
|
|
4961
5029
|
return result;
|
|
4962
5030
|
}
|
|
4963
5031
|
};
|
|
4964
5032
|
|
|
4965
5033
|
// src/market/services/MarketTaskTemplateService.ts
|
|
4966
|
-
import
|
|
4967
|
-
var
|
|
5034
|
+
import debug28 from "debug";
|
|
5035
|
+
var log28 = debug28("lobe-market-sdk:task-templates");
|
|
4968
5036
|
var MarketTaskTemplateService = class extends BaseSDK {
|
|
4969
5037
|
/**
|
|
4970
5038
|
* Retrieves personalized task template recommendations.
|
|
@@ -4987,7 +5055,7 @@ var MarketTaskTemplateService = class extends BaseSDK {
|
|
|
4987
5055
|
refreshSeed: params.refreshSeed,
|
|
4988
5056
|
seedKey: params.seedKey
|
|
4989
5057
|
};
|
|
4990
|
-
|
|
5058
|
+
log28("Getting task template recommendations: %O", body);
|
|
4991
5059
|
const result = await this.request(
|
|
4992
5060
|
"/v1/task-templates/recommendations",
|
|
4993
5061
|
{
|
|
@@ -4996,14 +5064,14 @@ var MarketTaskTemplateService = class extends BaseSDK {
|
|
|
4996
5064
|
method: "POST"
|
|
4997
5065
|
}
|
|
4998
5066
|
);
|
|
4999
|
-
|
|
5067
|
+
log28("Retrieved %d task template recommendations", result.items.length);
|
|
5000
5068
|
return result;
|
|
5001
5069
|
}
|
|
5002
5070
|
};
|
|
5003
5071
|
|
|
5004
5072
|
// src/market/services/MarketSkillCollectionService.ts
|
|
5005
|
-
import
|
|
5006
|
-
var
|
|
5073
|
+
import debug29 from "debug";
|
|
5074
|
+
var log29 = debug29("lobe-market-sdk:skill-collections");
|
|
5007
5075
|
var MarketSkillCollectionService = class extends BaseSDK {
|
|
5008
5076
|
async getSkillCollectionDetail(slug, params = {}, options) {
|
|
5009
5077
|
const locale = params.locale || this.defaultLocale;
|
|
@@ -5012,12 +5080,12 @@ var MarketSkillCollectionService = class extends BaseSDK {
|
|
|
5012
5080
|
locale
|
|
5013
5081
|
};
|
|
5014
5082
|
const queryString = this.buildQueryString(queryParams);
|
|
5015
|
-
|
|
5083
|
+
log29("Getting skill collection detail: %s %O", slug, queryParams);
|
|
5016
5084
|
const result = await this.request(
|
|
5017
5085
|
`/v1/skills/collections/${encodeURIComponent(slug)}${queryString}`,
|
|
5018
5086
|
options
|
|
5019
5087
|
);
|
|
5020
|
-
|
|
5088
|
+
log29("Skill collection detail retrieved: %s (%d items)", slug, result.items.length);
|
|
5021
5089
|
return result;
|
|
5022
5090
|
}
|
|
5023
5091
|
async getSkillCollections(params = {}, options) {
|
|
@@ -5027,19 +5095,19 @@ var MarketSkillCollectionService = class extends BaseSDK {
|
|
|
5027
5095
|
locale
|
|
5028
5096
|
};
|
|
5029
5097
|
const queryString = this.buildQueryString(queryParams);
|
|
5030
|
-
|
|
5098
|
+
log29("Getting skill collections: %O", queryParams);
|
|
5031
5099
|
const result = await this.request(
|
|
5032
5100
|
`/v1/skills/collections${queryString}`,
|
|
5033
5101
|
options
|
|
5034
5102
|
);
|
|
5035
|
-
|
|
5103
|
+
log29("Retrieved %d skill collections", result.length);
|
|
5036
5104
|
return result;
|
|
5037
5105
|
}
|
|
5038
5106
|
};
|
|
5039
5107
|
|
|
5040
5108
|
// src/market/services/MarketSkillService.ts
|
|
5041
|
-
import
|
|
5042
|
-
var
|
|
5109
|
+
import debug30 from "debug";
|
|
5110
|
+
var log30 = debug30("lobe-market-sdk:market-skills");
|
|
5043
5111
|
var MarketSkillService = class extends BaseSDK {
|
|
5044
5112
|
/**
|
|
5045
5113
|
* Retrieves a list of skills from the marketplace
|
|
@@ -5074,9 +5142,9 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5074
5142
|
const locale = params.locale || this.defaultLocale;
|
|
5075
5143
|
const queryParams = { ...params, locale };
|
|
5076
5144
|
const queryString = this.buildQueryString(queryParams);
|
|
5077
|
-
|
|
5145
|
+
log30("Getting skill list: %O", queryParams);
|
|
5078
5146
|
const result = await this.request(`/v1/skills${queryString}`, options);
|
|
5079
|
-
|
|
5147
|
+
log30(
|
|
5080
5148
|
"Retrieved %d skills (page %d/%d)",
|
|
5081
5149
|
result.items.length,
|
|
5082
5150
|
result.currentPage,
|
|
@@ -5115,12 +5183,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5115
5183
|
queryParams.version = params.version;
|
|
5116
5184
|
}
|
|
5117
5185
|
const queryString = this.buildQueryString(queryParams);
|
|
5118
|
-
|
|
5186
|
+
log30("Getting skill detail: %s %O", identifier, params);
|
|
5119
5187
|
const result = await this.request(
|
|
5120
5188
|
`/v1/skills/${encodeURIComponent(identifier)}${queryString}`,
|
|
5121
5189
|
options
|
|
5122
5190
|
);
|
|
5123
|
-
|
|
5191
|
+
log30("Skill detail retrieved: %s (v%s)", identifier, result.version);
|
|
5124
5192
|
return result;
|
|
5125
5193
|
}
|
|
5126
5194
|
/**
|
|
@@ -5151,7 +5219,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5151
5219
|
if (version) {
|
|
5152
5220
|
url += `?version=${encodeURIComponent(version)}`;
|
|
5153
5221
|
}
|
|
5154
|
-
|
|
5222
|
+
log30("Generated download URL: %s", url);
|
|
5155
5223
|
return url;
|
|
5156
5224
|
}
|
|
5157
5225
|
/**
|
|
@@ -5175,7 +5243,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5175
5243
|
* ```
|
|
5176
5244
|
*/
|
|
5177
5245
|
async downloadSkill(identifier, version, options) {
|
|
5178
|
-
|
|
5246
|
+
log30("Downloading skill: %s (version: %s)", identifier, version || "latest");
|
|
5179
5247
|
const queryParams = {};
|
|
5180
5248
|
if (version) {
|
|
5181
5249
|
queryParams.version = version;
|
|
@@ -5191,7 +5259,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5191
5259
|
});
|
|
5192
5260
|
if (!response.ok) {
|
|
5193
5261
|
const errorText = await response.text();
|
|
5194
|
-
|
|
5262
|
+
log30("Download failed: %s %s", response.status, errorText);
|
|
5195
5263
|
throw new Error(`Failed to download skill: ${response.statusText}`);
|
|
5196
5264
|
}
|
|
5197
5265
|
const contentDisposition = response.headers.get("content-disposition");
|
|
@@ -5203,7 +5271,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5203
5271
|
}
|
|
5204
5272
|
}
|
|
5205
5273
|
const buffer = await response.arrayBuffer();
|
|
5206
|
-
|
|
5274
|
+
log30("Downloaded skill: %s (%d bytes)", filename, buffer.byteLength);
|
|
5207
5275
|
return { buffer, filename };
|
|
5208
5276
|
}
|
|
5209
5277
|
/**
|
|
@@ -5231,12 +5299,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5231
5299
|
const locale = params.locale || this.defaultLocale;
|
|
5232
5300
|
const queryParams = { ...params, locale };
|
|
5233
5301
|
const queryString = this.buildQueryString(queryParams);
|
|
5234
|
-
|
|
5302
|
+
log30("Getting skill categories: %O", queryParams);
|
|
5235
5303
|
const result = await this.request(
|
|
5236
5304
|
`/v1/skills/categories${queryString}`,
|
|
5237
5305
|
options
|
|
5238
5306
|
);
|
|
5239
|
-
|
|
5307
|
+
log30("Retrieved %d categories", result.length);
|
|
5240
5308
|
return result;
|
|
5241
5309
|
}
|
|
5242
5310
|
/**
|
|
@@ -5251,12 +5319,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5251
5319
|
* @returns Promise resolving to an array of identifiers with last modified times
|
|
5252
5320
|
*/
|
|
5253
5321
|
async getPublishedIdentifiers(options) {
|
|
5254
|
-
|
|
5322
|
+
log30("Getting published skill identifiers");
|
|
5255
5323
|
const result = await this.request(
|
|
5256
5324
|
"/v1/skills/identifiers",
|
|
5257
5325
|
options
|
|
5258
5326
|
);
|
|
5259
|
-
|
|
5327
|
+
log30("Retrieved %d published skill identifiers", result.length);
|
|
5260
5328
|
return result;
|
|
5261
5329
|
}
|
|
5262
5330
|
/**
|
|
@@ -5267,9 +5335,9 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5267
5335
|
*/
|
|
5268
5336
|
async getSitemap(params = {}, options) {
|
|
5269
5337
|
const queryString = this.buildQueryString(params);
|
|
5270
|
-
|
|
5338
|
+
log30("Getting skill sitemap%s", queryString);
|
|
5271
5339
|
const result = await this.request(`/v1/skills/sitemap${queryString}`, options);
|
|
5272
|
-
|
|
5340
|
+
log30(
|
|
5273
5341
|
"Retrieved skill sitemap page %d/%d (%d items)",
|
|
5274
5342
|
result.currentPage,
|
|
5275
5343
|
result.totalPages,
|
|
@@ -5285,13 +5353,13 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5285
5353
|
* @returns Promise resolving to true if skill exists, false otherwise
|
|
5286
5354
|
*/
|
|
5287
5355
|
async checkSkillExists(identifier, options) {
|
|
5288
|
-
|
|
5356
|
+
log30("Checking if skill exists: %s", identifier);
|
|
5289
5357
|
try {
|
|
5290
5358
|
await this.getSkillDetail(identifier, {}, options);
|
|
5291
|
-
|
|
5359
|
+
log30("Skill exists: %s", identifier);
|
|
5292
5360
|
return true;
|
|
5293
5361
|
} catch (e) {
|
|
5294
|
-
|
|
5362
|
+
log30("Skill does not exist: %s", identifier);
|
|
5295
5363
|
return false;
|
|
5296
5364
|
}
|
|
5297
5365
|
}
|
|
@@ -5312,12 +5380,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5312
5380
|
* ```
|
|
5313
5381
|
*/
|
|
5314
5382
|
async getSkillVersions(identifier, options) {
|
|
5315
|
-
|
|
5383
|
+
log30("Getting skill versions: %s", identifier);
|
|
5316
5384
|
const result = await this.request(
|
|
5317
5385
|
`/v1/skills/${encodeURIComponent(identifier)}/versions`,
|
|
5318
5386
|
options
|
|
5319
5387
|
);
|
|
5320
|
-
|
|
5388
|
+
log30("Retrieved %d versions for skill %s", result.data.length, identifier);
|
|
5321
5389
|
return result.data;
|
|
5322
5390
|
}
|
|
5323
5391
|
/**
|
|
@@ -5341,12 +5409,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5341
5409
|
const locale = params.locale || this.defaultLocale;
|
|
5342
5410
|
const queryParams = { locale };
|
|
5343
5411
|
const queryString = this.buildQueryString(queryParams);
|
|
5344
|
-
|
|
5412
|
+
log30("Getting skill version: %s@%s", identifier, version);
|
|
5345
5413
|
const result = await this.request(
|
|
5346
5414
|
`/v1/skills/${encodeURIComponent(identifier)}/versions/${encodeURIComponent(version)}${queryString}`,
|
|
5347
5415
|
options
|
|
5348
5416
|
);
|
|
5349
|
-
|
|
5417
|
+
log30("Skill version detail retrieved: %s@%s", identifier, version);
|
|
5350
5418
|
return result;
|
|
5351
5419
|
}
|
|
5352
5420
|
/**
|
|
@@ -5375,13 +5443,13 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5375
5443
|
* ```
|
|
5376
5444
|
*/
|
|
5377
5445
|
async reportGitHubSkill(params, options) {
|
|
5378
|
-
|
|
5446
|
+
log30("Reporting GitHub skill: %s", params.gitUrl);
|
|
5379
5447
|
const result = await this.request("/v1/skills/report/github", {
|
|
5380
5448
|
...options,
|
|
5381
5449
|
body: JSON.stringify(params),
|
|
5382
5450
|
method: "POST"
|
|
5383
5451
|
});
|
|
5384
|
-
|
|
5452
|
+
log30("GitHub skill reported: %s (status: %s)", result.identifier, result.status);
|
|
5385
5453
|
return result;
|
|
5386
5454
|
}
|
|
5387
5455
|
/**
|
|
@@ -5406,7 +5474,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5406
5474
|
* ```
|
|
5407
5475
|
*/
|
|
5408
5476
|
async reportSkillInstall(params, options) {
|
|
5409
|
-
|
|
5477
|
+
log30("Reporting skill install: %s (success: %s)", params.identifier, params.success);
|
|
5410
5478
|
const result = await this.request(
|
|
5411
5479
|
"/v1/skills/report/installation",
|
|
5412
5480
|
{
|
|
@@ -5415,7 +5483,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5415
5483
|
method: "POST"
|
|
5416
5484
|
}
|
|
5417
5485
|
);
|
|
5418
|
-
|
|
5486
|
+
log30("Skill install reported: %s", result.message);
|
|
5419
5487
|
return result;
|
|
5420
5488
|
}
|
|
5421
5489
|
/**
|
|
@@ -5427,7 +5495,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5427
5495
|
* @returns Promise resolving to the submitted score
|
|
5428
5496
|
*/
|
|
5429
5497
|
async submitRating(identifier, score, options) {
|
|
5430
|
-
|
|
5498
|
+
log30("Submitting rating for skill %s: %d", identifier, score);
|
|
5431
5499
|
const result = await this.request(
|
|
5432
5500
|
`/v1/skills/${encodeURIComponent(identifier)}/ratings`,
|
|
5433
5501
|
{
|
|
@@ -5436,7 +5504,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5436
5504
|
method: "POST"
|
|
5437
5505
|
}
|
|
5438
5506
|
);
|
|
5439
|
-
|
|
5507
|
+
log30("Rating submitted for skill %s: %d", identifier, result.score);
|
|
5440
5508
|
return result;
|
|
5441
5509
|
}
|
|
5442
5510
|
/**
|
|
@@ -5447,12 +5515,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5447
5515
|
* @returns Promise resolving to the rating distribution
|
|
5448
5516
|
*/
|
|
5449
5517
|
async getRatingDistribution(identifier, options) {
|
|
5450
|
-
|
|
5518
|
+
log30("Getting rating distribution for skill: %s", identifier);
|
|
5451
5519
|
const result = await this.request(
|
|
5452
5520
|
`/v1/skills/${encodeURIComponent(identifier)}/ratings/distribution`,
|
|
5453
5521
|
options
|
|
5454
5522
|
);
|
|
5455
|
-
|
|
5523
|
+
log30("Rating distribution retrieved for skill %s: %d total", identifier, result.totalCount);
|
|
5456
5524
|
return result;
|
|
5457
5525
|
}
|
|
5458
5526
|
/**
|
|
@@ -5465,12 +5533,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5465
5533
|
*/
|
|
5466
5534
|
async getComments(identifier, params = {}, options) {
|
|
5467
5535
|
const queryString = this.buildQueryString(params);
|
|
5468
|
-
|
|
5536
|
+
log30("Getting comments for skill %s: %O", identifier, params);
|
|
5469
5537
|
const result = await this.request(
|
|
5470
5538
|
`/v1/skills/${encodeURIComponent(identifier)}/comments${queryString}`,
|
|
5471
5539
|
options
|
|
5472
5540
|
);
|
|
5473
|
-
|
|
5541
|
+
log30(
|
|
5474
5542
|
"Retrieved %d comments for skill %s (page %d/%d)",
|
|
5475
5543
|
result.items.length,
|
|
5476
5544
|
identifier,
|
|
@@ -5487,15 +5555,15 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5487
5555
|
* @returns Promise resolving to the latest own comment or null when none exists
|
|
5488
5556
|
*/
|
|
5489
5557
|
async getLatestOwnComment(identifier, options) {
|
|
5490
|
-
|
|
5558
|
+
log30("Getting latest own comment for skill %s", identifier);
|
|
5491
5559
|
const result = await this.request(
|
|
5492
5560
|
`/v1/skills/${encodeURIComponent(identifier)}/comments/latest`,
|
|
5493
5561
|
options
|
|
5494
5562
|
);
|
|
5495
5563
|
if (result) {
|
|
5496
|
-
|
|
5564
|
+
log30("Retrieved latest own comment for skill %s: id=%d", identifier, result.id);
|
|
5497
5565
|
} else {
|
|
5498
|
-
|
|
5566
|
+
log30("No own comments found for skill %s", identifier);
|
|
5499
5567
|
}
|
|
5500
5568
|
return result;
|
|
5501
5569
|
}
|
|
@@ -5508,7 +5576,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5508
5576
|
* @returns Promise resolving to the created comment (with optional rating field)
|
|
5509
5577
|
*/
|
|
5510
5578
|
async createComment(identifier, data, options) {
|
|
5511
|
-
|
|
5579
|
+
log30("Creating comment on skill %s", identifier);
|
|
5512
5580
|
const result = await this.request(
|
|
5513
5581
|
`/v1/skills/${encodeURIComponent(identifier)}/comments`,
|
|
5514
5582
|
{
|
|
@@ -5517,7 +5585,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5517
5585
|
method: "POST"
|
|
5518
5586
|
}
|
|
5519
5587
|
);
|
|
5520
|
-
|
|
5588
|
+
log30("Comment created on skill %s: id=%d", identifier, result.id);
|
|
5521
5589
|
return result;
|
|
5522
5590
|
}
|
|
5523
5591
|
/**
|
|
@@ -5529,7 +5597,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5529
5597
|
* @returns Promise resolving to success status
|
|
5530
5598
|
*/
|
|
5531
5599
|
async deleteComment(identifier, commentId, options) {
|
|
5532
|
-
|
|
5600
|
+
log30("Deleting comment %d from skill %s", commentId, identifier);
|
|
5533
5601
|
const result = await this.request(
|
|
5534
5602
|
`/v1/skills/${encodeURIComponent(identifier)}/comments/${commentId}`,
|
|
5535
5603
|
{
|
|
@@ -5537,7 +5605,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5537
5605
|
method: "DELETE"
|
|
5538
5606
|
}
|
|
5539
5607
|
);
|
|
5540
|
-
|
|
5608
|
+
log30("Comment %d deleted from skill %s", commentId, identifier);
|
|
5541
5609
|
return result;
|
|
5542
5610
|
}
|
|
5543
5611
|
/**
|
|
@@ -5549,7 +5617,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5549
5617
|
* @returns Promise resolving to the created reaction
|
|
5550
5618
|
*/
|
|
5551
5619
|
async addReaction(commentId, type, options) {
|
|
5552
|
-
|
|
5620
|
+
log30("Adding %s reaction to comment %d", type, commentId);
|
|
5553
5621
|
const result = await this.request(
|
|
5554
5622
|
`/v1/skills/comments/${commentId}/reactions`,
|
|
5555
5623
|
{
|
|
@@ -5558,7 +5626,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5558
5626
|
method: "POST"
|
|
5559
5627
|
}
|
|
5560
5628
|
);
|
|
5561
|
-
|
|
5629
|
+
log30("Reaction added to comment %d: %s (id=%d)", commentId, result.type, result.id);
|
|
5562
5630
|
return result;
|
|
5563
5631
|
}
|
|
5564
5632
|
/**
|
|
@@ -5569,7 +5637,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5569
5637
|
* @returns Promise resolving to success status
|
|
5570
5638
|
*/
|
|
5571
5639
|
async removeReaction(commentId, options) {
|
|
5572
|
-
|
|
5640
|
+
log30("Removing reaction from comment %d", commentId);
|
|
5573
5641
|
const result = await this.request(
|
|
5574
5642
|
`/v1/skills/comments/${commentId}/reactions`,
|
|
5575
5643
|
{
|
|
@@ -5577,19 +5645,19 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5577
5645
|
method: "DELETE"
|
|
5578
5646
|
}
|
|
5579
5647
|
);
|
|
5580
|
-
|
|
5648
|
+
log30("Reaction removed from comment %d", commentId);
|
|
5581
5649
|
return result;
|
|
5582
5650
|
}
|
|
5583
5651
|
};
|
|
5584
5652
|
|
|
5585
5653
|
// src/market/services/OrganizationCredsService.ts
|
|
5586
|
-
import
|
|
5654
|
+
import debug31 from "debug";
|
|
5587
5655
|
|
|
5588
5656
|
// src/utils/orgRef.ts
|
|
5589
5657
|
var orgRefToPathSegment = (ref) => typeof ref === "number" ? String(ref) : `workspace:${encodeURIComponent(ref.workspaceId)}`;
|
|
5590
5658
|
|
|
5591
5659
|
// src/market/services/OrganizationCredsService.ts
|
|
5592
|
-
var
|
|
5660
|
+
var log31 = debug31("lobe-market-sdk:org-creds");
|
|
5593
5661
|
var OrganizationCredsService = class extends BaseSDK {
|
|
5594
5662
|
constructor(orgId, options = {}, sharedHeaders, sharedTokenState) {
|
|
5595
5663
|
super(options, sharedHeaders, sharedTokenState);
|
|
@@ -5621,9 +5689,9 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5621
5689
|
*/
|
|
5622
5690
|
async list(options) {
|
|
5623
5691
|
var _a;
|
|
5624
|
-
|
|
5692
|
+
log31("Listing org %s credentials", this.orgSegment);
|
|
5625
5693
|
const result = await this.request(this.base(), options);
|
|
5626
|
-
|
|
5694
|
+
log31("Found %d credentials for org %s", ((_a = result.data) == null ? void 0 : _a.length) || 0, this.orgSegment);
|
|
5627
5695
|
return result;
|
|
5628
5696
|
}
|
|
5629
5697
|
/**
|
|
@@ -5632,20 +5700,20 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5632
5700
|
* owner via `CredService.get(id, { decrypt: true })`.
|
|
5633
5701
|
*/
|
|
5634
5702
|
async get(id, getOptions, options) {
|
|
5635
|
-
|
|
5703
|
+
log31("Getting org %s credential %d (decrypt=%s)", this.orgSegment, id, getOptions == null ? void 0 : getOptions.decrypt);
|
|
5636
5704
|
const queryString = this.buildQueryString((getOptions == null ? void 0 : getOptions.decrypt) ? { decrypt: "true" } : {});
|
|
5637
5705
|
const result = await this.request(
|
|
5638
5706
|
`${this.base()}/${id}${queryString}`,
|
|
5639
5707
|
options
|
|
5640
5708
|
);
|
|
5641
|
-
|
|
5709
|
+
log31("Retrieved org credential: %s", result.key);
|
|
5642
5710
|
return result;
|
|
5643
5711
|
}
|
|
5644
5712
|
// ===========================================================================
|
|
5645
5713
|
// Create
|
|
5646
5714
|
// ===========================================================================
|
|
5647
5715
|
async createKV(data, options) {
|
|
5648
|
-
|
|
5716
|
+
log31("Creating org %s KV credential: %s (type=%s)", this.orgSegment, data.key, data.type);
|
|
5649
5717
|
return this.request(`${this.base()}/kv`, {
|
|
5650
5718
|
body: JSON.stringify(data),
|
|
5651
5719
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5654,7 +5722,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5654
5722
|
});
|
|
5655
5723
|
}
|
|
5656
5724
|
async createOAuth(data, options) {
|
|
5657
|
-
|
|
5725
|
+
log31("Creating org %s OAuth credential: %s", this.orgSegment, data.key);
|
|
5658
5726
|
return this.request(`${this.base()}/oauth`, {
|
|
5659
5727
|
body: JSON.stringify(data),
|
|
5660
5728
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5663,7 +5731,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5663
5731
|
});
|
|
5664
5732
|
}
|
|
5665
5733
|
async createFile(data, options) {
|
|
5666
|
-
|
|
5734
|
+
log31("Creating org %s file credential: %s", this.orgSegment, data.key);
|
|
5667
5735
|
return this.request(`${this.base()}/file`, {
|
|
5668
5736
|
body: JSON.stringify(data),
|
|
5669
5737
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5675,7 +5743,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5675
5743
|
// Update
|
|
5676
5744
|
// ===========================================================================
|
|
5677
5745
|
async update(id, data, options) {
|
|
5678
|
-
|
|
5746
|
+
log31("Updating org %s credential %d", this.orgSegment, id);
|
|
5679
5747
|
return this.request(`${this.base()}/${id}`, {
|
|
5680
5748
|
body: JSON.stringify(data),
|
|
5681
5749
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5687,14 +5755,14 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5687
5755
|
// Delete
|
|
5688
5756
|
// ===========================================================================
|
|
5689
5757
|
async delete(id, options) {
|
|
5690
|
-
|
|
5758
|
+
log31("Deleting org %s credential %d", this.orgSegment, id);
|
|
5691
5759
|
return this.request(`${this.base()}/${id}`, {
|
|
5692
5760
|
method: "DELETE",
|
|
5693
5761
|
...options
|
|
5694
5762
|
});
|
|
5695
5763
|
}
|
|
5696
5764
|
async deleteByKey(key, options) {
|
|
5697
|
-
|
|
5765
|
+
log31("Deleting org %s credential by key: %s", this.orgSegment, key);
|
|
5698
5766
|
return this.request(`${this.base()}/key/${encodeURIComponent(key)}`, {
|
|
5699
5767
|
method: "DELETE",
|
|
5700
5768
|
...options
|
|
@@ -5708,7 +5776,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5708
5776
|
* the org has bound vs. is missing. Reads only; any org member may call.
|
|
5709
5777
|
*/
|
|
5710
5778
|
async getSkillCredStatus(skillIdentifier, options) {
|
|
5711
|
-
|
|
5779
|
+
log31("Getting org %s skill cred status: %s", this.orgSegment, skillIdentifier);
|
|
5712
5780
|
const path = `/v1/organizations/${this.orgSegment}/skills/${encodeURIComponent(skillIdentifier)}/creds/status`;
|
|
5713
5781
|
const result = await this.request(
|
|
5714
5782
|
path,
|
|
@@ -5719,8 +5787,8 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5719
5787
|
};
|
|
5720
5788
|
|
|
5721
5789
|
// src/market/services/OrganizationService.ts
|
|
5722
|
-
import
|
|
5723
|
-
var
|
|
5790
|
+
import debug32 from "debug";
|
|
5791
|
+
var log32 = debug32("lobe-market-sdk:organization");
|
|
5724
5792
|
var OrganizationService2 = class extends BaseSDK {
|
|
5725
5793
|
constructor(options = {}, sharedHeaders, sharedTokenState) {
|
|
5726
5794
|
super(options, sharedHeaders, sharedTokenState);
|
|
@@ -5768,12 +5836,12 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5768
5836
|
async getOrganizationInfo(idOrNamespace, params = {}, options) {
|
|
5769
5837
|
const locale = params.locale || this.defaultLocale;
|
|
5770
5838
|
const queryString = this.buildQueryString({ locale });
|
|
5771
|
-
|
|
5839
|
+
log32("Getting organization info: %O", { idOrNamespace, ...params });
|
|
5772
5840
|
const result = await this.request(
|
|
5773
5841
|
`/v1/organizations/info/${idOrNamespace}${queryString}`,
|
|
5774
5842
|
options
|
|
5775
5843
|
);
|
|
5776
|
-
|
|
5844
|
+
log32("Organization info retrieved for: %s", idOrNamespace);
|
|
5777
5845
|
return result;
|
|
5778
5846
|
}
|
|
5779
5847
|
/**
|
|
@@ -5783,7 +5851,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5783
5851
|
* @returns Promise resolving to the user's organizations
|
|
5784
5852
|
*/
|
|
5785
5853
|
async listMyOrganizations(options) {
|
|
5786
|
-
|
|
5854
|
+
log32("Listing organizations for current user");
|
|
5787
5855
|
const result = await this.request(
|
|
5788
5856
|
"/v1/organizations/me",
|
|
5789
5857
|
options
|
|
@@ -5801,7 +5869,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5801
5869
|
* @returns The created/existing organization and whether it was newly created
|
|
5802
5870
|
*/
|
|
5803
5871
|
async createOrganization(data, options) {
|
|
5804
|
-
|
|
5872
|
+
log32("Creating organization: %s", data.clerkId);
|
|
5805
5873
|
return this.request("/v1/organizations", {
|
|
5806
5874
|
...options,
|
|
5807
5875
|
body: JSON.stringify(data),
|
|
@@ -5816,7 +5884,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5816
5884
|
* @returns The updated organization
|
|
5817
5885
|
*/
|
|
5818
5886
|
async updateOrganization(orgId, data, options) {
|
|
5819
|
-
|
|
5887
|
+
log32("Updating organization %d: %O", orgId, data);
|
|
5820
5888
|
const result = await this.request(
|
|
5821
5889
|
`/v1/organizations/${orgRefToPathSegment(orgId)}`,
|
|
5822
5890
|
{
|
|
@@ -5835,7 +5903,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5835
5903
|
* @returns The archived organization
|
|
5836
5904
|
*/
|
|
5837
5905
|
async archiveOrganization(orgId, options) {
|
|
5838
|
-
|
|
5906
|
+
log32("Archiving organization %d", orgId);
|
|
5839
5907
|
const result = await this.request(
|
|
5840
5908
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/archive`,
|
|
5841
5909
|
{ ...options, method: "POST" }
|
|
@@ -5849,7 +5917,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5849
5917
|
* @returns The reactivated organization
|
|
5850
5918
|
*/
|
|
5851
5919
|
async unarchiveOrganization(orgId, options) {
|
|
5852
|
-
|
|
5920
|
+
log32("Unarchiving organization %d", orgId);
|
|
5853
5921
|
const result = await this.request(
|
|
5854
5922
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/unarchive`,
|
|
5855
5923
|
{ ...options, method: "POST" }
|
|
@@ -5863,7 +5931,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5863
5931
|
* @returns Hydrated member rows
|
|
5864
5932
|
*/
|
|
5865
5933
|
async listMembers(orgId, options) {
|
|
5866
|
-
|
|
5934
|
+
log32("Listing members of organization %d", orgId);
|
|
5867
5935
|
const result = await this.request(
|
|
5868
5936
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
5869
5937
|
options
|
|
@@ -5880,7 +5948,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5880
5948
|
* @returns Whether the member was newly added and their effective role
|
|
5881
5949
|
*/
|
|
5882
5950
|
async addMember(orgId, userAccountId, role, options) {
|
|
5883
|
-
|
|
5951
|
+
log32("Adding member %d to organization %d (role=%s)", userAccountId, orgId, role);
|
|
5884
5952
|
return this.request(
|
|
5885
5953
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
5886
5954
|
{
|
|
@@ -5899,7 +5967,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5899
5967
|
* @returns Whether a membership row was removed
|
|
5900
5968
|
*/
|
|
5901
5969
|
async removeMember(orgId, userAccountId, options) {
|
|
5902
|
-
|
|
5970
|
+
log32("Removing member %d from organization %d", userAccountId, orgId);
|
|
5903
5971
|
return this.request(
|
|
5904
5972
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members/${userAccountId}`,
|
|
5905
5973
|
{ ...options, method: "DELETE" }
|
|
@@ -5915,7 +5983,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5915
5983
|
* @returns The effective role and whether it changed
|
|
5916
5984
|
*/
|
|
5917
5985
|
async updateMemberRole(orgId, userAccountId, role, options) {
|
|
5918
|
-
|
|
5986
|
+
log32("Updating member %d role to %s in organization %d", userAccountId, role, orgId);
|
|
5919
5987
|
return this.request(
|
|
5920
5988
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members/${userAccountId}`,
|
|
5921
5989
|
{ ...options, body: JSON.stringify({ role }), method: "PATCH" }
|
|
@@ -5933,7 +6001,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5933
6001
|
* @returns Counts of added / removed / updated members and skipped ids
|
|
5934
6002
|
*/
|
|
5935
6003
|
async reconcileMembers(orgId, members, options) {
|
|
5936
|
-
|
|
6004
|
+
log32("Reconciling %d members for organization %d", members.length, orgId);
|
|
5937
6005
|
return this.request(
|
|
5938
6006
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
5939
6007
|
{
|
|
@@ -5946,8 +6014,8 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5946
6014
|
};
|
|
5947
6015
|
|
|
5948
6016
|
// src/market/services/UserService.ts
|
|
5949
|
-
import
|
|
5950
|
-
var
|
|
6017
|
+
import debug33 from "debug";
|
|
6018
|
+
var log33 = debug33("lobe-market-sdk:user");
|
|
5951
6019
|
var UserService = class extends BaseSDK {
|
|
5952
6020
|
/**
|
|
5953
6021
|
* Retrieves user information by account ID or userName
|
|
@@ -5964,12 +6032,12 @@ var UserService = class extends BaseSDK {
|
|
|
5964
6032
|
const locale = params.locale || this.defaultLocale;
|
|
5965
6033
|
const queryParams = { locale };
|
|
5966
6034
|
const queryString = this.buildQueryString(queryParams);
|
|
5967
|
-
|
|
6035
|
+
log33("Getting user info: %O", { idOrUserName, ...params });
|
|
5968
6036
|
const result = await this.request(
|
|
5969
6037
|
`/v1/user/info/${idOrUserName}${queryString}`,
|
|
5970
6038
|
options
|
|
5971
6039
|
);
|
|
5972
|
-
|
|
6040
|
+
log33("User info successfully retrieved for: %s", idOrUserName);
|
|
5973
6041
|
return result;
|
|
5974
6042
|
}
|
|
5975
6043
|
/**
|
|
@@ -5984,7 +6052,7 @@ var UserService = class extends BaseSDK {
|
|
|
5984
6052
|
* @throws Error if userName is already taken or update fails
|
|
5985
6053
|
*/
|
|
5986
6054
|
async updateUserInfo(data, options) {
|
|
5987
|
-
|
|
6055
|
+
log33("Updating user info: %O", data);
|
|
5988
6056
|
const result = await this.request("/v1/user/update", {
|
|
5989
6057
|
body: JSON.stringify(data),
|
|
5990
6058
|
headers: {
|
|
@@ -5993,7 +6061,7 @@ var UserService = class extends BaseSDK {
|
|
|
5993
6061
|
method: "POST",
|
|
5994
6062
|
...options
|
|
5995
6063
|
});
|
|
5996
|
-
|
|
6064
|
+
log33("User info updated successfully");
|
|
5997
6065
|
return result;
|
|
5998
6066
|
}
|
|
5999
6067
|
/**
|
|
@@ -6023,7 +6091,7 @@ var UserService = class extends BaseSDK {
|
|
|
6023
6091
|
* ```
|
|
6024
6092
|
*/
|
|
6025
6093
|
async register(data, options) {
|
|
6026
|
-
|
|
6094
|
+
log33("Registering user: %O", {
|
|
6027
6095
|
followUserId: data.followUserId,
|
|
6028
6096
|
registerUserId: data.registerUserId
|
|
6029
6097
|
});
|
|
@@ -6035,14 +6103,14 @@ var UserService = class extends BaseSDK {
|
|
|
6035
6103
|
method: "POST",
|
|
6036
6104
|
...options
|
|
6037
6105
|
});
|
|
6038
|
-
|
|
6106
|
+
log33("User registered successfully: created=%s, userId=%s", result.created, result.user.clerkId);
|
|
6039
6107
|
return result;
|
|
6040
6108
|
}
|
|
6041
6109
|
};
|
|
6042
6110
|
|
|
6043
6111
|
// src/market/services/UserFollowService.ts
|
|
6044
|
-
import
|
|
6045
|
-
var
|
|
6112
|
+
import debug34 from "debug";
|
|
6113
|
+
var log34 = debug34("lobe-market-sdk:user-follow");
|
|
6046
6114
|
var UserFollowService = class extends BaseSDK {
|
|
6047
6115
|
/**
|
|
6048
6116
|
* Follow a user
|
|
@@ -6056,7 +6124,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6056
6124
|
* @throws Error if already following or cannot follow yourself
|
|
6057
6125
|
*/
|
|
6058
6126
|
async follow(followingId, options) {
|
|
6059
|
-
|
|
6127
|
+
log34("Following user: %d", followingId);
|
|
6060
6128
|
const body = { followingId };
|
|
6061
6129
|
const result = await this.request("/v1/user/follows", {
|
|
6062
6130
|
body: JSON.stringify(body),
|
|
@@ -6066,7 +6134,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6066
6134
|
method: "POST",
|
|
6067
6135
|
...options
|
|
6068
6136
|
});
|
|
6069
|
-
|
|
6137
|
+
log34("Successfully followed user: %d", followingId);
|
|
6070
6138
|
return result;
|
|
6071
6139
|
}
|
|
6072
6140
|
/**
|
|
@@ -6081,7 +6149,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6081
6149
|
* @throws Error if follow relationship not found
|
|
6082
6150
|
*/
|
|
6083
6151
|
async unfollow(followingId, options) {
|
|
6084
|
-
|
|
6152
|
+
log34("Unfollowing user: %d", followingId);
|
|
6085
6153
|
const body = { followingId };
|
|
6086
6154
|
const result = await this.request("/v1/user/follows", {
|
|
6087
6155
|
body: JSON.stringify(body),
|
|
@@ -6091,7 +6159,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6091
6159
|
method: "DELETE",
|
|
6092
6160
|
...options
|
|
6093
6161
|
});
|
|
6094
|
-
|
|
6162
|
+
log34("Successfully unfollowed user: %d", followingId);
|
|
6095
6163
|
return result;
|
|
6096
6164
|
}
|
|
6097
6165
|
/**
|
|
@@ -6105,13 +6173,13 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6105
6173
|
* @returns Promise resolving to follow status (isFollowing, isMutual)
|
|
6106
6174
|
*/
|
|
6107
6175
|
async checkFollowStatus(targetUserId, options) {
|
|
6108
|
-
|
|
6176
|
+
log34("Checking follow status for user: %d", targetUserId);
|
|
6109
6177
|
const queryString = this.buildQueryString({ targetUserId: String(targetUserId) });
|
|
6110
6178
|
const result = await this.request(
|
|
6111
6179
|
`/v1/user/follows/check${queryString}`,
|
|
6112
6180
|
options
|
|
6113
6181
|
);
|
|
6114
|
-
|
|
6182
|
+
log34("Follow status retrieved: %O", result);
|
|
6115
6183
|
return result;
|
|
6116
6184
|
}
|
|
6117
6185
|
/**
|
|
@@ -6126,7 +6194,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6126
6194
|
* @returns Promise resolving to list of following users
|
|
6127
6195
|
*/
|
|
6128
6196
|
async getFollowing(userId, params = {}, options) {
|
|
6129
|
-
|
|
6197
|
+
log34("Getting following list for user: %d", userId);
|
|
6130
6198
|
const queryParams = {};
|
|
6131
6199
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6132
6200
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6135,7 +6203,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6135
6203
|
`/v1/user/follows/${userId}/following${queryString}`,
|
|
6136
6204
|
options
|
|
6137
6205
|
);
|
|
6138
|
-
|
|
6206
|
+
log34("Following list retrieved for user: %d", userId);
|
|
6139
6207
|
return result;
|
|
6140
6208
|
}
|
|
6141
6209
|
/**
|
|
@@ -6150,7 +6218,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6150
6218
|
* @returns Promise resolving to list of followers
|
|
6151
6219
|
*/
|
|
6152
6220
|
async getFollowers(userId, params = {}, options) {
|
|
6153
|
-
|
|
6221
|
+
log34("Getting followers list for user: %d", userId);
|
|
6154
6222
|
const queryParams = {};
|
|
6155
6223
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6156
6224
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6159,14 +6227,14 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6159
6227
|
`/v1/user/follows/${userId}/followers${queryString}`,
|
|
6160
6228
|
options
|
|
6161
6229
|
);
|
|
6162
|
-
|
|
6230
|
+
log34("Followers list retrieved for user: %d", userId);
|
|
6163
6231
|
return result;
|
|
6164
6232
|
}
|
|
6165
6233
|
};
|
|
6166
6234
|
|
|
6167
6235
|
// src/market/services/UserFavoriteService.ts
|
|
6168
|
-
import
|
|
6169
|
-
var
|
|
6236
|
+
import debug35 from "debug";
|
|
6237
|
+
var log35 = debug35("lobe-market-sdk:user-favorite");
|
|
6170
6238
|
var UserFavoriteService = class extends BaseSDK {
|
|
6171
6239
|
/**
|
|
6172
6240
|
* Add to favorites
|
|
@@ -6181,7 +6249,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6181
6249
|
* @throws Error if already in favorites
|
|
6182
6250
|
*/
|
|
6183
6251
|
async addFavorite(targetType, targetId, options) {
|
|
6184
|
-
|
|
6252
|
+
log35("Adding favorite: %s %d", targetType, targetId);
|
|
6185
6253
|
const body = { targetId, targetType };
|
|
6186
6254
|
const result = await this.request("/v1/user/favorites", {
|
|
6187
6255
|
body: JSON.stringify(body),
|
|
@@ -6191,7 +6259,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6191
6259
|
method: "POST",
|
|
6192
6260
|
...options
|
|
6193
6261
|
});
|
|
6194
|
-
|
|
6262
|
+
log35("Successfully added favorite: %s %d", targetType, targetId);
|
|
6195
6263
|
return result;
|
|
6196
6264
|
}
|
|
6197
6265
|
/**
|
|
@@ -6207,7 +6275,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6207
6275
|
* @throws Error if favorite not found
|
|
6208
6276
|
*/
|
|
6209
6277
|
async removeFavorite(targetType, targetId, options) {
|
|
6210
|
-
|
|
6278
|
+
log35("Removing favorite: %s %d", targetType, targetId);
|
|
6211
6279
|
const body = { targetId, targetType };
|
|
6212
6280
|
const result = await this.request("/v1/user/favorites", {
|
|
6213
6281
|
body: JSON.stringify(body),
|
|
@@ -6217,7 +6285,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6217
6285
|
method: "DELETE",
|
|
6218
6286
|
...options
|
|
6219
6287
|
});
|
|
6220
|
-
|
|
6288
|
+
log35("Successfully removed favorite: %s %d", targetType, targetId);
|
|
6221
6289
|
return result;
|
|
6222
6290
|
}
|
|
6223
6291
|
/**
|
|
@@ -6232,7 +6300,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6232
6300
|
* @returns Promise resolving to favorite status
|
|
6233
6301
|
*/
|
|
6234
6302
|
async checkFavorite(targetType, targetId, options) {
|
|
6235
|
-
|
|
6303
|
+
log35("Checking favorite status: %s %d", targetType, targetId);
|
|
6236
6304
|
const queryString = this.buildQueryString({
|
|
6237
6305
|
targetId: String(targetId),
|
|
6238
6306
|
targetType
|
|
@@ -6241,7 +6309,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6241
6309
|
`/v1/user/favorites/check${queryString}`,
|
|
6242
6310
|
options
|
|
6243
6311
|
);
|
|
6244
|
-
|
|
6312
|
+
log35("Favorite status retrieved: %O", result);
|
|
6245
6313
|
return result;
|
|
6246
6314
|
}
|
|
6247
6315
|
/**
|
|
@@ -6255,7 +6323,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6255
6323
|
* @returns Promise resolving to list of favorites
|
|
6256
6324
|
*/
|
|
6257
6325
|
async getMyFavorites(params = {}, options) {
|
|
6258
|
-
|
|
6326
|
+
log35("Getting my favorites: %O", params);
|
|
6259
6327
|
const queryParams = {};
|
|
6260
6328
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6261
6329
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6265,7 +6333,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6265
6333
|
`/v1/user/favorites/me${queryString}`,
|
|
6266
6334
|
options
|
|
6267
6335
|
);
|
|
6268
|
-
|
|
6336
|
+
log35("My favorites retrieved");
|
|
6269
6337
|
return result;
|
|
6270
6338
|
}
|
|
6271
6339
|
/**
|
|
@@ -6280,7 +6348,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6280
6348
|
* @returns Promise resolving to list of favorites
|
|
6281
6349
|
*/
|
|
6282
6350
|
async getUserFavorites(userId, params = {}, options) {
|
|
6283
|
-
|
|
6351
|
+
log35("Getting favorites for user: %d", userId);
|
|
6284
6352
|
const queryParams = {};
|
|
6285
6353
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6286
6354
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6290,7 +6358,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6290
6358
|
`/v1/user/favorites/${userId}${queryString}`,
|
|
6291
6359
|
options
|
|
6292
6360
|
);
|
|
6293
|
-
|
|
6361
|
+
log35("Favorites retrieved for user: %d", userId);
|
|
6294
6362
|
return result;
|
|
6295
6363
|
}
|
|
6296
6364
|
/**
|
|
@@ -6305,7 +6373,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6305
6373
|
* @returns Promise resolving to list of favorite agents
|
|
6306
6374
|
*/
|
|
6307
6375
|
async getUserFavoriteAgents(userId, params = {}, options) {
|
|
6308
|
-
|
|
6376
|
+
log35("Getting favorite agents for user: %d", userId);
|
|
6309
6377
|
const queryParams = {};
|
|
6310
6378
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6311
6379
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6314,7 +6382,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6314
6382
|
`/v1/user/favorites/${userId}/agents${queryString}`,
|
|
6315
6383
|
options
|
|
6316
6384
|
);
|
|
6317
|
-
|
|
6385
|
+
log35("Favorite agents retrieved for user: %d", userId);
|
|
6318
6386
|
return result;
|
|
6319
6387
|
}
|
|
6320
6388
|
/**
|
|
@@ -6329,7 +6397,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6329
6397
|
* @returns Promise resolving to list of favorite plugins
|
|
6330
6398
|
*/
|
|
6331
6399
|
async getUserFavoritePlugins(userId, params = {}, options) {
|
|
6332
|
-
|
|
6400
|
+
log35("Getting favorite plugins for user: %d", userId);
|
|
6333
6401
|
const queryParams = {};
|
|
6334
6402
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6335
6403
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6338,14 +6406,14 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6338
6406
|
`/v1/user/favorites/${userId}/plugins${queryString}`,
|
|
6339
6407
|
options
|
|
6340
6408
|
);
|
|
6341
|
-
|
|
6409
|
+
log35("Favorite plugins retrieved for user: %d", userId);
|
|
6342
6410
|
return result;
|
|
6343
6411
|
}
|
|
6344
6412
|
};
|
|
6345
6413
|
|
|
6346
6414
|
// src/market/services/UserLikeService.ts
|
|
6347
|
-
import
|
|
6348
|
-
var
|
|
6415
|
+
import debug36 from "debug";
|
|
6416
|
+
var log36 = debug36("lobe-market-sdk:user-like");
|
|
6349
6417
|
var UserLikeService = class extends BaseSDK {
|
|
6350
6418
|
/**
|
|
6351
6419
|
* Like content
|
|
@@ -6360,7 +6428,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6360
6428
|
* @throws Error if already liked
|
|
6361
6429
|
*/
|
|
6362
6430
|
async like(targetType, targetId, options) {
|
|
6363
|
-
|
|
6431
|
+
log36("Liking: %s %d", targetType, targetId);
|
|
6364
6432
|
const body = { targetId, targetType };
|
|
6365
6433
|
const result = await this.request("/v1/user/likes", {
|
|
6366
6434
|
body: JSON.stringify(body),
|
|
@@ -6370,7 +6438,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6370
6438
|
method: "POST",
|
|
6371
6439
|
...options
|
|
6372
6440
|
});
|
|
6373
|
-
|
|
6441
|
+
log36("Successfully liked: %s %d", targetType, targetId);
|
|
6374
6442
|
return result;
|
|
6375
6443
|
}
|
|
6376
6444
|
/**
|
|
@@ -6386,7 +6454,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6386
6454
|
* @throws Error if like not found
|
|
6387
6455
|
*/
|
|
6388
6456
|
async unlike(targetType, targetId, options) {
|
|
6389
|
-
|
|
6457
|
+
log36("Unliking: %s %d", targetType, targetId);
|
|
6390
6458
|
const body = { targetId, targetType };
|
|
6391
6459
|
const result = await this.request("/v1/user/likes", {
|
|
6392
6460
|
body: JSON.stringify(body),
|
|
@@ -6396,7 +6464,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6396
6464
|
method: "DELETE",
|
|
6397
6465
|
...options
|
|
6398
6466
|
});
|
|
6399
|
-
|
|
6467
|
+
log36("Successfully unliked: %s %d", targetType, targetId);
|
|
6400
6468
|
return result;
|
|
6401
6469
|
}
|
|
6402
6470
|
/**
|
|
@@ -6411,7 +6479,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6411
6479
|
* @returns Promise resolving to toggle response with new like status
|
|
6412
6480
|
*/
|
|
6413
6481
|
async toggleLike(targetType, targetId, options) {
|
|
6414
|
-
|
|
6482
|
+
log36("Toggling like: %s %d", targetType, targetId);
|
|
6415
6483
|
const body = { targetId, targetType };
|
|
6416
6484
|
const result = await this.request("/v1/user/likes/toggle", {
|
|
6417
6485
|
body: JSON.stringify(body),
|
|
@@ -6421,7 +6489,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6421
6489
|
method: "POST",
|
|
6422
6490
|
...options
|
|
6423
6491
|
});
|
|
6424
|
-
|
|
6492
|
+
log36("Like toggled, new status: %O", result);
|
|
6425
6493
|
return result;
|
|
6426
6494
|
}
|
|
6427
6495
|
/**
|
|
@@ -6436,7 +6504,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6436
6504
|
* @returns Promise resolving to like status
|
|
6437
6505
|
*/
|
|
6438
6506
|
async checkLike(targetType, targetId, options) {
|
|
6439
|
-
|
|
6507
|
+
log36("Checking like status: %s %d", targetType, targetId);
|
|
6440
6508
|
const queryString = this.buildQueryString({
|
|
6441
6509
|
targetId: String(targetId),
|
|
6442
6510
|
targetType
|
|
@@ -6445,7 +6513,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6445
6513
|
`/v1/user/likes/check${queryString}`,
|
|
6446
6514
|
options
|
|
6447
6515
|
);
|
|
6448
|
-
|
|
6516
|
+
log36("Like status retrieved: %O", result);
|
|
6449
6517
|
return result;
|
|
6450
6518
|
}
|
|
6451
6519
|
/**
|
|
@@ -6459,7 +6527,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6459
6527
|
* @returns Promise resolving to list of likes
|
|
6460
6528
|
*/
|
|
6461
6529
|
async getMyLikes(params = {}, options) {
|
|
6462
|
-
|
|
6530
|
+
log36("Getting my likes: %O", params);
|
|
6463
6531
|
const queryParams = {};
|
|
6464
6532
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6465
6533
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6469,7 +6537,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6469
6537
|
`/v1/user/likes/me${queryString}`,
|
|
6470
6538
|
options
|
|
6471
6539
|
);
|
|
6472
|
-
|
|
6540
|
+
log36("My likes retrieved");
|
|
6473
6541
|
return result;
|
|
6474
6542
|
}
|
|
6475
6543
|
/**
|
|
@@ -6484,7 +6552,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6484
6552
|
* @returns Promise resolving to list of likes
|
|
6485
6553
|
*/
|
|
6486
6554
|
async getUserLikes(userId, params = {}, options) {
|
|
6487
|
-
|
|
6555
|
+
log36("Getting likes for user: %d", userId);
|
|
6488
6556
|
const queryParams = {};
|
|
6489
6557
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6490
6558
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6494,7 +6562,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6494
6562
|
`/v1/user/likes/${userId}${queryString}`,
|
|
6495
6563
|
options
|
|
6496
6564
|
);
|
|
6497
|
-
|
|
6565
|
+
log36("Likes retrieved for user: %d", userId);
|
|
6498
6566
|
return result;
|
|
6499
6567
|
}
|
|
6500
6568
|
/**
|
|
@@ -6509,7 +6577,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6509
6577
|
* @returns Promise resolving to list of liked agents
|
|
6510
6578
|
*/
|
|
6511
6579
|
async getUserLikedAgents(userId, params = {}, options) {
|
|
6512
|
-
|
|
6580
|
+
log36("Getting liked agents for user: %d", userId);
|
|
6513
6581
|
const queryParams = {};
|
|
6514
6582
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6515
6583
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6518,7 +6586,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6518
6586
|
`/v1/user/likes/${userId}/agents${queryString}`,
|
|
6519
6587
|
options
|
|
6520
6588
|
);
|
|
6521
|
-
|
|
6589
|
+
log36("Liked agents retrieved for user: %d", userId);
|
|
6522
6590
|
return result;
|
|
6523
6591
|
}
|
|
6524
6592
|
/**
|
|
@@ -6533,7 +6601,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6533
6601
|
* @returns Promise resolving to list of liked plugins
|
|
6534
6602
|
*/
|
|
6535
6603
|
async getUserLikedPlugins(userId, params = {}, options) {
|
|
6536
|
-
|
|
6604
|
+
log36("Getting liked plugins for user: %d", userId);
|
|
6537
6605
|
const queryParams = {};
|
|
6538
6606
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6539
6607
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6542,14 +6610,14 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6542
6610
|
`/v1/user/likes/${userId}/plugins${queryString}`,
|
|
6543
6611
|
options
|
|
6544
6612
|
);
|
|
6545
|
-
|
|
6613
|
+
log36("Liked plugins retrieved for user: %d", userId);
|
|
6546
6614
|
return result;
|
|
6547
6615
|
}
|
|
6548
6616
|
};
|
|
6549
6617
|
|
|
6550
6618
|
// src/market/services/UserPublishService.ts
|
|
6551
|
-
import
|
|
6552
|
-
var
|
|
6619
|
+
import debug37 from "debug";
|
|
6620
|
+
var log37 = debug37("lobe-market-sdk:user-publish");
|
|
6553
6621
|
var UserPublishService = class extends BaseSDK {
|
|
6554
6622
|
/**
|
|
6555
6623
|
* Lists all plugins owned by the authenticated user
|
|
@@ -6559,9 +6627,9 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6559
6627
|
*/
|
|
6560
6628
|
async listPlugins(options) {
|
|
6561
6629
|
var _a;
|
|
6562
|
-
|
|
6630
|
+
log37("Listing user plugins");
|
|
6563
6631
|
const result = await this.request("/v1/user/plugins", options);
|
|
6564
|
-
|
|
6632
|
+
log37("Found %d user plugins", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
6565
6633
|
return result;
|
|
6566
6634
|
}
|
|
6567
6635
|
/**
|
|
@@ -6572,9 +6640,9 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6572
6640
|
*/
|
|
6573
6641
|
async listSkills(options) {
|
|
6574
6642
|
var _a;
|
|
6575
|
-
|
|
6643
|
+
log37("Listing user skills");
|
|
6576
6644
|
const result = await this.request("/v1/user/skills", options);
|
|
6577
|
-
|
|
6645
|
+
log37("Found %d user skills", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
6578
6646
|
return result;
|
|
6579
6647
|
}
|
|
6580
6648
|
/**
|
|
@@ -6586,7 +6654,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6586
6654
|
* @returns Promise resolving to the publish result
|
|
6587
6655
|
*/
|
|
6588
6656
|
async publishSkillVersion(identifier, zipBuffer, options) {
|
|
6589
|
-
|
|
6657
|
+
log37("Publishing skill version for: %s", identifier);
|
|
6590
6658
|
const formData = new FormData();
|
|
6591
6659
|
const arrayBuffer = zipBuffer instanceof ArrayBuffer ? zipBuffer : zipBuffer.buffer.slice(
|
|
6592
6660
|
zipBuffer.byteOffset,
|
|
@@ -6602,7 +6670,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6602
6670
|
...options
|
|
6603
6671
|
}
|
|
6604
6672
|
);
|
|
6605
|
-
|
|
6673
|
+
log37("Published skill version: %s@%s", identifier, result.version);
|
|
6606
6674
|
return result;
|
|
6607
6675
|
}
|
|
6608
6676
|
/**
|
|
@@ -6613,11 +6681,11 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6613
6681
|
*/
|
|
6614
6682
|
async scanClaimableAssets(assetType) {
|
|
6615
6683
|
var _a;
|
|
6616
|
-
|
|
6684
|
+
log37("Scanning claimable %s", assetType);
|
|
6617
6685
|
const result = await this.request(
|
|
6618
6686
|
`/v1/user/claims/scan/${assetType}`
|
|
6619
6687
|
);
|
|
6620
|
-
|
|
6688
|
+
log37("Found %d claimable %s", ((_a = result.data) == null ? void 0 : _a.length) || 0, assetType);
|
|
6621
6689
|
return result;
|
|
6622
6690
|
}
|
|
6623
6691
|
/**
|
|
@@ -6628,13 +6696,13 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6628
6696
|
* @returns Promise resolving to the claim result
|
|
6629
6697
|
*/
|
|
6630
6698
|
async claimAsset(assetId, assetType) {
|
|
6631
|
-
|
|
6699
|
+
log37("Claiming %s with id: %d", assetType, assetId);
|
|
6632
6700
|
const result = await this.request("/v1/user/claims", {
|
|
6633
6701
|
body: JSON.stringify({ assetId, assetType }),
|
|
6634
6702
|
headers: { "Content-Type": "application/json" },
|
|
6635
6703
|
method: "POST"
|
|
6636
6704
|
});
|
|
6637
|
-
|
|
6705
|
+
log37("Claim result for %s %d: %s", assetType, assetId, result.success);
|
|
6638
6706
|
return result;
|
|
6639
6707
|
}
|
|
6640
6708
|
/**
|
|
@@ -6648,13 +6716,13 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6648
6716
|
* @returns Promise resolving to the claim result
|
|
6649
6717
|
*/
|
|
6650
6718
|
async claimAssetByIdentifier(identifier, assetType) {
|
|
6651
|
-
|
|
6719
|
+
log37("Claiming %s with identifier: %s", assetType, identifier);
|
|
6652
6720
|
const result = await this.request("/v1/user/claims", {
|
|
6653
6721
|
body: JSON.stringify({ assetType, identifier }),
|
|
6654
6722
|
headers: { "Content-Type": "application/json" },
|
|
6655
6723
|
method: "POST"
|
|
6656
6724
|
});
|
|
6657
|
-
|
|
6725
|
+
log37("Claim result for %s %s: %s", assetType, identifier, result.success);
|
|
6658
6726
|
return result;
|
|
6659
6727
|
}
|
|
6660
6728
|
/**
|
|
@@ -6669,14 +6737,14 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6669
6737
|
* @returns Promise resolving to the submission result
|
|
6670
6738
|
*/
|
|
6671
6739
|
async submitRepo(params, options) {
|
|
6672
|
-
|
|
6740
|
+
log37("Submitting repository for import: %s (%s)", params.gitUrl, params.type);
|
|
6673
6741
|
const result = await this.request("/v1/user/claims/submit-repo", {
|
|
6674
6742
|
body: JSON.stringify(params),
|
|
6675
6743
|
headers: { "Content-Type": "application/json" },
|
|
6676
6744
|
method: "POST",
|
|
6677
6745
|
...options
|
|
6678
6746
|
});
|
|
6679
|
-
|
|
6747
|
+
log37("Submit result for %s: %s", params.gitUrl, result.success);
|
|
6680
6748
|
return result;
|
|
6681
6749
|
}
|
|
6682
6750
|
/**
|
|
@@ -6687,14 +6755,14 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6687
6755
|
* @returns Promise resolving immediately with the plugin identifier and version
|
|
6688
6756
|
*/
|
|
6689
6757
|
async publishPlugin(params, options) {
|
|
6690
|
-
|
|
6758
|
+
log37("Publishing plugin: %s@%s", params.identifier, params.version);
|
|
6691
6759
|
const result = await this.request("/v1/user/plugins", {
|
|
6692
6760
|
body: JSON.stringify(params),
|
|
6693
6761
|
headers: { "Content-Type": "application/json" },
|
|
6694
6762
|
method: "POST",
|
|
6695
6763
|
...options
|
|
6696
6764
|
});
|
|
6697
|
-
|
|
6765
|
+
log37("Published plugin: %s@%s (%s)", result.identifier, result.version, result.status);
|
|
6698
6766
|
return result;
|
|
6699
6767
|
}
|
|
6700
6768
|
/**
|
|
@@ -6705,12 +6773,12 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6705
6773
|
* @returns Promise resolving to the delete result
|
|
6706
6774
|
*/
|
|
6707
6775
|
async deleteSkill(identifier, options) {
|
|
6708
|
-
|
|
6776
|
+
log37("Deleting skill: %s", identifier);
|
|
6709
6777
|
const result = await this.request(
|
|
6710
6778
|
`/v1/user/skills/${encodeURIComponent(identifier)}`,
|
|
6711
6779
|
{ method: "DELETE", ...options }
|
|
6712
6780
|
);
|
|
6713
|
-
|
|
6781
|
+
log37("Deleted skill: %s", identifier);
|
|
6714
6782
|
return result;
|
|
6715
6783
|
}
|
|
6716
6784
|
/**
|
|
@@ -6722,7 +6790,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6722
6790
|
* @returns Promise resolving to the updated status
|
|
6723
6791
|
*/
|
|
6724
6792
|
async updateSkillStatus(identifier, status, options) {
|
|
6725
|
-
|
|
6793
|
+
log37("Updating skill status: %s \u2192 %s", identifier, status);
|
|
6726
6794
|
const result = await this.request(
|
|
6727
6795
|
`/v1/user/skills/${encodeURIComponent(identifier)}/status`,
|
|
6728
6796
|
{
|
|
@@ -6732,7 +6800,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6732
6800
|
...options
|
|
6733
6801
|
}
|
|
6734
6802
|
);
|
|
6735
|
-
|
|
6803
|
+
log37("Updated skill status: %s \u2192 %s", identifier, result.status);
|
|
6736
6804
|
return result;
|
|
6737
6805
|
}
|
|
6738
6806
|
/**
|
|
@@ -6743,12 +6811,12 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6743
6811
|
* @returns Promise resolving to the delete result
|
|
6744
6812
|
*/
|
|
6745
6813
|
async deletePlugin(identifier, options) {
|
|
6746
|
-
|
|
6814
|
+
log37("Deleting plugin: %s", identifier);
|
|
6747
6815
|
const result = await this.request(
|
|
6748
6816
|
`/v1/user/plugins/${encodeURIComponent(identifier)}`,
|
|
6749
6817
|
{ method: "DELETE", ...options }
|
|
6750
6818
|
);
|
|
6751
|
-
|
|
6819
|
+
log37("Deleted plugin: %s", identifier);
|
|
6752
6820
|
return result;
|
|
6753
6821
|
}
|
|
6754
6822
|
/**
|
|
@@ -6760,7 +6828,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6760
6828
|
* @returns Promise resolving to the updated status
|
|
6761
6829
|
*/
|
|
6762
6830
|
async updatePluginStatus(identifier, status, options) {
|
|
6763
|
-
|
|
6831
|
+
log37("Updating plugin status: %s \u2192 %s", identifier, status);
|
|
6764
6832
|
const result = await this.request(
|
|
6765
6833
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/status`,
|
|
6766
6834
|
{
|
|
@@ -6770,7 +6838,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6770
6838
|
...options
|
|
6771
6839
|
}
|
|
6772
6840
|
);
|
|
6773
|
-
|
|
6841
|
+
log37("Updated plugin status: %s \u2192 %s", identifier, result.status);
|
|
6774
6842
|
return result;
|
|
6775
6843
|
}
|
|
6776
6844
|
/**
|
|
@@ -6782,7 +6850,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6782
6850
|
* @returns Promise resolving to the publish result
|
|
6783
6851
|
*/
|
|
6784
6852
|
async publishPluginVersion(identifier, data, options) {
|
|
6785
|
-
|
|
6853
|
+
log37("Publishing plugin version for: %s", identifier);
|
|
6786
6854
|
const result = await this.request(
|
|
6787
6855
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/versions`,
|
|
6788
6856
|
{
|
|
@@ -6792,7 +6860,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6792
6860
|
...options
|
|
6793
6861
|
}
|
|
6794
6862
|
);
|
|
6795
|
-
|
|
6863
|
+
log37("Published plugin version: %s@%s", identifier, result.version);
|
|
6796
6864
|
return result;
|
|
6797
6865
|
}
|
|
6798
6866
|
/**
|
|
@@ -6805,13 +6873,13 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6805
6873
|
*/
|
|
6806
6874
|
async getPluginLocalizations(identifier, version, options) {
|
|
6807
6875
|
var _a;
|
|
6808
|
-
|
|
6876
|
+
log37("Listing localizations for plugin: %s", identifier);
|
|
6809
6877
|
const query = version ? `?version=${encodeURIComponent(version)}` : "";
|
|
6810
6878
|
const result = await this.request(
|
|
6811
6879
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations${query}`,
|
|
6812
6880
|
options
|
|
6813
6881
|
);
|
|
6814
|
-
|
|
6882
|
+
log37("Found %d localizations for %s", ((_a = result.localizations) == null ? void 0 : _a.length) || 0, identifier);
|
|
6815
6883
|
return result;
|
|
6816
6884
|
}
|
|
6817
6885
|
/**
|
|
@@ -6828,7 +6896,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6828
6896
|
* @returns Promise resolving to the upsert result
|
|
6829
6897
|
*/
|
|
6830
6898
|
async updatePluginLocalizations(identifier, localizations, version, options) {
|
|
6831
|
-
|
|
6899
|
+
log37("Upserting %d localization(s) for plugin: %s", localizations.length, identifier);
|
|
6832
6900
|
const result = await this.request(
|
|
6833
6901
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations`,
|
|
6834
6902
|
{
|
|
@@ -6838,7 +6906,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6838
6906
|
...options
|
|
6839
6907
|
}
|
|
6840
6908
|
);
|
|
6841
|
-
|
|
6909
|
+
log37("Upserted localizations for %s@%s", identifier, result.version);
|
|
6842
6910
|
return result;
|
|
6843
6911
|
}
|
|
6844
6912
|
/**
|
|
@@ -6852,31 +6920,31 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6852
6920
|
* @returns Promise resolving to the delete result
|
|
6853
6921
|
*/
|
|
6854
6922
|
async deletePluginLocalization(identifier, locale, version, options) {
|
|
6855
|
-
|
|
6923
|
+
log37("Deleting localization %s for plugin: %s", locale, identifier);
|
|
6856
6924
|
const query = version ? `?version=${encodeURIComponent(version)}` : "";
|
|
6857
6925
|
const result = await this.request(
|
|
6858
6926
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations/${encodeURIComponent(locale)}${query}`,
|
|
6859
6927
|
{ method: "DELETE", ...options }
|
|
6860
6928
|
);
|
|
6861
|
-
|
|
6929
|
+
log37("Deleted localization %s for %s", locale, identifier);
|
|
6862
6930
|
return result;
|
|
6863
6931
|
}
|
|
6864
6932
|
};
|
|
6865
6933
|
|
|
6866
6934
|
// src/market/services/CategoryService.ts
|
|
6867
|
-
import
|
|
6868
|
-
var
|
|
6935
|
+
import debug38 from "debug";
|
|
6936
|
+
var log38 = debug38("lobe-market-sdk:market:categories");
|
|
6869
6937
|
var CategoryService2 = class extends BaseSDK {
|
|
6870
6938
|
/** Lists configured categories with nullable HTTP(S) image URLs or lucide:<name> icons and public asset counts, including empty categories. */
|
|
6871
6939
|
async list(assetType, locale) {
|
|
6872
|
-
|
|
6940
|
+
log38("Listing categories for %s", assetType);
|
|
6873
6941
|
const query = this.buildQueryString({ assetType, locale });
|
|
6874
6942
|
return this.request(`/v1/categories${query}`);
|
|
6875
6943
|
}
|
|
6876
6944
|
};
|
|
6877
6945
|
|
|
6878
6946
|
// src/market/market-sdk.ts
|
|
6879
|
-
var
|
|
6947
|
+
var log39 = debug39("lobe-market-sdk");
|
|
6880
6948
|
var MarketSDK = class extends BaseSDK {
|
|
6881
6949
|
/** Anonymous WebP byte URL. No signed token or public bucket is required. */
|
|
6882
6950
|
getAssetImageUrl(id) {
|
|
@@ -6897,7 +6965,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
6897
6965
|
tokenExpiry: void 0
|
|
6898
6966
|
};
|
|
6899
6967
|
super(options, void 0, sharedTokenState);
|
|
6900
|
-
|
|
6968
|
+
log39("MarketSDK instance created");
|
|
6901
6969
|
this.agentProfile = new AgentProfileService(options, this.headers, sharedTokenState);
|
|
6902
6970
|
this.categories = new CategoryService2(options, this.headers, sharedTokenState);
|
|
6903
6971
|
this.agents = new AgentService2(options, this.headers, sharedTokenState);
|
|
@@ -6907,6 +6975,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
6907
6975
|
this.creds = new CredService(options, this.headers, sharedTokenState);
|
|
6908
6976
|
this.deployments = new DeploymentService(options, this.headers, sharedTokenState);
|
|
6909
6977
|
this.plugins = new PluginsService(options, this.headers, sharedTokenState);
|
|
6978
|
+
this.sandbox = new SandboxService(options, this.headers, sharedTokenState);
|
|
6910
6979
|
this.sandboxStorage = new SandboxStorageService2(options, this.headers, sharedTokenState);
|
|
6911
6980
|
this.organizations = new OrganizationService2(options, this.headers, sharedTokenState);
|
|
6912
6981
|
this.user = new UserService(options, this.headers, sharedTokenState);
|
|
@@ -6949,7 +7018,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
6949
7018
|
* @deprecated Use auth.registerClient() instead
|
|
6950
7019
|
*/
|
|
6951
7020
|
async registerClient(request) {
|
|
6952
|
-
|
|
7021
|
+
log39("Registering client (deprecated method, use auth.registerClient): %s", request.clientName);
|
|
6953
7022
|
return this.auth.registerClient(request);
|
|
6954
7023
|
}
|
|
6955
7024
|
};
|