priceos 0.0.1 → 0.0.4

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
@@ -46,12 +46,12 @@ Generates TypeScript feature access types for your PriceOS workspace.
46
46
  Options:
47
47
  --base-url <url> PriceOS API base URL (defaults to env PRICEOS_BASE_URL or https://api.priceos.com)
48
48
  --api-key <key> PriceOS API key (defaults to env PRICEOS_API_KEY) [required]
49
- --out <path> Output .d.ts file (default: src/priceos.d.ts)
49
+ --out <path> Output .d.ts file (default: priceos.d.ts in current directory)
50
50
  -h, --help Show help
51
51
 
52
52
  Examples:
53
53
  priceos sync --api-key sk_test_... --base-url http://localhost:3000
54
- priceos sync --api-key sk_test_... --out src/priceos.d.ts
54
+ priceos sync --api-key sk_test_... --out ./priceos.d.ts
55
55
  `.trim());
56
56
  }
57
57
  async function main() {
@@ -72,7 +72,7 @@ async function main() {
72
72
  console.error("Missing API key. Provide --api-key <key> or set PRICEOS_API_KEY.");
73
73
  process.exit(1);
74
74
  }
75
- const outRel = argValue(args, "--out") ?? "src/priceos.d.ts";
75
+ const outRel = argValue(args, "--out") ?? "priceos.d.ts";
76
76
  const outPath = import_node_path.default.resolve(process.cwd(), outRel);
77
77
  const url = `${normalizeBaseUrl(baseUrl)}/v1/features`;
78
78
  const res = await fetch(url, {
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 = { featureKey: string; type?: \"boolean\" | \"limit\" | null };\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\nfunction normalizeBaseUrl(baseUrl: string) {\n return baseUrl.replace(/\\/$/, \"\");\n}\n\nfunction printHelp() {\n console.log(`\npriceos sync\n\nGenerates TypeScript feature access types for your PriceOS workspace.\n\nOptions:\n --base-url <url> PriceOS API base URL (defaults to env PRICEOS_BASE_URL or https://api.priceos.com)\n --api-key <key> PriceOS API key (defaults to env PRICEOS_API_KEY) [required]\n --out <path> Output .d.ts file (default: src/priceos.d.ts)\n -h, --help Show help\n\nExamples:\n priceos sync --api-key sk_test_... --base-url http://localhost:3000\n priceos sync --api-key sk_test_... --out src/priceos.d.ts\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 !== \"sync\") {\n console.error(`Unknown command: ${cmd}`);\n printHelp();\n process.exit(1);\n }\n\n const baseUrl =\n argValue(args, \"--base-url\") ??\n process.env.PRICEOS_BASE_URL ??\n \"https://api.priceos.com\";\n\n const apiKey =\n argValue(args, \"--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.\");\n process.exit(1);\n }\n\n const outRel = argValue(args, \"--out\") ?? \"src/priceos.d.ts\";\n const outPath = path.resolve(process.cwd(), outRel);\n\n const url = `${normalizeBaseUrl(baseUrl)}/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\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 continue;\n }\n if (currentType !== nextType) {\n typeByKey.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 mapLines = keys.map((key) => {\n const featureType = typeByKey.get(key);\n const accessType =\n featureType === \"boolean\"\n ? \"BooleanFeatureAccess\"\n : featureType === \"limit\"\n ? \"LimitFeatureAccess\"\n : \"FeatureAccessEntry\";\n return ` ${JSON.stringify(key)}: ${accessType};`;\n });\n\n const content = `// Auto-generated by PriceOS (priceos sync). Do not edit.\nexport type FeatureKey = ${union};\nexport type BooleanFeatureAccess = {\n type: \"boolean\";\n hasAccess: boolean;\n};\nexport type LimitFeatureAccess = {\n type: \"limit\";\n hasAccess: boolean;\n isUnlimited: boolean;\n limit: number | null;\n used: number;\n};\nexport type FeatureAccessEntry = BooleanFeatureAccess | LimitFeatureAccess;\nexport type FeatureAccessMap = {\n${mapLines.join(\"\\n\")}\n} & Record<string, FeatureAccessEntry>;\n`;\n\n await fs.mkdir(path.dirname(outPath), { recursive: true });\n await fs.writeFile(outPath, content, \"utf8\");\n\n console.log(`Generated ${outRel} (${keys.length} feature keys)`);\n}\n\nmain().catch((e) => {\n console.error(e);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sBAAe;AACf,uBAAiB;AAIjB,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,SAAS,iBAAiB,SAAiB;AACzC,SAAO,QAAQ,QAAQ,OAAO,EAAE;AAClC;AAEA,SAAS,YAAY;AACnB,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcZ,K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aAAa,QAAQ,SAAS,UAAU,QAAQ,OAAO;AACzF,UAAM,cAAc,UAAU,IAAI,GAAG;AACrC,QAAI,CAAC,aAAa;AAChB,gBAAU,IAAI,KAAK,QAAQ;AAC3B;AAAA,IACF;AACA,QAAI,gBAAgB,UAAU;AAC5B,gBAAU,IAAI,KAAK,SAAS;AAAA,IAC9B;AAAA,EACF;AAEA,QAAM,OAAO,CAAC,GAAG,UAAU,KAAK,CAAC,EAAE,KAAK;AACxC,QAAM,QAAQ,KAAK,SAAS,KAAK,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI;AAC7E,QAAM,WAAW,KAAK,IAAI,CAAC,QAAQ;AACjC,UAAM,cAAc,UAAU,IAAI,GAAG;AACrC,UAAM,aACJ,gBAAgB,YACZ,yBACA,gBAAgB,UACd,uBACA;AACR,WAAO,KAAK,KAAK,UAAU,GAAG,CAAC,KAAK,UAAU;AAAA,EAChD,CAAC;AAED,QAAM,UAAU;AAAA,2BACS,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc9B,SAAS,KAAK,IAAI,CAAC;AAAA;AAAA;AAInB,QAAM,gBAAAC,QAAG,MAAM,iBAAAD,QAAK,QAAQ,OAAO,GAAG,EAAE,WAAW,KAAK,CAAC;AACzD,QAAM,gBAAAC,QAAG,UAAU,SAAS,SAAS,MAAM;AAE3C,UAAQ,IAAI,aAAa,MAAM,KAAK,KAAK,MAAM,gBAAgB;AACjE;AAEA,KAAK,EAAE,MAAM,CAAC,MAAM;AAClB,UAAQ,MAAM,CAAC;AACf,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["path","fs"]}
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 = { featureKey: string; type?: \"boolean\" | \"limit\" | null };\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\nfunction normalizeBaseUrl(baseUrl: string) {\n return baseUrl.replace(/\\/$/, \"\");\n}\n\nfunction printHelp() {\n console.log(`\npriceos sync\n\nGenerates TypeScript feature access types for your PriceOS workspace.\n\nOptions:\n --base-url <url> PriceOS API base URL (defaults to env PRICEOS_BASE_URL or https://api.priceos.com)\n --api-key <key> PriceOS API key (defaults to env PRICEOS_API_KEY) [required]\n --out <path> Output .d.ts file (default: priceos.d.ts in current directory)\n -h, --help Show help\n\nExamples:\n priceos sync --api-key sk_test_... --base-url http://localhost:3000\n priceos sync --api-key sk_test_... --out ./priceos.d.ts\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 !== \"sync\") {\n console.error(`Unknown command: ${cmd}`);\n printHelp();\n process.exit(1);\n }\n\n const baseUrl =\n argValue(args, \"--base-url\") ??\n process.env.PRICEOS_BASE_URL ??\n \"https://api.priceos.com\";\n\n const apiKey =\n argValue(args, \"--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.\");\n process.exit(1);\n }\n\n const outRel = argValue(args, \"--out\") ?? \"priceos.d.ts\";\n const outPath = path.resolve(process.cwd(), outRel);\n\n const url = `${normalizeBaseUrl(baseUrl)}/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\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 continue;\n }\n if (currentType !== nextType) {\n typeByKey.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 mapLines = keys.map((key) => {\n const featureType = typeByKey.get(key);\n const accessType =\n featureType === \"boolean\"\n ? \"BooleanFeatureAccess\"\n : featureType === \"limit\"\n ? \"LimitFeatureAccess\"\n : \"FeatureAccessEntry\";\n return ` ${JSON.stringify(key)}: ${accessType};`;\n });\n\n const content = `// Auto-generated by PriceOS (priceos sync). Do not edit.\nexport type FeatureKey = ${union};\nexport type BooleanFeatureAccess = {\n type: \"boolean\";\n hasAccess: boolean;\n};\nexport type LimitFeatureAccess = {\n type: \"limit\";\n hasAccess: boolean;\n isUnlimited: boolean;\n limit: number | null;\n used: number;\n};\nexport type FeatureAccessEntry = BooleanFeatureAccess | LimitFeatureAccess;\nexport type FeatureAccessMap = {\n${mapLines.join(\"\\n\")}\n} & Record<string, FeatureAccessEntry>;\n`;\n\n await fs.mkdir(path.dirname(outPath), { recursive: true });\n await fs.writeFile(outPath, content, \"utf8\");\n\n console.log(`Generated ${outRel} (${keys.length} feature keys)`);\n}\n\nmain().catch((e) => {\n console.error(e);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sBAAe;AACf,uBAAiB;AAIjB,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;AA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;AACf,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["path","fs"]}
package/dist/cli.js CHANGED
@@ -23,12 +23,12 @@ Generates TypeScript feature access types for your PriceOS workspace.
23
23
  Options:
24
24
  --base-url <url> PriceOS API base URL (defaults to env PRICEOS_BASE_URL or https://api.priceos.com)
25
25
  --api-key <key> PriceOS API key (defaults to env PRICEOS_API_KEY) [required]
26
- --out <path> Output .d.ts file (default: src/priceos.d.ts)
26
+ --out <path> Output .d.ts file (default: priceos.d.ts in current directory)
27
27
  -h, --help Show help
28
28
 
29
29
  Examples:
30
30
  priceos sync --api-key sk_test_... --base-url http://localhost:3000
31
- priceos sync --api-key sk_test_... --out src/priceos.d.ts
31
+ priceos sync --api-key sk_test_... --out ./priceos.d.ts
32
32
  `.trim());
33
33
  }
34
34
  async function main() {
@@ -49,7 +49,7 @@ async function main() {
49
49
  console.error("Missing API key. Provide --api-key <key> or set PRICEOS_API_KEY.");
50
50
  process.exit(1);
51
51
  }
52
- const outRel = argValue(args, "--out") ?? "src/priceos.d.ts";
52
+ const outRel = argValue(args, "--out") ?? "priceos.d.ts";
53
53
  const outPath = path.resolve(process.cwd(), outRel);
54
54
  const url = `${normalizeBaseUrl(baseUrl)}/v1/features`;
55
55
  const res = await fetch(url, {
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 = { featureKey: string; type?: \"boolean\" | \"limit\" | null };\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\nfunction normalizeBaseUrl(baseUrl: string) {\n return baseUrl.replace(/\\/$/, \"\");\n}\n\nfunction printHelp() {\n console.log(`\npriceos sync\n\nGenerates TypeScript feature access types for your PriceOS workspace.\n\nOptions:\n --base-url <url> PriceOS API base URL (defaults to env PRICEOS_BASE_URL or https://api.priceos.com)\n --api-key <key> PriceOS API key (defaults to env PRICEOS_API_KEY) [required]\n --out <path> Output .d.ts file (default: src/priceos.d.ts)\n -h, --help Show help\n\nExamples:\n priceos sync --api-key sk_test_... --base-url http://localhost:3000\n priceos sync --api-key sk_test_... --out src/priceos.d.ts\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 !== \"sync\") {\n console.error(`Unknown command: ${cmd}`);\n printHelp();\n process.exit(1);\n }\n\n const baseUrl =\n argValue(args, \"--base-url\") ??\n process.env.PRICEOS_BASE_URL ??\n \"https://api.priceos.com\";\n\n const apiKey =\n argValue(args, \"--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.\");\n process.exit(1);\n }\n\n const outRel = argValue(args, \"--out\") ?? \"src/priceos.d.ts\";\n const outPath = path.resolve(process.cwd(), outRel);\n\n const url = `${normalizeBaseUrl(baseUrl)}/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\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 continue;\n }\n if (currentType !== nextType) {\n typeByKey.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 mapLines = keys.map((key) => {\n const featureType = typeByKey.get(key);\n const accessType =\n featureType === \"boolean\"\n ? \"BooleanFeatureAccess\"\n : featureType === \"limit\"\n ? \"LimitFeatureAccess\"\n : \"FeatureAccessEntry\";\n return ` ${JSON.stringify(key)}: ${accessType};`;\n });\n\n const content = `// Auto-generated by PriceOS (priceos sync). Do not edit.\nexport type FeatureKey = ${union};\nexport type BooleanFeatureAccess = {\n type: \"boolean\";\n hasAccess: boolean;\n};\nexport type LimitFeatureAccess = {\n type: \"limit\";\n hasAccess: boolean;\n isUnlimited: boolean;\n limit: number | null;\n used: number;\n};\nexport type FeatureAccessEntry = BooleanFeatureAccess | LimitFeatureAccess;\nexport type FeatureAccessMap = {\n${mapLines.join(\"\\n\")}\n} & Record<string, FeatureAccessEntry>;\n`;\n\n await fs.mkdir(path.dirname(outPath), { recursive: true });\n await fs.writeFile(outPath, content, \"utf8\");\n\n console.log(`Generated ${outRel} (${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;AAIjB,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,SAAS,iBAAiB,SAAiB;AACzC,SAAO,QAAQ,QAAQ,OAAO,EAAE;AAClC;AAEA,SAAS,YAAY;AACnB,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcZ,KAAK,CAAC;AACR;AAEA,eAAe,OAAO;AACpB,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AAEjC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,aAAa;AAChB,gBAAU,IAAI,KAAK,QAAQ;AAC3B;AAAA,IACF;AACA,QAAI,gBAAgB,UAAU;AAC5B,gBAAU,IAAI,KAAK,SAAS;AAAA,IAC9B;AAAA,EACF;AAEA,QAAM,OAAO,CAAC,GAAG,UAAU,KAAK,CAAC,EAAE,KAAK;AACxC,QAAM,QAAQ,KAAK,SAAS,KAAK,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI;AAC7E,QAAM,WAAW,KAAK,IAAI,CAAC,QAAQ;AACjC,UAAM,cAAc,UAAU,IAAI,GAAG;AACrC,UAAM,aACJ,gBAAgB,YACZ,yBACA,gBAAgB,UACd,uBACA;AACR,WAAO,KAAK,KAAK,UAAU,GAAG,CAAC,KAAK,UAAU;AAAA,EAChD,CAAC;AAED,QAAM,UAAU;AAAA,2BACS,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc9B,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,MAAM,KAAK,KAAK,MAAM,gBAAgB;AACjE;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 = { featureKey: string; type?: \"boolean\" | \"limit\" | null };\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\nfunction normalizeBaseUrl(baseUrl: string) {\n return baseUrl.replace(/\\/$/, \"\");\n}\n\nfunction printHelp() {\n console.log(`\npriceos sync\n\nGenerates TypeScript feature access types for your PriceOS workspace.\n\nOptions:\n --base-url <url> PriceOS API base URL (defaults to env PRICEOS_BASE_URL or https://api.priceos.com)\n --api-key <key> PriceOS API key (defaults to env PRICEOS_API_KEY) [required]\n --out <path> Output .d.ts file (default: priceos.d.ts in current directory)\n -h, --help Show help\n\nExamples:\n priceos sync --api-key sk_test_... --base-url http://localhost:3000\n priceos sync --api-key sk_test_... --out ./priceos.d.ts\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 !== \"sync\") {\n console.error(`Unknown command: ${cmd}`);\n printHelp();\n process.exit(1);\n }\n\n const baseUrl =\n argValue(args, \"--base-url\") ??\n process.env.PRICEOS_BASE_URL ??\n \"https://api.priceos.com\";\n\n const apiKey =\n argValue(args, \"--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.\");\n process.exit(1);\n }\n\n const outRel = argValue(args, \"--out\") ?? \"priceos.d.ts\";\n const outPath = path.resolve(process.cwd(), outRel);\n\n const url = `${normalizeBaseUrl(baseUrl)}/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\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 continue;\n }\n if (currentType !== nextType) {\n typeByKey.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 mapLines = keys.map((key) => {\n const featureType = typeByKey.get(key);\n const accessType =\n featureType === \"boolean\"\n ? \"BooleanFeatureAccess\"\n : featureType === \"limit\"\n ? \"LimitFeatureAccess\"\n : \"FeatureAccessEntry\";\n return ` ${JSON.stringify(key)}: ${accessType};`;\n });\n\n const content = `// Auto-generated by PriceOS (priceos sync). Do not edit.\nexport type FeatureKey = ${union};\nexport type BooleanFeatureAccess = {\n type: \"boolean\";\n hasAccess: boolean;\n};\nexport type LimitFeatureAccess = {\n type: \"limit\";\n hasAccess: boolean;\n isUnlimited: boolean;\n limit: number | null;\n used: number;\n};\nexport type FeatureAccessEntry = BooleanFeatureAccess | LimitFeatureAccess;\nexport type FeatureAccessMap = {\n${mapLines.join(\"\\n\")}\n} & Record<string, FeatureAccessEntry>;\n`;\n\n await fs.mkdir(path.dirname(outPath), { recursive: true });\n await fs.writeFile(outPath, content, \"utf8\");\n\n console.log(`Generated ${outRel} (${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;AAIjB,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,SAAS,iBAAiB,SAAiB;AACzC,SAAO,QAAQ,QAAQ,OAAO,EAAE;AAClC;AAEA,SAAS,YAAY;AACnB,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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UAAM,MAAM,QAAQ;AACpB,UAAM,WAAW,QAAQ,SAAS,aAAa,QAAQ,SAAS,UAAU,QAAQ,OAAO;AACzF,UAAM,cAAc,UAAU,IAAI,GAAG;AACrC,QAAI,CAAC,aAAa;AAChB,gBAAU,IAAI,KAAK,QAAQ;AAC3B;AAAA,IACF;AACA,QAAI,gBAAgB,UAAU;AAC5B,gBAAU,IAAI,KAAK,SAAS;AAAA,IAC9B;AAAA,EACF;AAEA,QAAM,OAAO,CAAC,GAAG,UAAU,KAAK,CAAC,EAAE,KAAK;AACxC,QAAM,QAAQ,KAAK,SAAS,KAAK,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI;AAC7E,QAAM,WAAW,KAAK,IAAI,CAAC,QAAQ;AACjC,UAAM,cAAc,UAAU,IAAI,GAAG;AACrC,UAAM,aACJ,gBAAgB,YACZ,yBACA,gBAAgB,UACd,uBACA;AACR,WAAO,KAAK,KAAK,UAAU,GAAG,CAAC,KAAK,UAAU;AAAA,EAChD,CAAC;AAED,QAAM,UAAU;AAAA,2BACS,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc9B,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,MAAM,KAAK,KAAK,MAAM,gBAAgB;AACjE;AAEA,KAAK,EAAE,MAAM,CAAC,MAAM;AAClB,UAAQ,MAAM,CAAC;AACf,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
package/dist/index.cjs CHANGED
@@ -30,8 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- PriceOSError: () => PriceOSError,
34
- createHttpClient: () => createHttpClient
33
+ PriceOS: () => PriceOS,
34
+ PriceOSError: () => PriceOSError
35
35
  });
36
36
  module.exports = __toCommonJS(index_exports);
37
37
 
@@ -47,56 +47,63 @@ var PriceOSError = class extends Error {
47
47
  this.details = opts?.details;
48
48
  }
49
49
  };
50
- function createHttpClient(opts) {
51
- const baseUrl = opts.baseUrl ?? "https://api.priceos.com";
52
- const header = { "x-api-key": opts.apiKey };
53
- const client = (0, import_openapi_fetch.default)({
54
- baseUrl,
55
- fetch: opts.fetch,
56
- headers: {
57
- "x-api-key": opts.apiKey,
58
- ...opts.userAgent ? { "user-agent": opts.userAgent } : {}
59
- }
60
- });
61
- return {
62
- raw: client,
63
- async getCustomer(customerId) {
64
- const { data, error, response } = await client.GET("/v1/customer", {
65
- params: { query: { customerId }, header }
66
- });
67
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
68
- return data ?? null;
69
- },
70
- async identifyCustomer(input) {
71
- const { data, error, response } = await client.POST("/v1/customer/identify", {
72
- params: { header },
73
- body: input
74
- });
75
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
76
- return data ?? null;
77
- },
78
- async upsertCustomer(input) {
79
- const { data, error, response } = await client.PUT("/v1/customer", { params: { header }, body: input });
80
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
81
- return data;
82
- },
83
- async getFeatureAccess(customerId) {
84
- const { data, error, response } = await client.GET("/v1/feature-access", {
85
- params: { query: { customerId }, header }
86
- });
87
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
88
- return data;
89
- },
90
- async trackUsage(input) {
91
- const { data, error, response } = await client.POST("/v1/usage", { params: { header }, body: input });
92
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
93
- return data;
94
- }
95
- };
96
- }
50
+ var PriceOS = class {
51
+ client;
52
+ header;
53
+ constructor(apiKey, opts = {}) {
54
+ const baseUrl = opts.baseUrl ?? "https://api.priceos.com";
55
+ this.header = { "x-api-key": apiKey };
56
+ this.client = (0, import_openapi_fetch.default)({
57
+ baseUrl,
58
+ fetch: opts.fetch,
59
+ headers: {
60
+ "x-api-key": apiKey,
61
+ ...opts.userAgent ? { "user-agent": opts.userAgent } : {}
62
+ }
63
+ });
64
+ }
65
+ async getCustomer(customerId) {
66
+ const { data, error, response } = await this.client.GET("/v1/customer", {
67
+ params: { query: { customerId }, header: this.header }
68
+ });
69
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
70
+ return data ?? null;
71
+ }
72
+ async identifyCustomer(input) {
73
+ const { data, error, response } = await this.client.POST("/v1/customer/identify", {
74
+ params: { header: this.header },
75
+ body: input
76
+ });
77
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
78
+ return data ?? null;
79
+ }
80
+ async upsertCustomer(input) {
81
+ const { data, error, response } = await this.client.PUT("/v1/customer", {
82
+ params: { header: this.header },
83
+ body: input
84
+ });
85
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
86
+ return data;
87
+ }
88
+ async getFeatureAccess(customerId) {
89
+ const { data, error, response } = await this.client.GET("/v1/feature-access", {
90
+ params: { query: { customerId }, header: this.header }
91
+ });
92
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
93
+ return data;
94
+ }
95
+ async trackUsage(input) {
96
+ const { data, error, response } = await this.client.POST("/v1/usage", {
97
+ params: { header: this.header },
98
+ body: input
99
+ });
100
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
101
+ return data;
102
+ }
103
+ };
97
104
  // Annotate the CommonJS export names for ESM import in node:
98
105
  0 && (module.exports = {
99
- PriceOSError,
100
- createHttpClient
106
+ PriceOS,
107
+ PriceOSError
101
108
  });
102
109
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/client.ts"],"sourcesContent":["export { createHttpClient, PriceOSError } from \"./client\";\nexport type {\n PriceOSOptions,\n PriceOSHttpClient,\n} from \"./client\";\nexport type {\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n TrackUsageBody,\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 GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\n// --- Public options ---\nexport type PriceOSOptions = {\n baseUrl?: string;\n apiKey: string;\n fetch?: typeof fetch;\n userAgent?: string;\n};\n\n\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient = {\n raw: Client<paths>;\n getCustomer(customerId: string): Promise<GetCustomerResponse | null>;\n identifyCustomer(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse | null>;\n upsertCustomer(input: UpdateCustomerBody): Promise<UpdateCustomerResponse>;\n getFeatureAccess(customerId: string): Promise<GetFeatureAccessResponse>;\n trackUsage(input: TrackUsageBody): Promise<TrackUsageResponse>;\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 function createHttpClient(opts: PriceOSOptions): PriceOSHttpClient {\n const baseUrl = opts.baseUrl ?? \"https://api.priceos.com\";\n const header = { \"x-api-key\": opts.apiKey };\n\n const client = createClient<paths>({\n baseUrl,\n fetch: opts.fetch,\n headers: {\n \"x-api-key\": opts.apiKey,\n ...(opts.userAgent ? { \"user-agent\": opts.userAgent } : {}),\n },\n });\n\n return {\n raw: client,\n\n async getCustomer(customerId) {\n const { data, error, response } = await client.GET(\"/v1/customer\", {\n params: { query: { customerId }, header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n },\n\n async identifyCustomer(input) {\n const { data, error, response } = await client.POST(\"/v1/customer/identify\", {\n params: { header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n },\n\n async upsertCustomer(input) {\n const { data, error, response } = await client.PUT(\"/v1/customer\", { params: { header }, body: input });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n },\n\n async getFeatureAccess(customerId) {\n const { data, error, response } = await client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n },\n\n async trackUsage(input) {\n const { data, error, response } = await client.POST(\"/v1/usage\", { params: { header }, body: input });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAAyB;AAkClB,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC;AAAA,EACA;AAAA,EAEA,YAAY,SAAiB,MAA+C;AAC1E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS,MAAM;AACpB,SAAK,UAAU,MAAM;AAAA,EACvB;AACF;AAEO,SAAS,iBAAiB,MAAyC;AACxE,QAAM,UAAU,KAAK,WAAW;AAChC,QAAM,SAAS,EAAE,aAAa,KAAK,OAAO;AAE1C,QAAM,aAAS,qBAAAA,SAAoB;AAAA,IACjC;AAAA,IACA,OAAO,KAAK;AAAA,IACZ,SAAS;AAAA,MACP,aAAa,KAAK;AAAA,MAClB,GAAI,KAAK,YAAY,EAAE,cAAc,KAAK,UAAU,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/G,aAAO;AAAA,IACT;AAAA,IAEA,MAAM,WAAW,OAAO;AACtB,YAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,OAAO,KAAK,aAAa,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,MAAM,CAAC;AACpG,UAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,aAAO;AAAA,IACT;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 PriceOSHttpClient,\n} from \"./client\";\nexport type {\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n TrackUsageBody,\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 GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n baseUrl?: string;\n fetch?: typeof fetch;\n userAgent?: string;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n getCustomer(customerId: string): Promise<GetCustomerResponse | null>;\n identifyCustomer(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse | null>;\n upsertCustomer(input: UpdateCustomerBody): Promise<UpdateCustomerResponse>;\n getFeatureAccess(customerId: string): Promise<TFeatureAccessMap>;\n trackUsage(input: TrackUsageBody): Promise<TrackUsageResponse>;\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\n constructor(apiKey: string, opts: PriceOSClientOptions = {}) {\n const baseUrl = opts.baseUrl ?? \"https://api.priceos.com\";\n this.header = { \"x-api-key\": apiKey };\n this.client = createClient<paths>({\n baseUrl,\n fetch: opts.fetch,\n headers: {\n \"x-api-key\": apiKey,\n ...(opts.userAgent ? { \"user-agent\": opts.userAgent } : {}),\n },\n });\n }\n\n async getCustomer(customerId: string) {\n const { data, error, response } = await this.client.GET(\"/v1/customer\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n }\n\n async identifyCustomer(input: IdentifyCustomerBody) {\n const { data, error, response } = await this.client.POST(\"/v1/customer/identify\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n }\n\n async upsertCustomer(input: UpdateCustomerBody) {\n const { data, error, response } = await this.client.PUT(\"/v1/customer\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n }\n\n async getFeatureAccess(customerId: string) {\n const { data, error, response } = await this.client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as TFeatureAccessMap;\n }\n\n async trackUsage(input: TrackUsageBody) {\n const { data, error, response } = await this.client.POST(\"/v1/usage\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n }\n}\n"],"mappings":";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QAAQ,SAAS,MAAM,CAAC;AAC/G,WAAO,QAAQ;AAAA,EACjB;AAAA,EAEA,MAAM,eAAe,OAA2B;AAC9C,UAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,IAAI,gBAAgB;AAAA,MACtE,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,MAC9B,MAAM;AAAA,IACR,CAAC;AACD,QAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,iBAAiB,YAAoB;AACzC,UAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,IAAI,sBAAsB;AAAA,MAC5E,QAAQ,EAAE,OAAO,EAAE,WAAW,GAAG,QAAQ,KAAK,OAAO;AAAA,IACvD,CAAC;AACD,QAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,WAAW,OAAuB;AACtC,UAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,aAAa;AAAA,MACpE,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,MAC9B,MAAM;AAAA,IACR,CAAC;AACD,QAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,WAAO;AAAA,EACT;AACF;","names":["createClient"]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,3 @@
1
- import { Client } from 'openapi-fetch';
2
-
3
1
  /**
4
2
  * This file was auto-generated by openapi-typescript.
5
3
  * Do not make direct changes to the file.
@@ -1113,18 +1111,16 @@ type GetFeatureAccessResponse = paths["/v1/feature-access"]["get"]["responses"][
1113
1111
  type TrackUsageBody = paths["/v1/usage"]["post"]["requestBody"]["content"]["application/json"];
1114
1112
  type TrackUsageResponse = paths["/v1/usage"]["post"]["responses"][200]["content"]["application/json"];
1115
1113
 
1116
- type PriceOSOptions = {
1114
+ type PriceOSClientOptions = {
1117
1115
  baseUrl?: string;
1118
- apiKey: string;
1119
1116
  fetch?: typeof fetch;
1120
1117
  userAgent?: string;
1121
1118
  };
1122
- type PriceOSHttpClient = {
1123
- raw: Client<paths>;
1119
+ type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
1124
1120
  getCustomer(customerId: string): Promise<GetCustomerResponse | null>;
1125
1121
  identifyCustomer(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse | null>;
1126
1122
  upsertCustomer(input: UpdateCustomerBody): Promise<UpdateCustomerResponse>;
1127
- getFeatureAccess(customerId: string): Promise<GetFeatureAccessResponse>;
1123
+ getFeatureAccess(customerId: string): Promise<TFeatureAccessMap>;
1128
1124
  trackUsage(input: TrackUsageBody): Promise<TrackUsageResponse>;
1129
1125
  };
1130
1126
  declare class PriceOSError extends Error {
@@ -1135,6 +1131,133 @@ declare class PriceOSError extends Error {
1135
1131
  details?: unknown;
1136
1132
  });
1137
1133
  }
1138
- declare function createHttpClient(opts: PriceOSOptions): PriceOSHttpClient;
1134
+ declare class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse> implements PriceOSHttpClient<TFeatureAccessMap> {
1135
+ private client;
1136
+ private header;
1137
+ constructor(apiKey: string, opts?: PriceOSClientOptions);
1138
+ getCustomer(customerId: string): Promise<{
1139
+ customerId?: string;
1140
+ stripeCustomerId?: string;
1141
+ name?: string;
1142
+ email?: string;
1143
+ enviroment: "test" | "live";
1144
+ products: {
1145
+ id: string;
1146
+ name: string;
1147
+ version: number;
1148
+ status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
1149
+ canceledAt?: number | null;
1150
+ startedAt?: number;
1151
+ currentPeriodStart?: number;
1152
+ currentPeriodEnd?: number;
1153
+ prices?: {
1154
+ stripePriceId: string;
1155
+ quantity: number;
1156
+ currency: string;
1157
+ unitAmount: number;
1158
+ recurringInterval: string | null;
1159
+ isActive: boolean;
1160
+ isDefault: boolean;
1161
+ recurringIntervalCount: number;
1162
+ }[];
1163
+ }[];
1164
+ featureAccess: {
1165
+ [key: string]: {
1166
+ type: "boolean";
1167
+ hasAccess: boolean;
1168
+ } | {
1169
+ type: "limit";
1170
+ hasAccess: boolean;
1171
+ isUnlimited: boolean;
1172
+ limit: number | null;
1173
+ used: number;
1174
+ };
1175
+ };
1176
+ } | null>;
1177
+ identifyCustomer(input: IdentifyCustomerBody): Promise<{
1178
+ customerId?: string;
1179
+ stripeCustomerId?: string;
1180
+ name?: string;
1181
+ email?: string;
1182
+ enviroment: "test" | "live";
1183
+ products: {
1184
+ id: string;
1185
+ name: string;
1186
+ version: number;
1187
+ status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
1188
+ canceledAt?: number | null;
1189
+ startedAt?: number;
1190
+ currentPeriodStart?: number;
1191
+ currentPeriodEnd?: number;
1192
+ prices?: {
1193
+ stripePriceId: string;
1194
+ quantity: number;
1195
+ currency: string;
1196
+ unitAmount: number;
1197
+ recurringInterval: string | null;
1198
+ isActive: boolean;
1199
+ isDefault: boolean;
1200
+ recurringIntervalCount: number;
1201
+ }[];
1202
+ }[];
1203
+ featureAccess: {
1204
+ [key: string]: {
1205
+ type: "boolean";
1206
+ hasAccess: boolean;
1207
+ } | {
1208
+ type: "limit";
1209
+ hasAccess: boolean;
1210
+ isUnlimited: boolean;
1211
+ limit: number | null;
1212
+ used: number;
1213
+ };
1214
+ };
1215
+ }>;
1216
+ upsertCustomer(input: UpdateCustomerBody): Promise<{
1217
+ customerId?: string;
1218
+ stripeCustomerId?: string;
1219
+ name?: string;
1220
+ email?: string;
1221
+ enviroment: "test" | "live";
1222
+ products: {
1223
+ id: string;
1224
+ name: string;
1225
+ version: number;
1226
+ status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
1227
+ canceledAt?: number | null;
1228
+ startedAt?: number;
1229
+ currentPeriodStart?: number;
1230
+ currentPeriodEnd?: number;
1231
+ prices?: {
1232
+ stripePriceId: string;
1233
+ quantity: number;
1234
+ currency: string;
1235
+ unitAmount: number;
1236
+ recurringInterval: string | null;
1237
+ isActive: boolean;
1238
+ isDefault: boolean;
1239
+ recurringIntervalCount: number;
1240
+ }[];
1241
+ }[];
1242
+ featureAccess: {
1243
+ [key: string]: {
1244
+ type: "boolean";
1245
+ hasAccess: boolean;
1246
+ } | {
1247
+ type: "limit";
1248
+ hasAccess: boolean;
1249
+ isUnlimited: boolean;
1250
+ limit: number | null;
1251
+ used: number;
1252
+ };
1253
+ };
1254
+ }>;
1255
+ getFeatureAccess(customerId: string): Promise<TFeatureAccessMap>;
1256
+ trackUsage(input: TrackUsageBody): Promise<{
1257
+ applied: boolean;
1258
+ used: number | null;
1259
+ reason?: string | null;
1260
+ }>;
1261
+ }
1139
1262
 
1140
- export { type GetCustomerResponse, type GetFeatureAccessResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, PriceOSError, type PriceOSHttpClient, type PriceOSOptions, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse, createHttpClient };
1263
+ export { type GetCustomerResponse, type GetFeatureAccessResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, PriceOS, type PriceOSClientOptions, PriceOSError, type PriceOSHttpClient, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { Client } from 'openapi-fetch';
2
-
3
1
  /**
4
2
  * This file was auto-generated by openapi-typescript.
5
3
  * Do not make direct changes to the file.
@@ -1113,18 +1111,16 @@ type GetFeatureAccessResponse = paths["/v1/feature-access"]["get"]["responses"][
1113
1111
  type TrackUsageBody = paths["/v1/usage"]["post"]["requestBody"]["content"]["application/json"];
1114
1112
  type TrackUsageResponse = paths["/v1/usage"]["post"]["responses"][200]["content"]["application/json"];
1115
1113
 
1116
- type PriceOSOptions = {
1114
+ type PriceOSClientOptions = {
1117
1115
  baseUrl?: string;
1118
- apiKey: string;
1119
1116
  fetch?: typeof fetch;
1120
1117
  userAgent?: string;
1121
1118
  };
1122
- type PriceOSHttpClient = {
1123
- raw: Client<paths>;
1119
+ type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
1124
1120
  getCustomer(customerId: string): Promise<GetCustomerResponse | null>;
1125
1121
  identifyCustomer(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse | null>;
1126
1122
  upsertCustomer(input: UpdateCustomerBody): Promise<UpdateCustomerResponse>;
1127
- getFeatureAccess(customerId: string): Promise<GetFeatureAccessResponse>;
1123
+ getFeatureAccess(customerId: string): Promise<TFeatureAccessMap>;
1128
1124
  trackUsage(input: TrackUsageBody): Promise<TrackUsageResponse>;
1129
1125
  };
1130
1126
  declare class PriceOSError extends Error {
@@ -1135,6 +1131,133 @@ declare class PriceOSError extends Error {
1135
1131
  details?: unknown;
1136
1132
  });
1137
1133
  }
1138
- declare function createHttpClient(opts: PriceOSOptions): PriceOSHttpClient;
1134
+ declare class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse> implements PriceOSHttpClient<TFeatureAccessMap> {
1135
+ private client;
1136
+ private header;
1137
+ constructor(apiKey: string, opts?: PriceOSClientOptions);
1138
+ getCustomer(customerId: string): Promise<{
1139
+ customerId?: string;
1140
+ stripeCustomerId?: string;
1141
+ name?: string;
1142
+ email?: string;
1143
+ enviroment: "test" | "live";
1144
+ products: {
1145
+ id: string;
1146
+ name: string;
1147
+ version: number;
1148
+ status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
1149
+ canceledAt?: number | null;
1150
+ startedAt?: number;
1151
+ currentPeriodStart?: number;
1152
+ currentPeriodEnd?: number;
1153
+ prices?: {
1154
+ stripePriceId: string;
1155
+ quantity: number;
1156
+ currency: string;
1157
+ unitAmount: number;
1158
+ recurringInterval: string | null;
1159
+ isActive: boolean;
1160
+ isDefault: boolean;
1161
+ recurringIntervalCount: number;
1162
+ }[];
1163
+ }[];
1164
+ featureAccess: {
1165
+ [key: string]: {
1166
+ type: "boolean";
1167
+ hasAccess: boolean;
1168
+ } | {
1169
+ type: "limit";
1170
+ hasAccess: boolean;
1171
+ isUnlimited: boolean;
1172
+ limit: number | null;
1173
+ used: number;
1174
+ };
1175
+ };
1176
+ } | null>;
1177
+ identifyCustomer(input: IdentifyCustomerBody): Promise<{
1178
+ customerId?: string;
1179
+ stripeCustomerId?: string;
1180
+ name?: string;
1181
+ email?: string;
1182
+ enviroment: "test" | "live";
1183
+ products: {
1184
+ id: string;
1185
+ name: string;
1186
+ version: number;
1187
+ status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
1188
+ canceledAt?: number | null;
1189
+ startedAt?: number;
1190
+ currentPeriodStart?: number;
1191
+ currentPeriodEnd?: number;
1192
+ prices?: {
1193
+ stripePriceId: string;
1194
+ quantity: number;
1195
+ currency: string;
1196
+ unitAmount: number;
1197
+ recurringInterval: string | null;
1198
+ isActive: boolean;
1199
+ isDefault: boolean;
1200
+ recurringIntervalCount: number;
1201
+ }[];
1202
+ }[];
1203
+ featureAccess: {
1204
+ [key: string]: {
1205
+ type: "boolean";
1206
+ hasAccess: boolean;
1207
+ } | {
1208
+ type: "limit";
1209
+ hasAccess: boolean;
1210
+ isUnlimited: boolean;
1211
+ limit: number | null;
1212
+ used: number;
1213
+ };
1214
+ };
1215
+ }>;
1216
+ upsertCustomer(input: UpdateCustomerBody): Promise<{
1217
+ customerId?: string;
1218
+ stripeCustomerId?: string;
1219
+ name?: string;
1220
+ email?: string;
1221
+ enviroment: "test" | "live";
1222
+ products: {
1223
+ id: string;
1224
+ name: string;
1225
+ version: number;
1226
+ status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
1227
+ canceledAt?: number | null;
1228
+ startedAt?: number;
1229
+ currentPeriodStart?: number;
1230
+ currentPeriodEnd?: number;
1231
+ prices?: {
1232
+ stripePriceId: string;
1233
+ quantity: number;
1234
+ currency: string;
1235
+ unitAmount: number;
1236
+ recurringInterval: string | null;
1237
+ isActive: boolean;
1238
+ isDefault: boolean;
1239
+ recurringIntervalCount: number;
1240
+ }[];
1241
+ }[];
1242
+ featureAccess: {
1243
+ [key: string]: {
1244
+ type: "boolean";
1245
+ hasAccess: boolean;
1246
+ } | {
1247
+ type: "limit";
1248
+ hasAccess: boolean;
1249
+ isUnlimited: boolean;
1250
+ limit: number | null;
1251
+ used: number;
1252
+ };
1253
+ };
1254
+ }>;
1255
+ getFeatureAccess(customerId: string): Promise<TFeatureAccessMap>;
1256
+ trackUsage(input: TrackUsageBody): Promise<{
1257
+ applied: boolean;
1258
+ used: number | null;
1259
+ reason?: string | null;
1260
+ }>;
1261
+ }
1139
1262
 
1140
- export { type GetCustomerResponse, type GetFeatureAccessResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, PriceOSError, type PriceOSHttpClient, type PriceOSOptions, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse, createHttpClient };
1263
+ export { type GetCustomerResponse, type GetFeatureAccessResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, PriceOS, type PriceOSClientOptions, PriceOSError, type PriceOSHttpClient, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse };
package/dist/index.js CHANGED
@@ -10,55 +10,62 @@ var PriceOSError = class extends Error {
10
10
  this.details = opts?.details;
11
11
  }
12
12
  };
13
- function createHttpClient(opts) {
14
- const baseUrl = opts.baseUrl ?? "https://api.priceos.com";
15
- const header = { "x-api-key": opts.apiKey };
16
- const client = createClient({
17
- baseUrl,
18
- fetch: opts.fetch,
19
- headers: {
20
- "x-api-key": opts.apiKey,
21
- ...opts.userAgent ? { "user-agent": opts.userAgent } : {}
22
- }
23
- });
24
- return {
25
- raw: client,
26
- async getCustomer(customerId) {
27
- const { data, error, response } = await client.GET("/v1/customer", {
28
- params: { query: { customerId }, header }
29
- });
30
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
31
- return data ?? null;
32
- },
33
- async identifyCustomer(input) {
34
- const { data, error, response } = await client.POST("/v1/customer/identify", {
35
- params: { header },
36
- body: input
37
- });
38
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
39
- return data ?? null;
40
- },
41
- async upsertCustomer(input) {
42
- const { data, error, response } = await client.PUT("/v1/customer", { params: { header }, body: input });
43
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
44
- return data;
45
- },
46
- async getFeatureAccess(customerId) {
47
- const { data, error, response } = await client.GET("/v1/feature-access", {
48
- params: { query: { customerId }, header }
49
- });
50
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
51
- return data;
52
- },
53
- async trackUsage(input) {
54
- const { data, error, response } = await client.POST("/v1/usage", { params: { header }, body: input });
55
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
56
- return data;
57
- }
58
- };
59
- }
13
+ var PriceOS = class {
14
+ client;
15
+ header;
16
+ constructor(apiKey, opts = {}) {
17
+ const baseUrl = opts.baseUrl ?? "https://api.priceos.com";
18
+ this.header = { "x-api-key": apiKey };
19
+ this.client = createClient({
20
+ baseUrl,
21
+ fetch: opts.fetch,
22
+ headers: {
23
+ "x-api-key": apiKey,
24
+ ...opts.userAgent ? { "user-agent": opts.userAgent } : {}
25
+ }
26
+ });
27
+ }
28
+ async getCustomer(customerId) {
29
+ const { data, error, response } = await this.client.GET("/v1/customer", {
30
+ params: { query: { customerId }, header: this.header }
31
+ });
32
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
33
+ return data ?? null;
34
+ }
35
+ async identifyCustomer(input) {
36
+ const { data, error, response } = await this.client.POST("/v1/customer/identify", {
37
+ params: { header: this.header },
38
+ body: input
39
+ });
40
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
41
+ return data ?? null;
42
+ }
43
+ async upsertCustomer(input) {
44
+ const { data, error, response } = await this.client.PUT("/v1/customer", {
45
+ params: { header: this.header },
46
+ body: input
47
+ });
48
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
49
+ return data;
50
+ }
51
+ async getFeatureAccess(customerId) {
52
+ const { data, error, response } = await this.client.GET("/v1/feature-access", {
53
+ params: { query: { customerId }, header: this.header }
54
+ });
55
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
56
+ return data;
57
+ }
58
+ async trackUsage(input) {
59
+ const { data, error, response } = await this.client.POST("/v1/usage", {
60
+ params: { header: this.header },
61
+ body: input
62
+ });
63
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
64
+ return data;
65
+ }
66
+ };
60
67
  export {
61
- PriceOSError,
62
- createHttpClient
68
+ PriceOS,
69
+ PriceOSError
63
70
  };
64
71
  //# sourceMappingURL=index.js.map
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 GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\n// --- Public options ---\nexport type PriceOSOptions = {\n baseUrl?: string;\n apiKey: string;\n fetch?: typeof fetch;\n userAgent?: string;\n};\n\n\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient = {\n raw: Client<paths>;\n getCustomer(customerId: string): Promise<GetCustomerResponse | null>;\n identifyCustomer(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse | null>;\n upsertCustomer(input: UpdateCustomerBody): Promise<UpdateCustomerResponse>;\n getFeatureAccess(customerId: string): Promise<GetFeatureAccessResponse>;\n trackUsage(input: TrackUsageBody): Promise<TrackUsageResponse>;\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 function createHttpClient(opts: PriceOSOptions): PriceOSHttpClient {\n const baseUrl = opts.baseUrl ?? \"https://api.priceos.com\";\n const header = { \"x-api-key\": opts.apiKey };\n\n const client = createClient<paths>({\n baseUrl,\n fetch: opts.fetch,\n headers: {\n \"x-api-key\": opts.apiKey,\n ...(opts.userAgent ? { \"user-agent\": opts.userAgent } : {}),\n },\n });\n\n return {\n raw: client,\n\n async getCustomer(customerId) {\n const { data, error, response } = await client.GET(\"/v1/customer\", {\n params: { query: { customerId }, header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n },\n\n async identifyCustomer(input) {\n const { data, error, response } = await client.POST(\"/v1/customer/identify\", {\n params: { header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n },\n\n async upsertCustomer(input) {\n const { data, error, response } = await client.PUT(\"/v1/customer\", { params: { header }, body: input });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n },\n\n async getFeatureAccess(customerId) {\n const { data, error, response } = await client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n },\n\n async trackUsage(input) {\n const { data, error, response } = await client.POST(\"/v1/usage\", { params: { header }, body: input });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\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,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,OAAO,IAAI,gBAAgB,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,MAAM,CAAC;AACtG,UAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,aAAO;AAAA,IACT;AAAA,IAEA,MAAM,iBAAiB,YAAY;AACjC,YAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,OAAO,IAAI,sBAAsB;AAAA,QACvE,QAAQ,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO;AAAA,MAC1C,CAAC;AACD,UAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,aAAO;AAAA,IACT;AAAA,IAEA,MAAM,WAAW,OAAO;AACtB,YAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,OAAO,KAAK,aAAa,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,MAAM,CAAC;AACpG,UAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,aAAO;AAAA,IACT;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 GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n baseUrl?: string;\n fetch?: typeof fetch;\n userAgent?: string;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n getCustomer(customerId: string): Promise<GetCustomerResponse | null>;\n identifyCustomer(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse | null>;\n upsertCustomer(input: UpdateCustomerBody): Promise<UpdateCustomerResponse>;\n getFeatureAccess(customerId: string): Promise<TFeatureAccessMap>;\n trackUsage(input: TrackUsageBody): Promise<TrackUsageResponse>;\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\n constructor(apiKey: string, opts: PriceOSClientOptions = {}) {\n const baseUrl = opts.baseUrl ?? \"https://api.priceos.com\";\n this.header = { \"x-api-key\": apiKey };\n this.client = createClient<paths>({\n baseUrl,\n fetch: opts.fetch,\n headers: {\n \"x-api-key\": apiKey,\n ...(opts.userAgent ? { \"user-agent\": opts.userAgent } : {}),\n },\n });\n }\n\n async getCustomer(customerId: string) {\n const { data, error, response } = await this.client.GET(\"/v1/customer\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n }\n\n async identifyCustomer(input: IdentifyCustomerBody) {\n const { data, error, response } = await this.client.POST(\"/v1/customer/identify\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n }\n\n async upsertCustomer(input: UpdateCustomerBody) {\n const { data, error, response } = await this.client.PUT(\"/v1/customer\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n }\n\n async getFeatureAccess(customerId: string) {\n const { data, error, response } = await this.client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as TFeatureAccessMap;\n }\n\n async trackUsage(input: TrackUsageBody) {\n const { data, error, response } = await this.client.POST(\"/v1/usage\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n }\n}\n"],"mappings":";AAAA,OAAO,kBAAkB;AA8BlB,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC;AAAA,EACA;AAAA,EAEA,YAAY,SAAiB,MAA+C;AAC1E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS,MAAM;AACpB,SAAK,UAAU,MAAM;AAAA,EACvB;AACF;AAEO,IAAM,UAAN,MAEP;AAAA,EACU;AAAA,EACA;AAAA,EAER,YAAY,QAAgB,OAA6B,CAAC,GAAG;AAC3D,UAAM,UAAU,KAAK,WAAW;AAChC,SAAK,SAAS,EAAE,aAAa,OAAO;AACpC,SAAK,SAAS,aAAoB;AAAA,MAChC;AAAA,MACA,OAAO,KAAK;AAAA,MACZ,SAAS;AAAA,QACP,aAAa;AAAA,QACb,GAAI,KAAK,YAAY,EAAE,cAAc,KAAK,UAAU,IAAI,CAAC;AAAA,MAC3D;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,YAAY,YAAoB;AACpC,UAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,IAAI,gBAAgB;AAAA,MACtE,QAAQ,EAAE,OAAO,EAAE,WAAW,GAAG,QAAQ,KAAK,OAAO;AAAA,IACvD,CAAC;AACD,QAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,WAAO,QAAQ;AAAA,EACjB;AAAA,EAEA,MAAM,iBAAiB,OAA6B;AAClD,UAAM,EAAE,MAAM,OAAO,SAAS,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 @@
1
1
  {
2
2
  "name": "priceos",
3
- "version": "0.0.1",
3
+ "version": "0.0.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -36,5 +36,9 @@
36
36
  "tsup": "^8.0.0",
37
37
  "tsx": "^4.21.0",
38
38
  "typescript": "^5.0.0"
39
+ },
40
+ "optionalDependencies": {
41
+ "@rollup/rollup-darwin-x64": "4.56.0",
42
+ "@rollup/rollup-linux-x64-gnu": "4.56.0"
39
43
  }
40
44
  }