@space-df/sdk 0.0.1-dev.42 → 0.0.1-dev.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api.doc.md CHANGED
@@ -3012,7 +3012,7 @@ await client.trip.delete('trip-uuid-456');
3012
3012
 
3013
3013
  ## Overview
3014
3014
 
3015
- The `Telemetry` class provides methods for retrieving telemetry entities, alerts, and geofences. This class allows you to search and filter telemetry entities by display type and search terms, retrieve alerts, and manage geofences (list, create, retrieve, update, delete, test).
3015
+ The `Telemetry` class provides methods for retrieving telemetry entities, alerts, events, automations, and geofences. This class allows you to search and filter telemetry entities by display type and search terms, retrieve alerts, query events by device, manage automations (list, create, retrieve, update, delete), and manage geofences (list, create, retrieve, update, delete, test).
3016
3016
 
3017
3017
  ## Methods
3018
3018
 
@@ -3121,6 +3121,198 @@ console.log(alerts.count);
3121
3121
 
3122
3122
  </details>
3123
3123
 
3124
+ <details>
3125
+ <summary><strong>automations.list</strong></summary>
3126
+
3127
+ List telemetry automations with optional filtering and pagination.
3128
+
3129
+ **Signature:**
3130
+
3131
+ ```typescript
3132
+ list(params: AutomationsListParams, options?: Core.RequestOptions): Core.APIPromise<AutomationsListResponse>
3133
+ ```
3134
+
3135
+ **Parameters:**
3136
+
3137
+ - `params` _(AutomationsListParams)_: Query parameters for filtering and pagination:
3138
+ - `search` _(string, optional)_: A search term to filter results.
3139
+ - `ordering` _(string, optional)_: Which field to use when ordering the results.
3140
+ - `limit` _(integer, optional)_: Number of results to return per page.
3141
+ - `offset` _(integer, optional)_: The initial index from which to return the results.
3142
+ - `options` _(Core.RequestOptions)_: Additional request options.
3143
+
3144
+ **Returns:** `Promise<AutomationsListResponse>`
3145
+
3146
+ **Response shape:**
3147
+
3148
+ - `count` _(integer)_: Total number of automations matching the query.
3149
+ - `next` _(string | null)_: URL to the next page of results, or `null`.
3150
+ - `previous` _(string | null)_: URL to the previous page of results, or `null`.
3151
+ - `results` _(Automation[])_: Array of automation objects.
3152
+
3153
+ **Example:**
3154
+
3155
+ ```typescript
3156
+ const automations = await client.telemetry.automations.list({
3157
+ search: 'Low Battery',
3158
+ limit: 10,
3159
+ offset: 0,
3160
+ });
3161
+ console.log(automations.results);
3162
+ ```
3163
+
3164
+ </details>
3165
+
3166
+ <details>
3167
+ <summary><strong>automations.create</strong></summary>
3168
+
3169
+ Create a new telemetry automation.
3170
+
3171
+ **Signature:**
3172
+
3173
+ ```typescript
3174
+ create(params: AutomationParams, options?: Core.RequestOptions): Core.APIPromise<Automation>
3175
+ ```
3176
+
3177
+ **Parameters:**
3178
+
3179
+ - `params` _(AutomationParams)_: Automation payload:
3180
+ - `name` _(string)_: The automation name.
3181
+ - `device_id` _(string)_: Device UUID that this automation applies to.
3182
+ - `action_ids` _(string[])_: Action IDs to execute when the rule is triggered.
3183
+ - `event_rule` _(AutomationEventRule)_: Event rule definition:
3184
+ - `rule_key` _(string)_: Rule key identifier.
3185
+ - `definition.conditions.and` _(AutomationRuleCondition[])_: Rule conditions.
3186
+ - `is_active` _(boolean)_: Whether the rule is currently active.
3187
+ - `repeat_able` _(boolean)_: Whether the rule can repeat.
3188
+ - `cooldown_sec` _(number)_: Cooldown time in seconds.
3189
+ - `description` _(string)_: Human-readable rule description.
3190
+ - `options` _(Core.RequestOptions)_: Additional request options.
3191
+
3192
+ **Returns:** `Promise<Automation>`
3193
+
3194
+ **Example:**
3195
+
3196
+ ```typescript
3197
+ const automation = await client.telemetry.automations.create({
3198
+ name: 'Low Battery Alert',
3199
+ device_id: 'device-uuid-123',
3200
+ action_ids: ['action-uuid-1'],
3201
+ event_rule: {
3202
+ rule_key: 'battery_low',
3203
+ definition: {
3204
+ conditions: {
3205
+ and: [{ battery: { lte: 20 } }],
3206
+ },
3207
+ },
3208
+ is_active: true,
3209
+ repeat_able: true,
3210
+ cooldown_sec: 300,
3211
+ description: 'Trigger when battery is less than or equal to 20%',
3212
+ },
3213
+ });
3214
+ console.log(automation.id);
3215
+ ```
3216
+
3217
+ </details>
3218
+
3219
+ <details>
3220
+ <summary><strong>automations.retrieve</strong></summary>
3221
+
3222
+ Retrieve an automation by its ID.
3223
+
3224
+ **Signature:**
3225
+
3226
+ ```typescript
3227
+ retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<Automation>
3228
+ ```
3229
+
3230
+ **Parameters:**
3231
+
3232
+ - `id` _(string)_: The unique identifier of the automation to retrieve.
3233
+ - `options` _(Core.RequestOptions)_: Additional request options.
3234
+
3235
+ **Returns:** `Promise<Automation>`
3236
+
3237
+ **Example:**
3238
+
3239
+ ```typescript
3240
+ const automation = await client.telemetry.automations.retrieve('automation-uuid-123');
3241
+ console.log(automation.name);
3242
+ ```
3243
+
3244
+ </details>
3245
+
3246
+ <details>
3247
+ <summary><strong>automations.update</strong></summary>
3248
+
3249
+ Update an existing automation by its ID (full update).
3250
+
3251
+ **Signature:**
3252
+
3253
+ ```typescript
3254
+ update(id: string, params: AutomationParams, options?: Core.RequestOptions): Core.APIPromise<Automation>
3255
+ ```
3256
+
3257
+ **Parameters:**
3258
+
3259
+ - `id` _(string)_: The unique identifier of the automation to update.
3260
+ - `params` _(AutomationParams)_: Updated automation payload.
3261
+ - `options` _(Core.RequestOptions)_: Additional request options.
3262
+
3263
+ **Returns:** `Promise<Automation>`
3264
+
3265
+ **Example:**
3266
+
3267
+ ```typescript
3268
+ const updated = await client.telemetry.automations.update('automation-uuid-123', {
3269
+ name: 'Low Battery Alert Updated',
3270
+ device_id: 'device-uuid-123',
3271
+ action_ids: ['action-uuid-1', 'action-uuid-2'],
3272
+ event_rule: {
3273
+ rule_key: 'battery_low',
3274
+ definition: {
3275
+ conditions: {
3276
+ and: [{ battery: { lte: 15 } }],
3277
+ },
3278
+ },
3279
+ is_active: true,
3280
+ repeat_able: true,
3281
+ cooldown_sec: 180,
3282
+ description: 'Trigger when battery is less than or equal to 15%',
3283
+ },
3284
+ });
3285
+ console.log(updated.updated_at);
3286
+ ```
3287
+
3288
+ </details>
3289
+
3290
+ <details>
3291
+ <summary><strong>automations.delete</strong></summary>
3292
+
3293
+ Delete an automation by its ID.
3294
+
3295
+ **Signature:**
3296
+
3297
+ ```typescript
3298
+ delete(id: string, options?: Core.RequestOptions): Core.APIPromise<void>
3299
+ ```
3300
+
3301
+ **Parameters:**
3302
+
3303
+ - `id` _(string)_: The unique identifier of the automation to delete.
3304
+ - `options` _(Core.RequestOptions)_: Additional request options.
3305
+
3306
+ **Returns:** `Promise<void>`
3307
+
3308
+ **Example:**
3309
+
3310
+ ```typescript
3311
+ await client.telemetry.automations.delete('automation-uuid-123');
3312
+ ```
3313
+
3314
+ </details>
3315
+
3124
3316
  <details>
