@schematichq/schematic-typescript-node 1.6.0 → 1.6.1

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 (25) hide show
  1. package/README.md +49 -28
  2. package/dist/api/resources/planmigrations/client/Client.d.ts +4 -2
  3. package/dist/api/resources/planmigrations/client/requests/CountMigrationsRequest.d.ts +3 -1
  4. package/dist/api/resources/planmigrations/client/requests/ListMigrationsRequest.d.ts +3 -1
  5. package/dist/api/resources/planmigrations/types/CountMigrationsParams.d.ts +1 -0
  6. package/dist/api/resources/planmigrations/types/ListMigrationsParams.d.ts +1 -0
  7. package/dist/api/resources/plans/client/Client.d.ts +4 -0
  8. package/dist/api/resources/plans/client/requests/CountPlansRequest.d.ts +6 -0
  9. package/dist/api/resources/plans/client/requests/ListPlansRequest.d.ts +6 -0
  10. package/dist/api/resources/plans/types/CountPlansParams.d.ts +4 -0
  11. package/dist/api/resources/plans/types/ListPlansParams.d.ts +4 -0
  12. package/dist/api/types/PlanVersionMigrationResponseData.d.ts +2 -0
  13. package/dist/credits/index.d.ts +2 -2
  14. package/dist/credits/server-check.d.ts +40 -0
  15. package/dist/credits/track.d.ts +1 -1
  16. package/dist/credits/types.d.ts +36 -4
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +9 -9
  19. package/dist/serialization/resources/planmigrations/types/CountMigrationsParams.d.ts +1 -0
  20. package/dist/serialization/resources/planmigrations/types/ListMigrationsParams.d.ts +1 -0
  21. package/dist/serialization/resources/plans/types/CountPlansParams.d.ts +2 -0
  22. package/dist/serialization/resources/plans/types/ListPlansParams.d.ts +2 -0
  23. package/dist/serialization/types/PlanVersionMigrationResponseData.d.ts +2 -0
  24. package/dist/wrapper.d.ts +41 -10
  25. package/package.json +5 -1
@@ -5,6 +5,7 @@ import { PlanVersionMigrationStatus } from "../../../types/PlanVersionMigrationS
5
5
  export declare const CountMigrationsParams: core.serialization.ObjectSchema<serializers.CountMigrationsParams.Raw, Schematic.CountMigrationsParams>;
