@antonytm/mcp-sitecore-server 1.2.1 → 1.2.2-verbose-logging

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.
Files changed (33) hide show
  1. package/dist/bundle.js +321 -27
  2. package/dist/config.d.ts +6 -0
  3. package/dist/config.js +5 -1
  4. package/dist/config.js.map +1 -1
  5. package/dist/logLevel.d.ts +7 -0
  6. package/dist/logLevel.js +9 -0
  7. package/dist/logLevel.js.map +1 -0
  8. package/dist/tools/item-service/client.d.ts +2 -1
  9. package/dist/tools/item-service/client.js +298 -15
  10. package/dist/tools/item-service/client.js.map +1 -1
  11. package/dist/tools/item-service/logic/composite/get-item-descendants.js +1 -1
  12. package/dist/tools/item-service/logic/composite/get-item-descendants.js.map +1 -1
  13. package/dist/tools/item-service/logic/composite/get-languages.js +1 -1
  14. package/dist/tools/item-service/logic/composite/get-languages.js.map +1 -1
  15. package/dist/tools/item-service/logic/simple/create-item.js +1 -1
  16. package/dist/tools/item-service/logic/simple/create-item.js.map +1 -1
  17. package/dist/tools/item-service/logic/simple/delete-item.js +1 -1
  18. package/dist/tools/item-service/logic/simple/delete-item.js.map +1 -1
  19. package/dist/tools/item-service/logic/simple/edit-item.js +2 -1
  20. package/dist/tools/item-service/logic/simple/edit-item.js.map +1 -1
  21. package/dist/tools/item-service/logic/simple/get-item-by-path.js +1 -1
  22. package/dist/tools/item-service/logic/simple/get-item-by-path.js.map +1 -1
  23. package/dist/tools/item-service/logic/simple/get-item-children.js +1 -1
  24. package/dist/tools/item-service/logic/simple/get-item-children.js.map +1 -1
  25. package/dist/tools/item-service/logic/simple/get-item.js +1 -1
  26. package/dist/tools/item-service/logic/simple/get-item.js.map +1 -1
  27. package/dist/tools/item-service/logic/simple/run-stored-query.js +1 -1
  28. package/dist/tools/item-service/logic/simple/run-stored-query.js.map +1 -1
  29. package/dist/tools/item-service/logic/simple/run-stored-search.js +1 -1
  30. package/dist/tools/item-service/logic/simple/run-stored-search.js.map +1 -1
  31. package/dist/tools/item-service/logic/simple/search-items.js +1 -1
  32. package/dist/tools/item-service/logic/simple/search-items.js.map +1 -1
  33. package/package.json +5 -5
