Skip to content

Commit

Permalink
fix Kong#5942: Retain exported ID for resource
Browse files Browse the repository at this point in the history
  • Loading branch information
THORSTEN SCHMINKEL committed Oct 4, 2023
1 parent 7867080 commit e00173c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/insomnia/src/common/import.ts
Expand Up @@ -201,7 +201,14 @@ export const importResourcesToWorkspace = async ({ workspaceId }: { workspaceId:
// Create new ids for each resource below optionalResources
for (const resource of optionalResources) {
const model = getModel(resource.type);
model && ResourceIdMap.set(resource._id, generateId(model.prefix));
if (model) {
if (!resource._id) {
ResourceIdMap.set(resource._id, generateId(model.prefix));
} else {
console.log('[Import Scan] Retaining ID: ', resource._id);
ResourceIdMap.set(resource._id, resource._id);
}
}
}

// Preserve optionalResource relationships
Expand Down Expand Up @@ -298,7 +305,14 @@ const importResourcesToNewWorkspace = async (projectId: string, workspaceToImpor

for (const resource of resourcesWithoutWorkspaceAndApiSpec) {
const model = getModel(resource.type);
model && ResourceIdMap.set(resource._id, generateId(model.prefix));
if (model) {
if (!resource._id) {
ResourceIdMap.set(resource._id, generateId(model.prefix));
} else {
console.log('[Import Scan] Retaining ID: ', resource._id);
ResourceIdMap.set(resource._id, resource._id);
}
}
}

for (const resource of resourcesWithoutWorkspaceAndApiSpec) {
Expand Down

0 comments on commit e00173c

Please sign in to comment.