@dimo-network/data-sdk 1.3.0 → 1.3.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.
Files changed (54) hide show
  1. package/dist/api/Resource.d.ts +2 -2
  2. package/dist/api/Resource.js +1 -1
  3. package/dist/api/resources/DimoRestResources.d.ts +8 -8
  4. package/dist/api/resources/DimoRestResources.js +8 -8
  5. package/dist/api/resources/VehicleEvents/index.d.ts +2 -2
  6. package/dist/api/resources/VehicleEvents/index.js +35 -35
  7. package/dist/{index.cjs → cjs/index.js} +1325 -3119
  8. package/dist/cjs/index.js.map +1 -0
  9. package/dist/environments/index.js +22 -22
  10. package/dist/esm/index.js +142697 -0
  11. package/dist/esm/index.js.map +1 -0
  12. package/dist/graphql/functions/index.d.ts +2 -2
  13. package/dist/graphql/functions/index.js +2 -2
  14. package/dist/types/api/Method.d.ts +2 -0
  15. package/dist/types/api/Method.test.d.ts +1 -0
  16. package/dist/types/api/Resource.d.ts +11 -0
  17. package/dist/types/api/functions/getDeveloperJwt.d.ts +7 -0
  18. package/dist/types/api/functions/getVehicleJwt.d.ts +7 -0
  19. package/dist/types/api/functions/index.d.ts +4 -0
  20. package/dist/types/api/functions/signChallenge.d.ts +5 -0
  21. package/dist/types/api/index.d.ts +1 -0
  22. package/dist/types/api/resources/Attestation/index.d.ts +5 -0
  23. package/dist/types/api/resources/Auth/index.d.ts +5 -0
  24. package/dist/types/api/resources/DeviceDefinitions/index.d.ts +5 -0
  25. package/dist/types/api/resources/Devices/index.d.ts +5 -0
  26. package/dist/types/api/resources/DimoRestResources.d.ts +10 -0
  27. package/dist/types/api/resources/TokenExchange/index.d.ts +5 -0
  28. package/dist/types/api/resources/Trips/index.d.ts +5 -0
  29. package/dist/types/api/resources/Valuations/index.d.ts +5 -0
  30. package/dist/types/api/resources/VehicleEvents/index.d.ts +7 -0
  31. package/dist/types/api/types/Endpoint.d.ts +11 -0
  32. package/dist/types/constants.d.ts +14 -0
  33. package/dist/types/dimo.d.ts +18 -0
  34. package/dist/types/dimo.test.d.ts +1 -0
  35. package/dist/types/environments/index.d.ts +30 -0
  36. package/dist/types/errors/DimoError.d.ts +9 -0
  37. package/dist/types/errors/index.d.ts +1 -0
  38. package/dist/types/graphql/Query.d.ts +3 -0
  39. package/dist/types/graphql/Query.test.d.ts +1 -0
  40. package/dist/types/graphql/Resource.d.ts +16 -0
  41. package/dist/types/graphql/functions/getVehiclePrivileges.d.ts +6 -0
  42. package/dist/types/graphql/functions/getVin.d.ts +5 -0
  43. package/dist/types/graphql/functions/index.d.ts +3 -0
  44. package/dist/types/graphql/index.d.ts +1 -0
  45. package/dist/types/graphql/resources/DimoGraphqlResources.d.ts +3 -0
  46. package/dist/types/graphql/resources/Identity/index.d.ts +5 -0
  47. package/dist/types/graphql/resources/Telemetry/index.d.ts +5 -0
  48. package/dist/types/graphql/util/paginate.d.ts +9 -0
  49. package/dist/types/index.d.ts +18 -0
  50. package/dist/types/util/decodeJwt.d.ts +1 -0
  51. package/dist/types/util/decodePermissions.d.ts +1 -0
  52. package/dist/types/util/index.d.ts +8 -0
  53. package/package.json +15 -9
  54. package/rollup.config.js +33 -9
