@schematichq/schematic-typescript-node 1.5.13 → 1.6.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.
Files changed (40) hide show
  1. package/dist/api/resources/credits/client/Client.d.ts +41 -5
  2. package/dist/api/resources/credits/client/requests/ReserveCreditsRequestBody.d.ts +18 -0
  3. package/dist/api/resources/credits/client/requests/index.d.ts +1 -0
  4. package/dist/api/resources/credits/types/ReleaseCreditReservationResponse.d.ts +6 -0
  5. package/dist/api/resources/credits/types/ReserveCreditsResponse.d.ts +6 -0
  6. package/dist/api/resources/credits/types/index.d.ts +2 -0
  7. package/dist/api/resources/features/client/Client.d.ts +18 -0
  8. package/dist/api/resources/features/client/requests/CheckAndReserveFlagRequestBody.d.ts +15 -0
  9. package/dist/api/resources/features/client/requests/index.d.ts +1 -0
  10. package/dist/api/resources/features/types/CheckAndReserveFlagResponse.d.ts +6 -0
  11. package/dist/api/resources/features/types/index.d.ts +1 -0
  12. package/dist/api/types/CheckAndReserveFlagResponseData.d.ts +35 -0
  13. package/dist/api/types/CreditReservationResponseData.d.ts +15 -0
  14. package/dist/api/types/CreditUsageReason.d.ts +2 -0
  15. package/dist/api/types/EventBodyTrack.d.ts +2 -0
  16. package/dist/api/types/EventDetailResponseData.d.ts +1 -0
  17. package/dist/api/types/EventResponseData.d.ts +1 -0
  18. package/dist/api/types/FlagCheckReservationResponseData.d.ts +15 -0
  19. package/dist/api/types/index.d.ts +3 -1
  20. package/dist/index.js +9 -9
  21. package/dist/serialization/resources/credits/client/requests/ReserveCreditsRequestBody.d.ts +13 -0
  22. package/dist/serialization/resources/credits/client/requests/index.d.ts +1 -0
  23. package/dist/serialization/resources/credits/types/ReleaseCreditReservationResponse.d.ts +11 -0
  24. package/dist/serialization/resources/credits/types/ReserveCreditsResponse.d.ts +11 -0
  25. package/dist/serialization/resources/credits/types/index.d.ts +2 -0
  26. package/dist/serialization/resources/features/client/requests/CheckAndReserveFlagRequestBody.d.ts +14 -0
  27. package/dist/serialization/resources/features/client/requests/index.d.ts +1 -0
  28. package/dist/serialization/resources/features/types/CheckAndReserveFlagResponse.d.ts +11 -0
  29. package/dist/serialization/resources/features/types/index.d.ts +1 -0
  30. package/dist/serialization/types/CheckAndReserveFlagResponseData.d.ts +28 -0
  31. package/dist/serialization/types/CreditReservationResponseData.d.ts +17 -0
  32. package/dist/serialization/types/CreditUsageReason.d.ts +1 -1
  33. package/dist/serialization/types/EventBodyTrack.d.ts +1 -0
  34. package/dist/serialization/types/EventDetailResponseData.d.ts +1 -0
  35. package/dist/serialization/types/EventResponseData.d.ts +1 -0
  36. package/dist/serialization/types/FlagCheckReservationResponseData.d.ts +16 -0
  37. package/dist/serialization/types/index.d.ts +3 -1
  38. package/package.json +5 -1
  39. package/dist/api/types/ReleaseCreditLeaseRequestBody.d.ts +0 -1
  40. package/dist/serialization/types/ReleaseCreditLeaseRequestBody.d.ts +0 -7