3125
3317
  <summary><strong>events.list</strong></summary>
3126
3318
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@space-df/sdk",
3
- "version": "0.0.1-dev.42",
3
+ "version": "0.0.1-dev.44",
4
4
  "description": "The official TypeScript library for the Spacedf SDK API",
5
5
  "author": "Spacedf SDK <support@digitalfortress.dev>",
6
6
  "types": "./index.d.ts",
@@ -0,0 +1,65 @@
1
+ import { APIResource } from "../../resource.js";
2
+ import * as Core from "../../core.js";
3
+ import { ListParamsResponse, ListResponse } from "../../types/api.js";
4
+ export type AutomationRuleCondition = {
5
+ weekday_between: {
6
+ from: number;
7
+ to: number;
8
+ };
9
+ } | {
10
+ battery: Record<string, number>;
11
+ } | {
12
+ and: AutomationRuleCondition[];
13
+ } | {
14
+ or: AutomationRuleCondition[];
15
+ } | {
16
+ not: AutomationRuleCondition[];
17
+ };
18
+ export interface AutomationEventRule {
19
+ rule_key: string;
20
+ definition: {
21
+ conditions: {
22
+ and: AutomationRuleCondition[];
23
+ };
24
+ };
25
+ is_active: boolean;
26
+ repeat_able: boolean;
27
+ cooldown_sec: number;
28
+ description: string;
29
+ }
30
+ /** Expanded action as returned on automation resources (e.g. list/retrieve). */
31
+ export interface AutomationAction {
32
+ id: string;
33
+ key: string;
34
+ name: string;
35
+ data: Record<string, unknown>;
36
+ created_at: string;
37
+ }
38
+ export interface Automation {
39
+ id: string;
40
+ name: string;
41
+ device_id: string;
42
+ actions: AutomationAction[];
43
+ event_rule?: AutomationEventRule;
44
+ created_at: string;
45
+ updated_at: string;
46
+ }
47
+ /** Body for `create` and `update`; actions are referenced by id. */
48
+ export interface AutomationParams {
49
+ name: string;
50
+ device_id: string;
51
+ action_ids: string[];
52
+ event_rule: AutomationEventRule;
53
+ }
54
+ export type AutomationsListResponse = ListResponse<Automation>;
55
+ export interface AutomationsListParams extends ListParamsResponse {
56
+ search?: string;
57
+ }
58
+ export declare class Automations extends APIResource {
59
+ list(params: AutomationsListParams, options?: Core.RequestOptions): Core.APIPromise<AutomationsListResponse>;
60
+ create(params: AutomationParams, options?: Core.RequestOptions): Core.APIPromise<Automation>;
61
+ retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<Automation>;
62
+ update(id: string, params: AutomationParams, options?: Core.RequestOptions): Core.APIPromise<Automation>;
63
+ delete(id: string, options?: Core.RequestOptions): Core.APIPromise<void>;
64
+ }
65
+ //# sourceMappingURL=automations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automations.d.ts","sourceRoot":"","sources":["../../src/resources/telemetry/automations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEnE,MAAM,MAAM,uBAAuB,GAC7B;IAAE,eAAe,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACjD;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACnC;IAAE,GAAG,EAAE,uBAAuB,EAAE,CAAA;CAAE,GAClC;IAAE,EAAE,EAAE,uBAAuB,EAAE,CAAA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C,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC;IAS5G,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;IAS5F,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;IAOhF,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;IASxG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;CAM3E"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Automations = void 0;
4
+ const resource_1 = require("../../resource.js");
5
+ class Automations extends resource_1.APIResource {
6
+ list(params, options) {
7
+ const { ...query } = params;
8
+ return this._client.get(`/telemetry/v1/automations`, {
9
+ query,
10
+ ...options,
11
+ headers: { ...options?.headers },
12
+ });
13
+ }
14
+ create(params, options) {
15
+ const { ...body } = params;
16
+ return this._client.post(`/telemetry/v1/automations`, {
17
+ body,
18
+ ...options,
19
+ headers: { ...options?.headers },
20
+ });
21
+ }
22
+ retrieve(id, options) {
23
+ return this._client.get(`/telemetry/v1/automations/${id}`, {
24
+ ...options,
25
+ headers: { ...options?.headers },
26
+ });
27
+ }
28
+ update(id, params, options) {
29
+ const { ...body } = params;
30
+ return this._client.put(`/telemetry/v1/automations/${id}`, {
31
+ body,
32
+ ...options,
33
+ headers: { ...options?.headers },
34
+ });
35
+ }
36
+ delete(id, options) {
37
+ return this._client.delete(`/telemetry/v1/automations/${id}`, {
38
+ ...options,
39
+ headers: { ...options?.headers },
40
+ });
41
+ }
42
+ }
43
+ exports.Automations = Automations;
44
+ //# sourceMappingURL=automations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automations.js","sourceRoot":"","sources":["../../src/resources/telemetry/automations.ts"],"names":[],"mappings":";;;AAAA,gDAA6C;AAyD7C,MAAa,WAAY,SAAQ,sBAAW;IACxC,IAAI,CAAC,MAA6B,EAAE,OAA6B;QAC7D,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE;YACjD,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;SACnC,CAAC,CAAC;IACP,CAAC;IAED,MAAM,CAAC,MAAwB,EAAE,OAA6B;QAC1D,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,2BAA2B,EAAE;YAClD,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;SACnC,CAAC,CAAC;IACP,CAAC;IAED,QAAQ,CAAC,EAAU,EAAE,OAA6B;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,EAAE,EAAE;YACvD,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;SACnC,CAAC,CAAC;IACP,CAAC;IAED,MAAM,CAAC,EAAU,EAAE,MAAwB,EAAE,OAA6B;QACtE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,EAAE,EAAE;YACvD,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;SACnC,CAAC,CAAC;IACP,CAAC;IAED,MAAM,CAAC,EAAU,EAAE,OAA6B;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,6BAA6B,EAAE,EAAE,EAAE;YAC1D,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;SACnC,CAAC,CAAC;IACP,CAAC;CACJ;AAzCD,kCAyCC"}
@@ -0,0 +1,40 @@
1
+ import { APIResource } from "../../resource.mjs";
2
+ export class Automations extends APIResource {
3
+ list(params, options) {
4
+ const { ...query } = params;
5
+ return this._client.get(`/telemetry/v1/automations`, {
6
+ query,
7
+ ...options,
8
+ headers: { ...options?.headers },
9
+ });
10
+ }
11
+ create(params, options) {
12
+ const { ...body } = params;
13
+ return this._client.post(`/telemetry/v1/automations`, {
14
+ body,
15
+ ...options,
16
+ headers: { ...options?.headers },
17
+ });
18
+ }
19
+ retrieve(id, options) {
20
+ return this._client.get(`/telemetry/v1/automations/${id}`, {
21
+ ...options,
22
+ headers: { ...options?.headers },
23
+ });
24
+ }
25
+ update(id, params, options) {
26
+ const { ...body } = params;
27
+ return this._client.put(`/telemetry/v1/automations/${id}`, {
28
+ body,
29
+ ...options,
30
+ headers: { ...options?.headers },
31
+ });
32
+ }
33
+ delete(id, options) {
34
+ return this._client.delete(`/telemetry/v1/automations/${id}`, {
35
+ ...options,
36
+ headers: { ...options?.headers },
37
+ });
38
+ }
39
+ }
40
+ //# sourceMappingURL=automations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automations.mjs","sourceRoot":"","sources":["../../src/resources/telemetry/automations.ts"],"names":[],"mappings":"OAAO,EAAE,WAAW,EAAE;AAyDtB,MAAM,OAAO,WAAY,SAAQ,WAAW;IACxC,IAAI,CAAC,MAA6B,EAAE,OAA6B;QAC7D,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QAC5B,OAAO,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{ Alerts } from "./alerts.js";
4
4
  import { Geofences } from "./geofences.js";
