@revturbine/sdk 0.11.10 → 0.11.11

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.
@@ -212,10 +212,73 @@ declare const UserPlanContextSchema: z.ZodObject<{
212
212
  none: "none";
213
213
  }>>;
214
214
  }, z.core.$strip>;
215
+ /**
216
+ * Server-evaluated built-in segment dimension values for the user (plan 279
217
+ * PD-3). `buildTargetingState` stamps each present, in-vocabulary leaf onto
218
+ * the reserved `rt_<dimension>` segment trait; nothing else may set an `rt_*`
219
+ * trait (PD-1). An ABSENT leaf means "not evaluated" and stamps nothing, so
220
+ * every built-in of that dimension fails closed (PD-4, unknown is absence);
221
+ * when the control plane evaluated a dimension and found no classification it
222
+ * delivers the dimension's explicit fallback value instead.
223
+ *
224
+ * Assembled at retrieval — never persisted as a blob; the sources keep their
225
+ * own columns.
226
+ */
227
+ declare const UserBuiltinDimensionsSchema: z.ZodObject<{
228
+ activity_level: z.ZodOptional<z.ZodEnum<{
229
+ inactive: "inactive";
230
+ new: "new";
231
+ high: "high";
232
+ medium: "medium";
233
+ low: "low";
234
+ }>>;
235
+ subscription_state: z.ZodOptional<z.ZodEnum<{
236
+ trial: "trial";
237
+ none: "none";
238
+ paid: "paid";
239
+ cancelled: "cancelled";
240
+ }>>;
241
+ trial_type: z.ZodOptional<z.ZodEnum<{
242
+ none: "none";
243
+ free_trial: "free_trial";
244
+ reverse_trial: "reverse_trial";
245
+ }>>;
246
+ seat_type: z.ZodOptional<z.ZodString>;
247
+ buyer_role: z.ZodOptional<z.ZodEnum<{
248
+ buyer: "buyer";
249
+ non_buyer: "non_buyer";
250
+ }>>;
251
+ email_type: z.ZodOptional<z.ZodEnum<{
252
+ unknown: "unknown";
253
+ business: "business";
254
+ personal: "personal";
255
+ }>>;
256
+ billing_health: z.ZodOptional<z.ZodEnum<{
257
+ payment_failed: "payment_failed";
258
+ payment_method_missing: "payment_method_missing";
259
+ cancelled: "cancelled";
260
+ no_billing: "no_billing";
261
+ good_standing: "good_standing";
262
+ trial_payment_method_attached: "trial_payment_method_attached";
263
+ payment_overdue: "payment_overdue";
264
+ }>>;
265
+ region: z.ZodOptional<z.ZodEnum<{
266
+ us_canada: "us_canada";
267
+ europe: "europe";
268
+ rest_of_world: "rest_of_world";
269
+ }>>;
270
+ device_type: z.ZodOptional<z.ZodEnum<{
271
+ unknown: "unknown";
272
+ desktop: "desktop";
273
+ mobile: "mobile";
274
+ tablet: "tablet";
275
+ }>>;
276
+ }, z.core.$strip>;
215
277
 
216
278
  // AUTO-GENERATED by scripts/generate-zod-outputs.ts - do not edit.
217
279
 
218
280
 
281
+ type UserBuiltinDimensions = z.infer<typeof UserBuiltinDimensionsSchema>;
219
282
  type UserPlanContext = z.infer<typeof UserPlanContextSchema>;
220
283
  type UserUsageEntry = z.infer<typeof UserUsageEntrySchema>;
221
284
 
@@ -257,6 +320,15 @@ interface UserContextSnapshot {
257
320
  personalization?: Record<string, JsonValue>;
258
321
  /** Canonical experiment-handle to variant-handle assignments. */
259
322
  experiments?: Record<string, string>;
323
+ /**
324
+ * Built-in segment dimension values (plan 279 PD-3; targeting-studio-ui.md
325
+ * §4.1 "Built-in segment resolution contract"). The ONLY source of the
326
+ * reserved `rt_<dimension>` segment traits: `buildTargetingState` stamps
327
+ * each present, in-vocabulary value and ignores the rest. Delivered by the
328
+ * control plane's client context, or set by the app itself in `local_only`
329
+ * mode and on the server ports — a server-delivered value wins.
330
+ */
331
+ builtin_dimensions?: UserBuiltinDimensions;
260
332
  }
