akeyless-client-commons 1.0.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/dist/assets/index.d.mts +17 -0
- package/dist/assets/index.d.ts +17 -0
- package/dist/assets/index.js +334 -0
- package/dist/assets/index.js.map +1 -0
- package/dist/assets/index.mjs +248 -0
- package/dist/assets/index.mjs.map +1 -0
- package/dist/components/index.css +1815 -0
- package/dist/components/index.css.map +1 -0
- package/dist/components/index.d.mts +511 -0
- package/dist/components/index.d.ts +511 -0
- package/dist/components/index.js +5663 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +5423 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/helpers/index.d.mts +207 -0
- package/dist/helpers/index.d.ts +207 -0
- package/dist/helpers/index.js +1858 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/index.mjs +1494 -0
- package/dist/helpers/index.mjs.map +1 -0
- package/dist/hooks/index.d.mts +35 -0
- package/dist/hooks/index.d.ts +35 -0
- package/dist/hooks/index.js +592 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +496 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/types/index.d.mts +265 -0
- package/dist/types/index.d.ts +265 -0
- package/dist/types/index.js +49 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/index.mjs.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { FirebaseStorage } from 'firebase/storage';
|
|
2
|
+
import { Auth } from 'firebase/auth';
|
|
3
|
+
import { WhereFilterOp, Unsubscribe, Firestore, Timestamp, DocumentSnapshot, DocumentData, CollectionReference } from 'firebase/firestore';
|
|
4
|
+
import { TObject, CountryOptions, NxUser, Client } from 'akeyless-types-commons';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { ClassValue } from 'clsx';
|
|
7
|
+
|
|
8
|
+
type OnSnapshotCallback = (documents: any[], config: OnSnapshotConfig) => void;
|
|
9
|
+
interface OnSnapshotParsers {
|
|
10
|
+
onFirstTime?: OnSnapshotCallback;
|
|
11
|
+
onAdd?: OnSnapshotCallback;
|
|
12
|
+
onModify?: OnSnapshotCallback;
|
|
13
|
+
onRemove?: OnSnapshotCallback;
|
|
14
|
+
}
|
|
15
|
+
interface WhereCondition {
|
|
16
|
+
field_name: string;
|
|
17
|
+
operator: WhereFilterOp;
|
|
18
|
+
value: any;
|
|
19
|
+
}
|
|
20
|
+
interface OnSnapshotConfig extends OnSnapshotParsers {
|
|
21
|
+
collectionName: string;
|
|
22
|
+
extraParsers?: OnSnapshotParsers[];
|
|
23
|
+
conditions?: WhereCondition[];
|
|
24
|
+
orderBy?: {
|
|
25
|
+
fieldName: string;
|
|
26
|
+
direction: "asc" | "desc";
|
|
27
|
+
}[];
|
|
28
|
+
}
|
|
29
|
+
interface OnSnapshotConfigDocument extends Omit<OnSnapshotParsers, "onAdd"> {
|
|
30
|
+
collectionName: string;
|
|
31
|
+
documentId: string;
|
|
32
|
+
extraParsers?: Omit<OnSnapshotParsers, "onAdd">[];
|
|
33
|
+
conditions?: WhereCondition[];
|
|
34
|
+
}
|
|
35
|
+
interface SnapshotResult {
|
|
36
|
+
promise: Promise<void>;
|
|
37
|
+
unsubscribe: Unsubscribe;
|
|
38
|
+
}
|
|
39
|
+
type Snapshot = (config: OnSnapshotConfig, snapshotsFirstTime: string[]) => SnapshotResult;
|
|
40
|
+
type SnapshotDocument = (config: OnSnapshotConfigDocument, snapshotsFirstTime: string[]) => SnapshotResult;
|
|
41
|
+
|
|
42
|
+
declare const db: Firestore;
|
|
43
|
+
declare const auth: Auth;
|
|
44
|
+
declare const storage: FirebaseStorage;
|
|
45
|
+
interface Collections {
|
|
46
|
+
[key: string]: CollectionReference<DocumentData>;
|
|
47
|
+
clients: CollectionReference<DocumentData>;
|
|
48
|
+
sites: CollectionReference<DocumentData>;
|
|
49
|
+
cars: CollectionReference<DocumentData>;
|
|
50
|
+
users: CollectionReference<DocumentData>;
|
|
51
|
+
lastLocations: CollectionReference<DocumentData>;
|
|
52
|
+
ermEvents: CollectionReference<DocumentData>;
|
|
53
|
+
erm2Events: CollectionReference<DocumentData>;
|
|
54
|
+
ruptelaEvents: CollectionReference<DocumentData>;
|
|
55
|
+
polygons: CollectionReference<DocumentData>;
|
|
56
|
+
polygonEvents: CollectionReference<DocumentData>;
|
|
57
|
+
polygonCars: CollectionReference<DocumentData>;
|
|
58
|
+
canbus: CollectionReference<DocumentData>;
|
|
59
|
+
states: CollectionReference<DocumentData>;
|
|
60
|
+
app_pro_commands_queue: CollectionReference<DocumentData>;
|
|
61
|
+
trips: CollectionReference<DocumentData>;
|
|
62
|
+
tripsDetails: CollectionReference<DocumentData>;
|
|
63
|
+
audit: CollectionReference<DocumentData>;
|
|
64
|
+
nx_settings: CollectionReference<DocumentData>;
|
|
65
|
+
settings: CollectionReference<DocumentData>;
|
|
66
|
+
translations: CollectionReference<DocumentData>;
|
|
67
|
+
nx_cars: CollectionReference<DocumentData>;
|
|
68
|
+
boards: CollectionReference<DocumentData>;
|
|
69
|
+
protection_types: CollectionReference<DocumentData>;
|
|
70
|
+
board_types: CollectionReference<DocumentData>;
|
|
71
|
+
charge_capacities: CollectionReference<DocumentData>;
|
|
72
|
+
}
|
|
73
|
+
declare const collections: Collections;
|
|
74
|
+
declare const fire_base_TIME_TEMP: typeof Timestamp.now;
|
|
75
|
+
declare const extractAlertsData: (doc: DocumentSnapshot<DocumentData>) => {
|
|
76
|
+
timestamp_seconds: any;
|
|
77
|
+
timestamp_ui: string;
|
|
78
|
+
car_number: string;
|
|
79
|
+
};
|
|
80
|
+
declare const simpleExtractData: (doc: DocumentSnapshot<DocumentData>) => TObject<any>;
|
|
81
|
+
declare const extractSiteData: (doc: DocumentSnapshot<DocumentData>) => {
|
|
82
|
+
id: string;
|
|
83
|
+
created: string;
|
|
84
|
+
updated: string;
|
|
85
|
+
};
|
|
86
|
+
declare const extractClientData: (doc: DocumentSnapshot<DocumentData>) => {
|
|
87
|
+
id: string;
|
|
88
|
+
created: string;
|
|
89
|
+
updated: string;
|
|
90
|
+
};
|
|
91
|
+
declare const extractBoardsData: (doc: DocumentSnapshot<DocumentData>) => {
|
|
92
|
+
id: string;
|
|
93
|
+
uploaded: string;
|
|
94
|
+
};
|
|
95
|
+
declare const extractCarsData: (doc: DocumentSnapshot<DocumentData>) => {
|
|
96
|
+
id: string;
|
|
97
|
+
brand: any;
|
|
98
|
+
car_number: any;
|
|
99
|
+
icon: string;
|
|
100
|
+
};
|
|
101
|
+
declare const extractCanbusData: (doc: DocumentSnapshot<DocumentData>) => {
|
|
102
|
+
date_ui: string;
|
|
103
|
+
};
|
|
104
|
+
declare const extractLocationData: (doc: DocumentSnapshot<DocumentData>) => {
|
|
105
|
+
id: string;
|
|
106
|
+
lat: any;
|
|
107
|
+
lng: any;
|
|
108
|
+
prev_lat: any;
|
|
109
|
+
prev_lng: any;
|
|
110
|
+
timestamp: any;
|
|
111
|
+
spd: string;
|
|
112
|
+
};
|
|
113
|
+
declare const get_all_documents: (collection_path: string) => Promise<TObject<any>[]>;
|
|
114
|
+
declare const get_document_by_id: (collection_path: string, doc_id: string) => Promise<TObject<any>>;
|
|
115
|
+
declare const set_document: (collection_path: string, doc_id: string, data: DocumentData) => Promise<boolean>;
|
|
116
|
+
declare const add_document: (collection_path: string, data: DocumentData, include_id?: boolean) => Promise<boolean>;
|
|
117
|
+
declare const delete_document: (collection_path: string, doc_id: string) => Promise<boolean>;
|
|
118
|
+
declare const query_document: (collection_path: string, field_name: string, operator: WhereFilterOp, value: any, ignore_log?: boolean) => Promise<null | TObject<any>>;
|
|
119
|
+
declare const query_documents: (collection_path: string, field_name: string, operator: WhereFilterOp, value: any) => Promise<TObject<any>[]>;
|
|
120
|
+
declare const query_documents_by_conditions: (collection_path: string, where_conditions: WhereCondition[]) => Promise<TObject<any>[]>;
|
|
121
|
+
declare const query_document_by_conditions: (collection_path: string, where_conditions: WhereCondition[]) => Promise<TObject<any>>;
|
|
122
|
+
declare const snapshot: Snapshot;
|
|
123
|
+
declare const snapshotDocument: SnapshotDocument;
|
|
124
|
+
declare const cleanNxSites: () => Promise<void>;
|
|
125
|
+
|
|
126
|
+
declare const calculateBearing: (startLat: any, startLng: any, endLat: any, endLng: any) => number;
|
|
127
|
+
declare const renderOnce: () => boolean;
|
|
128
|
+
declare const propsAreEqual: (prevProps: any, nextProps: any) => boolean;
|
|
129
|
+
declare const getUserCountryByIp: () => Promise<CountryOptions>;
|
|
130
|
+
declare const parsePermissions: (object: NxUser | Client) => TObject<TObject<boolean>>;
|
|
131
|
+
interface InitializeUserPermissionsProps {
|
|
132
|
+
phoneNumber: string;
|
|
133
|
+
firstTimeArray: string[];
|
|
134
|
+
getUpdatePermissions: (permissions: TObject<TObject<boolean>>) => void;
|
|
135
|
+
}
|
|
136
|
+
declare const initializeUserPermissions: ({ phoneNumber, firstTimeArray, getUpdatePermissions }: InitializeUserPermissionsProps) => Promise<{
|
|
137
|
+
unsubscribe: () => void;
|
|
138
|
+
permissions: TObject<TObject<boolean>>;
|
|
139
|
+
}>;
|
|
140
|
+
declare const userNameFormat: (user?: NxUser) => string;
|
|
141
|
+
declare const multiStringFormat: (str1: string, str2?: string, str3?: string) => string;
|
|
142
|
+
declare const getLocationUrl: (lang: number, lat: number) => string;
|
|
143
|
+
declare const isNodeEnv: NodeJS.ProcessEnv;
|
|
144
|
+
declare const mode: string;
|
|
145
|
+
declare const isLocal: boolean;
|
|
146
|
+
|
|
147
|
+
declare const textRegex: RegExp;
|
|
148
|
+
declare const numbersRegex: RegExp;
|
|
149
|
+
declare const numbersOnlyRegex: RegExp;
|
|
150
|
+
declare const priceRegex: RegExp;
|
|
151
|
+
declare const emailRegex: RegExp;
|
|
152
|
+
declare const colorRegex: RegExp;
|
|
153
|
+
declare const carsRegex: RegExp;
|
|
154
|
+
declare const textNumbersRegex: RegExp;
|
|
155
|
+
declare const addressRegex: RegExp;
|
|
156
|
+
declare const chartsRegex: RegExp;
|
|
157
|
+
type ValidationType = "text" | "numbers" | "numbersOnly" | "price" | "textNumbers" | "email" | "color" | "address" | "cars" | "charts" | (string & {});
|
|
158
|
+
declare const handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
159
|
+
declare const handlePaste: (e: React.ClipboardEvent<HTMLInputElement>) => void;
|
|
160
|
+
declare const handleInvalid: (e: React.InvalidEvent<HTMLInputElement>, requireError?: string) => void;
|
|
161
|
+
declare const useValidation: (validationType: ValidationType, requireError?: string) => {
|
|
162
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
163
|
+
onPaste: (e: React.ClipboardEvent<HTMLInputElement>) => void;
|
|
164
|
+
onInvalid: (e: React.InvalidEvent<HTMLInputElement>) => void;
|
|
165
|
+
"data-validation": ValidationType;
|
|
166
|
+
};
|
|
167
|
+
declare const getFormElementValue: (form: EventTarget & HTMLFormElement, name: string) => string;
|
|
168
|
+
declare const parseMultiSelectInput: (input: string) => any;
|
|
169
|
+
|
|
170
|
+
declare const setState: <T>(updater: T | ((state: T) => T), set: (fn: (state: any) => any) => void, stateName: string) => void;
|
|
171
|
+
declare const createSelectors: <T extends object>(store: any) => { [K in keyof T]: () => T[K]; };
|
|
172
|
+
declare const useStoreValues: <T extends object>(store: {
|
|
173
|
+
use: { [K in keyof T]: () => T[K]; };
|
|
174
|
+
}, keys: Array<keyof T>) => Partial<T>;
|
|
175
|
+
|
|
176
|
+
declare const formatCarNumber: (car_number: string) => string;
|
|
177
|
+
|
|
178
|
+
type ConvertFunction = (input: string) => string;
|
|
179
|
+
type CheckFunction = (input: string) => boolean;
|
|
180
|
+
declare const isInternational: CheckFunction;
|
|
181
|
+
declare const isInternationalIsraelPhone: CheckFunction;
|
|
182
|
+
declare const local_israel_phone_format: ConvertFunction;
|
|
183
|
+
declare const international_israel_phone_format: ConvertFunction;
|
|
184
|
+
declare const displayFormatPhoneNumber: ConvertFunction;
|
|
185
|
+
declare const is_iccid: (number: string) => boolean;
|
|
186
|
+
|
|
187
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
188
|
+
|
|
189
|
+
interface TimeOptions {
|
|
190
|
+
format?: string;
|
|
191
|
+
fromFormat?: string;
|
|
192
|
+
tz?: string;
|
|
193
|
+
}
|
|
194
|
+
declare function timestamp_to_string(firebaseTimestamp: Timestamp | Date | string, options?: TimeOptions): string;
|
|
195
|
+
declare function timestamp_to_millis(firebaseTimestamp: Timestamp): number;
|
|
196
|
+
declare function sort_by_timestamp(a: Timestamp, b: Timestamp, reverse?: boolean): number;
|
|
197
|
+
|
|
198
|
+
declare const baseDomain: string;
|
|
199
|
+
declare const devicesDomain: string;
|
|
200
|
+
declare const biDomain: string;
|
|
201
|
+
declare const callCenterDomain: string;
|
|
202
|
+
declare const akeylessOnlineDomain: string;
|
|
203
|
+
type Method = "GET" | "POST" | "PUT" | "DELETE";
|
|
204
|
+
type ServerName = "devices" | "bi" | "call-center";
|
|
205
|
+
declare const nx_api_call: (serverName: ServerName, method: Method, url: string, data?: TObject<any>) => Promise<any>;
|
|
206
|
+
|
|
207
|
+
export { type ValidationType, add_document, addressRegex, akeylessOnlineDomain, auth, baseDomain, biDomain, calculateBearing, callCenterDomain, carsRegex, chartsRegex, cleanNxSites, cn, collections, colorRegex, createSelectors, db, delete_document, devicesDomain, displayFormatPhoneNumber, emailRegex, extractAlertsData, extractBoardsData, extractCanbusData, extractCarsData, extractClientData, extractLocationData, extractSiteData, fire_base_TIME_TEMP, formatCarNumber, getFormElementValue, getLocationUrl, getUserCountryByIp, get_all_documents, get_document_by_id, handleChange, handleInvalid, handlePaste, initializeUserPermissions, international_israel_phone_format, isInternational, isInternationalIsraelPhone, isLocal, isNodeEnv, is_iccid, local_israel_phone_format, mode, multiStringFormat, numbersOnlyRegex, numbersRegex, nx_api_call, parseMultiSelectInput, parsePermissions, priceRegex, propsAreEqual, query_document, query_document_by_conditions, query_documents, query_documents_by_conditions, renderOnce, setState, set_document, simpleExtractData, snapshot, snapshotDocument, sort_by_timestamp, storage, textNumbersRegex, textRegex, timestamp_to_millis, timestamp_to_string, useStoreValues, useValidation, userNameFormat };
|