@clocknext/sdk 0.13.0 → 0.14.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/dist/index.cjs +33 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -1
- package/dist/index.d.ts +106 -1
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +6 -0
- package/src/resources/signals.ts +35 -0
- package/src/types.ts +80 -0
package/dist/index.d.cts
CHANGED
|
@@ -356,6 +356,93 @@ interface UsageList {
|
|
|
356
356
|
};
|
|
357
357
|
logs: SerializedUsageLog[];
|
|
358
358
|
}
|
|
359
|
+
/** A preset time window, or `"custom"` for an explicit `from`/`to` range. */
|
|
360
|
+
type UsageLogPeriod = "all" | "today" | "7d" | "30d" | "90d" | "custom";
|
|
361
|
+
interface UsageLogListParams {
|
|
362
|
+
customerId: string;
|
|
363
|
+
/** Default 50, max 200. */
|
|
364
|
+
limit?: number;
|
|
365
|
+
/** Pass back a previous page's `nextCursor` to fetch the next page. Omit for
|
|
366
|
+
* the first page. */
|
|
367
|
+
cursor?: string;
|
|
368
|
+
/** Default `"all"`. Pair `"custom"` with `from`/`to`. */
|
|
369
|
+
period?: UsageLogPeriod;
|
|
370
|
+
/** `YYYY-MM-DD`, only used when `period` is `"custom"`. */
|
|
371
|
+
from?: string;
|
|
372
|
+
/** `YYYY-MM-DD`, only used when `period` is `"custom"`. */
|
|
373
|
+
to?: string;
|
|
374
|
+
}
|
|
375
|
+
interface UsageLogAppliedRule {
|
|
376
|
+
ruleId: string | null;
|
|
377
|
+
ruleName: string;
|
|
378
|
+
mode: "MARGIN" | "CREDIT" | null;
|
|
379
|
+
marginPercentApplied: number | null;
|
|
380
|
+
/** Formatted, same as {@link UsageLogEntry.credit}'s `amount`. */
|
|
381
|
+
creditsApplied: string;
|
|
382
|
+
}
|
|
383
|
+
interface UsageLogOutcomeAttribution {
|
|
384
|
+
/** "2 / 4" — the step this call performed, and the outcome's total step
|
|
385
|
+
* count. Not a progress target: a step may repeat within a run. */
|
|
386
|
+
step: string | null;
|
|
387
|
+
stepName: string | null;
|
|
388
|
+
runId: string | null;
|
|
389
|
+
/** How many signals the run holds. */
|
|
390
|
+
runSignals: number;
|
|
391
|
+
/** True once the run closed (`complete: true` was sent for it). */
|
|
392
|
+
closedRun: boolean;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* One row of a customer's usage history, merged from every meter kind
|
|
396
|
+
* (`UsageLog`, `UnitUsageLog`, completed composite occurrences) into one
|
|
397
|
+
* feed and sorted by time — the same rows the customer portal's own "Usage
|
|
398
|
+
* logs" table shows. `model`, `credit`, `outcome`, `unit` and `composite` are
|
|
399
|
+
* each `null` unless `kind` matches that group.
|
|
400
|
+
*/
|
|
401
|
+
interface UsageLogEntry {
|
|
402
|
+
id: string;
|
|
403
|
+
createdAt: string;
|
|
404
|
+
kind: "credit" | "outcome" | "unit" | "wallet" | "composite";
|
|
405
|
+
status: SignalStatus;
|
|
406
|
+
typeName: string | null;
|
|
407
|
+
member: string | null;
|
|
408
|
+
model: {
|
|
409
|
+
name: string | null;
|
|
410
|
+
provider: string | null;
|
|
411
|
+
} | null;
|
|
412
|
+
usage: {
|
|
413
|
+
inputTokens: number;
|
|
414
|
+
outputTokens: number;
|
|
415
|
+
cacheTokens: number;
|
|
416
|
+
};
|
|
417
|
+
/** Formatted USD strings (e.g. `"$0.0064"`). */
|
|
418
|
+
cost: {
|
|
419
|
+
providedCost: string;
|
|
420
|
+
customerCost: string;
|
|
421
|
+
};
|
|
422
|
+
/** Populated only when `kind === "credit"`. `amount` is a formatted credit
|
|
423
|
+
* value, honouring the org's credit-decimals display setting. */
|
|
424
|
+
credit: {
|
|
425
|
+
amount: string;
|
|
426
|
+
appliedRules: UsageLogAppliedRule[];
|
|
427
|
+
} | null;
|
|
428
|
+
/** Populated only when `kind === "outcome"`. */
|
|
429
|
+
outcome: UsageLogOutcomeAttribution | null;
|
|
430
|
+
/** Populated only when `kind === "unit"`. `quantity` is formatted. */
|
|
431
|
+
unit: {
|
|
432
|
+
quantity: string;
|
|
433
|
+
} | null;
|
|
434
|
+
/** Populated only when `kind === "composite"`. `amount` is a formatted USD
|
|
435
|
+
* price — the composite's flat price, read live, not stored per row. */
|
|
436
|
+
composite: {
|
|
437
|
+
amount: string;
|
|
438
|
+
} | null;
|
|
439
|
+
}
|
|
440
|
+
interface UsageLogPage {
|
|
441
|
+
usageLogs: UsageLogEntry[];
|
|
442
|
+
/** Pass this back as `cursor` to fetch the next page; `null` on the last
|
|
443
|
+
* page. */
|
|
444
|
+
nextCursor: string | null;
|
|
445
|
+
}
|
|
359
446
|
interface ApiCustomer {
|
|
360
447
|
id: string;
|
|
361
448
|
slug: string;
|
|
@@ -2119,6 +2206,24 @@ declare class Signals {
|
|
|
2119
2206
|
customerId: string;
|
|
2120
2207
|
limit?: number;
|
|
2121
2208
|
}): Promise<UnitUsageList>;
|
|
2209
|
+
/**
|
|
2210
|
+
* One customer's usage history, merged from every meter kind — credit,
|
|
2211
|
+
* outcome, unit, wallet, and completed composite occurrences — into one
|
|
2212
|
+
* feed sorted by time. `GET /api/v1/signal/usage-log`. Exactly the same
|
|
2213
|
+
* rows the customer portal's own "Usage logs" table shows, so a caller can
|
|
2214
|
+
* build against this instead of the portal UI.
|
|
2215
|
+
*
|
|
2216
|
+
* Cursor-paginated, NOT page-numbered: `limit` + `cursor` in, `nextCursor`
|
|
2217
|
+
* out. Omit `cursor` for the first page; pass the previous page's
|
|
2218
|
+
* `nextCursor` back to fetch the next one, and stop once it comes back
|
|
2219
|
+
* `null`. Unlike offset pagination, the cost of a page never grows with how
|
|
2220
|
+
* deep you've paged — each page only asks for rows strictly before the
|
|
2221
|
+
* cursor's position.
|
|
2222
|
+
*
|
|
2223
|
+
* Read-only; unlike {@link track}/{@link unit}/etc., there is nothing to
|
|
2224
|
+
* buffer or retry here.
|
|
2225
|
+
*/
|
|
2226
|
+
usageLog(params: UsageLogListParams): Promise<UsageLogPage>;
|
|
2122
2227
|
}
|
|
2123
2228
|
|
|
2124
2229
|
/**
|
|
@@ -2312,4 +2417,4 @@ declare class NetworkError extends ClockNextError {
|
|
|
2312
2417
|
});
|
|
2313
2418
|
}
|
|
2314
2419
|
|
|
2315
|
-
export { type AddMemberInput, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type Composite, type CompositeAdjustInput, type CompositeCatalogueRef, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeComponentInput, type CompositeTag, ConflictError, type CostPoint, type CostStats, type CreateCompositeInput, type CreateCreditInput, type CreateCustomerInput, type CreateOutcomeInput, type CreatePlanInput, type CreatePurchaseInput, type CreateUnitInput, type Credit, type CreditAdjustInput, type CreditAnalytics, type CreditBalance, type CreditComponentInput, type CreditDetail, type CreditInput, type CreditSignal, type CustomerBalances, type CustomerList, type CustomerPlan, type CustomerPlanDetails, type CustomerProfileInput, type DropReason, type FetchLike, type FlatComponentInput, type FlatUnitInput, ForbiddenError, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListRow, type InvoiceParty, type InvoicePlanSnapshot, type InvoiceStatus, type Logger, type Member, type MemberProfile, type Model, type ModelBundleEntry, NetworkError, NotFoundError, type Outcome, type OutcomeAdjustInput, type OutcomeAnalytics, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeComponentInput, type OutcomeDetail, type OutcomeInput, type OutcomeSignal, type OutcomeStepInput, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, type PlanComponentInput, type PlanDetail, PlanError, type PlanKind, type PlanRef, type PlanType, type PortalToken, type PortalTokenInput, type Purchase, type PurchaseDetail, type PurchaseStatus, RateLimitError, type RemovedMember, type SerializedOutcomeAttribution, type SerializedRuleApplication, type SerializedUnitUsage, type SerializedUsageLog, ServerError, type Signal, type SignalDelivery, type SignalStatus, type SignalType, type ThresholdKind, type TieredUnitInput, type Tokens, type TrackResult, type Unit, type UnitAdjustInput, type UnitBalance, type UnitComponentInput, type UnitCustomerRow, type UnitDetail, type UnitInput, type UnitPricingType, type UnitTier, type UnitTierInput, type UnitTrackResult, type UnitUsageList, type UnitUsageRow, type UpdateCreditInput, type UpdateMemberInput, type UpdateOutcomeInput, type UpdatePlanInput, type UpdateUnitInput, type UpsertWebhookInput, type UsageBalance, type UsageList, ValidationError, type WalletComponentInput, type WalletEntitlementKind, type WalletEntryInput, type WalletInput, type WalletList, type WalletSignal, type WalletTransaction, type WalletTransactionSource, type WalletTransactionType, type Webhook, type WorkspaceIdentity, signalToWire };
|
|
2420
|
+
export { type AddMemberInput, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type Composite, type CompositeAdjustInput, type CompositeCatalogueRef, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeComponentInput, type CompositeTag, ConflictError, type CostPoint, type CostStats, type CreateCompositeInput, type CreateCreditInput, type CreateCustomerInput, type CreateOutcomeInput, type CreatePlanInput, type CreatePurchaseInput, type CreateUnitInput, type Credit, type CreditAdjustInput, type CreditAnalytics, type CreditBalance, type CreditComponentInput, type CreditDetail, type CreditInput, type CreditSignal, type CustomerBalances, type CustomerList, type CustomerPlan, type CustomerPlanDetails, type CustomerProfileInput, type DropReason, type FetchLike, type FlatComponentInput, type FlatUnitInput, ForbiddenError, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListRow, type InvoiceParty, type InvoicePlanSnapshot, type InvoiceStatus, type Logger, type Member, type MemberProfile, type Model, type ModelBundleEntry, NetworkError, NotFoundError, type Outcome, type OutcomeAdjustInput, type OutcomeAnalytics, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeComponentInput, type OutcomeDetail, type OutcomeInput, type OutcomeSignal, type OutcomeStepInput, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, type PlanComponentInput, type PlanDetail, PlanError, type PlanKind, type PlanRef, type PlanType, type PortalToken, type PortalTokenInput, type Purchase, type PurchaseDetail, type PurchaseStatus, RateLimitError, type RemovedMember, type SerializedOutcomeAttribution, type SerializedRuleApplication, type SerializedUnitUsage, type SerializedUsageLog, ServerError, type Signal, type SignalDelivery, type SignalStatus, type SignalType, type ThresholdKind, type TieredUnitInput, type Tokens, type TrackResult, type Unit, type UnitAdjustInput, type UnitBalance, type UnitComponentInput, type UnitCustomerRow, type UnitDetail, type UnitInput, type UnitPricingType, type UnitTier, type UnitTierInput, type UnitTrackResult, type UnitUsageList, type UnitUsageRow, type UpdateCreditInput, type UpdateMemberInput, type UpdateOutcomeInput, type UpdatePlanInput, type UpdateUnitInput, type UpsertWebhookInput, type UsageBalance, type UsageList, type UsageLogAppliedRule, type UsageLogEntry, type UsageLogListParams, type UsageLogOutcomeAttribution, type UsageLogPage, type UsageLogPeriod, ValidationError, type WalletComponentInput, type WalletEntitlementKind, type WalletEntryInput, type WalletInput, type WalletList, type WalletSignal, type WalletTransaction, type WalletTransactionSource, type WalletTransactionType, type Webhook, type WorkspaceIdentity, signalToWire };
|
package/dist/index.d.ts
CHANGED
|
@@ -356,6 +356,93 @@ interface UsageList {
|
|
|
356
356
|
};
|
|
357
357
|
logs: SerializedUsageLog[];
|
|
358
358
|
}
|
|
359
|
+
/** A preset time window, or `"custom"` for an explicit `from`/`to` range. */
|
|
360
|
+
type UsageLogPeriod = "all" | "today" | "7d" | "30d" | "90d" | "custom";
|
|
361
|
+
interface UsageLogListParams {
|
|
362
|
+
customerId: string;
|
|
363
|
+
/** Default 50, max 200. */
|
|
364
|
+
limit?: number;
|
|
365
|
+
/** Pass back a previous page's `nextCursor` to fetch the next page. Omit for
|
|
366
|
+
* the first page. */
|
|
367
|
+
cursor?: string;
|
|
368
|
+
/** Default `"all"`. Pair `"custom"` with `from`/`to`. */
|
|
369
|
+
period?: UsageLogPeriod;
|
|
370
|
+
/** `YYYY-MM-DD`, only used when `period` is `"custom"`. */
|
|
371
|
+
from?: string;
|
|
372
|
+
/** `YYYY-MM-DD`, only used when `period` is `"custom"`. */
|
|
373
|
+
to?: string;
|
|
374
|
+
}
|
|
375
|
+
interface UsageLogAppliedRule {
|
|
376
|
+
ruleId: string | null;
|
|
377
|
+
ruleName: string;
|
|
378
|
+
mode: "MARGIN" | "CREDIT" | null;
|
|
379
|
+
marginPercentApplied: number | null;
|
|
380
|
+
/** Formatted, same as {@link UsageLogEntry.credit}'s `amount`. */
|
|
381
|
+
creditsApplied: string;
|
|
382
|
+
}
|
|
383
|
+
interface UsageLogOutcomeAttribution {
|
|
384
|
+
/** "2 / 4" — the step this call performed, and the outcome's total step
|
|
385
|
+
* count. Not a progress target: a step may repeat within a run. */
|
|
386
|
+
step: string | null;
|
|
387
|
+
stepName: string | null;
|
|
388
|
+
runId: string | null;
|
|
389
|
+
/** How many signals the run holds. */
|
|
390
|
+
runSignals: number;
|
|
391
|
+
/** True once the run closed (`complete: true` was sent for it). */
|
|
392
|
+
closedRun: boolean;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* One row of a customer's usage history, merged from every meter kind
|
|
396
|
+
* (`UsageLog`, `UnitUsageLog`, completed composite occurrences) into one
|
|
397
|
+
* feed and sorted by time — the same rows the customer portal's own "Usage
|
|
398
|
+
* logs" table shows. `model`, `credit`, `outcome`, `unit` and `composite` are
|
|
399
|
+
* each `null` unless `kind` matches that group.
|
|
400
|
+
*/
|
|
401
|
+
interface UsageLogEntry {
|
|
402
|
+
id: string;
|
|
403
|
+
createdAt: string;
|
|
404
|
+
kind: "credit" | "outcome" | "unit" | "wallet" | "composite";
|
|
405
|
+
status: SignalStatus;
|
|
406
|
+
typeName: string | null;
|
|
407
|
+
member: string | null;
|
|
408
|
+
model: {
|
|
409
|
+
name: string | null;
|
|
410
|
+
provider: string | null;
|
|
411
|
+
} | null;
|
|
412
|
+
usage: {
|
|
413
|
+
inputTokens: number;
|
|
414
|
+
outputTokens: number;
|
|
415
|
+
cacheTokens: number;
|
|
416
|
+
};
|
|
417
|
+
/** Formatted USD strings (e.g. `"$0.0064"`). */
|
|
418
|
+
cost: {
|
|
419
|
+
providedCost: string;
|
|
420
|
+
customerCost: string;
|
|
421
|
+
};
|
|
422
|
+
/** Populated only when `kind === "credit"`. `amount` is a formatted credit
|
|
423
|
+
* value, honouring the org's credit-decimals display setting. */
|
|
424
|
+
credit: {
|
|
425
|
+
amount: string;
|
|
426
|
+
appliedRules: UsageLogAppliedRule[];
|
|
427
|
+
} | null;
|
|
428
|
+
/** Populated only when `kind === "outcome"`. */
|
|
429
|
+
outcome: UsageLogOutcomeAttribution | null;
|
|
430
|
+
/** Populated only when `kind === "unit"`. `quantity` is formatted. */
|
|
431
|
+
unit: {
|
|
432
|
+
quantity: string;
|
|
433
|
+
} | null;
|
|
434
|
+
/** Populated only when `kind === "composite"`. `amount` is a formatted USD
|
|
435
|
+
* price — the composite's flat price, read live, not stored per row. */
|
|
436
|
+
composite: {
|
|
437
|
+
amount: string;
|
|
438
|
+
} | null;
|
|
439
|
+
}
|
|
440
|
+
interface UsageLogPage {
|
|
441
|
+
usageLogs: UsageLogEntry[];
|
|
442
|
+
/** Pass this back as `cursor` to fetch the next page; `null` on the last
|
|
443
|
+
* page. */
|
|
444
|
+
nextCursor: string | null;
|
|
445
|
+
}
|
|
359
446
|
interface ApiCustomer {
|
|
360
447
|
id: string;
|
|
361
448
|
slug: string;
|
|
@@ -2119,6 +2206,24 @@ declare class Signals {
|
|
|
2119
2206
|
customerId: string;
|
|
2120
2207
|
limit?: number;
|
|
2121
2208
|
}): Promise<UnitUsageList>;
|
|
2209
|
+
/**
|
|
2210
|
+
* One customer's usage history, merged from every meter kind — credit,
|
|
2211
|
+
* outcome, unit, wallet, and completed composite occurrences — into one
|
|
2212
|
+
* feed sorted by time. `GET /api/v1/signal/usage-log`. Exactly the same
|
|
2213
|
+
* rows the customer portal's own "Usage logs" table shows, so a caller can
|
|
2214
|
+
* build against this instead of the portal UI.
|
|
2215
|
+
*
|
|
2216
|
+
* Cursor-paginated, NOT page-numbered: `limit` + `cursor` in, `nextCursor`
|
|
2217
|
+
* out. Omit `cursor` for the first page; pass the previous page's
|
|
2218
|
+
* `nextCursor` back to fetch the next one, and stop once it comes back
|
|
2219
|
+
* `null`. Unlike offset pagination, the cost of a page never grows with how
|
|
2220
|
+
* deep you've paged — each page only asks for rows strictly before the
|
|
2221
|
+
* cursor's position.
|
|
2222
|
+
*
|
|
2223
|
+
* Read-only; unlike {@link track}/{@link unit}/etc., there is nothing to
|
|
2224
|
+
* buffer or retry here.
|
|
2225
|
+
*/
|
|
2226
|
+
usageLog(params: UsageLogListParams): Promise<UsageLogPage>;
|
|
2122
2227
|
}
|
|
2123
2228
|
|
|
2124
2229
|
/**
|
|
@@ -2312,4 +2417,4 @@ declare class NetworkError extends ClockNextError {
|
|
|
2312
2417
|
});
|
|
2313
2418
|
}
|
|
2314
2419
|
|
|
2315
|
-
export { type AddMemberInput, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type Composite, type CompositeAdjustInput, type CompositeCatalogueRef, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeComponentInput, type CompositeTag, ConflictError, type CostPoint, type CostStats, type CreateCompositeInput, type CreateCreditInput, type CreateCustomerInput, type CreateOutcomeInput, type CreatePlanInput, type CreatePurchaseInput, type CreateUnitInput, type Credit, type CreditAdjustInput, type CreditAnalytics, type CreditBalance, type CreditComponentInput, type CreditDetail, type CreditInput, type CreditSignal, type CustomerBalances, type CustomerList, type CustomerPlan, type CustomerPlanDetails, type CustomerProfileInput, type DropReason, type FetchLike, type FlatComponentInput, type FlatUnitInput, ForbiddenError, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListRow, type InvoiceParty, type InvoicePlanSnapshot, type InvoiceStatus, type Logger, type Member, type MemberProfile, type Model, type ModelBundleEntry, NetworkError, NotFoundError, type Outcome, type OutcomeAdjustInput, type OutcomeAnalytics, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeComponentInput, type OutcomeDetail, type OutcomeInput, type OutcomeSignal, type OutcomeStepInput, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, type PlanComponentInput, type PlanDetail, PlanError, type PlanKind, type PlanRef, type PlanType, type PortalToken, type PortalTokenInput, type Purchase, type PurchaseDetail, type PurchaseStatus, RateLimitError, type RemovedMember, type SerializedOutcomeAttribution, type SerializedRuleApplication, type SerializedUnitUsage, type SerializedUsageLog, ServerError, type Signal, type SignalDelivery, type SignalStatus, type SignalType, type ThresholdKind, type TieredUnitInput, type Tokens, type TrackResult, type Unit, type UnitAdjustInput, type UnitBalance, type UnitComponentInput, type UnitCustomerRow, type UnitDetail, type UnitInput, type UnitPricingType, type UnitTier, type UnitTierInput, type UnitTrackResult, type UnitUsageList, type UnitUsageRow, type UpdateCreditInput, type UpdateMemberInput, type UpdateOutcomeInput, type UpdatePlanInput, type UpdateUnitInput, type UpsertWebhookInput, type UsageBalance, type UsageList, ValidationError, type WalletComponentInput, type WalletEntitlementKind, type WalletEntryInput, type WalletInput, type WalletList, type WalletSignal, type WalletTransaction, type WalletTransactionSource, type WalletTransactionType, type Webhook, type WorkspaceIdentity, signalToWire };
|
|
2420
|
+
export { type AddMemberInput, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type Composite, type CompositeAdjustInput, type CompositeCatalogueRef, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeComponentInput, type CompositeTag, ConflictError, type CostPoint, type CostStats, type CreateCompositeInput, type CreateCreditInput, type CreateCustomerInput, type CreateOutcomeInput, type CreatePlanInput, type CreatePurchaseInput, type CreateUnitInput, type Credit, type CreditAdjustInput, type CreditAnalytics, type CreditBalance, type CreditComponentInput, type CreditDetail, type CreditInput, type CreditSignal, type CustomerBalances, type CustomerList, type CustomerPlan, type CustomerPlanDetails, type CustomerProfileInput, type DropReason, type FetchLike, type FlatComponentInput, type FlatUnitInput, ForbiddenError, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListRow, type InvoiceParty, type InvoicePlanSnapshot, type InvoiceStatus, type Logger, type Member, type MemberProfile, type Model, type ModelBundleEntry, NetworkError, NotFoundError, type Outcome, type OutcomeAdjustInput, type OutcomeAnalytics, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeComponentInput, type OutcomeDetail, type OutcomeInput, type OutcomeSignal, type OutcomeStepInput, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, type PlanComponentInput, type PlanDetail, PlanError, type PlanKind, type PlanRef, type PlanType, type PortalToken, type PortalTokenInput, type Purchase, type PurchaseDetail, type PurchaseStatus, RateLimitError, type RemovedMember, type SerializedOutcomeAttribution, type SerializedRuleApplication, type SerializedUnitUsage, type SerializedUsageLog, ServerError, type Signal, type SignalDelivery, type SignalStatus, type SignalType, type ThresholdKind, type TieredUnitInput, type Tokens, type TrackResult, type Unit, type UnitAdjustInput, type UnitBalance, type UnitComponentInput, type UnitCustomerRow, type UnitDetail, type UnitInput, type UnitPricingType, type UnitTier, type UnitTierInput, type UnitTrackResult, type UnitUsageList, type UnitUsageRow, type UpdateCreditInput, type UpdateMemberInput, type UpdateOutcomeInput, type UpdatePlanInput, type UpdateUnitInput, type UpsertWebhookInput, type UsageBalance, type UsageList, type UsageLogAppliedRule, type UsageLogEntry, type UsageLogListParams, type UsageLogOutcomeAttribution, type UsageLogPage, type UsageLogPeriod, ValidationError, type WalletComponentInput, type WalletEntitlementKind, type WalletEntryInput, type WalletInput, type WalletList, type WalletSignal, type WalletTransaction, type WalletTransactionSource, type WalletTransactionType, type Webhook, type WorkspaceIdentity, signalToWire };
|
package/dist/index.js
CHANGED
|
@@ -326,7 +326,7 @@ function sleep(ms) {
|
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
// src/http.ts
|
|
329
|
-
var SDK_VERSION = "0.
|
|
329
|
+
var SDK_VERSION = "0.14.0" ;
|
|
330
330
|
var Transport = class {
|
|
331
331
|
constructor(cfg) {
|
|
332
332
|
this.cfg = cfg;
|
|
@@ -1029,6 +1029,7 @@ var SIGNAL_PATHS = {
|
|
|
1029
1029
|
var UNIT_PATH = "/api/v1/signal/unit";
|
|
1030
1030
|
var COMPOSITE_COMPLETE_PATH = "/api/v1/signal/composite/complete";
|
|
1031
1031
|
var OUTCOME_COMPLETE_PATH = "/api/v1/signal/outcome/complete";
|
|
1032
|
+
var USAGE_LOG_PATH = "/api/v1/signal/usage-log";
|
|
1032
1033
|
function signalToWire(signal) {
|
|
1033
1034
|
const t = signal.tokens;
|
|
1034
1035
|
const body = {
|
|
@@ -1287,6 +1288,37 @@ var Signals = class {
|
|
|
1287
1288
|
query: { customerId: params.customerId, limit: params.limit }
|
|
1288
1289
|
});
|
|
1289
1290
|
}
|
|
1291
|
+
/**
|
|
1292
|
+
* One customer's usage history, merged from every meter kind — credit,
|
|
1293
|
+
* outcome, unit, wallet, and completed composite occurrences — into one
|
|
1294
|
+
* feed sorted by time. `GET /api/v1/signal/usage-log`. Exactly the same
|
|
1295
|
+
* rows the customer portal's own "Usage logs" table shows, so a caller can
|
|
1296
|
+
* build against this instead of the portal UI.
|
|
1297
|
+
*
|
|
1298
|
+
* Cursor-paginated, NOT page-numbered: `limit` + `cursor` in, `nextCursor`
|
|
1299
|
+
* out. Omit `cursor` for the first page; pass the previous page's
|
|
1300
|
+
* `nextCursor` back to fetch the next one, and stop once it comes back
|
|
1301
|
+
* `null`. Unlike offset pagination, the cost of a page never grows with how
|
|
1302
|
+
* deep you've paged — each page only asks for rows strictly before the
|
|
1303
|
+
* cursor's position.
|
|
1304
|
+
*
|
|
1305
|
+
* Read-only; unlike {@link track}/{@link unit}/etc., there is nothing to
|
|
1306
|
+
* buffer or retry here.
|
|
1307
|
+
*/
|
|
1308
|
+
usageLog(params) {
|
|
1309
|
+
return this.transport.request({
|
|
1310
|
+
method: "GET",
|
|
1311
|
+
path: USAGE_LOG_PATH,
|
|
1312
|
+
query: {
|
|
1313
|
+
customerId: params.customerId,
|
|
1314
|
+
limit: params.limit,
|
|
1315
|
+
cursor: params.cursor,
|
|
1316
|
+
period: params.period,
|
|
1317
|
+
from: params.from,
|
|
1318
|
+
to: params.to
|
|
1319
|
+
}
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1290
1322
|
};
|
|
1291
1323
|
|
|
1292
1324
|
// src/resources/units.ts
|