@sonoransoftware/sonoran.js 1.0.2 → 1.0.5

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 (43) hide show
  1. package/dist/constants.d.ts +84 -10
  2. package/dist/index.d.ts +1 -2
  3. package/dist/index.js +1 -1
  4. package/dist/libs/rest/src/lib/REST.js +23 -1
  5. package/dist/libs/rest/src/lib/utils/constants.d.ts +30 -2
  6. package/dist/libs/rest/src/lib/utils/constants.js +24 -0
  7. package/dist/managers/CMSManager.d.ts +40 -2
  8. package/dist/managers/CMSManager.js +109 -7
  9. package/dist/managers/CMSServerManager.js +6 -0
  10. package/package.json +2 -2
  11. package/src/builders/cad/DispatchCall.ts +158 -158
  12. package/src/builders/index.ts +2 -2
  13. package/src/constants.ts +85 -10
  14. package/src/errors/LibraryErrors.ts +42 -42
  15. package/src/errors/Messages.ts +6 -6
  16. package/src/errors/index.ts +1 -1
  17. package/src/index.ts +4 -12
  18. package/src/instance/Instance.ts +117 -117
  19. package/src/instance/instance.types.ts +16 -16
  20. package/src/libs/rest/src/index.ts +5 -5
  21. package/src/libs/rest/src/lib/REST.ts +23 -1
  22. package/src/libs/rest/src/lib/RequestManager.ts +255 -255
  23. package/src/libs/rest/src/lib/errors/APIError.ts +14 -14
  24. package/src/libs/rest/src/lib/errors/HTTPError.ts +21 -21
  25. package/src/libs/rest/src/lib/errors/RateLimitError.ts +20 -20
  26. package/src/libs/rest/src/lib/errors/index.ts +3 -3
  27. package/src/libs/rest/src/lib/handlers/IHandler.ts +12 -12
  28. package/src/libs/rest/src/lib/handlers/SequentialHandler.ts +157 -157
  29. package/src/libs/rest/src/lib/utils/constants.ts +55 -2
  30. package/src/libs/rest/src/lib/utils/utils.ts +17 -17
  31. package/src/managers/BaseManager.ts +15 -15
  32. package/src/managers/CADActiveUnitsManager.ts +49 -49
  33. package/src/managers/CADManager.ts +58 -58
  34. package/src/managers/CADServerManager.ts +26 -26
  35. package/src/managers/CMSManager.ts +103 -11
  36. package/src/managers/CMSServerManager.ts +6 -0
  37. package/src/managers/CacheManager.ts +37 -37
  38. package/src/managers/DataManager.ts +63 -63
  39. package/src/structures/Base.ts +27 -27
  40. package/src/structures/CADActiveUnit.ts +84 -84
  41. package/src/structures/CADServer.ts +36 -36
  42. package/src/structures/CMSServer.ts +25 -25
  43. package/src/utils/utils.ts +74 -74
