@lobehub/market-sdk 0.39.1 → 0.40.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 +155 -11
- package/dist/index.mjs +694 -535
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/admin/MarketAdmin.ts
|
|
2
|
-
import
|
|
2
|
+
import debug12 from "debug";
|
|
3
3
|
|
|
4
4
|
// src/core/BaseSDK.ts
|
|
5
5
|
import debug from "debug";
|
|
@@ -792,9 +792,51 @@ var AnalysisService = class extends BaseSDK {
|
|
|
792
792
|
}
|
|
793
793
|
};
|
|
794
794
|
|
|
795
|
-
// src/admin/services/
|
|
795
|
+
// src/admin/services/IngestionService.ts
|
|
796
796
|
import debug4 from "debug";
|
|
797
|
-
var log4 = debug4("lobe-market-sdk:admin:
|
|
797
|
+
var log4 = debug4("lobe-market-sdk:admin:ingestion");
|
|
798
|
+
var IngestionService = class extends BaseSDK {
|
|
799
|
+
/**
|
|
800
|
+
* Promote already-synced Official MCP Registry sources into Market MCP plugins.
|
|
801
|
+
*
|
|
802
|
+
* This import step creates missing public MCP plugin records and completes source/version
|
|
803
|
+
* ledger bindings for high-confidence matches; it does not run the registry sync itself.
|
|
804
|
+
*/
|
|
805
|
+
async importOfficialMcpRegistry(params = {}) {
|
|
806
|
+
log4("Importing Official MCP Registry sources: %O", params);
|
|
807
|
+
const result = await this.request(
|
|
808
|
+
"/admin/ingestion/plugin/official-mcp-registry/import",
|
|
809
|
+
{
|
|
810
|
+
body: JSON.stringify(params),
|
|
811
|
+
method: "POST"
|
|
812
|
+
}
|
|
813
|
+
);
|
|
814
|
+
log4("Official MCP Registry import result: %O", result.data);
|
|
815
|
+
return result;
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* Run the Official MCP Registry shadow sync.
|
|
819
|
+
*
|
|
820
|
+
* The server only writes source ledger snapshots and match/conflict results;
|
|
821
|
+
* it does not create or update public plugin records.
|
|
822
|
+
*/
|
|
823
|
+
async syncOfficialMcpRegistry(params = {}) {
|
|
824
|
+
log4("Running Official MCP Registry shadow sync: %O", params);
|
|
825
|
+
const result = await this.request(
|
|
826
|
+
"/admin/ingestion/plugin/official-mcp-registry/sync",
|
|
827
|
+
{
|
|
828
|
+
body: JSON.stringify(params),
|
|
829
|
+
method: "POST"
|
|
830
|
+
}
|
|
831
|
+
);
|
|
832
|
+
log4("Official MCP Registry shadow sync result: %O", result.data);
|
|
833
|
+
return result;
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
|
|
837
|
+
// src/admin/services/PluginService.ts
|
|
838
|
+
import debug5 from "debug";
|
|
839
|
+
var log5 = debug5("lobe-market-sdk:admin:plugins");
|
|
798
840
|
var PluginService = class extends BaseSDK {
|
|
799
841
|
/**
|
|
800
842
|
* Batch imports plugin manifests using the dedicated import endpoint
|
|
@@ -806,9 +848,9 @@ var PluginService = class extends BaseSDK {
|
|
|
806
848
|
* @returns Promise resolving to the import results with counts of success, skipped, failed, and a list of failed IDs
|
|
807
849
|
*/
|
|
808
850
|
async importPlugins(manifests, ownerId) {
|
|
809
|
-
|
|
851
|
+
log5(`Starting batch plugin import of ${manifests.length} manifests`);
|
|
810
852
|
if (ownerId) {
|
|
811
|
-
|
|
853
|
+
log5(`Using specified owner ID for import: ${ownerId}`);
|
|
812
854
|
}
|
|
813
855
|
const response = await this.request("/admin/plugins/import", {
|
|
814
856
|
body: JSON.stringify({
|
|
@@ -817,7 +859,7 @@ var PluginService = class extends BaseSDK {
|
|
|
817
859
|
}),
|
|
818
860
|
method: "POST"
|
|
819
861
|
});
|
|
820
|
-
|
|
862
|
+
log5(
|
|
821
863
|
`Plugin import completed: ${response.data.success} succeeded, ${response.data.skipped} skipped, ${response.data.failed} failed`
|
|
822
864
|
);
|
|
823
865
|
return response.data;
|
|
@@ -832,14 +874,14 @@ var PluginService = class extends BaseSDK {
|
|
|
832
874
|
* @returns Promise resolving to the import results with counts of success and failure
|
|
833
875
|
*/
|
|
834
876
|
async importPluginI18n(params) {
|
|
835
|
-
|
|
877
|
+
log5(
|
|
836
878
|
`Starting i18n import for plugin ${params.identifier} v${params.version} with ${params.localizations.length} localizations`
|
|
837
879
|
);
|
|
838
880
|
const response = await this.request("/admin/plugins/import/i18n", {
|
|
839
881
|
body: JSON.stringify(params),
|
|
840
882
|
method: "POST"
|
|
841
883
|
});
|
|
842
|
-
|
|
884
|
+
log5(
|
|
843
885
|
`Plugin i18n import completed: ${response.data.success} succeeded, ${response.data.failed} failed, ${response.data.totalLocalizations} total`
|
|
844
886
|
);
|
|
845
887
|
return response.data;
|
|
@@ -853,11 +895,11 @@ var PluginService = class extends BaseSDK {
|
|
|
853
895
|
* @returns Promise resolving to the plugin list response with admin details
|
|
854
896
|
*/
|
|
855
897
|
async getPlugins(params = {}) {
|
|
856
|
-
|
|
898
|
+
log5("Getting plugins with params: %O", params);
|
|
857
899
|
const queryString = this.buildQueryString(params);
|
|
858
900
|
const url = `/admin/plugins${queryString}`;
|
|
859
901
|
const result = await this.request(url);
|
|
860
|
-
|
|
902
|
+
log5("Retrieved %d plugins", result.data.length);
|
|
861
903
|
return result;
|
|
862
904
|
}
|
|
863
905
|
/**
|
|
@@ -870,9 +912,9 @@ var PluginService = class extends BaseSDK {
|
|
|
870
912
|
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
871
913
|
*/
|
|
872
914
|
async getPublishedIdentifiers() {
|
|
873
|
-
|
|
915
|
+
log5("Getting published plugin identifiers (admin)");
|
|
874
916
|
const result = await this.request("/v1/plugins/identifiers");
|
|
875
|
-
|
|
917
|
+
log5("Retrieved %d published plugin identifiers (admin)", result.length);
|
|
876
918
|
return result;
|
|
877
919
|
}
|
|
878
920
|
/**
|
|
@@ -882,9 +924,9 @@ var PluginService = class extends BaseSDK {
|
|
|
882
924
|
* @returns Promise resolving to the detailed plugin information with version history
|
|
883
925
|
*/
|
|
884
926
|
async getPlugin(id) {
|
|
885
|
-
|
|
927
|
+
log5("Getting plugin details (admin): %d", id);
|
|
886
928
|
const result = await this.request(`/admin/plugins/${id}`);
|
|
887
|
-
|
|
929
|
+
log5("Retrieved plugin with %d versions", result.versions.length);
|
|
888
930
|
return result;
|
|
889
931
|
}
|
|
890
932
|
/**
|
|
@@ -894,12 +936,12 @@ var PluginService = class extends BaseSDK {
|
|
|
894
936
|
* @returns Promise resolving to the detailed plugin information with version history
|
|
895
937
|
*/
|
|
896
938
|
async getPluginByGithubUrl(githubUrl) {
|
|
897
|
-
|
|
939
|
+
log5("Getting plugin by GitHub URL: %s", githubUrl);
|
|
898
940
|
const queryString = this.buildQueryString({ url: githubUrl });
|
|
899
941
|
const result = await this.request(
|
|
900
942
|
`/admin/plugins/by-github-url${queryString}`
|
|
901
943
|
);
|
|
902
|
-
|
|
944
|
+
log5("Retrieved plugin with %d versions", result.versions.length);
|
|
903
945
|
return result;
|
|
904
946
|
}
|
|
905
947
|
/**
|
|
@@ -910,12 +952,12 @@ var PluginService = class extends BaseSDK {
|
|
|
910
952
|
* @returns Promise resolving to the updated plugin
|
|
911
953
|
*/
|
|
912
954
|
async updatePlugin(id, data) {
|
|
913
|
-
|
|
955
|
+
log5("Updating plugin: %d, data: %O", id, data);
|
|
914
956
|
const result = await this.request(`/admin/plugins/${id}`, {
|
|
915
957
|
body: JSON.stringify(data),
|
|
916
958
|
method: "PUT"
|
|
917
959
|
});
|
|
918
|
-
|
|
960
|
+
log5("Plugin updated successfully");
|
|
919
961
|
return result;
|
|
920
962
|
}
|
|
921
963
|
/**
|
|
@@ -926,7 +968,7 @@ var PluginService = class extends BaseSDK {
|
|
|
926
968
|
* @returns Promise resolving to success response
|
|
927
969
|
*/
|
|
928
970
|
async updatePluginStatus(id, status) {
|
|
929
|
-
|
|
971
|
+
log5("Updating plugin status: %d to %s", id, status);
|
|
930
972
|
const result = await this.request(
|
|
931
973
|
`/admin/plugins/${id}/status`,
|
|
932
974
|
{
|
|
@@ -934,7 +976,7 @@ var PluginService = class extends BaseSDK {
|
|
|
934
976
|
method: "PATCH"
|
|
935
977
|
}
|
|
936
978
|
);
|
|
937
|
-
|
|
979
|
+
log5("Plugin status updated successfully");
|
|
938
980
|
return result;
|
|
939
981
|
}
|
|
940
982
|
/**
|
|
@@ -944,12 +986,12 @@ var PluginService = class extends BaseSDK {
|
|
|
944
986
|
* @returns Promise resolving to success response
|
|
945
987
|
*/
|
|
946
988
|
async deletePlugin(id) {
|
|
947
|
-
|
|
989
|
+
log5("Deleting plugin: %d", id);
|
|
948
990
|
const result = await this.request(
|
|
949
991
|
`/admin/plugins/${id}`,
|
|
950
992
|
{ method: "DELETE" }
|
|
951
993
|
);
|
|
952
|
-
|
|
994
|
+
log5("Plugin deleted successfully");
|
|
953
995
|
return result;
|
|
954
996
|
}
|
|
955
997
|
/**
|
|
@@ -959,9 +1001,9 @@ var PluginService = class extends BaseSDK {
|
|
|
959
1001
|
* @returns Promise resolving to an array of plugin versions
|
|
960
1002
|
*/
|
|
961
1003
|
async getPluginVersions(pluginId) {
|
|
962
|
-
|
|
1004
|
+
log5("Getting plugin versions: pluginId=%d", pluginId);
|
|
963
1005
|
const result = await this.request(`/admin/plugins/${pluginId}/versions`);
|
|
964
|
-
|
|
1006
|
+
log5("Retrieved %d versions", result.length);
|
|
965
1007
|
return result;
|
|
966
1008
|
}
|
|
967
1009
|
/**
|
|
@@ -972,11 +1014,11 @@ var PluginService = class extends BaseSDK {
|
|
|
972
1014
|
* @returns Promise resolving to the plugin version details
|
|
973
1015
|
*/
|
|
974
1016
|
async getPluginVersion(pluginId, versionId) {
|
|
975
|
-
|
|
1017
|
+
log5("Getting version details: pluginId=%d, versionId=%d", pluginId, versionId);
|
|
976
1018
|
const result = await this.request(
|
|
977
1019
|
`/admin/plugins/${pluginId}/versions/${versionId}`
|
|
978
1020
|
);
|
|
979
|
-
|
|
1021
|
+
log5("Version details retrieved");
|
|
980
1022
|
return result;
|
|
981
1023
|
}
|
|
982
1024
|
/**
|
|
@@ -987,11 +1029,11 @@ var PluginService = class extends BaseSDK {
|
|
|
987
1029
|
* @returns Promise resolving to an array of plugin version localizations
|
|
988
1030
|
*/
|
|
989
1031
|
async getPluginLocalizations(pluginId, versionId) {
|
|
990
|
-
|
|
1032
|
+
log5("Getting localizations: pluginId=%s, versionId=%d", pluginId, versionId);
|
|
991
1033
|
const result = await this.request(
|
|
992
1034
|
`/admin/plugins/${pluginId}/versions/${versionId}/localizations`
|
|
993
1035
|
);
|
|
994
|
-
|
|
1036
|
+
log5("Retrieved %d localizations for plugin %s, version %d", result.length, pluginId, versionId);
|
|
995
1037
|
return result;
|
|
996
1038
|
}
|
|
997
1039
|
/**
|
|
@@ -1002,12 +1044,12 @@ var PluginService = class extends BaseSDK {
|
|
|
1002
1044
|
* @returns Promise resolving to the created plugin version
|
|
1003
1045
|
*/
|
|
1004
1046
|
async createPluginVersion(pluginId, data) {
|
|
1005
|
-
|
|
1047
|
+
log5("Creating new plugin version: pluginId=%d, data: %O", pluginId, data);
|
|
1006
1048
|
const result = await this.request(`/admin/plugins/${pluginId}/versions`, {
|
|
1007
1049
|
body: JSON.stringify(data),
|
|
1008
1050
|
method: "POST"
|
|
1009
1051
|
});
|
|
1010
|
-
|
|
1052
|
+
log5("Plugin version created successfully: version=%s", data.version);
|
|
1011
1053
|
return result;
|
|
1012
1054
|
}
|
|
1013
1055
|
/**
|
|
@@ -1021,7 +1063,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1021
1063
|
*/
|
|
1022
1064
|
async createPluginVersionFromManifest(pluginId, manifest, options = {}) {
|
|
1023
1065
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1024
|
-
|
|
1066
|
+
log5(
|
|
1025
1067
|
"Creating plugin version from manifest: pluginId=%d, version=%s",
|
|
1026
1068
|
pluginId,
|
|
1027
1069
|
manifest.version
|
|
@@ -1057,7 +1099,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1057
1099
|
* @returns Promise resolving to the updated plugin version
|
|
1058
1100
|
*/
|
|
1059
1101
|
async updatePluginVersion(idOrIdentifier, versionId, data) {
|
|
1060
|
-
|
|
1102
|
+
log5(
|
|
1061
1103
|
"Updating plugin version: pluginId=%d, versionId=%d, data: %O",
|
|
1062
1104
|
idOrIdentifier,
|
|
1063
1105
|
versionId,
|
|
@@ -1070,7 +1112,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1070
1112
|
method: "PUT"
|
|
1071
1113
|
}
|
|
1072
1114
|
);
|
|
1073
|
-
|
|
1115
|
+
log5("Plugin version updated successfully");
|
|
1074
1116
|
return result;
|
|
1075
1117
|
}
|
|
1076
1118
|
/**
|
|
@@ -1081,12 +1123,12 @@ var PluginService = class extends BaseSDK {
|
|
|
1081
1123
|
* @returns Promise resolving to success response
|
|
1082
1124
|
*/
|
|
1083
1125
|
async deletePluginVersion(pluginId, versionId) {
|
|
1084
|
-
|
|
1126
|
+
log5("Deleting version: pluginId=%d, versionId=%d", pluginId, versionId);
|
|
1085
1127
|
const result = await this.request(
|
|
1086
1128
|
`/admin/plugins/${pluginId}/versions/${versionId}`,
|
|
1087
1129
|
{ method: "DELETE" }
|
|
1088
1130
|
);
|
|
1089
|
-
|
|
1131
|
+
log5("Plugin version deleted successfully");
|
|
1090
1132
|
return result;
|
|
1091
1133
|
}
|
|
1092
1134
|
/**
|
|
@@ -1097,12 +1139,12 @@ var PluginService = class extends BaseSDK {
|
|
|
1097
1139
|
* @returns Promise resolving to success response
|
|
1098
1140
|
*/
|
|
1099
1141
|
async setPluginVersionAsLatest(pluginId, versionId) {
|
|
1100
|
-
|
|
1142
|
+
log5("Setting version as latest: pluginId=%d, versionId=%d", pluginId, versionId);
|
|
1101
1143
|
const result = await this.request(
|
|
1102
1144
|
`/admin/plugins/${pluginId}/versions/${versionId}/latest`,
|
|
1103
1145
|
{ method: "POST" }
|
|
1104
1146
|
);
|
|
1105
|
-
|
|
1147
|
+
log5("Version set as latest successfully");
|
|
1106
1148
|
return result;
|
|
1107
1149
|
}
|
|
1108
1150
|
/**
|
|
@@ -1113,7 +1155,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1113
1155
|
* @returns Promise resolving to success response
|
|
1114
1156
|
*/
|
|
1115
1157
|
async updatePluginVisibility(id, visibility) {
|
|
1116
|
-
|
|
1158
|
+
log5("Updating plugin visibility: %d to %s", id, visibility);
|
|
1117
1159
|
const result = await this.request(
|
|
1118
1160
|
`/admin/plugins/${id}/visibility`,
|
|
1119
1161
|
{
|
|
@@ -1121,7 +1163,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1121
1163
|
method: "PATCH"
|
|
1122
1164
|
}
|
|
1123
1165
|
);
|
|
1124
|
-
|
|
1166
|
+
log5("Plugin visibility updated successfully");
|
|
1125
1167
|
return result;
|
|
1126
1168
|
}
|
|
1127
1169
|
/**
|
|
@@ -1132,7 +1174,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1132
1174
|
* @returns Promise resolving to success response
|
|
1133
1175
|
*/
|
|
1134
1176
|
async batchUpdatePluginStatus(ids, status) {
|
|
1135
|
-
|
|
1177
|
+
log5("Batch updating plugin status: %O to %s", ids, status);
|
|
1136
1178
|
const result = await this.request(
|
|
1137
1179
|
"/admin/plugins/batch/status",
|
|
1138
1180
|
{
|
|
@@ -1140,7 +1182,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1140
1182
|
method: "PATCH"
|
|
1141
1183
|
}
|
|
1142
1184
|
);
|
|
1143
|
-
|
|
1185
|
+
log5("Batch plugin status update completed");
|
|
1144
1186
|
return result;
|
|
1145
1187
|
}
|
|
1146
1188
|
/**
|
|
@@ -1150,7 +1192,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1150
1192
|
* @returns Promise resolving to success response
|
|
1151
1193
|
*/
|
|
1152
1194
|
async batchDeletePlugins(ids) {
|
|
1153
|
-
|
|
1195
|
+
log5("Batch deleting plugins: %O", ids);
|
|
1154
1196
|
const result = await this.request(
|
|
1155
1197
|
"/admin/plugins/batch/delete",
|
|
1156
1198
|
{
|
|
@@ -1158,7 +1200,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1158
1200
|
method: "DELETE"
|
|
1159
1201
|
}
|
|
1160
1202
|
);
|
|
1161
|
-
|
|
1203
|
+
log5("Batch plugin deletion completed");
|
|
1162
1204
|
return result;
|
|
1163
1205
|
}
|
|
1164
1206
|
/**
|
|
@@ -1169,7 +1211,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1169
1211
|
* @returns Promise resolving to version details with deployment options
|
|
1170
1212
|
*/
|
|
1171
1213
|
async getPluginVersionDetails(pluginId, versionId) {
|
|
1172
|
-
|
|
1214
|
+
log5(
|
|
1173
1215
|
"Getting version details with deployment options: pluginId=%d, versionId=%d",
|
|
1174
1216
|
pluginId,
|
|
1175
1217
|
versionId
|
|
@@ -1177,7 +1219,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1177
1219
|
const result = await this.request(
|
|
1178
1220
|
`/admin/plugins/${pluginId}/versions/${versionId}`
|
|
1179
1221
|
);
|
|
1180
|
-
|
|
1222
|
+
log5("Version details with deployment options retrieved");
|
|
1181
1223
|
return result;
|
|
1182
1224
|
}
|
|
1183
1225
|
/**
|
|
@@ -1188,11 +1230,11 @@ var PluginService = class extends BaseSDK {
|
|
|
1188
1230
|
* @returns Promise resolving to an array of deployment options
|
|
1189
1231
|
*/
|
|
1190
1232
|
async getDeploymentOptions(pluginId, versionId) {
|
|
1191
|
-
|
|
1233
|
+
log5("Getting deployment options: pluginId=%d, versionId=%d", pluginId, versionId);
|
|
1192
1234
|
const result = await this.request(
|
|
1193
1235
|
`/admin/plugins/${pluginId}/versions/${versionId}/deployment-options`
|
|
1194
1236
|
);
|
|
1195
|
-
|
|
1237
|
+
log5("Retrieved %d deployment options", result.length);
|
|
1196
1238
|
return result;
|
|
1197
1239
|
}
|
|
1198
1240
|
/**
|
|
@@ -1204,7 +1246,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1204
1246
|
* @returns Promise resolving to the created deployment option
|
|
1205
1247
|
*/
|
|
1206
1248
|
async createDeploymentOption(pluginId, versionId, data) {
|
|
1207
|
-
|
|
1249
|
+
log5("Creating deployment option: pluginId=%d, versionId=%d", pluginId, versionId);
|
|
1208
1250
|
const result = await this.request(
|
|
1209
1251
|
`/admin/plugins/${pluginId}/versions/${versionId}/deployment-options`,
|
|
1210
1252
|
{
|
|
@@ -1212,7 +1254,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1212
1254
|
method: "POST"
|
|
1213
1255
|
}
|
|
1214
1256
|
);
|
|
1215
|
-
|
|
1257
|
+
log5("Deployment option created successfully");
|
|
1216
1258
|
return result;
|
|
1217
1259
|
}
|
|
1218
1260
|
/**
|
|
@@ -1225,7 +1267,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1225
1267
|
* @returns Promise resolving to the updated deployment option
|
|
1226
1268
|
*/
|
|
1227
1269
|
async updateDeploymentOption(pluginId, versionId, optionId, data) {
|
|
1228
|
-
|
|
1270
|
+
log5(
|
|
1229
1271
|
"Updating deployment option: pluginId=%d, versionId=%d, optionId=%d",
|
|
1230
1272
|
pluginId,
|
|
1231
1273
|
versionId,
|
|
@@ -1238,7 +1280,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1238
1280
|
method: "PUT"
|
|
1239
1281
|
}
|
|
1240
1282
|
);
|
|
1241
|
-
|
|
1283
|
+
log5("Deployment option updated successfully");
|
|
1242
1284
|
return result;
|
|
1243
1285
|
}
|
|
1244
1286
|
/**
|
|
@@ -1250,7 +1292,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1250
1292
|
* @returns Promise resolving to success response
|
|
1251
1293
|
*/
|
|
1252
1294
|
async deleteDeploymentOption(pluginId, versionId, optionId) {
|
|
1253
|
-
|
|
1295
|
+
log5(
|
|
1254
1296
|
"Deleting deployment option: pluginId=%d, versionId=%d, optionId=%d",
|
|
1255
1297
|
pluginId,
|
|
1256
1298
|
versionId,
|
|
@@ -1260,7 +1302,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1260
1302
|
`/admin/plugins/${pluginId}/versions/${versionId}/deployment-options/${optionId}`,
|
|
1261
1303
|
{ method: "DELETE" }
|
|
1262
1304
|
);
|
|
1263
|
-
|
|
1305
|
+
log5("Deployment option deleted successfully");
|
|
1264
1306
|
return result;
|
|
1265
1307
|
}
|
|
1266
1308
|
/**
|
|
@@ -1272,7 +1314,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1272
1314
|
* @returns Promise resolving to an array of system dependencies
|
|
1273
1315
|
*/
|
|
1274
1316
|
async getDeploymentOptionSystemDependencies(pluginId, versionId, optionId) {
|
|
1275
|
-
|
|
1317
|
+
log5(
|
|
1276
1318
|
"Getting system dependencies: pluginId=%d, versionId=%d, optionId=%d",
|
|
1277
1319
|
pluginId,
|
|
1278
1320
|
versionId,
|
|
@@ -1281,7 +1323,7 @@ var PluginService = class extends BaseSDK {
|
|
|
1281
1323
|
const result = await this.request(
|
|
1282
1324
|
`/admin/plugins/${pluginId}/versions/${versionId}/deployment-options/${optionId}/system-dependencies`
|
|
1283
1325
|
);
|
|
1284
|
-
|
|
1326
|
+
log5("Retrieved %d system dependencies", result.length);
|
|
1285
1327
|
return result;
|
|
1286
1328
|
}
|
|
1287
1329
|
/**
|
|
@@ -1292,9 +1334,9 @@ var PluginService = class extends BaseSDK {
|
|
|
1292
1334
|
* @returns Promise resolving to array of plugins with incomplete summary data
|
|
1293
1335
|
*/
|
|
1294
1336
|
async getVerifiedPluginsWithoutSummary() {
|
|
1295
|
-
|
|
1337
|
+
log5("Getting verified plugins without summary");
|
|
1296
1338
|
const result = await this.request("/admin/plugins/verified-without-summary");
|
|
1297
|
-
|
|
1339
|
+
log5("Retrieved %d verified plugins without summary", result.length);
|
|
1298
1340
|
return result;
|
|
1299
1341
|
}
|
|
1300
1342
|
/**
|
|
@@ -1305,9 +1347,9 @@ var PluginService = class extends BaseSDK {
|
|
|
1305
1347
|
* @returns Promise resolving to an array of plugins with incomplete i18n
|
|
1306
1348
|
*/
|
|
1307
1349
|
async getIncompleteI18nPlugins() {
|
|
1308
|
-
|
|
1350
|
+
log5("Getting plugins with incomplete i18n");
|
|
1309
1351
|
const result = await this.request("/admin/plugins/incomplete-i18n");
|
|
1310
|
-
|
|
1352
|
+
log5("Retrieved %d plugins with incomplete i18n", result.length);
|
|
1311
1353
|
return result;
|
|
1312
1354
|
}
|
|
1313
1355
|
/**
|
|
@@ -1318,16 +1360,16 @@ var PluginService = class extends BaseSDK {
|
|
|
1318
1360
|
* @returns Promise resolving to an array of unclaimed plugins with basic info
|
|
1319
1361
|
*/
|
|
1320
1362
|
async getUnclaimedPlugins() {
|
|
1321
|
-
|
|
1363
|
+
log5("Getting unclaimed plugins");
|
|
1322
1364
|
const result = await this.request("/admin/plugins/unclaimed");
|
|
1323
|
-
|
|
1365
|
+
log5("Retrieved %d unclaimed plugins", result.length);
|
|
1324
1366
|
return result;
|
|
1325
1367
|
}
|
|
1326
1368
|
};
|
|
1327
1369
|
|
|
1328
1370
|
// src/admin/services/SystemDependencyService.ts
|
|
1329
|
-
import
|
|
1330
|
-
var
|
|
1371
|
+
import debug6 from "debug";
|
|
1372
|
+
var log6 = debug6("lobe-market-sdk:admin:dependency");
|
|
1331
1373
|
var SystemDependencyService = class extends BaseSDK {
|
|
1332
1374
|
/**
|
|
1333
1375
|
* Retrieves all system dependencies
|
|
@@ -1337,9 +1379,9 @@ var SystemDependencyService = class extends BaseSDK {
|
|
|
1337
1379
|
* @returns Promise resolving to an array of system dependencies
|
|
1338
1380
|
*/
|
|
1339
1381
|
async getSystemDependencies() {
|
|
1340
|
-
|
|
1382
|
+
log6("Getting all system dependencies");
|
|
1341
1383
|
const result = await this.request(`/admin/plugins/dependencies`);
|
|
1342
|
-
|
|
1384
|
+
log6("Retrieved %d system dependencies", result.length);
|
|
1343
1385
|
return result;
|
|
1344
1386
|
}
|
|
1345
1387
|
/**
|
|
@@ -1349,9 +1391,9 @@ var SystemDependencyService = class extends BaseSDK {
|
|
|
1349
1391
|
* @returns Promise resolving to the system dependency details
|
|
1350
1392
|
*/
|
|
1351
1393
|
async getSystemDependency(id) {
|
|
1352
|
-
|
|
1394
|
+
log6("Getting system dependency details: %d", id);
|
|
1353
1395
|
const result = await this.request(`/admin/plugins/dependencies/${id}`);
|
|
1354
|
-
|
|
1396
|
+
log6("System dependency details retrieved");
|
|
1355
1397
|
return result;
|
|
1356
1398
|
}
|
|
1357
1399
|
/**
|
|
@@ -1361,12 +1403,12 @@ var SystemDependencyService = class extends BaseSDK {
|
|
|
1361
1403
|
* @returns Promise resolving to the created system dependency
|
|
1362
1404
|
*/
|
|
1363
1405
|
async createSystemDependency(data) {
|
|
1364
|
-
|
|
1406
|
+
log6("Creating system dependency: %O", data);
|
|
1365
1407
|
const result = await this.request(`/admin/plugins/dependencies`, {
|
|
1366
1408
|
body: JSON.stringify(data),
|
|
1367
1409
|
method: "POST"
|
|
1368
1410
|
});
|
|
1369
|
-
|
|
1411
|
+
log6("System dependency created successfully");
|
|
1370
1412
|
return result;
|
|
1371
1413
|
}
|
|
1372
1414
|
/**
|
|
@@ -1377,12 +1419,12 @@ var SystemDependencyService = class extends BaseSDK {
|
|
|
1377
1419
|
* @returns Promise resolving to the updated system dependency
|
|
1378
1420
|
*/
|
|
1379
1421
|
async updateSystemDependency(id, data) {
|
|
1380
|
-
|
|
1422
|
+
log6("Updating system dependency: %d, data: %O", id, data);
|
|
1381
1423
|
const result = await this.request(`/admin/plugins/dependencies/${id}`, {
|
|
1382
1424
|
body: JSON.stringify(data),
|
|
1383
1425
|
method: "PUT"
|
|
1384
1426
|
});
|
|
1385
|
-
|
|
1427
|
+
log6("System dependency updated successfully");
|
|
1386
1428
|
return result;
|
|
1387
1429
|
}
|
|
1388
1430
|
/**
|
|
@@ -1392,19 +1434,19 @@ var SystemDependencyService = class extends BaseSDK {
|
|
|
1392
1434
|
* @returns Promise resolving to success response
|
|
1393
1435
|
*/
|
|
1394
1436
|
async deleteSystemDependency(id) {
|
|
1395
|
-
|
|
1437
|
+
log6("Deleting system dependency: %d", id);
|
|
1396
1438
|
const result = await this.request(
|
|
1397
1439
|
`/admin/plugins/dependencies/${id}`,
|
|
1398
1440
|
{ method: "DELETE" }
|
|
1399
1441
|
);
|
|
1400
|
-
|
|
1442
|
+
log6("System dependency deleted successfully");
|
|
1401
1443
|
return result;
|
|
1402
1444
|
}
|
|
1403
1445
|
};
|
|
1404
1446
|
|
|
1405
1447
|
// src/admin/services/SettingsService.ts
|
|
1406
|
-
import
|
|
1407
|
-
var
|
|
1448
|
+
import debug7 from "debug";
|
|
1449
|
+
var log7 = debug7("lobe-market-sdk:admin:settings");
|
|
1408
1450
|
var SettingsService = class extends BaseSDK {
|
|
1409
1451
|
/**
|
|
1410
1452
|
* Retrieves all system settings
|
|
@@ -1424,9 +1466,9 @@ var SettingsService = class extends BaseSDK {
|
|
|
1424
1466
|
* @returns Promise resolving to the setting details
|
|
1425
1467
|
*/
|
|
1426
1468
|
async getSettingByKey(key) {
|
|
1427
|
-
|
|
1469
|
+
log7("Getting setting: %s", key);
|
|
1428
1470
|
const result = await this.request(`/admin/settings/${key}`);
|
|
1429
|
-
|
|
1471
|
+
log7("Setting retrieved");
|
|
1430
1472
|
return result;
|
|
1431
1473
|
}
|
|
1432
1474
|
/**
|
|
@@ -1436,12 +1478,12 @@ var SettingsService = class extends BaseSDK {
|
|
|
1436
1478
|
* @returns Promise resolving to the created setting
|
|
1437
1479
|
*/
|
|
1438
1480
|
async createSetting(data) {
|
|
1439
|
-
|
|
1481
|
+
log7("Creating setting: %O", data);
|
|
1440
1482
|
const result = await this.request("/admin/settings", {
|
|
1441
1483
|
body: JSON.stringify(data),
|
|
1442
1484
|
method: "POST"
|
|
1443
1485
|
});
|
|
1444
|
-
|
|
1486
|
+
log7("Setting created successfully");
|
|
1445
1487
|
return result;
|
|
1446
1488
|
}
|
|
1447
1489
|
/**
|
|
@@ -1452,12 +1494,12 @@ var SettingsService = class extends BaseSDK {
|
|
|
1452
1494
|
* @returns Promise resolving to the updated setting
|
|
1453
1495
|
*/
|
|
1454
1496
|
async updateSetting(key, data) {
|
|
1455
|
-
|
|
1497
|
+
log7("Updating setting: %s, data: %O", key, data);
|
|
1456
1498
|
const result = await this.request(`/admin/settings/${key}`, {
|
|
1457
1499
|
body: JSON.stringify(data),
|
|
1458
1500
|
method: "PUT"
|
|
1459
1501
|
});
|
|
1460
|
-
|
|
1502
|
+
log7("Setting updated successfully");
|
|
1461
1503
|
return result;
|
|
1462
1504
|
}
|
|
1463
1505
|
/**
|
|
@@ -1467,18 +1509,18 @@ var SettingsService = class extends BaseSDK {
|
|
|
1467
1509
|
* @returns Promise resolving to success message
|
|
1468
1510
|
*/
|
|
1469
1511
|
async deleteSetting(key) {
|
|
1470
|
-
|
|
1512
|
+
log7("Deleting setting: %s", key);
|
|
1471
1513
|
const result = await this.request(`/admin/settings/${key}`, {
|
|
1472
1514
|
method: "DELETE"
|
|
1473
1515
|
});
|
|
1474
|
-
|
|
1516
|
+
log7("Setting deleted successfully");
|
|
1475
1517
|
return result;
|
|
1476
1518
|
}
|
|
1477
1519
|
};
|
|
1478
1520
|
|
|
1479
1521
|
// src/admin/services/ReviewService.ts
|
|
1480
|
-
import
|
|
1481
|
-
var
|
|
1522
|
+
import debug8 from "debug";
|
|
1523
|
+
var log8 = debug8("lobe-market-sdk:admin:review");
|
|
1482
1524
|
var ReviewService = class extends BaseSDK {
|
|
1483
1525
|
/**
|
|
1484
1526
|
* Retrieves a list of reviews with filtering options
|
|
@@ -1487,11 +1529,11 @@ var ReviewService = class extends BaseSDK {
|
|
|
1487
1529
|
* @returns Promise resolving to the review list response
|
|
1488
1530
|
*/
|
|
1489
1531
|
async getReviews(params = {}) {
|
|
1490
|
-
|
|
1532
|
+
log8("Getting reviews with params: %O", params);
|
|
1491
1533
|
const queryString = this.buildQueryString(params);
|
|
1492
1534
|
const url = `/admin/reviews${queryString ? `?${queryString}` : ""}`;
|
|
1493
1535
|
const result = await this.request(url);
|
|
1494
|
-
|
|
1536
|
+
log8("Retrieved %d reviews", result.data.length);
|
|
1495
1537
|
return result;
|
|
1496
1538
|
}
|
|
1497
1539
|
/**
|
|
@@ -1501,9 +1543,9 @@ var ReviewService = class extends BaseSDK {
|
|
|
1501
1543
|
* @returns Promise resolving to the review details
|
|
1502
1544
|
*/
|
|
1503
1545
|
async getReviewById(id) {
|
|
1504
|
-
|
|
1546
|
+
log8("Getting review details: %d", id);
|
|
1505
1547
|
const result = await this.request(`/admin/reviews/${id}`);
|
|
1506
|
-
|
|
1548
|
+
log8("Review details retrieved");
|
|
1507
1549
|
return result;
|
|
1508
1550
|
}
|
|
1509
1551
|
/**
|
|
@@ -1514,12 +1556,12 @@ var ReviewService = class extends BaseSDK {
|
|
|
1514
1556
|
* @returns Promise resolving to the updated review
|
|
1515
1557
|
*/
|
|
1516
1558
|
async updateReview(id, data) {
|
|
1517
|
-
|
|
1559
|
+
log8("Updating review: %d, data: %O", id, data);
|
|
1518
1560
|
const result = await this.request(`/admin/reviews/${id}`, {
|
|
1519
1561
|
body: JSON.stringify(data),
|
|
1520
1562
|
method: "PUT"
|
|
1521
1563
|
});
|
|
1522
|
-
|
|
1564
|
+
log8("Review updated successfully");
|
|
1523
1565
|
return result;
|
|
1524
1566
|
}
|
|
1525
1567
|
/**
|
|
@@ -1529,52 +1571,52 @@ var ReviewService = class extends BaseSDK {
|
|
|
1529
1571
|
* @returns Promise resolving to an array of reviews for the plugin
|
|
1530
1572
|
*/
|
|
1531
1573
|
async getPluginReviews(pluginId) {
|
|
1532
|
-
|
|
1574
|
+
log8("Getting plugin reviews: pluginId=%d", pluginId);
|
|
1533
1575
|
const result = await this.request(`/admin/reviews/plugin/${pluginId}`);
|
|
1534
|
-
|
|
1576
|
+
log8("Retrieved %d reviews for plugin", result.data.length);
|
|
1535
1577
|
return result;
|
|
1536
1578
|
}
|
|
1537
1579
|
};
|
|
1538
1580
|
|
|
1539
1581
|
// src/admin/services/SkillCollectionService.ts
|
|
1540
|
-
import
|
|
1541
|
-
var
|
|
1582
|
+
import debug9 from "debug";
|
|
1583
|
+
var log9 = debug9("lobe-market-sdk:admin:skill-collections");
|
|
1542
1584
|
var SkillCollectionService = class extends BaseSDK {
|
|
1543
1585
|
async createCollection(data) {
|
|
1544
|
-
|
|
1586
|
+
log9("Creating skill collection: %O", data);
|
|
1545
1587
|
const result = await this.request("/admin/skills/collections", {
|
|
1546
1588
|
body: JSON.stringify(data),
|
|
1547
1589
|
method: "POST"
|
|
1548
1590
|
});
|
|
1549
|
-
|
|
1591
|
+
log9("Created skill collection %d (%s)", result.id, result.slug);
|
|
1550
1592
|
return result;
|
|
1551
1593
|
}
|
|
1552
1594
|
async deleteCollection(id) {
|
|
1553
|
-
|
|
1595
|
+
log9("Deleting skill collection: %d", id);
|
|
1554
1596
|
await this.request(`/admin/skills/collections/${id}`, {
|
|
1555
1597
|
method: "DELETE"
|
|
1556
1598
|
});
|
|
1557
|
-
|
|
1599
|
+
log9("Deleted skill collection: %d", id);
|
|
1558
1600
|
}
|
|
1559
1601
|
async getCollection(id) {
|
|
1560
|
-
|
|
1602
|
+
log9("Getting skill collection: %d", id);
|
|
1561
1603
|
const result = await this.request(
|
|
1562
1604
|
`/admin/skills/collections/${id}`
|
|
1563
1605
|
);
|
|
1564
|
-
|
|
1606
|
+
log9("Retrieved skill collection %d (%s)", result.id, result.slug);
|
|
1565
1607
|
return result;
|
|
1566
1608
|
}
|
|
1567
1609
|
async getCollections(params = {}) {
|
|
1568
|
-
|
|
1610
|
+
log9("Getting skill collections: %O", params);
|
|
1569
1611
|
const queryString = this.buildQueryString(params);
|
|
1570
1612
|
const result = await this.request(
|
|
1571
1613
|
`/admin/skills/collections${queryString}`
|
|
1572
1614
|
);
|
|
1573
|
-
|
|
1615
|
+
log9("Retrieved %d skill collections", result.items.length);
|
|
1574
1616
|
return result;
|
|
1575
1617
|
}
|
|
1576
1618
|
async batchUpsertLocalizations(collectionId, data) {
|
|
1577
|
-
|
|
1619
|
+
log9("Batch upserting localizations for collection %d: %O", collectionId, data);
|
|
1578
1620
|
const result = await this.request(
|
|
1579
1621
|
`/admin/skills/collections/${collectionId}/localizations/batch`,
|
|
1580
1622
|
{
|
|
@@ -1582,38 +1624,38 @@ var SkillCollectionService = class extends BaseSDK {
|
|
|
1582
1624
|
method: "POST"
|
|
1583
1625
|
}
|
|
1584
1626
|
);
|
|
1585
|
-
|
|
1627
|
+
log9("Processed %d localizations for collection %d", result.results.length, collectionId);
|
|
1586
1628
|
return result;
|
|
1587
1629
|
}
|
|
1588
1630
|
async deleteLocalization(collectionId, locale) {
|
|
1589
|
-
|
|
1631
|
+
log9("Deleting localization for collection %d: %s", collectionId, locale);
|
|
1590
1632
|
const result = await this.request(
|
|
1591
1633
|
`/admin/skills/collections/${collectionId}/localizations/${encodeURIComponent(locale)}`,
|
|
1592
1634
|
{
|
|
1593
1635
|
method: "DELETE"
|
|
1594
1636
|
}
|
|
1595
1637
|
);
|
|
1596
|
-
|
|
1638
|
+
log9("Deleted localization for collection %d: %s", collectionId, locale);
|
|
1597
1639
|
return result;
|
|
1598
1640
|
}
|
|
1599
1641
|
async getLocalization(collectionId, locale) {
|
|
1600
|
-
|
|
1642
|
+
log9("Getting localization for collection %d: %s", collectionId, locale);
|
|
1601
1643
|
const result = await this.request(
|
|
1602
1644
|
`/admin/skills/collections/${collectionId}/localizations/${encodeURIComponent(locale)}`
|
|
1603
1645
|
);
|
|
1604
|
-
|
|
1646
|
+
log9("Retrieved localization %s for collection %d", locale, collectionId);
|
|
1605
1647
|
return result;
|
|
1606
1648
|
}
|
|
1607
1649
|
async getLocalizations(collectionId) {
|
|
1608
|
-
|
|
1650
|
+
log9("Getting localizations for collection %d", collectionId);
|
|
1609
1651
|
const result = await this.request(
|
|
1610
1652
|
`/admin/skills/collections/${collectionId}/localizations`
|
|
1611
1653
|
);
|
|
1612
|
-
|
|
1654
|
+
log9("Retrieved %d localizations for collection %d", result.length, collectionId);
|
|
1613
1655
|
return result;
|
|
1614
1656
|
}
|
|
1615
1657
|
async updateCollection(id, data) {
|
|
1616
|
-
|
|
1658
|
+
log9("Updating skill collection %d: %O", id, data);
|
|
1617
1659
|
const result = await this.request(
|
|
1618
1660
|
`/admin/skills/collections/${id}`,
|
|
1619
1661
|
{
|
|
@@ -1621,11 +1663,11 @@ var SkillCollectionService = class extends BaseSDK {
|
|
|
1621
1663
|
method: "PUT"
|
|
1622
1664
|
}
|
|
1623
1665
|
);
|
|
1624
|
-
|
|
1666
|
+
log9("Updated skill collection %d (%s)", result.id, result.slug);
|
|
1625
1667
|
return result;
|
|
1626
1668
|
}
|
|
1627
1669
|
async upsertLocalization(collectionId, locale, data) {
|
|
1628
|
-
|
|
1670
|
+
log9("Upserting localization for collection %d: %s %O", collectionId, locale, data);
|
|
1629
1671
|
const result = await this.request(
|
|
1630
1672
|
`/admin/skills/collections/${collectionId}/localizations/${encodeURIComponent(locale)}`,
|
|
1631
1673
|
{
|
|
@@ -1633,14 +1675,14 @@ var SkillCollectionService = class extends BaseSDK {
|
|
|
1633
1675
|
method: "PUT"
|
|
1634
1676
|
}
|
|
1635
1677
|
);
|
|
1636
|
-
|
|
1678
|
+
log9("Upserted localization for collection %d: %s", collectionId, locale);
|
|
1637
1679
|
return result;
|
|
1638
1680
|
}
|
|
1639
1681
|
};
|
|
1640
1682
|
|
|
1641
1683
|
// src/admin/services/PluginEnvService.ts
|
|
1642
|
-
import
|
|
1643
|
-
var
|
|
1684
|
+
import debug10 from "debug";
|
|
1685
|
+
var log10 = debug10("lobe-market-sdk:admin:plugin-env");
|
|
1644
1686
|
var PluginEnvService = class extends BaseSDK {
|
|
1645
1687
|
/**
|
|
1646
1688
|
* Retrieves a paginated list of plugin environment variables
|
|
@@ -1649,11 +1691,11 @@ var PluginEnvService = class extends BaseSDK {
|
|
|
1649
1691
|
* @returns Promise resolving to the env list response
|
|
1650
1692
|
*/
|
|
1651
1693
|
async getPluginEnvs(params = {}) {
|
|
1652
|
-
|
|
1694
|
+
log10("Getting plugin envs with params: %O", params);
|
|
1653
1695
|
const queryString = this.buildQueryString(params);
|
|
1654
1696
|
const url = `/admin/plugins/env${queryString}`;
|
|
1655
1697
|
const result = await this.request(url);
|
|
1656
|
-
|
|
1698
|
+
log10("Retrieved %d plugin envs", result.data.length);
|
|
1657
1699
|
return result;
|
|
1658
1700
|
}
|
|
1659
1701
|
/**
|
|
@@ -1663,9 +1705,9 @@ var PluginEnvService = class extends BaseSDK {
|
|
|
1663
1705
|
* @returns Promise resolving to the env item
|
|
1664
1706
|
*/
|
|
1665
1707
|
async getPluginEnv(id) {
|
|
1666
|
-
|
|
1708
|
+
log10("Getting plugin env: %d", id);
|
|
1667
1709
|
const result = await this.request(`/admin/plugins/env/${id}`);
|
|
1668
|
-
|
|
1710
|
+
log10("Retrieved plugin env: %d", id);
|
|
1669
1711
|
return result;
|
|
1670
1712
|
}
|
|
1671
1713
|
/**
|
|
@@ -1675,12 +1717,12 @@ var PluginEnvService = class extends BaseSDK {
|
|
|
1675
1717
|
* @returns Promise resolving to the created env item
|
|
1676
1718
|
*/
|
|
1677
1719
|
async createPluginEnv(data) {
|
|
1678
|
-
|
|
1720
|
+
log10("Creating plugin env: %O", data);
|
|
1679
1721
|
const result = await this.request(`/admin/plugins/env`, {
|
|
1680
1722
|
body: JSON.stringify(data),
|
|
1681
1723
|
method: "POST"
|
|
1682
1724
|
});
|
|
1683
|
-
|
|
1725
|
+
log10("Plugin env created successfully");
|
|
1684
1726
|
return result;
|
|
1685
1727
|
}
|
|
1686
1728
|
/**
|
|
@@ -1691,12 +1733,12 @@ var PluginEnvService = class extends BaseSDK {
|
|
|
1691
1733
|
* @returns Promise resolving to the updated env item
|
|
1692
1734
|
*/
|
|
1693
1735
|
async updatePluginEnv(id, data) {
|
|
1694
|
-
|
|
1736
|
+
log10("Updating plugin env: %d, data: %O", id, data);
|
|
1695
1737
|
const result = await this.request(`/admin/plugins/env/${id}`, {
|
|
1696
1738
|
body: JSON.stringify(data),
|
|
1697
1739
|
method: "PUT"
|
|
1698
1740
|
});
|
|
1699
|
-
|
|
1741
|
+
log10("Plugin env updated successfully");
|
|
1700
1742
|
return result;
|
|
1701
1743
|
}
|
|
1702
1744
|
/**
|
|
@@ -1706,11 +1748,11 @@ var PluginEnvService = class extends BaseSDK {
|
|
|
1706
1748
|
* @returns Promise resolving to success response
|
|
1707
1749
|
*/
|
|
1708
1750
|
async deletePluginEnv(id) {
|
|
1709
|
-
|
|
1751
|
+
log10("Deleting plugin env: %d", id);
|
|
1710
1752
|
const result = await this.request(`/admin/plugins/env/${id}`, {
|
|
1711
1753
|
method: "DELETE"
|
|
1712
1754
|
});
|
|
1713
|
-
|
|
1755
|
+
log10("Plugin env deleted successfully");
|
|
1714
1756
|
return result;
|
|
1715
1757
|
}
|
|
1716
1758
|
/**
|
|
@@ -1720,19 +1762,19 @@ var PluginEnvService = class extends BaseSDK {
|
|
|
1720
1762
|
* @returns Promise resolving to import result
|
|
1721
1763
|
*/
|
|
1722
1764
|
async importPluginEnvs(data) {
|
|
1723
|
-
|
|
1765
|
+
log10("Batch importing plugin envs: %O", data);
|
|
1724
1766
|
const result = await this.request(`/admin/plugins/env/import`, {
|
|
1725
1767
|
body: JSON.stringify(data),
|
|
1726
1768
|
method: "POST"
|
|
1727
1769
|
});
|
|
1728
|
-
|
|
1770
|
+
log10("Batch import completed: %d envs imported", result.success);
|
|
1729
1771
|
return result;
|
|
1730
1772
|
}
|
|
1731
1773
|
};
|
|
1732
1774
|
|
|
1733
1775
|
// src/admin/services/OrganizationService.ts
|
|
1734
|
-
import
|
|
1735
|
-
var
|
|
1776
|
+
import debug11 from "debug";
|
|
1777
|
+
var log11 = debug11("lobe-market-sdk:admin:organizations");
|
|
1736
1778
|
var OrganizationService = class extends BaseSDK {
|
|
1737
1779
|
/**
|
|
1738
1780
|
* Retrieves a paginated list of organizations with admin details
|
|
@@ -1741,12 +1783,12 @@ var OrganizationService = class extends BaseSDK {
|
|
|
1741
1783
|
* @returns Promise resolving to the organization list response
|
|
1742
1784
|
*/
|
|
1743
1785
|
async getOrganizations(params = {}) {
|
|
1744
|
-
|
|
1786
|
+
log11("Getting organizations with params: %O", params);
|
|
1745
1787
|
const queryString = this.buildQueryString(params);
|
|
1746
1788
|
const result = await this.request(
|
|
1747
1789
|
`/admin/organizations${queryString}`
|
|
1748
1790
|
);
|
|
1749
|
-
|
|
1791
|
+
log11("Retrieved %d organizations", result.data.length);
|
|
1750
1792
|
return result;
|
|
1751
1793
|
}
|
|
1752
1794
|
/**
|
|
@@ -1756,7 +1798,7 @@ var OrganizationService = class extends BaseSDK {
|
|
|
1756
1798
|
* @returns Promise resolving to the organization detail
|
|
1757
1799
|
*/
|
|
1758
1800
|
async getOrganization(id) {
|
|
1759
|
-
|
|
1801
|
+
log11("Getting organization detail: %d", id);
|
|
1760
1802
|
return this.request(`/admin/organizations/${id}`);
|
|
1761
1803
|
}
|
|
1762
1804
|
/**
|
|
@@ -1766,7 +1808,7 @@ var OrganizationService = class extends BaseSDK {
|
|
|
1766
1808
|
* @returns Promise resolving to the member list
|
|
1767
1809
|
*/
|
|
1768
1810
|
async getOrganizationMembers(id) {
|
|
1769
|
-
|
|
1811
|
+
log11("Getting organization members: %d", id);
|
|
1770
1812
|
return this.request(
|
|
1771
1813
|
`/admin/organizations/${id}/members`
|
|
1772
1814
|
);
|
|
@@ -1779,7 +1821,7 @@ var OrganizationService = class extends BaseSDK {
|
|
|
1779
1821
|
* @returns Promise resolving to the updated organization
|
|
1780
1822
|
*/
|
|
1781
1823
|
async updateOrganization(id, data) {
|
|
1782
|
-
|
|
1824
|
+
log11("Updating organization: %d, data: %O", id, data);
|
|
1783
1825
|
return this.request(`/admin/organizations/${id}`, {
|
|
1784
1826
|
body: JSON.stringify(data),
|
|
1785
1827
|
method: "PUT"
|
|
@@ -1792,7 +1834,7 @@ var OrganizationService = class extends BaseSDK {
|
|
|
1792
1834
|
* @returns Promise resolving to the archived organization
|
|
1793
1835
|
*/
|
|
1794
1836
|
async archiveOrganization(id) {
|
|
1795
|
-
|
|
1837
|
+
log11("Archiving organization: %d", id);
|
|
1796
1838
|
return this.request(`/admin/organizations/${id}/archive`, {
|
|
1797
1839
|
method: "PATCH"
|
|
1798
1840
|
});
|
|
@@ -1804,7 +1846,7 @@ var OrganizationService = class extends BaseSDK {
|
|
|
1804
1846
|
* @returns Promise resolving to the restored organization
|
|
1805
1847
|
*/
|
|
1806
1848
|
async unarchiveOrganization(id) {
|
|
1807
|
-
|
|
1849
|
+
log11("Unarchiving organization: %d", id);
|
|
1808
1850
|
return this.request(`/admin/organizations/${id}/unarchive`, {
|
|
1809
1851
|
method: "PATCH"
|
|
1810
1852
|
});
|
|
@@ -1812,7 +1854,7 @@ var OrganizationService = class extends BaseSDK {
|
|
|
1812
1854
|
};
|
|
1813
1855
|
|
|
1814
1856
|
// src/admin/MarketAdmin.ts
|
|
1815
|
-
var
|
|
1857
|
+
var log12 = debug12("lobe-market-sdk:admin");
|
|
1816
1858
|
var MarketAdmin = class extends BaseSDK {
|
|
1817
1859
|
/**
|
|
1818
1860
|
* Creates a new MarketAdmin instance
|
|
@@ -1826,11 +1868,12 @@ var MarketAdmin = class extends BaseSDK {
|
|
|
1826
1868
|
tokenExpiry: void 0
|
|
1827
1869
|
};
|
|
1828
1870
|
super({ ...options, apiKey }, void 0, sharedTokenState);
|
|
1829
|
-
|
|
1871
|
+
log12("MarketAdmin instance created");
|
|
1830
1872
|
this.agents = new AgentService(options, this.headers, sharedTokenState);
|
|
1831
1873
|
this.analysis = new AnalysisService(options, this.headers, sharedTokenState);
|
|
1832
1874
|
this.dependencies = new SystemDependencyService(options, this.headers, sharedTokenState);
|
|
1833
1875
|
this.env = new PluginEnvService(options, this.headers, sharedTokenState);
|
|
1876
|
+
this.ingestion = new IngestionService(options, this.headers, sharedTokenState);
|
|
1834
1877
|
this.organizations = new OrganizationService(options, this.headers, sharedTokenState);
|
|
1835
1878
|
this.plugins = new PluginService(options, this.headers, sharedTokenState);
|
|
1836
1879
|
this.reviews = new ReviewService(options, this.headers, sharedTokenState);
|
|
@@ -1840,11 +1883,11 @@ var MarketAdmin = class extends BaseSDK {
|
|
|
1840
1883
|
};
|
|
1841
1884
|
|
|
1842
1885
|
// src/market/market-sdk.ts
|
|
1843
|
-
import
|
|
1886
|
+
import debug33 from "debug";
|
|
1844
1887
|
|
|
1845
1888
|
// src/market/services/AgentProfileService.ts
|
|
1846
|
-
import
|
|
1847
|
-
var
|
|
1889
|
+
import debug13 from "debug";
|
|
1890
|
+
var log13 = debug13("lobe-market-sdk:agent-profile");
|
|
1848
1891
|
var AgentProfileService = class extends BaseSDK {
|
|
1849
1892
|
/**
|
|
1850
1893
|
* Retrieves the current agent's profile
|
|
@@ -1856,9 +1899,9 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
1856
1899
|
* @returns Promise resolving to the agent profile response
|
|
1857
1900
|
*/
|
|
1858
1901
|
async getProfile(options) {
|
|
1859
|
-
|
|
1902
|
+
log13("Getting agent profile");
|
|
1860
1903
|
const result = await this.request("/v1/agent/profile", options);
|
|
1861
|
-
|
|
1904
|
+
log13("Agent profile retrieved: id=%d, identifier=%s", result.agent.id, result.agent.identifier);
|
|
1862
1905
|
return result;
|
|
1863
1906
|
}
|
|
1864
1907
|
/**
|
|
@@ -1872,7 +1915,7 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
1872
1915
|
* @returns Promise resolving to the updated agent profile response
|
|
1873
1916
|
*/
|
|
1874
1917
|
async updateProfile(data, options) {
|
|
1875
|
-
|
|
1918
|
+
log13("Updating agent profile: %O", data);
|
|
1876
1919
|
const result = await this.request("/v1/agent/profile", {
|
|
1877
1920
|
body: JSON.stringify(data),
|
|
1878
1921
|
headers: {
|
|
@@ -1881,14 +1924,14 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
1881
1924
|
method: "PATCH",
|
|
1882
1925
|
...options
|
|
1883
1926
|
});
|
|
1884
|
-
|
|
1927
|
+
log13("Agent profile updated: id=%d, name=%s", result.agent.id, result.agent.name);
|
|
1885
1928
|
return result;
|
|
1886
1929
|
}
|
|
1887
1930
|
};
|
|
1888
1931
|
|
|
1889
1932
|
// src/market/services/AgentService.ts
|
|
1890
|
-
import
|
|
1891
|
-
var
|
|
1933
|
+
import debug14 from "debug";
|
|
1934
|
+
var log14 = debug14("lobe-market-sdk:agents");
|
|
1892
1935
|
var AgentService2 = class extends BaseSDK {
|
|
1893
1936
|
/**
|
|
1894
1937
|
* Retrieves a list of agents from the marketplace
|
|
@@ -1903,9 +1946,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1903
1946
|
const locale = params.locale || this.defaultLocale;
|
|
1904
1947
|
const queryParams = { ...params, locale };
|
|
1905
1948
|
const queryString = this.buildQueryString(queryParams);
|
|
1906
|
-
|
|
1949
|
+
log14("Getting agent list: %O", queryParams);
|
|
1907
1950
|
const result = await this.request(`/v1/agents${queryString}`, options);
|
|
1908
|
-
|
|
1951
|
+
log14("Retrieved %d agents", result.items.length);
|
|
1909
1952
|
return result;
|
|
1910
1953
|
}
|
|
1911
1954
|
/**
|
|
@@ -1922,9 +1965,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1922
1965
|
const locale = params.locale || this.defaultLocale;
|
|
1923
1966
|
const queryParams = { ...params, locale };
|
|
1924
1967
|
const queryString = this.buildQueryString(queryParams);
|
|
1925
|
-
|
|
1968
|
+
log14("Getting own agent list: %O", queryParams);
|
|
1926
1969
|
const result = await this.request(`/v1/agents/own${queryString}`, options);
|
|
1927
|
-
|
|
1970
|
+
log14("Retrieved %d own agents", result.items.length);
|
|
1928
1971
|
return result;
|
|
1929
1972
|
}
|
|
1930
1973
|
/**
|
|
@@ -1945,12 +1988,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1945
1988
|
queryParams.version = params.version.toString();
|
|
1946
1989
|
}
|
|
1947
1990
|
const queryString = this.buildQueryString(queryParams);
|
|
1948
|
-
|
|
1991
|
+
log14("Getting agent detail: %O", { id, ...params });
|
|
1949
1992
|
const result = await this.request(
|
|
1950
1993
|
`/v1/agents/detail/${id}${queryString}`,
|
|
1951
1994
|
options
|
|
1952
1995
|
);
|
|
1953
|
-
|
|
1996
|
+
log14("Agent detail successfully retrieved: %s", id);
|
|
1954
1997
|
return result;
|
|
1955
1998
|
}
|
|
1956
1999
|
/**
|
|
@@ -1966,12 +2009,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1966
2009
|
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
1967
2010
|
*/
|
|
1968
2011
|
async getPublishedIdentifiers(options) {
|
|
1969
|
-
|
|
2012
|
+
log14("Getting published agent identifiers");
|
|
1970
2013
|
const result = await this.request(
|
|
1971
2014
|
"/v1/agents/identifiers",
|
|
1972
2015
|
options
|
|
1973
2016
|
);
|
|
1974
|
-
|
|
2017
|
+
log14("Retrieved %d published agent identifiers", result.length);
|
|
1975
2018
|
return result;
|
|
1976
2019
|
}
|
|
1977
2020
|
/**
|
|
@@ -1982,9 +2025,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1982
2025
|
*/
|
|
1983
2026
|
async getSitemap(params = {}, options) {
|
|
1984
2027
|
const queryString = this.buildQueryString(params);
|
|
1985
|
-
|
|
2028
|
+
log14("Getting agent sitemap%s", queryString);
|
|
1986
2029
|
const result = await this.request(`/v1/agents/sitemap${queryString}`, options);
|
|
1987
|
-
|
|
2030
|
+
log14(
|
|
1988
2031
|
"Retrieved agent sitemap page %d/%d (%d items)",
|
|
1989
2032
|
result.currentPage,
|
|
1990
2033
|
result.totalPages,
|
|
@@ -2007,12 +2050,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2007
2050
|
const locale = params.locale || this.defaultLocale;
|
|
2008
2051
|
const queryParams = { ...params, locale };
|
|
2009
2052
|
const queryString = this.buildQueryString(queryParams);
|
|
2010
|
-
|
|
2053
|
+
log14("Getting agent categories: %O", queryParams);
|
|
2011
2054
|
const result = await this.request(
|
|
2012
2055
|
`/v1/agents/categories${queryString}`,
|
|
2013
2056
|
options
|
|
2014
2057
|
);
|
|
2015
|
-
|
|
2058
|
+
log14("Retrieved %d categories", result.length);
|
|
2016
2059
|
return result;
|
|
2017
2060
|
}
|
|
2018
2061
|
/**
|
|
@@ -2026,7 +2069,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2026
2069
|
* @returns Promise resolving to the upload response
|
|
2027
2070
|
*/
|
|
2028
2071
|
async uploadAgent(agentData, options) {
|
|
2029
|
-
|
|
2072
|
+
log14("Uploading agent: %s@%s", agentData.agentIdentifier, agentData.version.version);
|
|
2030
2073
|
const result = await this.request("/v1/agents/upload", {
|
|
2031
2074
|
body: JSON.stringify(agentData),
|
|
2032
2075
|
headers: {
|
|
@@ -2035,7 +2078,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2035
2078
|
method: "POST",
|
|
2036
2079
|
...options
|
|
2037
2080
|
});
|
|
2038
|
-
|
|
2081
|
+
log14("Agent uploaded successfully: %O", result);
|
|
2039
2082
|
return result;
|
|
2040
2083
|
}
|
|
2041
2084
|
/**
|
|
@@ -2046,7 +2089,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2046
2089
|
* @returns Promise resolving to the created agent response
|
|
2047
2090
|
*/
|
|
2048
2091
|
async createAgent(agentData, options) {
|
|
2049
|
-
|
|
2092
|
+
log14("Creating agent: %s", agentData.identifier);
|
|
2050
2093
|
const result = await this.request("/v1/agents/create", {
|
|
2051
2094
|
body: JSON.stringify(agentData),
|
|
2052
2095
|
headers: {
|
|
@@ -2055,7 +2098,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2055
2098
|
method: "POST",
|
|
2056
2099
|
...options
|
|
2057
2100
|
});
|
|
2058
|
-
|
|
2101
|
+
log14("Agent created successfully: %O", result);
|
|
2059
2102
|
return result;
|
|
2060
2103
|
}
|
|
2061
2104
|
/**
|
|
@@ -2066,7 +2109,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2066
2109
|
* @returns Promise resolving to the created version response
|
|
2067
2110
|
*/
|
|
2068
2111
|
async createAgentVersion(versionData, options) {
|
|
2069
|
-
|
|
2112
|
+
log14("Creating agent version: %s", versionData.identifier);
|
|
2070
2113
|
const result = await this.request("/v1/agents/version/create", {
|
|
2071
2114
|
body: JSON.stringify(versionData),
|
|
2072
2115
|
headers: {
|
|
@@ -2075,7 +2118,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2075
2118
|
method: "POST",
|
|
2076
2119
|
...options
|
|
2077
2120
|
});
|
|
2078
|
-
|
|
2121
|
+
log14("Agent version created successfully: %O", result);
|
|
2079
2122
|
return result;
|
|
2080
2123
|
}
|
|
2081
2124
|
/**
|
|
@@ -2086,7 +2129,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2086
2129
|
* @returns Promise resolving to the modified agent response
|
|
2087
2130
|
*/
|
|
2088
2131
|
async modifyAgent(agentData, options) {
|
|
2089
|
-
|
|
2132
|
+
log14("Modifying agent: %s", agentData.identifier);
|
|
2090
2133
|
const result = await this.request("/v1/agents/modify", {
|
|
2091
2134
|
body: JSON.stringify(agentData),
|
|
2092
2135
|
headers: {
|
|
@@ -2095,7 +2138,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2095
2138
|
method: "POST",
|
|
2096
2139
|
...options
|
|
2097
2140
|
});
|
|
2098
|
-
|
|
2141
|
+
log14("Agent modified successfully: %O", result);
|
|
2099
2142
|
return result;
|
|
2100
2143
|
}
|
|
2101
2144
|
/**
|
|
@@ -2106,7 +2149,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2106
2149
|
* @returns Promise resolving to the modified version response
|
|
2107
2150
|
*/
|
|
2108
2151
|
async modifyAgentVersion(versionData, options) {
|
|
2109
|
-
|
|
2152
|
+
log14("Modifying agent version: %s@%s", versionData.identifier, versionData.version);
|
|
2110
2153
|
const result = await this.request("/v1/agents/version/modify", {
|
|
2111
2154
|
body: JSON.stringify(versionData),
|
|
2112
2155
|
headers: {
|
|
@@ -2115,7 +2158,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2115
2158
|
method: "POST",
|
|
2116
2159
|
...options
|
|
2117
2160
|
});
|
|
2118
|
-
|
|
2161
|
+
log14("Agent version modified successfully: %O", result);
|
|
2119
2162
|
return result;
|
|
2120
2163
|
}
|
|
2121
2164
|
/**
|
|
@@ -2126,13 +2169,13 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2126
2169
|
* @returns Promise resolving to true if agent exists, false otherwise
|
|
2127
2170
|
*/
|
|
2128
2171
|
async checkAgentExists(identifier, options) {
|
|
2129
|
-
|
|
2172
|
+
log14("Checking if agent exists: %s", identifier);
|
|
2130
2173
|
try {
|
|
2131
2174
|
await this.getAgentDetail(identifier, {}, options);
|
|
2132
|
-
|
|
2175
|
+
log14("Agent exists: %s", identifier);
|
|
2133
2176
|
return true;
|
|
2134
2177
|
} catch (e) {
|
|
2135
|
-
|
|
2178
|
+
log14("Agent does not exist: %s", identifier);
|
|
2136
2179
|
return false;
|
|
2137
2180
|
}
|
|
2138
2181
|
}
|
|
@@ -2145,7 +2188,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2145
2188
|
* @param options - Optional request init overrides
|
|
2146
2189
|
*/
|
|
2147
2190
|
async createEvent(eventData, options) {
|
|
2148
|
-
|
|
2191
|
+
log14("Recording agent event: %s for %s", eventData.event, eventData.identifier);
|
|
2149
2192
|
await this.request("/v1/agents/events", {
|
|
2150
2193
|
body: JSON.stringify(eventData),
|
|
2151
2194
|
headers: {
|
|
@@ -2166,7 +2209,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2166
2209
|
* @returns Promise resolving to the updated install count response
|
|
2167
2210
|
*/
|
|
2168
2211
|
async increaseInstallCount(identifier, options) {
|
|
2169
|
-
|
|
2212
|
+
log14("Increasing install count for agent: %s", identifier);
|
|
2170
2213
|
const result = await this.request("/v1/agents/install-count", {
|
|
2171
2214
|
body: JSON.stringify({ identifier }),
|
|
2172
2215
|
headers: {
|
|
@@ -2175,7 +2218,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2175
2218
|
method: "POST",
|
|
2176
2219
|
...options
|
|
2177
2220
|
});
|
|
2178
|
-
|
|
2221
|
+
log14("Install count increased for agent %s: %d", identifier, result.installCount);
|
|
2179
2222
|
return result;
|
|
2180
2223
|
}
|
|
2181
2224
|
/**
|
|
@@ -2190,9 +2233,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2190
2233
|
* @returns Promise resolving to the status change response
|
|
2191
2234
|
*/
|
|
2192
2235
|
async changeStatus(identifier, status, options) {
|
|
2193
|
-
|
|
2236
|
+
log14("Changing agent status: %s -> %s", identifier, status);
|
|
2194
2237
|
const result = await this.modifyAgent({ identifier, status }, options);
|
|
2195
|
-
|
|
2238
|
+
log14("Agent status changed: %s -> %s", identifier, result.status);
|
|
2196
2239
|
return {
|
|
2197
2240
|
identifier: result.identifier,
|
|
2198
2241
|
status: result.status,
|
|
@@ -2210,7 +2253,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2210
2253
|
* @returns Promise resolving to the status change response
|
|
2211
2254
|
*/
|
|
2212
2255
|
async publish(identifier, options) {
|
|
2213
|
-
|
|
2256
|
+
log14("Publishing agent: %s", identifier);
|
|
2214
2257
|
return this.changeStatus(identifier, "published", options);
|
|
2215
2258
|
}
|
|
2216
2259
|
/**
|
|
@@ -2225,7 +2268,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2225
2268
|
* @returns Promise resolving to the status change response
|
|
2226
2269
|
*/
|
|
2227
2270
|
async unpublish(identifier, options) {
|
|
2228
|
-
|
|
2271
|
+
log14("Unpublishing agent: %s", identifier);
|
|
2229
2272
|
return this.changeStatus(identifier, "unpublished", options);
|
|
2230
2273
|
}
|
|
2231
2274
|
/**
|
|
@@ -2240,7 +2283,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2240
2283
|
* @returns Promise resolving to the status change response
|
|
2241
2284
|
*/
|
|
2242
2285
|
async archive(identifier, options) {
|
|
2243
|
-
|
|
2286
|
+
log14("Archiving agent: %s", identifier);
|
|
2244
2287
|
return this.changeStatus(identifier, "archived", options);
|
|
2245
2288
|
}
|
|
2246
2289
|
/**
|
|
@@ -2255,7 +2298,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2255
2298
|
* @returns Promise resolving to the status change response
|
|
2256
2299
|
*/
|
|
2257
2300
|
async deprecate(identifier, options) {
|
|
2258
|
-
|
|
2301
|
+
log14("Deprecating agent: %s", identifier);
|
|
2259
2302
|
return this.changeStatus(identifier, "deprecated", options);
|
|
2260
2303
|
}
|
|
2261
2304
|
/**
|
|
@@ -2273,12 +2316,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2273
2316
|
const locale = params.locale || this.defaultLocale;
|
|
2274
2317
|
const queryParams = { ...params, locale };
|
|
2275
2318
|
const queryString = this.buildQueryString(queryParams);
|
|
2276
|
-
|
|
2319
|
+
log14("Getting agents by plugin: %s", params.pluginId);
|
|
2277
2320
|
const result = await this.request(
|
|
2278
2321
|
`/v1/agents/by-plugin${queryString}`,
|
|
2279
2322
|
options
|
|
2280
2323
|
);
|
|
2281
|
-
|
|
2324
|
+
log14("Retrieved %d agents for plugin %s", result.items.length, params.pluginId);
|
|
2282
2325
|
return result;
|
|
2283
2326
|
}
|
|
2284
2327
|
/**
|
|
@@ -2294,7 +2337,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2294
2337
|
* @returns Promise resolving to the fork response with new agent details
|
|
2295
2338
|
*/
|
|
2296
2339
|
async forkAgent(sourceIdentifier, forkData, options) {
|
|
2297
|
-
|
|
2340
|
+
log14("Forking agent: %s -> %s", sourceIdentifier, forkData.identifier);
|
|
2298
2341
|
const result = await this.request(`/v1/agents/${sourceIdentifier}/fork`, {
|
|
2299
2342
|
body: JSON.stringify(forkData),
|
|
2300
2343
|
headers: {
|
|
@@ -2303,7 +2346,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2303
2346
|
method: "POST",
|
|
2304
2347
|
...options
|
|
2305
2348
|
});
|
|
2306
|
-
|
|
2349
|
+
log14("Agent forked successfully: %s (id: %d)", result.agent.identifier, result.agent.id);
|
|
2307
2350
|
return result;
|
|
2308
2351
|
}
|
|
2309
2352
|
/**
|
|
@@ -2317,12 +2360,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2317
2360
|
* @returns Promise resolving to the forks list response
|
|
2318
2361
|
*/
|
|
2319
2362
|
async getAgentForks(identifier, options) {
|
|
2320
|
-
|
|
2363
|
+
log14("Getting forks for agent: %s", identifier);
|
|
2321
2364
|
const result = await this.request(
|
|
2322
2365
|
`/v1/agents/${identifier}/forks`,
|
|
2323
2366
|
options
|
|
2324
2367
|
);
|
|
2325
|
-
|
|
2368
|
+
log14("Retrieved %d forks for agent: %s", result.totalCount, identifier);
|
|
2326
2369
|
return result;
|
|
2327
2370
|
}
|
|
2328
2371
|
/**
|
|
@@ -2335,23 +2378,23 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2335
2378
|
* @returns Promise resolving to the fork source response
|
|
2336
2379
|
*/
|
|
2337
2380
|
async getAgentForkSource(identifier, options) {
|
|
2338
|
-
|
|
2381
|
+
log14("Getting fork source for agent: %s", identifier);
|
|
2339
2382
|
const result = await this.request(
|
|
2340
2383
|
`/v1/agents/${identifier}/fork-source`,
|
|
2341
2384
|
options
|
|
2342
2385
|
);
|
|
2343
2386
|
if (result.source) {
|
|
2344
|
-
|
|
2387
|
+
log14("Agent %s was forked from: %s", identifier, result.source.identifier);
|
|
2345
2388
|
} else {
|
|
2346
|
-
|
|
2389
|
+
log14("Agent %s is not a fork (original agent)", identifier);
|
|
2347
2390
|
}
|
|
2348
2391
|
return result;
|
|
2349
2392
|
}
|
|
2350
2393
|
};
|
|
2351
2394
|
|
|
2352
2395
|
// src/market/services/AgentGroupService.ts
|
|
2353
|
-
import
|
|
2354
|
-
var
|
|
2396
|
+
import debug15 from "debug";
|
|
2397
|
+
var log15 = debug15("lobe-market-sdk:agent-groups");
|
|
2355
2398
|
var AgentGroupService = class extends BaseSDK {
|
|
2356
2399
|
/**
|
|
2357
2400
|
* Retrieves a list of agent groups from the marketplace
|
|
@@ -2366,12 +2409,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2366
2409
|
const locale = params.locale || this.defaultLocale;
|
|
2367
2410
|
const queryParams = { ...params, locale };
|
|
2368
2411
|
const queryString = this.buildQueryString(queryParams);
|
|
2369
|
-
|
|
2412
|
+
log15("Getting agent group list: %O", queryParams);
|
|
2370
2413
|
const result = await this.request(
|
|
2371
2414
|
`/v1/agent-groups${queryString}`,
|
|
2372
2415
|
options
|
|
2373
2416
|
);
|
|
2374
|
-
|
|
2417
|
+
log15("Retrieved %d agent groups", result.items.length);
|
|
2375
2418
|
return result;
|
|
2376
2419
|
}
|
|
2377
2420
|
/**
|
|
@@ -2388,12 +2431,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2388
2431
|
const locale = params.locale || this.defaultLocale;
|
|
2389
2432
|
const queryParams = { ...params, locale };
|
|
2390
2433
|
const queryString = this.buildQueryString(queryParams);
|
|
2391
|
-
|
|
2434
|
+
log15("Getting own agent group list: %O", queryParams);
|
|
2392
2435
|
const result = await this.request(
|
|
2393
2436
|
`/v1/agent-groups/own${queryString}`,
|
|
2394
2437
|
options
|
|
2395
2438
|
);
|
|
2396
|
-
|
|
2439
|
+
log15("Retrieved %d own agent groups", result.items.length);
|
|
2397
2440
|
return result;
|
|
2398
2441
|
}
|
|
2399
2442
|
/**
|
|
@@ -2414,12 +2457,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2414
2457
|
queryParams.version = params.version.toString();
|
|
2415
2458
|
}
|
|
2416
2459
|
const queryString = this.buildQueryString(queryParams);
|
|
2417
|
-
|
|
2460
|
+
log15("Getting agent group detail: %O", { identifier, ...params });
|
|
2418
2461
|
const result = await this.request(
|
|
2419
2462
|
`/v1/agent-groups/detail${queryString}`,
|
|
2420
2463
|
options
|
|
2421
2464
|
);
|
|
2422
|
-
|
|
2465
|
+
log15("Agent group detail successfully retrieved: %s", identifier);
|
|
2423
2466
|
return result;
|
|
2424
2467
|
}
|
|
2425
2468
|
/**
|
|
@@ -2433,7 +2476,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2433
2476
|
* @returns Promise resolving to the created agent group response
|
|
2434
2477
|
*/
|
|
2435
2478
|
async createAgentGroup(groupData, options) {
|
|
2436
|
-
|
|
2479
|
+
log15("Creating agent group: %s", groupData.identifier);
|
|
2437
2480
|
const result = await this.request("/v1/agent-groups/create", {
|
|
2438
2481
|
body: JSON.stringify(groupData),
|
|
2439
2482
|
headers: {
|
|
@@ -2442,7 +2485,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2442
2485
|
method: "POST",
|
|
2443
2486
|
...options
|
|
2444
2487
|
});
|
|
2445
|
-
|
|
2488
|
+
log15("Agent group created successfully: %O", result);
|
|
2446
2489
|
return result;
|
|
2447
2490
|
}
|
|
2448
2491
|
/**
|
|
@@ -2456,7 +2499,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2456
2499
|
* @returns Promise resolving to the created version response
|
|
2457
2500
|
*/
|
|
2458
2501
|
async createAgentGroupVersion(versionData, options) {
|
|
2459
|
-
|
|
2502
|
+
log15("Creating agent group version: %s", versionData.identifier);
|
|
2460
2503
|
const result = await this.request(
|
|
2461
2504
|
"/v1/agent-groups/version-create",
|
|
2462
2505
|
{
|
|
@@ -2468,7 +2511,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2468
2511
|
...options
|
|
2469
2512
|
}
|
|
2470
2513
|
);
|
|
2471
|
-
|
|
2514
|
+
log15("Agent group version created successfully: %O", result);
|
|
2472
2515
|
return result;
|
|
2473
2516
|
}
|
|
2474
2517
|
/**
|
|
@@ -2482,7 +2525,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2482
2525
|
* @returns Promise resolving to the modified agent group response
|
|
2483
2526
|
*/
|
|
2484
2527
|
async modifyAgentGroup(groupData, options) {
|
|
2485
|
-
|
|
2528
|
+
log15("Modifying agent group: %s", groupData.identifier);
|
|
2486
2529
|
const result = await this.request("/v1/agent-groups/modify", {
|
|
2487
2530
|
body: JSON.stringify(groupData),
|
|
2488
2531
|
headers: {
|
|
@@ -2491,7 +2534,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2491
2534
|
method: "POST",
|
|
2492
2535
|
...options
|
|
2493
2536
|
});
|
|
2494
|
-
|
|
2537
|
+
log15("Agent group modified successfully: %O", result);
|
|
2495
2538
|
return result;
|
|
2496
2539
|
}
|
|
2497
2540
|
/**
|
|
@@ -2502,13 +2545,13 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2502
2545
|
* @returns Promise resolving to true if agent group exists, false otherwise
|
|
2503
2546
|
*/
|
|
2504
2547
|
async checkAgentGroupExists(identifier, options) {
|
|
2505
|
-
|
|
2548
|
+
log15("Checking if agent group exists: %s", identifier);
|
|
2506
2549
|
try {
|
|
2507
2550
|
await this.getAgentGroupDetail(identifier, {}, options);
|
|
2508
|
-
|
|
2551
|
+
log15("Agent group exists: %s", identifier);
|
|
2509
2552
|
return true;
|
|
2510
2553
|
} catch (e) {
|
|
2511
|
-
|
|
2554
|
+
log15("Agent group does not exist: %s", identifier);
|
|
2512
2555
|
return false;
|
|
2513
2556
|
}
|
|
2514
2557
|
}
|
|
@@ -2524,9 +2567,9 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2524
2567
|
* @returns Promise resolving to the status change response
|
|
2525
2568
|
*/
|
|
2526
2569
|
async changeStatus(identifier, status, options) {
|
|
2527
|
-
|
|
2570
|
+
log15("Changing agent group status: %s -> %s", identifier, status);
|
|
2528
2571
|
const result = await this.modifyAgentGroup({ identifier, status }, options);
|
|
2529
|
-
|
|
2572
|
+
log15("Agent group status changed: %s -> %s", identifier, result.status);
|
|
2530
2573
|
return {
|
|
2531
2574
|
identifier: result.identifier,
|
|
2532
2575
|
status: result.status,
|
|
@@ -2545,7 +2588,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2545
2588
|
* @returns Promise resolving to the status change response
|
|
2546
2589
|
*/
|
|
2547
2590
|
async publish(identifier, options) {
|
|
2548
|
-
|
|
2591
|
+
log15("Publishing agent group: %s", identifier);
|
|
2549
2592
|
return this.changeStatus(identifier, "published", options);
|
|
2550
2593
|
}
|
|
2551
2594
|
/**
|
|
@@ -2560,7 +2603,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2560
2603
|
* @returns Promise resolving to the status change response
|
|
2561
2604
|
*/
|
|
2562
2605
|
async unpublish(identifier, options) {
|
|
2563
|
-
|
|
2606
|
+
log15("Unpublishing agent group: %s", identifier);
|
|
2564
2607
|
return this.changeStatus(identifier, "unpublished", options);
|
|
2565
2608
|
}
|
|
2566
2609
|
/**
|
|
@@ -2575,7 +2618,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2575
2618
|
* @returns Promise resolving to the status change response
|
|
2576
2619
|
*/
|
|
2577
2620
|
async archive(identifier, options) {
|
|
2578
|
-
|
|
2621
|
+
log15("Archiving agent group: %s", identifier);
|
|
2579
2622
|
return this.changeStatus(identifier, "archived", options);
|
|
2580
2623
|
}
|
|
2581
2624
|
/**
|
|
@@ -2590,7 +2633,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2590
2633
|
* @returns Promise resolving to the status change response
|
|
2591
2634
|
*/
|
|
2592
2635
|
async deprecate(identifier, options) {
|
|
2593
|
-
|
|
2636
|
+
log15("Deprecating agent group: %s", identifier);
|
|
2594
2637
|
return this.changeStatus(identifier, "deprecated", options);
|
|
2595
2638
|
}
|
|
2596
2639
|
/**
|
|
@@ -2606,7 +2649,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2606
2649
|
* @returns Promise resolving to the fork response with new group details
|
|
2607
2650
|
*/
|
|
2608
2651
|
async forkAgentGroup(sourceIdentifier, forkData, options) {
|
|
2609
|
-
|
|
2652
|
+
log15("Forking agent group: %s -> %s", sourceIdentifier, forkData.identifier);
|
|
2610
2653
|
const result = await this.request(
|
|
2611
2654
|
`/v1/agent-groups/${sourceIdentifier}/fork`,
|
|
2612
2655
|
{
|
|
@@ -2618,7 +2661,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2618
2661
|
...options
|
|
2619
2662
|
}
|
|
2620
2663
|
);
|
|
2621
|
-
|
|
2664
|
+
log15(
|
|
2622
2665
|
"Agent group forked successfully: %s (id: %d, members: %d)",
|
|
2623
2666
|
result.group.identifier,
|
|
2624
2667
|
result.group.id,
|
|
@@ -2637,12 +2680,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2637
2680
|
* @returns Promise resolving to the forks list response
|
|
2638
2681
|
*/
|
|
2639
2682
|
async getAgentGroupForks(identifier, options) {
|
|
2640
|
-
|
|
2683
|
+
log15("Getting forks for agent group: %s", identifier);
|
|
2641
2684
|
const result = await this.request(
|
|
2642
2685
|
`/v1/agent-groups/${identifier}/forks`,
|
|
2643
2686
|
options
|
|
2644
2687
|
);
|
|
2645
|
-
|
|
2688
|
+
log15("Retrieved %d forks for agent group: %s", result.totalCount, identifier);
|
|
2646
2689
|
return result;
|
|
2647
2690
|
}
|
|
2648
2691
|
/**
|
|
@@ -2655,24 +2698,24 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2655
2698
|
* @returns Promise resolving to the fork source response
|
|
2656
2699
|
*/
|
|
2657
2700
|
async getAgentGroupForkSource(identifier, options) {
|
|
2658
|
-
|
|
2701
|
+
log15("Getting fork source for agent group: %s", identifier);
|
|
2659
2702
|
const result = await this.request(
|
|
2660
2703
|
`/v1/agent-groups/${identifier}/fork-source`,
|
|
2661
2704
|
options
|
|
2662
2705
|
);
|
|
2663
2706
|
if (result.source) {
|
|
2664
|
-
|
|
2707
|
+
log15("Agent group %s was forked from: %s", identifier, result.source.identifier);
|
|
2665
2708
|
} else {
|
|
2666
|
-
|
|
2709
|
+
log15("Agent group %s is not a fork (original group)", identifier);
|
|
2667
2710
|
}
|
|
2668
2711
|
return result;
|
|
2669
2712
|
}
|
|
2670
2713
|
};
|
|
2671
2714
|
|
|
2672
2715
|
// src/market/services/AuthService.ts
|
|
2673
|
-
import
|
|
2716
|
+
import debug16 from "debug";
|
|
2674
2717
|
import urlJoin2 from "url-join";
|
|
2675
|
-
var
|
|
2718
|
+
var log16 = debug16("lobe-market-sdk:auth");
|
|
2676
2719
|
var _AuthService = class _AuthService extends BaseSDK {
|
|
2677
2720
|
/** Normalize token response from snake_case to camelCase fields */
|
|
2678
2721
|
static normalizeTokenResponse(data) {
|
|
@@ -2704,7 +2747,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2704
2747
|
if (grantType !== "authorization_code" && grantType !== "refresh_token") {
|
|
2705
2748
|
throw new Error(`Unsupported grant type: ${grantType}`);
|
|
2706
2749
|
}
|
|
2707
|
-
|
|
2750
|
+
log16("Exchanging OAuth token using grant_type=%s", grantType);
|
|
2708
2751
|
const tokenUrl = urlJoin2(this.baseUrl, "lobehub-oidc/token");
|
|
2709
2752
|
const params = new URLSearchParams();
|
|
2710
2753
|
params.set("grant_type", grantType);
|
|
@@ -2746,16 +2789,16 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2746
2789
|
try {
|
|
2747
2790
|
payload = await response.json();
|
|
2748
2791
|
} catch (error) {
|
|
2749
|
-
|
|
2792
|
+
log16("Failed to parse token response: %O", error);
|
|
2750
2793
|
throw new Error(`Failed to parse token response: ${response.status} ${response.statusText}`);
|
|
2751
2794
|
}
|
|
2752
2795
|
if (!response.ok) {
|
|
2753
2796
|
const errorDescription = (payload == null ? void 0 : payload.error_description) || (payload == null ? void 0 : payload.error) || response.statusText;
|
|
2754
2797
|
const errorMsg = `Token exchange failed: ${response.status} ${errorDescription}`;
|
|
2755
|
-
|
|
2798
|
+
log16("Error: %s", errorMsg);
|
|
2756
2799
|
throw new Error(errorMsg);
|
|
2757
2800
|
}
|
|
2758
|
-
|
|
2801
|
+
log16("Token exchange successful");
|
|
2759
2802
|
return _AuthService.normalizeTokenResponse(payload);
|
|
2760
2803
|
}
|
|
2761
2804
|
/**
|
|
@@ -2773,7 +2816,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2773
2816
|
if (!clientId || !token) {
|
|
2774
2817
|
throw new Error("clientId and token are required for token revocation");
|
|
2775
2818
|
}
|
|
2776
|
-
|
|
2819
|
+
log16("Revoking OAuth token (hint=%s)", tokenTypeHint != null ? tokenTypeHint : "none");
|
|
2777
2820
|
const revocationUrl = urlJoin2(this.baseUrl, "lobehub-oidc/token/revocation");
|
|
2778
2821
|
const params = new URLSearchParams();
|
|
2779
2822
|
params.set("client_id", clientId);
|
|
@@ -2801,10 +2844,10 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2801
2844
|
} catch (e) {
|
|
2802
2845
|
}
|
|
2803
2846
|
const errorMsg = `Token revocation failed: ${response.status} ${errorDescription}`;
|
|
2804
|
-
|
|
2847
|
+
log16("Error: %s", errorMsg);
|
|
2805
2848
|
throw new Error(errorMsg);
|
|
2806
2849
|
}
|
|
2807
|
-
|
|
2850
|
+
log16("Token revocation successful");
|
|
2808
2851
|
}
|
|
2809
2852
|
/**
|
|
2810
2853
|
* Retrieves user information from the OIDC userinfo endpoint
|
|
@@ -2816,7 +2859,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2816
2859
|
* @returns Promise resolving to the user information
|
|
2817
2860
|
*/
|
|
2818
2861
|
async getUserInfo(accessToken, options) {
|
|
2819
|
-
|
|
2862
|
+
log16("Getting user info");
|
|
2820
2863
|
const userInfoUrl = urlJoin2(this.baseUrl, "lobehub-oidc/userinfo");
|
|
2821
2864
|
const response = await fetch(userInfoUrl, {
|
|
2822
2865
|
headers: {
|
|
@@ -2828,11 +2871,11 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2828
2871
|
});
|
|
2829
2872
|
if (!response.ok) {
|
|
2830
2873
|
const errorMsg = `Failed to fetch user info: ${response.status} ${response.statusText}`;
|
|
2831
|
-
|
|
2874
|
+
log16("Error: %s", errorMsg);
|
|
2832
2875
|
throw new Error(errorMsg);
|
|
2833
2876
|
}
|
|
2834
2877
|
const userInfo = await response.json();
|
|
2835
|
-
|
|
2878
|
+
log16("User info retrieved successfully");
|
|
2836
2879
|
return userInfo;
|
|
2837
2880
|
}
|
|
2838
2881
|
/**
|
|
@@ -2846,7 +2889,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2846
2889
|
* @returns Promise resolving to the client credentials
|
|
2847
2890
|
*/
|
|
2848
2891
|
async registerClient(clientData, options) {
|
|
2849
|
-
|
|
2892
|
+
log16("Registering client: %s (%s)", clientData.clientName, clientData.clientType);
|
|
2850
2893
|
const result = await this.request("/v1/clients/register", {
|
|
2851
2894
|
body: JSON.stringify(clientData),
|
|
2852
2895
|
headers: {
|
|
@@ -2855,7 +2898,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2855
2898
|
method: "POST",
|
|
2856
2899
|
...options
|
|
2857
2900
|
});
|
|
2858
|
-
|
|
2901
|
+
log16("Client registered successfully: %s", result.client_id);
|
|
2859
2902
|
return result;
|
|
2860
2903
|
}
|
|
2861
2904
|
/**
|
|
@@ -2867,9 +2910,9 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2867
2910
|
* @returns Promise resolving to the access token and expiration time
|
|
2868
2911
|
*/
|
|
2869
2912
|
async getM2MToken() {
|
|
2870
|
-
|
|
2913
|
+
log16("Fetching M2M token");
|
|
2871
2914
|
const tokenInfo = await this.fetchM2MToken();
|
|
2872
|
-
|
|
2915
|
+
log16("M2M token fetched successfully");
|
|
2873
2916
|
return tokenInfo;
|
|
2874
2917
|
}
|
|
2875
2918
|
/** OAuth handoff response shapes */
|
|
@@ -2895,7 +2938,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2895
2938
|
async getOAuthHandoff(id, options) {
|
|
2896
2939
|
var _a, _b;
|
|
2897
2940
|
if (!id) throw new Error("id is required");
|
|
2898
|
-
|
|
2941
|
+
log16("Getting OAuth handoff: %s", id);
|
|
2899
2942
|
const handoffUrl = `${urlJoin2(this.baseUrl, "lobehub-oidc/handoff")}?id=${encodeURIComponent(id)}`;
|
|
2900
2943
|
const response = await fetch(handoffUrl, {
|
|
2901
2944
|
headers: {
|
|
@@ -2911,19 +2954,19 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2911
2954
|
code: json.code,
|
|
2912
2955
|
redirectUri: json.redirectUri
|
|
2913
2956
|
});
|
|
2914
|
-
|
|
2957
|
+
log16("OAuth handoff success for id: %s", id);
|
|
2915
2958
|
return result;
|
|
2916
2959
|
}
|
|
2917
2960
|
if (response.status === 202) {
|
|
2918
|
-
|
|
2961
|
+
log16("OAuth handoff pending for id: %s", id);
|
|
2919
2962
|
return { status: _AuthService.HANDOFF_PENDING_STATUS };
|
|
2920
2963
|
}
|
|
2921
2964
|
if (response.status === 404) {
|
|
2922
|
-
|
|
2965
|
+
log16("OAuth handoff consumed for id: %s", id);
|
|
2923
2966
|
return { status: _AuthService.HANDOFF_CONSUMED_STATUS };
|
|
2924
2967
|
}
|
|
2925
2968
|
if (response.status === 410) {
|
|
2926
|
-
|
|
2969
|
+
log16("OAuth handoff expired for id: %s", id);
|
|
2927
2970
|
return { status: _AuthService.HANDOFF_EXPIRED_STATUS };
|
|
2928
2971
|
}
|
|
2929
2972
|
let errorMessage = `Failed to fetch OAuth handoff (status ${response.status} ${response.statusText})`;
|
|
@@ -2934,7 +2977,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2934
2977
|
}
|
|
2935
2978
|
} catch (e) {
|
|
2936
2979
|
}
|
|
2937
|
-
|
|
2980
|
+
log16("Error: %s", errorMessage);
|
|
2938
2981
|
throw new Error(errorMessage);
|
|
2939
2982
|
}
|
|
2940
2983
|
/**
|
|
@@ -2948,21 +2991,21 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2948
2991
|
const timeoutMs = (_b = params.timeoutMs) != null ? _b : 6e4;
|
|
2949
2992
|
const startedAt = Date.now();
|
|
2950
2993
|
const { signal, requestInit } = params;
|
|
2951
|
-
|
|
2994
|
+
log16("Start polling OAuth handoff: %s", id);
|
|
2952
2995
|
while (true) {
|
|
2953
2996
|
if (signal == null ? void 0 : signal.aborted) {
|
|
2954
2997
|
const err = new Error("Polling aborted");
|
|
2955
|
-
|
|
2998
|
+
log16("Error: %s", err.message);
|
|
2956
2999
|
throw err;
|
|
2957
3000
|
}
|
|
2958
3001
|
if (Date.now() - startedAt > timeoutMs) {
|
|
2959
3002
|
const err = new Error("Polling timeout");
|
|
2960
|
-
|
|
3003
|
+
log16("Error: %s", err.message);
|
|
2961
3004
|
throw err;
|
|
2962
3005
|
}
|
|
2963
3006
|
const result = await this.getOAuthHandoff(id, requestInit);
|
|
2964
3007
|
if (result.status === "success" || result.status === "expired" || result.status === "consumed") {
|
|
2965
|
-
|
|
3008
|
+
log16("Stop polling OAuth handoff (terminal): %s -> %s", id, result.status);
|
|
2966
3009
|
return result;
|
|
2967
3010
|
}
|
|
2968
3011
|
await new Promise((resolve) => {
|
|
@@ -2983,9 +3026,20 @@ _AuthService.HANDOFF_EXPIRED_STATUS = "expired";
|
|
|
2983
3026
|
var AuthService = _AuthService;
|
|
2984
3027
|
|
|
2985
3028
|
// src/market/services/ConnectService.ts
|
|
2986
|
-
import
|
|
3029
|
+
import debug17 from "debug";
|
|
2987
3030
|
import urlJoin3 from "url-join";
|
|
2988
|
-
var
|
|
3031
|
+
var log17 = debug17("lobe-market-sdk:connect");
|
|
3032
|
+
var CIMD_CLIENT_METADATA_VERSION = "v1";
|
|
3033
|
+
var CIMD_CLIENT_METADATA_VERSION_BY_PROVIDER = {
|
|
3034
|
+
posthog: "v2"
|
|
3035
|
+
};
|
|
3036
|
+
function getCimdClientMetadataVersion(provider, version) {
|
|
3037
|
+
var _a;
|
|
3038
|
+
return (_a = version != null ? version : CIMD_CLIENT_METADATA_VERSION_BY_PROVIDER[provider]) != null ? _a : CIMD_CLIENT_METADATA_VERSION;
|
|
3039
|
+
}
|
|
3040
|
+
function isGetClientMetadataParams(value) {
|
|
3041
|
+
return typeof value === "object" && value !== null && "version" in value;
|
|
3042
|
+
}
|
|
2989
3043
|
var ConnectService = class extends BaseSDK {
|
|
2990
3044
|
/**
|
|
2991
3045
|
* Lists all available OAuth providers
|
|
@@ -2998,9 +3052,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
2998
3052
|
*/
|
|
2999
3053
|
async listProviders(options) {
|
|
3000
3054
|
var _a;
|
|
3001
|
-
|
|
3055
|
+
log17("Listing connect providers");
|
|
3002
3056
|
const result = await this.request("/connect/providers", options);
|
|
3003
|
-
|
|
3057
|
+
log17("Found %d connect providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
3004
3058
|
return result;
|
|
3005
3059
|
}
|
|
3006
3060
|
/**
|
|
@@ -3014,12 +3068,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3014
3068
|
*/
|
|
3015
3069
|
async getProvider(provider, options) {
|
|
3016
3070
|
var _a;
|
|
3017
|
-
|
|
3071
|
+
log17("Getting provider details: %s", provider);
|
|
3018
3072
|
const result = await this.request(
|
|
3019
3073
|
`/connect/providers/${encodeURIComponent(provider)}`,
|
|
3020
3074
|
options
|
|
3021
3075
|
);
|
|
3022
|
-
|
|
3076
|
+
log17("Retrieved provider: %s", (_a = result.provider) == null ? void 0 : _a.name);
|
|
3023
3077
|
return result;
|
|
3024
3078
|
}
|
|
3025
3079
|
/**
|
|
@@ -3029,16 +3083,21 @@ var ConnectService = class extends BaseSDK {
|
|
|
3029
3083
|
* support OAuth Client ID Metadata Documents.
|
|
3030
3084
|
*
|
|
3031
3085
|
* @param provider - The provider ID
|
|
3086
|
+
* @param params - Optional metadata document parameters
|
|
3032
3087
|
* @param options - Optional request options
|
|
3033
3088
|
* @returns Promise resolving to the CIMD client metadata document
|
|
3034
3089
|
*/
|
|
3035
|
-
async getClientMetadata(provider, options) {
|
|
3036
|
-
|
|
3090
|
+
async getClientMetadata(provider, params, options) {
|
|
3091
|
+
const hasParams = options !== void 0 || isGetClientMetadataParams(params);
|
|
3092
|
+
const metadataParams = hasParams ? params : void 0;
|
|
3093
|
+
const requestOptions = hasParams ? options : params;
|
|
3094
|
+
const version = getCimdClientMetadataVersion(provider, metadataParams == null ? void 0 : metadataParams.version);
|
|
3095
|
+
log17("Getting CIMD client metadata for provider: %s version: %s", provider, version);
|
|
3037
3096
|
const result = await this.request(
|
|
3038
|
-
`/connect/${encodeURIComponent(provider)}/oauth/client-metadata
|
|
3039
|
-
|
|
3097
|
+
`/connect/${encodeURIComponent(provider)}/oauth/client-metadata/${encodeURIComponent(version)}.json`,
|
|
3098
|
+
requestOptions
|
|
3040
3099
|
);
|
|
3041
|
-
|
|
3100
|
+
log17("Retrieved CIMD client metadata: %s", result.client_id);
|
|
3042
3101
|
return result;
|
|
3043
3102
|
}
|
|
3044
3103
|
/**
|
|
@@ -3078,7 +3137,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3078
3137
|
* ```
|
|
3079
3138
|
*/
|
|
3080
3139
|
async authorize(provider, params, options) {
|
|
3081
|
-
|
|
3140
|
+
log17("Requesting authorization code for provider: %s", provider);
|
|
3082
3141
|
const result = await this.request(
|
|
3083
3142
|
`/connect/${encodeURIComponent(provider)}/authorize`,
|
|
3084
3143
|
{
|
|
@@ -3090,7 +3149,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3090
3149
|
...options
|
|
3091
3150
|
}
|
|
3092
3151
|
);
|
|
3093
|
-
|
|
3152
|
+
log17("Authorization code obtained, expires in %d seconds", result.expires_in);
|
|
3094
3153
|
return result;
|
|
3095
3154
|
}
|
|
3096
3155
|
/**
|
|
@@ -3116,7 +3175,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3116
3175
|
* ```
|
|
3117
3176
|
*/
|
|
3118
3177
|
getAuthorizeUrl(provider, params) {
|
|
3119
|
-
|
|
3178
|
+
log17(
|
|
3120
3179
|
"Generating authorize URL for provider: %s (deprecated, use authorize() instead)",
|
|
3121
3180
|
provider
|
|
3122
3181
|
);
|
|
@@ -3130,7 +3189,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3130
3189
|
const queryString = queryParams.toString();
|
|
3131
3190
|
const path = `/connect/${encodeURIComponent(provider)}/start${queryString ? `?${queryString}` : ""}`;
|
|
3132
3191
|
const url = urlJoin3(this.baseUrl, "api", path);
|
|
3133
|
-
|
|
3192
|
+
log17("Generated authorize URL: %s", url);
|
|
3134
3193
|
return url;
|
|
3135
3194
|
}
|
|
3136
3195
|
/**
|
|
@@ -3144,12 +3203,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3144
3203
|
* @returns Promise resolving to the connection status
|
|
3145
3204
|
*/
|
|
3146
3205
|
async getStatus(provider, options) {
|
|
3147
|
-
|
|
3206
|
+
log17("Getting connection status for provider: %s", provider);
|
|
3148
3207
|
const result = await this.request(
|
|
3149
3208
|
`/connect/${encodeURIComponent(provider)}/status`,
|
|
3150
3209
|
options
|
|
3151
3210
|
);
|
|
3152
|
-
|
|
3211
|
+
log17("Provider %s connection status: connected=%s", provider, result.connected);
|
|
3153
3212
|
return result;
|
|
3154
3213
|
}
|
|
3155
3214
|
/**
|
|
@@ -3162,9 +3221,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
3162
3221
|
*/
|
|
3163
3222
|
async listConnections(options) {
|
|
3164
3223
|
var _a;
|
|
3165
|
-
|
|
3224
|
+
log17("Listing user connections");
|
|
3166
3225
|
const result = await this.request("/connect/connections", options);
|
|
3167
|
-
|
|
3226
|
+
log17("Found %d connections", ((_a = result.connections) == null ? void 0 : _a.length) || 0);
|
|
3168
3227
|
return result;
|
|
3169
3228
|
}
|
|
3170
3229
|
/**
|
|
@@ -3178,12 +3237,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3178
3237
|
* @returns Promise resolving to the connection health status
|
|
3179
3238
|
*/
|
|
3180
3239
|
async getHealth(provider, options) {
|
|
3181
|
-
|
|
3240
|
+
log17("Checking health for provider: %s", provider);
|
|
3182
3241
|
const result = await this.request(
|
|
3183
3242
|
`/connect/${encodeURIComponent(provider)}/health`,
|
|
3184
3243
|
options
|
|
3185
3244
|
);
|
|
3186
|
-
|
|
3245
|
+
log17("Provider %s health: healthy=%s, status=%s", provider, result.healthy, result.tokenStatus);
|
|
3187
3246
|
return result;
|
|
3188
3247
|
}
|
|
3189
3248
|
/**
|
|
@@ -3196,9 +3255,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
3196
3255
|
*/
|
|
3197
3256
|
async getAllHealth(options) {
|
|
3198
3257
|
var _a, _b, _c;
|
|
3199
|
-
|
|
3258
|
+
log17("Checking health for all connections");
|
|
3200
3259
|
const result = await this.request("/connect/health", options);
|
|
3201
|
-
|
|
3260
|
+
log17(
|
|
3202
3261
|
"Health check complete: total=%d, healthy=%d, unhealthy=%d",
|
|
3203
3262
|
((_a = result.summary) == null ? void 0 : _a.total) || 0,
|
|
3204
3263
|
((_b = result.summary) == null ? void 0 : _b.healthy) || 0,
|
|
@@ -3217,7 +3276,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3217
3276
|
* @returns Promise resolving to the refresh result
|
|
3218
3277
|
*/
|
|
3219
3278
|
async refresh(provider, options) {
|
|
3220
|
-
|
|
3279
|
+
log17("Refreshing token for provider: %s", provider);
|
|
3221
3280
|
const result = await this.request(
|
|
3222
3281
|
`/connect/${encodeURIComponent(provider)}/refresh`,
|
|
3223
3282
|
{
|
|
@@ -3225,7 +3284,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3225
3284
|
...options
|
|
3226
3285
|
}
|
|
3227
3286
|
);
|
|
3228
|
-
|
|
3287
|
+
log17("Token refresh for %s: refreshed=%s", provider, result.refreshed);
|
|
3229
3288
|
return result;
|
|
3230
3289
|
}
|
|
3231
3290
|
/**
|
|
@@ -3239,7 +3298,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3239
3298
|
* @returns Promise resolving to the revoke result
|
|
3240
3299
|
*/
|
|
3241
3300
|
async revoke(provider, options) {
|
|
3242
|
-
|
|
3301
|
+
log17("Revoking connection for provider: %s", provider);
|
|
3243
3302
|
const result = await this.request(
|
|
3244
3303
|
`/connect/${encodeURIComponent(provider)}`,
|
|
3245
3304
|
{
|
|
@@ -3247,14 +3306,14 @@ var ConnectService = class extends BaseSDK {
|
|
|
3247
3306
|
...options
|
|
3248
3307
|
}
|
|
3249
3308
|
);
|
|
3250
|
-
|
|
3309
|
+
log17("Connection revoked for %s: success=%s", provider, result.success);
|
|
3251
3310
|
return result;
|
|
3252
3311
|
}
|
|
3253
3312
|
};
|
|
3254
3313
|
|
|
3255
3314
|
// src/market/services/CredService.ts
|
|
3256
|
-
import
|
|
3257
|
-
var
|
|
3315
|
+
import debug18 from "debug";
|
|
3316
|
+
var log18 = debug18("lobe-market-sdk:creds");
|
|
3258
3317
|
var CredService = class extends BaseSDK {
|
|
3259
3318
|
// ===========================================================================
|
|
3260
3319
|
// List & Get Operations
|
|
@@ -3270,9 +3329,9 @@ var CredService = class extends BaseSDK {
|
|
|
3270
3329
|
*/
|
|
3271
3330
|
async list(options) {
|
|
3272
3331
|
var _a;
|
|
3273
|
-
|
|
3332
|
+
log18("Listing user credentials");
|
|
3274
3333
|
const result = await this.request("/v1/user/creds", options);
|
|
3275
|
-
|
|
3334
|
+
log18("Found %d credentials", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
3276
3335
|
return result;
|
|
3277
3336
|
}
|
|
3278
3337
|
/**
|
|
@@ -3287,7 +3346,7 @@ var CredService = class extends BaseSDK {
|
|
|
3287
3346
|
* @returns Promise resolving to the credential details
|
|
3288
3347
|
*/
|
|
3289
3348
|
async get(id, getOptions, options) {
|
|
3290
|
-
|
|
3349
|
+
log18("Getting credential: %d (decrypt=%s)", id, getOptions == null ? void 0 : getOptions.decrypt);
|
|
3291
3350
|
const queryParams = {};
|
|
3292
3351
|
if (getOptions == null ? void 0 : getOptions.decrypt) {
|
|
3293
3352
|
queryParams.decrypt = "true";
|
|
@@ -3297,7 +3356,7 @@ var CredService = class extends BaseSDK {
|
|
|
3297
3356
|
`/v1/user/creds/${id}${queryString}`,
|
|
3298
3357
|
options
|
|
3299
3358
|
);
|
|
3300
|
-
|
|
3359
|
+
log18("Retrieved credential: %s", result.key);
|
|
3301
3360
|
return result;
|
|
3302
3361
|
}
|
|
3303
3362
|
// ===========================================================================
|
|
@@ -3316,7 +3375,7 @@ var CredService = class extends BaseSDK {
|
|
|
3316
3375
|
* @returns Promise resolving to the created credential
|
|
3317
3376
|
*/
|
|
3318
3377
|
async createKV(data, options) {
|
|
3319
|
-
|
|
3378
|
+
log18("Creating KV credential: %s (type=%s)", data.key, data.type);
|
|
3320
3379
|
const result = await this.request("/v1/user/creds/kv", {
|
|
3321
3380
|
body: JSON.stringify(data),
|
|
3322
3381
|
headers: {
|
|
@@ -3325,7 +3384,7 @@ var CredService = class extends BaseSDK {
|
|
|
3325
3384
|
method: "POST",
|
|
3326
3385
|
...options
|
|
3327
3386
|
});
|
|
3328
|
-
|
|
3387
|
+
log18("Created KV credential: %d", result.id);
|
|
3329
3388
|
return result;
|
|
3330
3389
|
}
|
|
3331
3390
|
/**
|
|
@@ -3339,7 +3398,7 @@ var CredService = class extends BaseSDK {
|
|
|
3339
3398
|
* @returns Promise resolving to the created credential
|
|
3340
3399
|
*/
|
|
3341
3400
|
async createOAuth(data, options) {
|
|
3342
|
-
|
|
3401
|
+
log18("Creating OAuth credential: %s (connectionId=%d)", data.key, data.oauthConnectionId);
|
|
3343
3402
|
const result = await this.request("/v1/user/creds/oauth", {
|
|
3344
3403
|
body: JSON.stringify(data),
|
|
3345
3404
|
headers: {
|
|
@@ -3348,7 +3407,7 @@ var CredService = class extends BaseSDK {
|
|
|
3348
3407
|
method: "POST",
|
|
3349
3408
|
...options
|
|
3350
3409
|
});
|
|
3351
|
-
|
|
3410
|
+
log18("Created OAuth credential: %d", result.id);
|
|
3352
3411
|
return result;
|
|
3353
3412
|
}
|
|
3354
3413
|
/**
|
|
@@ -3362,7 +3421,7 @@ var CredService = class extends BaseSDK {
|
|
|
3362
3421
|
* @returns Promise resolving to the created credential
|
|
3363
3422
|
*/
|
|
3364
3423
|
async createFile(data, options) {
|
|
3365
|
-
|
|
3424
|
+
log18("Creating file credential: %s (fileName=%s)", data.key, data.fileName);
|
|
3366
3425
|
const result = await this.request("/v1/user/creds/file", {
|
|
3367
3426
|
body: JSON.stringify(data),
|
|
3368
3427
|
headers: {
|
|
@@ -3371,7 +3430,7 @@ var CredService = class extends BaseSDK {
|
|
|
3371
3430
|
method: "POST",
|
|
3372
3431
|
...options
|
|
3373
3432
|
});
|
|
3374
|
-
|
|
3433
|
+
log18("Created file credential: %d", result.id);
|
|
3375
3434
|
return result;
|
|
3376
3435
|
}
|
|
3377
3436
|
// ===========================================================================
|
|
@@ -3389,7 +3448,7 @@ var CredService = class extends BaseSDK {
|
|
|
3389
3448
|
* @returns Promise resolving to the updated credential
|
|
3390
3449
|
*/
|
|
3391
3450
|
async update(id, data, options) {
|
|
3392
|
-
|
|
3451
|
+
log18("Updating credential: %d", id);
|
|
3393
3452
|
const result = await this.request(`/v1/user/creds/${id}`, {
|
|
3394
3453
|
body: JSON.stringify(data),
|
|
3395
3454
|
headers: {
|
|
@@ -3398,7 +3457,77 @@ var CredService = class extends BaseSDK {
|
|
|
3398
3457
|
method: "PATCH",
|
|
3399
3458
|
...options
|
|
3400
3459
|
});
|
|
3401
|
-
|
|
3460
|
+
log18("Updated credential: %d", result.id);
|
|
3461
|
+
return result;
|
|
3462
|
+
}
|
|
3463
|
+
// ===========================================================================
|
|
3464
|
+
// Share Operations
|
|
3465
|
+
// ===========================================================================
|
|
3466
|
+
/**
|
|
3467
|
+
* Shares one of the caller's own credentials with an organization
|
|
3468
|
+
*
|
|
3469
|
+
* The caller must own the credential and be a member of the target
|
|
3470
|
+
* organization. The credential stays owned by the caller. Defaults to
|
|
3471
|
+
* `visibility: 'public'` (immediately visible to the org); pass
|
|
3472
|
+
* `visibility: 'private'` to only link it as a draft, then call
|
|
3473
|
+
* `publish()` later to reveal it. Requires authentication.
|
|
3474
|
+
*
|
|
3475
|
+
* @param id - The credential ID to share
|
|
3476
|
+
* @param data - The target organization (and optional draft visibility)
|
|
3477
|
+
* @param options - Optional request options
|
|
3478
|
+
* @returns Promise resolving to the updated credential
|
|
3479
|
+
*/
|
|
3480
|
+
async share(id, data, options) {
|
|
3481
|
+
log18("Sharing credential %d with org %s", id, data.orgId);
|
|
3482
|
+
const result = await this.request(`/v1/user/creds/${id}/share`, {
|
|
3483
|
+
body: JSON.stringify(data),
|
|
3484
|
+
headers: {
|
|
3485
|
+
"Content-Type": "application/json"
|
|
3486
|
+
},
|
|
3487
|
+
method: "POST",
|
|
3488
|
+
...options
|
|
3489
|
+
});
|
|
3490
|
+
log18("Shared credential: %d", result.id);
|
|
3491
|
+
return result;
|
|
3492
|
+
}
|
|
3493
|
+
/**
|
|
3494
|
+
* Publishes a draft-linked credential to its organization
|
|
3495
|
+
*
|
|
3496
|
+
* Use after calling `share()` with `visibility: 'private'` to make the
|
|
3497
|
+
* credential visible to the rest of the organization. Owner-only.
|
|
3498
|
+
* Requires authentication.
|
|
3499
|
+
*
|
|
3500
|
+
* @param id - The credential ID to publish
|
|
3501
|
+
* @param options - Optional request options
|
|
3502
|
+
* @returns Promise resolving to the updated credential
|
|
3503
|
+
*/
|
|
3504
|
+
async publish(id, options) {
|
|
3505
|
+
log18("Publishing credential: %d", id);
|
|
3506
|
+
const result = await this.request(`/v1/user/creds/${id}/publish`, {
|
|
3507
|
+
method: "POST",
|
|
3508
|
+
...options
|
|
3509
|
+
});
|
|
3510
|
+
log18("Published credential: %d", result.id);
|
|
3511
|
+
return result;
|
|
3512
|
+
}
|
|
3513
|
+
/**
|
|
3514
|
+
* Unshares a credential from its organization
|
|
3515
|
+
*
|
|
3516
|
+
* Flips the credential back to private without deleting it. Callable by
|
|
3517
|
+
* the credential's owner, or by an admin of the organization it's shared
|
|
3518
|
+
* to. Requires authentication.
|
|
3519
|
+
*
|
|
3520
|
+
* @param id - The credential ID to unshare
|
|
3521
|
+
* @param options - Optional request options
|
|
3522
|
+
* @returns Promise resolving to the updated credential
|
|
3523
|
+
*/
|
|
3524
|
+
async unshare(id, options) {
|
|
3525
|
+
log18("Unsharing credential: %d", id);
|
|
3526
|
+
const result = await this.request(`/v1/user/creds/${id}/unshare`, {
|
|
3527
|
+
method: "POST",
|
|
3528
|
+
...options
|
|
3529
|
+
});
|
|
3530
|
+
log18("Unshared credential: %d", result.id);
|
|
3402
3531
|
return result;
|
|
3403
3532
|
}
|
|
3404
3533
|
// ===========================================================================
|
|
@@ -3414,12 +3543,12 @@ var CredService = class extends BaseSDK {
|
|
|
3414
3543
|
* @returns Promise resolving to the delete result
|
|
3415
3544
|
*/
|
|
3416
3545
|
async delete(id, options) {
|
|
3417
|
-
|
|
3546
|
+
log18("Deleting credential by ID: %d", id);
|
|
3418
3547
|
const result = await this.request(`/v1/user/creds/${id}`, {
|
|
3419
3548
|
method: "DELETE",
|
|
3420
3549
|
...options
|
|
3421
3550
|
});
|
|
3422
|
-
|
|
3551
|
+
log18("Deleted credential: %d, success=%s", id, result.success);
|
|
3423
3552
|
return result;
|
|
3424
3553
|
}
|
|
3425
3554
|
/**
|
|
@@ -3433,7 +3562,7 @@ var CredService = class extends BaseSDK {
|
|
|
3433
3562
|
* @returns Promise resolving to the delete result
|
|
3434
3563
|
*/
|
|
3435
3564
|
async deleteByKey(key, options) {
|
|
3436
|
-
|
|
3565
|
+
log18("Deleting credential by key: %s", key);
|
|
3437
3566
|
const result = await this.request(
|
|
3438
3567
|
`/v1/user/creds/key/${encodeURIComponent(key)}`,
|
|
3439
3568
|
{
|
|
@@ -3441,7 +3570,7 @@ var CredService = class extends BaseSDK {
|
|
|
3441
3570
|
...options
|
|
3442
3571
|
}
|
|
3443
3572
|
);
|
|
3444
|
-
|
|
3573
|
+
log18("Deleted credential by key: %s, success=%s", key, result.success);
|
|
3445
3574
|
return result;
|
|
3446
3575
|
}
|
|
3447
3576
|
// ===========================================================================
|
|
@@ -3460,12 +3589,12 @@ var CredService = class extends BaseSDK {
|
|
|
3460
3589
|
* @returns Promise resolving to the credential status list
|
|
3461
3590
|
*/
|
|
3462
3591
|
async getSkillCredStatus(skillIdentifier, options) {
|
|
3463
|
-
|
|
3592
|
+
log18("Getting skill cred status: %s", skillIdentifier);
|
|
3464
3593
|
const result = await this.request(
|
|
3465
3594
|
`/v1/skills/${encodeURIComponent(skillIdentifier)}/creds/status`,
|
|
3466
3595
|
options
|
|
3467
3596
|
);
|
|
3468
|
-
|
|
3597
|
+
log18("Skill %s has %d credential requirements", skillIdentifier, result.length);
|
|
3469
3598
|
return result;
|
|
3470
3599
|
}
|
|
3471
3600
|
// ===========================================================================
|
|
@@ -3504,7 +3633,7 @@ var CredService = class extends BaseSDK {
|
|
|
3504
3633
|
*/
|
|
3505
3634
|
async inject(request, options) {
|
|
3506
3635
|
var _a, _b, _c, _d;
|
|
3507
|
-
|
|
3636
|
+
log18("Injecting credentials by keys: %O (sandbox=%s)", request.keys, request.sandbox);
|
|
3508
3637
|
const result = await this.request(
|
|
3509
3638
|
"/v1/plugins/run-buildin-tools/inject-creds",
|
|
3510
3639
|
{
|
|
@@ -3516,7 +3645,7 @@ var CredService = class extends BaseSDK {
|
|
|
3516
3645
|
...options
|
|
3517
3646
|
}
|
|
3518
3647
|
);
|
|
3519
|
-
|
|
3648
|
+
log18(
|
|
3520
3649
|
"Inject result: success=%s, env=%d, files=%d, notFound=%d",
|
|
3521
3650
|
result.success,
|
|
3522
3651
|
Object.keys(((_a = result.credentials) == null ? void 0 : _a.env) || {}).length,
|
|
@@ -3558,7 +3687,7 @@ var CredService = class extends BaseSDK {
|
|
|
3558
3687
|
*/
|
|
3559
3688
|
async injectForSkill(request, options) {
|
|
3560
3689
|
var _a, _b, _c, _d;
|
|
3561
|
-
|
|
3690
|
+
log18(
|
|
3562
3691
|
"Injecting credentials for skill: %s (sandbox=%s)",
|
|
3563
3692
|
request.skillIdentifier,
|
|
3564
3693
|
request.sandbox
|
|
@@ -3574,7 +3703,7 @@ var CredService = class extends BaseSDK {
|
|
|
3574
3703
|
...options
|
|
3575
3704
|
}
|
|
3576
3705
|
);
|
|
3577
|
-
|
|
3706
|
+
log18(
|
|
3578
3707
|
"Inject result: success=%s, env=%d, files=%d, missing=%d",
|
|
3579
3708
|
result.success,
|
|
3580
3709
|
Object.keys(((_a = result.credentials) == null ? void 0 : _a.env) || {}).length,
|
|
@@ -3586,9 +3715,9 @@ var CredService = class extends BaseSDK {
|
|
|
3586
3715
|
};
|
|
3587
3716
|
|
|
3588
3717
|
// src/market/services/DiscoveryService.ts
|
|
3589
|
-
import
|
|
3718
|
+
import debug19 from "debug";
|
|
3590
3719
|
import urlJoin4 from "url-join";
|
|
3591
|
-
var
|
|
3720
|
+
var log19 = debug19("lobe-market-sdk:discovery");
|
|
3592
3721
|
var DiscoveryService = class extends BaseSDK {
|
|
3593
3722
|
/**
|
|
3594
3723
|
* Retrieves the service discovery document
|
|
@@ -3600,9 +3729,9 @@ var DiscoveryService = class extends BaseSDK {
|
|
|
3600
3729
|
* @returns Promise resolving to the service discovery document
|
|
3601
3730
|
*/
|
|
3602
3731
|
async getDiscoveryDocument() {
|
|
3603
|
-
|
|
3732
|
+
log19("Fetching discovery document");
|
|
3604
3733
|
if (this.discoveryDoc) {
|
|
3605
|
-
|
|
3734
|
+
log19("Returning cached discovery document");
|
|
3606
3735
|
return this.discoveryDoc;
|
|
3607
3736
|
}
|
|
3608
3737
|
const res = await fetch(urlJoin4(this.baseUrl, "/.well-known/discovery"));
|
|
@@ -3610,14 +3739,14 @@ var DiscoveryService = class extends BaseSDK {
|
|
|
3610
3739
|
throw new Error(await res.text());
|
|
3611
3740
|
}
|
|
3612
3741
|
this.discoveryDoc = await res.json();
|
|
3613
|
-
|
|
3742
|
+
log19("Discovery document successfully fetched");
|
|
3614
3743
|
return this.discoveryDoc;
|
|
3615
3744
|
}
|
|
3616
3745
|
};
|
|
3617
3746
|
|
|
3618
3747
|
// src/market/services/FeedbackService.ts
|
|
3619
|
-
import
|
|
3620
|
-
var
|
|
3748
|
+
import debug20 from "debug";
|
|
3749
|
+
var log20 = debug20("lobe-market-sdk:feedback");
|
|
3621
3750
|
var FeedbackService = class extends BaseSDK {
|
|
3622
3751
|
/**
|
|
3623
3752
|
* Submits user feedback
|
|
@@ -3647,7 +3776,7 @@ var FeedbackService = class extends BaseSDK {
|
|
|
3647
3776
|
* ```
|
|
3648
3777
|
*/
|
|
3649
3778
|
async submitFeedback(data, options) {
|
|
3650
|
-
|
|
3779
|
+
log20("Submitting feedback: %s", data.title);
|
|
3651
3780
|
const result = await this.request("/v1/user/feedback", {
|
|
3652
3781
|
body: JSON.stringify(data),
|
|
3653
3782
|
headers: {
|
|
@@ -3656,14 +3785,14 @@ var FeedbackService = class extends BaseSDK {
|
|
|
3656
3785
|
method: "POST",
|
|
3657
3786
|
...options
|
|
3658
3787
|
});
|
|
3659
|
-
|
|
3788
|
+
log20("Feedback submitted successfully: %s", result.issueId);
|
|
3660
3789
|
return result;
|
|
3661
3790
|
}
|
|
3662
3791
|
};
|
|
3663
3792
|
|
|
3664
3793
|
// src/market/services/PluginsService.ts
|
|
3665
|
-
import
|
|
3666
|
-
var
|
|
3794
|
+
import debug21 from "debug";
|
|
3795
|
+
var log21 = debug21("lobe-market-sdk:plugins");
|
|
3667
3796
|
var PluginsService = class extends BaseSDK {
|
|
3668
3797
|
/**
|
|
3669
3798
|
* Retrieves a list of plugins from the marketplace
|
|
@@ -3678,9 +3807,9 @@ var PluginsService = class extends BaseSDK {
|
|
|
3678
3807
|
const locale = params.locale || this.defaultLocale;
|
|
3679
3808
|
const queryParams = { ...params, locale };
|
|
3680
3809
|
const queryString = this.buildQueryString(queryParams);
|
|
3681
|
-
|
|
3810
|
+
log21("Getting plugin list: %O", queryParams);
|
|
3682
3811
|
const result = await this.request(`/v1/plugins${queryString}`, options);
|
|
3683
|
-
|
|
3812
|
+
log21("Retrieved %d plugins", result.items.length);
|
|
3684
3813
|
return result;
|
|
3685
3814
|
}
|
|
3686
3815
|
/**
|
|
@@ -3698,12 +3827,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
3698
3827
|
const locale = params.locale || this.defaultLocale;
|
|
3699
3828
|
const queryParams = { ...params, locale };
|
|
3700
3829
|
const queryString = this.buildQueryString(queryParams);
|
|
3701
|
-
|
|
3830
|
+
log21("Getting plugin categories: %O", queryParams);
|
|
3702
3831
|
const result = await this.request(
|
|
3703
3832
|
`/v1/plugins/categories${queryString}`,
|
|
3704
3833
|
options
|
|
3705
3834
|
);
|
|
3706
|
-
|
|
3835
|
+
log21("Retrieved %d categories", result.length);
|
|
3707
3836
|
return result;
|
|
3708
3837
|
}
|
|
3709
3838
|
/**
|
|
@@ -3717,12 +3846,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
3717
3846
|
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
3718
3847
|
*/
|
|
3719
3848
|
async getPublishedIdentifiers(options) {
|
|
3720
|
-
|
|
3849
|
+
log21("Getting published plugin identifiers");
|
|
3721
3850
|
const result = await this.request(
|
|
3722
3851
|
"/v1/plugins/identifiers",
|
|
3723
3852
|
options
|
|
3724
3853
|
);
|
|
3725
|
-
|
|
3854
|
+
log21("Retrieved %d published plugin identifiers", result.length);
|
|
3726
3855
|
return result;
|
|
3727
3856
|
}
|
|
3728
3857
|
/**
|
|
@@ -3733,12 +3862,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
3733
3862
|
*/
|
|
3734
3863
|
async getSitemap(params = {}, options) {
|
|
3735
3864
|
const queryString = this.buildQueryString(params);
|
|
3736
|
-
|
|
3865
|
+
log21("Getting plugin sitemap%s", queryString);
|
|
3737
3866
|
const result = await this.request(
|
|
3738
3867
|
`/v1/plugins/sitemap${queryString}`,
|
|
3739
3868
|
options
|
|
3740
3869
|
);
|
|
3741
|
-
|
|
3870
|
+
log21(
|
|
3742
3871
|
"Retrieved plugin sitemap page %d/%d (%d items)",
|
|
3743
3872
|
result.currentPage,
|
|
3744
3873
|
result.totalPages,
|
|
@@ -3763,7 +3892,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3763
3892
|
version,
|
|
3764
3893
|
identifier
|
|
3765
3894
|
}, options) {
|
|
3766
|
-
|
|
3895
|
+
log21("Getting plugin manifest: %O", { identifier, locale, version });
|
|
3767
3896
|
const localeParam = locale || this.defaultLocale;
|
|
3768
3897
|
const params = { locale: localeParam };
|
|
3769
3898
|
if (version) {
|
|
@@ -3774,7 +3903,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3774
3903
|
`/v1/plugins/${identifier}/manifest${queryString}`,
|
|
3775
3904
|
options
|
|
3776
3905
|
);
|
|
3777
|
-
|
|
3906
|
+
log21("Plugin manifest successfully retrieved: %s", identifier);
|
|
3778
3907
|
return manifest;
|
|
3779
3908
|
}
|
|
3780
3909
|
/**
|
|
@@ -3791,7 +3920,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3791
3920
|
version,
|
|
3792
3921
|
identifier
|
|
3793
3922
|
}, options) {
|
|
3794
|
-
|
|
3923
|
+
log21("Getting plugin detail: %O", { identifier, locale, version });
|
|
3795
3924
|
const localeParam = locale || this.defaultLocale;
|
|
3796
3925
|
const params = { locale: localeParam };
|
|
3797
3926
|
if (version) {
|
|
@@ -3802,7 +3931,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3802
3931
|
`/v1/plugins/${identifier}${queryString}`,
|
|
3803
3932
|
options
|
|
3804
3933
|
);
|
|
3805
|
-
|
|
3934
|
+
log21("Plugin manifest successfully retrieved: %s", identifier);
|
|
3806
3935
|
return manifest;
|
|
3807
3936
|
}
|
|
3808
3937
|
/**
|
|
@@ -3817,7 +3946,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3817
3946
|
*
|
|
3818
3947
|
*/
|
|
3819
3948
|
async reportInstallation(reportData) {
|
|
3820
|
-
|
|
3949
|
+
log21("Reporting installation for %s@%s", reportData.identifier, reportData.version);
|
|
3821
3950
|
const result = await this.request("/v1/plugins/report/installation", {
|
|
3822
3951
|
body: JSON.stringify(reportData),
|
|
3823
3952
|
headers: {
|
|
@@ -3825,7 +3954,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3825
3954
|
},
|
|
3826
3955
|
method: "POST"
|
|
3827
3956
|
});
|
|
3828
|
-
|
|
3957
|
+
log21("Installation report submitted successfully: %O", result);
|
|
3829
3958
|
return result;
|
|
3830
3959
|
}
|
|
3831
3960
|
/**
|
|
@@ -3839,7 +3968,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3839
3968
|
* @returns Promise resolving to the report submission response
|
|
3840
3969
|
*/
|
|
3841
3970
|
async reportCall(reportData) {
|
|
3842
|
-
|
|
3971
|
+
log21(
|
|
3843
3972
|
"Reporting call for %s@%s - %s:%s",
|
|
3844
3973
|
reportData.identifier,
|
|
3845
3974
|
reportData.version,
|
|
@@ -3853,7 +3982,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3853
3982
|
},
|
|
3854
3983
|
method: "POST"
|
|
3855
3984
|
});
|
|
3856
|
-
|
|
3985
|
+
log21("Call report submitted successfully: %O", result);
|
|
3857
3986
|
return result;
|
|
3858
3987
|
}
|
|
3859
3988
|
/**
|
|
@@ -3865,7 +3994,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3865
3994
|
* @param options - Optional request init overrides
|
|
3866
3995
|
*/
|
|
3867
3996
|
async createEvent(eventData, options) {
|
|
3868
|
-
|
|
3997
|
+
log21("Recording plugin event: %s for %s", eventData.event, eventData.identifier);
|
|
3869
3998
|
await this.request("/v1/plugins/events", {
|
|
3870
3999
|
body: JSON.stringify(eventData),
|
|
3871
4000
|
headers: {
|
|
@@ -3895,7 +4024,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3895
4024
|
* ```
|
|
3896
4025
|
*/
|
|
3897
4026
|
async callCloudGateway(request, options) {
|
|
3898
|
-
|
|
4027
|
+
log21("Calling cloud gateway for plugin %s, tool %s", request.identifier, request.toolName);
|
|
3899
4028
|
const result = await this.request("/v1/plugins/cloud-gateway", {
|
|
3900
4029
|
body: JSON.stringify(request),
|
|
3901
4030
|
headers: {
|
|
@@ -3904,7 +4033,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3904
4033
|
method: "POST",
|
|
3905
4034
|
...options
|
|
3906
4035
|
});
|
|
3907
|
-
|
|
4036
|
+
log21("Cloud gateway call completed: %O", {
|
|
3908
4037
|
identifier: request.identifier,
|
|
3909
4038
|
isError: result.isError,
|
|
3910
4039
|
toolName: request.toolName
|
|
@@ -3945,7 +4074,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3945
4074
|
* ```
|
|
3946
4075
|
*/
|
|
3947
4076
|
async runBuildInTool(toolName, params, context, options) {
|
|
3948
|
-
|
|
4077
|
+
log21(
|
|
3949
4078
|
"Running built-in tool: %s for user %s, topic %s",
|
|
3950
4079
|
toolName,
|
|
3951
4080
|
context.userId,
|
|
@@ -3964,7 +4093,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3964
4093
|
method: "POST",
|
|
3965
4094
|
...options
|
|
3966
4095
|
});
|
|
3967
|
-
|
|
4096
|
+
log21("Built-in tool execution completed: %O", {
|
|
3968
4097
|
success: result.success,
|
|
3969
4098
|
toolName
|
|
3970
4099
|
});
|
|
@@ -4077,7 +4206,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4077
4206
|
* @returns Promise resolving to the submitted score
|
|
4078
4207
|
*/
|
|
4079
4208
|
async submitRating(identifier, score, options) {
|
|
4080
|
-
|
|
4209
|
+
log21("Submitting rating for plugin %s: %d", identifier, score);
|
|
4081
4210
|
const result = await this.request(
|
|
4082
4211
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings`,
|
|
4083
4212
|
{
|
|
@@ -4086,7 +4215,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4086
4215
|
method: "POST"
|
|
4087
4216
|
}
|
|
4088
4217
|
);
|
|
4089
|
-
|
|
4218
|
+
log21("Rating submitted for plugin %s: %d", identifier, result.score);
|
|
4090
4219
|
return result;
|
|
4091
4220
|
}
|
|
4092
4221
|
/**
|
|
@@ -4097,7 +4226,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4097
4226
|
* @returns Promise resolving to success status
|
|
4098
4227
|
*/
|
|
4099
4228
|
async deleteRating(identifier, options) {
|
|
4100
|
-
|
|
4229
|
+
log21("Deleting rating for plugin %s", identifier);
|
|
4101
4230
|
const result = await this.request(
|
|
4102
4231
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings`,
|
|
4103
4232
|
{
|
|
@@ -4105,7 +4234,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4105
4234
|
method: "DELETE"
|
|
4106
4235
|
}
|
|
4107
4236
|
);
|
|
4108
|
-
|
|
4237
|
+
log21("Rating deleted for plugin %s", identifier);
|
|
4109
4238
|
return result;
|
|
4110
4239
|
}
|
|
4111
4240
|
/**
|
|
@@ -4116,12 +4245,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
4116
4245
|
* @returns Promise resolving to the rating distribution
|
|
4117
4246
|
*/
|
|
4118
4247
|
async getRatingDistribution(identifier, options) {
|
|
4119
|
-
|
|
4248
|
+
log21("Getting rating distribution for plugin: %s", identifier);
|
|
4120
4249
|
const result = await this.request(
|
|
4121
4250
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings/distribution`,
|
|
4122
4251
|
options
|
|
4123
4252
|
);
|
|
4124
|
-
|
|
4253
|
+
log21("Rating distribution retrieved for plugin %s: %d total", identifier, result.totalCount);
|
|
4125
4254
|
return result;
|
|
4126
4255
|
}
|
|
4127
4256
|
// ============================================================================
|
|
@@ -4137,12 +4266,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
4137
4266
|
*/
|
|
4138
4267
|
async getComments(identifier, params = {}, options) {
|
|
4139
4268
|
const queryString = this.buildQueryString(params);
|
|
4140
|
-
|
|
4269
|
+
log21("Getting comments for plugin %s: %O", identifier, params);
|
|
4141
4270
|
const result = await this.request(
|
|
4142
4271
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments${queryString}`,
|
|
4143
4272
|
options
|
|
4144
4273
|
);
|
|
4145
|
-
|
|
4274
|
+
log21(
|
|
4146
4275
|
"Retrieved %d comments for plugin %s (page %d/%d)",
|
|
4147
4276
|
result.items.length,
|
|
4148
4277
|
identifier,
|
|
@@ -4159,15 +4288,15 @@ var PluginsService = class extends BaseSDK {
|
|
|
4159
4288
|
* @returns Promise resolving to the latest own comment or null when none exists
|
|
4160
4289
|
*/
|
|
4161
4290
|
async getLatestOwnComment(identifier, options) {
|
|
4162
|
-
|
|
4291
|
+
log21("Getting latest own comment for plugin %s", identifier);
|
|
4163
4292
|
const result = await this.request(
|
|
4164
4293
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments/latest`,
|
|
4165
4294
|
options
|
|
4166
4295
|
);
|
|
4167
4296
|
if (result) {
|
|
4168
|
-
|
|
4297
|
+
log21("Retrieved latest own comment for plugin %s: id=%d", identifier, result.id);
|
|
4169
4298
|
} else {
|
|
4170
|
-
|
|
4299
|
+
log21("No own comments found for plugin %s", identifier);
|
|
4171
4300
|
}
|
|
4172
4301
|
return result;
|
|
4173
4302
|
}
|
|
@@ -4180,7 +4309,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4180
4309
|
* @returns Promise resolving to the created comment (with optional rating field)
|
|
4181
4310
|
*/
|
|
4182
4311
|
async createComment(identifier, data, options) {
|
|
4183
|
-
|
|
4312
|
+
log21("Creating comment on plugin %s", identifier);
|
|
4184
4313
|
const result = await this.request(
|
|
4185
4314
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments`,
|
|
4186
4315
|
{
|
|
@@ -4189,7 +4318,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4189
4318
|
method: "POST"
|
|
4190
4319
|
}
|
|
4191
4320
|
);
|
|
4192
|
-
|
|
4321
|
+
log21("Comment created on plugin %s: id=%d", identifier, result.id);
|
|
4193
4322
|
return result;
|
|
4194
4323
|
}
|
|
4195
4324
|
/**
|
|
@@ -4201,7 +4330,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4201
4330
|
* @returns Promise resolving to success status
|
|
4202
4331
|
*/
|
|
4203
4332
|
async deleteComment(identifier, commentId, options) {
|
|
4204
|
-
|
|
4333
|
+
log21("Deleting comment %d from plugin %s", commentId, identifier);
|
|
4205
4334
|
const result = await this.request(
|
|
4206
4335
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments/${commentId}`,
|
|
4207
4336
|
{
|
|
@@ -4209,7 +4338,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4209
4338
|
method: "DELETE"
|
|
4210
4339
|
}
|
|
4211
4340
|
);
|
|
4212
|
-
|
|
4341
|
+
log21("Comment %d deleted from plugin %s", commentId, identifier);
|
|
4213
4342
|
return result;
|
|
4214
4343
|
}
|
|
4215
4344
|
// ============================================================================
|
|
@@ -4224,7 +4353,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4224
4353
|
* @returns Promise resolving to the created reaction
|
|
4225
4354
|
*/
|
|
4226
4355
|
async addReaction(commentId, type, options) {
|
|
4227
|
-
|
|
4356
|
+
log21("Adding %s reaction to comment %d", type, commentId);
|
|
4228
4357
|
const result = await this.request(
|
|
4229
4358
|
`/v1/plugins/comments/${commentId}/reactions`,
|
|
4230
4359
|
{
|
|
@@ -4233,7 +4362,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4233
4362
|
method: "POST"
|
|
4234
4363
|
}
|
|
4235
4364
|
);
|
|
4236
|
-
|
|
4365
|
+
log21("Reaction added to comment %d: %s (id=%d)", commentId, result.type, result.id);
|
|
4237
4366
|
return result;
|
|
4238
4367
|
}
|
|
4239
4368
|
/**
|
|
@@ -4244,7 +4373,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4244
4373
|
* @returns Promise resolving to success status
|
|
4245
4374
|
*/
|
|
4246
4375
|
async removeReaction(commentId, options) {
|
|
4247
|
-
|
|
4376
|
+
log21("Removing reaction from comment %d", commentId);
|
|
4248
4377
|
const result = await this.request(
|
|
4249
4378
|
`/v1/plugins/comments/${commentId}/reactions`,
|
|
4250
4379
|
{
|
|
@@ -4252,14 +4381,14 @@ var PluginsService = class extends BaseSDK {
|
|
|
4252
4381
|
method: "DELETE"
|
|
4253
4382
|
}
|
|
4254
4383
|
);
|
|
4255
|
-
|
|
4384
|
+
log21("Reaction removed from comment %d", commentId);
|
|
4256
4385
|
return result;
|
|
4257
4386
|
}
|
|
4258
4387
|
};
|
|
4259
4388
|
|
|
4260
4389
|
// src/market/services/SkillService.ts
|
|
4261
|
-
import
|
|
4262
|
-
var
|
|
4390
|
+
import debug22 from "debug";
|
|
4391
|
+
var log22 = debug22("lobe-market-sdk:skill");
|
|
4263
4392
|
var SkillService = class extends BaseSDK {
|
|
4264
4393
|
/**
|
|
4265
4394
|
* Lists all available skill providers
|
|
@@ -4272,9 +4401,9 @@ var SkillService = class extends BaseSDK {
|
|
|
4272
4401
|
*/
|
|
4273
4402
|
async listProviders(options) {
|
|
4274
4403
|
var _a;
|
|
4275
|
-
|
|
4404
|
+
log22("Listing skill providers");
|
|
4276
4405
|
const result = await this.request("/v1/skill/providers", options);
|
|
4277
|
-
|
|
4406
|
+
log22("Found %d skill providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
4278
4407
|
return result;
|
|
4279
4408
|
}
|
|
4280
4409
|
/**
|
|
@@ -4289,12 +4418,12 @@ var SkillService = class extends BaseSDK {
|
|
|
4289
4418
|
*/
|
|
4290
4419
|
async listTools(provider, options) {
|
|
4291
4420
|
var _a;
|
|
4292
|
-
|
|
4421
|
+
log22("Listing tools for provider: %s", provider);
|
|
4293
4422
|
const result = await this.request(
|
|
4294
4423
|
`/v1/skill/${encodeURIComponent(provider)}/tools`,
|
|
4295
4424
|
options
|
|
4296
4425
|
);
|
|
4297
|
-
|
|
4426
|
+
log22("Found %d tools for provider %s", ((_a = result.tools) == null ? void 0 : _a.length) || 0, provider);
|
|
4298
4427
|
return result;
|
|
4299
4428
|
}
|
|
4300
4429
|
/**
|
|
@@ -4311,12 +4440,12 @@ var SkillService = class extends BaseSDK {
|
|
|
4311
4440
|
*/
|
|
4312
4441
|
async listLiveTools(provider, options) {
|
|
4313
4442
|
var _a;
|
|
4314
|
-
|
|
4443
|
+
log22("Listing live tools for provider: %s", provider);
|
|
4315
4444
|
const result = await this.request(
|
|
4316
4445
|
`/v1/skill/${encodeURIComponent(provider)}/tools/live`,
|
|
4317
4446
|
options
|
|
4318
4447
|
);
|
|
4319
|
-
|
|
4448
|
+
log22("Found %d live tools for provider %s", ((_a = result.tools) == null ? void 0 : _a.length) || 0, provider);
|
|
4320
4449
|
return result;
|
|
4321
4450
|
}
|
|
4322
4451
|
/**
|
|
@@ -4332,12 +4461,12 @@ var SkillService = class extends BaseSDK {
|
|
|
4332
4461
|
*/
|
|
4333
4462
|
async getTool(provider, toolName, options) {
|
|
4334
4463
|
var _a;
|
|
4335
|
-
|
|
4464
|
+
log22("Getting tool %s from provider %s", toolName, provider);
|
|
4336
4465
|
const result = await this.request(
|
|
4337
4466
|
`/v1/skill/${encodeURIComponent(provider)}/tool/${encodeURIComponent(toolName)}`,
|
|
4338
4467
|
options
|
|
4339
4468
|
);
|
|
4340
|
-
|
|
4469
|
+
log22("Retrieved tool: %s", (_a = result.tool) == null ? void 0 : _a.name);
|
|
4341
4470
|
return result;
|
|
4342
4471
|
}
|
|
4343
4472
|
/**
|
|
@@ -4351,12 +4480,12 @@ var SkillService = class extends BaseSDK {
|
|
|
4351
4480
|
* @returns Promise resolving to the connection status
|
|
4352
4481
|
*/
|
|
4353
4482
|
async getStatus(provider, options) {
|
|
4354
|
-
|
|
4483
|
+
log22("Getting status for provider: %s", provider);
|
|
4355
4484
|
const result = await this.request(
|
|
4356
4485
|
`/v1/skill/${encodeURIComponent(provider)}/status`,
|
|
4357
4486
|
options
|
|
4358
4487
|
);
|
|
4359
|
-
|
|
4488
|
+
log22("Provider %s status: connected=%s", provider, result.connected);
|
|
4360
4489
|
return result;
|
|
4361
4490
|
}
|
|
4362
4491
|
/**
|
|
@@ -4384,7 +4513,7 @@ var SkillService = class extends BaseSDK {
|
|
|
4384
4513
|
* ```
|
|
4385
4514
|
*/
|
|
4386
4515
|
async callTool(provider, params, options) {
|
|
4387
|
-
|
|
4516
|
+
log22("Calling tool %s on provider %s", params.tool, provider);
|
|
4388
4517
|
const { args, tool, ...rest } = params;
|
|
4389
4518
|
const result = await this.request(
|
|
4390
4519
|
`/v1/skill/${encodeURIComponent(provider)}/call`,
|
|
@@ -4401,14 +4530,14 @@ var SkillService = class extends BaseSDK {
|
|
|
4401
4530
|
...options
|
|
4402
4531
|
}
|
|
4403
4532
|
);
|
|
4404
|
-
|
|
4533
|
+
log22("Tool %s call completed: success=%s", params.tool, result.success);
|
|
4405
4534
|
return result;
|
|
4406
4535
|
}
|
|
4407
4536
|
};
|
|
4408
4537
|
|
|
4409
4538
|
// src/market/services/MarketTaskTemplateService.ts
|
|
4410
|
-
import
|
|
4411
|
-
var
|
|
4539
|
+
import debug23 from "debug";
|
|
4540
|
+
var log23 = debug23("lobe-market-sdk:task-templates");
|
|
4412
4541
|
var MarketTaskTemplateService = class extends BaseSDK {
|
|
4413
4542
|
/**
|
|
4414
4543
|
* Retrieves personalized task template recommendations.
|
|
@@ -4431,7 +4560,7 @@ var MarketTaskTemplateService = class extends BaseSDK {
|
|
|
4431
4560
|
refreshSeed: params.refreshSeed,
|
|
4432
4561
|
seedKey: params.seedKey
|
|
4433
4562
|
};
|
|
4434
|
-
|
|
4563
|
+
log23("Getting task template recommendations: %O", body);
|
|
4435
4564
|
const result = await this.request(
|
|
4436
4565
|
"/v1/task-templates/recommendations",
|
|
4437
4566
|
{
|
|
@@ -4440,14 +4569,14 @@ var MarketTaskTemplateService = class extends BaseSDK {
|
|
|
4440
4569
|
method: "POST"
|
|
4441
4570
|
}
|
|
4442
4571
|
);
|
|
4443
|
-
|
|
4572
|
+
log23("Retrieved %d task template recommendations", result.items.length);
|
|
4444
4573
|
return result;
|
|
4445
4574
|
}
|
|
4446
4575
|
};
|
|
4447
4576
|
|
|
4448
4577
|
// src/market/services/MarketSkillCollectionService.ts
|
|
4449
|
-
import
|
|
4450
|
-
var
|
|
4578
|
+
import debug24 from "debug";
|
|
4579
|
+
var log24 = debug24("lobe-market-sdk:skill-collections");
|
|
4451
4580
|
var MarketSkillCollectionService = class extends BaseSDK {
|
|
4452
4581
|
async getSkillCollectionDetail(slug, params = {}, options) {
|
|
4453
4582
|
const locale = params.locale || this.defaultLocale;
|
|
@@ -4456,12 +4585,12 @@ var MarketSkillCollectionService = class extends BaseSDK {
|
|
|
4456
4585
|
locale
|
|
4457
4586
|
};
|
|
4458
4587
|
const queryString = this.buildQueryString(queryParams);
|
|
4459
|
-
|
|
4588
|
+
log24("Getting skill collection detail: %s %O", slug, queryParams);
|
|
4460
4589
|
const result = await this.request(
|
|
4461
4590
|
`/v1/skills/collections/${encodeURIComponent(slug)}${queryString}`,
|
|
4462
4591
|
options
|
|
4463
4592
|
);
|
|
4464
|
-
|
|
4593
|
+
log24("Skill collection detail retrieved: %s (%d items)", slug, result.items.length);
|
|
4465
4594
|
return result;
|
|
4466
4595
|
}
|
|
4467
4596
|
async getSkillCollections(params = {}, options) {
|
|
@@ -4471,19 +4600,19 @@ var MarketSkillCollectionService = class extends BaseSDK {
|
|
|
4471
4600
|
locale
|
|
4472
4601
|
};
|
|
4473
4602
|
const queryString = this.buildQueryString(queryParams);
|
|
4474
|
-
|
|
4603
|
+
log24("Getting skill collections: %O", queryParams);
|
|
4475
4604
|
const result = await this.request(
|
|
4476
4605
|
`/v1/skills/collections${queryString}`,
|
|
4477
4606
|
options
|
|
4478
4607
|
);
|
|
4479
|
-
|
|
4608
|
+
log24("Retrieved %d skill collections", result.length);
|
|
4480
4609
|
return result;
|
|
4481
4610
|
}
|
|
4482
4611
|
};
|
|
4483
4612
|
|
|
4484
4613
|
// src/market/services/MarketSkillService.ts
|
|
4485
|
-
import
|
|
4486
|
-
var
|
|
4614
|
+
import debug25 from "debug";
|
|
4615
|
+
var log25 = debug25("lobe-market-sdk:market-skills");
|
|
4487
4616
|
var MarketSkillService = class extends BaseSDK {
|
|
4488
4617
|
/**
|
|
4489
4618
|
* Retrieves a list of skills from the marketplace
|
|
@@ -4516,9 +4645,9 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4516
4645
|
const locale = params.locale || this.defaultLocale;
|
|
4517
4646
|
const queryParams = { ...params, locale };
|
|
4518
4647
|
const queryString = this.buildQueryString(queryParams);
|
|
4519
|
-
|
|
4648
|
+
log25("Getting skill list: %O", queryParams);
|
|
4520
4649
|
const result = await this.request(`/v1/skills${queryString}`, options);
|
|
4521
|
-
|
|
4650
|
+
log25(
|
|
4522
4651
|
"Retrieved %d skills (page %d/%d)",
|
|
4523
4652
|
result.items.length,
|
|
4524
4653
|
result.currentPage,
|
|
@@ -4557,12 +4686,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4557
4686
|
queryParams.version = params.version;
|
|
4558
4687
|
}
|
|
4559
4688
|
const queryString = this.buildQueryString(queryParams);
|
|
4560
|
-
|
|
4689
|
+
log25("Getting skill detail: %s %O", identifier, params);
|
|
4561
4690
|
const result = await this.request(
|
|
4562
4691
|
`/v1/skills/${encodeURIComponent(identifier)}${queryString}`,
|
|
4563
4692
|
options
|
|
4564
4693
|
);
|
|
4565
|
-
|
|
4694
|
+
log25("Skill detail retrieved: %s (v%s)", identifier, result.version);
|
|
4566
4695
|
return result;
|
|
4567
4696
|
}
|
|
4568
4697
|
/**
|
|
@@ -4593,7 +4722,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4593
4722
|
if (version) {
|
|
4594
4723
|
url += `?version=${encodeURIComponent(version)}`;
|
|
4595
4724
|
}
|
|
4596
|
-
|
|
4725
|
+
log25("Generated download URL: %s", url);
|
|
4597
4726
|
return url;
|
|
4598
4727
|
}
|
|
4599
4728
|
/**
|
|
@@ -4617,7 +4746,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4617
4746
|
* ```
|
|
4618
4747
|
*/
|
|
4619
4748
|
async downloadSkill(identifier, version, options) {
|
|
4620
|
-
|
|
4749
|
+
log25("Downloading skill: %s (version: %s)", identifier, version || "latest");
|
|
4621
4750
|
const queryParams = {};
|
|
4622
4751
|
if (version) {
|
|
4623
4752
|
queryParams.version = version;
|
|
@@ -4633,7 +4762,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4633
4762
|
});
|
|
4634
4763
|
if (!response.ok) {
|
|
4635
4764
|
const errorText = await response.text();
|
|
4636
|
-
|
|
4765
|
+
log25("Download failed: %s %s", response.status, errorText);
|
|
4637
4766
|
throw new Error(`Failed to download skill: ${response.statusText}`);
|
|
4638
4767
|
}
|
|
4639
4768
|
const contentDisposition = response.headers.get("content-disposition");
|
|
@@ -4645,7 +4774,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4645
4774
|
}
|
|
4646
4775
|
}
|
|
4647
4776
|
const buffer = await response.arrayBuffer();
|
|
4648
|
-
|
|
4777
|
+
log25("Downloaded skill: %s (%d bytes)", filename, buffer.byteLength);
|
|
4649
4778
|
return { buffer, filename };
|
|
4650
4779
|
}
|
|
4651
4780
|
/**
|
|
@@ -4673,12 +4802,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4673
4802
|
const locale = params.locale || this.defaultLocale;
|
|
4674
4803
|
const queryParams = { ...params, locale };
|
|
4675
4804
|
const queryString = this.buildQueryString(queryParams);
|
|
4676
|
-
|
|
4805
|
+
log25("Getting skill categories: %O", queryParams);
|
|
4677
4806
|
const result = await this.request(
|
|
4678
4807
|
`/v1/skills/categories${queryString}`,
|
|
4679
4808
|
options
|
|
4680
4809
|
);
|
|
4681
|
-
|
|
4810
|
+
log25("Retrieved %d categories", result.length);
|
|
4682
4811
|
return result;
|
|
4683
4812
|
}
|
|
4684
4813
|
/**
|
|
@@ -4693,12 +4822,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4693
4822
|
* @returns Promise resolving to an array of identifiers with last modified times
|
|
4694
4823
|
*/
|
|
4695
4824
|
async getPublishedIdentifiers(options) {
|
|
4696
|
-
|
|
4825
|
+
log25("Getting published skill identifiers");
|
|
4697
4826
|
const result = await this.request(
|
|
4698
4827
|
"/v1/skills/identifiers",
|
|
4699
4828
|
options
|
|
4700
4829
|
);
|
|
4701
|
-
|
|
4830
|
+
log25("Retrieved %d published skill identifiers", result.length);
|
|
4702
4831
|
return result;
|
|
4703
4832
|
}
|
|
4704
4833
|
/**
|
|
@@ -4709,9 +4838,9 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4709
4838
|
*/
|
|
4710
4839
|
async getSitemap(params = {}, options) {
|
|
4711
4840
|
const queryString = this.buildQueryString(params);
|
|
4712
|
-
|
|
4841
|
+
log25("Getting skill sitemap%s", queryString);
|
|
4713
4842
|
const result = await this.request(`/v1/skills/sitemap${queryString}`, options);
|
|
4714
|
-
|
|
4843
|
+
log25(
|
|
4715
4844
|
"Retrieved skill sitemap page %d/%d (%d items)",
|
|
4716
4845
|
result.currentPage,
|
|
4717
4846
|
result.totalPages,
|
|
@@ -4727,13 +4856,13 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4727
4856
|
* @returns Promise resolving to true if skill exists, false otherwise
|
|
4728
4857
|
*/
|
|
4729
4858
|
async checkSkillExists(identifier, options) {
|
|
4730
|
-
|
|
4859
|
+
log25("Checking if skill exists: %s", identifier);
|
|
4731
4860
|
try {
|
|
4732
4861
|
await this.getSkillDetail(identifier, {}, options);
|
|
4733
|
-
|
|
4862
|
+
log25("Skill exists: %s", identifier);
|
|
4734
4863
|
return true;
|
|
4735
4864
|
} catch (e) {
|
|
4736
|
-
|
|
4865
|
+
log25("Skill does not exist: %s", identifier);
|
|
4737
4866
|
return false;
|
|
4738
4867
|
}
|
|
4739
4868
|
}
|
|
@@ -4754,12 +4883,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4754
4883
|
* ```
|
|
4755
4884
|
*/
|
|
4756
4885
|
async getSkillVersions(identifier, options) {
|
|
4757
|
-
|
|
4886
|
+
log25("Getting skill versions: %s", identifier);
|
|
4758
4887
|
const result = await this.request(
|
|
4759
4888
|
`/v1/skills/${encodeURIComponent(identifier)}/versions`,
|
|
4760
4889
|
options
|
|
4761
4890
|
);
|
|
4762
|
-
|
|
4891
|
+
log25("Retrieved %d versions for skill %s", result.data.length, identifier);
|
|
4763
4892
|
return result.data;
|
|
4764
4893
|
}
|
|
4765
4894
|
/**
|
|
@@ -4783,12 +4912,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4783
4912
|
const locale = params.locale || this.defaultLocale;
|
|
4784
4913
|
const queryParams = { locale };
|
|
4785
4914
|
const queryString = this.buildQueryString(queryParams);
|
|
4786
|
-
|
|
4915
|
+
log25("Getting skill version: %s@%s", identifier, version);
|
|
4787
4916
|
const result = await this.request(
|
|
4788
4917
|
`/v1/skills/${encodeURIComponent(identifier)}/versions/${encodeURIComponent(version)}${queryString}`,
|
|
4789
4918
|
options
|
|
4790
4919
|
);
|
|
4791
|
-
|
|
4920
|
+
log25("Skill version detail retrieved: %s@%s", identifier, version);
|
|
4792
4921
|
return result;
|
|
4793
4922
|
}
|
|
4794
4923
|
/**
|
|
@@ -4817,13 +4946,13 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4817
4946
|
* ```
|
|
4818
4947
|
*/
|
|
4819
4948
|
async reportGitHubSkill(params, options) {
|
|
4820
|
-
|
|
4949
|
+
log25("Reporting GitHub skill: %s", params.gitUrl);
|
|
4821
4950
|
const result = await this.request("/v1/skills/report/github", {
|
|
4822
4951
|
...options,
|
|
4823
4952
|
body: JSON.stringify(params),
|
|
4824
4953
|
method: "POST"
|
|
4825
4954
|
});
|
|
4826
|
-
|
|
4955
|
+
log25("GitHub skill reported: %s (status: %s)", result.identifier, result.status);
|
|
4827
4956
|
return result;
|
|
4828
4957
|
}
|
|
4829
4958
|
/**
|
|
@@ -4848,7 +4977,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4848
4977
|
* ```
|
|
4849
4978
|
*/
|
|
4850
4979
|
async reportSkillInstall(params, options) {
|
|
4851
|
-
|
|
4980
|
+
log25("Reporting skill install: %s (success: %s)", params.identifier, params.success);
|
|
4852
4981
|
const result = await this.request(
|
|
4853
4982
|
"/v1/skills/report/installation",
|
|
4854
4983
|
{
|
|
@@ -4857,7 +4986,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4857
4986
|
method: "POST"
|
|
4858
4987
|
}
|
|
4859
4988
|
);
|
|
4860
|
-
|
|
4989
|
+
log25("Skill install reported: %s", result.message);
|
|
4861
4990
|
return result;
|
|
4862
4991
|
}
|
|
4863
4992
|
/**
|
|
@@ -4869,7 +4998,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4869
4998
|
* @returns Promise resolving to the submitted score
|
|
4870
4999
|
*/
|
|
4871
5000
|
async submitRating(identifier, score, options) {
|
|
4872
|
-
|
|
5001
|
+
log25("Submitting rating for skill %s: %d", identifier, score);
|
|
4873
5002
|
const result = await this.request(
|
|
4874
5003
|
`/v1/skills/${encodeURIComponent(identifier)}/ratings`,
|
|
4875
5004
|
{
|
|
@@ -4878,7 +5007,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4878
5007
|
method: "POST"
|
|
4879
5008
|
}
|
|
4880
5009
|
);
|
|
4881
|
-
|
|
5010
|
+
log25("Rating submitted for skill %s: %d", identifier, result.score);
|
|
4882
5011
|
return result;
|
|
4883
5012
|
}
|
|
4884
5013
|
/**
|
|
@@ -4889,12 +5018,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4889
5018
|
* @returns Promise resolving to the rating distribution
|
|
4890
5019
|
*/
|
|
4891
5020
|
async getRatingDistribution(identifier, options) {
|
|
4892
|
-
|
|
5021
|
+
log25("Getting rating distribution for skill: %s", identifier);
|
|
4893
5022
|
const result = await this.request(
|
|
4894
5023
|
`/v1/skills/${encodeURIComponent(identifier)}/ratings/distribution`,
|
|
4895
5024
|
options
|
|
4896
5025
|
);
|
|
4897
|
-
|
|
5026
|
+
log25("Rating distribution retrieved for skill %s: %d total", identifier, result.totalCount);
|
|
4898
5027
|
return result;
|
|
4899
5028
|
}
|
|
4900
5029
|
/**
|
|
@@ -4907,12 +5036,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4907
5036
|
*/
|
|
4908
5037
|
async getComments(identifier, params = {}, options) {
|
|
4909
5038
|
const queryString = this.buildQueryString(params);
|
|
4910
|
-
|
|
5039
|
+
log25("Getting comments for skill %s: %O", identifier, params);
|
|
4911
5040
|
const result = await this.request(
|
|
4912
5041
|
`/v1/skills/${encodeURIComponent(identifier)}/comments${queryString}`,
|
|
4913
5042
|
options
|
|
4914
5043
|
);
|
|
4915
|
-
|
|
5044
|
+
log25(
|
|
4916
5045
|
"Retrieved %d comments for skill %s (page %d/%d)",
|
|
4917
5046
|
result.items.length,
|
|
4918
5047
|
identifier,
|
|
@@ -4929,15 +5058,15 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4929
5058
|
* @returns Promise resolving to the latest own comment or null when none exists
|
|
4930
5059
|
*/
|
|
4931
5060
|
async getLatestOwnComment(identifier, options) {
|
|
4932
|
-
|
|
5061
|
+
log25("Getting latest own comment for skill %s", identifier);
|
|
4933
5062
|
const result = await this.request(
|
|
4934
5063
|
`/v1/skills/${encodeURIComponent(identifier)}/comments/latest`,
|
|
4935
5064
|
options
|
|
4936
5065
|
);
|
|
4937
5066
|
if (result) {
|
|
4938
|
-
|
|
5067
|
+
log25("Retrieved latest own comment for skill %s: id=%d", identifier, result.id);
|
|
4939
5068
|
} else {
|
|
4940
|
-
|
|
5069
|
+
log25("No own comments found for skill %s", identifier);
|
|
4941
5070
|
}
|
|
4942
5071
|
return result;
|
|
4943
5072
|
}
|
|
@@ -4950,7 +5079,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4950
5079
|
* @returns Promise resolving to the created comment (with optional rating field)
|
|
4951
5080
|
*/
|
|
4952
5081
|
async createComment(identifier, data, options) {
|
|
4953
|
-
|
|
5082
|
+
log25("Creating comment on skill %s", identifier);
|
|
4954
5083
|
const result = await this.request(
|
|
4955
5084
|
`/v1/skills/${encodeURIComponent(identifier)}/comments`,
|
|
4956
5085
|
{
|
|
@@ -4959,7 +5088,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4959
5088
|
method: "POST"
|
|
4960
5089
|
}
|
|
4961
5090
|
);
|
|
4962
|
-
|
|
5091
|
+
log25("Comment created on skill %s: id=%d", identifier, result.id);
|
|
4963
5092
|
return result;
|
|
4964
5093
|
}
|
|
4965
5094
|
/**
|
|
@@ -4971,7 +5100,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4971
5100
|
* @returns Promise resolving to success status
|
|
4972
5101
|
*/
|
|
4973
5102
|
async deleteComment(identifier, commentId, options) {
|
|
4974
|
-
|
|
5103
|
+
log25("Deleting comment %d from skill %s", commentId, identifier);
|
|
4975
5104
|
const result = await this.request(
|
|
4976
5105
|
`/v1/skills/${encodeURIComponent(identifier)}/comments/${commentId}`,
|
|
4977
5106
|
{
|
|
@@ -4979,7 +5108,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4979
5108
|
method: "DELETE"
|
|
4980
5109
|
}
|
|
4981
5110
|
);
|
|
4982
|
-
|
|
5111
|
+
log25("Comment %d deleted from skill %s", commentId, identifier);
|
|
4983
5112
|
return result;
|
|
4984
5113
|
}
|
|
4985
5114
|
/**
|
|
@@ -4991,7 +5120,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4991
5120
|
* @returns Promise resolving to the created reaction
|
|
4992
5121
|
*/
|
|
4993
5122
|
async addReaction(commentId, type, options) {
|
|
4994
|
-
|
|
5123
|
+
log25("Adding %s reaction to comment %d", type, commentId);
|
|
4995
5124
|
const result = await this.request(
|
|
4996
5125
|
`/v1/skills/comments/${commentId}/reactions`,
|
|
4997
5126
|
{
|
|
@@ -5000,7 +5129,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5000
5129
|
method: "POST"
|
|
5001
5130
|
}
|
|
5002
5131
|
);
|
|
5003
|
-
|
|
5132
|
+
log25("Reaction added to comment %d: %s (id=%d)", commentId, result.type, result.id);
|
|
5004
5133
|
return result;
|
|
5005
5134
|
}
|
|
5006
5135
|
/**
|
|
@@ -5011,7 +5140,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5011
5140
|
* @returns Promise resolving to success status
|
|
5012
5141
|
*/
|
|
5013
5142
|
async removeReaction(commentId, options) {
|
|
5014
|
-
|
|
5143
|
+
log25("Removing reaction from comment %d", commentId);
|
|
5015
5144
|
const result = await this.request(
|
|
5016
5145
|
`/v1/skills/comments/${commentId}/reactions`,
|
|
5017
5146
|
{
|
|
@@ -5019,19 +5148,19 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5019
5148
|
method: "DELETE"
|
|
5020
5149
|
}
|
|
5021
5150
|
);
|
|
5022
|
-
|
|
5151
|
+
log25("Reaction removed from comment %d", commentId);
|
|
5023
5152
|
return result;
|
|
5024
5153
|
}
|
|
5025
5154
|
};
|
|
5026
5155
|
|
|
5027
5156
|
// src/market/services/OrganizationCredsService.ts
|
|
5028
|
-
import
|
|
5157
|
+
import debug26 from "debug";
|
|
5029
5158
|
|
|
5030
5159
|
// src/utils/orgRef.ts
|
|
5031
5160
|
var orgRefToPathSegment = (ref) => typeof ref === "number" ? String(ref) : `workspace:${encodeURIComponent(ref.workspaceId)}`;
|
|
5032
5161
|
|
|
5033
5162
|
// src/market/services/OrganizationCredsService.ts
|
|
5034
|
-
var
|
|
5163
|
+
var log26 = debug26("lobe-market-sdk:org-creds");
|
|
5035
5164
|
var OrganizationCredsService = class extends BaseSDK {
|
|
5036
5165
|
constructor(orgId, options = {}, sharedHeaders, sharedTokenState) {
|
|
5037
5166
|
super(options, sharedHeaders, sharedTokenState);
|
|
@@ -5054,28 +5183,40 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5054
5183
|
// ===========================================================================
|
|
5055
5184
|
// Read
|
|
5056
5185
|
// ===========================================================================
|
|
5186
|
+
/**
|
|
5187
|
+
* Lists every credential visible in this organization's context: the
|
|
5188
|
+
* org's own directly-owned credentials, any member's published
|
|
5189
|
+
* credentials, and the caller's own draft-linked (not yet published)
|
|
5190
|
+
* credentials. Each entry's `ownerAccountId`/`ownerType`/
|
|
5191
|
+
* `ownerDisplayName`/`ownerNamespace` identify who it actually belongs to.
|
|
5192
|
+
*/
|
|
5057
5193
|
async list(options) {
|
|
5058
5194
|
var _a;
|
|
5059
|
-
|
|
5195
|
+
log26("Listing org %s credentials", this.orgSegment);
|
|
5060
5196
|
const result = await this.request(this.base(), options);
|
|
5061
|
-
|
|
5197
|
+
log26("Found %d credentials for org %s", ((_a = result.data) == null ? void 0 : _a.length) || 0, this.orgSegment);
|
|
5062
5198
|
return result;
|
|
5063
5199
|
}
|
|
5200
|
+
/**
|
|
5201
|
+
* `decrypt: true` only works for credentials the organization owns
|
|
5202
|
+
* directly — a member's shared credential can only be decrypted by its
|
|
5203
|
+
* owner via `CredService.get(id, { decrypt: true })`.
|
|
5204
|
+
*/
|
|
5064
5205
|
async get(id, getOptions, options) {
|
|
5065
|
-
|
|
5206
|
+
log26("Getting org %s credential %d (decrypt=%s)", this.orgSegment, id, getOptions == null ? void 0 : getOptions.decrypt);
|
|
5066
5207
|
const queryString = this.buildQueryString((getOptions == null ? void 0 : getOptions.decrypt) ? { decrypt: "true" } : {});
|
|
5067
5208
|
const result = await this.request(
|
|
5068
5209
|
`${this.base()}/${id}${queryString}`,
|
|
5069
5210
|
options
|
|
5070
5211
|
);
|
|
5071
|
-
|
|
5212
|
+
log26("Retrieved org credential: %s", result.key);
|
|
5072
5213
|
return result;
|
|
5073
5214
|
}
|
|
5074
5215
|
// ===========================================================================
|
|
5075
5216
|
// Create
|
|
5076
5217
|
// ===========================================================================
|
|
5077
5218
|
async createKV(data, options) {
|
|
5078
|
-
|
|
5219
|
+
log26("Creating org %s KV credential: %s (type=%s)", this.orgSegment, data.key, data.type);
|
|
5079
5220
|
return this.request(`${this.base()}/kv`, {
|
|
5080
5221
|
body: JSON.stringify(data),
|
|
5081
5222
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5084,7 +5225,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5084
5225
|
});
|
|
5085
5226
|
}
|
|
5086
5227
|
async createOAuth(data, options) {
|
|
5087
|
-
|
|
5228
|
+
log26("Creating org %s OAuth credential: %s", this.orgSegment, data.key);
|
|
5088
5229
|
return this.request(`${this.base()}/oauth`, {
|
|
5089
5230
|
body: JSON.stringify(data),
|
|
5090
5231
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5093,7 +5234,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5093
5234
|
});
|
|
5094
5235
|
}
|
|
5095
5236
|
async createFile(data, options) {
|
|
5096
|
-
|
|
5237
|
+
log26("Creating org %s file credential: %s", this.orgSegment, data.key);
|
|
5097
5238
|
return this.request(`${this.base()}/file`, {
|
|
5098
5239
|
body: JSON.stringify(data),
|
|
5099
5240
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5105,7 +5246,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5105
5246
|
// Update
|
|
5106
5247
|
// ===========================================================================
|
|
5107
5248
|
async update(id, data, options) {
|
|
5108
|
-
|
|
5249
|
+
log26("Updating org %s credential %d", this.orgSegment, id);
|
|
5109
5250
|
return this.request(`${this.base()}/${id}`, {
|
|
5110
5251
|
body: JSON.stringify(data),
|
|
5111
5252
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5117,14 +5258,14 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5117
5258
|
// Delete
|
|
5118
5259
|
// ===========================================================================
|
|
5119
5260
|
async delete(id, options) {
|
|
5120
|
-
|
|
5261
|
+
log26("Deleting org %s credential %d", this.orgSegment, id);
|
|
5121
5262
|
return this.request(`${this.base()}/${id}`, {
|
|
5122
5263
|
method: "DELETE",
|
|
5123
5264
|
...options
|
|
5124
5265
|
});
|
|
5125
5266
|
}
|
|
5126
5267
|
async deleteByKey(key, options) {
|
|
5127
|
-
|
|
5268
|
+
log26("Deleting org %s credential by key: %s", this.orgSegment, key);
|
|
5128
5269
|
return this.request(`${this.base()}/key/${encodeURIComponent(key)}`, {
|
|
5129
5270
|
method: "DELETE",
|
|
5130
5271
|
...options
|
|
@@ -5138,7 +5279,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5138
5279
|
* the org has bound vs. is missing. Reads only; any org member may call.
|
|
5139
5280
|
*/
|
|
5140
5281
|
async getSkillCredStatus(skillIdentifier, options) {
|
|
5141
|
-
|
|
5282
|
+
log26("Getting org %s skill cred status: %s", this.orgSegment, skillIdentifier);
|
|
5142
5283
|
const path = `/v1/organizations/${this.orgSegment}/skills/${encodeURIComponent(skillIdentifier)}/creds/status`;
|
|
5143
5284
|
const result = await this.request(
|
|
5144
5285
|
path,
|
|
@@ -5149,8 +5290,8 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5149
5290
|
};
|
|
5150
5291
|
|
|
5151
5292
|
// src/market/services/OrganizationService.ts
|
|
5152
|
-
import
|
|
5153
|
-
var
|
|
5293
|
+
import debug27 from "debug";
|
|
5294
|
+
var log27 = debug27("lobe-market-sdk:organization");
|
|
5154
5295
|
var OrganizationService2 = class extends BaseSDK {
|
|
5155
5296
|
constructor(options = {}, sharedHeaders, sharedTokenState) {
|
|
5156
5297
|
super(options, sharedHeaders, sharedTokenState);
|
|
@@ -5198,12 +5339,12 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5198
5339
|
async getOrganizationInfo(idOrNamespace, params = {}, options) {
|
|
5199
5340
|
const locale = params.locale || this.defaultLocale;
|
|
5200
5341
|
const queryString = this.buildQueryString({ locale });
|
|
5201
|
-
|
|
5342
|
+
log27("Getting organization info: %O", { idOrNamespace, ...params });
|
|
5202
5343
|
const result = await this.request(
|
|
5203
5344
|
`/v1/organizations/info/${idOrNamespace}${queryString}`,
|
|
5204
5345
|
options
|
|
5205
5346
|
);
|
|
5206
|
-
|
|
5347
|
+
log27("Organization info retrieved for: %s", idOrNamespace);
|
|
5207
5348
|
return result;
|
|
5208
5349
|
}
|
|
5209
5350
|
/**
|
|
@@ -5213,7 +5354,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5213
5354
|
* @returns Promise resolving to the user's organizations
|
|
5214
5355
|
*/
|
|
5215
5356
|
async listMyOrganizations(options) {
|
|
5216
|
-
|
|
5357
|
+
log27("Listing organizations for current user");
|
|
5217
5358
|
const result = await this.request(
|
|
5218
5359
|
"/v1/organizations/me",
|
|
5219
5360
|
options
|
|
@@ -5231,7 +5372,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5231
5372
|
* @returns The created/existing organization and whether it was newly created
|
|
5232
5373
|
*/
|
|
5233
5374
|
async createOrganization(data, options) {
|
|
5234
|
-
|
|
5375
|
+
log27("Creating organization: %s", data.clerkId);
|
|
5235
5376
|
return this.request("/v1/organizations", {
|
|
5236
5377
|
...options,
|
|
5237
5378
|
body: JSON.stringify(data),
|
|
@@ -5246,7 +5387,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5246
5387
|
* @returns The updated organization
|
|
5247
5388
|
*/
|
|
5248
5389
|
async updateOrganization(orgId, data, options) {
|
|
5249
|
-
|
|
5390
|
+
log27("Updating organization %d: %O", orgId, data);
|
|
5250
5391
|
const result = await this.request(
|
|
5251
5392
|
`/v1/organizations/${orgRefToPathSegment(orgId)}`,
|
|
5252
5393
|
{
|
|
@@ -5265,7 +5406,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5265
5406
|
* @returns The archived organization
|
|
5266
5407
|
*/
|
|
5267
5408
|
async archiveOrganization(orgId, options) {
|
|
5268
|
-
|
|
5409
|
+
log27("Archiving organization %d", orgId);
|
|
5269
5410
|
const result = await this.request(
|
|
5270
5411
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/archive`,
|
|
5271
5412
|
{ ...options, method: "POST" }
|
|
@@ -5279,7 +5420,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5279
5420
|
* @returns The reactivated organization
|
|
5280
5421
|
*/
|
|
5281
5422
|
async unarchiveOrganization(orgId, options) {
|
|
5282
|
-
|
|
5423
|
+
log27("Unarchiving organization %d", orgId);
|
|
5283
5424
|
const result = await this.request(
|
|
5284
5425
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/unarchive`,
|
|
5285
5426
|
{ ...options, method: "POST" }
|
|
@@ -5293,7 +5434,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5293
5434
|
* @returns Hydrated member rows
|
|
5294
5435
|
*/
|
|
5295
5436
|
async listMembers(orgId, options) {
|
|
5296
|
-
|
|
5437
|
+
log27("Listing members of organization %d", orgId);
|
|
5297
5438
|
const result = await this.request(
|
|
5298
5439
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
5299
5440
|
options
|
|
@@ -5310,7 +5451,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5310
5451
|
* @returns Whether the member was newly added and their effective role
|
|
5311
5452
|
*/
|
|
5312
5453
|
async addMember(orgId, userAccountId, role, options) {
|
|
5313
|
-
|
|
5454
|
+
log27("Adding member %d to organization %d (role=%s)", userAccountId, orgId, role);
|
|
5314
5455
|
return this.request(
|
|
5315
5456
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
5316
5457
|
{
|
|
@@ -5329,7 +5470,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5329
5470
|
* @returns Whether a membership row was removed
|
|
5330
5471
|
*/
|
|
5331
5472
|
async removeMember(orgId, userAccountId, options) {
|
|
5332
|
-
|
|
5473
|
+
log27("Removing member %d from organization %d", userAccountId, orgId);
|
|
5333
5474
|
return this.request(
|
|
5334
5475
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members/${userAccountId}`,
|
|
5335
5476
|
{ ...options, method: "DELETE" }
|
|
@@ -5345,7 +5486,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5345
5486
|
* @returns The effective role and whether it changed
|
|
5346
5487
|
*/
|
|
5347
5488
|
async updateMemberRole(orgId, userAccountId, role, options) {
|
|
5348
|
-
|
|
5489
|
+
log27("Updating member %d role to %s in organization %d", userAccountId, role, orgId);
|
|
5349
5490
|
return this.request(
|
|
5350
5491
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members/${userAccountId}`,
|
|
5351
5492
|
{ ...options, body: JSON.stringify({ role }), method: "PATCH" }
|
|
@@ -5363,7 +5504,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5363
5504
|
* @returns Counts of added / removed / updated members and skipped ids
|
|
5364
5505
|
*/
|
|
5365
5506
|
async reconcileMembers(orgId, members, options) {
|
|
5366
|
-
|
|
5507
|
+
log27("Reconciling %d members for organization %d", members.length, orgId);
|
|
5367
5508
|
return this.request(
|
|
5368
5509
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
5369
5510
|
{
|
|
@@ -5376,8 +5517,8 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5376
5517
|
};
|
|
5377
5518
|
|
|
5378
5519
|
// src/market/services/UserService.ts
|
|
5379
|
-
import
|
|
5380
|
-
var
|
|
5520
|
+
import debug28 from "debug";
|
|
5521
|
+
var log28 = debug28("lobe-market-sdk:user");
|
|
5381
5522
|
var UserService = class extends BaseSDK {
|
|
5382
5523
|
/**
|
|
5383
5524
|
* Retrieves user information by account ID or userName
|
|
@@ -5394,12 +5535,12 @@ var UserService = class extends BaseSDK {
|
|
|
5394
5535
|
const locale = params.locale || this.defaultLocale;
|
|
5395
5536
|
const queryParams = { locale };
|
|
5396
5537
|
const queryString = this.buildQueryString(queryParams);
|
|
5397
|
-
|
|
5538
|
+
log28("Getting user info: %O", { idOrUserName, ...params });
|
|
5398
5539
|
const result = await this.request(
|
|
5399
5540
|
`/v1/user/info/${idOrUserName}${queryString}`,
|
|
5400
5541
|
options
|
|
5401
5542
|
);
|
|
5402
|
-
|
|
5543
|
+
log28("User info successfully retrieved for: %s", idOrUserName);
|
|
5403
5544
|
return result;
|
|
5404
5545
|
}
|
|
5405
5546
|
/**
|
|
@@ -5414,7 +5555,7 @@ var UserService = class extends BaseSDK {
|
|
|
5414
5555
|
* @throws Error if userName is already taken or update fails
|
|
5415
5556
|
*/
|
|
5416
5557
|
async updateUserInfo(data, options) {
|
|
5417
|
-
|
|
5558
|
+
log28("Updating user info: %O", data);
|
|
5418
5559
|
const result = await this.request("/v1/user/update", {
|
|
5419
5560
|
body: JSON.stringify(data),
|
|
5420
5561
|
headers: {
|
|
@@ -5423,7 +5564,7 @@ var UserService = class extends BaseSDK {
|
|
|
5423
5564
|
method: "POST",
|
|
5424
5565
|
...options
|
|
5425
5566
|
});
|
|
5426
|
-
|
|
5567
|
+
log28("User info updated successfully");
|
|
5427
5568
|
return result;
|
|
5428
5569
|
}
|
|
5429
5570
|
/**
|
|
@@ -5453,7 +5594,7 @@ var UserService = class extends BaseSDK {
|
|
|
5453
5594
|
* ```
|
|
5454
5595
|
*/
|
|
5455
5596
|
async register(data, options) {
|
|
5456
|
-
|
|
5597
|
+
log28("Registering user: %O", {
|
|
5457
5598
|
followUserId: data.followUserId,
|
|
5458
5599
|
registerUserId: data.registerUserId
|
|
5459
5600
|
});
|
|
@@ -5465,14 +5606,14 @@ var UserService = class extends BaseSDK {
|
|
|
5465
5606
|
method: "POST",
|
|
5466
5607
|
...options
|
|
5467
5608
|
});
|
|
5468
|
-
|
|
5609
|
+
log28("User registered successfully: created=%s, userId=%s", result.created, result.user.clerkId);
|
|
5469
5610
|
return result;
|
|
5470
5611
|
}
|
|
5471
5612
|
};
|
|
5472
5613
|
|
|
5473
5614
|
// src/market/services/UserFollowService.ts
|
|
5474
|
-
import
|
|
5475
|
-
var
|
|
5615
|
+
import debug29 from "debug";
|
|
5616
|
+
var log29 = debug29("lobe-market-sdk:user-follow");
|
|
5476
5617
|
var UserFollowService = class extends BaseSDK {
|
|
5477
5618
|
/**
|
|
5478
5619
|
* Follow a user
|
|
@@ -5486,7 +5627,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5486
5627
|
* @throws Error if already following or cannot follow yourself
|
|
5487
5628
|
*/
|
|
5488
5629
|
async follow(followingId, options) {
|
|
5489
|
-
|
|
5630
|
+
log29("Following user: %d", followingId);
|
|
5490
5631
|
const body = { followingId };
|
|
5491
5632
|
const result = await this.request("/v1/user/follows", {
|
|
5492
5633
|
body: JSON.stringify(body),
|
|
@@ -5496,7 +5637,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5496
5637
|
method: "POST",
|
|
5497
5638
|
...options
|
|
5498
5639
|
});
|
|
5499
|
-
|
|
5640
|
+
log29("Successfully followed user: %d", followingId);
|
|
5500
5641
|
return result;
|
|
5501
5642
|
}
|
|
5502
5643
|
/**
|
|
@@ -5511,7 +5652,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5511
5652
|
* @throws Error if follow relationship not found
|
|
5512
5653
|
*/
|
|
5513
5654
|
async unfollow(followingId, options) {
|
|
5514
|
-
|
|
5655
|
+
log29("Unfollowing user: %d", followingId);
|
|
5515
5656
|
const body = { followingId };
|
|
5516
5657
|
const result = await this.request("/v1/user/follows", {
|
|
5517
5658
|
body: JSON.stringify(body),
|
|
@@ -5521,7 +5662,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5521
5662
|
method: "DELETE",
|
|
5522
5663
|
...options
|
|
5523
5664
|
});
|
|
5524
|
-
|
|
5665
|
+
log29("Successfully unfollowed user: %d", followingId);
|
|
5525
5666
|
return result;
|
|
5526
5667
|
}
|
|
5527
5668
|
/**
|
|
@@ -5535,13 +5676,13 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5535
5676
|
* @returns Promise resolving to follow status (isFollowing, isMutual)
|
|
5536
5677
|
*/
|
|
5537
5678
|
async checkFollowStatus(targetUserId, options) {
|
|
5538
|
-
|
|
5679
|
+
log29("Checking follow status for user: %d", targetUserId);
|
|
5539
5680
|
const queryString = this.buildQueryString({ targetUserId: String(targetUserId) });
|
|
5540
5681
|
const result = await this.request(
|
|
5541
5682
|
`/v1/user/follows/check${queryString}`,
|
|
5542
5683
|
options
|
|
5543
5684
|
);
|
|
5544
|
-
|
|
5685
|
+
log29("Follow status retrieved: %O", result);
|
|
5545
5686
|
return result;
|
|
5546
5687
|
}
|
|
5547
5688
|
/**
|
|
@@ -5556,7 +5697,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5556
5697
|
* @returns Promise resolving to list of following users
|
|
5557
5698
|
*/
|
|
5558
5699
|
async getFollowing(userId, params = {}, options) {
|
|
5559
|
-
|
|
5700
|
+
log29("Getting following list for user: %d", userId);
|
|
5560
5701
|
const queryParams = {};
|
|
5561
5702
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5562
5703
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5565,7 +5706,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5565
5706
|
`/v1/user/follows/${userId}/following${queryString}`,
|
|
5566
5707
|
options
|
|
5567
5708
|
);
|
|
5568
|
-
|
|
5709
|
+
log29("Following list retrieved for user: %d", userId);
|
|
5569
5710
|
return result;
|
|
5570
5711
|
}
|
|
5571
5712
|
/**
|
|
@@ -5580,7 +5721,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5580
5721
|
* @returns Promise resolving to list of followers
|
|
5581
5722
|
*/
|
|
5582
5723
|
async getFollowers(userId, params = {}, options) {
|
|
5583
|
-
|
|
5724
|
+
log29("Getting followers list for user: %d", userId);
|
|
5584
5725
|
const queryParams = {};
|
|
5585
5726
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5586
5727
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5589,14 +5730,14 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5589
5730
|
`/v1/user/follows/${userId}/followers${queryString}`,
|
|
5590
5731
|
options
|
|
5591
5732
|
);
|
|
5592
|
-
|
|
5733
|
+
log29("Followers list retrieved for user: %d", userId);
|
|
5593
5734
|
return result;
|
|
5594
5735
|
}
|
|
5595
5736
|
};
|
|
5596
5737
|
|
|
5597
5738
|
// src/market/services/UserFavoriteService.ts
|
|
5598
|
-
import
|
|
5599
|
-
var
|
|
5739
|
+
import debug30 from "debug";
|
|
5740
|
+
var log30 = debug30("lobe-market-sdk:user-favorite");
|
|
5600
5741
|
var UserFavoriteService = class extends BaseSDK {
|
|
5601
5742
|
/**
|
|
5602
5743
|
* Add to favorites
|
|
@@ -5611,7 +5752,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5611
5752
|
* @throws Error if already in favorites
|
|
5612
5753
|
*/
|
|
5613
5754
|
async addFavorite(targetType, targetId, options) {
|
|
5614
|
-
|
|
5755
|
+
log30("Adding favorite: %s %d", targetType, targetId);
|
|
5615
5756
|
const body = { targetId, targetType };
|
|
5616
5757
|
const result = await this.request("/v1/user/favorites", {
|
|
5617
5758
|
body: JSON.stringify(body),
|
|
@@ -5621,7 +5762,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5621
5762
|
method: "POST",
|
|
5622
5763
|
...options
|
|
5623
5764
|
});
|
|
5624
|
-
|
|
5765
|
+
log30("Successfully added favorite: %s %d", targetType, targetId);
|
|
5625
5766
|
return result;
|
|
5626
5767
|
}
|
|
5627
5768
|
/**
|
|
@@ -5637,7 +5778,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5637
5778
|
* @throws Error if favorite not found
|
|
5638
5779
|
*/
|
|
5639
5780
|
async removeFavorite(targetType, targetId, options) {
|
|
5640
|
-
|
|
5781
|
+
log30("Removing favorite: %s %d", targetType, targetId);
|
|
5641
5782
|
const body = { targetId, targetType };
|
|
5642
5783
|
const result = await this.request("/v1/user/favorites", {
|
|
5643
5784
|
body: JSON.stringify(body),
|
|
@@ -5647,7 +5788,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5647
5788
|
method: "DELETE",
|
|
5648
5789
|
...options
|
|
5649
5790
|
});
|
|
5650
|
-
|
|
5791
|
+
log30("Successfully removed favorite: %s %d", targetType, targetId);
|
|
5651
5792
|
return result;
|
|
5652
5793
|
}
|
|
5653
5794
|
/**
|
|
@@ -5662,7 +5803,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5662
5803
|
* @returns Promise resolving to favorite status
|
|
5663
5804
|
*/
|
|
5664
5805
|
async checkFavorite(targetType, targetId, options) {
|
|
5665
|
-
|
|
5806
|
+
log30("Checking favorite status: %s %d", targetType, targetId);
|
|
5666
5807
|
const queryString = this.buildQueryString({
|
|
5667
5808
|
targetId: String(targetId),
|
|
5668
5809
|
targetType
|
|
@@ -5671,7 +5812,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5671
5812
|
`/v1/user/favorites/check${queryString}`,
|
|
5672
5813
|
options
|
|
5673
5814
|
);
|
|
5674
|
-
|
|
5815
|
+
log30("Favorite status retrieved: %O", result);
|
|
5675
5816
|
return result;
|
|
5676
5817
|
}
|
|
5677
5818
|
/**
|
|
@@ -5685,7 +5826,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5685
5826
|
* @returns Promise resolving to list of favorites
|
|
5686
5827
|
*/
|
|
5687
5828
|
async getMyFavorites(params = {}, options) {
|
|
5688
|
-
|
|
5829
|
+
log30("Getting my favorites: %O", params);
|
|
5689
5830
|
const queryParams = {};
|
|
5690
5831
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5691
5832
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5695,7 +5836,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5695
5836
|
`/v1/user/favorites/me${queryString}`,
|
|
5696
5837
|
options
|
|
5697
5838
|
);
|
|
5698
|
-
|
|
5839
|
+
log30("My favorites retrieved");
|
|
5699
5840
|
return result;
|
|
5700
5841
|
}
|
|
5701
5842
|
/**
|
|
@@ -5710,7 +5851,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5710
5851
|
* @returns Promise resolving to list of favorites
|
|
5711
5852
|
*/
|
|
5712
5853
|
async getUserFavorites(userId, params = {}, options) {
|
|
5713
|
-
|
|
5854
|
+
log30("Getting favorites for user: %d", userId);
|
|
5714
5855
|
const queryParams = {};
|
|
5715
5856
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5716
5857
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5720,7 +5861,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5720
5861
|
`/v1/user/favorites/${userId}${queryString}`,
|
|
5721
5862
|
options
|
|
5722
5863
|
);
|
|
5723
|
-
|
|
5864
|
+
log30("Favorites retrieved for user: %d", userId);
|
|
5724
5865
|
return result;
|
|
5725
5866
|
}
|
|
5726
5867
|
/**
|
|
@@ -5735,7 +5876,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5735
5876
|
* @returns Promise resolving to list of favorite agents
|
|
5736
5877
|
*/
|
|
5737
5878
|
async getUserFavoriteAgents(userId, params = {}, options) {
|
|
5738
|
-
|
|
5879
|
+
log30("Getting favorite agents for user: %d", userId);
|
|
5739
5880
|
const queryParams = {};
|
|
5740
5881
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5741
5882
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5744,7 +5885,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5744
5885
|
`/v1/user/favorites/${userId}/agents${queryString}`,
|
|
5745
5886
|
options
|
|
5746
5887
|
);
|
|
5747
|
-
|
|
5888
|
+
log30("Favorite agents retrieved for user: %d", userId);
|
|
5748
5889
|
return result;
|
|
5749
5890
|
}
|
|
5750
5891
|
/**
|
|
@@ -5759,7 +5900,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5759
5900
|
* @returns Promise resolving to list of favorite plugins
|
|
5760
5901
|
*/
|
|
5761
5902
|
async getUserFavoritePlugins(userId, params = {}, options) {
|
|
5762
|
-
|
|
5903
|
+
log30("Getting favorite plugins for user: %d", userId);
|
|
5763
5904
|
const queryParams = {};
|
|
5764
5905
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5765
5906
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5768,14 +5909,14 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5768
5909
|
`/v1/user/favorites/${userId}/plugins${queryString}`,
|
|
5769
5910
|
options
|
|
5770
5911
|
);
|
|
5771
|
-
|
|
5912
|
+
log30("Favorite plugins retrieved for user: %d", userId);
|
|
5772
5913
|
return result;
|
|
5773
5914
|
}
|
|
5774
5915
|
};
|
|
5775
5916
|
|
|
5776
5917
|
// src/market/services/UserLikeService.ts
|
|
5777
|
-
import
|
|
5778
|
-
var
|
|
5918
|
+
import debug31 from "debug";
|
|
5919
|
+
var log31 = debug31("lobe-market-sdk:user-like");
|
|
5779
5920
|
var UserLikeService = class extends BaseSDK {
|
|
5780
5921
|
/**
|
|
5781
5922
|
* Like content
|
|
@@ -5790,7 +5931,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5790
5931
|
* @throws Error if already liked
|
|
5791
5932
|
*/
|
|
5792
5933
|
async like(targetType, targetId, options) {
|
|
5793
|
-
|
|
5934
|
+
log31("Liking: %s %d", targetType, targetId);
|
|
5794
5935
|
const body = { targetId, targetType };
|
|
5795
5936
|
const result = await this.request("/v1/user/likes", {
|
|
5796
5937
|
body: JSON.stringify(body),
|
|
@@ -5800,7 +5941,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5800
5941
|
method: "POST",
|
|
5801
5942
|
...options
|
|
5802
5943
|
});
|
|
5803
|
-
|
|
5944
|
+
log31("Successfully liked: %s %d", targetType, targetId);
|
|
5804
5945
|
return result;
|
|
5805
5946
|
}
|
|
5806
5947
|
/**
|
|
@@ -5816,7 +5957,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5816
5957
|
* @throws Error if like not found
|
|
5817
5958
|
*/
|
|
5818
5959
|
async unlike(targetType, targetId, options) {
|
|
5819
|
-
|
|
5960
|
+
log31("Unliking: %s %d", targetType, targetId);
|
|
5820
5961
|
const body = { targetId, targetType };
|
|
5821
5962
|
const result = await this.request("/v1/user/likes", {
|
|
5822
5963
|
body: JSON.stringify(body),
|
|
@@ -5826,7 +5967,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5826
5967
|
method: "DELETE",
|
|
5827
5968
|
...options
|
|
5828
5969
|
});
|
|
5829
|
-
|
|
5970
|
+
log31("Successfully unliked: %s %d", targetType, targetId);
|
|
5830
5971
|
return result;
|
|
5831
5972
|
}
|
|
5832
5973
|
/**
|
|
@@ -5841,7 +5982,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5841
5982
|
* @returns Promise resolving to toggle response with new like status
|
|
5842
5983
|
*/
|
|
5843
5984
|
async toggleLike(targetType, targetId, options) {
|
|
5844
|
-
|
|
5985
|
+
log31("Toggling like: %s %d", targetType, targetId);
|
|
5845
5986
|
const body = { targetId, targetType };
|
|
5846
5987
|
const result = await this.request("/v1/user/likes/toggle", {
|
|
5847
5988
|
body: JSON.stringify(body),
|
|
@@ -5851,7 +5992,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5851
5992
|
method: "POST",
|
|
5852
5993
|
...options
|
|
5853
5994
|
});
|
|
5854
|
-
|
|
5995
|
+
log31("Like toggled, new status: %O", result);
|
|
5855
5996
|
return result;
|
|
5856
5997
|
}
|
|
5857
5998
|
/**
|
|
@@ -5866,7 +6007,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5866
6007
|
* @returns Promise resolving to like status
|
|
5867
6008
|
*/
|
|
5868
6009
|
async checkLike(targetType, targetId, options) {
|
|
5869
|
-
|
|
6010
|
+
log31("Checking like status: %s %d", targetType, targetId);
|
|
5870
6011
|
const queryString = this.buildQueryString({
|
|
5871
6012
|
targetId: String(targetId),
|
|
5872
6013
|
targetType
|
|
@@ -5875,7 +6016,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5875
6016
|
`/v1/user/likes/check${queryString}`,
|
|
5876
6017
|
options
|
|
5877
6018
|
);
|
|
5878
|
-
|
|
6019
|
+
log31("Like status retrieved: %O", result);
|
|
5879
6020
|
return result;
|
|
5880
6021
|
}
|
|
5881
6022
|
/**
|
|
@@ -5889,7 +6030,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5889
6030
|
* @returns Promise resolving to list of likes
|
|
5890
6031
|
*/
|
|
5891
6032
|
async getMyLikes(params = {}, options) {
|
|
5892
|
-
|
|
6033
|
+
log31("Getting my likes: %O", params);
|
|
5893
6034
|
const queryParams = {};
|
|
5894
6035
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5895
6036
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5899,7 +6040,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5899
6040
|
`/v1/user/likes/me${queryString}`,
|
|
5900
6041
|
options
|
|
5901
6042
|
);
|
|
5902
|
-
|
|
6043
|
+
log31("My likes retrieved");
|
|
5903
6044
|
return result;
|
|
5904
6045
|
}
|
|
5905
6046
|
/**
|
|
@@ -5914,7 +6055,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5914
6055
|
* @returns Promise resolving to list of likes
|
|
5915
6056
|
*/
|
|
5916
6057
|
async getUserLikes(userId, params = {}, options) {
|
|
5917
|
-
|
|
6058
|
+
log31("Getting likes for user: %d", userId);
|
|
5918
6059
|
const queryParams = {};
|
|
5919
6060
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5920
6061
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5924,7 +6065,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5924
6065
|
`/v1/user/likes/${userId}${queryString}`,
|
|
5925
6066
|
options
|
|
5926
6067
|
);
|
|
5927
|
-
|
|
6068
|
+
log31("Likes retrieved for user: %d", userId);
|
|
5928
6069
|
return result;
|
|
5929
6070
|
}
|
|
5930
6071
|
/**
|
|
@@ -5939,7 +6080,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5939
6080
|
* @returns Promise resolving to list of liked agents
|
|
5940
6081
|
*/
|
|
5941
6082
|
async getUserLikedAgents(userId, params = {}, options) {
|
|
5942
|
-
|
|
6083
|
+
log31("Getting liked agents for user: %d", userId);
|
|
5943
6084
|
const queryParams = {};
|
|
5944
6085
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5945
6086
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5948,7 +6089,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5948
6089
|
`/v1/user/likes/${userId}/agents${queryString}`,
|
|
5949
6090
|
options
|
|
5950
6091
|
);
|
|
5951
|
-
|
|
6092
|
+
log31("Liked agents retrieved for user: %d", userId);
|
|
5952
6093
|
return result;
|
|
5953
6094
|
}
|
|
5954
6095
|
/**
|
|
@@ -5963,7 +6104,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5963
6104
|
* @returns Promise resolving to list of liked plugins
|
|
5964
6105
|
*/
|
|
5965
6106
|
async getUserLikedPlugins(userId, params = {}, options) {
|
|
5966
|
-
|
|
6107
|
+
log31("Getting liked plugins for user: %d", userId);
|
|
5967
6108
|
const queryParams = {};
|
|
5968
6109
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5969
6110
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5972,14 +6113,14 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5972
6113
|
`/v1/user/likes/${userId}/plugins${queryString}`,
|
|
5973
6114
|
options
|
|
5974
6115
|
);
|
|
5975
|
-
|
|
6116
|
+
log31("Liked plugins retrieved for user: %d", userId);
|
|
5976
6117
|
return result;
|
|
5977
6118
|
}
|
|
5978
6119
|
};
|
|
5979
6120
|
|
|
5980
6121
|
// src/market/services/UserPublishService.ts
|
|
5981
|
-
import
|
|
5982
|
-
var
|
|
6122
|
+
import debug32 from "debug";
|
|
6123
|
+
var log32 = debug32("lobe-market-sdk:user-publish");
|
|
5983
6124
|
var UserPublishService = class extends BaseSDK {
|
|
5984
6125
|
/**
|
|
5985
6126
|
* Lists all plugins owned by the authenticated user
|
|
@@ -5989,9 +6130,9 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5989
6130
|
*/
|
|
5990
6131
|
async listPlugins(options) {
|
|
5991
6132
|
var _a;
|
|
5992
|
-
|
|
6133
|
+
log32("Listing user plugins");
|
|
5993
6134
|
const result = await this.request("/v1/user/plugins", options);
|
|
5994
|
-
|
|
6135
|
+
log32("Found %d user plugins", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
5995
6136
|
return result;
|
|
5996
6137
|
}
|
|
5997
6138
|
/**
|
|
@@ -6002,9 +6143,9 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6002
6143
|
*/
|
|
6003
6144
|
async listSkills(options) {
|
|
6004
6145
|
var _a;
|
|
6005
|
-
|
|
6146
|
+
log32("Listing user skills");
|
|
6006
6147
|
const result = await this.request("/v1/user/skills", options);
|
|
6007
|
-
|
|
6148
|
+
log32("Found %d user skills", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
6008
6149
|
return result;
|
|
6009
6150
|
}
|
|
6010
6151
|
/**
|
|
@@ -6016,7 +6157,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6016
6157
|
* @returns Promise resolving to the publish result
|
|
6017
6158
|
*/
|
|
6018
6159
|
async publishSkillVersion(identifier, zipBuffer, options) {
|
|
6019
|
-
|
|
6160
|
+
log32("Publishing skill version for: %s", identifier);
|
|
6020
6161
|
const formData = new FormData();
|
|
6021
6162
|
const arrayBuffer = zipBuffer instanceof ArrayBuffer ? zipBuffer : zipBuffer.buffer.slice(
|
|
6022
6163
|
zipBuffer.byteOffset,
|
|
@@ -6032,7 +6173,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6032
6173
|
...options
|
|
6033
6174
|
}
|
|
6034
6175
|
);
|
|
6035
|
-
|
|
6176
|
+
log32("Published skill version: %s@%s", identifier, result.version);
|
|
6036
6177
|
return result;
|
|
6037
6178
|
}
|
|
6038
6179
|
/**
|
|
@@ -6043,11 +6184,11 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6043
6184
|
*/
|
|
6044
6185
|
async scanClaimableAssets(assetType) {
|
|
6045
6186
|
var _a;
|
|
6046
|
-
|
|
6187
|
+
log32("Scanning claimable %s", assetType);
|
|
6047
6188
|
const result = await this.request(
|
|
6048
6189
|
`/v1/user/claims/scan/${assetType}`
|
|
6049
6190
|
);
|
|
6050
|
-
|
|
6191
|
+
log32("Found %d claimable %s", ((_a = result.data) == null ? void 0 : _a.length) || 0, assetType);
|
|
6051
6192
|
return result;
|
|
6052
6193
|
}
|
|
6053
6194
|
/**
|
|
@@ -6058,35 +6199,53 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6058
6199
|
* @returns Promise resolving to the claim result
|
|
6059
6200
|
*/
|
|
6060
6201
|
async claimAsset(assetId, assetType) {
|
|
6061
|
-
|
|
6202
|
+
log32("Claiming %s with id: %d", assetType, assetId);
|
|
6062
6203
|
const result = await this.request("/v1/user/claims", {
|
|
6063
6204
|
body: JSON.stringify({ assetId, assetType }),
|
|
6064
6205
|
headers: { "Content-Type": "application/json" },
|
|
6065
6206
|
method: "POST"
|
|
6066
6207
|
});
|
|
6067
|
-
|
|
6208
|
+
log32("Claim result for %s %d: %s", assetType, assetId, result.success);
|
|
6068
6209
|
return result;
|
|
6069
6210
|
}
|
|
6070
6211
|
/**
|
|
6071
|
-
* Submits a GitHub repository
|
|
6072
|
-
*
|
|
6212
|
+
* Submits a GitHub repository the authenticated user owns or can push to for
|
|
6213
|
+
* import as a new skill listing
|
|
6073
6214
|
*
|
|
6074
6215
|
* The import runs asynchronously on the server. The user must have a verified
|
|
6075
|
-
* GitHub profile
|
|
6216
|
+
* GitHub profile. Organization repositories require push or admin access.
|
|
6076
6217
|
*
|
|
6077
6218
|
* @param params - The repository submission parameters
|
|
6078
6219
|
* @param options - Optional request options (must include authentication)
|
|
6079
6220
|
* @returns Promise resolving to the submission result
|
|
6080
6221
|
*/
|
|
6081
6222
|
async submitRepo(params, options) {
|
|
6082
|
-
|
|
6223
|
+
log32("Submitting repository for import: %s (%s)", params.gitUrl, params.type);
|
|
6083
6224
|
const result = await this.request("/v1/user/claims/submit-repo", {
|
|
6084
6225
|
body: JSON.stringify(params),
|
|
6085
6226
|
headers: { "Content-Type": "application/json" },
|
|
6086
6227
|
method: "POST",
|
|
6087
6228
|
...options
|
|
6088
6229
|
});
|
|
6089
|
-
|
|
6230
|
+
log32("Submit result for %s: %s", params.gitUrl, result.success);
|
|
6231
|
+
return result;
|
|
6232
|
+
}
|
|
6233
|
+
/**
|
|
6234
|
+
* Publishes an owner-declared MCP plugin and starts repository enrichment
|
|
6235
|
+
*
|
|
6236
|
+
* @param params - Repository URL and lhm.plugin.json content
|
|
6237
|
+
* @param options - Optional request options (must include authentication)
|
|
6238
|
+
* @returns Promise resolving immediately with the plugin identifier and version
|
|
6239
|
+
*/
|
|
6240
|
+
async publishPlugin(params, options) {
|
|
6241
|
+
log32("Publishing plugin: %s@%s", params.identifier, params.version);
|
|
6242
|
+
const result = await this.request("/v1/user/plugins", {
|
|
6243
|
+
body: JSON.stringify(params),
|
|
6244
|
+
headers: { "Content-Type": "application/json" },
|
|
6245
|
+
method: "POST",
|
|
6246
|
+
...options
|
|
6247
|
+
});
|
|
6248
|
+
log32("Published plugin: %s@%s (%s)", result.identifier, result.version, result.status);
|
|
6090
6249
|
return result;
|
|
6091
6250
|
}
|
|
6092
6251
|
/**
|
|
@@ -6097,12 +6256,12 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6097
6256
|
* @returns Promise resolving to the delete result
|
|
6098
6257
|
*/
|
|
6099
6258
|
async deleteSkill(identifier, options) {
|
|
6100
|
-
|
|
6259
|
+
log32("Deleting skill: %s", identifier);
|
|
6101
6260
|
const result = await this.request(
|
|
6102
6261
|
`/v1/user/skills/${encodeURIComponent(identifier)}`,
|
|
6103
6262
|
{ method: "DELETE", ...options }
|
|
6104
6263
|
);
|
|
6105
|
-
|
|
6264
|
+
log32("Deleted skill: %s", identifier);
|
|
6106
6265
|
return result;
|
|
6107
6266
|
}
|
|
6108
6267
|
/**
|
|
@@ -6114,7 +6273,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6114
6273
|
* @returns Promise resolving to the updated status
|
|
6115
6274
|
*/
|
|
6116
6275
|
async updateSkillStatus(identifier, status, options) {
|
|
6117
|
-
|
|
6276
|
+
log32("Updating skill status: %s \u2192 %s", identifier, status);
|
|
6118
6277
|
const result = await this.request(
|
|
6119
6278
|
`/v1/user/skills/${encodeURIComponent(identifier)}/status`,
|
|
6120
6279
|
{
|
|
@@ -6124,7 +6283,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6124
6283
|
...options
|
|
6125
6284
|
}
|
|
6126
6285
|
);
|
|
6127
|
-
|
|
6286
|
+
log32("Updated skill status: %s \u2192 %s", identifier, result.status);
|
|
6128
6287
|
return result;
|
|
6129
6288
|
}
|
|
6130
6289
|
/**
|
|
@@ -6135,12 +6294,12 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6135
6294
|
* @returns Promise resolving to the delete result
|
|
6136
6295
|
*/
|
|
6137
6296
|
async deletePlugin(identifier, options) {
|
|
6138
|
-
|
|
6297
|
+
log32("Deleting plugin: %s", identifier);
|
|
6139
6298
|
const result = await this.request(
|
|
6140
6299
|
`/v1/user/plugins/${encodeURIComponent(identifier)}`,
|
|
6141
6300
|
{ method: "DELETE", ...options }
|
|
6142
6301
|
);
|
|
6143
|
-
|
|
6302
|
+
log32("Deleted plugin: %s", identifier);
|
|
6144
6303
|
return result;
|
|
6145
6304
|
}
|
|
6146
6305
|
/**
|
|
@@ -6152,7 +6311,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6152
6311
|
* @returns Promise resolving to the updated status
|
|
6153
6312
|
*/
|
|
6154
6313
|
async updatePluginStatus(identifier, status, options) {
|
|
6155
|
-
|
|
6314
|
+
log32("Updating plugin status: %s \u2192 %s", identifier, status);
|
|
6156
6315
|
const result = await this.request(
|
|
6157
6316
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/status`,
|
|
6158
6317
|
{
|
|
@@ -6162,7 +6321,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6162
6321
|
...options
|
|
6163
6322
|
}
|
|
6164
6323
|
);
|
|
6165
|
-
|
|
6324
|
+
log32("Updated plugin status: %s \u2192 %s", identifier, result.status);
|
|
6166
6325
|
return result;
|
|
6167
6326
|
}
|
|
6168
6327
|
/**
|
|
@@ -6174,7 +6333,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6174
6333
|
* @returns Promise resolving to the publish result
|
|
6175
6334
|
*/
|
|
6176
6335
|
async publishPluginVersion(identifier, data, options) {
|
|
6177
|
-
|
|
6336
|
+
log32("Publishing plugin version for: %s", identifier);
|
|
6178
6337
|
const result = await this.request(
|
|
6179
6338
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/versions`,
|
|
6180
6339
|
{
|
|
@@ -6184,7 +6343,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6184
6343
|
...options
|
|
6185
6344
|
}
|
|
6186
6345
|
);
|
|
6187
|
-
|
|
6346
|
+
log32("Published plugin version: %s@%s", identifier, result.version);
|
|
6188
6347
|
return result;
|
|
6189
6348
|
}
|
|
6190
6349
|
/**
|
|
@@ -6197,13 +6356,13 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6197
6356
|
*/
|
|
6198
6357
|
async getPluginLocalizations(identifier, version, options) {
|
|
6199
6358
|
var _a;
|
|
6200
|
-
|
|
6359
|
+
log32("Listing localizations for plugin: %s", identifier);
|
|
6201
6360
|
const query = version ? `?version=${encodeURIComponent(version)}` : "";
|
|
6202
6361
|
const result = await this.request(
|
|
6203
6362
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations${query}`,
|
|
6204
6363
|
options
|
|
6205
6364
|
);
|
|
6206
|
-
|
|
6365
|
+
log32("Found %d localizations for %s", ((_a = result.localizations) == null ? void 0 : _a.length) || 0, identifier);
|
|
6207
6366
|
return result;
|
|
6208
6367
|
}
|
|
6209
6368
|
/**
|
|
@@ -6220,7 +6379,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6220
6379
|
* @returns Promise resolving to the upsert result
|
|
6221
6380
|
*/
|
|
6222
6381
|
async updatePluginLocalizations(identifier, localizations, version, options) {
|
|
6223
|
-
|
|
6382
|
+
log32("Upserting %d localization(s) for plugin: %s", localizations.length, identifier);
|
|
6224
6383
|
const result = await this.request(
|
|
6225
6384
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations`,
|
|
6226
6385
|
{
|
|
@@ -6230,7 +6389,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6230
6389
|
...options
|
|
6231
6390
|
}
|
|
6232
6391
|
);
|
|
6233
|
-
|
|
6392
|
+
log32("Upserted localizations for %s@%s", identifier, result.version);
|
|
6234
6393
|
return result;
|
|
6235
6394
|
}
|
|
6236
6395
|
/**
|
|
@@ -6244,19 +6403,19 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6244
6403
|
* @returns Promise resolving to the delete result
|
|
6245
6404
|
*/
|
|
6246
6405
|
async deletePluginLocalization(identifier, locale, version, options) {
|
|
6247
|
-
|
|
6406
|
+
log32("Deleting localization %s for plugin: %s", locale, identifier);
|
|
6248
6407
|
const query = version ? `?version=${encodeURIComponent(version)}` : "";
|
|
6249
6408
|
const result = await this.request(
|
|
6250
6409
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations/${encodeURIComponent(locale)}${query}`,
|
|
6251
6410
|
{ method: "DELETE", ...options }
|
|
6252
6411
|
);
|
|
6253
|
-
|
|
6412
|
+
log32("Deleted localization %s for %s", locale, identifier);
|
|
6254
6413
|
return result;
|
|
6255
6414
|
}
|
|
6256
6415
|
};
|
|
6257
6416
|
|
|
6258
6417
|
// src/market/market-sdk.ts
|
|
6259
|
-
var
|
|
6418
|
+
var log33 = debug33("lobe-market-sdk");
|
|
6260
6419
|
var MarketSDK = class extends BaseSDK {
|
|
6261
6420
|
/**
|
|
6262
6421
|
* Creates a new MarketSDK instance
|
|
@@ -6269,7 +6428,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
6269
6428
|
tokenExpiry: void 0
|
|
6270
6429
|
};
|
|
6271
6430
|
super(options, void 0, sharedTokenState);
|
|
6272
|
-
|
|
6431
|
+
log33("MarketSDK instance created");
|
|
6273
6432
|
this.agentProfile = new AgentProfileService(options, this.headers, sharedTokenState);
|
|
6274
6433
|
this.agents = new AgentService2(options, this.headers, sharedTokenState);
|
|
6275
6434
|
this.agentGroups = new AgentGroupService(options, this.headers, sharedTokenState);
|
|
@@ -6318,7 +6477,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
6318
6477
|
* @deprecated Use auth.registerClient() instead
|
|
6319
6478
|
*/
|
|
6320
6479
|
async registerClient(request) {
|
|
6321
|
-
|
|
6480
|
+
log33("Registering client (deprecated method, use auth.registerClient): %s", request.clientName);
|
|
6322
6481
|
return this.auth.registerClient(request);
|
|
6323
6482
|
}
|
|
6324
6483
|
};
|