-
Notifications
You must be signed in to change notification settings - Fork 0
Map Operations
Phantom.js provides access to five types of maps commonly used in OIE scripting.
- Channel Map - Channel-scoped variables
- Global Map - Global variables across integrations
- Connector Map - Connector-specific variables
- Response Map - Response context variables (read-only in some contexts)
- Configuration Map - Configuration values (read-only)
All maps (except Configuration) support these operations:
-
save(key, value)- Save a value -
get(key)- Retrieve a value -
exists(key)- Check if key exists -
delete(key)- Remove a key
Channel-scoped variables available within the current channel.
// Save
phantom.maps.channel.save("userId", "12345");
// Get
var userId = phantom.maps.channel.get("userId");
// Output: "12345"
// Check existence
if (phantom.maps.channel.exists("userId")) {
// Process user
}
// Delete
phantom.maps.channel.delete("userId");Use Cases:
- Temporary data storage within a channel
- Passing data between stages in a flow
- Storing intermediate processing results
Global variables accessible across all integrations.
phantom.maps.global.save("systemConfig", "production");
var config = phantom.maps.global.get("systemConfig");Use Cases:
- System-wide configuration
- Shared data across multiple integrations
- Global flags and settings
Connector-specific variables.
phantom.maps.connector.save("apiKey", "secret123");
var apiKey = phantom.maps.connector.get("apiKey");Use Cases:
- Connector-specific configuration
- API credentials
- Connector state management
Response context variables (only available in response context).
// Only works in response context
phantom.maps.response.save("status", "success");
var status = phantom.maps.response.get("status");Important: This map is only available when responseMap is defined in the context. Attempting to use it outside response context will throw an error.
Use Cases:
- Storing response data
- Response status information
- Response metadata
Configuration values from the integration configuration.
// Get configuration value
var timeout = phantom.maps.configuration.get("timeout");
// Check if exists
if (phantom.maps.configuration.exists("timeout")) {
// Use timeout value
}
// Save/Delete operations are NOT allowed
phantom.maps.configuration.save("key", "value");
// Throws: Error("Invalid operation")Use Cases:
- Reading configuration parameters
- Accessing integration settings
- Retrieving environment-specific values
// Use channel map for temporary data
phantom.maps.channel.save("tempData", value);
// Use global map for shared data
phantom.maps.global.save("sharedConfig", config);
// Use connector map for connector-specific data
phantom.maps.connector.save("connectorState", state);if (phantom.maps.channel.exists("userId")) {
var userId = phantom.maps.channel.get("userId");
// Process user
} else {
// Handle missing data
}// After processing
phantom.maps.channel.delete("tempData");try {
var value = phantom.maps.channel.get("key");
} catch (e) {
// Handle error: "Invalid operation"
logger.error("Failed to get value: " + e.message);
}// Stage 1: Save raw data
phantom.maps.channel.save("rawData", inputData);
// Stage 2: Process and save
var processed = processData(phantom.maps.channel.get("rawData"));
phantom.maps.channel.save("processedData", processed);
// Stage 3: Use processed data
var result = phantom.maps.channel.get("processedData");var mode = phantom.maps.configuration.get("mode");
if (mode === "production") {
// Production logic
} else {
// Development logic
}if (phantom.maps.channel.exists("skipProcessing")) {
// Skip processing
} else {
// Normal processing
phantom.maps.channel.save("result", processData());
}phantom.maps.* are not available for drag-and-drop in the Destination Mappings section. This is an OIE editor limitation.
- String Operations - Process string data from maps
- Number Operations - Process numeric data from maps
- Examples - Real-world map usage examples
Phantom - A product of David Labs.