### Installation Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.1_activeTab=dependents Instructions for installing the Lumi.new SDK using pnpm, npm, or yarn. ```APIDOC ## Installation ```bash # pnpm pnpm add @lumi.new/sdk # npm npm install @lumi.new/sdk # yarn yarn add @lumi.new/sdk ``` ``` -------------------------------- ### Install @lumi.new/sdk using package managers Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.0 Install the Lumi.new SDK using popular package managers like pnpm, npm, or yarn. This is the first step to integrating Lumi.new services into your application. ```bash # pnpm pnpm add @lumi.new/sdk # npm npm install @lumi.new/sdk # yarn yarn add @lumi.new/sdk ``` -------------------------------- ### Initialize Lumi Client Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.0 Initialize the Lumi client with your project credentials. This setup is essential before making any calls to the Lumi API. You will need your `projectId`, `apiBaseUrl`, and `authOrigin`. ```typescript import { createClient } from '@lumi.new/sdk' export const lumi = createClient({ projectId: 'YOUR_PROJECT_ID', apiBaseUrl: 'YOUR_API_BASE_URL', authOrigin: 'YOUR_AUTH_ORIGIN', }) ``` -------------------------------- ### Server-side Usage with Deno Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.2_activeTab=dependents An example of using the Lumi SDK within a Deno server environment. It demonstrates how to retrieve an authorization token from headers, initialize the client, and refresh the user. Securely handle authorization tokens. ```typescript Deno.serve(async (req) => { const authorization = req.headers.get('Authorization') const lumi = createClient({ projectId: 'YOUR_PROJECT_ID', apiBaseUrl: 'YOUR_API_BASE_URL', authOrigin: '', authorization, }) const user = await lumi.auth.refreshUser() return lumi.auth.user }) ``` -------------------------------- ### Initiate Sign-In Process with Lumi SDK Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.1_activeTab=code The `signIn()` function starts the authentication process by opening a popup window. It returns a promise that resolves with user and session details, including project ID, user information, and an access token. Ensure the lumi SDK is initialized before calling this function. ```javascript lumi.auth.signIn().then(session => { console.log('Signed in:', session); }); ``` -------------------------------- ### AI: Stream Text Generation (Server-Side) Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.4_activeTab=code This Deno example demonstrates the server-side part of streaming AI text generation. It calls `lumi.tools.ai.generateTextStream` to get a raw stream and pipes it to the client as Server-Sent Events (SSE). Ensure `LUMI_API_KEY` is set in your environment variables. ```typescript // Example: A Deno-based Lumi Function Deno.serve(async (request: Request) => { // Initialize Lumi client with authorization token if needed // const lumi = createClient({ ... }); const rawStream = await lumi.tools.ai.generateTextStream({ model: 'gemini-2.5-flash', messages: [ { role: 'system', content: 'You are a helpful assistant.' }, { role: 'user', content: 'Stream a short poem line by line.' }, ], }); // Pipe the raw stream to the response with proper SSE headers return new Response(rawStream, { headers: { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache', 'X-Accel-Buffering': 'no', }, }); }); ``` -------------------------------- ### Client Initialization Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.1_activeTab=dependents Demonstrates how to initialize the Lumi client with your project credentials. ```APIDOC ## Getting Started First, initialize the Lumi client. You can get your `projectId` from your Lumi project settings. ```javascript import { createClient } from '@lumi.new/sdk' export const lumi = createClient({ projectId: 'YOUR_PROJECT_ID', apiBaseUrl: 'YOUR_API_BASE_URL', authOrigin: 'YOUR_AUTH_ORIGIN', }) ``` ``` -------------------------------- ### Client Initialization Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.2 Initializes the Lumi client with provided configuration. ```APIDOC ## createClient(config) ### Description Initializes the Lumi client with the necessary configuration. ### Method Function Call ### Parameters #### Request Body - **config** (object) - Required - The configuration object for the client. - **projectId** (string) - Required - Your Lumi project ID. - **apiBaseUrl** (string) - Required - The base URL of the Lumi API. - **authOrigin** (string) - Required - The origin URL for the authentication popup. - **authorization** (string) - Optional - An authorization token (e.g., `Bearer YOUR_TOKEN`). Recommended for server-side usage. ### Returns - **LumiClient**: An instance of the Lumi client. ``` -------------------------------- ### Get a Single Record by ID (JavaScript) Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.0_activeTab=versions The `get` method fetches a single record from an entity using its unique ID. It returns a promise that resolves with the record object or `null` if the record is not found. ```javascript lumi.entities.YourEntity.get('record-id').then(record => { if (record) { console.log('Found record:', record); } else { console.log('Record not found.'); } }); ``` -------------------------------- ### SDK Initialization Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.1_activeTab=versions Initializes the Lumi client with your project credentials. ```APIDOC ## SDK Initialization ### Description Initializes the Lumi client using your `projectId`. You can optionally provide `apiBaseUrl` and `authOrigin`. ### Method `createClient(options)` ### Parameters #### Request Body - **projectId** (string) - Required - Your Lumi project ID. - **apiBaseUrl** (string) - Optional - The base URL for the API. - **authOrigin** (string) - Optional - The origin URL for authentication. ### Request Example ```javascript import { createClient } from '@lumi.new/sdk' export const lumi = createClient({ projectId: 'YOUR_PROJECT_ID', apiBaseUrl: 'YOUR_API_BASE_URL', authOrigin: 'YOUR_AUTH_ORIGIN', }) ``` ``` -------------------------------- ### Client Initialization Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.4_activeTab=dependencies Explains how to initialize the Lumi client with the necessary configuration parameters. ```APIDOC ## API Reference ### `createClient(config)` Initializes the Lumi client. #### Parameters * **config** (`object`) - Required - The configuration object for the client. * **projectId** (`string`) - Required - Your Lumi project ID. * **apiBaseUrl** (`string`) - Required - The base URL of the Lumi API. * **authOrigin** (`string`) - Required - The origin URL for the authentication popup. * **authorization** (`string`) - Optional - An authorization token (e.g., `Bearer YOUR_TOKEN`). Recommended for server-side usage. #### Returns * `LumiClient` - An instance of the Lumi client. ``` -------------------------------- ### Get a Single Record Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.4_activeTab=dependencies Retrieve a single record by its ID. ```APIDOC ## Get a Single Record ### Description Retrieve a single record by its ID. ### Method GET (implicitly through SDK method) ### Endpoint `lumi.entities..get(id)` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the record to retrieve. ### Request Example ```javascript async function getPost(id) { const post = await lumi.entities.Posts.get(id); console.log('Post:', post); } getPost('your-post-id'); ``` ### Response #### Success Response (200) - **(object)** - The record matching the provided ID. #### Response Example ```json { "id": "post-id-1", "title": "My Post", "content": "...", "published": true, "createdAt": "..." } ``` ``` -------------------------------- ### Posts API - Get a Single Record Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.2_activeTab=versions Retrieve a single record from the Posts entity by its unique ID. ```APIDOC ## GET /entities/{entityName}/{id} ### Description Retrieve a single record by its ID. ### Method GET ### Endpoint /entities/{entityName}/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the record to retrieve. ### Request Example ```javascript await lumi.entities.Posts.get('your-post-id'); ``` ### Response #### Success Response (200) - **(object)** - The requested record. #### Response Example ```json { "id": "post-id-1", "title": "My Post", "content": "...", "published": true, "createdAt": "..." } ``` ``` -------------------------------- ### Initialization Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.1_activeTab=dependencies Initialize the Lumi client with your project ID and other configuration details. ```APIDOC ## Initialization ### Description Initialize the Lumi client with your project configuration. ### Method `createClient` ### Parameters #### Request Body - **projectId** (string) - Required - Your Lumi project ID. - **apiBaseUrl** (string) - Optional - The base URL for the Lumi API. - **authOrigin** (string) - Optional - The origin URL for authentication. ### Request Example ```javascript import { createClient } from '@lumi.new/sdk' export const lumi = createClient({ projectId: 'YOUR_PROJECT_ID', apiBaseUrl: 'YOUR_API_BASE_URL', authOrigin: 'YOUR_AUTH_ORIGIN', }) ``` ``` -------------------------------- ### Entities API Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.3_activeTab=versions Interact with your project's data collections (entities). You can list, get, create, update, and delete records within an entity. ```APIDOC ## Entities API You can interact with your project's data collections (entities) using the `lumi.entities` client. Access a specific entity by its name, for example, `lumi.entities.Posts`. ### List Records Retrieve a list of records from an entity. This method returns an object containing the list of records and the total count. You can use `filter`, `sort`, `limit`, and `skip` to control the query. #### Method GET (simulated) #### Endpoint `/entities/{entityName}` #### Query Parameters - **filter** (object) - Optional - Criteria to filter records. - **sort** (object) - Optional - Field and order to sort records. - **limit** (integer) - Optional - Maximum number of records to return. - **skip** (integer) - Optional - Number of records to skip from the beginning. #### Response Example (200 OK) ```json { "list": [ { "id": "post-id-1", "title": "First Post", "content": "...", "published": true, "createdAt": "..." }, { "id": "post-id-2", "title": "Second Post", "content": "...", "published": true, "createdAt": "..." } ], "total": 2 } ``` ### Get a Single Record Retrieve a single record by its ID. #### Method GET #### Endpoint `/entities/{entityName}/{id}` #### Parameters ##### Path Parameters - **id** (string) - Required - The unique identifier of the record. #### Response Example (200 OK) ```json { "id": "post-id-1", "title": "My Post", "content": "...", "published": true, "createdAt": "..." } ``` ### Create a Record Create a new record in an entity. #### Method POST #### Endpoint `/entities/{entityName}` #### Request Body - **data** (object) - Required - The data for the new record. #### Request Example ```json { "title": "My Awesome Post", "content": "This is the content of my new post.", "published": false } ``` #### Response Example (201 Created) ```json { "id": "new-post-id", "title": "My Awesome Post", "content": "This is the content of my new post.", "published": false, "creator": "user-id-123", "createdAt": "2024-01-16T10:30:00Z", "updatedAt": "2024-01-16T10:30:00Z" } ``` ### Create Multiple Records Create multiple records in a single request. #### Method POST #### Endpoint `/entities/{entityName}/batch` #### Request Body - **records** (array) - Required - An array of record objects to create. #### Request Example ```json [ { "title": "First Awesome Post", "content": "Content for the first post." }, { "title": "Second Awesome Post", "content": "Content for the second post." } ] ``` #### Response Example (201 Created) ```json [ { "id": "post-1", "title": "Post 1", "content": "...", "published": false, "creator": "user-id-123", "createdAt": "...", "updatedAt": "..." }, { "id": "post-2", "title": "Post 2", "content": "...", "published": false, "creator": "user-id-123", "createdAt": "...", "updatedAt": "..." } ] ``` ### Update a Record Update an existing record by its ID. #### Method PUT or PATCH #### Endpoint `/entities/{entityName}/{id}` #### Parameters ##### Path Parameters - **id** (string) - Required - The unique identifier of the record to update. #### Request Body - **updates** (object) - Required - An object containing the fields to update. #### Request Example ```json { "published": true, "title": "My Updated Post" } ``` #### Response Example (200 OK) ```json { "id": "post-id-1", "title": "My Updated Post", "content": "...", "published": true, "creator": "user-id-123", "createdAt": "...", "updatedAt": "..." } ``` ### Delete a Record Delete a record by its ID. #### Method DELETE #### Endpoint `/entities/{entityName}/{id}` #### Parameters ##### Path Parameters - **id** (string) - Required - The unique identifier of the record to delete. #### Response Example (204 No Content) (No response body) ### Delete Multiple Records Delete multiple records by their IDs in a single request. #### Method DELETE #### Endpoint `/entities/{entityName}/batch` #### Request Body - **ids** (array of strings) - Required - An array of record IDs to delete. #### Request Example ```json [ "post-id-1", "post-id-2" ] ``` #### Response Example (204 No Content) (No response body) ``` -------------------------------- ### Initiate Sign-in with Lumi SDK Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.1_activeTab=dependents The `signIn()` function initiates the user sign-in process by opening a popup window. It returns a Promise that resolves with project ID, user information, and an access token upon successful authentication. ```javascript lumi.auth.signIn().then(authData => { console.log('Signed in:', authData.projectId, authData.user, authData.accessToken); }); ``` -------------------------------- ### Lumi Entities: Get Single Record Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.4 Retrieves a single record from an entity by its unique identifier. Returns a promise that resolves with the record object or null if not found. ```javascript const record = await lumi.entities.YourEntity.get('recordId'); ``` -------------------------------- ### Client Initialization Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.0_activeTab=code API for initializing the Lumi client with configuration settings. ```APIDOC ## POST /clients ### Description Initializes the Lumi client with the provided configuration. ### Method POST ### Endpoint /clients ### Parameters #### Request Body - **config** (object) - Required - The configuration object for the client. - **projectId** (string) - Required - Your Lumi project ID. - **apiBaseUrl** (string) - Optional - The base URL of the Lumi API. Defaults to a production URL. - **authOrigin** (string) - Optional - The origin URL for the authentication popup. Defaults to a production URL. ### Request Example ```json { "projectId": "your-project-id", "apiBaseUrl": "https://api.lumi.app", "authOrigin": "https://auth.lumi.app" } ``` ### Response #### Success Response (200) - **lumiClient** (object) - Description: An instance of the Lumi client, which can be used to interact with the Lumi API. #### Response Example ```json { "lumiClient": { ... } } ``` ``` -------------------------------- ### Get a Single Record by ID (JavaScript) Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.3_activeTab=dependencies Retrieves a single record from an entity using its unique ID. Returns the record object. ```javascript async function getPost(id: string) { const post = await lumi.entities.Posts.get(id); console.log('Post:', post); } // Example Request: getPost('your-post-id'); // Example Response: // Post: { id: 'post-id-1', title: 'My Post', content: '...', published: true, createdAt: '...' } ``` -------------------------------- ### Initialize Lumi Client Configuration Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.0_activeTab=versions Initializes the Lumi client with essential configuration parameters. Requires a project ID, API base URL, and authentication origin URL. Returns an instance of the Lumi client for further interactions. ```javascript const config = { projectId: 'YOUR_PROJECT_ID', apiBaseUrl: 'https://api.lumi.com', authOrigin: 'https://auth.lumi.com' }; const lumi = createClient(config); ``` -------------------------------- ### Client Initialization Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.3_activeTab=versions Initializes the Lumi client with the provided configuration object. This is the first step to using the Lumi SDK. ```APIDOC ## `createClient(config)` Initializes the Lumi client. ### Parameters #### Request Body - **config** (object) - Required - The configuration object for the client. - **projectId** (string) - Required - Your Lumi project ID. - **apiBaseUrl** (string) - Required - The base URL of the Lumi API. - **authOrigin** (string) - Required - The origin URL for the authentication popup. - **authorization** (string) - Optional - An authorization token (e.g., `Bearer YOUR_TOKEN`). Recommended for server-side usage. ### Returns - **LumiClient**: An instance of the Lumi client. ``` -------------------------------- ### Entities API Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.3_activeTab=dependents Interact with your project's data collections (entities) using methods for listing, getting, creating, updating, and deleting records. ```APIDOC ## Entities API The `entities` client allows you to interact with your project's data collections. You can access a specific entity by its name. ### List Records Retrieve a list of records from an entity. This method returns an object containing the list of records and the total count. You can use `filter`, `sort`, `limit`, and `skip` to control the query. #### Method GET (simulated) #### Endpoint `/entities/{entityName}/list` (conceptual) #### Query Parameters - **filter** (object) - Optional - Criteria to filter records. - **sort** (object) - Optional - Field and order to sort records. - **limit** (number) - Optional - Maximum number of records to return. - **skip** (number) - Optional - Number of records to skip from the beginning. #### Request Example ```javascript async function getPosts() { const { list, total } = await lumi.entities.Posts.list({ filter: { published: true }, sort: { createdAt: -1 }, limit: 10, skip: 0, }); console.log('Posts:', list); console.log('Total records:', total); } getPosts(); ``` #### Response Example (Success) ```json { "list": [ { "id": "post-id-1", "title": "First Post", "content": "...", "published": true, "createdAt": "..." }, { "id": "post-id-2", "title": "Second Post", "content": "...", "published": true, "createdAt": "..." } ], "total": 2 } ``` ### Get a Single Record Retrieve a single record by its ID. #### Method GET #### Endpoint `/entities/{entityName}/{id}` (conceptual) #### Path Parameters - **id** (string) - Required - The unique identifier of the record. #### Request Example ```javascript async function getPost(id) { const post = await lumi.entities.Posts.get(id); console.log('Post:', post); } getPost('your-post-id'); ``` #### Response Example (Success) ```json { "id": "post-id-1", "title": "My Post", "content": "...", "published": true, "createdAt": "..." } ``` ### Create a Record Create a new record in an entity. #### Method POST #### Endpoint `/entities/{entityName}` (conceptual) #### Request Body - **(object)** - Required - The data for the new record. #### Request Example ```javascript async function createPost(title, content) { const newPost = await lumi.entities.Posts.create({ title, content, published: false, }); console.log('Created post:', newPost); } createPost('My Awesome Post', 'This is the content of my new post.'); ``` #### Response Example (Success) ```json { "id": "new-post-id", "title": "My Awesome Post", "content": "This is the content of my new post.", "published": false, "creator": "user-id-123", "createdAt": "2024-01-16T10:30:00Z", "updatedAt": "2024-01-16T10:30:00Z" } ``` ### Create Multiple Records Create multiple records in a single request. #### Method POST #### Endpoint `/entities/{entityName}/batch` (conceptual) #### Request Body - **(array of objects)** - Required - An array of data objects for the new records. #### Request Example ```javascript async function createMultiplePosts(newPostsData) { const newPosts = await lumi.entities.Posts.createMany(newPostsData); console.log('Created posts:', newPosts); } const postsToCreate = [ { title: 'First Awesome Post', content: 'Content for the first post.' }, { title: 'Second Awesome Post', content: 'Content for the second post.' } ]; createMultiplePosts(postsToCreate); ``` #### Response Example (Success) ```json [ { "id": "post-1", "title": "Post 1", "content": "...", "published": false, "creator": "user-id-123", "createdAt": "...", "updatedAt": "..." }, { "id": "post-2", "title": "Post 2", "content": "...", "published": false, "creator": "user-id-123", "createdAt": "...", "updatedAt": "..." } ] ``` ### Update a Record Update an existing record by its ID. #### Method PUT or PATCH #### Endpoint `/entities/{entityName}/{id}` (conceptual) #### Path Parameters - **id** (string) - Required - The unique identifier of the record to update. #### Request Body - **(object)** - Required - An object containing the fields to update. #### Request Example ```javascript async function updatePost(id, updates) { const updatedPost = await lumi.entities.Posts.update(id, updates); console.log('Updated post:', updatedPost); } updatePost('your-post-id', { published: true, title: 'My Updated Post' }); ``` #### Response Example (Success) ```json { "id": "post-id-1", "title": "My Updated Post", "content": "...", "published": true, "creator": "user-id-123", "createdAt": "...", "updatedAt": "..." } ``` ### Delete a Record Delete a record by its ID. #### Method DELETE #### Endpoint `/entities/{entityName}/{id}` (conceptual) #### Path Parameters - **id** (string) - Required - The unique identifier of the record to delete. #### Request Example ```javascript async function deletePost(id) { await lumi.entities.Posts.delete(id); console.log('Post deleted.'); } deletePost('your-post-id'); ``` ### Delete Multiple Records Delete multiple records by their IDs in a single request. #### Method DELETE #### Endpoint `/entities/{entityName}/batch` (conceptual) #### Request Body - **ids** (array of strings) - Required - An array of record IDs to delete. #### Request Example ```javascript async function deleteMultiplePosts(ids) { await lumi.entities.Posts.deleteMany(ids); console.log('Posts deleted.'); } deleteMultiplePosts(['post-id-1', 'post-id-2']); ``` ``` -------------------------------- ### Get a Single Record by ID from an Entity Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.1_activeTab=dependencies Fetches a specific record from an entity using its unique identifier. This method is useful for displaying details of a single item. ```typescript async function getPost(id: string) { const post = await lumi.entities.Posts.get(id) console.log('Post:', post) } // Example Request: getPost('your-post-id'); // Example Response: // Post: { id: 'post-id-1', title: 'My Post', content: '...', published: true, createdAt: '...' } ``` -------------------------------- ### Lumi Client Initialization Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.0_activeTab=versions API for initializing the Lumi client with necessary configuration. ```APIDOC ## Initialize Lumi Client ### Description Initializes the Lumi client with the provided configuration object. ### Method `createClient` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **config** (object) - Required - The configuration object for the client. - **projectId** (string) - Required - Your Lumi project ID. - **apiBaseUrl** (string) - Optional - The base URL of the Lumi API (defaults to a standard URL). - **authOrigin** (string) - Optional - The origin URL for the authentication popup. ### Request Example ```javascript const lumi = createClient({ projectId: 'YOUR_PROJECT_ID', apiBaseUrl: 'https://api.lumi.app', authOrigin: 'https://auth.lumi.app' }); ``` ### Response #### Success Response - **LumiClient**: An instance of the Lumi client configured with the provided settings. #### Response Example ```javascript // lumi is now an initialized LumiClient instance console.log(lumi); ``` ``` -------------------------------- ### Initialize Lumi Client Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.1_activeTab=versions Initializes the Lumi client with provided configuration. Requires project ID, API base URL, and authentication origin. Returns an instance of the Lumi client for subsequent operations. ```javascript const lumiClient = createClient({ projectId: 'your-project-id', apiBaseUrl: 'https://api.lumi.app', authOrigin: 'https://auth.lumi.app', }); ``` -------------------------------- ### Accessing Data Entities Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.1_activeTab=dependencies Demonstrates how to get a reference to a specific data entity collection, such as 'Posts', using the Lumi client. This is the entry point for data manipulation. ```typescript const posts = lumi.entities.Posts ``` -------------------------------- ### Client Initialization Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.1_activeTab=versions Initializes the Lumi client with the provided configuration, including project ID, API base URL, and authentication origin. ```APIDOC ## createClient(config) ### Description Initializes the Lumi client. ### Parameters #### `config` (object) - Required - **`projectId`** (`string`) - Required - Your Lumi project ID. - **`apiBaseUrl`** (`string`) - Required - The base URL of the Lumi API. - **`authOrigin`** (`string`) - Required - The origin URL for the authentication popup. ### Returns - **`LumiClient`** - An instance of the Lumi client. ``` -------------------------------- ### Get a Single Record by ID - JavaScript Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.2_activeTab=dependencies Fetches a single record from an entity using its unique identifier. Returns a promise that resolves with the record object or null if the record is not found. ```javascript const record = await lumi.entities.YourEntity.get('record-id'); if (record) { console.log('Found record:', record); } else { console.log('Record not found.'); } ``` -------------------------------- ### Get Single Record by ID from Lumi Entity Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.1_activeTab=versions Fetches a single record from an entity using its unique identifier. Returns the record object if found, otherwise returns null. ```javascript const recordId = 'some-record-id'; lumi.entities.YourEntity.get(recordId) .then(record => { if (record) { console.log('Retrieved record:', record); } else { console.log('Record not found.'); } }) .catch(error => { console.error('Failed to get record:', error); }); ``` -------------------------------- ### Get Single Record by ID from Lumi Entity Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.0 Fetches a single record from an entity using its unique identifier. It returns a promise that resolves with the record object or `null` if the record is not found. ```javascript const record = await lumi.entities.YourEntity.get('record-id-123'); if (record) { console.log('Retrieved record:', record); } else { console.log('Record not found.'); } ``` -------------------------------- ### Client Initialization Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.2_activeTab=dependencies Initializes the Lumi client with project details. Ensure you obtain your 'projectId' from your Lumi project settings. ```APIDOC ## Client Initialization ### Description Initializes the Lumi client with project details. Ensure you obtain your 'projectId' from your Lumi project settings. ### Method `createClient` ### Parameters #### Request Body - **projectId** (string) - Required - Your Lumi project ID. - **apiBaseUrl** (string) - Optional - The base URL for the API. - **authOrigin** (string) - Optional - The origin for authentication. - **authorization** (string) - Optional - The authorization token (required for server-side usage). ### Request Example ```javascript import { createClient } from '@lumi.new/sdk' const lumi = createClient({ projectId: 'YOUR_PROJECT_ID', apiBaseUrl: 'YOUR_API_BASE_URL', authOrigin: 'YOUR_AUTH_ORIGIN', authorization: 'YOUR_AUTHORIZATION_TOKEN' // Required for server-side }) ``` ### Response #### Success Response (200) - **lumiClient** (object) - An instance of the Lumi client. #### Response Example ```json { "lumiClient": { /* ... client object ... */ } } ``` ``` -------------------------------- ### Initialize Lumi Client Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.0_activeTab=code Initializes the Lumi client with project-specific configuration. This function requires a configuration object containing `projectId`, `apiBaseUrl`, and `authOrigin`. It returns an instance of the Lumi client. Dependencies: Lumi SDK. ```javascript const lumiClient = createClient({ projectId: 'YOUR_PROJECT_ID', apiBaseUrl: 'https://api.lumi.com', authOrigin: 'https://auth.lumi.com' }); ``` -------------------------------- ### Get a Single Record by ID (JavaScript) Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.2_activeTab=dependents Retrieves a single record from an entity using its unique identifier. Returns a promise that resolves to the record object or null if not found. ```javascript const record = await lumi.entities.YourEntity.get('record-id'); if (record) { console.log('Found record:', record); } else { console.log('Record not found.'); } ``` -------------------------------- ### Initialize Lumi Client Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.0 Initializes the Lumi client with necessary configuration details. The `createClient` function requires a configuration object containing your project ID, the API base URL, and the authentication origin URL for popup interactions. It returns an instance of the Lumi client. ```javascript const lumi = createClient({ projectId: 'YOUR_PROJECT_ID', apiBaseUrl: 'https://api.lumi.com', authOrigin: 'https://auth.lumi.com' }); ``` -------------------------------- ### Get Single Record by ID with Lumi SDK Source: https://www.npmjs.com/package/@lumi.new/sdk/package/%40lumi.new/sdk/v/0.2_activeTab=dependents Retrieves a single record from an entity using its unique identifier. Requires the entity name and the record's ID as input. ```javascript async function getPost(id: string) { const post = await lumi.entities.Posts.get(id) console.log('Post:', post) } // Example Request: getPost('your-post-id'); ```