From 6a9f4b9f6b4a1425a99c65fd2962ed0592737825 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Fri, 19 Sep 2025 22:00:33 -0700 Subject: [PATCH 1/2] Uniq itemHashTags --- .github/workflows/publish.yml | 5 ++++- api/routes/import.ts | 9 +++++++-- api/shapes/export.ts | 8 +++++++- dim-api-types/package.json | 2 +- package.json | 7 +++++-- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b7926e43..c7fb75e1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -47,4 +47,7 @@ jobs: - name: Publish the package to NPM if: steps.check.outputs.changed == 'true' - run: cd dim-api-types && npm publish --access public --provenance + run: | + cd dim-api-types + npm install -g npm@latest + npm publish --access public --provenance diff --git a/api/routes/import.ts b/api/routes/import.ts index ecfb26d4..d8ca77aa 100644 --- a/api/routes/import.ts +++ b/api/routes/import.ts @@ -1,3 +1,4 @@ +import { uniqBy } from 'es-toolkit'; import { isEmpty } from 'es-toolkit/compat'; import asyncHandler from 'express-async-handler'; import { ExportResponse } from '../shapes/export.js'; @@ -104,9 +105,13 @@ export async function statelyImport( const items: AnyItem[] = []; items.push(...importLoadouts(loadouts)); items.push(...importTags(itemAnnotations)); + // TODO: I guess save item hash tags to each platform? I should really + // refactor the import shape to have hashtags per platform, or merge/unique + // them. for (const platformMembershipId of platformMembershipIds) { - // TODO: I guess save them to each platform? I should really refactor the - // import shape to have hashtags per platform, or merge/unique them. + // The export will have duplicates because import saved to each profile + // instead of the one that was exported. + itemHashTags = uniqBy(itemHashTags, (a) => a.hash); items.push(...importHashTags(platformMembershipId, itemHashTags)); } if (Array.isArray(triumphs)) { diff --git a/api/shapes/export.ts b/api/shapes/export.ts index ecaae8cd..a4873024 100644 --- a/api/shapes/export.ts +++ b/api/shapes/export.ts @@ -16,7 +16,13 @@ export interface ExportResponse { destinyVersion: DestinyVersion; annotation: ItemAnnotation; }[]; - itemHashTags: ItemHashTag[]; + itemHashTags: ( + | ItemHashTag + | { + platformMembershipId: string; + itemHashTag: ItemHashTag; + } + )[]; triumphs: { platformMembershipId: string; triumphs: number[]; diff --git a/dim-api-types/package.json b/dim-api-types/package.json index 60f18475..afd7f698 100644 --- a/dim-api-types/package.json +++ b/dim-api-types/package.json @@ -17,7 +17,7 @@ ], "repository": { "type": "git", - "url": "https://github.com/DestinyItemManager/dim-api.git" + "url": "git+https://github.com/DestinyItemManager/dim-api.git" }, "author": "Ben Hollis", "license": "MIT", diff --git a/package.json b/package.json index 8d9ca2dd..8e115359 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,10 @@ "version": "1.0.0", "description": "Destiny Item Manager API Server", "main": "api/index.js", - "repository": "https://github.com/DestinyItemManager/dim-api", + "repository": { + "type": "git", + "url": "git+https://github.com/DestinyItemManager/dim-api.git" + }, "private": true, "author": "Ben Hollis ", "license": "MIT", @@ -87,4 +90,4 @@ "vhost": "^3.0.2" }, "packageManager": "pnpm@8.9.0+sha256.8f5264ad1d100da11a6add6bb8a94c6f1e913f9e9261b2a551fabefad2ec0fec" -} \ No newline at end of file +} From 3ee8eabc99fa457e4462be2b54ec7a6780e080a3 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Fri, 19 Sep 2025 22:33:01 -0700 Subject: [PATCH 2/2] OK --- api/routes/import.ts | 8 +++++--- api/shapes/export.ts | 8 +------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/api/routes/import.ts b/api/routes/import.ts index d8ca77aa..92cd0f0a 100644 --- a/api/routes/import.ts +++ b/api/routes/import.ts @@ -102,6 +102,11 @@ export async function statelyImport( bungieMembershipId, ); + // The export will have duplicates because import saved to each profile + // instead of the one that was exported. + itemHashTags = uniqBy(itemHashTags, (a) => a.hash); + searches = uniqBy(searches, (s) => s.search.query); + const items: AnyItem[] = []; items.push(...importLoadouts(loadouts)); items.push(...importTags(itemAnnotations)); @@ -109,9 +114,6 @@ export async function statelyImport( // refactor the import shape to have hashtags per platform, or merge/unique // them. for (const platformMembershipId of platformMembershipIds) { - // The export will have duplicates because import saved to each profile - // instead of the one that was exported. - itemHashTags = uniqBy(itemHashTags, (a) => a.hash); items.push(...importHashTags(platformMembershipId, itemHashTags)); } if (Array.isArray(triumphs)) { diff --git a/api/shapes/export.ts b/api/shapes/export.ts index a4873024..ecaae8cd 100644 --- a/api/shapes/export.ts +++ b/api/shapes/export.ts @@ -16,13 +16,7 @@ export interface ExportResponse { destinyVersion: DestinyVersion; annotation: ItemAnnotation; }[]; - itemHashTags: ( - | ItemHashTag - | { - platformMembershipId: string; - itemHashTag: ItemHashTag; - } - )[]; + itemHashTags: ItemHashTag[]; triumphs: { platformMembershipId: string; triumphs: number[];