@joomengine/joomla-mcp 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +88 -4
  3. package/dist/application/custom-fields.d.ts +28 -0
  4. package/dist/application/custom-fields.d.ts.map +1 -0
  5. package/dist/application/custom-fields.js +169 -0
  6. package/dist/application/custom-fields.js.map +1 -0
  7. package/dist/application/joomla-service.d.ts +1 -1
  8. package/dist/application/joomla-service.d.ts.map +1 -1
  9. package/dist/application/joomla-service.js +54 -2
  10. package/dist/application/joomla-service.js.map +1 -1
  11. package/dist/application/joomla-write-service.d.ts +4 -4
  12. package/dist/application/joomla-write-service.d.ts.map +1 -1
  13. package/dist/application/joomla-write-service.js +152 -70
  14. package/dist/application/joomla-write-service.js.map +1 -1
  15. package/dist/application/menu-component-binding.d.ts +24 -0
  16. package/dist/application/menu-component-binding.d.ts.map +1 -0
  17. package/dist/application/menu-component-binding.js +223 -0
  18. package/dist/application/menu-component-binding.js.map +1 -0
  19. package/dist/application/template-style-inheritance.d.ts +9 -0
  20. package/dist/application/template-style-inheritance.d.ts.map +1 -0
  21. package/dist/application/template-style-inheritance.js +104 -0
  22. package/dist/application/template-style-inheritance.js.map +1 -0
  23. package/dist/catalog/action-catalog.d.ts +3 -1
  24. package/dist/catalog/action-catalog.d.ts.map +1 -1
  25. package/dist/catalog/action-catalog.js +64 -14
  26. package/dist/catalog/action-catalog.js.map +1 -1
  27. package/dist/catalog/companion-actions.d.ts.map +1 -1
  28. package/dist/catalog/companion-actions.js +20 -2
  29. package/dist/catalog/companion-actions.js.map +1 -1
  30. package/dist/catalog/crud-write-fields.js +1 -1
  31. package/dist/catalog/crud-write-fields.js.map +1 -1
  32. package/dist/contracts/article-text.d.ts +9 -0
  33. package/dist/contracts/article-text.d.ts.map +1 -0
  34. package/dist/contracts/article-text.js +29 -0
  35. package/dist/contracts/article-text.js.map +1 -0
  36. package/dist/contracts/subform-json.d.ts +3 -0
  37. package/dist/contracts/subform-json.d.ts.map +1 -0
  38. package/dist/contracts/subform-json.js +104 -0
  39. package/dist/contracts/subform-json.js.map +1 -0
  40. package/dist/live-test/fixtures.d.ts.map +1 -1
  41. package/dist/live-test/fixtures.js +8 -4
  42. package/dist/live-test/fixtures.js.map +1 -1
  43. package/dist/live-test/runner.d.ts +4 -0
  44. package/dist/live-test/runner.d.ts.map +1 -1
  45. package/dist/live-test/runner.js +138 -13
  46. package/dist/live-test/runner.js.map +1 -1
  47. package/dist/mcp/create-server.d.ts.map +1 -1
  48. package/dist/mcp/create-server.js +8 -40
  49. package/dist/mcp/create-server.js.map +1 -1
  50. package/dist/security/confirmation-service.d.ts +4 -0
  51. package/dist/security/confirmation-service.d.ts.map +1 -1
  52. package/dist/security/confirmation-service.js +11 -0
  53. package/dist/security/confirmation-service.js.map +1 -1
  54. package/dist/version.d.ts +1 -1
  55. package/dist/version.js +1 -1
  56. package/docs/API_ACTIONS.md +14 -12
  57. package/docs/ARTICLE_TEXT.md +72 -0
  58. package/docs/CLIENTS.md +25 -38
  59. package/docs/COMPANION_RUNTIME_PARITY.md +51 -0
  60. package/docs/COVERAGE.md +1 -1
  61. package/docs/CUSTOM_FIELDS.md +202 -0
  62. package/docs/DEPLOYMENT.md +26 -12
  63. package/docs/FIXTURES.md +1 -1
  64. package/docs/LIBRARY.md +3 -3
  65. package/docs/MENU_COMPONENT_BINDING.md +90 -0
  66. package/docs/PHP_COMPANION.md +3 -3
  67. package/docs/RELEASING.md +52 -19
  68. package/docs/SINGLE_SITE.md +1 -1
  69. package/docs/TEMPLATE_STYLE_INHERITANCE.md +53 -0
  70. package/docs/TROUBLESHOOTING.md +1 -1
  71. package/examples/embedded-host/package.json +1 -1
  72. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -3,6 +3,64 @@
3
3
  All notable changes to the published packages are documented here. Releases
4
4
  follow Semantic Versioning.
