priceos 0.0.17 → 0.0.20
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 +5 -5
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +5 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +69 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -35
- package/dist/index.d.ts +53 -35
- package/dist/index.js +69 -39
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -60,7 +60,7 @@ async function readEnvFile(filePath) {
|
|
|
60
60
|
}
|
|
61
61
|
function printHelp() {
|
|
62
62
|
console.log(`
|
|
63
|
-
priceos
|
|
63
|
+
priceos generate-types
|
|
64
64
|
|
|
65
65
|
Generates TypeScript feature access types for your PriceOS workspace.
|
|
66
66
|
|
|
@@ -71,8 +71,8 @@ Options:
|
|
|
71
71
|
-h, --help Show help
|
|
72
72
|
|
|
73
73
|
Examples:
|
|
74
|
-
priceos
|
|
75
|
-
priceos
|
|
74
|
+
priceos generate-types --api-key sk_test_... --out ./priceos.d.ts
|
|
75
|
+
priceos generate-types --api-key sk_test_... --out-dir ./src
|
|
76
76
|
`.trim());
|
|
77
77
|
}
|
|
78
78
|
async function main() {
|
|
@@ -82,7 +82,7 @@ async function main() {
|
|
|
82
82
|
process.exit(args.length === 0 ? 1 : 0);
|
|
83
83
|
}
|
|
84
84
|
const cmd = args[0];
|
|
85
|
-
if (cmd !== "
|
|
85
|
+
if (cmd !== "generate-types") {
|
|
86
86
|
console.error(`Unknown command: ${cmd}`);
|
|
87
87
|
printHelp();
|
|
88
88
|
process.exit(1);
|
|
@@ -131,7 +131,7 @@ ${text}`);
|
|
|
131
131
|
const accessType = featureType === "boolean" ? "BooleanFeatureAccess" : featureType === "limit" ? "LimitFeatureAccess" : "FeatureAccessEntry";
|
|
132
132
|
return ` ${JSON.stringify(key)}: ${accessType};`;
|
|
133
133
|
});
|
|
134
|
-
const content = `// Auto-generated by PriceOS (priceos
|
|
134
|
+
const content = `// Auto-generated by PriceOS (priceos generate-types). Do not edit.
|
|
135
135
|
export type FeatureKey = ${union};
|
|
136
136
|
export type BooleanFeatureAccess = {
|
|
137
137
|
type: "boolean";
|
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\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
|
|
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\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\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 generate-types). 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 ${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;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,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;AAC1C,UACG,MAAM,WAAW,GAAI,KAAK,MAAM,SAAS,GAAI,KAC7C,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG,GAC5C;AACA,gBAAQ,MAAM,MAAM,GAAG,EAAE;AAAA,MAC3B;AACA,UAAI,KAAK;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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc9B,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
|
@@ -37,7 +37,7 @@ async function readEnvFile(filePath) {
|
|
|
37
37
|
}
|
|
38
38
|
function printHelp() {
|
|
39
39
|
console.log(`
|
|
40
|
-
priceos
|
|
40
|
+
priceos generate-types
|
|
41
41
|
|
|
42
42
|
Generates TypeScript feature access types for your PriceOS workspace.
|
|
43
43
|
|
|
@@ -48,8 +48,8 @@ Options:
|
|
|
48
48
|
-h, --help Show help
|
|
49
49
|
|
|
50
50
|
Examples:
|
|
51
|
-
priceos
|
|
52
|
-
priceos
|
|
51
|
+
priceos generate-types --api-key sk_test_... --out ./priceos.d.ts
|
|
52
|
+
priceos generate-types --api-key sk_test_... --out-dir ./src
|
|
53
53
|
`.trim());
|
|
54
54
|
}
|
|
55
55
|
async function main() {
|
|
@@ -59,7 +59,7 @@ async function main() {
|
|
|
59
59
|
process.exit(args.length === 0 ? 1 : 0);
|
|
60
60
|
}
|
|
61
61
|
const cmd = args[0];
|
|
62
|
-
if (cmd !== "
|
|
62
|
+
if (cmd !== "generate-types") {
|
|
63
63
|
console.error(`Unknown command: ${cmd}`);
|
|
64
64
|
printHelp();
|
|
65
65
|
process.exit(1);
|
|
@@ -108,7 +108,7 @@ ${text}`);
|
|
|
108
108
|
const accessType = featureType === "boolean" ? "BooleanFeatureAccess" : featureType === "limit" ? "LimitFeatureAccess" : "FeatureAccessEntry";
|
|
109
109
|
return ` ${JSON.stringify(key)}: ${accessType};`;
|
|
110
110
|
});
|
|
111
|
-
const content = `// Auto-generated by PriceOS (priceos
|
|
111
|
+
const content = `// Auto-generated by PriceOS (priceos generate-types). Do not edit.
|
|
112
112
|
export type FeatureKey = ${union};
|
|
113
113
|
export type BooleanFeatureAccess = {
|
|
114
114
|
type: "boolean";
|
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\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
|
|
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\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\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 generate-types). 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 ${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;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,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,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;AAC1C,UACG,MAAM,WAAW,GAAI,KAAK,MAAM,SAAS,GAAI,KAC7C,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG,GAC5C;AACA,gBAAQ,MAAM,MA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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,UAAU,KAAK,KAAK,MAAM,gBAAgB;AACrE;AAEA,KAAK,EAAE,MAAM,CAAC,MAAM;AAClB,UAAQ,MAAM,CAAC;AACf,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -50,6 +50,9 @@ var PriceOSError = class extends Error {
|
|
|
50
50
|
var PriceOS = class {
|
|
51
51
|
client;
|
|
52
52
|
header;
|
|
53
|
+
customers;
|
|
54
|
+
features;
|
|
55
|
+
usage;
|
|
53
56
|
constructor(apiKey, opts = {}) {
|
|
54
57
|
const baseUrl = opts.baseUrl ?? "https://api.priceos.com";
|
|
55
58
|
this.header = { "x-api-key": apiKey };
|
|
@@ -61,45 +64,72 @@ var PriceOS = class {
|
|
|
61
64
|
...opts.userAgent ? { "user-agent": opts.userAgent } : {}
|
|
62
65
|
}
|
|
63
66
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
67
|
+
this.customers = {
|
|
68
|
+
get: async (customerId) => {
|
|
69
|
+
const { data, error, response } = await this.client.GET("/v1/customer", {
|
|
70
|
+
params: { query: { customerId }, header: this.header }
|
|
71
|
+
});
|
|
72
|
+
if (error)
|
|
73
|
+
throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
|
|
74
|
+
return data ?? null;
|
|
75
|
+
},
|
|
76
|
+
identify: async (input) => {
|
|
77
|
+
const { data, error, response } = await this.client.POST("/v1/customer/identify", {
|
|
78
|
+
params: { header: this.header },
|
|
79
|
+
body: input
|
|
80
|
+
});
|
|
81
|
+
if (error)
|
|
82
|
+
throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
|
|
83
|
+
return data ?? null;
|
|
84
|
+
},
|
|
85
|
+
create: async (input) => {
|
|
86
|
+
const { data, error, response } = await this.client.POST("/v1/customer", {
|
|
87
|
+
params: { header: this.header },
|
|
88
|
+
body: input
|
|
89
|
+
});
|
|
90
|
+
if (error)
|
|
91
|
+
throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
|
|
92
|
+
return data;
|
|
93
|
+
},
|
|
94
|
+
update: async (input) => {
|
|
95
|
+
const { data, error, response } = await this.client.PUT("/v1/customer", {
|
|
96
|
+
params: { header: this.header },
|
|
97
|
+
body: input
|
|
98
|
+
});
|
|
99
|
+
if (error)
|
|
100
|
+
throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
|
|
101
|
+
return data;
|
|
102
|
+
},
|
|
103
|
+
delete: async (customerId) => {
|
|
104
|
+
const { data, error, response } = await this.client.DELETE("/v1/customer", {
|
|
105
|
+
params: { query: { customerId }, header: this.header }
|
|
106
|
+
});
|
|
107
|
+
if (error)
|
|
108
|
+
throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
|
|
109
|
+
return data;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
this.features = {
|
|
113
|
+
getAccess: async (customerId) => {
|
|
114
|
+
const { data, error, response } = await this.client.GET("/v1/feature-access", {
|
|
115
|
+
params: { query: { customerId }, header: this.header }
|
|
116
|
+
});
|
|
117
|
+
if (error)
|
|
118
|
+
throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
|
|
119
|
+
return data;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
this.usage = {
|
|
123
|
+
track: async (input) => {
|
|
124
|
+
const { data, error, response } = await this.client.POST("/v1/usage", {
|
|
125
|
+
params: { header: this.header },
|
|
126
|
+
body: input
|
|
127
|
+
});
|
|
128
|
+
if (error)
|
|
129
|
+
throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
|
|
130
|
+
return data;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
103
133
|
}
|
|
104
134
|
};
|
|
105
135
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts"],"sourcesContent":["export { PriceOS, PriceOSError } from \"./client\";\nexport type {\n PriceOSClientOptions,\n PriceOSCustomersClient,\n PriceOSFeaturesClient,\n PriceOSHttpClient,\n PriceOSUsageClient,\n} from \"./client\";\nexport type {\n CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteCustomerRequest,\n DeleteCustomerResponse,\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 CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteCustomerResponse,\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\nexport type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;\n identify(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse<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 PriceOSUsageClient = {\n track(input: TrackUsageBody): Promise<TrackUsageResponse>;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient;\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 customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient;\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 this.customers = {\n get: async (customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.GET(\"/v1/customer\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return (data ?? null) as GetCustomerResponse<TFeatureAccessMap> | null;\n },\n identify: async (\n input: IdentifyCustomerBody\n ): Promise<IdentifyCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.POST(\"/v1/customer/identify\", {\n params: { header: this.header },\n body: input,\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return (data ?? null) as IdentifyCustomerResponse<TFeatureAccessMap> | null;\n },\n create: async (input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>> => {\n const { data, error, response } = await this.client.POST(\"/v1/customer\", {\n params: { header: this.header },\n body: input,\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as CreateCustomerResponse<TFeatureAccessMap>;\n },\n update: async (input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>> => {\n const { data, error, response } = await this.client.PUT(\"/v1/customer\", {\n params: { header: this.header },\n body: input,\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as UpdateCustomerResponse<TFeatureAccessMap>;\n },\n delete: async (customerId: string): Promise<DeleteCustomerResponse> => {\n const { data, error, response } = await this.client.DELETE(\"/v1/customer\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\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)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as TFeatureAccessMap;\n },\n };\n\n this.usage = {\n track: async (input: TrackUsageBody): 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)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n },\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAAyB;AA+ClB,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,EACR;AAAA,EACA;AAAA,EACA;AAAA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AACF,gBAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AACtG,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":["createClient"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -45,6 +45,8 @@ interface paths {
|
|
|
45
45
|
name?: string;
|
|
46
46
|
/** @description Customer email address. */
|
|
47
47
|
email?: string;
|
|
48
|
+
/** @description Unix timestamp (ms) when usage tracking started. */
|
|
49
|
+
usageStartedAt?: number;
|
|
48
50
|
/**
|
|
49
51
|
* @description Customer environment.
|
|
50
52
|
* @enum {string}
|
|
@@ -56,17 +58,17 @@ interface paths {
|
|
|
56
58
|
id: string;
|
|
57
59
|
/** @description Product name. */
|
|
58
60
|
name: string;
|
|
61
|
+
/**
|
|
62
|
+
* @description Stripe subscription status (Stripe customers only).
|
|
63
|
+
* @enum {string}
|
|
64
|
+
*/
|
|
65
|
+
status: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
59
66
|
/** @description Product version number. */
|
|
60
67
|
version: number;
|
|
61
68
|
/** @description Custom product metadata (custom products only). */
|
|
62
69
|
metadata?: {
|
|
63
70
|
[key: string]: string;
|
|
64
71
|
};
|
|
65
|
-
/**
|
|
66
|
-
* @description Stripe subscription status (Stripe customers only).
|
|
67
|
-
* @enum {string}
|
|
68
|
-
*/
|
|
69
|
-
status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
70
72
|
/** @description Unix timestamp (ms) when the subscription was canceled (Stripe customers only). */
|
|
71
73
|
canceledAt?: number | null;
|
|
72
74
|
/** @description Unix timestamp (ms) when the subscription started (Stripe customers only). */
|
|
@@ -206,6 +208,8 @@ interface paths {
|
|
|
206
208
|
name?: string;
|
|
207
209
|
/** @description Customer email address. */
|
|
208
210
|
email?: string;
|
|
211
|
+
/** @description Unix timestamp (ms) when usage tracking started. */
|
|
212
|
+
usageStartedAt?: number;
|
|
209
213
|
/**
|
|
210
214
|
* @description Customer environment.
|
|
211
215
|
* @enum {string}
|
|
@@ -217,17 +221,17 @@ interface paths {
|
|
|
217
221
|
id: string;
|
|
218
222
|
/** @description Product name. */
|
|
219
223
|
name: string;
|
|
224
|
+
/**
|
|
225
|
+
* @description Stripe subscription status (Stripe customers only).
|
|
226
|
+
* @enum {string}
|
|
227
|
+
*/
|
|
228
|
+
status: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
220
229
|
/** @description Product version number. */
|
|
221
230
|
version: number;
|
|
222
231
|
/** @description Custom product metadata (custom products only). */
|
|
223
232
|
metadata?: {
|
|
224
233
|
[key: string]: string;
|
|
225
234
|
};
|
|
226
|
-
/**
|
|
227
|
-
* @description Stripe subscription status (Stripe customers only).
|
|
228
|
-
* @enum {string}
|
|
229
|
-
*/
|
|
230
|
-
status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
231
235
|
/** @description Unix timestamp (ms) when the subscription was canceled (Stripe customers only). */
|
|
232
236
|
canceledAt?: number | null;
|
|
233
237
|
/** @description Unix timestamp (ms) when the subscription started (Stripe customers only). */
|
|
@@ -379,6 +383,8 @@ interface paths {
|
|
|
379
383
|
name?: string;
|
|
380
384
|
/** @description Customer email address. */
|
|
381
385
|
email?: string;
|
|
386
|
+
/** @description Unix timestamp (ms) when usage tracking started. */
|
|
387
|
+
usageStartedAt?: number;
|
|
382
388
|
/**
|
|
383
389
|
* @description Customer environment.
|
|
384
390
|
* @enum {string}
|
|
@@ -390,17 +396,17 @@ interface paths {
|
|
|
390
396
|
id: string;
|
|
391
397
|
/** @description Product name. */
|
|
392
398
|
name: string;
|
|
399
|
+
/**
|
|
400
|
+
* @description Stripe subscription status (Stripe customers only).
|
|
401
|
+
* @enum {string}
|
|
402
|
+
*/
|
|
403
|
+
status: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
393
404
|
/** @description Product version number. */
|
|
394
405
|
version: number;
|
|
395
406
|
/** @description Custom product metadata (custom products only). */
|
|
396
407
|
metadata?: {
|
|
397
408
|
[key: string]: string;
|
|
398
409
|
};
|
|
399
|
-
/**
|
|
400
|
-
* @description Stripe subscription status (Stripe customers only).
|
|
401
|
-
* @enum {string}
|
|
402
|
-
*/
|
|
403
|
-
status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
404
410
|
/** @description Unix timestamp (ms) when the subscription was canceled (Stripe customers only). */
|
|
405
411
|
canceledAt?: number | null;
|
|
406
412
|
/** @description Unix timestamp (ms) when the subscription started (Stripe customers only). */
|
|
@@ -643,6 +649,8 @@ interface paths {
|
|
|
643
649
|
name?: string;
|
|
644
650
|
/** @description Customer email address. */
|
|
645
651
|
email?: string;
|
|
652
|
+
/** @description Unix timestamp (ms) when usage tracking started. */
|
|
653
|
+
usageStartedAt?: number;
|
|
646
654
|
/**
|
|
647
655
|
* @description Customer environment.
|
|
648
656
|
* @enum {string}
|
|
@@ -654,17 +662,17 @@ interface paths {
|
|
|
654
662
|
id: string;
|
|
655
663
|
/** @description Product name. */
|
|
656
664
|
name: string;
|
|
665
|
+
/**
|
|
666
|
+
* @description Stripe subscription status (Stripe customers only).
|
|
667
|
+
* @enum {string}
|
|
668
|
+
*/
|
|
669
|
+
status: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
657
670
|
/** @description Product version number. */
|
|
658
671
|
version: number;
|
|
659
672
|
/** @description Custom product metadata (custom products only). */
|
|
660
673
|
metadata?: {
|
|
661
674
|
[key: string]: string;
|
|
662
675
|
};
|
|
663
|
-
/**
|
|
664
|
-
* @description Stripe subscription status (Stripe customers only).
|
|
665
|
-
* @enum {string}
|
|
666
|
-
*/
|
|
667
|
-
status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
668
676
|
/** @description Unix timestamp (ms) when the subscription was canceled (Stripe customers only). */
|
|
669
677
|
canceledAt?: number | null;
|
|
670
678
|
/** @description Unix timestamp (ms) when the subscription started (Stripe customers only). */
|
|
@@ -1125,9 +1133,14 @@ type WithFeatureAccess<T, TFeatureAccessMap> = T extends {
|
|
|
1125
1133
|
} : T;
|
|
1126
1134
|
type GetCustomerResponseBase = paths["/v1/customer"]["get"]["responses"][200]["content"]["application/json"];
|
|
1127
1135
|
type GetCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<GetCustomerResponseBase, TFeatureAccessMap>;
|
|
1136
|
+
type CreateCustomerRequest = paths["/v1/customer"]["post"]["requestBody"]["content"]["application/json"];
|
|
1137
|
+
type CreateCustomerResponseBase = paths["/v1/customer"]["post"]["responses"][201]["content"]["application/json"];
|
|
1138
|
+
type CreateCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<CreateCustomerResponseBase, TFeatureAccessMap>;
|
|
1128
1139
|
type UpdateCustomerBody = paths["/v1/customer"]["put"]["requestBody"]["content"]["application/json"];
|
|
1129
1140
|
type UpdateCustomerResponseBase = paths["/v1/customer"]["put"]["responses"][200]["content"]["application/json"];
|
|
1130
1141
|
type UpdateCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<UpdateCustomerResponseBase, TFeatureAccessMap>;
|
|
1142
|
+
type DeleteCustomerRequest = paths["/v1/customer"]["delete"]["parameters"]["query"];
|
|
1143
|
+
type DeleteCustomerResponse = paths["/v1/customer"]["delete"]["responses"][200]["content"]["application/json"];
|
|
1131
1144
|
type IdentifyCustomerBody = paths["/v1/customer/identify"]["post"]["requestBody"]["content"]["application/json"];
|
|
1132
1145
|
type IdentifyCustomerResponseBase = paths["/v1/customer/identify"]["post"]["responses"][200]["content"]["application/json"];
|
|
1133
1146
|
type IdentifyCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<IdentifyCustomerResponseBase, TFeatureAccessMap>;
|
|
@@ -1140,12 +1153,23 @@ type PriceOSClientOptions = {
|
|
|
1140
1153
|
fetch?: typeof fetch;
|
|
1141
1154
|
userAgent?: string;
|
|
1142
1155
|
};
|
|
1156
|
+
type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1157
|
+
get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;
|
|
1158
|
+
identify(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse<TFeatureAccessMap> | null>;
|
|
1159
|
+
create(input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>>;
|
|
1160
|
+
update(input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>>;
|
|
1161
|
+
delete(customerId: string): Promise<DeleteCustomerResponse>;
|
|
1162
|
+
};
|
|
1163
|
+
type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1164
|
+
getAccess(customerId: string): Promise<TFeatureAccessMap>;
|
|
1165
|
+
};
|
|
1166
|
+
type PriceOSUsageClient = {
|
|
1167
|
+
track(input: TrackUsageBody): Promise<TrackUsageResponse>;
|
|
1168
|
+
};
|
|
1143
1169
|
type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
getFeatureAccess(customerId: string): Promise<TFeatureAccessMap>;
|
|
1148
|
-
trackUsage(input: TrackUsageBody): Promise<TrackUsageResponse>;
|
|
1170
|
+
customers: PriceOSCustomersClient<TFeatureAccessMap>;
|
|
1171
|
+
features: PriceOSFeaturesClient<TFeatureAccessMap>;
|
|
1172
|
+
usage: PriceOSUsageClient;
|
|
1149
1173
|
};
|
|
1150
1174
|
declare class PriceOSError extends Error {
|
|
1151
1175
|
status?: number;
|
|
@@ -1158,16 +1182,10 @@ declare class PriceOSError extends Error {
|
|
|
1158
1182
|
declare class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse> implements PriceOSHttpClient<TFeatureAccessMap> {
|
|
1159
1183
|
private client;
|
|
1160
1184
|
private header;
|
|
1185
|
+
customers: PriceOSCustomersClient<TFeatureAccessMap>;
|
|
1186
|
+
features: PriceOSFeaturesClient<TFeatureAccessMap>;
|
|
1187
|
+
usage: PriceOSUsageClient;
|
|
1161
1188
|
constructor(apiKey: string, opts?: PriceOSClientOptions);
|
|
1162
|
-
getCustomer(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;
|
|
1163
|
-
identifyCustomer(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse<TFeatureAccessMap> | null>;
|
|
1164
|
-
upsertCustomer(input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>>;
|
|
1165
|
-
getFeatureAccess(customerId: string): Promise<TFeatureAccessMap>;
|
|
1166
|
-
trackUsage(input: TrackUsageBody): Promise<{
|
|
1167
|
-
applied: boolean;
|
|
1168
|
-
used: number | null;
|
|
1169
|
-
reason?: string | null;
|
|
1170
|
-
}>;
|
|
1171
1189
|
}
|
|
1172
1190
|
|
|
1173
|
-
export { type GetCustomerResponse, type GetFeatureAccessResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, PriceOS, type PriceOSClientOptions, PriceOSError, type PriceOSHttpClient, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse };
|
|
1191
|
+
export { type CreateCustomerRequest, type CreateCustomerResponse, type DeleteCustomerRequest, type DeleteCustomerResponse, type GetCustomerResponse, type GetFeatureAccessResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, PriceOS, type PriceOSClientOptions, type PriceOSCustomersClient, PriceOSError, type PriceOSFeaturesClient, type PriceOSHttpClient, type PriceOSUsageClient, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,8 @@ interface paths {
|
|
|
45
45
|
name?: string;
|
|
46
46
|
/** @description Customer email address. */
|
|
47
47
|
email?: string;
|
|
48
|
+
/** @description Unix timestamp (ms) when usage tracking started. */
|
|
49
|
+
usageStartedAt?: number;
|
|
48
50
|
/**
|
|
49
51
|
* @description Customer environment.
|
|
50
52
|
* @enum {string}
|
|
@@ -56,17 +58,17 @@ interface paths {
|
|
|
56
58
|
id: string;
|
|
57
59
|
/** @description Product name. */
|
|
58
60
|
name: string;
|
|
61
|
+
/**
|
|
62
|
+
* @description Stripe subscription status (Stripe customers only).
|
|
63
|
+
* @enum {string}
|
|
64
|
+
*/
|
|
65
|
+
status: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
59
66
|
/** @description Product version number. */
|
|
60
67
|
version: number;
|
|
61
68
|
/** @description Custom product metadata (custom products only). */
|
|
62
69
|
metadata?: {
|
|
63
70
|
[key: string]: string;
|
|
64
71
|
};
|
|
65
|
-
/**
|
|
66
|
-
* @description Stripe subscription status (Stripe customers only).
|
|
67
|
-
* @enum {string}
|
|
68
|
-
*/
|
|
69
|
-
status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
70
72
|
/** @description Unix timestamp (ms) when the subscription was canceled (Stripe customers only). */
|
|
71
73
|
canceledAt?: number | null;
|
|
72
74
|
/** @description Unix timestamp (ms) when the subscription started (Stripe customers only). */
|
|
@@ -206,6 +208,8 @@ interface paths {
|
|
|
206
208
|
name?: string;
|
|
207
209
|
/** @description Customer email address. */
|
|
208
210
|
email?: string;
|
|
211
|
+
/** @description Unix timestamp (ms) when usage tracking started. */
|
|
212
|
+
usageStartedAt?: number;
|
|
209
213
|
/**
|
|
210
214
|
* @description Customer environment.
|
|
211
215
|
* @enum {string}
|
|
@@ -217,17 +221,17 @@ interface paths {
|
|
|
217
221
|
id: string;
|
|
218
222
|
/** @description Product name. */
|
|
219
223
|
name: string;
|
|
224
|
+
/**
|
|
225
|
+
* @description Stripe subscription status (Stripe customers only).
|
|
226
|
+
* @enum {string}
|
|
227
|
+
*/
|
|
228
|
+
status: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
220
229
|
/** @description Product version number. */
|
|
221
230
|
version: number;
|
|
222
231
|
/** @description Custom product metadata (custom products only). */
|
|
223
232
|
metadata?: {
|
|
224
233
|
[key: string]: string;
|
|
225
234
|
};
|
|
226
|
-
/**
|
|
227
|
-
* @description Stripe subscription status (Stripe customers only).
|
|
228
|
-
* @enum {string}
|
|
229
|
-
*/
|
|
230
|
-
status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
231
235
|
/** @description Unix timestamp (ms) when the subscription was canceled (Stripe customers only). */
|
|
232
236
|
canceledAt?: number | null;
|
|
233
237
|
/** @description Unix timestamp (ms) when the subscription started (Stripe customers only). */
|
|
@@ -379,6 +383,8 @@ interface paths {
|
|
|
379
383
|
name?: string;
|
|
380
384
|
/** @description Customer email address. */
|
|
381
385
|
email?: string;
|
|
386
|
+
/** @description Unix timestamp (ms) when usage tracking started. */
|
|
387
|
+
usageStartedAt?: number;
|
|
382
388
|
/**
|
|
383
389
|
* @description Customer environment.
|
|
384
390
|
* @enum {string}
|
|
@@ -390,17 +396,17 @@ interface paths {
|
|
|
390
396
|
id: string;
|
|
391
397
|
/** @description Product name. */
|
|
392
398
|
name: string;
|
|
399
|
+
/**
|
|
400
|
+
* @description Stripe subscription status (Stripe customers only).
|
|
401
|
+
* @enum {string}
|
|
402
|
+
*/
|
|
403
|
+
status: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
393
404
|
/** @description Product version number. */
|
|
394
405
|
version: number;
|
|
395
406
|
/** @description Custom product metadata (custom products only). */
|
|
396
407
|
metadata?: {
|
|
397
408
|
[key: string]: string;
|
|
398
409
|
};
|
|
399
|
-
/**
|
|
400
|
-
* @description Stripe subscription status (Stripe customers only).
|
|
401
|
-
* @enum {string}
|
|
402
|
-
*/
|
|
403
|
-
status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
404
410
|
/** @description Unix timestamp (ms) when the subscription was canceled (Stripe customers only). */
|
|
405
411
|
canceledAt?: number | null;
|
|
406
412
|
/** @description Unix timestamp (ms) when the subscription started (Stripe customers only). */
|
|
@@ -643,6 +649,8 @@ interface paths {
|
|
|
643
649
|
name?: string;
|
|
644
650
|
/** @description Customer email address. */
|
|
645
651
|
email?: string;
|
|
652
|
+
/** @description Unix timestamp (ms) when usage tracking started. */
|
|
653
|
+
usageStartedAt?: number;
|
|
646
654
|
/**
|
|
647
655
|
* @description Customer environment.
|
|
648
656
|
* @enum {string}
|
|
@@ -654,17 +662,17 @@ interface paths {
|
|
|
654
662
|
id: string;
|
|
655
663
|
/** @description Product name. */
|
|
656
664
|
name: string;
|
|
665
|
+
/**
|
|
666
|
+
* @description Stripe subscription status (Stripe customers only).
|
|
667
|
+
* @enum {string}
|
|
668
|
+
*/
|
|
669
|
+
status: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
657
670
|
/** @description Product version number. */
|
|
658
671
|
version: number;
|
|
659
672
|
/** @description Custom product metadata (custom products only). */
|
|
660
673
|
metadata?: {
|
|
661
674
|
[key: string]: string;
|
|
662
675
|
};
|
|
663
|
-
/**
|
|
664
|
-
* @description Stripe subscription status (Stripe customers only).
|
|
665
|
-
* @enum {string}
|
|
666
|
-
*/
|
|
667
|
-
status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
|
|
668
676
|
/** @description Unix timestamp (ms) when the subscription was canceled (Stripe customers only). */
|
|
669
677
|
canceledAt?: number | null;
|
|
670
678
|
/** @description Unix timestamp (ms) when the subscription started (Stripe customers only). */
|
|
@@ -1125,9 +1133,14 @@ type WithFeatureAccess<T, TFeatureAccessMap> = T extends {
|
|
|
1125
1133
|
} : T;
|
|
1126
1134
|
type GetCustomerResponseBase = paths["/v1/customer"]["get"]["responses"][200]["content"]["application/json"];
|
|
1127
1135
|
type GetCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<GetCustomerResponseBase, TFeatureAccessMap>;
|
|
1136
|
+
type CreateCustomerRequest = paths["/v1/customer"]["post"]["requestBody"]["content"]["application/json"];
|
|
1137
|
+
type CreateCustomerResponseBase = paths["/v1/customer"]["post"]["responses"][201]["content"]["application/json"];
|
|
1138
|
+
type CreateCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<CreateCustomerResponseBase, TFeatureAccessMap>;
|
|
1128
1139
|
type UpdateCustomerBody = paths["/v1/customer"]["put"]["requestBody"]["content"]["application/json"];
|
|
1129
1140
|
type UpdateCustomerResponseBase = paths["/v1/customer"]["put"]["responses"][200]["content"]["application/json"];
|
|
1130
1141
|
type UpdateCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<UpdateCustomerResponseBase, TFeatureAccessMap>;
|
|
1142
|
+
type DeleteCustomerRequest = paths["/v1/customer"]["delete"]["parameters"]["query"];
|
|
1143
|
+
type DeleteCustomerResponse = paths["/v1/customer"]["delete"]["responses"][200]["content"]["application/json"];
|
|
1131
1144
|
type IdentifyCustomerBody = paths["/v1/customer/identify"]["post"]["requestBody"]["content"]["application/json"];
|
|
1132
1145
|
type IdentifyCustomerResponseBase = paths["/v1/customer/identify"]["post"]["responses"][200]["content"]["application/json"];
|
|
1133
1146
|
type IdentifyCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<IdentifyCustomerResponseBase, TFeatureAccessMap>;
|
|
@@ -1140,12 +1153,23 @@ type PriceOSClientOptions = {
|
|
|
1140
1153
|
fetch?: typeof fetch;
|
|
1141
1154
|
userAgent?: string;
|
|
1142
1155
|
};
|
|
1156
|
+
type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1157
|
+
get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;
|
|
1158
|
+
identify(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse<TFeatureAccessMap> | null>;
|
|
1159
|
+
create(input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>>;
|
|
1160
|
+
update(input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>>;
|
|
1161
|
+
delete(customerId: string): Promise<DeleteCustomerResponse>;
|
|
1162
|
+
};
|
|
1163
|
+
type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1164
|
+
getAccess(customerId: string): Promise<TFeatureAccessMap>;
|
|
1165
|
+
};
|
|
1166
|
+
type PriceOSUsageClient = {
|
|
1167
|
+
track(input: TrackUsageBody): Promise<TrackUsageResponse>;
|
|
1168
|
+
};
|
|
1143
1169
|
type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
getFeatureAccess(customerId: string): Promise<TFeatureAccessMap>;
|
|
1148
|
-
trackUsage(input: TrackUsageBody): Promise<TrackUsageResponse>;
|
|
1170
|
+
customers: PriceOSCustomersClient<TFeatureAccessMap>;
|
|
1171
|
+
features: PriceOSFeaturesClient<TFeatureAccessMap>;
|
|
1172
|
+
usage: PriceOSUsageClient;
|
|
1149
1173
|
};
|
|
1150
1174
|
declare class PriceOSError extends Error {
|
|
1151
1175
|
status?: number;
|
|
@@ -1158,16 +1182,10 @@ declare class PriceOSError extends Error {
|
|
|
1158
1182
|
declare class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse> implements PriceOSHttpClient<TFeatureAccessMap> {
|
|
1159
1183
|
private client;
|
|
1160
1184
|
private header;
|
|
1185
|
+
customers: PriceOSCustomersClient<TFeatureAccessMap>;
|
|
1186
|
+
features: PriceOSFeaturesClient<TFeatureAccessMap>;
|
|
1187
|
+
usage: PriceOSUsageClient;
|
|
1161
1188
|
constructor(apiKey: string, opts?: PriceOSClientOptions);
|
|
1162
|
-
getCustomer(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;
|
|
1163
|
-
identifyCustomer(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse<TFeatureAccessMap> | null>;
|
|
1164
|
-
upsertCustomer(input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>>;
|
|
1165
|
-
getFeatureAccess(customerId: string): Promise<TFeatureAccessMap>;
|
|
1166
|
-
trackUsage(input: TrackUsageBody): Promise<{
|
|
1167
|
-
applied: boolean;
|
|
1168
|
-
used: number | null;
|
|
1169
|
-
reason?: string | null;
|
|
1170
|
-
}>;
|
|
1171
1189
|
}
|
|
1172
1190
|
|
|
1173
|
-
export { type GetCustomerResponse, type GetFeatureAccessResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, PriceOS, type PriceOSClientOptions, PriceOSError, type PriceOSHttpClient, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse };
|
|
1191
|
+
export { type CreateCustomerRequest, type CreateCustomerResponse, type DeleteCustomerRequest, type DeleteCustomerResponse, type GetCustomerResponse, type GetFeatureAccessResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, PriceOS, type PriceOSClientOptions, type PriceOSCustomersClient, PriceOSError, type PriceOSFeaturesClient, type PriceOSHttpClient, type PriceOSUsageClient, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse };
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,9 @@ var PriceOSError = class extends Error {
|
|
|
13
13
|
var PriceOS = class {
|
|
14
14
|
client;
|
|
15
15
|
header;
|
|
16
|
+
customers;
|
|
17
|
+
features;
|
|
18
|
+
usage;
|
|
16
19
|
constructor(apiKey, opts = {}) {
|
|
17
20
|
const baseUrl = opts.baseUrl ?? "https://api.priceos.com";
|
|
18
21
|
this.header = { "x-api-key": apiKey };
|
|
@@ -24,45 +27,72 @@ var PriceOS = class {
|
|
|
24
27
|
...opts.userAgent ? { "user-agent": opts.userAgent } : {}
|
|
25
28
|
}
|
|
26
29
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
30
|
+
this.customers = {
|
|
31
|
+
get: async (customerId) => {
|
|
32
|
+
const { data, error, response } = await this.client.GET("/v1/customer", {
|
|
33
|
+
params: { query: { customerId }, header: this.header }
|
|
34
|
+
});
|
|
35
|
+
if (error)
|
|
36
|
+
throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
|
|
37
|
+
return data ?? null;
|
|
38
|
+
},
|
|
39
|
+
identify: async (input) => {
|
|
40
|
+
const { data, error, response } = await this.client.POST("/v1/customer/identify", {
|
|
41
|
+
params: { header: this.header },
|
|
42
|
+
body: input
|
|
43
|
+
});
|
|
44
|
+
if (error)
|
|
45
|
+
throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
|
|
46
|
+
return data ?? null;
|
|
47
|
+
},
|
|
48
|
+
create: async (input) => {
|
|
49
|
+
const { data, error, response } = await this.client.POST("/v1/customer", {
|
|
50
|
+
params: { header: this.header },
|
|
51
|
+
body: input
|
|
52
|
+
});
|
|
53
|
+
if (error)
|
|
54
|
+
throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
|
|
55
|
+
return data;
|
|
56
|
+
},
|
|
57
|
+
update: async (input) => {
|
|
58
|
+
const { data, error, response } = await this.client.PUT("/v1/customer", {
|
|
59
|
+
params: { header: this.header },
|
|
60
|
+
body: input
|
|
61
|
+
});
|
|
62
|
+
if (error)
|
|
63
|
+
throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
|
|
64
|
+
return data;
|
|
65
|
+
},
|
|
66
|
+
delete: async (customerId) => {
|
|
67
|
+
const { data, error, response } = await this.client.DELETE("/v1/customer", {
|
|
68
|
+
params: { query: { customerId }, header: this.header }
|
|
69
|
+
});
|
|
70
|
+
if (error)
|
|
71
|
+
throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
|
|
72
|
+
return data;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
this.features = {
|
|
76
|
+
getAccess: async (customerId) => {
|
|
77
|
+
const { data, error, response } = await this.client.GET("/v1/feature-access", {
|
|
78
|
+
params: { query: { customerId }, header: this.header }
|
|
79
|
+
});
|
|
80
|
+
if (error)
|
|
81
|
+
throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
|
|
82
|
+
return data;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
this.usage = {
|
|
86
|
+
track: async (input) => {
|
|
87
|
+
const { data, error, response } = await this.client.POST("/v1/usage", {
|
|
88
|
+
params: { header: this.header },
|
|
89
|
+
body: input
|
|
90
|
+
});
|
|
91
|
+
if (error)
|
|
92
|
+
throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
|
|
93
|
+
return data;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
66
96
|
}
|
|
67
97
|
};
|
|
68
98
|
export {
|
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 PriceOSClientOptions = {\n baseUrl?: string;\n fetch?: typeof fetch;\n userAgent?: string;\n};\n\
|
|
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 CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteCustomerResponse,\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\nexport type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;\n identify(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse<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 PriceOSUsageClient = {\n track(input: TrackUsageBody): Promise<TrackUsageResponse>;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient;\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 customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient;\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 this.customers = {\n get: async (customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.GET(\"/v1/customer\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return (data ?? null) as GetCustomerResponse<TFeatureAccessMap> | null;\n },\n identify: async (\n input: IdentifyCustomerBody\n ): Promise<IdentifyCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.POST(\"/v1/customer/identify\", {\n params: { header: this.header },\n body: input,\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return (data ?? null) as IdentifyCustomerResponse<TFeatureAccessMap> | null;\n },\n create: async (input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>> => {\n const { data, error, response } = await this.client.POST(\"/v1/customer\", {\n params: { header: this.header },\n body: input,\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as CreateCustomerResponse<TFeatureAccessMap>;\n },\n update: async (input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>> => {\n const { data, error, response } = await this.client.PUT(\"/v1/customer\", {\n params: { header: this.header },\n body: input,\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as UpdateCustomerResponse<TFeatureAccessMap>;\n },\n delete: async (customerId: string): Promise<DeleteCustomerResponse> => {\n const { data, error, response } = await this.client.DELETE(\"/v1/customer\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\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)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as TFeatureAccessMap;\n },\n };\n\n this.usage = {\n track: async (input: TrackUsageBody): 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)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n },\n };\n }\n}\n"],"mappings":";AAAA,OAAO,kBAAkB;AA+ClB,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,EACR;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY,QAAgB,OAA6B,CAAC,GAAG;AAC3D,UAAM,U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,QAAQ,SAAS,MAAM,CAAC;AACtG,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.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
20
|
"gen:types": "openapi-typescript ../../api/public/openapi.json -o src/gen/openapi.d.ts",
|
|
21
|
-
"sync:features": "node --import tsx src/cli.ts
|
|
21
|
+
"sync:features": "node --import tsx src/cli.ts generate-types --out ../playground/src/feature-keys.d.ts",
|
|
22
22
|
"build": "pnpm gen:types && tsup",
|
|
23
23
|
"dev": "pnpm gen:types && tsup src/index.ts --format esm,cjs --dts --watch",
|
|
24
24
|
"lint": "eslint .",
|