@tenonhq/sincronia-core 0.0.31 → 0.0.35
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/allScopesCommands.js +39 -2
- package/dist/updateSetCommands.js +23 -3
- package/package.json +1 -1
|
@@ -141,9 +141,46 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
141
141
|
else {
|
|
142
142
|
Logger_1.logger.info(`Found app: ${scopeApp.displayName} (${scopeName})`);
|
|
143
143
|
}
|
|
144
|
-
// Get manifest
|
|
144
|
+
// Get manifest for this scope (without files first)
|
|
145
145
|
Logger_1.logger.info(`Downloading manifest for scope: ${scopeName}`);
|
|
146
|
-
const manifest = await (0, snClient_1.unwrapSNResponse)(client.getManifest(scopeName, config,
|
|
146
|
+
const manifest = await (0, snClient_1.unwrapSNResponse)(client.getManifest(scopeName, config, false));
|
|
147
|
+
// Now get the actual files using getMissingFiles
|
|
148
|
+
Logger_1.logger.info(`Downloading files for scope: ${scopeName}...`);
|
|
149
|
+
const missing = {};
|
|
150
|
+
// Build missing files map from manifest
|
|
151
|
+
const tables = (manifest === null || manifest === void 0 ? void 0 : manifest.tables) || {};
|
|
152
|
+
for (const tableName of Object.keys(tables)) {
|
|
153
|
+
const table = tables[tableName];
|
|
154
|
+
for (const recordId of Object.keys(table.records || {})) {
|
|
155
|
+
const record = table.records[recordId];
|
|
156
|
+
if (record.files && record.files.length > 0) {
|
|
157
|
+
if (!missing[tableName]) {
|
|
158
|
+
missing[tableName] = {};
|
|
159
|
+
}
|
|
160
|
+
missing[tableName][recordId] = record.files.map(f => ({
|
|
161
|
+
name: f.name,
|
|
162
|
+
type: f.type
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// Fetch the actual file contents
|
|
168
|
+
let filesWithContent = {};
|
|
169
|
+
if (Object.keys(missing).length > 0) {
|
|
170
|
+
const tableOptions = (typeof scopeConfig === 'object' && scopeConfig.tableOptions) || config.tableOptions || {};
|
|
171
|
+
filesWithContent = await (0, snClient_1.unwrapSNResponse)(client.getMissingFiles(missing, tableOptions));
|
|
172
|
+
}
|
|
173
|
+
// Merge the file contents back into the manifest
|
|
174
|
+
for (const tableName of Object.keys(filesWithContent)) {
|
|
175
|
+
if (manifest.tables[tableName]) {
|
|
176
|
+
for (const recordId of Object.keys(filesWithContent[tableName].records || {})) {
|
|
177
|
+
if (manifest.tables[tableName].records[recordId]) {
|
|
178
|
+
manifest.tables[tableName].records[recordId].files =
|
|
179
|
+
filesWithContent[tableName].records[recordId].files;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
147
184
|
// Process the manifest to create local files in the correct directory
|
|
148
185
|
Logger_1.logger.info(`Processing manifest and creating local files for ${scopeName}...`);
|
|
149
186
|
Logger_1.logger.info(`Manifest has ${Object.keys((manifest === null || manifest === void 0 ? void 0 : manifest.tables) || {}).length} tables`);
|
|
@@ -219,8 +219,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
219
219
|
const createResult = await (0, snClient_1.unwrapSNResponse)(createResponse);
|
|
220
220
|
const updateSetSysId = createResult.sys_id;
|
|
221
221
|
// Switch to the new update set
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
Logger_1.logger.info(`Activating update set: ${name}`);
|
|
223
|
+
try {
|
|
224
|
+
await switchToUpdateSet(updateSetSysId, name, scope);
|
|
225
|
+
Logger_1.logger.info(chalk_1.default.green(`✓ Update set "${name}" created and activated`));
|
|
226
|
+
}
|
|
227
|
+
catch (switchError) {
|
|
228
|
+
Logger_1.logger.warn(`Update set "${name}" created but could not be activated automatically`);
|
|
229
|
+
Logger_1.logger.info(`You can manually switch to it using: npx sinc switchUpdateSet --name "${name}"`);
|
|
230
|
+
if (switchError instanceof Error) {
|
|
231
|
+
Logger_1.logger.debug(`Switch error: ${switchError.message}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
224
234
|
Logger_1.logger.info(`Update Set ID: ${updateSetSysId}`);
|
|
225
235
|
if (scope) {
|
|
226
236
|
Logger_1.logger.info(`Scope: ${scope}`);
|
|
@@ -373,6 +383,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
373
383
|
*/
|
|
374
384
|
async function switchToUpdateSet(updateSetSysId, name, scope) {
|
|
375
385
|
const client = (0, snClient_1.defaultClient)();
|
|
386
|
+
Logger_1.logger.debug(`Switching to update set - sysId: ${updateSetSysId}, name: ${name}, scope: ${scope}`);
|
|
376
387
|
// Use the new changeUpdateSet endpoint
|
|
377
388
|
// Can use either sysId or name+scope combination
|
|
378
389
|
const params = {};
|
|
@@ -386,10 +397,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
386
397
|
params.scope = scope;
|
|
387
398
|
}
|
|
388
399
|
const response = await client.changeUpdateSet(params);
|
|
389
|
-
|
|
400
|
+
let result = await response.data;
|
|
401
|
+
// Handle wrapped response
|
|
402
|
+
if (result && result.result) {
|
|
403
|
+
result = result.result;
|
|
404
|
+
}
|
|
405
|
+
Logger_1.logger.debug(`Change update set response: ${JSON.stringify(result)}`);
|
|
390
406
|
if (result.error) {
|
|
391
407
|
throw new Error(result.error);
|
|
392
408
|
}
|
|
409
|
+
// Check if the message indicates success
|
|
410
|
+
if (result.message && !result.message.includes("Success") && !result.message.includes("changed")) {
|
|
411
|
+
throw new Error(result.message);
|
|
412
|
+
}
|
|
393
413
|
}
|
|
394
414
|
/**
|
|
395
415
|
* Helper function to switch to a scope
|