priceos 0.0.35 → 0.0.37

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 CHANGED
@@ -298,12 +298,28 @@ var PriceOS = class {
298
298
  if (error) throwRequestError(this.log, error, response, "POST /v1/usage");
299
299
  return data;
300
300
  },
301
+ grantBonus: async (input) => {
302
+ const { data, error, response } = await this.client.POST("/v1/usage/bonus/grant", {
303
+ params: { header: this.header },
304
+ body: input
305
+ });
306
+ if (error) throwRequestError(this.log, error, response, "POST /v1/usage/bonus/grant");
307
+ return data;
308
+ },
301
309
  reset: async (input) => {
302
- const { data, error, response } = await this.client.POST("/v1/usage/reset", {
310
+ const { data, error, response } = await this.client.POST("/v1/usage/void", {
311
+ params: { header: this.header },
312
+ body: input
313
+ });
314
+ if (error) throwRequestError(this.log, error, response, "POST /v1/usage/void");
315
+ return data;
316
+ },
317
+ deleteEvents: async (input) => {
318
+ const { data, error, response } = await this.client.POST("/v1/usage/delete", {
303
319
  params: { header: this.header },
304
320
  body: input
305
321
  });
306
- if (error) throwRequestError(this.log, error, response, "POST /v1/usage/reset");
322
+ if (error) throwRequestError(this.log, error, response, "POST /v1/usage/delete");
307
323
  return data;
308
324
  },
309
325
  trackBatch: async (input) => {
@@ -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 DeleteCustomerRequest,\n DeleteCustomerResponse,\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 DeleteCustomerResponse,\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 reset(\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse>;\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 reset: async (\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/reset\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/reset\");\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;AA+BzB,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,oB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AAO,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,mBAAmB;AAAA,UAC1E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,sBAAsB;AAC9E,eAAO;AAAA,MACT;AAAA,MACA,YAAY,OACV,UACqC;AACrC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,oBAAoB;AAAA,UAC3E,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI,MAAO,mBAAkB,KAAK,KAAK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":["createClient"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/client.ts"],"sourcesContent":["export { PriceOS, PriceOSError } from \"./client\";\nexport type {\n PriceOSClientOptions,\n PriceOSLogLevel,\n 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;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,QA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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
@@ -54,10 +54,19 @@ interface paths {
54
54
  enviroment: "test" | "live";
55
55
  /** @description Subscribed or assigned products. */
56
56
  products: {
57
- /** @description PriceOS product ID. */
57
+ /** @description Product ID. */
58
58
  id: string;
59
+ /** @description Product key. */
60
+ key: string;
59
61
  /** @description Product name. */
60
62
  name: string;
63
+ /**
64
+ * @description Product type.
65
+ * @enum {string}
66
+ */
67
+ type: "stripe" | "custom";
68
+ /** @description Whether this product is the default custom product. */
69
+ isDefault: boolean;
61
70
  /**
62
71
  * @description Stripe subscription status (Stripe customers only).
63
72
  * @enum {string}
@@ -217,10 +226,19 @@ interface paths {
217
226
  enviroment: "test" | "live";
218
227
  /** @description Subscribed or assigned products. */
219
228
  products: {
220
- /** @description PriceOS product ID. */
229
+ /** @description Product ID. */
221
230
  id: string;
231
+ /** @description Product key. */
232
+ key: string;
222
233
  /** @description Product name. */
223
234
  name: string;
235
+ /**
236
+ * @description Product type.
237
+ * @enum {string}
238
+ */
239
+ type: "stripe" | "custom";
240
+ /** @description Whether this product is the default custom product. */
241
+ isDefault: boolean;
224
242
  /**
225
243
  * @description Stripe subscription status (Stripe customers only).
226
244
  * @enum {string}
@@ -392,10 +410,19 @@ interface paths {
392
410
  enviroment: "test" | "live";
393
411
  /** @description Subscribed or assigned products. */
394
412
  products: {
395
- /** @description PriceOS product ID. */
413
+ /** @description Product ID. */
396
414
  id: string;
415
+ /** @description Product key. */
416
+ key: string;
397
417
  /** @description Product name. */
398
418
  name: string;
419
+ /**
420
+ * @description Product type.
421
+ * @enum {string}
422
+ */
423
+ type: "stripe" | "custom";
424
+ /** @description Whether this product is the default custom product. */
425
+ isDefault: boolean;
399
426
  /**
400
427
  * @description Stripe subscription status (Stripe customers only).
401
428
  * @enum {string}
@@ -658,10 +685,19 @@ interface paths {
658
685
  enviroment: "test" | "live";
659
686
  /** @description Subscribed or assigned products. */
660
687
  products: {
661
- /** @description PriceOS product ID. */
688
+ /** @description Product ID. */
662
689
  id: string;
690
+ /** @description Product key. */
691
+ key: string;
663
692
  /** @description Product name. */
664
693
  name: string;
694
+ /**
695
+ * @description Product type.
696
+ * @enum {string}
697
+ */
698
+ type: "stripe" | "custom";
699
+ /** @description Whether this product is the default custom product. */
700
+ isDefault: boolean;
665
701
  /**
666
702
  * @description Stripe subscription status (Stripe customers only).
667
703
  * @enum {string}
@@ -1128,7 +1164,126 @@ interface paths {
1128
1164
  patch?: never;
1129
1165
  trace?: never;
1130
1166
  };
1131
- "/v1/usage/reset": {
1167
+ "/v1/usage/bonus/grant": {
1168
+ parameters: {
1169
+ query?: never;
1170
+ header?: never;
1171
+ path?: never;
1172
+ cookie?: never;
1173
+ };
1174
+ get?: never;
1175
+ put?: never;
1176
+ /**
1177
+ * Grant bonus
1178
+ * @description Grant a one-time bonus amount for a customer feature.
1179
+ */
1180
+ post: {
1181
+ parameters: {
1182
+ query?: never;
1183
+ header: {
1184
+ /** @description API key from your PriceOS dashboard. */
1185
+ "x-api-key": string;
1186
+ };
1187
+ path?: never;
1188
+ cookie?: never;
1189
+ };
1190
+ requestBody: {
1191
+ content: {
1192
+ "application/json": {
1193
+ /** @description Customer ID (internal or Stripe). */
1194
+ customerId: string;
1195
+ /** @description Feature key to grant bonus for. */
1196
+ featureKey: string;
1197
+ /** @description Bonus amount to grant. */
1198
+ amount: number;
1199
+ /** @description Optional Unix timestamp (ms) when the bonus expires. */
1200
+ expiresAt?: number;
1201
+ /** @description Optional reason for the bonus grant. */
1202
+ reason?: string | null;
1203
+ /** @description Optional metadata for the grant (string key/value pairs). */
1204
+ metadata?: {
1205
+ [key: string]: string;
1206
+ };
1207
+ };
1208
+ };
1209
+ };
1210
+ responses: {
1211
+ /** @description Bonus granted */
1212
+ 200: {
1213
+ headers: {
1214
+ [name: string]: unknown;
1215
+ };
1216
+ content: {
1217
+ "application/json": {
1218
+ /**
1219
+ * Format: uuid
1220
+ * @description Bonus grant ID.
1221
+ */
1222
+ grantId: string;
1223
+ /** @description Remaining amount for the newly created grant. */
1224
+ remainingAmount: number;
1225
+ /** @description Total remaining bonus amount for this customer + feature. */
1226
+ counterRemaining: number;
1227
+ };
1228
+ };
1229
+ };
1230
+ /** @description Bad request */
1231
+ 400: {
1232
+ headers: {
1233
+ [name: string]: unknown;
1234
+ };
1235
+ content: {
1236
+ "application/json": {
1237
+ /** @description Error message. */
1238
+ error: string;
1239
+ };
1240
+ };
1241
+ };
1242
+ /** @description Unauthorized */
1243
+ 401: {
1244
+ headers: {
1245
+ [name: string]: unknown;
1246
+ };
1247
+ content: {
1248
+ "application/json": {
1249
+ /** @description Error message. */
1250
+ error: string;
1251
+ };
1252
+ };
1253
+ };
1254
+ /** @description Not found */
1255
+ 404: {
1256
+ headers: {
1257
+ [name: string]: unknown;
1258
+ };
1259
+ content: {
1260
+ "application/json": {
1261
+ /** @description Error message. */
1262
+ error: string;
1263
+ };
1264
+ };
1265
+ };
1266
+ /** @description Server error */
1267
+ 500: {
1268
+ headers: {
1269
+ [name: string]: unknown;
1270
+ };
1271
+ content: {
1272
+ "application/json": {
1273
+ /** @description Error message. */
1274
+ error: string;
1275
+ };
1276
+ };
1277
+ };
1278
+ };
1279
+ };
1280
+ delete?: never;
1281
+ options?: never;
1282
+ head?: never;
1283
+ patch?: never;
1284
+ trace?: never;
1285
+ };
1286
+ "/v1/usage/void": {
1132
1287
  parameters: {
1133
1288
  query?: never;
1134
1289
  header?: never;
@@ -1158,6 +1313,13 @@ interface paths {
1158
1313
  customerId: string;
1159
1314
  /** @description Optional feature key to reset usage for. Omit to reset all usage for the customer. */
1160
1315
  featureKey?: string | null;
1316
+ /**
1317
+ * @description Optional usage period to reset (current or previous). Defaults to current.
1318
+ * @enum {string}
1319
+ */
1320
+ period?: "current" | "previous";
1321
+ /** @description Optional usage event IDs to reset. When provided, period and featureKey cannot be provided. */
1322
+ eventIds?: string[];
1161
1323
  /** @description Optional reason for the usage reset. */
1162
1324
  reason?: string | null;
1163
1325
  };
@@ -1232,6 +1394,122 @@ interface paths {
1232
1394
  patch?: never;
1233
1395
  trace?: never;
1234
1396
  };
1397
+ "/v1/usage/delete": {
1398
+ parameters: {
1399
+ query?: never;
1400
+ header?: never;
1401
+ path?: never;
1402
+ cookie?: never;
1403
+ };
1404
+ get?: never;
1405
+ put?: never;
1406
+ /**
1407
+ * Delete usage events
1408
+ * @description Delete usage events either by event IDs or by customer filters (customerId with optional featureKey and optional customRange or period).
1409
+ */
1410
+ post: {
1411
+ parameters: {
1412
+ query?: never;
1413
+ header: {
1414
+ /** @description API key from your PriceOS dashboard. */
1415
+ "x-api-key": string;
1416
+ };
1417
+ path?: never;
1418
+ cookie?: never;
1419
+ };
1420
+ requestBody: {
1421
+ content: {
1422
+ "application/json": {
1423
+ /** @description Customer ID (internal or Stripe). Required when deleting by filters instead of eventIds. */
1424
+ customerId?: string | null;
1425
+ /** @description Optional feature key to scope deletes. Only valid when customerId is provided. */
1426
+ featureKey?: string | null;
1427
+ /** @description Optional custom time range (Unix ms start/end) for deletes. Only valid with customerId. Mutually exclusive with period. */
1428
+ customRange?: {
1429
+ /** @description Unix timestamp (ms) start for the custom range. */
1430
+ start: number;
1431
+ /** @description Unix timestamp (ms) end for the custom range. */
1432
+ end: number;
1433
+ };
1434
+ /**
1435
+ * @description Optional usage period to delete for (current or previous). Only valid with customerId. Mutually exclusive with customRange.
1436
+ * @enum {string}
1437
+ */
1438
+ period?: "current" | "previous";
1439
+ /** @description Optional usage event IDs to delete directly. Cannot be combined with customerId filters. */
1440
+ eventIds?: string[];
1441
+ };
1442
+ };
1443
+ };
1444
+ responses: {
1445
+ /** @description Usage events deleted */
1446
+ 200: {
1447
+ headers: {
1448
+ [name: string]: unknown;
1449
+ };
1450
+ content: {
1451
+ "application/json": {
1452
+ /** @description Number of usage events deleted. */
1453
+ deletedCount: number;
1454
+ };
1455
+ };
1456
+ };
1457
+ /** @description Bad request */
1458
+ 400: {
1459
+ headers: {
1460
+ [name: string]: unknown;
1461
+ };
1462
+ content: {
1463
+ "application/json": {
1464
+ /** @description Error message. */
1465
+ error: string;
1466
+ };
1467
+ };
1468
+ };
1469
+ /** @description Unauthorized */
1470
+ 401: {
1471
+ headers: {
1472
+ [name: string]: unknown;
1473
+ };
1474
+ content: {
1475
+ "application/json": {
1476
+ /** @description Error message. */
1477
+ error: string;
1478
+ };
1479
+ };
1480
+ };
1481
+ /** @description Not found */
1482
+ 404: {
1483
+ headers: {
1484
+ [name: string]: unknown;
1485
+ };
1486
+ content: {
1487
+ "application/json": {
1488
+ /** @description Error message. */
1489
+ error: string;
1490
+ };
1491
+ };
1492
+ };
1493
+ /** @description Server error */
1494
+ 500: {
1495
+ headers: {
1496
+ [name: string]: unknown;
1497
+ };
1498
+ content: {
1499
+ "application/json": {
1500
+ /** @description Error message. */
1501
+ error: string;
1502
+ };
1503
+ };
1504
+ };
1505
+ };
1506
+ };
1507
+ delete?: never;
1508
+ options?: never;
1509
+ head?: never;
1510
+ patch?: never;
1511
+ trace?: never;
1512
+ };
1235
1513
  "/v1/usage/batch": {
1236
1514
  parameters: {
1237
1515
  query?: never;
@@ -1552,11 +1830,21 @@ type TrackUsageBody<TFeatureKey extends string = TrackUsageBodyBase["featureKey"
1552
1830
  featureKey: TFeatureKey;
1553
1831
  };
1554
1832
  type TrackUsageResponse = paths["/v1/usage"]["post"]["responses"][200]["content"]["application/json"];
1555
- type ResetUsageBodyBase = paths["/v1/usage/reset"]["post"]["requestBody"]["content"]["application/json"];
1833
+ type GrantBonusBodyBase = paths["/v1/usage/bonus/grant"]["post"]["requestBody"]["content"]["application/json"];
1834
+ type GrantBonusBody<TFeatureKey extends string = GrantBonusBodyBase["featureKey"]> = Omit<GrantBonusBodyBase, "featureKey"> & {
1835
+ featureKey: TFeatureKey;
1836
+ };
1837
+ type GrantBonusResponse = paths["/v1/usage/bonus/grant"]["post"]["responses"][200]["content"]["application/json"];
1838
+ type ResetUsageBodyBase = paths["/v1/usage/void"]["post"]["requestBody"]["content"]["application/json"];
1556
1839
  type ResetUsageBody<TFeatureKey extends string = NonNullable<ResetUsageBodyBase["featureKey"]>> = Omit<ResetUsageBodyBase, "featureKey"> & {
1557
1840
  featureKey?: TFeatureKey;
1558
1841
  };
1559
- type ResetUsageResponse = paths["/v1/usage/reset"]["post"]["responses"][200]["content"]["application/json"];
1842
+ type ResetUsageResponse = paths["/v1/usage/void"]["post"]["responses"][200]["content"]["application/json"];
1843
+ type DeleteUsageEventsBodyBase = paths["/v1/usage/delete"]["post"]["requestBody"]["content"]["application/json"];
1844
+ type DeleteUsageEventsBody<TFeatureKey extends string = NonNullable<DeleteUsageEventsBodyBase["featureKey"]>> = Omit<DeleteUsageEventsBodyBase, "featureKey"> & {
1845
+ featureKey?: TFeatureKey;
1846
+ };
1847
+ type DeleteUsageEventsResponse = paths["/v1/usage/delete"]["post"]["responses"][200]["content"]["application/json"];
1560
1848
  type TrackUsageBatchBodyBase = paths["/v1/usage/batch"]["post"]["requestBody"]["content"]["application/json"];
1561
1849
  type TrackUsageBatchEventBase = TrackUsageBatchBodyBase["events"][number];
1562
1850
  type TrackUsageBatchEvent<TFeatureKey extends string = TrackUsageBatchEventBase["featureKey"]> = Omit<TrackUsageBatchEventBase, "featureKey"> & {
@@ -1589,7 +1877,9 @@ type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
1589
1877
  };
1590
1878
  type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
1591
1879
  track(input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<TrackUsageResponse>;
1880
+ grantBonus(input: GrantBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<GrantBonusResponse>;
1592
1881
  reset(input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<ResetUsageResponse>;
1882
+ deleteEvents(input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<DeleteUsageEventsResponse>;
1593
1883
  trackBatch(input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<TrackUsageBatchResponse>;
1594
1884
  listEvents(input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<ListUsageEventsResponse>;
1595
1885
  };
@@ -1616,4 +1906,4 @@ declare class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse> implements P
1616
1906
  constructor(apiKey: string, opts?: PriceOSClientOptions);
1617
1907
  }
1618
1908
 
1619
- export { type CreateCustomerRequest, type CreateCustomerResponse, type DeleteCustomerRequest, type DeleteCustomerResponse, type GetCustomerResponse, type GetFeatureAccessResponse, 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -54,10 +54,19 @@ interface paths {
54
54
  enviroment: "test" | "live";
55
55
  /** @description Subscribed or assigned products. */
56
56
  products: {
57
- /** @description PriceOS product ID. */
57
+ /** @description Product ID. */
58
58
  id: string;
59
+ /** @description Product key. */
60
+ key: string;
59
61
  /** @description Product name. */
60
62
  name: string;
63
+ /**
64
+ * @description Product type.
65
+ * @enum {string}
66
+ */
67
+ type: "stripe" | "custom";
68
+ /** @description Whether this product is the default custom product. */
69
+ isDefault: boolean;
61
70
  /**
62
71
  * @description Stripe subscription status (Stripe customers only).
63
72
  * @enum {string}
@@ -217,10 +226,19 @@ interface paths {
217
226
  enviroment: "test" | "live";
218
227
  /** @description Subscribed or assigned products. */
219
228
  products: {
220
- /** @description PriceOS product ID. */
229
+ /** @description Product ID. */
221
230
  id: string;
231
+ /** @description Product key. */
232
+ key: string;
222
233
  /** @description Product name. */
223
234
  name: string;
235
+ /**
236
+ * @description Product type.
237
+ * @enum {string}
238
+ */
239
+ type: "stripe" | "custom";
240
+ /** @description Whether this product is the default custom product. */
241
+ isDefault: boolean;
224
242
  /**
225
243
  * @description Stripe subscription status (Stripe customers only).
226
244
  * @enum {string}
@@ -392,10 +410,19 @@ interface paths {
392
410
  enviroment: "test" | "live";
393
411
  /** @description Subscribed or assigned products. */
394
412
  products: {
395
- /** @description PriceOS product ID. */
413
+ /** @description Product ID. */
396
414
  id: string;
415
+ /** @description Product key. */
416
+ key: string;
397
417
  /** @description Product name. */
398
418
  name: string;
419
+ /**
420
+ * @description Product type.
421
+ * @enum {string}
422
+ */
423
+ type: "stripe" | "custom";
424
+ /** @description Whether this product is the default custom product. */
425
+ isDefault: boolean;
399
426
  /**
400
427
  * @description Stripe subscription status (Stripe customers only).
401
428
  * @enum {string}
@@ -658,10 +685,19 @@ interface paths {
658
685
  enviroment: "test" | "live";
659
686
  /** @description Subscribed or assigned products. */
660
687
  products: {
661
- /** @description PriceOS product ID. */
688
+ /** @description Product ID. */
662
689
  id: string;
690
+ /** @description Product key. */
691
+ key: string;
663
692
  /** @description Product name. */
664
693
  name: string;
694
+ /**
695
+ * @description Product type.
696
+ * @enum {string}
697
+ */
698
+ type: "stripe" | "custom";
699
+ /** @description Whether this product is the default custom product. */
700
+ isDefault: boolean;
665
701
  /**
666
702
  * @description Stripe subscription status (Stripe customers only).
667
703
  * @enum {string}
@@ -1128,7 +1164,126 @@ interface paths {
1128
1164
  patch?: never;
1129
1165
  trace?: never;
1130
1166
  };
1131
- "/v1/usage/reset": {
1167
+ "/v1/usage/bonus/grant": {
1168
+ parameters: {
1169
+ query?: never;
1170
+ header?: never;
1171
+ path?: never;
1172
+ cookie?: never;
1173
+ };
1174
+ get?: never;
1175
+ put?: never;
1176
+ /**
1177
+ * Grant bonus
1178
+ * @description Grant a one-time bonus amount for a customer feature.
1179
+ */
1180
+ post: {
1181
+ parameters: {
1182
+ query?: never;
1183
+ header: {
1184
+ /** @description API key from your PriceOS dashboard. */
1185
+ "x-api-key": string;
1186
+ };
1187
+ path?: never;
1188
+ cookie?: never;
1189
+ };
1190
+ requestBody: {
1191
+ content: {
1192
+ "application/json": {
1193
+ /** @description Customer ID (internal or Stripe). */
1194
+ customerId: string;
1195
+ /** @description Feature key to grant bonus for. */
1196
+ featureKey: string;
1197
+ /** @description Bonus amount to grant. */
1198
+ amount: number;
1199
+ /** @description Optional Unix timestamp (ms) when the bonus expires. */
1200
+ expiresAt?: number;
1201
+ /** @description Optional reason for the bonus grant. */
1202
+ reason?: string | null;
1203
+ /** @description Optional metadata for the grant (string key/value pairs). */
1204
+ metadata?: {
1205
+ [key: string]: string;
1206
+ };
1207
+ };
1208
+ };
1209
+ };
1210
+ responses: {
1211
+ /** @description Bonus granted */
1212
+ 200: {
1213
+ headers: {
1214
+ [name: string]: unknown;
1215
+ };
1216
+ content: {
1217
+ "application/json": {
1218
+ /**
1219
+ * Format: uuid
1220
+ * @description Bonus grant ID.
1221
+ */
1222
+ grantId: string;
1223
+ /** @description Remaining amount for the newly created grant. */
1224
+ remainingAmount: number;
1225
+ /** @description Total remaining bonus amount for this customer + feature. */
1226
+ counterRemaining: number;
1227
+ };
1228
+ };
1229
+ };
1230
+ /** @description Bad request */
1231
+ 400: {
1232
+ headers: {
1233
+ [name: string]: unknown;
1234
+ };
1235
+ content: {
1236
+ "application/json": {
1237
+ /** @description Error message. */
1238
+ error: string;
1239
+ };
1240
+ };
1241
+ };
1242
+ /** @description Unauthorized */
1243
+ 401: {
1244
+ headers: {
1245
+ [name: string]: unknown;
1246
+ };
1247
+ content: {
1248
+ "application/json": {
1249
+ /** @description Error message. */
1250
+ error: string;
1251
+ };
1252
+ };
1253
+ };
1254
+ /** @description Not found */
1255
+ 404: {
1256
+ headers: {
1257
+ [name: string]: unknown;
1258
+ };
1259
+ content: {
1260
+ "application/json": {
1261
+ /** @description Error message. */
1262
+ error: string;
1263
+ };
1264
+ };
1265
+ };
1266
+ /** @description Server error */
1267
+ 500: {
1268
+ headers: {
1269
+ [name: string]: unknown;
1270
+ };
1271
+ content: {
1272
+ "application/json": {
1273
+ /** @description Error message. */
1274
+ error: string;
1275
+ };
1276
+ };
1277
+ };
1278
+ };
1279
+ };
1280
+ delete?: never;
1281
+ options?: never;
1282
+ head?: never;
1283
+ patch?: never;
1284
+ trace?: never;
1285
+ };
1286
+ "/v1/usage/void": {
1132
1287
  parameters: {
1133
1288
  query?: never;
1134
1289
  header?: never;
@@ -1158,6 +1313,13 @@ interface paths {
1158
1313
  customerId: string;
1159
1314
  /** @description Optional feature key to reset usage for. Omit to reset all usage for the customer. */
1160
1315
  featureKey?: string | null;
1316
+ /**
1317
+ * @description Optional usage period to reset (current or previous). Defaults to current.
1318
+ * @enum {string}
1319
+ */
1320
+ period?: "current" | "previous";
1321
+ /** @description Optional usage event IDs to reset. When provided, period and featureKey cannot be provided. */
1322
+ eventIds?: string[];
1161
1323
  /** @description Optional reason for the usage reset. */
1162
1324
  reason?: string | null;
1163
1325
  };
@@ -1232,6 +1394,122 @@ interface paths {
1232
1394
  patch?: never;
1233
1395
  trace?: never;
1234
1396
  };
1397
+ "/v1/usage/delete": {
1398
+ parameters: {
1399
+ query?: never;
1400
+ header?: never;
1401
+ path?: never;
1402
+ cookie?: never;
1403
+ };
1404
+ get?: never;
1405
+ put?: never;
1406
+ /**
1407
+ * Delete usage events
1408
+ * @description Delete usage events either by event IDs or by customer filters (customerId with optional featureKey and optional customRange or period).
1409
+ */
1410
+ post: {
1411
+ parameters: {
1412
+ query?: never;
1413
+ header: {
1414
+ /** @description API key from your PriceOS dashboard. */
1415
+ "x-api-key": string;
1416
+ };
1417
+ path?: never;
1418
+ cookie?: never;
1419
+ };
1420
+ requestBody: {
1421
+ content: {
1422
+ "application/json": {
1423
+ /** @description Customer ID (internal or Stripe). Required when deleting by filters instead of eventIds. */
1424
+ customerId?: string | null;
1425
+ /** @description Optional feature key to scope deletes. Only valid when customerId is provided. */
1426
+ featureKey?: string | null;
1427
+ /** @description Optional custom time range (Unix ms start/end) for deletes. Only valid with customerId. Mutually exclusive with period. */
1428
+ customRange?: {
1429
+ /** @description Unix timestamp (ms) start for the custom range. */
1430
+ start: number;
1431
+ /** @description Unix timestamp (ms) end for the custom range. */
1432
+ end: number;
1433
+ };
1434
+ /**
1435
+ * @description Optional usage period to delete for (current or previous). Only valid with customerId. Mutually exclusive with customRange.
1436
+ * @enum {string}
1437
+ */
1438
+ period?: "current" | "previous";
1439
+ /** @description Optional usage event IDs to delete directly. Cannot be combined with customerId filters. */
1440
+ eventIds?: string[];
1441
+ };
1442
+ };
1443
+ };
1444
+ responses: {
1445
+ /** @description Usage events deleted */
1446
+ 200: {
1447
+ headers: {
1448
+ [name: string]: unknown;
1449
+ };
1450
+ content: {
1451
+ "application/json": {
1452
+ /** @description Number of usage events deleted. */
1453
+ deletedCount: number;
1454
+ };
1455
+ };
1456
+ };
1457
+ /** @description Bad request */
1458
+ 400: {
1459
+ headers: {
1460
+ [name: string]: unknown;
1461
+ };
1462
+ content: {
1463
+ "application/json": {
1464
+ /** @description Error message. */
1465
+ error: string;
1466
+ };
1467
+ };
1468
+ };
1469
+ /** @description Unauthorized */
1470
+ 401: {
1471
+ headers: {
1472
+ [name: string]: unknown;
1473
+ };
1474
+ content: {
1475
+ "application/json": {
1476
+ /** @description Error message. */
1477
+ error: string;
1478
+ };
1479
+ };
1480
+ };
1481
+ /** @description Not found */
1482
+ 404: {
1483
+ headers: {
1484
+ [name: string]: unknown;
1485
+ };
1486
+ content: {
1487
+ "application/json": {
1488
+ /** @description Error message. */
1489
+ error: string;
1490
+ };
1491
+ };
1492
+ };
1493
+ /** @description Server error */
1494
+ 500: {
1495
+ headers: {
1496
+ [name: string]: unknown;
1497
+ };
1498
+ content: {
1499
+ "application/json": {
1500
+ /** @description Error message. */
1501
+ error: string;
1502
+ };
1503
+ };
1504
+ };
1505
+ };
1506
+ };
1507
+ delete?: never;
1508
+ options?: never;
1509
+ head?: never;
1510
+ patch?: never;
1511
+ trace?: never;
1512
+ };
1235
1513
  "/v1/usage/batch": {
1236
1514
  parameters: {
1237
1515
  query?: never;
@@ -1552,11 +1830,21 @@ type TrackUsageBody<TFeatureKey extends string = TrackUsageBodyBase["featureKey"
1552
1830
  featureKey: TFeatureKey;
1553
1831
  };
1554
1832
  type TrackUsageResponse = paths["/v1/usage"]["post"]["responses"][200]["content"]["application/json"];
1555
- type ResetUsageBodyBase = paths["/v1/usage/reset"]["post"]["requestBody"]["content"]["application/json"];
1833
+ type GrantBonusBodyBase = paths["/v1/usage/bonus/grant"]["post"]["requestBody"]["content"]["application/json"];
1834
+ type GrantBonusBody<TFeatureKey extends string = GrantBonusBodyBase["featureKey"]> = Omit<GrantBonusBodyBase, "featureKey"> & {
1835
+ featureKey: TFeatureKey;
1836
+ };
1837
+ type GrantBonusResponse = paths["/v1/usage/bonus/grant"]["post"]["responses"][200]["content"]["application/json"];
1838
+ type ResetUsageBodyBase = paths["/v1/usage/void"]["post"]["requestBody"]["content"]["application/json"];
1556
1839
  type ResetUsageBody<TFeatureKey extends string = NonNullable<ResetUsageBodyBase["featureKey"]>> = Omit<ResetUsageBodyBase, "featureKey"> & {
1557
1840
  featureKey?: TFeatureKey;
1558
1841
  };
1559
- type ResetUsageResponse = paths["/v1/usage/reset"]["post"]["responses"][200]["content"]["application/json"];
1842
+ type ResetUsageResponse = paths["/v1/usage/void"]["post"]["responses"][200]["content"]["application/json"];
1843
+ type DeleteUsageEventsBodyBase = paths["/v1/usage/delete"]["post"]["requestBody"]["content"]["application/json"];
1844
+ type DeleteUsageEventsBody<TFeatureKey extends string = NonNullable<DeleteUsageEventsBodyBase["featureKey"]>> = Omit<DeleteUsageEventsBodyBase, "featureKey"> & {
1845
+ featureKey?: TFeatureKey;
1846
+ };
1847
+ type DeleteUsageEventsResponse = paths["/v1/usage/delete"]["post"]["responses"][200]["content"]["application/json"];
1560
1848
  type TrackUsageBatchBodyBase = paths["/v1/usage/batch"]["post"]["requestBody"]["content"]["application/json"];
1561
1849
  type TrackUsageBatchEventBase = TrackUsageBatchBodyBase["events"][number];
1562
1850
  type TrackUsageBatchEvent<TFeatureKey extends string = TrackUsageBatchEventBase["featureKey"]> = Omit<TrackUsageBatchEventBase, "featureKey"> & {
@@ -1589,7 +1877,9 @@ type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
1589
1877
  };
1590
1878
  type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
1591
1879
  track(input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<TrackUsageResponse>;
1880
+ grantBonus(input: GrantBonusBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<GrantBonusResponse>;
1592
1881
  reset(input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<ResetUsageResponse>;
1882
+ deleteEvents(input: DeleteUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<DeleteUsageEventsResponse>;
1593
1883
  trackBatch(input: TrackUsageBatchBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<TrackUsageBatchResponse>;
1594
1884
  listEvents(input: ListUsageEventsBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<ListUsageEventsResponse>;
1595
1885
  };
@@ -1616,4 +1906,4 @@ declare class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse> implements P
1616
1906
  constructor(apiKey: string, opts?: PriceOSClientOptions);
1617
1907
  }
1618
1908
 
1619
- export { type CreateCustomerRequest, type CreateCustomerResponse, type DeleteCustomerRequest, type DeleteCustomerResponse, type GetCustomerResponse, type GetFeatureAccessResponse, 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 };
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 };
package/dist/index.js CHANGED
@@ -261,12 +261,28 @@ var PriceOS = class {
261
261
  if (error) throwRequestError(this.log, error, response, "POST /v1/usage");
262
262
  return data;
263
263
  },
264
+ grantBonus: async (input) => {
265
+ const { data, error, response } = await this.client.POST("/v1/usage/bonus/grant", {
266
+ params: { header: this.header },
267
+ body: input
268
+ });
269
+ if (error) throwRequestError(this.log, error, response, "POST /v1/usage/bonus/grant");
270
+ return data;
271
+ },
264
272
  reset: async (input) => {
265
- const { data, error, response } = await this.client.POST("/v1/usage/reset", {
273
+ const { data, error, response } = await this.client.POST("/v1/usage/void", {
274
+ params: { header: this.header },
275
+ body: input
276
+ });
277
+ if (error) throwRequestError(this.log, error, response, "POST /v1/usage/void");
278
+ return data;
279
+ },
280
+ deleteEvents: async (input) => {
281
+ const { data, error, response } = await this.client.POST("/v1/usage/delete", {
266
282
  params: { header: this.header },
267
283
  body: input
268
284
  });
269
- if (error) throwRequestError(this.log, error, response, "POST /v1/usage/reset");
285
+ if (error) throwRequestError(this.log, error, response, "POST /v1/usage/delete");
270
286
  return data;
271
287
  },
272
288
  trackBatch: 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 DeleteCustomerResponse,\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 reset(\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse>;\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 reset: async (\n input: ResetUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<ResetUsageResponse> => {\n const { data, error, response } = await this.client.POST(\"/v1/usage/reset\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throwRequestError(this.log, error, response, \"POST /v1/usage/reset\");\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;AA+BzB,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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I,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,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 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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AK,OAAO,UAAU,uBAAuB;AAC/E,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "priceos",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",