@dimo-network/data-sdk 1.3.1 → 1.3.3
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.md +49 -2
- package/dist/api/resources/Attestation/index.js +23 -6
- package/dist/{index.cjs → cjs/index.js} +1292 -3069
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/index.js +142714 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/types/api/Method.d.ts +2 -0
- package/dist/types/api/Method.test.d.ts +1 -0
- package/dist/types/api/Resource.d.ts +11 -0
- package/dist/types/api/functions/getDeveloperJwt.d.ts +7 -0
- package/dist/types/api/functions/getVehicleJwt.d.ts +7 -0
- package/dist/types/api/functions/index.d.ts +4 -0
- package/dist/types/api/functions/signChallenge.d.ts +5 -0
- package/dist/types/api/index.d.ts +1 -0
- package/dist/types/api/resources/Attestation/index.d.ts +5 -0
- package/dist/types/api/resources/Auth/index.d.ts +5 -0
- package/dist/types/api/resources/DeviceDefinitions/index.d.ts +5 -0
- package/dist/types/api/resources/Devices/index.d.ts +5 -0
- package/dist/types/api/resources/DimoRestResources.d.ts +10 -0
- package/dist/types/api/resources/TokenExchange/index.d.ts +5 -0
- package/dist/types/api/resources/Trips/index.d.ts +5 -0
- package/dist/types/api/resources/Valuations/index.d.ts +5 -0
- package/dist/types/api/resources/VehicleEvents/index.d.ts +7 -0
- package/dist/types/api/types/Endpoint.d.ts +11 -0
- package/dist/types/constants.d.ts +14 -0
- package/dist/types/dimo.d.ts +18 -0
- package/dist/types/dimo.test.d.ts +1 -0
- package/dist/types/environments/index.d.ts +30 -0
- package/dist/types/errors/DimoError.d.ts +9 -0
- package/dist/types/errors/index.d.ts +1 -0
- package/dist/types/graphql/Query.d.ts +3 -0
- package/dist/types/graphql/Query.test.d.ts +1 -0
- package/dist/types/graphql/Resource.d.ts +16 -0
- package/dist/types/graphql/functions/getVehiclePrivileges.d.ts +6 -0
- package/dist/types/graphql/functions/getVin.d.ts +5 -0
- package/dist/types/graphql/functions/index.d.ts +3 -0
- package/dist/types/graphql/index.d.ts +1 -0
- package/dist/types/graphql/resources/DimoGraphqlResources.d.ts +3 -0
- package/dist/types/graphql/resources/Identity/index.d.ts +5 -0
- package/dist/types/graphql/resources/Telemetry/index.d.ts +5 -0
- package/dist/types/graphql/util/paginate.d.ts +9 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/util/decodeJwt.d.ts +1 -0
- package/dist/types/util/decodePermissions.d.ts +1 -0
- package/dist/types/util/index.d.ts +8 -0
- package/package.json +14 -9
- package/rollup.config.js +33 -9
|
@@ -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 @@
|
|
|
1
|
+
export * from './resources/DimoRestResources';
|
|
@@ -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,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 @@
|
|
|
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 @@
|
|
|
1
|
+
export * from './resources/DimoGraphqlResources';
|
|
@@ -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.
|
|
3
|
+
"version": "1.3.3",
|
|
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": [
|
|
9
|
+
"contributors": [
|
|
10
|
+
"Yusuf Çırak",
|
|
11
|
+
"Eduardo Rodriguez"
|
|
12
|
+
],
|
|
8
13
|
"license": "Apache-2.0",
|
|
9
14
|
"type": "module",
|
|
10
15
|
"exports": {
|
|
11
|
-
"import": "./dist/index.js",
|
|
12
|
-
"require": "./dist/index.
|
|
16
|
+
"import": "./dist/esm/index.js",
|
|
17
|
+
"require": "./dist/cjs/index.js",
|
|
18
|
+
"types": "./dist/types/index.d.ts"
|
|
13
19
|
},
|
|
14
20
|
"keywords": [
|
|
15
21
|
"data-sdk",
|
|
@@ -53,8 +59,7 @@
|
|
|
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
|
+
}
|
|
60
65
|
}
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|