@de./sdk-rn 1.0.0

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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -0
  3. package/dist/allend/Access.d.ts +12 -0
  4. package/dist/allend/Access.d.ts.map +1 -0
  5. package/dist/allend/Access.js +43 -0
  6. package/dist/allend/Access.js.map +1 -0
  7. package/dist/allend/DClient/Client.d.ts +11 -0
  8. package/dist/allend/DClient/Client.d.ts.map +1 -0
  9. package/dist/allend/DClient/Client.js +50 -0
  10. package/dist/allend/DClient/Client.js.map +1 -0
  11. package/dist/allend/DClient/Event.d.ts +19 -0
  12. package/dist/allend/DClient/Event.d.ts.map +1 -0
  13. package/dist/allend/DClient/Event.js +74 -0
  14. package/dist/allend/DClient/Event.js.map +1 -0
  15. package/dist/allend/DClient/Order.d.ts +50 -0
  16. package/dist/allend/DClient/Order.d.ts.map +1 -0
  17. package/dist/allend/DClient/Order.js +321 -0
  18. package/dist/allend/DClient/Order.js.map +1 -0
  19. package/dist/allend/MSI/Controls.d.ts +232 -0
  20. package/dist/allend/MSI/Controls.d.ts.map +1 -0
  21. package/dist/allend/MSI/Controls.js +668 -0
  22. package/dist/allend/MSI/Controls.js.map +1 -0
  23. package/dist/allend/MSI/Handles.d.ts +89 -0
  24. package/dist/allend/MSI/Handles.d.ts.map +1 -0
  25. package/dist/allend/MSI/Handles.js +328 -0
  26. package/dist/allend/MSI/Handles.js.map +1 -0
  27. package/dist/allend/MSI/Plugins.d.ts +23 -0
  28. package/dist/allend/MSI/Plugins.d.ts.map +1 -0
  29. package/dist/allend/MSI/Plugins.js +29 -0
  30. package/dist/allend/MSI/Plugins.js.map +1 -0
  31. package/dist/allend/MSI/index.d.ts +38 -0
  32. package/dist/allend/MSI/index.d.ts.map +1 -0
  33. package/dist/allend/MSI/index.js +176 -0
  34. package/dist/allend/MSI/index.js.map +1 -0
  35. package/dist/allend/index.d.ts +16 -0
  36. package/dist/allend/index.d.ts.map +1 -0
  37. package/dist/allend/index.js +12 -0
  38. package/dist/allend/index.js.map +1 -0
  39. package/dist/backend/Auth.d.ts +14 -0
  40. package/dist/backend/Auth.d.ts.map +1 -0
  41. package/dist/backend/Auth.js +84 -0
  42. package/dist/backend/Auth.js.map +1 -0
  43. package/dist/index.d.ts +13 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +12 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/utils/index.d.ts +6 -0
  48. package/dist/utils/index.d.ts.map +1 -0
  49. package/dist/utils/index.js +3 -0
  50. package/dist/utils/index.js.map +1 -0
  51. package/dist/utils/stream.d.ts +21 -0
  52. package/dist/utils/stream.d.ts.map +1 -0
  53. package/dist/utils/stream.js +59 -0
  54. package/dist/utils/stream.js.map +1 -0
  55. package/package.json +81 -0
  56. package/src/allend/Access.ts +58 -0
  57. package/src/allend/DClient/Client.ts +76 -0
  58. package/src/allend/DClient/Event.ts +76 -0
  59. package/src/allend/DClient/Order.ts +452 -0
  60. package/src/allend/MSI/Controls.ts +703 -0
  61. package/src/allend/MSI/Handles.ts +387 -0
  62. package/src/allend/MSI/Plugins.ts +52 -0
  63. package/src/allend/MSI/index.tsx +254 -0
  64. package/src/allend/index.ts +14 -0
  65. package/src/backend/Auth.ts +112 -0
  66. package/src/index.ts +18 -0
  67. package/src/types/access.d.ts +7 -0
  68. package/src/types/auth.d.ts +26 -0
  69. package/src/types/index.d.ts +275 -0
  70. package/src/utils/index.ts +4 -0
  71. package/src/utils/stream.ts +68 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 PWS-Hub
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # de.SDK
2
+ Complete SDK pack for MSI React Native (Map Service Interface) and DClient services
@@ -0,0 +1,12 @@
1
+ import type { AccessOptions } from '../types/access';
2
+ import type { HTTPRequestOptions } from '../types';
3
+ export default class Access {
4
+ private version;
5
+ private baseURL;
6
+ protected accessToken?: string;
7
+ protected remoteOrigin?: string;
8
+ constructor(options: AccessOptions);
9
+ request<Response>(options: HTTPRequestOptions): Promise<Response>;
10
+ setToken(token: string): void;
11
+ }
12
+ //# sourceMappingURL=Access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Access.d.ts","sourceRoot":"","sources":["../../src/allend/Access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAElD,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,OAAO,CAAQ;IACvB,SAAS,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC9B,SAAS,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;gBAElB,OAAO,EAAE,aAAa;IAa7B,OAAO,CAAC,QAAQ,EAAG,OAAO,EAAE,kBAAkB,GAAI,OAAO,CAAC,QAAQ,CAAC;IAgCzE,QAAQ,CAAE,KAAK,EAAE,MAAM,GAAI,IAAI;CAGhC"}
@@ -0,0 +1,43 @@
1
+ export default class Access {
2
+ constructor(options) {
3
+ if (!options)
4
+ throw new Error('Undefined Access Configuration');
5
+ if (!options.workspace)
6
+ throw new Error('Undefined Workspace Reference');
7
+ if (!options.accessToken)
8
+ throw new Error('Undefined Access Token');
9
+ this.version = options.version || 1;
10
+ this.accessToken = options.accessToken;
11
+ this.remoteOrigin = options.remoteOrigin;
12
+ this.baseURL = options.env === 'prod'
13
+ ? 'https://api.dedot.com'
14
+ : 'http://api.dedot.io:24800';
15
+ }
16
+ async request(options) {
17
+ const rawOptions = {
18
+ method: 'GET',
19
+ headers: {
20
+ origin: this.remoteOrigin,
21
+ 'x-user-agent': `De.remote/${this.version}.0`
22
+ }
23
+ };
24
+ if (this.accessToken)
25
+ rawOptions.headers.authorization = `Bearer ${this.accessToken}`;
26
+ if (options.body) {
27
+ rawOptions.headers['content-type'] = 'application/json';
28
+ options.body = JSON.stringify(options.body);
29
+ }
30
+ if (typeof options.headers == 'object')
31
+ options.headers = Object.assign(Object.assign({}, options.headers), rawOptions.headers);
32
+ options = Object.assign(Object.assign({}, rawOptions), options);
33
+ if (!options.url)
34
+ throw new Error('Undefined request <url>');
35
+ const url = `${this.baseURL}/v${this.version}/${options.url.replace(/^\//, '')}`;
36
+ // React Native has built-in fetch
37
+ return await (await fetch(url, options)).json();
38
+ }
39
+ setToken(token) {
40
+ this.accessToken = token;
41
+ }
42
+ }
43
+ //# sourceMappingURL=Access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Access.js","sourceRoot":"","sources":["../../src/allend/Access.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,OAAO,MAAM;IAMzB,YAAa,OAAsB;QACjC,IAAI,CAAC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AA;QAEvC,IAAI,CAAC,OAAO,CAAC,GAAG;YAAG,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;QAC7D,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAA;QAEhF,kCAAkC;QAClC,OAAO,MAAM,CAAE,MAAM,KAAK,CAAE,GAAG,EAAE,OAAO,CAAE,CAAE,CAAC,IAAI,EAAc,CAAA;IACjE,CAAC;IAED,QAAQ,CAAE,KAAa;QACrB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAA;IAC1B,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ import type { AccessOptions } from '../../types/access';
2
+ import type { GPSLocation, OrderService, Entity } from '../../types';
3
+ import Access from '../Access';
4
+ export default class Client extends Access {
5
+ private clientId;
6
+ constructor(clientId: string, access: AccessOptions);
7
+ fetchActiveOrders(): Promise<OrderService[]>;
8
+ fetchOrderHistory(): Promise<OrderService[]>;
9
+ nearby(location: GPSLocation): Promise<Entity[]>;
10
+ }
11
+ //# sourceMappingURL=Client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/allend/DClient/Client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAsB,WAAW,EAAE,YAAY,EAAgB,MAAM,EAAG,MAAM,aAAa,CAAA;AACvG,OAAO,MAAM,MAAM,WAAW,CAAA;AAS9B,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,MAAM;IACxC,OAAO,CAAC,QAAQ,CAAQ;gBAEX,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa;IAU9C,iBAAiB;IAejB,iBAAiB;IAejB,MAAM,CAAE,QAAQ,EAAE,WAAW;CAqBpC"}
@@ -0,0 +1,50 @@
1
+ import Access from '../Access';
2
+ export default class Client extends Access {
3
+ constructor(clientId, access) {
4
+ if (!clientId)
5
+ throw new Error('Undefined <clientId>');
6
+ // Instanciate access
7
+ super(access);
8
+ // ID/reference of the client on this session
9
+ this.clientId = clientId;
10
+ }
11
+ async fetchActiveOrders() {
12
+ if (!this.accessToken)
13
+ throw new Error('Authentication required');
14
+ const options = {
15
+ url: `/client/${this.clientId}/orders/actives`,
16
+ method: 'GET'
17
+ }, { error, message, orders } = await this.request(options);
18
+ if (error)
19
+ throw new Error(message);
20
+ return orders;
21
+ }
22
+ async fetchOrderHistory() {
23
+ if (!this.accessToken)
24
+ throw new Error('Authentication required');
25
+ const options = {
26
+ url: `/client/${this.clientId}/orders/history`,
27
+ method: 'GET'
28
+ }, { error, message, orders } = await this.request(options);
29
+ if (error)
30
+ throw new Error(message);
31
+ return orders;
32
+ }
33
+ async nearby(location) {
34
+ if (!this.accessToken)
35
+ throw new Error('Authentication required');
36
+ if (!location)
37
+ throw new Error('Undefined epicenter location');
38
+ if (!location.lng || !location.lat)
39
+ throw new Error('Invalid location coordinates');
40
+ const options = {
41
+ url: `/client/${this.clientId}/nearby`,
42
+ method: 'POST',
43
+ body: location
44
+ }, { error, message, nearby } = await this.request(options);
45
+ if (error)
46
+ throw new Error(message);
47
+ return nearby;
48
+ }
49
+ }
50
+ //# sourceMappingURL=Client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Client.js","sourceRoot":"","sources":["../../../src/allend/DClient/Client.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,WAAW,CAAA;AAS9B,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,MAAM;IAGxC,YAAa,QAAgB,EAAE,MAAqB;QAClD,IAAI,CAAC,QAAQ;YACX,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;QAEzC,qBAAqB;QACrB,KAAK,CAAE,MAAM,CAAE,CAAA;QACf,6CAA6C;QAC7C,IAA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O,GAAuB;YAC5B,GAAG,EAAE,WAAW,IAAI,CAAC,QAAQ,SAAS;YACtC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,QAAQ;SACf,EACD,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAkB,OAAO,CAAE,CAAA;QAC1E,IAAI,KAAK;YAAG,MAAM,IAAI,KAAK,CAAE,OAAO,CAAE,CAAA;QAEtC,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ import type { GPSLocation, Message, Peer, OrderStage } from '../../types';
2
+ import type { AccessOptions } from '../../types/access';
3
+ import Access from '../Access';
4
+ export default class Event extends Access {
5
+ private nsp?;
6
+ private iosHost;
7
+ constructor(access: AccessOptions);
8
+ connect(clientId: string): Promise<void>;
9
+ disconnect(): boolean;
10
+ join(jrtoken: string): Promise<boolean>;
11
+ onLeft(fn: (peer: Peer) => void): this;
12
+ onConnected(fn: (peer: Peer) => void): this;
13
+ onDisconnected(fn: (peer: Peer) => void): this;
14
+ onRoute(fn: (data: any) => void): this;
15
+ onStage(fn: (data: OrderStage) => void): this;
16
+ onLocation(fn: (location: GPSLocation) => void): this;
17
+ onMessage(fn: (payload: Message) => void): this;
18
+ }
19
+ //# sourceMappingURL=Event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Event.d.ts","sourceRoot":"","sources":["../../../src/allend/DClient/Event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAG,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,MAAM,MAAM,WAAW,CAAA;AAE9B,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,MAAM;IACvC,OAAO,CAAC,GAAG,CAAC,CAAQ;IACpB,OAAO,CAAC,OAAO,CAAQ;gBAEV,MAAM,EAAE,aAAa;IASlC,OAAO,CAAE,QAAQ,EAAE,MAAM,GAAI,OAAO,CAAC,IAAI,CAAC;IAe1C,UAAU;IAIV,IAAI,CAAE,OAAO,EAAE,MAAM,GAAI,OAAO,CAAC,OAAO,CAAC;IAQzC,MAAM,CAAE,EAAE,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI;IAIlC,WAAW,CAAE,EAAE,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI;IAIvC,cAAc,CAAE,EAAE,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI;IAK1C,OAAO,CAAE,EAAE,EAAE,CAAE,IAAI,EAAE,GAAG,KAAM,IAAI;IAIlC,OAAO,CAAE,EAAE,EAAE,CAAE,IAAI,EAAE,UAAU,KAAM,IAAI;IAIzC,UAAU,CAAE,EAAE,EAAE,CAAE,QAAQ,EAAE,WAAW,KAAO,IAAI;IAIlD,SAAS,CAAE,EAAE,EAAE,CAAE,OAAO,EAAE,OAAO,KAAM,IAAI;CAI5C"}
@@ -0,0 +1,74 @@
1
+ import io from 'socket.io-client';
2
+ import Access from '../Access';
3
+ export default class Event extends Access {
4
+ constructor(access) {
5
+ super(access);
6
+ // Socket server host
7
+ this.iosHost = access.env == 'prod' ?
8
+ 'https://api.dedot.io' // Production server
9
+ : 'http://api.dedot.io:24800'; // Development & staging server
10
+ }
11
+ connect(clientId) {
12
+ return new Promise((resolve, reject) => {
13
+ // Connect to main clients namespace
14
+ const auth = {
15
+ utype: 'client',
16
+ id: clientId,
17
+ remoteOrigin: this.remoteOrigin,
18
+ accessToken: this.accessToken
19
+ };
20
+ this.nsp = io(this.iosHost, { auth });
21
+ this.nsp.on('connect', resolve);
22
+ this.nsp.on('connect_error', reject);
23
+ });
24
+ }
25
+ disconnect() {
26
+ var _a;
27
+ (_a = this.nsp) === null || _a === void 0 ? void 0 : _a.disconnect();
28
+ return true;
29
+ }
30
+ join(jrtoken) {
31
+ return new Promise((resolve, reject) => {
32
+ var _a;
33
+ (_a = this.nsp) === null || _a === void 0 ? void 0 : _a.emit('JOIN', jrtoken, (errmess) => {
34
+ errmess ? reject(new Error(errmess)) : resolve(true);
35
+ });
36
+ });
37
+ }
38
+ onLeft(fn) {
39
+ var _a;
40
+ (_a = this.nsp) === null || _a === void 0 ? void 0 : _a.on('LEFT', fn);
41
+ return this;
42
+ }
43
+ onConnected(fn) {
44
+ var _a;
45
+ (_a = this.nsp) === null || _a === void 0 ? void 0 : _a.on('CONNECTED', fn);
46
+ return this;
47
+ }
48
+ onDisconnected(fn) {
49
+ var _a;
50
+ (_a = this.nsp) === null || _a === void 0 ? void 0 : _a.on('DISCONNECTED', fn);
51
+ return this;
52
+ }
53
+ onRoute(fn) {
54
+ var _a;
55
+ (_a = this.nsp) === null || _a === void 0 ? void 0 : _a.on('ROUTE-CHANGE', fn);
56
+ return this;
57
+ }
58
+ onStage(fn) {
59
+ var _a;
60
+ (_a = this.nsp) === null || _a === void 0 ? void 0 : _a.on('STAGE-CHANGE', fn);
61
+ return this;
62
+ }
63
+ onLocation(fn) {
64
+ var _a;
65
+ (_a = this.nsp) === null || _a === void 0 ? void 0 : _a.on('LOCATION-CHANGE', fn);
66
+ return this;
67
+ }
68
+ onMessage(fn) {
69
+ var _a;
70
+ (_a = this.nsp) === null || _a === void 0 ? void 0 : _a.on('MESSAGE', fn);
71
+ return this;
72
+ }
73
+ }
74
+ //# sourceMappingURL=Event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Event.js","sourceRoot":"","sources":["../../../src/allend/DClient/Event.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,MAAM,MAAM,WAAW,CAAA;AAE9B,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,MAAM;IAIvC,YAAa,MAAqB;QAChC,KAAK,CAAE,MAAM,CAAE,CAAA;QAEf,qBAAqB;QACrB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,IA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AAA;QACzB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,WAAW,CAAE,EAA0B;;QACrC,MAAA,IAAI,CAAC,GAAG,0CAAE,EAAE,CAAC,WAAW,EAAE,EAAE,CAAE,CAAA;QAC9B,OAAO,IAAI,CAAA;IACb,CAAC;IACD,cAAc,CAAE,EAA0B;;QACxC,MAAA,IAAI,CAAC,GAAG,0CAAE,EAAE,CAAC,cAAc,EAAE,EAAE,CAAE,CAAA;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,CAAE,EAAyB;;QAChC,MAAA,IAAI,CAAC,GAAG,0CAAE,EAAE,CAAC,cAAc,EAAE,EAAE,CAAE,CAAA;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,CAAE,EAAgC;;QACvC,MAAA,IAAI,CAAC,GAAG,0CAAE,EAAE,CAAC,cAAc,EAAE,EAAE,CAAE,CAAA;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;IACD,UAAU,CAAE,EAAsC;;QAChD,MAAA,IAAI,CAAC,GAAG,0CAAE,EAAE,CAAC,iBAAiB,EAAE,EAAE,CAAE,CAAA;QACpC,OAAO,IAAI,CAAA;IACb,CAAC;IACD,SAAS,CAAE,EAAgC;;QACzC,MAAA,IAAI,CAAC,GAAG,0CAAE,EAAE,CAAC,SAAS,EAAE,EAAE,CAAE,CAAA;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
@@ -0,0 +1,50 @@
1
+ import type { AccessOptions } from '../../types/access';
2
+ import type { Package, PackageOptions, Waypoint, WaypointOptions, OrderService, OrderServiceOptions, OrderOperator, OrderStage } from '../../types';
3
+ import Access from '../Access';
4
+ type OrderOperators = {
5
+ [index: string]: OrderOperator;
6
+ };
7
+ export default class Order extends Access {
8
+ private intentToken;
9
+ constructor(access: AccessOptions);
10
+ /**
11
+ * Order intent
12
+ */
13
+ intent(clientId: string): Promise<string>;
14
+ unintent(token: string): Promise<boolean>;
15
+ /**
16
+ * Order waypoints
17
+ */
18
+ addWaypoint(list: Waypoint | Waypoint[], token?: string): Promise<Waypoint[]>;
19
+ getWaypoint(no: number, token?: string): Promise<Waypoint>;
20
+ fetchWaypoints(token?: string): Promise<Waypoint[]>;
21
+ updateWaypoint(no: number, updates: WaypointOptions, token?: string): Promise<Waypoint[]>;
22
+ deleteWaypoint(no: number, token?: string): Promise<Waypoint[]>;
23
+ /**
24
+ * Order packages
25
+ */
26
+ addPackage(list: Package | Package[], token?: string): Promise<Package[]>;
27
+ getPackage(PTC: string, token?: string): Promise<Package>;
28
+ fetchPackages(token?: string): Promise<Package[]>;
29
+ updatePackage(PTC: number, updates: PackageOptions, token?: string): Promise<Package[]>;
30
+ deletePackage(PTC: number, token?: string): Promise<Package[]>;
31
+ /**
32
+ * Order service
33
+ */
34
+ initiate(payload: OrderService, token?: string): Promise<string>;
35
+ getService(token?: string): Promise<OrderService>;
36
+ updateService(updates: OrderServiceOptions, token?: string): Promise<OrderService>;
37
+ rateService(rating: number, token?: string): Promise<boolean>;
38
+ /**
39
+ * Order operators
40
+ */
41
+ getOperator(type: string, token?: string): Promise<OrderOperator>;
42
+ getOperators(token?: string): Promise<OrderOperators>;
43
+ /**
44
+ * Order monitoring
45
+ */
46
+ getCurrentStage(token?: string): Promise<OrderStage>;
47
+ getCurrentRoute(token?: string): Promise<any>;
48
+ }
49
+ export {};
50
+ //# sourceMappingURL=Order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Order.d.ts","sourceRoot":"","sources":["../../../src/allend/DClient/Order.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EACV,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,eAAe,EACzB,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,UAAU,EAC7D,MAAM,aAAa,CAAA;AACpB,OAAO,MAAM,MAAM,WAAW,CAAA;AA0B9B,KAAK,cAAc,GAAG;IACpB,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AO,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,GAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAuBzF,aAAa,CAAE,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAmBtE;;OAEG;IAEG,QAAQ,CAAE,OAAO,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,MAAM,GAAI,OAAO,CAAC,MAAM,CAAC;IAoBlE,UAAU,CAAE,KAAK,CAAC,EAAE,MAAM,GAAI,OAAO,CAAC,YAAY,CAAC;IAgBnD,aAAa,CAAE,OAAO,EAAE,mBAAmB,EAAE,KAAK,CAAC,EAAE,MAAM,GAAI,OAAO,CAAC,YAAY,CAAC;IAoBpF,WAAW,CAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAI,OAAO,CAAC,OAAO,CAAC;IAoBrE;;OAEG;IAEG,WAAW,CAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAI,OAAO,CAAC,aAAa,CAAC;IAmBnE,YAAY,CAAE,KAAK,CAAC,EAAE,MAAM,GAAI,OAAO,CAAC,cAAc,CAAC;IAgB7D;;OAEG;IAEG,eAAe,CAAE,KAAK,CAAC,EAAE,MAAM,GAAI,OAAO,CAAC,UAAU,CAAC;IAgBtD,eAAe,CAAE,KAAK,CAAC,EAAE,MAAM,GAAI,OAAO,CAAC,GAAG,CAAC;CAetD"}
@@ -0,0 +1,321 @@
1
+ import Access from '../Access';
2
+ export default class Order extends Access {
3
+ constructor(access) {
4
+ super(access);
5
+ this.intentToken = '';
6
+ }
7
+ /**
8
+ * Order intent
9
+ */
10
+ async intent(clientId) {
11
+ if (!clientId)
12
+ throw new Error('<clientId> argument required');
13
+ const options = {
14
+ url: '/order/intent',
15
+ method: 'POST',
16
+ body: { clientId }
17
+ }, { error, message, token } = await this.request(options);
18
+ if (error)
19
+ throw new Error(message);
20
+ this.intentToken = token;
21
+ return token;
22
+ }
23
+ async unintent(token) {
24
+ if (!token)
25
+ throw new Error('Undefined intent token');
26
+ const options = {
27
+ url: '/order/intent',
28
+ method: 'DELETE',
29
+ headers: { 'x-intent-token': token }
30
+ }, { error, message } = await this.request(options);
31
+ if (error)
32
+ throw new Error(message);
33
+ this.intentToken = '';
34
+ return true;
35
+ }
36
+ /**
37
+ * Order waypoints
38
+ */
39
+ async addWaypoint(list, token) {
40
+ if (!list)
41
+ throw new Error('Expect <list> argument to be [Waypoint or Waypoint<array>]');
42
+ token = token || this.intentToken;
43
+ if (!token)
44
+ throw new Error('Expected intent order token');
45
+ const options = {
46
+ url: '/order/waypoints/add',
47
+ method: 'PUT',
48
+ headers: { 'x-intent-token': token },
49
+ body: !Array.isArray(list) ? [list] : list
50
+ }, { error, message, waypoints } = await this.request(options);
51
+ if (error)
52
+ throw new Error(message);
53
+ return waypoints;
54
+ }
55
+ async getWaypoint(no, token) {
56
+ if (!no)
57
+ throw new Error('Expected waypoint number');
58
+ token = token || this.intentToken;
59
+ if (!token)
60
+ throw new Error('Expected intent order token');
61
+ const options = {
62
+ url: `/order/waypoints/${no}`,
63
+ method: 'GET',
64
+ headers: { 'x-intent-token': token }
65
+ }, { error, message, waypoint } = await this.request(options);
66
+ if (error)
67
+ throw new Error(message);
68
+ return waypoint;
69
+ }
70
+ async fetchWaypoints(token) {
71
+ token = token || this.intentToken;
72
+ if (!token)
73
+ throw new Error('Expected intent order token');
74
+ const options = {
75
+ url: `/order/waypoints`,
76
+ method: 'GET',
77
+ headers: { 'x-intent-token': token }
78
+ }, { error, message, waypoints } = await this.request(options);
79
+ if (error)
80
+ throw new Error(message);
81
+ return waypoints;
82
+ }
83
+ async updateWaypoint(no, updates, token) {
84
+ if (!no)
85
+ throw new Error('Expected waypoint number');
86
+ if (!updates)
87
+ throw new Error('Expect <updates: WaypointOptions> to be object');
88
+ token = token || this.intentToken;
89
+ if (!token)
90
+ throw new Error('Expected intent order token');
91
+ const options = {
92
+ url: `/order/waypoints/${no}`,
93
+ method: 'PATCH',
94
+ headers: { 'x-intent-token': token },
95
+ body: updates
96
+ }, { error, message, waypoints } = await this.request(options);
97
+ if (error)
98
+ throw new Error(message);
99
+ return waypoints;
100
+ }
101
+ async deleteWaypoint(no, token) {
102
+ if (!no)
103
+ throw new Error('Expected waypoint number');
104
+ token = token || this.intentToken;
105
+ if (!token)
106
+ throw new Error('Expected intent order token');
107
+ const options = {
108
+ url: `/order/waypoints/${no}`,
109
+ method: 'DELETE',
110
+ headers: { 'x-intent-token': token }
111
+ }, { error, message, waypoints } = await this.request(options);
112
+ if (error)
113
+ throw new Error(message);
114
+ return waypoints;
115
+ }
116
+ /**
117
+ * Order packages
118
+ */
119
+ async addPackage(list, token) {
120
+ if (!list)
121
+ throw new Error('Expect <list> argument to be [Package or Package<array>]');
122
+ token = token || this.intentToken;
123
+ if (!token)
124
+ throw new Error('Expected intent order token');
125
+ const options = {
126
+ url: '/order/packages/add',
127
+ method: 'PUT',
128
+ headers: { 'x-intent-token': token },
129
+ body: !Array.isArray(list) ? [list] : list
130
+ }, { error, message, packages } = await this.request(options);
131
+ if (error)
132
+ throw new Error(message);
133
+ return packages;
134
+ }
135
+ async getPackage(PTC, token) {
136
+ if (!PTC)
137
+ throw new Error('Expected <PTC> Package Tracking Code');
138
+ token = token || this.intentToken;
139
+ if (!token)
140
+ throw new Error('Expected intent order token');
141
+ const options = {
142
+ url: `/order/packages/${PTC}`,
143
+ method: 'GET',
144
+ headers: { 'x-intent-token': token }
145
+ }, response = await this.request(options);
146
+ if (response.error)
147
+ throw new Error(response.message);
148
+ return response.package;
149
+ }
150
+ async fetchPackages(token) {
151
+ token = token || this.intentToken;
152
+ if (!token)
153
+ throw new Error('Expected intent order token');
154
+ const options = {
155
+ url: `/order/packages`,
156
+ method: 'GET',
157
+ headers: { 'x-intent-token': token }
158
+ }, { error, message, packages } = await this.request(options);
159
+ if (error)
160
+ throw new Error(message);
161
+ return packages;
162
+ }
163
+ async updatePackage(PTC, updates, token) {
164
+ if (!PTC)
165
+ throw new Error('Expected Package Tracking Code');
166
+ if (!updates)
167
+ throw new Error('Expect <updates: PackageOptions> to be object');
168
+ token = token || this.intentToken;
169
+ if (!token)
170
+ throw new Error('Expected intent order token');
171
+ const options = {
172
+ url: `/order/packages/${PTC}`,
173
+ method: 'PATCH',
174
+ headers: { 'x-intent-token': token },
175
+ body: updates
176
+ }, { error, message, packages } = await this.request(options);
177
+ if (error)
178
+ throw new Error(message);
179
+ return packages;
180
+ }
181
+ async deletePackage(PTC, token) {
182
+ if (!PTC)
183
+ throw new Error('Expected Package Tracking Code');
184
+ token = token || this.intentToken;
185
+ if (!token)
186
+ throw new Error('Expected intent order token');
187
+ const options = {
188
+ url: `/order/packages/${PTC}`,
189
+ method: 'DELETE',
190
+ headers: { 'x-intent-token': token }
191
+ }, { error, message, packages } = await this.request(options);
192
+ if (error)
193
+ throw new Error(message);
194
+ return packages;
195
+ }
196
+ /**
197
+ * Order service
198
+ */
199
+ async initiate(payload, token) {
200
+ if (!payload)
201
+ throw new Error('Expect <payload> argument to be [OrderService]');
202
+ token = token || this.intentToken;
203
+ if (!token)
204
+ throw new Error('Expected intent order token');
205
+ const options = {
206
+ url: '/order/service',
207
+ method: 'POST',
208
+ headers: { 'x-intent-token': token },
209
+ body: payload
210
+ }, { error, message, jrtoken } = await this.request(options);
211
+ if (error)
212
+ throw new Error(message);
213
+ return jrtoken;
214
+ }
215
+ async getService(token) {
216
+ token = token || this.intentToken;
217
+ if (!token)
218
+ throw new Error('Expected intent order token');
219
+ const options = {
220
+ url: `/order/service`,
221
+ method: 'GET',
222
+ headers: { 'x-intent-token': token }
223
+ }, { error, message, service } = await this.request(options);
224
+ if (error)
225
+ throw new Error(message);
226
+ return service;
227
+ }
228
+ async updateService(updates, token) {
229
+ if (!updates)
230
+ throw new Error('Expect <updates: OrderServiceOptions> to be object');
231
+ token = token || this.intentToken;
232
+ if (!token)
233
+ throw new Error('Expected intent order token');
234
+ const options = {
235
+ url: `/order/service`,
236
+ method: 'PATCH',
237
+ headers: { 'x-intent-token': token },
238
+ body: updates
239
+ }, { error, message, service } = await this.request(options);
240
+ if (error)
241
+ throw new Error(message);
242
+ return service;
243
+ }
244
+ async rateService(rating, token) {
245
+ if (!rating)
246
+ throw new Error('Expect <rating> to be number betwee 0 to 5');
247
+ token = token || this.intentToken;
248
+ if (!token)
249
+ throw new Error('Expected intent order token');
250
+ const options = {
251
+ url: `/order/service/rating`,
252
+ method: 'POST',
253
+ headers: { 'x-intent-token': token },
254
+ body: { rating }
255
+ }, { error, message } = await this.request(options);
256
+ if (error)
257
+ throw new Error(message);
258
+ return true;
259
+ }
260
+ /**
261
+ * Order operators
262
+ */
263
+ async getOperator(type, token) {
264
+ if (!['LSP', 'partner', 'warehouse', 'agent'].includes(type))
265
+ throw new Error('Unknown order operator');
266
+ token = token || this.intentToken;
267
+ if (!token)
268
+ throw new Error('Expected intent order token');
269
+ const options = {
270
+ url: `/order/operators?type=${type}`,
271
+ method: 'GET',
272
+ headers: { 'x-intent-token': token }
273
+ }, { error, message, operators } = await this.request(options);
274
+ if (error)
275
+ throw new Error(message);
276
+ return operators[type];
277
+ }
278
+ async getOperators(token) {
279
+ token = token || this.intentToken;
280
+ if (!token)
281
+ throw new Error('Expected intent order token');
282
+ const options = {
283
+ url: '/order/operators',
284
+ method: 'GET',
285
+ headers: { 'x-intent-token': token }
286
+ }, { error, message, operators } = await this.request(options);
287
+ if (error)
288
+ throw new Error(message);
289
+ return operators;
290
+ }
291
+ /**
292
+ * Order monitoring
293
+ */
294
+ async getCurrentStage(token) {
295
+ token = token || this.intentToken;
296
+ if (!token)
297
+ throw new Error('Expected intent order token');
298
+ const options = {
299
+ url: '/order/stage',
300
+ method: 'GET',
301
+ headers: { 'x-intent-token': token }
302
+ }, { error, message, stage } = await this.request(options);
303
+ if (error)
304
+ throw new Error(message);
305
+ return stage;
306
+ }
307
+ async getCurrentRoute(token) {
308
+ token = token || this.intentToken;
309
+ if (!token)
310
+ throw new Error('Expected intent order token');
311
+ const options = {
312
+ url: '/order/route',
313
+ method: 'GET',
314
+ headers: { 'x-intent-token': token }
315
+ }, { error, message, route } = await this.request(options);
316
+ if (error)
317
+ throw new Error(message);
318
+ return route;
319
+ }
320
+ }
321
+ //# sourceMappingURL=Order.js.map