@@ -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 };
@@ -0,0 +1,2 @@
1
+ import { DimoEnvironment } from '../environments';
2
+ export declare const Method: (resource: any, baseUrl: any, params: any | undefined, env: keyof typeof DimoEnvironment) => Promise<any>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ /** @format */
2
+ import { DimoEnvironment } from '../environments';
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
+ }
@@ -0,0 +1,7 @@
1
+ import { DimoEnvironment } from '../../environments';
2
+ export declare const getDeveloperJwt: (input: {
3
+ client_id: string;
4
+ domain: string;
5
+ private_key: string;
6
+ address: string;
7
+ }, env: keyof typeof DimoEnvironment) => Promise<any>;
@@ -0,0 +1,7 @@
1
+ import { DimoEnvironment } from '../../environments';
2
+ export declare const getVehicleJwt: (input: {
3
+ headers: {
4
+ Authorization: string;
5
+ };
6
+ tokenId: number;
7
+ }, env: keyof typeof DimoEnvironment) => Promise<any>;
@@ -0,0 +1,4 @@
1
+ import { getDeveloperJwt } from "./getDeveloperJwt";
2
+ import { getVehicleJwt } from "./getVehicleJwt";
3
+ import { signChallenge } from "./signChallenge";
4
+ export { getDeveloperJwt, getVehicleJwt, signChallenge };
@@ -0,0 +1,5 @@
1
+ import { DimoEnvironment } from '../../environments';
2
+ export declare const signChallenge: (input: {
3
+ message: string;
4
+ private_key: string;
5
+ }, env: keyof typeof DimoEnvironment) => Promise<string>;
@@ -0,0 +1 @@
1
+ export * from './resources/DimoRestResources';
@@ -0,0 +1,5 @@
1
+ import { Resource } from '../../Resource';
2
+ import { DimoEnvironment } from '../../../environments';
3
+ export declare class Attestation extends Resource {
4
+ constructor(api: any, env: keyof typeof DimoEnvironment);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { Resource } from '../../Resource';
2
+ import { DimoEnvironment } from '../../../environments';
3
+ export declare class Auth extends Resource {
4
+ constructor(api: any, env: keyof typeof DimoEnvironment);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { Resource } from '../../Resource';
2
+ import { DimoEnvironment } from '../../../environments';
3
+ export declare class DeviceDefinitions extends Resource {
4
+ constructor(api: any, env: keyof typeof DimoEnvironment);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { Resource } from '../../Resource';
2
+ import { DimoEnvironment } from '../../../environments';
3
+ export declare class Devices extends Resource {
4
+ constructor(api: any, env: keyof typeof DimoEnvironment);
5
+ }
@@ -0,0 +1,10 @@
1
+ /** @format */
2
+ import { Attestation } from './Attestation';
3
+ import { Auth } from './Auth';
4
+ import { DeviceDefinitions } from './DeviceDefinitions';
5
+ import { Devices } from './Devices';
6
+ import { TokenExchange } from './TokenExchange';
7
+ import { Trips } from './Trips';
8
+ import { Valuations } from './Valuations';
9
+ import { VehicleEvents } from './VehicleEvents';
10
+ export { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleEvents, };
@@ -0,0 +1,5 @@
1
+ import { Resource } from '../../Resource';
2
+ import { DimoEnvironment } from '../../../environments';
3
+ export declare class TokenExchange extends Resource {
4
+ constructor(api: any, env: keyof typeof DimoEnvironment);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { Resource } from '../../Resource';
2
+ import { DimoEnvironment } from '../../../environments';
3
+ export declare class Trips extends Resource {
4
+ constructor(api: any, env: keyof typeof DimoEnvironment);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { Resource } from '../../Resource';
2
+ import { DimoEnvironment } from '../../../environments';
3
+ export declare class Valuations extends Resource {
4
+ constructor(api: any, env: keyof typeof DimoEnvironment);
5
+ }
@@ -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,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,14 @@
1
+ export declare const DimoConstants: {
2
+ readonly Production: {
3
+ readonly NFT_address: "0xbA5738a18d83D41847dfFbDC6101d37C69c9B0cF";
4
+ readonly RPC_provider: "https://eth.llamarpc.com";
5
+ };
6
+ readonly Dev: {
7
+ readonly NFT_address: "0x45fbCD3ef7361d156e8b16F5538AE36DEdf61Da8";
8
+ readonly RPC_provider: "https://eth.llamarpc.com";
9
+ };
10
+ readonly Query: {
11
+ readonly PAGE_SIZE: 100;
12
+ };
13
+ };
14
+ export type DimoConstants = typeof DimoConstants.Production | typeof DimoConstants.Dev | typeof DimoConstants.Query;
@@ -0,0 +1,18 @@
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";
5
+ export declare class DIMO {
6
+ attestation: Attestation;
7
+ auth: Auth;
8
+ devicedefinitions: DeviceDefinitions;
9
+ devices: Devices;
10
+ identity: Identity;
11
+ telemetry: Telemetry;
12
+ tokenexchange: TokenExchange;
13
+ trips: Trips;
14
+ valuations: Valuations;
15
+ vehicleEvents: VehicleEvents;
16
+ constructor(env: keyof typeof DimoEnvironment);
17
+ authenticate(): Promise<any>;
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ /** @format */
2
+ export declare const DimoEnvironment: {
3
+ readonly Production: {
4
+ readonly Attestation: "https://attestation-api.dimo.zone";
5
+ readonly Auth: "https://auth.dimo.zone";
6
+ readonly Identity: "https://identity-api.dimo.zone/query";
7
+ readonly Devices: "https://devices-api.dimo.zone";
8
+ readonly DeviceDefinitions: "https://device-definitions-api.dimo.zone";
9
+ readonly Telemetry: "https://telemetry-api.dimo.zone/query";
10
+ readonly TokenExchange: "https://token-exchange-api.dimo.zone";
11
+ readonly Trips: "https://trips-api.dimo.zone";
12
+ readonly Valuations: "https://valuations-api.dimo.zone";
13
+ readonly VehicleSignalDecoding: "https://vehicle-signal-decoding.dimo.zone";
14
+ readonly VehicleEvents: "https://vehicle-events-api.dimo.zone";
15
+ };
16
+ readonly Dev: {
17
+ readonly Attestation: "https://attestation-api.dev.dimo.zone";
18
+ readonly Auth: "https://auth.dev.dimo.zone";
19
+ readonly Identity: "https://identity-api.dev.dimo.zone/query";
20
+ readonly Devices: "https://devices-api.dev.dimo.zone";
21
+ readonly DeviceDefinitions: "https://device-definitions-api.dev.dimo.zone";
22
+ readonly Telemetry: "https://telemetry-api.dev.dimo.zone/query";
23
+ readonly TokenExchange: "https://token-exchange-api.dev.dimo.zone";
24
+ readonly Trips: "https://trips-api.dev.dimo.zone";
25
+ readonly Valuations: "https://valuations-api.dev.dimo.zone";
26
+ readonly VehicleSignalDecoding: "https://vehicle-signal-decoding.dev.dimo.zone";
27
+ readonly VehicleEvents: "https://vehicle-events-api.dev.dimo.zone";
28
+ };
29
+ };
30
+ export type DimoEnvironment = typeof DimoEnvironment.Production | typeof DimoEnvironment.Dev;
@@ -0,0 +1,9 @@
1
+ export declare class DimoError extends Error {
2
+ readonly statusCode?: number;
3
+ readonly body?: unknown;
4
+ constructor({ message, statusCode, body }: {
5
+ message?: string;
6
+ statusCode?: number;
7
+ body?: unknown;
8
+ });
9
+ }
@@ -0,0 +1 @@
1
+ export * from './DimoError';
@@ -0,0 +1,3 @@
1
+ import { DimoEnvironment } from '../environments';
2
+ export declare const Query: (resource: any, baseUrl: any, params: any | undefined, env: keyof typeof DimoEnvironment) => Promise<any>;
3
+ export declare const CustomQuery: (resource: any, baseUrl: string, params?: any) => Promise<any>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ 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 setQueries(resources: any): void;
11
+ /**
12
+ * Custom GraphQL Queries
13
+ * @param resources
14
+ */
15
+ query(resources: any): void;
16
+ }
@@ -0,0 +1,6 @@
1
+ import { DimoEnvironment } from '../../environments';
2
+ export declare const getVehiclePrivileges: (input: {
3
+ headers: any;
4
+ tokenId: string;
5
+ clientId?: string;
6
+ }, env: keyof typeof DimoEnvironment) => Promise<any>;
@@ -0,0 +1,5 @@
1
+ import { DimoEnvironment } from '../../environments';
2
+ export declare const getVin: (input: {
3
+ headers: any;
4
+ tokenId: string;
5
+ }, env: keyof typeof DimoEnvironment) => Promise<any>;
@@ -0,0 +1,3 @@
1
+ import { getVehiclePrivileges } from './getVehiclePrivileges';
2
+ import { getVin } from './getVin';
3
+ export { getVehiclePrivileges, getVin };
@@ -0,0 +1 @@
1
+ export * from './resources/DimoGraphqlResources';
@@ -0,0 +1,3 @@
1
+ import { Identity } from './Identity';
2
+ import { Telemetry } from './Telemetry';
3
+ export { Identity, Telemetry };
@@ -0,0 +1,5 @@
1
+ import { Resource } from '../../Resource';
2
+ import { DimoEnvironment } from '../../../environments';
3
+ export declare class Identity extends Resource {
4
+ constructor(api: any, env: keyof typeof DimoEnvironment);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { Resource } from '../../Resource';
2
+ import { DimoEnvironment } from '../../../environments';
3
+ export declare class Telemetry extends Resource {
4
+ constructor(api: any, env: keyof typeof DimoEnvironment);
5
+ }
@@ -0,0 +1,9 @@
1
+ export declare const paginate: <T>(fetchPage: (after: string | undefined) => Promise<{
2
+ nodes: {
3
+ nodes: T[];
4
+ };
5
+ pageInfo: {
6
+ endCursor: string | null;
7
+ };
8
+ totalCount: number | null;
9
+ }>) => Promise<T[]>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * _..-------++._
3
+ * _.-'/ | _|| \"--._
4
+ * __.--'`._/_\j_____/_||___\ `----.
5
+ * _.--'_____ | D I M O \ _____ /
6
+ * _j /,---.\ | S D K =o| /,---.\ |_
7
+ * [__]==// .-. \\==`===========/==// .-. \\=[__]
8
+ * `-._|\ `-' /|___\_________/___|\ `-' /|_.'
9
+ * `---' `---'
10
+ *
11
+ *
12
+ */
13
+ export * from './api';
14
+ export * from './environments';
15
+ export * from './errors';
16
+ export * from './graphql';
17
+ export * from './constants';
18
+ export * from './dimo';
@@ -0,0 +1 @@
1
+ export declare const decodeJwt: (token: string) => any;
@@ -0,0 +1 @@
1
+ export declare const decodePermissions: (permissionHex: string) => number[];
@@ -0,0 +1,8 @@
1
+ import { decodeJwt } from './decodeJwt';
2
+ import { decodePermissions } from './decodePermissions';
3
+ export { decodeJwt, decodePermissions };
4
+ declare const _default: {
5
+ decodeJwt: (token: string) => any;
6
+ decodePermissions: (permissionHex: string) => number[];
7
+ };
8
+ export default _default;
package/package.json CHANGED
@@ -1,15 +1,21 @@
1
1
  {
2
2
  "name": "@dimo-network/data-sdk",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "DIMO Data SDK for JavaScript",
5
- "main": "dist/index.js",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "./dist/types/index.d.ts",
6
8
  "author": "James Li",
7
- "contributors": ["Yusuf Çırak"],
9
+ "contributors": [
10
+ "Yusuf Çırak",
11
+ "Eduardo Rodriguez"
12
+ ],
8
13
  "license": "Apache-2.0",
9
14
  "type": "module",
15
+
10
16
  "exports": {
11
- "import": "./dist/index.js",
12
- "require": "./dist/index.cjs"
17
+ "import": "./dist/esm/index.js",
18
+ "require": "./dist/cjs/index.js"
13
19
  },
14
20
  "keywords": [
15
21
  "data-sdk",
@@ -53,8 +59,8 @@
53
59
  "ts-jest": "^29.1.4",
54
60
  "typescript": "^5.4.5"
55
61
  },
56
- "optionalDependencies": {
57
- "@rollup/rollup-linux-x64-gnu": "*"
58
- },
59
- "types": "./dist/index.d.ts"
62
+ "optionalDependencies": {
63
+ "@rollup/rollup-linux-x64-gnu": "*"
64
+ }
65
+
60
66
  }
package/rollup.config.js CHANGED
@@ -4,19 +4,43 @@ import typescript from '@rollup/plugin-typescript';
4
4
  import json from '@rollup/plugin-json';
5
5
  import globals from 'rollup-plugin-node-globals';
6
6
 
7
+ const external = [
8
+ // Node built-ins:
9
+ 'node:util','util','node:stream','stream','path','fs','events','buffer','os','http','https','url','zlib','tty'
10
+ ];
7
11
 
8
12
  export default {
9
13
  input: './src/index.ts',
10
- output: {
11
- file: './dist/index.cjs',
12
- format: 'cjs',
13
- },
14
+ external: external,
15
+ output: [
16
+ {
17
+ dir: './dist',
18
+ entryFileNames: 'esm/[name].js',
19
+ format: 'esm',
20
+ sourcemap: true,
21
+ },
22
+ {
23
+ dir: './dist',
24
+ entryFileNames: 'cjs/[name].js',
25
+ format: 'cjs',
26
+ sourcemap: true,
27
+ plugins: [
28
+ globals(), // Provides global variables for Node.js built-ins
29
+ ]
30
+ },
31
+ ],
14
32
  plugins: [
15
- resolve({ preferBuiltins: true }), // Resolves node_modules and relative paths
16
- commonjs(), // Converts CommonJS modules to ES6
17
- typescript(), // Handles TypeScript (if needed)
18
- json(),
19
- globals(),
33
+ typescript({
34
+ tsconfig: './tsconfig.json',
35
+ declaration: true,
36
+ declarationDir: './dist/types',
37
+ }), // Handles TypeScript (if needed)
38
+ resolve({
39
+ preferBuiltins: true,
40
+ extensions: ['.js', '.ts'],
41
+ }), // Resolves node_modules and relative paths
42
+ commonjs(),// Converts CommonJS modules to ES6
43
+ json(), // Allows importing JSON files
20
44
  ],
21
45
  onwarn(warning, warn) {
22
46
  // Print detailed warnings