5
+ import { Automations } from "./automations.js";
5
6
  import { Events } from "./events.js";
6
7
  export declare class Telemetry extends APIResource {
7
8
  entities: Entities;
8
9
  alerts: Alerts;
9
10
  geofences: Geofences;
11
+ automations: Automations;
10
12
  events: Events;
11
13
  }
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/telemetry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,SAAU,SAAQ,WAAW;IACtC,QAAQ,EAAE,QAAQ,CAA8B;IAChD,MAAM,EAAE,MAAM,CAA4B;IAC1C,SAAS,EAAE,SAAS,CAA+B;IACnD,MAAM,EAAE,MAAM,CAA4B;CAC7C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/telemetry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,SAAU,SAAQ,WAAW;IACtC,QAAQ,EAAE,QAAQ,CAA8B;IAChD,MAAM,EAAE,MAAM,CAA4B;IAC1C,SAAS,EAAE,SAAS,CAA+B;IACnD,WAAW,EAAE,WAAW,CAAiC;IACzD,MAAM,EAAE,MAAM,CAA4B;CAC7C"}
@@ -5,6 +5,7 @@ const resource_1 = require("@space-df/sdk/resource");
5
5
  const entities_1 = require("./entities.js");
6
6
  const alerts_1 = require("./alerts.js");
