@softruck/api-contracts 0.1.1-beta.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 +0 -0
- package/dist/alerts/api.d.ts +9 -0
- package/dist/alerts/api.js +8 -0
- package/dist/alerts/index.d.ts +3 -0
- package/dist/alerts/index.js +3 -0
- package/dist/alerts/schemas.d.ts +65 -0
- package/dist/alerts/schemas.js +29 -0
- package/dist/alerts/types.d.ts +36 -0
- package/dist/alerts/types.js +1 -0
- package/dist/auth/api.d.ts +26 -0
- package/dist/auth/api.js +39 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.js +3 -0
- package/dist/auth/schemas/access-codes.d.ts +16 -0
- package/dist/auth/schemas/access-codes.js +13 -0
- package/dist/auth/schemas/login.d.ts +13 -0
- package/dist/auth/schemas/login.js +9 -0
- package/dist/auth/schemas/passwords.d.ts +81 -0
- package/dist/auth/schemas/passwords.js +28 -0
- package/dist/auth/schemas/sessions.d.ts +3 -0
- package/dist/auth/schemas/sessions.js +2 -0
- package/dist/auth/schemas/tokens.d.ts +11 -0
- package/dist/auth/schemas/tokens.js +9 -0
- package/dist/auth/schemas.d.ts +5 -0
- package/dist/auth/schemas.js +5 -0
- package/dist/auth/types.d.ts +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/checklist/api.d.ts +30 -0
- package/dist/checklist/api.js +15 -0
- package/dist/checklist/index.d.ts +3 -0
- package/dist/checklist/index.js +3 -0
- package/dist/checklist/schemas.d.ts +62 -0
- package/dist/checklist/schemas.js +46 -0
- package/dist/checklist/types.d.ts +76 -0
- package/dist/checklist/types.js +1 -0
- package/dist/chips/api.d.ts +17 -0
- package/dist/chips/api.js +8 -0
- package/dist/chips/connections/api.d.ts +13 -0
- package/dist/chips/connections/api.js +4 -0
- package/dist/chips/connections/index.d.ts +3 -0
- package/dist/chips/connections/index.js +3 -0
- package/dist/chips/connections/schemas.d.ts +31 -0
- package/dist/chips/connections/schemas.js +31 -0
- package/dist/chips/connections/types.d.ts +26 -0
- package/dist/chips/connections/types.js +1 -0
- package/dist/chips/index.d.ts +5 -0
- package/dist/chips/index.js +5 -0
- package/dist/chips/requirements/api.d.ts +13 -0
- package/dist/chips/requirements/api.js +4 -0
- package/dist/chips/requirements/index.d.ts +3 -0
- package/dist/chips/requirements/index.js +3 -0
- package/dist/chips/requirements/schemas.d.ts +21 -0
- package/dist/chips/requirements/schemas.js +21 -0
- package/dist/chips/requirements/types.d.ts +16 -0
- package/dist/chips/requirements/types.js +1 -0
- package/dist/chips/schemas.d.ts +78 -0
- package/dist/chips/schemas.js +72 -0
- package/dist/chips/types.d.ts +76 -0
- package/dist/chips/types.js +1 -0
- package/dist/core/client.d.ts +45 -0
- package/dist/core/client.js +42 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +4 -0
- package/dist/core/query-builder.d.ts +34 -0
- package/dist/core/query-builder.js +86 -0
- package/dist/core/schemas.d.ts +80 -0
- package/dist/core/schemas.js +31 -0
- package/dist/core/types.d.ts +119 -0
- package/dist/core/types.js +2 -0
- package/dist/devices/activations/api.d.ts +20 -0
- package/dist/devices/activations/api.js +9 -0
- package/dist/devices/activations/index.d.ts +3 -0
- package/dist/devices/activations/index.js +3 -0
- package/dist/devices/activations/schemas.d.ts +42 -0
- package/dist/devices/activations/schemas.js +42 -0
- package/dist/devices/activations/types.d.ts +75 -0
- package/dist/devices/activations/types.js +1 -0
- package/dist/devices/api.d.ts +28 -0
- package/dist/devices/api.js +11 -0
- package/dist/devices/commands/api.d.ts +17 -0
- package/dist/devices/commands/api.js +8 -0
- package/dist/devices/commands/index.d.ts +3 -0
- package/dist/devices/commands/index.js +3 -0
- package/dist/devices/commands/schemas.d.ts +39 -0
- package/dist/devices/commands/schemas.js +33 -0
- package/dist/devices/commands/types.d.ts +58 -0
- package/dist/devices/commands/types.js +1 -0
- package/dist/devices/index.d.ts +5 -0
- package/dist/devices/index.js +5 -0
- package/dist/devices/schemas.d.ts +115 -0
- package/dist/devices/schemas.js +96 -0
- package/dist/devices/types.d.ts +142 -0
- package/dist/devices/types.js +1 -0
- package/dist/enterprises/api.d.ts +27 -0
- package/dist/enterprises/api.js +15 -0
- package/dist/enterprises/index.d.ts +3 -0
- package/dist/enterprises/index.js +3 -0
- package/dist/enterprises/schemas.d.ts +59 -0
- package/dist/enterprises/schemas.js +53 -0
- package/dist/enterprises/types.d.ts +160 -0
- package/dist/enterprises/types.js +1 -0
- package/dist/events/api.d.ts +18 -0
- package/dist/events/api.js +13 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.js +3 -0
- package/dist/events/schemas.d.ts +262 -0
- package/dist/events/schemas.js +54 -0
- package/dist/events/types.d.ts +130 -0
- package/dist/events/types.js +1 -0
- package/dist/exports/api.d.ts +18 -0
- package/dist/exports/api.js +9 -0
- package/dist/exports/index.d.ts +3 -0
- package/dist/exports/index.js +3 -0
- package/dist/exports/schemas.d.ts +27 -0
- package/dist/exports/schemas.js +22 -0
- package/dist/exports/types.d.ts +47 -0
- package/dist/exports/types.js +1 -0
- package/dist/fuelings/api.d.ts +22 -0
- package/dist/fuelings/api.js +9 -0
- package/dist/fuelings/index.d.ts +3 -0
- package/dist/fuelings/index.js +3 -0
- package/dist/fuelings/schemas.d.ts +84 -0
- package/dist/fuelings/schemas.js +52 -0
- package/dist/fuelings/types.d.ts +80 -0
- package/dist/fuelings/types.js +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +22 -0
- package/dist/maintenances/api.d.ts +31 -0
- package/dist/maintenances/api.js +12 -0
- package/dist/maintenances/index.d.ts +3 -0
- package/dist/maintenances/index.js +3 -0
- package/dist/maintenances/schemas.d.ts +74 -0
- package/dist/maintenances/schemas.js +44 -0
- package/dist/maintenances/types.d.ts +69 -0
- package/dist/maintenances/types.js +1 -0
- package/dist/operation-logs/api.d.ts +13 -0
- package/dist/operation-logs/api.js +10 -0
- package/dist/operation-logs/index.d.ts +3 -0
- package/dist/operation-logs/index.js +3 -0
- package/dist/operation-logs/schemas.d.ts +34 -0
- package/dist/operation-logs/schemas.js +22 -0
- package/dist/operation-logs/types.d.ts +32 -0
- package/dist/operation-logs/types.js +1 -0
- package/dist/protocols/api.d.ts +34 -0
- package/dist/protocols/api.js +13 -0
- package/dist/protocols/index.d.ts +3 -0
- package/dist/protocols/index.js +3 -0
- package/dist/protocols/schemas.d.ts +66 -0
- package/dist/protocols/schemas.js +36 -0
- package/dist/protocols/types.d.ts +99 -0
- package/dist/protocols/types.js +1 -0
- package/dist/service-orders/api.d.ts +38 -0
- package/dist/service-orders/api.js +14 -0
- package/dist/service-orders/index.d.ts +3 -0
- package/dist/service-orders/index.js +3 -0
- package/dist/service-orders/schemas.d.ts +82 -0
- package/dist/service-orders/schemas.js +47 -0
- package/dist/service-orders/types.d.ts +84 -0
- package/dist/service-orders/types.js +1 -0
- package/dist/sharings/api.d.ts +17 -0
- package/dist/sharings/api.js +8 -0
- package/dist/sharings/index.d.ts +3 -0
- package/dist/sharings/index.js +3 -0
- package/dist/sharings/schemas.d.ts +47 -0
- package/dist/sharings/schemas.js +36 -0
- package/dist/sharings/types.d.ts +54 -0
- package/dist/sharings/types.js +1 -0
- package/dist/surveys/api.d.ts +2 -0
- package/dist/surveys/api.js +3 -0
- package/dist/surveys/index.d.ts +3 -0
- package/dist/surveys/index.js +3 -0
- package/dist/surveys/schemas.d.ts +33 -0
- package/dist/surveys/schemas.js +23 -0
- package/dist/surveys/types.d.ts +27 -0
- package/dist/surveys/types.js +1 -0
- package/dist/tags/api.d.ts +24 -0
- package/dist/tags/api.js +28 -0
- package/dist/tags/index.d.ts +3 -0
- package/dist/tags/index.js +3 -0
- package/dist/tags/schemas.d.ts +26 -0
- package/dist/tags/schemas.js +19 -0
- package/dist/tags/types.d.ts +16 -0
- package/dist/tags/types.js +1 -0
- package/dist/tracking/api.d.ts +2 -0
- package/dist/tracking/api.js +3 -0
- package/dist/tracking/index.d.ts +3 -0
- package/dist/tracking/index.js +3 -0
- package/dist/tracking/schemas.d.ts +12 -0
- package/dist/tracking/schemas.js +12 -0
- package/dist/tracking/types.d.ts +11 -0
- package/dist/tracking/types.js +1 -0
- package/dist/trajectories/api.d.ts +27 -0
- package/dist/trajectories/api.js +13 -0
- package/dist/trajectories/index.d.ts +3 -0
- package/dist/trajectories/index.js +3 -0
- package/dist/trajectories/schemas.d.ts +39 -0
- package/dist/trajectories/schemas.js +30 -0
- package/dist/trajectories/types.d.ts +58 -0
- package/dist/trajectories/types.js +1 -0
- package/dist/trips/api.d.ts +30 -0
- package/dist/trips/api.js +12 -0
- package/dist/trips/index.d.ts +3 -0
- package/dist/trips/index.js +3 -0
- package/dist/trips/schemas.d.ts +62 -0
- package/dist/trips/schemas.js +36 -0
- package/dist/trips/types.d.ts +65 -0
- package/dist/trips/types.js +1 -0
- package/dist/users/api.d.ts +533 -0
- package/dist/users/api.js +102 -0
- package/dist/users/configuration/api.d.ts +21 -0
- package/dist/users/configuration/api.js +16 -0
- package/dist/users/configuration/index.d.ts +3 -0
- package/dist/users/configuration/index.js +3 -0
- package/dist/users/configuration/schemas.d.ts +91 -0
- package/dist/users/configuration/schemas.js +42 -0
- package/dist/users/configuration/types.d.ts +36 -0
- package/dist/users/configuration/types.js +1 -0
- package/dist/users/index.d.ts +4 -0
- package/dist/users/index.js +4 -0
- package/dist/users/schemas/addresses.d.ts +136 -0
- package/dist/users/schemas/addresses.js +94 -0
- package/dist/users/schemas/authenticated-user.d.ts +30 -0
- package/dist/users/schemas/authenticated-user.js +21 -0
- package/dist/users/schemas/common.d.ts +28 -0
- package/dist/users/schemas/common.js +26 -0
- package/dist/users/schemas/documents.d.ts +40 -0
- package/dist/users/schemas/documents.js +53 -0
- package/dist/users/schemas/passwords.d.ts +10 -0
- package/dist/users/schemas/passwords.js +15 -0
- package/dist/users/schemas/roles.d.ts +60 -0
- package/dist/users/schemas/roles.js +9 -0
- package/dist/users/schemas/sessions.d.ts +84 -0
- package/dist/users/schemas/sessions.js +55 -0
- package/dist/users/schemas/usernames.d.ts +14 -0
- package/dist/users/schemas/usernames.js +12 -0
- package/dist/users/schemas/users.d.ts +648 -0
- package/dist/users/schemas/users.js +243 -0
- package/dist/users/schemas.d.ts +8 -0
- package/dist/users/schemas.js +8 -0
- package/dist/users/types.d.ts +1 -0
- package/dist/users/types.js +1 -0
- package/dist/vehicles/api.d.ts +28 -0
- package/dist/vehicles/api.js +13 -0
- package/dist/vehicles/index.d.ts +3 -0
- package/dist/vehicles/index.js +3 -0
- package/dist/vehicles/schemas.d.ts +88 -0
- package/dist/vehicles/schemas.js +71 -0
- package/dist/vehicles/types.d.ts +142 -0
- package/dist/vehicles/types.js +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const FILTER_OPERATORS: readonly ["eq", "neq", "gt", "gte", "lt", "lte", "btw", "nbtw", "ilk", "ew", "sw", "in", "nin", "is"];
|
|
2
|
+
export type FilterOperator = typeof FILTER_OPERATORS[number];
|
|
3
|
+
export declare const FILTERS_OPERATORS: {
|
|
4
|
+
readonly string: readonly ["eq", "neq", "ilk", "ew", "sw"];
|
|
5
|
+
readonly number: readonly ["eq", "neq", "gt", "gte", "lt", "lte", "btw", "nbtw"];
|
|
6
|
+
readonly boolean: readonly ["eq", "neq"];
|
|
7
|
+
readonly date: readonly ["gt", "gte", "lt", "lte", "btw", "nbtw"];
|
|
8
|
+
readonly shortdate: readonly ["eq", "neq", "gt", "gte", "lt", "lte", "btw", "nbtw"];
|
|
9
|
+
readonly enum: readonly ["in", "nin"];
|
|
10
|
+
};
|
|
11
|
+
export interface FilterValue {
|
|
12
|
+
operator: FilterOperator;
|
|
13
|
+
value: string | number | boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface SortParam {
|
|
16
|
+
prop: string;
|
|
17
|
+
order: 'ASC' | 'DESC';
|
|
18
|
+
}
|
|
19
|
+
export interface QueryParams {
|
|
20
|
+
count?: boolean | 'only';
|
|
21
|
+
page?: number;
|
|
22
|
+
limit?: number;
|
|
23
|
+
search?: string;
|
|
24
|
+
attributes?: string[];
|
|
25
|
+
includes?: Record<string, string[]>;
|
|
26
|
+
filters?: Record<string, FilterValue | FilterValue[]>;
|
|
27
|
+
sort?: SortParam;
|
|
28
|
+
any?: Record<string, {
|
|
29
|
+
value: string | number;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
export declare function buildQuery(params: QueryParams): string;
|
|
33
|
+
export declare function withQuery(url: string, params: QueryParams): string;
|
|
34
|
+
export declare function mergeQuery(base: QueryParams, overrides: Partial<QueryParams>): QueryParams;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export const FILTER_OPERATORS = [
|
|
2
|
+
'eq', 'neq', 'gt', 'gte', 'lt', 'lte',
|
|
3
|
+
'btw', 'nbtw', 'ilk', 'ew', 'sw',
|
|
4
|
+
'in', 'nin', 'is',
|
|
5
|
+
];
|
|
6
|
+
export const FILTERS_OPERATORS = {
|
|
7
|
+
string: ['eq', 'neq', 'ilk', 'ew', 'sw'],
|
|
8
|
+
number: ['eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'btw', 'nbtw'],
|
|
9
|
+
boolean: ['eq', 'neq'],
|
|
10
|
+
date: ['gt', 'gte', 'lt', 'lte', 'btw', 'nbtw'],
|
|
11
|
+
shortdate: ['eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'btw', 'nbtw'],
|
|
12
|
+
enum: ['in', 'nin'],
|
|
13
|
+
};
|
|
14
|
+
function sanitizeSearch(value) {
|
|
15
|
+
return value
|
|
16
|
+
.replace(/&/g, '%26')
|
|
17
|
+
.replace(/\?/g, '')
|
|
18
|
+
.replace(/'/g, '')
|
|
19
|
+
.replace(/--/g, '')
|
|
20
|
+
.replace(/=/g, '')
|
|
21
|
+
.replace(/\/\//g, '');
|
|
22
|
+
}
|
|
23
|
+
function buildParts(params) {
|
|
24
|
+
const parts = [];
|
|
25
|
+
if (params.count !== undefined) {
|
|
26
|
+
parts.push(`count=${params.count}`);
|
|
27
|
+
}
|
|
28
|
+
if (params.page !== undefined) {
|
|
29
|
+
parts.push(`page=${params.page}`);
|
|
30
|
+
}
|
|
31
|
+
if (params.limit !== undefined) {
|
|
32
|
+
parts.push(`limit=${params.limit}`);
|
|
33
|
+
}
|
|
34
|
+
if (params.search) {
|
|
35
|
+
parts.push(`search=${sanitizeSearch(params.search)}`);
|
|
36
|
+
}
|
|
37
|
+
if (params.attributes?.length) {
|
|
38
|
+
parts.push(`attributes=${params.attributes.join(',')}`);
|
|
39
|
+
}
|
|
40
|
+
if (params.includes) {
|
|
41
|
+
for (const [key, fields] of Object.entries(params.includes)) {
|
|
42
|
+
parts.push(`includes[${key}]=${fields.join(',')}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (params.filters) {
|
|
46
|
+
for (const [key, val] of Object.entries(params.filters)) {
|
|
47
|
+
if (Array.isArray(val)) {
|
|
48
|
+
val.forEach((v, i) => parts.push(`filters[${key}][${v.operator}][${i}]=${v.value}`));
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
parts.push(`filters[${key}][${val.operator}]=${val.value}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (params.sort) {
|
|
56
|
+
parts.push(`sort[${params.sort.prop}]=${params.sort.order === 'ASC' ? '1' : '-1'}`);
|
|
57
|
+
}
|
|
58
|
+
if (params.any) {
|
|
59
|
+
for (const [key, { value }] of Object.entries(params.any)) {
|
|
60
|
+
parts.push(`${key}=${value}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return parts;
|
|
64
|
+
}
|
|
65
|
+
function toBase64(str) {
|
|
66
|
+
return btoa(unescape(encodeURIComponent(str)));
|
|
67
|
+
}
|
|
68
|
+
export function buildQuery(params) {
|
|
69
|
+
return toBase64(buildParts(params).join('&'));
|
|
70
|
+
}
|
|
71
|
+
export function withQuery(url, params) {
|
|
72
|
+
const parts = buildParts(params);
|
|
73
|
+
if (parts.length === 0) {
|
|
74
|
+
return url;
|
|
75
|
+
}
|
|
76
|
+
return `${url}?q=${encodeURIComponent(toBase64(parts.join('&')))}`;
|
|
77
|
+
}
|
|
78
|
+
export function mergeQuery(base, overrides) {
|
|
79
|
+
const result = { ...base };
|
|
80
|
+
for (const [k, v] of Object.entries(overrides)) {
|
|
81
|
+
if (v !== undefined) {
|
|
82
|
+
result[k] = v;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const varChar: (length?: number) => z.ZodString;
|
|
3
|
+
export declare const varCharOptional: (length?: number) => z.ZodOptional<z.ZodString>;
|
|
4
|
+
export declare const nullableVarCharOptional: (length?: number) => z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
5
|
+
export declare const FilterValueSchema: z.ZodObject<{
|
|
6
|
+
operator: z.ZodEnum<{
|
|
7
|
+
in: "in";
|
|
8
|
+
eq: "eq";
|
|
9
|
+
neq: "neq";
|
|
10
|
+
gt: "gt";
|
|
11
|
+
gte: "gte";
|
|
12
|
+
lt: "lt";
|
|
13
|
+
lte: "lte";
|
|
14
|
+
btw: "btw";
|
|
15
|
+
nbtw: "nbtw";
|
|
16
|
+
ilk: "ilk";
|
|
17
|
+
ew: "ew";
|
|
18
|
+
sw: "sw";
|
|
19
|
+
nin: "nin";
|
|
20
|
+
is: "is";
|
|
21
|
+
}>;
|
|
22
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
export declare function makeQueryParamsSchema<TKey extends string>(attributeKeySchema: z.ZodType<TKey>): z.ZodObject<{
|
|
25
|
+
count: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"only">]>>;
|
|
26
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
search: z.ZodOptional<z.ZodString>;
|
|
29
|
+
attributes: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodType<TKey, unknown, z.core.$ZodTypeInternals<TKey, unknown>>, z.ZodLiteral<"*">]>>>;
|
|
30
|
+
filters: z.ZodOptional<z.ZodRecord<z.ZodType<TKey, unknown, z.core.$ZodTypeInternals<TKey, unknown>> & z.core.$partial, z.ZodUnion<readonly [z.ZodObject<{
|
|
31
|
+
operator: z.ZodEnum<{
|
|
32
|
+
in: "in";
|
|
33
|
+
eq: "eq";
|
|
34
|
+
neq: "neq";
|
|
35
|
+
gt: "gt";
|
|
36
|
+
gte: "gte";
|
|
37
|
+
lt: "lt";
|
|
38
|
+
lte: "lte";
|
|
39
|
+
btw: "btw";
|
|
40
|
+
nbtw: "nbtw";
|
|
41
|
+
ilk: "ilk";
|
|
42
|
+
ew: "ew";
|
|
43
|
+
sw: "sw";
|
|
44
|
+
nin: "nin";
|
|
45
|
+
is: "is";
|
|
46
|
+
}>;
|
|
47
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
48
|
+
}, z.core.$strict>, z.ZodArray<z.ZodObject<{
|
|
49
|
+
operator: z.ZodEnum<{
|
|
50
|
+
in: "in";
|
|
51
|
+
eq: "eq";
|
|
52
|
+
neq: "neq";
|
|
53
|
+
gt: "gt";
|
|
54
|
+
gte: "gte";
|
|
55
|
+
lt: "lt";
|
|
56
|
+
lte: "lte";
|
|
57
|
+
btw: "btw";
|
|
58
|
+
nbtw: "nbtw";
|
|
59
|
+
ilk: "ilk";
|
|
60
|
+
ew: "ew";
|
|
61
|
+
sw: "sw";
|
|
62
|
+
nin: "nin";
|
|
63
|
+
is: "is";
|
|
64
|
+
}>;
|
|
65
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
66
|
+
}, z.core.$strict>>]>>>;
|
|
67
|
+
sort: z.ZodOptional<z.ZodObject<{
|
|
68
|
+
prop: z.ZodType<TKey, unknown, z.core.$ZodTypeInternals<TKey, unknown>>;
|
|
69
|
+
order: z.ZodEnum<{
|
|
70
|
+
ASC: "ASC";
|
|
71
|
+
DESC: "DESC";
|
|
72
|
+
}>;
|
|
73
|
+
}, z.core.$strict>>;
|
|
74
|
+
}, z.core.$strict>;
|
|
75
|
+
export declare const EnterpriseRelAttrSchema: z.ZodObject<{
|
|
76
|
+
name: z.ZodNullable<z.ZodString>;
|
|
77
|
+
cnpj: z.ZodNullable<z.ZodString>;
|
|
78
|
+
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
export type EnterpriseRelAttr = z.infer<typeof EnterpriseRelAttrSchema>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { FILTER_OPERATORS } from './query-builder.js';
|
|
3
|
+
// Mirrors the backend's `varChar` Joi helper (`Joi.string().max(length)`): Joi's
|
|
4
|
+
// string() rejects '' by default, so `.min(1)` is required to match that behavior —
|
|
5
|
+
// plain `z.string()` would silently accept empty strings Joi would reject.
|
|
6
|
+
export const varChar = (length = 255) => z.string().min(1).max(length);
|
|
7
|
+
export const varCharOptional = (length = 255) => varChar(length).optional();
|
|
8
|
+
export const nullableVarCharOptional = (length = 255) => varCharOptional(length).nullable().optional();
|
|
9
|
+
export const FilterValueSchema = z.object({
|
|
10
|
+
operator: z.enum(FILTER_OPERATORS),
|
|
11
|
+
value: z.union([z.string(), z.number(), z.boolean()]),
|
|
12
|
+
}).strict();
|
|
13
|
+
// Builds a strict QueryParams schema for a resource, restricting `attributes`,
|
|
14
|
+
// `filters` and `sort.prop` to that resource's own attribute keys.
|
|
15
|
+
export function makeQueryParamsSchema(attributeKeySchema) {
|
|
16
|
+
const attributeSelectionSchema = z.union([attributeKeySchema, z.literal('*')]);
|
|
17
|
+
return z.object({
|
|
18
|
+
count: z.union([z.boolean(), z.literal('only')]).optional(),
|
|
19
|
+
page: z.number().optional(),
|
|
20
|
+
limit: z.number().optional(),
|
|
21
|
+
search: z.string().optional(),
|
|
22
|
+
attributes: z.array(attributeSelectionSchema).optional(),
|
|
23
|
+
filters: z.partialRecord(attributeKeySchema, z.union([FilterValueSchema, z.array(FilterValueSchema)])).optional(),
|
|
24
|
+
sort: z.object({ prop: attributeKeySchema, order: z.enum(['ASC', 'DESC']) }).strict().optional(),
|
|
25
|
+
}).strict();
|
|
26
|
+
}
|
|
27
|
+
export const EnterpriseRelAttrSchema = z.object({
|
|
28
|
+
name: z.string().nullable(),
|
|
29
|
+
cnpj: z.string().nullable(),
|
|
30
|
+
email: z.string().nullable().optional(),
|
|
31
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export interface ListResponse<T> {
|
|
2
|
+
data: T[];
|
|
3
|
+
count?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface PagedResponse<T> {
|
|
6
|
+
data: T[];
|
|
7
|
+
count: number;
|
|
8
|
+
}
|
|
9
|
+
export interface Timestamped {
|
|
10
|
+
created_at: string | null;
|
|
11
|
+
updated_at: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface Deactivatable extends Timestamped {
|
|
14
|
+
deactivated_at: string | null;
|
|
15
|
+
}
|
|
16
|
+
export type { EnterpriseRelAttr } from './schemas';
|
|
17
|
+
export interface DeviceRelAttr {
|
|
18
|
+
name: string | null;
|
|
19
|
+
imei: string | null;
|
|
20
|
+
code: string | null;
|
|
21
|
+
}
|
|
22
|
+
export interface ChipRelAttr {
|
|
23
|
+
serial: string | null;
|
|
24
|
+
number: string | null;
|
|
25
|
+
imsi?: string | null;
|
|
26
|
+
service_provider: string | null;
|
|
27
|
+
carrier: string | null;
|
|
28
|
+
}
|
|
29
|
+
export interface VehicleRelAttr {
|
|
30
|
+
plate: string | null;
|
|
31
|
+
vin: string | null;
|
|
32
|
+
label: string | null;
|
|
33
|
+
type_name: string | null;
|
|
34
|
+
brand_name?: string | null;
|
|
35
|
+
}
|
|
36
|
+
export interface UserRelAttr {
|
|
37
|
+
name: string | null;
|
|
38
|
+
username?: string | null;
|
|
39
|
+
email: string | null;
|
|
40
|
+
phone1: string | null;
|
|
41
|
+
phone2?: string | null;
|
|
42
|
+
deleted_at?: string | null;
|
|
43
|
+
}
|
|
44
|
+
export interface TypeRelAttr {
|
|
45
|
+
name: string | null;
|
|
46
|
+
}
|
|
47
|
+
export interface SectionRelAttr {
|
|
48
|
+
name: string | null;
|
|
49
|
+
}
|
|
50
|
+
export interface CompletionRelAttr {
|
|
51
|
+
completed_at: string | null;
|
|
52
|
+
}
|
|
53
|
+
export interface AssigneeRelAttr {
|
|
54
|
+
name: string | null;
|
|
55
|
+
email: string | null;
|
|
56
|
+
phone1: string | null;
|
|
57
|
+
phone2: string | null;
|
|
58
|
+
}
|
|
59
|
+
export interface LastGpsAttr {
|
|
60
|
+
last_gps_time: string | null;
|
|
61
|
+
last_connection_time: string | null;
|
|
62
|
+
lat?: string | null;
|
|
63
|
+
lng?: string | null;
|
|
64
|
+
}
|
|
65
|
+
export interface Tag {
|
|
66
|
+
id: string;
|
|
67
|
+
attributes: {
|
|
68
|
+
name: string;
|
|
69
|
+
color: string | null;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export interface Address {
|
|
73
|
+
id: string;
|
|
74
|
+
attributes: {
|
|
75
|
+
formatted_address: string | null;
|
|
76
|
+
type?: string | null;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export interface Document {
|
|
80
|
+
id: string;
|
|
81
|
+
attributes: {
|
|
82
|
+
name: string | null;
|
|
83
|
+
key_name: string | null;
|
|
84
|
+
file_size: number | null;
|
|
85
|
+
mime: string | null;
|
|
86
|
+
created_at: string | null;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export interface CustomField {
|
|
90
|
+
id: string;
|
|
91
|
+
attributes: {
|
|
92
|
+
name: string | null;
|
|
93
|
+
field_format: string | null;
|
|
94
|
+
value: string | null;
|
|
95
|
+
is_required: boolean | null;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export interface TaskBaseAttributes extends Timestamped {
|
|
99
|
+
token: string | null;
|
|
100
|
+
status: string | null;
|
|
101
|
+
priority: string | null;
|
|
102
|
+
description: string | null;
|
|
103
|
+
notes: string | null;
|
|
104
|
+
}
|
|
105
|
+
export interface TaskEntry {
|
|
106
|
+
id: string;
|
|
107
|
+
attributes: {
|
|
108
|
+
category: string | null;
|
|
109
|
+
description: string | null;
|
|
110
|
+
amount: number | null;
|
|
111
|
+
unit_price: number | null;
|
|
112
|
+
total_price: number | null;
|
|
113
|
+
};
|
|
114
|
+
relationships: {
|
|
115
|
+
assignee: {
|
|
116
|
+
attributes: Pick<AssigneeRelAttr, 'name'>;
|
|
117
|
+
} | null;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ApiClientLike } from '../../core/client';
|
|
2
|
+
import type { QueryParams } from '../../core/query-builder';
|
|
3
|
+
import type { Activation, ActPanelRow, DeactPanelRow } from './types';
|
|
4
|
+
export declare function createActivationsApi(client: ApiClientLike): {
|
|
5
|
+
panelAct: (params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
|
|
6
|
+
data: ActPanelRow[];
|
|
7
|
+
}>;
|
|
8
|
+
panelDeact: (params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
|
|
9
|
+
data: DeactPanelRow[];
|
|
10
|
+
}>;
|
|
11
|
+
endpoint: string;
|
|
12
|
+
list: <R = Activation>(params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<import("../..").ListResponse<R>>;
|
|
13
|
+
get: <R = Activation>(id: string, params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
|
|
14
|
+
data: R;
|
|
15
|
+
}>;
|
|
16
|
+
create: (payload: unknown) => Promise<undefined>;
|
|
17
|
+
update: (id: string, payload: unknown) => Promise<undefined>;
|
|
18
|
+
remove: (id: string) => Promise<undefined>;
|
|
19
|
+
removeMany: (payload: unknown, signal?: AbortSignal) => Promise<undefined>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createResourceApi } from '../../core/client.js';
|
|
2
|
+
import { withQuery } from '../../core/query-builder.js';
|
|
3
|
+
export function createActivationsApi(client) {
|
|
4
|
+
return {
|
|
5
|
+
...createResourceApi(client, '/v5/devices/activation-history'),
|
|
6
|
+
panelAct: (params = {}, signal) => client.get(withQuery('/v5/devices/activation-history', params), { signal }).then(r => r.data),
|
|
7
|
+
panelDeact: (params = {}, signal) => client.get(withQuery('/v5/devices/activation-history', params), { signal }).then(r => r.data),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ActivationSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
attributes: z.ZodObject<{
|
|
5
|
+
activated_at: z.ZodNullable<z.ZodString>;
|
|
6
|
+
deactivated_at: z.ZodNullable<z.ZodString>;
|
|
7
|
+
created_at: z.ZodNullable<z.ZodString>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
relationships: z.ZodObject<{
|
|
10
|
+
device: z.ZodNullable<z.ZodObject<{
|
|
11
|
+
attributes: z.ZodObject<{
|
|
12
|
+
name: z.ZodNullable<z.ZodString>;
|
|
13
|
+
imei: z.ZodNullable<z.ZodString>;
|
|
14
|
+
code: z.ZodNullable<z.ZodString>;
|
|
15
|
+
active: z.ZodNullable<z.ZodBoolean>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
activator: z.ZodNullable<z.ZodObject<{
|
|
19
|
+
attributes: z.ZodObject<{
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
username: z.ZodNullable<z.ZodString>;
|
|
22
|
+
email: z.ZodNullable<z.ZodString>;
|
|
23
|
+
phone1: z.ZodNullable<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
}, z.core.$strip>>;
|
|
26
|
+
deactivator: z.ZodNullable<z.ZodObject<{
|
|
27
|
+
attributes: z.ZodObject<{
|
|
28
|
+
name: z.ZodString;
|
|
29
|
+
username: z.ZodNullable<z.ZodString>;
|
|
30
|
+
email: z.ZodNullable<z.ZodString>;
|
|
31
|
+
phone1: z.ZodNullable<z.ZodString>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
}, z.core.$strip>>;
|
|
34
|
+
device_type: z.ZodNullable<z.ZodObject<{
|
|
35
|
+
attributes: z.ZodObject<{
|
|
36
|
+
brand_alias: z.ZodNullable<z.ZodString>;
|
|
37
|
+
alias: z.ZodNullable<z.ZodString>;
|
|
38
|
+
type: z.ZodNullable<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
}, z.core.$strip>>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const ActivationSchema = z.object({
|
|
3
|
+
id: z.string(),
|
|
4
|
+
attributes: z.object({
|
|
5
|
+
activated_at: z.string().nullable(),
|
|
6
|
+
deactivated_at: z.string().nullable(),
|
|
7
|
+
created_at: z.string().nullable(),
|
|
8
|
+
}),
|
|
9
|
+
relationships: z.object({
|
|
10
|
+
device: z.object({
|
|
11
|
+
attributes: z.object({
|
|
12
|
+
name: z.string().nullable(),
|
|
13
|
+
imei: z.string().nullable(),
|
|
14
|
+
code: z.string().nullable(),
|
|
15
|
+
active: z.boolean().nullable(),
|
|
16
|
+
}),
|
|
17
|
+
}).nullable(),
|
|
18
|
+
activator: z.object({
|
|
19
|
+
attributes: z.object({
|
|
20
|
+
name: z.string(),
|
|
21
|
+
username: z.string().nullable(),
|
|
22
|
+
email: z.string().nullable(),
|
|
23
|
+
phone1: z.string().nullable(),
|
|
24
|
+
}),
|
|
25
|
+
}).nullable(),
|
|
26
|
+
deactivator: z.object({
|
|
27
|
+
attributes: z.object({
|
|
28
|
+
name: z.string(),
|
|
29
|
+
username: z.string().nullable(),
|
|
30
|
+
email: z.string().nullable(),
|
|
31
|
+
phone1: z.string().nullable(),
|
|
32
|
+
}),
|
|
33
|
+
}).nullable(),
|
|
34
|
+
device_type: z.object({
|
|
35
|
+
attributes: z.object({
|
|
36
|
+
brand_alias: z.string().nullable(),
|
|
37
|
+
alias: z.string().nullable(),
|
|
38
|
+
type: z.string().nullable(),
|
|
39
|
+
}),
|
|
40
|
+
}).nullable(),
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { DeviceTypeAttr } from '../types';
|
|
2
|
+
export interface ActivationAttributes {
|
|
3
|
+
activated_at: string | null;
|
|
4
|
+
deactivated_at: string | null;
|
|
5
|
+
created_at: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface Activation {
|
|
8
|
+
id: string;
|
|
9
|
+
attributes: ActivationAttributes;
|
|
10
|
+
relationships: {
|
|
11
|
+
device: {
|
|
12
|
+
attributes: {
|
|
13
|
+
name: string | null;
|
|
14
|
+
imei: string | null;
|
|
15
|
+
code: string | null;
|
|
16
|
+
active: boolean | null;
|
|
17
|
+
};
|
|
18
|
+
} | null;
|
|
19
|
+
activator: {
|
|
20
|
+
attributes: {
|
|
21
|
+
name: string;
|
|
22
|
+
username: string | null;
|
|
23
|
+
email: string | null;
|
|
24
|
+
phone1: string | null;
|
|
25
|
+
};
|
|
26
|
+
} | null;
|
|
27
|
+
deactivator: {
|
|
28
|
+
attributes: {
|
|
29
|
+
name: string;
|
|
30
|
+
username: string | null;
|
|
31
|
+
email: string | null;
|
|
32
|
+
phone1: string | null;
|
|
33
|
+
};
|
|
34
|
+
} | null;
|
|
35
|
+
device_type: {
|
|
36
|
+
attributes: DeviceTypeAttr;
|
|
37
|
+
} | null;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface ActPanelRow {
|
|
41
|
+
attributes: {
|
|
42
|
+
count: string;
|
|
43
|
+
created_at: {
|
|
44
|
+
day: string;
|
|
45
|
+
} | null;
|
|
46
|
+
activator: {
|
|
47
|
+
name: string | null;
|
|
48
|
+
} | null;
|
|
49
|
+
device: {
|
|
50
|
+
name: string | null;
|
|
51
|
+
} | null;
|
|
52
|
+
device_type: {
|
|
53
|
+
alias: string | null;
|
|
54
|
+
brand_alias: string | null;
|
|
55
|
+
} | null;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface DeactPanelRow {
|
|
59
|
+
attributes: {
|
|
60
|
+
count: string;
|
|
61
|
+
deleted_at: {
|
|
62
|
+
day: string;
|
|
63
|
+
} | null;
|
|
64
|
+
deactivator: {
|
|
65
|
+
name: string | null;
|
|
66
|
+
} | null;
|
|
67
|
+
device: {
|
|
68
|
+
name: string | null;
|
|
69
|
+
} | null;
|
|
70
|
+
device_type: {
|
|
71
|
+
alias: string | null;
|
|
72
|
+
brand_alias: string | null;
|
|
73
|
+
} | null;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ApiClientLike } from '../core/client';
|
|
2
|
+
import type { QueryParams } from '../core/query-builder';
|
|
3
|
+
import type { ActivationHistoryItem, AssociationHistoryItem, Device, DeviceModel, DevicePanelRow } from './types';
|
|
4
|
+
export declare function createDevicesApi(client: ApiClientLike): {
|
|
5
|
+
listModels: (params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
|
|
6
|
+
data: DeviceModel[];
|
|
7
|
+
}>;
|
|
8
|
+
listActivationHistory: (deviceId: string, params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
|
|
9
|
+
data: ActivationHistoryItem[];
|
|
10
|
+
count: number;
|
|
11
|
+
}>;
|
|
12
|
+
listAssociationHistory: (deviceId: string, params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
|
|
13
|
+
data: AssociationHistoryItem[];
|
|
14
|
+
count: number;
|
|
15
|
+
}>;
|
|
16
|
+
panel: (params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
|
|
17
|
+
data: DevicePanelRow[];
|
|
18
|
+
}>;
|
|
19
|
+
endpoint: string;
|
|
20
|
+
list: <R = Device>(params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<import("..").ListResponse<R>>;
|
|
21
|
+
get: <R = Device>(id: string, params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
|
|
22
|
+
data: R;
|
|
23
|
+
}>;
|
|
24
|
+
create: (payload: unknown) => Promise<undefined>;
|
|
25
|
+
update: (id: string, payload: unknown) => Promise<undefined>;
|
|
26
|
+
remove: (id: string) => Promise<undefined>;
|
|
27
|
+
removeMany: (payload: unknown, signal?: AbortSignal) => Promise<undefined>;
|
|
28
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createResourceApi } from '../core/client.js';
|
|
2
|
+
import { withQuery } from '../core/query-builder.js';
|
|
3
|
+
export function createDevicesApi(client) {
|
|
4
|
+
return {
|
|
5
|
+
...createResourceApi(client, '/v5/devices'),
|
|
6
|
+
listModels: (params = {}, signal) => client.get(withQuery('/v5/devices/models', params), { signal }).then(r => r.data),
|
|
7
|
+
listActivationHistory: (deviceId, params = {}, signal) => client.get(withQuery(`/v5/devices/${deviceId}/activation-history`, params), { signal }).then(r => r.data),
|
|
8
|
+
listAssociationHistory: (deviceId, params = {}, signal) => client.get(withQuery(`/v5/devices/${deviceId}/association-history`, params), { signal }).then(r => r.data),
|
|
9
|
+
panel: (params = {}, signal) => client.get(withQuery('/v5/devices', params), { signal }).then(r => r.data),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ApiClientLike } from '../../core/client';
|
|
2
|
+
import type { QueryParams } from '../../core/query-builder';
|
|
3
|
+
import type { Command, CommandPanelRow } from './types';
|
|
4
|
+
export declare function createCommandsApi(client: ApiClientLike): {
|
|
5
|
+
panel: (params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
|
|
6
|
+
data: CommandPanelRow[];
|
|
7
|
+
}>;
|
|
8
|
+
endpoint: string;
|
|
9
|
+
list: <R = Command>(params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<import("../..").ListResponse<R>>;
|
|
10
|
+
get: <R = Command>(id: string, params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
|
|
11
|
+
data: R;
|
|
12
|
+
}>;
|
|
13
|
+
create: (payload: unknown) => Promise<undefined>;
|
|
14
|
+
update: (id: string, payload: unknown) => Promise<undefined>;
|
|
15
|
+
remove: (id: string) => Promise<undefined>;
|
|
16
|
+
removeMany: (payload: unknown, signal?: AbortSignal) => Promise<undefined>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createResourceApi } from '../../core/client.js';
|
|
2
|
+
import { withQuery } from '../../core/query-builder.js';
|
|
3
|
+
export function createCommandsApi(client) {
|
|
4
|
+
return {
|
|
5
|
+
...createResourceApi(client, '/v5/devices/commands-history'),
|
|
6
|
+
panel: (params = {}, signal) => client.get(withQuery('/v5/devices/commands-history', params), { signal }).then(r => r.data),
|
|
7
|
+
};
|
|
8
|
+
}
|