@sonoransoftware/sonoran.js 1.0.18 → 1.0.20
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/.eslintrc.js +10 -10
- package/.github/workflows/npm-publish.yml +34 -34
- package/.prettierrc.js +6 -6
- package/dist/builders/cad/DispatchCall.d.ts +92 -92
- package/dist/builders/cad/DispatchCall.js +144 -144
- package/dist/builders/cad/index.d.ts +1 -1
- package/dist/builders/cad/index.js +17 -17
- package/dist/builders/index.d.ts +1 -1
- package/dist/builders/index.js +19 -19
- package/dist/constants.d.ts +230 -230
- package/dist/constants.js +27 -27
- package/dist/errors/LibraryErrors.d.ts +19 -19
- package/dist/errors/LibraryErrors.js +47 -47
- package/dist/errors/Messages.d.ts +1 -1
- package/dist/errors/Messages.js +8 -8
- package/dist/errors/index.d.ts +2 -2
- package/dist/errors/index.js +18 -18
- package/dist/index.d.ts +4 -4
- package/dist/index.js +24 -24
- package/dist/instance/Instance.d.ts +24 -24
- package/dist/instance/Instance.js +139 -139
- package/dist/instance/instance.types.d.ts +17 -17
- package/dist/instance/instance.types.js +2 -2
- package/dist/libs/rest/src/index.d.ts +6 -6
- package/dist/libs/rest/src/index.js +22 -22
- package/dist/libs/rest/src/lib/REST.d.ts +101 -101
- package/dist/libs/rest/src/lib/REST.js +136 -129
- package/dist/libs/rest/src/lib/RequestManager.d.ts +59 -59
- package/dist/libs/rest/src/lib/RequestManager.js +191 -191
- package/dist/libs/rest/src/lib/errors/APIError.d.ts +9 -9
- package/dist/libs/rest/src/lib/errors/APIError.js +17 -17
- package/dist/libs/rest/src/lib/errors/HTTPError.d.ts +17 -17
- package/dist/libs/rest/src/lib/errors/HTTPError.js +23 -23
- package/dist/libs/rest/src/lib/errors/RateLimitError.d.ts +13 -13
- package/dist/libs/rest/src/lib/errors/RateLimitError.js +19 -19
- package/dist/libs/rest/src/lib/errors/index.d.ts +4 -4
- package/dist/libs/rest/src/lib/errors/index.js +20 -20
- package/dist/libs/rest/src/lib/handlers/IHandler.d.ts +7 -7
- package/dist/libs/rest/src/lib/handlers/IHandler.js +2 -2
- package/dist/libs/rest/src/lib/handlers/SequentialHandler.d.ts +45 -45
- package/dist/libs/rest/src/lib/handlers/SequentialHandler.js +143 -143
- package/dist/libs/rest/src/lib/utils/constants.d.ts +533 -527
- package/dist/libs/rest/src/lib/utils/constants.js +463 -443
- package/dist/libs/rest/src/lib/utils/utils.d.ts +1 -1
- package/dist/libs/rest/src/lib/utils/utils.js +22 -22
- package/dist/managers/BaseManager.d.ts +14 -14
- package/dist/managers/BaseManager.js +18 -18
- package/dist/managers/CADActiveUnitsManager.d.ts +15 -15
- package/dist/managers/CADActiveUnitsManager.js +38 -38
- package/dist/managers/CADManager.d.ts +29 -29
- package/dist/managers/CADManager.js +86 -86
- package/dist/managers/CADServerManager.d.ts +8 -8
- package/dist/managers/CADServerManager.js +28 -28
- package/dist/managers/CMSManager.d.ts +101 -101
- package/dist/managers/CMSManager.js +266 -266
- package/dist/managers/CMSServerManager.d.ts +8 -8
- package/dist/managers/CMSServerManager.js +34 -34
- package/dist/managers/CacheManager.d.ts +10 -10
- package/dist/managers/CacheManager.js +36 -36
- package/dist/managers/DataManager.d.ts +31 -31
- package/dist/managers/DataManager.js +58 -58
- package/dist/structures/Base.d.ts +9 -9
- package/dist/structures/Base.js +24 -24
- package/dist/structures/CADActiveUnit.d.ts +47 -47
- package/dist/structures/CADActiveUnit.js +66 -66
- package/dist/structures/CADServer.d.ts +26 -26
- package/dist/structures/CADServer.js +15 -15
- package/dist/structures/CMSServer.d.ts +18 -18
- package/dist/structures/CMSServer.js +12 -12
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +17 -17
- package/dist/utils/utils.d.ts +13 -13
- package/dist/utils/utils.js +79 -79
- package/docs/CAD-Methods-and-Usage.md +58 -58
- package/docs/CMS-Methods-and-Usage.md +211 -211
- package/docs/REST-Methods-and-Usage.md +46 -46
- package/package.json +48 -48
- package/readme.md +53 -53
- package/src/constants.ts +248 -248
- package/src/instance/Instance.ts +121 -121
- package/src/instance/instance.types.ts +17 -17
- package/src/libs/rest/src/lib/REST.ts +241 -235
- package/src/libs/rest/src/lib/RequestManager.ts +260 -260
- package/src/libs/rest/src/lib/handlers/SequentialHandler.ts +160 -160
- package/src/libs/rest/src/lib/utils/constants.ts +1012 -985
- package/src/managers/CADManager.ts +63 -63
- package/src/managers/CMSManager.ts +226 -226
- package/src/managers/CMSServerManager.ts +32 -32
- package/tsconfig.json +71 -71
package/src/instance/Instance.ts
CHANGED
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
import EventEmitter from 'events';
|
|
2
|
-
|
|
3
|
-
import * as globalTypes from '../constants';
|
|
4
|
-
import * as InstanceTypes from './instance.types';
|
|
5
|
-
import { CADManager } from '../managers/CADManager';
|
|
6
|
-
import { CMSManager } from '../managers/CMSManager';
|
|
7
|
-
import { debugLog } from '../utils';
|
|
8
|
-
|
|
9
|
-
export class Instance extends EventEmitter {
|
|
10
|
-
public cadCommunityId: string | undefined;
|
|
11
|
-
public cadApiKey: string | undefined;
|
|
12
|
-
public cadApiUrl: string = 'https://api.sonorancad.com';
|
|
13
|
-
public cadDefaultServerId: number = 1;
|
|
14
|
-
public isCADSuccessful: boolean = false;
|
|
15
|
-
public cmsCommunityId: string | undefined;
|
|
16
|
-
public cmsApiKey: string | undefined;
|
|
17
|
-
public cmsApiUrl: string = 'https://api.sonorancms.com';
|
|
18
|
-
public cmsDefaultServerId: number = 1;
|
|
19
|
-
public isCMSSuccessful: boolean = false;
|
|
20
|
-
|
|
21
|
-
public cad: CADManager | undefined;
|
|
22
|
-
public cms: CMSManager | undefined;
|
|
23
|
-
|
|
24
|
-
public debug: boolean = false;
|
|
25
|
-
public apiHeaders: HeadersInit = {};
|
|
26
|
-
|
|
27
|
-
constructor(options: InstanceTypes.InstanceOptions) {
|
|
28
|
-
super({ captureRejections: true });
|
|
29
|
-
if (options.debug) {
|
|
30
|
-
this.debug = options.debug;
|
|
31
|
-
}
|
|
32
|
-
if (Object.prototype.hasOwnProperty.call(options, 'apiHeaders') && options.apiHeaders !== undefined) {
|
|
33
|
-
this.apiHeaders = options.apiHeaders;
|
|
34
|
-
}
|
|
35
|
-
if (Object.prototype.hasOwnProperty.call(options, 'apiKey') && Object.prototype.hasOwnProperty.call(options, 'communityId')) {
|
|
36
|
-
if (Object.prototype.hasOwnProperty.call(options, 'product')) {
|
|
37
|
-
switch (options.product) {
|
|
38
|
-
case globalTypes.productEnums.CAD: {
|
|
39
|
-
this.cadCommunityId = options.communityId;
|
|
40
|
-
this.cadApiKey = options.apiKey;
|
|
41
|
-
if (options.serverId !== undefined) {
|
|
42
|
-
this._debugLog(`Overriding default server id... ${options.serverId}`);
|
|
43
|
-
this.cadDefaultServerId = options.serverId;
|
|
44
|
-
}
|
|
45
|
-
if (Object.prototype.hasOwnProperty.call(options, 'cadApiUrl') && typeof options.cadApiUrl === 'string') {
|
|
46
|
-
this._debugLog(`Overriding CAD API Url... ${options.cadApiUrl}`);
|
|
47
|
-
this.cadApiUrl = options.cadApiUrl;
|
|
48
|
-
}
|
|
49
|
-
this._debugLog('About to initialize instance.');
|
|
50
|
-
this.initialize();
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
case globalTypes.productEnums.CMS: {
|
|
54
|
-
this.cmsCommunityId = options.communityId;
|
|
55
|
-
this.cmsApiKey = options.apiKey;
|
|
56
|
-
if (options.serverId !== undefined) {
|
|
57
|
-
this._debugLog(`Overriding default server id... ${options.serverId}`);
|
|
58
|
-
this.cmsDefaultServerId = options.serverId;
|
|
59
|
-
}
|
|
60
|
-
if (Object.prototype.hasOwnProperty.call(options, 'cmsApiUrl') && typeof options.cmsApiUrl === 'string') {
|
|
61
|
-
this._debugLog(`Overriding CMS API URL... ${options.cmsApiUrl}`);
|
|
62
|
-
this.cmsApiUrl = options.cmsApiUrl;
|
|
63
|
-
}
|
|
64
|
-
this.initialize();
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
default: {
|
|
68
|
-
throw new Error('Invalid product enum given for constructor.');
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
} else {
|
|
72
|
-
throw new Error('No product enum given when instancing.');
|
|
73
|
-
}
|
|
74
|
-
} else {
|
|
75
|
-
this.cadCommunityId = options.cadCommunityId;
|
|
76
|
-
this.cadApiKey = options.cadApiKey;
|
|
77
|
-
this.cmsCommunityId = options.cmsCommunityId;
|
|
78
|
-
this.cmsApiKey = options.cmsApiKey;
|
|
79
|
-
|
|
80
|
-
if (options.cadDefaultServerId !== undefined) {
|
|
81
|
-
this._debugLog(`Overriding default CAD server id... ${options.serverId}`);
|
|
82
|
-
this.cadDefaultServerId = options.cadDefaultServerId;
|
|
83
|
-
}
|
|
84
|
-
if (options.cmsDefaultServerId !== undefined) {
|
|
85
|
-
this._debugLog(`Overriding default CMS server id... ${options.serverId}`);
|
|
86
|
-
this.cmsDefaultServerId = options.cmsDefaultServerId;
|
|
87
|
-
}
|
|
88
|
-
if (Object.prototype.hasOwnProperty.call(options, 'cadApiUrl') && typeof options.cadApiUrl === 'string') {
|
|
89
|
-
this._debugLog(`Overriding CAD API Url... ${options.cadApiUrl}`);
|
|
90
|
-
this.cadApiUrl = options.cadApiUrl;
|
|
91
|
-
}
|
|
92
|
-
if (Object.prototype.hasOwnProperty.call(options, 'cmsApiUrl') && typeof options.cmsApiUrl === 'string') {
|
|
93
|
-
this._debugLog(`Overriding CMS API URL... ${options.cmsApiUrl}`);
|
|
94
|
-
this.cmsApiUrl = options.cmsApiUrl;
|
|
95
|
-
}
|
|
96
|
-
this.initialize();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
private initialize() {
|
|
103
|
-
if (this.cadCommunityId && this.cadApiKey && this.cadApiUrl) {
|
|
104
|
-
this._debugLog('About to initialize CAD Manager');
|
|
105
|
-
this.cad = new CADManager(this);
|
|
106
|
-
} else {
|
|
107
|
-
this._debugLog('Not initializing CAD Manager due to a missing community id, api key, or api url.');
|
|
108
|
-
}
|
|
109
|
-
if (this.cmsCommunityId && this.cmsApiKey && this.cmsApiUrl) {
|
|
110
|
-
this._debugLog('About to initialize CMS Manager');
|
|
111
|
-
this.cms = new CMSManager(this);
|
|
112
|
-
} else {
|
|
113
|
-
this._debugLog('Not initializing CMS Manager due to a missing community id, api key, or api url.');
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
public _debugLog(message: string): void {
|
|
118
|
-
if (this.debug) {
|
|
119
|
-
debugLog(message);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
1
|
+
import EventEmitter from 'events';
|
|
2
|
+
|
|
3
|
+
import * as globalTypes from '../constants';
|
|
4
|
+
import * as InstanceTypes from './instance.types';
|
|
5
|
+
import { CADManager } from '../managers/CADManager';
|
|
6
|
+
import { CMSManager } from '../managers/CMSManager';
|
|
7
|
+
import { debugLog } from '../utils';
|
|
8
|
+
|
|
9
|
+
export class Instance extends EventEmitter {
|
|
10
|
+
public cadCommunityId: string | undefined;
|
|
11
|
+
public cadApiKey: string | undefined;
|
|
12
|
+
public cadApiUrl: string = 'https://api.sonorancad.com';
|
|
13
|
+
public cadDefaultServerId: number = 1;
|
|
14
|
+
public isCADSuccessful: boolean = false;
|
|
15
|
+
public cmsCommunityId: string | undefined;
|
|
16
|
+
public cmsApiKey: string | undefined;
|
|
17
|
+
public cmsApiUrl: string = 'https://api.sonorancms.com';
|
|
18
|
+
public cmsDefaultServerId: number = 1;
|
|
19
|
+
public isCMSSuccessful: boolean = false;
|
|
20
|
+
|
|
21
|
+
public cad: CADManager | undefined;
|
|
22
|
+
public cms: CMSManager | undefined;
|
|
23
|
+
|
|
24
|
+
public debug: boolean = false;
|
|
25
|
+
public apiHeaders: HeadersInit = {};
|
|
26
|
+
|
|
27
|
+
constructor(options: InstanceTypes.InstanceOptions) {
|
|
28
|
+
super({ captureRejections: true });
|
|
29
|
+
if (options.debug) {
|
|
30
|
+
this.debug = options.debug;
|
|
31
|
+
}
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(options, 'apiHeaders') && options.apiHeaders !== undefined) {
|
|
33
|
+
this.apiHeaders = options.apiHeaders;
|
|
34
|
+
}
|
|
35
|
+
if (Object.prototype.hasOwnProperty.call(options, 'apiKey') && Object.prototype.hasOwnProperty.call(options, 'communityId')) {
|
|
36
|
+
if (Object.prototype.hasOwnProperty.call(options, 'product')) {
|
|
37
|
+
switch (options.product) {
|
|
38
|
+
case globalTypes.productEnums.CAD: {
|
|
39
|
+
this.cadCommunityId = options.communityId;
|
|
40
|
+
this.cadApiKey = options.apiKey;
|
|
41
|
+
if (options.serverId !== undefined) {
|
|
42
|
+
this._debugLog(`Overriding default server id... ${options.serverId}`);
|
|
43
|
+
this.cadDefaultServerId = options.serverId;
|
|
44
|
+
}
|
|
45
|
+
if (Object.prototype.hasOwnProperty.call(options, 'cadApiUrl') && typeof options.cadApiUrl === 'string') {
|
|
46
|
+
this._debugLog(`Overriding CAD API Url... ${options.cadApiUrl}`);
|
|
47
|
+
this.cadApiUrl = options.cadApiUrl;
|
|
48
|
+
}
|
|
49
|
+
this._debugLog('About to initialize instance.');
|
|
50
|
+
this.initialize();
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case globalTypes.productEnums.CMS: {
|
|
54
|
+
this.cmsCommunityId = options.communityId;
|
|
55
|
+
this.cmsApiKey = options.apiKey;
|
|
56
|
+
if (options.serverId !== undefined) {
|
|
57
|
+
this._debugLog(`Overriding default server id... ${options.serverId}`);
|
|
58
|
+
this.cmsDefaultServerId = options.serverId;
|
|
59
|
+
}
|
|
60
|
+
if (Object.prototype.hasOwnProperty.call(options, 'cmsApiUrl') && typeof options.cmsApiUrl === 'string') {
|
|
61
|
+
this._debugLog(`Overriding CMS API URL... ${options.cmsApiUrl}`);
|
|
62
|
+
this.cmsApiUrl = options.cmsApiUrl;
|
|
63
|
+
}
|
|
64
|
+
this.initialize();
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
default: {
|
|
68
|
+
throw new Error('Invalid product enum given for constructor.');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
throw new Error('No product enum given when instancing.');
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
this.cadCommunityId = options.cadCommunityId;
|
|
76
|
+
this.cadApiKey = options.cadApiKey;
|
|
77
|
+
this.cmsCommunityId = options.cmsCommunityId;
|
|
78
|
+
this.cmsApiKey = options.cmsApiKey;
|
|
79
|
+
|
|
80
|
+
if (options.cadDefaultServerId !== undefined) {
|
|
81
|
+
this._debugLog(`Overriding default CAD server id... ${options.serverId}`);
|
|
82
|
+
this.cadDefaultServerId = options.cadDefaultServerId;
|
|
83
|
+
}
|
|
84
|
+
if (options.cmsDefaultServerId !== undefined) {
|
|
85
|
+
this._debugLog(`Overriding default CMS server id... ${options.serverId}`);
|
|
86
|
+
this.cmsDefaultServerId = options.cmsDefaultServerId;
|
|
87
|
+
}
|
|
88
|
+
if (Object.prototype.hasOwnProperty.call(options, 'cadApiUrl') && typeof options.cadApiUrl === 'string') {
|
|
89
|
+
this._debugLog(`Overriding CAD API Url... ${options.cadApiUrl}`);
|
|
90
|
+
this.cadApiUrl = options.cadApiUrl;
|
|
91
|
+
}
|
|
92
|
+
if (Object.prototype.hasOwnProperty.call(options, 'cmsApiUrl') && typeof options.cmsApiUrl === 'string') {
|
|
93
|
+
this._debugLog(`Overriding CMS API URL... ${options.cmsApiUrl}`);
|
|
94
|
+
this.cmsApiUrl = options.cmsApiUrl;
|
|
95
|
+
}
|
|
96
|
+
this.initialize();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
private initialize() {
|
|
103
|
+
if (this.cadCommunityId && this.cadApiKey && this.cadApiUrl) {
|
|
104
|
+
this._debugLog('About to initialize CAD Manager');
|
|
105
|
+
this.cad = new CADManager(this);
|
|
106
|
+
} else {
|
|
107
|
+
this._debugLog('Not initializing CAD Manager due to a missing community id, api key, or api url.');
|
|
108
|
+
}
|
|
109
|
+
if (this.cmsCommunityId && this.cmsApiKey && this.cmsApiUrl) {
|
|
110
|
+
this._debugLog('About to initialize CMS Manager');
|
|
111
|
+
this.cms = new CMSManager(this);
|
|
112
|
+
} else {
|
|
113
|
+
this._debugLog('Not initializing CMS Manager due to a missing community id, api key, or api url.');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public _debugLog(message: string): void {
|
|
118
|
+
if (this.debug) {
|
|
119
|
+
debugLog(message);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
122
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import * as globalTypes from '../constants';
|
|
2
|
-
|
|
3
|
-
export type InstanceOptions = {
|
|
4
|
-
communityId?: string;
|
|
5
|
-
apiKey?: string;
|
|
6
|
-
product?: globalTypes.productEnums;
|
|
7
|
-
serverId?: number;
|
|
8
|
-
cadCommunityId?: string;
|
|
9
|
-
cadApiKey?: string;
|
|
10
|
-
cadApiUrl?: string;
|
|
11
|
-
cadDefaultServerId?: number;
|
|
12
|
-
cmsCommunityId?: string;
|
|
13
|
-
cmsApiKey?: string;
|
|
14
|
-
cmsApiUrl?: string;
|
|
15
|
-
cmsDefaultServerId?: number;
|
|
16
|
-
debug?: boolean;
|
|
17
|
-
apiHeaders?: HeadersInit ;
|
|
1
|
+
import * as globalTypes from '../constants';
|
|
2
|
+
|
|
3
|
+
export type InstanceOptions = {
|
|
4
|
+
communityId?: string;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
product?: globalTypes.productEnums;
|
|
7
|
+
serverId?: number;
|
|
8
|
+
cadCommunityId?: string;
|
|
9
|
+
cadApiKey?: string;
|
|
10
|
+
cadApiUrl?: string;
|
|
11
|
+
cadDefaultServerId?: number;
|
|
12
|
+
cmsCommunityId?: string;
|
|
13
|
+
cmsApiKey?: string;
|
|
14
|
+
cmsApiUrl?: string;
|
|
15
|
+
cmsDefaultServerId?: number;
|
|
16
|
+
debug?: boolean;
|
|
17
|
+
apiHeaders?: HeadersInit ;
|
|
18
18
|
};
|