Skip to main content
Version: v1 (Current)

Collection API Integration Through the Runtime

Use the supplied GxP store and a declared collection dependency to preserve installed page/principal context. This page provides a small adapter boundary, not a separate HTTP client or a credential-management service. For full request examples see the Collections plugin guide.

Prepare the installed context​

  1. Select actual operation IDs and payload schemas from the deployed REST API catalog. The runtime first tries the supplied ID, then the portal.v1.project. prefix; unknown operations fail.
  2. Declare the corresponding supported model actions in the intended App version. Use a dependency identifier that matches the configuration selector and verify its saved installation binding.
  3. Bind the intended collection in the selected project. Collection routes use the collection slug; child entry IDs and asset references must also belong to the permitted parent/project.
  4. Mount inside the runtime Vue/store context and confirm project/page/principal initialization before requesting data. A local mock result is not installed authorization acceptance.

See Build and Bind Collections for setup, and Permissions and Dependencies for action, object, parent and field scopes. The visual builder has limits when preserving advanced dependency metadata; inspect the persisted version and binding rather than assuming a selector label establishes scope.

Minimal adapter​

The example below rejects absent initialization and accidental overrides of its bound parent/project. It leaves operation lookup, request transport and response envelopes to the supplied store:

Use the standard App scaffold’s @/stores/gxpPortalConfigStore import so the production bundle uses the installed host store. The reviewed AI scaffold’s @gx-runtime variant can bundle a separate local store; do not substitute it.

import { useGxpStore } from '@/stores/gxpPortalConfigStore'
const store = useGxpStore()

async function callBoundCollection(operationId, dependencyIdentifier, data = {}) {
const project = String(store.pluginVars?.projectId || '').split('/')
if (project.length !== 2 || project.some((part) => !part.trim())) {
throw new Error('Collection API requires initialized team/project context')
}
if (typeof operationId !== 'string' || !operationId.trim()) {
throw new Error('Collection API requires a catalog operation ID')
}
if (typeof dependencyIdentifier !== 'string' || !dependencyIdentifier.trim()) {
throw new Error('Collection API requires a dependency identifier')
}
const binding = store.dependencyList?.[dependencyIdentifier]
if (binding === undefined || binding === null || binding === '') {
throw new Error('Collection API requires an installed collection binding')
}
for (const key of ['teamSlug', 'projectSlug', 'collection', dependencyIdentifier]) {
const present = typeof FormData !== 'undefined' && data instanceof FormData
? data.has(key)
: Object.prototype.hasOwnProperty.call(data ?? {}, key)
if (present) throw new Error(`Collection API rejects parent override: ${key}`)
}
return await store.callApi(operationId, dependencyIdentifier, data)
}

This is an App-local convenience guard for the current collection path names. It does not validate every operation, binding shape, child ID or caller permission. Restrict which catalog operations the feature invokes, and adapt the parent checks explicitly if a future catalog changes parameter names. A caller can bypass a JavaScript wrapper; model/page/audience authorization must remain on the server.

Pass entry IDs using the selected operation's child parameter and entry values in its nested data body. The binding supplies the collection parent; do not replace it with an unrelated caller-provided collection. A metadata/tag-only binding is not necessarily a scalar path value. Verify what the operation requires and do not infer that declaring a dependency makes every route parameter resolvable.

Runtime resolution and results​

The inspected callApi implementation:

  • Initializes operation metadata, selects the operation, and derives team/project context from pluginVars.projectId.
  • Resolves the dependency value to a matching path parameter or the catalog's parent parameter; array bindings extract model IDs rather than treating tag tokens as IDs.
  • Merges additional data into context, so direct store calls can override resolved parameters. The example guard prevents selected accidental overrides, not hostile access.
  • Encodes required path values and fails when they remain missing. Without the wrapper, malformed project context can return [] before a request; do not interpret that as an empty collection.
  • Removes path parameters from the transmitted data and returns the HTTP response body. Resource/list envelopes still need the selected operation's parsing.

Inspect returned resource IDs, pagination and meta.population_truncated where applicable. Keep raw IDs and saved state available for reconciliation. Definition metadata, expanded relationships and signed asset URLs have different lifetimes and authorization concerns.

Writes, files and failures​

Use the catalog's declared method. The platform store has no shared apiPatch; toolkit extras and direct POST method override are not universal compatibility guarantees.

Current callApi detects explicit FormData or top-level Blob/File values for multipart transport. Explicit FormData preserves an original filename and uses the runtime's auth/page headers; do not set the browser boundary manually. The initial request does not automatically perform returned signed PUTs or wait for finalization, variants or provider output. Follow the upload lifecycle for that endpoint.

The current network error wrapper preserves a numeric HTTP status when available, but not the complete field-validation map. Setup/path failures may have no HTTP status. Retain entered values and use a recoverable message; detailed field errors require an implemented, tested adapter within the authenticated host/runtime contract. There is no submitJson() or submitMultipart() helper supplied by this page.

Configured offline service-worker strategies can intercept operations, use cached data or queue writes; a worker communication failure falls through to the network path. A returned body alone does not certify fresh server state or a replayed write's final persistence. Test the strategy enabled for the selected operation, including reconnection and failure recovery.

Never blindly retry a lost create/batch response. Read back authoritative IDs/state first: collection batches have no enabled Orion outer transaction in the reviewed configuration, so earlier items can persist before a later failure. See the batch contract.

Verify the adapter​

Test successful and rejected operations, uninitialized context, missing/tag-only bindings, parent overrides, absent/foreign child IDs, excluded projects/audiences, response envelopes, schema validation, files and interrupted writes. Use the deployed catalog and selected principal, not a copied project credential in browser code.

The repository retains executable checks for this canonical wrapper and selected actual runtime resolution paths using synthetic metadata and mocked transport. Those checks establish local guard/resolution behavior, not deployed credentials, policy isolation, offline replay, actual multipart transfer or provider acceptance. Source/reader evidence is recorded in docs/collections-runtime-adapter-review-2026-10-15.md and its coverage snapshot.