@dimo-network/data-sdk 1.4.0 → 1.5.2
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 +3 -1
- package/dist/api/resources/DimoRestResources.js +3 -1
- package/dist/api/resources/Fetch/index.d.ts +5 -0
- package/dist/api/resources/Fetch/index.js +64 -0
- package/dist/cjs/index.js +144 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/dimo.d.ts +3 -1
- package/dist/dimo.js +5 -1
- package/dist/dimo.test.js +4 -0
- package/dist/environments/index.d.ts +4 -0
- package/dist/environments/index.js +4 -0
- package/dist/esm/index.js +143 -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 +3 -1
- package/dist/types/api/resources/Fetch/index.d.ts +5 -0
- package/dist/types/dimo.d.ts +3 -1
- package/dist/types/environments/index.d.ts +4 -0
- package/package.json +3 -2
package/dist/dimo.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
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, Fetch, 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;
|
|
9
10
|
devices: Devices;
|
|
11
|
+
fetch: Fetch;
|
|
10
12
|
identity: Identity;
|
|
11
13
|
telemetry: Telemetry;
|
|
12
14
|
tokenexchange: TokenExchange;
|
package/dist/dimo.js
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
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, Fetch, 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;
|
|
11
12
|
devices;
|
|
13
|
+
fetch;
|
|
12
14
|
identity;
|
|
13
15
|
telemetry;
|
|
14
16
|
tokenexchange;
|
|
@@ -21,10 +23,12 @@ export class DIMO {
|
|
|
21
23
|
/**
|
|
22
24
|
* Set up all REST Endpoints
|
|
23
25
|
*/
|
|
26
|
+
this.agents = new Agents(DimoEnvironment[env].Agents, env);
|
|
24
27
|
this.attestation = new Attestation(DimoEnvironment[env].Attestation, env);
|
|
25
28
|
this.auth = new Auth(DimoEnvironment[env].Auth, env);
|
|
26
29
|
this.devicedefinitions = new DeviceDefinitions(DimoEnvironment[env].DeviceDefinitions, env);
|
|
27
30
|
this.devices = new Devices(DimoEnvironment[env].Devices, env);
|
|
31
|
+
this.fetch = new Fetch(DimoEnvironment[env].Fetch, env);
|
|
28
32
|
this.tokenexchange = new TokenExchange(DimoEnvironment[env].TokenExchange, env);
|
|
29
33
|
this.trips = new Trips(DimoEnvironment[env].Trips, env);
|
|
30
34
|
this.valuations = new Valuations(DimoEnvironment[env].Valuations, 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,11 +1,13 @@
|
|
|
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";
|
|
7
8
|
readonly Devices: "https://devices-api.dimo.zone";
|
|
8
9
|
readonly DeviceDefinitions: "https://device-definitions-api.dimo.zone";
|
|
10
|
+
readonly Fetch: "https://fetch-api.dimo.zone";
|
|
9
11
|
readonly Telemetry: "https://telemetry-api.dimo.zone/query";
|
|
10
12
|
readonly TokenExchange: "https://token-exchange-api.dimo.zone";
|
|
11
13
|
readonly Trips: "https://trips-api.dimo.zone";
|
|
@@ -14,11 +16,13 @@ export declare const DimoEnvironment: {
|
|
|
14
16
|
readonly VehicleTriggers: "https://vehicle-triggers-api.dimo.zone";
|
|
15
17
|
};
|
|
16
18
|
readonly Dev: {
|
|
19
|
+
readonly Agents: "https://agents.dev.dimo.zone";
|
|
17
20
|
readonly Attestation: "https://attestation-api.dev.dimo.zone";
|
|
18
21
|
readonly Auth: "https://auth.dev.dimo.zone";
|
|
19
22
|
readonly Identity: "https://identity-api.dev.dimo.zone/query";
|
|
20
23
|
readonly Devices: "https://devices-api.dev.dimo.zone";
|
|
21
24
|
readonly DeviceDefinitions: "https://device-definitions-api.dev.dimo.zone";
|
|
25
|
+
readonly Fetch: "https://fetch-api.dev.dimo.zone";
|
|
22
26
|
readonly Telemetry: "https://telemetry-api.dev.dimo.zone/query";
|
|
23
27
|
readonly TokenExchange: "https://token-exchange-api.dev.dimo.zone";
|
|
24
28
|
readonly Trips: "https://trips-api.dev.dimo.zone";
|
|
@@ -1,11 +1,13 @@
|
|
|
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',
|
|
7
8
|
Devices: 'https://devices-api.dimo.zone',
|
|
8
9
|
DeviceDefinitions: 'https://device-definitions-api.dimo.zone',
|
|
10
|
+
Fetch: 'https://fetch-api.dimo.zone',
|
|
9
11
|
Telemetry: 'https://telemetry-api.dimo.zone/query',
|
|
10
12
|
TokenExchange: 'https://token-exchange-api.dimo.zone',
|
|
11
13
|
Trips: 'https://trips-api.dimo.zone',
|
|
@@ -14,11 +16,13 @@ export const DimoEnvironment = {
|
|
|
14
16
|
VehicleTriggers: 'https://vehicle-triggers-api.dimo.zone',
|
|
15
17
|
},
|
|
16
18
|
Dev: {
|
|
19
|
+
Agents: 'https://agents.dev.dimo.zone',
|
|
17
20
|
Attestation: 'https://attestation-api.dev.dimo.zone',
|
|
18
21
|
Auth: 'https://auth.dev.dimo.zone',
|
|
19
22
|
Identity: 'https://identity-api.dev.dimo.zone/query',
|
|
20
23
|
Devices: 'https://devices-api.dev.dimo.zone',
|
|
21
24
|
DeviceDefinitions: 'https://device-definitions-api.dev.dimo.zone',
|
|
25
|
+
Fetch: 'https://fetch-api.dev.dimo.zone',
|
|
22
26
|
Telemetry: 'https://telemetry-api.dev.dimo.zone/query',
|
|
23
27
|
TokenExchange: 'https://token-exchange-api.dev.dimo.zone',
|
|
24
28
|
Trips: 'https://trips-api.dev.dimo.zone',
|
package/dist/esm/index.js
CHANGED
|
@@ -20162,11 +20162,13 @@ 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',
|
|
20168
20169
|
Devices: 'https://devices-api.dimo.zone',
|
|
20169
20170
|
DeviceDefinitions: 'https://device-definitions-api.dimo.zone',
|
|
20171
|
+
Fetch: 'https://fetch-api.dimo.zone',
|
|
20170
20172
|
Telemetry: 'https://telemetry-api.dimo.zone/query',
|
|
20171
20173
|
TokenExchange: 'https://token-exchange-api.dimo.zone',
|
|
20172
20174
|
Trips: 'https://trips-api.dimo.zone',
|
|
@@ -20175,11 +20177,13 @@ const DimoEnvironment = {
|
|
|
20175
20177
|
VehicleTriggers: 'https://vehicle-triggers-api.dimo.zone',
|
|
20176
20178
|
},
|
|
20177
20179
|
Dev: {
|
|
20180
|
+
Agents: 'https://agents.dev.dimo.zone',
|
|
20178
20181
|
Attestation: 'https://attestation-api.dev.dimo.zone',
|
|
20179
20182
|
Auth: 'https://auth.dev.dimo.zone',
|
|
20180
20183
|
Identity: 'https://identity-api.dev.dimo.zone/query',
|
|
20181
20184
|
Devices: 'https://devices-api.dev.dimo.zone',
|
|
20182
20185
|
DeviceDefinitions: 'https://device-definitions-api.dev.dimo.zone',
|
|
20186
|
+
Fetch: 'https://fetch-api.dev.dimo.zone',
|
|
20183
20187
|
Telemetry: 'https://telemetry-api.dev.dimo.zone/query',
|
|
20184
20188
|
TokenExchange: 'https://token-exchange-api.dev.dimo.zone',
|
|
20185
20189
|
Trips: 'https://trips-api.dev.dimo.zone',
|
|
@@ -20630,10 +20634,12 @@ class Telemetry extends Resource$1 {
|
|
|
20630
20634
|
/** @format */
|
|
20631
20635
|
// import { Stream } from './streamr';
|
|
20632
20636
|
class DIMO {
|
|
20637
|
+
agents;
|
|
20633
20638
|
attestation;
|
|
20634
20639
|
auth;
|
|
20635
20640
|
devicedefinitions;
|
|
20636
20641
|
devices;
|
|
20642
|
+
fetch;
|
|
20637
20643
|
identity;
|
|
20638
20644
|
telemetry;
|
|
20639
20645
|
tokenexchange;
|
|
@@ -20646,10 +20652,12 @@ class DIMO {
|
|
|
20646
20652
|
/**
|
|
20647
20653
|
* Set up all REST Endpoints
|
|
20648
20654
|
*/
|
|
20655
|
+
this.agents = new Agents(DimoEnvironment[env].Agents, env);
|
|
20649
20656
|
this.attestation = new Attestation(DimoEnvironment[env].Attestation, env);
|
|
20650
20657
|
this.auth = new Auth(DimoEnvironment[env].Auth, env);
|
|
20651
20658
|
this.devicedefinitions = new DeviceDefinitions(DimoEnvironment[env].DeviceDefinitions, env);
|
|
20652
20659
|
this.devices = new Devices(DimoEnvironment[env].Devices, env);
|
|
20660
|
+
this.fetch = new Fetch(DimoEnvironment[env].Fetch, env);
|
|
20653
20661
|
this.tokenexchange = new TokenExchange(DimoEnvironment[env].TokenExchange, env);
|
|
20654
20662
|
this.trips = new Trips(DimoEnvironment[env].Trips, env);
|
|
20655
20663
|
this.valuations = new Valuations(DimoEnvironment[env].Valuations, env);
|
|
@@ -142420,14 +142428,19 @@ const Method = async (resource, baseUrl, params = {}, env) => {
|
|
|
142420
142428
|
let body = {};
|
|
142421
142429
|
if (resource.body) {
|
|
142422
142430
|
for (const key in resource.body) {
|
|
142423
|
-
if (
|
|
142431
|
+
if (resource.body[key] === true) {
|
|
142432
|
+
// Required field
|
|
142424
142433
|
if (!params[key]) {
|
|
142425
142434
|
console.error(`Missing required body parameter: ${key}`);
|
|
142426
142435
|
throw new DimoError({
|
|
142427
142436
|
message: `Missing required body parameter: ${key}`
|
|
142428
142437
|
});
|
|
142429
142438
|
}
|
|
142430
|
-
|
|
142439
|
+
body[key] = params[key];
|
|
142440
|
+
}
|
|
142441
|
+
else if (resource.body[key] === false) {
|
|
142442
|
+
// Optional field - include only if provided
|
|
142443
|
+
if (params[key] !== undefined) {
|
|
142431
142444
|
body[key] = params[key];
|
|
142432
142445
|
}
|
|
142433
142446
|
}
|
|
@@ -142485,6 +142498,69 @@ class Resource {
|
|
|
142485
142498
|
}
|
|
142486
142499
|
}
|
|
142487
142500
|
|
|
142501
|
+
class Agents extends Resource {
|
|
142502
|
+
constructor(api, env) {
|
|
142503
|
+
super(api, 'Agents', env);
|
|
142504
|
+
this.setResource({
|
|
142505
|
+
healthCheck: {
|
|
142506
|
+
method: 'GET',
|
|
142507
|
+
path: '/'
|
|
142508
|
+
},
|
|
142509
|
+
createAgent: {
|
|
142510
|
+
method: 'POST',
|
|
142511
|
+
path: '/agents',
|
|
142512
|
+
body: {
|
|
142513
|
+
'type': false,
|
|
142514
|
+
'personality': false,
|
|
142515
|
+
'secrets': true,
|
|
142516
|
+
'variables': true,
|
|
142517
|
+
},
|
|
142518
|
+
auth: 'developer_jwt'
|
|
142519
|
+
},
|
|
142520
|
+
deleteAgent: {
|
|
142521
|
+
method: 'DELETE',
|
|
142522
|
+
path: '/agents/:agentId',
|
|
142523
|
+
auth: 'developer_jwt'
|
|
142524
|
+
},
|
|
142525
|
+
sendMessage: {
|
|
142526
|
+
method: 'POST',
|
|
142527
|
+
path: '/agents/:agentId/message',
|
|
142528
|
+
body: {
|
|
142529
|
+
'message': true,
|
|
142530
|
+
'vehicleIds': false,
|
|
142531
|
+
'user': false
|
|
142532
|
+
},
|
|
142533
|
+
auth: 'developer_jwt'
|
|
142534
|
+
},
|
|
142535
|
+
streamMessage: {
|
|
142536
|
+
method: 'POST',
|
|
142537
|
+
path: '/agents/:agentId/stream',
|
|
142538
|
+
body: {
|
|
142539
|
+
'message': true,
|
|
142540
|
+
'vehicleIds': false,
|
|
142541
|
+
'user': false
|
|
142542
|
+
},
|
|
142543
|
+
auth: 'developer_jwt'
|
|
142544
|
+
},
|
|
142545
|
+
getHistory: {
|
|
142546
|
+
method: 'GET',
|
|
142547
|
+
path: '/agents/:agentId/history',
|
|
142548
|
+
queryParams: {
|
|
142549
|
+
'limit': false
|
|
142550
|
+
},
|
|
142551
|
+
auth: 'developer_jwt'
|
|
142552
|
+
}
|
|
142553
|
+
});
|
|
142554
|
+
const originalCreateAgent = this.createAgent;
|
|
142555
|
+
this.createAgent = (params = {}) => {
|
|
142556
|
+
return originalCreateAgent({
|
|
142557
|
+
type: 'driver_agent_v1',
|
|
142558
|
+
...params
|
|
142559
|
+
});
|
|
142560
|
+
};
|
|
142561
|
+
}
|
|
142562
|
+
}
|
|
142563
|
+
|
|
142488
142564
|
class Attestation extends Resource {
|
|
142489
142565
|
constructor(api, env) {
|
|
142490
142566
|
super(api, 'Attestation', env);
|
|
@@ -142601,6 +142677,70 @@ class Devices extends Resource {
|
|
|
142601
142677
|
}
|
|
142602
142678
|
}
|
|
142603
142679
|
|
|
142680
|
+
class Fetch extends Resource {
|
|
142681
|
+
constructor(api, env) {
|
|
142682
|
+
super(api, 'Fetch', env);
|
|
142683
|
+
this.setResource({
|
|
142684
|
+
getIndexKeys: {
|
|
142685
|
+
method: 'GET',
|
|
142686
|
+
path: '/v1/vehicle/index-keys/:tokenId',
|
|
142687
|
+
queryParams: {
|
|
142688
|
+
after: false,
|
|
142689
|
+
before: false,
|
|
142690
|
+
id: false,
|
|
142691
|
+
limit: false,
|
|
142692
|
+
producer: false,
|
|
142693
|
+
source: false,
|
|
142694
|
+
type: false
|
|
142695
|
+
},
|
|
142696
|
+
auth: 'vehicle_jwt'
|
|
142697
|
+
},
|
|
142698
|
+
getLatestIndexKey: {
|
|
142699
|
+
method: 'GET',
|
|
142700
|
+
path: '/v1/vehicle/latest-index-key/:tokenId',
|
|
142701
|
+
queryParams: {
|
|
142702
|
+
after: false,
|
|
142703
|
+
before: false,
|
|
142704
|
+
id: false,
|
|
142705
|
+
limit: false,
|
|
142706
|
+
producer: false,
|
|
142707
|
+
source: false,
|
|
142708
|
+
type: false
|
|
142709
|
+
},
|
|
142710
|
+
auth: 'vehicle_jwt'
|
|
142711
|
+
},
|
|
142712
|
+
getLatestObject: {
|
|
142713
|
+
method: 'GET',
|
|
142714
|
+
path: '/v1/vehicle/latest-object/:tokenId',
|
|
142715
|
+
queryParams: {
|
|
142716
|
+
after: false,
|
|
142717
|
+
before: false,
|
|
142718
|
+
id: false,
|
|
142719
|
+
limit: false,
|
|
142720
|
+
producer: false,
|
|
142721
|
+
source: false,
|
|
142722
|
+
type: false
|
|
142723
|
+
},
|
|
142724
|
+
auth: 'vehicle_jwt'
|
|
142725
|
+
},
|
|
142726
|
+
getObjects: {
|
|
142727
|
+
method: 'GET',
|
|
142728
|
+
path: '/v1/vehicle/objects/:tokenId',
|
|
142729
|
+
queryParams: {
|
|
142730
|
+
after: false,
|
|
142731
|
+
before: false,
|
|
142732
|
+
id: false,
|
|
142733
|
+
limit: false,
|
|
142734
|
+
producer: false,
|
|
142735
|
+
source: false,
|
|
142736
|
+
type: false
|
|
142737
|
+
},
|
|
142738
|
+
auth: 'vehicle_jwt'
|
|
142739
|
+
}
|
|
142740
|
+
});
|
|
142741
|
+
}
|
|
142742
|
+
}
|
|
142743
|
+
|
|
142604
142744
|
class TokenExchange extends Resource {
|
|
142605
142745
|
constructor(api, env) {
|
|
142606
142746
|
super(api, 'TokenExchange', env);
|
|
@@ -142741,5 +142881,5 @@ class VehicleTriggers extends Resource {
|
|
|
142741
142881
|
}
|
|
142742
142882
|
}
|
|
142743
142883
|
|
|
142744
|
-
export { Attestation, Auth, DIMO, DeviceDefinitions, Devices, DimoConstants, DimoEnvironment, DimoError, Identity, Telemetry, TokenExchange, Trips, Valuations, VehicleTriggers };
|
|
142884
|
+
export { Agents, Attestation, Auth, DIMO, DeviceDefinitions, Devices, DimoConstants, DimoEnvironment, DimoError, Fetch, Identity, Telemetry, TokenExchange, Trips, Valuations, VehicleTriggers };
|
|
142745
142885
|
//# sourceMappingURL=index.js.map
|