Skip to main content

Introduction

Fetch the system-wide entity types that classify your pages, forms, blocks, and products.

More information about the module's user interface: https://doc.oneentry.cloud/docs/attributes/types/#General-Type-Attributes


🎯 What does this module do?

The GeneralTypes module lets you retrieve system-wide entity types - page types, form types, block types, and product types - that define the categories of content in your OneEntry project. OneEntry uses a fixed set of system types (BlockType) to classify pages (common_page, catalog_page, external_page, error_page), forms (form), blocks (common_block, product_block, slider_block, …), and products (product, service). This module is read-only.

🚀 Quickstart

Initialize the module from defineOneEntry:


const { GeneralTypes } = defineOneEntry(
"your-project-url", {
"token": "your-app-token"
}
);

Fetch all types and use them:

// Returns a combined list of types across all entities.
const types = await GeneralTypes.getAllTypes();
// e.g. [{ id: 1, type: "product" }, { id: 2, type: "common_page" }, ...]

// Filter manually - there is no built-in per-entity filter.
const pageTypes = types.filter((t) => t.type.endsWith("_page"));

console.log(pageTypes);

✨ Key Concepts

Type System

OneEntry classifies every entity by a BlockType value:

EntityExample Types (BlockType)Purpose
Pagescommon_page, catalog_page, external_page, error_pageDefine page layouts and functionality
FormsformCategorize form purposes
Blockscommon_block, product_block, slider_blockBuilding blocks for pages/products
Productsproduct, serviceClassify product inventory

Type Entity Structure

Each type returned by getAllTypes() is a GeneralTypeEntity:

interface GeneralTypeEntity {
id: number; // Unique numeric ID (e.g. 1, 2, 3)
type: BlockType; // Type name (e.g. "product", "common_page", "form")
}

📋 What You Need to Know

Types are predefined system categories

You don't create types via the SDK - they are a fixed set of system categories (BlockType) defined by the platform. GeneralTypes only retrieves the list of types present in your project. All type management happens in the OneEntry admin panel.

getAllTypes() returns ALL types across all entities

The method returns a combined list of types from pages, forms, blocks, products, and any other entities. There is no built-in filtering by entity category, so filter the result manually (for example, t.type.endsWith('_page')).

Type vs. Marker vs. ID

IdentifierWhat It IsExampleBest For
TypeCategory/classification of entity"catalog_page"Filtering and grouping
MarkerUnique human-readable identifier"my_about_page"Fetching specific entities
IDNumeric database identifier42Internal system use

Use the type string in your code logic (e.g. if (page.type === 'catalog_page')) - it is stable across environments, whereas id can differ.


📊 Quick Reference Table

MethodDescriptionUse Case
getAllTypes()Retrieves all general types in the systemPopulate dropdowns, validate types

❓ Common Questions (FAQ)

How do I create new types?

You cannot - types are a fixed set of system categories (BlockType) and the module is read-only. Fetch the ones available in your project with getAllTypes().


How do I filter types by entity (pages, forms, products)?

getAllTypes() returns all types across all entities. Filter the result manually, for example types.filter(t => t.type.endsWith('_page')).


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.


What's the difference between type ID and type name?

Use the type string for your code logic and comparisons (stable across environments). The id number is for internal database references and can change between projects.


Can I cache the types list?

Yes - types rarely change, so caching is recommended.


🎓 Best Practices

  • Fetch types dynamically - don't hardcode type lists.
  • Use the type string, not the id - type names are stable across environments.
  • Filter manually - getAllTypes() returns every entity's types in one list.
  • Cache the list - it rarely changes.
  • Handle unknown types gracefully - provide fallback rendering.