@squiz/dxp-cli-next 5.28.0-develop.3 → 5.28.0-develop.4

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.
@@ -31,7 +31,7 @@ const createMigrationCommand = () => {
31
31
  })
32
32
  .action((options) => __awaiter(void 0, void 0, void 0, function* () {
33
33
  yield (0, utils_1.throwErrorIfNotLoggedIn)(createCommand);
34
- let spinner = (0, ora_1.default)('Creating migration').start();
34
+ const spinner = (0, ora_1.default)('Creating migration').start();
35
35
  try {
36
36
  // Create migration
37
37
  const response = yield (0, utils_1.createMigration)(options);
@@ -39,8 +39,6 @@ const createMigrationCommand = () => {
39
39
  throw new Error('Migration creation failed');
40
40
  }
41
41
  spinner.succeed('Migration created successfully');
42
- // Upload file to S3
43
- spinner = (0, ora_1.default)('Uploading file to S3').start();
44
42
  spinner.succeed(`Successfully created migration: ${JSON.stringify({
45
43
  migrationId: response.assetMigration.migrationId,
46
44
  assetId: response.assetMigration.assetId,
@@ -65,7 +65,6 @@ describe('createMigrationCommand', () => {
65
65
  updated: 1234567890,
66
66
  migrationIdAssetId: 'migration-123-asset-456',
67
67
  },
68
- uploadUrl: 'https://upload.s3.amazonaws.com',
69
68
  };
70
69
  mockCreateMigration.createMigration.mockResolvedValue(mockCreateMigrationResponse);
71
70
  });
@@ -3,5 +3,4 @@ export interface CreateMigrationOptions extends CommonCommandOptions, Pick<Asset
3
3
  }
4
4
  export interface CreateMigrationApiResponse {
5
5
  assetMigration: AssetMigration;
6
- uploadUrl: string;
7
6
  }
@@ -28,5 +28,4 @@ export declare function buildMigrationUrl(tenantID?: string, overrideUrl?: strin
28
28
  */
29
29
  export declare function validateAxiosStatus(status: number): boolean;
30
30
  export declare function getMigrationHeaders(tenantID?: string, isJson?: boolean): Promise<Record<string, string>>;
31
- export declare function uploadFileToS3(uploadUrl: string, filePath: string, tenantID?: string): Promise<string>;
32
31
  export declare function redactKey(key: string, visibleChars?: number): string;
@@ -12,8 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.redactKey = exports.uploadFileToS3 = exports.getMigrationHeaders = exports.validateAxiosStatus = exports.buildMigrationUrl = exports.throwErrorIfNotLoggedIn = exports.handleCommandError = void 0;
16
- const fs_1 = __importDefault(require("fs"));
15
+ exports.redactKey = exports.getMigrationHeaders = exports.validateAxiosStatus = exports.buildMigrationUrl = exports.throwErrorIfNotLoggedIn = exports.handleCommandError = void 0;
17
16
  const chalk_1 = __importDefault(require("chalk"));
18
17
  const ApplicationConfig_1 = require("../../ApplicationConfig");
19
18
  const axios_1 = __importDefault(require("axios"));
@@ -105,18 +104,6 @@ function getMigrationHeaders(tenantID, isJson = true) {
105
104
  });
106
105
  }
107
106
  exports.getMigrationHeaders = getMigrationHeaders;
108
- function uploadFileToS3(uploadUrl, filePath, tenantID) {
109
- return __awaiter(this, void 0, void 0, function* () {
110
- const fileBuffer = fs_1.default.readFileSync(filePath);
111
- const response = yield fetch(uploadUrl, {
112
- method: 'PUT',
113
- body: fileBuffer,
114
- headers: yield getMigrationHeaders(tenantID, false),
115
- });
116
- return response.url;
117
- });
118
- }
119
- exports.uploadFileToS3 = uploadFileToS3;
120
107
  function redactKey(key, visibleChars = 3) {
121
108
  if (!key)
122
109
  return '';
@@ -155,37 +155,6 @@ describe('Migration Utils', () => {
155
155
  expect(mockFetchApplicationConfig).toHaveBeenCalledWith('tenant-id');
156
156
  }));
157
157
  });
158
- describe('uploadFileToS3', () => {
159
- beforeEach(() => {
160
- mockFs.readFileSync.mockReturnValue(Buffer.from('file content'));
161
- mockFetchApplicationConfig.mockResolvedValue({
162
- tenant: 'test-tenant',
163
- baseUrl: 'https://example.com',
164
- region: 'au',
165
- });
166
- });
167
- it('uploads file successfully', () => __awaiter(void 0, void 0, void 0, function* () {
168
- const mockResponse = {
169
- url: 'https://s3.amazonaws.com/uploaded-file',
170
- };
171
- mockFetch.mockResolvedValue(mockResponse);
172
- const result = yield (0, _1.uploadFileToS3)('https://upload.url', '/path/to/file.tar.gz', 'tenant-id');
173
- expect(result).toBe('https://s3.amazonaws.com/uploaded-file');
174
- expect(mockFetch).toHaveBeenCalledWith('https://upload.url', {
175
- method: 'PUT',
176
- body: Buffer.from('file content'),
177
- headers: {
178
- 'x-dxp-tenant': 'test-tenant',
179
- },
180
- });
181
- }));
182
- it('handles file read error', () => __awaiter(void 0, void 0, void 0, function* () {
183
- mockFs.readFileSync.mockImplementation(() => {
184
- throw new Error('File not found');
185
- });
186
- yield expect((0, _1.uploadFileToS3)('https://upload.url', '/nonexistent/file.tar.gz')).rejects.toThrow('File not found');
187
- }));
188
- });
189
158
  describe('redactKey', () => {
190
159
  it('redacts key correctly', () => {
191
160
  expect((0, _1.redactKey)('1234567890', 3)).toBe('*******890');
@@ -37,19 +37,15 @@ function createMigration(options) {
37
37
  throw new Error(`Migration creation failed with status: ${response.status}`);
38
38
  }
39
39
  // Validate response structure
40
- const { assetMigration, uploadUrl } = response.data || {};
40
+ const { assetMigration } = response.data || {};
41
41
  if (!(assetMigration === null || assetMigration === void 0 ? void 0 : assetMigration.migrationId) ||
42
42
  !(assetMigration === null || assetMigration === void 0 ? void 0 : assetMigration.assetId) ||
43
43
  !(assetMigration === null || assetMigration === void 0 ? void 0 : assetMigration.stage) ||
44
44
  !(assetMigration === null || assetMigration === void 0 ? void 0 : assetMigration.status)) {
45
45
  throw new Error('Invalid response format from migration service');
46
46
  }
47
- if (!uploadUrl) {
48
- throw new Error('Upload URL not found in response');
49
- }
50
47
  return {
51
48
  assetMigration,
52
- uploadUrl,
53
49
  };
54
50
  }
55
51
  catch (error) {
@@ -161,7 +161,6 @@ describe('createMigration', () => {
161
161
  updated: 1234567890,
162
162
  migrationIdAssetId: 'migration-123-asset-123',
163
163
  },
164
- uploadUrl: 'https://upload.s3.amazonaws.com',
165
164
  },
166
165
  };
167
166
  mockApiServiceInstance.client.post.mockResolvedValue(mockResponse);
@@ -195,27 +194,11 @@ describe('createMigration', () => {
195
194
  stage: 'pending',
196
195
  status: 'created',
197
196
  },
198
- uploadUrl: 'https://upload.s3.amazonaws.com',
199
197
  },
200
198
  };
201
199
  mockApiServiceInstance.client.post.mockResolvedValue(mockResponse);
202
200
  yield expect((0, _1.createMigration)(mockOptions)).rejects.toThrow('Invalid response format from migration service');
203
201
  }));
204
- it('handles missing upload URL', () => __awaiter(void 0, void 0, void 0, function* () {
205
- const mockResponse = {
206
- status: 200,
207
- data: {
208
- assetMigration: {
209
- migrationId: 'migration-123',
210
- assetId: 'asset-123',
211
- stage: 'pending',
212
- status: 'created',
213
- },
214
- },
215
- };
216
- mockApiServiceInstance.client.post.mockResolvedValue(mockResponse);
217
- yield expect((0, _1.createMigration)(mockOptions)).rejects.toThrow('Upload URL not found in response');
218
- }));
219
202
  it('handles API service errors', () => __awaiter(void 0, void 0, void 0, function* () {
220
203
  const error = new Error('Network error');
221
204
  mockApiServiceInstance.client.post.mockRejectedValue(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/dxp-cli-next",
3
- "version": "5.28.0-develop.3",
3
+ "version": "5.28.0-develop.4",
4
4
  "repository": {
5
5
  "url": "https://gitlab.squiz.net/dxp/dxp-cli-next"
6
6
  },