priceos 0.0.43 → 0.0.45

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.
package/dist/cli.cjs CHANGED
@@ -154,8 +154,6 @@ export type LimitFeatureUsage = {
154
154
  remaining: number | null;
155
155
  bonusRemaining: number;
156
156
  bonusUsed: number;
157
- resetsWhen: "billing_period" | "calendar";
158
- resetType: "never" | "day" | "week" | "month" | "year";
159
157
  nextReset: number | null;
160
158
  lastReset: number | null;
161
159
  };
package/dist/cli.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\ntype Feature = {\n featureKey: string;\n type?: \"boolean\" | \"limit\" | null;\n tracksUsage?: boolean | null;\n};\n\nfunction argValue(args: string[], name: string) {\n const idx = args.indexOf(name);\n if (idx === -1) return undefined;\n return args[idx + 1];\n}\n\nfunction hasFlag(args: string[], name: string) {\n return args.includes(name);\n}\n\nasync function readEnvFile(filePath: string) {\n try {\n const raw = await fs.readFile(filePath, \"utf8\");\n const entries: Record<string, string> = {};\n for (const line of raw.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n const eqIdx = trimmed.indexOf(\"=\");\n if (eqIdx === -1) continue;\n const rawKey = trimmed.slice(0, eqIdx).trim();\n const key = rawKey.startsWith(\"export \") ? rawKey.slice(\"export \".length).trim() : rawKey;\n let value = trimmed.slice(eqIdx + 1).trim();\n if (\n (value.startsWith(\"\\\"\") && value.endsWith(\"\\\"\")) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n if (key) {\n entries[key] = value;\n }\n }\n return entries;\n } catch {\n return {};\n }\n}\n\nfunction printHelp() {\n console.log(`\npriceos generate-types\n\nGenerates TypeScript feature access types for your PriceOS workspace.\n\nOptions:\n --api-key <key> PriceOS API key (defaults to .env.local, .env, or env PRICEOS_API_KEY) [required]\n --out <path> Output .d.ts file (default: priceos.d.ts in current directory)\n --out-dir <path> Output directory for priceos.d.ts (ignored if --out is set)\n -h, --help Show help\n\nExamples:\n priceos generate-types --api-key sk_test_... --out ./priceos.d.ts\n priceos generate-types --api-key sk_test_... --out-dir ./src\n`.trim());\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n\n if (args.length === 0 || hasFlag(args, \"--help\") || hasFlag(args, \"-h\")) {\n printHelp();\n process.exit(args.length === 0 ? 1 : 0);\n }\n\n const cmd = args[0];\n if (cmd !== \"generate-types\") {\n console.error(`Unknown command: ${cmd}`);\n printHelp();\n process.exit(1);\n }\n\n const envLocal = await readEnvFile(path.resolve(process.cwd(), \".env.local\"));\n const envDefault = await readEnvFile(path.resolve(process.cwd(), \".env\"));\n const apiKey =\n argValue(args, \"--api-key\") ??\n envLocal.PRICEOS_API_KEY ??\n envDefault.PRICEOS_API_KEY ??\n process.env.PRICEOS_API_KEY;\n\n if (!apiKey) {\n console.error(\"Missing API key. Provide --api-key <key> or set PRICEOS_API_KEY in .env.local/.env.\");\n process.exit(1);\n }\n\n const outRel = argValue(args, \"--out\");\n const outDir = argValue(args, \"--out-dir\");\n const outFile = outRel ?? \"priceos.d.ts\";\n const outPath = outDir && !outRel\n ? path.resolve(process.cwd(), outDir, outFile)\n : path.resolve(process.cwd(), outFile);\n const outDisplay = outDir && !outRel ? path.join(outDir, outFile) : outFile;\n\n const url = \"https://api.priceos.com/v1/features\";\n const res = await fetch(url, {\n headers: { \"x-api-key\": apiKey },\n });\n\n if (!res.ok) {\n const text = await res.text().catch(() => \"\");\n console.error(`Failed to fetch features: ${res.status} ${res.statusText}\\n${text}`);\n process.exit(1);\n }\n\n const features = (await res.json()) as Feature[];\n const typeByKey = new Map<string, \"boolean\" | \"limit\" | \"unknown\">();\n const trackingByKey = new Map<string, \"tracked\" | \"untracked\" | \"unknown\">();\n\n for (const feature of features ?? []) {\n if (!feature?.featureKey) continue;\n const key = feature.featureKey;\n const nextType = feature.type === \"boolean\" || feature.type === \"limit\" ? feature.type : \"unknown\";\n const currentType = typeByKey.get(key);\n if (!currentType) {\n typeByKey.set(key, nextType);\n } else if (currentType !== nextType) {\n typeByKey.set(key, \"unknown\");\n }\n\n if (nextType !== \"limit\") continue;\n\n const nextTracking =\n feature.tracksUsage === true\n ? \"tracked\"\n : feature.tracksUsage === false\n ? \"untracked\"\n : \"unknown\";\n const currentTracking = trackingByKey.get(key);\n if (!currentTracking) {\n trackingByKey.set(key, nextTracking);\n continue;\n }\n if (currentTracking !== nextTracking) {\n trackingByKey.set(key, \"unknown\");\n }\n }\n\n const keys = [...typeByKey.keys()].sort();\n const union = keys.length ? keys.map((k) => JSON.stringify(k)).join(\" | \") : \"never\";\n const limitKeys = keys.filter((key) => typeByKey.get(key) === \"limit\");\n const limitUnion = limitKeys.length ? limitKeys.map((k) => JSON.stringify(k)).join(\" | \") : \"never\";\n const mapLines = keys.map((key) => {\n const featureType = typeByKey.get(key);\n const accessType =\n featureType === \"boolean\"\n ? \"BooleanFeatureAccess\"\n : featureType === \"limit\"\n ? trackingByKey.get(key) === \"tracked\"\n ? \"TrackedLimitFeatureAccess\"\n : trackingByKey.get(key) === \"untracked\"\n ? \"UntrackedLimitFeatureAccess\"\n : \"LimitFeatureAccess\"\n : \"FeatureAccessEntry\";\n return ` ${JSON.stringify(key)}: ${accessType};`;\n });\n\n const content = `// Auto-generated by PriceOS (priceos generate-types). Do not edit.\nexport type FeatureKey = ${union};\nexport type LimitFeatureKey = ${limitUnion};\nexport type BooleanFeatureAccess = {\n type: \"boolean\";\n hasAccess: boolean;\n};\nexport type LimitFeatureUsage = {\n used: number;\n remaining: number | null;\n bonusRemaining: number;\n bonusUsed: number;\n resetsWhen: \"billing_period\" | \"calendar\";\n resetType: \"never\" | \"day\" | \"week\" | \"month\" | \"year\";\n nextReset: number | null;\n lastReset: number | null;\n};\nexport type TrackedLimitFeatureAccess = {\n type: \"limit\";\n hasAccess: boolean;\n isUnlimited: boolean;\n limit: number | null;\n usage: LimitFeatureUsage;\n};\nexport type UntrackedLimitFeatureAccess = {\n type: \"limit\";\n hasAccess: boolean;\n isUnlimited: boolean;\n limit: number | null;\n};\nexport type LimitFeatureAccess = TrackedLimitFeatureAccess | UntrackedLimitFeatureAccess;\nexport type FeatureAccessEntry = BooleanFeatureAccess | LimitFeatureAccess;\nexport type FeatureAccessMap = {\n${mapLines.join(\"\\n\")}\n};\n`;\n\n await fs.mkdir(path.dirname(outPath), { recursive: true });\n await fs.writeFile(outPath, content, \"utf8\");\n\n console.log(`Generated ${outDisplay} (${keys.length} feature keys)`);\n}\n\nmain().catch((e) => {\n console.error(e);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sBAAe;AACf,uBAAiB;AAQjB,SAAS,SAAS,MAAgB,MAAc;AAC9C,QAAM,MAAM,KAAK,QAAQ,IAAI;AAC7B,MAAI,QAAQ,GAAI,QAAO;AACvB,SAAO,KAAK,MAAM,CAAC;AACrB;AAEA,SAAS,QAAQ,MAAgB,MAAc;AAC7C,SAAO,KAAK,SAAS,IAAI;AAC3B;AAEA,eAAe,YAAY,UAAkB;AAC3C,MAAI;AACF,UAAM,MAAM,MAAM,gBAAAA,QAAG,SAAS,UAAU,MAAM;AAC9C,UAAM,UAAkC,CAAC;AACzC,eAAW,QAAQ,IAAI,MAAM,OAAO,GAAG;AACrC,YAAM,UAAU,KAAK,KAAK;AAC1B,UAAI,CAAC,WAAW,QAAQ,WAAW,GAAG,EAAG;AACzC,YAAM,QAAQ,QAAQ,QAAQ,GAAG;AACjC,UAAI,UAAU,GAAI;AAClB,YAAM,SAAS,QAAQ,MAAM,GAAG,KAAK,EAAE,KAAK;AAC5C,YAAM,MAAM,OAAO,WAAW,SAAS,IAAI,OAAO,MAAM,UAAU,MAAM,EAAE,KAAK,IAAI;AACnF,UAAI,QAAQ,QAAQ,MAAM,QAAQ,CAAC,EAAE,KAAK;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AChB,CAAC;","names":["fs","path"]}
1
+ {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\ntype Feature = {\n featureKey: string;\n type?: \"boolean\" | \"limit\" | null;\n tracksUsage?: boolean | null;\n};\n\nfunction argValue(args: string[], name: string) {\n const idx = args.indexOf(name);\n if (idx === -1) return undefined;\n return args[idx + 1];\n}\n\nfunction hasFlag(args: string[], name: string) {\n return args.includes(name);\n}\n\nasync function readEnvFile(filePath: string) {\n try {\n const raw = await fs.readFile(filePath, \"utf8\");\n const entries: Record<string, string> = {};\n for (const line of raw.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n const eqIdx = trimmed.indexOf(\"=\");\n if (eqIdx === -1) continue;\n const rawKey = trimmed.slice(0, eqIdx).trim();\n const key = rawKey.startsWith(\"export \") ? rawKey.slice(\"export \".length).trim() : rawKey;\n let value = trimmed.slice(eqIdx + 1).trim();\n if (\n (value.startsWith(\"\\\"\") && value.endsWith(\"\\\"\")) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n if (key) {\n entries[key] = value;\n }\n }\n return entries;\n } catch {\n return {};\n }\n}\n\nfunction printHelp() {\n console.log(`\npriceos generate-types\n\nGenerates TypeScript feature access types for your PriceOS workspace.\n\nOptions:\n --api-key <key> PriceOS API key (defaults to .env.local, .env, or env PRICEOS_API_KEY) [required]\n --out <path> Output .d.ts file (default: priceos.d.ts in current directory)\n --out-dir <path> Output directory for priceos.d.ts (ignored if --out is set)\n -h, --help Show help\n\nExamples:\n priceos generate-types --api-key sk_test_... --out ./priceos.d.ts\n priceos generate-types --api-key sk_test_... --out-dir ./src\n`.trim());\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n\n if (args.length === 0 || hasFlag(args, \"--help\") || hasFlag(args, \"-h\")) {\n printHelp();\n process.exit(args.length === 0 ? 1 : 0);\n }\n\n const cmd = args[0];\n if (cmd !== \"generate-types\") {\n console.error(`Unknown command: ${cmd}`);\n printHelp();\n process.exit(1);\n }\n\n const envLocal = await readEnvFile(path.resolve(process.cwd(), \".env.local\"));\n const envDefault = await readEnvFile(path.resolve(process.cwd(), \".env\"));\n const apiKey =\n argValue(args, \"--api-key\") ??\n envLocal.PRICEOS_API_KEY ??\n envDefault.PRICEOS_API_KEY ??\n process.env.PRICEOS_API_KEY;\n\n if (!apiKey) {\n console.error(\"Missing API key. Provide --api-key <key> or set PRICEOS_API_KEY in .env.local/.env.\");\n process.exit(1);\n }\n\n const outRel = argValue(args, \"--out\");\n const outDir = argValue(args, \"--out-dir\");\n const outFile = outRel ?? \"priceos.d.ts\";\n const outPath = outDir && !outRel\n ? path.resolve(process.cwd(), outDir, outFile)\n : path.resolve(process.cwd(), outFile);\n const outDisplay = outDir && !outRel ? path.join(outDir, outFile) : outFile;\n\n const url = \"https://api.priceos.com/v1/features\";\n const res = await fetch(url, {\n headers: { \"x-api-key\": apiKey },\n });\n\n if (!res.ok) {\n const text = await res.text().catch(() => \"\");\n console.error(`Failed to fetch features: ${res.status} ${res.statusText}\\n${text}`);\n process.exit(1);\n }\n\n const features = (await res.json()) as Feature[];\n const typeByKey = new Map<string, \"boolean\" | \"limit\" | \"unknown\">();\n const trackingByKey = new Map<string, \"tracked\" | \"untracked\" | \"unknown\">();\n\n for (const feature of features ?? []) {\n if (!feature?.featureKey) continue;\n const key = feature.featureKey;\n const nextType = feature.type === \"boolean\" || feature.type === \"limit\" ? feature.type : \"unknown\";\n const currentType = typeByKey.get(key);\n if (!currentType) {\n typeByKey.set(key, nextType);\n } else if (currentType !== nextType) {\n typeByKey.set(key, \"unknown\");\n }\n\n if (nextType !== \"limit\") continue;\n\n const nextTracking =\n feature.tracksUsage === true\n ? \"tracked\"\n : feature.tracksUsage === false\n ? \"untracked\"\n : \"unknown\";\n const currentTracking = trackingByKey.get(key);\n if (!currentTracking) {\n trackingByKey.set(key, nextTracking);\n continue;\n }\n if (currentTracking !== nextTracking) {\n trackingByKey.set(key, \"unknown\");\n }\n }\n\n const keys = [...typeByKey.keys()].sort();\n const union = keys.length ? keys.map((k) => JSON.stringify(k)).join(\" | \") : \"never\";\n const limitKeys = keys.filter((key) => typeByKey.get(key) === \"limit\");\n const limitUnion = limitKeys.length ? limitKeys.map((k) => JSON.stringify(k)).join(\" | \") : \"never\";\n const mapLines = keys.map((key) => {\n const featureType = typeByKey.get(key);\n const accessType =\n featureType === \"boolean\"\n ? \"BooleanFeatureAccess\"\n : featureType === \"limit\"\n ? trackingByKey.get(key) === \"tracked\"\n ? \"TrackedLimitFeatureAccess\"\n : trackingByKey.get(key) === \"untracked\"\n ? \"UntrackedLimitFeatureAccess\"\n : \"LimitFeatureAccess\"\n : \"FeatureAccessEntry\";\n return ` ${JSON.stringify(key)}: ${accessType};`;\n });\n\n const content = `// Auto-generated by PriceOS (priceos generate-types). Do not edit.\nexport type FeatureKey = ${union};\nexport type LimitFeatureKey = ${limitUnion};\nexport type BooleanFeatureAccess = {\n type: \"boolean\";\n hasAccess: boolean;\n};\nexport type LimitFeatureUsage = {\n used: number;\n remaining: number | null;\n bonusRemaining: number;\n bonusUsed: number;\n nextReset: number | null;\n lastReset: number | null;\n};\nexport type TrackedLimitFeatureAccess = {\n type: \"limit\";\n hasAccess: boolean;\n isUnlimited: boolean;\n limit: number | null;\n usage: LimitFeatureUsage;\n};\nexport type UntrackedLimitFeatureAccess = {\n type: \"limit\";\n hasAccess: boolean;\n isUnlimited: boolean;\n limit: number | null;\n};\nexport type LimitFeatureAccess = TrackedLimitFeatureAccess | UntrackedLimitFeatureAccess;\nexport type FeatureAccessEntry = BooleanFeatureAccess | LimitFeatureAccess;\nexport type FeatureAccessMap = {\n${mapLines.join(\"\\n\")}\n};\n`;\n\n await fs.mkdir(path.dirname(outPath), { recursive: true });\n await fs.writeFile(outPath, content, \"utf8\");\n\n console.log(`Generated ${outDisplay} (${keys.length} feature keys)`);\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CAAC,QAAQ;AACjC,UAAM,cAAc,UAAU,IAAI,GAAG;AACrC,UAAM,aACJ,gBAAgB,YACZ,yBACA,gBAAgB,UACd,cAAc,IAAI,GAAG,MAAM,YACzB,8BACA,cAAc,IAAI,GAAG,MAAM,cACzB,gCACA,uBACJ;AACR,WAAO,KAAK,KAAK,UAAU,GAAG,CAAC,KAAK,UAAU;AAAA,EAChD,CAAC;AAED,QAAM,UAAU;AAAA,2BACS,KAAK;AAAA,gCACA,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6BxC,SAAS,KAAK,IAAI,CAAC;AAAA;AAAA;AAInB,QAAM,gBAAAD,QAAG,MAAM,iBAAAC,QAAK,QAAQ,OAAO,GAAG,EAAE,WAAW,KAAK,CAAC;AACzD,QAAM,gBAAAD,QAAG,UAAU,SAAS,SAAS,MAAM;AAE3C,UAAQ,IAAI,aAAa,UAAU,KAAK,KAAK,MAAM,gBAAgB;AACrE;AAEA,KAAK,EAAE,MAAM,CAAC,MAAM;AAClB,UAAQ,MAAM,CAAC;AACf,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["fs","path"]}
package/dist/cli.js CHANGED
@@ -131,8 +131,6 @@ export type LimitFeatureUsage = {
131
131
  remaining: number | null;
132
132
  bonusRemaining: number;
133
133
  bonusUsed: number;
134
- resetsWhen: "billing_period" | "calendar";
135
- resetType: "never" | "day" | "week" | "month" | "year";
136
134
  nextReset: number | null;
137
135
  lastReset: number | null;
138
136
  };
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\ntype Feature = {\n featureKey: string;\n type?: \"boolean\" | \"limit\" | null;\n tracksUsage?: boolean | null;\n};\n\nfunction argValue(args: string[], name: string) {\n const idx = args.indexOf(name);\n if (idx === -1) return undefined;\n return args[idx + 1];\n}\n\nfunction hasFlag(args: string[], name: string) {\n return args.includes(name);\n}\n\nasync function readEnvFile(filePath: string) {\n try {\n const raw = await fs.readFile(filePath, \"utf8\");\n const entries: Record<string, string> = {};\n for (const line of raw.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n const eqIdx = trimmed.indexOf(\"=\");\n if (eqIdx === -1) continue;\n const rawKey = trimmed.slice(0, eqIdx).trim();\n const key = rawKey.startsWith(\"export \") ? rawKey.slice(\"export \".length).trim() : rawKey;\n let value = trimmed.slice(eqIdx + 1).trim();\n if (\n (value.startsWith(\"\\\"\") && value.endsWith(\"\\\"\")) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n if (key) {\n entries[key] = value;\n }\n }\n return entries;\n } catch {\n return {};\n }\n}\n\nfunction printHelp() {\n console.log(`\npriceos generate-types\n\nGenerates TypeScript feature access types for your PriceOS workspace.\n\nOptions:\n --api-key <key> PriceOS API key (defaults to .env.local, .env, or env PRICEOS_API_KEY) [required]\n --out <path> Output .d.ts file (default: priceos.d.ts in current directory)\n --out-dir <path> Output directory for priceos.d.ts (ignored if --out is set)\n -h, --help Show help\n\nExamples:\n priceos generate-types --api-key sk_test_... --out ./priceos.d.ts\n priceos generate-types --api-key sk_test_... --out-dir ./src\n`.trim());\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n\n if (args.length === 0 || hasFlag(args, \"--help\") || hasFlag(args, \"-h\")) {\n printHelp();\n process.exit(args.length === 0 ? 1 : 0);\n }\n\n const cmd = args[0];\n if (cmd !== \"generate-types\") {\n console.error(`Unknown command: ${cmd}`);\n printHelp();\n process.exit(1);\n }\n\n const envLocal = await readEnvFile(path.resolve(process.cwd(), \".env.local\"));\n const envDefault = await readEnvFile(path.resolve(process.cwd(), \".env\"));\n const apiKey =\n argValue(args, \"--api-key\") ??\n envLocal.PRICEOS_API_KEY ??\n envDefault.PRICEOS_API_KEY ??\n process.env.PRICEOS_API_KEY;\n\n if (!apiKey) {\n console.error(\"Missing API key. Provide --api-key <key> or set PRICEOS_API_KEY in .env.local/.env.\");\n process.exit(1);\n }\n\n const outRel = argValue(args, \"--out\");\n const outDir = argValue(args, \"--out-dir\");\n const outFile = outRel ?? \"priceos.d.ts\";\n const outPath = outDir && !outRel\n ? path.resolve(process.cwd(), outDir, outFile)\n : path.resolve(process.cwd(), outFile);\n const outDisplay = outDir && !outRel ? path.join(outDir, outFile) : outFile;\n\n const url = \"https://api.priceos.com/v1/features\";\n const res = await fetch(url, {\n headers: { \"x-api-key\": apiKey },\n });\n\n if (!res.ok) {\n const text = await res.text().catch(() => \"\");\n console.error(`Failed to fetch features: ${res.status} ${res.statusText}\\n${text}`);\n process.exit(1);\n }\n\n const features = (await res.json()) as Feature[];\n const typeByKey = new Map<string, \"boolean\" | \"limit\" | \"unknown\">();\n const trackingByKey = new Map<string, \"tracked\" | \"untracked\" | \"unknown\">();\n\n for (const feature of features ?? []) {\n if (!feature?.featureKey) continue;\n const key = feature.featureKey;\n const nextType = feature.type === \"boolean\" || feature.type === \"limit\" ? feature.type : \"unknown\";\n const currentType = typeByKey.get(key);\n if (!currentType) {\n typeByKey.set(key, nextType);\n } else if (currentType !== nextType) {\n typeByKey.set(key, \"unknown\");\n }\n\n if (nextType !== \"limit\") continue;\n\n const nextTracking =\n feature.tracksUsage === true\n ? \"tracked\"\n : feature.tracksUsage === false\n ? \"untracked\"\n : \"unknown\";\n const currentTracking = trackingByKey.get(key);\n if (!currentTracking) {\n trackingByKey.set(key, nextTracking);\n continue;\n }\n if (currentTracking !== nextTracking) {\n trackingByKey.set(key, \"unknown\");\n }\n }\n\n const keys = [...typeByKey.keys()].sort();\n const union = keys.length ? keys.map((k) => JSON.stringify(k)).join(\" | \") : \"never\";\n const limitKeys = keys.filter((key) => typeByKey.get(key) === \"limit\");\n const limitUnion = limitKeys.length ? limitKeys.map((k) => JSON.stringify(k)).join(\" | \") : \"never\";\n const mapLines = keys.map((key) => {\n const featureType = typeByKey.get(key);\n const accessType =\n featureType === \"boolean\"\n ? \"BooleanFeatureAccess\"\n : featureType === \"limit\"\n ? trackingByKey.get(key) === \"tracked\"\n ? \"TrackedLimitFeatureAccess\"\n : trackingByKey.get(key) === \"untracked\"\n ? \"UntrackedLimitFeatureAccess\"\n : \"LimitFeatureAccess\"\n : \"FeatureAccessEntry\";\n return ` ${JSON.stringify(key)}: ${accessType};`;\n });\n\n const content = `// Auto-generated by PriceOS (priceos generate-types). Do not edit.\nexport type FeatureKey = ${union};\nexport type LimitFeatureKey = ${limitUnion};\nexport type BooleanFeatureAccess = {\n type: \"boolean\";\n hasAccess: boolean;\n};\nexport type LimitFeatureUsage = {\n used: number;\n remaining: number | null;\n bonusRemaining: number;\n bonusUsed: number;\n resetsWhen: \"billing_period\" | \"calendar\";\n resetType: \"never\" | \"day\" | \"week\" | \"month\" | \"year\";\n nextReset: number | null;\n lastReset: number | null;\n};\nexport type TrackedLimitFeatureAccess = {\n type: \"limit\";\n hasAccess: boolean;\n isUnlimited: boolean;\n limit: number | null;\n usage: LimitFeatureUsage;\n};\nexport type UntrackedLimitFeatureAccess = {\n type: \"limit\";\n hasAccess: boolean;\n isUnlimited: boolean;\n limit: number | null;\n};\nexport type LimitFeatureAccess = TrackedLimitFeatureAccess | UntrackedLimitFeatureAccess;\nexport type FeatureAccessEntry = BooleanFeatureAccess | LimitFeatureAccess;\nexport type FeatureAccessMap = {\n${mapLines.join(\"\\n\")}\n};\n`;\n\n await fs.mkdir(path.dirname(outPath), { recursive: true });\n await fs.writeFile(outPath, content, \"utf8\");\n\n console.log(`Generated ${outDisplay} (${keys.length} feature keys)`);\n}\n\nmain().catch((e) => {\n console.error(e);\n process.exit(1);\n});\n"],"mappings":";;;AACA,OAAO,QAAQ;AACf,OAAO,UAAU;AAQ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B,gCACA,uBACJ;AACR,WAAO,KAAK,KAAK,UAAU,GAAG,CAAC,KAAK,UAAU;AAAA,EAChD,CAAC;AAED,QAAM,UAAU;AAAA,2BACS,KAAK;AAAA,gCACA,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA+BxC,SAAS,KAAK,IAAI,CAAC;AAAA;AAAA;AAInB,QAAM,GAAG,MAAM,KAAK,QAAQ,OAAO,GAAG,EAAE,WAAW,KAAK,CAAC;AACzD,QAAM,GAAG,UAAU,SAAS,SAAS,MAAM;AAE3C,UAAQ,IAAI,aAAa,UAAU,KAAK,KAAK,MAAM,gBAAgB;AACrE;AAEA,KAAK,EAAE,MAAM,CAAC,MAAM;AAClB,UAAQ,MAAM,CAAC;AACf,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\ntype Feature = {\n featureKey: string;\n type?: \"boolean\" | \"limit\" | null;\n tracksUsage?: boolean | null;\n};\n\nfunction argValue(args: string[], name: string) {\n const idx = args.indexOf(name);\n if (idx === -1) return undefined;\n return args[idx + 1];\n}\n\nfunction hasFlag(args: string[], name: string) {\n return args.includes(name);\n}\n\nasync function readEnvFile(filePath: string) {\n try {\n const raw = await fs.readFile(filePath, \"utf8\");\n const entries: Record<string, string> = {};\n for (const line of raw.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n const eqIdx = trimmed.indexOf(\"=\");\n if (eqIdx === -1) continue;\n const rawKey = trimmed.slice(0, eqIdx).trim();\n const key = rawKey.startsWith(\"export \") ? rawKey.slice(\"export \".length).trim() : rawKey;\n let value = trimmed.slice(eqIdx + 1).trim();\n if (\n (value.startsWith(\"\\\"\") && value.endsWith(\"\\\"\")) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n if (key) {\n entries[key] = value;\n }\n }\n return entries;\n } catch {\n return {};\n }\n}\n\nfunction printHelp() {\n console.log(`\npriceos generate-types\n\nGenerates TypeScript feature access types for your PriceOS workspace.\n\nOptions:\n --api-key <key> PriceOS API key (defaults to .env.local, .env, or env PRICEOS_API_KEY) [required]\n --out <path> Output .d.ts file (default: priceos.d.ts in current directory)\n --out-dir <path> Output directory for priceos.d.ts (ignored if --out is set)\n -h, --help Show help\n\nExamples:\n priceos generate-types --api-key sk_test_... --out ./priceos.d.ts\n priceos generate-types --api-key sk_test_... --out-dir ./src\n`.trim());\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n\n if (args.length === 0 || hasFlag(args, \"--help\") || hasFlag(args, \"-h\")) {\n printHelp();\n process.exit(args.length === 0 ? 1 : 0);\n }\n\n const cmd = args[0];\n if (cmd !== \"generate-types\") {\n console.error(`Unknown command: ${cmd}`);\n printHelp();\n process.exit(1);\n }\n\n const envLocal = await readEnvFile(path.resolve(process.cwd(), \".env.local\"));\n const envDefault = await readEnvFile(path.resolve(process.cwd(), \".env\"));\n const apiKey =\n argValue(args, \"--api-key\") ??\n envLocal.PRICEOS_API_KEY ??\n envDefault.PRICEOS_API_KEY ??\n process.env.PRICEOS_API_KEY;\n\n if (!apiKey) {\n console.error(\"Missing API key. Provide --api-key <key> or set PRICEOS_API_KEY in .env.local/.env.\");\n process.exit(1);\n }\n\n const outRel = argValue(args, \"--out\");\n const outDir = argValue(args, \"--out-dir\");\n const outFile = outRel ?? \"priceos.d.ts\";\n const outPath = outDir && !outRel\n ? path.resolve(process.cwd(), outDir, outFile)\n : path.resolve(process.cwd(), outFile);\n const outDisplay = outDir && !outRel ? path.join(outDir, outFile) : outFile;\n\n const url = \"https://api.priceos.com/v1/features\";\n const res = await fetch(url, {\n headers: { \"x-api-key\": apiKey },\n });\n\n if (!res.ok) {\n const text = await res.text().catch(() => \"\");\n console.error(`Failed to fetch features: ${res.status} ${res.statusText}\\n${text}`);\n process.exit(1);\n }\n\n const features = (await res.json()) as Feature[];\n const typeByKey = new Map<string, \"boolean\" | \"limit\" | \"unknown\">();\n const trackingByKey = new Map<string, \"tracked\" | \"untracked\" | \"unknown\">();\n\n for (const feature of features ?? []) {\n if (!feature?.featureKey) continue;\n const key = feature.featureKey;\n const nextType = feature.type === \"boolean\" || feature.type === \"limit\" ? feature.type : \"unknown\";\n const currentType = typeByKey.get(key);\n if (!currentType) {\n typeByKey.set(key, nextType);\n } else if (currentType !== nextType) {\n typeByKey.set(key, \"unknown\");\n }\n\n if (nextType !== \"limit\") continue;\n\n const nextTracking =\n feature.tracksUsage === true\n ? \"tracked\"\n : feature.tracksUsage === false\n ? \"untracked\"\n : \"unknown\";\n const currentTracking = trackingByKey.get(key);\n if (!currentTracking) {\n trackingByKey.set(key, nextTracking);\n continue;\n }\n if (currentTracking !== nextTracking) {\n trackingByKey.set(key, \"unknown\");\n }\n }\n\n const keys = [...typeByKey.keys()].sort();\n const union = keys.length ? keys.map((k) => JSON.stringify(k)).join(\" | \") : \"never\";\n const limitKeys = keys.filter((key) => typeByKey.get(key) === \"limit\");\n const limitUnion = limitKeys.length ? limitKeys.map((k) => JSON.stringify(k)).join(\" | \") : \"never\";\n const mapLines = keys.map((key) => {\n const featureType = typeByKey.get(key);\n const accessType =\n featureType === \"boolean\"\n ? \"BooleanFeatureAccess\"\n : featureType === \"limit\"\n ? trackingByKey.get(key) === \"tracked\"\n ? \"TrackedLimitFeatureAccess\"\n : trackingByKey.get(key) === \"untracked\"\n ? \"UntrackedLimitFeatureAccess\"\n : \"LimitFeatureAccess\"\n : \"FeatureAccessEntry\";\n return ` ${JSON.stringify(key)}: ${accessType};`;\n });\n\n const content = `// Auto-generated by PriceOS (priceos generate-types). Do not edit.\nexport type FeatureKey = ${union};\nexport type LimitFeatureKey = ${limitUnion};\nexport type BooleanFeatureAccess = {\n type: \"boolean\";\n hasAccess: boolean;\n};\nexport type LimitFeatureUsage = {\n used: number;\n remaining: number | null;\n bonusRemaining: number;\n bonusUsed: number;\n nextReset: number | null;\n lastReset: number | null;\n};\nexport type TrackedLimitFeatureAccess = {\n type: \"limit\";\n hasAccess: boolean;\n isUnlimited: boolean;\n limit: number | null;\n usage: LimitFeatureUsage;\n};\nexport type UntrackedLimitFeatureAccess = {\n type: \"limit\";\n hasAccess: boolean;\n isUnlimited: boolean;\n limit: number | null;\n};\nexport type LimitFeatureAccess = TrackedLimitFeatureAccess | UntrackedLimitFeatureAccess;\nexport type FeatureAccessEntry = BooleanFeatureAccess | LimitFeatureAccess;\nexport type FeatureAccessMap = {\n${mapLines.join(\"\\n\")}\n};\n`;\n\n await fs.mkdir(path.dirname(outPath), { recursive: true });\n await fs.writeFile(outPath, content, \"utf8\");\n\n console.log(`Generated ${outDisplay} (${keys.length} feature keys)`);\n}\n\nmain().catch((e) => {\n console.error(e);\n process.exit(1);\n});\n"],"mappings":";;;AACA,OAAO,QAAQ;AACf,OAAO,UAAU;AAQjB,SAAS,SAAS,MAAgB,MAAc;AAC9C,QAAM,MAAM,KAAK,QAAQ,IAAI;AAC7B,MAAI,QAAQ,GAAI,QAAO;AACvB,SAAO,KAAK,MAAM,CAAC;AACrB;AAEA,SAAS,QAAQ,MAAgB,MAAc;AAC7C,SAAO,KAAK,SAAS,IAAI;AAC3B;AAEA,eAAe,YAAY,UAAkB;AAC3C,MAAI;AACF,UAAM,MAAM,MAAM,GAAG,SAAS,UAAU,MAAM;AAC9C,UAAM,UAAkC,CAAC;AACzC,eAAW,QAAQ,IAAI,MAAM,OAAO,GAAG;AACrC,YAAM,UAAU,KAAK,KAAK;AAC1B,UAAI,CAAC,WAAW,QAAQ,WAAW,GAAG,EAAG;AACzC,YAAM,QAAQ,QAAQ,QAAQ,GAAG;AACjC,UAAI,UAAU,GAA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U,KAAK,KAAK,MAAM,gBAAgB;AACrE;AAEA,KAAK,EAAE,MAAM,CAAC,MAAM;AAClB,UAAQ,MAAM,CAAC;AACf,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/client.ts"],"sourcesContent":["export { PriceOS, PriceOSError } from \"./client\";\nexport type {\n PriceOSClientOptions,\n PriceOSLogLevel,\n PriceOSBonusesClient,\n PriceOSCustomersClient,\n PriceOSFeaturesClient,\n PriceOSHttpClient,\n PriceOSUsageClient,\n} from \"./client\";\nexport type {\n CreateBonusBody,\n CreateBonusResponse,\n ListBonusesRequest,\n ListBonusesResponse,\n UpdateBonusBody,\n UpdateBonusRequest,\n UpdateBonusResponse,\n DeleteBonusRequest,\n DeleteBonusResponse,\n CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteUsageEventsBody,\n DeleteUsageEventsResponse,\n DeleteCustomerRequest,\n DeleteCustomerResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n LinkCustomerBody,\n LinkCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n ListUsageEventsBody,\n ListUsageEventsResponse,\n ResetUsageBody,\n ResetUsageResponse,\n UsageEvent,\n TrackUsageBody,\n TrackUsageBatchBody,\n TrackUsageBatchEvent,\n TrackUsageBatchResponse,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n","import createClient from \"openapi-fetch\";\nimport type { Client } from \"openapi-fetch\";\nimport type { paths } from \"./gen/openapi\";\nimport {\n CreateBonusBody,\n CreateBonusResponse,\n CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteBonusResponse,\n ListBonusesRequest,\n ListBonusesResponse,\n DeleteUsageEventsBody,\n DeleteUsageEventsResponse,\n DeleteCustomerResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n LinkCustomerBody,\n LinkCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n ListUsageEventsBody,\n ListUsageEventsResponse,\n ResetUsageBody,\n ResetUsageResponse,\n UpdateBonusRequest,\n UpdateBonusResponse,\n TrackUsageBody,\n TrackUsageBatchBody,\n TrackUsageBatchResponse,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\nexport type PriceOSLogLevel = \"none\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n logLevel?: PriceOSLogLevel;\n};\n\nconst RATE_LIMIT_STATUS = 429;\nconst MAX_RETRIES = 4;\nconst BASE_DELAY_MS = 250;\nconst BACKOFF_MULTIPLIER = 2;\nconst JITTER_MS = 250;\nconst RETRY_DELAY_CAP_MS = 5_000;\nconst REQUEST_TIMEOUT_MS = 20_000;\n\nconst LOG_LEVELS: Record<PriceOSLogLevel, number> = {\n none: 0,\n error: 1,\n warning: 2,\n info: 3,\n debug: 4,\n};\n\ntype Logger = {\n error: (message: string, details?: Record<string, unknown>) => void;\n warning: (message: string, details?: Record<string, unknown>) => void;\n info: (message: string, details?: Record<string, unknown>) => void;\n debug: (message: string, details?: Record<string, unknown>) => void;\n};\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\nconst getRetryDelayMs = (retryCount: number): number => {\n const backoff = BASE_DELAY_MS * Math.pow(BACKOFF_MULTIPLIER, retryCount - 1);\n const jitter = Math.random() * JITTER_MS;\n return Math.min(RETRY_DELAY_CAP_MS, backoff + jitter);\n};\n\nconst createLogger = (logLevel: PriceOSLogLevel): Logger => {\n const shouldLog = (level: PriceOSLogLevel): boolean =>\n logLevel !== \"none\" && LOG_LEVELS[level] <= LOG_LEVELS[logLevel];\n\n const write = (\n level: PriceOSLogLevel,\n message: string,\n details?: Record<string, unknown>\n ): void => {\n if (!shouldLog(level)) return;\n const prefix = `[PriceOS] ${level.toUpperCase()}: ${message}`;\n const payload = details && Object.keys(details).length > 0 ? details : undefined;\n\n switch (level) {\n case \"error\":\n payload ? console.error(prefix, payload) : console.error(prefix);\n return;\n case \"warning\":\n payload ? console.warn(prefix, payload) : console.warn(prefix);\n return;\n case \"info\":\n payload ? console.info(prefix, payload) : console.info(prefix);\n return;\n case \"debug\":\n payload ? console.debug(prefix, payload) : console.debug(prefix);\n return;\n }\n };\n\n return {\n error: (message, details) => write(\"error\", message, details),\n warning: (message, details) => write(\"warning\", message, details),\n info: (message, details) => write(\"info\", message, details),\n debug: (message, details) => write(\"debug\", message, details),\n };\n};\n\nconst getUpstreamSignal = (input: RequestInfo | URL, init?: RequestInit): AbortSignal | undefined => {\n if (init?.signal) return init.signal;\n if (typeof Request !== \"undefined\" && input instanceof Request) return input.signal;\n return undefined;\n};\n\nconst stripSignal = (init?: RequestInit): RequestInit | undefined => {\n if (!init) return undefined;\n const { signal: _signal, ...rest } = init;\n return rest;\n};\n\nconst getRequestDetails = (\n input: RequestInfo | URL,\n init?: RequestInit\n): { method: string; url: string } => {\n const method =\n init?.method ??\n (typeof Request !== \"undefined\" && input instanceof Request ? input.method : \"GET\");\n const url =\n typeof input === \"string\"\n ? input\n : input instanceof URL\n ? input.toString()\n : input.url;\n return { method, url };\n};\n\nconst prepareRetryRequest = async (\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n log: Logger,\n method: string,\n url: string\n): Promise<{ requestInput: RequestInfo | URL; baseInit?: RequestInit; canRetry: boolean }> => {\n if (!(typeof Request !== \"undefined\" && input instanceof Request)) {\n return { requestInput: input, baseInit: stripSignal(init), canRetry: true };\n }\n\n if (input.bodyUsed) {\n log.warning(\"Request body already used; retries disabled\", { method, url });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n\n let body: BodyInit | undefined = undefined;\n if (method !== \"GET\" && method !== \"HEAD\") {\n try {\n body = await input.clone().arrayBuffer();\n } catch (error) {\n log.warning(\"Unable to clone request body; retries disabled\", { method, url, error });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n }\n\n const headers = new Headers(input.headers);\n const baseInit = { ...stripSignal(init), method, headers, body };\n return { requestInput: input.url, baseInit, canRetry: true };\n};\n\nconst getErrorMessage = (error: unknown): string => {\n const maybeError = error as { error?: unknown } | null;\n if (maybeError && typeof maybeError.error === \"string\") return maybeError.error;\n return \"Request failed\";\n};\n\nconst throwRequestError = (\n log: Logger,\n error: unknown,\n response: Response | undefined,\n context: string\n): never => {\n log.error(\"Request failed\", { context, status: response?.status, error });\n throw new PriceOSError(getErrorMessage(error), { status: response?.status, details: error });\n};\n\nconst createRetryingFetch = (baseFetch: typeof fetch, log: Logger): typeof fetch => {\n return async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {\n const { method, url } = getRequestDetails(input, init);\n const upstreamSignal = getUpstreamSignal(input, init);\n const { requestInput, baseInit, canRetry } = await prepareRetryRequest(\n input,\n init,\n log,\n method,\n url\n );\n let attempt = 0;\n while (true) {\n log.debug(\"Request attempt\", { method, url, attempt: attempt + 1, maxRetries: MAX_RETRIES });\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);\n let removeAbortListener: (() => void) | null = null;\n\n if (upstreamSignal) {\n if (upstreamSignal.aborted) {\n controller.abort();\n } else {\n const onAbort = () => controller.abort();\n upstreamSignal.addEventListener(\"abort\", onAbort);\n removeAbortListener = () => upstreamSignal.removeEventListener(\"abort\", onAbort);\n }\n }\n\n try {\n const requestInit = { ...(baseInit ?? {}), signal: controller.signal };\n const response = await baseFetch(requestInput, requestInit);\n if (response.status !== RATE_LIMIT_STATUS) return response;\n\n const retryAfter = response.headers.get(\"retry-after\") ?? undefined;\n log.warning(\"Rate limit hit (429)\", {\n method,\n url,\n attempt: attempt + 1,\n maxRetries: MAX_RETRIES,\n retryAfter,\n });\n\n if (!canRetry) {\n log.warning(\"Skipping retry because request body is not replayable\", { method, url });\n return response;\n }\n\n if (attempt >= MAX_RETRIES) {\n log.error(\"Rate limit retries exhausted\", { method, url, attempts: attempt + 1 });\n return response;\n }\n\n const delayMs = getRetryDelayMs(attempt + 1);\n log.info(\"Waiting to retry after rate limit\", {\n method,\n url,\n delayMs,\n nextAttempt: attempt + 2,\n maxRetries: MAX_RETRIES,\n });\n await sleep(delayMs);\n attempt += 1;\n } catch (error) {\n if (controller.signal.aborted) {\n const abortedByCaller = upstreamSignal?.aborted ?? false;\n if (abortedByCaller) {\n log.warning(\"Request aborted by caller\", { method, url, attempt: attempt + 1 });\n } else {\n log.error(\"Request timed out\", {\n method,\n url,\n attempt: attempt + 1,\n timeoutMs: REQUEST_TIMEOUT_MS,\n });\n }\n } else {\n log.error(\"Request failed\", { method, url, attempt: attempt + 1, error });\n }\n throw error;\n } finally {\n clearTimeout(timeoutId);\n removeAbortListener?.();\n }\n }\n };\n};\n\nexport type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;\n link(input: LinkCustomerBody): Promise<LinkCustomerResponse<TFeatureAccessMap> | null>;\n create(input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>>;\n update(input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>>;\n delete(customerId: string): Promise<DeleteCustomerResponse>;\n};\n\nexport type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n getAccess(customerId: string): Promise<TFeatureAccessMap>;\n};\n\nexport type PriceOSBonusesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n create(\n input: CreateBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<CreateBonusResponse>;\n list(\n input: ListBonusesRequest<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListBonusesResponse>;\n update(input: UpdateBonusRequest): Promise<UpdateBonusResponse>;\n delete(bonusId: string): Promise<DeleteBonusResponse>;\n};\n\nexport type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n track(\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse>;\n reset(\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse>;\n deleteEvents(\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse>;\n trackBatch(\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse>;\n listEvents(\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse>;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n bonuses: PriceOSBonusesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n};\n\nexport class PriceOSError extends Error {\n status?: number;\n details?: unknown;\n\n constructor(message: string, opts?: { status?: number; details?: unknown }) {\n super(message);\n this.name = \"PriceOSError\";\n this.status = opts?.status;\n this.details = opts?.details;\n }\n}\n\nexport class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse>\n implements PriceOSHttpClient<TFeatureAccessMap>\n{\n private client: Client<paths>;\n private header: { \"x-api-key\": string };\n private log: Logger;\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n bonuses: PriceOSBonusesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n\n constructor(apiKey: string, opts: PriceOSClientOptions = {}) {\n const logLevel = opts.logLevel ?? \"none\";\n this.log = createLogger(logLevel);\n const baseUrl = \"https://api.priceos.com\";\n this.header = { \"x-api-key\": apiKey };\n const fetchWithRetry = createRetryingFetch(fetch, this.log);\n this.client = createClient<paths>({\n baseUrl,\n fetch: fetchWithRetry,\n headers: {\n \"x-api-key\": apiKey,\n },\n });\n\n this.customers = {\n get: async (customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.GET(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/customers/{customerId}\");\n return (data ?? null) as GetCustomerResponse<TFeatureAccessMap> | null;\n },\n link: async (\n input: LinkCustomerBody\n ): Promise<LinkCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.POST(\"/v1/customers/link\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/customers/link\");\n return (data ?? null) as LinkCustomerResponse<TFeatureAccessMap> | null;\n },\n create: async (input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>> => {\n const { data, error, response } = await this.client.POST(\"/v1/customers\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/customers\");\n return data! as CreateCustomerResponse<TFeatureAccessMap>;\n },\n update: async (input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>> => {\n const { customerId, ...body } = input;\n const { data, error, response } = await this.client.PUT(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n body,\n });\n if (error) throwRequestError(this.log, error, response, \"PUT /v1/customers/{customerId}\");\n return data! as UpdateCustomerResponse<TFeatureAccessMap>;\n },\n delete: async (customerId: string): Promise<DeleteCustomerResponse> => {\n const { data, error, response } = await this.client.DELETE(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"DELETE /v1/customers/{customerId}\");\n return data! as DeleteCustomerResponse;\n },\n };\n\n this.features = {\n getAccess: async (customerId: string): Promise<TFeatureAccessMap> => {\n const { data, error, response } = await this.client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/feature-access\");\n return data! as TFeatureAccessMap;\n },\n };\n\n this.bonuses = {\n create: async (\n input: CreateBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<CreateBonusResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/bonuses\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/bonuses\");\n return data!;\n },\n list: async (\n input: ListBonusesRequest<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListBonusesResponse> => {\n const { data, error, response } = await this.client.GET(\"/v1/bonuses\", {\n params: { header: this.header, query: input },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/bonuses\");\n return data!;\n },\n update: async (input: UpdateBonusRequest): Promise<UpdateBonusResponse> => {\n const { bonusId, ...body } = input;\n const { data, error, response } = await this.client.PUT(\"/v1/bonuses/{bonusId}\", {\n params: { header: this.header, path: { bonusId } },\n body,\n });\n if (error) throwRequestError(this.log, error, response, \"PUT /v1/bonuses/{bonusId}\");\n return data!;\n },\n delete: async (bonusId: string): Promise<DeleteBonusResponse> => {\n const { data, error, response } = await this.client.DELETE(\"/v1/bonuses/{bonusId}\", {\n params: { header: this.header, path: { bonusId } },\n });\n if (error) throwRequestError(this.log, error, response, \"DELETE /v1/bonuses/{bonusId}\");\n return data!;\n },\n };\n\n this.usage = {\n track: async (\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage\");\n return data!;\n },\n reset: async (\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/void\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/void\");\n return data!;\n },\n deleteEvents: async (\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/delete\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/delete\");\n return data!;\n },\n trackBatch: async (\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/batch\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/batch\");\n return data!;\n },\n listEvents: async (\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/events\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/events\");\n return data!;\n },\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAAyB;AAwCzB,IAAM,oBAAoB;AAC1B,IAAM,cAAc;AACpB,IAAM,gBAAgB;AACtB,IAAM,qBAAqB;AAC3B,IAAM,YAAY;AAClB,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAE3B,IAAM,aAA8C;AAAA,EAClD,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACT;AASA,IAAM,QAAQ,CAAC,OAA8B,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAE7F,IAAM,kBAAkB,CAAC,eAA+B;AACtD,QAAM,UAAU,gBAAgB,KAAK,IAAI,oBAAoB,aAAa,CAAC;AAC3E,QAAM,SAAS,KAAK,OA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AQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,qBAAqB;AAC7E,eAAO;AAAA,MACT;AAAA,MACA,cAAc,OACZ,UACuC;AACvC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,oBAAoB;AAAA,UAC3E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,MACA,YAAY,OACV,UACqC;AACrC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,mBAAmB;AAAA,UAC1E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,sBAAsB;AAC9E,eAAO;AAAA,MACT;AAAA,MACA,YAAY,OACV,UACqC;AACrC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,oBAAoB;AAAA,UAC3E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":["createClient"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/client.ts"],"sourcesContent":["export { PriceOS, PriceOSError } from \"./client\";\nexport type {\n PriceOSClientOptions,\n PriceOSLogLevel,\n PriceOSBonusesClient,\n PriceOSCustomersClient,\n PriceOSFeaturesClient,\n PriceOSHttpClient,\n PriceOSUsageClient,\n} from \"./client\";\nexport type {\n CreateBonusBody,\n CreateBonusResponse,\n ListBonusesRequest,\n ListBonusesResponse,\n UpdateBonusBody,\n UpdateBonusRequest,\n UpdateBonusResponse,\n DeleteBonusRequest,\n DeleteBonusResponse,\n CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteUsageEventsBody,\n DeleteUsageEventsResponse,\n DeleteCustomerRequest,\n DeleteCustomerResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n LinkCustomerBody,\n LinkCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n TrackedLimitFeatureKeyFromAccessMap,\n ListUsageEventsBody,\n ListUsageEventsResponse,\n ResetUsageBody,\n ResetUsageResponse,\n UsageEvent,\n TrackUsageBody,\n TrackUsageBatchBody,\n TrackUsageBatchEvent,\n TrackUsageBatchResponse,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n","import createClient from \"openapi-fetch\";\nimport type { Client } from \"openapi-fetch\";\nimport type { paths } from \"./gen/openapi\";\nimport {\n CreateBonusBody,\n CreateBonusResponse,\n CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteBonusResponse,\n ListBonusesRequest,\n ListBonusesResponse,\n DeleteUsageEventsBody,\n DeleteUsageEventsResponse,\n DeleteCustomerResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n LinkCustomerBody,\n LinkCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n TrackedLimitFeatureKeyFromAccessMap,\n ListUsageEventsBody,\n ListUsageEventsResponse,\n ResetUsageBody,\n ResetUsageResponse,\n UpdateBonusRequest,\n UpdateBonusResponse,\n TrackUsageBody,\n TrackUsageBatchBody,\n TrackUsageBatchResponse,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\nexport type PriceOSLogLevel = \"none\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n logLevel?: PriceOSLogLevel;\n};\n\nconst RATE_LIMIT_STATUS = 429;\nconst MAX_RETRIES = 4;\nconst BASE_DELAY_MS = 250;\nconst BACKOFF_MULTIPLIER = 2;\nconst JITTER_MS = 250;\nconst RETRY_DELAY_CAP_MS = 5_000;\nconst REQUEST_TIMEOUT_MS = 20_000;\n\nconst LOG_LEVELS: Record<PriceOSLogLevel, number> = {\n none: 0,\n error: 1,\n warning: 2,\n info: 3,\n debug: 4,\n};\n\ntype Logger = {\n error: (message: string, details?: Record<string, unknown>) => void;\n warning: (message: string, details?: Record<string, unknown>) => void;\n info: (message: string, details?: Record<string, unknown>) => void;\n debug: (message: string, details?: Record<string, unknown>) => void;\n};\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\nconst getRetryDelayMs = (retryCount: number): number => {\n const backoff = BASE_DELAY_MS * Math.pow(BACKOFF_MULTIPLIER, retryCount - 1);\n const jitter = Math.random() * JITTER_MS;\n return Math.min(RETRY_DELAY_CAP_MS, backoff + jitter);\n};\n\nconst createLogger = (logLevel: PriceOSLogLevel): Logger => {\n const shouldLog = (level: PriceOSLogLevel): boolean =>\n logLevel !== \"none\" && LOG_LEVELS[level] <= LOG_LEVELS[logLevel];\n\n const write = (\n level: PriceOSLogLevel,\n message: string,\n details?: Record<string, unknown>\n ): void => {\n if (!shouldLog(level)) return;\n const prefix = `[PriceOS] ${level.toUpperCase()}: ${message}`;\n const payload = details && Object.keys(details).length > 0 ? details : undefined;\n\n switch (level) {\n case \"error\":\n payload ? console.error(prefix, payload) : console.error(prefix);\n return;\n case \"warning\":\n payload ? console.warn(prefix, payload) : console.warn(prefix);\n return;\n case \"info\":\n payload ? console.info(prefix, payload) : console.info(prefix);\n return;\n case \"debug\":\n payload ? console.debug(prefix, payload) : console.debug(prefix);\n return;\n }\n };\n\n return {\n error: (message, details) => write(\"error\", message, details),\n warning: (message, details) => write(\"warning\", message, details),\n info: (message, details) => write(\"info\", message, details),\n debug: (message, details) => write(\"debug\", message, details),\n };\n};\n\nconst getUpstreamSignal = (input: RequestInfo | URL, init?: RequestInit): AbortSignal | undefined => {\n if (init?.signal) return init.signal;\n if (typeof Request !== \"undefined\" && input instanceof Request) return input.signal;\n return undefined;\n};\n\nconst stripSignal = (init?: RequestInit): RequestInit | undefined => {\n if (!init) return undefined;\n const { signal: _signal, ...rest } = init;\n return rest;\n};\n\nconst getRequestDetails = (\n input: RequestInfo | URL,\n init?: RequestInit\n): { method: string; url: string } => {\n const method =\n init?.method ??\n (typeof Request !== \"undefined\" && input instanceof Request ? input.method : \"GET\");\n const url =\n typeof input === \"string\"\n ? input\n : input instanceof URL\n ? input.toString()\n : input.url;\n return { method, url };\n};\n\nconst prepareRetryRequest = async (\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n log: Logger,\n method: string,\n url: string\n): Promise<{ requestInput: RequestInfo | URL; baseInit?: RequestInit; canRetry: boolean }> => {\n if (!(typeof Request !== \"undefined\" && input instanceof Request)) {\n return { requestInput: input, baseInit: stripSignal(init), canRetry: true };\n }\n\n if (input.bodyUsed) {\n log.warning(\"Request body already used; retries disabled\", { method, url });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n\n let body: BodyInit | undefined = undefined;\n if (method !== \"GET\" && method !== \"HEAD\") {\n try {\n body = await input.clone().arrayBuffer();\n } catch (error) {\n log.warning(\"Unable to clone request body; retries disabled\", { method, url, error });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n }\n\n const headers = new Headers(input.headers);\n const baseInit = { ...stripSignal(init), method, headers, body };\n return { requestInput: input.url, baseInit, canRetry: true };\n};\n\nconst getErrorMessage = (error: unknown): string => {\n const maybeError = error as { error?: unknown } | null;\n if (maybeError && typeof maybeError.error === \"string\") return maybeError.error;\n return \"Request failed\";\n};\n\nconst throwRequestError = (\n log: Logger,\n error: unknown,\n response: Response | undefined,\n context: string\n): never => {\n log.error(\"Request failed\", { context, status: response?.status, error });\n throw new PriceOSError(getErrorMessage(error), { status: response?.status, details: error });\n};\n\nconst createRetryingFetch = (baseFetch: typeof fetch, log: Logger): typeof fetch => {\n return async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {\n const { method, url } = getRequestDetails(input, init);\n const upstreamSignal = getUpstreamSignal(input, init);\n const { requestInput, baseInit, canRetry } = await prepareRetryRequest(\n input,\n init,\n log,\n method,\n url\n );\n let attempt = 0;\n while (true) {\n log.debug(\"Request attempt\", { method, url, attempt: attempt + 1, maxRetries: MAX_RETRIES });\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);\n let removeAbortListener: (() => void) | null = null;\n\n if (upstreamSignal) {\n if (upstreamSignal.aborted) {\n controller.abort();\n } else {\n const onAbort = () => controller.abort();\n upstreamSignal.addEventListener(\"abort\", onAbort);\n removeAbortListener = () => upstreamSignal.removeEventListener(\"abort\", onAbort);\n }\n }\n\n try {\n const requestInit = { ...(baseInit ?? {}), signal: controller.signal };\n const response = await baseFetch(requestInput, requestInit);\n if (response.status !== RATE_LIMIT_STATUS) return response;\n\n const retryAfter = response.headers.get(\"retry-after\") ?? undefined;\n log.warning(\"Rate limit hit (429)\", {\n method,\n url,\n attempt: attempt + 1,\n maxRetries: MAX_RETRIES,\n retryAfter,\n });\n\n if (!canRetry) {\n log.warning(\"Skipping retry because request body is not replayable\", { method, url });\n return response;\n }\n\n if (attempt >= MAX_RETRIES) {\n log.error(\"Rate limit retries exhausted\", { method, url, attempts: attempt + 1 });\n return response;\n }\n\n const delayMs = getRetryDelayMs(attempt + 1);\n log.info(\"Waiting to retry after rate limit\", {\n method,\n url,\n delayMs,\n nextAttempt: attempt + 2,\n maxRetries: MAX_RETRIES,\n });\n await sleep(delayMs);\n attempt += 1;\n } catch (error) {\n if (controller.signal.aborted) {\n const abortedByCaller = upstreamSignal?.aborted ?? false;\n if (abortedByCaller) {\n log.warning(\"Request aborted by caller\", { method, url, attempt: attempt + 1 });\n } else {\n log.error(\"Request timed out\", {\n method,\n url,\n attempt: attempt + 1,\n timeoutMs: REQUEST_TIMEOUT_MS,\n });\n }\n } else {\n log.error(\"Request failed\", { method, url, attempt: attempt + 1, error });\n }\n throw error;\n } finally {\n clearTimeout(timeoutId);\n removeAbortListener?.();\n }\n }\n };\n};\n\nexport type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;\n link(input: LinkCustomerBody): Promise<LinkCustomerResponse<TFeatureAccessMap> | null>;\n create(input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>>;\n update(input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>>;\n delete(customerId: string): Promise<DeleteCustomerResponse>;\n};\n\nexport type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n getAccess(customerId: string): Promise<TFeatureAccessMap>;\n};\n\nexport type PriceOSBonusesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n create(\n input: CreateBonusBody<TrackedLimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<CreateBonusResponse>;\n list(\n input: ListBonusesRequest<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListBonusesResponse>;\n update(input: UpdateBonusRequest): Promise<UpdateBonusResponse>;\n delete(bonusId: string): Promise<DeleteBonusResponse>;\n};\n\nexport type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n track(\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse>;\n reset(\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse>;\n deleteEvents(\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse>;\n trackBatch(\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse>;\n listEvents(\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse>;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n bonuses: PriceOSBonusesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n};\n\nexport class PriceOSError extends Error {\n status?: number;\n details?: unknown;\n\n constructor(message: string, opts?: { status?: number; details?: unknown }) {\n super(message);\n this.name = \"PriceOSError\";\n this.status = opts?.status;\n this.details = opts?.details;\n }\n}\n\nexport class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse>\n implements PriceOSHttpClient<TFeatureAccessMap>\n{\n private client: Client<paths>;\n private header: { \"x-api-key\": string };\n private log: Logger;\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n bonuses: PriceOSBonusesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n\n constructor(apiKey: string, opts: PriceOSClientOptions = {}) {\n const logLevel = opts.logLevel ?? \"none\";\n this.log = createLogger(logLevel);\n const baseUrl = \"https://api.priceos.com\";\n this.header = { \"x-api-key\": apiKey };\n const fetchWithRetry = createRetryingFetch(fetch, this.log);\n this.client = createClient<paths>({\n baseUrl,\n fetch: fetchWithRetry,\n headers: {\n \"x-api-key\": apiKey,\n },\n });\n\n this.customers = {\n get: async (customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.GET(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/customers/{customerId}\");\n return (data ?? null) as GetCustomerResponse<TFeatureAccessMap> | null;\n },\n link: async (\n input: LinkCustomerBody\n ): Promise<LinkCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.POST(\"/v1/customers/link\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/customers/link\");\n return (data ?? null) as LinkCustomerResponse<TFeatureAccessMap> | null;\n },\n create: async (input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>> => {\n const { data, error, response } = await this.client.POST(\"/v1/customers\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/customers\");\n return data! as CreateCustomerResponse<TFeatureAccessMap>;\n },\n update: async (input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>> => {\n const { customerId, ...body } = input;\n const { data, error, response } = await this.client.PUT(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n body,\n });\n if (error) throwRequestError(this.log, error, response, \"PUT /v1/customers/{customerId}\");\n return data! as UpdateCustomerResponse<TFeatureAccessMap>;\n },\n delete: async (customerId: string): Promise<DeleteCustomerResponse> => {\n const { data, error, response } = await this.client.DELETE(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"DELETE /v1/customers/{customerId}\");\n return data! as DeleteCustomerResponse;\n },\n };\n\n this.features = {\n getAccess: async (customerId: string): Promise<TFeatureAccessMap> => {\n const { data, error, response } = await this.client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/feature-access\");\n return data! as TFeatureAccessMap;\n },\n };\n\n this.bonuses = {\n create: async (\n input: CreateBonusBody<TrackedLimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<CreateBonusResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/bonuses\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/bonuses\");\n return data!;\n },\n list: async (\n input: ListBonusesRequest<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListBonusesResponse> => {\n const { data, error, response } = await this.client.GET(\"/v1/bonuses\", {\n params: { header: this.header, query: input },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/bonuses\");\n return data!;\n },\n update: async (input: UpdateBonusRequest): Promise<UpdateBonusResponse> => {\n const { bonusId, ...body } = input;\n const { data, error, response } = await this.client.PUT(\"/v1/bonuses/{bonusId}\", {\n params: { header: this.header, path: { bonusId } },\n body,\n });\n if (error) throwRequestError(this.log, error, response, \"PUT /v1/bonuses/{bonusId}\");\n return data!;\n },\n delete: async (bonusId: string): Promise<DeleteBonusResponse> => {\n const { data, error, response } = await this.client.DELETE(\"/v1/bonuses/{bonusId}\", {\n params: { header: this.header, path: { bonusId } },\n });\n if (error) throwRequestError(this.log, error, response, \"DELETE /v1/bonuses/{bonusId}\");\n return data!;\n },\n };\n\n this.usage = {\n track: async (\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage\");\n return data!;\n },\n reset: async (\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/void\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/void\");\n return data!;\n },\n deleteEvents: async (\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/delete\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/delete\");\n return data!;\n },\n trackBatch: async (\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/batch\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/batch\");\n return data!;\n },\n listEvents: async (\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/events\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/events\");\n return data!;\n },\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAAyB;AAyCzB,IAAM,oBAAoB;AAC1B,IAAM,cAAc;AACpB,IAAM,gBAAgB;AACtB,IAAM,qBAAqB;AAC3B,IAAM,YAAY;AAClB,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAE3B,IAAM,aAA8C;AAAA,EAClD,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACT;AASA,IAAM,QAAQ,CAAC,OAA8B,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAE7F,IAAM,kBAAkB,CAAC,eAA+B;AACtD,QAAM,UAAU,gBAAgB,KAAK,IAAI,oBAAoB,aAAa,CAAC;AAC3E,QAAM,SAAS,KAAK,OAAO,IAAI;AAC/B,SAAO,KAAK,IAAI,oBAAoB,UAAU,MAAM;AACtD;AAEA,IAAM,eAAe,CAAC,aAAsC;AAC1D,QAAM,YAAY,CAAC,UACjB,aAAa,UAAU,WAAW,KAAK,KAAK,WAAW,QAAQ;AAEjE,QAAM,QAAQ,CACZ,OACA,SACA,YACS;AACT,QAAI,CAAC,UAAU,KAAK,EAAG;AACvB,UAAM,SAAS,aAAa,MAAM,YAAY,CAAC,KAAK,OAAO;AAC3D,UAAM,UAAU,WAAW,OAAO,KAAK,OAAO,EAAE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KAAK,KAAK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,MACA,YAAY,OACV,UACqC;AACrC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,mBAAmB;AAAA,UAC1E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,sBAAsB;AAC9E,eAAO;AAAA,MACT;AAAA,MACA,YAAY,OACV,UACqC;AACrC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,oBAAoB;AAAA,UAC3E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":["createClient"]}
package/dist/index.d.cts CHANGED
@@ -42,6 +42,7 @@ interface paths {
42
42
  * "stripeCustomerId": "cus_abc123",
43
43
  * "name": "Ada Lovelace",
44
44
  * "email": "ada@example.com",
45
+ * "created": 1735689600000,
45
46
  * "usageStartedAt": 1735689600000,
46
47
  * "enviroment": "test",
47
48
  * "products": [
@@ -85,8 +86,6 @@ interface paths {
85
86
  * "remaining": 880,
86
87
  * "bonusRemaining": 25,
87
88
  * "bonusUsed": 5,
88
- * "resetsWhen": "billing_period",
89
- * "resetType": "month",
90
89
  * "nextReset": 1738368000000,
91
90
  * "lastReset": 1735689600000
92
91
  * }
@@ -122,6 +121,8 @@ interface paths {
122
121
  name?: string;
123
122
  /** @description Customer email address. */
124
123
  email?: string;
124
+ /** @description Unix timestamp (ms) when the customer was created. */
125
+ created?: number;
125
126
  /** @description Unix timestamp (ms) when usage tracking started. */
126
127
  usageStartedAt?: number;
127
128
  /**
@@ -215,16 +216,6 @@ interface paths {
215
216
  bonusRemaining: number;
216
217
  /** @description Bonus amount consumed. */
217
218
  bonusUsed: number;
218
- /**
219
- * @description When usage resets are anchored.
220
- * @enum {string}
221
- */
222
- resetsWhen: "billing_period" | "calendar";
223
- /**
224
- * @description How frequently usage resets.
225
- * @enum {string}
226
- */
227
- resetType: "never" | "day" | "week" | "month" | "year";
228
219
  /** @description Unix timestamp (ms) for the next reset, when applicable. */
229
220
  nextReset: number | null;
230
221
  /** @description Unix timestamp (ms) for the last reset, when applicable. */
@@ -343,6 +334,7 @@ interface paths {
343
334
  * "stripeCustomerId": "cus_abc123",
344
335
  * "name": "Ada Lovelace",
345
336
  * "email": "ada@example.com",
337
+ * "created": 1735689600000,
346
338
  * "usageStartedAt": 1735689600000,
347
339
  * "enviroment": "test",
348
340
  * "products": [
@@ -386,8 +378,6 @@ interface paths {
386
378
  * "remaining": 880,
387
379
  * "bonusRemaining": 25,
388
380
  * "bonusUsed": 5,
389
- * "resetsWhen": "billing_period",
390
- * "resetType": "month",
391
381
  * "nextReset": 1738368000000,
392
382
  * "lastReset": 1735689600000
393
383
  * }
@@ -423,6 +413,8 @@ interface paths {
423
413
  name?: string;
424
414
  /** @description Customer email address. */
425
415
  email?: string;
416
+ /** @description Unix timestamp (ms) when the customer was created. */
417
+ created?: number;
426
418
  /** @description Unix timestamp (ms) when usage tracking started. */
427
419
  usageStartedAt?: number;
428
420
  /**
@@ -516,16 +508,6 @@ interface paths {
516
508
  bonusRemaining: number;
517
509
  /** @description Bonus amount consumed. */
518
510
  bonusUsed: number;
519
- /**
520
- * @description When usage resets are anchored.
521
- * @enum {string}
522
- */
523
- resetsWhen: "billing_period" | "calendar";
524
- /**
525
- * @description How frequently usage resets.
526
- * @enum {string}
527
- */
528
- resetType: "never" | "day" | "week" | "month" | "year";
529
511
  /** @description Unix timestamp (ms) for the next reset, when applicable. */
530
512
  nextReset: number | null;
531
513
  /** @description Unix timestamp (ms) for the last reset, when applicable. */
@@ -751,6 +733,7 @@ interface paths {
751
733
  * "stripeCustomerId": "cus_abc123",
752
734
  * "name": "Ada Lovelace",
753
735
  * "email": "ada@example.com",
736
+ * "created": 1735689600000,
754
737
  * "usageStartedAt": 1735689600000,
755
738
  * "enviroment": "test",
756
739
  * "products": [
@@ -794,8 +777,6 @@ interface paths {
794
777
  * "remaining": 880,
795
778
  * "bonusRemaining": 25,
796
779
  * "bonusUsed": 5,
797
- * "resetsWhen": "billing_period",
798
- * "resetType": "month",
799
780
  * "nextReset": 1738368000000,
800
781
  * "lastReset": 1735689600000
801
782
  * }
@@ -831,6 +812,8 @@ interface paths {
831
812
  name?: string;
832
813
  /** @description Customer email address. */
833
814
  email?: string;
815
+ /** @description Unix timestamp (ms) when the customer was created. */
816
+ created?: number;
834
817
  /** @description Unix timestamp (ms) when usage tracking started. */
835
818
  usageStartedAt?: number;
836
819
  /**
@@ -924,16 +907,6 @@ interface paths {
924
907
  bonusRemaining: number;
925
908
  /** @description Bonus amount consumed. */
926
909
  bonusUsed: number;
927
- /**
928
- * @description When usage resets are anchored.
929
- * @enum {string}
930
- */
931
- resetsWhen: "billing_period" | "calendar";
932
- /**
933
- * @description How frequently usage resets.
934
- * @enum {string}
935
- */
936
- resetType: "never" | "day" | "week" | "month" | "year";
937
910
  /** @description Unix timestamp (ms) for the next reset, when applicable. */
938
911
  nextReset: number | null;
939
912
  /** @description Unix timestamp (ms) for the last reset, when applicable. */
@@ -1072,6 +1045,7 @@ interface paths {
1072
1045
  * "stripeCustomerId": "cus_abc123",
1073
1046
  * "name": "Ada Lovelace",
1074
1047
  * "email": "ada@example.com",
1048
+ * "created": 1735689600000,
1075
1049
  * "usageStartedAt": 1735689600000,
1076
1050
  * "enviroment": "test",
1077
1051
  * "products": [
@@ -1115,8 +1089,6 @@ interface paths {
1115
1089
  * "remaining": 880,
1116
1090
  * "bonusRemaining": 25,
1117
1091
  * "bonusUsed": 5,
1118
- * "resetsWhen": "billing_period",
1119
- * "resetType": "month",
1120
1092
  * "nextReset": 1738368000000,
1121
1093
  * "lastReset": 1735689600000
1122
1094
  * }
@@ -1152,6 +1124,8 @@ interface paths {
1152
1124
  name?: string;
1153
1125
  /** @description Customer email address. */
1154
1126
  email?: string;
1127
+ /** @description Unix timestamp (ms) when the customer was created. */
1128
+ created?: number;
1155
1129
  /** @description Unix timestamp (ms) when usage tracking started. */
1156
1130
  usageStartedAt?: number;
1157
1131
  /**
@@ -1245,16 +1219,6 @@ interface paths {
1245
1219
  bonusRemaining: number;
1246
1220
  /** @description Bonus amount consumed. */
1247
1221
  bonusUsed: number;
1248
- /**
1249
- * @description When usage resets are anchored.
1250
- * @enum {string}
1251
- */
1252
- resetsWhen: "billing_period" | "calendar";
1253
- /**
1254
- * @description How frequently usage resets.
1255
- * @enum {string}
1256
- */
1257
- resetType: "never" | "day" | "week" | "month" | "year";
1258
1222
  /** @description Unix timestamp (ms) for the next reset, when applicable. */
1259
1223
  nextReset: number | null;
1260
1224
  /** @description Unix timestamp (ms) for the last reset, when applicable. */
@@ -1403,8 +1367,6 @@ interface paths {
1403
1367
  * "remaining": 880,
1404
1368
  * "bonusRemaining": 25,
1405
1369
  * "bonusUsed": 5,
1406
- * "resetsWhen": "billing_period",
1407
- * "resetType": "month",
1408
1370
  * "nextReset": 1738368000000,
1409
1371
  * "lastReset": 1735689600000
1410
1372
  * }
@@ -1446,16 +1408,6 @@ interface paths {
1446
1408
  bonusRemaining: number;
1447
1409
  /** @description Bonus amount consumed. */
1448
1410
  bonusUsed: number;
1449
- /**
1450
- * @description When usage resets are anchored.
1451
- * @enum {string}
1452
- */
1453
- resetsWhen: "billing_period" | "calendar";
1454
- /**
1455
- * @description How frequently usage resets.
1456
- * @enum {string}
1457
- */
1458
- resetType: "never" | "day" | "week" | "month" | "year";
1459
1411
  /** @description Unix timestamp (ms) for the next reset, when applicable. */
1460
1412
  nextReset: number | null;
1461
1413
  /** @description Unix timestamp (ms) for the last reset, when applicable. */
@@ -2718,6 +2670,13 @@ type LimitFeatureKeyFromEntries<TFeatureAccessMap> = ({
2718
2670
  } ? K : never;
2719
2671
  }[keyof TFeatureAccessMap] & string);
2720
2672
  type LimitFeatureKeyFromAccessMap<TFeatureAccessMap> = IsAny<TFeatureAccessMap> extends true ? string : LimitFeatureKeyFromEntries<TFeatureAccessMap> extends never ? string : LimitFeatureKeyFromEntries<TFeatureAccessMap>;
2673
+ type TrackedLimitFeatureKeyFromEntries<TFeatureAccessMap> = ({
2674
+ [K in keyof TFeatureAccessMap]: Extract<TFeatureAccessMap[K], {
2675
+ type: "limit";
2676
+ usage: unknown;
2677
+ }> extends never ? never : K;
2678
+ }[keyof TFeatureAccessMap] & string);
2679
+ type TrackedLimitFeatureKeyFromAccessMap<TFeatureAccessMap> = IsAny<TFeatureAccessMap> extends true ? string : TrackedLimitFeatureKeyFromEntries<TFeatureAccessMap> extends never ? string : TrackedLimitFeatureKeyFromEntries<TFeatureAccessMap>;
2721
2680
  type TrackUsageBodyBase = paths["/v1/usage"]["post"]["requestBody"]["content"]["application/json"];
2722
2681
  type TrackUsageBody<TFeatureKey extends string = TrackUsageBodyBase["featureKey"]> = Omit<TrackUsageBodyBase, "featureKey"> & {
2723
2682
  featureKey: TFeatureKey;
@@ -2781,7 +2740,7 @@ type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
2781
2740
  getAccess(customerId: string): Promise<TFeatureAccessMap>;
2782
2741
  };
2783
2742
  type PriceOSBonusesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
2784
- create(input: CreateBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<CreateBonusResponse>;
2743
+ create(input: CreateBonusBody<TrackedLimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<CreateBonusResponse>;
2785
2744
  list(input: ListBonusesRequest<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<ListBonusesResponse>;
2786
2745
  update(input: UpdateBonusRequest): Promise<UpdateBonusResponse>;
2787
2746
  delete(bonusId: string): Promise<DeleteBonusResponse>;
@@ -2818,4 +2777,4 @@ declare class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse> implements P
2818
2777
  constructor(apiKey: string, opts?: PriceOSClientOptions);
2819
2778
  }
2820
2779
 
2821
- export { type CreateBonusBody, type CreateBonusResponse, type CreateCustomerRequest, type CreateCustomerResponse, type DeleteBonusRequest, type DeleteBonusResponse, type DeleteCustomerRequest, type DeleteCustomerResponse, type DeleteUsageEventsBody, type DeleteUsageEventsResponse, type GetCustomerResponse, type GetFeatureAccessResponse, type LimitFeatureKeyFromAccessMap, type LinkCustomerBody, type LinkCustomerResponse, type ListBonusesRequest, type ListBonusesResponse, type ListUsageEventsBody, type ListUsageEventsResponse, PriceOS, type PriceOSBonusesClient, type PriceOSClientOptions, type PriceOSCustomersClient, PriceOSError, type PriceOSFeaturesClient, type PriceOSHttpClient, type PriceOSLogLevel, type PriceOSUsageClient, type ResetUsageBody, type ResetUsageResponse, type TrackUsageBatchBody, type TrackUsageBatchEvent, type TrackUsageBatchResponse, type TrackUsageBody, type TrackUsageResponse, type UpdateBonusBody, type UpdateBonusRequest, type UpdateBonusResponse, type UpdateCustomerBody, type UpdateCustomerResponse, type UsageEvent };
2780
+ export { type CreateBonusBody, type CreateBonusResponse, type CreateCustomerRequest, type CreateCustomerResponse, type DeleteBonusRequest, type DeleteBonusResponse, type DeleteCustomerRequest, type DeleteCustomerResponse, type DeleteUsageEventsBody, type DeleteUsageEventsResponse, type GetCustomerResponse, type GetFeatureAccessResponse, type LimitFeatureKeyFromAccessMap, type LinkCustomerBody, type LinkCustomerResponse, type ListBonusesRequest, type ListBonusesResponse, type ListUsageEventsBody, type ListUsageEventsResponse, PriceOS, type PriceOSBonusesClient, type PriceOSClientOptions, type PriceOSCustomersClient, PriceOSError, type PriceOSFeaturesClient, type PriceOSHttpClient, type PriceOSLogLevel, type PriceOSUsageClient, type ResetUsageBody, type ResetUsageResponse, type TrackUsageBatchBody, type TrackUsageBatchEvent, type TrackUsageBatchResponse, type TrackUsageBody, type TrackUsageResponse, type TrackedLimitFeatureKeyFromAccessMap, type UpdateBonusBody, type UpdateBonusRequest, type UpdateBonusResponse, type UpdateCustomerBody, type UpdateCustomerResponse, type UsageEvent };
package/dist/index.d.ts CHANGED
@@ -42,6 +42,7 @@ interface paths {
42
42
  * "stripeCustomerId": "cus_abc123",
43
43
  * "name": "Ada Lovelace",
44
44
  * "email": "ada@example.com",
45
+ * "created": 1735689600000,
45
46
  * "usageStartedAt": 1735689600000,
46
47
  * "enviroment": "test",
47
48
  * "products": [
@@ -85,8 +86,6 @@ interface paths {
85
86
  * "remaining": 880,
86
87
  * "bonusRemaining": 25,
87
88
  * "bonusUsed": 5,
88
- * "resetsWhen": "billing_period",
89
- * "resetType": "month",
90
89
  * "nextReset": 1738368000000,
91
90
  * "lastReset": 1735689600000
92
91
  * }
@@ -122,6 +121,8 @@ interface paths {
122
121
  name?: string;
123
122
  /** @description Customer email address. */
124
123
  email?: string;
124
+ /** @description Unix timestamp (ms) when the customer was created. */
125
+ created?: number;
125
126
  /** @description Unix timestamp (ms) when usage tracking started. */
126
127
  usageStartedAt?: number;
127
128
  /**
@@ -215,16 +216,6 @@ interface paths {
215
216
  bonusRemaining: number;
216
217
  /** @description Bonus amount consumed. */
217
218
  bonusUsed: number;
218
- /**
219
- * @description When usage resets are anchored.
220
- * @enum {string}
221
- */
222
- resetsWhen: "billing_period" | "calendar";
223
- /**
224
- * @description How frequently usage resets.
225
- * @enum {string}
226
- */
227
- resetType: "never" | "day" | "week" | "month" | "year";
228
219
  /** @description Unix timestamp (ms) for the next reset, when applicable. */
229
220
  nextReset: number | null;
230
221
  /** @description Unix timestamp (ms) for the last reset, when applicable. */
@@ -343,6 +334,7 @@ interface paths {
343
334
  * "stripeCustomerId": "cus_abc123",
344
335
  * "name": "Ada Lovelace",
345
336
  * "email": "ada@example.com",
337
+ * "created": 1735689600000,
346
338
  * "usageStartedAt": 1735689600000,
347
339
  * "enviroment": "test",
348
340
  * "products": [
@@ -386,8 +378,6 @@ interface paths {
386
378
  * "remaining": 880,
387
379
  * "bonusRemaining": 25,
388
380
  * "bonusUsed": 5,
389
- * "resetsWhen": "billing_period",
390
- * "resetType": "month",
391
381
  * "nextReset": 1738368000000,
392
382
  * "lastReset": 1735689600000
393
383
  * }
@@ -423,6 +413,8 @@ interface paths {
423
413
  name?: string;
424
414
  /** @description Customer email address. */
425
415
  email?: string;
416
+ /** @description Unix timestamp (ms) when the customer was created. */
417
+ created?: number;
426
418
  /** @description Unix timestamp (ms) when usage tracking started. */
427
419
  usageStartedAt?: number;
428
420
  /**
@@ -516,16 +508,6 @@ interface paths {
516
508
  bonusRemaining: number;
517
509
  /** @description Bonus amount consumed. */
518
510
  bonusUsed: number;
519
- /**
520
- * @description When usage resets are anchored.
521
- * @enum {string}
522
- */
523
- resetsWhen: "billing_period" | "calendar";
524
- /**
525
- * @description How frequently usage resets.
526
- * @enum {string}
527
- */
528
- resetType: "never" | "day" | "week" | "month" | "year";
529
511
  /** @description Unix timestamp (ms) for the next reset, when applicable. */
530
512
  nextReset: number | null;
531
513
  /** @description Unix timestamp (ms) for the last reset, when applicable. */
@@ -751,6 +733,7 @@ interface paths {
751
733
  * "stripeCustomerId": "cus_abc123",
752
734
  * "name": "Ada Lovelace",
753
735
  * "email": "ada@example.com",
736
+ * "created": 1735689600000,
754
737
  * "usageStartedAt": 1735689600000,
755
738
  * "enviroment": "test",
756
739
  * "products": [
@@ -794,8 +777,6 @@ interface paths {
794
777
  * "remaining": 880,
795
778
  * "bonusRemaining": 25,
796
779
  * "bonusUsed": 5,
797
- * "resetsWhen": "billing_period",
798
- * "resetType": "month",
799
780
  * "nextReset": 1738368000000,
800
781
  * "lastReset": 1735689600000
801
782
  * }
@@ -831,6 +812,8 @@ interface paths {
831
812
  name?: string;
832
813
  /** @description Customer email address. */
833
814
  email?: string;
815
+ /** @description Unix timestamp (ms) when the customer was created. */
816
+ created?: number;
834
817
  /** @description Unix timestamp (ms) when usage tracking started. */
835
818
  usageStartedAt?: number;
836
819
  /**
@@ -924,16 +907,6 @@ interface paths {
924
907
  bonusRemaining: number;
925
908
  /** @description Bonus amount consumed. */
926
909
  bonusUsed: number;
927
- /**
928
- * @description When usage resets are anchored.
929
- * @enum {string}
930
- */
931
- resetsWhen: "billing_period" | "calendar";
932
- /**
933
- * @description How frequently usage resets.
934
- * @enum {string}
935
- */
936
- resetType: "never" | "day" | "week" | "month" | "year";
937
910
  /** @description Unix timestamp (ms) for the next reset, when applicable. */
938
911
  nextReset: number | null;
939
912
  /** @description Unix timestamp (ms) for the last reset, when applicable. */
@@ -1072,6 +1045,7 @@ interface paths {
1072
1045
  * "stripeCustomerId": "cus_abc123",
1073
1046
  * "name": "Ada Lovelace",
1074
1047
  * "email": "ada@example.com",
1048
+ * "created": 1735689600000,
1075
1049
  * "usageStartedAt": 1735689600000,
1076
1050
  * "enviroment": "test",
1077
1051
  * "products": [
@@ -1115,8 +1089,6 @@ interface paths {
1115
1089
  * "remaining": 880,
1116
1090
  * "bonusRemaining": 25,
1117
1091
  * "bonusUsed": 5,
1118
- * "resetsWhen": "billing_period",
1119
- * "resetType": "month",
1120
1092
  * "nextReset": 1738368000000,
1121
1093
  * "lastReset": 1735689600000
1122
1094
  * }
@@ -1152,6 +1124,8 @@ interface paths {
1152
1124
  name?: string;
1153
1125
  /** @description Customer email address. */
1154
1126
  email?: string;
1127
+ /** @description Unix timestamp (ms) when the customer was created. */
1128
+ created?: number;
1155
1129
  /** @description Unix timestamp (ms) when usage tracking started. */
1156
1130
  usageStartedAt?: number;
1157
1131
  /**
@@ -1245,16 +1219,6 @@ interface paths {
1245
1219
  bonusRemaining: number;
1246
1220
  /** @description Bonus amount consumed. */
1247
1221
  bonusUsed: number;
1248
- /**
1249
- * @description When usage resets are anchored.
1250
- * @enum {string}
1251
- */
1252
- resetsWhen: "billing_period" | "calendar";
1253
- /**
1254
- * @description How frequently usage resets.
1255
- * @enum {string}
1256
- */
1257
- resetType: "never" | "day" | "week" | "month" | "year";
1258
1222
  /** @description Unix timestamp (ms) for the next reset, when applicable. */
1259
1223
  nextReset: number | null;
1260
1224
  /** @description Unix timestamp (ms) for the last reset, when applicable. */
@@ -1403,8 +1367,6 @@ interface paths {
1403
1367
  * "remaining": 880,
1404
1368
  * "bonusRemaining": 25,
1405
1369
  * "bonusUsed": 5,
1406
- * "resetsWhen": "billing_period",
1407
- * "resetType": "month",
1408
1370
  * "nextReset": 1738368000000,
1409
1371
  * "lastReset": 1735689600000
1410
1372
  * }
@@ -1446,16 +1408,6 @@ interface paths {
1446
1408
  bonusRemaining: number;
1447
1409
  /** @description Bonus amount consumed. */
1448
1410
  bonusUsed: number;
1449
- /**
1450
- * @description When usage resets are anchored.
1451
- * @enum {string}
1452
- */
1453
- resetsWhen: "billing_period" | "calendar";
1454
- /**
1455
- * @description How frequently usage resets.
1456
- * @enum {string}
1457
- */
1458
- resetType: "never" | "day" | "week" | "month" | "year";
1459
1411
  /** @description Unix timestamp (ms) for the next reset, when applicable. */
1460
1412
  nextReset: number | null;
1461
1413
  /** @description Unix timestamp (ms) for the last reset, when applicable. */
@@ -2718,6 +2670,13 @@ type LimitFeatureKeyFromEntries<TFeatureAccessMap> = ({
2718
2670
  } ? K : never;
2719
2671
  }[keyof TFeatureAccessMap] & string);
2720
2672
  type LimitFeatureKeyFromAccessMap<TFeatureAccessMap> = IsAny<TFeatureAccessMap> extends true ? string : LimitFeatureKeyFromEntries<TFeatureAccessMap> extends never ? string : LimitFeatureKeyFromEntries<TFeatureAccessMap>;
2673
+ type TrackedLimitFeatureKeyFromEntries<TFeatureAccessMap> = ({
2674
+ [K in keyof TFeatureAccessMap]: Extract<TFeatureAccessMap[K], {
2675
+ type: "limit";
2676
+ usage: unknown;
2677
+ }> extends never ? never : K;
2678
+ }[keyof TFeatureAccessMap] & string);
2679
+ type TrackedLimitFeatureKeyFromAccessMap<TFeatureAccessMap> = IsAny<TFeatureAccessMap> extends true ? string : TrackedLimitFeatureKeyFromEntries<TFeatureAccessMap> extends never ? string : TrackedLimitFeatureKeyFromEntries<TFeatureAccessMap>;
2721
2680
  type TrackUsageBodyBase = paths["/v1/usage"]["post"]["requestBody"]["content"]["application/json"];
2722
2681
  type TrackUsageBody<TFeatureKey extends string = TrackUsageBodyBase["featureKey"]> = Omit<TrackUsageBodyBase, "featureKey"> & {
2723
2682
  featureKey: TFeatureKey;
@@ -2781,7 +2740,7 @@ type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
2781
2740
  getAccess(customerId: string): Promise<TFeatureAccessMap>;
2782
2741
  };
2783
2742
  type PriceOSBonusesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
2784
- create(input: CreateBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<CreateBonusResponse>;
2743
+ create(input: CreateBonusBody<TrackedLimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<CreateBonusResponse>;
2785
2744
  list(input: ListBonusesRequest<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<ListBonusesResponse>;
2786
2745
  update(input: UpdateBonusRequest): Promise<UpdateBonusResponse>;
2787
2746
  delete(bonusId: string): Promise<DeleteBonusResponse>;
@@ -2818,4 +2777,4 @@ declare class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse> implements P
2818
2777
  constructor(apiKey: string, opts?: PriceOSClientOptions);
2819
2778
  }
2820
2779
 
2821
- export { type CreateBonusBody, type CreateBonusResponse, type CreateCustomerRequest, type CreateCustomerResponse, type DeleteBonusRequest, type DeleteBonusResponse, type DeleteCustomerRequest, type DeleteCustomerResponse, type DeleteUsageEventsBody, type DeleteUsageEventsResponse, type GetCustomerResponse, type GetFeatureAccessResponse, type LimitFeatureKeyFromAccessMap, type LinkCustomerBody, type LinkCustomerResponse, type ListBonusesRequest, type ListBonusesResponse, type ListUsageEventsBody, type ListUsageEventsResponse, PriceOS, type PriceOSBonusesClient, type PriceOSClientOptions, type PriceOSCustomersClient, PriceOSError, type PriceOSFeaturesClient, type PriceOSHttpClient, type PriceOSLogLevel, type PriceOSUsageClient, type ResetUsageBody, type ResetUsageResponse, type TrackUsageBatchBody, type TrackUsageBatchEvent, type TrackUsageBatchResponse, type TrackUsageBody, type TrackUsageResponse, type UpdateBonusBody, type UpdateBonusRequest, type UpdateBonusResponse, type UpdateCustomerBody, type UpdateCustomerResponse, type UsageEvent };
2780
+ export { type CreateBonusBody, type CreateBonusResponse, type CreateCustomerRequest, type CreateCustomerResponse, type DeleteBonusRequest, type DeleteBonusResponse, type DeleteCustomerRequest, type DeleteCustomerResponse, type DeleteUsageEventsBody, type DeleteUsageEventsResponse, type GetCustomerResponse, type GetFeatureAccessResponse, type LimitFeatureKeyFromAccessMap, type LinkCustomerBody, type LinkCustomerResponse, type ListBonusesRequest, type ListBonusesResponse, type ListUsageEventsBody, type ListUsageEventsResponse, PriceOS, type PriceOSBonusesClient, type PriceOSClientOptions, type PriceOSCustomersClient, PriceOSError, type PriceOSFeaturesClient, type PriceOSHttpClient, type PriceOSLogLevel, type PriceOSUsageClient, type ResetUsageBody, type ResetUsageResponse, type TrackUsageBatchBody, type TrackUsageBatchEvent, type TrackUsageBatchResponse, type TrackUsageBody, type TrackUsageResponse, type TrackedLimitFeatureKeyFromAccessMap, type UpdateBonusBody, type UpdateBonusRequest, type UpdateBonusResponse, type UpdateCustomerBody, type UpdateCustomerResponse, type UsageEvent };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import createClient from \"openapi-fetch\";\nimport type { Client } from \"openapi-fetch\";\nimport type { paths } from \"./gen/openapi\";\nimport {\n CreateBonusBody,\n CreateBonusResponse,\n CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteBonusResponse,\n ListBonusesRequest,\n ListBonusesResponse,\n DeleteUsageEventsBody,\n DeleteUsageEventsResponse,\n DeleteCustomerResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n LinkCustomerBody,\n LinkCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n ListUsageEventsBody,\n ListUsageEventsResponse,\n ResetUsageBody,\n ResetUsageResponse,\n UpdateBonusRequest,\n UpdateBonusResponse,\n TrackUsageBody,\n TrackUsageBatchBody,\n TrackUsageBatchResponse,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\nexport type PriceOSLogLevel = \"none\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n logLevel?: PriceOSLogLevel;\n};\n\nconst RATE_LIMIT_STATUS = 429;\nconst MAX_RETRIES = 4;\nconst BASE_DELAY_MS = 250;\nconst BACKOFF_MULTIPLIER = 2;\nconst JITTER_MS = 250;\nconst RETRY_DELAY_CAP_MS = 5_000;\nconst REQUEST_TIMEOUT_MS = 20_000;\n\nconst LOG_LEVELS: Record<PriceOSLogLevel, number> = {\n none: 0,\n error: 1,\n warning: 2,\n info: 3,\n debug: 4,\n};\n\ntype Logger = {\n error: (message: string, details?: Record<string, unknown>) => void;\n warning: (message: string, details?: Record<string, unknown>) => void;\n info: (message: string, details?: Record<string, unknown>) => void;\n debug: (message: string, details?: Record<string, unknown>) => void;\n};\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\nconst getRetryDelayMs = (retryCount: number): number => {\n const backoff = BASE_DELAY_MS * Math.pow(BACKOFF_MULTIPLIER, retryCount - 1);\n const jitter = Math.random() * JITTER_MS;\n return Math.min(RETRY_DELAY_CAP_MS, backoff + jitter);\n};\n\nconst createLogger = (logLevel: PriceOSLogLevel): Logger => {\n const shouldLog = (level: PriceOSLogLevel): boolean =>\n logLevel !== \"none\" && LOG_LEVELS[level] <= LOG_LEVELS[logLevel];\n\n const write = (\n level: PriceOSLogLevel,\n message: string,\n details?: Record<string, unknown>\n ): void => {\n if (!shouldLog(level)) return;\n const prefix = `[PriceOS] ${level.toUpperCase()}: ${message}`;\n const payload = details && Object.keys(details).length > 0 ? details : undefined;\n\n switch (level) {\n case \"error\":\n payload ? console.error(prefix, payload) : console.error(prefix);\n return;\n case \"warning\":\n payload ? console.warn(prefix, payload) : console.warn(prefix);\n return;\n case \"info\":\n payload ? console.info(prefix, payload) : console.info(prefix);\n return;\n case \"debug\":\n payload ? console.debug(prefix, payload) : console.debug(prefix);\n return;\n }\n };\n\n return {\n error: (message, details) => write(\"error\", message, details),\n warning: (message, details) => write(\"warning\", message, details),\n info: (message, details) => write(\"info\", message, details),\n debug: (message, details) => write(\"debug\", message, details),\n };\n};\n\nconst getUpstreamSignal = (input: RequestInfo | URL, init?: RequestInit): AbortSignal | undefined => {\n if (init?.signal) return init.signal;\n if (typeof Request !== \"undefined\" && input instanceof Request) return input.signal;\n return undefined;\n};\n\nconst stripSignal = (init?: RequestInit): RequestInit | undefined => {\n if (!init) return undefined;\n const { signal: _signal, ...rest } = init;\n return rest;\n};\n\nconst getRequestDetails = (\n input: RequestInfo | URL,\n init?: RequestInit\n): { method: string; url: string } => {\n const method =\n init?.method ??\n (typeof Request !== \"undefined\" && input instanceof Request ? input.method : \"GET\");\n const url =\n typeof input === \"string\"\n ? input\n : input instanceof URL\n ? input.toString()\n : input.url;\n return { method, url };\n};\n\nconst prepareRetryRequest = async (\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n log: Logger,\n method: string,\n url: string\n): Promise<{ requestInput: RequestInfo | URL; baseInit?: RequestInit; canRetry: boolean }> => {\n if (!(typeof Request !== \"undefined\" && input instanceof Request)) {\n return { requestInput: input, baseInit: stripSignal(init), canRetry: true };\n }\n\n if (input.bodyUsed) {\n log.warning(\"Request body already used; retries disabled\", { method, url });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n\n let body: BodyInit | undefined = undefined;\n if (method !== \"GET\" && method !== \"HEAD\") {\n try {\n body = await input.clone().arrayBuffer();\n } catch (error) {\n log.warning(\"Unable to clone request body; retries disabled\", { method, url, error });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n }\n\n const headers = new Headers(input.headers);\n const baseInit = { ...stripSignal(init), method, headers, body };\n return { requestInput: input.url, baseInit, canRetry: true };\n};\n\nconst getErrorMessage = (error: unknown): string => {\n const maybeError = error as { error?: unknown } | null;\n if (maybeError && typeof maybeError.error === \"string\") return maybeError.error;\n return \"Request failed\";\n};\n\nconst throwRequestError = (\n log: Logger,\n error: unknown,\n response: Response | undefined,\n context: string\n): never => {\n log.error(\"Request failed\", { context, status: response?.status, error });\n throw new PriceOSError(getErrorMessage(error), { status: response?.status, details: error });\n};\n\nconst createRetryingFetch = (baseFetch: typeof fetch, log: Logger): typeof fetch => {\n return async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {\n const { method, url } = getRequestDetails(input, init);\n const upstreamSignal = getUpstreamSignal(input, init);\n const { requestInput, baseInit, canRetry } = await prepareRetryRequest(\n input,\n init,\n log,\n method,\n url\n );\n let attempt = 0;\n while (true) {\n log.debug(\"Request attempt\", { method, url, attempt: attempt + 1, maxRetries: MAX_RETRIES });\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);\n let removeAbortListener: (() => void) | null = null;\n\n if (upstreamSignal) {\n if (upstreamSignal.aborted) {\n controller.abort();\n } else {\n const onAbort = () => controller.abort();\n upstreamSignal.addEventListener(\"abort\", onAbort);\n removeAbortListener = () => upstreamSignal.removeEventListener(\"abort\", onAbort);\n }\n }\n\n try {\n const requestInit = { ...(baseInit ?? {}), signal: controller.signal };\n const response = await baseFetch(requestInput, requestInit);\n if (response.status !== RATE_LIMIT_STATUS) return response;\n\n const retryAfter = response.headers.get(\"retry-after\") ?? undefined;\n log.warning(\"Rate limit hit (429)\", {\n method,\n url,\n attempt: attempt + 1,\n maxRetries: MAX_RETRIES,\n retryAfter,\n });\n\n if (!canRetry) {\n log.warning(\"Skipping retry because request body is not replayable\", { method, url });\n return response;\n }\n\n if (attempt >= MAX_RETRIES) {\n log.error(\"Rate limit retries exhausted\", { method, url, attempts: attempt + 1 });\n return response;\n }\n\n const delayMs = getRetryDelayMs(attempt + 1);\n log.info(\"Waiting to retry after rate limit\", {\n method,\n url,\n delayMs,\n nextAttempt: attempt + 2,\n maxRetries: MAX_RETRIES,\n });\n await sleep(delayMs);\n attempt += 1;\n } catch (error) {\n if (controller.signal.aborted) {\n const abortedByCaller = upstreamSignal?.aborted ?? false;\n if (abortedByCaller) {\n log.warning(\"Request aborted by caller\", { method, url, attempt: attempt + 1 });\n } else {\n log.error(\"Request timed out\", {\n method,\n url,\n attempt: attempt + 1,\n timeoutMs: REQUEST_TIMEOUT_MS,\n });\n }\n } else {\n log.error(\"Request failed\", { method, url, attempt: attempt + 1, error });\n }\n throw error;\n } finally {\n clearTimeout(timeoutId);\n removeAbortListener?.();\n }\n }\n };\n};\n\nexport type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;\n link(input: LinkCustomerBody): Promise<LinkCustomerResponse<TFeatureAccessMap> | null>;\n create(input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>>;\n update(input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>>;\n delete(customerId: string): Promise<DeleteCustomerResponse>;\n};\n\nexport type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n getAccess(customerId: string): Promise<TFeatureAccessMap>;\n};\n\nexport type PriceOSBonusesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n create(\n input: CreateBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<CreateBonusResponse>;\n list(\n input: ListBonusesRequest<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListBonusesResponse>;\n update(input: UpdateBonusRequest): Promise<UpdateBonusResponse>;\n delete(bonusId: string): Promise<DeleteBonusResponse>;\n};\n\nexport type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n track(\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse>;\n reset(\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse>;\n deleteEvents(\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse>;\n trackBatch(\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse>;\n listEvents(\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse>;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n bonuses: PriceOSBonusesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n};\n\nexport class PriceOSError extends Error {\n status?: number;\n details?: unknown;\n\n constructor(message: string, opts?: { status?: number; details?: unknown }) {\n super(message);\n this.name = \"PriceOSError\";\n this.status = opts?.status;\n this.details = opts?.details;\n }\n}\n\nexport class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse>\n implements PriceOSHttpClient<TFeatureAccessMap>\n{\n private client: Client<paths>;\n private header: { \"x-api-key\": string };\n private log: Logger;\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n bonuses: PriceOSBonusesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n\n constructor(apiKey: string, opts: PriceOSClientOptions = {}) {\n const logLevel = opts.logLevel ?? \"none\";\n this.log = createLogger(logLevel);\n const baseUrl = \"https://api.priceos.com\";\n this.header = { \"x-api-key\": apiKey };\n const fetchWithRetry = createRetryingFetch(fetch, this.log);\n this.client = createClient<paths>({\n baseUrl,\n fetch: fetchWithRetry,\n headers: {\n \"x-api-key\": apiKey,\n },\n });\n\n this.customers = {\n get: async (customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.GET(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/customers/{customerId}\");\n return (data ?? null) as GetCustomerResponse<TFeatureAccessMap> | null;\n },\n link: async (\n input: LinkCustomerBody\n ): Promise<LinkCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.POST(\"/v1/customers/link\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/customers/link\");\n return (data ?? null) as LinkCustomerResponse<TFeatureAccessMap> | null;\n },\n create: async (input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>> => {\n const { data, error, response } = await this.client.POST(\"/v1/customers\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/customers\");\n return data! as CreateCustomerResponse<TFeatureAccessMap>;\n },\n update: async (input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>> => {\n const { customerId, ...body } = input;\n const { data, error, response } = await this.client.PUT(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n body,\n });\n if (error) throwRequestError(this.log, error, response, \"PUT /v1/customers/{customerId}\");\n return data! as UpdateCustomerResponse<TFeatureAccessMap>;\n },\n delete: async (customerId: string): Promise<DeleteCustomerResponse> => {\n const { data, error, response } = await this.client.DELETE(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"DELETE /v1/customers/{customerId}\");\n return data! as DeleteCustomerResponse;\n },\n };\n\n this.features = {\n getAccess: async (customerId: string): Promise<TFeatureAccessMap> => {\n const { data, error, response } = await this.client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/feature-access\");\n return data! as TFeatureAccessMap;\n },\n };\n\n this.bonuses = {\n create: async (\n input: CreateBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<CreateBonusResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/bonuses\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/bonuses\");\n return data!;\n },\n list: async (\n input: ListBonusesRequest<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListBonusesResponse> => {\n const { data, error, response } = await this.client.GET(\"/v1/bonuses\", {\n params: { header: this.header, query: input },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/bonuses\");\n return data!;\n },\n update: async (input: UpdateBonusRequest): Promise<UpdateBonusResponse> => {\n const { bonusId, ...body } = input;\n const { data, error, response } = await this.client.PUT(\"/v1/bonuses/{bonusId}\", {\n params: { header: this.header, path: { bonusId } },\n body,\n });\n if (error) throwRequestError(this.log, error, response, \"PUT /v1/bonuses/{bonusId}\");\n return data!;\n },\n delete: async (bonusId: string): Promise<DeleteBonusResponse> => {\n const { data, error, response } = await this.client.DELETE(\"/v1/bonuses/{bonusId}\", {\n params: { header: this.header, path: { bonusId } },\n });\n if (error) throwRequestError(this.log, error, response, \"DELETE /v1/bonuses/{bonusId}\");\n return data!;\n },\n };\n\n this.usage = {\n track: async (\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage\");\n return data!;\n },\n reset: async (\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/void\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/void\");\n return data!;\n },\n deleteEvents: async (\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/delete\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/delete\");\n return data!;\n },\n trackBatch: async (\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/batch\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/batch\");\n return data!;\n },\n listEvents: async (\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/events\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/events\");\n return data!;\n },\n };\n }\n}\n"],"mappings":";AAAA,OAAO,kBAAkB;AAwCzB,IAAM,oBAAoB;AAC1B,IAAM,cAAc;AACpB,IAAM,gBAAgB;AACtB,IAAM,qBAAqB;AAC3B,IAAM,YAAY;AAClB,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAE3B,IAAM,aAA8C;AAAA,EAClD,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACT;AASA,IAAM,QAAQ,CAAC,OAA8B,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAE7F,IAAM,kBAAkB,CAAC,eAA+B;AACtD,QAAM,UAAU,gBAAgB,KAAK,IAAI,oBAAoB,aAAa,CAAC;AAC3E,QAAM,SAAS,KAAK,OAAO,IAAI;AAC/B,SAAO,KAAK,IAAI,oBAAoB,UAAU,M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AAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,qBAAqB;AAC7E,eAAO;AAAA,MACT;AAAA,MACA,cAAc,OACZ,UACuC;AACvC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,oBAAoB;AAAA,UAC3E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,MACA,YAAY,OACV,UACqC;AACrC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,mBAAmB;AAAA,UAC1E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,sBAAsB;AAC9E,eAAO;AAAA,MACT;AAAA,MACA,YAAY,OACV,UACqC;AACrC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,oBAAoB;AAAA,UAC3E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import createClient from \"openapi-fetch\";\nimport type { Client } from \"openapi-fetch\";\nimport type { paths } from \"./gen/openapi\";\nimport {\n CreateBonusBody,\n CreateBonusResponse,\n CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteBonusResponse,\n ListBonusesRequest,\n ListBonusesResponse,\n DeleteUsageEventsBody,\n DeleteUsageEventsResponse,\n DeleteCustomerResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n LinkCustomerBody,\n LinkCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n TrackedLimitFeatureKeyFromAccessMap,\n ListUsageEventsBody,\n ListUsageEventsResponse,\n ResetUsageBody,\n ResetUsageResponse,\n UpdateBonusRequest,\n UpdateBonusResponse,\n TrackUsageBody,\n TrackUsageBatchBody,\n TrackUsageBatchResponse,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\nexport type PriceOSLogLevel = \"none\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n logLevel?: PriceOSLogLevel;\n};\n\nconst RATE_LIMIT_STATUS = 429;\nconst MAX_RETRIES = 4;\nconst BASE_DELAY_MS = 250;\nconst BACKOFF_MULTIPLIER = 2;\nconst JITTER_MS = 250;\nconst RETRY_DELAY_CAP_MS = 5_000;\nconst REQUEST_TIMEOUT_MS = 20_000;\n\nconst LOG_LEVELS: Record<PriceOSLogLevel, number> = {\n none: 0,\n error: 1,\n warning: 2,\n info: 3,\n debug: 4,\n};\n\ntype Logger = {\n error: (message: string, details?: Record<string, unknown>) => void;\n warning: (message: string, details?: Record<string, unknown>) => void;\n info: (message: string, details?: Record<string, unknown>) => void;\n debug: (message: string, details?: Record<string, unknown>) => void;\n};\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\nconst getRetryDelayMs = (retryCount: number): number => {\n const backoff = BASE_DELAY_MS * Math.pow(BACKOFF_MULTIPLIER, retryCount - 1);\n const jitter = Math.random() * JITTER_MS;\n return Math.min(RETRY_DELAY_CAP_MS, backoff + jitter);\n};\n\nconst createLogger = (logLevel: PriceOSLogLevel): Logger => {\n const shouldLog = (level: PriceOSLogLevel): boolean =>\n logLevel !== \"none\" && LOG_LEVELS[level] <= LOG_LEVELS[logLevel];\n\n const write = (\n level: PriceOSLogLevel,\n message: string,\n details?: Record<string, unknown>\n ): void => {\n if (!shouldLog(level)) return;\n const prefix = `[PriceOS] ${level.toUpperCase()}: ${message}`;\n const payload = details && Object.keys(details).length > 0 ? details : undefined;\n\n switch (level) {\n case \"error\":\n payload ? console.error(prefix, payload) : console.error(prefix);\n return;\n case \"warning\":\n payload ? console.warn(prefix, payload) : console.warn(prefix);\n return;\n case \"info\":\n payload ? console.info(prefix, payload) : console.info(prefix);\n return;\n case \"debug\":\n payload ? console.debug(prefix, payload) : console.debug(prefix);\n return;\n }\n };\n\n return {\n error: (message, details) => write(\"error\", message, details),\n warning: (message, details) => write(\"warning\", message, details),\n info: (message, details) => write(\"info\", message, details),\n debug: (message, details) => write(\"debug\", message, details),\n };\n};\n\nconst getUpstreamSignal = (input: RequestInfo | URL, init?: RequestInit): AbortSignal | undefined => {\n if (init?.signal) return init.signal;\n if (typeof Request !== \"undefined\" && input instanceof Request) return input.signal;\n return undefined;\n};\n\nconst stripSignal = (init?: RequestInit): RequestInit | undefined => {\n if (!init) return undefined;\n const { signal: _signal, ...rest } = init;\n return rest;\n};\n\nconst getRequestDetails = (\n input: RequestInfo | URL,\n init?: RequestInit\n): { method: string; url: string } => {\n const method =\n init?.method ??\n (typeof Request !== \"undefined\" && input instanceof Request ? input.method : \"GET\");\n const url =\n typeof input === \"string\"\n ? input\n : input instanceof URL\n ? input.toString()\n : input.url;\n return { method, url };\n};\n\nconst prepareRetryRequest = async (\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n log: Logger,\n method: string,\n url: string\n): Promise<{ requestInput: RequestInfo | URL; baseInit?: RequestInit; canRetry: boolean }> => {\n if (!(typeof Request !== \"undefined\" && input instanceof Request)) {\n return { requestInput: input, baseInit: stripSignal(init), canRetry: true };\n }\n\n if (input.bodyUsed) {\n log.warning(\"Request body already used; retries disabled\", { method, url });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n\n let body: BodyInit | undefined = undefined;\n if (method !== \"GET\" && method !== \"HEAD\") {\n try {\n body = await input.clone().arrayBuffer();\n } catch (error) {\n log.warning(\"Unable to clone request body; retries disabled\", { method, url, error });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n }\n\n const headers = new Headers(input.headers);\n const baseInit = { ...stripSignal(init), method, headers, body };\n return { requestInput: input.url, baseInit, canRetry: true };\n};\n\nconst getErrorMessage = (error: unknown): string => {\n const maybeError = error as { error?: unknown } | null;\n if (maybeError && typeof maybeError.error === \"string\") return maybeError.error;\n return \"Request failed\";\n};\n\nconst throwRequestError = (\n log: Logger,\n error: unknown,\n response: Response | undefined,\n context: string\n): never => {\n log.error(\"Request failed\", { context, status: response?.status, error });\n throw new PriceOSError(getErrorMessage(error), { status: response?.status, details: error });\n};\n\nconst createRetryingFetch = (baseFetch: typeof fetch, log: Logger): typeof fetch => {\n return async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {\n const { method, url } = getRequestDetails(input, init);\n const upstreamSignal = getUpstreamSignal(input, init);\n const { requestInput, baseInit, canRetry } = await prepareRetryRequest(\n input,\n init,\n log,\n method,\n url\n );\n let attempt = 0;\n while (true) {\n log.debug(\"Request attempt\", { method, url, attempt: attempt + 1, maxRetries: MAX_RETRIES });\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);\n let removeAbortListener: (() => void) | null = null;\n\n if (upstreamSignal) {\n if (upstreamSignal.aborted) {\n controller.abort();\n } else {\n const onAbort = () => controller.abort();\n upstreamSignal.addEventListener(\"abort\", onAbort);\n removeAbortListener = () => upstreamSignal.removeEventListener(\"abort\", onAbort);\n }\n }\n\n try {\n const requestInit = { ...(baseInit ?? {}), signal: controller.signal };\n const response = await baseFetch(requestInput, requestInit);\n if (response.status !== RATE_LIMIT_STATUS) return response;\n\n const retryAfter = response.headers.get(\"retry-after\") ?? undefined;\n log.warning(\"Rate limit hit (429)\", {\n method,\n url,\n attempt: attempt + 1,\n maxRetries: MAX_RETRIES,\n retryAfter,\n });\n\n if (!canRetry) {\n log.warning(\"Skipping retry because request body is not replayable\", { method, url });\n return response;\n }\n\n if (attempt >= MAX_RETRIES) {\n log.error(\"Rate limit retries exhausted\", { method, url, attempts: attempt + 1 });\n return response;\n }\n\n const delayMs = getRetryDelayMs(attempt + 1);\n log.info(\"Waiting to retry after rate limit\", {\n method,\n url,\n delayMs,\n nextAttempt: attempt + 2,\n maxRetries: MAX_RETRIES,\n });\n await sleep(delayMs);\n attempt += 1;\n } catch (error) {\n if (controller.signal.aborted) {\n const abortedByCaller = upstreamSignal?.aborted ?? false;\n if (abortedByCaller) {\n log.warning(\"Request aborted by caller\", { method, url, attempt: attempt + 1 });\n } else {\n log.error(\"Request timed out\", {\n method,\n url,\n attempt: attempt + 1,\n timeoutMs: REQUEST_TIMEOUT_MS,\n });\n }\n } else {\n log.error(\"Request failed\", { method, url, attempt: attempt + 1, error });\n }\n throw error;\n } finally {\n clearTimeout(timeoutId);\n removeAbortListener?.();\n }\n }\n };\n};\n\nexport type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;\n link(input: LinkCustomerBody): Promise<LinkCustomerResponse<TFeatureAccessMap> | null>;\n create(input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>>;\n update(input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>>;\n delete(customerId: string): Promise<DeleteCustomerResponse>;\n};\n\nexport type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n getAccess(customerId: string): Promise<TFeatureAccessMap>;\n};\n\nexport type PriceOSBonusesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n create(\n input: CreateBonusBody<TrackedLimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<CreateBonusResponse>;\n list(\n input: ListBonusesRequest<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListBonusesResponse>;\n update(input: UpdateBonusRequest): Promise<UpdateBonusResponse>;\n delete(bonusId: string): Promise<DeleteBonusResponse>;\n};\n\nexport type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n track(\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse>;\n reset(\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse>;\n deleteEvents(\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse>;\n trackBatch(\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse>;\n listEvents(\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse>;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n bonuses: PriceOSBonusesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n};\n\nexport class PriceOSError extends Error {\n status?: number;\n details?: unknown;\n\n constructor(message: string, opts?: { status?: number; details?: unknown }) {\n super(message);\n this.name = \"PriceOSError\";\n this.status = opts?.status;\n this.details = opts?.details;\n }\n}\n\nexport class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse>\n implements PriceOSHttpClient<TFeatureAccessMap>\n{\n private client: Client<paths>;\n private header: { \"x-api-key\": string };\n private log: Logger;\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n bonuses: PriceOSBonusesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n\n constructor(apiKey: string, opts: PriceOSClientOptions = {}) {\n const logLevel = opts.logLevel ?? \"none\";\n this.log = createLogger(logLevel);\n const baseUrl = \"https://api.priceos.com\";\n this.header = { \"x-api-key\": apiKey };\n const fetchWithRetry = createRetryingFetch(fetch, this.log);\n this.client = createClient<paths>({\n baseUrl,\n fetch: fetchWithRetry,\n headers: {\n \"x-api-key\": apiKey,\n },\n });\n\n this.customers = {\n get: async (customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.GET(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/customers/{customerId}\");\n return (data ?? null) as GetCustomerResponse<TFeatureAccessMap> | null;\n },\n link: async (\n input: LinkCustomerBody\n ): Promise<LinkCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.POST(\"/v1/customers/link\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/customers/link\");\n return (data ?? null) as LinkCustomerResponse<TFeatureAccessMap> | null;\n },\n create: async (input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>> => {\n const { data, error, response } = await this.client.POST(\"/v1/customers\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/customers\");\n return data! as CreateCustomerResponse<TFeatureAccessMap>;\n },\n update: async (input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>> => {\n const { customerId, ...body } = input;\n const { data, error, response } = await this.client.PUT(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n body,\n });\n if (error) throwRequestError(this.log, error, response, \"PUT /v1/customers/{customerId}\");\n return data! as UpdateCustomerResponse<TFeatureAccessMap>;\n },\n delete: async (customerId: string): Promise<DeleteCustomerResponse> => {\n const { data, error, response } = await this.client.DELETE(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"DELETE /v1/customers/{customerId}\");\n return data! as DeleteCustomerResponse;\n },\n };\n\n this.features = {\n getAccess: async (customerId: string): Promise<TFeatureAccessMap> => {\n const { data, error, response } = await this.client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/feature-access\");\n return data! as TFeatureAccessMap;\n },\n };\n\n this.bonuses = {\n create: async (\n input: CreateBonusBody<TrackedLimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<CreateBonusResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/bonuses\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/bonuses\");\n return data!;\n },\n list: async (\n input: ListBonusesRequest<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListBonusesResponse> => {\n const { data, error, response } = await this.client.GET(\"/v1/bonuses\", {\n params: { header: this.header, query: input },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/bonuses\");\n return data!;\n },\n update: async (input: UpdateBonusRequest): Promise<UpdateBonusResponse> => {\n const { bonusId, ...body } = input;\n const { data, error, response } = await this.client.PUT(\"/v1/bonuses/{bonusId}\", {\n params: { header: this.header, path: { bonusId } },\n body,\n });\n if (error) throwRequestError(this.log, error, response, \"PUT /v1/bonuses/{bonusId}\");\n return data!;\n },\n delete: async (bonusId: string): Promise<DeleteBonusResponse> => {\n const { data, error, response } = await this.client.DELETE(\"/v1/bonuses/{bonusId}\", {\n params: { header: this.header, path: { bonusId } },\n });\n if (error) throwRequestError(this.log, error, response, \"DELETE /v1/bonuses/{bonusId}\");\n return data!;\n },\n };\n\n this.usage = {\n track: async (\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage\");\n return data!;\n },\n reset: async (\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/void\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/void\");\n return data!;\n },\n deleteEvents: async (\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/delete\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/delete\");\n return data!;\n },\n trackBatch: async (\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/batch\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/batch\");\n return data!;\n },\n listEvents: async (\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/events\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/events\");\n return data!;\n },\n };\n }\n}\n"],"mappings":";AAAA,OAAO,kBAAkB;AAyCzB,IAAM,oBAAoB;AAC1B,IAAM,cAAc;AACpB,IAAM,gBAAgB;AACtB,IAAM,qBAAqB;AAC3B,IAAM,YAAY;AAClB,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAE3B,IAAM,aAA8C;AAAA,EAClD,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACT;AASA,IAAM,QAAQ,CAAC,OAA8B,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAE7F,IAAM,kBAAkB,CAAC,eAA+B;AACtD,QAAM,UAAU,gBAAgB,KAAK,IAAI,oBAAoB,aAAa,CAAC;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zE,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,qBAAqB;AAC7E,eAAO;AAAA,MACT;AAAA,MACA,cAAc,OACZ,UACuC;AACvC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,oBAAoB;AAAA,UAC3E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,MACA,YAAY,OACV,UACqC;AACrC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,mBAAmB;AAAA,UAC1E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,sBAAsB;AAC9E,eAAO;AAAA,MACT;AAAA,MACA,YAAY,OACV,UACqC;AACrC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,oBAAoB;AAAA,UAC3E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "priceos",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",