@tenonhq/sincronia-core 0.0.26 → 0.0.28

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/commander.js CHANGED
@@ -137,6 +137,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
137
137
  });
138
138
  return cmdArgs;
139
139
  }, updateSetCommands_1.listUpdateSetsCommand)
140
+ .command("currentUpdateSet", "Show the current active update set", (cmdArgs) => {
141
+ cmdArgs.options({
142
+ ...sharedOptions,
143
+ scope: {
144
+ alias: "s",
145
+ type: "string",
146
+ describe: "Scope to check update set for",
147
+ },
148
+ });
149
+ return cmdArgs;
150
+ }, updateSetCommands_1.showCurrentUpdateSetCommand)
140
151
  .help().argv;
141
152
  }
142
153
  });
package/dist/snClient.js CHANGED
@@ -181,6 +181,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
181
181
  withFiles,
182
182
  });
183
183
  };
184
+ const changeUpdateSet = (params) => {
185
+ const endpoint = "api/cadso/claude/changeUpdateSet";
186
+ return client.get(endpoint, {
187
+ params,
188
+ });
189
+ };
190
+ const getCurrentUpdateSet = (scope) => {
191
+ const endpoint = "api/cadso/claude/currentUpdateSet";
192
+ const params = {};
193
+ if (scope) {
194
+ params.scope = scope;
195
+ }
196
+ return client.get(endpoint, {
197
+ params,
198
+ });
199
+ };
184
200
  return {
185
201
  getAppList,
186
202
  updateRecord,
@@ -196,6 +212,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
196
212
  createCurrentUpdateSetUserPref,
197
213
  getMissingFiles,
198
214
  getManifest,
215
+ changeUpdateSet,
216
+ getCurrentUpdateSet,
199
217
  client, // Expose the axios client for custom queries
200
218
  };
