@dimo-network/data-sdk 1.2.5 → 1.3.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/README.jp.md CHANGED
@@ -53,7 +53,7 @@ const dimo = new DIMO('Production');
53
53
  3. API キー(API Key)を生成し、希望するリダイレクト URI(RedirectURI)を追加します。
54
54
 
55
55
  ### 開発者認証
56
- SDK は、[認証フロー](https://docs.dimo.org/developer-platform/getting-started/developer-guide/authentication) に必要なすべての手順を提供し、「開発者 JWT」(Developer JWT) を取得し、アプリと共有されている各車両の「車両 JWT」(Vehicle JWT を取得することができます。
56
+ SDK は、「開発者用 JWT を取得するための[認証フロー](https://docs.dimo.org/developer-platform/getting-started/developer-guide/authentication) に必要なすべての手順」と、「アプリと共有された各車両に対して Vehicle JWT を取得するための手順」を提供します。
57
57
 
58
58
  #### 認証の前提条件
59
59
  1. 開発者ライセンス
@@ -83,4 +83,4 @@ const vehicleJwt = await dimo.tokenexchange.getVehicleJwt({
83
83
  ```
84
84
 
85
85
  ## SDK への貢献方法
86
- SDK への貢献についての詳細は、[こちら](https://github.com/DIMO-Network/data-sdk/blob/master/CONTRIBUTING.md)をご覧ください。
86
+ SDK への貢献についての詳細は、[こちら](https://github.com/DIMO-Network/data-sdk/blob/master/CONTRIBUTING.md)をご覧ください。
@@ -1,11 +1,11 @@
1
+ /** @format */
1
2
  import { DimoEnvironment } from '../environments';
2
- export interface Resource {
3
- [key: string]: (...args: any) => any;
4
- }
5
- export declare class Resource {
6
- api: any;
7
- resourceName: any;
8
- env: any;
9
- constructor(api: any, resourceName: string, env: keyof typeof DimoEnvironment);
10
- protected setResource(resources: any): void;
3
+ import { ResourceMap } from './types/Endpoint';
4
+ export declare class Resource<TApi = string> {
5
+ [key: string]: any;
6
+ api: TApi;
7
+ resourceName: string;
8
+ env: keyof typeof DimoEnvironment;
9
+ constructor(api: TApi, resourceName: string, env: keyof typeof DimoEnvironment);
10
+ protected setResource<T extends ResourceMap>(resources: T): void;
11
11
  }
@@ -1,3 +1,4 @@
1
+ /** @format */
1
2
  import { Method } from './Method';
2
3
  export class Resource {
3
4
  api;
@@ -9,12 +10,8 @@ export class Resource {
9
10
  this.env = env;
10
11
  }
11
12
  setResource(resources) {
12
- Object.keys(resources).forEach(key => {
13
- this[key] = (params = {}) => Method(resources[key], // Setup the endpoint resources
14
- this.api, // Setup the base URL
15
- params, // Pass through the params
16
- this.env // Identiy the environment
17
- );
13
+ Object.keys(resources).forEach((key) => {
14
+ this[key] = (params = {}) => Method(resources[key], this.api, params, this.env);
18
15
  });
19
16
  }
20
17
  }
@@ -1,3 +1,4 @@
1
+ /** @format */
1
2
  import { Attestation } from './Attestation';
2
3
  import { Auth } from './Auth';
3
4
  import { DeviceDefinitions } from './DeviceDefinitions';
@@ -5,4 +6,5 @@ import { Devices } from './Devices';
5
6
  import { TokenExchange } from './TokenExchange';
6
7
  import { Trips } from './Trips';
7
8
  import { Valuations } from './Valuations';
8
- export { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations };
9
+ import { VehicleEvents } from './VehicleEvents';
10
+ export { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleEvents, };
@@ -1,3 +1,4 @@
1
+ /** @format */
1
2
  import { Attestation } from './Attestation';
2
3
  import { Auth } from './Auth';
3
4
  import { DeviceDefinitions } from './DeviceDefinitions';
@@ -5,4 +6,5 @@ import { Devices } from './Devices';
5
6
  import { TokenExchange } from './TokenExchange';
6
7
  import { Trips } from './Trips';
7
8
  import { Valuations } from './Valuations';
8
- export { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations };
9
+ import { VehicleEvents } from './VehicleEvents';
10
+ export { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleEvents, };
@@ -0,0 +1,7 @@
1
+ /** @format */
2
+ import { Resource } from '../../Resource';
3
+ import { DimoEnvironment } from '../../../environments';
4
+ declare class VehicleEvents extends Resource {
5
+ constructor(api: any, env: keyof typeof DimoEnvironment);
6
+ }
7
+ export { VehicleEvents };
@@ -0,0 +1,85 @@
1
+ /** @format */
2
+ import { Resource } from '../../Resource';
3
+ class VehicleEvents extends Resource {
4
+ constructor(api, env) {
5
+ super(api, 'VehicleEvents', env);
6
+ this.setResource({
7
+ listWebhooks: {
8
+ method: 'GET',
9
+ path: '/v1/webhooks',
10
+ auth: 'developer_jwt',
11
+ },
12
+ createWebhook: {
13
+ method: 'POST',
14
+ path: '/v1/webhooks',
15
+ body: {
16
+ service: true,
17
+ data: true,
18
+ trigger: true,
19
+ setup: true,
20
+ description: false,
21
+ target_uri: true,
22
+ status: true,
23
+ verification_token: true,
24
+ },
25
+ auth: 'developer_jwt',
26
+ },
27
+ updateWebhook: {
28
+ method: 'PUT',
29
+ path: '/v1/webhooks/:webhookId',
30
+ body: {
31
+ service: true,
32
+ data: true,
33
+ trigger: true,
34
+ setup: true,
35
+ description: false,
36
+ target_uri: true,
37
+ status: true,
38
+ verification_token: true,
39
+ },
40
+ auth: 'developer_jwt',
41
+ },
42
+ deleteWebhook: {
43
+ method: 'DELETE',
44
+ path: '/v1/webhooks/:webhookId',
45
+ auth: 'developer_jwt',
46
+ },
47
+ getWebhookSignalNames: {
48
+ method: 'GET',
49
+ path: '/v1/webhooks/signals',
50
+ auth: 'developer_jwt',
51
+ },
52
+ listSubscribedVehicles: {
53
+ method: 'GET',
54
+ path: '/v1/webhooks/:webhookId',
55
+ auth: 'developer_jwt',
56
+ },
57
+ listVehicleSubscriptions: {
58
+ method: 'GET',
59
+ path: '/v1/webhooks/vehicles/:tokenId',
60
+ auth: 'developer_jwt',
61
+ },
62
+ subscribeVehicle: {
63
+ method: 'POST',
64
+ path: '/v1/webhooks/:webhookId/subscribe/:tokenId',
65
+ auth: 'developer_jwt',
66
+ },
67
+ subscribeAllVehicles: {
68
+ method: 'POST',
69
+ path: '/v1/webhooks/:webhookId/subscribe/all',
70
+ auth: 'developer_jwt',
71
+ },
72
+ unsubscribeVehicle: {
73
+ method: 'DELETE',
74
+ path: '/v1/webhooks/:webhookId/unsubscribe/:tokenId',
75
+ auth: 'developer_jwt',
76
+ },
77
+ unsubscribeAllVehicles: {
78
+ method: 'DELETE',
79
+ path: '/v1/webhooks/:webhookId/unsubscribe/all',
80
+ auth: 'developer_jwt',
81
+ },
82
+ });
83
+ }
84
+ }
85
+ export { VehicleEvents };
@@ -0,0 +1,11 @@
1
+ /** @format */
2
+ export type EndpointDefinition = {
3
+ method: "GET" | "POST" | "PUT" | "DELETE" | "FUNCTION";
4
+ path: string;
5
+ auth?: "developer_jwt" | "vehicle_jwt";
6
+ body?: Record<string, boolean | string | number>;
7
+ queryParams?: Record<string, boolean | string | number>;
8
+ headers?: Record<string, string>;
9
+ return?: string;
10
+ };
11
+ export type ResourceMap = Record<string, EndpointDefinition>;
@@ -0,0 +1,2 @@
1
+ /** @format */
2
+ export {};
package/dist/dimo.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { DimoEnvironment } from './environments';
2
- import { Identity, Telemetry } from './graphql/resources/DimoGraphqlResources';
3
- import { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations } from './api/resources/DimoRestResources';
1
+ /** @format */
2
+ import { DimoEnvironment } from "./environments";
3
+ import { Identity, Telemetry } from "./graphql/resources/DimoGraphqlResources";
4
+ import { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleEvents } from "./api/resources/DimoRestResources";
4
5
  export declare class DIMO {
5
6
  attestation: Attestation;
6
7
  auth: Auth;
@@ -11,6 +12,7 @@ export declare class DIMO {
11
12
  tokenexchange: TokenExchange;
12
13
  trips: Trips;
13
14
  valuations: Valuations;
15
+ vehicleEvents: VehicleEvents;
14
16
  constructor(env: keyof typeof DimoEnvironment);
15
17
  authenticate(): Promise<any>;
16
18
  }
package/dist/dimo.js CHANGED
@@ -1,7 +1,8 @@
1
- import { DimoEnvironment } from './environments';
2
- import { DimoError } from './errors';
3
- import { Identity, Telemetry } from './graphql/resources/DimoGraphqlResources';
4
- import { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations } from './api/resources/DimoRestResources';
1
+ /** @format */
2
+ import { DimoEnvironment } from "./environments";
3
+ import { DimoError } from "./errors";
4
+ import { Identity, Telemetry } from "./graphql/resources/DimoGraphqlResources";
5
+ import { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleEvents, } from "./api/resources/DimoRestResources";
5
6
  // import { Stream } from './streamr';
6
7
  export class DIMO {
7
8
  attestation;
@@ -13,6 +14,7 @@ export class DIMO {
13
14
  tokenexchange;
14
15
  trips;
15
16
  valuations;
17
+ vehicleEvents;
16
18
  constructor(env) {
17
19
  this.identity = new Identity(DimoEnvironment[env].Identity, env);
18
20
  this.telemetry = new Telemetry(DimoEnvironment[env].Telemetry, env);
@@ -26,26 +28,29 @@ export class DIMO {
26
28
  this.tokenexchange = new TokenExchange(DimoEnvironment[env].TokenExchange, env);
27
29
  this.trips = new Trips(DimoEnvironment[env].Trips, env);
28
30
  this.valuations = new Valuations(DimoEnvironment[env].Valuations, env);
31
+ this.vehicleEvents = new VehicleEvents(DimoEnvironment[env].VehicleEvents, env);
29
32
  }
30
33
  // Helper Function
31
34
  async authenticate() {
32
35
  let fs;
33
36
  try {
34
37
  // Dynamically import fs
35
- if (typeof process !== 'undefined' && process.versions && process.versions.node) {
36
- fs = await import('fs');
38
+ if (typeof process !== "undefined" &&
39
+ process.versions &&
40
+ process.versions.node) {
41
+ fs = await import("fs");
37
42
  }
38
43
  else {
39
44
  // Optionally handle the case where 'fs' is not available, returns null
40
- console.log('Not in Node.js environment; `fs` module is not available.');
45
+ console.log("Not in Node.js environment; `fs` module is not available.");
41
46
  return null;
42
47
  }
43
- if (!fs.existsSync('.credentials.json')) {
48
+ if (!fs.existsSync(".credentials.json")) {
44
49
  throw new DimoError({
45
- message: 'Credentials file does not exist'
50
+ message: "Credentials file does not exist",
46
51
  });
47
52
  }
48
- const data = fs.readFileSync('.credentials.json', 'utf8');
53
+ const data = fs.readFileSync(".credentials.json", "utf8");
49
54
  const credentials = JSON.parse(data);
50
55
  const authHeader = await this.auth.getDeveloperJwt({
51
56
  client_id: credentials.client_id,
@@ -56,10 +61,10 @@ export class DIMO {
56
61
  }
57
62
  catch (error) {
58
63
  // Handle file not existing and other errors
59
- console.error('Failed to authenticate:', error.message);
64
+ console.error("Failed to authenticate:", error.message);
60
65
  // Decide whether to throw the error or handle it differently
61
66
  throw new DimoError({
62
- message: 'Authentication failed'
67
+ message: "Authentication failed",
63
68
  });
64
69
  }
65
70
  }
@@ -1,3 +1,4 @@
1
+ /** @format */
1
2
  export declare const DimoEnvironment: {
2
3
  readonly Production: {
3
4
  readonly Attestation: "https://attestation-api.dimo.zone";
@@ -10,6 +11,7 @@ export declare const DimoEnvironment: {
10
11
  readonly Trips: "https://trips-api.dimo.zone";
11
12
  readonly Valuations: "https://valuations-api.dimo.zone";
12
13
  readonly VehicleSignalDecoding: "https://vehicle-signal-decoding.dimo.zone";
14
+ readonly VehicleEvents: "https://vehicle-events-api.dimo.zone";
13
15
  };
14
16
  readonly Dev: {
15
17
  readonly Attestation: "https://attestation-api.dev.dimo.zone";
@@ -22,6 +24,7 @@ export declare const DimoEnvironment: {
22
24
  readonly Trips: "https://trips-api.dev.dimo.zone";
23
25
  readonly Valuations: "https://valuations-api.dev.dimo.zone";
24
26
  readonly VehicleSignalDecoding: "https://vehicle-signal-decoding.dev.dimo.zone";
27
+ readonly VehicleEvents: "https://vehicle-events-api.dev.dimo.zone";
25
28
  };
26
29
  };
27
30
  export type DimoEnvironment = typeof DimoEnvironment.Production | typeof DimoEnvironment.Dev;
@@ -1,26 +1,29 @@
1
+ /** @format */
1
2
  export const DimoEnvironment = {
2
3
  Production: {
3
- 'Attestation': 'https://attestation-api.dimo.zone',
4
- 'Auth': 'https://auth.dimo.zone',
5
- 'Identity': 'https://identity-api.dimo.zone/query',
6
- 'Devices': 'https://devices-api.dimo.zone',
7
- 'DeviceDefinitions': 'https://device-definitions-api.dimo.zone',
8
- 'Telemetry': 'https://telemetry-api.dimo.zone/query',
9
- 'TokenExchange': 'https://token-exchange-api.dimo.zone',
10
- 'Trips': 'https://trips-api.dimo.zone',
11
- 'Valuations': 'https://valuations-api.dimo.zone',
12
- 'VehicleSignalDecoding': 'https://vehicle-signal-decoding.dimo.zone'
4
+ Attestation: 'https://attestation-api.dimo.zone',
5
+ Auth: 'https://auth.dimo.zone',
6
+ Identity: 'https://identity-api.dimo.zone/query',
7
+ Devices: 'https://devices-api.dimo.zone',
8
+ DeviceDefinitions: 'https://device-definitions-api.dimo.zone',
9
+ Telemetry: 'https://telemetry-api.dimo.zone/query',
10
+ TokenExchange: 'https://token-exchange-api.dimo.zone',
11
+ Trips: 'https://trips-api.dimo.zone',
12
+ Valuations: 'https://valuations-api.dimo.zone',
13
+ VehicleSignalDecoding: 'https://vehicle-signal-decoding.dimo.zone',
14
+ VehicleEvents: 'https://vehicle-events-api.dimo.zone',
13
15
  },
14
16
  Dev: {
15
- 'Attestation': 'https://attestation-api.dev.dimo.zone',
16
- 'Auth': 'https://auth.dev.dimo.zone',
17
- 'Identity': 'https://identity-api.dev.dimo.zone/query',
18
- 'Devices': 'https://devices-api.dev.dimo.zone',
19
- 'DeviceDefinitions': 'https://device-definitions-api.dev.dimo.zone',
20
- 'Telemetry': 'https://telemetry-api.dev.dimo.zone/query',
21
- 'TokenExchange': 'https://token-exchange-api.dev.dimo.zone',
22
- 'Trips': 'https://trips-api.dev.dimo.zone',
23
- 'Valuations': 'https://valuations-api.dev.dimo.zone',
24
- 'VehicleSignalDecoding': 'https://vehicle-signal-decoding.dev.dimo.zone'
25
- }
17
+ Attestation: 'https://attestation-api.dev.dimo.zone',
18
+ Auth: 'https://auth.dev.dimo.zone',
19
+ Identity: 'https://identity-api.dev.dimo.zone/query',
20
+ Devices: 'https://devices-api.dev.dimo.zone',
21
+ DeviceDefinitions: 'https://device-definitions-api.dev.dimo.zone',
22
+ Telemetry: 'https://telemetry-api.dev.dimo.zone/query',
23
+ TokenExchange: 'https://token-exchange-api.dev.dimo.zone',
24
+ Trips: 'https://trips-api.dev.dimo.zone',
25
+ Valuations: 'https://valuations-api.dev.dimo.zone',
26
+ VehicleSignalDecoding: 'https://vehicle-signal-decoding.dev.dimo.zone',
27
+ VehicleEvents: 'https://vehicle-events-api.dev.dimo.zone',
28
+ },
26
29
  };
@@ -1,3 +1,3 @@
1
- import { getVehiclePrivileges } from "./getVehiclePrivileges";
2
- import { getVin } from "./getVin";
1
+ import { getVehiclePrivileges } from './getVehiclePrivileges';
2
+ import { getVin } from './getVin';
3
3
  export { getVehiclePrivileges, getVin };
@@ -1,3 +1,3 @@
1
- import { getVehiclePrivileges } from "./getVehiclePrivileges";
2
- import { getVin } from "./getVin";
1
+ import { getVehiclePrivileges } from './getVehiclePrivileges';
2
+ import { getVin } from './getVin';
3
3
  export { getVehiclePrivileges, getVin };
package/dist/index.cjs CHANGED
@@ -22009,31 +22009,34 @@ const {
22009
22009
  mergeConfig
22010
22010
  } = axios;
22011
22011
 
22012
+ /** @format */
22012
22013
  const DimoEnvironment = {
22013
22014
  Production: {
22014
- 'Attestation': 'https://attestation-api.dimo.zone',
22015
- 'Auth': 'https://auth.dimo.zone',
22016
- 'Identity': 'https://identity-api.dimo.zone/query',
22017
- 'Devices': 'https://devices-api.dimo.zone',
22018
- 'DeviceDefinitions': 'https://device-definitions-api.dimo.zone',
22019
- 'Telemetry': 'https://telemetry-api.dimo.zone/query',
22020
- 'TokenExchange': 'https://token-exchange-api.dimo.zone',
22021
- 'Trips': 'https://trips-api.dimo.zone',
22022
- 'Valuations': 'https://valuations-api.dimo.zone',
22023
- 'VehicleSignalDecoding': 'https://vehicle-signal-decoding.dimo.zone'
22015
+ Attestation: 'https://attestation-api.dimo.zone',
22016
+ Auth: 'https://auth.dimo.zone',
22017
+ Identity: 'https://identity-api.dimo.zone/query',
22018
+ Devices: 'https://devices-api.dimo.zone',
22019
+ DeviceDefinitions: 'https://device-definitions-api.dimo.zone',
22020
+ Telemetry: 'https://telemetry-api.dimo.zone/query',
22021
+ TokenExchange: 'https://token-exchange-api.dimo.zone',
22022
+ Trips: 'https://trips-api.dimo.zone',
22023
+ Valuations: 'https://valuations-api.dimo.zone',
22024
+ VehicleSignalDecoding: 'https://vehicle-signal-decoding.dimo.zone',
22025
+ VehicleEvents: 'https://vehicle-events-api.dimo.zone',
22024
22026
  },
22025
22027
  Dev: {
22026
- 'Attestation': 'https://attestation-api.dev.dimo.zone',
22027
- 'Auth': 'https://auth.dev.dimo.zone',
22028
- 'Identity': 'https://identity-api.dev.dimo.zone/query',
22029
- 'Devices': 'https://devices-api.dev.dimo.zone',
22030
- 'DeviceDefinitions': 'https://device-definitions-api.dev.dimo.zone',
22031
- 'Telemetry': 'https://telemetry-api.dev.dimo.zone/query',
22032
- 'TokenExchange': 'https://token-exchange-api.dev.dimo.zone',
22033
- 'Trips': 'https://trips-api.dev.dimo.zone',
22034
- 'Valuations': 'https://valuations-api.dev.dimo.zone',
22035
- 'VehicleSignalDecoding': 'https://vehicle-signal-decoding.dev.dimo.zone'
22036
- }
22028
+ Attestation: 'https://attestation-api.dev.dimo.zone',
22029
+ Auth: 'https://auth.dev.dimo.zone',
22030
+ Identity: 'https://identity-api.dev.dimo.zone/query',
22031
+ Devices: 'https://devices-api.dev.dimo.zone',
22032
+ DeviceDefinitions: 'https://device-definitions-api.dev.dimo.zone',
22033
+ Telemetry: 'https://telemetry-api.dev.dimo.zone/query',
22034
+ TokenExchange: 'https://token-exchange-api.dev.dimo.zone',
22035
+ Trips: 'https://trips-api.dev.dimo.zone',
22036
+ Valuations: 'https://valuations-api.dev.dimo.zone',
22037
+ VehicleSignalDecoding: 'https://vehicle-signal-decoding.dev.dimo.zone',
22038
+ VehicleEvents: 'https://vehicle-events-api.dev.dimo.zone',
22039
+ },
22037
22040
  };
22038
22041
 
22039
22042
  class DimoError extends Error {
@@ -22474,6 +22477,7 @@ class Telemetry extends Resource$1 {
22474
22477
  }
22475
22478
  }
22476
22479
 
22480
+ /** @format */
22477
22481
  // import { Stream } from './streamr';
22478
22482
  class DIMO {
22479
22483
  attestation;
@@ -22485,6 +22489,7 @@ class DIMO {
22485
22489
  tokenexchange;
22486
22490
  trips;
22487
22491
  valuations;
22492
+ vehicleEvents;
22488
22493
  constructor(env) {
22489
22494
  this.identity = new Identity(DimoEnvironment[env].Identity, env);
22490
22495
  this.telemetry = new Telemetry(DimoEnvironment[env].Telemetry, env);
@@ -22498,26 +22503,29 @@ class DIMO {
22498
22503
  this.tokenexchange = new TokenExchange(DimoEnvironment[env].TokenExchange, env);
22499
22504
  this.trips = new Trips(DimoEnvironment[env].Trips, env);
22500
22505
  this.valuations = new Valuations(DimoEnvironment[env].Valuations, env);
22506
+ this.vehicleEvents = new VehicleEvents(DimoEnvironment[env].VehicleEvents, env);
22501
22507
  }
22502
22508
  // Helper Function
22503
22509
  async authenticate() {
22504
22510
  let fs;
22505
22511
  try {
22506
22512
  // Dynamically import fs
22507
- if (typeof process !== 'undefined' && process.versions && process.versions.node) {
22513
+ if (typeof process !== "undefined" &&
22514
+ process.versions &&
22515
+ process.versions.node) {
22508
22516
  fs = await import('fs');
22509
22517
  }
22510
22518
  else {
22511
22519
  // Optionally handle the case where 'fs' is not available, returns null
22512
- console.log('Not in Node.js environment; `fs` module is not available.');
22520
+ console.log("Not in Node.js environment; `fs` module is not available.");
22513
22521
  return null;
22514
22522
  }
22515
- if (!fs.existsSync('.credentials.json')) {
22523
+ if (!fs.existsSync(".credentials.json")) {
22516
22524
  throw new DimoError({
22517
- message: 'Credentials file does not exist'
22525
+ message: "Credentials file does not exist",
22518
22526
  });
22519
22527
  }
22520
- const data = fs.readFileSync('.credentials.json', 'utf8');
22528
+ const data = fs.readFileSync(".credentials.json", "utf8");
22521
22529
  const credentials = JSON.parse(data);
22522
22530
  const authHeader = await this.auth.getDeveloperJwt({
22523
22531
  client_id: credentials.client_id,
@@ -22528,10 +22536,10 @@ class DIMO {
22528
22536
  }
22529
22537
  catch (error) {
22530
22538
  // Handle file not existing and other errors
22531
- console.error('Failed to authenticate:', error.message);
22539
+ console.error("Failed to authenticate:", error.message);
22532
22540
  // Decide whether to throw the error or handle it differently
22533
22541
  throw new DimoError({
22534
- message: 'Authentication failed'
22542
+ message: "Authentication failed",
22535
22543
  });
22536
22544
  }
22537
22545
  }
@@ -144220,6 +144228,7 @@ const Method = async (resource, baseUrl, params = {}, env) => {
144220
144228
  }
144221
144229
  };
144222
144230
 
144231
+ /** @format */
144223
144232
  class Resource {
144224
144233
  api;
144225
144234
  resourceName;
@@ -144230,12 +144239,8 @@ class Resource {
144230
144239
  this.env = env;
144231
144240
  }
144232
144241
  setResource(resources) {
144233
- Object.keys(resources).forEach(key => {
144234
- this[key] = (params = {}) => Method(resources[key], // Setup the endpoint resources
144235
- this.api, // Setup the base URL
144236
- params, // Pass through the params
144237
- this.env // Identiy the environment
144238
- );
144242
+ Object.keys(resources).forEach((key) => {
144243
+ this[key] = (params = {}) => Method(resources[key], this.api, params, this.env);
144239
144244
  });
144240
144245
  }
144241
144246
  }
@@ -144401,6 +144406,90 @@ class Valuations extends Resource {
144401
144406
  }
144402
144407
  }
144403
144408
 
144409
+ /** @format */
144410
+ class VehicleEvents extends Resource {
144411
+ constructor(api, env) {
144412
+ super(api, 'VehicleEvents', env);
144413
+ this.setResource({
144414
+ listWebhooks: {
144415
+ method: 'GET',
144416
+ path: '/v1/webhooks',
144417
+ auth: 'developer_jwt',
144418
+ },
144419
+ createWebhook: {
144420
+ method: 'POST',
144421
+ path: '/v1/webhooks',
144422
+ body: {
144423
+ service: true,
144424
+ data: true,
144425
+ trigger: true,
144426
+ setup: true,
144427
+ description: false,
144428
+ target_uri: true,
144429
+ status: true,
144430
+ verification_token: true,
144431
+ },
144432
+ auth: 'developer_jwt',
144433
+ },
144434
+ updateWebhook: {
144435
+ method: 'PUT',
144436
+ path: '/v1/webhooks/:webhookId',
144437
+ body: {
144438
+ service: true,
144439
+ data: true,
144440
+ trigger: true,
144441
+ setup: true,
144442
+ description: false,
144443
+ target_uri: true,
144444
+ status: true,
144445
+ verification_token: true,
144446
+ },
144447
+ auth: 'developer_jwt',
144448
+ },
144449
+ deleteWebhook: {
144450
+ method: 'DELETE',
144451
+ path: '/v1/webhooks/:webhookId',
144452
+ auth: 'developer_jwt',
144453
+ },
144454
+ getWebhookSignalNames: {
144455
+ method: 'GET',
144456
+ path: '/v1/webhooks/signals',
144457
+ auth: 'developer_jwt',
144458
+ },
144459
+ listSubscribedVehicles: {
144460
+ method: 'GET',
144461
+ path: '/v1/webhooks/:webhookId',
144462
+ auth: 'developer_jwt',
144463
+ },
144464
+ listVehicleSubscriptions: {
144465
+ method: 'GET',
144466
+ path: '/v1/webhooks/vehicles/:tokenId',
144467
+ auth: 'developer_jwt',
144468
+ },
144469
+ subscribeVehicle: {
144470
+ method: 'POST',
144471
+ path: '/v1/webhooks/:webhookId/subscribe/:tokenId',
144472
+ auth: 'developer_jwt',
144473
+ },
144474
+ subscribeAllVehicles: {
144475
+ method: 'POST',
144476
+ path: '/v1/webhooks/:webhookId/subscribe/all',
144477
+ auth: 'developer_jwt',
144478
+ },
144479
+ unsubscribeVehicle: {
144480
+ method: 'DELETE',
144481
+ path: '/v1/webhooks/:webhookId/unsubscribe/:tokenId',
144482
+ auth: 'developer_jwt',
144483
+ },
144484
+ unsubscribeAllVehicles: {
144485
+ method: 'DELETE',
144486
+ path: '/v1/webhooks/:webhookId/unsubscribe/all',
144487
+ auth: 'developer_jwt',
144488
+ },
144489
+ });
144490
+ }
144491
+ }
144492
+
144404
144493
  exports.Attestation = Attestation;
144405
144494
  exports.Auth = Auth;
144406
144495
  exports.DIMO = DIMO;
@@ -144414,3 +144503,4 @@ exports.Telemetry = Telemetry;
144414
144503
  exports.TokenExchange = TokenExchange;
144415
144504
  exports.Trips = Trips;
144416
144505
  exports.Valuations = Valuations;
144506
+ exports.VehicleEvents = VehicleEvents;
package/jest.config.js CHANGED
@@ -1,16 +1,19 @@
1
+ /** @format */
2
+
1
3
  export default {
2
- preset: 'ts-jest',
3
- testEnvironment: 'node',
4
- roots: ['<rootDir>/src'],
5
- testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'],
6
- transform: {
7
- '^.+\\.tsx?$': 'ts-jest', // Transform TypeScript files
8
- '^.+\\.mjs$': 'babel-jest', // Transform .mjs files using Babel
9
- '^.+\\.js$': 'babel-jest', // Transform JavaScript files
10
- },
11
- transformIgnorePatterns: ['<rootDir>/node_modules/'],
12
- moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node', 'mjs'],
13
- moduleNameMapper: {
14
- '^@/(.*)$': '<rootDir>/src/$1' // Adjust this if you're using path aliases
15
- }
4
+ preset: "ts-jest",
5
+ testEnvironment: "node",
6
+ roots: ["<rootDir>/src"],
7
+ testMatch: ["**/__tests__/**/*.ts", "**/?(*.)+(spec|test).ts"],
8
+ transform: {
9
+ "^.+\\.tsx?$": "ts-jest", // Transform TypeScript files
10
+ "^.+\\.mjs$": "babel-jest", // Transform .mjs files using Babel
11
+ "^.+\\.js$": "babel-jest", // Transform JavaScript files
12
+ },
13
+ transformIgnorePatterns: ["<rootDir>/node_modules/"],
14
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node", "mjs"],
15
+ moduleNameMapper: {
16
+ "^api/(.*)$": "<rootDir>/src/api/$1",
17
+ "^@/(.*)$": "<rootDir>/src/$1",
18
+ },
16
19
  };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@dimo-network/data-sdk",
3
- "version": "1.2.5",
3
+ "version": "1.3.1",
4
4
  "description": "DIMO Data SDK for JavaScript",
5
5
  "main": "dist/index.js",
6
6
  "author": "James Li",
7
- "contributors": [],
7
+ "contributors": ["Yusuf Çırak"],
8
8
  "license": "Apache-2.0",
9
9
  "type": "module",
10
10
  "exports": {
File without changes
@@ -1,51 +0,0 @@
1
- "use strict";
2
- // import StreamrClient from '@streamr/sdk';
3
- // import { DimoError } from '../errors';
4
- // import { Observable } from 'rxjs';
5
- // import { catchError, finalize } from 'rxjs/operators';
6
- // type StreamOptions = {
7
- // streamId: string,
8
- // clientId: string,
9
- // privateKey: string,
10
- // log?: string
11
- // };
12
- // export const Stream = async ({ streamId, clientId, privateKey, log }: StreamOptions) => {
13
- // return new Observable(observer => {
14
- // const client = new StreamrClient({
15
- // logLevel: 'info' || log,
16
- // auth: {
17
- // //this is the signer private key the developer adds
18
- // privateKey: privateKey
19
- // },
20
- // });
21
- // const setupStream = async () => {
22
- // try {
23
- // const stream = await client.getStream(streamId);
24
- // await client.subscribe({
25
- // streamId,
26
- // erc1271Contract: clientId,
27
- // }, (msg) => {
28
- // observer.next(msg);
29
- // });
30
- // } catch (error) {
31
- // console.error('Streamr connection failed:', error);
32
- // observer.error(new DimoError({
33
- // message: 'Streamr connection failure'
34
- // }));
35
- // observer.complete();
36
- // }
37
- // };
38
- // setupStream();
39
- // return async () => {
40
- // await client.unsubscribe(streamId);
41
- // }
42
- // }).pipe(
43
- // catchError(error => {
44
- // console.error('Streamr subscription error:', error);
45
- // return new Observable();
46
- // }),
47
- // finalize(() => {
48
- // console.log('Cleaning up Stream listeners');
49
- // })
50
- // );
51
- // }