From 2aca3c8a681bed3f8935f72d227924a33b67c031 Mon Sep 17 00:00:00 2001 From: Emil Widlund Date: Fri, 7 Feb 2025 11:19:59 +0100 Subject: [PATCH] fix license keys --- package.json | 4 ++-- pnpm-lock.yaml | 10 +++++----- src/product.ts | 18 +++++++----------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index a211054..9dfa0a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polar-migrate", - "version": "0.1.3", + "version": "0.1.4", "license": "Apache-2.0", "bin": "bin/cli.js", "type": "module", @@ -17,7 +17,7 @@ "dependencies": { "@inkjs/ui": "^2.0.0", "@lemonsqueezy/lemonsqueezy.js": "^4.0.0", - "@polar-sh/sdk": "^0.22.2", + "@polar-sh/sdk": "^0.24.0", "@types/cross-spawn": "^6.0.6", "cross-spawn": "^7.0.3", "ink": "^4.4.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 98e8ba0..c6bfb48 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ importers: specifier: ^4.0.0 version: 4.0.0 '@polar-sh/sdk': - specifier: ^0.22.2 - version: 0.22.2(zod@3.23.8) + specifier: ^0.24.0 + version: 0.24.0(zod@3.23.8) '@types/cross-spawn': specifier: ^6.0.6 version: 6.0.6 @@ -417,8 +417,8 @@ packages: resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} - '@polar-sh/sdk@0.22.2': - resolution: {integrity: sha512-B0H7IrhkEVUMoJxNJ840sPMAtTSWjbr+evOhy7jpxS+COjlWygJEDb9fIhxdjWE5m9Iwlk5LaHsgipxjkP+Vyw==} + '@polar-sh/sdk@0.24.0': + resolution: {integrity: sha512-bTx5agBShP7L0ZpFGSVO1Ux1Epxk9S1L6iFNZEL0n5JK8ZDwzmnNou7csEycn/FzbTYC8KBEhZP+O6T1Bx8ULA==} peerDependencies: zod: '>= 3' @@ -3484,7 +3484,7 @@ snapshots: '@pkgjs/parseargs@0.11.0': optional: true - '@polar-sh/sdk@0.22.2(zod@3.23.8)': + '@polar-sh/sdk@0.24.0(zod@3.23.8)': dependencies: standardwebhooks: 1.0.0 zod: 3.23.8 diff --git a/src/product.ts b/src/product.ts index 88525a7..11b4bc5 100644 --- a/src/product.ts +++ b/src/product.ts @@ -10,7 +10,6 @@ import { import type { Polar } from "@polar-sh/sdk"; import type { Timeframe } from "@polar-sh/sdk/models/components/benefitlicensekeyexpirationproperties.js"; import type { BenefitLicenseKeyExpirationProperties } from "@polar-sh/sdk/models/components/benefitlicensekeyexpirationproperties.js"; -import type { Interval } from "@polar-sh/sdk/models/components/interval.js"; import type { FileRead } from "@polar-sh/sdk/models/components/listresourcefileread.js"; import type { Organization } from "@polar-sh/sdk/models/components/organization.js"; import type { Product } from "@polar-sh/sdk/models/components/product.js"; @@ -24,21 +23,18 @@ import type { ProductRecurringCreate } from "@polar-sh/sdk/models/components/pro import mime from "mime-types"; import { uploadFailedMessage, uploadMessage } from "./ui/upload.js"; import { Upload } from "./upload.js"; +import type { SubscriptionRecurringInterval } from "@polar-sh/sdk/models/components/subscriptionrecurringinterval.js"; const resolveInterval = ( interval: ListVariants["data"][number]["attributes"]["interval"], -): Interval => { +): SubscriptionRecurringInterval => { switch (interval) { - case "day": - return "day"; - case "week": - return "week"; case "month": return "month"; case "year": return "year"; default: - throw new Error(`Unknown interval: ${interval}`); + return "month"; } }; @@ -161,12 +157,12 @@ export const createProduct = async ( expires: variant.attributes.is_license_length_unlimited ? undefined : resolveLicenseKeyExpiration(variant), - activations: variant.attributes.license_activation_limit - ? { + activations: variant.attributes.is_license_limit_unlimited + ? undefined + : { limit: variant.attributes.license_activation_limit, enableCustomerAdmin: true, - } - : undefined, + }, }, organizationId: organization.id, });