7
7
  const geofences_1 = require("./geofences.js");
8
+ const automations_1 = require("./automations.js");
8
9
  const events_1 = require("./events.js");
9
10
  class Telemetry extends resource_1.APIResource {
10
11
  constructor() {
@@ -12,6 +13,7 @@ class Telemetry extends resource_1.APIResource {
12
13
  this.entities = new entities_1.Entities(this._client);
13
14
  this.alerts = new alerts_1.Alerts(this._client);
14
15
  this.geofences = new geofences_1.Geofences(this._client);
16
+ this.automations = new automations_1.Automations(this._client);
15
17
  this.events = new events_1.Events(this._client);
16
18
  }
17
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/telemetry/index.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,4CAAsC;AACtC,wCAAkC;AAClC,8CAAwC;AACxC,wCAAkC;AAElC,MAAa,SAAU,SAAQ,sBAAW;IAA1C;;QACI,aAAQ,GAAa,IAAI,mBAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChD,WAAM,GAAW,IAAI,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,cAAS,GAAc,IAAI,qBAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnD,WAAM,GAAW,IAAI,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;CAAA;AALD,8BAKC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/telemetry/index.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,4CAAsC;AACtC,wCAAkC;AAClC,8CAAwC;AACxC,kDAA4C;AAC5C,wCAAkC;AAElC,MAAa,SAAU,SAAQ,sBAAW;IAA1C;;QACI,aAAQ,GAAa,IAAI,mBAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChD,WAAM,GAAW,IAAI,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,cAAS,GAAc,IAAI,qBAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnD,gBAAW,GAAgB,IAAI,yBAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzD,WAAM,GAAW,IAAI,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;CAAA;AAND,8BAMC"}
@@ -2,6 +2,7 @@ import { APIResource } from '@space-df/sdk/resource';
2
2
  import { Entities } from "./entities.mjs";
3
3
  import { Alerts } from "./alerts.mjs";
4
4
  import { Geofences } from "./geofences.mjs";
5
+ import { Automations } from "./automations.mjs";
5
6
  import { Events } from "./events.mjs";
6
7
  export class Telemetry extends APIResource {
7
8
  constructor() {
@@ -9,6 +10,7 @@ export class Telemetry extends APIResource {
9
10
  this.entities = new Entities(this._client);
10
11
  this.alerts = new Alerts(this._client);
11
12
  this.geofences = new Geofences(this._client);
13
+ this.automations = new Automations(this._client);
12
14
  this.events = new Events(this._client);
13
15
  }
14
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/resources/telemetry/index.ts"],"names":[],"mappings":"OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB;OAC7C,EAAE,QAAQ,EAAE;OACZ,EAAE,MAAM,EAAE;OACV,EAAE,SAAS,EAAE;OACb,EAAE,MAAM,EAAE;AAEjB,MAAM,OAAO,SAAU,SAAQ,WAAW;IAA1C;;QACI,aAAQ,GAAa,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChD,WAAM,GAAW,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,cAAS,GAAc,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnD,WAAM,GAAW,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;CAAA"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/resources/telemetry/index.ts"],"names":[],"mappings":"OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB;OAC7C,EAAE,QAAQ,EAAE;OACZ,EAAE,MAAM,EAAE;OACV,EAAE,SAAS,EAAE;OACb,EAAE,WAAW,EAAE;OACf,EAAE,MAAM,EAAE;AAEjB,MAAM,OAAO,SAAU,SAAQ,WAAW;IAA1C;;QACI,aAAQ,GAAa,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChD,WAAM,GAAW,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,cAAS,GAAc,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnD,gBAAW,GAAgB,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzD,WAAM,GAAW,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;CAAA"}
@@ -0,0 +1,99 @@
1
+ import { APIResource } from '../../resource';
2
+ import * as Core from '../../core';
3
+ import { ListParamsResponse, ListResponse } from '../../types/api';
4
+
5
+ export type AutomationRuleCondition =
6
+ | { weekday_between: { from: number; to: number } }
7
+ | { battery: Record<string, number> }
8
+ | { and: AutomationRuleCondition[] }
9
+ | { or: AutomationRuleCondition[] }
10
+ | { not: AutomationRuleCondition[] };
11
+
12
+ export interface AutomationEventRule {
13
+ rule_key: string;
14
+ definition: {
15
+ conditions: {
16
+ and: AutomationRuleCondition[];
17
+ };
18
+ };
19
+ is_active: boolean;
20
+ repeat_able: boolean;
21
+ cooldown_sec: number;
22
+ description: string;
23
+ }
24
+
25
+ /** Expanded action as returned on automation resources (e.g. list/retrieve). */
26
+ export interface AutomationAction {
27
+ id: string;
28
+ key: string;
29
+ name: string;
30
+ data: Record<string, unknown>;
31
+ created_at: string;
32
+ }
33
+
34
+ export interface Automation {
35
+ id: string;
36
+ name: string;
37
+ device_id: string;
38
+ actions: AutomationAction[];
39
+ event_rule?: AutomationEventRule;
40
+ created_at: string;
41
+ updated_at: string;
42
+ }
43
+
44
+ /** Body for `create` and `update`; actions are referenced by id. */
45
+ export interface AutomationParams {
46
+ name: string;
47
+ device_id: string;
48
+ action_ids: string[];
49
+ event_rule: AutomationEventRule;
50
+ }
51
+
52
+ export type AutomationsListResponse = ListResponse<Automation>;
53
+
54
+ export interface AutomationsListParams extends ListParamsResponse {
55
+ search?: string;
56
+ }
57
+
58
+ export class Automations extends APIResource {
59
+ list(params: AutomationsListParams, options?: Core.RequestOptions): Core.APIPromise<AutomationsListResponse> {
60
+ const { ...query } = params;
61
+ return this._client.get(`/telemetry/v1/automations`, {
62
+ query,
63
+ ...options,
64
+ headers: { ...options?.headers },
65
+ });
66
+ }
67
+
68
+ create(params: AutomationParams, options?: Core.RequestOptions): Core.APIPromise<Automation> {
69
+ const { ...body } = params;
70
+ return this._client.post(`/telemetry/v1/automations`, {
71
+ body,
72
+ ...options,
73
+ headers: { ...options?.headers },
74
+ });
75
+ }
76
+
77
+ retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<Automation> {
78
+ return this._client.get(`/telemetry/v1/automations/${id}`, {
79
+ ...options,
80
+ headers: { ...options?.headers },
81
+ });
82
+ }
83
+
84
+ update(id: string, params: AutomationParams, options?: Core.RequestOptions): Core.APIPromise<Automation> {
85
+ const { ...body } = params;
86
+ return this._client.put(`/telemetry/v1/automations/${id}`, {
87
+ body,
88
+ ...options,
89
+ headers: { ...options?.headers },
90
+ });
91
+ }
92
+
93
+ delete(id: string, options?: Core.RequestOptions): Core.APIPromise<void> {
94
+ return this._client.delete(`/telemetry/v1/automations/${id}`, {
95
+ ...options,
96
+ headers: { ...options?.headers },
97
+ });
98
+ }
99
+ }
@@ -2,11 +2,13 @@ import { APIResource } from "../../resource";
2
2
  import { Entities } from './entities';
3
3
  import { Alerts } from './alerts';
4
4
  import { Geofences } from './geofences';
5
+ import { Automations } from './automations';
5
6
  import { Events } from './events';
6
7
 
7
8
  export class Telemetry extends APIResource {
8
9
  entities: Entities = new Entities(this._client);
9
10
  alerts: Alerts = new Alerts(this._client);
10
11
  geofences: Geofences = new Geofences(this._client);
12
+ automations: Automations = new Automations(this._client);
11
13
  events: Events = new Events(this._client);
12
14
  }
@@ -1 +1 @@
1
- export const VERSION = '0.0.1-dev.42';
1
+ export const VERSION = '0.0.1-dev.44';
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.0.1-dev.42";
1
+ export declare const VERSION = "0.0.1-dev.44";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.0.1-dev.42';
4
+ exports.VERSION = '0.0.1-dev.44';
5
5
  //# sourceMappingURL=version.js.map
package/dist/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.0.1-dev.42';
1
+ export const VERSION = '0.0.1-dev.44';
2
2
  //# sourceMappingURL=version.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@space-df/sdk",
3
- "version": "0.0.1-dev.42",
3
+ "version": "0.0.1-dev.44",
4
4
  "description": "The official TypeScript library for the Spacedf SDK API",
5
5
  "author": "Spacedf SDK <support@digitalfortress.dev>",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,99 @@
1
+ import { APIResource } from '../../resource';
2
+ import * as Core from '../../core';
3
+ import { ListParamsResponse, ListResponse } from '../../types/api';
4
+
5
+ export type AutomationRuleCondition =
6
+ | { weekday_between: { from: number; to: number } }
7
+ | { battery: Record<string, number> }
8
+ | { and: AutomationRuleCondition[] }
9
+ | { or: AutomationRuleCondition[] }
10
+ | { not: AutomationRuleCondition[] };
11
+
12
+ export interface AutomationEventRule {
13
+ rule_key: string;
14
+ definition: {
15
+ conditions: {
16
+ and: AutomationRuleCondition[];
17
+ };
18
+ };
19
+ is_active: boolean;
20
+ repeat_able: boolean;
21
+ cooldown_sec: number;
22
+ description: string;
23
+ }
24
+
25
+ /** Expanded action as returned on automation resources (e.g. list/retrieve). */
26
+ export interface AutomationAction {
27
+ id: string;
28
+ key: string;
29
+ name: string;
30
+ data: Record<string, unknown>;
31
+ created_at: string;
32
+ }
33
+
34
+ export interface Automation {
35
+ id: string;
36
+ name: string;
37
+ device_id: string;
38
+ actions: AutomationAction[];
39
+ event_rule?: AutomationEventRule;
40
+ created_at: string;
41
+ updated_at: string;
42
+ }
43
+
44
+ /** Body for `create` and `update`; actions are referenced by id. */
45
+ export interface AutomationParams {
46
+ name: string;
47
+ device_id: string;
48
+ action_ids: string[];
49
+ event_rule: AutomationEventRule;
50
+ }
51
+
52
+ export type AutomationsListResponse = ListResponse<Automation>;
53
+
54
+ export interface AutomationsListParams extends ListParamsResponse {
55
+ search?: string;
56
+ }
57
+
58
+ export class Automations extends APIResource {
59
+ list(params: AutomationsListParams, options?: Core.RequestOptions): Core.APIPromise<AutomationsListResponse> {
60
+ const { ...query } = params;
61
+ return this._client.get(`/telemetry/v1/automations`, {
62
+ query,
63
+ ...options,
64
+ headers: { ...options?.headers },
65
+ });
66
+ }
67
+
68
+ create(params: AutomationParams, options?: Core.RequestOptions): Core.APIPromise<Automation> {
69
+ const { ...body } = params;
70
+ return this._client.post(`/telemetry/v1/automations`, {
71
+ body,
72
+ ...options,
73
+ headers: { ...options?.headers },
74
+ });
75
+ }
76
+
77
+ retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<Automation> {
78
+ return this._client.get(`/telemetry/v1/automations/${id}`, {
79
+ ...options,
80
+ headers: { ...options?.headers },
81
+ });
82
+ }
83
+
84
+ update(id: string, params: AutomationParams, options?: Core.RequestOptions): Core.APIPromise<Automation> {
85
+ const { ...body } = params;
86
+ return this._client.put(`/telemetry/v1/automations/${id}`, {
87
+ body,
88
+ ...options,
89
+ headers: { ...options?.headers },
90
+ });
91
+ }
92
+
93
+ delete(id: string, options?: Core.RequestOptions): Core.APIPromise<void> {
94
+ return this._client.delete(`/telemetry/v1/automations/${id}`, {
95
+ ...options,
96
+ headers: { ...options?.headers },
97
+ });
98
+ }
99
+ }
@@ -2,11 +2,13 @@ import { APIResource } from '@space-df/sdk/resource';
2
2
  import { Entities } from './entities';
3
3
  import { Alerts } from './alerts';
4
4
  import { Geofences } from './geofences';
5
+ import { Automations } from './automations';
5
6
  import { Events } from './events';
6
7
 
7
8
  export class Telemetry extends APIResource {
8
9
  entities: Entities = new Entities(this._client);
9
10
  alerts: Alerts = new Alerts(this._client);
10
11
  geofences: Geofences = new Geofences(this._client);
12
+ automations: Automations = new Automations(this._client);
11
13
  events: Events = new Events(this._client);
12
14
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.0.1-dev.42';
1
+ export const VERSION = '0.0.1-dev.44';