201
219
  };
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  })(function (require, exports) {
13
13
  "use strict";
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.showCurrentUpdateSetCommand = showCurrentUpdateSetCommand;
15
16
  exports.createUpdateSetCommand = createUpdateSetCommand;
16
17
  exports.switchUpdateSetCommand = switchUpdateSetCommand;
17
18
  exports.listUpdateSetsCommand = listUpdateSetsCommand;
@@ -20,6 +21,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
21
  const Logger_1 = require("./Logger");
21
22
  const commands_1 = require("./commands");
22
23
  const chalk_1 = __importDefault(require("chalk"));
24
+ /**
25
+ * Shows the current active update set
26
+ */
27
+ async function showCurrentUpdateSetCommand(args) {
28
+ (0, commands_1.setLogLevel)(args);
29
+ try {
30
+ const currentUpdateSet = await getCurrentUpdateSetDetails(args.scope);
31
+ if (currentUpdateSet) {
32
+ Logger_1.logger.info(chalk_1.default.bold("\nCurrent Update Set:"));
33
+ Logger_1.logger.info("─".repeat(40));
34
+ Logger_1.logger.info(chalk_1.default.green(`► ${currentUpdateSet.name}`));
35
+ Logger_1.logger.info(` ID: ${currentUpdateSet.sysId}`);
36
+ if (args.scope) {
37
+ Logger_1.logger.info(` Scope: ${args.scope}`);
38
+ }
39
+ }
40
+ else {
41
+ Logger_1.logger.warn("No update set is currently active or unable to retrieve update set information");
42
+ }
43
+ }
44
+ catch (e) {
45
+ Logger_1.logger.error("Failed to get current update set");
46
+ if (e instanceof Error)
47
+ Logger_1.logger.error(e.message);
48
+ process.exit(1);
49
+ }
50
+ }
23
51
  /**
24
52
  * Creates a new update set with the given name and switches to it
25
53
  */
@@ -48,7 +76,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
48
76
  const createResult = await (0, snClient_1.unwrapSNResponse)(createResponse);
49
77
  const updateSetSysId = createResult.sys_id;
50
78
  // Switch to the new update set
51
- await switchToUpdateSet(updateSetSysId, name);
79
+ await switchToUpdateSet(updateSetSysId, name, scope);
52
80
  Logger_1.logger.info(chalk_1.default.green(`✓ Update set "${name}" created and activated`));
53
81
  Logger_1.logger.info(`Update Set ID: ${updateSetSysId}`);
54
82
  if (scope) {
@@ -80,8 +108,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
80
108
  const sysId = typeof targetUpdateSet.sys_id === 'object' && targetUpdateSet.sys_id !== null ? targetUpdateSet.sys_id.value : targetUpdateSet.sys_id;
81
109
  const name = typeof targetUpdateSet.name === 'object' && targetUpdateSet.name !== null ? targetUpdateSet.name.value : targetUpdateSet.name;
82
110
  const applicationName = ((_a = targetUpdateSet.application) === null || _a === void 0 ? void 0 : _a.display_value) || (typeof targetUpdateSet.application === 'object' && targetUpdateSet.application !== null ? targetUpdateSet.application.value : targetUpdateSet.application);
111
+ const applicationScope = typeof targetUpdateSet.application === 'object' && targetUpdateSet.application !== null ? targetUpdateSet.application.value : targetUpdateSet.application;
83
112
  // Switch to the selected update set
84
- await switchToUpdateSet(sysId, name);
113
+ await switchToUpdateSet(sysId, name, args.scope || applicationScope);
85
114
  Logger_1.logger.info(chalk_1.default.green(`✓ Switched to update set: ${name}`));
86
115
  Logger_1.logger.info(`Update Set ID: ${sysId}`);
87
116
  if (applicationName) {
@@ -197,21 +226,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
197
226
  };
198
227
  }
199
228
  /**
200
- * Helper function to switch to an update set
229
+ * Helper function to switch to an update set using the new API endpoint
201
230
  */
202
- async function switchToUpdateSet(updateSetSysId, name) {
231
+ async function switchToUpdateSet(updateSetSysId, name, scope) {
203
232
  const client = (0, snClient_1.defaultClient)();
204
- // Get current user sys_id
205
- const userSysId = await (0, snClient_1.unwrapTableAPIFirstItem)(client.getUserSysId(), "sys_id");
206
- // Get or create user preference for current update set
207
- try {
208
- const curUpdateSetUserPrefId = await (0, snClient_1.unwrapTableAPIFirstItem)(client.getCurrentUpdateSetUserPref(userSysId), "sys_id");
209
- // Update existing preference
210
- await client.updateCurrentUpdateSetUserPref(updateSetSysId, curUpdateSetUserPrefId);
233
+ // Use the new changeUpdateSet endpoint
234
+ // Can use either sysId or name+scope combination
235
+ const params = {};
236
+ if (updateSetSysId) {
237
+ params.sysId = updateSetSysId;
211
238
  }
212
- catch (e) {
213
- // Create new preference if it doesn't exist
214
- await client.createCurrentUpdateSetUserPref(updateSetSysId, userSysId);
239
+ if (name) {
240
+ params.name = name;
241
+ }
242
+ if (scope) {
243
+ params.scope = scope;
244
+ }
245
+ const response = await client.changeUpdateSet(params);
246
+ const result = await response.data;
247
+ if (result.error) {
248
+ throw new Error(result.error);
215
249
  }
216
250
  }
217
251
  /**
@@ -250,21 +284,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
250
284
  return (0, snClient_1.unwrapSNResponse)(response);
251
285
  }
252
286
  /**
253
- * Helper function to get current update set ID
287
+ * Helper function to get current update set ID using the new endpoint
254
288
  */
255
- async function getCurrentUpdateSetId() {
289
+ async function getCurrentUpdateSetId(scope) {
256
290
  try {
257
291
  const client = (0, snClient_1.defaultClient)();
258
- const userSysId = await (0, snClient_1.unwrapTableAPIFirstItem)(client.getUserSysId(), "sys_id");
259
- const endpoint = "api/now/table/sys_user_preference";
260
- const response = client.client.get(endpoint, {
261
- params: {
262
- sysparm_query: `user=${userSysId}^name=sys_update_set`,
263
- sysparm_fields: "value"
264
- }
265
- });
266
- const result = await (0, snClient_1.unwrapSNResponse)(response);
267
- return result.length > 0 ? result[0].value : null;
292
+ const response = await client.getCurrentUpdateSet(scope);
293
+ const result = await response.data;
294
+ if (result && result.sysId) {
295
+ return result.sysId;
296
+ }
297
+ return null;
298
+ }
299
+ catch (e) {
300
+ return null;
301
+ }
302
+ }
303
+ /**
304
+ * Helper function to get current update set details
305
+ */
306
+ async function getCurrentUpdateSetDetails(scope) {
307
+ try {
308
+ const client = (0, snClient_1.defaultClient)();
309
+ const response = await client.getCurrentUpdateSet(scope);
310
+ const result = await response.data;
311
+ if (result && result.sysId) {
312
+ return {
313
+ sysId: result.sysId,
314
+ name: result.name || 'Unknown'
315
+ };
316
+ }
317
+ return null;
268
318
  }
269
319
  catch (e) {
270
320
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenonhq/sincronia-core",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "description": "Next-gen file syncer",
5
5
  "license": "GPL-3.0",
6
6
  "main": "./dist/index.js",