particle-api-js 10.1.0 → 10.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "particle-api-js",
3
- "version": "10.1.0",
3
+ "version": "10.2.0",
4
4
  "description": "Particle API Client",
5
5
  "main": "src/Particle.js",
6
6
  "scripts": {
package/src/Particle.js CHANGED
@@ -2115,48 +2115,48 @@ class Particle {
2115
2115
  }
2116
2116
 
2117
2117
  /**
2118
- * Creates a new logic block in the specified organization using the provided block data.
2118
+ * Creates a new logic function in the specified organization using the provided function data.
2119
2119
  *
2120
- * When you create a logic block with PubSub matchers, events will immediately
2121
- * start being handled by the block code.
2120
+ * When you create a logic function with Event logic triggers, events will immediately
2121
+ * start being handled by the function code.
2122
2122
  *
2123
- * When you create a Chron matcher, it will immediately be scheduled at the next time
2123
+ * When you create a Scheduled logic trigger, it will immediately be scheduled at the next time
2124
2124
  * according to the cron and start_at properties.
2125
2125
  *
2126
- * @param {Object} options The options for creating the logic block.
2126
+ * @param {Object} options The options for creating the logic function.
2127
2127
  * @param {Object} options.auth Access token
2128
2128
  * @param {string} options.org The name of the organization.
2129
- * @param {string} options.block The block object containing the block details.
2129
+ * @param {string} options.logicFunction The logic function object containing the function details.
2130
2130
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2131
2131
  * @param {Object} [options.context] Request context
2132
2132
  *
2133
- * @returns {Promise<RequestResponse>} A promise that resolves to the created logic block data.
2133
+ * @returns {Promise<RequestResponse>} A promise that resolves to the created logic function data.
2134
2134
  */
2135
- createLogicBlock({ auth, org, block, headers, context }) {
2135
+ createLogicFunction({ auth, org, logicFunction, headers, context }) {
2136
2136
  return this.post({
2137
- uri: `/v1/orgs/${org}/blocks`,
2137
+ uri: `/v1/orgs/${org}/logic/functions`,
2138
2138
  auth,
2139
- data: { block },
2139
+ data: { logic_function: logicFunction },
2140
2140
  headers,
2141
2141
  context
2142
2142
  });
2143
2143
  }
2144
2144
 
2145
2145
  /**
2146
- * Get a logic block in the specified organization by block ID.
2146
+ * Get a logic function in the specified organization by logic function ID.
2147
2147
  *
2148
- * @param {Object} options The options for the logic block.
2148
+ * @param {Object} options The options for the logic function.
2149
2149
  * @param {Object} options.auth Access token
2150
2150
  * @param {string} options.org The name of the organization.
2151
- * @param {string} options.blockId The ID of the block to retrieve.
2151
+ * @param {string} options.logicFunctionId The ID of the logic function to retrieve.
2152
2152
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2153
2153
  * @param {Object} [options.context] Request context
2154
2154
  *
2155
- * @returns {Promise<RequestResponse>} A promise that resolves to the specified logic block data.
2155
+ * @returns {Promise<RequestResponse>} A promise that resolves to the specified logic function data.
2156
2156
  */
2157
- getLogicBlock({ auth, org, blockId, headers, context }) {
2157
+ getLogicFunction({ auth, org, logicFunctionId, headers, context }) {
2158
2158
  return this.get({
2159
- uri: `/v1/orgs/${org}/blocks/${blockId}`,
2159
+ uri: `/v1/orgs/${org}/logic/functions/${logicFunctionId}`,
2160
2160
  auth,
2161
2161
  headers,
2162
2162
  context
@@ -2164,45 +2164,45 @@ class Particle {
2164
2164
  }
2165
2165
 
2166
2166
  /**
2167
- * Updates an existing logic block in the specified organization using the provided block data.
2167
+ * Updates an existing logic function in the specified organization using the provided function data.
2168
2168
  *
2169
- * If you include an id on a matcher, it will update the matcher in place.
2169
+ * If you include an id on a logic trigger, it will update the logic trigger in place.
2170
2170
  *
2171
- * @param {Object} options The options for updating the logic block.
2171
+ * @param {Object} options The options for updating the logic function.
2172
2172
  * @param {Object} options.auth The authentication object with the API key.
2173
2173
  * @param {string} options.org The unique identifier of the organization.
2174
- * @param {string} options.blockId The ID of the block to update.
2175
- * @param {string} options.block The block object containing the block details.
2174
+ * @param {string} options.logicFunctionId The ID of the logic function to update.
2175
+ * @param {string} options.logicFunction The logic function object containing the logic function details.
2176
2176
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2177
2177
  * @param {Object} [options.context] Request context.
2178
2178
  *
2179
- * @returns {Promise<RequestResponse>} A promise that resolves to the updated logic block data.
2179
+ * @returns {Promise<RequestResponse>} A promise that resolves to the updated logic function data.
2180
2180
  */
2181
- updateLogicBlock({ auth, org, blockId, block, headers, context }) {
2181
+ updateLogicFunction({ auth, org, logicFunctionId, logicFunction, headers, context }) {
2182
2182
  return this.put({
2183
- uri: `/v1/orgs/${org}/blocks/${blockId}`,
2183
+ uri: `/v1/orgs/${org}/logic/functions/${logicFunctionId}`,
2184
2184
  auth,
2185
- data: { block },
2185
+ data: { logic_function: logicFunction },
2186
2186
  headers,
2187
2187
  context
2188
2188
  });
2189
2189
  }
2190
2190
 
2191
2191
  /**
2192
- * Deletes a logic block in the specified organization by block ID.
2192
+ * Deletes a logic function in the specified organization by logic function ID.
2193
2193
  *
2194
- * @param {Object} options The options for deleting the logic block.
2194
+ * @param {Object} options The options for deleting the logic function.
2195
2195
  * @param {Object} options.auth The authentication object with the API key.
2196
2196
  * @param {string} options.org The unique identifier of the organization.
2197
- * @param {string} options.blockId The ID of the block to delete.
2197
+ * @param {string} options.logicFunctionId The ID of the logic function to delete.
2198
2198
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2199
2199
  * @param {Object} [options.context] Request context.
2200
2200
  *
2201
- * @returns {Promise<RequestResponse>} A promise that resolves to an object containing the deleted block ID.
2201
+ * @returns {Promise<RequestResponse>} A promise that resolves to an object containing the deleted logic function ID.
2202
2202
  */
2203
- deleteLogicBlock({ auth, org, blockId, headers, context }) {
2203
+ deleteLogicFunction({ auth, org, logicFunctionId, headers, context }) {
2204
2204
  return this.delete({
2205
- uri: `/v1/orgs/${org}/blocks/${blockId}`,
2205
+ uri: `/v1/orgs/${org}/logic/functions/${logicFunctionId}`,
2206
2206
  auth,
2207
2207
  headers,
2208
2208
  context
@@ -2210,19 +2210,19 @@ class Particle {
2210
2210
  }
2211
2211
 
2212
2212
  /**
2213
- * Lists all logic blocks in the specified organization.
2213
+ * Lists all logic functions in the specified organization.
2214
2214
  *
2215
- * @param {Object} options The options for listing logic blocks.
2215
+ * @param {Object} options The options for listing logic functions.
2216
2216
  * @param {Object} options.auth The authentication object with the API key.
2217
2217
  * @param {string} options.org The unique identifier of the organization.
2218
2218
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2219
2219
  * @param {Object} [options.context] Request context.
2220
2220
  *
2221
- * @returns {Promise<RequestResponse>} A promise that resolves to an array of logic block data.
2221
+ * @returns {Promise<RequestResponse>} A promise that resolves to an array of logic functions data.
2222
2222
  */
2223
- listLogicBlocks({ auth, org, headers, context }) {
2223
+ listLogicFunctions({ auth, org, headers, context }) {
2224
2224
  return this.get({
2225
- uri: `/v1/orgs/${org}/blocks`,
2225
+ uri: `/v1/orgs/${org}/logic/functions`,
2226
2226
  auth,
2227
2227
  headers,
2228
2228
  context
@@ -2230,20 +2230,20 @@ class Particle {
2230
2230
  }
2231
2231
 
2232
2232
  /**
2233
- * Lists all block runs for the specified block.
2233
+ * Lists all logic runs for the specified logic function.
2234
2234
  *
2235
2235
  * @param {Object} options The options for the request.
2236
2236
  * @param {Object} options.auth Access token
2237
2237
  * @param {string} options.org The unique identifier of the organization.
2238
- * @param {number} options.blockId The ID of the block for which to retrieve the block runs.
2238
+ * @param {number} options.logicFunctionId The ID of the logic function for which to retrieve the logic runs.
2239
2239
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2240
2240
  * @param {Object} [options.context] Request context
2241
2241
  *
2242
- * @returns {Promise<RequestResponse>} A promise that resolves to an array of block run data.
2242
+ * @returns {Promise<RequestResponse>} A promise that resolves to an array of logic run data.
2243
2243
  */
2244
- listBlockRuns({ auth, org, blockId, headers, context }) {
2244
+ listLogicRuns({ auth, org, logicFunctionId, headers, context }) {
2245
2245
  return this.get({
2246
- uri: `/v1/orgs/${org}/blocks/${blockId}/runs`,
2246
+ uri: `/v1/orgs/${org}/logic/functions/${logicFunctionId}/runs`,
2247
2247
  auth,
2248
2248
  headers,
2249
2249
  context
@@ -2251,21 +2251,21 @@ class Particle {
2251
2251
  }
2252
2252
 
2253
2253
  /**
2254
- * Retrieves a block run by its ID for the specified block.
2254
+ * Retrieves a logic run by its ID for the specified logic function.
2255
2255
  *
2256
2256
  * @param {Object} options The options for the request.
2257
2257
  * @param {Object} options.auth Access token
2258
2258
  * @param {string} options.org The unique identifier of the organization.
2259
- * @param {number} options.blockId The ID of the block for which to retrieve the block run.
2260
- * @param {number} options.runId The ID of the block run to retrieve.
2259
+ * @param {number} options.logicFunctionId The ID of the logic function for which to retrieve the logic run.
2260
+ * @param {number} options.logicRunId The ID of the logic run to retrieve.
2261
2261
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2262
2262
  * @param {Object} [options.context] Request context
2263
2263
  *
2264
- * @returns {Promise<RequestResponse>} A promise that resolves to an array of block run data for the specified block run ID.
2264
+ * @returns {Promise<RequestResponse>} A promise that resolves to an array of logic run data for the specified logic run ID.
2265
2265
  */
2266
- getBlockRun({ auth, org, blockId, runId, headers, context }) {
2266
+ getLogicRun({ auth, org, logicFunctionId, logicRunId, headers, context }) {
2267
2267
  return this.get({
2268
- uri: `/v1/orgs/${org}/blocks/${blockId}/runs/${runId}`,
2268
+ uri: `/v1/orgs/${org}/logic/functions/${logicFunctionId}/runs/${logicRunId}`,
2269
2269
  auth,
2270
2270
  headers,
2271
2271
  context
@@ -2273,21 +2273,21 @@ class Particle {
2273
2273
  }
2274
2274
 
2275
2275
  /**
2276
- * Retrieves the logs for a block run by its ID for the specified block.
2276
+ * Retrieves the logs for a logic run by its ID for the specified logic function.
2277
2277
  *
2278
2278
  * @param {Object} options The options for the request.
2279
2279
  * @param {Object} options.auth Access token
2280
2280
  * @param {string} options.org The unique identifier of the organization.
2281
- * @param {number} options.blockId The ID of the block for which to retrieve the block run logs.
2282
- * @param {number} options.runId The ID of the block run for which to retrieve the logs.
2281
+ * @param {number} options.logicFunctionId The ID of the logic function for which to retrieve the logic run logs.
2282
+ * @param {number} options.logicRunId The ID of the logic run for which to retrieve the logs.
2283
2283
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2284
2284
  * @param {Object} [options.context] Request context
2285
2285
  *
2286
- * @returns {Promise<RequestResponse>} A promise that resolves to the logs for the specified block run ID.
2286
+ * @returns {Promise<RequestResponse>} A promise that resolves to the logs for the specified logic run ID.
2287
2287
  */
2288
- getBlockRunLog({ auth, org, blockId, runId, headers, context }) {
2288
+ getLogicRunLogs({ auth, org, logicFunctionId, logicRunId, headers, context }) {
2289
2289
  return this.get({
2290
- uri: `/v1/orgs/${org}/blocks/${blockId}/runs/${runId}/logs`,
2290
+ uri: `/v1/orgs/${org}/logic/functions/${logicFunctionId}/runs/${logicRunId}/logs`,
2291
2291
  auth,
2292
2292
  headers,
2293
2293
  context
@@ -96,25 +96,25 @@ const props = {
96
96
  dateRange: '2020-05-15T18:29:45.000Z,2020-05-19T18:29:45.000Z',
97
97
  rectBl: '56.185412,-4.049868',
98
98
  rectTr: '56.571537,-5.385920',
99
- blockId: 1,
100
- runId: 1,
101
- block: {
99
+ logicFunctionId: 1,
100
+ logicRunId: 1,
101
+ logicFunction: {
102
102
  enabled: true,
103
- name: 'block-1',
103
+ name: 'function-1',
104
104
  description: 'hello world',
105
- logic: {
105
+ source: {
106
106
  type: 'JavaScript',
107
- code: 'console.log("hello from block-1");'
107
+ code: 'console.log("hello from function-1");'
108
108
  },
109
- matchers: [
109
+ logic_triggers: [
110
110
  {
111
- type: 'PubSub',
111
+ type: 'Event',
112
112
  enabled: true,
113
113
  product_id: 9001,
114
114
  event_name: 'main',
115
115
  },
116
116
  {
117
- type: 'Chron',
117
+ type: 'Scheduled',
118
118
  enabled: true,
119
119
  cron: '0 0 1 * *',
120
120
  start_at: '2021-05-15T18:29:45.000Z',
@@ -2574,31 +2574,31 @@ describe('ParticleAPI', () => {
2574
2574
  });
2575
2575
  });
2576
2576
 
2577
- describe('.createLogicBlock', () => {
2577
+ describe('.createLogicFunction', () => {
2578
2578
  it('generates request', () => {
2579
- return api.createLogicBlock(propsWithOrg).then((results) => {
2579
+ return api.createLogicFunction(propsWithOrg).then((results) => {
2580
2580
  results.should.match({
2581
2581
  method: 'post',
2582
- uri: `/v1/orgs/${org}/blocks`,
2582
+ uri: `/v1/orgs/${org}/logic/functions`,
2583
2583
  auth: props.auth,
2584
2584
  data: {
2585
- block: {
2585
+ logic_function: {
2586
2586
  enabled: true,
2587
- name: 'block-1',
2587
+ name: 'function-1',
2588
2588
  description: 'hello world',
2589
- logic: {
2589
+ source: {
2590
2590
  type: 'JavaScript',
2591
- code: 'console.log("hello from block-1");'
2591
+ code: 'console.log("hello from function-1");'
2592
2592
  },
2593
- matchers: [
2593
+ logic_triggers: [
2594
2594
  {
2595
- type: 'PubSub',
2595
+ type: 'Event',
2596
2596
  enabled: true,
2597
2597
  product_id: parseInt(props.productId),
2598
2598
  event_name: props.event,
2599
2599
  },
2600
2600
  {
2601
- type: 'Chron',
2601
+ type: 'Scheduled',
2602
2602
  enabled: true,
2603
2603
  cron: '0 0 1 * *',
2604
2604
  start_at: '2021-05-15T18:29:45.000Z',
@@ -2612,43 +2612,43 @@ describe('ParticleAPI', () => {
2612
2612
  });
2613
2613
  });
2614
2614
 
2615
- describe('.getLogicBlock', () => {
2615
+ describe('.getLogicFunction', () => {
2616
2616
  it('generates request', () => {
2617
- return api.getLogicBlock(propsWithOrg).then((results) => {
2617
+ return api.getLogicFunction(propsWithOrg).then((results) => {
2618
2618
  results.should.match({
2619
2619
  method: 'get',
2620
- uri: `/v1/orgs/${org}/blocks/${props.blockId}`,
2620
+ uri: `/v1/orgs/${org}/logic/functions/${props.logicFunctionId}`,
2621
2621
  auth: props.auth
2622
2622
  });
2623
2623
  });
2624
2624
  });
2625
2625
  });
2626
2626
 
2627
- describe('.updateLogicBlock', () => {
2627
+ describe('.updateLogicFunction', () => {
2628
2628
  it('generates request', () => {
2629
- return api.updateLogicBlock(propsWithOrg).then((results) => {
2629
+ return api.updateLogicFunction(propsWithOrg).then((results) => {
2630
2630
  results.should.match({
2631
2631
  method: 'put',
2632
- uri: `/v1/orgs/${org}/blocks/${props.blockId}`,
2632
+ uri: `/v1/orgs/${org}/logic/functions/${props.logicFunctionId}`,
2633
2633
  auth: props.auth,
2634
2634
  data: {
2635
- block: {
2635
+ logic_function: {
2636
2636
  enabled: true,
2637
- name: 'block-1',
2637
+ name: 'function-1',
2638
2638
  description: 'hello world',
2639
- logic: {
2639
+ source: {
2640
2640
  type: 'JavaScript',
2641
- code: 'console.log("hello from block-1");'
2641
+ code: 'console.log("hello from function-1");'
2642
2642
  },
2643
- matchers: [
2643
+ logic_triggers: [
2644
2644
  {
2645
- type: 'PubSub',
2645
+ type: 'Event',
2646
2646
  enabled: true,
2647
2647
  product_id: parseInt(props.productId),
2648
2648
  event_name: props.event,
2649
2649
  },
2650
2650
  {
2651
- type: 'Chron',
2651
+ type: 'Scheduled',
2652
2652
  enabled: true,
2653
2653
  cron: '0 0 1 * *',
2654
2654
  start_at: '2021-05-15T18:29:45.000Z',
@@ -2662,60 +2662,60 @@ describe('ParticleAPI', () => {
2662
2662
  });
2663
2663
  });
2664
2664
 
2665
- describe('.deleteLogicBlock', () => {
2665
+ describe('.deleteLogicFunction', () => {
2666
2666
  it('generates request', () => {
2667
- return api.deleteLogicBlock(propsWithOrg).then((results) => {
2667
+ return api.deleteLogicFunction(propsWithOrg).then((results) => {
2668
2668
  results.should.match({
2669
2669
  method: 'delete',
2670
- uri: `/v1/orgs/${org}/blocks/${props.blockId}`,
2670
+ uri: `/v1/orgs/${org}/logic/functions/${props.logicFunctionId}`,
2671
2671
  auth: props.auth
2672
2672
  });
2673
2673
  });
2674
2674
  });
2675
2675
  });
2676
2676
 
2677
- describe('.listLogicBlocks', () => {
2677
+ describe('.listLogicFunctions', () => {
2678
2678
  it('generates request', () => {
2679
- return api.listLogicBlocks(propsWithOrg).then((results) => {
2679
+ return api.listLogicFunctions(propsWithOrg).then((results) => {
2680
2680
  results.should.match({
2681
2681
  method: 'get',
2682
- uri: `/v1/orgs/${org}/blocks`,
2682
+ uri: `/v1/orgs/${org}/logic/functions`,
2683
2683
  auth: props.auth
2684
2684
  });
2685
2685
  });
2686
2686
  });
2687
2687
  });
2688
2688
 
2689
- describe('.listBlockRuns', () => {
2689
+ describe('.listLogicRuns', () => {
2690
2690
  it('generates request', () => {
2691
- return api.listBlockRuns(propsWithOrg).then((results) => {
2691
+ return api.listLogicRuns(propsWithOrg).then((results) => {
2692
2692
  results.should.match({
2693
2693
  method: 'get',
2694
- uri: `/v1/orgs/${org}/blocks/${props.blockId}/runs`,
2694
+ uri: `/v1/orgs/${org}/logic/functions/${props.logicFunctionId}/runs`,
2695
2695
  auth: props.auth,
2696
2696
  });
2697
2697
  });
2698
2698
  });
2699
2699
  });
2700
2700
 
2701
- describe('.getBlockRun', () => {
2701
+ describe('.getLogicRun', () => {
2702
2702
  it('generates request', () => {
2703
- return api.getBlockRun(propsWithOrg).then((results) => {
2703
+ return api.getLogicRun(propsWithOrg).then((results) => {
2704
2704
  results.should.match({
2705
2705
  method: 'get',
2706
- uri: `/v1/orgs/${org}/blocks/${props.blockId}/runs/${props.runId}`,
2706
+ uri: `/v1/orgs/${org}/logic/functions/${props.logicFunctionId}/runs/${props.logicRunId}`,
2707
2707
  auth: props.auth,
2708
2708
  });
2709
2709
  });
2710
2710
  });
2711
2711
  });
2712
2712
 
2713
- describe('.getBlockRunLog', () => {
2713
+ describe('.getLogicRunLogs', () => {
2714
2714
  it('generates request', () => {
2715
- return api.getBlockRunLog(propsWithOrg).then((results) => {
2715
+ return api.getLogicRunLogs(propsWithOrg).then((results) => {
2716
2716
  results.should.match({
2717
2717
  method: 'get',
2718
- uri: `/v1/orgs/${org}/blocks/${props.blockId}/runs/${props.runId}/logs`,
2718
+ uri: `/v1/orgs/${org}/logic/functions/${props.logicFunctionId}/runs/${props.logicRunId}/logs`,
2719
2719
  auth: props.auth,
2720
2720
  });
2721
2721
  });