priceos 0.0.21 → 0.0.22
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.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/client.ts"],"sourcesContent":["export { PriceOS, PriceOSError } from \"./client\";\nexport type {\n PriceOSClientOptions,\n 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 TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n","import createClient from \"openapi-fetch\";\nimport type { Client } from \"openapi-fetch\";\nimport type { paths } from \"./gen/openapi\";\nimport {\n CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteCustomerResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n baseUrl?: string;\n fetch?: typeof fetch;\n userAgent?: string;\n};\n\nexport type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;\n identify(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse<TFeatureAccessMap> | null>;\n create(input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>>;\n update(input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>>;\n delete(customerId: string): Promise<DeleteCustomerResponse>;\n};\n\nexport type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n getAccess(customerId: string): Promise<TFeatureAccessMap>;\n};\n\nexport type PriceOSUsageClient<
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts"],"sourcesContent":["export { PriceOS, PriceOSError } from \"./client\";\nexport type {\n PriceOSClientOptions,\n PriceOSCustomersClient,\n PriceOSFeaturesClient,\n PriceOSHttpClient,\n PriceOSUsageClient,\n} from \"./client\";\nexport type {\n CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteCustomerRequest,\n DeleteCustomerResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n","import createClient from \"openapi-fetch\";\nimport type { Client } from \"openapi-fetch\";\nimport type { paths } from \"./gen/openapi\";\nimport {\n CreateCustomerRequest,\n CreateCustomerResponse,\n DeleteCustomerResponse,\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n LimitFeatureKeyFromAccessMap,\n TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n baseUrl?: string;\n fetch?: typeof fetch;\n userAgent?: string;\n};\n\nexport type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;\n identify(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse<TFeatureAccessMap> | null>;\n create(input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>>;\n update(input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>>;\n delete(customerId: string): Promise<DeleteCustomerResponse>;\n};\n\nexport type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n getAccess(customerId: string): Promise<TFeatureAccessMap>;\n};\n\nexport type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n track(\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse>;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<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 customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n\n constructor(apiKey: string, opts: PriceOSClientOptions = {}) {\n const baseUrl = opts.baseUrl ?? \"https://api.priceos.com\";\n this.header = { \"x-api-key\": apiKey };\n this.client = createClient<paths>({\n baseUrl,\n fetch: opts.fetch,\n headers: {\n \"x-api-key\": apiKey,\n ...(opts.userAgent ? { \"user-agent\": opts.userAgent } : {}),\n },\n });\n\n this.customers = {\n get: async (customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.GET(\"/v1/customer\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return (data ?? null) as GetCustomerResponse<TFeatureAccessMap> | null;\n },\n identify: async (\n input: IdentifyCustomerBody\n ): Promise<IdentifyCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.POST(\"/v1/customer/identify\", {\n params: { header: this.header },\n body: input,\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return (data ?? null) as IdentifyCustomerResponse<TFeatureAccessMap> | null;\n },\n create: async (input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>> => {\n const { data, error, response } = await this.client.POST(\"/v1/customer\", {\n params: { header: this.header },\n body: input,\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as CreateCustomerResponse<TFeatureAccessMap>;\n },\n update: async (input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>> => {\n const { data, error, response } = await this.client.PUT(\"/v1/customer\", {\n params: { header: this.header },\n body: input,\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as UpdateCustomerResponse<TFeatureAccessMap>;\n },\n delete: async (customerId: string): Promise<DeleteCustomerResponse> => {\n const { data, error, response } = await this.client.DELETE(\"/v1/customer\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as DeleteCustomerResponse;\n },\n };\n\n this.features = {\n getAccess: async (customerId: string): Promise<TFeatureAccessMap> => {\n const { data, error, response } = await this.client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as TFeatureAccessMap;\n },\n };\n\n this.usage = {\n track: async (\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)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n },\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAAyB;AAkDlB,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC;AAAA,EACA;AAAA,EAEA,YAAY,SAAiB,MAA+C;AAC1E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS,MAAM;AACpB,SAAK,UAAU,MAAM;AAAA,EACvB;AACF;AAEO,IAAM,UAAN,MAEP;AAAA,EACU;AAAA,EACA;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY,QAAgB,OAA6B,CAAC,GAAG;AAC3D,UAAM,UAAU,KAAK,WAAW;AAChC,SAAK,SAAS,EAAE,aAAa,OAAO;AACpC,SAAK,aAAS,qBAAAA,SAAoB;AAAA,MAChC;AAAA,MACA,OAAO,KAAK;AAAA,MACZ,SAAS;AAAA,QACP,aAAa;AAAA,QACb,GAAI,KAAK,YAAY,EAAE,cAAc,KAAK,UAAU,IAAI,CAAC;AAAA,MAC3D;AAAA,IACF,CAAC;AAED,SAAK,YAAY;AAAA,MACf,KAAK,OAAO,eAA+E;AACzF,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,IAAI,gBAAgB;AAAA,UACtE,QAAQ,EAAE,OAAO,EAAE,WAAW,GAAG,QAAQ,KAAK,OAAO;AAAA,QACvD,CAAC;AACD,YAAI;AACF,gBAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AACtG,eAAQ,QAAQ;AAAA,MAClB;AAAA,MACA,UAAU,OACR,UACgE;AAChE,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,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,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,IAAI,sBAAsB;AAAA,UAC5E,QAAQ,EAAE,OAAO,EAAE,WAAW,GAAG,QAAQ,KAAK,OAAO;AAAA,QACvD,CAAC;AACD,YAAI;AACF,gBAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AACtG,eAAO;AAAA,MACT;AAAA,IACF;AAEA,SAAK,QAAQ;AAAA,MACX,OAAO,OACL,UACgC;AAChC,cAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,aAAa;AAAA,UACpE,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,UAC9B,MAAM;AAAA,QACR,CAAC;AACD,YAAI;AACF,gBAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AACtG,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":["createClient"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1171,13 +1171,13 @@ type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
|
1171
1171
|
type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1172
1172
|
getAccess(customerId: string): Promise<TFeatureAccessMap>;
|
|
1173
1173
|
};
|
|
1174
|
-
type PriceOSUsageClient<
|
|
1175
|
-
track(input: TrackUsageBody<
|
|
1174
|
+
type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1175
|
+
track(input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<TrackUsageResponse>;
|
|
1176
1176
|
};
|
|
1177
|
-
type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse
|
|
1177
|
+
type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1178
1178
|
customers: PriceOSCustomersClient<TFeatureAccessMap>;
|
|
1179
1179
|
features: PriceOSFeaturesClient<TFeatureAccessMap>;
|
|
1180
|
-
usage: PriceOSUsageClient<
|
|
1180
|
+
usage: PriceOSUsageClient<TFeatureAccessMap>;
|
|
1181
1181
|
};
|
|
1182
1182
|
declare class PriceOSError extends Error {
|
|
1183
1183
|
status?: number;
|
|
@@ -1187,12 +1187,12 @@ declare class PriceOSError extends Error {
|
|
|
1187
1187
|
details?: unknown;
|
|
1188
1188
|
});
|
|
1189
1189
|
}
|
|
1190
|
-
declare class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse
|
|
1190
|
+
declare class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse> implements PriceOSHttpClient<TFeatureAccessMap> {
|
|
1191
1191
|
private client;
|
|
1192
1192
|
private header;
|
|
1193
1193
|
customers: PriceOSCustomersClient<TFeatureAccessMap>;
|
|
1194
1194
|
features: PriceOSFeaturesClient<TFeatureAccessMap>;
|
|
1195
|
-
usage: PriceOSUsageClient<
|
|
1195
|
+
usage: PriceOSUsageClient<TFeatureAccessMap>;
|
|
1196
1196
|
constructor(apiKey: string, opts?: PriceOSClientOptions);
|
|
1197
1197
|
}
|
|
1198
1198
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1171,13 +1171,13 @@ type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
|
1171
1171
|
type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1172
1172
|
getAccess(customerId: string): Promise<TFeatureAccessMap>;
|
|
1173
1173
|
};
|
|
1174
|
-
type PriceOSUsageClient<
|
|
1175
|
-
track(input: TrackUsageBody<
|
|
1174
|
+
type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1175
|
+
track(input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>): Promise<TrackUsageResponse>;
|
|
1176
1176
|
};
|
|
1177
|
-
type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse
|
|
1177
|
+
type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {
|
|
1178
1178
|
customers: PriceOSCustomersClient<TFeatureAccessMap>;
|
|
1179
1179
|
features: PriceOSFeaturesClient<TFeatureAccessMap>;
|
|
1180
|
-
usage: PriceOSUsageClient<
|
|
1180
|
+
usage: PriceOSUsageClient<TFeatureAccessMap>;
|
|
1181
1181
|
};
|
|
1182
1182
|
declare class PriceOSError extends Error {
|
|
1183
1183
|
status?: number;
|
|
@@ -1187,12 +1187,12 @@ declare class PriceOSError extends Error {
|
|
|
1187
1187
|
details?: unknown;
|
|
1188
1188
|
});
|
|
1189
1189
|
}
|
|
1190
|
-
declare class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse
|
|
1190
|
+
declare class PriceOS<TFeatureAccessMap = GetFeatureAccessResponse> implements PriceOSHttpClient<TFeatureAccessMap> {
|
|
1191
1191
|
private client;
|
|
1192
1192
|
private header;
|
|
1193
1193
|
customers: PriceOSCustomersClient<TFeatureAccessMap>;
|
|
1194
1194
|
features: PriceOSFeaturesClient<TFeatureAccessMap>;
|
|
1195
|
-
usage: PriceOSUsageClient<
|
|
1195
|
+
usage: PriceOSUsageClient<TFeatureAccessMap>;
|
|
1196
1196
|
constructor(apiKey: string, opts?: PriceOSClientOptions);
|
|
1197
1197
|
}
|
|
1198
1198
|
|
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 TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n baseUrl?: string;\n fetch?: typeof fetch;\n userAgent?: string;\n};\n\nexport type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;\n identify(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse<TFeatureAccessMap> | null>;\n create(input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>>;\n update(input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>>;\n delete(customerId: string): Promise<DeleteCustomerResponse>;\n};\n\nexport type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n getAccess(customerId: string): Promise<TFeatureAccessMap>;\n};\n\nexport type PriceOSUsageClient<
|
|
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 TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n baseUrl?: string;\n fetch?: typeof fetch;\n userAgent?: string;\n};\n\nexport type PriceOSCustomersClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n get(customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null>;\n identify(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse<TFeatureAccessMap> | null>;\n create(input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>>;\n update(input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>>;\n delete(customerId: string): Promise<DeleteCustomerResponse>;\n};\n\nexport type PriceOSFeaturesClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n getAccess(customerId: string): Promise<TFeatureAccessMap>;\n};\n\nexport type PriceOSUsageClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n track(\n input: TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>\n ): Promise<TrackUsageResponse>;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient<TFeatureAccessMap = GetFeatureAccessResponse> = {\n customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<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 customers: PriceOSCustomersClient<TFeatureAccessMap>;\n features: PriceOSFeaturesClient<TFeatureAccessMap>;\n usage: PriceOSUsageClient<TFeatureAccessMap>;\n\n constructor(apiKey: string, opts: PriceOSClientOptions = {}) {\n const baseUrl = opts.baseUrl ?? \"https://api.priceos.com\";\n this.header = { \"x-api-key\": apiKey };\n this.client = createClient<paths>({\n baseUrl,\n fetch: opts.fetch,\n headers: {\n \"x-api-key\": apiKey,\n ...(opts.userAgent ? { \"user-agent\": opts.userAgent } : {}),\n },\n });\n\n this.customers = {\n get: async (customerId: string): Promise<GetCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.GET(\"/v1/customer\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return (data ?? null) as GetCustomerResponse<TFeatureAccessMap> | null;\n },\n identify: async (\n input: IdentifyCustomerBody\n ): Promise<IdentifyCustomerResponse<TFeatureAccessMap> | null> => {\n const { data, error, response } = await this.client.POST(\"/v1/customer/identify\", {\n params: { header: this.header },\n body: input,\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return (data ?? null) as IdentifyCustomerResponse<TFeatureAccessMap> | null;\n },\n create: async (input: CreateCustomerRequest): Promise<CreateCustomerResponse<TFeatureAccessMap>> => {\n const { data, error, response } = await this.client.POST(\"/v1/customer\", {\n params: { header: this.header },\n body: input,\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as CreateCustomerResponse<TFeatureAccessMap>;\n },\n update: async (input: UpdateCustomerBody): Promise<UpdateCustomerResponse<TFeatureAccessMap>> => {\n const { data, error, response } = await this.client.PUT(\"/v1/customer\", {\n params: { header: this.header },\n body: input,\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as UpdateCustomerResponse<TFeatureAccessMap>;\n },\n delete: async (customerId: string): Promise<DeleteCustomerResponse> => {\n const { data, error, response } = await this.client.DELETE(\"/v1/customer\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as DeleteCustomerResponse;\n },\n };\n\n this.features = {\n getAccess: async (customerId: string): Promise<TFeatureAccessMap> => {\n const { data, error, response } = await this.client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data! as TFeatureAccessMap;\n },\n };\n\n this.usage = {\n track: async (\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)\n throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\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