@usagetap/sdk 0.1.0 → 0.2.0
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/README.md +17 -1
- package/dist/adapters/openai.d.cts +1 -1
- package/dist/adapters/openai.d.ts +1 -1
- package/dist/adapters/openrouter.d.cts +1 -1
- package/dist/adapters/openrouter.d.ts +1 -1
- package/dist/index.cjs +75 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +75 -1
- package/dist/index.js.map +1 -1
- package/dist/{openai-CKyw08rB.d.cts → openai-CeptbEGH.d.cts} +23 -1
- package/dist/{openai-CKyw08rB.d.ts → openai-CeptbEGH.d.ts} +23 -1
- package/package.json +6 -4
|
@@ -237,6 +237,26 @@ interface WithUsageOptions {
|
|
|
237
237
|
*/
|
|
238
238
|
defaultErrorCode?: string;
|
|
239
239
|
}
|
|
240
|
+
interface CheckUsageRequest {
|
|
241
|
+
customerId: string;
|
|
242
|
+
}
|
|
243
|
+
interface CheckUsageOptions extends RequestOptions {
|
|
244
|
+
correlationId?: string;
|
|
245
|
+
}
|
|
246
|
+
interface CheckUsageResponseBody {
|
|
247
|
+
customerId: string;
|
|
248
|
+
canceled: boolean;
|
|
249
|
+
policy: LimitType;
|
|
250
|
+
allowed: AllowedEntitlements;
|
|
251
|
+
entitlementHints: EntitlementHints;
|
|
252
|
+
meters: MeterSnapshot;
|
|
253
|
+
remainingRatios: RemainingRatios;
|
|
254
|
+
subscription: SubscriptionSnapshot;
|
|
255
|
+
models?: ModelHints;
|
|
256
|
+
plan?: PlanSummary;
|
|
257
|
+
balances?: BalanceSummary;
|
|
258
|
+
stripeCustomerId?: string | null;
|
|
259
|
+
}
|
|
240
260
|
|
|
241
261
|
declare class UsageTapClient {
|
|
242
262
|
private readonly apiKey;
|
|
@@ -253,8 +273,10 @@ declare class UsageTapClient {
|
|
|
253
273
|
constructor(options: UsageTapClientOptions);
|
|
254
274
|
beginCall(request: BeginCallRequest, options?: BeginCallOptions): Promise<UsageTapSuccessResponse<BeginCallResponseBody>>;
|
|
255
275
|
endCall(request: EndCallRequest, options?: EndCallOptions): Promise<UsageTapSuccessResponse<EndCallResponseBody>>;
|
|
276
|
+
checkUsage(request: CheckUsageRequest, options?: CheckUsageOptions): Promise<UsageTapSuccessResponse<CheckUsageResponseBody>>;
|
|
256
277
|
withUsage<T>(beginRequest: BeginCallRequest, handler: (context: WithUsageContext) => Promise<T>, options?: WithUsageOptions): Promise<T>;
|
|
257
278
|
private request;
|
|
279
|
+
private requestGet;
|
|
258
280
|
private performFetch;
|
|
259
281
|
private composeHeaders;
|
|
260
282
|
private log;
|
|
@@ -395,4 +417,4 @@ interface NodeResponseLike {
|
|
|
395
417
|
flush?(): void;
|
|
396
418
|
}
|
|
397
419
|
|
|
398
|
-
export { type
|
|
420
|
+
export { type OpenAIRequestContext as $, type RequestedEntitlements as A, type BeginCallRequest as B, type CheckUsageOptions as C, type AllowedEntitlements as D, type EndCallOptions as E, type RetryOptions as F, type UsageTapClientOptions as G, type UsageTapSuccessResponse as H, type UsageTapErrorResponse as I, type UsageTapResultEnvelope as J, type UsageTapResultStatus as K, type UsageTapLogEntry as L, type MeterSummary as M, type NodeResponseLike as N, type OpenAIAdapter as O, type PlanSummary as P, type WithUsageContext as Q, type RemainingRatios as R, type StreamMode as S, type WithUsageOptions as T, UsageTapClient as U, type VendorHints as V, type WrapOpenAIContext as W, type LimitType as X, type SubscriptionSnapshot as Y, type ModelHints as Z, type IdempotencyMetadata as _, type WrapOpenAIOptions as a, type OpenAIStreamCallResult as a0, type UsageTapStream as a1, type OpenAIAdapterInit as b, createOpenAIAdapter as c, type OpenAIInvokeParams as d, type OpenAIInvokeResult as e, type OpenAIStreamParams as f, type OpenAIStreamResult as g, type StreamToResponseOptions as h, type WrapOpenAICallOptions as i, type WrapOpenAIResponseCallOptions as j, type WrappedOpenAI as k, type StreamOpenAIRouteOptions as l, type BeginCallOptions as m, type BeginCallResponseBody as n, type CheckUsageRequest as o, pipeToResponse as p, type CheckUsageResponseBody as q, type EndCallRequest as r, streamOpenAIRoute as s, toNextResponse as t, type EndCallResponseBody as u, type BalanceSummary as v, wrapOpenAI as w, type EntitlementHints as x, type MeterSnapshot as y, type MeteredUsage as z };
|
|
@@ -237,6 +237,26 @@ interface WithUsageOptions {
|
|
|
237
237
|
*/
|
|
238
238
|
defaultErrorCode?: string;
|
|
239
239
|
}
|
|
240
|
+
interface CheckUsageRequest {
|
|
241
|
+
customerId: string;
|
|
242
|
+
}
|
|
243
|
+
interface CheckUsageOptions extends RequestOptions {
|
|
244
|
+
correlationId?: string;
|
|
245
|
+
}
|
|
246
|
+
interface CheckUsageResponseBody {
|
|
247
|
+
customerId: string;
|
|
248
|
+
canceled: boolean;
|
|
249
|
+
policy: LimitType;
|
|
250
|
+
allowed: AllowedEntitlements;
|
|
251
|
+
entitlementHints: EntitlementHints;
|
|
252
|
+
meters: MeterSnapshot;
|
|
253
|
+
remainingRatios: RemainingRatios;
|
|
254
|
+
subscription: SubscriptionSnapshot;
|
|
255
|
+
models?: ModelHints;
|
|
256
|
+
plan?: PlanSummary;
|
|
257
|
+
balances?: BalanceSummary;
|
|
258
|
+
stripeCustomerId?: string | null;
|
|
259
|
+
}
|
|
240
260
|
|
|
241
261
|
declare class UsageTapClient {
|
|
242
262
|
private readonly apiKey;
|
|
@@ -253,8 +273,10 @@ declare class UsageTapClient {
|
|
|
253
273
|
constructor(options: UsageTapClientOptions);
|
|
254
274
|
beginCall(request: BeginCallRequest, options?: BeginCallOptions): Promise<UsageTapSuccessResponse<BeginCallResponseBody>>;
|
|
255
275
|
endCall(request: EndCallRequest, options?: EndCallOptions): Promise<UsageTapSuccessResponse<EndCallResponseBody>>;
|
|
276
|
+
checkUsage(request: CheckUsageRequest, options?: CheckUsageOptions): Promise<UsageTapSuccessResponse<CheckUsageResponseBody>>;
|
|
256
277
|
withUsage<T>(beginRequest: BeginCallRequest, handler: (context: WithUsageContext) => Promise<T>, options?: WithUsageOptions): Promise<T>;
|
|
257
278
|
private request;
|
|
279
|
+
private requestGet;
|
|
258
280
|
private performFetch;
|
|
259
281
|
private composeHeaders;
|
|
260
282
|
private log;
|
|
@@ -395,4 +417,4 @@ interface NodeResponseLike {
|
|
|
395
417
|
flush?(): void;
|
|
396
418
|
}
|
|
397
419
|
|
|
398
|
-
export { type
|
|
420
|
+
export { type OpenAIRequestContext as $, type RequestedEntitlements as A, type BeginCallRequest as B, type CheckUsageOptions as C, type AllowedEntitlements as D, type EndCallOptions as E, type RetryOptions as F, type UsageTapClientOptions as G, type UsageTapSuccessResponse as H, type UsageTapErrorResponse as I, type UsageTapResultEnvelope as J, type UsageTapResultStatus as K, type UsageTapLogEntry as L, type MeterSummary as M, type NodeResponseLike as N, type OpenAIAdapter as O, type PlanSummary as P, type WithUsageContext as Q, type RemainingRatios as R, type StreamMode as S, type WithUsageOptions as T, UsageTapClient as U, type VendorHints as V, type WrapOpenAIContext as W, type LimitType as X, type SubscriptionSnapshot as Y, type ModelHints as Z, type IdempotencyMetadata as _, type WrapOpenAIOptions as a, type OpenAIStreamCallResult as a0, type UsageTapStream as a1, type OpenAIAdapterInit as b, createOpenAIAdapter as c, type OpenAIInvokeParams as d, type OpenAIInvokeResult as e, type OpenAIStreamParams as f, type OpenAIStreamResult as g, type StreamToResponseOptions as h, type WrapOpenAICallOptions as i, type WrapOpenAIResponseCallOptions as j, type WrappedOpenAI as k, type StreamOpenAIRouteOptions as l, type BeginCallOptions as m, type BeginCallResponseBody as n, type CheckUsageRequest as o, pipeToResponse as p, type CheckUsageResponseBody as q, type EndCallRequest as r, streamOpenAIRoute as s, toNextResponse as t, type EndCallResponseBody as u, type BalanceSummary as v, wrapOpenAI as w, type EntitlementHints as x, type MeterSnapshot as y, type MeteredUsage as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usagetap/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "UsageTap SDK core client plus optional React helpers.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
},
|
|
33
33
|
"typesVersions": {
|
|
34
34
|
"*": {
|
|
35
|
-
"react": [
|
|
35
|
+
"react": [
|
|
36
|
+
"dist/react/index.d.ts"
|
|
37
|
+
]
|
|
36
38
|
}
|
|
37
39
|
},
|
|
38
40
|
"sideEffects": false,
|
|
@@ -45,8 +47,8 @@
|
|
|
45
47
|
"clean": "rimraf dist",
|
|
46
48
|
"test": "vitest run --coverage",
|
|
47
49
|
"test:watch": "vitest",
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
"lint": "eslint --config ../../libraries.config.mjs --max-warnings=0 --ignore-pattern \"src/**/*.test.ts\" --ignore-pattern \"src/**/*.test.tsx\" --ignore-pattern \"src/**/*.spec.ts\" --ignore-pattern \"src/**/*.spec.tsx\" \"src/**/*.{ts,tsx}\"",
|
|
51
|
+
"lint:fix": "eslint --config ../../libraries.config.mjs --fix --ignore-pattern \"src/**/*.test.ts\" --ignore-pattern \"src/**/*.test.tsx\" --ignore-pattern \"src/**/*.spec.ts\" --ignore-pattern \"src/**/*.spec.tsx\" \"src/**/*.{ts,tsx}\"",
|
|
50
52
|
"docs": "npm run build && api-extractor run --local --verbose && api-documenter markdown --input-folder temp --output-folder docs",
|
|
51
53
|
"prepare": "npm run build"
|
|
52
54
|
},
|