diff --git a/README.md b/README.md
index 608f542a..fd14278a 100644
--- a/README.md
+++ b/README.md
@@ -102,3 +102,11 @@ npx wrangler secret put EXTENSIONS_REVALIDATE_SECRET
The extension directory website is licensed under the GNU Affero General Public License Version 3. See [LICENSE](./LICENSE) for details.
Individual extensions are licensed by their respective authors.
+
+## Manifest API contract
+
+The generated v2 client follows the API's manifest v1 contract: `module`, string licenses, optional `homepage_url`, package authors, and full FOSSBilling/PHP/module requirements. Author/edit/moderator forms preserve these fields; historical revision diffs also accept pre-manifest license objects and `website` fields.
+
+Package icons are paths relative to the distribution root. For GitHub release assets matching the declared source repository, the site resolves them against the release tag. `FOSSBilling/modules` uses its `Ucfirst(id)/` package directory; other GitHub sources use the repository root. Unsupported sources omit relative icons. Legacy HTTP(S) icons continue to work.
+
+API mutations and site mutations both purge the `extensions` and `developers` tags. The `developers` tag is currently a no-op reserved for future cached surfaces; developer pages are uncached. Deploy this site with the API's manifest migration and cache-tag change before enabling the updated modules publisher. Existing cached pages expire through their cache windows; deployment must coordinate the new contract and tag. Old pending revisions require resubmission using the manifest fields before approval.
diff --git a/astro.config.ts b/astro.config.ts
index 4a940dbf..7ae5f4e5 100644
--- a/astro.config.ts
+++ b/astro.config.ts
@@ -1,5 +1,6 @@
// @ts-check
import { defineConfig } from 'astro/config';
+import { EXTENSIONS_CACHE_TAG } from './src/lib/cache-tags';
import tailwindcss from '@tailwindcss/vite';
import cloudflare from '@astrojs/cloudflare';
import { cacheCloudflare } from '@astrojs/cloudflare/cache';
@@ -9,17 +10,17 @@ export default defineConfig({
output: 'server',
// Canonical and Open Graph URLs are built from this origin at render time.
site: 'https://extensions.fossbilling.org',
- // Route caching: public catalogue pages carry a Cloudflare-CDN-Cache-Control
+ // Route caching: public directory pages carry a Cloudflare-CDN-Cache-Control
// header, so Cloudflare's zone-wide CDN serves cache hits without invoking
// the worker at all. Per-colo Cache API cannot be purged remotely; these
- // entries are tag-purgeable, which is what makes catalogue mutations
+ // entries are tag-purgeable, which is what makes directory mutations
// visible within seconds instead of after a TTL (see lib/cache-invalidate).
cache: {
provider: cacheCloudflare(),
},
routeRules: {
- // New submissions enter a pending review queue, so the catalogue only
- // changes when a dashboard approval (purges 'catalogue') or an api-side
+ // New submissions enter a pending review queue, so the directory only
+ // changes when a dashboard approval (purges 'extensions') or an api-side
// writer (POST /api/revalidate) publishes something; between events,
// maxAge+SWR bound the staleness of any other drift.
//
@@ -27,8 +28,8 @@ export default defineConfig({
// a session-dependent claim form vs sign-in link, and CDN hits are
// served by URL without cookies, so the first visitor's variant would
// leak to everyone.
- '/': { maxAge: 120, swr: 60, tags: ['catalogue'] },
- '/extension/[id]': { maxAge: 300, swr: 120, tags: ['catalogue'] },
+ '/': { maxAge: 120, swr: 60, tags: [EXTENSIONS_CACHE_TAG] },
+ '/extension/[id]': { maxAge: 300, swr: 120, tags: [EXTENSIONS_CACHE_TAG] },
'/404': { maxAge: 60 },
},
// Prefetch is disabled entirely: Cloudflare's edge refuses
diff --git a/openapi/extensions-v2.json b/openapi/extensions-v2.json
index d3199f73..0586ae6c 100644
--- a/openapi/extensions-v2.json
+++ b/openapi/extensions-v2.json
@@ -43,15 +43,18 @@
"ExtensionListItem": {
"type": "object",
"properties": {
+ "manifest_version": {
+ "type": "number",
+ "enum": [1]
+ },
"type": {
"type": "string",
"enum": [
- "mod",
+ "module",
"theme",
"payment-gateway",
"server-manager",
"domain-registrar",
- "hook",
"translation"
]
},
@@ -65,19 +68,37 @@
"minLength": 1,
"maxLength": 4000
},
- "website": {
+ "author": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 200
+ },
+ "url": {
+ "type": "string",
+ "maxLength": 2048,
+ "format": "uri"
+ }
+ },
+ "required": ["name"],
+ "additionalProperties": false
+ },
+ "homepage_url": {
"type": ["string", "null"],
"maxLength": 2048,
"format": "uri",
"description": "Null when a legacy URL exceeds the card length bound"
},
"license": {
- "$ref": "#/components/schemas/License"
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 1000
},
"icon_url": {
"type": "string",
- "maxLength": 2048,
- "format": "uri"
+ "maxLength": 2048
},
"source": {
"$ref": "#/components/schemas/Repository"
@@ -101,10 +122,11 @@
}
},
"required": [
+ "manifest_version",
"type",
"name",
"description",
- "website",
+ "author",
"license",
"source",
"version",
@@ -113,28 +135,6 @@
"developer"
]
},
- "License": {
- "type": "object",
- "properties": {
- "name": {
- "type": "string",
- "minLength": 1,
- "maxLength": 100
- },
- "spdx_id": {
- "type": "string",
- "description": "A current SPDX license identifier (https://spdx.org/licenses/). Omitted for custom or proprietary licenses.",
- "example": "MIT"
- },
- "URL": {
- "type": "string",
- "maxLength": 2048,
- "format": "uri"
- }
- },
- "required": ["name"],
- "additionalProperties": false
- },
"Repository": {
"type": "object",
"properties": {
@@ -198,15 +198,18 @@
"published": {
"type": ["object", "null"],
"properties": {
+ "manifest_version": {
+ "type": "number",
+ "enum": [1]
+ },
"type": {
"type": "string",
"enum": [
- "mod",
+ "module",
"theme",
"payment-gateway",
"server-manager",
"domain-registrar",
- "hook",
"translation"
]
},
@@ -220,19 +223,37 @@
"minLength": 1,
"maxLength": 4000
},
- "website": {
+ "author": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 200
+ },
+ "url": {
+ "type": "string",
+ "maxLength": 2048,
+ "format": "uri"
+ }
+ },
+ "required": ["name"],
+ "additionalProperties": false
+ },
+ "homepage_url": {
"type": ["string", "null"],
"maxLength": 2048,
"format": "uri",
"description": "Null when a legacy URL exceeds the card length bound"
},
"license": {
- "$ref": "#/components/schemas/License"
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 1000
},
"icon_url": {
"type": "string",
- "maxLength": 2048,
- "format": "uri"
+ "maxLength": 2048
},
"source": {
"$ref": "#/components/schemas/Repository"
@@ -250,10 +271,11 @@
}
},
"required": [
+ "manifest_version",
"type",
"name",
"description",
- "website",
+ "author",
"license",
"source",
"version",
@@ -397,6 +419,28 @@
{
"type": "object",
"properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 120
+ },
+ "description": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 4000
+ },
+ "license": {
+ "type": "string",
+ "minLength": 1
+ },
+ "icon_url": {
+ "type": "string"
+ },
+ "version": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 100
+ },
"id": {
"type": "string"
},
@@ -408,6 +452,31 @@
}
]
},
+ "ManifestRequirements": {
+ "type": "object",
+ "properties": {
+ "fossbilling": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 1000
+ },
+ "php": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 1000
+ },
+ "modules": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 1000
+ }
+ }
+ },
+ "required": ["fossbilling", "php"],
+ "additionalProperties": false
+ },
"Release": {
"type": "object",
"properties": {
@@ -431,39 +500,60 @@
"maxLength": 2048,
"format": "uri"
},
- "min_fossbilling_version": {
- "type": "string",
- "minLength": 1,
- "maxLength": 100
+ "requires": {
+ "$ref": "#/components/schemas/ManifestRequirements"
}
},
- "required": ["tag", "date", "download_url", "min_fossbilling_version"],
+ "required": ["tag", "date", "download_url", "requires"],
"additionalProperties": false
},
"ExtensionContent": {
"type": "object",
"properties": {
+ "manifest_version": {
+ "type": "number",
+ "enum": [1]
+ },
"type": {
"type": "string",
"enum": [
- "mod",
+ "module",
"theme",
"payment-gateway",
"server-manager",
"domain-registrar",
- "hook",
"translation"
]
},
"name": {
"type": "string",
"minLength": 1,
- "maxLength": 120
+ "maxLength": 100
},
"description": {
"type": "string",
"minLength": 1,
- "maxLength": 4000
+ "maxLength": 500
+ },
+ "author": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 200
+ },
+ "url": {
+ "type": "string",
+ "maxLength": 2048,
+ "format": "uri"
+ }
+ },
+ "required": ["name"],
+ "additionalProperties": false
+ },
+ "requires": {
+ "$ref": "#/components/schemas/ManifestRequirements"
},
"releases": {
"type": "array",
@@ -473,18 +563,22 @@
"minItems": 1,
"maxItems": 100
},
- "website": {
+ "homepage_url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
},
"license": {
- "$ref": "#/components/schemas/License"
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 1000,
+ "pattern": "^[A-Za-z0-9.\\-+_:() |]+$"
},
"icon_url": {
"type": "string",
+ "minLength": 1,
"maxLength": 2048,
- "format": "uri"
+ "pattern": "^(?!\\/)(?![a-zA-Z][a-zA-Z0-9+.-]*:)(?!.*\\.\\.)[^\\\\]+$"
},
"readme": {
"type": "string",
@@ -496,8 +590,8 @@
},
"version": {
"type": "string",
- "minLength": 1,
- "maxLength": 100
+ "maxLength": 100,
+ "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
},
"download_url": {
"type": "string",
@@ -506,11 +600,13 @@
}
},
"required": [
+ "manifest_version",
"type",
"name",
"description",
+ "author",
+ "requires",
"releases",
- "website",
"license",
"readme",
"source",
@@ -534,6 +630,16 @@
{
"type": ["object", "null"],
"properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 120
+ },
+ "description": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 4000
+ },
"releases": {
"type": "array",
"items": {
@@ -549,6 +655,9 @@
"minLength": 1,
"maxLength": 200,
"description": "At most 100 Unicode code points in historical content"
+ },
+ "min_fossbilling_version": {
+ "type": "string"
}
},
"additionalProperties": false
@@ -556,6 +665,18 @@
]
},
"maxItems": 100
+ },
+ "license": {
+ "type": "string",
+ "minLength": 1
+ },
+ "icon_url": {
+ "type": "string"
+ },
+ "version": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 100
}
}
}
@@ -584,16 +705,21 @@
"StoredExtensionContent": {
"type": "object",
"properties": {
+ "manifest_version": {
+ "type": "number",
+ "enum": [1]
+ },
"type": {
"type": "string",
"enum": [
- "mod",
+ "module",
"theme",
"payment-gateway",
"server-manager",
"domain-registrar",
- "hook",
- "translation"
+ "translation",
+ "mod",
+ "hook"
]
},
"name": {
@@ -606,6 +732,26 @@
"minLength": 1,
"maxLength": 4000
},
+ "author": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 200
+ },
+ "url": {
+ "type": "string",
+ "maxLength": 2048,
+ "format": "uri"
+ }
+ },
+ "required": ["name"],
+ "additionalProperties": false
+ },
+ "requires": {
+ "$ref": "#/components/schemas/ManifestRequirements"
+ },
"releases": {
"type": "array",
"items": {
@@ -621,6 +767,9 @@
"minLength": 1,
"maxLength": 200,
"description": "At most 100 Unicode code points in historical content"
+ },
+ "min_fossbilling_version": {
+ "type": "string"
}
},
"additionalProperties": false
@@ -629,18 +778,52 @@
},
"maxItems": 100
},
- "website": {
+ "homepage_url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
},
"license": {
- "$ref": "#/components/schemas/License"
+ "anyOf": [
+ {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 1000,
+ "pattern": "^[A-Za-z0-9.\\-+_:() |]+$"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "spdx_id": {
+ "type": "string"
+ },
+ "URL": {
+ "type": "string",
+ "maxLength": 2048,
+ "format": "uri"
+ }
+ },
+ "required": ["name"]
+ }
+ ]
},
"icon_url": {
- "type": "string",
- "maxLength": 2048,
- "format": "uri"
+ "anyOf": [
+ {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 2048,
+ "pattern": "^(?!\\/)(?![a-zA-Z][a-zA-Z0-9+.-]*:)(?!.*\\.\\.)[^\\\\]+$"
+ },
+ {
+ "type": "string",
+ "maxLength": 2048,
+ "format": "uri"
+ }
+ ]
},
"readme": {
"type": "string",
@@ -659,33 +842,61 @@
"type": "string",
"maxLength": 2048,
"format": "uri"
+ },
+ "website": {
+ "type": "string",
+ "maxLength": 2048,
+ "format": "uri"
}
}
},
"ExtensionCreate": {
"type": "object",
"properties": {
+ "manifest_version": {
+ "type": "number",
+ "enum": [1]
+ },
"type": {
"type": "string",
"enum": [
- "mod",
+ "module",
"theme",
"payment-gateway",
"server-manager",
"domain-registrar",
- "hook",
"translation"
]
},
"name": {
"type": "string",
"minLength": 1,
- "maxLength": 120
+ "maxLength": 100
},
"description": {
"type": "string",
"minLength": 1,
- "maxLength": 4000
+ "maxLength": 500
+ },
+ "author": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 200
+ },
+ "url": {
+ "type": "string",
+ "maxLength": 2048,
+ "format": "uri"
+ }
+ },
+ "required": ["name"],
+ "additionalProperties": false
+ },
+ "requires": {
+ "$ref": "#/components/schemas/ManifestRequirements"
},
"releases": {
"type": "array",
@@ -695,18 +906,22 @@
"minItems": 1,
"maxItems": 100
},
- "website": {
+ "homepage_url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
},
"license": {
- "$ref": "#/components/schemas/License"
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 1000,
+ "pattern": "^[A-Za-z0-9.\\-+_:() |]+$"
},
"icon_url": {
"type": "string",
+ "minLength": 1,
"maxLength": 2048,
- "format": "uri"
+ "pattern": "^(?!\\/)(?![a-zA-Z][a-zA-Z0-9+.-]*:)(?!.*\\.\\.)[^\\\\]+$"
},
"readme": {
"type": "string",
@@ -718,8 +933,8 @@
},
"version": {
"type": "string",
- "minLength": 1,
- "maxLength": 100
+ "maxLength": 100,
+ "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
},
"download_url": {
"type": "string",
@@ -728,16 +943,19 @@
},
"id": {
"type": "string",
- "maxLength": 200,
- "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
+ "minLength": 1,
+ "maxLength": 64,
+ "pattern": "^[a-z0-9_-]+$"
}
},
"required": [
+ "manifest_version",
"type",
"name",
"description",
+ "author",
+ "requires",
"releases",
- "website",
"license",
"readme",
"source",
@@ -750,27 +968,50 @@
"ExtensionUpdate": {
"type": "object",
"properties": {
+ "manifest_version": {
+ "type": "number",
+ "enum": [1]
+ },
"type": {
"type": "string",
"enum": [
- "mod",
+ "module",
"theme",
"payment-gateway",
"server-manager",
"domain-registrar",
- "hook",
"translation"
]
},
"name": {
"type": "string",
"minLength": 1,
- "maxLength": 120
+ "maxLength": 100
},
"description": {
"type": "string",
"minLength": 1,
- "maxLength": 4000
+ "maxLength": 500
+ },
+ "author": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 200
+ },
+ "url": {
+ "type": "string",
+ "maxLength": 2048,
+ "format": "uri"
+ }
+ },
+ "required": ["name"],
+ "additionalProperties": false
+ },
+ "requires": {
+ "$ref": "#/components/schemas/ManifestRequirements"
},
"releases": {
"type": "array",
@@ -780,18 +1021,22 @@
"minItems": 1,
"maxItems": 100
},
- "website": {
+ "homepage_url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
},
"license": {
- "$ref": "#/components/schemas/License"
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 1000,
+ "pattern": "^[A-Za-z0-9.\\-+_:() |]+$"
},
"icon_url": {
"type": "string",
+ "minLength": 1,
"maxLength": 2048,
- "format": "uri"
+ "pattern": "^(?!\\/)(?![a-zA-Z][a-zA-Z0-9+.-]*:)(?!.*\\.\\.)[^\\\\]+$"
},
"readme": {
"type": "string",
@@ -803,8 +1048,8 @@
},
"version": {
"type": "string",
- "minLength": 1,
- "maxLength": 100
+ "maxLength": 100,
+ "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
},
"download_url": {
"type": "string",
@@ -813,11 +1058,13 @@
}
},
"required": [
+ "manifest_version",
"type",
"name",
"description",
+ "author",
+ "requires",
"releases",
- "website",
"license",
"readme",
"source",
@@ -1292,27 +1539,50 @@
"ModeratorCorrect": {
"type": "object",
"properties": {
+ "manifest_version": {
+ "type": "number",
+ "enum": [1]
+ },
"type": {
"type": "string",
"enum": [
- "mod",
+ "module",
"theme",
"payment-gateway",
"server-manager",
"domain-registrar",
- "hook",
"translation"
]
},
"name": {
"type": "string",
"minLength": 1,
- "maxLength": 120
+ "maxLength": 100
},
"description": {
"type": "string",
"minLength": 1,
- "maxLength": 4000
+ "maxLength": 500
+ },
+ "author": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 200
+ },
+ "url": {
+ "type": "string",
+ "maxLength": 2048,
+ "format": "uri"
+ }
+ },
+ "required": ["name"],
+ "additionalProperties": false
+ },
+ "requires": {
+ "$ref": "#/components/schemas/ManifestRequirements"
},
"releases": {
"type": "array",
@@ -1322,18 +1592,22 @@
"minItems": 1,
"maxItems": 100
},
- "website": {
+ "homepage_url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
},
"license": {
- "$ref": "#/components/schemas/License"
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 1000,
+ "pattern": "^[A-Za-z0-9.\\-+_:() |]+$"
},
"icon_url": {
"type": "string",
+ "minLength": 1,
"maxLength": 2048,
- "format": "uri"
+ "pattern": "^(?!\\/)(?![a-zA-Z][a-zA-Z0-9+.-]*:)(?!.*\\.\\.)[^\\\\]+$"
},
"readme": {
"type": "string",
@@ -1345,8 +1619,8 @@
},
"version": {
"type": "string",
- "minLength": 1,
- "maxLength": 100
+ "maxLength": 100,
+ "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
},
"download_url": {
"type": "string",
@@ -1360,11 +1634,13 @@
}
},
"required": [
+ "manifest_version",
"type",
"name",
"description",
+ "author",
+ "requires",
"releases",
- "website",
"license",
"readme",
"source",
@@ -1553,7 +1829,7 @@
"/extensions": {
"get": {
"tags": ["Extensions"],
- "summary": "List extensions: published catalogue (scope=public), caller's own (scope=mine), or every extension (scope=all, moderator)",
+ "summary": "List extensions: published extension directory (scope=public), caller's own (scope=mine), or every extension (scope=all, moderator)",
"security": [
{
"Bearer": []
@@ -1564,12 +1840,11 @@
"schema": {
"type": "string",
"enum": [
- "mod",
+ "module",
"theme",
"payment-gateway",
"server-manager",
"domain-registrar",
- "hook",
"translation"
]
},
@@ -1615,10 +1890,10 @@
"type": "string",
"enum": ["public", "mine", "all"],
"default": "public",
- "description": "public: published catalogue (anonymous allowed). mine: caller's own extensions. all: every extension (moderator only)."
+ "description": "public: published extension directory (anonymous allowed). mine: caller's own extensions. all: every extension (moderator only)."
},
"required": false,
- "description": "public: published catalogue (anonymous allowed). mine: caller's own extensions. all: every extension (moderator only).",
+ "description": "public: published extension directory (anonymous allowed). mine: caller's own extensions. all: every extension (moderator only).",
"name": "scope",
"in": "query"
},
@@ -1648,7 +1923,7 @@
],
"responses": {
"200": {
- "description": "Extensions matching the scope: catalogue cards for scope=public, owned rows for scope=mine/all",
+ "description": "Extensions matching the scope: extension cards for scope=public, owned rows for scope=mine/all",
"content": {
"application/json": {
"schema": {
@@ -1718,7 +1993,7 @@
},
"responses": {
"201": {
- "description": "Extension created. It holds the id immediately but stays out of the public catalogue until a moderator approves the revision.",
+ "description": "Extension created. It holds the id immediately but stays out of the public extension listing until a moderator approves the revision.",
"content": {
"application/json": {
"schema": {
@@ -3906,7 +4181,7 @@
"/extensions/{id}/delist": {
"post": {
"tags": ["Moderation"],
- "summary": "Remove a published extension from the public catalogue",
+ "summary": "Remove a published extension from the public extension listing",
"security": [
{
"Bearer": []
@@ -3945,7 +4220,7 @@
},
"responses": {
"200": {
- "description": "Extension removed from the public catalogue. Its content and history are kept, and its owner can still see and edit it.",
+ "description": "Extension removed from the public extension listing. Its content and history are kept, and its owner can still see and edit it.",
"content": {
"application/json": {
"schema": {
@@ -4041,7 +4316,7 @@
"/extensions/{id}/relist": {
"post": {
"tags": ["Moderation"],
- "summary": "Restore a delisted extension to the public catalogue",
+ "summary": "Restore a delisted extension to the public extension listing",
"security": [
{
"Bearer": []
@@ -4080,7 +4355,7 @@
},
"responses": {
"200": {
- "description": "Extension restored to the public catalogue. Content and history unchanged.",
+ "description": "Extension restored to the public extension listing. Content and history unchanged.",
"content": {
"application/json": {
"schema": {
diff --git a/scripts/update-extensions-openapi.ts b/scripts/update-extensions-openapi.ts
index 059ed2ba..0bbb6af0 100644
--- a/scripts/update-extensions-openapi.ts
+++ b/scripts/update-extensions-openapi.ts
@@ -68,10 +68,33 @@ if (!listItemProperties) {
if (
Object.hasOwn(listItemProperties, 'readme') ||
- Object.hasOwn(listItemProperties, 'releases')
+ Object.hasOwn(listItemProperties, 'releases') ||
+ Object.hasOwn(listItemProperties, 'requires')
) {
throw new Error(
- 'The fetched OpenAPI document must keep readme and releases out of ExtensionListItem.',
+ 'The fetched OpenAPI document must keep readme, releases, and requires out of ExtensionListItem.',
+ );
+}
+
+const content = schemaProperties(schemas?.ExtensionContent);
+const manifestVersion = resolveSchema(content?.manifest_version);
+const versions = manifestVersion?.enum;
+const isManifestV1 =
+ (manifestVersion?.type === 'number' || manifestVersion?.type === 'integer') &&
+ Array.isArray(versions) &&
+ versions.length === 1 &&
+ versions[0] === 1;
+if (
+ !content ||
+ !isManifestV1 ||
+ !Object.hasOwn(content, 'requires') ||
+ !Object.hasOwn(content, 'author') ||
+ !Object.hasOwn(content, 'homepage_url') ||
+ Object.hasOwn(content, 'website') ||
+ asObject(content.license)?.type !== 'string'
+) {
+ throw new Error(
+ 'The fetched OpenAPI document must expose the manifest v1 extension contract.',
);
}
diff --git a/src/components/DetailsCard.astro b/src/components/DetailsCard.astro
index 11169c4d..264e25a7 100644
--- a/src/components/DetailsCard.astro
+++ b/src/components/DetailsCard.astro
@@ -1,6 +1,6 @@
---
import type { Extension } from '@/types';
-import { getLatestRelease, repositoryURL } from '@/types';
+import { repositoryURL } from '@/types';
import { isSafeHttpUrl } from '@/lib/safe-url';
import { CircleCheck, Download, GitBranch, Scale, User } from '@lucide/astro';
@@ -9,7 +9,6 @@ interface Props {
}
const { ext } = Astro.props;
-const latest = getLatestRelease(ext);
const sourceUrl = repositoryURL(ext.source);
type DetailsItem = {
@@ -45,20 +44,38 @@ const details: DetailsItem[] = [
name: 'FOSSBilling Version',
icon: CircleCheck,
color: 'green',
- text: latest
- ? `FOSSBilling v${latest.min_fossbilling_version} and later`
- : 'Unknown version',
+ text: ext.requires.fossbilling,
+ },
+ {
+ name: 'PHP Version',
+ icon: CircleCheck,
+ color: 'green',
+ text: ext.requires.php,
+ },
+ {
+ name: 'Package Author',
+ icon: User,
+ color: 'amber',
+ text: ext.author.name,
+ link:
+ ext.author.url && isSafeHttpUrl(ext.author.url)
+ ? ext.author.url
+ : undefined,
},
{
name: 'License',
icon: Scale,
color: 'blue',
- text: ext.license.name,
- link:
- ext.license.URL && isSafeHttpUrl(ext.license.URL)
- ? ext.license.URL
- : undefined,
+ text: ext.license,
},
+ ...Object.entries(ext.requires.modules ?? {}).map(
+ ([id, range]): DetailsItem => ({
+ name: `Module: ${id}`,
+ icon: CircleCheck,
+ color: 'green',
+ text: range,
+ }),
+ ),
{
name: 'Source Code',
icon: GitBranch,
diff --git a/src/components/CatalogueSection.astro b/src/components/DirectorySection.astro
similarity index 87%
rename from src/components/CatalogueSection.astro
rename to src/components/DirectorySection.astro
index 82bc2ffd..dcfe0562 100644
--- a/src/components/CatalogueSection.astro
+++ b/src/components/DirectorySection.astro
@@ -1,9 +1,9 @@
---
import ExtensionCard from './ExtensionCard.astro';
import type { ExtensionListResponse } from '@/lib/api/client';
-import { hasNextPage } from '@/lib/catalogue-pagination';
+import { hasNextPage } from '@/lib/directory-pagination';
-// The server-rendered catalogue skeleton that extension-catalogue.ts wires:
+// The server-rendered directory skeleton that extension-directory.ts wires:
// the grid, the empty state, and the load-more controls it drives. Shared by
// the directory index and developer profiles so the data attributes the
// script selects on can't drift between the two pages.
@@ -37,12 +37,12 @@ const hasNext = pagination ? hasNextPage(pagination) : false;
(emptyAsCard ? (
{emptyMessage}
) : (
-
+
{emptyMessage}
))}
@@ -62,7 +62,7 @@ const hasNext = pagination ? hasNextPage(pagination) : false;
All extensions loaded.
) : null}
diff --git a/src/components/ExtensionCard.astro b/src/components/ExtensionCard.astro
index 4750b50a..d1e67bf1 100644
--- a/src/components/ExtensionCard.astro
+++ b/src/components/ExtensionCard.astro
@@ -1,5 +1,6 @@
---
import type { ExtensionListItem } from '@/lib/api/client';
+import { extensionIconUrl } from '@/lib/extension-icon';
import { getSignedImageUrl } from '@/lib/signed-image-url';
interface Props {
@@ -8,7 +9,7 @@ interface Props {
const { ext } = Astro.props;
const iconUrl = await getSignedImageUrl(
- ext.icon_url,
+ extensionIconUrl(ext),
'icon',
Astro.locals.env.sessionSecret,
);
diff --git a/src/components/ExtensionForm.astro b/src/components/ExtensionForm.astro
index 6543222a..b4f80685 100644
--- a/src/components/ExtensionForm.astro
+++ b/src/components/ExtensionForm.astro
@@ -3,7 +3,11 @@ import { EXTENSION_TYPES, SOURCE_TYPES, SPDX_LICENSE_IDS } from '@/types';
import type { Developer, Extension } from '@/types';
import { CircleAlert, SquarePen, ChevronDown } from '@lucide/astro';
import { stripUrlScheme } from '@/lib/url-prefix';
-import { OTHER_LICENSE, type ReleaseDraft } from '@/lib/extension-form';
+import {
+ OTHER_LICENSE,
+ type ExtensionFormEcho,
+ type ReleaseDraft,
+} from '@/lib/extension-form';
import { MARKDOWN_SCROLL_CLASS } from '@/lib/revision-diff-shared';
interface Props {
@@ -15,7 +19,7 @@ interface Props {
// echoNewExtensionFromForm and echoExtensionFromForm). Values only:
// passing an echo never flips the form into edit mode, so create keeps
// its writable extension_id and create submit semantics.
- echo?: Extension;
+ echo?: ExtensionFormEcho;
error?: string | null;
submitLabel?: string;
cancelHref?: string;
@@ -46,7 +50,7 @@ const shown = echo ?? extension;
// form with no releases yet (rejected and never resubmitted).
const requireRelease = !isEdit || extension!.releases.length === 0;
-const existingSpdxId = shown?.license.spdx_id;
+const existingSpdxId = shown?.license;
// An existing license only lands in the custom bucket when it truly isn't
// one of the ids this form offers — covers both genuinely custom/proprietary
// licenses and (defensively) a stored spdx_id this deployed list doesn't
@@ -127,6 +131,7 @@ const otherSpdxIds = SPDX_LICENSE_IDS.filter((id) => !popularSpdxIds.has(id));
type="text"
id="name"
name="name"
+ maxlength={100}
required
value={shown?.name}
/>
@@ -141,7 +146,8 @@ const otherSpdxIds = SPDX_LICENSE_IDS.filter((id) => !popularSpdxIds.has(id));
id="extension_id"
name="extension_id"
required
- pattern="[a-z0-9]+(-[a-z0-9]+)*"
+ pattern="[a-z0-9_\-]+"
+ maxlength={64}
value={shown?.id}
disabled={isEdit}
/>
@@ -175,43 +181,38 @@ const otherSpdxIds = SPDX_LICENSE_IDS.filter((id) => !popularSpdxIds.has(id));
type="text"
id="description"
name="description"
+ maxlength={500}
required
value={shown?.description}
/>
-
- Website *
-
+
Homepage (optional)
https://
@@ -244,6 +245,73 @@ const otherSpdxIds = SPDX_LICENSE_IDS.filter((id) => !popularSpdxIds.has(id));
+
+ Package Author
+
+ Author Name *
+
+
+
+ Author URL (optional)
+
+
+
+
+ Requirements
+
+ Requirements for the current version, or the new release added
+ below. Use version constraints such as ^0.8.9 or >=8.3 <9.
+
+
+ FOSSBilling *
+
+
+
+ PHP *
+
+
+
+
Module Dependencies (optional)
+
+
+ One module-id: constraint per line.
+
+
+
+
License
@@ -308,7 +376,7 @@ const otherSpdxIds = SPDX_LICENSE_IDS.filter((id) => !popularSpdxIds.has(id));
- Other / Proprietary
+ Other / License Expression
@@ -326,7 +394,7 @@ const otherSpdxIds = SPDX_LICENSE_IDS.filter((id) => !popularSpdxIds.has(id));
hidden={!isCustomLicense}
>
- Custom License Name *
+ License Expression *
!popularSpdxIds.has(id));
id="license_name_custom"
name="license_name_custom"
required={isCustomLicense}
- value={isCustomLicense ? shown?.license.name : undefined}
+ value={isCustomLicense ? shown?.license : undefined}
/>
-
-
- License URL
-
- Optional
-
-
-
-
- https://
-
-
-
-
@@ -402,7 +451,7 @@ const otherSpdxIds = SPDX_LICENSE_IDS.filter((id) => !popularSpdxIds.has(id));
{extension.releases.map((r) => (
v{r.tag} · {r.date} · FOSSBilling{' '}
- {r.min_fossbilling_version}+
+ {r.requires.fossbilling}
))}
@@ -486,21 +535,6 @@ const otherSpdxIds = SPDX_LICENSE_IDS.filter((id) => !popularSpdxIds.has(id));
/>
-
-
- Minimum FOSSBilling Version{' '}
- {requireRelease && * }
-
-
-
@@ -601,14 +635,6 @@ const otherSpdxIds = SPDX_LICENSE_IDS.filter((id) => !popularSpdxIds.has(id));
diff --git a/src/components/ExtensionHeader.astro b/src/components/ExtensionHeader.astro
index 235b74e6..13111083 100644
--- a/src/components/ExtensionHeader.astro
+++ b/src/components/ExtensionHeader.astro
@@ -1,6 +1,7 @@
---
import type { Extension } from '@/types';
import { ArrowLeft } from '@lucide/astro';
+import { extensionIconUrl } from '@/lib/extension-icon';
import { getSignedImageUrl } from '@/lib/signed-image-url';
interface Props {
@@ -9,7 +10,7 @@ interface Props {
const { ext } = Astro.props;
const iconUrl = await getSignedImageUrl(
- ext.icon_url,
+ extensionIconUrl(ext),
'icon',
Astro.locals.env.sessionSecret,
);
diff --git a/src/components/FlashToaster.astro b/src/components/FlashToaster.astro
index 2a0c4168..d198701f 100644
--- a/src/components/FlashToaster.astro
+++ b/src/components/FlashToaster.astro
@@ -1,5 +1,5 @@
---
-// Server Island: renders the one-shot flash message so cached catalogue
+// Server Island: renders the one-shot flash message so cached directory
// pages can still surface per-request toasts. The flash lives in a signed
// cookie (src/lib/flash.ts), which is read and cleared here, inside the
// island endpoint's own request, so the cookie delete is guaranteed to land
diff --git a/src/components/ReleasesTable.astro b/src/components/ReleasesTable.astro
index a6eef931..5e7aaafd 100644
--- a/src/components/ReleasesTable.astro
+++ b/src/components/ReleasesTable.astro
@@ -27,6 +27,9 @@ const releases = sortReleasesDescending(ext.releases);
Tag
Release date
+ FOSSBilling
+ PHP
+ Modules
Links
@@ -37,6 +40,13 @@ const releases = sortReleasesDescending(ext.releases);
{formatDate(release.date)}
+ {release.requires.fossbilling}
+ {release.requires.php}
+
+ {Object.entries(release.requires.modules ?? {})
+ .map(([id, range]) => `${id}: ${range}`)
+ .join(', ') || '—'}
+
;
+ };
releases?: Array<{ tag?: string }>;
};
@@ -129,10 +136,11 @@ function renderDiff(
const tdField = document.createElement('td');
tdField.className = 'py-1 pr-3 font-medium whitespace-nowrap';
tdField.textContent = label + (isChanged ? ' •' : '');
- // Source and license rows link via their own URL (type-aware for
+ // Source, license and author rows link via their own URL (type-aware for
// sources); URL fields link via their own value. Everything else
// renders as text.
- const linkedField = field === 'source' || field === 'license';
+ const linkedField =
+ field === 'source' || field === 'license' || field === 'author';
const oldHref = linkedField
? fieldUrl(field, published)
: URL_FIELDS.has(field)
@@ -238,7 +246,7 @@ export function initRevisionQueue(): void {
label.textContent = FIELD_LABELS[field];
const value = fieldDisplay(field, revision);
const href =
- field === 'source' || field === 'license'
+ field === 'source' || field === 'license' || field === 'author'
? fieldUrl(field, revision)
: URL_FIELDS.has(field)
? value
diff --git a/src/lib/api/client.ts b/src/lib/api/client.ts
index 8e855870..07fa4d19 100644
--- a/src/lib/api/client.ts
+++ b/src/lib/api/client.ts
@@ -76,7 +76,7 @@ type ListFilters = Pick<
'type' | 'developer_id' | 'status' | 'q' | 'limit' | 'cursor'
>;
-export type ExtensionCatalogueFilters = Pick<
+export type ExtensionDirectoryFilters = Pick<
ExtensionListQuery,
'type' | 'developer_id' | 'limit' | 'cursor'
>;
@@ -101,7 +101,7 @@ export type RevisionStatus = Exclude;
export type ModerationCounts = GetModerationCountsResponse['result'];
// The v2 list/detail reads are role-aware unions. These wrappers pin a scope
-// (public catalogue vs mine/all) or a transport (anonymous vs authenticated),
+// (public directory vs mine/all) or a transport (anonymous vs authenticated),
// so they narrow to the projection that scope always returns.
export interface ExtensionListResponse {
result: ExtensionListItem[];
@@ -367,7 +367,7 @@ function requireOwnedExtension(
}
// Builds the query for the role-aware extension list reads. `scope` selects
-// the projection (undefined = public catalogue); callers pass only the
+// the projection (undefined = public directory); callers pass only the
// filters their surface uses.
function listQuery(
scope: 'mine' | 'all' | undefined,
@@ -397,13 +397,13 @@ function listQuery(
return query;
}
-// The three anonymous catalogue reads below are edge-cached: their results
+// The three anonymous directory reads below are edge-cached: their results
// only change when a moderator approves a revision, so a short TTL absorbs
// most repeat traffic without any invalidation protocol. Authenticated
// reads (scope=mine/all) must never pass through this cache.
export async function listExtensions(
env: ApplicationEnv,
- filters: ExtensionCatalogueFilters = {},
+ filters: ExtensionDirectoryFilters = {},
): Promise {
const query = listQuery(undefined, filters);
return cachedEdgeRead(
diff --git a/src/lib/api/generated/extensions-v2/index.ts b/src/lib/api/generated/extensions-v2/index.ts
index 717b5951..d1265da2 100644
--- a/src/lib/api/generated/extensions-v2/index.ts
+++ b/src/lib/api/generated/extensions-v2/index.ts
@@ -147,7 +147,7 @@ export type {
GetUsersMeErrors,
GetUsersMeResponse,
GetUsersMeResponses,
- License,
+ ManifestRequirements,
ModeratorCorrect,
OwnedDeveloperProfile,
OwnedExtension,
diff --git a/src/lib/api/generated/extensions-v2/sdk.gen.ts b/src/lib/api/generated/extensions-v2/sdk.gen.ts
index ad605175..2dd2862e 100644
--- a/src/lib/api/generated/extensions-v2/sdk.gen.ts
+++ b/src/lib/api/generated/extensions-v2/sdk.gen.ts
@@ -141,7 +141,7 @@ export type Options<
};
/**
- * List extensions: published catalogue (scope=public), caller's own (scope=mine), or every extension (scope=all, moderator)
+ * List extensions: published extension directory (scope=public), caller's own (scope=mine), or every extension (scope=all, moderator)
*/
export const getExtensions = (
options?: Options,
@@ -603,7 +603,7 @@ export const postExtensionsByIdRevisionsByRevisionIdReject = <
});
/**
- * Remove a published extension from the public catalogue
+ * Remove a published extension from the public extension listing
*/
export const postExtensionsByIdDelist = (
options: Options,
@@ -627,7 +627,7 @@ export const postExtensionsByIdDelist = (
});
/**
- * Restore a delisted extension to the public catalogue
+ * Restore a delisted extension to the public extension listing
*/
export const postExtensionsByIdRelist = (
options: Options,
diff --git a/src/lib/api/generated/extensions-v2/types.gen.ts b/src/lib/api/generated/extensions-v2/types.gen.ts
index d6ef61ac..cdabaefb 100644
--- a/src/lib/api/generated/extensions-v2/types.gen.ts
+++ b/src/lib/api/generated/extensions-v2/types.gen.ts
@@ -10,21 +10,25 @@ export type UnifiedExtensionListResponse = {
};
export type ExtensionListItem = {
+ manifest_version: 1;
type:
- | 'mod'
+ | 'module'
| 'theme'
| 'payment-gateway'
| 'server-manager'
| 'domain-registrar'
- | 'hook'
| 'translation';
name: string;
description: string;
+ author: {
+ name: string;
+ url?: string;
+ };
/**
* Null when a legacy URL exceeds the card length bound
*/
- website: string | null;
- license: License;
+ homepage_url?: string | null;
+ license: string;
icon_url?: string;
source: Repository;
version: string;
@@ -36,15 +40,6 @@ export type ExtensionListItem = {
developer: PublicDeveloper;
};
-export type License = {
- name: string;
- /**
- * A current SPDX license identifier (https://spdx.org/licenses/). Omitted for custom or proprietary licenses.
- */
- spdx_id?: string;
- URL?: string;
-};
-
export type Repository = {
type: 'github' | 'gitlab' | 'custom';
repo: string;
@@ -64,21 +59,25 @@ export type OwnedExtensionListItem = {
id: string;
developer: PublicDeveloper;
published: {
+ manifest_version: 1;
type:
- | 'mod'
+ | 'module'
| 'theme'
| 'payment-gateway'
| 'server-manager'
| 'domain-registrar'
- | 'hook'
| 'translation';
name: string;
description: string;
+ author: {
+ name: string;
+ url?: string;
+ };
/**
* Null when a legacy URL exceeds the card length bound
*/
- website: string | null;
- license: License;
+ homepage_url?: string | null;
+ license: string;
icon_url?: string;
source: Repository;
version: string;
@@ -138,32 +137,50 @@ export type ExtensionDetailResponse = {
};
export type Extension = ExtensionContent & {
+ name?: string;
+ description?: string;
+ license?: string;
+ icon_url?: string;
+ version?: string;
id: string;
developer: PublicDeveloper;
};
+export type ManifestRequirements = {
+ fossbilling: string;
+ php: string;
+ modules?: {
+ [key: string]: string;
+ };
+};
+
export type Release = {
tag: string;
date: string;
download_url: string;
changelog_url?: string;
- min_fossbilling_version: string;
+ requires: ManifestRequirements;
};
export type ExtensionContent = {
+ manifest_version: 1;
type:
- | 'mod'
+ | 'module'
| 'theme'
| 'payment-gateway'
| 'server-manager'
| 'domain-registrar'
- | 'hook'
| 'translation';
name: string;
description: string;
+ author: {
+ name: string;
+ url?: string;
+ };
+ requires: ManifestRequirements;
releases: Array;
- website: string;
- license: License;
+ homepage_url?: string;
+ license: string;
icon_url?: string;
readme: string;
source: Repository;
@@ -174,14 +191,20 @@ export type ExtensionContent = {
export type OwnedExtension = OwnedExtensionListItem & {
published?: ExtensionContent &
({
+ name?: string;
+ description?: string;
releases?: Array<
Release & {
/**
* At most 100 Unicode code points in historical content
*/
tag?: string;
+ min_fossbilling_version?: string;
}
>;
+ license?: string;
+ icon_url?: string;
+ version?: string;
} | null);
pending_revision?: PendingRevisionRef &
({
@@ -190,47 +213,67 @@ export type OwnedExtension = OwnedExtensionListItem & {
};
export type StoredExtensionContent = {
+ manifest_version?: 1;
type?:
- | 'mod'
+ | 'module'
| 'theme'
| 'payment-gateway'
| 'server-manager'
| 'domain-registrar'
- | 'hook'
- | 'translation';
+ | 'translation'
+ | 'mod'
+ | 'hook';
name?: string;
description?: string;
+ author?: {
+ name: string;
+ url?: string;
+ };
+ requires?: ManifestRequirements;
releases?: Array<
Release & {
/**
* At most 100 Unicode code points in historical content
*/
tag?: string;
+ min_fossbilling_version?: string;
}
>;
- website?: string;
- license?: License;
- icon_url?: string;
+ homepage_url?: string;
+ license?:
+ | string
+ | {
+ name: string;
+ spdx_id?: string;
+ URL?: string;
+ };
+ icon_url?: string | string;
readme?: string;
source?: Repository;
version?: string;
download_url?: string;
+ website?: string;
};
export type ExtensionCreate = {
+ manifest_version: 1;
type:
- | 'mod'
+ | 'module'
| 'theme'
| 'payment-gateway'
| 'server-manager'
| 'domain-registrar'
- | 'hook'
| 'translation';
name: string;
description: string;
+ author: {
+ name: string;
+ url?: string;
+ };
+ requires: ManifestRequirements;
releases: Array;
- website: string;
- license: License;
+ homepage_url?: string;
+ license: string;
icon_url?: string;
readme: string;
source: Repository;
@@ -240,19 +283,24 @@ export type ExtensionCreate = {
};
export type ExtensionUpdate = {
+ manifest_version: 1;
type:
- | 'mod'
+ | 'module'
| 'theme'
| 'payment-gateway'
| 'server-manager'
| 'domain-registrar'
- | 'hook'
| 'translation';
name: string;
description: string;
+ author: {
+ name: string;
+ url?: string;
+ };
+ requires: ManifestRequirements;
releases: Array;
- website: string;
- license: License;
+ homepage_url?: string;
+ license: string;
icon_url?: string;
readme: string;
source: Repository;
@@ -392,19 +440,24 @@ export type DelistReason = {
};
export type ModeratorCorrect = {
+ manifest_version: 1;
type:
- | 'mod'
+ | 'module'
| 'theme'
| 'payment-gateway'
| 'server-manager'
| 'domain-registrar'
- | 'hook'
| 'translation';
name: string;
description: string;
+ author: {
+ name: string;
+ url?: string;
+ };
+ requires: ManifestRequirements;
releases: Array;
- website: string;
- license: License;
+ homepage_url?: string;
+ license: string;
icon_url?: string;
readme: string;
source: Repository;
@@ -465,12 +518,11 @@ export type GetExtensionsData = {
path?: never;
query?: {
type?:
- | 'mod'
+ | 'module'
| 'theme'
| 'payment-gateway'
| 'server-manager'
| 'domain-registrar'
- | 'hook'
| 'translation';
/**
* Public scope only
@@ -482,7 +534,7 @@ export type GetExtensionsData = {
*/
cursor?: string;
/**
- * public: published catalogue (anonymous allowed). mine: caller's own extensions. all: every extension (moderator only).
+ * public: published extension directory (anonymous allowed). mine: caller's own extensions. all: every extension (moderator only).
*/
scope?: 'public' | 'mine' | 'all';
/**
@@ -520,7 +572,7 @@ export type GetExtensionsError = GetExtensionsErrors[keyof GetExtensionsErrors];
export type GetExtensionsResponses = {
/**
- * Extensions matching the scope: catalogue cards for scope=public, owned rows for scope=mine/all
+ * Extensions matching the scope: extension cards for scope=public, owned rows for scope=mine/all
*/
200: UnifiedExtensionListResponse;
};
@@ -575,7 +627,7 @@ export type PostExtensionsError =
export type PostExtensionsResponses = {
/**
- * Extension created. It holds the id immediately but stays out of the public catalogue until a moderator approves the revision.
+ * Extension created. It holds the id immediately but stays out of the public extension listing until a moderator approves the revision.
*/
201: {
result: {
@@ -1635,7 +1687,7 @@ export type PostExtensionsByIdDelistError =
export type PostExtensionsByIdDelistResponses = {
/**
- * Extension removed from the public catalogue. Its content and history are kept, and its owner can still see and edit it.
+ * Extension removed from the public extension listing. Its content and history are kept, and its owner can still see and edit it.
*/
200: {
result: {
@@ -1698,7 +1750,7 @@ export type PostExtensionsByIdRelistError =
export type PostExtensionsByIdRelistResponses = {
/**
- * Extension restored to the public catalogue. Content and history unchanged.
+ * Extension restored to the public extension listing. Content and history unchanged.
*/
200: {
result: {
diff --git a/src/lib/cache-invalidate.ts b/src/lib/cache-invalidate.ts
index 7c8fa894..7fb9a625 100644
--- a/src/lib/cache-invalidate.ts
+++ b/src/lib/cache-invalidate.ts
@@ -1,22 +1,22 @@
import type { APIContext } from 'astro';
import { markEdgeCachePurged } from './cache';
+import { EXTENSIONS_CACHE_TAGS } from './cache-tags';
-// Shared cache-tag vocabulary. astro.config.mjs's routeRules tag cached
+// Shared cache-tag vocabulary. astro.config.ts's routeRules tag cached
// pages with these, and both purge paths — the dashboard helpers below and
// POST /api/revalidate — purge them. 'developers' currently tags no route
// (developer pages are deliberately uncached — see routeRules) but is kept
// accepted because the api worker sends it; purging a tag no URL carries is
// a no-op, and it is reserved for any future developer-surface caching.
-export const CATALOGUE_CACHE_TAGS = ['catalogue', 'developers'];
-// Purging both tags together is a single CDN purge call, and every catalogue
+// Purging both tags together is a single CDN purge call, and every directory
// mutation touches at least one of the two surfaces.
//
// Mutation endpoints call this fire-and-forget right after a successful
// write: the CDN purge runs on waitUntil so the redirect is not delayed, and
-// route-cached catalogue pages re-render on the next request — dashboard
+// route-cached directory pages re-render on the next request — dashboard
// changes become visible within a second or two instead of after a TTL.
-export function purgeCatalogue(context: APIContext): void {
+export function purgeDirectory(context: APIContext): void {
if (!context.cache.enabled) return;
let purge: Promise;
@@ -24,7 +24,7 @@ export function purgeCatalogue(context: APIContext): void {
// Same-isolate data-cache entries must not repopulate re-renders with
// pre-purge data (CDN tag purges cannot reach the per-colo Cache API).
markEdgeCachePurged();
- purge = context.cache.invalidate({ tags: [...CATALOGUE_CACHE_TAGS] });
+ purge = context.cache.invalidate({ tags: [...EXTENSIONS_CACHE_TAGS] });
} catch (error) {
// A synchronous failure here must never fail the mutation that already
// succeeded; the route-rule windows bound any staleness.
diff --git a/src/lib/cache-tags.ts b/src/lib/cache-tags.ts
new file mode 100644
index 00000000..9877aed4
--- /dev/null
+++ b/src/lib/cache-tags.ts
@@ -0,0 +1,2 @@
+export const EXTENSIONS_CACHE_TAG = 'extensions';
+export const EXTENSIONS_CACHE_TAGS = [EXTENSIONS_CACHE_TAG, 'developers'];
diff --git a/src/lib/cache.ts b/src/lib/cache.ts
index bba4998a..51de0533 100644
--- a/src/lib/cache.ts
+++ b/src/lib/cache.ts
@@ -1,11 +1,11 @@
// Edge-cache helpers for public, user-independent responses. Cloudflare
// does not automatically cache Worker-generated responses, so hot public
// reads are stored through the Cache API (per-colo, isolate-independent)
-// with a short TTL: catalogue content only changes when a moderator
+// with a short TTL: directory content only changes when a moderator
// approves a revision, so a minute of staleness trades negligible
// invocation and API-subrequest cost for most repeat traffic.
-const CATALOGUE_CACHE_TTL_SECONDS = 60;
+const DIRECTORY_CACHE_TTL_SECONDS = 60;
// Per-isolate purge marker. CDN tag purges cannot reach the per-colo Cache
// API entries cached here, so a page re-rendered right after a purge could
@@ -113,7 +113,7 @@ export async function cachedEdgeRead(
new Response(JSON.stringify({ writtenAt: missStartedAt, value }), {
headers: {
'content-type': 'application/json',
- 'cache-control': `public, s-maxage=${CATALOGUE_CACHE_TTL_SECONDS}`,
+ 'cache-control': `public, s-maxage=${DIRECTORY_CACHE_TTL_SECONDS}`,
},
}),
);
diff --git a/src/lib/catalogue-filters.ts b/src/lib/directory-filters.ts
similarity index 76%
rename from src/lib/catalogue-filters.ts
rename to src/lib/directory-filters.ts
index 0d12e65f..5dc5c754 100644
--- a/src/lib/catalogue-filters.ts
+++ b/src/lib/directory-filters.ts
@@ -1,19 +1,19 @@
-import type { ExtensionCatalogueFilters } from '@/lib/api/client';
+import type { ExtensionDirectoryFilters } from '@/lib/api/client';
import { isExtensionType } from '@/types';
-// Query parsing shared by the catalogue JSON API (/api/extensions) and the
+// Query parsing shared by the directory JSON API (/api/extensions) and the
// load-more fragment (/api/extensions/cards), so the two endpoints always
// accept exactly the same filters.
-export function parseCatalogueFilters(params: URLSearchParams):
+export function parseDirectoryFilters(params: URLSearchParams):
| {
- filters: ExtensionCatalogueFilters;
+ filters: ExtensionDirectoryFilters;
error: null;
}
| {
filters: null;
error: string;
} {
- const filters: ExtensionCatalogueFilters = {};
+ const filters: ExtensionDirectoryFilters = {};
const type = params.get('type');
if (type !== null && type !== '' && !isExtensionType(type)) {
return { filters: null, error: 'The extension type filter is invalid.' };
diff --git a/src/lib/catalogue-pagination.ts b/src/lib/directory-pagination.ts
similarity index 66%
rename from src/lib/catalogue-pagination.ts
rename to src/lib/directory-pagination.ts
index 2bc3d4bb..9d54ae9a 100644
--- a/src/lib/catalogue-pagination.ts
+++ b/src/lib/directory-pagination.ts
@@ -1,25 +1,25 @@
import type { ExtensionListItem, ExtensionListResponse } from './api/client';
-type CatalogueItem = {
+type DirectoryItem = {
id: string;
};
-type CataloguePage- = {
+type DirectoryPage
- = {
result: Item[];
pagination: ExtensionListResponse['pagination'];
};
-type CataloguePageFilters = {
+type DirectoryPageFilters = {
type?: string;
developer_id?: string;
limit?: number;
};
-export type CataloguePageRequest = CataloguePageFilters & {
+export type DirectoryPageRequest = DirectoryPageFilters & {
cursor: string;
};
-type CataloguePagerState
- = {
+type DirectoryPagerState
- = {
items: Item[];
nextCursor: string | null;
hasMore: boolean;
@@ -27,16 +27,16 @@ type CataloguePagerState
- = {
error: unknown | null;
};
-type CataloguePageLoader
- = (
- request: CataloguePageRequest,
-) => Promise
>;
+type DirectoryPageLoader- = (
+ request: DirectoryPageRequest,
+) => Promise
>;
-export function createCataloguePager<
- Item extends CatalogueItem = ExtensionListItem,
+export function createDirectoryPager<
+ Item extends DirectoryItem = ExtensionListItem,
>(
- firstPage: CataloguePage- ,
- filters: CataloguePageFilters,
- loadPage: CataloguePageLoader
- ,
+ firstPage: DirectoryPage
- ,
+ filters: DirectoryPageFilters,
+ loadPage: DirectoryPageLoader
- ,
initialIds: string[] = [],
) {
let state = stateFromPage(firstPage);
@@ -44,14 +44,14 @@ export function createCataloguePager<
...initialIds.map((id) => id.toLowerCase()),
...state.items.map((item) => item.id.toLowerCase()),
]);
- let inFlight: Promise
> | null = null;
+ let inFlight: Promise> | null = null;
return {
- getState(): CataloguePagerState- {
+ getState(): DirectoryPagerState
- {
return state;
},
- loadNextPage(): Promise
> {
+ loadNextPage(): Promise> {
if (inFlight) {
return inFlight;
}
@@ -60,7 +60,7 @@ export function createCataloguePager<
return Promise.resolve(state);
}
- const request: CataloguePageRequest = {
+ const request: DirectoryPageRequest = {
...filters,
cursor: state.nextCursor,
};
@@ -101,15 +101,15 @@ export function createCataloguePager<
};
}
-export function createCataloguePagerFromIds<
- Item extends CatalogueItem = ExtensionListItem,
+export function createDirectoryPagerFromIds<
+ Item extends DirectoryItem = ExtensionListItem,
>(
initialIds: string[],
- pagination: CataloguePage- ['pagination'],
- filters: CataloguePageFilters,
- loadPage: CataloguePageLoader
- ,
+ pagination: DirectoryPage
- ['pagination'],
+ filters: DirectoryPageFilters,
+ loadPage: DirectoryPageLoader
- ,
) {
- return createCataloguePager
- (
+ return createDirectoryPager
- (
{ result: [], pagination },
filters,
loadPage,
@@ -117,9 +117,9 @@ export function createCataloguePagerFromIds<
);
}
-export function stateFromPage
- (
- page: CataloguePage
- ,
-): CataloguePagerState
- {
+export function stateFromPage
- (
+ page: DirectoryPage
- ,
+): DirectoryPagerState
- {
return {
items: [...page.result],
nextCursor: page.pagination.next_cursor,
@@ -129,11 +129,11 @@ export function stateFromPage
- (
};
}
-export function appendPage
- (
- state: CataloguePagerState
- ,
- page: CataloguePage
- ,
+export function appendPage
- (
+ state: DirectoryPagerState
- ,
+ page: DirectoryPage
- ,
knownIds = new Set(state.items.map((item) => item.id.toLowerCase())),
-): CataloguePagerState
- {
+): DirectoryPagerState
- {
const newItems = page.result.filter((item) => {
const key = item.id.toLowerCase();
if (knownIds.has(key)) {
@@ -153,7 +153,7 @@ export function appendPage
- (
}
// Whether another page exists at all. Shared with the server-rendered
-// catalogue wrappers, whose data-has-more attribute seeds the client pager.
+// directory wrappers, whose data-has-more attribute seeds the client pager.
export function hasNextPage(
pagination: ExtensionListResponse['pagination'],
): boolean {
diff --git a/src/lib/extension-form.ts b/src/lib/extension-form.ts
index 705873ad..9fe00cfd 100644
--- a/src/lib/extension-form.ts
+++ b/src/lib/extension-form.ts
@@ -1,47 +1,71 @@
+import { isPackageIconPath } from './package-icon';
import { isExtensionType, isSourceType, SPDX_LICENSE_IDS } from '@/types';
import type { Extension, Release } from '@/types';
import type { ExtensionCreate, ExtensionUpdate } from '@/lib/api/client';
import { formString } from './form';
import { withHttpsScheme } from './url-prefix';
+export type ExtensionFormEcho = Extension & { moduleRequirementsInput: string };
+
// Thrown for form-level validation failures that should be shown to the
// user, distinct from ApiRequestError (the api rejecting an otherwise
// well-formed payload) — see the try/catch in new.astro/edit.astro.
export class ExtensionValidationError extends Error {}
-// "Other / Proprietary" is a form-only sentinel, never a real spdx_id value
-// — buildLicense() reads it back out of license_spdx_id to decide whether
-// license_name_custom (vs. the spdx_id itself) becomes license.name. The
-// single export here is what ExtensionForm.astro and edit.astro both use,
-// rather than each hand-copying the string.
+// The combobox offers SPDX identifiers; Other also accepts compound expressions.
export const OTHER_LICENSE = 'other';
-// The License field pair: a
of current SPDX ids (matching the api's
-// own spdx-license-ids-backed validation) plus an "Other / Proprietary"
-// sentinel that reveals a free-text name instead. Mirrors the server: a
-// recognized id becomes both `name` and `spdx_id`; "Other" carries only a
-// custom `name`.
-function buildLicense(form: FormData) {
+function buildLicense(form: FormData): string {
const selected = formString(form, 'license_spdx_id');
- const url = withHttpsScheme(formString(form, 'license_url'));
+ const license =
+ selected === OTHER_LICENSE
+ ? formString(form, 'license_name_custom')
+ : selected;
+ if (
+ !license ||
+ license.length > 1000 ||
+ !/^[A-Za-z0-9.\-+_:() |]+$/.test(license) ||
+ (selected !== OTHER_LICENSE && !SPDX_LICENSE_IDS.includes(selected))
+ ) {
+ throw new ExtensionValidationError(
+ 'Choose a license or enter a license expression.',
+ );
+ }
+ return license;
+}
- if (selected === OTHER_LICENSE) {
- const customName = formString(form, 'license_name_custom');
- if (!customName) {
+function moduleRequirements(input: string): Record | undefined {
+ if (!input.trim()) return undefined;
+ const modules: Record = Object.create(null);
+ for (const line of input.split(/\r?\n/)) {
+ if (!line.trim()) continue;
+ const match = /^([a-z0-9_-]+)\s*:\s*(.+)$/.exec(line.trim());
+ if (
+ !match ||
+ !match[2].trim() ||
+ match[2].trim().length > 1000 ||
+ Object.hasOwn(modules, match[1])
+ )
throw new ExtensionValidationError(
- 'Enter a name for the custom or proprietary license.',
+ 'Enter module dependencies once each, as module-id: constraint on separate lines.',
);
- }
- return { name: customName, URL: url };
+ modules[match[1]] = match[2].trim();
}
+ return modules;
+}
- if (!SPDX_LICENSE_IDS.includes(selected)) {
+function buildRequirements(form: FormData) {
+ const fossbilling = formString(form, 'requires_fossbilling');
+ const php = formString(form, 'requires_php');
+ if (!fossbilling || !php || fossbilling.length > 1000 || php.length > 1000)
throw new ExtensionValidationError(
- 'Choose a license, or "Other / Proprietary" for one not listed.',
+ 'Enter the FOSSBilling and PHP version requirements.',
);
- }
-
- return { name: selected, spdx_id: selected, URL: url };
+ return {
+ fossbilling,
+ php,
+ modules: moduleRequirements(formString(form, 'requires_modules')),
+ };
}
// Shared by both builders below. A new release is only appended when
@@ -56,6 +80,7 @@ function buildContent(
requireRelease: boolean,
) {
const str = (name: string) => formString(form, name);
+ const requires = buildRequirements(form);
const releases = [...existing.releases];
let version = existing.version;
@@ -85,10 +110,9 @@ function buildContent(
const releaseDate = str('release_date');
const releaseDownloadUrl = withHttpsScheme(str('download_url'));
- const minVersion = str('min_fossbilling_version');
- if (!releaseDate || !releaseDownloadUrl || !minVersion) {
+ if (!releaseDate || !releaseDownloadUrl) {
throw new ExtensionValidationError(
- 'To add a new release, fill in the release date, download URL, and minimum FOSSBilling version.',
+ 'To add a new release, fill in the release date and download URL.',
);
}
@@ -97,7 +121,7 @@ function buildContent(
date: releaseDate,
download_url: releaseDownloadUrl,
changelog_url: withHttpsScheme(str('changelog_url')),
- min_fossbilling_version: minVersion,
+ requires,
};
releases.push(release);
version = release.tag;
@@ -112,14 +136,27 @@ function buildContent(
);
}
+ const icon = str('icon_url');
+ if (icon && !isPackageIconPath(icon))
+ throw new ExtensionValidationError(
+ 'Enter an icon path relative to the package root, such as icon.svg.',
+ );
+ if (!str('author_name'))
+ throw new ExtensionValidationError('Enter the package author name.');
return {
+ manifest_version: 1 as const,
+ author: {
+ name: str('author_name'),
+ url: withHttpsScheme(str('author_url')),
+ },
+ requires,
type: typeInput,
name: str('name'),
description: str('description'),
releases,
- website: withHttpsScheme(str('website')) ?? '',
+ homepage_url: withHttpsScheme(str('homepage_url')),
license: buildLicense(form),
- icon_url: withHttpsScheme(str('icon_url')),
+ icon_url: icon || undefined,
readme: str('readme'),
source: {
type: sourceTypeInput,
@@ -167,7 +204,7 @@ export function buildExtensionUpdatePayload(
export function echoExtensionFromForm(
form: FormData,
base: Extension,
-): Extension {
+): ExtensionFormEcho {
const selectedLicenseId = formString(form, 'license_spdx_id');
const isRecognizedLicense =
selectedLicenseId !== OTHER_LICENSE &&
@@ -177,19 +214,23 @@ export function echoExtensionFromForm(
type: formString(form, 'type') as Extension['type'],
name: formString(form, 'name'),
description: formString(form, 'description'),
- website: formString(form, 'website'),
+ homepage_url: formString(form, 'homepage_url'),
icon_url: formString(form, 'icon_url') || undefined,
readme: formString(form, 'readme'),
+ manifest_version: 1,
+ author: {
+ name: formString(form, 'author_name'),
+ url: formString(form, 'author_url') || undefined,
+ },
+ requires: {
+ fossbilling: formString(form, 'requires_fossbilling'),
+ php: formString(form, 'requires_php'),
+ modules: base.requires.modules,
+ },
+ moduleRequirementsInput: formString(form, 'requires_modules'),
license: isRecognizedLicense
- ? {
- name: selectedLicenseId,
- spdx_id: selectedLicenseId,
- URL: formString(form, 'license_url') || undefined,
- }
- : {
- name: formString(form, 'license_name_custom'),
- URL: formString(form, 'license_url') || undefined,
- },
+ ? selectedLicenseId
+ : formString(form, 'license_name_custom'),
source: {
type: formString(form, 'source_type') as Extension['source']['type'],
repo: formString(form, 'source_repo'),
@@ -208,7 +249,6 @@ export interface ReleaseDraft {
release_date: string;
download_url: string;
changelog_url: string;
- min_fossbilling_version: string;
}
export function echoReleaseDraftFromForm(form: FormData): ReleaseDraft {
@@ -217,7 +257,6 @@ export function echoReleaseDraftFromForm(form: FormData): ReleaseDraft {
release_date: formString(form, 'release_date'),
download_url: formString(form, 'download_url'),
changelog_url: formString(form, 'changelog_url'),
- min_fossbilling_version: formString(form, 'min_fossbilling_version'),
};
}
@@ -229,15 +268,18 @@ export function echoReleaseDraftFromForm(form: FormData): ReleaseDraft {
export function echoNewExtensionFromForm(
form: FormData,
developer: Extension['developer'],
-): { extension: Extension; releaseDraft: ReleaseDraft } {
+): { extension: ExtensionFormEcho; releaseDraft: ReleaseDraft } {
const base: Extension = {
+ manifest_version: 1,
+ author: { name: developer.name, url: developer.URL },
+ requires: { fossbilling: '', php: '' },
id: formString(form, 'extension_id').toLowerCase(),
- type: 'mod',
+ type: 'module',
name: '',
description: '',
releases: [],
- website: '',
- license: { name: '' },
+ homepage_url: '',
+ license: '',
readme: '',
source: { type: 'github', repo: '' },
version: '',
diff --git a/src/lib/extension-icon.ts b/src/lib/extension-icon.ts
new file mode 100644
index 00000000..5870ff86
--- /dev/null
+++ b/src/lib/extension-icon.ts
@@ -0,0 +1,63 @@
+import { isPackageIconPath } from './package-icon';
+
+/** Resolve manifest paths from supported GitHub release assets; retain legacy URLs. */
+export function extensionIconUrl(extension: {
+ id: string;
+ icon_url?: string;
+ download_url?: string | null;
+ source: { type: string; repo: string };
+}): string | undefined {
+ const icon = extension.icon_url;
+ if (!icon || /[\u0000-\u001f\u007f-\u009f\u2028\u2029]/.test(icon))
+ return undefined;
+ try {
+ const absolute = new URL(icon);
+ return /^https?:$/.test(absolute.protocol) &&
+ !absolute.username &&
+ !absolute.password
+ ? absolute.href
+ : undefined;
+ } catch {
+ // Manifest icons are package-relative; do not resolve them against the site.
+ }
+ if (!isPackageIconPath(icon)) return undefined;
+ if (
+ extension.source.type !== 'github' ||
+ !/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(extension.source.repo)
+ )
+ return undefined;
+ try {
+ const download = new URL(extension.download_url ?? '');
+ if (
+ download.origin !== 'https://github.com' ||
+ download.username ||
+ download.password
+ )
+ return undefined;
+ const [owner, repo] = extension.source.repo.split('/');
+ const parts = download.pathname.split('/').slice(1);
+ if (
+ parts[0].toLowerCase() !== owner.toLowerCase() ||
+ parts[1].toLowerCase() !== repo.toLowerCase() ||
+ parts[2] !== 'releases' ||
+ parts[3] !== 'download' ||
+ parts.length !== 6
+ )
+ return undefined;
+ const ref = decodeURIComponent(parts[4]);
+ // GitHub refs that look like paths need a separate explicit API contract.
+ if (!ref || ref === '.' || ref === '..' || /[/\\]/.test(ref))
+ return undefined;
+ const packageRoot =
+ extension.source.repo.toLowerCase() === 'fossbilling/modules'
+ ? extension.id.charAt(0).toUpperCase() + extension.id.slice(1)
+ : '';
+ const path = [packageRoot, ...icon.split('/')]
+ .filter(Boolean)
+ .map(encodeURIComponent)
+ .join('/');
+ return `https://raw.githubusercontent.com/${owner}/${repo}/${encodeURIComponent(ref)}/${path}`;
+ } catch {
+ return undefined;
+ }
+}
diff --git a/src/lib/extensions-data.ts b/src/lib/extensions-data.ts
index c31e49fe..efef291e 100644
--- a/src/lib/extensions-data.ts
+++ b/src/lib/extensions-data.ts
@@ -15,11 +15,7 @@ import type { ApplicationEnv } from './runtime';
import type {
DeveloperProfile,
Extension,
- ExtensionType,
- License,
PublicDeveloperProfile,
- Release,
- Repository,
} from '@/types';
export interface OwnerReadOptions {
@@ -34,19 +30,8 @@ export interface OwnerReadOptions {
// The content of a proposed revision. Revision history predates current
// validation rules, so every field is optional here — unlike Extension,
// which describes only published content and is always complete.
-export interface StoredExtensionFields {
- type?: ExtensionType;
- name?: string;
- description?: string;
- website?: string;
- license?: License;
- icon_url?: string;
- readme?: string;
- source?: Repository;
- version?: string;
- download_url?: string;
- releases?: Release[];
-}
+export type StoredExtensionFields =
+ import('./api/generated/extensions-v2').StoredExtensionContent;
export interface PendingRevision {
id: string;
@@ -112,12 +97,15 @@ function toPublicDeveloper(developer: PublicDeveloper): PublicDeveloperProfile {
function toExtension(extension: ApiExtension): Extension {
return {
+ manifest_version: extension.manifest_version,
+ author: extension.author,
+ requires: extension.requires,
id: extension.id,
type: extension.type,
name: extension.name,
description: extension.description,
releases: extension.releases,
- website: extension.website,
+ homepage_url: extension.homepage_url,
license: extension.license,
icon_url: extension.icon_url,
readme: extension.readme,
diff --git a/src/lib/markdown.ts b/src/lib/markdown.ts
index 0451aba2..7de39021 100644
--- a/src/lib/markdown.ts
+++ b/src/lib/markdown.ts
@@ -2,7 +2,7 @@ import { marked } from 'marked';
import sanitizeHtml from 'sanitize-html';
// The site's single markdown pipeline, so moderators preview exactly what
-// the public catalogue renders (see Overview.astro). Readme content is
+// the public directory renders (see Overview.astro). Readme content is
// untrusted author input rendered in other users' sessions — always sanitize,
// never inject marked output directly.
const SANITIZE_OPTIONS: sanitizeHtml.IOptions = {
diff --git a/src/lib/package-icon.ts b/src/lib/package-icon.ts
new file mode 100644
index 00000000..7116ae5a
--- /dev/null
+++ b/src/lib/package-icon.ts
@@ -0,0 +1,12 @@
+/** The manifest icon must stay within the package root. */
+export function isPackageIconPath(path: string): boolean {
+ return (
+ path.length > 0 &&
+ path.length <= 2048 &&
+ !path.startsWith('/') &&
+ !path.includes('\\') &&
+ !path.includes('..') &&
+ !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(path) &&
+ !/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/.test(path)
+ );
+}
diff --git a/src/lib/revision-diff-shared.ts b/src/lib/revision-diff-shared.ts
index 1b0bf17a..5104b672 100644
--- a/src/lib/revision-diff-shared.ts
+++ b/src/lib/revision-diff-shared.ts
@@ -26,21 +26,25 @@ interface DiffRelease {
}
interface DiffContent {
- license?: DiffLicense | null;
+ author?: { name?: string; url?: string } | null;
+ license?: string | DiffLicense | null;
source?: DiffSource | null;
releases?: Array | null;
[field: string]: unknown;
}
// Fields moderators actually compare, in review order. `releases` and
-// `readme` are handled specially (counts / collapsible) by the card UI but
+// `readme` are handled specially (collapsible) by the card UI but
// still appear here so "unchanged" state is explicit.
export const DIFF_FIELDS = [
'name',
'type',
'version',
'description',
- 'website',
+ 'manifest_version',
+ 'author',
+ 'requires',
+ 'homepage_url',
'download_url',
'icon_url',
'source',
@@ -54,7 +58,7 @@ export type DiffField = (typeof DIFF_FIELDS)[number];
// Fields whose plain values render as clickable links. DiffValue.astro and
// the browser queue renderer both check this set.
export const URL_FIELDS: ReadonlySet = new Set([
- 'website',
+ 'homepage_url',
'download_url',
'icon_url',
]);
@@ -77,7 +81,10 @@ export const FIELD_LABELS: Record = {
type: 'Type',
version: 'Version',
description: 'Description',
- website: 'Website',
+ manifest_version: 'Manifest Version',
+ author: 'Package Author',
+ requires: 'Requirements',
+ homepage_url: 'Website',
download_url: 'Download URL',
icon_url: 'Icon URL',
source: 'Source Repo',
@@ -92,8 +99,9 @@ function scalarLabel(value: unknown): string | null {
return text.length > 0 ? text : null;
}
-function licenseLabel(license?: DiffLicense | null): string | null {
+function licenseLabel(license?: string | DiffLicense | null): string | null {
if (!license) return null;
+ if (typeof license === 'string') return license;
if (typeof license.name === 'string' && license.name.length > 0) {
return license.spdx_id
? `${license.name} (${license.spdx_id})`
@@ -102,13 +110,21 @@ function licenseLabel(license?: DiffLicense | null): string | null {
return null;
}
-function licenseUrl(license?: DiffLicense | null): string | null {
- if (!license || typeof license.URL !== 'string') return null;
+function licenseUrl(license?: string | DiffLicense | null): string | null {
+ if (
+ !license ||
+ typeof license === 'string' ||
+ typeof license.URL !== 'string'
+ )
+ return null;
return license.URL.length > 0 ? license.URL : null;
}
-function licenseCompareKey(license?: DiffLicense | null): string | null {
+function licenseCompareKey(
+ license?: string | DiffLicense | null,
+): string | null {
if (!license) return null;
+ if (typeof license === 'string') return JSON.stringify([license]);
const parts = [license.name, license.spdx_id, license.URL].filter(
(part): part is string => typeof part === 'string' && part.length > 0,
);
@@ -152,33 +168,28 @@ function sourceHref(source?: DiffSource | null): string | null {
}
}
-function releasesLabel(
- releases?: Array | null,
-): string | null {
- if (!releases) return null;
- if (releases.length === 0) return '—';
- const tags = releases
- .map((r) => r?.tag)
- .filter((t): t is string => typeof t === 'string' && t.length > 0);
- if (tags.length === 0) return `${releases.length} release(s)`;
- const shown = tags.slice(0, 5).join(', ');
- return tags.length > 5
- ? `${releases.length} releases (${shown}, …)`
- : `${releases.length} release(s): ${shown}`;
-}
-
export function fieldDisplay(
field: DiffField,
content: DiffContent | null,
): string | null {
if (!content) return null;
switch (field) {
+ case 'homepage_url':
+ return scalarLabel(content.homepage_url ?? content.website);
+ case 'author':
+ return scalarLabel(content.author?.name);
+ case 'requires':
+ return content[field] == null ? null : canonicalJson(content[field]);
case 'license':
return licenseLabel(content.license);
case 'source':
return sourceLabel(content.source);
case 'releases':
- return releasesLabel(content.releases);
+ return content.releases == null
+ ? null
+ : content.releases.length === 0
+ ? '—'
+ : canonicalJson(content.releases);
default:
return scalarLabel(content[field]);
}
@@ -190,10 +201,14 @@ export function fieldCompareKey(
): string | null {
if (!content) return null;
switch (field) {
+ case 'author':
+ return content.author == null ? null : canonicalJson(content.author);
case 'license':
return licenseCompareKey(content.license);
case 'source':
return sourceCompareKey(content.source);
+ case 'releases':
+ return content.releases == null ? null : canonicalJson(content.releases);
default:
return fieldDisplay(field, content);
}
@@ -219,6 +234,8 @@ export function fieldUrl(
): string | null {
if (!content) return null;
switch (field) {
+ case 'author':
+ return scalarLabel(content.author?.url);
case 'license':
return licenseUrl(content.license);
case 'source':
@@ -227,3 +244,16 @@ export function fieldUrl(
return null;
}
}
+
+function canonicalJson(value: unknown): string {
+ return JSON.stringify(value, (_key, item) =>
+ item && typeof item === 'object' && !Array.isArray(item)
+ ? Object.fromEntries(
+ Object.keys(item)
+ .sort()
+ .filter((key) => item[key] !== undefined)
+ .map((key) => [key, item[key]]),
+ )
+ : item,
+ );
+}
diff --git a/src/lib/runtime.ts b/src/lib/runtime.ts
index f1ff34bb..7cb8107f 100644
--- a/src/lib/runtime.ts
+++ b/src/lib/runtime.ts
@@ -27,7 +27,7 @@ export interface ApplicationEnv {
sessionSecret: string;
assertionSigningSecret: string;
// Shared secret for POST /api/revalidate, called by the api worker (and
- // other writers) to purge CDN-cached catalogue pages after mutations that
+ // other writers) to purge CDN-cached directory pages after mutations that
// bypass this dashboard.
revalidateSecret: string;
}
diff --git a/src/lib/signed-image-url.ts b/src/lib/signed-image-url.ts
index 4cd26184..3159f14a 100644
--- a/src/lib/signed-image-url.ts
+++ b/src/lib/signed-image-url.ts
@@ -1,4 +1,4 @@
-// Server-only issuance: call with images from catalogue/account data, never
+// Server-only issuance: call with images from directory/account data, never
// with an arbitrary request query value. The browser only receives the URL.
import {
getOptimizedImageUrl,
diff --git a/src/pages/account/admin/developers/[id]/approve.ts b/src/pages/account/admin/developers/[id]/approve.ts
index 149a8e3e..745cd149 100644
--- a/src/pages/account/admin/developers/[id]/approve.ts
+++ b/src/pages/account/admin/developers/[id]/approve.ts
@@ -3,7 +3,7 @@ import { requireModerator } from '@/lib/auth-guard';
import { createApiClient } from '@/lib/api/client';
import { formAction } from '@/lib/form-action';
import { formFlag, formString } from '@/lib/form';
-import { purgeCatalogue } from '@/lib/cache-invalidate';
+import { purgeDirectory } from '@/lib/cache-invalidate';
import { setFlash } from '@/lib/flash';
export const POST: APIRoute = formAction<{
@@ -39,7 +39,7 @@ export const POST: APIRoute = formAction<{
input.expectedGeneration,
input.notify,
);
- purgeCatalogue(context);
+ purgeDirectory(context);
if (input.notify && !result.notified) {
await setFlash(context, env.sessionSecret, {
category: 'warning',
diff --git a/src/pages/account/admin/developers/claims/[id]/approve.ts b/src/pages/account/admin/developers/claims/[id]/approve.ts
index 8526d8ee..879b5bc2 100644
--- a/src/pages/account/admin/developers/claims/[id]/approve.ts
+++ b/src/pages/account/admin/developers/claims/[id]/approve.ts
@@ -3,7 +3,7 @@ import { requireModerator } from '@/lib/auth-guard';
import { createApiClient } from '@/lib/api/client';
import { formAction } from '@/lib/form-action';
import { formFlag, formString } from '@/lib/form';
-import { purgeCatalogue } from '@/lib/cache-invalidate';
+import { purgeDirectory } from '@/lib/cache-invalidate';
import { setFlash } from '@/lib/flash';
export const POST: APIRoute = formAction<{ notify: boolean }>({
@@ -28,7 +28,7 @@ export const POST: APIRoute = formAction<{ notify: boolean }>({
id,
input.notify,
);
- purgeCatalogue(context);
+ purgeDirectory(context);
if (input.notify && !result.notified) {
await setFlash(context, env.sessionSecret, {
category: 'warning',
diff --git a/src/pages/account/admin/developers/claims/[id]/reject.ts b/src/pages/account/admin/developers/claims/[id]/reject.ts
index 082addba..c4ec92f0 100644
--- a/src/pages/account/admin/developers/claims/[id]/reject.ts
+++ b/src/pages/account/admin/developers/claims/[id]/reject.ts
@@ -3,7 +3,7 @@ import { requireModerator } from '@/lib/auth-guard';
import { createApiClient } from '@/lib/api/client';
import { formAction } from '@/lib/form-action';
import { formFlag, formString } from '@/lib/form';
-import { purgeCatalogue } from '@/lib/cache-invalidate';
+import { purgeDirectory } from '@/lib/cache-invalidate';
import { setFlash } from '@/lib/flash';
export const POST: APIRoute = formAction<{
@@ -27,7 +27,7 @@ export const POST: APIRoute = formAction<{
input.reviewNote,
input.notify,
);
- purgeCatalogue(context);
+ purgeDirectory(context);
if (input.notify && !result.notified) {
await setFlash(context, env.sessionSecret, {
category: 'warning',
diff --git a/src/pages/account/admin/extensions/[id].astro b/src/pages/account/admin/extensions/[id].astro
index bdd2917c..7bd8d2cb 100644
--- a/src/pages/account/admin/extensions/[id].astro
+++ b/src/pages/account/admin/extensions/[id].astro
@@ -140,10 +140,12 @@ const correctable = Boolean(
@@ -161,7 +163,7 @@ const correctable = Boolean(
License
- {ext.published.license.name}
+ {ext.published.license}
) : (
diff --git a/src/pages/account/admin/extensions/[id]/edit.astro b/src/pages/account/admin/extensions/[id]/edit.astro
index 4ca6a0f9..f02fc4ad 100644
--- a/src/pages/account/admin/extensions/[id]/edit.astro
+++ b/src/pages/account/admin/extensions/[id]/edit.astro
@@ -21,7 +21,7 @@ import {
import { formString } from '@/lib/form';
import { formatDate } from '@/lib/format-date';
import { setFlash } from '@/lib/flash';
-import { purgeCatalogue } from '@/lib/cache-invalidate';
+import { purgeDirectory } from '@/lib/cache-invalidate';
import type { Extension } from '@/types';
import { CircleAlert } from '@lucide/astro';
import DateTime from '@/components/admin/DateTime.astro';
@@ -67,7 +67,7 @@ let error: string | null = null;
// Falls back to the just-submitted values on a failed correction, so the
// form doesn't reset to the published content and discard the edit — same
// submitted echo as the author edit page.
-let submitted: Extension | null = null;
+let submitted: ReturnType | null = null;
let submittedNote = '';
let submittedReleaseDraft: ReleaseDraft | null = null;
@@ -89,7 +89,7 @@ if (
}
const payload = buildExtensionUpdatePayload(form, base);
await api.correctExtension(owned.id, payload, submittedNote);
- purgeCatalogue(Astro);
+ purgeDirectory(Astro);
await setFlash(Astro, env.sessionSecret, {
category: 'success',
title: `"${owned.id}" corrected.`,
@@ -107,7 +107,6 @@ if (
}
}
-const fields = submitted ?? base;
const title = base?.name || owned?.id || id;
---
@@ -184,7 +183,7 @@ const title = base?.name || owned?.id || id;
) : (
- fields && (
+ base && (
For live listing corruption — a truncated readme, a broken link —
@@ -192,7 +191,8 @@ const title = base?.name || owned?.id || id;
@@ -99,7 +99,7 @@ try {
{s === 'unpublished'
? 'Never Published'
: s.charAt(0).toUpperCase() + s.slice(1)}
- {catalogueCounts ? ` (${catalogueCounts[s]})` : ''}
+ {directoryCounts ? ` (${directoryCounts[s]})` : ''}
))}
@@ -147,7 +147,7 @@ try {
({
@@ -30,7 +30,7 @@ export const POST: APIRoute = formAction<{ notify: boolean }>({
undefined,
input.notify,
);
- purgeCatalogue(context);
+ purgeDirectory(context);
if (input.notify && !result.notified) {
await setFlash(context, env.sessionSecret, {
category: 'warning',
diff --git a/src/pages/account/admin/revisions/[id]/[revisionId]/reject.ts b/src/pages/account/admin/revisions/[id]/[revisionId]/reject.ts
index df2e6e50..53ce083d 100644
--- a/src/pages/account/admin/revisions/[id]/[revisionId]/reject.ts
+++ b/src/pages/account/admin/revisions/[id]/[revisionId]/reject.ts
@@ -3,7 +3,7 @@ import { requireModerator } from '@/lib/auth-guard';
import { createApiClient } from '@/lib/api/client';
import { formAction } from '@/lib/form-action';
import { formFlag, formString } from '@/lib/form';
-import { purgeCatalogue } from '@/lib/cache-invalidate';
+import { purgeDirectory } from '@/lib/cache-invalidate';
import { setFlash } from '@/lib/flash';
export const POST: APIRoute = formAction<{
@@ -28,7 +28,7 @@ export const POST: APIRoute = formAction<{
input.reviewNote,
input.notify,
);
- purgeCatalogue(context);
+ purgeDirectory(context);
if (input.notify && !result.notified) {
await setFlash(context, env.sessionSecret, {
category: 'warning',
diff --git a/src/pages/account/developer/reverify.ts b/src/pages/account/developer/reverify.ts
index 5f1a259f..c1f17e89 100644
--- a/src/pages/account/developer/reverify.ts
+++ b/src/pages/account/developer/reverify.ts
@@ -2,7 +2,7 @@ import type { APIRoute } from 'astro';
import { requireUser } from '@/lib/auth-guard';
import { getDeveloperByOwner } from '@/lib/extensions-data';
import { createApiClient, ApiRequestError } from '@/lib/api/client';
-import { purgeCatalogue } from '@/lib/cache-invalidate';
+import { purgeDirectory } from '@/lib/cache-invalidate';
import { setFlash } from '@/lib/flash';
import { buildGithubReconnectUrl } from '@/lib/oauth';
import {
@@ -37,7 +37,7 @@ export const POST: APIRoute = async (context) => {
let result;
try {
result = await api.reverifyDeveloper(true);
- purgeCatalogue(context);
+ purgeDirectory(context);
} catch (e) {
let description =
'Unable to refresh your GitHub verification right now. Please try again manually.';
diff --git a/src/pages/account/extensions/[id]/edit.astro b/src/pages/account/extensions/[id]/edit.astro
index 98a78e92..28826853 100644
--- a/src/pages/account/extensions/[id]/edit.astro
+++ b/src/pages/account/extensions/[id]/edit.astro
@@ -44,13 +44,16 @@ if (!owned) {
const base: Extension =
owned.published ??
({
+ manifest_version: 1,
+ author: { name: owned.developer.name, url: owned.developer.URL },
+ requires: { fossbilling: '', php: '' },
id: owned.id,
- type: 'mod',
+ type: 'module',
name: '',
description: '',
releases: [],
- website: '',
- license: { name: '' },
+ homepage_url: '',
+ license: '',
readme: '',
source: { type: 'github', repo: '' },
version: '',
@@ -61,7 +64,7 @@ const base: Extension =
let error: string | null = null;
// Falls back to the just-submitted values on a rejected edit, so the form
// doesn't reset to the previous content and discard the edit.
-let submitted: Extension | null = null;
+let submitted: ReturnType | null = null;
let submittedReleaseDraft: ReleaseDraft | null = null;
// Only one revision may be unreviewed at a time — the api rejects a second
@@ -90,7 +93,6 @@ if (!owned.pendingRevision && Astro.request.method === 'POST') {
}
}
-const fields = submitted ?? base;
const title = base.name || owned.id;
---
@@ -114,7 +116,8 @@ const title = base.name || owned.id;
diff --git a/src/pages/account/extensions/[id]/withdraw.ts b/src/pages/account/extensions/[id]/withdraw.ts
index d5841752..7f244a19 100644
--- a/src/pages/account/extensions/[id]/withdraw.ts
+++ b/src/pages/account/extensions/[id]/withdraw.ts
@@ -2,7 +2,7 @@ import type { APIRoute } from 'astro';
import { requireUser } from '@/lib/auth-guard';
import { createApiClient } from '@/lib/api/client';
import { formAction } from '@/lib/form-action';
-import { purgeCatalogue } from '@/lib/cache-invalidate';
+import { purgeDirectory } from '@/lib/cache-invalidate';
import { setFlash } from '@/lib/flash';
export const POST: APIRoute = formAction({
@@ -19,7 +19,7 @@ export const POST: APIRoute = formAction({
if (!id) return '/account';
await createApiClient(env, user.sub).withdrawExtension(id);
- purgeCatalogue(context);
+ purgeDirectory(context);
await setFlash(context, env.sessionSecret, {
title: 'Extension withdrawn.',
});
diff --git a/src/pages/api/extensions.ts b/src/pages/api/extensions.ts
index 09000eb2..bd4cab6a 100644
--- a/src/pages/api/extensions.ts
+++ b/src/pages/api/extensions.ts
@@ -1,11 +1,12 @@
import type { APIRoute } from 'astro';
import { apiErrorResponse, listExtensions } from '@/lib/api/client';
-import { parseCatalogueFilters } from '@/lib/catalogue-filters';
+import { parseDirectoryFilters } from '@/lib/directory-filters';
+import { extensionIconUrl } from '@/lib/extension-icon';
import { getSignedImageUrl } from '@/lib/signed-image-url';
export const GET: APIRoute = async ({ url, locals }) => {
const env = locals.env;
- const parsed = parseCatalogueFilters(url.searchParams);
+ const parsed = parseDirectoryFilters(url.searchParams);
if (parsed.error !== null) {
return Response.json(
{
@@ -21,13 +22,13 @@ export const GET: APIRoute = async ({ url, locals }) => {
try {
// Short browser TTL so repeated Load-more/filter requests reuse the same
// cursor page; the edge cache for the underlying read lives in the
- // client-layer catalogue wrapper.
+ // client-layer directory wrapper.
const page = await listExtensions(env, parsed.filters);
const result = await Promise.all(
page.result.map(async (item) => ({
...item,
optimized_icon_url: await getSignedImageUrl(
- item.icon_url,
+ extensionIconUrl(item),
'icon',
env.sessionSecret,
),
diff --git a/src/pages/api/extensions/cards.astro b/src/pages/api/extensions/cards.astro
index 560e5f58..4d803210 100644
--- a/src/pages/api/extensions/cards.astro
+++ b/src/pages/api/extensions/cards.astro
@@ -6,15 +6,15 @@ import {
listExtensions,
type ExtensionListResponse,
} from '@/lib/api/client';
-import { parseCatalogueFilters } from '@/lib/catalogue-filters';
+import { parseDirectoryFilters } from '@/lib/directory-filters';
-// Load-more fragment for the catalogue grids (see extension-catalogue.ts).
+// Load-more fragment for the directory grids (see extension-directory.ts).
// Renders the same ExtensionCard component as the server-rendered first
// page, so card markup and server-signed icon URLs have exactly one source
// of truth. The pagination envelope rides on the wrapper's data attributes;
// the client parses cards out of the markup and dedupes by
// [data-extension-id].
-const parsed = parseCatalogueFilters(Astro.url.searchParams);
+const parsed = parseDirectoryFilters(Astro.url.searchParams);
let page: ExtensionListResponse | null = null;
let error: string | null = null;
@@ -26,7 +26,7 @@ if (parsed.error !== null) {
page = await listExtensions(Astro.locals.env, parsed.filters);
// Matches /api/extensions: a short browser TTL so repeated load-more
// and filter requests reuse the same cursor page; the edge cache for
- // the underlying read lives in the client-layer catalogue wrapper.
+ // the underlying read lives in the client-layer directory wrapper.
Astro.response.headers.set('cache-control', 'public, max-age=30');
} catch (e) {
if (e instanceof ApiRequestError) {
@@ -50,10 +50,10 @@ if (error !== null) {
---
{error !== null ? (
-
+
) : page !== null ? (
diff --git a/src/pages/api/revalidate.ts b/src/pages/api/revalidate.ts
index 770c8b0b..cec90395 100644
--- a/src/pages/api/revalidate.ts
+++ b/src/pages/api/revalidate.ts
@@ -1,14 +1,14 @@
import type { APIRoute } from 'astro';
-import { CATALOGUE_CACHE_TAGS } from '@/lib/cache-invalidate';
+import { EXTENSIONS_CACHE_TAGS } from '@/lib/cache-tags';
import { markEdgeCachePurged } from '@/lib/cache';
-// Catalogue mutations that bypass this dashboard (the api worker, other
-// tooling) cannot trigger the in-request purgeCatalogue() hooks, so they call
-// this endpoint to purge the route-cached catalogue pages instead. Until it
+// Directory mutations that bypass this dashboard (the api worker, other
+// tooling) cannot trigger the in-request purgeDirectory() hooks, so they call
+// this endpoint to purge the route-cached directory pages instead. Until it
// is wired up, api-side changes surface within the route rule's
// maxAge+SWR window rather than instantly.
-const PURGEABLE_TAGS = new Set
(CATALOGUE_CACHE_TAGS);
+const PURGEABLE_TAGS = new Set(EXTENSIONS_CACHE_TAGS);
function isLocalRuntime(url: URL): boolean {
// WHATWG URL keeps IPv6 hosts bracketed ([::1]), so strip brackets before
diff --git a/src/pages/developer/[id].astro b/src/pages/developer/[id].astro
index fd8ccb1f..6c6c2160 100644
--- a/src/pages/developer/[id].astro
+++ b/src/pages/developer/[id].astro
@@ -1,6 +1,6 @@
---
import Base from '../../layouts/Base.astro';
-import CatalogueSection from '@/components/CatalogueSection.astro';
+import DirectorySection from '@/components/DirectorySection.astro';
import { getDeveloperById } from '@/lib/extensions-data';
import {
ApiRequestError,
@@ -9,7 +9,7 @@ import {
listExtensions,
type ExtensionListResponse,
} from '@/lib/api/client';
-import { hasNextPage } from '@/lib/catalogue-pagination';
+import { hasNextPage } from '@/lib/directory-pagination';
import { getSessionUser } from '@/lib/session';
import { requireUser } from '@/lib/auth-guard';
import { formString } from '@/lib/form';
@@ -186,7 +186,7 @@ const extensions = extensionsPage?.result ?? [];
Extensions by {developer.name}
) : (
<>
-
-
+
diff --git a/src/pages/extension/[id].astro b/src/pages/extension/[id].astro
index 1b2f2a59..df9bd54d 100644
--- a/src/pages/extension/[id].astro
+++ b/src/pages/extension/[id].astro
@@ -1,4 +1,5 @@
---
+import { extensionIconUrl } from '@/lib/extension-icon';
import Base from '@/layouts/Base.astro';
import ExtensionHeader from '@/components/ExtensionHeader.astro';
import DetailsCard from '@/components/DetailsCard.astro';
@@ -63,14 +64,7 @@ const shareDescription = ext
// Stored URLs arrive unvalidated from upstream, and Base builds the share
// URL with `new URL(image, Astro.site)` — which throws on malformed input
// and would 500 the whole page — so only pass cleanly-parseable URLs.
-let shareImage: string | undefined;
-if (ext?.icon_url) {
- try {
- shareImage = new URL(ext.icon_url).href;
- } catch {
- // Malformed stored URL: omit the social image rather than fail render.
- }
-}
+const shareImage = ext ? extensionIconUrl(ext) : undefined;
---
= 400 ? error.status : 502;
} else {
- catalogueError =
- 'Unable to load the extension catalogue. Please try again.';
+ directoryError =
+ 'Unable to load the extension directory. Please try again.';
Astro.response.status = 502;
}
// Opt out of the '/' route rule: cache headers are stamped after render,
@@ -45,7 +45,7 @@ try {
Astro.response.headers.set('Cache-Control', 'no-store');
}
-const extensions = cataloguePage?.result ?? [];
+const extensions = directoryPage?.result ?? [];
const activeFilterCount =
Number(Boolean(activeType)) + Number(Boolean(activeDeveloperId));
---
@@ -75,13 +75,13 @@ const activeFilterCount =
0}>
@@ -133,22 +133,22 @@ const activeFilterCount =
- {catalogueError ? (
+ {directoryError ? (
Unable to Load Extensions
-
{catalogueError}
+
{directoryError}
Try Again
) : (
<>
-
@@ -157,4 +157,4 @@ const activeFilterCount =
-
+
diff --git a/src/scripts/extension-catalogue.ts b/src/scripts/extension-directory.ts
similarity index 85%
rename from src/scripts/extension-catalogue.ts
rename to src/scripts/extension-directory.ts
index 34be81f0..c6877b86 100644
--- a/src/scripts/extension-catalogue.ts
+++ b/src/scripts/extension-directory.ts
@@ -1,4 +1,4 @@
-// Client-side behaviour for the catalogue's Load More control. Appended
+// Client-side behaviour for the directory's Load More control. Appended
// cards come from /api/extensions/cards, which renders the same
// ExtensionCard component as the server-rendered grid — card markup and
// server-signed icon URLs cannot drift between the first page and the rest.
@@ -6,22 +6,22 @@
// TypeScript checking like any other lib file.
import {
- createCataloguePagerFromIds,
- type CataloguePageRequest,
-} from '@/lib/catalogue-pagination';
+ createDirectoryPagerFromIds,
+ type DirectoryPageRequest,
+} from '@/lib/directory-pagination';
import type { ExtensionListResponse } from '@/lib/api/client';
const DEFAULT_PAGE_LIMIT = 50;
// A rendered card and its extension id. The id backs the pager's dedupe;
// the markup is appended as-is.
-type CatalogueCard = {
+type DirectoryCard = {
id: string;
html: string;
};
-type CatalogueCardPage = {
- result: CatalogueCard[];
+type DirectoryCardPage = {
+ result: DirectoryCard[];
pagination: ExtensionListResponse['pagination'];
};
@@ -34,8 +34,8 @@ function getErrorMessage(error: unknown): string {
async function loadPage(
apiUrl: string,
- request: CataloguePageRequest,
-): Promise {
+ request: DirectoryPageRequest,
+): Promise {
const params = new URLSearchParams();
params.set('limit', String(request.limit ?? DEFAULT_PAGE_LIMIT));
if (request.type !== undefined) {
@@ -58,16 +58,16 @@ async function loadPage(
if (!response.ok) {
const errorEl = fragment.content.querySelector(
- '[data-catalogue-error]',
+ '[data-directory-error]',
);
throw new Error(
- errorEl?.dataset.catalogueError ??
+ errorEl?.dataset.directoryError ??
`The extensions API returned ${response.status}.`,
);
}
const wrapper = fragment.content.querySelector(
- '[data-catalogue-page]',
+ '[data-directory-page]',
);
if (!wrapper) {
throw new Error('The extensions API returned an unexpected response.');
@@ -89,11 +89,11 @@ async function loadPage(
};
}
-function installCatalogue(root: HTMLElement): void {
+function installDirectory(root: HTMLElement): void {
const loadMore = root.querySelector('[data-load-more]');
- const status = root.querySelector('[data-catalogue-status]');
+ const status = root.querySelector('[data-directory-status]');
const grid = root.querySelector('[data-extension-grid]');
- const emptyState = root.querySelector('[data-empty-catalogue]');
+ const emptyState = root.querySelector('[data-empty-directory]');
if (!loadMore || !status || !grid) {
return;
@@ -104,7 +104,7 @@ function installCatalogue(root: HTMLElement): void {
)
.map((card) => card.dataset.extensionId ?? '')
.filter(Boolean);
- const pagination: CatalogueCardPage['pagination'] = {
+ const pagination: DirectoryCardPage['pagination'] = {
next_cursor: loadMore.dataset.nextCursor ?? null,
has_more: root.dataset.hasMore === 'true',
};
@@ -113,7 +113,7 @@ function installCatalogue(root: HTMLElement): void {
developer_id: root.dataset.developerId,
limit: Number(root.dataset.limit) || DEFAULT_PAGE_LIMIT,
};
- const pager = createCataloguePagerFromIds(
+ const pager = createDirectoryPagerFromIds(
initialIds,
pagination,
filters,
@@ -132,7 +132,7 @@ function installCatalogue(root: HTMLElement): void {
loadMore.textContent = state.isLoading
? 'Loading extensions…'
: state.error
- ? 'Restart catalogue'
+ ? 'Restart directory'
: 'Load more extensions';
if (!state.hasMore || state.nextCursor === null) {
@@ -177,10 +177,10 @@ function installCatalogue(root: HTMLElement): void {
}
if (typeof document !== 'undefined') {
- const catalogue = document.querySelector(
- '[data-extension-catalogue]',
+ const directory = document.querySelector(
+ '[data-extension-directory]',
);
- if (catalogue) {
- installCatalogue(catalogue);
+ if (directory) {
+ installDirectory(directory);
}
}
diff --git a/src/types/index.ts b/src/types/index.ts
index fc180aa8..819cb47d 100644
--- a/src/types/index.ts
+++ b/src/types/index.ts
@@ -2,19 +2,15 @@ import gt from 'semver/functions/gt.js';
import lt from 'semver/functions/lt.js';
import SPDX_LICENSE_IDS from 'spdx-license-ids/index.json';
-// Current (non-deprecated) SPDX license identifiers — same package and same
-// list the api repo validates `license.spdx_id` against, so a license this
-// form offers is never rejected by the api. Not itself the source of truth;
-// re-exported so the id list only has one import site in this repo.
+// SPDX identifiers offered as form suggestions; manifest licenses are strings.
export { SPDX_LICENSE_IDS };
export const EXTENSION_TYPES = [
- 'mod',
+ 'module',
'theme',
'payment-gateway',
'server-manager',
'domain-registrar',
- 'hook',
'translation',
] as const;
@@ -44,24 +40,21 @@ export function isDeveloperType(value: string): value is DeveloperType {
// Local view/domain models used by API-backed account pages and shared detail
// components. These intentionally do not depend on API transport DTOs.
+export type Requirements = {
+ fossbilling: string;
+ php: string;
+ modules?: Record;
+};
+export type PackageAuthor = { name: string; url?: string };
export type Release = {
tag: string;
date: string;
download_url: string;
changelog_url?: string;
- min_fossbilling_version: string;
-};
-
-export type Repository = {
- type: SourceType;
- repo: string;
-};
-
-export type License = {
- name: string;
- spdx_id?: string;
- URL?: string;
+ requires: Requirements;
};
+export type Repository = { type: SourceType; repo: string };
+export type License = string;
export type Developer = {
id: string;
@@ -73,12 +66,15 @@ export type Developer = {
};
export type Extension = {
+ manifest_version: 1;
+ author: PackageAuthor;
+ requires: Requirements;
id: string;
type: ExtensionType;
name: string;
description: string;
releases: Release[];
- website: string;
+ homepage_url?: string;
license: License;
icon_url?: string;
readme: string;
diff --git a/test/catalogue-images.test.ts b/test/directory-images.test.ts
similarity index 80%
rename from test/catalogue-images.test.ts
rename to test/directory-images.test.ts
index 6a45271c..867df745 100644
--- a/test/catalogue-images.test.ts
+++ b/test/directory-images.test.ts
@@ -12,9 +12,9 @@ vi.mock('@/lib/api/client', async (importOriginal) => ({
listExtensions: vi.fn(),
}));
-// Shape guard for the JSON catalogue response: every card carries only the
+// Shape guard for the JSON directory response: every card carries only the
// fields the response contract defines, plus the signed icon URL.
-type CatalogueCardItem = Pick<
+type DirectoryCardItem = Pick<
ExtensionListItem,
'id' | 'name' | 'description' | 'version' | 'icon_url'
> & { optimized_icon_url?: string };
@@ -23,7 +23,7 @@ function isRecord(value: unknown): value is Record {
return typeof value === 'object' && value !== null;
}
-function isCatalogueJsonItem(value: unknown): value is CatalogueCardItem {
+function isDirectoryJsonItem(value: unknown): value is DirectoryCardItem {
if (!isRecord(value)) return false;
return (
@@ -37,8 +37,8 @@ function isCatalogueJsonItem(value: unknown): value is CatalogueCardItem {
);
}
-function isCatalogueJsonPage(value: unknown): value is {
- result: CatalogueCardItem[];
+function isDirectoryJsonPage(value: unknown): value is {
+ result: DirectoryCardItem[];
pagination: ExtensionListResponse['pagination'];
} {
if (!isRecord(value) || !isRecord(value.pagination)) {
@@ -47,7 +47,7 @@ function isCatalogueJsonPage(value: unknown): value is {
return (
Array.isArray(value.result) &&
- value.result.every(isCatalogueJsonItem) &&
+ value.result.every(isDirectoryJsonItem) &&
((typeof value.pagination.next_cursor === 'string' &&
value.pagination.next_cursor.length > 0) ||
value.pagination.next_cursor === null) &&
@@ -55,14 +55,14 @@ function isCatalogueJsonPage(value: unknown): value is {
);
}
-describe('catalogue image issuance', () => {
- it('issues only returned catalogue images and retains pagination/raw fields', async () => {
+describe('directory image issuance', () => {
+ it('issues only returned directory images and retains pagination/raw fields', async () => {
const item = {
id: 'ext',
name: 'Extension',
description: 'Description',
version: '1.0',
- icon_url: 'https://github.com/catalogue/logo.png',
+ icon_url: 'https://github.com/directory/logo.png',
};
const pagination = { next_cursor: 'opaque', has_more: true };
vi.mocked(listExtensions).mockResolvedValue({
@@ -73,11 +73,11 @@ describe('catalogue image issuance', () => {
url: new URL(
'https://extensions.example/api/extensions?src=https://github.com/attacker/logo.png',
),
- locals: { env: { sessionSecret: 'catalogue-test-secret' } },
+ locals: { env: { sessionSecret: 'directory-test-secret' } },
} as Parameters[0]);
const body = await response.json();
- if (!isCatalogueJsonPage(body))
- throw new Error('Invalid catalogue response');
+ if (!isDirectoryJsonPage(body))
+ throw new Error('Invalid directory response');
expect(response.status).toBe(200);
expect(body.pagination).toEqual(pagination);
expect(body.result[0]).toMatchObject(item);
@@ -91,7 +91,7 @@ describe('catalogue image issuance', () => {
new URL(item.icon_url),
'icon',
image.searchParams.get('sig'),
- 'catalogue-test-secret',
+ 'directory-test-secret',
),
).toBe(true);
expect(
@@ -99,7 +99,7 @@ describe('catalogue image issuance', () => {
new URL('https://github.com/attacker/logo.png'),
'icon',
image.searchParams.get('sig'),
- 'catalogue-test-secret',
+ 'directory-test-secret',
),
).toBe(false);
});
diff --git a/test/catalogue-pagination.test.ts b/test/directory-pagination.test.ts
similarity index 88%
rename from test/catalogue-pagination.test.ts
rename to test/directory-pagination.test.ts
index b959866a..2f788bdf 100644
--- a/test/catalogue-pagination.test.ts
+++ b/test/directory-pagination.test.ts
@@ -2,16 +2,16 @@ import { describe, expect, it, vi } from 'vitest';
import { ApiRequestError, type ExtensionListResponse } from '@/lib/api/client';
import {
appendPage,
- createCataloguePager,
- createCataloguePagerFromIds,
+ createDirectoryPager,
+ createDirectoryPagerFromIds,
stateFromPage,
- type CataloguePageRequest,
-} from '@/lib/catalogue-pagination';
-import { item, page } from './helpers/catalogue-fixtures';
+ type DirectoryPageRequest,
+} from '@/lib/directory-pagination';
+import { item, page } from './helpers/directory-fixtures';
-describe('catalogue page accumulation', () => {
+describe('directory page accumulation', () => {
const filters = {
- type: 'mod' as const,
+ type: 'module' as const,
developer_id: 'developer-id',
limit: 100,
};
@@ -28,14 +28,14 @@ describe('catalogue page accumulation', () => {
true,
);
const loadPage = vi.fn().mockResolvedValue(second);
- const pager = createCataloguePager(first, filters, loadPage);
+ const pager = createDirectoryPager(first, filters, loadPage);
const state = await pager.loadNextPage();
expect(loadPage).toHaveBeenCalledWith({
...filters,
cursor: 'cursor-2',
- } satisfies CataloguePageRequest);
+ } satisfies DirectoryPageRequest);
expect(state.items.map((extension) => extension.id)).toEqual([
'zeta',
'alpha',
@@ -49,7 +49,7 @@ describe('catalogue page accumulation', () => {
const loadPage = vi
.fn()
.mockResolvedValue(page([item('ALPHA'), item('second')], null, false));
- const pager = createCataloguePagerFromIds(
+ const pager = createDirectoryPagerFromIds(
['alpha'],
{ next_cursor: 'cursor-2', has_more: true },
filters,
@@ -62,7 +62,7 @@ describe('catalogue page accumulation', () => {
});
it('does not duplicate concurrent next-page requests', async () => {
- // Seeded like the real caller (createCataloguePagerFromIds): the server
+ // Seeded like the real caller (createDirectoryPagerFromIds): the server
// renders page one (its ids seed the dedupe set), the client accumulates
// the rest.
let resolvePage: ((value: ExtensionListResponse) => void) | undefined;
@@ -72,7 +72,7 @@ describe('catalogue page accumulation', () => {
resolvePage = resolve;
}),
);
- const pager = createCataloguePagerFromIds(
+ const pager = createDirectoryPagerFromIds(
['first'],
{ next_cursor: 'cursor-2', has_more: true },
filters,
@@ -96,7 +96,7 @@ describe('catalogue page accumulation', () => {
const loadPage = vi
.fn()
.mockResolvedValueOnce(page([item('last')], null, false));
- const pager = createCataloguePager(
+ const pager = createDirectoryPager(
page([item('first')], 'cursor-final', true),
filters,
loadPage,
@@ -136,7 +136,7 @@ describe('catalogue page accumulation', () => {
.fn()
.mockResolvedValueOnce(page([item('second')], 'invalid-cursor', true))
.mockRejectedValueOnce(invalidCursor);
- const pager = createCataloguePagerFromIds(
+ const pager = createDirectoryPagerFromIds(
['first'],
{ next_cursor: 'cursor-2', has_more: true },
filters,
@@ -164,7 +164,7 @@ describe('catalogue page accumulation', () => {
],
pagination: { next_cursor: null, has_more: false },
});
- const pager = createCataloguePagerFromIds(
+ const pager = createDirectoryPagerFromIds(
[],
{ next_cursor: 'cursor-2', has_more: true },
filters,
diff --git a/test/extension-catalogue.test.ts b/test/extension-directory.test.ts
similarity index 70%
rename from test/extension-catalogue.test.ts
rename to test/extension-directory.test.ts
index 9088beb6..de378200 100644
--- a/test/extension-catalogue.test.ts
+++ b/test/extension-directory.test.ts
@@ -1,10 +1,10 @@
import { describe, expect, it } from 'vitest';
import { isDeveloperType, isExtensionType, isSourceType } from '@/types';
-import { parseCatalogueFilters } from '@/lib/catalogue-filters';
+import { parseDirectoryFilters } from '@/lib/directory-filters';
describe('application boundary validation', () => {
it('validates extension, source, and developer type guards', () => {
- expect(isExtensionType('mod')).toBe(true);
+ expect(isExtensionType('module')).toBe(true);
expect(isExtensionType('not-a-type')).toBe(false);
expect(isSourceType('github')).toBe(true);
expect(isSourceType('not-a-source')).toBe(false);
@@ -13,14 +13,14 @@ describe('application boundary validation', () => {
});
});
-describe('catalogue filter parsing', () => {
+describe('directory filter parsing', () => {
it('parses every supported filter and ignores unknown params', () => {
const params = new URLSearchParams(
- 'type=mod&developer_id=dev-1&limit=24&cursor=opaque&q=ignored',
+ 'type=module&developer_id=dev-1&limit=24&cursor=opaque&q=ignored',
);
- expect(parseCatalogueFilters(params)).toEqual({
+ expect(parseDirectoryFilters(params)).toEqual({
filters: {
- type: 'mod',
+ type: 'module',
developer_id: 'dev-1',
limit: 24,
cursor: 'opaque',
@@ -30,11 +30,11 @@ describe('catalogue filter parsing', () => {
});
it('treats an empty type as absent and a non-numeric limit as unset', () => {
- expect(parseCatalogueFilters(new URLSearchParams('type='))).toEqual({
+ expect(parseDirectoryFilters(new URLSearchParams('type='))).toEqual({
filters: {},
error: null,
});
- expect(parseCatalogueFilters(new URLSearchParams('limit=abc'))).toEqual({
+ expect(parseDirectoryFilters(new URLSearchParams('limit=abc'))).toEqual({
filters: {},
error: null,
});
@@ -42,7 +42,7 @@ describe('catalogue filter parsing', () => {
it('rejects an unrecognized extension type', () => {
expect(
- parseCatalogueFilters(new URLSearchParams('type=not-a-type')),
+ parseDirectoryFilters(new URLSearchParams('type=not-a-type')),
).toEqual({
filters: null,
error: 'The extension type filter is invalid.',
diff --git a/test/extension-form.test.ts b/test/extension-form.test.ts
index 691a28f9..632d2df1 100644
--- a/test/extension-form.test.ts
+++ b/test/extension-form.test.ts
@@ -9,343 +9,256 @@ import {
} from '@/lib/extension-form';
import type { Extension } from '@/types';
-function extensionForm(overrides: Record = {}): FormData {
+function extensionForm(overrides: Record = {}) {
const form = new FormData();
- form.set('extension_id', 'example');
- form.set('type', 'mod');
- form.set('name', 'Example');
- form.set('description', 'An example extension.');
- form.set('website', 'example.test');
- form.set('license_spdx_id', 'MIT');
- form.set('license_url', 'https://example.test/license');
- form.set('readme', '# Example');
- form.set('source_type', 'github');
- form.set('source_repo', 'fossbilling/example');
- form.set('version_tag', '1.0.0');
- form.set('release_date', '2026-01-01');
- form.set('download_url', 'https://example.test/example.zip');
- form.set('min_fossbilling_version', '0.6.0');
- for (const [key, value] of Object.entries(overrides)) {
- form.set(key, value);
- }
+ const values = {
+ extension_id: 'example_module',
+ type: 'module',
+ name: 'Example',
+ description: 'Description',
+ homepage_url: 'example.test',
+ author_name: 'Package Author',
+ author_url: 'author.example.test',
+ requires_fossbilling: '^0.8.9 || ^1.0',
+ requires_php: '>=8.3 <9',
+ requires_modules: 'branding: ^1.2',
+ license_spdx_id: 'MIT',
+ readme: '# Example',
+ source_type: 'github',
+ source_repo: 'fossbilling/example',
+ version_tag: '1.0.0',
+ release_date: '2026-01-01',
+ download_url: 'example.test/example.zip',
+ icon_url: 'assets/icon.svg',
+ ...overrides,
+ };
+ for (const [key, value] of Object.entries(values))
+ if (typeof value === 'string') form.set(key, value);
return form;
}
-
-const publishedExtension: Extension = {
- id: 'example',
- type: 'mod',
+const developer = {
+ id: 'owner',
+ type: 'organization' as const,
+ name: 'Developer',
+};
+const published: Extension = {
+ manifest_version: 1,
+ type: 'module',
name: 'Example',
- description: 'An example extension.',
+ description: 'Description',
+ author: { name: 'Package Author', url: 'https://author.example.test' },
+ requires: {
+ fossbilling: '^0.8.9 || ^1.0',
+ php: '>=8.3 <9',
+ modules: { branding: '^1.2' },
+ },
+ homepage_url: 'https://example.test',
+ license: 'MIT',
+ readme: '# Example',
+ source: { type: 'github', repo: 'fossbilling/example' },
+ version: '1.0.0',
+ download_url: 'https://example.test/example.zip',
releases: [
{
- tag: '0.9.0',
- date: '2025-12-01',
- download_url: 'https://example.test/example-0.9.0.zip',
- min_fossbilling_version: '0.5.0',
+ tag: '1.0.0',
+ date: '2026-01-01',
+ download_url: 'https://example.test/example.zip',
+ requires: {
+ fossbilling: '^0.8.9 || ^1.0',
+ php: '>=8.3 <9',
+ modules: { branding: '^1.2' },
+ },
},
],
- website: 'https://example.test',
- license: { name: 'MIT', spdx_id: 'MIT' },
- readme: '# Example',
- source: { type: 'github', repo: 'fossbilling/example' },
- version: '0.9.0',
- download_url: 'https://example.test/example-0.9.0.zip',
- developer: {
- id: 'developer',
- type: 'organization',
- name: 'Example developer',
- },
+ id: 'example_module',
+ developer,
};
-describe('buildExtensionCreatePayload', () => {
- it('builds a POST /extensions payload with no developer field', () => {
- const payload = buildExtensionCreatePayload(extensionForm());
-
- expect(payload).not.toHaveProperty('developer');
- expect(payload.id).toBe('example');
- expect(payload.name).toBe('Example');
- expect(payload.releases).toEqual([
- {
- tag: '1.0.0',
- date: '2026-01-01',
- download_url: 'https://example.test/example.zip',
- changelog_url: undefined,
- min_fossbilling_version: '0.6.0',
+describe('manifest publishing forms', () => {
+ it('sends the new manifest fields without transforming constraints or attribution', () => {
+ const body = buildExtensionCreatePayload(extensionForm());
+ expect(body).toMatchObject({
+ id: 'example_module',
+ manifest_version: 1,
+ type: 'module',
+ license: 'MIT',
+ homepage_url: 'https://example.test',
+ icon_url: 'assets/icon.svg',
+ author: { name: 'Package Author', url: 'https://author.example.test' },
+ requires: {
+ fossbilling: '^0.8.9 || ^1.0',
+ php: '>=8.3 <9',
+ modules: { branding: '^1.2' },
},
- ]);
- });
-
- it('lowercases the extension id', () => {
- const payload = buildExtensionCreatePayload(
- extensionForm({ extension_id: 'Example-ID' }),
- );
-
- expect(payload.id).toBe('example-id');
- });
-
- it('requires an initial release', () => {
- const form = extensionForm({ version_tag: '' });
- form.delete('release_date');
- form.delete('download_url');
- form.delete('min_fossbilling_version');
-
- expect(() => buildExtensionCreatePayload(form)).toThrow(
- ExtensionValidationError,
- );
- });
-
- it('sets both name and spdx_id for a recognized license', () => {
- const payload = buildExtensionCreatePayload(
- extensionForm({ license_spdx_id: 'Apache-2.0' }),
- );
-
- expect(payload.license).toEqual({
- name: 'Apache-2.0',
- spdx_id: 'Apache-2.0',
- URL: 'https://example.test/license',
});
+ expect(body.releases[0].requires).toEqual(body.requires);
+ expect(body).not.toHaveProperty('developer');
+ expect(body).not.toHaveProperty('website');
+ expect(body.releases[0]).not.toHaveProperty('min_fossbilling_version');
});
-
- it('rejects a license_spdx_id that is not a real SPDX identifier', () => {
- const form = extensionForm({ license_spdx_id: 'not-a-real-license' });
-
- expect(() => buildExtensionCreatePayload(form)).toThrow(
- ExtensionValidationError,
+ it('lowercases new ids and accepts an omitted homepage', () => {
+ const body = buildExtensionCreatePayload(
+ extensionForm({ extension_id: 'My_Module', homepage_url: '' }),
);
+ expect(body.id).toBe('my_module');
+ expect(body.homepage_url).toBeUndefined();
});
-
- it('uses the custom name with no spdx_id for Other / Proprietary', () => {
- const payload = buildExtensionCreatePayload(
+ it('carries published releases unchanged when editing metadata', () => {
+ const body = buildExtensionUpdatePayload(
extensionForm({
- license_spdx_id: 'other',
- license_name_custom: 'Acme Proprietary License',
+ version_tag: '',
+ release_date: '',
+ download_url: '',
+ requires_php: '>=8.4',
}),
+ published,
);
-
- expect(payload.license).toEqual({
- name: 'Acme Proprietary License',
- URL: 'https://example.test/license',
- });
- });
-
- it('requires a custom name when Other / Proprietary is selected', () => {
- const form = extensionForm({ license_spdx_id: 'other' });
-
- expect(() => buildExtensionCreatePayload(form)).toThrow(
- ExtensionValidationError,
- );
- });
-});
-
-describe('buildExtensionUpdatePayload', () => {
- it('carries existing releases through unchanged when no new release is added', () => {
- const form = extensionForm();
- form.delete('version_tag');
- form.delete('release_date');
- form.delete('download_url');
- form.delete('min_fossbilling_version');
-
- const payload = buildExtensionUpdatePayload(form, publishedExtension);
-
- expect(payload).not.toHaveProperty('developer');
- expect(payload).not.toHaveProperty('id');
- expect(payload.releases).toEqual(publishedExtension.releases);
- expect(payload.version).toBe('0.9.0');
- });
-
- it('appends a new release and updates version/download_url when provided', () => {
- const payload = buildExtensionUpdatePayload(
- extensionForm(),
- publishedExtension,
- );
-
- expect(payload.releases).toHaveLength(2);
- expect(payload.version).toBe('1.0.0');
- expect(payload.download_url).toBe('https://example.test/example.zip');
+ expect(body).not.toHaveProperty('id');
+ expect(body.releases).toEqual(published.releases);
+ expect(body.version).toBe(published.version);
+ expect(body.requires.php).toBe('>=8.4');
+ expect(body.releases[0].requires.php).toBe('>=8.3 <9');
});
-
- it('requires an initial release when nothing has ever been published', () => {
- const form = extensionForm({ version_tag: '' });
- form.delete('release_date');
- form.delete('download_url');
- form.delete('min_fossbilling_version');
-
- expect(() => buildExtensionUpdatePayload(form, null)).toThrow(
- ExtensionValidationError,
+ it('appends a release with its own requirements while preserving history', () => {
+ const body = buildExtensionUpdatePayload(
+ extensionForm({ version_tag: '1.1.0', requires_php: '>=8.4' }),
+ published,
);
+ expect(body.releases).toHaveLength(2);
+ expect(body.releases[0]).toEqual(published.releases[0]);
+ expect(body.releases[1].requires.php).toBe('>=8.4');
+ expect(body.version).toBe('1.1.0');
});
-
- it('rejects a version_tag that duplicates an existing release instead of appending a second copy', () => {
- const form = extensionForm({ version_tag: '0.9.0' });
-
- expect(() => buildExtensionUpdatePayload(form, publishedExtension)).toThrow(
- ExtensionValidationError,
- );
+ it('rejects duplicate tags and overflowing release history', () => {
+ expect(() =>
+ buildExtensionUpdatePayload(extensionForm(), published),
+ ).toThrow(/already exists/);
+ expect(() =>
+ buildExtensionUpdatePayload(extensionForm({ version_tag: '2.0.0' }), {
+ ...published,
+ releases: Array.from({ length: 100 }, () => published.releases[0]),
+ }),
+ ).toThrow(/100 releases/);
});
-
- it('rejects a new release once the extension already has 100', () => {
- const atLimit: Extension = {
- ...publishedExtension,
- releases: Array.from({ length: 100 }, (_, i) => ({
- tag: `0.${i}.0`,
- date: '2025-01-01',
- download_url: `https://example.test/example-0.${i}.0.zip`,
- min_fossbilling_version: '0.5.0',
- })),
- };
-
- expect(() => buildExtensionUpdatePayload(extensionForm(), atLimit)).toThrow(
- ExtensionValidationError,
- );
+ it('requires an initial release for creation and unpublished resubmission', () => {
+ expect(() =>
+ buildExtensionCreatePayload(extensionForm({ version_tag: '' })),
+ ).toThrow(ExtensionValidationError);
+ expect(() =>
+ buildExtensionUpdatePayload(extensionForm({ version_tag: '' }), null),
+ ).toThrow(ExtensionValidationError);
+ expect(() =>
+ buildExtensionCreatePayload(extensionForm({ release_date: '' })),
+ ).toThrow(ExtensionValidationError);
});
-});
-
-describe('echoExtensionFromForm', () => {
- // The submitted echo is a best-effort redisplay spread over the
- // extension's current content — never the validated payload — so an
- // incomplete license choice must redisplay as-is instead of throwing.
- it('echoes submitted fields over the base and keeps base-only fields', () => {
- const form = extensionForm({ name: 'Renamed', icon_url: '' });
-
- const echo = echoExtensionFromForm(form, publishedExtension);
-
- expect(echo).toMatchObject({
- id: 'example',
- name: 'Renamed',
- description: 'An example extension.',
- // Base-only content survives: the echo never touches releases.
- releases: publishedExtension.releases,
- version: '0.9.0',
- license: { name: 'MIT', spdx_id: 'MIT' },
- // An empty icon input echoes as absent, not as an empty string.
- icon_url: undefined,
- });
+ it('supports compound SPDX expressions and custom license references', () => {
+ for (const license of ['MIT OR Apache-2.0', 'LicenseRef-Acme'])
+ expect(
+ buildExtensionCreatePayload(
+ extensionForm({
+ license_spdx_id: 'other',
+ license_name_custom: license,
+ }),
+ ).license,
+ ).toBe(license);
+ expect(() =>
+ buildExtensionCreatePayload(
+ extensionForm({ license_spdx_id: 'not-real' }),
+ ),
+ ).toThrow(ExtensionValidationError);
+ expect(() =>
+ buildExtensionCreatePayload(
+ extensionForm({
+ license_spdx_id: 'other',
+ license_name_custom: 'invalid/license',
+ }),
+ ),
+ ).toThrow(ExtensionValidationError);
});
-
- it('echoes a recognized SPDX license as name and spdx_id', () => {
- const echo = echoExtensionFromForm(extensionForm(), publishedExtension);
-
- expect(echo.license).toEqual({
- name: 'MIT',
- spdx_id: 'MIT',
- URL: 'https://example.test/license',
- });
+ it.each([
+ '../icon.svg',
+ 'x\n../icon.svg',
+ 'a\n/../../icon.svg',
+ 'x\r../icon.svg',
+ 'x\u2028../icon.svg',
+ 'x\u2029../icon.svg',
+ 'assets/\u0000icon.svg',
+ '/icon.svg',
+ 'https://example.com/icon.svg',
+ 'a\\icon.svg',
+ ])('rejects unsafe package icon %s', (icon_url) => {
+ expect(() =>
+ buildExtensionCreatePayload(extensionForm({ icon_url })),
+ ).toThrow(ExtensionValidationError);
});
-
- it('echoes the custom-license branch without validating it', () => {
- const echo = echoExtensionFromForm(
- extensionForm({ license_spdx_id: 'other', license_name_custom: 'Mine' }),
- publishedExtension,
- );
-
- expect(echo.license).toEqual({
- name: 'Mine',
- URL: 'https://example.test/license',
- });
- expect(echo.license).not.toHaveProperty('spdx_id');
+ it('validates required metadata and dependency syntax without losing ranges', () => {
+ for (const overrides of [
+ { author_name: '' },
+ { requires_php: '' },
+ { requires_fossbilling: '' },
+ { type: 'mod' },
+ { source_type: 'ftp' },
+ { requires_modules: 'bad/name: ^1' },
+ { requires_modules: 'branding: ^1\nbranding: ^2' },
+ ] satisfies Record[])
+ expect(() =>
+ buildExtensionCreatePayload(extensionForm(overrides)),
+ ).toThrow(ExtensionValidationError);
});
-
- it('never throws on an incomplete license choice', () => {
- // Unlike buildLicense, the echo is a best-effort redisplay: a blank
- // custom name for "other", or an unrecognized selection, must echo
- // as-is rather than reject the redisplay.
- const blankCustom = echoExtensionFromForm(
- extensionForm({ license_spdx_id: 'other', license_name_custom: '' }),
- publishedExtension,
- );
- expect(blankCustom.license).toEqual({
- name: '',
- URL: 'https://example.test/license',
+ it('preserves submitted fields and invalid dependency input on error', () => {
+ const form = extensionForm({
+ name: 'Changed',
+ requires_modules: 'unfinished dependency',
+ license_spdx_id: 'other',
+ license_name_custom: 'MIT OR BSD-3-Clause',
});
-
- const unrecognized = echoExtensionFromForm(
- extensionForm({ license_spdx_id: 'not-a-license' }),
- publishedExtension,
+ const echo = echoExtensionFromForm(form, published);
+ expect(echo.name).toBe('Changed');
+ expect(echo.author.name).toBe('Package Author');
+ expect(echo.moduleRequirementsInput).toBe('unfinished dependency');
+ expect(echo.license).toBe('MIT OR BSD-3-Clause');
+ expect(echoReleaseDraftFromForm(form).version_tag).toBe('1.0.0');
+ expect(echoNewExtensionFromForm(form, developer).extension.id).toBe(
+ 'example_module',
);
- expect(unrecognized.license).toEqual({
- name: '',
- URL: 'https://example.test/license',
- });
});
});
-describe('echoReleaseDraftFromForm', () => {
- it('carries the release-section inputs exactly as typed', () => {
- const form = extensionForm({
- version_tag: '1.1.0',
- release_date: '2026-02-01',
- // No scheme normalization on redisplay: echo what the user typed.
- download_url: 'example.test/1.1.0.zip',
- changelog_url: '',
- min_fossbilling_version: '0.6.0',
- });
-
- expect(echoReleaseDraftFromForm(form)).toEqual({
- version_tag: '1.1.0',
- release_date: '2026-02-01',
- download_url: 'example.test/1.1.0.zip',
- changelog_url: '',
- min_fossbilling_version: '0.6.0',
- });
- });
-
- it('returns blank fields when the form omits the release section', () => {
- expect(echoReleaseDraftFromForm(new FormData())).toEqual({
- version_tag: '',
- release_date: '',
- download_url: '',
- changelog_url: '',
- min_fossbilling_version: '',
- });
+it('rejects a blank custom license but safely echoes incomplete edits', () => {
+ const form = extensionForm({
+ license_spdx_id: 'other',
+ license_name_custom: '',
+ version_tag: '',
+ author_url: '',
});
+ expect(() =>
+ buildExtensionCreatePayload(
+ extensionForm({ license_spdx_id: 'other', license_name_custom: '' }),
+ ),
+ ).toThrow(/license/i);
+ expect(() => buildExtensionUpdatePayload(form, published)).toThrow(
+ /license/i,
+ );
+ const echo = echoExtensionFromForm(form, published);
+ expect(echo.license).toBe('');
+ expect(echo.author.url).toBeUndefined();
});
-describe('echoNewExtensionFromForm', () => {
- const developer = {
- id: 'developer',
- type: 'organization' as const,
- name: 'Example developer',
- };
-
- it('builds a blank base with the lowercased form id and echoes the submission', () => {
- const form = extensionForm({
- extension_id: 'Mixed-Case',
- name: 'New name',
- version_tag: '1.0.0',
- });
-
- const { extension, releaseDraft } = echoNewExtensionFromForm(
- form,
- developer,
- );
-
- expect(extension).toMatchObject({
- // Lowercased to match what a successful submit would store.
- id: 'mixed-case',
- name: 'New name',
- description: 'An example extension.',
- developer,
- releases: [],
- version: '',
- });
- expect(releaseDraft.version_tag).toBe('1.0.0');
+it('safely echoes blank new-extension and release submissions', () => {
+ const form = new FormData();
+ expect(echoReleaseDraftFromForm(form)).toEqual({
+ version_tag: '',
+ release_date: '',
+ download_url: '',
+ changelog_url: '',
});
-
- it('echoes a blank form without throwing', () => {
- const { extension, releaseDraft } = echoNewExtensionFromForm(
- new FormData(),
- developer,
- );
-
- expect(extension.id).toBe('');
- expect(extension.name).toBe('');
- expect(extension.releases).toEqual([]);
- expect(releaseDraft).toEqual({
- version_tag: '',
- release_date: '',
- download_url: '',
- changelog_url: '',
- min_fossbilling_version: '',
- });
+ const echo = echoNewExtensionFromForm(form, developer);
+ expect(echo.extension).toMatchObject({
+ id: '',
+ name: '',
+ license: '',
+ moduleRequirementsInput: '',
+ author: { name: '' },
});
+ expect(echo.releaseDraft).toEqual(echoReleaseDraftFromForm(form));
});
diff --git a/test/extension-icon.test.ts b/test/extension-icon.test.ts
new file mode 100644
index 00000000..3d5ed9bb
--- /dev/null
+++ b/test/extension-icon.test.ts
@@ -0,0 +1,65 @@
+import { describe, expect, it } from 'vitest';
+import { extensionIconUrl } from '@/lib/extension-icon';
+const extension = {
+ id: 'branding',
+ icon_url: 'assets/icon.svg',
+ download_url:
+ 'https://github.com/FOSSBilling/modules/releases/download/branding-v0.8.9/branding.zip',
+ source: { type: 'github', repo: 'FOSSBilling/modules' },
+};
+describe('package icons', () => {
+ it('resolves first-party package paths against the published release tag', () => {
+ expect(extensionIconUrl(extension)).toBe(
+ 'https://raw.githubusercontent.com/FOSSBilling/modules/branding-v0.8.9/Branding/assets/icon.svg',
+ );
+ });
+ it('resolves single-repository package paths at the repository root', () => {
+ expect(
+ extensionIconUrl({
+ ...extension,
+ source: { type: 'github', repo: 'owner/module' },
+ download_url:
+ 'https://github.com/owner/module/releases/download/v1.0.0/module.zip',
+ }),
+ ).toBe(
+ 'https://raw.githubusercontent.com/owner/module/v1.0.0/assets/icon.svg',
+ );
+ });
+ it('retains legacy absolute HTTP(S) icons', () => {
+ expect(
+ extensionIconUrl({
+ ...extension,
+ icon_url: 'https://example.test/icon.svg',
+ }),
+ ).toBe('https://example.test/icon.svg');
+ });
+ it.each([
+ '../icon.svg',
+ 'x\n../icon.svg',
+ 'a\n/../../icon.svg',
+ 'x\r../icon.svg',
+ 'x\u2028../icon.svg',
+ 'x\u2029../icon.svg',
+ 'assets/\u0000icon.svg',
+ '/icon.svg',
+ 'javascript:alert(1)',
+ 'a\\icon.svg',
+ 'https://user:password@example.com/icon.svg',
+ ])('rejects unsafe icon %s', (icon_url) => {
+ expect(extensionIconUrl({ ...extension, icon_url })).toBeUndefined();
+ });
+ it('rejects mismatched asset sources, unsupported hosts, and refs containing paths', () => {
+ for (const download_url of [
+ 'https://github.com/other/repo/releases/download/v1.0.0/a.zip',
+ 'https://example.com/icon.zip',
+ 'https://github.com/FOSSBilling/modules/releases/download/a%2Fb/a.zip',
+ ])
+ expect(extensionIconUrl({ ...extension, download_url })).toBeUndefined();
+ expect(
+ extensionIconUrl({
+ ...extension,
+ source: { type: 'custom', repo: 'https://example.com' },
+ }),
+ ).toBeUndefined();
+ });
+});
diff --git a/test/extensions-api.test.ts b/test/extensions-api.test.ts
index e5ae35ac..a18bdf35 100644
--- a/test/extensions-api.test.ts
+++ b/test/extensions-api.test.ts
@@ -35,7 +35,7 @@ import {
} from '@/lib/assertion';
import { sha256Hex } from '@/lib/hash';
import { makeEnv } from './helpers/env';
-import { item, page } from './helpers/catalogue-fixtures';
+import { item, page } from './helpers/directory-fixtures';
import type {
DeveloperHistoryEntry,
DeveloperProfile,
@@ -271,7 +271,8 @@ describe('generated Extensions v2 façade', () => {
it('returns the complete detail DTO by ID', async () => {
const detail: Extension = {
...item('full-extension'),
- website: 'https://example.test/full-extension',
+ requires: { fossbilling: '^0.8.9', php: '>=8.3' },
+ homepage_url: 'https://example.test/full-extension',
download_url: 'https://example.test/full-extension.zip',
readme: '# Full extension\n\nREADME content',
releases: [
@@ -279,14 +280,14 @@ describe('generated Extensions v2 façade', () => {
tag: '1.0.0',
date: '2026-01-01T00:00:00Z',
download_url: 'https://example.test/full-extension-1.0.0.zip',
- min_fossbilling_version: '0.6.0',
+ requires: { fossbilling: '>=0.6.0', php: '*' },
},
{
tag: '0.9.0',
date: '2025-12-01T00:00:00Z',
download_url: 'https://example.test/full-extension-0.9.0.zip',
changelog_url: 'https://example.test/changelog/0.9.0',
- min_fossbilling_version: '0.5.0',
+ requires: { fossbilling: '>=0.5.0', php: '*' },
},
],
};
@@ -302,6 +303,11 @@ describe('generated Extensions v2 façade', () => {
);
expect(response.readme).toContain('README content');
expect(response.releases).toHaveLength(2);
+ expect(response.requires).toEqual(detail.requires);
+ expect(response.homepage_url).toBe(detail.homepage_url);
+ expect(response.releases.map((release) => release.requires)).toEqual(
+ detail.releases.map((release) => release.requires),
+ );
expect(response.source.repo).toBe('fossbilling/full-extension');
expect(response.version).toBe('1.0.0');
expect(response.download_url).toContain('full-extension.zip');
@@ -346,7 +352,7 @@ describe('generated Extensions v2 façade', () => {
'opaque cursor',
);
// The mine scope forwards a type filter when asked, and never carries
- // the public catalogue's developer_id filter.
+ // the public directory's developer_id filter.
expect(requestUrl(fetchMock, 0).searchParams.get('type')).toBe('theme');
expect(requestUrl(fetchMock, 0).searchParams.has('developer_id')).toBe(
false,
@@ -357,12 +363,15 @@ describe('generated Extensions v2 façade', () => {
it('serializes a create payload with no developer field and reports the new revision', async () => {
const payload = {
id: 'body-extension',
- type: 'mod' as const,
+ manifest_version: 1 as const,
+ author: { name: 'Package Author' },
+ requires: { fossbilling: '^0.8.9', php: '>=8.3' },
+ type: 'module' as const,
name: 'Body extension',
description: 'Submitted through the generated client.',
releases: [],
- website: 'https://example.test/body-extension',
- license: { name: 'MIT' },
+ homepage_url: 'https://example.test/body-extension',
+ license: 'MIT',
readme: '# Body extension',
source: { type: 'github' as const, repo: 'fossbilling/body-extension' },
version: '1.0.0',
@@ -401,12 +410,15 @@ describe('generated Extensions v2 façade', () => {
it('sends an edit as PUT and reads the 202 pending-revision result', async () => {
const payload = {
- type: 'mod' as const,
+ manifest_version: 1 as const,
+ author: { name: 'Package Author' },
+ requires: { fossbilling: '^0.8.9', php: '>=8.3' },
+ type: 'module' as const,
name: 'Body extension',
description: 'Edited through the generated client.',
releases: [],
- website: 'https://example.test/body-extension',
- license: { name: 'MIT' },
+ homepage_url: 'https://example.test/body-extension',
+ license: 'MIT',
readme: '# Body extension',
source: { type: 'github' as const, repo: 'fossbilling/body-extension' },
version: '1.1.0',
@@ -508,12 +520,15 @@ describe('generated Extensions v2 façade', () => {
);
vi.stubGlobal('fetch', fetchMock);
const payload = {
- type: 'mod' as const,
+ manifest_version: 1 as const,
+ author: { name: 'Package Author' },
+ requires: { fossbilling: '^0.8.9', php: '>=8.3' },
+ type: 'module' as const,
name: 'Fixed',
description: 'd',
releases: [],
- website: 'https://example.test',
- license: { name: 'MIT' },
+ homepage_url: 'https://example.test',
+ license: 'MIT',
readme: '# Fixed',
source: { type: 'github' as const, repo: 'example/live' },
version: '1.0.0',
@@ -669,7 +684,7 @@ describe('generated Extensions v2 façade', () => {
it('preserves unavailable legacy-card links without treating them as detail URLs', async () => {
const card: ExtensionListItem = {
...item('legacy'),
- website: null,
+ homepage_url: null,
download_url: null,
};
vi.stubGlobal(
@@ -677,8 +692,12 @@ describe('generated Extensions v2 façade', () => {
vi.fn().mockResolvedValue(apiResponse(page([card], null, false))),
);
expect((await listExtensions(publicEnv)).result[0]).toEqual(card);
- expectTypeOf().toEqualTypeOf();
- expectTypeOf().toEqualTypeOf();
+ expectTypeOf().toEqualTypeOf<
+ string | null | undefined
+ >();
+ expectTypeOf().toEqualTypeOf<
+ string | undefined
+ >();
});
it('fetches one revision on demand and supports compacted content', async () => {
diff --git a/test/extensions-data.test.ts b/test/extensions-data.test.ts
index f738d252..dcf9c897 100644
--- a/test/extensions-data.test.ts
+++ b/test/extensions-data.test.ts
@@ -54,12 +54,19 @@ describe('API-backed extension data adapters', () => {
id: 'extension-id',
developer,
published: {
- type: 'mod',
+ manifest_version: 1 as const,
+ author: { name: 'Package Author' },
+ requires: {
+ fossbilling: '^0.8.9 || ^1.0',
+ php: '>=8.3 <9',
+ modules: { branding: '^1.2' },
+ },
+ type: 'module',
name: 'Example',
description: 'desc',
releases: [],
- website: 'https://example.test',
- license: { name: 'MIT' },
+ homepage_url: 'https://example.test',
+ license: 'MIT',
readme: '# Example',
source: { type: 'github', repo: 'fossbilling/example' },
version: '1.0.0',
@@ -84,6 +91,14 @@ describe('API-backed extension data adapters', () => {
const detail = await getOwnedExtension(env, 'user-subject', 'extension-id');
expect(detail?.published?.name).toBe('Example');
+ expect(detail?.published?.author).toEqual({ name: 'Package Author' });
+ expect(detail?.published?.requires).toEqual({
+ fossbilling: '^0.8.9 || ^1.0',
+ php: '>=8.3 <9',
+ modules: { branding: '^1.2' },
+ });
+ expect(detail?.published?.homepage_url).toBe('https://example.test');
+ expect(detail?.published?.license).toBe('MIT');
expect(detail?.pendingRevision).toEqual({
id: 'revision-1',
createdAt: '2026-01-01T00:00:00Z',
@@ -102,12 +117,19 @@ describe('API-backed extension data adapters', () => {
id: 'extension-id',
developer,
published: {
- type: 'mod',
+ manifest_version: 1 as const,
+ author: { name: 'Package Author' },
+ requires: {
+ fossbilling: '^0.8.9 || ^1.0',
+ php: '>=8.3 <9',
+ modules: { branding: '^1.2' },
+ },
+ type: 'module',
name: 'Example',
description: 'desc',
releases: [],
- website: 'https://example.test',
- license: { name: 'MIT' },
+ homepage_url: 'https://example.test',
+ license: 'MIT',
readme: '# Example',
source: { type: 'github', repo: 'fossbilling/example' },
version: '1.0.0',
diff --git a/test/helpers/catalogue-fixtures.ts b/test/helpers/directory-fixtures.ts
similarity index 80%
rename from test/helpers/catalogue-fixtures.ts
rename to test/helpers/directory-fixtures.ts
index 03c81dee..ee8ece24 100644
--- a/test/helpers/catalogue-fixtures.ts
+++ b/test/helpers/directory-fixtures.ts
@@ -5,11 +5,13 @@ import type { ExtensionListItem } from '@/lib/api/client';
export function item(id: string, name = id): ExtensionListItem {
return {
id,
- type: 'mod',
+ manifest_version: 1 as const,
+ author: { name: 'Package Author' },
+ type: 'module',
name,
description: `${name} description`,
- website: `https://example.test/${id}`,
- license: { name: 'MIT' },
+ homepage_url: `https://example.test/${id}`,
+ license: 'MIT',
source: { type: 'github', repo: `fossbilling/${id}` },
version: '1.0.0',
download_url: `https://example.test/${id}.zip`,
@@ -23,7 +25,7 @@ export function item(id: string, name = id): ExtensionListItem {
};
}
-// A paginated API response body for any row type — catalogue items, claim
+// A paginated API response body for any row type — directory items, claim
// rows, history entries — shaped like the generated Pagination envelope.
export function page(
result: T[],
diff --git a/test/revalidate.test.ts b/test/revalidate.test.ts
index f1053b41..46f3b4b6 100644
--- a/test/revalidate.test.ts
+++ b/test/revalidate.test.ts
@@ -61,7 +61,7 @@ describe('POST /api/revalidate', () => {
const cache = makeCache();
const response = await POST(
makeContext(
- makeRequest({ tags: ['catalogue'] }),
+ makeRequest({ tags: ['extensions'] }),
makeRevalidateEnv(),
cache,
),
@@ -76,7 +76,7 @@ describe('POST /api/revalidate', () => {
const response = await POST(
makeContext(
makeRequest(
- { tags: ['catalogue'] },
+ { tags: ['extensions'] },
{ authorization: `Bearer wrong-token` },
),
makeRevalidateEnv(),
@@ -93,7 +93,7 @@ describe('POST /api/revalidate', () => {
const response = await POST(
makeContext(
makeRequest(
- { tags: ['catalogue'] },
+ { tags: ['extensions'] },
{ authorization: `Bearer ${SECRET}` },
),
makeRevalidateEnv({ revalidateSecret: '' }),
@@ -121,7 +121,7 @@ describe('POST /api/revalidate', () => {
it('rejects unknown or non-string tags', async () => {
const cache = makeCache();
- for (const tags of [['products'], [], ['catalogue', 42], 'catalogue']) {
+ for (const tags of [['products'], [], ['extensions', 42], 'extensions']) {
const response = await POST(
makeContext(
makeRequest({ tags }, { authorization: `Bearer ${SECRET}` }),
@@ -149,7 +149,7 @@ describe('POST /api/revalidate', () => {
const response = await POST(
makeContext(
makeRequest(
- { tags: ['catalogue', 'developers'] },
+ { tags: ['extensions', 'developers'] },
{ authorization: `Bearer ${SECRET}` },
),
makeRevalidateEnv(),
@@ -159,11 +159,11 @@ describe('POST /api/revalidate', () => {
expect(response.status).toBe(200);
await expect(response.json()).resolves.toEqual({
- purged: ['catalogue', 'developers'],
+ purged: ['extensions', 'developers'],
});
expect(order).toEqual(['marker', 'invalidate']);
expect(cache.invalidate).toHaveBeenCalledWith({
- tags: ['catalogue', 'developers'],
+ tags: ['extensions', 'developers'],
});
});
@@ -172,7 +172,7 @@ describe('POST /api/revalidate', () => {
const response = await POST(
makeContext(
makeRequest(
- { tags: ['catalogue'] },
+ { tags: ['extensions'] },
{ authorization: `Bearer ${SECRET}` },
),
makeRevalidateEnv(),
@@ -190,7 +190,7 @@ describe('POST /api/revalidate', () => {
const response = await POST(
makeContext(
makeRequest(
- { tags: ['catalogue'] },
+ { tags: ['extensions'] },
{ authorization: `Bearer ${SECRET}` },
),
makeRevalidateEnv(),
@@ -212,7 +212,7 @@ describe('POST /api/revalidate', () => {
const response = await POST(
makeContext(
makeRequest(
- { tags: ['catalogue'] },
+ { tags: ['extensions'] },
{ authorization: `Bearer ${SECRET}` },
),
makeRevalidateEnv(),
@@ -232,7 +232,7 @@ describe('POST /api/revalidate', () => {
const response = await POST(
makeContext(
makeRequest(
- { tags: ['catalogue'] },
+ { tags: ['extensions'] },
{ authorization: `Bearer ${SECRET}` },
'http://localhost:4321/api/revalidate',
),
@@ -243,7 +243,7 @@ describe('POST /api/revalidate', () => {
expect(response.status).toBe(200);
await expect(response.json()).resolves.toEqual({
- purged: ['catalogue'],
+ purged: ['extensions'],
cache: 'purge-unavailable-locally',
});
});
diff --git a/test/revision-diff.test.ts b/test/revision-diff.test.ts
index dd3166e1..3a3f3109 100644
--- a/test/revision-diff.test.ts
+++ b/test/revision-diff.test.ts
@@ -6,12 +6,15 @@ import type {
} from '@/lib/api/generated/extensions-v2/types.gen';
const published: ExtensionContent = {
- type: 'mod',
+ manifest_version: 1,
+ author: { name: 'Package Author' },
+ requires: { fossbilling: '^0.8.9', php: '>=8.3' },
+ type: 'module',
name: 'Old name',
version: '1.0.0',
description: 'Old description',
- website: 'https://example.test',
- license: { name: 'MIT', spdx_id: 'MIT' },
+ homepage_url: 'https://example.test',
+ license: 'MIT',
source: { type: 'github', repo: 'org/old' },
download_url: 'https://example.test/old.zip',
icon_url: 'https://example.test/icon.png',
@@ -21,7 +24,7 @@ const published: ExtensionContent = {
tag: 'v1.0.0',
date: '2026-01-01',
download_url: 'https://example.test/old.zip',
- min_fossbilling_version: '0.1.0',
+ requires: { fossbilling: '>=0.1.0', php: '*' },
},
],
};
@@ -49,13 +52,13 @@ describe('diffRevisionContent', () => {
expect(byField.name.isNew).toBe(true);
expect(byField.name.changed).toBe(true);
expect(byField.name.oldValue).toBeNull();
- expect(byField.website.changed).toBe(false);
+ expect(byField.homepage_url.changed).toBe(false);
});
it('compares license, source and releases by label rather than object identity', () => {
const revision: StoredExtensionContent = {
...published,
- license: { name: 'MIT', spdx_id: 'MIT' },
+ license: 'MIT',
source: { type: 'github', repo: 'org/old' },
releases: published.releases.map((r) => ({ ...r })),
};
@@ -77,7 +80,7 @@ describe('diffRevisionContent', () => {
});
const byField = Object.fromEntries(rows.map((r) => [r.field, r]));
expect(byField.license.changed).toBe(true);
- expect(byField.license.oldValue).toBe('MIT (MIT)');
+ expect(byField.license.oldValue).toBe('MIT');
expect(byField.license.newValue).toBe('MIT (MIT)');
expect(byField.license.oldUrl).toBeNull();
expect(byField.license.newUrl).toBe('https://example.test/licenses/mit');
@@ -134,10 +137,68 @@ describe('diffRevisionContent', () => {
it('does not let delimiter text in values collide comparison keys', () => {
const rows = diffRevisionContent(
- { ...published, license: { name: 'A|B' } },
+ { ...published, license: 'A|B' },
{ ...published, license: { name: 'A', spdx_id: 'B' } },
);
const byField = Object.fromEntries(rows.map((r) => [r.field, r]));
expect(byField.license.changed).toBe(true);
});
});
+
+it('detects requirement-only and author-only edits and compares complete release metadata', () => {
+ const changed = diffRevisionContent(published, {
+ ...published,
+ author: { name: 'Different Author' },
+ requires: { ...published.requires, php: '>=8.4' },
+ releases: published.releases.map((release) => ({
+ ...release,
+ requires: { ...release.requires, php: '>=8.4' },
+ })),
+ });
+ const fields = Object.fromEntries(changed.map((row) => [row.field, row]));
+ expect(fields.author.changed).toBe(true);
+ expect(fields.requires.changed).toBe(true);
+ expect(fields.releases.changed).toBe(true);
+ expect(fields.requires.newValue).toContain('>=8.4');
+});
+
+it('still renders legacy website and license audit fields', () => {
+ const fields = Object.fromEntries(
+ diffRevisionContent(null, {
+ website: 'https://legacy.example.com',
+ license: { name: 'MIT', URL: 'https://legacy.example.com/license' },
+ }).map((row) => [row.field, row]),
+ );
+ expect(fields.homepage_url.newValue).toBe('https://legacy.example.com');
+ expect(fields.license.newUrl).toBe('https://legacy.example.com/license');
+});
+
+it('shows author names and URLs and detects URL-only edits', () => {
+ const row = diffRevisionContent(published, {
+ ...published,
+ author: { name: 'Package Author', url: 'https://author.example.test' },
+ }).find((row) => row.field === 'author')!;
+ expect(row.changed).toBe(true);
+ expect(row.oldValue).toBe('Package Author');
+ expect(row.newValue).toBe('Package Author');
+ expect(row.oldUrl).toBeNull();
+ expect(row.newUrl).toBe('https://author.example.test');
+});
+
+it.each([
+ { date: '2026-02-01' },
+ { download_url: 'https://example.test/new.zip' },
+ { changelog_url: 'https://example.test/changelog' },
+ { requires: { fossbilling: '^1.0', php: '>=8.4' } },
+])('shows complete release metadata for edits %j', (update) => {
+ const releases = published.releases.map((release) => ({
+ ...release,
+ ...update,
+ }));
+ const row = diffRevisionContent(published, { ...published, releases }).find(
+ (row) => row.field === 'releases',
+ )!;
+ expect(row.changed).toBe(true);
+ expect(row.oldValue).not.toBe(row.newValue);
+ expect(JSON.parse(row.newValue!)).toEqual(releases);
+});
diff --git a/test/update-extensions-openapi.test.ts b/test/update-extensions-openapi.test.ts
index e4496521..f4eeef55 100644
--- a/test/update-extensions-openapi.test.ts
+++ b/test/update-extensions-openapi.test.ts
@@ -18,6 +18,15 @@ const createDocument = () => ({
},
Pagination: createPaginationSchema(),
ExtensionListItem: { properties: { id: { type: 'string' } } },
+ ExtensionContent: {
+ properties: {
+ manifest_version: { type: 'number', enum: [1] },
+ requires: { type: 'object' },
+ author: { type: 'object' },
+ homepage_url: { type: 'string' },
+ license: { type: 'string' },
+ },
+ },
},
},
});
@@ -61,6 +70,7 @@ describe('OpenAPI snapshot update', () => {
await runUpdate({
components: {
schemas: {
+ ExtensionContent: value.components.schemas.ExtensionContent,
Pagination: value.components.schemas.Pagination,
ExtensionListItem: value.components.schemas.ExtensionListItem,
ExtensionListResponse: {
@@ -98,7 +108,7 @@ describe('OpenAPI snapshot update', () => {
expect(writeFile).not.toHaveBeenCalled();
});
- it.each([null, [], { readme: {} }, { releases: {} }])(
+ it.each([null, [], { readme: {} }, { releases: {} }, { requires: {} }])(
'rejects invalid list item properties %j without writing',
async (properties) => {
const value = createDocument();
@@ -116,6 +126,27 @@ describe('OpenAPI snapshot update', () => {
},
);
+ it('rejects a pre-manifest contract before replacing the snapshot', async () => {
+ const value = createDocument();
+ await expect(
+ runUpdate({
+ ...value,
+ components: {
+ schemas: {
+ ...value.components.schemas,
+ ExtensionContent: {
+ properties: {
+ website: { type: 'string' },
+ license: { type: 'object' },
+ },
+ },
+ },
+ },
+ }),
+ ).rejects.toThrow('manifest v1');
+ expect(writeFile).not.toHaveBeenCalled();
+ });
+
it('reports HTTP failures without writing', async () => {
vi.stubGlobal(
'fetch',
@@ -129,3 +160,41 @@ describe('OpenAPI snapshot update', () => {
expect(writeFile).not.toHaveBeenCalled();
});
});
+
+describe('manifest version guard', () => {
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ vi.unstubAllEnvs();
+ });
+ it.each([
+ { type: 'number', enum: [2] },
+ { type: 'string', enum: ['1'] },
+ { type: 'number' },
+ { type: 'number', enum: [1, 2] },
+ {},
+ ])(
+ 'rejects unsupported manifest schema %j without writing',
+ async (manifest_version) => {
+ vi.resetModules();
+ vi.clearAllMocks();
+ const value = createDocument();
+ await expect(
+ runUpdate({
+ ...value,
+ components: {
+ schemas: {
+ ...value.components.schemas,
+ ExtensionContent: {
+ properties: {
+ ...value.components.schemas.ExtensionContent.properties,
+ manifest_version,
+ },
+ },
+ },
+ },
+ }),
+ ).rejects.toThrow('manifest v1');
+ expect(writeFile).not.toHaveBeenCalled();
+ },
+ );
+});