
Description
Use when integrating rstore with Monospace REST and OpenAPI helpers, generated Monospace collections, Monospace REST query options, primary key overrides, createMonospaceRestClient, createMonospaceRstorePlugin, createMonospaceQuery, and schema generation from remote or local OpenAPI documents; also use before writing custom Monospace REST CRUD around rstore collections.
SKILL.md
Rstore Monospace
Use @rstore/monospace as the shared Monospace adapter layer for OpenAPI-generated rstore collections and REST-backed runtime CRUD behavior.
Core APIs
| Area | API |
|---|---|
| Runtime client | createMonospaceRestClient({ url, project, apiKey?, fetch? }) |
| Runtime plugin | createMonospaceRstorePlugin({ url?, project?, apiKey?, client?, scopeId? }) |
| Query mapping | createMonospaceQuery(findOptions, overrides?) |
| Query serialization | serializeMonospaceQuery(query) |
| Mutation payloads | stripPrimaryKeys(item, primaryKeys) |
| Collection metadata | DEFAULT_MONOSPACE_SCOPE_ID, getMonospacePrimaryKeys, getMonospaceCollectionName |
| Schema loading | loadMonospaceCollections({ url?, project?, schemaApiKey?, input?, metadataInput?, primaryKeys?, scopeId? }) |
| Schema building | buildMonospaceCollections({ document, metadata, primaryKeys?, scopeId }) |
| Code generation | generateCollectionsTemplate, generateItemsTemplate, generateTypedCollectionsTemplate, generateConfigTemplate, generateViteDeclarations |
Workflow
- Load the Monospace OpenAPI document and the system schema metadata (meta collections read through the items API) from a remote project or local JSON files.
- Generate rstore collections from
x-monospace-mappings,*CollectionOutputschemas, primary indexes, and FK constraints. - Create a runtime REST client with
createMonospaceRestClient. - Register
createMonospaceRstorePluginin the store plugins list. - Query and mutate through rstore collection APIs instead of component-level REST calls.
Schema Loading
- Generation requires both the OpenAPI document and the schema metadata (system meta collections:
MonospaceCollection,MonospacePrimitiveField,MonospaceSingleRelationField,MonospaceSingleConstraintField,MonospaceIndex,MonospaceIndexField). - Remote schema loading requires
urlandproject; metadata queries use explicitfieldsandlimit=0(unlimited). - Fully local loading uses
input(OpenAPI JSON) plusmetadataInput(metadata snapshot keyed by meta collection name) and can skip remote schema credentials. schemaApiKeyis only for build-time schema loading and needs theopenApiSchema:readanddataModel:readentitlements.- Primary keys come from each collection's primary index (ordered, composite supported);
primaryKeysis an override only, and a collection without a primary index and without an override fails generation. - Relations join on the real FK constraint columns (
onmaps target columns to source FK columns).
Runtime REST Behavior
- The runtime client calls endpoints under
/api/{project}/items/{collection}. - Supported item operations include read one, read many, create one, create many, update one, update many, delete one, and delete many.
- Bulk update and delete require a non-empty filter query.
- Primary key fields are stripped from update payloads before REST mutation calls.
- Monospace REST errors are mapped to typed errors such as auth, permission, validation, and not-found errors.
Query Behavior
- Pass Monospace REST query options in rstore find options:
fields,filter,sort,limit,offset, andparams. pageIndexandpageSizemap tooffsetandlimitwhen explicit pagination is not provided.createMonospaceQuerymerges adapterparams, top-level find options, and optional overrides.serializeMonospaceQueryconverts nested query options into URL search parameters.
Guardrails
- Keep
schemaApiKeybuild/server-side; it is for OpenAPI loading. - Treat
runtimeApiKeyorapiKeyas emitted runtime/client code when configured. - Prefer the generated rstore plugin over ad hoc Monospace REST calls for generated collections.
- Use
rstore-vuefor query, live query, form, and cache semantics. - Use
rstore-vite-monospaceorrstore-nuxt-monospacefor framework wiring.
More skills from the rstore repository
View all 8 skillsrstore-directus
integrate rstore with Directus
Jul 12API DevelopmentDatabaseDirectusrstore-nuxt
integrate rstore into Nuxt applications
Jul 12FrontendNuxtVuerstore-nuxt-drizzle
expose Drizzle data in Nuxt applications
Jul 12API DevelopmentDatabaseDrizzleNuxtrstore-nuxt-monospace
integrate Monospace into Nuxt applications
Jul 12API DevelopmentDirectusNuxtVuerstore-vite-directus
integrate Directus into Vite applications
Jul 12API DevelopmentDirectusViteVuerstore-vite-monospace
integrate Monospace into Vite applications
Jul 12API DevelopmentDirectusViteVue