![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@contentrain/generator
Advanced tools
`@contentrain/generator` is a type and schema generator tool for the Contentrain SDK. It generates TypeScript interfaces for your content models and can be used via CLI or programmatically.
@contentrain/generator
is a type and schema generator tool for the Contentrain SDK. It generates TypeScript interfaces for your content models and can be used via CLI or programmatically.
You can install the package via npm:
npm install @contentrain/generator
The CLI tool allows you to generate type definitions for your models.
# Generate types for all models
contentrain-generate
# Generate types with custom configuration
contentrain-generate --models ./content --output ./types
You can use the ContentrainGenerator
class to generate type definitions programmatically.
import { ContentrainGenerator } from '@contentrain/generator';
// Initialize the generator
const generator = new ContentrainGenerator({
modelsDir: './content',
outputDir: './types'
});
// Generate types
await generator.generateTypes();
The ContentrainGenerator
class supports the following configuration options:
interface GeneratorConfig {
// Path to the models directory (default: 'contentrain/models')
modelsDir?: string;
// Output path for generated types (default: 'contentrain/types')
outputDir?: string;
}
Additionally, you can provide configuration via a contentrain-config.json
file in the root directory. This file will be merged with the default configuration.
This tool generates TypeScript interfaces for your content models. Example:
// Base model type that all content models extend
export interface BaseContentrainModel {
ID: string;
createdAt: string;
updatedAt: string;
status: 'draft' | 'changed' | 'publish';
}
// Generated from metadata.json
// {
// "name": "BlogPost",
// "modelId": "blog-posts",
// ...
// }
interface IBlogPost extends BaseContentrainModel {
title: string;
content: string;
author: string;
tags: string[];
}
// Type mapping for model IDs to their respective interfaces
export type ContentrainTypeMap = {
'blog-posts': IBlogPost;
'authors': IAuthor;
}
The CLI tool supports the following options:
Options:
--models Path to the models directory [string] [default: "contentrain/models"]
--output Output path for types [string] [default: "contentrain/types"]
--help Show help [boolean]
--version Show version number [boolean]
MIT
FAQs
`@contentrain/generator` is a type and schema generator tool for the Contentrain SDK. It generates TypeScript interfaces for your content models and can be used via CLI or programmatically.
The npm package @contentrain/generator receives a total of 0 weekly downloads. As such, @contentrain/generator popularity was classified as not popular.
We found that @contentrain/generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.