priceos 0.0.37 → 0.0.38
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/index.cjs +26 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +129 -105
- package/dist/index.d.ts +129 -105
- package/dist/index.js +26 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -226,6 +226,7 @@ var PriceOS = class {
|
|
|
226
226
|
log;
|
|
227
227
|
customers;
|
|
228
228
|
features;
|
|
229
|
+
bonuses;
|
|
229
230
|
usage;
|
|
230
231
|
constructor(apiKey, opts = {}) {
|
|
231
232
|
const logLevel = opts.logLevel ?? "none";
|
|
@@ -242,41 +243,42 @@ var PriceOS = class {
|
|
|
242
243
|
});
|
|
243
244
|
this.customers = {
|
|
244
245
|
get: async (customerId) => {
|
|
245
|
-
const { data, error, response } = await this.client.GET("/v1/
|
|
246
|
-
params: {
|
|
246
|
+
const { data, error, response } = await this.client.GET("/v1/customers/{customerId}", {
|
|
247
|
+
params: { path: { customerId }, header: this.header }
|
|
247
248
|
});
|
|
248
|
-
if (error) throwRequestError(this.log, error, response, "GET /v1/
|
|
249
|
+
if (error) throwRequestError(this.log, error, response, "GET /v1/customers/{customerId}");
|
|
249
250
|
return data ?? null;
|
|
250
251
|
},
|
|
251
252
|
identify: async (input) => {
|
|
252
|
-
const { data, error, response } = await this.client.POST("/v1/
|
|
253
|
+
const { data, error, response } = await this.client.POST("/v1/customers/identify", {
|
|
253
254
|
params: { header: this.header },
|
|
254
255
|
body: input
|
|
255
256
|
});
|
|
256
|
-
if (error) throwRequestError(this.log, error, response, "POST /v1/
|
|
257
|
+
if (error) throwRequestError(this.log, error, response, "POST /v1/customers/identify");
|
|
257
258
|
return data ?? null;
|
|
258
259
|
},
|
|
259
260
|
create: async (input) => {
|
|
260
|
-
const { data, error, response } = await this.client.POST("/v1/
|
|
261
|
+
const { data, error, response } = await this.client.POST("/v1/customers", {
|
|
261
262
|
params: { header: this.header },
|
|
262
263
|
body: input
|
|
263
264
|
});
|
|
264
|
-
if (error) throwRequestError(this.log, error, response, "POST /v1/
|
|
265
|
+
if (error) throwRequestError(this.log, error, response, "POST /v1/customers");
|
|
265
266
|
return data;
|
|
266
267
|
},
|
|
267
268
|
update: async (input) => {
|
|
268
|
-
const {
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
const { customerId, ...body } = input;
|
|
270
|
+
const { data, error, response } = await this.client.PUT("/v1/customers/{customerId}", {
|
|
271
|
+
params: { path: { customerId }, header: this.header },
|
|
272
|
+
body
|
|
271
273
|
});
|
|
272
|
-
if (error) throwRequestError(this.log, error, response, "PUT /v1/
|
|
274
|
+
if (error) throwRequestError(this.log, error, response, "PUT /v1/customers/{customerId}");
|
|
273
275
|
return data;
|
|
274
276
|
},
|
|
275
277
|
delete: async (customerId) => {
|
|
276
|
-
const { data, error, response } = await this.client.DELETE("/v1/
|
|
277
|
-
params: {
|
|
278
|
+
const { data, error, response } = await this.client.DELETE("/v1/customers/{customerId}", {
|
|
279
|
+
params: { path: { customerId }, header: this.header }
|
|
278
280
|
});
|
|
279
|
-
if (error) throwRequestError(this.log, error, response, "DELETE /v1/
|
|
281
|
+
if (error) throwRequestError(this.log, error, response, "DELETE /v1/customers/{customerId}");
|
|
280
282
|
return data;
|
|
281
283
|
}
|
|
282
284
|
};
|
|
@@ -289,21 +291,23 @@ var PriceOS = class {
|
|
|
289
291
|
return data;
|
|
290
292
|
}
|
|
291
293
|
};
|
|
292
|
-
this.
|
|
293
|
-
|
|
294
|
-
const { data, error, response } = await this.client.POST("/v1/
|
|
294
|
+
this.bonuses = {
|
|
295
|
+
grant: async (input) => {
|
|
296
|
+
const { data, error, response } = await this.client.POST("/v1/bonuses", {
|
|
295
297
|
params: { header: this.header },
|
|
296
298
|
body: input
|
|
297
299
|
});
|
|
298
|
-
if (error) throwRequestError(this.log, error, response, "POST /v1/
|
|
300
|
+
if (error) throwRequestError(this.log, error, response, "POST /v1/bonuses");
|
|
299
301
|
return data;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
this.usage = {
|
|
305
|
+
track: async (input) => {
|
|
306
|
+
const { data, error, response } = await this.client.POST("/v1/usage", {
|
|
303
307
|
params: { header: this.header },
|
|
304
308
|
body: input
|
|
305
309
|
});
|
|
306
|
-
if (error) throwRequestError(this.log, error, response, "POST /v1/usage
|
|
310
|
+
if (error) throwRequestError(this.log, error, response, "POST /v1/usage");
|
|
307
311
|
return data;
|
|
308
312
|
},
|
|
309
313
|
reset: async (input) => {
|
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 PriceOSLogLevel,\n PriceOSCustomersClient,\n PriceOSFeaturesClient,\n PriceOSHttpClient,\n PriceOSUsageClient,\n} from \"./client\";\nexport type {\n CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteUsageEventsBody,\n DeleteUsageEventsResponse,\n DeleteCustomerRequest,\n DeleteCustomerResponse,\n GrantBonusBody,\n GrantBonusResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n ListUsageEventsBody,\n ListUsageEventsResponse,\n ResetUsageBody,\n ResetUsageResponse,\n UsageEvent,\n TrackUsageBody,\n TrackUsageBatchBody,\n TrackUsageBatchEvent,\n TrackUsageBatchResponse,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n","import createClient from \"openapi-fetch\";\nimport type { Client } from \"openapi-fetch\";\nimport type { paths } from \"./gen/openapi\";\nimport {\n CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteUsageEventsBody,\n DeleteUsageEventsResponse,\n DeleteCustomerResponse,\n GrantBonusBody,\n GrantBonusResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n ListUsageEventsBody,\n ListUsageEventsResponse,\n ResetUsageBody,\n ResetUsageResponse,\n TrackUsageBody,\n TrackUsageBatchBody,\n TrackUsageBatchResponse,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\nexport type PriceOSLogLevel = \"none\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n logLevel?: PriceOSLogLevel;\n};\n\nconst RATE_LIMIT_STATUS = 429;\nconst MAX_RETRIES = 4;\nconst BASE_DELAY_MS = 250;\nconst BACKOFF_MULTIPLIER = 2;\nconst JITTER_MS = 250;\nconst RETRY_DELAY_CAP_MS = 5_000;\nconst REQUEST_TIMEOUT_MS = 20_000;\n\nconst LOG_LEVELS: Record<PriceOSLogLevel, number> = {\n none: 0,\n error: 1,\n warning: 2,\n info: 3,\n debug: 4,\n};\n\ntype Logger = {\n error: (message: string, details?: Record<string, unknown>) => void;\n warning: (message: string, details?: Record<string, unknown>) => void;\n info: (message: string, details?: Record<string, unknown>) => void;\n debug: (message: string, details?: Record<string, unknown>) => void;\n};\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\nconst getRetryDelayMs = (retryCount: number): number => {\n const backoff = BASE_DELAY_MS * Math.pow(BACKOFF_MULTIPLIER, retryCount - 1);\n const jitter = Math.random() * JITTER_MS;\n return Math.min(RETRY_DELAY_CAP_MS, backoff + jitter);\n};\n\nconst createLogger = (logLevel: PriceOSLogLevel): Logger => {\n const shouldLog = (level: PriceOSLogLevel): boolean =>\n logLevel !== \"none\" && LOG_LEVELS[level] <= LOG_LEVELS[logLevel];\n\n const write = (\n level: PriceOSLogLevel,\n message: string,\n details?: Record<string, unknown>\n ): void => {\n if (!shouldLog(level)) return;\n const prefix = `[PriceOS] ${level.toUpperCase()}: ${message}`;\n const payload = details && Object.keys(details).length > 0 ? details : undefined;\n\n switch (level) {\n case \"error\":\n payload ? console.error(prefix, payload) : console.error(prefix);\n return;\n case \"warning\":\n payload ? console.warn(prefix, payload) : console.warn(prefix);\n return;\n case \"info\":\n payload ? console.info(prefix, payload) : console.info(prefix);\n return;\n case \"debug\":\n payload ? console.debug(prefix, payload) : console.debug(prefix);\n return;\n }\n };\n\n return {\n error: (message, details) => write(\"error\", message, details),\n warning: (message, details) => write(\"warning\", message, details),\n info: (message, details) => write(\"info\", message, details),\n debug: (message, details) => write(\"debug\", message, details),\n };\n};\n\nconst getUpstreamSignal = (input: RequestInfo | URL, init?: RequestInit): AbortSignal | undefined => {\n if (init?.signal) return init.signal;\n if (typeof Request !== \"undefined\" && input instanceof Request) return input.signal;\n return undefined;\n};\n\nconst stripSignal = (init?: RequestInit): RequestInit | undefined => {\n if (!init) return undefined;\n const { signal: _signal, ...rest } = init;\n return rest;\n};\n\nconst getRequestDetails = (\n input: RequestInfo | URL,\n init?: RequestInit\n): { method: string; url: string } => {\n const method =\n init?.method ??\n (typeof Request !== \"undefined\" && input instanceof Request ? input.method : \"GET\");\n const url =\n typeof input === \"string\"\n ? input\n : input instanceof URL\n ? input.toString()\n : input.url;\n return { method, url };\n};\n\nconst prepareRetryRequest = async (\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n log: Logger,\n method: string,\n url: string\n): Promise<{ requestInput: RequestInfo | URL; baseInit?: RequestInit; canRetry: boolean }> => {\n if (!(typeof Request !== \"undefined\" && input instanceof Request)) {\n return { requestInput: input, baseInit: stripSignal(init), canRetry: true };\n }\n\n if (input.bodyUsed) {\n log.warning(\"Request body already used; retries disabled\", { method, url });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n\n let body: BodyInit | undefined = undefined;\n if (method !== \"GET\" && method !== \"HEAD\") {\n try {\n body = await input.clone().arrayBuffer();\n } catch (error) {\n log.warning(\"Unable to clone request body; retries disabled\", { method, url, error });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n }\n\n const headers = new Headers(input.headers);\n const baseInit = { ...stripSignal(init), method, headers, body };\n return { requestInput: input.url, baseInit, canRetry: true };\n};\n\nconst getErrorMessage = (error: unknown): string => {\n const maybeError = error as { error?: unknown } | null;\n if (maybeError && typeof maybeError.error === \"string\") return maybeError.error;\n return \"Request failed\";\n};\n\nconst throwRequestError = (\n log: Logger,\n error: unknown,\n response: Response | undefined,\n context: string\n): never => {\n log.error(\"Request failed\", { context, status: response?.status, error });\n throw new PriceOSError(getErrorMessage(error), { status: response?.status, details: error });\n};\n\nconst createRetryingFetch = (baseFetch: typeof fetch, log: Logger): typeof fetch => {\n return async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {\n const { method, url } = getRequestDetails(input, init);\n const upstreamSignal = getUpstreamSignal(input, init);\n const { requestInput, baseInit, canRetry } = await prepareRetryRequest(\n input,\n init,\n log,\n method,\n url\n );\n let attempt = 0;\n while (true) {\n log.debug(\"Request attempt\", { method, url, attempt: attempt + 1, maxRetries: MAX_RETRIES });\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);\n let removeAbortListener: (() => void) | null = null;\n\n if (upstreamSignal) {\n if (upstreamSignal.aborted) {\n controller.abort();\n } else {\n const onAbort = () => controller.abort();\n upstreamSignal.addEventListener(\"abort\", onAbort);\n removeAbortListener = () => upstreamSignal.removeEventListener(\"abort\", onAbort);\n }\n }\n\n try {\n const requestInit = { ...(baseInit ?? {}), signal: controller.signal };\n const response = await baseFetch(requestInput, requestInit);\n if (response.status !== RATE_LIMIT_STATUS) return response;\n\n const retryAfter = response.headers.get(\"retry-after\") ?? undefined;\n log.warning(\"Rate limit hit (429)\", {\n method,\n url,\n attempt: attempt + 1,\n maxRetries: MAX_RETRIES,\n retryAfter,\n });\n\n if (!canRetry) {\n log.warning(\"Skipping retry because request body is not replayable\", { method, url });\n return response;\n }\n\n if (attempt >= MAX_RETRIES) {\n log.error(\"Rate limit retries exhausted\", { method, url, attempts: attempt + 1 });\n return response;\n }\n\n const delayMs = getRetryDelayMs(attempt + 1);\n log.info(\"Waiting to retry after rate limit\", {\n method,\n url,\n delayMs,\n nextAttempt: attempt + 2,\n maxRetries: MAX_RETRIES,\n });\n await sleep(delayMs);\n attempt += 1;\n } catch (error) {\n if (controller.signal.aborted) {\n const abortedByCaller = upstreamSignal?.aborted ?? false;\n if (abortedByCaller) {\n log.warning(\"Request aborted by caller\", { method, url, attempt: attempt + 1 });\n } else {\n log.error(\"Request timed out\", {\n method,\n url,\n attempt: attempt + 1,\n timeoutMs: REQUEST_TIMEOUT_MS,\n });\n }\n } else {\n log.error(\"Request failed\", { method, url, attempt: attempt + 1, error });\n }\n throw error;\n } finally {\n clearTimeout(timeoutId);\n removeAbortListener?.();\n }\n }\n };\n};\n\nexport type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;\n 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<TFeatureAccessMap = GetFeatureAccessResponse> = {\n track(\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse>;\n grantBonus(\n input: GrantBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<GrantBonusResponse>;\n reset(\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse>;\n deleteEvents(\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse>;\n trackBatch(\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse>;\n listEvents(\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse>;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n};\n\nexport class PriceOSError extends Error {\n status?: number;\n details?: unknown;\n\n constructor(message: string, opts?: { status?: number; details?: unknown }) {\n super(message);\n this.name = \"PriceOSError\";\n this.status = opts?.status;\n this.details = opts?.details;\n }\n}\n\nexport class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse>\n implements PriceOSHttpClient<TFeatureAccessMap>\n{\n private client: Client<paths>;\n private header: { \"x-api-key\": string };\n private log: Logger;\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n\n constructor(apiKey: string, opts: PriceOSClientOptions = {}) {\n const logLevel = opts.logLevel ?? \"none\";\n this.log = createLogger(logLevel);\n const baseUrl = \"https://api.priceos.com\";\n this.header = { \"x-api-key\": apiKey };\n const fetchWithRetry = createRetryingFetch(fetch, this.log);\n this.client = createClient<paths>({\n baseUrl,\n fetch: fetchWithRetry,\n headers: {\n \"x-api-key\": apiKey,\n },\n });\n\n this.customers = {\n get: async (customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.GET(\"/v1/customer\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/customer\");\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) throwRequestError(this.log, error, response, \"POST /v1/customer/identify\");\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) throwRequestError(this.log, error, response, \"POST /v1/customer\");\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) throwRequestError(this.log, error, response, \"PUT /v1/customer\");\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) throwRequestError(this.log, error, response, \"DELETE /v1/customer\");\n return data! as DeleteCustomerResponse;\n },\n };\n\n this.features = {\n getAccess: async (customerId: string): Promise<TFeatureAccessMap> => {\n const { data, error, response } = await this.client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/feature-access\");\n return data! as TFeatureAccessMap;\n },\n };\n\n this.usage = {\n track: async (\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage\");\n return data!;\n },\n grantBonus: async (\n input: GrantBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<GrantBonusResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/bonus/grant\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/bonus/grant\");\n return data!;\n },\n reset: async (\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/void\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/void\");\n return data!;\n },\n deleteEvents: async (\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/delete\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/delete\");\n return data!;\n },\n trackBatch: async (\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/batch\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/batch\");\n return data!;\n },\n listEvents: async (\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/events\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/events\");\n return data!;\n },\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAAyB;AAmCzB,IAAM,oBAAoB;AAC1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KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,sBAAsB;AAC9E,eAAO;AAAA,MACT;AAAA,MACA,YAAY,OACV,UACqC;AACrC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,oBAAoB;AAAA,UAC3E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":["createClient"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts"],"sourcesContent":["export { PriceOS, PriceOSError } from \"./client\";\nexport type {\n PriceOSClientOptions,\n PriceOSLogLevel,\n PriceOSBonusesClient,\n PriceOSCustomersClient,\n PriceOSFeaturesClient,\n PriceOSHttpClient,\n PriceOSUsageClient,\n} from \"./client\";\nexport type {\n CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteUsageEventsBody,\n DeleteUsageEventsResponse,\n DeleteCustomerRequest,\n DeleteCustomerResponse,\n GrantBonusBody,\n GrantBonusResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n ListUsageEventsBody,\n ListUsageEventsResponse,\n ResetUsageBody,\n ResetUsageResponse,\n UsageEvent,\n TrackUsageBody,\n TrackUsageBatchBody,\n TrackUsageBatchEvent,\n TrackUsageBatchResponse,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n","import createClient from \"openapi-fetch\";\nimport type { Client } from \"openapi-fetch\";\nimport type { paths } from \"./gen/openapi\";\nimport {\n CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteUsageEventsBody,\n DeleteUsageEventsResponse,\n DeleteCustomerResponse,\n GrantBonusBody,\n GrantBonusResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n ListUsageEventsBody,\n ListUsageEventsResponse,\n ResetUsageBody,\n ResetUsageResponse,\n TrackUsageBody,\n TrackUsageBatchBody,\n TrackUsageBatchResponse,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\nexport type PriceOSLogLevel = \"none\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n logLevel?: PriceOSLogLevel;\n};\n\nconst RATE_LIMIT_STATUS = 429;\nconst MAX_RETRIES = 4;\nconst BASE_DELAY_MS = 250;\nconst BACKOFF_MULTIPLIER = 2;\nconst JITTER_MS = 250;\nconst RETRY_DELAY_CAP_MS = 5_000;\nconst REQUEST_TIMEOUT_MS = 20_000;\n\nconst LOG_LEVELS: Record<PriceOSLogLevel, number> = {\n none: 0,\n error: 1,\n warning: 2,\n info: 3,\n debug: 4,\n};\n\ntype Logger = {\n error: (message: string, details?: Record<string, unknown>) => void;\n warning: (message: string, details?: Record<string, unknown>) => void;\n info: (message: string, details?: Record<string, unknown>) => void;\n debug: (message: string, details?: Record<string, unknown>) => void;\n};\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\nconst getRetryDelayMs = (retryCount: number): number => {\n const backoff = BASE_DELAY_MS * Math.pow(BACKOFF_MULTIPLIER, retryCount - 1);\n const jitter = Math.random() * JITTER_MS;\n return Math.min(RETRY_DELAY_CAP_MS, backoff + jitter);\n};\n\nconst createLogger = (logLevel: PriceOSLogLevel): Logger => {\n const shouldLog = (level: PriceOSLogLevel): boolean =>\n logLevel !== \"none\" && LOG_LEVELS[level] <= LOG_LEVELS[logLevel];\n\n const write = (\n level: PriceOSLogLevel,\n message: string,\n details?: Record<string, unknown>\n ): void => {\n if (!shouldLog(level)) return;\n const prefix = `[PriceOS] ${level.toUpperCase()}: ${message}`;\n const payload = details && Object.keys(details).length > 0 ? details : undefined;\n\n switch (level) {\n case \"error\":\n payload ? console.error(prefix, payload) : console.error(prefix);\n return;\n case \"warning\":\n payload ? console.warn(prefix, payload) : console.warn(prefix);\n return;\n case \"info\":\n payload ? console.info(prefix, payload) : console.info(prefix);\n return;\n case \"debug\":\n payload ? console.debug(prefix, payload) : console.debug(prefix);\n return;\n }\n };\n\n return {\n error: (message, details) => write(\"error\", message, details),\n warning: (message, details) => write(\"warning\", message, details),\n info: (message, details) => write(\"info\", message, details),\n debug: (message, details) => write(\"debug\", message, details),\n };\n};\n\nconst getUpstreamSignal = (input: RequestInfo | URL, init?: RequestInit): AbortSignal | undefined => {\n if (init?.signal) return init.signal;\n if (typeof Request !== \"undefined\" && input instanceof Request) return input.signal;\n return undefined;\n};\n\nconst stripSignal = (init?: RequestInit): RequestInit | undefined => {\n if (!init) return undefined;\n const { signal: _signal, ...rest } = init;\n return rest;\n};\n\nconst getRequestDetails = (\n input: RequestInfo | URL,\n init?: RequestInit\n): { method: string; url: string } => {\n const method =\n init?.method ??\n (typeof Request !== \"undefined\" && input instanceof Request ? input.method : \"GET\");\n const url =\n typeof input === \"string\"\n ? input\n : input instanceof URL\n ? input.toString()\n : input.url;\n return { method, url };\n};\n\nconst prepareRetryRequest = async (\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n log: Logger,\n method: string,\n url: string\n): Promise<{ requestInput: RequestInfo | URL; baseInit?: RequestInit; canRetry: boolean }> => {\n if (!(typeof Request !== \"undefined\" && input instanceof Request)) {\n return { requestInput: input, baseInit: stripSignal(init), canRetry: true };\n }\n\n if (input.bodyUsed) {\n log.warning(\"Request body already used; retries disabled\", { method, url });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n\n let body: BodyInit | undefined = undefined;\n if (method !== \"GET\" && method !== \"HEAD\") {\n try {\n body = await input.clone().arrayBuffer();\n } catch (error) {\n log.warning(\"Unable to clone request body; retries disabled\", { method, url, error });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n }\n\n const headers = new Headers(input.headers);\n const baseInit = { ...stripSignal(init), method, headers, body };\n return { requestInput: input.url, baseInit, canRetry: true };\n};\n\nconst getErrorMessage = (error: unknown): string => {\n const maybeError = error as { error?: unknown } | null;\n if (maybeError && typeof maybeError.error === \"string\") return maybeError.error;\n return \"Request failed\";\n};\n\nconst throwRequestError = (\n log: Logger,\n error: unknown,\n response: Response | undefined,\n context: string\n): never => {\n log.error(\"Request failed\", { context, status: response?.status, error });\n throw new PriceOSError(getErrorMessage(error), { status: response?.status, details: error });\n};\n\nconst createRetryingFetch = (baseFetch: typeof fetch, log: Logger): typeof fetch => {\n return async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {\n const { method, url } = getRequestDetails(input, init);\n const upstreamSignal = getUpstreamSignal(input, init);\n const { requestInput, baseInit, canRetry } = await prepareRetryRequest(\n input,\n init,\n log,\n method,\n url\n );\n let attempt = 0;\n while (true) {\n log.debug(\"Request attempt\", { method, url, attempt: attempt + 1, maxRetries: MAX_RETRIES });\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);\n let removeAbortListener: (() => void) | null = null;\n\n if (upstreamSignal) {\n if (upstreamSignal.aborted) {\n controller.abort();\n } else {\n const onAbort = () => controller.abort();\n upstreamSignal.addEventListener(\"abort\", onAbort);\n removeAbortListener = () => upstreamSignal.removeEventListener(\"abort\", onAbort);\n }\n }\n\n try {\n const requestInit = { ...(baseInit ?? {}), signal: controller.signal };\n const response = await baseFetch(requestInput, requestInit);\n if (response.status !== RATE_LIMIT_STATUS) return response;\n\n const retryAfter = response.headers.get(\"retry-after\") ?? undefined;\n log.warning(\"Rate limit hit (429)\", {\n method,\n url,\n attempt: attempt + 1,\n maxRetries: MAX_RETRIES,\n retryAfter,\n });\n\n if (!canRetry) {\n log.warning(\"Skipping retry because request body is not replayable\", { method, url });\n return response;\n }\n\n if (attempt >= MAX_RETRIES) {\n log.error(\"Rate limit retries exhausted\", { method, url, attempts: attempt + 1 });\n return response;\n }\n\n const delayMs = getRetryDelayMs(attempt + 1);\n log.info(\"Waiting to retry after rate limit\", {\n method,\n url,\n delayMs,\n nextAttempt: attempt + 2,\n maxRetries: MAX_RETRIES,\n });\n await sleep(delayMs);\n attempt += 1;\n } catch (error) {\n if (controller.signal.aborted) {\n const abortedByCaller = upstreamSignal?.aborted ?? false;\n if (abortedByCaller) {\n log.warning(\"Request aborted by caller\", { method, url, attempt: attempt + 1 });\n } else {\n log.error(\"Request timed out\", {\n method,\n url,\n attempt: attempt + 1,\n timeoutMs: REQUEST_TIMEOUT_MS,\n });\n }\n } else {\n log.error(\"Request failed\", { method, url, attempt: attempt + 1, error });\n }\n throw error;\n } finally {\n clearTimeout(timeoutId);\n removeAbortListener?.();\n }\n }\n };\n};\n\nexport type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;\n 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 PriceOSBonusesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n grant(\n input: GrantBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<GrantBonusResponse>;\n};\n\nexport type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n track(\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse>;\n reset(\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse>;\n deleteEvents(\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse>;\n trackBatch(\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse>;\n listEvents(\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse>;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n bonuses: PriceOSBonusesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n};\n\nexport class PriceOSError extends Error {\n status?: number;\n details?: unknown;\n\n constructor(message: string, opts?: { status?: number; details?: unknown }) {\n super(message);\n this.name = \"PriceOSError\";\n this.status = opts?.status;\n this.details = opts?.details;\n }\n}\n\nexport class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse>\n implements PriceOSHttpClient<TFeatureAccessMap>\n{\n private client: Client<paths>;\n private header: { \"x-api-key\": string };\n private log: Logger;\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n bonuses: PriceOSBonusesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n\n constructor(apiKey: string, opts: PriceOSClientOptions = {}) {\n const logLevel = opts.logLevel ?? \"none\";\n this.log = createLogger(logLevel);\n const baseUrl = \"https://api.priceos.com\";\n this.header = { \"x-api-key\": apiKey };\n const fetchWithRetry = createRetryingFetch(fetch, this.log);\n this.client = createClient<paths>({\n baseUrl,\n fetch: fetchWithRetry,\n headers: {\n \"x-api-key\": apiKey,\n },\n });\n\n this.customers = {\n get: async (customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.GET(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/customers/{customerId}\");\n return (data ?? null) as GetCustomerResponse<TFeatureAccessMap> | null;\n },\n identify: async (\n input: IdentifyCustomerBody\n ): Promise<IdentifyCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.POST(\"/v1/customers/identify\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/customers/identify\");\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/customers\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/customers\");\n return data! as CreateCustomerResponse<TFeatureAccessMap>;\n },\n update: async (input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>> => {\n const { customerId, ...body } = input;\n const { data, error, response } = await this.client.PUT(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n body,\n });\n if (error) throwRequestError(this.log, error, response, \"PUT /v1/customers/{customerId}\");\n return data! as UpdateCustomerResponse<TFeatureAccessMap>;\n },\n delete: async (customerId: string): Promise<DeleteCustomerResponse> => {\n const { data, error, response } = await this.client.DELETE(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"DELETE /v1/customers/{customerId}\");\n return data! as DeleteCustomerResponse;\n },\n };\n\n this.features = {\n getAccess: async (customerId: string): Promise<TFeatureAccessMap> => {\n const { data, error, response } = await this.client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/feature-access\");\n return data! as TFeatureAccessMap;\n },\n };\n\n this.bonuses = {\n grant: async (\n input: GrantBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<GrantBonusResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/bonuses\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/bonuses\");\n return data!;\n },\n };\n\n this.usage = {\n track: async (\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage\");\n return data!;\n },\n reset: async (\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/void\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/void\");\n return data!;\n },\n deleteEvents: async (\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/delete\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/delete\");\n return data!;\n },\n trackBatch: async (\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/batch\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/batch\");\n return data!;\n },\n listEvents: async (\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/events\", {\n params: { header: this.header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AAA,UAC3E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,MACA,YAAY,OACV,UACqC;AACrC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,mBAAmB;AAAA,UAC1E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,sBAAsB;AAC9E,eAAO;AAAA,MACT;AAAA,MACA,YAAY,OACV,UACqC;AACrC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,oBAAoB;AAAA,UAC3E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":["createClient"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
interface paths {
|
|
7
|
-
"/v1/
|
|
7
|
+
"/v1/customers/{customerId}": {
|
|
8
8
|
parameters: {
|
|
9
9
|
query?: never;
|
|
10
10
|
header?: never;
|
|
@@ -17,15 +17,15 @@ interface paths {
|
|
|
17
17
|
*/
|
|
18
18
|
get: {
|
|
19
19
|
parameters: {
|
|
20
|
-
query
|
|
21
|
-
/** @description Customer ID (internal or Stripe). */
|
|
22
|
-
customerId: string;
|
|
23
|
-
};
|
|
20
|
+
query?: never;
|
|
24
21
|
header: {
|
|
25
22
|
/** @description API key from your PriceOS dashboard. */
|
|
26
23
|
"x-api-key": string;
|
|
27
24
|
};
|
|
28
|
-
path
|
|
25
|
+
path: {
|
|
26
|
+
/** @description Customer ID (internal or Stripe). */
|
|
27
|
+
customerId: string;
|
|
28
|
+
};
|
|
29
29
|
cookie?: never;
|
|
30
30
|
};
|
|
31
31
|
requestBody?: never;
|
|
@@ -184,14 +184,15 @@ interface paths {
|
|
|
184
184
|
/** @description API key from your PriceOS dashboard. */
|
|
185
185
|
"x-api-key": string;
|
|
186
186
|
};
|
|
187
|
-
path
|
|
187
|
+
path: {
|
|
188
|
+
/** @description Customer ID (internal or Stripe). */
|
|
189
|
+
customerId: string;
|
|
190
|
+
};
|
|
188
191
|
cookie?: never;
|
|
189
192
|
};
|
|
190
193
|
requestBody: {
|
|
191
194
|
content: {
|
|
192
195
|
"application/json": {
|
|
193
|
-
/** @description Customer ID (internal or Stripe). */
|
|
194
|
-
customerId: string;
|
|
195
196
|
/** @description Customer name. */
|
|
196
197
|
name?: string;
|
|
197
198
|
/** @description Customer email address. */
|
|
@@ -357,6 +358,102 @@ interface paths {
|
|
|
357
358
|
};
|
|
358
359
|
};
|
|
359
360
|
};
|
|
361
|
+
post?: never;
|
|
362
|
+
/**
|
|
363
|
+
* Delete customer
|
|
364
|
+
* @description Delete a customer record.
|
|
365
|
+
*/
|
|
366
|
+
delete: {
|
|
367
|
+
parameters: {
|
|
368
|
+
query?: never;
|
|
369
|
+
header: {
|
|
370
|
+
/** @description API key from your PriceOS dashboard. */
|
|
371
|
+
"x-api-key": string;
|
|
372
|
+
};
|
|
373
|
+
path: {
|
|
374
|
+
/** @description Customer ID (internal or Stripe). */
|
|
375
|
+
customerId: string;
|
|
376
|
+
};
|
|
377
|
+
cookie?: never;
|
|
378
|
+
};
|
|
379
|
+
requestBody?: never;
|
|
380
|
+
responses: {
|
|
381
|
+
/** @description Customer deleted */
|
|
382
|
+
200: {
|
|
383
|
+
headers: {
|
|
384
|
+
[name: string]: unknown;
|
|
385
|
+
};
|
|
386
|
+
content: {
|
|
387
|
+
"application/json": {
|
|
388
|
+
/** @description Deleted customer record ID. */
|
|
389
|
+
id: string;
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
/** @description Bad request */
|
|
394
|
+
400: {
|
|
395
|
+
headers: {
|
|
396
|
+
[name: string]: unknown;
|
|
397
|
+
};
|
|
398
|
+
content: {
|
|
399
|
+
"application/json": {
|
|
400
|
+
/** @description Error message. */
|
|
401
|
+
error: string;
|
|
402
|
+
};
|
|
403
|
+
};
|
|
404
|
+
};
|
|
405
|
+
/** @description Unauthorized */
|
|
406
|
+
401: {
|
|
407
|
+
headers: {
|
|
408
|
+
[name: string]: unknown;
|
|
409
|
+
};
|
|
410
|
+
content: {
|
|
411
|
+
"application/json": {
|
|
412
|
+
/** @description Error message. */
|
|
413
|
+
error: string;
|
|
414
|
+
};
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
/** @description Not found */
|
|
418
|
+
404: {
|
|
419
|
+
headers: {
|
|
420
|
+
[name: string]: unknown;
|
|
421
|
+
};
|
|
422
|
+
content: {
|
|
423
|
+
"application/json": {
|
|
424
|
+
/** @description Error message. */
|
|
425
|
+
error: string;
|
|
426
|
+
};
|
|
427
|
+
};
|
|
428
|
+
};
|
|
429
|
+
/** @description Server error */
|
|
430
|
+
500: {
|
|
431
|
+
headers: {
|
|
432
|
+
[name: string]: unknown;
|
|
433
|
+
};
|
|
434
|
+
content: {
|
|
435
|
+
"application/json": {
|
|
436
|
+
/** @description Error message. */
|
|
437
|
+
error: string;
|
|
438
|
+
};
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
options?: never;
|
|
444
|
+
head?: never;
|
|
445
|
+
patch?: never;
|
|
446
|
+
trace?: never;
|
|
447
|
+
};
|
|
448
|
+
"/v1/customers": {
|
|
449
|
+
parameters: {
|
|
450
|
+
query?: never;
|
|
451
|
+
header?: never;
|
|
452
|
+
path?: never;
|
|
453
|
+
cookie?: never;
|
|
454
|
+
};
|
|
455
|
+
get?: never;
|
|
456
|
+
put?: never;
|
|
360
457
|
/**
|
|
361
458
|
* Create customer
|
|
362
459
|
* @description Create a customer record.
|
|
@@ -541,93 +638,13 @@ interface paths {
|
|
|
541
638
|
};
|
|
542
639
|
};
|
|
543
640
|
};
|
|
544
|
-
|
|
545
|
-
* Delete customer
|
|
546
|
-
* @description Delete a customer record.
|
|
547
|
-
*/
|
|
548
|
-
delete: {
|
|
549
|
-
parameters: {
|
|
550
|
-
query: {
|
|
551
|
-
/** @description Customer ID (internal or Stripe). */
|
|
552
|
-
customerId: string;
|
|
553
|
-
};
|
|
554
|
-
header: {
|
|
555
|
-
/** @description API key from your PriceOS dashboard. */
|
|
556
|
-
"x-api-key": string;
|
|
557
|
-
};
|
|
558
|
-
path?: never;
|
|
559
|
-
cookie?: never;
|
|
560
|
-
};
|
|
561
|
-
requestBody?: never;
|
|
562
|
-
responses: {
|
|
563
|
-
/** @description Customer deleted */
|
|
564
|
-
200: {
|
|
565
|
-
headers: {
|
|
566
|
-
[name: string]: unknown;
|
|
567
|
-
};
|
|
568
|
-
content: {
|
|
569
|
-
"application/json": {
|
|
570
|
-
/** @description Deleted customer record ID. */
|
|
571
|
-
id: string;
|
|
572
|
-
};
|
|
573
|
-
};
|
|
574
|
-
};
|
|
575
|
-
/** @description Bad request */
|
|
576
|
-
400: {
|
|
577
|
-
headers: {
|
|
578
|
-
[name: string]: unknown;
|
|
579
|
-
};
|
|
580
|
-
content: {
|
|
581
|
-
"application/json": {
|
|
582
|
-
/** @description Error message. */
|
|
583
|
-
error: string;
|
|
584
|
-
};
|
|
585
|
-
};
|
|
586
|
-
};
|
|
587
|
-
/** @description Unauthorized */
|
|
588
|
-
401: {
|
|
589
|
-
headers: {
|
|
590
|
-
[name: string]: unknown;
|
|
591
|
-
};
|
|
592
|
-
content: {
|
|
593
|
-
"application/json": {
|
|
594
|
-
/** @description Error message. */
|
|
595
|
-
error: string;
|
|
596
|
-
};
|
|
597
|
-
};
|
|
598
|
-
};
|
|
599
|
-
/** @description Not found */
|
|
600
|
-
404: {
|
|
601
|
-
headers: {
|
|
602
|
-
[name: string]: unknown;
|
|
603
|
-
};
|
|
604
|
-
content: {
|
|
605
|
-
"application/json": {
|
|
606
|
-
/** @description Error message. */
|
|
607
|
-
error: string;
|
|
608
|
-
};
|
|
609
|
-
};
|
|
610
|
-
};
|
|
611
|
-
/** @description Server error */
|
|
612
|
-
500: {
|
|
613
|
-
headers: {
|
|
614
|
-
[name: string]: unknown;
|
|
615
|
-
};
|
|
616
|
-
content: {
|
|
617
|
-
"application/json": {
|
|
618
|
-
/** @description Error message. */
|
|
619
|
-
error: string;
|
|
620
|
-
};
|
|
621
|
-
};
|
|
622
|
-
};
|
|
623
|
-
};
|
|
624
|
-
};
|
|
641
|
+
delete?: never;
|
|
625
642
|
options?: never;
|
|
626
643
|
head?: never;
|
|
627
644
|
patch?: never;
|
|
628
645
|
trace?: never;
|
|
629
646
|
};
|
|
630
|
-
"/v1/
|
|
647
|
+
"/v1/customers/identify": {
|
|
631
648
|
parameters: {
|
|
632
649
|
query?: never;
|
|
633
650
|
header?: never;
|
|
@@ -1164,7 +1181,7 @@ interface paths {
|
|
|
1164
1181
|
patch?: never;
|
|
1165
1182
|
trace?: never;
|
|
1166
1183
|
};
|
|
1167
|
-
"/v1/
|
|
1184
|
+
"/v1/bonuses": {
|
|
1168
1185
|
parameters: {
|
|
1169
1186
|
query?: never;
|
|
1170
1187
|
header?: never;
|
|
@@ -1804,18 +1821,21 @@ type WithFeatureAccess<T, TFeatureAccessMap> = T extends {
|
|
|
1804
1821
|
} ? Omit<T, "featureAccess"> & {
|
|
1805
1822
|
featureAccess: TFeatureAccessMap;
|
|
1806
1823
|
} : T;
|
|
1807
|
-
type GetCustomerResponseBase = paths["/v1/
|
|
1824
|
+
type GetCustomerResponseBase = paths["/v1/customers/{customerId}"]["get"]["responses"][200]["content"]["application/json"];
|
|
1808
1825
|
type GetCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<GetCustomerResponseBase, TFeatureAccessMap>;
|
|
1809
|
-
type CreateCustomerRequest = paths["/v1/
|
|
1810
|
-
type CreateCustomerResponseBase = paths["/v1/
|
|
1826
|
+
type CreateCustomerRequest = paths["/v1/customers"]["post"]["requestBody"]["content"]["application/json"];
|
|
1827
|
+
type CreateCustomerResponseBase = paths["/v1/customers"]["post"]["responses"][201]["content"]["application/json"];
|
|
1811
1828
|
type CreateCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<CreateCustomerResponseBase, TFeatureAccessMap>;
|
|
1812
|
-
type
|
|
1813
|
-
type
|
|
1829
|
+
type UpdateCustomerBodyBase = paths["/v1/customers/{customerId}"]["put"]["requestBody"]["content"]["application/json"];
|
|
1830
|
+
type UpdateCustomerBody = UpdateCustomerBodyBase & {
|
|
1831
|
+
customerId: string;
|
|
1832
|
+
};
|
|
1833
|
+
type UpdateCustomerResponseBase = paths["/v1/customers/{customerId}"]["put"]["responses"][200]["content"]["application/json"];
|
|
1814
1834
|
type UpdateCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<UpdateCustomerResponseBase, TFeatureAccessMap>;
|
|
1815
|
-
type DeleteCustomerRequest = paths["/v1/
|
|
1816
|
-
type DeleteCustomerResponse = paths["/v1/
|
|
1817
|
-
type IdentifyCustomerBody = paths["/v1/
|
|
1818
|
-
type IdentifyCustomerResponseBase = paths["/v1/
|
|
1835
|
+
type DeleteCustomerRequest = paths["/v1/customers/{customerId}"]["delete"]["parameters"]["path"];
|
|
1836
|
+
type DeleteCustomerResponse = paths["/v1/customers/{customerId}"]["delete"]["responses"][200]["content"]["application/json"];
|
|
1837
|
+
type IdentifyCustomerBody = paths["/v1/customers/identify"]["post"]["requestBody"]["content"]["application/json"];
|
|
1838
|
+
type IdentifyCustomerResponseBase = paths["/v1/customers/identify"]["post"]["responses"][200]["content"]["application/json"];
|
|
1819
1839
|
type IdentifyCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<IdentifyCustomerResponseBase, TFeatureAccessMap>;
|
|
1820
1840
|
type GetFeatureAccessResponse = paths["/v1/feature-access"]["get"]["responses"][200]["content"]["application/json"];
|
|
1821
1841
|
type LimitFeatureKeyFromAccessMap<TFeatureAccessMap> = TFeatureAccessMap extends {
|
|
@@ -1830,11 +1850,11 @@ type TrackUsageBody<TFeatureKey extends string = TrackUsageBodyBase["featureKey"
|
|
|
1830
1850
|
featureKey: TFeatureKey;
|
|
1831
1851
|
};
|
|
1832
1852
|
type TrackUsageResponse = paths["/v1/usage"]["post"]["responses"][200]["content"]["application/json"];
|
|
1833
|
-
type GrantBonusBodyBase = paths["/v1/
|
|
1853
|
+
type GrantBonusBodyBase = paths["/v1/bonuses"]["post"]["requestBody"]["content"]["application/json"];
|
|
1834
1854
|
type GrantBonusBody<TFeatureKey extends string = GrantBonusBodyBase["featureKey"]> = Omit<GrantBonusBodyBase, "featureKey"> & {
|
|
1835
1855
|
featureKey: TFeatureKey;
|
|
1836
1856
|
};
|
|
1837
|
-
type GrantBonusResponse = paths["/v1/
|
|
1857
|
+
type GrantBonusResponse = paths["/v1/bonuses"]["post"]["responses"][200]["content"]["application/json"];
|
|
1838
1858
|
type ResetUsageBodyBase = paths["/v1/usage/void"]["post"]["requestBody"]["content"]["application/json"];
|
|
1839
1859
|
type ResetUsageBody<TFeatureKey extends string = NonNullable<ResetUsageBodyBase["featureKey"]>> = Omit<ResetUsageBodyBase, "featureKey"> & {
|
|
1840
1860
|
featureKey?: TFeatureKey;
|
|
@@ -1875,9 +1895,11 @@ type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
|
1875
1895
|
type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1876
1896
|
getAccess(customerId: string): Promise<TFeatureAccessMap>;
|
|
1877
1897
|
};
|
|
1898
|
+
type PriceOSBonusesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1899
|
+
grant(input: GrantBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<GrantBonusResponse>;
|
|
1900
|
+
};
|
|
1878
1901
|
type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1879
1902
|
track(input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<TrackUsageResponse>;
|
|
1880
|
-
grantBonus(input: GrantBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<GrantBonusResponse>;
|
|
1881
1903
|
reset(input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<ResetUsageResponse>;
|
|
1882
1904
|
deleteEvents(input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<DeleteUsageEventsResponse>;
|
|
1883
1905
|
trackBatch(input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<TrackUsageBatchResponse>;
|
|
@@ -1886,6 +1908,7 @@ type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
|
1886
1908
|
type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1887
1909
|
customers: PriceOSCustomersClient<TFeatureAccessMap>;
|
|
1888
1910
|
features: PriceOSFeaturesClient<TFeatureAccessMap>;
|
|
1911
|
+
bonuses: PriceOSBonusesClient<TFeatureAccessMap>;
|
|
1889
1912
|
usage: PriceOSUsageClient<TFeatureAccessMap>;
|
|
1890
1913
|
};
|
|
1891
1914
|
declare class PriceOSError extends Error {
|
|
@@ -1902,8 +1925,9 @@ declare class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse> implements P
|
|
|
1902
1925
|
private log;
|
|
1903
1926
|
customers: PriceOSCustomersClient<TFeatureAccessMap>;
|
|
1904
1927
|
features: PriceOSFeaturesClient<TFeatureAccessMap>;
|
|
1928
|
+
bonuses: PriceOSBonusesClient<TFeatureAccessMap>;
|
|
1905
1929
|
usage: PriceOSUsageClient<TFeatureAccessMap>;
|
|
1906
1930
|
constructor(apiKey: string, opts?: PriceOSClientOptions);
|
|
1907
1931
|
}
|
|
1908
1932
|
|
|
1909
|
-
export { type CreateCustomerRequest, type CreateCustomerResponse, type DeleteCustomerRequest, type DeleteCustomerResponse, type DeleteUsageEventsBody, type DeleteUsageEventsResponse, type GetCustomerResponse, type GetFeatureAccessResponse, type GrantBonusBody, type GrantBonusResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, type LimitFeatureKeyFromAccessMap, type ListUsageEventsBody, type ListUsageEventsResponse, PriceOS, type PriceOSClientOptions, type PriceOSCustomersClient, PriceOSError, type PriceOSFeaturesClient, type PriceOSHttpClient, type PriceOSLogLevel, type PriceOSUsageClient, type ResetUsageBody, type ResetUsageResponse, type TrackUsageBatchBody, type TrackUsageBatchEvent, type TrackUsageBatchResponse, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse, type UsageEvent };
|
|
1933
|
+
export { type CreateCustomerRequest, type CreateCustomerResponse, type DeleteCustomerRequest, type DeleteCustomerResponse, type DeleteUsageEventsBody, type DeleteUsageEventsResponse, type GetCustomerResponse, type GetFeatureAccessResponse, type GrantBonusBody, type GrantBonusResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, type LimitFeatureKeyFromAccessMap, type ListUsageEventsBody, type ListUsageEventsResponse, PriceOS, type PriceOSBonusesClient, type PriceOSClientOptions, type PriceOSCustomersClient, PriceOSError, type PriceOSFeaturesClient, type PriceOSHttpClient, type PriceOSLogLevel, type PriceOSUsageClient, type ResetUsageBody, type ResetUsageResponse, type TrackUsageBatchBody, type TrackUsageBatchEvent, type TrackUsageBatchResponse, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse, type UsageEvent };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
interface paths {
|
|
7
|
-
"/v1/
|
|
7
|
+
"/v1/customers/{customerId}": {
|
|
8
8
|
parameters: {
|
|
9
9
|
query?: never;
|
|
10
10
|
header?: never;
|
|
@@ -17,15 +17,15 @@ interface paths {
|
|
|
17
17
|
*/
|
|
18
18
|
get: {
|
|
19
19
|
parameters: {
|
|
20
|
-
query
|
|
21
|
-
/** @description Customer ID (internal or Stripe). */
|
|
22
|
-
customerId: string;
|
|
23
|
-
};
|
|
20
|
+
query?: never;
|
|
24
21
|
header: {
|
|
25
22
|
/** @description API key from your PriceOS dashboard. */
|
|
26
23
|
"x-api-key": string;
|
|
27
24
|
};
|
|
28
|
-
path
|
|
25
|
+
path: {
|
|
26
|
+
/** @description Customer ID (internal or Stripe). */
|
|
27
|
+
customerId: string;
|
|
28
|
+
};
|
|
29
29
|
cookie?: never;
|
|
30
30
|
};
|
|
31
31
|
requestBody?: never;
|
|
@@ -184,14 +184,15 @@ interface paths {
|
|
|
184
184
|
/** @description API key from your PriceOS dashboard. */
|
|
185
185
|
"x-api-key": string;
|
|
186
186
|
};
|
|
187
|
-
path
|
|
187
|
+
path: {
|
|
188
|
+
/** @description Customer ID (internal or Stripe). */
|
|
189
|
+
customerId: string;
|
|
190
|
+
};
|
|
188
191
|
cookie?: never;
|
|
189
192
|
};
|
|
190
193
|
requestBody: {
|
|
191
194
|
content: {
|
|
192
195
|
"application/json": {
|
|
193
|
-
/** @description Customer ID (internal or Stripe). */
|
|
194
|
-
customerId: string;
|
|
195
196
|
/** @description Customer name. */
|
|
196
197
|
name?: string;
|
|
197
198
|
/** @description Customer email address. */
|
|
@@ -357,6 +358,102 @@ interface paths {
|
|
|
357
358
|
};
|
|
358
359
|
};
|
|
359
360
|
};
|
|
361
|
+
post?: never;
|
|
362
|
+
/**
|
|
363
|
+
* Delete customer
|
|
364
|
+
* @description Delete a customer record.
|
|
365
|
+
*/
|
|
366
|
+
delete: {
|
|
367
|
+
parameters: {
|
|
368
|
+
query?: never;
|
|
369
|
+
header: {
|
|
370
|
+
/** @description API key from your PriceOS dashboard. */
|
|
371
|
+
"x-api-key": string;
|
|
372
|
+
};
|
|
373
|
+
path: {
|
|
374
|
+
/** @description Customer ID (internal or Stripe). */
|
|
375
|
+
customerId: string;
|
|
376
|
+
};
|
|
377
|
+
cookie?: never;
|
|
378
|
+
};
|
|
379
|
+
requestBody?: never;
|
|
380
|
+
responses: {
|
|
381
|
+
/** @description Customer deleted */
|
|
382
|
+
200: {
|
|
383
|
+
headers: {
|
|
384
|
+
[name: string]: unknown;
|
|
385
|
+
};
|
|
386
|
+
content: {
|
|
387
|
+
"application/json": {
|
|
388
|
+
/** @description Deleted customer record ID. */
|
|
389
|
+
id: string;
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
/** @description Bad request */
|
|
394
|
+
400: {
|
|
395
|
+
headers: {
|
|
396
|
+
[name: string]: unknown;
|
|
397
|
+
};
|
|
398
|
+
content: {
|
|
399
|
+
"application/json": {
|
|
400
|
+
/** @description Error message. */
|
|
401
|
+
error: string;
|
|
402
|
+
};
|
|
403
|
+
};
|
|
404
|
+
};
|
|
405
|
+
/** @description Unauthorized */
|
|
406
|
+
401: {
|
|
407
|
+
headers: {
|
|
408
|
+
[name: string]: unknown;
|
|
409
|
+
};
|
|
410
|
+
content: {
|
|
411
|
+
"application/json": {
|
|
412
|
+
/** @description Error message. */
|
|
413
|
+
error: string;
|
|
414
|
+
};
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
/** @description Not found */
|
|
418
|
+
404: {
|
|
419
|
+
headers: {
|
|
420
|
+
[name: string]: unknown;
|
|
421
|
+
};
|
|
422
|
+
content: {
|
|
423
|
+
"application/json": {
|
|
424
|
+
/** @description Error message. */
|
|
425
|
+
error: string;
|
|
426
|
+
};
|
|
427
|
+
};
|
|
428
|
+
};
|
|
429
|
+
/** @description Server error */
|
|
430
|
+
500: {
|
|
431
|
+
headers: {
|
|
432
|
+
[name: string]: unknown;
|
|
433
|
+
};
|
|
434
|
+
content: {
|
|
435
|
+
"application/json": {
|
|
436
|
+
/** @description Error message. */
|
|
437
|
+
error: string;
|
|
438
|
+
};
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
options?: never;
|
|
444
|
+
head?: never;
|
|
445
|
+
patch?: never;
|
|
446
|
+
trace?: never;
|
|
447
|
+
};
|
|
448
|
+
"/v1/customers": {
|
|
449
|
+
parameters: {
|
|
450
|
+
query?: never;
|
|
451
|
+
header?: never;
|
|
452
|
+
path?: never;
|
|
453
|
+
cookie?: never;
|
|
454
|
+
};
|
|
455
|
+
get?: never;
|
|
456
|
+
put?: never;
|
|
360
457
|
/**
|
|
361
458
|
* Create customer
|
|
362
459
|
* @description Create a customer record.
|
|
@@ -541,93 +638,13 @@ interface paths {
|
|
|
541
638
|
};
|
|
542
639
|
};
|
|
543
640
|
};
|
|
544
|
-
|
|
545
|
-
* Delete customer
|
|
546
|
-
* @description Delete a customer record.
|
|
547
|
-
*/
|
|
548
|
-
delete: {
|
|
549
|
-
parameters: {
|
|
550
|
-
query: {
|
|
551
|
-
/** @description Customer ID (internal or Stripe). */
|
|
552
|
-
customerId: string;
|
|
553
|
-
};
|
|
554
|
-
header: {
|
|
555
|
-
/** @description API key from your PriceOS dashboard. */
|
|
556
|
-
"x-api-key": string;
|
|
557
|
-
};
|
|
558
|
-
path?: never;
|
|
559
|
-
cookie?: never;
|
|
560
|
-
};
|
|
561
|
-
requestBody?: never;
|
|
562
|
-
responses: {
|
|
563
|
-
/** @description Customer deleted */
|
|
564
|
-
200: {
|
|
565
|
-
headers: {
|
|
566
|
-
[name: string]: unknown;
|
|
567
|
-
};
|
|
568
|
-
content: {
|
|
569
|
-
"application/json": {
|
|
570
|
-
/** @description Deleted customer record ID. */
|
|
571
|
-
id: string;
|
|
572
|
-
};
|
|
573
|
-
};
|
|
574
|
-
};
|
|
575
|
-
/** @description Bad request */
|
|
576
|
-
400: {
|
|
577
|
-
headers: {
|
|
578
|
-
[name: string]: unknown;
|
|
579
|
-
};
|
|
580
|
-
content: {
|
|
581
|
-
"application/json": {
|
|
582
|
-
/** @description Error message. */
|
|
583
|
-
error: string;
|
|
584
|
-
};
|
|
585
|
-
};
|
|
586
|
-
};
|
|
587
|
-
/** @description Unauthorized */
|
|
588
|
-
401: {
|
|
589
|
-
headers: {
|
|
590
|
-
[name: string]: unknown;
|
|
591
|
-
};
|
|
592
|
-
content: {
|
|
593
|
-
"application/json": {
|
|
594
|
-
/** @description Error message. */
|
|
595
|
-
error: string;
|
|
596
|
-
};
|
|
597
|
-
};
|
|
598
|
-
};
|
|
599
|
-
/** @description Not found */
|
|
600
|
-
404: {
|
|
601
|
-
headers: {
|
|
602
|
-
[name: string]: unknown;
|
|
603
|
-
};
|
|
604
|
-
content: {
|
|
605
|
-
"application/json": {
|
|
606
|
-
/** @description Error message. */
|
|
607
|
-
error: string;
|
|
608
|
-
};
|
|
609
|
-
};
|
|
610
|
-
};
|
|
611
|
-
/** @description Server error */
|
|
612
|
-
500: {
|
|
613
|
-
headers: {
|
|
614
|
-
[name: string]: unknown;
|
|
615
|
-
};
|
|
616
|
-
content: {
|
|
617
|
-
"application/json": {
|
|
618
|
-
/** @description Error message. */
|
|
619
|
-
error: string;
|
|
620
|
-
};
|
|
621
|
-
};
|
|
622
|
-
};
|
|
623
|
-
};
|
|
624
|
-
};
|
|
641
|
+
delete?: never;
|
|
625
642
|
options?: never;
|
|
626
643
|
head?: never;
|
|
627
644
|
patch?: never;
|
|
628
645
|
trace?: never;
|
|
629
646
|
};
|
|
630
|
-
"/v1/
|
|
647
|
+
"/v1/customers/identify": {
|
|
631
648
|
parameters: {
|
|
632
649
|
query?: never;
|
|
633
650
|
header?: never;
|
|
@@ -1164,7 +1181,7 @@ interface paths {
|
|
|
1164
1181
|
patch?: never;
|
|
1165
1182
|
trace?: never;
|
|
1166
1183
|
};
|
|
1167
|
-
"/v1/
|
|
1184
|
+
"/v1/bonuses": {
|
|
1168
1185
|
parameters: {
|
|
1169
1186
|
query?: never;
|
|
1170
1187
|
header?: never;
|
|
@@ -1804,18 +1821,21 @@ type WithFeatureAccess<T, TFeatureAccessMap> = T extends {
|
|
|
1804
1821
|
} ? Omit<T, "featureAccess"> & {
|
|
1805
1822
|
featureAccess: TFeatureAccessMap;
|
|
1806
1823
|
} : T;
|
|
1807
|
-
type GetCustomerResponseBase = paths["/v1/
|
|
1824
|
+
type GetCustomerResponseBase = paths["/v1/customers/{customerId}"]["get"]["responses"][200]["content"]["application/json"];
|
|
1808
1825
|
type GetCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<GetCustomerResponseBase, TFeatureAccessMap>;
|
|
1809
|
-
type CreateCustomerRequest = paths["/v1/
|
|
1810
|
-
type CreateCustomerResponseBase = paths["/v1/
|
|
1826
|
+
type CreateCustomerRequest = paths["/v1/customers"]["post"]["requestBody"]["content"]["application/json"];
|
|
1827
|
+
type CreateCustomerResponseBase = paths["/v1/customers"]["post"]["responses"][201]["content"]["application/json"];
|
|
1811
1828
|
type CreateCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<CreateCustomerResponseBase, TFeatureAccessMap>;
|
|
1812
|
-
type
|
|
1813
|
-
type
|
|
1829
|
+
type UpdateCustomerBodyBase = paths["/v1/customers/{customerId}"]["put"]["requestBody"]["content"]["application/json"];
|
|
1830
|
+
type UpdateCustomerBody = UpdateCustomerBodyBase & {
|
|
1831
|
+
customerId: string;
|
|
1832
|
+
};
|
|
1833
|
+
type UpdateCustomerResponseBase = paths["/v1/customers/{customerId}"]["put"]["responses"][200]["content"]["application/json"];
|
|
1814
1834
|
type UpdateCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<UpdateCustomerResponseBase, TFeatureAccessMap>;
|
|
1815
|
-
type DeleteCustomerRequest = paths["/v1/
|
|
1816
|
-
type DeleteCustomerResponse = paths["/v1/
|
|
1817
|
-
type IdentifyCustomerBody = paths["/v1/
|
|
1818
|
-
type IdentifyCustomerResponseBase = paths["/v1/
|
|
1835
|
+
type DeleteCustomerRequest = paths["/v1/customers/{customerId}"]["delete"]["parameters"]["path"];
|
|
1836
|
+
type DeleteCustomerResponse = paths["/v1/customers/{customerId}"]["delete"]["responses"][200]["content"]["application/json"];
|
|
1837
|
+
type IdentifyCustomerBody = paths["/v1/customers/identify"]["post"]["requestBody"]["content"]["application/json"];
|
|
1838
|
+
type IdentifyCustomerResponseBase = paths["/v1/customers/identify"]["post"]["responses"][200]["content"]["application/json"];
|
|
1819
1839
|
type IdentifyCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<IdentifyCustomerResponseBase, TFeatureAccessMap>;
|
|
1820
1840
|
type GetFeatureAccessResponse = paths["/v1/feature-access"]["get"]["responses"][200]["content"]["application/json"];
|
|
1821
1841
|
type LimitFeatureKeyFromAccessMap<TFeatureAccessMap> = TFeatureAccessMap extends {
|
|
@@ -1830,11 +1850,11 @@ type TrackUsageBody<TFeatureKey extends string = TrackUsageBodyBase["featureKey"
|
|
|
1830
1850
|
featureKey: TFeatureKey;
|
|
1831
1851
|
};
|
|
1832
1852
|
type TrackUsageResponse = paths["/v1/usage"]["post"]["responses"][200]["content"]["application/json"];
|
|
1833
|
-
type GrantBonusBodyBase = paths["/v1/
|
|
1853
|
+
type GrantBonusBodyBase = paths["/v1/bonuses"]["post"]["requestBody"]["content"]["application/json"];
|
|
1834
1854
|
type GrantBonusBody<TFeatureKey extends string = GrantBonusBodyBase["featureKey"]> = Omit<GrantBonusBodyBase, "featureKey"> & {
|
|
1835
1855
|
featureKey: TFeatureKey;
|
|
1836
1856
|
};
|
|
1837
|
-
type GrantBonusResponse = paths["/v1/
|
|
1857
|
+
type GrantBonusResponse = paths["/v1/bonuses"]["post"]["responses"][200]["content"]["application/json"];
|
|
1838
1858
|
type ResetUsageBodyBase = paths["/v1/usage/void"]["post"]["requestBody"]["content"]["application/json"];
|
|
1839
1859
|
type ResetUsageBody<TFeatureKey extends string = NonNullable<ResetUsageBodyBase["featureKey"]>> = Omit<ResetUsageBodyBase, "featureKey"> & {
|
|
1840
1860
|
featureKey?: TFeatureKey;
|
|
@@ -1875,9 +1895,11 @@ type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
|
1875
1895
|
type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1876
1896
|
getAccess(customerId: string): Promise<TFeatureAccessMap>;
|
|
1877
1897
|
};
|
|
1898
|
+
type PriceOSBonusesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1899
|
+
grant(input: GrantBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<GrantBonusResponse>;
|
|
1900
|
+
};
|
|
1878
1901
|
type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1879
1902
|
track(input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<TrackUsageResponse>;
|
|
1880
|
-
grantBonus(input: GrantBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<GrantBonusResponse>;
|
|
1881
1903
|
reset(input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<ResetUsageResponse>;
|
|
1882
1904
|
deleteEvents(input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<DeleteUsageEventsResponse>;
|
|
1883
1905
|
trackBatch(input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<TrackUsageBatchResponse>;
|
|
@@ -1886,6 +1908,7 @@ type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
|
1886
1908
|
type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1887
1909
|
customers: PriceOSCustomersClient<TFeatureAccessMap>;
|
|
1888
1910
|
features: PriceOSFeaturesClient<TFeatureAccessMap>;
|
|
1911
|
+
bonuses: PriceOSBonusesClient<TFeatureAccessMap>;
|
|
1889
1912
|
usage: PriceOSUsageClient<TFeatureAccessMap>;
|
|
1890
1913
|
};
|
|
1891
1914
|
declare class PriceOSError extends Error {
|
|
@@ -1902,8 +1925,9 @@ declare class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse> implements P
|
|
|
1902
1925
|
private log;
|
|
1903
1926
|
customers: PriceOSCustomersClient<TFeatureAccessMap>;
|
|
1904
1927
|
features: PriceOSFeaturesClient<TFeatureAccessMap>;
|
|
1928
|
+
bonuses: PriceOSBonusesClient<TFeatureAccessMap>;
|
|
1905
1929
|
usage: PriceOSUsageClient<TFeatureAccessMap>;
|
|
1906
1930
|
constructor(apiKey: string, opts?: PriceOSClientOptions);
|
|
1907
1931
|
}
|
|
1908
1932
|
|
|
1909
|
-
export { type CreateCustomerRequest, type CreateCustomerResponse, type DeleteCustomerRequest, type DeleteCustomerResponse, type DeleteUsageEventsBody, type DeleteUsageEventsResponse, type GetCustomerResponse, type GetFeatureAccessResponse, type GrantBonusBody, type GrantBonusResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, type LimitFeatureKeyFromAccessMap, type ListUsageEventsBody, type ListUsageEventsResponse, PriceOS, type PriceOSClientOptions, type PriceOSCustomersClient, PriceOSError, type PriceOSFeaturesClient, type PriceOSHttpClient, type PriceOSLogLevel, type PriceOSUsageClient, type ResetUsageBody, type ResetUsageResponse, type TrackUsageBatchBody, type TrackUsageBatchEvent, type TrackUsageBatchResponse, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse, type UsageEvent };
|
|
1933
|
+
export { type CreateCustomerRequest, type CreateCustomerResponse, type DeleteCustomerRequest, type DeleteCustomerResponse, type DeleteUsageEventsBody, type DeleteUsageEventsResponse, type GetCustomerResponse, type GetFeatureAccessResponse, type GrantBonusBody, type GrantBonusResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, type LimitFeatureKeyFromAccessMap, type ListUsageEventsBody, type ListUsageEventsResponse, PriceOS, type PriceOSBonusesClient, type PriceOSClientOptions, type PriceOSCustomersClient, PriceOSError, type PriceOSFeaturesClient, type PriceOSHttpClient, type PriceOSLogLevel, type PriceOSUsageClient, type ResetUsageBody, type ResetUsageResponse, type TrackUsageBatchBody, type TrackUsageBatchEvent, type TrackUsageBatchResponse, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse, type UsageEvent };
|
package/dist/index.js
CHANGED
|
@@ -189,6 +189,7 @@ var PriceOS = class {
|
|
|
189
189
|
log;
|
|
190
190
|
customers;
|
|
191
191
|
features;
|
|
192
|
+
bonuses;
|
|
192
193
|
usage;
|
|
193
194
|
constructor(apiKey, opts = {}) {
|
|
194
195
|
const logLevel = opts.logLevel ?? "none";
|
|
@@ -205,41 +206,42 @@ var PriceOS = class {
|
|
|
205
206
|
});
|
|
206
207
|
this.customers = {
|
|
207
208
|
get: async (customerId) => {
|
|
208
|
-
const { data, error, response } = await this.client.GET("/v1/
|
|
209
|
-
params: {
|
|
209
|
+
const { data, error, response } = await this.client.GET("/v1/customers/{customerId}", {
|
|
210
|
+
params: { path: { customerId }, header: this.header }
|
|
210
211
|
});
|
|
211
|
-
if (error) throwRequestError(this.log, error, response, "GET /v1/
|
|
212
|
+
if (error) throwRequestError(this.log, error, response, "GET /v1/customers/{customerId}");
|
|
212
213
|
return data ?? null;
|
|
213
214
|
},
|
|
214
215
|
identify: async (input) => {
|
|
215
|
-
const { data, error, response } = await this.client.POST("/v1/
|
|
216
|
+
const { data, error, response } = await this.client.POST("/v1/customers/identify", {
|
|
216
217
|
params: { header: this.header },
|
|
217
218
|
body: input
|
|
218
219
|
});
|
|
219
|
-
if (error) throwRequestError(this.log, error, response, "POST /v1/
|
|
220
|
+
if (error) throwRequestError(this.log, error, response, "POST /v1/customers/identify");
|
|
220
221
|
return data ?? null;
|
|
221
222
|
},
|
|
222
223
|
create: async (input) => {
|
|
223
|
-
const { data, error, response } = await this.client.POST("/v1/
|
|
224
|
+
const { data, error, response } = await this.client.POST("/v1/customers", {
|
|
224
225
|
params: { header: this.header },
|
|
225
226
|
body: input
|
|
226
227
|
});
|
|
227
|
-
if (error) throwRequestError(this.log, error, response, "POST /v1/
|
|
228
|
+
if (error) throwRequestError(this.log, error, response, "POST /v1/customers");
|
|
228
229
|
return data;
|
|
229
230
|
},
|
|
230
231
|
update: async (input) => {
|
|
231
|
-
const {
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
const { customerId, ...body } = input;
|
|
233
|
+
const { data, error, response } = await this.client.PUT("/v1/customers/{customerId}", {
|
|
234
|
+
params: { path: { customerId }, header: this.header },
|
|
235
|
+
body
|
|
234
236
|
});
|
|
235
|
-
if (error) throwRequestError(this.log, error, response, "PUT /v1/
|
|
237
|
+
if (error) throwRequestError(this.log, error, response, "PUT /v1/customers/{customerId}");
|
|
236
238
|
return data;
|
|
237
239
|
},
|
|
238
240
|
delete: async (customerId) => {
|
|
239
|
-
const { data, error, response } = await this.client.DELETE("/v1/
|
|
240
|
-
params: {
|
|
241
|
+
const { data, error, response } = await this.client.DELETE("/v1/customers/{customerId}", {
|
|
242
|
+
params: { path: { customerId }, header: this.header }
|
|
241
243
|
});
|
|
242
|
-
if (error) throwRequestError(this.log, error, response, "DELETE /v1/
|
|
244
|
+
if (error) throwRequestError(this.log, error, response, "DELETE /v1/customers/{customerId}");
|
|
243
245
|
return data;
|
|
244
246
|
}
|
|
245
247
|
};
|
|
@@ -252,21 +254,23 @@ var PriceOS = class {
|
|
|
252
254
|
return data;
|
|
253
255
|
}
|
|
254
256
|
};
|
|
255
|
-
this.
|
|
256
|
-
|
|
257
|
-
const { data, error, response } = await this.client.POST("/v1/
|
|
257
|
+
this.bonuses = {
|
|
258
|
+
grant: async (input) => {
|
|
259
|
+
const { data, error, response } = await this.client.POST("/v1/bonuses", {
|
|
258
260
|
params: { header: this.header },
|
|
259
261
|
body: input
|
|
260
262
|
});
|
|
261
|
-
if (error) throwRequestError(this.log, error, response, "POST /v1/
|
|
263
|
+
if (error) throwRequestError(this.log, error, response, "POST /v1/bonuses");
|
|
262
264
|
return data;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
this.usage = {
|
|
268
|
+
track: async (input) => {
|
|
269
|
+
const { data, error, response } = await this.client.POST("/v1/usage", {
|
|
266
270
|
params: { header: this.header },
|
|
267
271
|
body: input
|
|
268
272
|
});
|
|
269
|
-
if (error) throwRequestError(this.log, error, response, "POST /v1/usage
|
|
273
|
+
if (error) throwRequestError(this.log, error, response, "POST /v1/usage");
|
|
270
274
|
return data;
|
|
271
275
|
},
|
|
272
276
|
reset: async (input) => {
|
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 CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteUsageEventsBody,\n DeleteUsageEventsResponse,\n DeleteCustomerResponse,\n GrantBonusBody,\n GrantBonusResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n ListUsageEventsBody,\n ListUsageEventsResponse,\n ResetUsageBody,\n ResetUsageResponse,\n TrackUsageBody,\n TrackUsageBatchBody,\n TrackUsageBatchResponse,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\nexport type PriceOSLogLevel = \"none\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n logLevel?: PriceOSLogLevel;\n};\n\nconst RATE_LIMIT_STATUS = 429;\nconst MAX_RETRIES = 4;\nconst BASE_DELAY_MS = 250;\nconst BACKOFF_MULTIPLIER = 2;\nconst JITTER_MS = 250;\nconst RETRY_DELAY_CAP_MS = 5_000;\nconst REQUEST_TIMEOUT_MS = 20_000;\n\nconst LOG_LEVELS: Record<PriceOSLogLevel, number> = {\n none: 0,\n error: 1,\n warning: 2,\n info: 3,\n debug: 4,\n};\n\ntype Logger = {\n error: (message: string, details?: Record<string, unknown>) => void;\n warning: (message: string, details?: Record<string, unknown>) => void;\n info: (message: string, details?: Record<string, unknown>) => void;\n debug: (message: string, details?: Record<string, unknown>) => void;\n};\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\nconst getRetryDelayMs = (retryCount: number): number => {\n const backoff = BASE_DELAY_MS * Math.pow(BACKOFF_MULTIPLIER, retryCount - 1);\n const jitter = Math.random() * JITTER_MS;\n return Math.min(RETRY_DELAY_CAP_MS, backoff + jitter);\n};\n\nconst createLogger = (logLevel: PriceOSLogLevel): Logger => {\n const shouldLog = (level: PriceOSLogLevel): boolean =>\n logLevel !== \"none\" && LOG_LEVELS[level] <= LOG_LEVELS[logLevel];\n\n const write = (\n level: PriceOSLogLevel,\n message: string,\n details?: Record<string, unknown>\n ): void => {\n if (!shouldLog(level)) return;\n const prefix = `[PriceOS] ${level.toUpperCase()}: ${message}`;\n const payload = details && Object.keys(details).length > 0 ? details : undefined;\n\n switch (level) {\n case \"error\":\n payload ? console.error(prefix, payload) : console.error(prefix);\n return;\n case \"warning\":\n payload ? console.warn(prefix, payload) : console.warn(prefix);\n return;\n case \"info\":\n payload ? console.info(prefix, payload) : console.info(prefix);\n return;\n case \"debug\":\n payload ? console.debug(prefix, payload) : console.debug(prefix);\n return;\n }\n };\n\n return {\n error: (message, details) => write(\"error\", message, details),\n warning: (message, details) => write(\"warning\", message, details),\n info: (message, details) => write(\"info\", message, details),\n debug: (message, details) => write(\"debug\", message, details),\n };\n};\n\nconst getUpstreamSignal = (input: RequestInfo | URL, init?: RequestInit): AbortSignal | undefined => {\n if (init?.signal) return init.signal;\n if (typeof Request !== \"undefined\" && input instanceof Request) return input.signal;\n return undefined;\n};\n\nconst stripSignal = (init?: RequestInit): RequestInit | undefined => {\n if (!init) return undefined;\n const { signal: _signal, ...rest } = init;\n return rest;\n};\n\nconst getRequestDetails = (\n input: RequestInfo | URL,\n init?: RequestInit\n): { method: string; url: string } => {\n const method =\n init?.method ??\n (typeof Request !== \"undefined\" && input instanceof Request ? input.method : \"GET\");\n const url =\n typeof input === \"string\"\n ? input\n : input instanceof URL\n ? input.toString()\n : input.url;\n return { method, url };\n};\n\nconst prepareRetryRequest = async (\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n log: Logger,\n method: string,\n url: string\n): Promise<{ requestInput: RequestInfo | URL; baseInit?: RequestInit; canRetry: boolean }> => {\n if (!(typeof Request !== \"undefined\" && input instanceof Request)) {\n return { requestInput: input, baseInit: stripSignal(init), canRetry: true };\n }\n\n if (input.bodyUsed) {\n log.warning(\"Request body already used; retries disabled\", { method, url });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n\n let body: BodyInit | undefined = undefined;\n if (method !== \"GET\" && method !== \"HEAD\") {\n try {\n body = await input.clone().arrayBuffer();\n } catch (error) {\n log.warning(\"Unable to clone request body; retries disabled\", { method, url, error });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n }\n\n const headers = new Headers(input.headers);\n const baseInit = { ...stripSignal(init), method, headers, body };\n return { requestInput: input.url, baseInit, canRetry: true };\n};\n\nconst getErrorMessage = (error: unknown): string => {\n const maybeError = error as { error?: unknown } | null;\n if (maybeError && typeof maybeError.error === \"string\") return maybeError.error;\n return \"Request failed\";\n};\n\nconst throwRequestError = (\n log: Logger,\n error: unknown,\n response: Response | undefined,\n context: string\n): never => {\n log.error(\"Request failed\", { context, status: response?.status, error });\n throw new PriceOSError(getErrorMessage(error), { status: response?.status, details: error });\n};\n\nconst createRetryingFetch = (baseFetch: typeof fetch, log: Logger): typeof fetch => {\n return async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {\n const { method, url } = getRequestDetails(input, init);\n const upstreamSignal = getUpstreamSignal(input, init);\n const { requestInput, baseInit, canRetry } = await prepareRetryRequest(\n input,\n init,\n log,\n method,\n url\n );\n let attempt = 0;\n while (true) {\n log.debug(\"Request attempt\", { method, url, attempt: attempt + 1, maxRetries: MAX_RETRIES });\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);\n let removeAbortListener: (() => void) | null = null;\n\n if (upstreamSignal) {\n if (upstreamSignal.aborted) {\n controller.abort();\n } else {\n const onAbort = () => controller.abort();\n upstreamSignal.addEventListener(\"abort\", onAbort);\n removeAbortListener = () => upstreamSignal.removeEventListener(\"abort\", onAbort);\n }\n }\n\n try {\n const requestInit = { ...(baseInit ?? {}), signal: controller.signal };\n const response = await baseFetch(requestInput, requestInit);\n if (response.status !== RATE_LIMIT_STATUS) return response;\n\n const retryAfter = response.headers.get(\"retry-after\") ?? undefined;\n log.warning(\"Rate limit hit (429)\", {\n method,\n url,\n attempt: attempt + 1,\n maxRetries: MAX_RETRIES,\n retryAfter,\n });\n\n if (!canRetry) {\n log.warning(\"Skipping retry because request body is not replayable\", { method, url });\n return response;\n }\n\n if (attempt >= MAX_RETRIES) {\n log.error(\"Rate limit retries exhausted\", { method, url, attempts: attempt + 1 });\n return response;\n }\n\n const delayMs = getRetryDelayMs(attempt + 1);\n log.info(\"Waiting to retry after rate limit\", {\n method,\n url,\n delayMs,\n nextAttempt: attempt + 2,\n maxRetries: MAX_RETRIES,\n });\n await sleep(delayMs);\n attempt += 1;\n } catch (error) {\n if (controller.signal.aborted) {\n const abortedByCaller = upstreamSignal?.aborted ?? false;\n if (abortedByCaller) {\n log.warning(\"Request aborted by caller\", { method, url, attempt: attempt + 1 });\n } else {\n log.error(\"Request timed out\", {\n method,\n url,\n attempt: attempt + 1,\n timeoutMs: REQUEST_TIMEOUT_MS,\n });\n }\n } else {\n log.error(\"Request failed\", { method, url, attempt: attempt + 1, error });\n }\n throw error;\n } finally {\n clearTimeout(timeoutId);\n removeAbortListener?.();\n }\n }\n };\n};\n\nexport type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;\n 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<TFeatureAccessMap = GetFeatureAccessResponse> = {\n track(\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse>;\n grantBonus(\n input: GrantBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<GrantBonusResponse>;\n reset(\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse>;\n deleteEvents(\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse>;\n trackBatch(\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse>;\n listEvents(\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse>;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n};\n\nexport class PriceOSError extends Error {\n status?: number;\n details?: unknown;\n\n constructor(message: string, opts?: { status?: number; details?: unknown }) {\n super(message);\n this.name = \"PriceOSError\";\n this.status = opts?.status;\n this.details = opts?.details;\n }\n}\n\nexport class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse>\n implements PriceOSHttpClient<TFeatureAccessMap>\n{\n private client: Client<paths>;\n private header: { \"x-api-key\": string };\n private log: Logger;\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n\n constructor(apiKey: string, opts: PriceOSClientOptions = {}) {\n const logLevel = opts.logLevel ?? \"none\";\n this.log = createLogger(logLevel);\n const baseUrl = \"https://api.priceos.com\";\n this.header = { \"x-api-key\": apiKey };\n const fetchWithRetry = createRetryingFetch(fetch, this.log);\n this.client = createClient<paths>({\n baseUrl,\n fetch: fetchWithRetry,\n headers: {\n \"x-api-key\": apiKey,\n },\n });\n\n this.customers = {\n get: async (customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.GET(\"/v1/customer\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/customer\");\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) throwRequestError(this.log, error, response, \"POST /v1/customer/identify\");\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) throwRequestError(this.log, error, response, \"POST /v1/customer\");\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) throwRequestError(this.log, error, response, \"PUT /v1/customer\");\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) throwRequestError(this.log, error, response, \"DELETE /v1/customer\");\n return data! as DeleteCustomerResponse;\n },\n };\n\n this.features = {\n getAccess: async (customerId: string): Promise<TFeatureAccessMap> => {\n const { data, error, response } = await this.client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/feature-access\");\n return data! as TFeatureAccessMap;\n },\n };\n\n this.usage = {\n track: async (\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage\");\n return data!;\n },\n grantBonus: async (\n input: GrantBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<GrantBonusResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/bonus/grant\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/bonus/grant\");\n return data!;\n },\n reset: async (\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/void\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/void\");\n return data!;\n },\n deleteEvents: async (\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/delete\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/delete\");\n return data!;\n },\n trackBatch: async (\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/batch\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/batch\");\n return data!;\n },\n listEvents: async (\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/events\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/events\");\n return data!;\n },\n };\n }\n}\n"],"mappings":";AAAA,OAAO,kBAAkB;AAmCzB,IAAM,oBAAoB;AAC1B,IAAM,cAAc;AACpB,IAAM,gBAAgB;AACtB,IAAM,qBAAqB;AAC3B,IAAM,YAAY;AAClB,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAE3B,IAAM,aAA8C;AAAA,EAClD,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACT;AASA,IAAM,QAAQ,CAAC,OAA8B,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAE7F,IAAM,kBAAkB,CAAC,eAA+B;AACtD,QAAM,UAAU,gBAAgB,KAAK,IAAI,oBAAoB,aAAa,CAAC;AAC3E,QAAM,SAAS,KAAK,OAAO,IAAI;AAC/B,SAAO,KAAK,IAAI,oBAAoB,UAAU,MAAM;AACtD;AAEA,IAAM,eAAe,CAAC,aAAsC;AAC1D,QAAM,YAAY,CAAC,UACjB,aAAa,UAAU,WAAW,KAAK,KAAK,WAAW,QAAQ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,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,kBAAkB;AAAA,UACzE,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,qBAAqB;AAC7E,eAAO;AAAA,MACT;AAAA,MACA,cAAc,OACZ,UACuC;AACvC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,oBAAoB;AAAA,UAC3E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,MACA,YAAY,OACV,UACqC;AACrC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,mBAAmB;AAAA,UAC1E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,sBAAsB;AAC9E,eAAO;AAAA,MACT;AAAA,MACA,YAAY,OACV,UACqC;AACrC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,oBAAoB;AAAA,UAC3E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
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 DeleteUsageEventsBody,\n DeleteUsageEventsResponse,\n DeleteCustomerResponse,\n GrantBonusBody,\n GrantBonusResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n ListUsageEventsBody,\n ListUsageEventsResponse,\n ResetUsageBody,\n ResetUsageResponse,\n TrackUsageBody,\n TrackUsageBatchBody,\n TrackUsageBatchResponse,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\nexport type PriceOSLogLevel = \"none\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n logLevel?: PriceOSLogLevel;\n};\n\nconst RATE_LIMIT_STATUS = 429;\nconst MAX_RETRIES = 4;\nconst BASE_DELAY_MS = 250;\nconst BACKOFF_MULTIPLIER = 2;\nconst JITTER_MS = 250;\nconst RETRY_DELAY_CAP_MS = 5_000;\nconst REQUEST_TIMEOUT_MS = 20_000;\n\nconst LOG_LEVELS: Record<PriceOSLogLevel, number> = {\n none: 0,\n error: 1,\n warning: 2,\n info: 3,\n debug: 4,\n};\n\ntype Logger = {\n error: (message: string, details?: Record<string, unknown>) => void;\n warning: (message: string, details?: Record<string, unknown>) => void;\n info: (message: string, details?: Record<string, unknown>) => void;\n debug: (message: string, details?: Record<string, unknown>) => void;\n};\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\nconst getRetryDelayMs = (retryCount: number): number => {\n const backoff = BASE_DELAY_MS * Math.pow(BACKOFF_MULTIPLIER, retryCount - 1);\n const jitter = Math.random() * JITTER_MS;\n return Math.min(RETRY_DELAY_CAP_MS, backoff + jitter);\n};\n\nconst createLogger = (logLevel: PriceOSLogLevel): Logger => {\n const shouldLog = (level: PriceOSLogLevel): boolean =>\n logLevel !== \"none\" && LOG_LEVELS[level] <= LOG_LEVELS[logLevel];\n\n const write = (\n level: PriceOSLogLevel,\n message: string,\n details?: Record<string, unknown>\n ): void => {\n if (!shouldLog(level)) return;\n const prefix = `[PriceOS] ${level.toUpperCase()}: ${message}`;\n const payload = details && Object.keys(details).length > 0 ? details : undefined;\n\n switch (level) {\n case \"error\":\n payload ? console.error(prefix, payload) : console.error(prefix);\n return;\n case \"warning\":\n payload ? console.warn(prefix, payload) : console.warn(prefix);\n return;\n case \"info\":\n payload ? console.info(prefix, payload) : console.info(prefix);\n return;\n case \"debug\":\n payload ? console.debug(prefix, payload) : console.debug(prefix);\n return;\n }\n };\n\n return {\n error: (message, details) => write(\"error\", message, details),\n warning: (message, details) => write(\"warning\", message, details),\n info: (message, details) => write(\"info\", message, details),\n debug: (message, details) => write(\"debug\", message, details),\n };\n};\n\nconst getUpstreamSignal = (input: RequestInfo | URL, init?: RequestInit): AbortSignal | undefined => {\n if (init?.signal) return init.signal;\n if (typeof Request !== \"undefined\" && input instanceof Request) return input.signal;\n return undefined;\n};\n\nconst stripSignal = (init?: RequestInit): RequestInit | undefined => {\n if (!init) return undefined;\n const { signal: _signal, ...rest } = init;\n return rest;\n};\n\nconst getRequestDetails = (\n input: RequestInfo | URL,\n init?: RequestInit\n): { method: string; url: string } => {\n const method =\n init?.method ??\n (typeof Request !== \"undefined\" && input instanceof Request ? input.method : \"GET\");\n const url =\n typeof input === \"string\"\n ? input\n : input instanceof URL\n ? input.toString()\n : input.url;\n return { method, url };\n};\n\nconst prepareRetryRequest = async (\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n log: Logger,\n method: string,\n url: string\n): Promise<{ requestInput: RequestInfo | URL; baseInit?: RequestInit; canRetry: boolean }> => {\n if (!(typeof Request !== \"undefined\" && input instanceof Request)) {\n return { requestInput: input, baseInit: stripSignal(init), canRetry: true };\n }\n\n if (input.bodyUsed) {\n log.warning(\"Request body already used; retries disabled\", { method, url });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n\n let body: BodyInit | undefined = undefined;\n if (method !== \"GET\" && method !== \"HEAD\") {\n try {\n body = await input.clone().arrayBuffer();\n } catch (error) {\n log.warning(\"Unable to clone request body; retries disabled\", { method, url, error });\n return { requestInput: input, baseInit: stripSignal(init), canRetry: false };\n }\n }\n\n const headers = new Headers(input.headers);\n const baseInit = { ...stripSignal(init), method, headers, body };\n return { requestInput: input.url, baseInit, canRetry: true };\n};\n\nconst getErrorMessage = (error: unknown): string => {\n const maybeError = error as { error?: unknown } | null;\n if (maybeError && typeof maybeError.error === \"string\") return maybeError.error;\n return \"Request failed\";\n};\n\nconst throwRequestError = (\n log: Logger,\n error: unknown,\n response: Response | undefined,\n context: string\n): never => {\n log.error(\"Request failed\", { context, status: response?.status, error });\n throw new PriceOSError(getErrorMessage(error), { status: response?.status, details: error });\n};\n\nconst createRetryingFetch = (baseFetch: typeof fetch, log: Logger): typeof fetch => {\n return async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {\n const { method, url } = getRequestDetails(input, init);\n const upstreamSignal = getUpstreamSignal(input, init);\n const { requestInput, baseInit, canRetry } = await prepareRetryRequest(\n input,\n init,\n log,\n method,\n url\n );\n let attempt = 0;\n while (true) {\n log.debug(\"Request attempt\", { method, url, attempt: attempt + 1, maxRetries: MAX_RETRIES });\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);\n let removeAbortListener: (() => void) | null = null;\n\n if (upstreamSignal) {\n if (upstreamSignal.aborted) {\n controller.abort();\n } else {\n const onAbort = () => controller.abort();\n upstreamSignal.addEventListener(\"abort\", onAbort);\n removeAbortListener = () => upstreamSignal.removeEventListener(\"abort\", onAbort);\n }\n }\n\n try {\n const requestInit = { ...(baseInit ?? {}), signal: controller.signal };\n const response = await baseFetch(requestInput, requestInit);\n if (response.status !== RATE_LIMIT_STATUS) return response;\n\n const retryAfter = response.headers.get(\"retry-after\") ?? undefined;\n log.warning(\"Rate limit hit (429)\", {\n method,\n url,\n attempt: attempt + 1,\n maxRetries: MAX_RETRIES,\n retryAfter,\n });\n\n if (!canRetry) {\n log.warning(\"Skipping retry because request body is not replayable\", { method, url });\n return response;\n }\n\n if (attempt >= MAX_RETRIES) {\n log.error(\"Rate limit retries exhausted\", { method, url, attempts: attempt + 1 });\n return response;\n }\n\n const delayMs = getRetryDelayMs(attempt + 1);\n log.info(\"Waiting to retry after rate limit\", {\n method,\n url,\n delayMs,\n nextAttempt: attempt + 2,\n maxRetries: MAX_RETRIES,\n });\n await sleep(delayMs);\n attempt += 1;\n } catch (error) {\n if (controller.signal.aborted) {\n const abortedByCaller = upstreamSignal?.aborted ?? false;\n if (abortedByCaller) {\n log.warning(\"Request aborted by caller\", { method, url, attempt: attempt + 1 });\n } else {\n log.error(\"Request timed out\", {\n method,\n url,\n attempt: attempt + 1,\n timeoutMs: REQUEST_TIMEOUT_MS,\n });\n }\n } else {\n log.error(\"Request failed\", { method, url, attempt: attempt + 1, error });\n }\n throw error;\n } finally {\n clearTimeout(timeoutId);\n removeAbortListener?.();\n }\n }\n };\n};\n\nexport type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;\n 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 PriceOSBonusesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n grant(\n input: GrantBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<GrantBonusResponse>;\n};\n\nexport type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n track(\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse>;\n reset(\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse>;\n deleteEvents(\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse>;\n trackBatch(\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse>;\n listEvents(\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse>;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n bonuses: PriceOSBonusesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n};\n\nexport class PriceOSError extends Error {\n status?: number;\n details?: unknown;\n\n constructor(message: string, opts?: { status?: number; details?: unknown }) {\n super(message);\n this.name = \"PriceOSError\";\n this.status = opts?.status;\n this.details = opts?.details;\n }\n}\n\nexport class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse>\n implements PriceOSHttpClient<TFeatureAccessMap>\n{\n private client: Client<paths>;\n private header: { \"x-api-key\": string };\n private log: Logger;\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n bonuses: PriceOSBonusesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n\n constructor(apiKey: string, opts: PriceOSClientOptions = {}) {\n const logLevel = opts.logLevel ?? \"none\";\n this.log = createLogger(logLevel);\n const baseUrl = \"https://api.priceos.com\";\n this.header = { \"x-api-key\": apiKey };\n const fetchWithRetry = createRetryingFetch(fetch, this.log);\n this.client = createClient<paths>({\n baseUrl,\n fetch: fetchWithRetry,\n headers: {\n \"x-api-key\": apiKey,\n },\n });\n\n this.customers = {\n get: async (customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.GET(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/customers/{customerId}\");\n return (data ?? null) as GetCustomerResponse<TFeatureAccessMap> | null;\n },\n identify: async (\n input: IdentifyCustomerBody\n ): Promise<IdentifyCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.POST(\"/v1/customers/identify\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/customers/identify\");\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/customers\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/customers\");\n return data! as CreateCustomerResponse<TFeatureAccessMap>;\n },\n update: async (input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>> => {\n const { customerId, ...body } = input;\n const { data, error, response } = await this.client.PUT(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n body,\n });\n if (error) throwRequestError(this.log, error, response, \"PUT /v1/customers/{customerId}\");\n return data! as UpdateCustomerResponse<TFeatureAccessMap>;\n },\n delete: async (customerId: string): Promise<DeleteCustomerResponse> => {\n const { data, error, response } = await this.client.DELETE(\"/v1/customers/{customerId}\", {\n params: { path: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"DELETE /v1/customers/{customerId}\");\n return data! as DeleteCustomerResponse;\n },\n };\n\n this.features = {\n getAccess: async (customerId: string): Promise<TFeatureAccessMap> => {\n const { data, error, response } = await this.client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throwRequestError(this.log, error, response, \"GET /v1/feature-access\");\n return data! as TFeatureAccessMap;\n },\n };\n\n this.bonuses = {\n grant: async (\n input: GrantBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<GrantBonusResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/bonuses\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/bonuses\");\n return data!;\n },\n };\n\n this.usage = {\n track: async (\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage\");\n return data!;\n },\n reset: async (\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/void\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/void\");\n return data!;\n },\n deleteEvents: async (\n input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<DeleteUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/delete\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/delete\");\n return data!;\n },\n trackBatch: async (\n input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageBatchResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/batch\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/batch\");\n return data!;\n },\n listEvents: async (\n input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ListUsageEventsResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/events\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/events\");\n return data!;\n },\n };\n }\n}\n"],"mappings":";AAAA,OAAO,kBAAkB;AAmCzB,IAAM,oBAAoB;AAC1B,IAAM,cAAc;AACpB,IAAM,gBAAgB;AACtB,IAAM,qBAAqB;AAC3B,IAAM,YAAY;AAClB,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAE3B,IAAM,aAA8C;AAAA,EAClD,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACT;AASA,IAAM,QAAQ,CAAC,OAA8B,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAE7F,IAAM,kBAAkB,CAAC,eAA+B;AACtD,QAAM,UAAU,gBAAgB,KAAK,IAAI,oBAAoB,aAAa,CAAC;AAC3E,QAAM,SAAS,KAAK,OAAO,IAAI;AAC/B,SAAO,KAAK,IAAI,oBAAoB,UAAU,MAAM;AACtD;AAEA,IAAM,eAAe,CAAC,aAAsC;AAC1D,QAAM,YAAY,CAAC,UACjB,aAAa,UAAU,WAAW,KAAK,KAAK,WAAW,QAAQ;AAEjE,QAAM,QAAQ,CACZ,OACA,SACA,YACS;AACT,QAAI,CAAC,UAAU,KAAK,EAAG;AACvB,UAAM,SAAS,aAAa,MAAM,YAAY,CAAC,KAAK,OAAO;AAC3D,UAAM,UAAU,WAAW,OAAO,KAAK,OAAO,EAAE,SAAS,IAAI,UAAU;AAEvE,YAAQ,OAAO;AAAA,MACb,KAAK;AACH,kBAAU,QAAQ,MAAM,QAAQ,OAAO,IAAI,QAAQ,MAAM,MAAM;AAC/D;AAAA,MACF,KAAK;AACH,kBAAU,QAAQ,KAAK,QAAQ,OAAO,IAAI,QAAQ,KAAK,MAAM;AAC7D;AAAA,MACF,KAAK;AACH,kBAAU,QAAQ,KAAK,QAAQ,OAAO,IAAI,QAAQ,KAAK,MAAM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