
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
microcms_sdk_generator
Advanced tools
microcms_sdk_generator
is a Deno tool designed to automatically generate
TypeScript SDKs from your microCMS API schema. The tool
leverages Zod schemas to ensure TypeScript type safety.
Installation and usage are easily handled via npm or Deno.
Execute the following command for installation using Deno.
deno install --allow-read --allow-write https://deno.land/x/microcms_sdk_generator/microcms_sdk_generator.ts
Or execute directly.
deno run --allow-read --allow-write https://deno.land/x/microcms_sdk_generator/microcms_sdk_generator.ts
Execute the following command for installation using npm.
npm install --global microcms_sdk_generator
Or execute directly.
npx microcms_sdk_generator
To use the tool, specify the directory of the schema files and the destination TypeScript file.
microcms_sdk_generator <schema directory> <destination typescript file>
For example, execute the following command on the root of this repository.
microcms_sdk_generator ./src/testdata/schemas ./src/testdata/generated.ts
Initialize the client with your service domain and API key.
const client = createClient({
serviceDomain: "YOUR_SERVICE_DOMAIN",
apiKey: "YOUR_API_KEY",
});
Use the client to make requests as follows.
const resp = await client[`${endpointName}`].list({...})
const resp = await client[`${endpointName}`].get({...})
const resp = await client[`${endpointName}`].post({...})
const resp = await client[`${endpointName}`].put({...})
const resp = await client[`${endpointName}`].patch({...})
const resp = await client[`${endpointName}`].delete({...})
const resp = await client[`${endpointName}`].listMetadata({...})
const resp = await client[`${endpointName}`].getMetadata({...})
const resp = await client[`${endpointName}`].patchStatus({...})
For example, for the sampleForListApi
endpoint.
const listResp = await client.sampleForListApi.list({
limit: 2,
orders: ["-createdAt"],
});
if (!listResp.ok) {
throw listResp;
}
console.log(listResp.data.contents);
Schema files need to be placed under the schema directory in the following structure:
NOTE: microCMS currently does not support exporting schemas per endpoint. You
will need to use the exported schema file, but this file does not resolve
endpointName
and API type (list or object)
. Therefore, you should structure
your files as shown above.
We welcome bug reports and feature requests through GitHub issues. Pull requests are also welcome.
This project is open-sourced under the MIT License. See the LICENSE file for details.
You can prepare a fetcher capable of retrying, and specify it as a customFetcher in option.
e.g. vercel/async-retry: Retrying made simple, easy and async
FAQs
A type-safe MicroCMS SDK Generator
The npm package microcms_sdk_generator receives a total of 25 weekly downloads. As such, microcms_sdk_generator popularity was classified as not popular.
We found that microcms_sdk_generator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.