@questlabs/greta-strapi-plugin
v0.1.0
Published
Sync published Strapi content with Greta and receive safe draft content.
Readme
Greta Strapi Connector
@questlabs/greta-strapi-plugin connects a Strapi 5 server to Greta's CMS connector API.
It syncs only content types and fields that you explicitly map, and can create
Greta-generated content as an unpublished Strapi draft. It never publishes or
updates an existing entry.
Requirements
- Strapi 5.x with Node.js 20 or newer.
- A Greta project connection created for platform
strapi. - Enable that connection in Greta before the plugin can sync. Keep the one-time connector key on the Strapi server; do not put it in browser code.
Install
npm install @questlabs/greta-strapi-pluginAdd the plugin configuration to config/plugins.ts (or config/plugins.js):
export default ({ env }) => ({
greta: {
enabled: env.bool("GRETA_CMS_ENABLED", false),
config: {
enabled: env.bool("GRETA_CMS_ENABLED", false),
apiUrl: env("GRETA_CMS_API_URL", "https://app.greta.sh/api/greta/cms"),
apiKey: env("GRETA_CMS_API_KEY", ""),
syncIntervalMs: env.int("GRETA_CMS_SYNC_INTERVAL_MS", 3600000),
// Explicit allowlist: don't sync fields you have not reviewed.
contentTypes: env.json("GRETA_STRAPI_CONTENT_TYPES", [
{
uid: "api::article.article",
contentType: "article",
titleField: "title",
slugField: "slug",
bodyField: "body",
excerptField: "excerpt",
pathPrefix: "/blog",
},
]),
siteUrl: env("GRETA_CMS_SITE_URL", ""),
drafts: {
enabled: env.bool("GRETA_STRAPI_IMPORT_DRAFTS", false),
contentTypeUid: "api::article.article",
titleField: "title",
bodyField: "body",
slugField: "slug",
pathPrefix: "/blog",
},
},
},
});Set the key and settings in the Strapi server's secret environment, not in the admin frontend:
GRETA_CMS_ENABLED=true
GRETA_CMS_API_KEY=grc_sk_... # generated once by Greta for this Strapi site
GRETA_CMS_API_URL=https://app.greta.sh/api/greta/cms
GRETA_CMS_SITE_URL=https://www.example.com
GRETA_CMS_SYNC_INTERVAL_MS=3600000
GRETA_STRAPI_IMPORT_DRAFTS=falseRestart Strapi after changing plugin config. The connector checks its Greta
connection on startup and on the configured interval. It sends only the mapped
content fields and only entries queried with Strapi's status: "published".
Drafts
Draft import is opt-in. Enable GRETA_STRAPI_IMPORT_DRAFTS, grant this key the
draft:pull and draft:ack scopes, and configure a destination collection with
Draft & Publish enabled. Greta items are created with status: "draft"; a
stable generated slug makes retries idempotent. The plugin acknowledges the
draft to Greta only after Strapi confirms it exists. Failed drafts remain
visible for a manual retry in Greta.
Safety
- The connector is disabled by default.
- It requires HTTPS except for localhost development.
- It stores no Greta key in Strapi content or browser code.
- It ignores all content types not explicitly mapped.
- It never calls Strapi's publish operation.
- Draft import never overwrites an existing Strapi document.
The connection, content-sync, and draft-delivery endpoints are provided by Greta's CMS connector service.