5
5
 
6
+ ## Unreleased
7
+
8
+ ### Fixed
9
+
10
+ - Verify approved native subform custom field values by their bounded decoded JSON structure, preserving list order, object/list shape, scalar types, independent read-back and idempotent replay. Keep the raw API verification response and add scoped field evidence; use the same metadata-bound comparison in configured live tests ([#57](https://github.com/joomengine/joomla-mcp/issues/57), [PHP #39](https://github.com/joomengine/mcp_component/issues/39)).
11
+ - Complete omitted native field-create descriptions and parameter groups with administrator form defaults through the API and companion. Preserve explicit values and partial updates; prevent the missing non-null SQL payload failure reported in [#57](https://github.com/joomengine/joomla-mcp/issues/57) without assuming every HTTP 400 is effect-free.
12
+ - Accept category assignments on create and update for all six native custom-field contexts. Preserve omitted assignments during API and companion updates, expose assignment read-back, and retain Joomla's All, None and subform-only behavior.
13
+
14
+ ## [0.8.0] - 2026-09-30
15
+
16
+ ### Changed
17
+
18
+ - Align Docker images with the npm release version: retain commit-addressed and
19
+ v-prefixed tags and publish an immutable bare SemVer tag for the same digest.
20
+ - Promote the Docker `latest` channel only after verified stable npm publication;
21
+ prereleases use `next` without changing `latest`. Reject channel regressions
22
+ and reconcile missing image aliases when recovering a partial release.
23
+
24
+ ### Fixed
25
+
26
+ - Publish and normalize the native `extensions.list` type filter in the Node
27
+ companion catalogue, allowing safe plugin selection through both MCP transports
28
+ while rejecting unsupported types and unknown properties.
29
+ - Select a disabled, unprotected optional plugin from bounded explicit plugin pages in live extension-state validation, preserving its identity and original state for restoration when deterministic native ordering puts components on the first page.
30
+ - Preserve object-valued native companion inputs and schema mappings, reject
31
+ arrays/null/scalars where objects are required, and retain nested empty values.
32
+ Keep exact zero-based native list pagination at partial/end boundaries and map
33
+ content-language `id` ordering to Joomla's real `lang_id` field
34
+ ([#44](https://github.com/joomengine/joomla-mcp/issues/44),
35
+ [PHP PR #16](https://github.com/joomengine/mcp_component/pull/16)).
36
+ - Preserve stored empty and numeric-key JSON mappings in native item reads and
37
+ saved read-back, including article metadata and attributes that Joomla models
38
+ convert from Registry objects to arrays. Keep stored lists distinct and retain
39
+ strict write verification ([#44](https://github.com/joomengine/joomla-mcp/issues/44)).
40
+ - Supply Joomla's empty-string `default_value` when a `fields.*.create` call
41
+ omits it, through both API and companion transports. Preserve caller-supplied
42
+ defaults and leave partial updates unchanged
43
+ ([#42](https://github.com/joomengine/joomla-mcp/issues/42)).
44
+ - Resolve site-specific published custom fields for API article, content-category,
45
+ contact and user create/update plans, including the typed article tools,
46
+ while rejecting unrecognized keys and retaining approved field snapshots
47
+ ([#38](https://github.com/joomengine/joomla-mcp/issues/38)).
48
+
49
+ - Preserve installed template inheritance when creating site or administrator
50
+ styles through the API or companion. Derive hidden `parent` and `inheritable`
51
+ fields from an existing style's native manifest before confirmation; refuse
52
+ missing, ambiguous, invalid, or changed metadata ([#40](https://github.com/joomengine/joomla-mcp/issues/40)).
53
+ - Persist and verify native menu component IDs for API creates and updates,
54
+ including cross-component link changes. Approved corrective PATCHes and
55
+ stored-list verification retain honest partial/uncertain outcomes and prevent
56
+ same-key duplicate creates ([#39](https://github.com/joomengine/joomla-mcp/issues/39)).
57
+ - Normalize combined article text to Joomla's native `introtext` and `fulltext`
58
+ before planning API or companion creates and updates, fixing silently unchanged
59
+ article bodies on Joomla 6 PATCH requests ([#31](https://github.com/joomengine/joomla-mcp/issues/31)).
60
+ - Preserve Joomla Read More splitting, clear old full text on complete body
61
+ replacement, and reject ambiguous combined/native text inputs. Native partial
62
+ text updates and title-only updates retain omitted content.
63
+
6
64
  ## [0.7.0] - 2026-07-24
7
65
 
8
66
  ### Added
@@ -71,3 +129,4 @@ follow Semantic Versioning.
71
129
 
72
130
  [0.6.0]: https://github.com/joomengine/joomla-mcp/releases/tag/v0.6.0
73
131
  [0.7.0]: https://github.com/joomengine/joomla-mcp/releases/tag/v0.7.0
132
+ [0.8.0]: https://github.com/joomengine/joomla-mcp/releases/tag/v0.8.0
package/README.md CHANGED
@@ -1,5 +1,61 @@
1
1
  # JoomEngine MCP for Joomla
2
2
 
3
+ [![CI](https://github.com/joomengine/joomla-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/joomengine/joomla-mcp/actions/workflows/ci.yml) [![Release](https://github.com/joomengine/joomla-mcp/actions/workflows/release.yml/badge.svg)](https://github.com/joomengine/joomla-mcp/actions/workflows/release.yml) [![Publish](https://github.com/joomengine/joomla-mcp/actions/workflows/publish-release.yml/badge.svg)](https://github.com/joomengine/joomla-mcp/actions/workflows/publish-release.yml) [![npm](https://img.shields.io/npm/v/%40joomengine%2Fjoomla-mcp?label=npm)](https://www.npmjs.com/package/@joomengine/joomla-mcp) [![Joomla](https://img.shields.io/badge/Joomla-6.1%2B-5091CD?logo=joomla&logoColor=white)](https://www.joomla.org/) [![Node](https://img.shields.io/badge/Node-22.12%2B-339933?logo=nodedotjs&logoColor=white)](https://nodejs.org/) [![License](https://img.shields.io/badge/License-GPL--2.0%2B-blue)](LICENSE)
4
+
5
+ ## Project notice: use the Joomla-native MCP package
6
+
7
+ This repository started as the **TypeScript proof of concept** for JoomEngine
8
+ MCP. Active development has moved to the Joomla-native
9
+ [`mcp_component`](https://github.com/joomengine/mcp_component) and its companion
10
+ plugins. This is the **fourth iteration of the MCP implementation**, with broader
11
+ functionality and native Joomla administration and Joomla Component Builder (JCB)
12
+ integration. “Fourth iteration” describes the project's development history,
13
+ not a `v4` release number.
14
+
15
+ **For new installations, install the stable
16
+ [`mcp_package`](https://github.com/joomengine/mcp_package) on your Joomla site.**
17
+ It bundles the MCP component, the console plugin and the webservices plugin in
18
+ one Joomla extension ZIP. The component release workflow rebuilds the package
19
+ from the tagged extensions; use a published
20
+ [package tag ZIP](https://github.com/joomengine/mcp_package/tags) and keep receiving
21
+ updates through Joomla's extension updater.
22
+
23
+ The current stack is distributed alongside JCB and designed to work with it.
24
+ JCB itself is a separate installation; Joomla core operations also work without
25
+ JCB.
26
+
27
+ | Start here | Purpose |
28
+ | --- | --- |
29
+ | [Install and set up your Joomla site](https://github.com/joomengine/mcp_component/blob/main/docs/GETTING-STARTED.md) | Package installation, plugin enablement, component settings, API identity and permissions |
30
+ | [Connect an AI or use the tools directly](https://github.com/joomengine/mcp_component/blob/main/docs/CLIENT-CONNECTIONS.md) | PHP client setup, stdio connections, provider requirements and use without an AI |
31
+ | [Component overview and documentation](https://github.com/joomengine/mcp_component#readme) | Current features, administrator areas, JCB integration and operational references |
32
+ | [External PHP client and bridge](https://github.com/joomengine/mcp_client#readme) | Connect compatible MCP applications to your site's authenticated endpoint |
33
+
34
+ The package contains:
35
+
36
+ - [`mcp_component`](https://github.com/joomengine/mcp_component): the Joomla-native MCP server and administrator component.
37
+ - [`mcp_plugin`](https://github.com/joomengine/mcp_plugin): the local Joomla console server.
38
+ - [`mcp_webservices`](https://github.com/joomengine/mcp_webservices): authenticated Joomla API routing.
39
+
40
+ [`mcp_client`](https://github.com/joomengine/mcp_client) is installed separately
41
+ on the client machine. It exposes the site's MCP tools to applications that
42
+ support a local stdio MCP process and can also be used directly as a PHP SDK.
43
+ For ChatGPT and other applications that require a remote HTTPS MCP connector,
44
+ see the [connection guide](https://github.com/joomengine/mcp_component/blob/main/docs/CLIENT-CONNECTIONS.md)
45
+ for the supported transport requirements.
46
+
47
+ **Maintenance plan, October 2026:** this TypeScript predecessor will continue
48
+ to receive maintenance for the next two months, through early December 2026.
49
+ The recommended installation and ongoing development are the component,
50
+ plugins, package and PHP client linked above.
51
+
52
+ ## Legacy TypeScript implementation
53
+
54
+ The sections below document this repository's existing TypeScript server and
55
+ companion. Their npm packages, Node.js requirements, configuration files and
56
+ deployment instructions apply to this predecessor. Use the current guides
57
+ above when installing the Joomla-native package.
58
+
3
59
  An embeddable library and self-hosted Model Context Protocol (MCP) server for
4
60
  administering Joomla 6.x through bounded, auditable semantic actions.
5
61
 
@@ -14,9 +70,11 @@ Joomla 6.1 is the implementation baseline, Joomla 6.2 is the compatibility targe
14
70
 
15
71
  > **Production status:** all 236 Joomla 6.1 core Web Services route templates are source-catalogued, but five are explicitly source-only and no family has completed the required live Joomla 6.1/6.2 success, denial, postcondition, and recovery matrix. Production certification remains gated on that evidence, deeper value/output contracts, privileged recovery tests, and shared coordination for multi-replica writes. See [coverage and release status](docs/COVERAGE.md).
16
72
 
17
- ## Why this stack
73
+ ## Legacy technology choices
18
74
 
19
- TypeScript is a Tier 1 MCP SDK while PHP is Tier 3. For convenience, TypeScript is used and PHP where possible.
75
+ This proof of concept uses TypeScript for the MCP server and PHP for its Joomla
76
+ companion. The actively developed Joomla-native server and client are maintained
77
+ in the repositories linked in the project notice above.
20
78
 
21
79
  ## Capabilities
22
80
 
@@ -36,6 +94,14 @@ TypeScript is a Tier 1 MCP SDK while PHP is Tier 3. For convenience, TypeScript
36
94
 
37
95
  The generated [API action reference](docs/API_ACTIONS.md) lists every route, semantic ID, accepted field set, transport, risk, and source-only gate. The release truth table is in [docs/COVERAGE.md](docs/COVERAGE.md). An implemented action is not described as production-verified until it has passed the corresponding live Joomla matrix.
38
96
 
97
+ For article creation and updates, see [Writing article text](docs/ARTICLE_TEXT.md).
98
+ MCP converts `articletext` into Joomla's native `introtext` and `fulltext` fields,
99
+ including Read More splitting and clearing old full text when replacing the body.
100
+
101
+ For site-specific custom fields, see [Writing custom field values](docs/CUSTOM_FIELDS.md).
102
+ API write plans resolve published fields on the selected site and retain the
103
+ normal permission and confirmation flow.
104
+
39
105
  ## Requirements
40
106
 
41
107
  - Node.js 22.12 or newer.
@@ -49,7 +115,7 @@ The generated [API action reference](docs/API_ACTIONS.md) lists every route, sem
49
115
  Install the public, versioned package:
50
116
 
51
117
  ```bash
52
- npm install @joomengine/joomla-mcp@^0.7.0
118
+ npm install @joomengine/joomla-mcp@^0.8.0
53
119
  ```
54
120
 
55
121
  Create a transport-neutral application without starting a process or binding a
@@ -76,6 +142,18 @@ See [library integration](docs/LIBRARY.md) for every public entry point,
76
142
  configuration and secret-manager integration, stdio/HTTP lifecycle, adapter
77
143
  contracts, isolation rules, executable examples, and compatibility policy.
78
144
 
145
+ ## Docker release images
146
+
147
+ Docker and npm use the same release version. For the 0.8.0 stable release,
148
+ `ghcr.io/joomengine/joomla-mcp:0.8.0`, `:v0.8.0`, and `:latest` resolve to
149
+ the same image digest. Commit-addressed `:sha-<commit>` images remain available.
150
+ Version tags are immutable; `latest` advances only after verified stable npm
151
+ publication. Prereleases use `next` and never change `latest`.
152
+
153
+ See [deployment](docs/DEPLOYMENT.md) for configuration and digest-pinned
154
+ production rollout, and [releasing](docs/RELEASING.md) for publication and
155
+ recovery.
156
+
79
157
  ## Install and validate
80
158
 
81
159
  ```bash
@@ -239,7 +317,12 @@ One-operation grants are consumed by one apply attempt. Thirty-minute grants exp
239
317
 
240
318
  Do not enable destructive or privileged toolsets until their live and recovery gates in [docs/COVERAGE.md](docs/COVERAGE.md) have passed for your environment.
241
319
 
242
- ## Documentation
320
+ ## Documentation for this predecessor
321
+
322
+ For the current Joomla-native stack, use the
323
+ [installation guide](https://github.com/joomengine/mcp_component/blob/main/docs/GETTING-STARTED.md)
324
+ and [AI and direct client guide](https://github.com/joomengine/mcp_component/blob/main/docs/CLIENT-CONNECTIONS.md).
325
+ The references below describe this TypeScript implementation.
243
326
 
244
327
  - [Architecture and native-first rules](docs/ARCHITECTURE.md)
245
328
  - [Library and host-application integration](docs/LIBRARY.md)
@@ -247,6 +330,7 @@ Do not enable destructive or privileged toolsets until their live and recovery g
247
330
  - [Single-company, single-site deployment](docs/SINGLE_SITE.md)
248
331
  - [ChatGPT, Codex, Claude, Gemini, and Grok connections](docs/CLIENTS.md)
249
332
  - [Generated Joomla API action reference](docs/API_ACTIONS.md)
333
+ - [Menu component binding and partial-write recovery](docs/MENU_COMPONENT_BINDING.md)
250
334
  - [Action coverage and release status](docs/COVERAGE.md)
251
335
  - [Deployment, upgrades, and rollback](docs/DEPLOYMENT.md)
252
336
  - [Fixture setup and live verification](docs/FIXTURES.md)
@@ -0,0 +1,28 @@
1
+ import type { ApiConfig, Toolset } from '../config/schema.js';
2
+ import type { JoomlaApiTransport } from '../infrastructure/api/joomla-api-client.js';
3
+ export interface ResolvedCustomField {
4
+ readonly name: string;
5
+ readonly type: string;
6
+ readonly context: string;
7
+ }
8
+ interface CustomFieldTarget {
9
+ readonly base: string;
10
+ readonly context: string;
11
+ readonly listAction: string;
12
+ readonly nested: boolean;
13
+ }
14
+ export declare function customFieldTarget(actionId: string): (CustomFieldTarget & {
15
+ readonly readToolset: Toolset;
16
+ }) | undefined;
17
+ /** Retains dynamic input for site-backed validation; never broadens the static catalogue. */
18
+ export declare function customFieldInput(actionId: string, value: unknown): {
19
+ readonly data: Readonly<Record<string, unknown>>;
20
+ readonly names: readonly string[];
21
+ } | undefined;
22
+ /** Uses fixed catalogue routes and numeric offsets, never a response-provided URL. */
23
+ export declare function resolvePublishedCustomFields(actionId: string, apiConfig: ApiConfig, api: JoomlaApiTransport): Promise<readonly ResolvedCustomField[]>;
24
+ export declare function encodeCustomFieldBody(actionId: string, body: Readonly<Record<string, unknown>>, fields: readonly ResolvedCustomField[]): Readonly<Record<string, unknown>>;
25
+ /** Apply JSON meaning only to the approved native subform field and context. */
26
+ export declare function compareSubformCustomField(actionId: string, fields: readonly ResolvedCustomField[], name: string, desired: unknown, observed: unknown): boolean | undefined;
27
+ export {};
28
+ //# sourceMappingURL=custom-fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-fields.d.ts","sourceRoot":"","sources":["../../src/application/custom-fields.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAGrF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,UAAU,iBAAiB;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAmBD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,iBAAiB,GAAG;IAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;CAAE,CAAC,GAAG,SAAS,CAGvH;AAED,6FAA6F;AAC7F,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG;IAClE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,GAAG,SAAS,CA6BZ;AAED,sFAAsF;AACtF,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,kBAAkB,GACtB,OAAO,CAAC,SAAS,mBAAmB,EAAE,CAAC,CA2DzC;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACvC,MAAM,EAAE,SAAS,mBAAmB,EAAE,GACrC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAWnC;AAED,gFAAgF;AAChF,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,mBAAmB,EAAE,EACtC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,OAAO,GAChB,OAAO,GAAG,SAAS,CASrB"}
@@ -0,0 +1,169 @@
1
+ import { getJoomlaReadAction, resolveJoomlaReadRequest, validateJoomlaMutationJson } from '../catalog/action-catalog.js';
2
+ import { crudWriteFields } from '../catalog/crud-write-fields.js';
3
+ import { equalSubformJson } from '../contracts/subform-json.js';
4
+ // Only contexts whose native Joomla API form/save path has been reviewed.
5
+ const targets = Object.freeze([
6
+ { base: 'content.articles', context: 'com_content.article', listAction: 'fields.content-articles.list', nested: false },
7
+ { base: 'content.categories', context: 'com_content.categories', listAction: 'fields.content-categories.list', nested: true },
8
+ { base: 'contacts.contacts', context: 'com_contact.contact', listAction: 'fields.contact.list', nested: false },
9
+ { base: 'users.users', context: 'com_users.user', listAction: 'fields.users.list', nested: false },
10
+ ]);
11
+ const reserved = new Set([
12
+ '__proto__', 'prototype', 'constructor', 'com_fields', 'id', 'asset_id', 'extension',
13
+ 'client_id', 'component', 'option', 'task', 'view', 'layout', 'format', 'controller',
14
+ 'model', 'method', 'path', 'url', 'token', 'jform', 'rules', 'created', 'created_by',
15
+ 'modified', 'modified_by', 'checked_out', 'checked_out_time', 'version', 'hits',
16
+ 'registerDate', 'lastvisitDate', 'activation', 'lastResetTime', 'resetCount', 'otpKey', 'otep', 'authProvider',
17
+ 'dryRun', '_edgeConfirmed', 'action', 'transport', 'etag', 'idempotencyKey',
18
+ ]);
19
+ export function customFieldTarget(actionId) {
20
+ const target = targets.find((candidate) => actionId === `${candidate.base}.create` || actionId === `${candidate.base}.update`);
21
+ return target === undefined ? undefined : { ...target, readToolset: getJoomlaReadAction(target.listAction).toolset };
22
+ }
23
+ /** Retains dynamic input for site-backed validation; never broadens the static catalogue. */
24
+ export function customFieldInput(actionId, value) {
25
+ const target = customFieldTarget(actionId);
26
+ if (target === undefined)
27
+ return undefined;
28
+ validateJoomlaMutationJson(value);
29
+ const data = structuredClone(value);
30
+ const core = new Set(crudWriteFields(target.base));
31
+ const alias = data['com_fields'];
32
+ if (Object.hasOwn(data, 'com_fields')) {
33
+ if (!isRecord(alias) || Object.keys(alias).length === 0) {
34
+ throw new Error('com_fields must be a non-empty object mapping published field names to values.');
35
+ }
36
+ for (const [name, fieldValue] of Object.entries(alias)) {
37
+ assertNonNumericName(name);
38
+ if (!safeName(name, core))
39
+ throw new Error(`Unsafe or reserved custom field name: ${name}.`);
40
+ if (Object.hasOwn(data, name))
41
+ throw new Error(`Custom field ${name} is supplied both at the top level and in com_fields.`);
42
+ data[name] = fieldValue;
43
+ }
44
+ delete data['com_fields'];
45
+ }
46
+ const names = Object.keys(data).filter((name) => !core.has(name)).sort();
47
+ for (const name of names) {
48
+ assertNonNumericName(name);
49
+ if (!safeName(name, core))
50
+ throw new Error(`Unsafe or reserved custom field name: ${name}.`);
51
+ if (data[name] === null) {
52
+ throw new Error(`Custom field ${name} cannot be null; use the field's supported empty string or array to clear it.`);
53
+ }
54
+ }
55
+ validateJoomlaMutationJson(data);
56
+ return { data, names };
57
+ }
58
+ /** Uses fixed catalogue routes and numeric offsets, never a response-provided URL. */
59
+ export async function resolvePublishedCustomFields(actionId, apiConfig, api) {
60
+ const target = customFieldTarget(actionId);
61
+ if (target === undefined)
62
+ return [];
63
+ const core = new Set(crudWriteFields(target.base));
64
+ const found = new Map();
65
+ const seenIds = new Set();
66
+ const limit = Math.min(100, apiConfig.maxPageSize);
67
+ let offset = 0;
68
+ for (let page = 0; page < 100; page += 1) {
69
+ const request = resolveJoomlaReadRequest(target.listAction, { offset, limit }, apiConfig.maxPageSize);
70
+ const response = await api.get(apiConfig, request.path, request.query);
71
+ if (!isRecord(response.data) || !Array.isArray(response.data['data'])) {
72
+ throw new Error('Joomla custom field discovery returned an invalid collection.');
73
+ }
74
+ const rows = response.data['data'];
75
+ if (rows.length > limit || offset + rows.length > 1_000)
76
+ throw new Error('Joomla custom field discovery exceeded its 1000-field collection limit.');
77
+ for (const row of rows) {
78
+ if (!isRecord(row) || !isRecord(row['attributes']) || !/^[1-9][0-9]*$/.test(String(row['id']))) {
79
+ throw new Error('Joomla custom field discovery returned invalid field metadata.');
80
+ }
81
+ const id = String(row['id']);
82
+ if (seenIds.has(id))
83
+ throw new Error('Joomla custom field discovery repeated a field; pagination is not stable.');
84
+ seenIds.add(id);
85
+ const field = row['attributes'];
86
+ if (field['context'] !== target.context || (field['state'] !== 1 && field['state'] !== '1'))
87
+ continue;
88
+ const groupId = field['group_id'];
89
+ if ((typeof groupId !== 'number' && typeof groupId !== 'string') || !/^[0-9]+$/.test(String(groupId)))
90
+ continue;
91
+ if (Number(groupId) !== 0 && field['group_state'] !== 1 && field['group_state'] !== '1')
92
+ continue;
93
+ // Joomla's stock field API omits only_use_in_subform. Honour it when an
94
+ // implementation supplies it; Joomla remains responsible for applicability.
95
+ if (field['only_use_in_subform'] === true || Number(field['only_use_in_subform']) === 1)
96
+ continue;
97
+ const name = field['name'];
98
+ const type = field['type'];
99
+ if (!target.nested && typeof name === 'string' && (core.has(name) || reserved.has(name))) {
100
+ throw new Error(`Published custom field ${name} collides with a core Joomla form field; rename the custom field before planning this write.`);
101
+ }
102
+ if (typeof name !== 'string' || !safeName(name, core))
103
+ continue;
104
+ if (typeof type !== 'string' || !/^[a-zA-Z0-9_-]{1,100}$/.test(type))
105
+ throw new Error('Joomla custom field discovery returned an invalid field type.');
106
+ if (found.has(name))
107
+ throw new Error(`Joomla custom field discovery returned duplicate field name: ${name}.`);
108
+ found.set(name, Object.freeze({ name, type, context: target.context }));
109
+ }
110
+ const links = response.data['links'];
111
+ const hasNext = isRecord(links) && links['next'] !== undefined && links['next'] !== null && links['next'] !== '';
112
+ const meta = response.data['meta'];
113
+ const totalPages = isRecord(meta) ? meta['total-pages'] : undefined;
114
+ if (totalPages !== undefined && (!Number.isSafeInteger(totalPages) || totalPages < 0 || totalPages > 100)) {
115
+ throw new Error('Joomla custom field discovery returned an invalid page count.');
116
+ }
117
+ const morePages = typeof totalPages === 'number' && page + 1 < totalPages;
118
+ if (rows.length === 0) {
119
+ if (hasNext || morePages)
120
+ throw new Error('Joomla custom field discovery returned an empty unfinished page.');
121
+ return Object.freeze([...found.values()].sort((a, b) => a.name.localeCompare(b.name)));
122
+ }
123
+ offset += rows.length;
124
+ if (!hasNext && !morePages && (rows.length < limit || typeof totalPages === 'number')) {
125
+ return Object.freeze([...found.values()].sort((a, b) => a.name.localeCompare(b.name)));
126
+ }
127
+ }
128
+ throw new Error('Joomla custom field discovery exceeded its 100-page limit.');
129
+ }
130
+ export function encodeCustomFieldBody(actionId, body, fields) {
131
+ if (customFieldTarget(actionId)?.nested !== true || fields.length === 0)
132
+ return body;
133
+ const result = { ...body };
134
+ const values = {};
135
+ for (const field of fields) {
136
+ values[field.name] = result[field.name];
137
+ delete result[field.name];
138
+ }
139
+ result['com_fields'] = values;
140
+ validateJoomlaMutationJson(result);
141
+ return result;
142
+ }
143
+ /** Apply JSON meaning only to the approved native subform field and context. */
144
+ export function compareSubformCustomField(actionId, fields, name, desired, observed) {
145
+ const target = customFieldTarget(actionId);
146
+ if (target === undefined)
147
+ return undefined;
148
+ const definitions = fields.filter((field) => field.name === name);
149
+ if (definitions.length === 0)
150
+ return undefined;
151
+ if (definitions.length !== 1)
152
+ return false;
153
+ const field = definitions[0];
154
+ if (field.type !== 'subform' || field.context !== target.context)
155
+ return undefined;
156
+ return equalSubformJson(desired, observed);
157
+ }
158
+ function safeName(name, core) {
159
+ return /^[\p{L}\p{N}\p{M}_-]{1,255}$/u.test(name) && !/^[0-9]+$/.test(name) && !reserved.has(name) && !core.has(name);
160
+ }
161
+ function assertNonNumericName(name) {
162
+ if (/^[0-9]+$/.test(name)) {
163
+ throw new Error(`Purely numeric custom field names are not supported: ${name}. Rename the field to include a letter, hyphen or underscore.`);
164
+ }
165
+ }
166
+ function isRecord(value) {
167
+ return typeof value === 'object' && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
168
+ }
169
+ //# sourceMappingURL=custom-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-fields.js","sourceRoot":"","sources":["../../src/application/custom-fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AACzH,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC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,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACxH,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAY;IACxC,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,wDAAwD,IAAI,+DAA+D,CAAC,CAAC;IAC/I,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,SAAS,CAAC;AACnI,CAAC"}
@@ -54,7 +54,7 @@ export declare class JoomlaService {
54
54
  readonly includeSensitive?: boolean | undefined;
55
55
  readonly includeWrites?: boolean | undefined;
56
56
  }): Promise<Record<string, unknown>>;
57
- describeAction(actionId: string, siteId?: string): Promise<Record<string, unknown>>;
57
+ describeAction(actionId: string, siteId?: string, authorizeRead?: (site: string, toolset: string) => void): Promise<Record<string, unknown>>;
58
58
  executeReadAction(input: {
59
59
  readonly site?: string | undefined;
60
60
  readonly action: string;
@@ -1 +1 @@
1
- {"version":3,"file":"joomla-service.d.ts","sourceRoot":"","sources":["../../src/application/joomla-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AACjG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAuBxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MA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import { sourceOnlyGateReason } from '../catalog/action-gates.js';
6
6
  import { JoomlaApiClient, } from '../infrastructure/api/joomla-api-client.js';
7
7
  import { JoomlaCliClient } from '../infrastructure/cli/joomla-cli-client.js';
8
8
  import { SiteRegistry } from './site-registry.js';
9
+ import { customFieldTarget, resolvePublishedCustomFields } from './custom-fields.js';
9
10
  export const companionReadToolsets = Object.freeze(Object.fromEntries(companionReadActions.map((action) => [action.id, action.toolset])));
10
11
  const crudReadActionIds = new Set(joomlaCrudReadActions.map((action) => action.id));
11
12
  const crudWriteActionIds = new Set(joomlaCrudWriteActions.map((action) => action.id));
@@ -199,7 +200,7 @@ export class JoomlaService {
199
200
  companionCapability: companionCapability.status,
200
201
  };
201
202
  }
202
- async describeAction(actionId, siteId) {
203
+ async describeAction(actionId, siteId, authorizeRead) {
203
204
  const apiAction = getJoomlaAction(actionId);
204
205
  const companionAction = getCompanionReadAction(actionId) ?? getCompanionWriteAction(actionId);
205
206
  if (apiAction === undefined && companionAction === undefined) {
@@ -216,10 +217,60 @@ export class JoomlaService {
216
217
  ?? (availableTransports.length === 0
217
218
  ? 'The selected site does not configure a transport that implements this action.'
218
219
  : null);
220
+ const target = customFieldTarget(actionId);
221
+ let describedAction = apiAction;
222
+ let customFields;
223
+ if (target !== undefined && apiAction !== undefined) {
224
+ let permitted = site.api !== undefined && site.toolsets.has(target.readToolset);
225
+ if (permitted && authorizeRead !== undefined) {
226
+ try {
227
+ authorizeRead(site.id, target.readToolset);
228
+ }
229
+ catch {
230
+ permitted = false;
231
+ }
232
+ }
233
+ const fields = permitted ? await resolvePublishedCustomFields(actionId, site.api, this.api) : [];
234
+ customFields = {
235
+ status: permitted ? 'resolved' : 'unavailable',
236
+ context: target.context,
237
+ transport: 'api',
238
+ readToolset: target.readToolset,
239
+ fields,
240
+ ...(permitted ? {} : { reason: `Custom field discovery requires the Joomla API adapter and ${target.readToolset} permission.` }),
241
+ };
242
+ if (permitted) {
243
+ const dataSchema = apiAction.inputSchema.properties['data'];
244
+ const customProperties = Object.fromEntries(fields.map((field) => [field.name, {
245
+ description: `Published Joomla ${field.type} custom field; Joomla validates its value. Null is not supported.`,
246
+ 'x-joomla-field-type': field.type,
247
+ 'x-joomla-field-context': field.context,
248
+ not: { type: 'null' },
249
+ }]));
250
+ describedAction = {
251
+ ...apiAction,
252
+ inputSchema: {
253
+ ...apiAction.inputSchema,
254
+ properties: {
255
+ ...apiAction.inputSchema.properties,
256
+ data: {
257
+ ...dataSchema,
258
+ properties: {
259
+ ...dataSchema['properties'],
260
+ ...customProperties,
261
+ com_fields: { type: 'object', properties: customProperties, additionalProperties: false, maxProperties: 512,
262
+ description: 'Alias for published custom fields; do not also supply the same name at the top level.' },
263
+ },
264
+ },
265
+ },
266
+ },
267
+ };
268
+ }
269
+ }
219
270
  return {
220
271
  site: site.id,
221
272
  action: {
222
- ...(apiAction ?? {}),
273
+ ...(describedAction ?? {}),
223
274
  ...(companionAction === undefined ? {} : { companionNative: companionAction.native }),
224
275
  },
225
276
  availability: {
@@ -229,6 +280,7 @@ export class JoomlaService {
229
280
  companionCapability: companionCapability.status,
230
281
  },
231
282
  coverage: actionCoverage(actionId),
283
+ ...(customFields === undefined ? {} : { customFields }),
232
284
  };
233
285
  }
234
286
  async executeReadAction(input) {