|
| 1 | +# Splunk Enterprise SDK for JavaScript - AI Coding Agent Instructions |
| 2 | + |
| 3 | +This document provides guidance for AI coding agents working on the Splunk Enterprise SDK for JavaScript. |
| 4 | + |
| 5 | +## Architecture Overview |
| 6 | + |
| 7 | +The SDK is designed to be used in both Node.js and browser environments. |
| 8 | + |
| 9 | +- **Core Logic (`lib/`)**: The main SDK logic resides in the `lib/` directory. |
| 10 | + - `lib/context.js`: Manages the connection and authentication with the Splunk server. |
| 11 | + - `lib/service.js`: Provides a high-level API for interacting with Splunk services and endpoints. This is the primary interface for most operations. |
| 12 | + - `lib/http.js`: A low-level HTTP client for making requests to the Splunk REST API. |
| 13 | + - `lib/utils.js`: Contains utility functions used throughout the SDK. |
| 14 | + |
| 15 | +- **Platform-Specific Implementations (`lib/platform/`)**: |
| 16 | + - `lib/platform/node/`: Contains Node.js-specific code. |
| 17 | + - `lib/platform/client/`: Contains browser-specific code. |
| 18 | + |
| 19 | +- **Entry Points (`lib/entries/`)**: These files are used by Browserify to create bundles for different environments. |
| 20 | + - `browser.entry.js`: The main entry point for the browser bundle. |
| 21 | + |
| 22 | +- **UI Components (`lib/ui/`)**: Reusable UI components. |
| 23 | + - `charting.js`: For creating charts. |
| 24 | + - `timeline.js`: For creating timelines. |
| 25 | + |
| 26 | +## Developer Workflow |
| 27 | + |
| 28 | +- **Installation**: To install dependencies, run: |
| 29 | + |
| 30 | + ```bash |
| 31 | + npm install |
| 32 | + ``` |
| 33 | + |
| 34 | +- **Testing**: To run the test suite, use: |
| 35 | + |
| 36 | + ```bash |
| 37 | + npm test |
| 38 | + ``` |
| 39 | + |
| 40 | + This command executes the tests located in the `tests/` directory using Mocha. The test configuration is in `package.json`. |
| 41 | + |
| 42 | +- **Building**: The project uses a `Makefile` for build tasks. The primary build process uses `browserify` to create browser-compatible bundles from the entry points in `lib/entries/`. |
| 43 | + |
| 44 | +## Key Conventions and Patterns |
| 45 | + |
| 46 | +- **Asynchronous Operations**: The SDK uses Promises for all asynchronous operations. When adding new functionality, prefer `async/await` over callbacks. |
| 47 | + |
| 48 | +- **Error Handling**: Errors from the API are returned as standard JavaScript `Error` objects in the `catch` block of a Promise chain. |
| 49 | + |
| 50 | +- **Modularity**: The SDK is modular. When adding new features, consider if they can be implemented as separate modules. |
| 51 | + |
| 52 | +## Important Files and Directories |
| 53 | + |
| 54 | +- `package.json`: Defines project metadata, dependencies, and scripts. |
| 55 | +- `tests/`: Contains all the tests for the SDK. |
| 56 | +- `lib/`: The core of the SDK. |
| 57 | +- `examples/`: Contains example usage of the SDK. |
| 58 | +- `Makefile`: Contains build scripts. |
0 commit comments