261
333
 
262
334
  /**
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * RevTurbine Server-Side SDK Client.
3
3
  *
4
- * Performs server-to-server evaluation calls against the RevTurbine decision
5
- * engine and returns a serializable `ServerEvaluationPayload` that the
6
- * client-side SDK can hydrate.
4
+ * Holds the customer's **server key** and mints short-lived, browser-safe
5
+ * `rt_client_` session keys for one end user at a time. Evaluation does not
6
+ * happen here (plan 192) — it runs in the customer SDKs.
7
7
  *
8
8
  * Designed for:
9
- * - Next.js `getServerSideProps` / RSC / API routes
9
+ * - Next.js RSC / route handlers / `getServerSideProps`
10
10
  * - Express / Fastify middleware
11
- * - Any Node.js server-side rendering pipeline
11
+ * - Any Node.js backend
12
12
  *
13
13
  * @example
14
14
  * ```ts
@@ -16,27 +16,19 @@
16
16
  *
17
17
  * const server = new RevTurbineServer({
18
18
  * tenantId: 'tenant_abc',
19
- * apiKey: process.env.REVTURBINE_SECRET_KEY!,
19
+ * apiKey: process.env.REVTURBINE_API_KEY!, // the server key (rtk_…, type server)
20
20
  * endpoint: 'https://edge.example.com',
21
21
  * });
22
22
  *
23
- * // In getServerSideProps:
24
- * const payload = await server.evaluate({
25
- * userId: session.user.id,
26
- * traits: { plan: 'pro' },
27
- * placements: [{ slotId: 'hero_banner' }],
28
- * entitlementHandles: ['advanced_analytics'],
29
- * includeTheme: true,
30
- * });
31
- *
32
- * return { props: { rtPayload: payload } };
23
+ * // Mint a session key for the signed-in user and hand it to the browser.
24
+ * const { client_token } = await server.createClientSession({ subject: session.user.id });
33
25
  * ```
34
26
  */
35
27
  import type { ClientSessionResult, CreateClientSessionInput, RevTurbineServerOptions } from './types';
36
28
  /**
37
29
  * Error thrown when a client-session mint request is rejected by the control
38
30
  * plane. Carries only the HTTP status and a correlation id — deliberately never
39
- * the mint secret, request headers, or response body — so the secret cannot leak
31
+ * the server key, request headers, or response body — so the key cannot leak
40
32
  * through error logs (plan 157 AC-8).
41
33
  */