6
6
  export declare namespace CountMigrationsParams {
7
7
  interface Raw {
8
+ feature_id?: string | null;
8
9
  limit?: number | null;
9
10
  offset?: number | null;
10
11
  plan_version_id?: string | null;
@@ -5,6 +5,7 @@ import { PlanVersionMigrationStatus } from "../../../types/PlanVersionMigrationS
5
5
  export declare const ListMigrationsParams: core.serialization.ObjectSchema<serializers.ListMigrationsParams.Raw, Schematic.ListMigrationsParams>;
6
6
  export declare namespace ListMigrationsParams {
7
7
  interface Raw {
8
+ feature_id?: string | null;
8
9
  limit?: number | null;
9
10
  offset?: number | null;
10
11
  plan_version_id?: string | null;
@@ -21,7 +21,9 @@ export declare namespace CountPlansParams {
21
21
  q?: string | null;
22
22
  scoped_to_company_id?: string | null;
23
23
  with_entitlements?: boolean | null;
24
+ with_published_version?: boolean | null;
24
25
  without_entitlement_for?: string | null;
26
+ without_entitlement_for_include_drafts?: boolean | null;
25
27
  without_paid_product_id?: boolean | null;
26
28
  }
27
29
  }
@@ -21,7 +21,9 @@ export declare namespace ListPlansParams {
21
21
  q?: string | null;
22
22
  scoped_to_company_id?: string | null;
23
23
  with_entitlements?: boolean | null;
24
+ with_published_version?: boolean | null;
24
25
  without_entitlement_for?: string | null;
26
+ without_entitlement_for_include_drafts?: boolean | null;
25
27
  without_paid_product_id?: boolean | null;
26
28
  }
27
29
  }
@@ -12,6 +12,8 @@ export declare namespace PlanVersionMigrationResponseData {
12
12
  created_at: string;
13
13
  error?: string | null;
14
14
  failed_companies: number;
15
+ feature_id?: string | null;
16
+ feature_plan_rollout_id?: string | null;
15
17
  id: string;
16
18
  next_due_at?: string | null;
17
19
  plan_id: string;
package/dist/wrapper.d.ts CHANGED
@@ -55,12 +55,14 @@ export interface SchematicOptions {
55
55
  /** The default maximum time to wait for a response in milliseconds */
56
56
  timeoutMs?: number;
57
57
  /**
58
- * Enable client-side credit lease + reservation behavior on `check` /
59
- * `trackWithReservation`. Omit to keep the SDK lease-unaware.
58
+ * Enable credit reservation behavior on `check` / `trackWithReservation`.
59
+ * Omit to keep the SDK credit-unaware.
60
60
  *
61
- * Lease-bearing checks require DataStream (or replicator mode) so the
62
- * SDK has access to the cached flag + company state needed for local
63
- * gating against the lease balance.
61
+ * Client mode (local leases) requires DataStream (or replicator mode) so
62
+ * the SDK has the cached flag + company state it needs to gate locally
63
+ * against the lease balance. Without DataStream the SDK gates in server
64
+ * mode instead — one `check-and-reserve` API call per check. See
65
+ * `CreditLeaseConfig.mode`.
64
66
  */
65
67
  creditLeases?: CreditLeaseConfig;
66
68
  }
@@ -145,6 +147,8 @@ export declare class SchematicClient extends BaseClient {
145
147
  private reservations?;
146
148
  private leaseBackendShared;
147
149
  private prewarmResolveTimeoutMs;
150
+ private creditLeaseMode?;
151
+ private serverReservationTTL;
148
152
  /**
149
153
  * Creates a new instance of the SchematicClient
150
154
  * @param opts - Configuration options for the client
@@ -154,6 +158,23 @@ export declare class SchematicClient extends BaseClient {
154
158
  * Returns whether DataStream is enabled and available
155
159
  */
156
160
  private useDataStream;
161
+ /**
162
+ * Whether the configured mode wants the local lease plumbing (stores,
163
+ * manager, sweeper). Read during construction, after the DataStream client
164
+ * has been wired, so `auto` can resolve against it.
165
+ */
166
+ private creditLeaseModeUsesLeases;
167
+ /**
168
+ * Which reservation mode a `check()` with `usage` resolves to right now.
169
+ * `undefined` means no credit gating at all — `creditLeases` isn't
170
+ * configured, or the client is offline.
171
+ *
172
+ * `auto` is resolved per check rather than once at startup so a DataStream
173
+ * that failed to start after construction (its `start()` rejection clears
174
+ * `datastreamClient`) falls to server mode instead of silently dropping
175
+ * every check to a plain, ungated flag check.
176
+ */
177
+ private effectiveLeaseMode;
157
178
  /**
158
179
  * Checks the value of a feature flag for the given evaluation context
159
180
  * @param evalCtx - The context (company and/or user) for evaluating the feature flag
@@ -232,11 +253,17 @@ export declare class SchematicClient extends BaseClient {
232
253
  */
233
254
  private resolveCompanyIdWithWait;
234
255
  /**
235
- * Lease-aware feature check. When `creditLeases` is configured and the
256
+ * Credit-aware feature check. When `creditLeases` is configured and the
236
257
  * caller passes `usage` (optionally qualified by `eventSubtype`), this
237
- * acquires a lease (if needed), gates the check against the lease's local
238
- * balance via WASM, and returns a reservation handle on success — pass
239
- * that handle to `trackWithReservation` when the work completes.
258
+ * gates the check against the company's credit balance and returns a
259
+ * reservation handle on success — pass that handle to
260
+ * `trackWithReservation` when the work completes.
261
+ *
262
+ * In client mode (DataStream enabled) the hold is carved out of a local
263
+ * lease and the flag is evaluated by the WASM engine. In server mode it is
264
+ * a single `check-and-reserve` API call that evaluates the flag and takes
265
+ * the hold server-side. `creditLeases.mode` picks; the default (`auto`)
266
+ * uses client mode when DataStream is enabled and server mode otherwise.
240
267
  *
241
268
  * When `creditLeases` is not configured (or `usage` is omitted) this falls
242
269
  * through to a plain flag check and returns `{allowed: value}` with no
@@ -255,6 +282,10 @@ export declare class SchematicClient extends BaseClient {
255
282
  * `actualQuantity × consumption_rate` from the company's real credit
256
283
  * balance.
257
284
  *
285
+ * A server-mode handle has no local hold to refund: the Track event carries
286
+ * the reservation id, and the server settles the hold (refunding the
287
+ * unspent slice) when it processes the event.
288
+ *
258
289
  * If the work outlived the reservation's TTL and the sweeper already
259
290
  * returned the hold to the lease, the local refund has happened but the
260
291
  * usage must still be billed — so we emit the Track anyway (a "recovery"
@@ -269,7 +300,7 @@ export declare class SchematicClient extends BaseClient {
269
300
  * accidental second `trackWithReservation`, collapses to a single billed
270
301
  * event — across pods and process restarts, not just within one process.
271
302
  */
272
- trackWithReservation(reservation: Reservation, actualQuantity: number, options?: TrackWithReservationOptions): Promise<void>;
303
+ trackWithReservation(reservation: Reservation | undefined, actualQuantity: number, options?: TrackWithReservationOptions): Promise<void>;
273
304
  private resolveCompanyId;
274
305
  /**
275
306
  * Send a non-blocking event to create or update companies and users.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-typescript-node",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -57,6 +57,10 @@
57
57
  "crypto": false,
58
58
  "timers": false
59
59
  },
60
+ "resolutions": {
61
+ "sharp": "^0.35.4",
62
+ "undici": "7.29.0"
63
+ },
60
64
  "packageManager": "yarn@1.22.22",
61
65
  "engines": {
62
66
  "node": ">=18.0.0"