priceos 0.0.1 → 0.0.3

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
@@ -30,8 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- PriceOSError: () => PriceOSError,
34
- createHttpClient: () => createHttpClient
33
+ PriceOS: () => PriceOS,
34
+ PriceOSError: () => PriceOSError
35
35
  });
36
36
  module.exports = __toCommonJS(index_exports);
37
37
 
@@ -47,56 +47,63 @@ var PriceOSError = class extends Error {
47
47
  this.details = opts?.details;
48
48
  }
49
49
  };
50
- function createHttpClient(opts) {
51
- const baseUrl = opts.baseUrl ?? "https://api.priceos.com";
52
- const header = { "x-api-key": opts.apiKey };
53
- const client = (0, import_openapi_fetch.default)({
54
- baseUrl,
55
- fetch: opts.fetch,
56
- headers: {
57
- "x-api-key": opts.apiKey,
58
- ...opts.userAgent ? { "user-agent": opts.userAgent } : {}
59
- }
60
- });
61
- return {
62
- raw: client,
63
- async getCustomer(customerId) {
64
- const { data, error, response } = await client.GET("/v1/customer", {
65
- params: { query: { customerId }, header }
66
- });
67
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
68
- return data ?? null;
69
- },
70
- async identifyCustomer(input) {
71
- const { data, error, response } = await client.POST("/v1/customer/identify", {
72
- params: { header },
73
- body: input
74
- });
75
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
76
- return data ?? null;
77
- },
78
- async upsertCustomer(input) {
79
- const { data, error, response } = await client.PUT("/v1/customer", { params: { header }, body: input });
80
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
81
- return data;
82
- },
83
- async getFeatureAccess(customerId) {
84
- const { data, error, response } = await client.GET("/v1/feature-access", {
85
- params: { query: { customerId }, header }
86
- });
87
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
88
- return data;
89
- },
90
- async trackUsage(input) {
91
- const { data, error, response } = await client.POST("/v1/usage", { params: { header }, body: input });
92
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
93
- return data;
94
- }
95
- };
96
- }
50
+ var PriceOS = class {
51
+ client;
52
+ header;
53
+ constructor(apiKey, opts = {}) {
54
+ const baseUrl = opts.baseUrl ?? "https://api.priceos.com";
55
+ this.header = { "x-api-key": apiKey };
56
+ this.client = (0, import_openapi_fetch.default)({
57
+ baseUrl,
58
+ fetch: opts.fetch,
59
+ headers: {
60
+ "x-api-key": apiKey,
61
+ ...opts.userAgent ? { "user-agent": opts.userAgent } : {}
62
+ }
63
+ });
64
+ }
65
+ async getCustomer(customerId) {
66
+ const { data, error, response } = await this.client.GET("/v1/customer", {
67
+ params: { query: { customerId }, header: this.header }
68
+ });
69
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
70
+ return data ?? null;
71
+ }
72
+ async identifyCustomer(input) {
73
+ const { data, error, response } = await this.client.POST("/v1/customer/identify", {
74
+ params: { header: this.header },
75
+ body: input
76
+ });
77
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
78
+ return data ?? null;
79
+ }
80
+ async upsertCustomer(input) {
81
+ const { data, error, response } = await this.client.PUT("/v1/customer", {
82
+ params: { header: this.header },
83
+ body: input
84
+ });
85
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
86
+ return data;
87
+ }
88
+ async getFeatureAccess(customerId) {
89
+ const { data, error, response } = await this.client.GET("/v1/feature-access", {
90
+ params: { query: { customerId }, header: this.header }
91
+ });
92
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
93
+ return data;
94
+ }
95
+ async trackUsage(input) {
96
+ const { data, error, response } = await this.client.POST("/v1/usage", {
97
+ params: { header: this.header },
98
+ body: input
99
+ });
100
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
101
+ return data;
102
+ }
103
+ };
97
104
  // Annotate the CommonJS export names for ESM import in node:
98
105
  0 && (module.exports = {
99
- PriceOSError,
100
- createHttpClient
106
+ PriceOS,
107
+ PriceOSError
101
108
  });
