Elements Manual
Elements 2 Manual
Elements 2 Manual
  • Welcome 👋
  • QUICK START
    • Elements in Five Minutes or Less
  • General
    • General Concepts
    • N-Tier Architecture
    • Security Model
  • SCRIPTING ENGINE
    • Scripting Engine Overview
      • Intro to Resources and Cloud Functions
      • Horizontal Scaling Model
      • Database Access
      • Server-to-Server API Calls
      • Deploy Cloud Functions via Git
      • Creating and Destroying Resources
      • Cross-Resource Invocation
      • Indexing Resources
      • Coroutines
      • Manifest
  • Core Features
    • Core API Overview
    • Sessions
    • Applications
      • Facebook Application Configuration
      • Firebase Application Configuration
      • Amazon GameOn Application Configuration
      • iOS Application Configuration
      • Android Application Configuration
      • Matchmaking Application Configuration [deprecated]
    • Users and Profiles
    • Digital Goods
    • Progress and Missions
    • Leaderboards
    • Matchmaking
    • Followers
    • Friends
    • Reward Issuance
    • Push Notifications
    • Auth Schemes
    • Save Data
    • Schemas and Metadata Specifications
    • Queries
      • Base Query Syntax
      • Boolean Queries
      • Object Graph Navigation
      • Advanced Operators
        • .ref
        • .name
  • Web 3
    • Omni Chain Support
    • Vaults
    • Wallets
    • Smart Contracts
      • Smart Contracts: Ethereum
      • Smart Contracts: Flow
      • Smart Contracts: Solana
      • Smart Contracts: Neo
    • Know Your Customer
      • Formidium
  • CONFIGURATION
    • Using the Web Console
    • iOS and Android Product Bundles
    • Direct Database Access and Batch Configuration
  • UNITY PLUG-INS
    • Unity Plugin
    • Content Delivery Management and Unity CDN Plugin
  • DEPLOYMENT
    • Deployment Overview
      • Docker Containers
      • AWS Deployment
      • Standalone docker-compose
  • LUA SAMPLES
    • lua Samples
      • main.lua
      • event.lua
      • hello_world.lua
      • model.lua
      • startup.lua
      • HTTP Manifest
        • Example endpoint handler
        • Example operations table
  • RESTful APIs
    • Swagger and Swagger UI
    • Elements 3.0.X (Preview)
      • Applications
      • Friends and Followers
      • Digital Goods and Inventory
      • Leaderboards
      • Missions and Rewards
      • User and Profiles
      • Save Data
      • Custom Metadata
Powered by GitBook
On this page
  • Model
  • HTTP
  • Startup
  • Events
  • Security
  1. SCRIPTING ENGINE
  2. Scripting Engine Overview

Manifest

Use the Elements Manifest to keep a record of all your endpoint and model definitions, define your security model, and set up handlers for startup and other events in your game or application.

PreviousCoroutinesNextCore API Overview

Last updated 2 years ago

The manifest is a Lua table containing all of the endpoint and model definitions. It is also where you can define the security model and set up handlers for startup and various other events, such as new Profile creation.

The manifest will automatically be loaded from main.lua at the root of your project. See .

Model

All model objects that will be used for client code generation, request parameters, and response objects, must be defined here.

The anatomy of a model object is as such:

  • description - (string) A description of the model object

  • properties - (table) A list of properties for this object. This follows two formats:

    • (property name) - Basic types

      • description

      • type

    • (property name) - Arrays or custom types

      • description

      • type

      • model

Valid Property Types:

  • "string"

  • "number"

  • "integer"

  • "boolean"

  • "object"

  • "array"

Example code:

    --example_model.lua
    return {
        description = "A model object representing a several example properties.",
        properties = {
            message = {
                description = "A simple string message.",
                type = "string"
            },
            message_array = {
                description = "An array of messages.",
                type = "array",
                model = "string"        
            },
            some_other_model = {
                description = "Some other model. Must also be defined in manifest.",
                type = "object",
                model = "some_other_model"
            }
        }
    }

    --main.lua
    local manifest = {}
    manifest.model = {}
    manifest.model.example = require "example_model"
    manifest.model.some_other_model = require "some_other_model"
    return manifest

It is also possible to create a Pagination of any of your model objects here as well! This will allow you to fetch subsets of larger data sets when you want to stagger their retrieval from the client side.

    --main.lua
    local pagination = require "namazu.pagination"
    ...
    manifest.model.example = require "example_model"
    manifest.model.pagination_of_example = pagination.manifest_for("example")

HTTP

The manifest's HTTP definitions are your custom endpoint definitions. Everything that you define here will be found in DefaultApi in the generated client code, as well as tell Elements which endpoint handler functions to call when the client makes a request.

-- <Path to handler> = <operations table>
manifest.http = {
    ["example_endpoints"] = require "example_endpoints_operations"
}

Startup

Runs the specified scripts whenever Elements launches. This will include restarts made for code changes.

-- Assumes startup.lua exists and has a function "run"

manifest.startup = {
    ["startup"] = {
        operations = {
            run = {
                method = "run"
            }
        }
    }
}

If your startup script creates a new resource, you should check if it has already been created before creating a new one.

Events

Events allow you to add special functionality to certain Elements events.

Currently supported events:

  • "com.namazustudios.elements.service.profile.created" - a new Profile creation event

  • More coming soon!

-- Example for handling a new Profile creation event
manifest.event = {
    ["com.namazustudios.elements.service.profile.created"] = {
        { module = "new_profile_event_handler", method = "on_new_profile" }
    }
}

Security

local auth = require "namazu.elements.auth"
...
manifest.security = auth.default_security_manifest()

a sample here
Example operations table
Example endpoint handler