UNPKG

@aws-amplify/cli-internal

Version:
36 lines 1.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AuthUserPoolGroupsForwardRefactorer = exports.RESOURCE_TYPES = exports.USER_POOL_GROUP_TYPE = void 0; const amplify_cli_core_1 = require("@aws-amplify/amplify-cli-core"); const forward_category_refactorer_1 = require("../workflow/forward-category-refactorer"); exports.USER_POOL_GROUP_TYPE = 'AWS::Cognito::UserPoolGroup'; exports.RESOURCE_TYPES = [exports.USER_POOL_GROUP_TYPE]; class AuthUserPoolGroupsForwardRefactorer extends forward_category_refactorer_1.ForwardCategoryRefactorer { resourceTypes() { return exports.RESOURCE_TYPES; } async fetchSourceStackId() { return this.findNestedStack(this.gen1Env, `auth${this.resource.resourceName}`); } async fetchDestStackId() { return this.findNestedStack(this.gen2Branch, 'auth'); } async gen2LogicalId(sourceId, sourceResource, targetResources) { if (sourceResource.Type !== exports.USER_POOL_GROUP_TYPE) { return await super.gen2LogicalId(sourceId, sourceResource, targetResources); } const candidates = Array.from(targetResources.keys()).filter((r) => { var _a, _b; return ((_a = targetResources.get(r)) === null || _a === void 0 ? void 0 : _a.Type) === sourceResource.Type && sourceResource.Properties['GroupName'] === ((_b = targetResources.get(r)) === null || _b === void 0 ? void 0 : _b.Properties['GroupName']); }); if (candidates.length !== 1) { throw new amplify_cli_core_1.AmplifyError('MigrationError', { message: `Unable to map Gen1 resource ${sourceId} (${sourceResource.Type}) to Gen2 resource`, }); } return candidates[0]; } } exports.AuthUserPoolGroupsForwardRefactorer = AuthUserPoolGroupsForwardRefactorer; //# sourceMappingURL=auth-user-pool-groups-forward.js.map