@solidxai/core 0.1.20-beta.1 → 0.1.20-beta.3
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/.agents/skills/agenthub-agent-configuration/SKILL.md +41 -0
- package/.agents/skills/agenthub-agent-configuration/references/data-model.md +34 -0
- package/.agents/skills/agenthub-agent-configuration/references/runtime.md +28 -0
- package/CHANGELOG.md +27 -0
- package/dist/controllers/chatter-message-archive.controller.d.ts +22 -0
- package/dist/controllers/chatter-message-archive.controller.d.ts.map +1 -0
- package/dist/controllers/chatter-message-archive.controller.js +69 -0
- package/dist/controllers/chatter-message-archive.controller.js.map +1 -0
- package/dist/controllers/module-package.controller.d.ts +493 -1
- package/dist/controllers/module-package.controller.d.ts.map +1 -1
- package/dist/controllers/module-package.controller.js +47 -3
- package/dist/controllers/module-package.controller.js.map +1 -1
- package/dist/decorators/chatter-message-archive-provider.decorator.d.ts +3 -0
- package/dist/decorators/chatter-message-archive-provider.decorator.d.ts.map +1 -0
- package/dist/decorators/chatter-message-archive-provider.decorator.js +8 -0
- package/dist/decorators/chatter-message-archive-provider.decorator.js.map +1 -0
- package/dist/dtos/confirm-module-package-import.dto.d.ts +2 -0
- package/dist/dtos/confirm-module-package-import.dto.d.ts.map +1 -1
- package/dist/dtos/confirm-module-package-import.dto.js +20 -1
- package/dist/dtos/confirm-module-package-import.dto.js.map +1 -1
- package/dist/dtos/create-module-metadata.dto.d.ts +1 -0
- package/dist/dtos/create-module-metadata.dto.d.ts.map +1 -1
- package/dist/dtos/create-module-metadata.dto.js +7 -1
- package/dist/dtos/create-module-metadata.dto.js.map +1 -1
- package/dist/dtos/export-module-package.dto.d.ts +7 -0
- package/dist/dtos/export-module-package.dto.d.ts.map +1 -0
- package/dist/dtos/export-module-package.dto.js +44 -0
- package/dist/dtos/export-module-package.dto.js.map +1 -0
- package/dist/dtos/run-module-package-seed.dto.d.ts +1 -0
- package/dist/dtos/run-module-package-seed.dto.d.ts.map +1 -1
- package/dist/dtos/run-module-package-seed.dto.js +11 -1
- package/dist/dtos/run-module-package-seed.dto.js.map +1 -1
- package/dist/dtos/validate-module-package-import.dto.d.ts +4 -0
- package/dist/dtos/validate-module-package-import.dto.d.ts.map +1 -0
- package/dist/dtos/validate-module-package-import.dto.js +30 -0
- package/dist/dtos/validate-module-package-import.dto.js.map +1 -0
- package/dist/entities/agent-registry.entity.js.map +1 -1
- package/dist/entities/module-metadata.entity.d.ts +1 -0
- package/dist/entities/module-metadata.entity.d.ts.map +1 -1
- package/dist/entities/module-metadata.entity.js +5 -1
- package/dist/entities/module-metadata.entity.js.map +1 -1
- package/dist/helpers/agent-required-inputs.d.ts.map +1 -1
- package/dist/helpers/agent-required-inputs.js +25 -1
- package/dist/helpers/agent-required-inputs.js.map +1 -1
- package/dist/helpers/bootstrap.helper.d.ts +1 -1
- package/dist/helpers/bootstrap.helper.d.ts.map +1 -1
- package/dist/helpers/bootstrap.helper.js +9 -3
- package/dist/helpers/bootstrap.helper.js.map +1 -1
- package/dist/helpers/solid-registry.d.ts +4 -0
- package/dist/helpers/solid-registry.d.ts.map +1 -1
- package/dist/helpers/solid-registry.js +11 -0
- package/dist/helpers/solid-registry.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/chatter-message-archive.interface.d.ts +22 -0
- package/dist/interfaces/chatter-message-archive.interface.d.ts.map +1 -0
- package/dist/interfaces/chatter-message-archive.interface.js +3 -0
- package/dist/interfaces/chatter-message-archive.interface.js.map +1 -0
- package/dist/seeders/module-metadata-seeder.service.js +1 -1
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +110 -18
- package/dist/services/agent-tool-registry.service.d.ts.map +1 -1
- package/dist/services/agent-tool-registry.service.js +10 -6
- package/dist/services/agent-tool-registry.service.js.map +1 -1
- package/dist/services/chatter-message-archive.service.d.ts +17 -0
- package/dist/services/chatter-message-archive.service.d.ts.map +1 -0
- package/dist/services/chatter-message-archive.service.js +82 -0
- package/dist/services/chatter-message-archive.service.js.map +1 -0
- package/dist/services/model-metadata.service.js +1 -1
- package/dist/services/model-metadata.service.js.map +1 -1
- package/dist/services/module-package.service.d.ts +162 -3
- package/dist/services/module-package.service.d.ts.map +1 -1
- package/dist/services/module-package.service.js +465 -18
- package/dist/services/module-package.service.js.map +1 -1
- package/dist/services/settings/default-settings-provider.service.d.ts +20 -0
- package/dist/services/settings/default-settings-provider.service.d.ts.map +1 -1
- package/dist/services/settings/default-settings-provider.service.js +11 -0
- package/dist/services/settings/default-settings-provider.service.js.map +1 -1
- package/dist/services/solid-introspect.service.d.ts.map +1 -1
- package/dist/services/solid-introspect.service.js +5 -0
- package/dist/services/solid-introspect.service.js.map +1 -1
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +4 -0
- package/dist/solid-core.module.js.map +1 -1
- package/dist/testing/adapters/ui/playwright-adapter.d.ts +4 -0
- package/dist/testing/adapters/ui/playwright-adapter.d.ts.map +1 -1
- package/dist/testing/adapters/ui/playwright-adapter.js +35 -0
- package/dist/testing/adapters/ui/playwright-adapter.js.map +1 -1
- package/dist/testing/core/interpolation.d.ts.map +1 -1
- package/dist/testing/core/interpolation.js +38 -2
- package/dist/testing/core/interpolation.js.map +1 -1
- package/dist/testing/steps/ui/actions.step.d.ts.map +1 -1
- package/dist/testing/steps/ui/actions.step.js +40 -3
- package/dist/testing/steps/ui/actions.step.js.map +1 -1
- package/dist/testing/steps/ui/navigation.step.d.ts.map +1 -1
- package/dist/testing/steps/ui/navigation.step.js +39 -0
- package/dist/testing/steps/ui/navigation.step.js.map +1 -1
- package/package.json +4 -2
- package/src/controllers/chatter-message-archive.controller.ts +32 -0
- package/src/controllers/module-package.controller.ts +33 -1
- package/src/decorators/chatter-message-archive-provider.decorator.ts +4 -0
- package/src/dtos/confirm-module-package-import.dto.ts +17 -1
- package/src/dtos/create-module-metadata.dto.ts +5 -0
- package/src/dtos/export-module-package.dto.ts +23 -0
- package/src/dtos/run-module-package-seed.dto.ts +8 -0
- package/src/dtos/validate-module-package-import.dto.ts +11 -0
- package/src/entities/agent-registry.entity.ts +1 -1
- package/src/entities/module-metadata.entity.ts +3 -0
- package/src/helpers/agent-required-inputs.ts +18 -1
- package/src/helpers/bootstrap.helper.ts +15 -6
- package/src/helpers/solid-registry.ts +14 -0
- package/src/index.ts +3 -0
- package/src/interfaces/chatter-message-archive.interface.ts +22 -0
- package/src/seeders/module-metadata-seeder.service.ts +2 -2
- package/src/seeders/seed-data/solid-core-metadata.json +110 -18
- package/src/services/agent-tool-registry.service.ts +10 -6
- package/src/services/chatter-message-archive.service.ts +72 -0
- package/src/services/model-metadata.service.ts +1 -1
- package/src/services/module-package.service.ts +597 -14
- package/src/services/settings/default-settings-provider.service.ts +11 -0
- package/src/services/solid-introspect.service.ts +6 -0
- package/src/solid-core.module.ts +4 -0
- package/src/testing/adapters/ui/playwright-adapter.ts +44 -0
- package/src/testing/core/interpolation.ts +42 -2
- package/src/testing/steps/ui/actions.step.ts +52 -4
- package/src/testing/steps/ui/navigation.step.ts +56 -0
|
@@ -41,6 +41,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
41
41
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
42
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
43
|
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
44
47
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
49
|
};
|
|
@@ -48,15 +51,20 @@ var ModulePackageService_1;
|
|
|
48
51
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
52
|
exports.ModulePackageService = void 0;
|
|
50
53
|
const common_1 = require("@nestjs/common");
|
|
54
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
51
55
|
const crypto_1 = require("crypto");
|
|
52
56
|
const archiver_1 = __importDefault(require("archiver"));
|
|
53
57
|
const fs_1 = require("fs");
|
|
58
|
+
const semver = __importStar(require("semver"));
|
|
54
59
|
const disallow_in_production_decorator_1 = require("../decorators/disallow-in-production.decorator");
|
|
55
60
|
const confirm_module_package_import_dto_1 = require("../dtos/confirm-module-package-import.dto");
|
|
61
|
+
const export_module_package_dto_1 = require("../dtos/export-module-package.dto");
|
|
56
62
|
const run_module_package_build_dto_1 = require("../dtos/run-module-package-build.dto");
|
|
57
63
|
const run_module_package_seed_dto_1 = require("../dtos/run-module-package-seed.dto");
|
|
64
|
+
const module_metadata_entity_1 = require("../entities/module-metadata.entity");
|
|
58
65
|
const command_service_1 = require("../helpers/command.service");
|
|
59
66
|
const module_metadata_helper_service_1 = require("../helpers/module-metadata-helper.service");
|
|
67
|
+
const typeorm_2 = require("typeorm");
|
|
60
68
|
const fs = __importStar(require("fs/promises"));
|
|
61
69
|
const path = __importStar(require("path"));
|
|
62
70
|
const uuid_1 = require("uuid");
|
|
@@ -72,16 +80,18 @@ var ModulePackageStatus;
|
|
|
72
80
|
ModulePackageStatus["build_succeeded"] = "build_succeeded";
|
|
73
81
|
ModulePackageStatus["seed_running"] = "seed_running";
|
|
74
82
|
ModulePackageStatus["seed_failed"] = "seed_failed";
|
|
83
|
+
ModulePackageStatus["restore_running"] = "restore_running";
|
|
75
84
|
ModulePackageStatus["completed"] = "completed";
|
|
76
85
|
ModulePackageStatus["failed"] = "failed";
|
|
77
86
|
})(ModulePackageStatus || (ModulePackageStatus = {}));
|
|
78
87
|
let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
79
|
-
constructor(commandService, moduleMetadataHelperService) {
|
|
88
|
+
constructor(commandService, moduleMetadataHelperService, dataSource) {
|
|
80
89
|
this.commandService = commandService;
|
|
81
90
|
this.moduleMetadataHelperService = moduleMetadataHelperService;
|
|
91
|
+
this.dataSource = dataSource;
|
|
82
92
|
this.logger = new common_1.Logger(ModulePackageService_1.name);
|
|
83
93
|
}
|
|
84
|
-
async validateUpload(file) {
|
|
94
|
+
async validateUpload(file, expectedModuleNameInput) {
|
|
85
95
|
if (!file) {
|
|
86
96
|
throw new common_1.BadRequestException('A .sldx archive file is required.');
|
|
87
97
|
}
|
|
@@ -95,6 +105,7 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
95
105
|
await fs.rename(file.path, archiveFilePath);
|
|
96
106
|
const parsed = await this.parseArchive(archiveFilePath);
|
|
97
107
|
await this.extractArchive(archiveFilePath, extractDirPath);
|
|
108
|
+
await this.applyInstallStateToPreview(parsed, this.resolveExtractRoot(extractDirPath, parsed.archiveRootPrefix), (expectedModuleNameInput ?? '').trim() || null);
|
|
98
109
|
const transaction = {
|
|
99
110
|
transactionKey,
|
|
100
111
|
status: parsed.validation.valid ? ModulePackageStatus.awaiting_confirmation : ModulePackageStatus.failed,
|
|
@@ -110,10 +121,17 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
110
121
|
preview: parsed.preview,
|
|
111
122
|
validation: parsed.validation,
|
|
112
123
|
conflicts: parsed.preview.conflicts,
|
|
124
|
+
mode: parsed.preview.mode,
|
|
125
|
+
installedVersion: parsed.preview.installedVersion,
|
|
126
|
+
incomingVersion: parsed.preview.incomingVersion,
|
|
127
|
+
versionComparison: parsed.preview.versionComparison,
|
|
128
|
+
backup: null,
|
|
129
|
+
restoredFromBackup: false,
|
|
113
130
|
outputs: {
|
|
114
131
|
import: null,
|
|
115
132
|
build: null,
|
|
116
133
|
seed: null,
|
|
134
|
+
restore: null,
|
|
117
135
|
},
|
|
118
136
|
errorMessage: parsed.validation.valid ? null : parsed.validation.errors.join('\n'),
|
|
119
137
|
createdAt: new Date().toISOString(),
|
|
@@ -150,7 +168,7 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
150
168
|
clearedAt: new Date().toISOString(),
|
|
151
169
|
};
|
|
152
170
|
}
|
|
153
|
-
async exportModulePackage(moduleNameInput) {
|
|
171
|
+
async exportModulePackage(moduleNameInput, dto = {}) {
|
|
154
172
|
const moduleName = (moduleNameInput ?? '').trim();
|
|
155
173
|
if (!moduleName) {
|
|
156
174
|
throw new common_1.BadRequestException('A module name is required to export a module package.');
|
|
@@ -161,11 +179,17 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
161
179
|
await this.assertPathExists(solidApiModulePath, 'solid-api module path');
|
|
162
180
|
await this.assertPathExists(solidUiModulePath, 'solid-ui module path');
|
|
163
181
|
await this.assertPathExists(metadataFilePath, 'module metadata file');
|
|
164
|
-
|
|
182
|
+
let metadataDocument = this.parseMetadataDocument(await fs.readFile(metadataFilePath, 'utf-8'), []);
|
|
183
|
+
const currentVersion = this.toValidVersion(metadataDocument?.moduleMetadata?.version);
|
|
184
|
+
const exportVersion = this.resolveExportVersion(currentVersion, dto);
|
|
185
|
+
if (exportVersion !== currentVersion) {
|
|
186
|
+
metadataDocument = await this.writeModuleVersion(metadataFilePath, exportVersion);
|
|
187
|
+
await this.syncModuleVersionInDb(moduleName, exportVersion);
|
|
188
|
+
}
|
|
165
189
|
const transactionKey = (0, uuid_1.v4)();
|
|
166
190
|
const exportRoot = path.join(this.getModulePackageExportsRoot(), transactionKey);
|
|
167
191
|
const stagingDir = path.join(exportRoot, 'staging');
|
|
168
|
-
const archiveFileName = `${moduleName}.sldx`;
|
|
192
|
+
const archiveFileName = exportVersion ? `${moduleName}-v${exportVersion}.sldx` : `${moduleName}.sldx`;
|
|
169
193
|
const archiveFilePath = path.join(exportRoot, archiveFileName);
|
|
170
194
|
await fs.mkdir(path.join(stagingDir, 'solid-api', 'src'), { recursive: true });
|
|
171
195
|
await fs.mkdir(path.join(stagingDir, 'solid-ui', 'src'), { recursive: true });
|
|
@@ -193,8 +217,12 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
193
217
|
validation,
|
|
194
218
|
});
|
|
195
219
|
}
|
|
196
|
-
const
|
|
197
|
-
if (
|
|
220
|
+
const isUpdate = transaction.mode === 'update';
|
|
221
|
+
if (isUpdate) {
|
|
222
|
+
await this.assertUpdateApproved(transaction, dto);
|
|
223
|
+
}
|
|
224
|
+
const overwriteExisting = isUpdate || (dto.overwriteExisting ?? false);
|
|
225
|
+
if (!isUpdate && preview.conflicts.length > 0 && !overwriteExisting) {
|
|
198
226
|
throw new common_1.BadRequestException({
|
|
199
227
|
message: 'Conflicts were detected. Re-submit with overwriteExisting=true to continue.',
|
|
200
228
|
conflicts: preview.conflicts,
|
|
@@ -208,13 +236,15 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
208
236
|
const moduleName = preview.module.name;
|
|
209
237
|
const solidApiTarget = this.getSolidApiModuleTargetPath(moduleName);
|
|
210
238
|
const solidUiTarget = this.getSolidUiModuleTargetPath(moduleName);
|
|
211
|
-
const extractRoot = transaction.archiveRootPrefix
|
|
212
|
-
? path.join(transaction.extractDirPath, transaction.archiveRootPrefix.replace(/\/$/, ''))
|
|
213
|
-
: transaction.extractDirPath;
|
|
239
|
+
const extractRoot = this.resolveExtractRoot(transaction.extractDirPath, transaction.archiveRootPrefix);
|
|
214
240
|
const solidApiSource = path.join(extractRoot, 'solid-api', 'src', moduleName);
|
|
215
241
|
const solidUiSource = path.join(extractRoot, 'solid-ui', 'src', moduleName);
|
|
216
242
|
await this.assertPathExists(solidApiSource, 'solid-api module source');
|
|
217
243
|
await this.assertPathExists(solidUiSource, 'solid-ui module source');
|
|
244
|
+
if (isUpdate) {
|
|
245
|
+
transaction.backup = await this.backupModuleFolders(transactionKey, moduleName, transaction.installedVersion);
|
|
246
|
+
await this.writeStatusFile(transactionKey, transaction);
|
|
247
|
+
}
|
|
218
248
|
if (overwriteExisting) {
|
|
219
249
|
await fs.rm(solidApiTarget, { recursive: true, force: true });
|
|
220
250
|
await fs.rm(solidUiTarget, { recursive: true, force: true });
|
|
@@ -223,6 +253,7 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
223
253
|
await fs.mkdir(path.dirname(solidUiTarget), { recursive: true });
|
|
224
254
|
await fs.cp(solidApiSource, solidApiTarget, { recursive: true, force: overwriteExisting });
|
|
225
255
|
await fs.cp(solidUiSource, solidUiTarget, { recursive: true, force: overwriteExisting });
|
|
256
|
+
await this.writeModuleVersion(await this.moduleMetadataHelperService.getModuleMetadataFilePath(moduleName), transaction.incomingVersion);
|
|
226
257
|
if (transaction.extractDirPath) {
|
|
227
258
|
await fs.rm(transaction.extractDirPath, { recursive: true, force: true });
|
|
228
259
|
transaction.extractDirPath = null;
|
|
@@ -230,10 +261,14 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
230
261
|
transaction.status = ModulePackageStatus.awaiting_restart;
|
|
231
262
|
transaction.currentStep = 'restart';
|
|
232
263
|
transaction.outputs.import = [
|
|
264
|
+
isUpdate
|
|
265
|
+
? `Updated ${moduleName} from ${this.formatVersion(transaction.installedVersion)} to ${this.formatVersion(transaction.incomingVersion)}`
|
|
266
|
+
: null,
|
|
233
267
|
`Placed solid-api module at ${solidApiTarget}`,
|
|
234
268
|
`Placed solid-ui module at ${solidUiTarget}`,
|
|
235
269
|
`Metadata file placed at ${preview.requiredPaths.metadataPath}`,
|
|
236
|
-
|
|
270
|
+
transaction.backup ? `Backed up the previous module folders to ${transaction.backup.path}` : null,
|
|
271
|
+
].filter(Boolean).join('\n');
|
|
237
272
|
await this.writeStatusFile(transactionKey, transaction);
|
|
238
273
|
await this.syncActiveTransactionPointer(transaction);
|
|
239
274
|
return this.toStatusResponse(transaction);
|
|
@@ -320,15 +355,16 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
320
355
|
transaction.errorMessage = null;
|
|
321
356
|
await this.writeStatusFile(transactionKey, transaction);
|
|
322
357
|
try {
|
|
358
|
+
const seedArgs = ['seed', '--modules-to-seed', moduleName, ...(dto.prune ? ['--prune'] : [])];
|
|
323
359
|
const output = await this.commandService.executeCommandWithArgs({
|
|
324
360
|
command: 'npx',
|
|
325
|
-
args: ['-y', '@solidxai/solidctl@latest',
|
|
361
|
+
args: ['-y', '@solidxai/solidctl@latest', ...seedArgs],
|
|
326
362
|
cwd: this.getProjectRoot(),
|
|
327
363
|
});
|
|
328
364
|
transaction.status = ModulePackageStatus.completed;
|
|
329
365
|
transaction.currentStep = 'done';
|
|
330
366
|
transaction.outputs.seed = [
|
|
331
|
-
`solidctl
|
|
367
|
+
`solidctl ${seedArgs.join(' ')} [success]`,
|
|
332
368
|
output,
|
|
333
369
|
].filter(Boolean).join('\n');
|
|
334
370
|
await this.writeStatusFile(transactionKey, transaction);
|
|
@@ -345,6 +381,93 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
345
381
|
return this.toStatusResponse(transaction);
|
|
346
382
|
}
|
|
347
383
|
}
|
|
384
|
+
async getLatestBackup(moduleNameInput) {
|
|
385
|
+
const moduleName = (moduleNameInput ?? '').trim();
|
|
386
|
+
if (!moduleName) {
|
|
387
|
+
throw new common_1.BadRequestException('A module name is required to look up its backup.');
|
|
388
|
+
}
|
|
389
|
+
await this.cleanupModulePackageTransactions();
|
|
390
|
+
const candidates = [];
|
|
391
|
+
for (const entry of await this.readDirSafe(this.getModulePackageImportsRoot())) {
|
|
392
|
+
if (!entry.isDirectory() || !/^[a-zA-Z0-9-]+$/.test(entry.name)) {
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
try {
|
|
396
|
+
const transaction = await this.loadTransaction(entry.name);
|
|
397
|
+
if (transaction.moduleName === moduleName
|
|
398
|
+
&& transaction.backup
|
|
399
|
+
&& !transaction.restoredFromBackup
|
|
400
|
+
&& this.isRestorableStatus(transaction.status)
|
|
401
|
+
&& await this.pathExists(transaction.backup.path)) {
|
|
402
|
+
candidates.push(transaction);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
catch (error) {
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
candidates.sort((left, right) => new Date(right.backup.createdAt).getTime() - new Date(left.backup.createdAt).getTime());
|
|
410
|
+
const latest = candidates[0];
|
|
411
|
+
if (!latest) {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
const installedState = await this.resolveInstalledState(moduleName);
|
|
415
|
+
return {
|
|
416
|
+
...this.toStatusResponse(latest),
|
|
417
|
+
currentVersion: installedState.version,
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
async restoreBackup(transactionKey) {
|
|
421
|
+
const transaction = await this.loadTransaction(transactionKey);
|
|
422
|
+
const moduleName = transaction.moduleName;
|
|
423
|
+
const backup = transaction.backup;
|
|
424
|
+
if (!moduleName || !backup) {
|
|
425
|
+
throw new common_1.BadRequestException('This module package transaction has no backup to restore.');
|
|
426
|
+
}
|
|
427
|
+
if (!this.isRestorableStatus(transaction.status)) {
|
|
428
|
+
throw new common_1.BadRequestException(`A backup cannot be restored while the transaction is ${transaction.status}.`);
|
|
429
|
+
}
|
|
430
|
+
await this.assertPathExists(backup.path, 'module backup');
|
|
431
|
+
transaction.status = ModulePackageStatus.restore_running;
|
|
432
|
+
transaction.currentStep = 'restore';
|
|
433
|
+
transaction.errorMessage = null;
|
|
434
|
+
await this.writeStatusFile(transactionKey, transaction);
|
|
435
|
+
try {
|
|
436
|
+
const targets = [
|
|
437
|
+
{ label: 'solid-api', source: path.join(backup.path, 'solid-api'), target: this.getSolidApiModuleTargetPath(moduleName) },
|
|
438
|
+
{ label: 'solid-ui', source: path.join(backup.path, 'solid-ui'), target: this.getSolidUiModuleTargetPath(moduleName) },
|
|
439
|
+
];
|
|
440
|
+
const outputs = [`Restored ${moduleName} ${this.formatVersion(backup.version)} from ${backup.path}`];
|
|
441
|
+
for (const { label, source, target } of targets) {
|
|
442
|
+
await fs.rm(target, { recursive: true, force: true });
|
|
443
|
+
if (await this.pathExists(source)) {
|
|
444
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
445
|
+
await fs.cp(source, target, { recursive: true });
|
|
446
|
+
outputs.push(`Restored ${label} module at ${target}`);
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
outputs.push(`Removed ${label} module at ${target} (it did not exist before the update)`);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
transaction.status = ModulePackageStatus.awaiting_restart;
|
|
453
|
+
transaction.currentStep = 'restart';
|
|
454
|
+
transaction.restoredFromBackup = true;
|
|
455
|
+
transaction.outputs.restore = outputs.join('\n');
|
|
456
|
+
transaction.outputs.build = null;
|
|
457
|
+
transaction.outputs.seed = null;
|
|
458
|
+
await this.writeStatusFile(transactionKey, transaction);
|
|
459
|
+
await this.syncActiveTransactionPointer(transaction);
|
|
460
|
+
return this.toStatusResponse(transaction);
|
|
461
|
+
}
|
|
462
|
+
catch (error) {
|
|
463
|
+
transaction.status = ModulePackageStatus.failed;
|
|
464
|
+
transaction.currentStep = 'restore';
|
|
465
|
+
transaction.errorMessage = error.message ?? 'Failed to restore the module backup.';
|
|
466
|
+
await this.writeStatusFile(transactionKey, transaction);
|
|
467
|
+
await this.syncActiveTransactionPointer(transaction);
|
|
468
|
+
throw error;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
348
471
|
async parseArchive(archiveFilePath) {
|
|
349
472
|
const entries = await this.listArchiveEntries(archiveFilePath);
|
|
350
473
|
const archiveRootPrefix = this.detectArchiveRootPrefix(entries);
|
|
@@ -379,6 +502,7 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
379
502
|
},
|
|
380
503
|
preview: {
|
|
381
504
|
module: { name: '', displayName: '' },
|
|
505
|
+
...this.getEmptyInstallState(),
|
|
382
506
|
manifest: this.getFallbackManifest(),
|
|
383
507
|
contentsSummary: {
|
|
384
508
|
totalEntries: normalizedEntries.length,
|
|
@@ -405,6 +529,12 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
405
529
|
if (!manifest.module?.name) {
|
|
406
530
|
validationErrors.push('manifest.json module.name is required.');
|
|
407
531
|
}
|
|
532
|
+
if (manifest.module?.version !== undefined && manifest.module?.version !== null && !this.toValidVersion(manifest.module.version)) {
|
|
533
|
+
validationErrors.push(`manifest.json module.version "${manifest.module.version}" is not a valid semver version.`);
|
|
534
|
+
}
|
|
535
|
+
if (!this.toValidVersion(manifest.module?.version)) {
|
|
536
|
+
validationWarnings.push('This package is unversioned.');
|
|
537
|
+
}
|
|
408
538
|
const moduleName = manifest.module?.name ?? '';
|
|
409
539
|
const expectedPaths = this.buildExpectedPaths(moduleName);
|
|
410
540
|
if (manifest.contents?.metadataPath !== expectedPaths.metadataPath) {
|
|
@@ -437,7 +567,7 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
437
567
|
}
|
|
438
568
|
const conflicts = await this.detectConflicts(moduleName);
|
|
439
569
|
if (conflicts.length > 0) {
|
|
440
|
-
validationWarnings.push(
|
|
570
|
+
validationWarnings.push(ModulePackageService_1.OVERWRITE_CONFIRMATION_WARNING);
|
|
441
571
|
}
|
|
442
572
|
const validation = {
|
|
443
573
|
valid: validationErrors.length === 0,
|
|
@@ -446,6 +576,8 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
446
576
|
};
|
|
447
577
|
const preview = {
|
|
448
578
|
module: manifest.module,
|
|
579
|
+
...this.getEmptyInstallState(),
|
|
580
|
+
incomingVersion: this.toValidVersion(manifest.module?.version),
|
|
449
581
|
manifest,
|
|
450
582
|
contentsSummary: {
|
|
451
583
|
totalEntries: normalizedEntries.length,
|
|
@@ -470,6 +602,269 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
470
602
|
preview,
|
|
471
603
|
};
|
|
472
604
|
}
|
|
605
|
+
getEmptyInstallState() {
|
|
606
|
+
return {
|
|
607
|
+
mode: 'install',
|
|
608
|
+
installedVersion: null,
|
|
609
|
+
incomingVersion: null,
|
|
610
|
+
versionComparison: null,
|
|
611
|
+
requiresVersionAcknowledgement: false,
|
|
612
|
+
identicalContent: false,
|
|
613
|
+
contentFingerprint: null,
|
|
614
|
+
changeSet: null,
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
async applyInstallStateToPreview(parsed, extractRoot, expectedModuleName) {
|
|
618
|
+
const { preview, validation } = parsed;
|
|
619
|
+
const moduleName = parsed.manifest.module?.name ?? '';
|
|
620
|
+
if (expectedModuleName && moduleName !== expectedModuleName) {
|
|
621
|
+
validation.errors.push(`This package is for module "${moduleName || 'unknown'}", but you are updating "${expectedModuleName}".`);
|
|
622
|
+
}
|
|
623
|
+
if (moduleName) {
|
|
624
|
+
validation.errors.push(...await this.verifyArchiveChecksums(parsed.manifest, extractRoot));
|
|
625
|
+
const incomingChecksums = await this.computeModuleContentChecksums(path.join(extractRoot, 'solid-api', 'src', moduleName), path.join(extractRoot, 'solid-ui', 'src', moduleName), moduleName);
|
|
626
|
+
preview.contentFingerprint = this.computeContentFingerprint(incomingChecksums);
|
|
627
|
+
const installedState = await this.resolveInstalledState(moduleName);
|
|
628
|
+
preview.versionComparison = this.compareModuleVersions(installedState, preview.incomingVersion);
|
|
629
|
+
if (installedState.installed) {
|
|
630
|
+
const installedChecksums = await this.computeModuleContentChecksums(this.getSolidApiModuleTargetPath(moduleName), this.getSolidUiModuleTargetPath(moduleName), moduleName);
|
|
631
|
+
preview.mode = 'update';
|
|
632
|
+
preview.installedVersion = installedState.version;
|
|
633
|
+
preview.identicalContent = this.computeContentFingerprint(installedChecksums) === preview.contentFingerprint;
|
|
634
|
+
preview.changeSet = {
|
|
635
|
+
solidApi: this.diffChecksums(installedChecksums, incomingChecksums, `solid-api/src/${moduleName}/`),
|
|
636
|
+
solidUi: this.diffChecksums(installedChecksums, incomingChecksums, `solid-ui/src/${moduleName}/`),
|
|
637
|
+
};
|
|
638
|
+
preview.requiresVersionAcknowledgement = preview.identicalContent
|
|
639
|
+
|| ModulePackageService_1.VERSION_ACKNOWLEDGEMENT_COMPARISONS.includes(preview.versionComparison);
|
|
640
|
+
preview.nextActions = [
|
|
641
|
+
'Review the version change and the files that will change.',
|
|
642
|
+
'Approve the update to replace the module folders. The current folders are backed up first.',
|
|
643
|
+
'Wait for service restart, then run build and seed.',
|
|
644
|
+
];
|
|
645
|
+
validation.warnings = validation.warnings.filter((warning) => warning !== ModulePackageService_1.OVERWRITE_CONFIRMATION_WARNING);
|
|
646
|
+
validation.warnings.push(...this.buildUpdateWarnings(preview));
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
validation.valid = validation.errors.length === 0;
|
|
650
|
+
}
|
|
651
|
+
buildUpdateWarnings(preview) {
|
|
652
|
+
const installed = this.formatVersion(preview.installedVersion);
|
|
653
|
+
const incoming = this.formatVersion(preview.incomingVersion);
|
|
654
|
+
const warnings = [];
|
|
655
|
+
if (preview.versionComparison === 'downgrade') {
|
|
656
|
+
warnings.push(`This package (${incoming}) is older than the installed version (${installed}).`);
|
|
657
|
+
}
|
|
658
|
+
else if (preview.versionComparison === 'same') {
|
|
659
|
+
warnings.push(preview.identicalContent
|
|
660
|
+
? `${installed} is already installed with identical content.`
|
|
661
|
+
: `${installed} is already installed, but this package's content is different.`);
|
|
662
|
+
}
|
|
663
|
+
else if (preview.versionComparison === 'legacy_package' && preview.installedVersion) {
|
|
664
|
+
warnings.push(`The installed module is ${installed}, but this package is unversioned. After the update the module will be unversioned.`);
|
|
665
|
+
}
|
|
666
|
+
if (preview.identicalContent && preview.versionComparison !== 'same') {
|
|
667
|
+
warnings.push('The package content is identical to the installed module.');
|
|
668
|
+
}
|
|
669
|
+
warnings.push('Updating replaces the solid-api and solid-ui module folders. Local changes inside them are kept only in the backup.');
|
|
670
|
+
return warnings;
|
|
671
|
+
}
|
|
672
|
+
compareModuleVersions(installedState, incomingVersion) {
|
|
673
|
+
if (!installedState.installed) {
|
|
674
|
+
return 'new';
|
|
675
|
+
}
|
|
676
|
+
if (!incomingVersion) {
|
|
677
|
+
return 'legacy_package';
|
|
678
|
+
}
|
|
679
|
+
if (!installedState.version) {
|
|
680
|
+
return 'first_version';
|
|
681
|
+
}
|
|
682
|
+
const comparison = semver.compare(incomingVersion, installedState.version);
|
|
683
|
+
return comparison > 0 ? 'upgrade' : comparison === 0 ? 'same' : 'downgrade';
|
|
684
|
+
}
|
|
685
|
+
async assertUpdateApproved(transaction, dto) {
|
|
686
|
+
const moduleName = transaction.moduleName;
|
|
687
|
+
const incomingVersion = transaction.incomingVersion ?? null;
|
|
688
|
+
if ((dto.confirmedVersion ?? null) !== incomingVersion) {
|
|
689
|
+
throw new common_1.BadRequestException({
|
|
690
|
+
message: `Approve the update to ${this.formatVersion(incomingVersion)} to continue.`,
|
|
691
|
+
incomingVersion,
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
if (transaction.preview?.requiresVersionAcknowledgement && !dto.acknowledgeVersionChange) {
|
|
695
|
+
throw new common_1.BadRequestException('This update is a reinstall, a downgrade, identical content or an unversioned package. Acknowledge the version change to continue.');
|
|
696
|
+
}
|
|
697
|
+
const currentState = await this.resolveInstalledState(moduleName);
|
|
698
|
+
if (!currentState.installed || currentState.version !== transaction.installedVersion) {
|
|
699
|
+
throw new common_1.BadRequestException(`The installed module changed since this package was previewed (now ${this.formatVersion(currentState.version)}). Upload the package again to refresh the preview.`);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
async resolveInstalledState(moduleName) {
|
|
703
|
+
const metadataFilePath = await this.moduleMetadataHelperService.getModuleMetadataFilePath(moduleName);
|
|
704
|
+
const installed = (await this.pathExists(this.getSolidApiModuleTargetPath(moduleName)))
|
|
705
|
+
|| (await this.pathExists(this.getSolidUiModuleTargetPath(moduleName)))
|
|
706
|
+
|| (await this.pathExists(metadataFilePath));
|
|
707
|
+
let version = null;
|
|
708
|
+
if (await this.pathExists(metadataFilePath)) {
|
|
709
|
+
try {
|
|
710
|
+
const metadataDocument = JSON.parse(await fs.readFile(metadataFilePath, 'utf-8'));
|
|
711
|
+
version = this.toValidVersion(metadataDocument?.moduleMetadata?.version);
|
|
712
|
+
}
|
|
713
|
+
catch (error) {
|
|
714
|
+
version = null;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
return { installed, version };
|
|
718
|
+
}
|
|
719
|
+
async verifyArchiveChecksums(manifest, extractRoot) {
|
|
720
|
+
const expected = manifest.checksums;
|
|
721
|
+
if (!expected || Object.keys(expected).length === 0) {
|
|
722
|
+
return [];
|
|
723
|
+
}
|
|
724
|
+
const actual = await this.computeDirectoryChecksums(extractRoot, ['manifest.json']);
|
|
725
|
+
const actualPaths = Object.keys(actual).filter((entry) => !this.isMacOsMetadataEntry(entry));
|
|
726
|
+
const missing = Object.keys(expected).filter((entry) => !(entry in actual));
|
|
727
|
+
const unexpected = actualPaths.filter((entry) => !(entry in expected));
|
|
728
|
+
const mismatched = Object.keys(expected).filter((entry) => entry in actual && actual[entry] !== expected[entry]);
|
|
729
|
+
const errors = [];
|
|
730
|
+
if (mismatched.length > 0) {
|
|
731
|
+
errors.push(`Checksum mismatch for ${this.summarizePaths(mismatched)}. The package may be corrupted or was modified after export.`);
|
|
732
|
+
}
|
|
733
|
+
if (missing.length > 0) {
|
|
734
|
+
errors.push(`Archive is missing files listed in manifest.json checksums: ${this.summarizePaths(missing)}.`);
|
|
735
|
+
}
|
|
736
|
+
if (unexpected.length > 0) {
|
|
737
|
+
errors.push(`Archive contains files not listed in manifest.json checksums: ${this.summarizePaths(unexpected)}.`);
|
|
738
|
+
}
|
|
739
|
+
return errors;
|
|
740
|
+
}
|
|
741
|
+
async computeModuleContentChecksums(solidApiDir, solidUiDir, moduleName) {
|
|
742
|
+
const checksums = {};
|
|
743
|
+
const roots = [
|
|
744
|
+
[`solid-api/src/${moduleName}`, solidApiDir],
|
|
745
|
+
[`solid-ui/src/${moduleName}`, solidUiDir],
|
|
746
|
+
];
|
|
747
|
+
for (const [prefix, rootDir] of roots) {
|
|
748
|
+
if (!(await this.pathExists(rootDir))) {
|
|
749
|
+
continue;
|
|
750
|
+
}
|
|
751
|
+
const rootChecksums = await this.computeDirectoryChecksums(rootDir);
|
|
752
|
+
for (const [relativePath, checksum] of Object.entries(rootChecksums)) {
|
|
753
|
+
if (this.isMacOsMetadataEntry(relativePath) || path.posix.basename(relativePath) === '.DS_Store') {
|
|
754
|
+
continue;
|
|
755
|
+
}
|
|
756
|
+
checksums[`${prefix}/${relativePath}`] = checksum;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
const metadataKey = `solid-api/src/${moduleName}/metadata/${moduleName}-metadata.json`;
|
|
760
|
+
if (checksums[metadataKey]) {
|
|
761
|
+
const metadataText = await fs.readFile(path.join(solidApiDir, 'metadata', `${moduleName}-metadata.json`), 'utf-8');
|
|
762
|
+
try {
|
|
763
|
+
const versionless = this.withModuleVersion(JSON.parse(metadataText), null);
|
|
764
|
+
checksums[metadataKey] = (0, crypto_1.createHash)('sha256').update(JSON.stringify(versionless)).digest('hex');
|
|
765
|
+
}
|
|
766
|
+
catch (error) {
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
return checksums;
|
|
770
|
+
}
|
|
771
|
+
computeContentFingerprint(checksums) {
|
|
772
|
+
const lines = Object.keys(checksums).sort().map((entry) => `${entry}:${checksums[entry]}`);
|
|
773
|
+
return (0, crypto_1.createHash)('sha256').update(lines.join('\n')).digest('hex');
|
|
774
|
+
}
|
|
775
|
+
diffChecksums(installed, incoming, prefix) {
|
|
776
|
+
const strip = (entries) => entries.filter((entry) => entry.startsWith(prefix)).map((entry) => entry.slice(prefix.length)).sort();
|
|
777
|
+
const installedPaths = Object.keys(installed);
|
|
778
|
+
const incomingPaths = Object.keys(incoming);
|
|
779
|
+
const added = strip(incomingPaths.filter((entry) => !(entry in installed)));
|
|
780
|
+
const removed = strip(installedPaths.filter((entry) => !(entry in incoming)));
|
|
781
|
+
const shared = incomingPaths.filter((entry) => entry in installed);
|
|
782
|
+
const modified = strip(shared.filter((entry) => installed[entry] !== incoming[entry]));
|
|
783
|
+
const unchangedCount = strip(shared.filter((entry) => installed[entry] === incoming[entry])).length;
|
|
784
|
+
return { added, modified, removed, unchangedCount };
|
|
785
|
+
}
|
|
786
|
+
async backupModuleFolders(transactionKey, moduleName, version) {
|
|
787
|
+
const backupPath = path.join(this.getModulePackageBackupsRoot(), transactionKey);
|
|
788
|
+
await fs.rm(backupPath, { recursive: true, force: true });
|
|
789
|
+
await fs.mkdir(backupPath, { recursive: true });
|
|
790
|
+
const sources = [
|
|
791
|
+
['solid-api', this.getSolidApiModuleTargetPath(moduleName)],
|
|
792
|
+
['solid-ui', this.getSolidUiModuleTargetPath(moduleName)],
|
|
793
|
+
];
|
|
794
|
+
for (const [label, sourcePath] of sources) {
|
|
795
|
+
if (await this.pathExists(sourcePath)) {
|
|
796
|
+
await fs.cp(sourcePath, path.join(backupPath, label), { recursive: true });
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
const backup = { path: backupPath, version, createdAt: new Date().toISOString() };
|
|
800
|
+
await fs.writeFile(path.join(backupPath, 'backup.json'), JSON.stringify({ moduleName, ...backup }, null, 2));
|
|
801
|
+
return backup;
|
|
802
|
+
}
|
|
803
|
+
resolveExportVersion(currentVersion, dto) {
|
|
804
|
+
const explicitVersion = (dto.version ?? '').trim();
|
|
805
|
+
if (explicitVersion) {
|
|
806
|
+
const version = this.toValidVersion(explicitVersion);
|
|
807
|
+
if (!version) {
|
|
808
|
+
throw new common_1.BadRequestException(`"${explicitVersion}" is not a valid semver version.`);
|
|
809
|
+
}
|
|
810
|
+
if (currentVersion && version !== currentVersion) {
|
|
811
|
+
throw new common_1.BadRequestException(`This module is already at v${currentVersion}. Choose a patch, minor or major bump instead.`);
|
|
812
|
+
}
|
|
813
|
+
return version;
|
|
814
|
+
}
|
|
815
|
+
const bump = dto.bump ?? 'none';
|
|
816
|
+
if (bump === 'none') {
|
|
817
|
+
return currentVersion;
|
|
818
|
+
}
|
|
819
|
+
const nextVersion = semver.inc(currentVersion ?? '0.0.0', bump);
|
|
820
|
+
if (!nextVersion) {
|
|
821
|
+
throw new common_1.BadRequestException(`Unable to bump version ${currentVersion ?? '0.0.0'} by ${bump}.`);
|
|
822
|
+
}
|
|
823
|
+
return nextVersion;
|
|
824
|
+
}
|
|
825
|
+
async writeModuleVersion(metadataFilePath, version) {
|
|
826
|
+
const currentDocument = JSON.parse(await fs.readFile(metadataFilePath, 'utf-8'));
|
|
827
|
+
if ((currentDocument?.moduleMetadata?.version ?? null) === version) {
|
|
828
|
+
return currentDocument;
|
|
829
|
+
}
|
|
830
|
+
const metadataDocument = this.withModuleVersion(currentDocument, version);
|
|
831
|
+
await fs.writeFile(metadataFilePath, JSON.stringify(metadataDocument, null, 2));
|
|
832
|
+
return metadataDocument;
|
|
833
|
+
}
|
|
834
|
+
withModuleVersion(metadataDocument, version) {
|
|
835
|
+
if (!metadataDocument?.moduleMetadata) {
|
|
836
|
+
return metadataDocument;
|
|
837
|
+
}
|
|
838
|
+
const { version: _previousVersion, ...moduleMetadata } = metadataDocument.moduleMetadata;
|
|
839
|
+
const entries = Object.entries(moduleMetadata);
|
|
840
|
+
if (version) {
|
|
841
|
+
entries.splice(entries.findIndex(([key]) => key === 'name') + 1, 0, ['version', version]);
|
|
842
|
+
}
|
|
843
|
+
return { ...metadataDocument, moduleMetadata: Object.fromEntries(entries) };
|
|
844
|
+
}
|
|
845
|
+
async syncModuleVersionInDb(moduleName, version) {
|
|
846
|
+
try {
|
|
847
|
+
await this.dataSource.getRepository(module_metadata_entity_1.ModuleMetadata).update({ name: moduleName }, { version });
|
|
848
|
+
}
|
|
849
|
+
catch (error) {
|
|
850
|
+
this.logger.warn(`Failed to update the version of module ${moduleName} in the database: ${String(error)}`);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
toValidVersion(value) {
|
|
854
|
+
return typeof value === 'string' ? semver.valid(value.trim()) : null;
|
|
855
|
+
}
|
|
856
|
+
formatVersion(version) {
|
|
857
|
+
return version ? `v${version}` : 'unversioned';
|
|
858
|
+
}
|
|
859
|
+
summarizePaths(paths, limit = 5) {
|
|
860
|
+
const shown = paths.slice(0, limit).join(', ');
|
|
861
|
+
return paths.length > limit ? `${shown} and ${paths.length - limit} more` : shown;
|
|
862
|
+
}
|
|
863
|
+
resolveExtractRoot(extractDirPath, archiveRootPrefix) {
|
|
864
|
+
return archiveRootPrefix
|
|
865
|
+
? path.join(extractDirPath, archiveRootPrefix.replace(/\/$/, ''))
|
|
866
|
+
: extractDirPath;
|
|
867
|
+
}
|
|
473
868
|
parseManifest(manifestText, validationErrors) {
|
|
474
869
|
if (!manifestText) {
|
|
475
870
|
return null;
|
|
@@ -596,7 +991,25 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
596
991
|
if (!(await this.pathExists(statusFilePath))) {
|
|
597
992
|
throw new common_1.NotFoundException(`Module package transaction ${transactionKey} was not found.`);
|
|
598
993
|
}
|
|
599
|
-
return JSON.parse(await fs.readFile(statusFilePath, 'utf-8'));
|
|
994
|
+
return this.normalizeTransaction(JSON.parse(await fs.readFile(statusFilePath, 'utf-8')));
|
|
995
|
+
}
|
|
996
|
+
normalizeTransaction(transaction) {
|
|
997
|
+
return {
|
|
998
|
+
...transaction,
|
|
999
|
+
mode: transaction.mode ?? 'install',
|
|
1000
|
+
installedVersion: transaction.installedVersion ?? null,
|
|
1001
|
+
incomingVersion: transaction.incomingVersion ?? this.toValidVersion(transaction.manifest?.module?.version),
|
|
1002
|
+
versionComparison: transaction.versionComparison ?? null,
|
|
1003
|
+
backup: transaction.backup ?? null,
|
|
1004
|
+
restoredFromBackup: transaction.restoredFromBackup ?? false,
|
|
1005
|
+
outputs: {
|
|
1006
|
+
import: null,
|
|
1007
|
+
build: null,
|
|
1008
|
+
seed: null,
|
|
1009
|
+
restore: null,
|
|
1010
|
+
...(transaction.outputs ?? {}),
|
|
1011
|
+
},
|
|
1012
|
+
};
|
|
600
1013
|
}
|
|
601
1014
|
isResumableStatus(status) {
|
|
602
1015
|
return [
|
|
@@ -607,8 +1020,13 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
607
1020
|
ModulePackageStatus.build_succeeded,
|
|
608
1021
|
ModulePackageStatus.seed_running,
|
|
609
1022
|
ModulePackageStatus.seed_failed,
|
|
1023
|
+
ModulePackageStatus.restore_running,
|
|
610
1024
|
].includes(status);
|
|
611
1025
|
}
|
|
1026
|
+
isRestorableStatus(status) {
|
|
1027
|
+
return this.isResumableStatus(status)
|
|
1028
|
+
|| [ModulePackageStatus.failed, ModulePackageStatus.completed].includes(status);
|
|
1029
|
+
}
|
|
612
1030
|
async createWorkingDir(transactionKey) {
|
|
613
1031
|
const baseDir = path.join(this.getModulePackageImportsRoot(), transactionKey);
|
|
614
1032
|
await fs.mkdir(baseDir, { recursive: true });
|
|
@@ -629,6 +1047,9 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
629
1047
|
getModulePackageExportsRoot() {
|
|
630
1048
|
return path.join(this.getModulePackageRuntimeRoot(), 'module-package-exports');
|
|
631
1049
|
}
|
|
1050
|
+
getModulePackageBackupsRoot() {
|
|
1051
|
+
return path.join(this.getModulePackageRuntimeRoot(), 'module-package-backups');
|
|
1052
|
+
}
|
|
632
1053
|
getModulePackageRuntimeRoot() {
|
|
633
1054
|
const configuredRuntimeRoot = process.env.SOLIDX_MODULE_PACKAGE_RUNTIME_DIR?.trim();
|
|
634
1055
|
if (configuredRuntimeRoot) {
|
|
@@ -716,6 +1137,7 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
716
1137
|
async collectRuntimeCleanupSnapshot() {
|
|
717
1138
|
const importEntries = await this.readDirSafe(this.getModulePackageImportsRoot());
|
|
718
1139
|
const exportEntries = await this.readDirSafe(this.getModulePackageExportsRoot());
|
|
1140
|
+
const backupEntries = await this.readDirSafe(this.getModulePackageBackupsRoot());
|
|
719
1141
|
const importTransactionEntries = importEntries.filter((entry) => entry.isDirectory() && /^[a-zA-Z0-9-]+$/.test(entry.name));
|
|
720
1142
|
const exportTransactionEntries = exportEntries.filter((entry) => entry.isDirectory() && /^[a-zA-Z0-9-]+$/.test(entry.name));
|
|
721
1143
|
const importLooseEntries = importEntries.filter((entry) => !(entry.isDirectory() && /^[a-zA-Z0-9-]+$/.test(entry.name)));
|
|
@@ -725,6 +1147,7 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
725
1147
|
removedExportTransactions: exportTransactionEntries.length,
|
|
726
1148
|
removedImportLooseEntries: importLooseEntries.length,
|
|
727
1149
|
removedExportLooseEntries: exportLooseEntries.length,
|
|
1150
|
+
removedBackups: backupEntries.filter((entry) => entry.isDirectory()).length,
|
|
728
1151
|
clearedActiveTransactionPointer: importEntries.some((entry) => entry.name === 'active-transaction.json'),
|
|
729
1152
|
};
|
|
730
1153
|
}
|
|
@@ -772,6 +1195,7 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
772
1195
|
continue;
|
|
773
1196
|
}
|
|
774
1197
|
await fs.rm(path.join(importsRoot, transactionKey), { recursive: true, force: true });
|
|
1198
|
+
await fs.rm(path.join(this.getModulePackageBackupsRoot(), transactionKey), { recursive: true, force: true });
|
|
775
1199
|
if (activePointer?.transactionKey === transactionKey) {
|
|
776
1200
|
await fs.rm(this.getActiveTransactionFilePath(), { force: true });
|
|
777
1201
|
}
|
|
@@ -839,6 +1263,12 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
839
1263
|
currentStep: transaction.currentStep,
|
|
840
1264
|
moduleName: transaction.moduleName,
|
|
841
1265
|
moduleDisplayName: transaction.moduleDisplayName,
|
|
1266
|
+
mode: transaction.mode,
|
|
1267
|
+
installedVersion: transaction.installedVersion,
|
|
1268
|
+
incomingVersion: transaction.incomingVersion,
|
|
1269
|
+
versionComparison: transaction.versionComparison,
|
|
1270
|
+
backup: transaction.backup,
|
|
1271
|
+
restoredFromBackup: transaction.restoredFromBackup,
|
|
842
1272
|
archiveFileName: transaction.archiveFileName,
|
|
843
1273
|
manifest: transaction.manifest,
|
|
844
1274
|
preview: transaction.preview,
|
|
@@ -862,6 +1292,7 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
862
1292
|
},
|
|
863
1293
|
module: {
|
|
864
1294
|
name: moduleName,
|
|
1295
|
+
version: this.toValidVersion(metadataDocument?.moduleMetadata?.version) ?? undefined,
|
|
865
1296
|
displayName: metadataDocument?.moduleMetadata?.displayName,
|
|
866
1297
|
description: metadataDocument?.moduleMetadata?.description,
|
|
867
1298
|
},
|
|
@@ -924,10 +1355,12 @@ let ModulePackageService = ModulePackageService_1 = class ModulePackageService {
|
|
|
924
1355
|
exports.ModulePackageService = ModulePackageService;
|
|
925
1356
|
ModulePackageService.SUPPORTED_SCHEMA_VERSION = '1.0';
|
|
926
1357
|
ModulePackageService.SUPPORTED_PACKAGE_TYPE = 'solidx-module';
|
|
1358
|
+
ModulePackageService.OVERWRITE_CONFIRMATION_WARNING = 'The target module already exists locally and will require overwrite confirmation.';
|
|
1359
|
+
ModulePackageService.VERSION_ACKNOWLEDGEMENT_COMPARISONS = ['same', 'downgrade', 'legacy_package'];
|
|
927
1360
|
__decorate([
|
|
928
1361
|
(0, disallow_in_production_decorator_1.DisallowInProduction)(),
|
|
929
1362
|
__metadata("design:type", Function),
|
|
930
|
-
__metadata("design:paramtypes", [Object]),
|
|
1363
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
931
1364
|
__metadata("design:returntype", Promise)
|
|
932
1365
|
], ModulePackageService.prototype, "validateUpload", null);
|
|
933
1366
|
__decorate([
|
|
@@ -951,7 +1384,7 @@ __decorate([
|
|
|
951
1384
|
__decorate([
|
|
952
1385
|
(0, disallow_in_production_decorator_1.DisallowInProduction)(),
|
|
953
1386
|
__metadata("design:type", Function),
|
|
954
|
-
__metadata("design:paramtypes", [String]),
|
|
1387
|
+
__metadata("design:paramtypes", [String, export_module_package_dto_1.ExportModulePackageDto]),
|
|
955
1388
|
__metadata("design:returntype", Promise)
|
|
956
1389
|
], ModulePackageService.prototype, "exportModulePackage", null);
|
|
957
1390
|
__decorate([
|
|
@@ -972,9 +1405,23 @@ __decorate([
|
|
|
972
1405
|
__metadata("design:paramtypes", [String, run_module_package_seed_dto_1.RunModulePackageSeedDto]),
|
|
973
1406
|
__metadata("design:returntype", Promise)
|
|
974
1407
|
], ModulePackageService.prototype, "runSeed", null);
|
|
1408
|
+
__decorate([
|
|
1409
|
+
(0, disallow_in_production_decorator_1.DisallowInProduction)(),
|
|
1410
|
+
__metadata("design:type", Function),
|
|
1411
|
+
__metadata("design:paramtypes", [String]),
|
|
1412
|
+
__metadata("design:returntype", Promise)
|
|
1413
|
+
], ModulePackageService.prototype, "getLatestBackup", null);
|
|
1414
|
+
__decorate([
|
|
1415
|
+
(0, disallow_in_production_decorator_1.DisallowInProduction)(),
|
|
1416
|
+
__metadata("design:type", Function),
|
|
1417
|
+
__metadata("design:paramtypes", [String]),
|
|
1418
|
+
__metadata("design:returntype", Promise)
|
|
1419
|
+
], ModulePackageService.prototype, "restoreBackup", null);
|
|
975
1420
|
exports.ModulePackageService = ModulePackageService = ModulePackageService_1 = __decorate([
|
|
976
1421
|
(0, common_1.Injectable)(),
|
|
1422
|
+
__param(2, (0, typeorm_1.InjectDataSource)()),
|
|
977
1423
|
__metadata("design:paramtypes", [command_service_1.CommandService,
|
|
978
|
-
module_metadata_helper_service_1.ModuleMetadataHelperService
|
|
1424
|
+
module_metadata_helper_service_1.ModuleMetadataHelperService,
|
|
1425
|
+
typeorm_2.DataSource])
|
|
979
1426
|
], ModulePackageService);
|
|
980
1427
|
//# sourceMappingURL=module-package.service.js.map
|