@revturbine/sdk 0.2.23 → 0.2.26

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.
@@ -16,21 +16,36 @@ export type AccessGateSurfaceSlotProps = {
16
16
  id: string;
17
17
  /** Optional human-readable slot label used for analytics/debugging. */
18
18
  name?: string;
19
+ /**
20
+ * Shorthand entitlement gate — `can="brand_kit"` is equivalent to
21
+ * `check={{ entitlement: 'brand_kit' }}`, mirroring the `useCan('brand_kit')`
22
+ * hook. Merged with `check` when both are supplied. Provide `can` or `check`.
23
+ */
24
+ can?: string;
19
25
  /**
20
26
  * One or more access checks to evaluate before granting access.
21
27
  *
22
28
  * - `{ entitlement: 'brand_kit' }` — check an entitlement handle.
23
29
  * - `{ usage: 'core_credits', threshold: 80 }` — check a usage percentage threshold.
24
30
  *
25
- * When an array is passed, access is denied if **any** check fails.
31
+ * When an array is passed, access is denied if **any** check fails. Optional
32
+ * when `can` is provided.
26
33
  */
27
- check: AccessGateCheck | AccessGateCheck[];
34
+ check?: AccessGateCheck | AccessGateCheck[];
28
35
  /**
29
36
  * Placement to display when access is denied.
30
37
  * The slot fetches the gated placement from the decision engine.
31
38
  * If no placement matches, `deniedFallback` is shown.
32
39
  */
33
40
  deniedFallback?: React.ReactNode;
41
+ /**
42
+ * Rendered instead of `children` when the entitlement is `limited` — access is
43
+ * still granted, the usage/credit balance is just running low. Use it for a soft
44
+ * "running low" state (e.g. the feature plus a warning). When omitted, `limited`
45
+ * renders `children` normally, since a `limited` user is still entitled; pass
46
+ * `null` to render nothing.
47
+ */
48
+ limitedFallback?: React.ReactNode;
34
49
  /** Content to render when access is granted. */
35
50
  children: React.ReactNode;
36
51
  /**
@@ -52,23 +67,31 @@ export type AccessGateSurfaceSlotProps = {
52
67
  style?: React.CSSProperties;
53
68
  };
54
69
  /**
55
- * Access-gate surface slot renders children when entitled, or a gated
56
- * placement when access is denied.
70
+ * Merge the `can` shorthand and the `check` prop into the effective check list:
71
+ * `can="x"` becomes `{ entitlement: 'x' }`, and `check` is appended as-is.
72
+ * Exported for unit testing.
73
+ */
74
+ export declare function resolveGateChecks(can: string | undefined, check: AccessGateCheck | AccessGateCheck[] | undefined): AccessGateCheck[];
75
+ /**
76
+ * Access-gate surface slot — renders children when entitled (allowed *or*
77
+ * `limited`), or a gated placement when access is `denied`.
57
78
  *
58
- * Checks entitlements and/or usage thresholds. On failure, displays the
59
- * configured gated placement (or `deniedFallback` if no placement matches).
60
- * On success, renders `children` unmodified.
79
+ * Checks entitlements and/or usage thresholds. On denial, displays the configured
80
+ * gated placement (or `deniedFallback` if no placement matches). On success,
81
+ * renders `children` — or `limitedFallback` when the entitlement is `limited`.
61
82
  *
62
83
  * @example
63
84
  * ```tsx
64
- * <AccessGateSurfaceSlot
65
- * id="export-gate"
66
- * check={{ entitlement: 'mp4_download' }}
67
- * deniedFallback={<span>Upgrade to export</span>}
68
- * >
85
+ * // `can` shorthand — mirrors useCan('mp4_download')
86
+ * <AccessGateSurfaceSlot id="export-gate" can="mp4_download" deniedFallback={<span>Upgrade to export</span>}>
69
87
  * <ExportButton />
70
88
  * </AccessGateSurfaceSlot>
71
89
  *
90
+ * // soft-warn while still granting access when the balance runs low
91
+ * <AccessGateSurfaceSlot id="credits-gate" can="core_credits" limitedFallback={<LowBalanceNotice />}>
92
+ * <RecordButton />
93
+ * </AccessGateSurfaceSlot>
94
+ *
72
95
  * <AccessGateSurfaceSlot
73
96
  * id="usage-gate"
74
97
  * check={[
@@ -81,7 +104,7 @@ export type AccessGateSurfaceSlotProps = {
81
104
  * </AccessGateSurfaceSlot>
82
105
  * ```
83
106
  */
84
- export declare function AccessGateSurfaceSlot({ id, name, check, children, deniedFallback, surfaceTemplateIds, metadata, onDenied, ...options }: AccessGateSurfaceSlotProps): React.JSX.Element | null;
107
+ export declare function AccessGateSurfaceSlot({ id, name, can, check, children, deniedFallback, limitedFallback, surfaceTemplateIds, metadata, onDenied, ...options }: AccessGateSurfaceSlotProps): React.JSX.Element | null;
85
108
  export declare namespace AccessGateSurfaceSlot {
86
109
  var displayName: string;
87
110
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AccessGateSurfaceSlot.d.ts","sourceRoot":"","sources":["../../../../placements/AccessGateSurfaceSlot.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EACV,qBAAqB,EACrB,4BAA4B,EAC5B,oCAAoC,EAEpC,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAItC,MAAM,MAAM,eAAe,GACvB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,4BAA4B,CAAA;CAAE,GAC/D;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzC,MAAM,MAAM,0BAA0B,GAAG;IACvC,uDAAuD;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;;;OAOG;IACH,KAAK,EAAE,eAAe,GAAG,eAAe,EAAE,CAAC;IAE3C;;;;OAIG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEjC,gDAAgD;IAChD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,SAA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AAM,GAAG,SAAS,EACvB,KAAK,EAAE,eAAe,GAAG,eAAe,EAAE,GAAG,SAAS,GACrD,eAAe,EAAE,CAKnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,EAAE,EACF,IAAI,EACJ,GAAG,EACH,KAAK,EACL,QAAQ,EACR,cAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,QAAQ,EACR,GAAG,OAAO,EACX,EAAE,0BAA0B,4BA+E5B;yBA3Fe,qBAAqB"}
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@revturbine/sdk",
3
- "version": "0.2.23",
3
+ "version": "0.2.26",
4
4
  "description": "RevTurbine customer-facing SDK — placement decisioning, entitlement checks, and usage tracking.",
5
5
  "type": "module",
6
+ "packageManager": "pnpm@11.12.0",
7
+ "engines": {
8
+ "node": ">=22.13"
9
+ },
6
10
  "exports": {
7
11
  ".": {
8
12
  "import": "./dist/index.js",
@@ -31,15 +35,15 @@
31
35
  }
32
36
  },
33
37
  "devDependencies": {
34
- "@revt-eng/core": "0.1.100",
35
- "@revt-eng/schema": "0.1.100",
36
- "@revt-eng/schema-external": "0.1.100",
37
- "@types/react": "^19.1.2",
38
- "@types/react-dom": "^19.1.2",
38
+ "@revt-eng/core": "0.1.131",
39
+ "@revt-eng/schema": "0.1.131",
40
+ "@revt-eng/schema-external": "0.1.131",
41
+ "@types/react": "^19.2.17",
42
+ "@types/react-dom": "^19.2.3",
39
43
  "openapi-fetch": "^0.17.0",
40
- "playwright": "^1.59.1",
41
- "tsup": "^8.5.0",
42
- "typescript": "^6.0.2"
44
+ "playwright": "^1.61.1",
45
+ "tsup": "^8.5.1",
46
+ "typescript": "^6.0.3"
43
47
  },
44
48
  "publishConfig": {
45
49
  "registry": "https://registry.npmjs.org",