102
109
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/client.ts"],"sourcesContent":["export { createHttpClient, PriceOSError } from \"./client\";\nexport type {\n PriceOSOptions,\n PriceOSHttpClient,\n} from \"./client\";\nexport type {\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n","import createClient from \"openapi-fetch\";\nimport type { Client } from \"openapi-fetch\";\nimport type { paths } from \"./gen/openapi\";\nimport {\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\n// --- Public options ---\nexport type PriceOSOptions = {\n baseUrl?: string;\n apiKey: string;\n fetch?: typeof fetch;\n userAgent?: string;\n};\n\n\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient = {\n raw: Client<paths>;\n getCustomer(customerId: string): Promise<GetCustomerResponse | null>;\n identifyCustomer(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse | null>;\n upsertCustomer(input: UpdateCustomerBody): Promise<UpdateCustomerResponse>;\n getFeatureAccess(customerId: string): Promise<GetFeatureAccessResponse>;\n trackUsage(input: TrackUsageBody): Promise<TrackUsageResponse>;\n};\n\nexport class PriceOSError extends Error {\n status?: number;\n details?: unknown;\n\n constructor(message: string, opts?: { status?: number; details?: unknown }) {\n super(message);\n this.name = \"PriceOSError\";\n this.status = opts?.status;\n this.details = opts?.details;\n }\n}\n\nexport function createHttpClient(opts: PriceOSOptions): PriceOSHttpClient {\n const baseUrl = opts.baseUrl ?? \"https://api.priceos.com\";\n const header = { \"x-api-key\": opts.apiKey };\n\n const client = createClient<paths>({\n baseUrl,\n fetch: opts.fetch,\n headers: {\n \"x-api-key\": opts.apiKey,\n ...(opts.userAgent ? { \"user-agent\": opts.userAgent } : {}),\n },\n });\n\n return {\n raw: client,\n\n async getCustomer(customerId) {\n const { data, error, response } = await client.GET(\"/v1/customer\", {\n params: { query: { customerId }, header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n },\n\n async identifyCustomer(input) {\n const { data, error, response } = await client.POST(\"/v1/customer/identify\", {\n params: { header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n },\n\n async upsertCustomer(input) {\n const { data, error, response } = await client.PUT(\"/v1/customer\", { params: { header }, body: input });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n },\n\n async getFeatureAccess(customerId) {\n const { data, error, response } = await client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n },\n\n async trackUsage(input) {\n const { data, error, response } = await client.POST(\"/v1/usage\", { params: { header }, body: input });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAAyB;AAkClB,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC;AAAA,EACA;AAAA,EAEA,YAAY,SAAiB,MAA+C;AAC1E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS,MAAM;AACpB,SAAK,UAAU,MAAM;AAAA,EACvB;AACF;AAEO,SAAS,iBAAiB,MAAyC;AACx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AAE,MAAM,OAAO,SAAS,IAAI,MAAM,OAAO,IAAI,sBAAsB;AAAA,QACvE,QAAQ,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO;AAAA,MAC1C,CAAC;AACD,UAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,aAAO;AAAA,IACT;AAAA,IAEA,MAAM,WAAW,OAAO;AACtB,YAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,OAAO,KAAK,aAAa,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,MAAM,CAAC;AACpG,UAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["createClient"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/client.ts"],"sourcesContent":["export { PriceOS, PriceOSError } from \"./client\";\nexport type {\n PriceOSClientOptions,\n PriceOSHttpClient,\n} from \"./client\";\nexport type {\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n","import createClient from \"openapi-fetch\";\nimport type { Client } from \"openapi-fetch\";\nimport type { paths } from \"./gen/openapi\";\nimport {\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n baseUrl?: string;\n fetch?: typeof fetch;\n userAgent?: string;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient = {\n getCustomer(customerId: string): Promise<GetCustomerResponse | null>;\n identifyCustomer(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse | null>;\n upsertCustomer(input: UpdateCustomerBody): Promise<UpdateCustomerResponse>;\n getFeatureAccess(customerId: string): Promise<GetFeatureAccessResponse>;\n trackUsage(input: TrackUsageBody): Promise<TrackUsageResponse>;\n};\n\nexport class PriceOSError extends Error {\n status?: number;\n details?: unknown;\n\n constructor(message: string, opts?: { status?: number; details?: unknown }) {\n super(message);\n this.name = \"PriceOSError\";\n this.status = opts?.status;\n this.details = opts?.details;\n }\n}\n\nexport class PriceOS implements PriceOSHttpClient {\n private client: Client<paths>;\n private header: { \"x-api-key\": string };\n\n constructor(apiKey: string, opts: PriceOSClientOptions = {}) {\n const baseUrl = opts.baseUrl ?? \"https://api.priceos.com\";\n this.header = { \"x-api-key\": apiKey };\n this.client = createClient<paths>({\n baseUrl,\n fetch: opts.fetch,\n headers: {\n \"x-api-key\": apiKey,\n ...(opts.userAgent ? { \"user-agent\": opts.userAgent } : {}),\n },\n });\n }\n\n async getCustomer(customerId: string) {\n const { data, error, response } = await this.client.GET(\"/v1/customer\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n }\n\n async identifyCustomer(input: IdentifyCustomerBody) {\n const { data, error, response } = await this.client.POST(\"/v1/customer/identify\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n }\n\n async upsertCustomer(input: UpdateCustomerBody) {\n const { data, error, response } = await this.client.PUT(\"/v1/customer\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n }\n\n async getFeatureAccess(customerId: string) {\n const { data, error, response } = await this.client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n }\n\n async trackUsage(input: TrackUsageBody) {\n const { data, error, response } = await this.client.POST(\"/v1/usage\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAAyB;AA8BlB,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC;AAAA,EACA;AAAA,EAEA,YAAY,SAAiB,MAA+C;AAC1E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS,MAAM;AACpB,SAAK,UAAU,MAAM;AAAA,EACvB;AACF;AAEO,IAAM,UAAN,MAA2C;AAAA,EACxC;AAAA,EACA;AAAA,EAER,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;AAAA,EACH;AAAA,EAEA,MAAM,YAAY,YAAoB;AACpC,UAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,IAAI,gBAAgB;AAAA,MACtE,QAAQ,EAAE,OAAO,EAAE,WAAW,GAAG,QAAQ,KAAK,OAAO;AAAA,IACvD,CAAC;AACD,QAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,WAAO,QAAQ;AAAA,EACjB;AAAA,EAEA,MAAM,iBAAiB,OAA6B;AAClD,UAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,yBAAyB;AAAA,MACh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1
  /**
4
2
  * This file was auto-generated by openapi-typescript.
5
3
  * Do not make direct changes to the file.
@@ -1113,14 +1111,12 @@ type GetFeatureAccessResponse = paths["/v1/feature-access"]["get"]["responses"][
1113
1111
  type TrackUsageBody = paths["/v1/usage"]["post"]["requestBody"]["content"]["application/json"];
1114
1112
  type TrackUsageResponse = paths["/v1/usage"]["post"]["responses"][200]["content"]["application/json"];
1115
1113
 
1116
- type PriceOSOptions = {
1114
+ type PriceOSClientOptions = {
1117
1115
  baseUrl?: string;
1118
- apiKey: string;
1119
1116
  fetch?: typeof fetch;
1120
1117
  userAgent?: string;
1121
1118
  };
1122
1119
  type PriceOSHttpClient = {
1123
- raw: Client<paths>;
1124
1120
  getCustomer(customerId: string): Promise<GetCustomerResponse | null>;
1125
1121
  identifyCustomer(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse | null>;
1126
1122
  upsertCustomer(input: UpdateCustomerBody): Promise<UpdateCustomerResponse>;
@@ -1135,6 +1131,144 @@ declare class PriceOSError extends Error {
1135
1131
  details?: unknown;
1136
1132
  });
1137
1133
  }
1138
- declare function createHttpClient(opts: PriceOSOptions): PriceOSHttpClient;
1134
+ declare class PriceOS implements PriceOSHttpClient {
1135
+ private client;
1136
+ private header;
1137
+ constructor(apiKey: string, opts?: PriceOSClientOptions);
1138
+ getCustomer(customerId: string): Promise<{
1139
+ customerId?: string;
1140
+ stripeCustomerId?: string;
1141
+ name?: string;
1142
+ email?: string;
1143
+ enviroment: "test" | "live";
1144
+ products: {
1145
+ id: string;
1146
+ name: string;
1147
+ version: number;
1148
+ status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
1149
+ canceledAt?: number | null;
1150
+ startedAt?: number;
1151
+ currentPeriodStart?: number;
1152
+ currentPeriodEnd?: number;
1153
+ prices?: {
1154
+ stripePriceId: string;
1155
+ quantity: number;
1156
+ currency: string;
1157
+ unitAmount: number;
1158
+ recurringInterval: string | null;
1159
+ isActive: boolean;
1160
+ isDefault: boolean;
1161
+ recurringIntervalCount: number;
1162
+ }[];
1163
+ }[];
1164
+ featureAccess: {
1165
+ [key: string]: {
1166
+ type: "boolean";
1167
+ hasAccess: boolean;
1168
+ } | {
1169
+ type: "limit";
1170
+ hasAccess: boolean;
1171
+ isUnlimited: boolean;
1172
+ limit: number | null;
1173
+ used: number;
1174
+ };
1175
+ };
1176
+ } | null>;
1177
+ identifyCustomer(input: IdentifyCustomerBody): Promise<{
1178
+ customerId?: string;
1179
+ stripeCustomerId?: string;
1180
+ name?: string;
1181
+ email?: string;
1182
+ enviroment: "test" | "live";
1183
+ products: {
1184
+ id: string;
1185
+ name: string;
1186
+ version: number;
1187
+ status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
1188
+ canceledAt?: number | null;
1189
+ startedAt?: number;
1190
+ currentPeriodStart?: number;
1191
+ currentPeriodEnd?: number;
1192
+ prices?: {
1193
+ stripePriceId: string;
1194
+ quantity: number;
1195
+ currency: string;
1196
+ unitAmount: number;
1197
+ recurringInterval: string | null;
1198
+ isActive: boolean;
1199
+ isDefault: boolean;
1200
+ recurringIntervalCount: number;
1201
+ }[];
1202
+ }[];
1203
+ featureAccess: {
1204
+ [key: string]: {
1205
+ type: "boolean";
1206
+ hasAccess: boolean;
1207
+ } | {
1208
+ type: "limit";
1209
+ hasAccess: boolean;
1210
+ isUnlimited: boolean;
1211
+ limit: number | null;
1212
+ used: number;
1213
+ };
1214
+ };
1215
+ }>;
1216
+ upsertCustomer(input: UpdateCustomerBody): Promise<{
1217
+ customerId?: string;
1218
+ stripeCustomerId?: string;
1219
+ name?: string;
1220
+ email?: string;
1221
+ enviroment: "test" | "live";
1222
+ products: {
1223
+ id: string;
1224
+ name: string;
1225
+ version: number;
1226
+ status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
1227
+ canceledAt?: number | null;
1228
+ startedAt?: number;
1229
+ currentPeriodStart?: number;
1230
+ currentPeriodEnd?: number;
1231
+ prices?: {
1232
+ stripePriceId: string;
1233
+ quantity: number;
1234
+ currency: string;
1235
+ unitAmount: number;
1236
+ recurringInterval: string | null;
1237
+ isActive: boolean;
1238
+ isDefault: boolean;
1239
+ recurringIntervalCount: number;
1240
+ }[];
1241
+ }[];
1242
+ featureAccess: {
1243
+ [key: string]: {
1244
+ type: "boolean";
1245
+ hasAccess: boolean;
1246
+ } | {
1247
+ type: "limit";
1248
+ hasAccess: boolean;
1249
+ isUnlimited: boolean;
1250
+ limit: number | null;
1251
+ used: number;
1252
+ };
1253
+ };
1254
+ }>;
1255
+ getFeatureAccess(customerId: string): Promise<{
1256
+ [key: string]: {
1257
+ type: "boolean";
1258
+ hasAccess: boolean;
1259
+ } | {
1260
+ type: "limit";
1261
+ hasAccess: boolean;
1262
+ isUnlimited: boolean;
1263
+ limit: number | null;
1264
+ used: number;
1265
+ };
1266
+ }>;
1267
+ trackUsage(input: TrackUsageBody): Promise<{
1268
+ applied: boolean;
1269
+ used: number | null;
1270
+ reason?: string | null;
1271
+ }>;
1272
+ }
1139
1273
 
1140
- export { type GetCustomerResponse, type GetFeatureAccessResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, PriceOSError, type PriceOSHttpClient, type PriceOSOptions, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse, createHttpClient };
1274
+ export { type GetCustomerResponse, type GetFeatureAccessResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, PriceOS, type PriceOSClientOptions, PriceOSError, type PriceOSHttpClient, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { Client } from 'openapi-fetch';
2
-
3
1
  /**
4
2
  * This file was auto-generated by openapi-typescript.
5
3
  * Do not make direct changes to the file.
@@ -1113,14 +1111,12 @@ type GetFeatureAccessResponse = paths["/v1/feature-access"]["get"]["responses"][
1113
1111
  type TrackUsageBody = paths["/v1/usage"]["post"]["requestBody"]["content"]["application/json"];
1114
1112
  type TrackUsageResponse = paths["/v1/usage"]["post"]["responses"][200]["content"]["application/json"];
1115
1113
 
1116
- type PriceOSOptions = {
1114
+ type PriceOSClientOptions = {
1117
1115
  baseUrl?: string;
1118
- apiKey: string;
1119
1116
  fetch?: typeof fetch;
1120
1117
  userAgent?: string;
1121
1118
  };
1122
1119
  type PriceOSHttpClient = {
1123
- raw: Client<paths>;
1124
1120
  getCustomer(customerId: string): Promise<GetCustomerResponse | null>;
1125
1121
  identifyCustomer(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse | null>;
1126
1122
  upsertCustomer(input: UpdateCustomerBody): Promise<UpdateCustomerResponse>;
@@ -1135,6 +1131,144 @@ declare class PriceOSError extends Error {
1135
1131
  details?: unknown;
1136
1132
  });
1137
1133
  }
1138
- declare function createHttpClient(opts: PriceOSOptions): PriceOSHttpClient;
1134
+ declare class PriceOS implements PriceOSHttpClient {
1135
+ private client;
1136
+ private header;
1137
+ constructor(apiKey: string, opts?: PriceOSClientOptions);
1138
+ getCustomer(customerId: string): Promise<{
1139
+ customerId?: string;
1140
+ stripeCustomerId?: string;
1141
+ name?: string;
1142
+ email?: string;
1143
+ enviroment: "test" | "live";
1144
+ products: {
1145
+ id: string;
1146
+ name: string;
1147
+ version: number;
1148
+ status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
1149
+ canceledAt?: number | null;
1150
+ startedAt?: number;
1151
+ currentPeriodStart?: number;
1152
+ currentPeriodEnd?: number;
1153
+ prices?: {
1154
+ stripePriceId: string;
1155
+ quantity: number;
1156
+ currency: string;
1157
+ unitAmount: number;
1158
+ recurringInterval: string | null;
1159
+ isActive: boolean;
1160
+ isDefault: boolean;
1161
+ recurringIntervalCount: number;
1162
+ }[];
1163
+ }[];
1164
+ featureAccess: {
1165
+ [key: string]: {
1166
+ type: "boolean";
1167
+ hasAccess: boolean;
1168
+ } | {
1169
+ type: "limit";
1170
+ hasAccess: boolean;
1171
+ isUnlimited: boolean;
1172
+ limit: number | null;
1173
+ used: number;
1174
+ };
1175
+ };
1176
+ } | null>;
1177
+ identifyCustomer(input: IdentifyCustomerBody): Promise<{
1178
+ customerId?: string;
1179
+ stripeCustomerId?: string;
1180
+ name?: string;
1181
+ email?: string;
1182
+ enviroment: "test" | "live";
1183
+ products: {
1184
+ id: string;
1185
+ name: string;
1186
+ version: number;
1187
+ status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
1188
+ canceledAt?: number | null;
1189
+ startedAt?: number;
1190
+ currentPeriodStart?: number;
1191
+ currentPeriodEnd?: number;
1192
+ prices?: {
1193
+ stripePriceId: string;
1194
+ quantity: number;
1195
+ currency: string;
1196
+ unitAmount: number;
1197
+ recurringInterval: string | null;
1198
+ isActive: boolean;
1199
+ isDefault: boolean;
1200
+ recurringIntervalCount: number;
1201
+ }[];
1202
+ }[];
1203
+ featureAccess: {
1204
+ [key: string]: {
1205
+ type: "boolean";
1206
+ hasAccess: boolean;
1207
+ } | {
1208
+ type: "limit";
1209
+ hasAccess: boolean;
1210
+ isUnlimited: boolean;
1211
+ limit: number | null;
1212
+ used: number;
1213
+ };
1214
+ };
1215
+ }>;
1216
+ upsertCustomer(input: UpdateCustomerBody): Promise<{
1217
+ customerId?: string;
1218
+ stripeCustomerId?: string;
1219
+ name?: string;
1220
+ email?: string;
1221
+ enviroment: "test" | "live";
1222
+ products: {
1223
+ id: string;
1224
+ name: string;
1225
+ version: number;
1226
+ status?: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "paused" | "unpaid" | "canceled";
1227
+ canceledAt?: number | null;
1228
+ startedAt?: number;
1229
+ currentPeriodStart?: number;
1230
+ currentPeriodEnd?: number;
1231
+ prices?: {
1232
+ stripePriceId: string;
1233
+ quantity: number;
1234
+ currency: string;
1235
+ unitAmount: number;
1236
+ recurringInterval: string | null;
1237
+ isActive: boolean;
1238
+ isDefault: boolean;
1239
+ recurringIntervalCount: number;
1240
+ }[];
1241
+ }[];
1242
+ featureAccess: {
1243
+ [key: string]: {
1244
+ type: "boolean";
1245
+ hasAccess: boolean;
1246
+ } | {
1247
+ type: "limit";
1248
+ hasAccess: boolean;
1249
+ isUnlimited: boolean;
1250
+ limit: number | null;
1251
+ used: number;
1252
+ };
1253
+ };
1254
+ }>;
1255
+ getFeatureAccess(customerId: string): Promise<{
1256
+ [key: string]: {
1257
+ type: "boolean";
1258
+ hasAccess: boolean;
1259
+ } | {
1260
+ type: "limit";
1261
+ hasAccess: boolean;
1262
+ isUnlimited: boolean;
1263
+ limit: number | null;
1264
+ used: number;
1265
+ };
1266
+ }>;
1267
+ trackUsage(input: TrackUsageBody): Promise<{
1268
+ applied: boolean;
1269
+ used: number | null;
1270
+ reason?: string | null;
1271
+ }>;
1272
+ }
1139
1273
 
1140
- export { type GetCustomerResponse, type GetFeatureAccessResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, PriceOSError, type PriceOSHttpClient, type PriceOSOptions, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse, createHttpClient };
1274
+ export { type GetCustomerResponse, type GetFeatureAccessResponse, type IdentifyCustomerBody, type IdentifyCustomerResponse, PriceOS, type PriceOSClientOptions, PriceOSError, type PriceOSHttpClient, type TrackUsageBody, type TrackUsageResponse, type UpdateCustomerBody, type UpdateCustomerResponse };
package/dist/index.js CHANGED
@@ -10,55 +10,62 @@ var PriceOSError = class extends Error {
10
10
  this.details = opts?.details;
11
11
  }
12
12
  };
13
- function createHttpClient(opts) {
14
- const baseUrl = opts.baseUrl ?? "https://api.priceos.com";
15
- const header = { "x-api-key": opts.apiKey };
16
- const client = createClient({
17
- baseUrl,
18
- fetch: opts.fetch,
19
- headers: {
20
- "x-api-key": opts.apiKey,
21
- ...opts.userAgent ? { "user-agent": opts.userAgent } : {}
22
- }
23
- });
24
- return {
25
- raw: client,
26
- async getCustomer(customerId) {
27
- const { data, error, response } = await client.GET("/v1/customer", {
28
- params: { query: { customerId }, header }
29
- });
30
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
31
- return data ?? null;
32
- },
33
- async identifyCustomer(input) {
34
- const { data, error, response } = await client.POST("/v1/customer/identify", {
35
- params: { header },
36
- body: input
37
- });
38
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
39
- return data ?? null;
40
- },
41
- async upsertCustomer(input) {
42
- const { data, error, response } = await client.PUT("/v1/customer", { params: { header }, body: input });
43
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
44
- return data;
45
- },
46
- async getFeatureAccess(customerId) {
47
- const { data, error, response } = await client.GET("/v1/feature-access", {
48
- params: { query: { customerId }, header }
49
- });
50
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
51
- return data;
52
- },
53
- async trackUsage(input) {
54
- const { data, error, response } = await client.POST("/v1/usage", { params: { header }, body: input });
55
- if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
56
- return data;
57
- }
58
- };
59
- }
13
+ var PriceOS = class {
14
+ client;
15
+ header;
16
+ constructor(apiKey, opts = {}) {
17
+ const baseUrl = opts.baseUrl ?? "https://api.priceos.com";
18
+ this.header = { "x-api-key": apiKey };
19
+ this.client = createClient({
20
+ baseUrl,
21
+ fetch: opts.fetch,
22
+ headers: {
23
+ "x-api-key": apiKey,
24
+ ...opts.userAgent ? { "user-agent": opts.userAgent } : {}
25
+ }
26
+ });
27
+ }
28
+ async getCustomer(customerId) {
29
+ const { data, error, response } = await this.client.GET("/v1/customer", {
30
+ params: { query: { customerId }, header: this.header }
31
+ });
32
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
33
+ return data ?? null;
34
+ }
35
+ async identifyCustomer(input) {
36
+ const { data, error, response } = await this.client.POST("/v1/customer/identify", {
37
+ params: { header: this.header },
38
+ body: input
39
+ });
40
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
41
+ return data ?? null;
42
+ }
43
+ async upsertCustomer(input) {
44
+ const { data, error, response } = await this.client.PUT("/v1/customer", {
45
+ params: { header: this.header },
46
+ body: input
47
+ });
48
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
49
+ return data;
50
+ }
51
+ async getFeatureAccess(customerId) {
52
+ const { data, error, response } = await this.client.GET("/v1/feature-access", {
53
+ params: { query: { customerId }, header: this.header }
54
+ });
55
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
56
+ return data;
57
+ }
58
+ async trackUsage(input) {
59
+ const { data, error, response } = await this.client.POST("/v1/usage", {
60
+ params: { header: this.header },
61
+ body: input
62
+ });
63
+ if (error) throw new PriceOSError(error.error ?? "Request failed", { status: response?.status, details: error });
64
+ return data;
65
+ }
66
+ };
60
67
  export {
61
- PriceOSError,
62
- createHttpClient
68
+ PriceOS,
69
+ PriceOSError
63
70
  };
64
71
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import createClient from \"openapi-fetch\";\nimport type { Client } from \"openapi-fetch\";\nimport type { paths } from \"./gen/openapi\";\nimport {\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\n// --- Public options ---\nexport type PriceOSOptions = {\n baseUrl?: string;\n apiKey: string;\n fetch?: typeof fetch;\n userAgent?: string;\n};\n\n\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient = {\n raw: Client<paths>;\n getCustomer(customerId: string): Promise<GetCustomerResponse | null>;\n identifyCustomer(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse | null>;\n upsertCustomer(input: UpdateCustomerBody): Promise<UpdateCustomerResponse>;\n getFeatureAccess(customerId: string): Promise<GetFeatureAccessResponse>;\n trackUsage(input: TrackUsageBody): Promise<TrackUsageResponse>;\n};\n\nexport class PriceOSError extends Error {\n status?: number;\n details?: unknown;\n\n constructor(message: string, opts?: { status?: number; details?: unknown }) {\n super(message);\n this.name = \"PriceOSError\";\n this.status = opts?.status;\n this.details = opts?.details;\n }\n}\n\nexport function createHttpClient(opts: PriceOSOptions): PriceOSHttpClient {\n const baseUrl = opts.baseUrl ?? \"https://api.priceos.com\";\n const header = { \"x-api-key\": opts.apiKey };\n\n const client = createClient<paths>({\n baseUrl,\n fetch: opts.fetch,\n headers: {\n \"x-api-key\": opts.apiKey,\n ...(opts.userAgent ? { \"user-agent\": opts.userAgent } : {}),\n },\n });\n\n return {\n raw: client,\n\n async getCustomer(customerId) {\n const { data, error, response } = await client.GET(\"/v1/customer\", {\n params: { query: { customerId }, header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n },\n\n async identifyCustomer(input) {\n const { data, error, response } = await client.POST(\"/v1/customer/identify\", {\n params: { header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n },\n\n async upsertCustomer(input) {\n const { data, error, response } = await client.PUT(\"/v1/customer\", { params: { header }, body: input });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n },\n\n async getFeatureAccess(customerId) {\n const { data, error, response } = await client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n },\n\n async trackUsage(input) {\n const { data, error, response } = await client.POST(\"/v1/usage\", { params: { header }, body: input });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n },\n };\n}\n"],"mappings":";AAAA,OAAO,kBAAkB;AAkClB,IAAM,eAAN,cAA2B,MA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MAAM,CAAC;AACtG,UAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,aAAO;AAAA,IACT;AAAA,IAEA,MAAM,iBAAiB,YAAY;AACjC,YAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,OAAO,IAAI,sBAAsB;AAAA,QACvE,QAAQ,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO;AAAA,MAC1C,CAAC;AACD,UAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,aAAO;AAAA,IACT;AAAA,IAEA,MAAM,WAAW,OAAO;AACtB,YAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,OAAO,KAAK,aAAa,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,MAAM,CAAC;AACpG,UAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import createClient from \"openapi-fetch\";\nimport type { Client } from \"openapi-fetch\";\nimport type { paths } from \"./gen/openapi\";\nimport {\n GetCustomerResponse,\n GetFeatureAccessResponse,\n IdentifyCustomerBody,\n IdentifyCustomerResponse,\n TrackUsageBody,\n TrackUsageResponse,\n UpdateCustomerBody,\n UpdateCustomerResponse,\n} from \"./types\";\n\n// --- Public options ---\nexport type PriceOSClientOptions = {\n baseUrl?: string;\n fetch?: typeof fetch;\n userAgent?: string;\n};\n\n// --- Public SDK surface type ---\nexport type PriceOSHttpClient = {\n getCustomer(customerId: string): Promise<GetCustomerResponse | null>;\n identifyCustomer(input: IdentifyCustomerBody): Promise<IdentifyCustomerResponse | null>;\n upsertCustomer(input: UpdateCustomerBody): Promise<UpdateCustomerResponse>;\n getFeatureAccess(customerId: string): Promise<GetFeatureAccessResponse>;\n trackUsage(input: TrackUsageBody): Promise<TrackUsageResponse>;\n};\n\nexport class PriceOSError extends Error {\n status?: number;\n details?: unknown;\n\n constructor(message: string, opts?: { status?: number; details?: unknown }) {\n super(message);\n this.name = \"PriceOSError\";\n this.status = opts?.status;\n this.details = opts?.details;\n }\n}\n\nexport class PriceOS implements PriceOSHttpClient {\n private client: Client<paths>;\n private header: { \"x-api-key\": string };\n\n constructor(apiKey: string, opts: PriceOSClientOptions = {}) {\n const baseUrl = opts.baseUrl ?? \"https://api.priceos.com\";\n this.header = { \"x-api-key\": apiKey };\n this.client = createClient<paths>({\n baseUrl,\n fetch: opts.fetch,\n headers: {\n \"x-api-key\": apiKey,\n ...(opts.userAgent ? { \"user-agent\": opts.userAgent } : {}),\n },\n });\n }\n\n async getCustomer(customerId: string) {\n const { data, error, response } = await this.client.GET(\"/v1/customer\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n }\n\n async identifyCustomer(input: IdentifyCustomerBody) {\n const { data, error, response } = await this.client.POST(\"/v1/customer/identify\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data ?? null;\n }\n\n async upsertCustomer(input: UpdateCustomerBody) {\n const { data, error, response } = await this.client.PUT(\"/v1/customer\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n }\n\n async getFeatureAccess(customerId: string) {\n const { data, error, response } = await this.client.GET(\"/v1/feature-access\", {\n params: { query: { customerId }, header: this.header },\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n }\n\n async trackUsage(input: TrackUsageBody) {\n const { data, error, response } = await this.client.POST(\"/v1/usage\", {\n params: { header: this.header },\n body: input,\n });\n if (error) throw new PriceOSError(error.error ?? \"Request failed\", { status: response?.status, details: error });\n return data!;\n }\n}\n"],"mappings":";AAAA,OAAO,kBAAkB;AA8BlB,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC;AAAA,EACA;AAAA,EAEA,YAAY,SAAiB,MAA+C;AAC1E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS,MAAM;AACpB,SAAK,UAAU,MAAM;AAAA,EACvB;AACF;AAEO,IAAM,UAAN,MAA2C;AAAA,EACxC;AAAA,EACA;AAAA,EAER,YAAY,QAAgB,OAA6B,CAAC,GAAG;AAC3D,UAAM,UAAU,KAAK,WAAW;AAChC,SAAK,SAAS,EAAE,aAAa,OAAO;AACpC,SAAK,SAAS,aAAoB;AAAA,MAChC;AAAA,MACA,OAAO,KAAK;AAAA,MACZ,SAAS;AAAA,QACP,aAAa;AAAA,QACb,GAAI,KAAK,YAAY,EAAE,cAAc,KAAK,UAAU,IAAI,CAAC;AAAA,MAC3D;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,YAAY,YAAoB;AACpC,UAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,IAAI,gBAAgB;AAAA,MACtE,QAAQ,EAAE,OAAO,EAAE,WAAW,GAAG,QAAQ,KAAK,OAAO;AAAA,IACvD,CAAC;AACD,QAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,WAAO,QAAQ;AAAA,EACjB;AAAA,EAEA,MAAM,iBAAiB,OAA6B;AAClD,UAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,yBAAyB;AAAA,MAChF,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,MAC9B,MAAM;AAAA,IACR,CAAC;AACD,QAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,WAAO,QAAQ;AAAA,EACjB;AAAA,EAEA,MAAM,eAAe,OAA2B;AAC9C,UAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,IAAI,gBAAgB;AAAA,MACtE,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,MAC9B,MAAM;AAAA,IACR,CAAC;AACD,QAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,iBAAiB,YAAoB;AACzC,UAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,IAAI,sBAAsB;AAAA,MAC5E,QAAQ,EAAE,OAAO,EAAE,WAAW,GAAG,QAAQ,KAAK,OAAO;AAAA,IACvD,CAAC;AACD,QAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,WAAW,OAAuB;AACtC,UAAM,EAAE,MAAM,OAAO,SAAS,IAAI,MAAM,KAAK,OAAO,KAAK,aAAa;AAAA,MACpE,QAAQ,EAAE,QAAQ,KAAK,OAAO;AAAA,MAC9B,MAAM;AAAA,IACR,CAAC;AACD,QAAI,MAAO,OAAM,IAAI,aAAa,MAAM,SAAS,kBAAkB,EAAE,QAAQ,UAAU,QAAQ,SAAS,MAAM,CAAC;AAC/G,WAAO;AAAA,EACT;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "priceos",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -36,5 +36,9 @@
36
36
  "tsup": "^8.0.0",
37
37
  "tsx": "^4.21.0",
38
38
  "typescript": "^5.0.0"
39
+ },
40
+ "optionalDependencies": {
41
+ "@rollup/rollup-darwin-x64": "4.56.0",
42
+ "@rollup/rollup-linux-x64-gnu": "4.56.0"
39
43
  }
40
44
  }