Introduction
🎯 What does this module do?
The GeneralTypes module lets you retrieve system-wide entity types - page types, form types, product block types, and more - that define the structure and categories of your content in OneEntry.
Think of it as your content classification system - OneEntry uses types to organize different kinds of pages (homepage, blog post, product page), forms (contact, survey), blocks (hero, gallery), and products (physical, digital), and this module lets you fetch all available types to build dynamic interfaces.
📖 Simple Explanation
In OneEntry, every entity has a type that determines its purpose and structure:
- Page Types:
homepage,blog_post,product_page,landing_page - Form Types:
contact_form,survey,registration,feedback - Product Block Types:
hero_section,image_gallery,text_block,video_embed - Product Types:
physical_product,digital_product,service,subscription
The GeneralTypes module provides the complete list of all types configured in your OneEntry project, so you can:
✅ Build dynamic dropdowns - Let admins choose page type when creating content ✅ Filter content - Show only "blog_post" pages or "contact_form" forms ✅ Validate data - Check if a type exists before creating an entity ✅ Create type-based logic - Display different UI based on page type
Real-world example:
Your blog app fetches all page types:
- "homepage" → Renders featured posts slider
- "blog_post" → Renders article layout with comments
- "about_page" → Renders team member cards
- "contact_page" → Renders contact form
✨ Key Concepts
Type System Hierarchy
OneEntry organizes content using a type system where every entity belongs to a category:
| Entity | Example Types | Purpose |
|---|---|---|
| Pages | homepage, blog_post, product_page, landing_page | Define page layouts and functionality |
| Forms | contact_form, survey, registration, feedback | Categorize different form purposes |
| Product Blocks | hero_section, gallery, text_block, video_embed | Building blocks for product pages |
| Products | physical_product, digital_product, service, subscription | Classify product inventory |
Type Entity Structure
Each type returned by GeneralTypes.getAllTypes() has this structure:
interface GeneralTypeEntity {
id: number; // Unique numeric ID (e.g., 1, 2, 3)
type: string; // Type name (e.g., "blog_post", "contact_form")
}
When to Use GeneralTypes
| Use Case | Why GeneralTypes? |
|---|---|
| Building CMS admin interface | Populate dropdowns with available types |
| Creating type filters | Let users filter content by type (blog posts vs. landing pages) |
| Validating entity creation | Check if a type exists before creating a page/form |
| Dynamic routing | Route different page types to different components |
| Type-based permissions | Allow different roles to access different content types |
📋 What You Need to Know
1. Types are configured in OneEntry Admin Panel
You don't create types via the SDK - types are defined in your OneEntry admin panel when you configure your project. The GeneralTypes module only retrieves the list of existing types.
How types are created:
OneEntry Admin Panel → Settings → Content Types → Add Page Type → "blog_post"
Once created, you can fetch them
2. Types vs. Markers vs. IDs
Important distinction:
| Identifier | What It Is | Example | Best For |
|---|---|---|---|
| Type | Category/classification of entity | "blog_post" | Filtering and grouping |
| Marker | Unique human-readable identifier | "my_about_page" | Fetching specific entities |
| ID | Numeric database identifier | 42 | Internal system use |
3. getAllTypes() returns ALL types across all entities
The method returns a combined list of types from:
- Pages
- Forms
- Product Blocks
- Products
- Any other entities in your OneEntry project
There's no built-in filtering by entity category, so you'll need to filter manually:
4. Types are case-sensitive
Always use exact case matching when working with types
5. Use types for dynamic content rendering
Types enable polymorphic content - different rendering logic based on type:
📊 Quick Reference Table
| Method | Description | Returns | Use Case |
|---|---|---|---|
getAllTypes() | Retrieves all general types in the system | Promise<GeneralTypeEntity[]> | Populate dropdowns, validate types |
GeneralTypeEntity Structure:
{
id: number; // Unique numeric ID
type: string; // Type name (e.g., "blog_post")
}
❓ Frequently Asked Questions (FAQ)
1. How do I create new types?
You cannot create types via the SDK. Types are created in the OneEntry Admin Panel:
1. Log in to OneEntry Admin Panel
2. Go to Settings → Content Types
3. Click "Add Page Type" (or Form Type, Product Type, etc.)
4. Enter type name: "blog_post"
5. Save
Now fetch it via SDK:
const types = await GeneralTypes.getAllTypes();
// Returns: [{ id: 1, type: "blog_post" }, ...]
2. How do I filter types by entity (pages, forms, products)?
The getAllTypes() method returns all types across all entities. You need to filter manually
3. Can I update or delete types via the SDK?
No. The GeneralTypes module is read-only. All type management happens in the OneEntry Admin Panel.
4. What's the difference between type ID and type name?
When to use each:
| Field | Use For | Example |
|---|---|---|
id | Internal system references | Database relations |
type | Your code logic and comparisons | if (page.type === 'blog_post') |
Best practice: Always use type string in your code, not id number (IDs can change between environments).
5. Can I cache the types list?
Yes! Types rarely change, so caching is recommended
7. How do I use types with TypeScript?
OneEntry SDK exports the GeneralTypeEntity interface that you can use to type your types.
8. How do I handle missing types gracefully?
Always validate that a type exists before using it
10. Can I use types for authorization/permissions?
Yes! You can implement type-based access Control
💡 Important Notes
⚠️ Types are Project-Specific
Types are configured in your OneEntry admin panel and vary between projects. There are no universal "default" types - always fetch the list dynamically:
// ❌ Don't hardcode types
const pageTypes = ['homepage', 'blog_post', 'product_page'];
// ✅ Fetch types dynamically
const allTypes = await GeneralTypes.getAllTypes();
const pageTypes = allTypes.filter(t => t.type.endsWith('_page'));
🔒 Read-Only Module
The GeneralTypes module only reads types. All type creation, modification, and deletion happens in the OneEntry Admin Panel.
🎓 Best Practices
✅ DO:
-
Fetch types dynamically - Don't hardcode type lists
const types = await GeneralTypes.getAllTypes(); -
Cache types - They rarely change, cache for performance
const cached = localStorage.getItem('types');
if (cached) return JSON.parse(cached); -
Use type strings, not IDs - Type names are stable across environments
if (page.type === 'blog_post') { /* ... */ } -
Validate types exist - Check if a type is valid before using
const exists = allTypes.some(t => t.type === 'blog_post'); -
Use naming conventions - Consistent naming makes filtering easier
const pageTypes = types.filter(t => t.type.endsWith('_page')); -
Implement fallback rendering - Handle unknown types gracefully
const Component = TYPE_MAP[page.type] || DefaultComponent; -
Document your types - Maintain a list of types and their purposes
// Types:
// - homepage: Main landing page
// - blog_post: Blog article
// - product_page: Product detail page -
Use TypeScript for type safety - Leverage
GeneralTypeEntityinterfaceconst types: GeneralTypeEntity[] = await GeneralTypes.getAllTypes();
❌ DON'T:
- Don't hardcode type IDs - IDs can change between environments
- Don't assume types exist - Always validate first
- Don't fetch types on every render - Implement caching
- Don't use case-insensitive comparisons - Types are case-sensitive
- Don't mix type and marker - They're different identifiers
- Don't create UI-specific types - Types should represent content structure
- Don't ignore type errors in production - Log and handle unknown types
- Don't filter types on frontend only - Use types for backend logic too
Definition of the GeneralTypes module
The GeneralTypes module in OneEntry Platform is designed to manage and retrieve general types used within the system. By using the defineOneEntry function, you can create a GeneralTypes object to interact with these types.
The primary method available is getAllTypes, which retrieves all objects of type GeneralTypeEntity from the API.
This method returns a Promise that resolves to an array of GeneralTypeEntity objects, each containing an id and a type.
The types cover various purposes, such as page layouts, forms, product blocks, and more, providing flexibility for different content management needs.
const { GeneralTypes } = defineOneEntry( "your-project-url", { "token": "your-app-token" });