@kitcms/plugin-entitlements 0.1.1 → 0.1.3
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 +2 -0
- package/package.json +3 -3
- package/src/plugin.ts +5 -5
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @kitcms/plugin-entitlements
|
|
2
2
|
|
|
3
|
+
**Docs:** [kitcms.dev/docs/plugins/entitlements](https://kitcms.dev/docs/plugins/entitlements)
|
|
4
|
+
|
|
3
5
|
Turns a plan (set by your platform's control plane) into add-on gates and usage limits for a kitcms app.
|
|
4
6
|
The plan is read from a Worker variable, never from D1, and nothing in kitcms can edit it.
|
|
5
7
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitcms/plugin-entitlements",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@kitcms/core": "^0.1.
|
|
23
|
+
"@kitcms/core": "^0.1.3",
|
|
24
24
|
"svelte": "^5"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@kitcms/core": "0.1.
|
|
27
|
+
"@kitcms/core": "0.1.3",
|
|
28
28
|
"@sveltejs/kit": "^3.2.0",
|
|
29
29
|
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
30
30
|
"svelte": "^5.57.3",
|
package/src/plugin.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
KitcmsPlugin,
|
|
6
6
|
PanelBlock,
|
|
7
7
|
} from '@kitcms/core';
|
|
8
|
-
import { ForbiddenError } from '@kitcms/core';
|
|
8
|
+
import { ForbiddenError, resolveValue, type Resolvable } from '@kitcms/core';
|
|
9
9
|
import { parseEntitlements, type Entitlements } from './parse';
|
|
10
10
|
|
|
11
11
|
export interface EntitlementsOptions {
|
|
@@ -16,7 +16,7 @@ export interface EntitlementsOptions {
|
|
|
16
16
|
/** Known add-ons, so the panel can show locked ones too: `{ booking: { label: 'Booking', description? } }`. */
|
|
17
17
|
addons?: Record<string, { label: string; description?: string }>;
|
|
18
18
|
/** Shown as a "Manage plan" link in the panel (https only; core drops anything else). */
|
|
19
|
-
manageUrl?: string
|
|
19
|
+
manageUrl?: Resolvable<string | undefined>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const DEFAULT_VARIABLE = 'KITCMS_ENTITLEMENTS';
|
|
@@ -178,7 +178,7 @@ export function entitlements(options: EntitlementsOptions = {}): KitcmsPlugin {
|
|
|
178
178
|
{
|
|
179
179
|
id: 'plan',
|
|
180
180
|
label: 'Plan & add-ons',
|
|
181
|
-
async load({ cms }) {
|
|
181
|
+
async load({ cms, runtime }) {
|
|
182
182
|
const ent = await provider.get();
|
|
183
183
|
const blocks: PanelBlock[] = [
|
|
184
184
|
{ type: 'heading', text: ent.valid ? `Plan: ${ent.plan}` : 'Plan unknown' },
|
|
@@ -223,8 +223,8 @@ export function entitlements(options: EntitlementsOptions = {}): KitcmsPlugin {
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
|
|
227
|
-
|
|
226
|
+
const manageUrl = options.manageUrl === undefined ? undefined : await resolveValue(options.manageUrl, runtime);
|
|
227
|
+
if (manageUrl) blocks.push({ type: 'link', label: 'Manage plan', href: manageUrl });
|
|
228
228
|
return { blocks };
|
|
229
229
|
},
|
|
230
230
|
},
|