@@ -447,7 +447,6 @@ export declare class CreditsClient {
447
447
  private __extendCreditLease;
448
448
  /**
449
449
  * @param {string} lease_id - lease_id
450
- * @param {Schematic.ReleaseCreditLeaseRequestBody} request
451
450
  * @param {CreditsClient.RequestOptions} requestOptions - Request-specific configuration.
452
451
  *
453
452
  * @throws {@link Schematic.BadRequestError}
@@ -459,11 +458,9 @@ export declare class CreditsClient {
459
458
  * @throws {@link errors.SchematicTimeoutError}
460
459
  *
461
460
  * @example
462
- * await client.credits.releaseCreditLease("lease_id", {
463
- * "key": "value"
464
- * })
461
+ * await client.credits.releaseCreditLease("lease_id")
465
462
  */
466
- releaseCreditLease(lease_id: string, request: Schematic.ReleaseCreditLeaseRequestBody, requestOptions?: CreditsClient.RequestOptions): core.HttpResponsePromise<Schematic.ReleaseCreditLeaseResponse>;
463
+ releaseCreditLease(lease_id: string, requestOptions?: CreditsClient.RequestOptions): core.HttpResponsePromise<Schematic.ReleaseCreditLeaseResponse>;
467
464
  private __releaseCreditLease;
468
465
  /**
469
466
  * @param {Schematic.ListBillingPlanCreditGrantsRequest} request
@@ -597,6 +594,45 @@ export declare class CreditsClient {
597
594
  */
598
595
  countBillingPlanCreditGrants(request?: Schematic.CountBillingPlanCreditGrantsRequest, requestOptions?: CreditsClient.RequestOptions): core.HttpResponsePromise<Schematic.CountBillingPlanCreditGrantsResponse>;
599
596
  private __countBillingPlanCreditGrants;
597
+ /**
598
+ * @param {Schematic.ReserveCreditsRequestBody} request
599
+ * @param {CreditsClient.RequestOptions} requestOptions - Request-specific configuration.
600
+ *
601
+ * @throws {@link Schematic.BadRequestError}
602
+ * @throws {@link Schematic.UnauthorizedError}
603
+ * @throws {@link Schematic.PaymentRequiredError}
604
+ * @throws {@link Schematic.ForbiddenError}
605
+ * @throws {@link Schematic.NotFoundError}
606
+ * @throws {@link Schematic.InternalServerError}
607
+ * @throws {@link errors.SchematicError}
608
+ * @throws {@link errors.SchematicTimeoutError}
609
+ *
610
+ * @example
611
+ * await client.credits.reserveCredits({
612
+ * amount: 1.1,
613
+ * companyId: "company_id",
614
+ * creditTypeId: "credit_type_id"
615
+ * })
616
+ */
617
+ reserveCredits(request: Schematic.ReserveCreditsRequestBody, requestOptions?: CreditsClient.RequestOptions): core.HttpResponsePromise<Schematic.ReserveCreditsResponse>;
618
+ private __reserveCredits;
619
+ /**
620
+ * @param {string} reservation_id - reservation_id
621
+ * @param {CreditsClient.RequestOptions} requestOptions - Request-specific configuration.
622
+ *
623
+ * @throws {@link Schematic.BadRequestError}
624
+ * @throws {@link Schematic.UnauthorizedError}
625
+ * @throws {@link Schematic.ForbiddenError}
626
+ * @throws {@link Schematic.NotFoundError}
627
+ * @throws {@link Schematic.InternalServerError}
628
+ * @throws {@link errors.SchematicError}
629
+ * @throws {@link errors.SchematicTimeoutError}
630
+ *
631
+ * @example
632
+ * await client.credits.releaseCreditReservation("reservation_id")
633
+ */
634
+ releaseCreditReservation(reservation_id: string, requestOptions?: CreditsClient.RequestOptions): core.HttpResponsePromise<Schematic.ReleaseCreditReservationResponse>;
635
+ private __releaseCreditReservation;
600
636
  /**
601
637
  * @param {Schematic.ListCreditSpendPoliciesRequest} request
602
638
  * @param {CreditsClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * amount: 1.1,
5
+ * companyId: "company_id",
6
+ * creditTypeId: "credit_type_id"
7
+ * }
8
+ */
9
+ export interface ReserveCreditsRequestBody {
10
+ /** Credits to hold for the operation. The full amount must be available; a partial hold is never taken */
11
+ amount: number;
12
+ companyId: string;
13
+ creditTypeId: string;
14
+ /** When the hold lapses if no track event settles it; defaults to one minute from now and may be at most one hour out. The unspent hold is refunded on expiry */
15
+ expiresAt?: Date;
16
+ /** A caller-chosen key for safe retries: a second request with the same key returns the original reservation instead of taking another hold */
17
+ idempotencyKey?: string;
18
+ }
@@ -20,6 +20,7 @@ export type { ListCreditBundlesRequest } from "./ListCreditBundlesRequest";
20
20
  export type { ListCreditEventLedgerRequest } from "./ListCreditEventLedgerRequest";
21
21
  export type { ListCreditSpendPoliciesRequest } from "./ListCreditSpendPoliciesRequest";
22
22
  export type { ListGrantsForCreditRequest } from "./ListGrantsForCreditRequest";
23
+ export type { ReserveCreditsRequestBody } from "./ReserveCreditsRequestBody";
23
24
  export type { UpdateBillingCreditRequestBody } from "./UpdateBillingCreditRequestBody";
24
25
  export type { UpdateCreditBundleDetailsRequestBody } from "./UpdateCreditBundleDetailsRequestBody";
25
26
  export type { UpdateCreditSpendPolicyRequestBody } from "./UpdateCreditSpendPolicyRequestBody";
@@ -0,0 +1,6 @@
1
+ import type * as Schematic from "../../../index";
2
+ export interface ReleaseCreditReservationResponse {
3
+ data: Schematic.CreditReservationResponseData;
4
+ /** Input parameters */
5
+ params: Record<string, unknown>;
6
+ }
@@ -0,0 +1,6 @@
1
+ import type * as Schematic from "../../../index";
2
+ export interface ReserveCreditsResponse {
3
+ data: Schematic.CreditReservationResponseData;
4
+ /** Input parameters */
5
+ params: Record<string, unknown>;
6
+ }
@@ -44,6 +44,8 @@ export * from "./ListCreditSpendPoliciesResponse";
44
44
  export * from "./ListGrantsForCreditParams";
45
45
  export * from "./ListGrantsForCreditResponse";
46
46
  export * from "./ReleaseCreditLeaseResponse";
47
+ export * from "./ReleaseCreditReservationResponse";
48
+ export * from "./ReserveCreditsResponse";
47
49
  export * from "./SoftDeleteBillingCreditResponse";
48
50
  export * from "./UpdateBillingCreditResponse";
49
51
  export * from "./UpdateBillingPlanCreditGrantResponse";
@@ -318,6 +318,24 @@ export declare class FeaturesClient {
318
318
  */
319
319
  checkFlag(key: string, request: Schematic.CheckFlagRequestBody, requestOptions?: FeaturesClient.RequestOptions): core.HttpResponsePromise<Schematic.CheckFlagResponse>;
320
320
  private __checkFlag;
321
+ /**
322
+ * @param {string} key - key
323
+ * @param {Schematic.CheckAndReserveFlagRequestBody} request
324
+ * @param {FeaturesClient.RequestOptions} requestOptions - Request-specific configuration.
325
+ *
326
+ * @throws {@link Schematic.BadRequestError}
327
+ * @throws {@link Schematic.UnauthorizedError}
328
+ * @throws {@link Schematic.ForbiddenError}
329
+ * @throws {@link Schematic.NotFoundError}
330
+ * @throws {@link Schematic.InternalServerError}
331
+ * @throws {@link errors.SchematicError}
332
+ * @throws {@link errors.SchematicTimeoutError}
333
+ *
334
+ * @example
335
+ * await client.features.checkAndReserveFlag("key")
336
+ */
337
+ checkAndReserveFlag(key: string, request?: Schematic.CheckAndReserveFlagRequestBody, requestOptions?: FeaturesClient.RequestOptions): core.HttpResponsePromise<Schematic.CheckAndReserveFlagResponse>;
338
+ private __checkAndReserveFlag;
321
339
  /**
322
340
  * @param {Schematic.CheckFlagRequestBody} request
323
341
  * @param {FeaturesClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -0,0 +1,15 @@
1
+ import type * as Schematic from "../../../../index";
2
+ /**
3
+ * @example
4
+ * {}
5
+ */
6
+ export interface CheckAndReserveFlagRequestBody {
7
+ company?: Record<string, string>;
8
+ /** When the hold lapses if no track event settles it; defaults to one minute from now and may be at most one hour out. The unspent hold is refunded on expiry */
9
+ expiresAt?: Date;
10
+ /** Hypothetical usage to evaluate the flag against. When credit_cost names the entitlement's credit, that cost is what gets held; otherwise the hold is quantity times the entitlement's consumption rate */
11
+ preflight?: Schematic.PreflightRequestBody;
12
+ /** Units of the feature the operation will consume; defaults to 1. Sets the hold size together with the entitlement's consumption rate, and is echoed back on the reservation for the settling track event */
13
+ quantity?: number;
14
+ user?: Record<string, string>;
15
+ }
@@ -1,3 +1,4 @@
1
+ export type { CheckAndReserveFlagRequestBody } from "./CheckAndReserveFlagRequestBody";
1
2
  export type { CheckFlagsBulkRequestBody } from "./CheckFlagsBulkRequestBody";
2
3
  export type { CountFeaturesRequest } from "./CountFeaturesRequest";
3
4
  export type { CountFlagsRequest } from "./CountFlagsRequest";
@@ -0,0 +1,6 @@
1
+ import type * as Schematic from "../../../index";
2
+ export interface CheckAndReserveFlagResponse {
3
+ data: Schematic.CheckAndReserveFlagResponseData;
4
+ /** Input parameters */
5
+ params: Record<string, unknown>;
6
+ }
@@ -1,3 +1,4 @@
1
+ export * from "./CheckAndReserveFlagResponse";
1
2
  export * from "./CheckFlagResponse";
2
3
  export * from "./CheckFlagsBulkResponse";
3
4
  export * from "./CheckFlagsResponse";
@@ -0,0 +1,35 @@
1
+ import type * as Schematic from "../index";
2
+ export interface CheckAndReserveFlagResponseData {
3
+ /** If company keys were provided and matched a company, its ID */
4
+ companyId?: string;
5
+ /** If a feature entitlement rule was matched, its entitlement details */
6
+ entitlement?: Schematic.FeatureEntitlement;
7
+ /** If an error occurred while checking the flag, the error message */
8
+ error?: string;
9
+ /** Deprecated: Use Entitlement.Allocation instead. */
10
+ featureAllocation?: number;
11
+ /** Deprecated: Use Entitlement.Usage instead. */
12
+ featureUsage?: number;
13
+ /** Deprecated: Use Entitlement.EventName instead. */
14
+ featureUsageEvent?: string;
15
+ /** Deprecated: Use Entitlement.MetricPeriod instead. */
16
+ featureUsagePeriod?: Schematic.MetricPeriod;
17
+ /** Deprecated: Use Entitlement.MetricResetAt instead. */
18
+ featureUsageResetAt?: Date;
19
+ /** The key used to check the flag */
20
+ flag: string;
21
+ /** If a flag was found, its ID */
22
+ flagId?: string;
23
+ /** A human-readable explanation of the result */
24
+ reason: string;
25
+ /** The hold taken on the company's credit balance for this operation, when the flag allowed it and the feature is credit-metered. Settle it by sending a track event carrying its ID as reservation_id; the unspent hold is refunded at expires_at otherwise */
26
+ reservation?: Schematic.FlagCheckReservationResponseData;
27
+ /** If a rule was found, its ID */
28
+ ruleId?: string;
29
+ /** If a rule was found, its type */
30
+ ruleType?: Schematic.RuleType;
31
+ /** If user keys were provided and matched a user, its ID */
32
+ userId?: string;
33
+ /** A boolean flag check result; for feature entitlements, this represents whether further consumption of the feature is permitted */
34
+ value: boolean;
35
+ }
@@ -0,0 +1,15 @@
1
+ export interface CreditReservationResponseData {
2
+ companyId: string;
3
+ createdAt: Date;
4
+ creditTypeId: string;
5
+ /** When the unspent hold is refunded if no track event settles it */
6
+ expiresAt: Date;
7
+ id: string;
8
+ /** When the reservation was settled, released, or expired; null while the hold is open */
9
+ releasedAt?: Date;
10
+ /** Credits held from the company's balance for the operation */
11
+ reservedAmount: number;
12
+ /** Credits the settling track event recorded against the hold; zero until settled. May exceed reserved_amount, in which case the overage was debited from the balance, up to the overdraft limit when one is set */
13
+ settledAmount: number;
14
+ updatedAt: Date;
15
+ }
@@ -3,6 +3,8 @@ export declare const CreditUsageReason: {
3
3
  readonly LeaseRelease: "lease_release";
4
4
  readonly ManualAdjustment: "manual_adjustment";
5
5
  readonly Reconciliation: "reconciliation";
6
+ readonly ReservationHold: "reservation_hold";
7
+ readonly ReservationRelease: "reservation_release";
6
8
  readonly Track: "track";
7
9
  };
8
10
  export type CreditUsageReason = (typeof CreditUsageReason)[keyof typeof CreditUsageReason];
@@ -7,6 +7,8 @@ export interface EventBodyTrack {
7
7
  leaseId?: string;
8
8
  /** Optionally specify the quantity of the event */
9
9
  quantity?: number;
10
+ /** Credit reservation ID this track event settles. lease_id takes precedence when both are set */
11
+ reservationId?: string;
10
12
  /** A map of trait names to trait values */
11
13
  traits?: Record<string, unknown>;
12
14
  /** Key-value pairs to identify user associated with track event */
@@ -18,6 +18,7 @@ export interface EventDetailResponseData {
18
18
  loadedAt?: Date;
19
19
  processedAt?: Date;
20
20
  quantity: number;
21
+ reservationId?: string;
21
22
  sentAt?: Date;
22
23
  status: Schematic.EventStatus;
23
24
  subtype?: string;
@@ -15,6 +15,7 @@ export interface EventResponseData {
15
15
  loadedAt?: Date;
16
16
  processedAt?: Date;
17
17
  quantity: number;
18
+ reservationId?: string;
18
19
  sentAt?: Date;
19
20
  status: Schematic.EventStatus;
20
21
  subtype?: string;
@@ -0,0 +1,15 @@
1
+ export interface FlagCheckReservationResponseData {
2
+ companyId: string;
3
+ /** Credits per unit of usage the hold was priced at */
4
+ consumptionRate: number;
5
+ creditTypeId: string;
6
+ /** Credits held from the company's balance */
7
+ creditsReserved: number;
8
+ /** The event subtype the settling track event should carry */
9
+ eventSubtype?: string;
10
+ /** When the unspent hold is refunded if no track event settles it */
11
+ expiresAt: Date;
12
+ id: string;
13
+ /** Units of usage the hold covers, as requested */
14
+ quantityReserved: number;
15
+ }
@@ -79,6 +79,7 @@ export * from "./CatalogResponseData";
79
79
  export * from "./ChangeSubscriptionInternalRequestBody";
80
80
  export * from "./ChangeSubscriptionRequestBody";
81
81
  export * from "./ChargeType";
82
+ export * from "./CheckAndReserveFlagResponseData";
82
83
  export * from "./CheckFlagRequestBody";
83
84
  export * from "./CheckFlagResponseData";
84
85
  export * from "./CheckFlagsBulkResponseData";
@@ -169,6 +170,7 @@ export * from "./CreditGrantDetail";
169
170
  export * from "./CreditGrantExpiryRequestBody";
170
171
  export * from "./CreditGrantSortOrder";
171
172
  export * from "./CreditLeaseResponseData";
173
+ export * from "./CreditReservationResponseData";
172
174
  export * from "./CreditSpendPolicyResponseData";
173
175
  export * from "./CreditSpendPolicyScope";
174
176
  export * from "./CreditsAutoTopupCompanySummary";
@@ -251,6 +253,7 @@ export * from "./FeatureUsageLegacyResponseData";
251
253
  export * from "./FeatureUsageResponseData";
252
254
  export * from "./FeatureUsageTimeSeriesResponseData";
253
255
  export * from "./FeatureView";
256
+ export * from "./FlagCheckReservationResponseData";
254
257
  export * from "./FlagDetailResponseData";
255
258
  export * from "./FlagInPlanResponseData";
256
259
  export * from "./FlagResponseData";
@@ -360,7 +363,6 @@ export * from "./PublicPlansResponseData";
360
363
  export * from "./QuickstartResp";
361
364
  export * from "./RawEventBatchResponseData";
362
365
  export * from "./RawEventResponseData";
363
- export * from "./ReleaseCreditLeaseRequestBody";
364
366
  export * from "./Rule";
365
367
  export * from "./RuleConditionDetailResponseData";
366
368
  export * from "./RuleConditionGroupDetailResponseData";