@clocknext/sdk 0.16.0 → 0.18.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 +42 -5
- package/dist/index.cjs +52 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +90 -17
- package/dist/index.d.ts +90 -17
- package/dist/index.js +52 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +4 -0
- package/src/index.ts +5 -1
- package/src/resources/signals.ts +0 -1
- package/src/resources/taxes.ts +59 -0
- package/src/types.ts +63 -17
package/dist/index.d.cts
CHANGED
|
@@ -342,8 +342,6 @@ interface TrackResult {
|
|
|
342
342
|
*/
|
|
343
343
|
rawId?: string;
|
|
344
344
|
}
|
|
345
|
-
/** A preset time window, or `"custom"` for an explicit `from`/`to` range. */
|
|
346
|
-
type UsageLogPeriod = "all" | "today" | "7d" | "30d" | "90d" | "custom";
|
|
347
345
|
interface UsageLogListParams {
|
|
348
346
|
customerId: string;
|
|
349
347
|
/** Default 50, max 200. */
|
|
@@ -351,11 +349,11 @@ interface UsageLogListParams {
|
|
|
351
349
|
/** Pass back a previous page's `nextCursor` to fetch the next page. Omit for
|
|
352
350
|
* the first page. */
|
|
353
351
|
cursor?: string;
|
|
354
|
-
/**
|
|
355
|
-
|
|
356
|
-
/** `YYYY-MM-DD`, only used when `period` is `"custom"`. */
|
|
352
|
+
/** First day to include, `YYYY-MM-DD` (UTC). The whole day is included.
|
|
353
|
+
* Keep sending the same value while paging with `cursor`. */
|
|
357
354
|
from?: string;
|
|
358
|
-
/** `YYYY-MM-DD
|
|
355
|
+
/** Last day to include, `YYYY-MM-DD` (UTC). The whole day is included.
|
|
356
|
+
* Must not be before `from`. */
|
|
359
357
|
to?: string;
|
|
360
358
|
}
|
|
361
359
|
interface UsageLogAppliedRule {
|
|
@@ -381,13 +379,14 @@ interface UsageLogOutcomeAttribution {
|
|
|
381
379
|
* One row of a customer's usage history, merged from every meter kind
|
|
382
380
|
* (`UsageLog`, `UnitUsageLog`, completed composite occurrences) into one
|
|
383
381
|
* feed and sorted by time — the same rows the customer portal's own "Usage
|
|
384
|
-
* logs" table shows. `
|
|
385
|
-
*
|
|
382
|
+
* logs" table shows. `credit`, `outcome`, `unit` and `composite` are each
|
|
383
|
+
* `null` unless `type` matches that group.
|
|
386
384
|
*/
|
|
387
385
|
interface UsageLogEntry {
|
|
388
386
|
id: string;
|
|
389
387
|
createdAt: string;
|
|
390
|
-
|
|
388
|
+
/** Which meter this row is. */
|
|
389
|
+
type: "credit" | "outcome" | "unit" | "wallet" | "composite";
|
|
391
390
|
status: SignalStatus;
|
|
392
391
|
typeName: string | null;
|
|
393
392
|
member: string | null;
|
|
@@ -408,23 +407,26 @@ interface UsageLogEntry {
|
|
|
408
407
|
providedCost: string;
|
|
409
408
|
customerCost: string;
|
|
410
409
|
};
|
|
411
|
-
/** Populated only when `
|
|
410
|
+
/** Populated only when `type === "credit"`. `amount` is a formatted credit
|
|
412
411
|
* value, honouring the org's credit-decimals display setting. */
|
|
413
412
|
credit: {
|
|
414
413
|
amount: string;
|
|
415
414
|
appliedRules: UsageLogAppliedRule[];
|
|
416
415
|
} | null;
|
|
417
|
-
/** Populated only when `
|
|
416
|
+
/** Populated only when `type === "outcome"`. */
|
|
418
417
|
outcome: UsageLogOutcomeAttribution | null;
|
|
419
|
-
/** Populated only when `
|
|
418
|
+
/** Populated only when `type === "unit"`. `quantity` is formatted. */
|
|
420
419
|
unit: {
|
|
421
420
|
quantity: string;
|
|
422
421
|
} | null;
|
|
423
|
-
/** Populated only when `
|
|
422
|
+
/** Populated only when `type === "composite"`. `amount` is a formatted USD
|
|
424
423
|
* price — the composite's flat price, read live, not stored per row. */
|
|
425
424
|
composite: {
|
|
426
425
|
amount: string;
|
|
427
426
|
} | null;
|
|
427
|
+
/** The `custom` object sent on the signal, as sent. `null` when none was
|
|
428
|
+
* sent, and always `null` for unit and composite rows. */
|
|
429
|
+
custom: Record<string, unknown> | null;
|
|
428
430
|
}
|
|
429
431
|
interface UsageLogPage {
|
|
430
432
|
usageLogs: UsageLogEntry[];
|
|
@@ -713,8 +715,10 @@ interface CreatePlanInput {
|
|
|
713
715
|
type UpdatePlanInput = Partial<CreatePlanInput>;
|
|
714
716
|
/** One model line of a credit's / outcome step's pricing bundle, as returned. */
|
|
715
717
|
interface ModelBundleLine {
|
|
716
|
-
/** The
|
|
717
|
-
|
|
718
|
+
/** The model's id — the same one a usage signal sends as `usage.model`.
|
|
719
|
+
* `null` only when the model was removed from the workspace after this
|
|
720
|
+
* bundle was saved (the line keeps its name and stored price). */
|
|
721
|
+
modelId: string | null;
|
|
718
722
|
/** The model's display name, filled in by the server. */
|
|
719
723
|
modelName: string;
|
|
720
724
|
/** Average tokens one LLM call uses on this model. */
|
|
@@ -730,7 +734,10 @@ interface ModelBundleLine {
|
|
|
730
734
|
* the price is the sum of their costs, worked out on the server from the
|
|
731
735
|
* models' live prices. */
|
|
732
736
|
interface ModelBundleLineInput {
|
|
733
|
-
|
|
737
|
+
/** The model's id, e.g. `"gpt-4o"` — the same one a usage signal sends as
|
|
738
|
+
* `usage.model`. Matched ignoring case; it must be enabled in your
|
|
739
|
+
* workspace. */
|
|
740
|
+
modelId: string;
|
|
734
741
|
/** Above 0. */
|
|
735
742
|
averageTokensPerLLMCall: number;
|
|
736
743
|
input: number;
|
|
@@ -873,6 +880,42 @@ interface CreateUnitInput {
|
|
|
873
880
|
}
|
|
874
881
|
/** `units.update()` body — PARTIAL. `tiers`, when sent, is the complete list. */
|
|
875
882
|
type UpdateUnitInput = Partial<CreateUnitInput>;
|
|
883
|
+
/** How a tax applies: `"inclusive"` — already inside the price;
|
|
884
|
+
* `"exclusive"` — added on top. Lower case only. */
|
|
885
|
+
type TaxBehavior = "inclusive" | "exclusive";
|
|
886
|
+
/** A tax rate, charged to customers whose billing country matches. */
|
|
887
|
+
interface Tax {
|
|
888
|
+
id: string;
|
|
889
|
+
/** Shown on invoices. Unique among active taxes in the same country,
|
|
890
|
+
* ignoring case. */
|
|
891
|
+
name: string;
|
|
892
|
+
/** A note for your team; not shown to customers. */
|
|
893
|
+
description: string | null;
|
|
894
|
+
/** 0–100. */
|
|
895
|
+
percentage: number;
|
|
896
|
+
/** ISO 3166-1 alpha-2, upper case (e.g. `"IN"`). */
|
|
897
|
+
countryCode: string;
|
|
898
|
+
behavior: TaxBehavior;
|
|
899
|
+
/** `false` once archived in the dashboard (Settings → Taxes): it no longer
|
|
900
|
+
* applies to new invoices. */
|
|
901
|
+
isActive: boolean;
|
|
902
|
+
createdAt: string;
|
|
903
|
+
updatedAt: string;
|
|
904
|
+
}
|
|
905
|
+
/** `taxes.create()` body. */
|
|
906
|
+
interface CreateTaxInput {
|
|
907
|
+
/** 1–100 characters. */
|
|
908
|
+
name: string;
|
|
909
|
+
/** 0–100. */
|
|
910
|
+
percentage: number;
|
|
911
|
+
/** ISO 3166-1 alpha-2 (lower case is accepted). A country name is refused. */
|
|
912
|
+
countryCode: string;
|
|
913
|
+
behavior: TaxBehavior;
|
|
914
|
+
/** Up to 500 characters. */
|
|
915
|
+
description?: string | null;
|
|
916
|
+
}
|
|
917
|
+
/** `taxes.update()` body — PARTIAL: only the fields you send change. */
|
|
918
|
+
type UpdateTaxInput = Partial<CreateTaxInput>;
|
|
876
919
|
/** A catalogue item a composite wraps. */
|
|
877
920
|
interface CompositeItem {
|
|
878
921
|
id: string;
|
|
@@ -2206,6 +2249,34 @@ declare class Units {
|
|
|
2206
2249
|
unarchive(id: string): Promise<Unit>;
|
|
2207
2250
|
}
|
|
2208
2251
|
|
|
2252
|
+
/**
|
|
2253
|
+
* The `taxes` resource — the tax rates charged to customers by billing
|
|
2254
|
+
* country (the same rates as Settings → Taxes). `/api/v1/taxes`.
|
|
2255
|
+
*
|
|
2256
|
+
* Every active tax for a customer's country is applied to their invoices and
|
|
2257
|
+
* portal purchases automatically. There is no `delete()`, `archive()` or
|
|
2258
|
+
* `unarchive()` — archiving and restoring a tax is done in the dashboard.
|
|
2259
|
+
*/
|
|
2260
|
+
declare class Taxes {
|
|
2261
|
+
private readonly transport;
|
|
2262
|
+
constructor(transport: Transport);
|
|
2263
|
+
/** List them, oldest first. `{ active: true }` returns only active ones,
|
|
2264
|
+
* `{ active: false }` only archived ones; omit it for both. */
|
|
2265
|
+
list(params?: {
|
|
2266
|
+
active?: boolean;
|
|
2267
|
+
}): Promise<Tax[]>;
|
|
2268
|
+
/** One tax. */
|
|
2269
|
+
get(id: string): Promise<Tax>;
|
|
2270
|
+
/** Create one. It starts active. Two active taxes can't share a name
|
|
2271
|
+
* (ignoring case) in the same country — that's a `ConflictError`. Not
|
|
2272
|
+
* retried on failure — a retry could create a second row. */
|
|
2273
|
+
create(input: CreateTaxInput): Promise<Tax>;
|
|
2274
|
+
/** PARTIAL update: only the fields you send change. Archived taxes can be
|
|
2275
|
+
* edited and stay archived. Only invoices issued afterwards use the new
|
|
2276
|
+
* values. */
|
|
2277
|
+
update(id: string, input: UpdateTaxInput): Promise<Tax>;
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2209
2280
|
/**
|
|
2210
2281
|
* The ClockNext client.
|
|
2211
2282
|
*
|
|
@@ -2238,6 +2309,8 @@ declare class ClockNext {
|
|
|
2238
2309
|
readonly units: Units;
|
|
2239
2310
|
/** Composites: list, get, create, update, archive, unarchive (no delete). */
|
|
2240
2311
|
readonly composites: Composites;
|
|
2312
|
+
/** Tax rates by country: list, get, create, update (archive in the dashboard). */
|
|
2313
|
+
readonly taxes: Taxes;
|
|
2241
2314
|
/** Subscribe customers to plans (purchases). */
|
|
2242
2315
|
readonly purchases: Purchases;
|
|
2243
2316
|
/** Read invoices and mint hosted pay links. */
|
|
@@ -2333,4 +2406,4 @@ declare class NetworkError extends ClockNextError {
|
|
|
2333
2406
|
});
|
|
2334
2407
|
}
|
|
2335
2408
|
|
|
2336
|
-
export { type AddMemberInput, type AdjustResult, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type Composite, type CompositeAdjustInput, type CompositeBalance, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeItem, type CompositeTag, ConflictError, type CreateCompositeInput, type CreateCreditInput, type CreateCustomerInput, type CreateOutcomeInput, type CreatePlanInput, type CreatePurchaseInput, type CreateUnitInput, type Credit, type CreditAdjustInput, type CreditBalance, type CreditInput, type CreditSignal, type CustomerBalances, type CustomerList, type CustomerPlan, type CustomerPlanDetails, type CustomerProfileInput, type CustomerRef, type DropReason, type FetchLike, ForbiddenError, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListRow, type InvoiceParty, type InvoicePlanSnapshot, type InvoiceStatus, type Logger, type Member, type MemberProfile, type ModelBundleLine, type ModelBundleLineInput, NetworkError, NotFoundError, type Outcome, type OutcomeAdjustInput, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeInput, type OutcomeSignal, type OutcomeStep, type OutcomeStepInput, type OutcomeWithSteps, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, type PlanEntitlement, type PlanEntitlementInput, PlanError, type PlanKind, type PlanRef, type PlanType, type PortalToken, type PortalTokenInput, type Purchase, type PurchaseDetail, type PurchaseStatus, RateLimitError, type RecurringGrantInput, type RecurringGrantResult, type RemovedMember, type SerializedOutcomeAttribution, type SerializedRuleApplication, type SerializedUnitUsage, type SerializedUsageLog, ServerError, type Signal, type SignalDelivery, type SignalStatus, type SignalType, type Tokens, type TrackResult, type Unit, type UnitAdjustInput, type UnitBalance, type UnitInput, type UnitPricingType, type UnitTier, type UnitTrackResult, type UpdateCompositeInput, type UpdateCreditInput, type UpdateMemberInput, type UpdateOutcomeInput, type UpdatePlanInput, type UpdateUnitInput, type UsageBalance, type UsageLogAppliedRule, type UsageLogEntry, type UsageLogListParams, type UsageLogOutcomeAttribution, type UsageLogPage,
|
|
2409
|
+
export { type AddMemberInput, type AdjustResult, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type Composite, type CompositeAdjustInput, type CompositeBalance, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeItem, type CompositeTag, ConflictError, type CreateCompositeInput, type CreateCreditInput, type CreateCustomerInput, type CreateOutcomeInput, type CreatePlanInput, type CreatePurchaseInput, type CreateTaxInput, type CreateUnitInput, type Credit, type CreditAdjustInput, type CreditBalance, type CreditInput, type CreditSignal, type CustomerBalances, type CustomerList, type CustomerPlan, type CustomerPlanDetails, type CustomerProfileInput, type CustomerRef, type DropReason, type FetchLike, ForbiddenError, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListRow, type InvoiceParty, type InvoicePlanSnapshot, type InvoiceStatus, type Logger, type Member, type MemberProfile, type ModelBundleLine, type ModelBundleLineInput, NetworkError, NotFoundError, type Outcome, type OutcomeAdjustInput, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeInput, type OutcomeSignal, type OutcomeStep, type OutcomeStepInput, type OutcomeWithSteps, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, type PlanEntitlement, type PlanEntitlementInput, PlanError, type PlanKind, type PlanRef, type PlanType, type PortalToken, type PortalTokenInput, type Purchase, type PurchaseDetail, type PurchaseStatus, RateLimitError, type RecurringGrantInput, type RecurringGrantResult, type RemovedMember, type SerializedOutcomeAttribution, type SerializedRuleApplication, type SerializedUnitUsage, type SerializedUsageLog, ServerError, type Signal, type SignalDelivery, type SignalStatus, type SignalType, type Tax, type TaxBehavior, type Tokens, type TrackResult, type Unit, type UnitAdjustInput, type UnitBalance, type UnitInput, type UnitPricingType, type UnitTier, type UnitTrackResult, type UpdateCompositeInput, type UpdateCreditInput, type UpdateMemberInput, type UpdateOutcomeInput, type UpdatePlanInput, type UpdateTaxInput, type UpdateUnitInput, type UsageBalance, type UsageLogAppliedRule, type UsageLogEntry, type UsageLogListParams, type UsageLogOutcomeAttribution, type UsageLogPage, ValidationError, type WalletAdjustInput, type WalletInput, type WalletPool, type WalletSignal, signalToWire };
|
package/dist/index.d.ts
CHANGED
|
@@ -342,8 +342,6 @@ interface TrackResult {
|
|
|
342
342
|
*/
|
|
343
343
|
rawId?: string;
|
|
344
344
|
}
|
|
345
|
-
/** A preset time window, or `"custom"` for an explicit `from`/`to` range. */
|
|
346
|
-
type UsageLogPeriod = "all" | "today" | "7d" | "30d" | "90d" | "custom";
|
|
347
345
|
interface UsageLogListParams {
|
|
348
346
|
customerId: string;
|
|
349
347
|
/** Default 50, max 200. */
|
|
@@ -351,11 +349,11 @@ interface UsageLogListParams {
|
|
|
351
349
|
/** Pass back a previous page's `nextCursor` to fetch the next page. Omit for
|
|
352
350
|
* the first page. */
|
|
353
351
|
cursor?: string;
|
|
354
|
-
/**
|
|
355
|
-
|
|
356
|
-
/** `YYYY-MM-DD`, only used when `period` is `"custom"`. */
|
|
352
|
+
/** First day to include, `YYYY-MM-DD` (UTC). The whole day is included.
|
|
353
|
+
* Keep sending the same value while paging with `cursor`. */
|
|
357
354
|
from?: string;
|
|
358
|
-
/** `YYYY-MM-DD
|
|
355
|
+
/** Last day to include, `YYYY-MM-DD` (UTC). The whole day is included.
|
|
356
|
+
* Must not be before `from`. */
|
|
359
357
|
to?: string;
|
|
360
358
|
}
|
|
361
359
|
interface UsageLogAppliedRule {
|
|
@@ -381,13 +379,14 @@ interface UsageLogOutcomeAttribution {
|
|
|
381
379
|
* One row of a customer's usage history, merged from every meter kind
|
|
382
380
|
* (`UsageLog`, `UnitUsageLog`, completed composite occurrences) into one
|
|
383
381
|
* feed and sorted by time — the same rows the customer portal's own "Usage
|
|
384
|
-
* logs" table shows. `
|
|
385
|
-
*
|
|
382
|
+
* logs" table shows. `credit`, `outcome`, `unit` and `composite` are each
|
|
383
|
+
* `null` unless `type` matches that group.
|
|
386
384
|
*/
|
|
387
385
|
interface UsageLogEntry {
|
|
388
386
|
id: string;
|
|
389
387
|
createdAt: string;
|
|
390
|
-
|
|
388
|
+
/** Which meter this row is. */
|
|
389
|
+
type: "credit" | "outcome" | "unit" | "wallet" | "composite";
|
|
391
390
|
status: SignalStatus;
|
|
392
391
|
typeName: string | null;
|
|
393
392
|
member: string | null;
|
|
@@ -408,23 +407,26 @@ interface UsageLogEntry {
|
|
|
408
407
|
providedCost: string;
|
|
409
408
|
customerCost: string;
|
|
410
409
|
};
|
|
411
|
-
/** Populated only when `
|
|
410
|
+
/** Populated only when `type === "credit"`. `amount` is a formatted credit
|
|
412
411
|
* value, honouring the org's credit-decimals display setting. */
|
|
413
412
|
credit: {
|
|
414
413
|
amount: string;
|
|
415
414
|
appliedRules: UsageLogAppliedRule[];
|
|
416
415
|
} | null;
|
|
417
|
-
/** Populated only when `
|
|
416
|
+
/** Populated only when `type === "outcome"`. */
|
|
418
417
|
outcome: UsageLogOutcomeAttribution | null;
|
|
419
|
-
/** Populated only when `
|
|
418
|
+
/** Populated only when `type === "unit"`. `quantity` is formatted. */
|
|
420
419
|
unit: {
|
|
421
420
|
quantity: string;
|
|
422
421
|
} | null;
|
|
423
|
-
/** Populated only when `
|
|
422
|
+
/** Populated only when `type === "composite"`. `amount` is a formatted USD
|
|
424
423
|
* price — the composite's flat price, read live, not stored per row. */
|
|
425
424
|
composite: {
|
|
426
425
|
amount: string;
|
|
427
426
|
} | null;
|
|
427
|
+
/** The `custom` object sent on the signal, as sent. `null` when none was
|
|
428
|
+
* sent, and always `null` for unit and composite rows. */
|
|
429
|
+
custom: Record<string, unknown> | null;
|
|
428
430
|
}
|
|
429
431
|
interface UsageLogPage {
|
|
430
432
|
usageLogs: UsageLogEntry[];
|
|
@@ -713,8 +715,10 @@ interface CreatePlanInput {
|
|
|
713
715
|
type UpdatePlanInput = Partial<CreatePlanInput>;
|
|
714
716
|
/** One model line of a credit's / outcome step's pricing bundle, as returned. */
|
|
715
717
|
interface ModelBundleLine {
|
|
716
|
-
/** The
|
|
717
|
-
|
|
718
|
+
/** The model's id — the same one a usage signal sends as `usage.model`.
|
|
719
|
+
* `null` only when the model was removed from the workspace after this
|
|
720
|
+
* bundle was saved (the line keeps its name and stored price). */
|
|
721
|
+
modelId: string | null;
|
|
718
722
|
/** The model's display name, filled in by the server. */
|
|
719
723
|
modelName: string;
|
|
720
724
|
/** Average tokens one LLM call uses on this model. */
|
|
@@ -730,7 +734,10 @@ interface ModelBundleLine {
|
|
|
730
734
|
* the price is the sum of their costs, worked out on the server from the
|
|
731
735
|
* models' live prices. */
|
|
732
736
|
interface ModelBundleLineInput {
|
|
733
|
-
|
|
737
|
+
/** The model's id, e.g. `"gpt-4o"` — the same one a usage signal sends as
|
|
738
|
+
* `usage.model`. Matched ignoring case; it must be enabled in your
|
|
739
|
+
* workspace. */
|
|
740
|
+
modelId: string;
|
|
734
741
|
/** Above 0. */
|
|
735
742
|
averageTokensPerLLMCall: number;
|
|
736
743
|
input: number;
|
|
@@ -873,6 +880,42 @@ interface CreateUnitInput {
|
|
|
873
880
|
}
|
|
874
881
|
/** `units.update()` body — PARTIAL. `tiers`, when sent, is the complete list. */
|
|
875
882
|
type UpdateUnitInput = Partial<CreateUnitInput>;
|
|
883
|
+
/** How a tax applies: `"inclusive"` — already inside the price;
|
|
884
|
+
* `"exclusive"` — added on top. Lower case only. */
|
|
885
|
+
type TaxBehavior = "inclusive" | "exclusive";
|
|
886
|
+
/** A tax rate, charged to customers whose billing country matches. */
|
|
887
|
+
interface Tax {
|
|
888
|
+
id: string;
|
|
889
|
+
/** Shown on invoices. Unique among active taxes in the same country,
|
|
890
|
+
* ignoring case. */
|
|
891
|
+
name: string;
|
|
892
|
+
/** A note for your team; not shown to customers. */
|
|
893
|
+
description: string | null;
|
|
894
|
+
/** 0–100. */
|
|
895
|
+
percentage: number;
|
|
896
|
+
/** ISO 3166-1 alpha-2, upper case (e.g. `"IN"`). */
|
|
897
|
+
countryCode: string;
|
|
898
|
+
behavior: TaxBehavior;
|
|
899
|
+
/** `false` once archived in the dashboard (Settings → Taxes): it no longer
|
|
900
|
+
* applies to new invoices. */
|
|
901
|
+
isActive: boolean;
|
|
902
|
+
createdAt: string;
|
|
903
|
+
updatedAt: string;
|
|
904
|
+
}
|
|
905
|
+
/** `taxes.create()` body. */
|
|
906
|
+
interface CreateTaxInput {
|
|
907
|
+
/** 1–100 characters. */
|
|
908
|
+
name: string;
|
|
909
|
+
/** 0–100. */
|
|
910
|
+
percentage: number;
|
|
911
|
+
/** ISO 3166-1 alpha-2 (lower case is accepted). A country name is refused. */
|
|
912
|
+
countryCode: string;
|
|
913
|
+
behavior: TaxBehavior;
|
|
914
|
+
/** Up to 500 characters. */
|
|
915
|
+
description?: string | null;
|
|
916
|
+
}
|
|
917
|
+
/** `taxes.update()` body — PARTIAL: only the fields you send change. */
|
|
918
|
+
type UpdateTaxInput = Partial<CreateTaxInput>;
|
|
876
919
|
/** A catalogue item a composite wraps. */
|
|
877
920
|
interface CompositeItem {
|
|
878
921
|
id: string;
|
|
@@ -2206,6 +2249,34 @@ declare class Units {
|
|
|
2206
2249
|
unarchive(id: string): Promise<Unit>;
|
|
2207
2250
|
}
|
|
2208
2251
|
|
|
2252
|
+
/**
|
|
2253
|
+
* The `taxes` resource — the tax rates charged to customers by billing
|
|
2254
|
+
* country (the same rates as Settings → Taxes). `/api/v1/taxes`.
|
|
2255
|
+
*
|
|
2256
|
+
* Every active tax for a customer's country is applied to their invoices and
|
|
2257
|
+
* portal purchases automatically. There is no `delete()`, `archive()` or
|
|
2258
|
+
* `unarchive()` — archiving and restoring a tax is done in the dashboard.
|
|
2259
|
+
*/
|
|
2260
|
+
declare class Taxes {
|
|
2261
|
+
private readonly transport;
|
|
2262
|
+
constructor(transport: Transport);
|
|
2263
|
+
/** List them, oldest first. `{ active: true }` returns only active ones,
|
|
2264
|
+
* `{ active: false }` only archived ones; omit it for both. */
|
|
2265
|
+
list(params?: {
|
|
2266
|
+
active?: boolean;
|
|
2267
|
+
}): Promise<Tax[]>;
|
|
2268
|
+
/** One tax. */
|
|
2269
|
+
get(id: string): Promise<Tax>;
|
|
2270
|
+
/** Create one. It starts active. Two active taxes can't share a name
|
|
2271
|
+
* (ignoring case) in the same country — that's a `ConflictError`. Not
|
|
2272
|
+
* retried on failure — a retry could create a second row. */
|
|
2273
|
+
create(input: CreateTaxInput): Promise<Tax>;
|
|
2274
|
+
/** PARTIAL update: only the fields you send change. Archived taxes can be
|
|
2275
|
+
* edited and stay archived. Only invoices issued afterwards use the new
|
|
2276
|
+
* values. */
|
|
2277
|
+
update(id: string, input: UpdateTaxInput): Promise<Tax>;
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2209
2280
|
/**
|
|
2210
2281
|
* The ClockNext client.
|
|
2211
2282
|
*
|
|
@@ -2238,6 +2309,8 @@ declare class ClockNext {
|
|
|
2238
2309
|
readonly units: Units;
|
|
2239
2310
|
/** Composites: list, get, create, update, archive, unarchive (no delete). */
|
|
2240
2311
|
readonly composites: Composites;
|
|
2312
|
+
/** Tax rates by country: list, get, create, update (archive in the dashboard). */
|
|
2313
|
+
readonly taxes: Taxes;
|
|
2241
2314
|
/** Subscribe customers to plans (purchases). */
|
|
2242
2315
|
readonly purchases: Purchases;
|
|
2243
2316
|
/** Read invoices and mint hosted pay links. */
|
|
@@ -2333,4 +2406,4 @@ declare class NetworkError extends ClockNextError {
|
|
|
2333
2406
|
});
|
|
2334
2407
|
}
|
|
2335
2408
|
|
|
2336
|
-
export { type AddMemberInput, type AdjustResult, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type Composite, type CompositeAdjustInput, type CompositeBalance, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeItem, type CompositeTag, ConflictError, type CreateCompositeInput, type CreateCreditInput, type CreateCustomerInput, type CreateOutcomeInput, type CreatePlanInput, type CreatePurchaseInput, type CreateUnitInput, type Credit, type CreditAdjustInput, type CreditBalance, type CreditInput, type CreditSignal, type CustomerBalances, type CustomerList, type CustomerPlan, type CustomerPlanDetails, type CustomerProfileInput, type CustomerRef, type DropReason, type FetchLike, ForbiddenError, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListRow, type InvoiceParty, type InvoicePlanSnapshot, type InvoiceStatus, type Logger, type Member, type MemberProfile, type ModelBundleLine, type ModelBundleLineInput, NetworkError, NotFoundError, type Outcome, type OutcomeAdjustInput, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeInput, type OutcomeSignal, type OutcomeStep, type OutcomeStepInput, type OutcomeWithSteps, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, type PlanEntitlement, type PlanEntitlementInput, PlanError, type PlanKind, type PlanRef, type PlanType, type PortalToken, type PortalTokenInput, type Purchase, type PurchaseDetail, type PurchaseStatus, RateLimitError, type RecurringGrantInput, type RecurringGrantResult, type RemovedMember, type SerializedOutcomeAttribution, type SerializedRuleApplication, type SerializedUnitUsage, type SerializedUsageLog, ServerError, type Signal, type SignalDelivery, type SignalStatus, type SignalType, type Tokens, type TrackResult, type Unit, type UnitAdjustInput, type UnitBalance, type UnitInput, type UnitPricingType, type UnitTier, type UnitTrackResult, type UpdateCompositeInput, type UpdateCreditInput, type UpdateMemberInput, type UpdateOutcomeInput, type UpdatePlanInput, type UpdateUnitInput, type UsageBalance, type UsageLogAppliedRule, type UsageLogEntry, type UsageLogListParams, type UsageLogOutcomeAttribution, type UsageLogPage,
|
|
2409
|
+
export { type AddMemberInput, type AdjustResult, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type Composite, type CompositeAdjustInput, type CompositeBalance, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeItem, type CompositeTag, ConflictError, type CreateCompositeInput, type CreateCreditInput, type CreateCustomerInput, type CreateOutcomeInput, type CreatePlanInput, type CreatePurchaseInput, type CreateTaxInput, type CreateUnitInput, type Credit, type CreditAdjustInput, type CreditBalance, type CreditInput, type CreditSignal, type CustomerBalances, type CustomerList, type CustomerPlan, type CustomerPlanDetails, type CustomerProfileInput, type CustomerRef, type DropReason, type FetchLike, ForbiddenError, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListRow, type InvoiceParty, type InvoicePlanSnapshot, type InvoiceStatus, type Logger, type Member, type MemberProfile, type ModelBundleLine, type ModelBundleLineInput, NetworkError, NotFoundError, type Outcome, type OutcomeAdjustInput, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeInput, type OutcomeSignal, type OutcomeStep, type OutcomeStepInput, type OutcomeWithSteps, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, type PlanEntitlement, type PlanEntitlementInput, PlanError, type PlanKind, type PlanRef, type PlanType, type PortalToken, type PortalTokenInput, type Purchase, type PurchaseDetail, type PurchaseStatus, RateLimitError, type RecurringGrantInput, type RecurringGrantResult, type RemovedMember, type SerializedOutcomeAttribution, type SerializedRuleApplication, type SerializedUnitUsage, type SerializedUsageLog, ServerError, type Signal, type SignalDelivery, type SignalStatus, type SignalType, type Tax, type TaxBehavior, type Tokens, type TrackResult, type Unit, type UnitAdjustInput, type UnitBalance, type UnitInput, type UnitPricingType, type UnitTier, type UnitTrackResult, type UpdateCompositeInput, type UpdateCreditInput, type UpdateMemberInput, type UpdateOutcomeInput, type UpdatePlanInput, type UpdateTaxInput, type UpdateUnitInput, type UsageBalance, type UsageLogAppliedRule, type UsageLogEntry, type UsageLogListParams, type UsageLogOutcomeAttribution, type UsageLogPage, ValidationError, type WalletAdjustInput, type WalletInput, type WalletPool, type WalletSignal, signalToWire };
|
package/dist/index.js
CHANGED
|
@@ -331,7 +331,7 @@ function sleep(ms) {
|
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
// src/http.ts
|
|
334
|
-
var SDK_VERSION = "0.
|
|
334
|
+
var SDK_VERSION = "0.18.0" ;
|
|
335
335
|
var Transport = class {
|
|
336
336
|
constructor(cfg) {
|
|
337
337
|
this.cfg = cfg;
|
|
@@ -1439,7 +1439,6 @@ var Signals = class {
|
|
|
1439
1439
|
customerId: params.customerId,
|
|
1440
1440
|
limit: params.limit,
|
|
1441
1441
|
cursor: params.cursor,
|
|
1442
|
-
period: params.period,
|
|
1443
1442
|
from: params.from,
|
|
1444
1443
|
to: params.to
|
|
1445
1444
|
}
|
|
@@ -1511,6 +1510,54 @@ var Units = class {
|
|
|
1511
1510
|
}
|
|
1512
1511
|
};
|
|
1513
1512
|
|
|
1513
|
+
// src/resources/taxes.ts
|
|
1514
|
+
var Taxes = class {
|
|
1515
|
+
constructor(transport) {
|
|
1516
|
+
this.transport = transport;
|
|
1517
|
+
}
|
|
1518
|
+
transport;
|
|
1519
|
+
/** List them, oldest first. `{ active: true }` returns only active ones,
|
|
1520
|
+
* `{ active: false }` only archived ones; omit it for both. */
|
|
1521
|
+
async list(params = {}) {
|
|
1522
|
+
const res = await this.transport.request({
|
|
1523
|
+
method: "GET",
|
|
1524
|
+
path: "/api/v1/taxes",
|
|
1525
|
+
query: { active: activeQuery(params.active) }
|
|
1526
|
+
});
|
|
1527
|
+
return filterByActive(res.taxes, params.active);
|
|
1528
|
+
}
|
|
1529
|
+
/** One tax. */
|
|
1530
|
+
async get(id) {
|
|
1531
|
+
const res = await this.transport.request({
|
|
1532
|
+
method: "GET",
|
|
1533
|
+
path: `/api/v1/taxes/${encodeURIComponent(id)}`
|
|
1534
|
+
});
|
|
1535
|
+
return res.tax;
|
|
1536
|
+
}
|
|
1537
|
+
/** Create one. It starts active. Two active taxes can't share a name
|
|
1538
|
+
* (ignoring case) in the same country — that's a `ConflictError`. Not
|
|
1539
|
+
* retried on failure — a retry could create a second row. */
|
|
1540
|
+
async create(input) {
|
|
1541
|
+
const res = await this.transport.request({
|
|
1542
|
+
method: "POST",
|
|
1543
|
+
path: "/api/v1/taxes",
|
|
1544
|
+
body: input
|
|
1545
|
+
});
|
|
1546
|
+
return res.tax;
|
|
1547
|
+
}
|
|
1548
|
+
/** PARTIAL update: only the fields you send change. Archived taxes can be
|
|
1549
|
+
* edited and stay archived. Only invoices issued afterwards use the new
|
|
1550
|
+
* values. */
|
|
1551
|
+
async update(id, input) {
|
|
1552
|
+
const res = await this.transport.request({
|
|
1553
|
+
method: "PATCH",
|
|
1554
|
+
path: `/api/v1/taxes/${encodeURIComponent(id)}`,
|
|
1555
|
+
body: input
|
|
1556
|
+
});
|
|
1557
|
+
return res.tax;
|
|
1558
|
+
}
|
|
1559
|
+
};
|
|
1560
|
+
|
|
1514
1561
|
// src/client.ts
|
|
1515
1562
|
var ClockNext = class {
|
|
1516
1563
|
/** Record usage signals (credit / wallet / outcome / unit) and read the usage log. */
|
|
@@ -1527,6 +1574,8 @@ var ClockNext = class {
|
|
|
1527
1574
|
units;
|
|
1528
1575
|
/** Composites: list, get, create, update, archive, unarchive (no delete). */
|
|
1529
1576
|
composites;
|
|
1577
|
+
/** Tax rates by country: list, get, create, update (archive in the dashboard). */
|
|
1578
|
+
taxes;
|
|
1530
1579
|
/** Subscribe customers to plans (purchases). */
|
|
1531
1580
|
purchases;
|
|
1532
1581
|
/** Read invoices and mint hosted pay links. */
|
|
@@ -1553,6 +1602,7 @@ var ClockNext = class {
|
|
|
1553
1602
|
this.outcomes = new Outcomes(transport);
|
|
1554
1603
|
this.units = new Units(transport);
|
|
1555
1604
|
this.composites = new Composites(transport);
|
|
1605
|
+
this.taxes = new Taxes(transport);
|
|
1556
1606
|
this.purchases = new Purchases(transport);
|
|
1557
1607
|
this.invoices = new Invoices(transport);
|
|
1558
1608
|
this.payments = new Payments(transport);
|