@dimo-network/data-sdk 1.4.0 → 1.5.1
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/.github/workflows/npm-publish.yml +6 -3
- package/README.md +82 -0
- package/dist/api/Method.js +7 -2
- package/dist/api/Method.test.js +10 -5
- package/dist/api/resources/Agents/index.d.ts +5 -0
- package/dist/api/resources/Agents/index.js +63 -0
- package/dist/api/resources/DimoRestResources.d.ts +2 -1
- package/dist/api/resources/DimoRestResources.js +2 -1
- package/dist/cjs/index.js +75 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/dimo.d.ts +2 -1
- package/dist/dimo.js +3 -1
- package/dist/dimo.test.js +4 -0
- package/dist/environments/index.d.ts +2 -0
- package/dist/environments/index.js +2 -0
- package/dist/esm/index.js +75 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/types/api/resources/Agents/index.d.ts +5 -0
- package/dist/types/api/resources/DimoRestResources.d.ts +2 -1
- package/dist/types/dimo.d.ts +2 -1
- package/dist/types/environments/index.d.ts +2 -0
- package/package.json +3 -2
package/dist/dimo.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/** @format */
|
|
2
2
|
import { DimoEnvironment } from "./environments";
|
|
3
3
|
import { Identity, Telemetry } from "./graphql/resources/DimoGraphqlResources";
|
|
4
|
-
import { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleTriggers } from "./api/resources/DimoRestResources";
|
|
4
|
+
import { Agents, Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleTriggers } from "./api/resources/DimoRestResources";
|
|
5
5
|
export declare class DIMO {
|
|
6
|
+
agents: Agents;
|
|
6
7
|
attestation: Attestation;
|
|
7
8
|
auth: Auth;
|
|
8
9
|
devicedefinitions: DeviceDefinitions;
|
package/dist/dimo.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { DimoEnvironment } from "./environments";
|
|
3
3
|
import { DimoError } from "./errors";
|
|
4
4
|
import { Identity, Telemetry } from "./graphql/resources/DimoGraphqlResources";
|
|
5
|
-
import { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleTriggers, } from "./api/resources/DimoRestResources";
|
|
5
|
+
import { Agents, Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleTriggers, } from "./api/resources/DimoRestResources";
|
|
6
6
|
// import { Stream } from './streamr';
|
|
7
7
|
export class DIMO {
|
|
8
|
+
agents;
|
|
8
9
|
attestation;
|
|
9
10
|
auth;
|
|
10
11
|
devicedefinitions;
|
|
@@ -21,6 +22,7 @@ export class DIMO {
|
|
|
21
22
|
/**
|
|
22
23
|
* Set up all REST Endpoints
|
|
23
24
|
*/
|
|
25
|
+
this.agents = new Agents(DimoEnvironment[env].Agents, env);
|
|
24
26
|
this.attestation = new Attestation(DimoEnvironment[env].Attestation, env);
|
|
25
27
|
this.auth = new Auth(DimoEnvironment[env].Auth, env);
|
|
26
28
|
this.devicedefinitions = new DeviceDefinitions(DimoEnvironment[env].DeviceDefinitions, env);
|
package/dist/dimo.test.js
CHANGED
|
@@ -5,6 +5,7 @@ const dimo = new DIMO(PROD);
|
|
|
5
5
|
const devDimo = new DIMO(DEV);
|
|
6
6
|
describe('Production Environment', () => {
|
|
7
7
|
test('Production resources are initialized with the correct environment', () => {
|
|
8
|
+
expect(dimo.agents.env).toBe(PROD);
|
|
8
9
|
expect(dimo.attestation.env).toBe(PROD);
|
|
9
10
|
expect(dimo.auth.env).toBe(PROD);
|
|
10
11
|
expect(dimo.devicedefinitions.env).toBe(PROD);
|
|
@@ -16,6 +17,7 @@ describe('Production Environment', () => {
|
|
|
16
17
|
expect(dimo.valuations.env).toBe(PROD);
|
|
17
18
|
});
|
|
18
19
|
test('Production API endpoints are defined', () => {
|
|
20
|
+
expect(dimo.agents.api).toBeDefined;
|
|
19
21
|
expect(dimo.attestation.api).toBeDefined;
|
|
20
22
|
expect(dimo.auth.api).toBeDefined;
|
|
21
23
|
expect(dimo.devicedefinitions.api).toBeDefined;
|
|
@@ -29,6 +31,7 @@ describe('Production Environment', () => {
|
|
|
29
31
|
});
|
|
30
32
|
describe('Dev Environment', () => {
|
|
31
33
|
test('Dev resources are initialized with the correct environment', () => {
|
|
34
|
+
expect(devDimo.agents.env).toBe(DEV);
|
|
32
35
|
expect(devDimo.attestation.env).toBe(DEV);
|
|
33
36
|
expect(devDimo.auth.env).toBe(DEV);
|
|
34
37
|
expect(devDimo.devicedefinitions.env).toBe(DEV);
|
|
@@ -40,6 +43,7 @@ describe('Dev Environment', () => {
|
|
|
40
43
|
expect(devDimo.valuations.env).toBe(DEV);
|
|
41
44
|
});
|
|
42
45
|
test('Dev API endpoints are defined', () => {
|
|
46
|
+
expect(devDimo.agents.api).toBeDefined;
|
|
43
47
|
expect(devDimo.attestation.api).toBeDefined;
|
|
44
48
|
expect(devDimo.auth.api).toBeDefined;
|
|
45
49
|
expect(devDimo.devicedefinitions.api).toBeDefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @format */
|
|
2
2
|
export declare const DimoEnvironment: {
|
|
3
3
|
readonly Production: {
|
|
4
|
+
readonly Agents: "https://agents.dimo.zone";
|
|
4
5
|
readonly Attestation: "https://attestation-api.dimo.zone";
|
|
5
6
|
readonly Auth: "https://auth.dimo.zone";
|
|
6
7
|
readonly Identity: "https://identity-api.dimo.zone/query";
|
|
@@ -14,6 +15,7 @@ export declare const DimoEnvironment: {
|
|
|
14
15
|
readonly VehicleTriggers: "https://vehicle-triggers-api.dimo.zone";
|
|
15
16
|
};
|
|
16
17
|
readonly Dev: {
|
|
18
|
+
readonly Agents: "https://agents.dev.dimo.zone";
|
|
17
19
|
readonly Attestation: "https://attestation-api.dev.dimo.zone";
|
|
18
20
|
readonly Auth: "https://auth.dev.dimo.zone";
|
|
19
21
|
readonly Identity: "https://identity-api.dev.dimo.zone/query";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @format */
|
|
2
2
|
export const DimoEnvironment = {
|
|
3
3
|
Production: {
|
|
4
|
+
Agents: 'https://agents.dimo.zone',
|
|
4
5
|
Attestation: 'https://attestation-api.dimo.zone',
|
|
5
6
|
Auth: 'https://auth.dimo.zone',
|
|
6
7
|
Identity: 'https://identity-api.dimo.zone/query',
|
|
@@ -14,6 +15,7 @@ export const DimoEnvironment = {
|
|
|
14
15
|
VehicleTriggers: 'https://vehicle-triggers-api.dimo.zone',
|
|
15
16
|
},
|
|
16
17
|
Dev: {
|
|
18
|
+
Agents: 'https://agents.dev.dimo.zone',
|
|
17
19
|
Attestation: 'https://attestation-api.dev.dimo.zone',
|
|
18
20
|
Auth: 'https://auth.dev.dimo.zone',
|
|
19
21
|
Identity: 'https://identity-api.dev.dimo.zone/query',
|
package/dist/esm/index.js
CHANGED
|
@@ -20162,6 +20162,7 @@ const {
|
|
|
20162
20162
|
/** @format */
|
|
20163
20163
|
const DimoEnvironment = {
|
|
20164
20164
|
Production: {
|
|
20165
|
+
Agents: 'https://agents.dimo.zone',
|
|
20165
20166
|
Attestation: 'https://attestation-api.dimo.zone',
|
|
20166
20167
|
Auth: 'https://auth.dimo.zone',
|
|
20167
20168
|
Identity: 'https://identity-api.dimo.zone/query',
|
|
@@ -20175,6 +20176,7 @@ const DimoEnvironment = {
|
|
|
20175
20176
|
VehicleTriggers: 'https://vehicle-triggers-api.dimo.zone',
|
|
20176
20177
|
},
|
|
20177
20178
|
Dev: {
|
|
20179
|
+
Agents: 'https://agents.dev.dimo.zone',
|
|
20178
20180
|
Attestation: 'https://attestation-api.dev.dimo.zone',
|
|
20179
20181
|
Auth: 'https://auth.dev.dimo.zone',
|
|
20180
20182
|
Identity: 'https://identity-api.dev.dimo.zone/query',
|
|
@@ -20630,6 +20632,7 @@ class Telemetry extends Resource$1 {
|
|
|
20630
20632
|
/** @format */
|
|
20631
20633
|
// import { Stream } from './streamr';
|
|
20632
20634
|
class DIMO {
|
|
20635
|
+
agents;
|
|
20633
20636
|
attestation;
|
|
20634
20637
|
auth;
|
|
20635
20638
|
devicedefinitions;
|
|
@@ -20646,6 +20649,7 @@ class DIMO {
|
|
|
20646
20649
|
/**
|
|
20647
20650
|
* Set up all REST Endpoints
|
|
20648
20651
|
*/
|
|
20652
|
+
this.agents = new Agents(DimoEnvironment[env].Agents, env);
|
|
20649
20653
|
this.attestation = new Attestation(DimoEnvironment[env].Attestation, env);
|
|
20650
20654
|
this.auth = new Auth(DimoEnvironment[env].Auth, env);
|
|
20651
20655
|
this.devicedefinitions = new DeviceDefinitions(DimoEnvironment[env].DeviceDefinitions, env);
|
|
@@ -142420,14 +142424,19 @@ const Method = async (resource, baseUrl, params = {}, env) => {
|
|
|
142420
142424
|
let body = {};
|
|
142421
142425
|
if (resource.body) {
|
|
142422
142426
|
for (const key in resource.body) {
|
|
142423
|
-
if (
|
|
142427
|
+
if (resource.body[key] === true) {
|
|
142428
|
+
// Required field
|
|
142424
142429
|
if (!params[key]) {
|
|
142425
142430
|
console.error(`Missing required body parameter: ${key}`);
|
|
142426
142431
|
throw new DimoError({
|
|
142427
142432
|
message: `Missing required body parameter: ${key}`
|
|
142428
142433
|
});
|
|
142429
142434
|
}
|
|
142430
|
-
|
|
142435
|
+
body[key] = params[key];
|
|
142436
|
+
}
|
|
142437
|
+
else if (resource.body[key] === false) {
|
|
142438
|
+
// Optional field - include only if provided
|
|
142439
|
+
if (params[key] !== undefined) {
|
|
142431
142440
|
body[key] = params[key];
|
|
142432
142441
|
}
|
|
142433
142442
|
}
|
|
@@ -142485,6 +142494,69 @@ class Resource {
|
|
|
142485
142494
|
}
|
|
142486
142495
|
}
|
|
142487
142496
|
|
|
142497
|
+
class Agents extends Resource {
|
|
142498
|
+
constructor(api, env) {
|
|
142499
|
+
super(api, 'Agents', env);
|
|
142500
|
+
this.setResource({
|
|
142501
|
+
healthCheck: {
|
|
142502
|
+
method: 'GET',
|
|
142503
|
+
path: '/'
|
|
142504
|
+
},
|
|
142505
|
+
createAgent: {
|
|
142506
|
+
method: 'POST',
|
|
142507
|
+
path: '/agents',
|
|
142508
|
+
body: {
|
|
142509
|
+
'type': false,
|
|
142510
|
+
'personality': false,
|
|
142511
|
+
'secrets': true,
|
|
142512
|
+
'variables': true,
|
|
142513
|
+
},
|
|
142514
|
+
auth: 'developer_jwt'
|
|
142515
|
+
},
|
|
142516
|
+
deleteAgent: {
|
|
142517
|
+
method: 'DELETE',
|
|
142518
|
+
path: '/agents/:agentId',
|
|
142519
|
+
auth: 'developer_jwt'
|
|
142520
|
+
},
|
|
142521
|
+
sendMessage: {
|
|
142522
|
+
method: 'POST',
|
|
142523
|
+
path: '/agents/:agentId/message',
|
|
142524
|
+
body: {
|
|
142525
|
+
'message': true,
|
|
142526
|
+
'vehicleIds': false,
|
|
142527
|
+
'user': false
|
|
142528
|
+
},
|
|
142529
|
+
auth: 'developer_jwt'
|
|
142530
|
+
},
|
|
142531
|
+
streamMessage: {
|
|
142532
|
+
method: 'POST',
|
|
142533
|
+
path: '/agents/:agentId/stream',
|
|
142534
|
+
body: {
|
|
142535
|
+
'message': true,
|
|
142536
|
+
'vehicleIds': false,
|
|
142537
|
+
'user': false
|
|
142538
|
+
},
|
|
142539
|
+
auth: 'developer_jwt'
|
|
142540
|
+
},
|
|
142541
|
+
getHistory: {
|
|
142542
|
+
method: 'GET',
|
|
142543
|
+
path: '/agents/:agentId/history',
|
|
142544
|
+
queryParams: {
|
|
142545
|
+
'limit': false
|
|
142546
|
+
},
|
|
142547
|
+
auth: 'developer_jwt'
|
|
142548
|
+
}
|
|
142549
|
+
});
|
|
142550
|
+
const originalCreateAgent = this.createAgent;
|
|
142551
|
+
this.createAgent = (params = {}) => {
|
|
142552
|
+
return originalCreateAgent({
|
|
142553
|
+
type: 'driver_agent_v1',
|
|
142554
|
+
...params
|
|
142555
|
+
});
|
|
142556
|
+
};
|
|
142557
|
+
}
|
|
142558
|
+
}
|
|
142559
|
+
|
|
142488
142560
|
class Attestation extends Resource {
|
|
142489
142561
|
constructor(api, env) {
|
|
142490
142562
|
super(api, 'Attestation', env);
|
|
@@ -142741,5 +142813,5 @@ class VehicleTriggers extends Resource {
|
|
|
142741
142813
|
}
|
|
142742
142814
|
}
|
|
142743
142815
|
|
|
142744
|
-
export { Attestation, Auth, DIMO, DeviceDefinitions, Devices, DimoConstants, DimoEnvironment, DimoError, Identity, Telemetry, TokenExchange, Trips, Valuations, VehicleTriggers };
|
|
142816
|
+
export { Agents, Attestation, Auth, DIMO, DeviceDefinitions, Devices, DimoConstants, DimoEnvironment, DimoError, Identity, Telemetry, TokenExchange, Trips, Valuations, VehicleTriggers };
|
|
142745
142817
|
//# sourceMappingURL=index.js.map
|