package/dist/bundle.js CHANGED
@@ -4478,6 +4478,15 @@ function requireConfig () {
4478
4478
 
4479
4479
  requireConfig();
4480
4480
 
4481
+ var LogLevel$1;
4482
+ (function (LogLevel) {
4483
+ LogLevel["DEBUG"] = "DEBUG";
4484
+ LogLevel["INFO"] = "INFO";
4485
+ LogLevel["WARN"] = "WARN";
4486
+ LogLevel["ERROR"] = "ERROR";
4487
+ LogLevel["FATAL"] = "FATAL";
4488
+ })(LogLevel$1 || (LogLevel$1 = {}));
4489
+
4481
4490
  objectType({
4482
4491
  name: stringType().default("mcp-sitecore-server"),
4483
4492
  version: stringType().optional(),
@@ -4514,7 +4523,8 @@ objectType({
4514
4523
  password: "b",
4515
4524
  serverUrl: "https://xmcloudcm.localhost/",
4516
4525
  }),
4517
- authorizationHeader: stringType().default("")
4526
+ authorizationHeader: stringType().default(""),
4527
+ logLevel: stringType().default(LogLevel$1.INFO),
4518
4528
  });
4519
4529
  const envSchema = objectType({
4520
4530
  GRAPHQL_ENDPOINT: stringType().url().optional(),
@@ -4530,6 +4540,7 @@ const envSchema = objectType({
4530
4540
  POWERSHELL_PASSWORD: stringType().optional(),
4531
4541
  POWERSHELL_SERVER_URL: stringType().url().optional(),
4532
4542
  AUTORIZATION_HEADER: stringType().optional(),
4543
+ LOG_LEVEL: stringType().optional(),
4533
4544
  });
4534
4545
  const envStartSchema = objectType({
4535
4546
  //* The transport to use for the server. Can be one of 'stdio' or 'sse'.
@@ -4573,6 +4584,7 @@ const config = {
4573
4584
  serverUrl: ENV$1.POWERSHELL_SERVER_URL || "https://xmcloudcm.localhost/",
4574
4585
  },
4575
4586
  authorizationHeader: ENV$1.AUTORIZATION_HEADER || "",
4587
+ logLevel: ENV$1.LOG_LEVEL || LogLevel$1.INFO,
4576
4588
  };
4577
4589
 
4578
4590
  const LATEST_PROTOCOL_VERSION = "2025-06-18";
@@ -29823,11 +29835,13 @@ class RestfulItemServiceClient {
29823
29835
  domain;
29824
29836
  authCookie = null;
29825
29837
  isInitialized = false;
29826
- constructor(serverUrl, username, password, domain = 'sitecore') {
29838
+ logLevel;
29839
+ constructor(serverUrl, username, password, domain = 'sitecore', logLevel = LogLevel$1.INFO) {
29827
29840
  this.serverUrl = serverUrl;
29828
29841
  this.username = username;
29829
29842
  this.password = password;
29830
29843
  this.domain = domain;
29844
+ this.logLevel = logLevel;
29831
29845
  }
29832
29846
  /**
29833
29847
  * Initializes the client by logging in and setting the authentication cookie.
@@ -29835,15 +29849,28 @@ class RestfulItemServiceClient {
29835
29849
  */
29836
29850
  async initialize() {
29837
29851
  if (!this.isInitialized) {
29852
+ if (this.logLevel === LogLevel$1.DEBUG) {
29853
+ console.log('Item Service Client: Initializing client...', JSON.stringify({
29854
+ serverUrl: this.serverUrl,
29855
+ username: this.username,
29856
+ domain: this.domain
29857
+ }, null, '\t'));
29858
+ }
29838
29859
  try {
29839
29860
  await this.login();
29840
29861
  this.isInitialized = true;
29862
+ if (this.logLevel === LogLevel$1.DEBUG) {
29863
+ console.log('Item Service Client: Successfully initialized');
29864
+ }
29841
29865
  }
29842
29866
  catch (error) {
29843
29867
  console.error('Failed to initialize client:', error);
29844
29868
  throw error;
29845
29869
  }
29846
29870
  }
29871
+ else if (this.logLevel === LogLevel$1.DEBUG) {
29872
+ console.log('Item Service Client: Already initialized, skipping initialization');
29873
+ }
29847
29874
  }
29848
29875
  /**
29849
29876
  * Logs in to the Sitecore server and sets the authentication cookie.
@@ -29851,16 +29878,31 @@ class RestfulItemServiceClient {
29851
29878
  */
29852
29879
  async login() {
29853
29880
  const url = `${this.serverUrl}/sitecore/api/ssc/auth/login`;
29881
+ const loginData = {
29882
+ username: this.username,
29883
+ password: this.password,
29884
+ domain: this.domain
29885
+ };
29886
+ if (this.logLevel === LogLevel$1.DEBUG) {
29887
+ console.log('Item Service Client: Attempting login...', JSON.stringify({
29888
+ url,
29889
+ username: this.username,
29890
+ domain: this.domain
29891
+ }, null, '\t'));
29892
+ }
29854
29893
  try {
29855
29894
  const response = await fetch(url, {
29856
29895
  method: 'POST',
29857
29896
  headers: { 'Content-Type': 'application/json' },
29858
- body: JSON.stringify({
29859
- username: this.username,
29860
- password: this.password,
29861
- domain: this.domain
29862
- })
29897
+ body: JSON.stringify(loginData)
29863
29898
  });
29899
+ if (this.logLevel === LogLevel$1.DEBUG) {
29900
+ console.log('Item Service Client: Login response received', JSON.stringify({
29901
+ status: response.status,
29902
+ statusText: response.statusText,
29903
+ headers: Object.fromEntries(response.headers.entries())
29904
+ }, null, '\t'));
29905
+ }
29864
29906
  if (!response.ok) {
29865
29907
  throw new Error('Login failed');
29866
29908
  }
@@ -29869,6 +29911,9 @@ class RestfulItemServiceClient {
29869
29911
  const match = cookies.match(/\.AspNet\.Cookies=([^;]+);/);
29870
29912
  if (match) {
29871
29913
  this.authCookie = match[1];
29914
+ if (this.logLevel === LogLevel$1.DEBUG) {
29915
+ console.log('Item Service Client: Authentication cookie retrieved successfully');
29916
+ }
29872
29917
  }
29873
29918
  }
29874
29919
  else {
@@ -29879,6 +29924,9 @@ class RestfulItemServiceClient {
29879
29924
  }
29880
29925
  }
29881
29926
  catch (error) {
29927
+ if (this.logLevel === LogLevel$1.DEBUG) {
29928
+ console.error('Item Service Client: Login failed', error);
29929
+ }
29882
29930
  if (error instanceof Error) {
29883
29931
  throw new Error(`Failed to log in: ${error.message}`);
29884
29932
  }
@@ -29902,16 +29950,42 @@ class RestfulItemServiceClient {
29902
29950
  params.set('fields', options.fields.join(','));
29903
29951
  }
29904
29952
  const url = `${this.serverUrl}/sitecore/api/ssc/item/${id}?${params.toString()}`;
29953
+ if (this.logLevel === LogLevel$1.DEBUG) {
29954
+ console.log('Item Service Client: Getting item by ID...', JSON.stringify({
29955
+ id,
29956
+ options,
29957
+ url
29958
+ }, null, '\t'));
29959
+ }
29905
29960
  try {
29906
29961
  const response = await fetch(url, {
29907
29962
  headers: { 'Cookie': `.AspNet.Cookies=${this.authCookie}` }
29908
29963
  });
29964
+ if (this.logLevel === LogLevel$1.DEBUG) {
29965
+ console.log('Item Service Client: Get item by ID response received', JSON.stringify({
29966
+ status: response.status,
29967
+ statusText: response.statusText
29968
+ }, null, '\t'));
29969
+ }
29909
29970
  if (!response.ok) {
29910
29971
  throw new Error(`HTTP error! status: ${response.status}`);
29911
29972
  }
29912
- return await response.json();
29973
+ const result = await response.json();
29974
+ if (this.logLevel === LogLevel$1.DEBUG) {
29975
+ console.log('Item Service Client: Item retrieved successfully', JSON.stringify({
29976
+ itemId: id,
29977
+ resultKeys: Object.keys(result)
29978
+ }, null, '\t'));
29979
+ }
29980
+ return result;
29913
29981
  }
29914
29982
  catch (error) {
29983
+ if (this.logLevel === LogLevel$1.DEBUG) {
29984
+ console.error('Item Service Client: Failed to get item by ID', JSON.stringify({
29985
+ id,
29986
+ error
29987
+ }, null, '\t'));
29988
+ }
29915
29989
  if (error instanceof Error) {
29916
29990
  throw new Error(`Failed to retrieve item by ID: ${error.message}`);
29917
29991
  }
@@ -29935,16 +30009,42 @@ class RestfulItemServiceClient {
29935
30009
  params.set('fields', options.fields.join(','));
29936
30010
  }
29937
30011
  const url = `${this.serverUrl}/sitecore/api/ssc/item/${id}/children?${params.toString()}`;
30012
+ if (this.logLevel === LogLevel$1.DEBUG) {
30013
+ console.log('Item Service Client: Getting item children...', JSON.stringify({
30014
+ id,
30015
+ options,
30016
+ url
30017
+ }, null, '\t'));
30018
+ }
29938
30019
  try {
29939
30020
  const response = await fetch(url, {
29940
30021
  headers: { 'Cookie': `.AspNet.Cookies=${this.authCookie}` }
29941
30022
  });
30023
+ if (this.logLevel === LogLevel$1.DEBUG) {
30024
+ console.log('Item Service Client: Get item children response received', JSON.stringify({
30025
+ status: response.status,
30026
+ statusText: response.statusText
30027
+ }, null, '\t'));
30028
+ }
29942
30029
  if (!response.ok) {
29943
30030
  throw new Error(`HTTP error! status: ${response.status}`);
29944
30031
  }
29945
- return await response.json();
30032
+ const result = await response.json();
30033
+ if (this.logLevel === LogLevel$1.DEBUG) {
30034
+ console.log('Item Service Client: Item children retrieved successfully', JSON.stringify({
30035
+ parentId: id,
30036
+ resultKeys: Object.keys(result)
30037
+ }, null, '\t'));
30038
+ }
30039
+ return result;
29946
30040
  }
29947
30041
  catch (error) {
30042
+ if (this.logLevel === LogLevel$1.DEBUG) {
30043
+ console.error('Item Service Client: Failed to get item children', JSON.stringify({
30044
+ id,
30045
+ error
30046
+ }, null, '\t'));
30047
+ }
29948
30048
  if (error instanceof Error) {
29949
30049
  throw new Error(`Failed to retrieve item children: ${error.message}`);
29950
30050
  }
@@ -29970,16 +30070,43 @@ class RestfulItemServiceClient {
29970
30070
  params.set('fields', options.fields.join(','));
29971
30071
  }
29972
30072
  const url = `${this.serverUrl}/sitecore/api/ssc/item?path=${encodedPath}&${params.toString()}`;
30073
+ if (this.logLevel === LogLevel$1.DEBUG) {
30074
+ console.log('Item Service Client: Getting item by path...', JSON.stringify({
30075
+ path,
30076
+ encodedPath,
30077
+ options,
30078
+ url
30079
+ }, null, '\t'));
30080
+ }
29973
30081
  try {
29974
30082
  const response = await fetch(url, {
29975
30083
  headers: { 'Cookie': `.AspNet.Cookies=${this.authCookie}` }
29976
30084
  });
30085
+ if (this.logLevel === LogLevel$1.DEBUG) {
30086
+ console.log('Item Service Client: Get item by path response received', JSON.stringify({
30087
+ status: response.status,
30088
+ statusText: response.statusText
30089
+ }, null, '\t'));
30090
+ }
29977
30091
  if (!response.ok) {
29978
30092
  throw new Error(`HTTP error! status: ${response.status}`);
29979
30093
  }
29980
- return await response.json();
30094
+ const result = await response.json();
30095
+ if (this.logLevel === LogLevel$1.DEBUG) {
30096
+ console.log('Item Service Client: Item retrieved by path successfully', JSON.stringify({
30097
+ path,
30098
+ resultKeys: Object.keys(result)
30099
+ }, null, '\t'));
30100
+ }
30101
+ return result;
29981
30102
  }
29982
30103
  catch (error) {
30104
+ if (this.logLevel === LogLevel$1.DEBUG) {
30105
+ console.error('Item Service Client: Failed to get item by path', JSON.stringify({
30106
+ path,
30107
+ error
30108
+ }, null, '\t'));
30109
+ }
29983
30110
  if (error instanceof Error) {
29984
30111
  throw new Error(`Failed to retrieve item by path: ${error.message}`);
29985
30112
  }
@@ -30003,6 +30130,15 @@ class RestfulItemServiceClient {
30003
30130
  const encodedPath = encodeURIComponent(parentPath);
30004
30131
  const params = new URLSearchParams(options);
30005
30132
  const url = `${this.serverUrl}/sitecore/api/ssc/item/${encodedPath}?${params.toString()}`;
30133
+ if (this.logLevel === LogLevel$1.DEBUG) {
30134
+ console.log('Item Service Client: Creating item...', JSON.stringify({
30135
+ parentPath,
30136
+ encodedPath,
30137
+ data,
30138
+ options,
30139
+ url
30140
+ }, null, '\t'));
30141
+ }
30006
30142
  try {
30007
30143
  const response = await fetch(url, {
30008
30144
  method: 'POST',
@@ -30012,16 +30148,38 @@ class RestfulItemServiceClient {
30012
30148
  },
30013
30149
  body: JSON.stringify(data)
30014
30150
  });
30151
+ if (this.logLevel === LogLevel$1.DEBUG) {
30152
+ console.log('Item Service Client: Create item response received', JSON.stringify({
30153
+ status: response.status,
30154
+ statusText: response.statusText
30155
+ }, null, '\t'));
30156
+ }
30015
30157
  if (!response.ok) {
30016
30158
  throw new Error(`HTTP error! status: ${response.status}`);
30017
30159
  }
30018
- return {
30160
+ const result = {
30019
30161
  "Status": "Success",
30020
30162
  "Code": response.status,
30021
30163
  "Message": "Item created successfully",
30022
30164
  };
30165
+ if (this.logLevel === LogLevel$1.DEBUG) {
30166
+ console.log('Item Service Client: Item created successfully', JSON.stringify({
30167
+ parentPath,
30168
+ itemName: data.ItemName,
30169
+ templateId: data.TemplateID,
30170
+ result
30171
+ }, null, '\t'));
30172
+ }
30173
+ return result;
30023
30174
  }
30024
30175
  catch (error) {
30176
+ if (this.logLevel === LogLevel$1.DEBUG) {
30177
+ console.error('Item Service Client: Failed to create item', JSON.stringify({
30178
+ parentPath,
30179
+ data,
30180
+ error
30181
+ }, null, '\t'));
30182
+ }
30025
30183
  if (error instanceof Error) {
30026
30184
  throw new Error(`Failed to create item: ${error.message}`);
30027
30185
  }
@@ -30043,6 +30201,14 @@ class RestfulItemServiceClient {
30043
30201
  }
30044
30202
  const params = new URLSearchParams(options);
30045
30203
  const url = `${this.serverUrl}/sitecore/api/ssc/item/${id}?${params.toString()}`;
30204
+ if (this.logLevel === LogLevel$1.DEBUG) {
30205
+ console.log('Item Service Client: Editing item...', JSON.stringify({
30206
+ id,
30207
+ data,
30208
+ options,
30209
+ url
30210
+ }, null, '\t'));
30211
+ }
30046
30212
  try {
30047
30213
  const response = await fetch(url, {
30048
30214
  method: 'PATCH',
@@ -30052,16 +30218,36 @@ class RestfulItemServiceClient {
30052
30218
  },
30053
30219
  body: JSON.stringify(data)
30054
30220
  });
30221
+ if (this.logLevel === LogLevel$1.DEBUG) {
30222
+ console.log('Item Service Client: Edit item response received', JSON.stringify({
30223
+ status: response.status,
30224
+ statusText: response.statusText
30225
+ }, null, '\t'));
30226
+ }
30055
30227
  if (!response.ok) {
30056
30228
  throw new Error(`HTTP error! status: ${response.status}`);
30057
30229
  }
30058
- return {
30230
+ const result = {
30059
30231
  "Status": "Success",
30060
30232
  "Code": response.status,
30061
30233
  "Message": "Item updated successfully",
30062
30234
  };
30235
+ if (this.logLevel === LogLevel$1.DEBUG) {
30236
+ console.log('Item Service Client: Item edited successfully', JSON.stringify({
30237
+ id,
30238
+ result
30239
+ }, null, '\t'));
30240
+ }
30241
+ return result;
30063
30242
  }
30064
30243
  catch (error) {
30244
+ if (this.logLevel === LogLevel$1.DEBUG) {
30245
+ console.error('Item Service Client: Failed to edit item', JSON.stringify({
30246
+ id,
30247
+ data,
30248
+ error
30249
+ }, null, '\t'));
30250
+ }
30065
30251
  if (error instanceof Error) {
30066
30252
  throw new Error(`Failed to edit item: ${error.message}`);
30067
30253
  }
@@ -30082,6 +30268,13 @@ class RestfulItemServiceClient {
30082
30268
  }
30083
30269
  const params = new URLSearchParams(options);
30084
30270
  const url = `${this.serverUrl}/sitecore/api/ssc/item/${id}?${params.toString()}`;
30271
+ if (this.logLevel === LogLevel$1.DEBUG) {
30272
+ console.log('Item Service Client: Deleting item...', JSON.stringify({
30273
+ id,
30274
+ options,
30275
+ url
30276
+ }, null, '\t'));
30277
+ }
30085
30278
  try {
30086
30279
  const response = await fetch(url, {
30087
30280
  method: 'DELETE',
@@ -30089,16 +30282,35 @@ class RestfulItemServiceClient {
30089
30282
  'Cookie': `.AspNet.Cookies=${this.authCookie}`
30090
30283
  }
30091
30284
  });
30285
+ if (this.logLevel === LogLevel$1.DEBUG) {
30286
+ console.log('Item Service Client: Delete item response received', JSON.stringify({
30287
+ status: response.status,
30288
+ statusText: response.statusText
30289
+ }, null, '\t'));
30290
+ }
30092
30291
  if (!response.ok) {
30093
30292
  throw new Error(`HTTP error! status: ${response.status}`);
30094
30293
  }
30095
- return {
30294
+ const result = {
30096
30295
  "Status": "Success",
30097
30296
  "Code": response.status,
30098
30297
  "Message": "Item deleted successfully",
30099
30298
  };
30299
+ if (this.logLevel === LogLevel$1.DEBUG) {
30300
+ console.log('Item Service Client: Item deleted successfully', JSON.stringify({
30301
+ id,
30302
+ result
30303
+ }, null, '\t'));
30304
+ }
30305
+ return result;
30100
30306
  }
30101
30307
  catch (error) {
30308
+ if (this.logLevel === LogLevel$1.DEBUG) {
30309
+ console.error('Item Service Client: Failed to delete item', JSON.stringify({
30310
+ id,
30311
+ error
30312
+ }, null, '\t'));
30313
+ }
30102
30314
  if (error instanceof Error) {
30103
30315
  throw new Error(`Failed to delete item: ${error.message}`);
30104
30316
  }
@@ -30132,16 +30344,41 @@ class RestfulItemServiceClient {
30132
30344
  if (options.includeStandardTemplateFields !== undefined)
30133
30345
  params.set('includeStandardTemplateFields', String(options.includeStandardTemplateFields));
30134
30346
  const url = `${this.serverUrl}/sitecore/api/ssc/item/search?${params.toString()}`;
30347
+ if (this.logLevel === LogLevel$1.DEBUG) {
30348
+ console.log('Item Service Client: Searching items...', JSON.stringify({
30349
+ options,
30350
+ url
30351
+ }, null, '\t'));
30352
+ }
30135
30353
  try {
30136
30354
  const response = await fetch(url, {
30137
30355
  headers: { 'Cookie': `.AspNet.Cookies=${this.authCookie}` }
30138
30356
  });
30357
+ if (this.logLevel === LogLevel$1.DEBUG) {
30358
+ console.log('Item Service Client: Search items response received', JSON.stringify({
30359
+ status: response.status,
30360
+ statusText: response.statusText
30361
+ }, null, '\t'));
30362
+ }
30139
30363
  if (!response.ok) {
30140
30364
  throw new Error(`HTTP error! status: ${response.status}`);
30141
30365
  }
30142
- return await response.json();
30366
+ const result = await response.json();
30367
+ if (this.logLevel === LogLevel$1.DEBUG) {
30368
+ console.log('Item Service Client: Search completed successfully', JSON.stringify({
30369
+ searchTerm: options.term,
30370
+ resultKeys: Object.keys(result)
30371
+ }, null, '\t'));
30372
+ }
30373
+ return result;
30143
30374
  }
30144
30375
  catch (error) {
30376
+ if (this.logLevel === LogLevel$1.DEBUG) {
30377
+ console.error('Item Service Client: Failed to search items', JSON.stringify({
30378
+ options,
30379
+ error
30380
+ }, null, '\t'));
30381
+ }
30145
30382
  if (error instanceof Error) {
30146
30383
  throw new Error(`Failed to search items: ${error.message}`);
30147
30384
  }
@@ -30176,16 +30413,43 @@ class RestfulItemServiceClient {
30176
30413
  if (options.includeStandardTemplateFields !== undefined)
30177
30414
  params.set('includeStandardTemplateFields', String(options.includeStandardTemplateFields));
30178
30415
  const url = `${this.serverUrl}/sitecore/api/ssc/item/${id}/query?${params.toString()}`;
30416
+ if (this.logLevel === LogLevel$1.DEBUG) {
30417
+ console.log('Item Service Client: Running stored query...', JSON.stringify({
30418
+ id,
30419
+ options,
30420
+ url
30421
+ }, null, '\t'));
30422
+ }
30179
30423
  try {
30180
30424
  const response = await fetch(url, {
30181
30425
  headers: { 'Cookie': `.AspNet.Cookies=${this.authCookie}` }
30182
30426
  });
30427
+ if (this.logLevel === LogLevel$1.DEBUG) {
30428
+ console.log('Item Service Client: Stored query response received', JSON.stringify({
30429
+ status: response.status,
30430
+ statusText: response.statusText
30431
+ }, null, '\t'));
30432
+ }
30183
30433
  if (!response.ok) {
30184
30434
  throw new Error(`HTTP error! status: ${response.status}`);
30185
30435
  }
30186
- return await response.json();
30436
+ const result = await response.json();
30437
+ if (this.logLevel === LogLevel$1.DEBUG) {
30438
+ console.log('Item Service Client: Stored query completed successfully', JSON.stringify({
30439
+ queryId: id,
30440
+ resultKeys: Object.keys(result)
30441
+ }, null, '\t'));
30442
+ }
30443
+ return result;
30187
30444
  }
30188
30445
  catch (error) {
30446
+ if (this.logLevel === LogLevel$1.DEBUG) {
30447
+ console.error('Item Service Client: Failed to run stored query', JSON.stringify({
30448
+ id,
30449
+ options,
30450
+ error
30451
+ }, null, '\t'));
30452
+ }
30189
30453
  if (error instanceof Error) {
30190
30454
  throw new Error(`Failed to run stored query: ${error.message}`);
30191
30455
  }
@@ -30223,16 +30487,46 @@ class RestfulItemServiceClient {
30223
30487
  if (options.sorting)
30224
30488
  params.set('sorting', options.sorting);
30225
30489
  const url = `${this.serverUrl}/sitecore/api/ssc/item/${id}/search?${params.toString()}`;
30490
+ if (this.logLevel === LogLevel$1.DEBUG) {
30491
+ console.log('Item Service Client: Running stored search...', JSON.stringify({
30492
+ id,
30493
+ term,
30494
+ options,
30495
+ url
30496
+ }, null, '\t'));
30497
+ }
30226
30498
  try {
30227
30499
  const response = await fetch(url, {
30228
30500
  headers: { 'Cookie': `.AspNet.Cookies=${this.authCookie}` }
30229
30501
  });
30502
+ if (this.logLevel === LogLevel$1.DEBUG) {
30503
+ console.log('Item Service Client: Stored search response received', JSON.stringify({
30504
+ status: response.status,
30505
+ statusText: response.statusText
30506
+ }, null, '\t'));
30507
+ }
30230
30508
  if (!response.ok) {
30231
30509
  throw new Error(`HTTP error! status: ${response.status}`);
30232
30510
  }
30233
- return await response.json();
30511
+ const result = await response.json();
30512
+ if (this.logLevel === LogLevel$1.DEBUG) {
30513
+ console.log('Item Service Client: Stored search completed successfully', JSON.stringify({
30514
+ searchId: id,
30515
+ term,
30516
+ resultKeys: Object.keys(result)
30517
+ }, null, '\t'));
30518
+ }
30519
+ return result;
30234
30520
  }
30235
30521
  catch (error) {
30522
+ if (this.logLevel === LogLevel$1.DEBUG) {
30523
+ console.error('Item Service Client: Failed to run stored search', JSON.stringify({
30524
+ id,
30525
+ term,
30526
+ options,
30527
+ error
30528
+ }, null, '\t'));
30529
+ }
30236
30530
  if (error instanceof Error) {
30237
30531
  throw new Error(`Failed to run stored search: ${error.message}`);
30238
30532
  }
@@ -30244,7 +30538,7 @@ class RestfulItemServiceClient {
30244
30538
  }
30245
30539
 
30246
30540
  async function getItemById(conf, id, options) {
30247
- const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain);
30541
+ const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain, conf.logLevel);
30248
30542
  const response = await client.getItemById(id, options);
30249
30543
  return {
30250
30544
  content: [
@@ -30274,7 +30568,7 @@ function getItemTool(server, config) {
30274
30568
  }
30275
30569
 
30276
30570
  async function getItemChildren(conf, id, options) {
30277
- const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain);
30571
+ const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain, conf.logLevel);
30278
30572
  const response = await client.getItemChildren(id, options);
30279
30573
  return {
30280
30574
  content: [
@@ -30304,7 +30598,7 @@ function getItemChildrenTool(server, config) {
30304
30598
  }
30305
30599
 
30306
30600
  async function getItemByPath(conf, path, options) {
30307
- const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain);
30601
+ const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain, conf.logLevel);
30308
30602
  const response = await client.getItemByPath(path, options);
30309
30603
  return {
30310
30604
  content: [
@@ -30334,7 +30628,7 @@ function getItemByPathTool(server, config) {
30334
30628
  }
30335
30629
 
30336
30630
  async function createItem(conf, parentPath, data, options = {}) {
30337
- const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain);
30631
+ const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain, conf.logLevel);
30338
30632
  const response = await client.createItem(parentPath, data, options);
30339
30633
  return {
30340
30634
  content: [
@@ -30370,7 +30664,7 @@ function createItemTool(server, config) {
30370
30664
  * @param options - Optional parameters (database, language, version)
30371
30665
  */
30372
30666
  async function editItem(conf, id, data, options = {}) {
30373
- const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain);
30667
+ const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain, conf.logLevel);
30374
30668
  const response = await client.editItem(id, data, options);
30375
30669
  return {
30376
30670
  content: [
@@ -30404,7 +30698,7 @@ function editItemTool(server, config) {
30404
30698
  * @param options - Optional parameters (database, language, version)
30405
30699
  */
30406
30700
  async function deleteItem(conf, id, options = {}) {
30407
- const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain);
30701
+ const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain, conf.logLevel);
30408
30702
  const response = await client.deleteItem(id, options);
30409
30703
  return {
30410
30704
  content: [
@@ -30431,7 +30725,7 @@ function deleteItemTool(server, config) {
30431
30725
  }
30432
30726
 
30433
30727
  async function searchItems(conf, options) {
30434
- const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain);
30728
+ const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain, conf.logLevel);
30435
30729
  const response = await client.searchItems(options);
30436
30730
  return {
30437
30731
  content: [
@@ -30466,7 +30760,7 @@ function searchItemsTool(server, config) {
30466
30760
  * @returns {Promise<CallToolResult>} - The query results.
30467
30761
  */
30468
30762
  async function runStoredQuery(conf, id, options = {}) {
30469
- const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain);
30763
+ const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain, conf.logLevel);
30470
30764
  const response = await client.runStoredQuery(id, options);
30471
30765
  return {
30472
30766
  content: [
@@ -30503,7 +30797,7 @@ function runStoredQueryTool(server, config) {
30503
30797
  * @returns {Promise<CallToolResult>} - The search results.
30504
30798
  */
30505
30799
  async function runStoredSearch(conf, id, term, options) {
30506
- const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain);
30800
+ const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain, conf.logLevel);
30507
30801
  const response = await client.runStoredSearch(id, term, options);
30508
30802
  return {
30509
30803
  content: [
@@ -30536,7 +30830,7 @@ function runStoredSearchTool(server, config) {
30536
30830
  }
30537
30831
 
30538
30832
  async function getItemDescendants(conf, id, options) {
30539
- const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain);
30833
+ const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain, conf.logLevel);
30540
30834
  const responseArray = [];
30541
30835
  const idsSet = new Set();
30542
30836
  idsSet.add(id);
@@ -30579,7 +30873,7 @@ function getItemDescendantsTool(server, config) {
30579
30873
  }
30580
30874
 
30581
30875
  async function getLanguages(conf) {
30582
- const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain);
30876
+ const client = new RestfulItemServiceClient(conf.itemService.serverUrl, conf.itemService.username, conf.itemService.password, conf.itemService.domain, conf.logLevel);
30583
30877
  const languagesItemResponse = await client.getItemByPath("/sitecore/system/Languages");
30584
30878
  const itemId = languagesItemResponse.ItemID;
30585
30879
  const languagesChildrenResponse = await client.getItemChildren(itemId);