### Installing Squidex Node.js Library with npm or yarn Source: https://github.com/squidex/sdk-node/blob/main/README.md Provides the command-line instructions to install the Squidex Node.js library package using either the npm or yarn package managers. ```bash npm install @squidex/squidex # or yarn add @squidex/squidex ``` -------------------------------- ### Initializing Squidex Client and Running a Rule in TypeScript Source: https://github.com/squidex/sdk-node/blob/main/README.md Demonstrates how to import necessary classes, initialize the Squidex client with required credentials (clientId, clientSecret, appName), and execute a specific rule using the client instance. Includes commented-out options for environment and token store configuration. ```typescript import { SquidexClient, SquidexInMemoryTokenStore, SquidexStorageTokenStore } from "@squidex/squidex"; const client = new SquidexClient({ clientId: "client-id", clientSecret: "client-secret", appName: "my-app", // environment: "https://your.squidex-deployment", // tokenStore: new SquidexInMemoryTokenStore(), // tokenStore: new SquidexStorageTokenStore() // Keep the tokens in the local store. // tokenStore: new SquidexStorageTokenStore(sessionStorage, "CustomKey") }); const response = await client.rules.runRule("rule-id", { fromSnapshots: true, }); console.log("Received response from Squidex!", response); ``` -------------------------------- ### Configuring tsconfig.json for ESM Projects with Squidex SDK Source: https://github.com/squidex/sdk-node/blob/main/README.md Provides a snippet for the `tsconfig.json` file, showing the necessary `esModuleInterop` compiler option that should be enabled when using the Squidex Node SDK in a TypeScript project configured for ECMAScript Modules (ESM). ```jsonc { "compilerOptions": { "esModuleInterop": true, ... } } ``` -------------------------------- ### Handling Squidex API Errors in TypeScript Source: https://github.com/squidex/sdk-node/blob/main/README.md Illustrates how to implement error handling for Squidex API calls using a try-catch block. It shows how to check if a caught error is an instance of a specific Squidex error subclass (e.g., `BadRequestError`) and access its properties like statusCode, message, and body. ```typescript import { Squidex } from "@squidex/squidex"; try { const response = await client.rules.runRule("rule-id", { fromSnapshots: true, }); } catch (err) { if (err instanceof Squidex.BadRequestError) { console.log(err.statusCode); console.log(err.message); console.log(err.body); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.