Skip to content

Commit 1226fce

Browse files
committed
Add plugin pricing and addons support to schemas
Introduces plugin pricing models to MarketplacePlugin and a dedicated PluginPricing schema. Adds support for purchased addons in SpaceSubscription and HubSpace schemas, and tracks enabled plugins in License. Updates Zod schemas to reflect these new properties for better marketplace and subscription management.
1 parent 30ae246 commit 1226fce

File tree

8 files changed

+178
-0
lines changed

8 files changed

+178
-0
lines changed

packages/spec/json-schema/hub/HubSpace.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,37 @@
180180
"stripeSubscriptionId": {
181181
"type": "string"
182182
},
183+
"addons": {
184+
"type": "array",
185+
"items": {
186+
"type": "object",
187+
"properties": {
188+
"pluginId": {
189+
"type": "string",
190+
"description": "Marketplace Plugin ID (NPM package name)"
191+
},
192+
"quantity": {
193+
"type": "number",
194+
"default": 1
195+
},
196+
"status": {
197+
"type": "string",
198+
"enum": [
199+
"active",
200+
"past_due",
201+
"canceled",
202+
"trialing",
203+
"incomplete"
204+
],
205+
"default": "active"
206+
}
207+
},
208+
"required": [
209+
"pluginId"
210+
],
211+
"additionalProperties": false
212+
}
213+
},
183214
"usage": {
184215
"type": "object",
185216
"additionalProperties": {

packages/spec/json-schema/hub/License.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
"type": "number"
4141
}
4242
},
43+
"plugins": {
44+
"type": "array",
45+
"items": {
46+
"type": "string"
47+
},
48+
"description": "List of enabled plugin package IDs"
49+
},
4350
"signature": {
4451
"type": "string",
4552
"description": "Cryptographic signature of the license"

packages/spec/json-schema/hub/MarketplacePlugin.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,43 @@
8686
"minimum": 0,
8787
"maximum": 5
8888
},
89+
"pricing": {
90+
"type": "object",
91+
"properties": {
92+
"type": {
93+
"type": "string",
94+
"enum": [
95+
"free",
96+
"one_time",
97+
"recurring"
98+
]
99+
},
100+
"currency": {
101+
"type": "string",
102+
"default": "USD"
103+
},
104+
"amount": {
105+
"type": "number",
106+
"minimum": 0
107+
},
108+
"interval": {
109+
"type": "string",
110+
"enum": [
111+
"month",
112+
"year"
113+
],
114+
"description": "Required if type is recurring"
115+
},
116+
"trialDays": {
117+
"type": "integer"
118+
}
119+
},
120+
"required": [
121+
"type",
122+
"amount"
123+
],
124+
"additionalProperties": false
125+
},
89126
"verified": {
90127
"type": "boolean",
91128
"default": false,
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"$ref": "#/definitions/PluginPricing",
3+
"definitions": {
4+
"PluginPricing": {
5+
"type": "object",
6+
"properties": {
7+
"type": {
8+
"type": "string",
9+
"enum": [
10+
"free",
11+
"one_time",
12+
"recurring"
13+
]
14+
},
15+
"currency": {
16+
"type": "string",
17+
"default": "USD"
18+
},
19+
"amount": {
20+
"type": "number",
21+
"minimum": 0
22+
},
23+
"interval": {
24+
"type": "string",
25+
"enum": [
26+
"month",
27+
"year"
28+
],
29+
"description": "Required if type is recurring"
30+
},
31+
"trialDays": {
32+
"type": "integer"
33+
}
34+
},
35+
"required": [
36+
"type",
37+
"amount"
38+
],
39+
"additionalProperties": false
40+
}
41+
},
42+
"$schema": "http://json-schema.org/draft-07/schema#"
43+
}

packages/spec/json-schema/hub/SpaceSubscription.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,37 @@
2828
"stripeSubscriptionId": {
2929
"type": "string"
3030
},
31+
"addons": {
32+
"type": "array",
33+
"items": {
34+
"type": "object",
35+
"properties": {
36+
"pluginId": {
37+
"type": "string",
38+
"description": "Marketplace Plugin ID (NPM package name)"
39+
},
40+
"quantity": {
41+
"type": "number",
42+
"default": 1
43+
},
44+
"status": {
45+
"type": "string",
46+
"enum": [
47+
"active",
48+
"past_due",
49+
"canceled",
50+
"trialing",
51+
"incomplete"
52+
],
53+
"default": "active"
54+
}
55+
},
56+
"required": [
57+
"pluginId"
58+
],
59+
"additionalProperties": false
60+
}
61+
},
3162
"usage": {
3263
"type": "object",
3364
"additionalProperties": {

packages/spec/src/hub/license.zod.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ export const LicenseSchema = z.object({
6969
customFeatures: z.array(z.string()).optional(),
7070
customLimits: z.record(z.number()).optional(),
7171

72+
/** Authorized Add-ons */
73+
plugins: z.array(z.string()).optional().describe('List of enabled plugin package IDs'),
74+
7275
/** Signature */
7376
signature: z.string().optional().describe('Cryptographic signature of the license'),
7477
});

packages/spec/src/hub/marketplace.zod.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ export const PluginAuthorSchema = z.object({
1616
url: z.string().url().optional(),
1717
});
1818

19+
/**
20+
* Plugin Pricing Model Schema
21+
*/
22+
export const PluginPricingSchema = z.object({
23+
type: z.enum(['free', 'one_time', 'recurring']),
24+
currency: z.string().default('USD'),
25+
amount: z.number().min(0),
26+
interval: z.enum(['month', 'year']).optional().describe('Required if type is recurring'),
27+
trialDays: z.number().int().optional(),
28+
});
29+
1930
/**
2031
* Plugin Registry Entry Schema
2132
* Represents a listing in the Marketplace.
@@ -76,6 +87,12 @@ export const MarketplacePluginSchema = z.object({
7687
*/
7788
downloads: z.number().int().optional(),
7889
rating: z.number().min(0).max(5).optional(),
90+
91+
/**
92+
* Commercial Information
93+
*/
94+
pricing: PluginPricingSchema.optional(),
95+
7996
verified: z.boolean().default(false).describe('Is verified maintaned by ObjectStack'),
8097
});
8198

packages/spec/src/hub/space.zod.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ export const SpaceSubscriptionSchema = z.object({
3131
stripeCustomerId: z.string().optional(),
3232
stripeSubscriptionId: z.string().optional(),
3333

34+
/**
35+
* Purchased Add-ons from Marketplace
36+
*/
37+
addons: z.array(z.object({
38+
pluginId: z.string().describe('Marketplace Plugin ID (NPM package name)'),
39+
quantity: z.number().default(1),
40+
status: SubscriptionStatus.default('active'),
41+
})).optional(),
42+
3443
/**
3544
* Quota Usage Snapshot
3645
* Cached usage metrics for quick display/validation.

0 commit comments

Comments
 (0)