@@ -1,159 +1,159 @@
1
- import { CADNewDispatchBuilderOptions } from '../../constants';
2
- import { CADDispatchOriginEnums, CADDispatchStatusEnums } from '../../libs/rest/src';
3
-
4
- /**
5
- * Represents a constructed dispatch call for API requests
6
- */
7
- export class DispatchCallBuilder {
8
- public readonly data: CADNewDispatchBuilderOptions;
9
-
10
- /**
11
- * Dispatch Call Builder used for API calls with Sonoran CAD to create a new dispatch call.
12
- * @param data Data Options (CADNewDispatchBuilderOptions) used to build the new dispatch call
13
- */
14
- public constructor(data: CADNewDispatchBuilderOptions = {}) {
15
- this.data = { ...data };
16
- }
17
-
18
- /**
19
- * Sets the origin for this dispatch call
20
- * @param origin Origin enum used for this dispatch call for information purposes
21
- */
22
- public setOrigin(origin: CADDispatchOriginEnums): this {
23
- this.data.origin = origin;
24
- return this;
25
- }
26
-
27
- /**
28
- * Sets the status for this dispatch call
29
- * @param status Status enum used for the dispatch call for information purposes
30
- */
31
- public setStatus(status: CADDispatchStatusEnums): this {
32
- this.data.status = status;
33
- return this;
34
- }
35
-
36
- /**
37
- * Sets the priority level for this dispatch call
38
- * @param priority Priority level used for the dispatch call for information purposes
39
- */
40
- public setPriority(priority: 1 | 2 | 3): this {
41
- this.data.priority = priority;
42
- return this;
43
- }
44
-
45
- /**
46
- * Sets the block for this dispatch call
47
- * @param block Block used for the dispatch call for information purposes
48
- */
49
- public setBlock(block: string): this {
50
- this.data.block = block;
51
- return this;
52
- }
53
-
54
- /**
55
- * Sets the address for this dispatch call
56
- * @param address Address used for the dispatch call for information purposes
57
- */
58
- public setAddress(address: string): this {
59
- this.data.address = address;
60
- return this;
61
- }
62
-
63
- /**
64
- * Sets the postal for this dispatch call
65
- * @param postal Postal used for the dispatch call for information purposes
66
- */
67
- public setPostal(postal: string): this {
68
- this.data.postal = postal;
69
- return this;
70
- }
71
-
72
- /**
73
- * Sets the title for this dispatch call
74
- * @param title Title used for the dispatch call for information purposes
75
- */
76
- public setTitle(title: string): this {
77
- this.data.title = title;
78
- return this;
79
- }
80
-
81
- /**
82
- * Sets the code for this dispatch call
83
- * @param code Code used for the dispatch call for information purposes
84
- */
85
- public setCode(code: string): this {
86
- this.data.code = code;
87
- return this;
88
- }
89
-
90
- /**
91
- * Sets the primary tracking preference for this dispatch call
92
- * @param primaryUnit Primary unit identifier
93
- */
94
- public setPrimary(primaryUnit: number): this {
95
- this.data.primary = primaryUnit;
96
- return this;
97
- }
98
-
99
- /**
100
- * Sets the track primary preference for this dispatch call
101
- * @param preference Preference for tracking primary
102
- */
103
- public setTrackPrimaryPreference(preference: boolean): this {
104
- this.data.trackPrimary = preference;
105
- return this;
106
- }
107
-
108
- /**
109
- * Sets the description for this dispatch call
110
- * @param description Description for a dispatch call
111
- */
112
- public setDescription(description: string): this {
113
- this.data.description = description;
114
- return this;
115
- }
116
-
117
- /**
118
- * Sets metadata for this dispatch call that can be used later on
119
- * @param metaData Dictionary of metadata to store with a dispatch call, can be used later on
120
- */
121
- public setMetadata(metaData: Record<string, string>): this {
122
- this.data.metaData = metaData;
123
- return this;
124
- }
125
-
126
- /**
127
- * Sets specified units for this dispatch call
128
- * @param units Units to be removed from a call
129
- */
130
- public setUnits(units: string[]): this {
131
- this.data.units = units;
132
- return this;
133
- }
134
-
135
- /**
136
- * Adds specified units from this dispatch call
137
- * @param units Units to be removed from a call
138
- */
139
- public addUnits(...units: string[]): this {
140
- this.data.units?.push(...units);
141
- return this;
142
- }
143
-
144
- /**
145
- * Removes specified units from this dispatch call
146
- * @param units Units to be removed from a call
147
- */
148
- public removeUnits(...units: string[]): this {
149
- this.data.units?.filter((unit) => !units.includes(unit));
150
- return this;
151
- }
152
-
153
- /**
154
- * Transforms the dispatch call to a plain object
155
- */
156
- public toJSON(): CADNewDispatchBuilderOptions{
157
- return { ...this.data };
158
- }
1
+ import { CADNewDispatchBuilderOptions } from '../../constants';
2
+ import { CADDispatchOriginEnums, CADDispatchStatusEnums } from '../../libs/rest/src';
3
+
4
+ /**
5
+ * Represents a constructed dispatch call for API requests
6
+ */
7
+ export class DispatchCallBuilder {
8
+ public readonly data: CADNewDispatchBuilderOptions;
9
+
10
+ /**
11
+ * Dispatch Call Builder used for API calls with Sonoran CAD to create a new dispatch call.
12
+ * @param data Data Options (CADNewDispatchBuilderOptions) used to build the new dispatch call
13
+ */
14
+ public constructor(data: CADNewDispatchBuilderOptions = {}) {
15
+ this.data = { ...data };
16
+ }
17
+
18
+ /**
19
+ * Sets the origin for this dispatch call
20
+ * @param origin Origin enum used for this dispatch call for information purposes
21
+ */
22
+ public setOrigin(origin: CADDispatchOriginEnums): this {
23
+ this.data.origin = origin;
24
+ return this;
25
+ }
26
+
27
+ /**
28
+ * Sets the status for this dispatch call
29
+ * @param status Status enum used for the dispatch call for information purposes
30
+ */
31
+ public setStatus(status: CADDispatchStatusEnums): this {
32
+ this.data.status = status;
33
+ return this;
34
+ }
35
+
36
+ /**
37
+ * Sets the priority level for this dispatch call
38
+ * @param priority Priority level used for the dispatch call for information purposes
39
+ */
40
+ public setPriority(priority: 1 | 2 | 3): this {
41
+ this.data.priority = priority;
42
+ return this;
43
+ }
44
+
45
+ /**
46
+ * Sets the block for this dispatch call
47
+ * @param block Block used for the dispatch call for information purposes
48
+ */
49
+ public setBlock(block: string): this {
50
+ this.data.block = block;
51
+ return this;
52
+ }
53
+
54
+ /**
55
+ * Sets the address for this dispatch call
56
+ * @param address Address used for the dispatch call for information purposes
57
+ */
58
+ public setAddress(address: string): this {
59
+ this.data.address = address;
60
+ return this;
61
+ }
62
+
63
+ /**
64
+ * Sets the postal for this dispatch call
65
+ * @param postal Postal used for the dispatch call for information purposes
66
+ */
67
+ public setPostal(postal: string): this {
68
+ this.data.postal = postal;
69
+ return this;
70
+ }
71
+
72
+ /**
73
+ * Sets the title for this dispatch call
74
+ * @param title Title used for the dispatch call for information purposes
75
+ */
76
+ public setTitle(title: string): this {
77
+ this.data.title = title;
78
+ return this;
79
+ }
80
+
81
+ /**
82
+ * Sets the code for this dispatch call
83
+ * @param code Code used for the dispatch call for information purposes
84
+ */
85
+ public setCode(code: string): this {
86
+ this.data.code = code;
87
+ return this;
88
+ }
89
+
90
+ /**
91
+ * Sets the primary tracking preference for this dispatch call
92
+ * @param primaryUnit Primary unit identifier
93
+ */
94
+ public setPrimary(primaryUnit: number): this {
95
+ this.data.primary = primaryUnit;
96
+ return this;
97
+ }
98
+
99
+ /**
100
+ * Sets the track primary preference for this dispatch call
101
+ * @param preference Preference for tracking primary
102
+ */
103
+ public setTrackPrimaryPreference(preference: boolean): this {
104
+ this.data.trackPrimary = preference;
105
+ return this;
106
+ }
107
+
108
+ /**
109
+ * Sets the description for this dispatch call
110
+ * @param description Description for a dispatch call
111
+ */
112
+ public setDescription(description: string): this {
113
+ this.data.description = description;
114
+ return this;
115
+ }
116
+
117
+ /**
118
+ * Sets metadata for this dispatch call that can be used later on
119
+ * @param metaData Dictionary of metadata to store with a dispatch call, can be used later on
120
+ */
121
+ public setMetadata(metaData: Record<string, string>): this {
122
+ this.data.metaData = metaData;
123
+ return this;
124
+ }
125
+
126
+ /**
127
+ * Sets specified units for this dispatch call
128
+ * @param units Units to be removed from a call
129
+ */
130
+ public setUnits(units: string[]): this {
131
+ this.data.units = units;
132
+ return this;
133
+ }
134
+
135
+ /**
136
+ * Adds specified units from this dispatch call
137
+ * @param units Units to be removed from a call
138
+ */
139
+ public addUnits(...units: string[]): this {
140
+ this.data.units?.push(...units);
141
+ return this;
142
+ }
143
+
144
+ /**
145
+ * Removes specified units from this dispatch call
146
+ * @param units Units to be removed from a call
147
+ */
148
+ public removeUnits(...units: string[]): this {
149
+ this.data.units?.filter((unit) => !units.includes(unit));
150
+ return this;
151
+ }
152
+
153
+ /**
154
+ * Transforms the dispatch call to a plain object
155
+ */
156
+ public toJSON(): CADNewDispatchBuilderOptions{
157
+ return { ...this.data };
158
+ }
159
159
  }
@@ -1,3 +1,3 @@
1
- export * from './cad';
2
- // export * from './cms';
1
+ export * from './cad';
2
+ // export * from './cms';
3
3
  // export * from './global';
package/src/constants.ts CHANGED
@@ -74,26 +74,41 @@ export interface CMSVerifyWhitelistPromiseResult {
74
74
  reason?: string;
75
75
  }
76
76
 
77
+ export interface CMSGetFullWhitelistPromiseResult {
78
+ success: boolean;
79
+ reason?: string;
80
+ data?: {
81
+ name: string;
82
+ apiIds: string[];
83
+ }[];
84
+ }
85
+
86
+ export interface CMSGetAccountRanksPromiseResult {
87
+ success: boolean;
88
+ reason?: string;
89
+ data?: string[];
90
+ }
91
+
77
92
  export interface CMSGetComAccountPromiseResult {
78
93
  success: boolean;
79
94
  reason?: string;
80
95
  data?: {
81
96
  accId: string;
82
- active: boolean;
83
- accName: string;
84
- comName: string;
97
+ sysStatus: boolean;
98
+ comStatus: boolean;
99
+ joinDate: string;
100
+ lastLogin: string;
101
+ owner: boolean;
102
+ banned: boolean;
103
+ activeApiIds: string[];
85
104
  primaryIdentifier: string;
86
- secondaryIdentifiers: string[];
105
+ secondaryIdentifiers: {
106
+ identifiers: { id: string; label: string; }[];
107
+ }
87
108
  primaryRank: string;
88
109
  secondaryRanks: string[];
89
110
  primaryDepartment: string;
90
111
  secondaryDepartments: string[];
91
- joinDate: string;
92
- totalRankPower: number;
93
- comOwner: boolean;
94
- isBanned: boolean;
95
- lastLogin: string;
96
- activeApiIds: string[];
97
112
  }
98
113
  }
99
114
 
@@ -117,6 +132,56 @@ export interface CMSCheckComApiIdPromiseResult {
117
132
  username?: string;
118
133
  }
119
134
 
135
+ export interface CMSGetDepartmentsPromiseResult {
136
+ success: boolean;
137
+ reason?: string;
138
+ data?: CMSDepartment[];
139
+ }
140
+
141
+ export interface CMSSetAccountRanksPromiseResult {
142
+ success: boolean;
143
+ reason?: string;
144
+ data?: {
145
+ accId: string;
146
+ sysStatus: boolean;
147
+ comStatus: boolean;
148
+ joinDate: string;
149
+ lastLogin: string;
150
+ owner: boolean;
151
+ banned: boolean;
152
+ activeApiIds: string[];
153
+ primaryIdentifier: string;
154
+ secondaryIdentifiers: {
155
+ identifiers: { id: string; label: string; }[];
156
+ }
157
+ primaryRank: string;
158
+ secondaryRanks: string[];
159
+ primaryDepartment: string;
160
+ secondaryDepartments: string[];
161
+ }
162
+ }
163
+
164
+ export interface CMSSetAccountRanksChangesObject {
165
+ set?: {
166
+ primary?: string | null;
167
+ secondary?: string[];
168
+ }
169
+ add: string[];
170
+ remove: string[];
171
+ }
172
+
173
+ export interface CMSDepartment {
174
+ uuid: string;
175
+ label: string;
176
+ labelTwo: string;
177
+ ranks: {
178
+ id: string;
179
+ label: string;
180
+ primaryOnly: boolean;
181
+ secondaryOnly: boolean;
182
+ }[];
183
+ }
184
+
120
185
  export interface CADGetAccountPromiseResult {
121
186
  success: boolean;
122
187
  reason?: string;
@@ -142,6 +207,7 @@ export interface CADGetAccountPromiseResult {
142
207
  polEditUnit: boolean;
143
208
  polEditOtherUnit: boolean;
144
209
  selfDispatch: boolean;
210
+ liveMap: boolean;
145
211
  medRecAdd: boolean;
146
212
  medRecEdit: boolean;
147
213
  medRecRemove: boolean;
@@ -154,6 +220,7 @@ export interface CADGetAccountPromiseResult {
154
220
  dmvRecEdit: boolean;
155
221
  dmvRecRemove: boolean;
156
222
  dmvSuper: boolean;
223
+ modifyStreetSigns: boolean;
157
224
  lawRecAdd: boolean;
158
225
  lawRecEdit: boolean;
159
226
  lawRecRemove: boolean;
@@ -171,4 +238,12 @@ export interface CADGetAccountPromiseResult {
171
238
  },
172
239
  apiIds: string[];
173
240
  }
241
+ }
242
+
243
+ export interface clockInOutRequest {
244
+ id: number;
245
+ notes: any[];
246
+ endTime: string;
247
+ completed: boolean;
248
+ startTime: string;
174
249
  }
@@ -1,43 +1,43 @@
1
- const messages = new Map();
2
-
3
- export class GenericError extends Error {
4
- private readonly errCode: string;
5
- constructor(key: string, ...args: Array<any>) {
6
- super(GenericError.message(key, args));
7
- this.errCode = key;
8
- if (Error.captureStackTrace) Error.captureStackTrace(this, GenericError);
9
- }
10
-
11
- get name(): string {
12
- return `${super.name} [${this.errCode}]`;
13
- }
14
-
15
- get code(): string {
16
- return this.errCode;
17
- }
18
-
19
- /**
20
- * Format the message for an error.
21
- * @param {string} key Error key
22
- * @param {Array<any>} args Arguments to pass for util format or as function args
23
- * @returns {string} Formatted string
24
- */
25
- private static message(key: string, args: Array<any>): string {
26
- if (typeof key !== 'string') throw new Error('Error message key must be a string');
27
- const msg = messages.get(key);
28
- if (!msg) throw new Error(`An invalid error message key was used: ${key}.`);
29
- if (typeof msg === 'function') return msg(...args);
30
- if (!args?.length) return msg;
31
- args.unshift(msg);
32
- return String(...args);
33
- }
34
- }
35
-
36
- /**
37
- * Register an error code and message.
38
- * @param {string} sym Unique name for the error
39
- * @param {*} val Value of the error
40
- */
41
- export function register(sym: symbol, val: any): void {
42
- messages.set(sym, typeof val === 'function' ? val : String(val));
1
+ const messages = new Map();
2
+
3
+ export class GenericError extends Error {
4
+ private readonly errCode: string;
5
+ constructor(key: string, ...args: Array<any>) {
6
+ super(GenericError.message(key, args));
7
+ this.errCode = key;
8
+ if (Error.captureStackTrace) Error.captureStackTrace(this, GenericError);
9
+ }
10
+
11
+ get name(): string {
12
+ return `${super.name} [${this.errCode}]`;
13
+ }
14
+
15
+ get code(): string {
16
+ return this.errCode;
17
+ }
18
+
19
+ /**
20
+ * Format the message for an error.
21
+ * @param {string} key Error key
22
+ * @param {Array<any>} args Arguments to pass for util format or as function args
23
+ * @returns {string} Formatted string
24
+ */
25
+ private static message(key: string, args: Array<any>): string {
26
+ if (typeof key !== 'string') throw new Error('Error message key must be a string');
27
+ const msg = messages.get(key);
28
+ if (!msg) throw new Error(`An invalid error message key was used: ${key}.`);
29
+ if (typeof msg === 'function') return msg(...args);
30
+ if (!args?.length) return msg;
31
+ args.unshift(msg);
32
+ return String(...args);
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Register an error code and message.
38
+ * @param {string} sym Unique name for the error
39
+ * @param {*} val Value of the error
40
+ */
41
+ export function register(sym: symbol, val: any): void {
42
+ messages.set(sym, typeof val === 'function' ? val : String(val));
43
43
  }
@@ -1,7 +1,7 @@
1
- import { register } from './LibraryErrors';
2
-
3
- const Messages: Record<string | number | symbol, any> = {
4
- NOT_IMPLEMENTED: (what: string, name: string) => `Method ${what} not implemented on ${name}.`
5
- };
6
-
1
+ import { register } from './LibraryErrors';
2
+
3
+ const Messages: Record<string | number | symbol, any> = {
4
+ NOT_IMPLEMENTED: (what: string, name: string) => `Method ${what} not implemented on ${name}.`
5
+ };
6
+
7
7
  for (const [name, message] of Object.entries(Messages)) register(Symbol(name), message);
@@ -1,2 +1,2 @@
1
- export * from './LibraryErrors';
1
+ export * from './LibraryErrors';
2
2
  export * from './Messages';
package/src/index.ts CHANGED
@@ -1,12 +1,4 @@
1
- export * from './instance/Instance';
2
- export * from './builders';
3
- export * from './libs/rest/src';
4
-
5
- import { productEnums, CADNewDispatchBuilderOptions, CADSubscriptionVersionEnum, CMSSubscriptionVersionEnum } from './constants';
6
-
7
- export {
8
- productEnums,
9
- CADNewDispatchBuilderOptions,
10
- CADSubscriptionVersionEnum,
11
- CMSSubscriptionVersionEnum
12
- }
1
+ export * from './instance/Instance';
2
+ export * from './builders';
3
+ export * from './libs/rest/src';
4
+ export { productEnums, CADNewDispatchBuilderOptions, CADSubscriptionVersionEnum, CMSSubscriptionVersionEnum } from './constants';