Methods
# aggregate(params) → {Promise.<ServiceResponse>}
Runs an aggregation query against the source's data.
Supports filtering, sorting, field selection, pagination via cursor (pageKey),
and Elasticsearch-style aggregations. Pass raw: true to query the raw index
(unprocessed field values as ingested).
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
Object
|
Aggregation parameters. |
|
size |
number
|
<optional> |
Number of rows to return. |
fields |
Array.<string>
|
<optional> |
Fields to include in each row. |
sort |
Object
|
<optional> |
Sort descriptor. |
filter |
Object
|
<optional> |
Filter conditions. |
aggs |
Object
|
<optional> |
Elasticsearch aggregation definitions. |
pageKey |
string
|
<optional> |
Cursor for the next page (from a previous response's |
raw |
boolean
|
<optional> |
When |
Promise.<ServiceResponse>
Example
const { result } = await insights.Source('Orders').aggregate({
size: 100,
filter: { status: 'active' },
sort: { createdAt: 'desc' }
})
# get(withSchemaopt) → {Promise.<ServiceResponse>}
Fetches metadata for the source, optionally including its formulator validation schema.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
withSchema |
boolean
|
<optional> |
false | When |
Promise.<ServiceResponse>
Example
const { result } = await insights.Source('Orders').get(true)
// result.schema.validation, result.schema.render, result.schema.translations
Type Definitions
Object
# FieldMappingObject
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
include |
Array.<string>
|
<optional> |
|
exclude |
Array.<string>
|
<optional> |
Object
# ServiceResponse
Properties:
| Name | Type | Description |
|---|---|---|
status |
number
|
HTTP status code returned by the service. |
result |
*
|
Parsed JSON body of the response, or |