42
34
  export declare class RevTurbineClientSessionError extends Error {
@@ -73,7 +65,8 @@ export declare class RevTurbineServer {
73
65
  create: (input: CreateClientSessionInput) => Promise<ClientSessionResult>;
74
66
  };
75
67
  /**
76
- * Mint a short-lived, opaque per-user client-session token (plan 157).
68
+ * Mint a short-lived, opaque per-user client-session token (plan 157; the
69
+ * server key is the minting authority, plan 256).
77
70
  *
78
71
  * The customer backend — which holds the server key (passed as
79
72
  * {@link RevTurbineServerOptions.apiKey}) — calls this to obtain a browser-safe
@@ -82,11 +75,11 @@ export declare class RevTurbineServer {
82
75
  * it to read the user's client-safe context.
83
76
  *
84
77
  * This is a **server-only** capability: the browser SDK never mints tokens (it
85
- * only consumes them). Tenant / application / environment are derived
86
- * server-side from the mint secret, never from this call.
78
+ * only consumes them). The tenant is derived server-side from the server key,
79
+ * never from this call.
87
80
  *
88
81
  * @throws {RevTurbineClientSessionError} if the control plane rejects the mint.
89
- * The error carries only the HTTP status + request id — never the secret.
82
+ * The error carries only the HTTP status + request id — never the key.
90
83
  */
91
84
  createClientSession(input: CreateClientSessionInput): Promise<ClientSessionResult>;
92
85
  private apiCall;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../server-node/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EAExB,uBAAuB,EAQxB,MAAM,SAAS,CAAC;AASjB;;;;;GAKG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IAEnD,iDAAiD;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,EAAE,MAAM;;IAH1B,iDAAiD;IACxC,MAAM,EAAE,MAAM;IACvB,6CAA6C;IACpC,SAAS,EAAE,MAAM;CAK7B;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;gBAEtC,OAAO,EAAE,uBAAuB;IAQ5C;;;;;;;;;;;OAWG;IACH,IAAI,cAAc,IAAI;QACpB,MAAM,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;KAC3E,CAEA;IAED;;;;;;;;;;;;;;;OAeG;IACG,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAqB1E,OAAO;YAaP,MAAM;CAWrB"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../server-node/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EAExB,uBAAuB,EAQxB,MAAM,SAAS,CAAC;AASjB;;;;;GAKG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IAEnD,iDAAiD;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,EAAE,MAAM;;IAH1B,iDAAiD;IACxC,MAAM,EAAE,MAAM;IACvB,6CAA6C;IACpC,SAAS,EAAE,MAAM;CAK7B;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;gBAEtC,OAAO,EAAE,uBAAuB;IAQ5C;;;;;;;;;;;OAWG;IACH,IAAI,cAAc,IAAI;QACpB,MAAM,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;KAC3E,CAEA;IAED;;;;;;;;;;;;;;;;OAgBG;IACG,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAqB1E,OAAO;YAaP,MAAM;CAWrB"}
@@ -24,12 +24,12 @@
24
24
  *
25
25
  * const server = new RevTurbineServer({
26
26
  * tenantId: 'tenant_abc',
27
- * apiKey: process.env.REVTURBINE_SECRET_KEY!,
27
+ * apiKey: process.env.REVTURBINE_API_KEY!, // the server key (rtk_…, type server)
28
28
  * endpoint: 'https://edge.example.com',
29
29
  * });
30
30
  *
31
31
  * // Hand this to the browser; the client SDK re-mints on expiry.
32
- * const { token } = await server.createClientSession({ userId: 'user_123' });
32
+ * const { client_token } = await server.createClientSession({ subject: 'user_123' });
33
33
  * ```
34
34
  */
35
35
  export { RevTurbineServer, RevTurbineClientSessionError } from './client';
@@ -56,8 +56,8 @@ export interface ServerEvaluationRequest {
56
56
  * Input for minting a short-lived, per-user client-session token.
57
57
  *
58
58
  * The customer backend attests the end user, then mints a browser-safe token
59
- * scoped to exactly that subject. Tenant / application / environment are derived
60
- * server-side from the mint secret — never from this input.
59
+ * scoped to exactly that subject. The tenant is derived server-side from the
60
+ * server key ({@link RevTurbineServerOptions.apiKey}) — never from this input.
61
61
  */
62
62
  export interface CreateClientSessionInput {
63
63
  /** The end-user subject the token is minted for (opaque to RevTurbine). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revturbine/sdk",
3
- "version": "0.11.10",
3
+ "version": "0.11.11",
4
4
  "description": "RevTurbine customer-facing SDK — placement decisioning, entitlement checks, and usage tracking.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.12.0",
@@ -56,9 +56,9 @@
56
56
  "devDependencies": {
57
57
  "@growthbook/growthbook": "^1.7.0",
58
58
  "@optimizely/optimizely-sdk": "^6.5.0",
59
- "@revt-eng/core": "0.1.352",
60
- "@revt-eng/schema": "0.1.352",
61
- "@revt-eng/schema-external": "0.1.352",
59
+ "@revt-eng/core": "0.1.359",
60
+ "@revt-eng/schema": "0.1.359",
61
+ "@revt-eng/schema-external": "0.1.359",
62
62
  "@types/react": "^19.2.17",
63
63
  "@types/react-dom": "^19.2.3",
64
64
  "openapi-fetch": "^0.17.0",