@de./sdk 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.
- package/LICENSE +21 -0
- package/README.md +4391 -0
- package/dist/allend/Access.d.ts +15 -0
- package/dist/allend/Access.js +164 -0
- package/dist/allend/Access.js.map +1 -0
- package/dist/allend/DAuth/index.d.ts +20 -0
- package/dist/allend/DAuth/index.js +92 -0
- package/dist/allend/DAuth/index.js.map +1 -0
- package/dist/allend/DClient/Client.d.ts +10 -0
- package/dist/allend/DClient/Client.js +144 -0
- package/dist/allend/DClient/Client.js.map +1 -0
- package/dist/allend/DClient/Event.d.ts +18 -0
- package/dist/allend/DClient/Event.js +100 -0
- package/dist/allend/DClient/Event.js.map +1 -0
- package/dist/allend/DClient/Order.d.ts +49 -0
- package/dist/allend/DClient/Order.js +601 -0
- package/dist/allend/DClient/Order.js.map +1 -0
- package/dist/allend/IoTClient.d.ts +29 -0
- package/dist/allend/IoTClient.js +59 -0
- package/dist/allend/IoTClient.js.map +1 -0
- package/dist/allend/MSI/Controls.d.ts +256 -0
- package/dist/allend/MSI/Controls.js +763 -0
- package/dist/allend/MSI/Controls.js.map +1 -0
- package/dist/allend/MSI/Handles.d.ts +88 -0
- package/dist/allend/MSI/Handles.js +445 -0
- package/dist/allend/MSI/Handles.js.map +1 -0
- package/dist/allend/MSI/Plugins.d.ts +22 -0
- package/dist/allend/MSI/Plugins.js +38 -0
- package/dist/allend/MSI/Plugins.js.map +1 -0
- package/dist/allend/MSI/index.d.ts +55 -0
- package/dist/allend/MSI/index.js +155 -0
- package/dist/allend/MSI/index.js.map +1 -0
- package/dist/allend/index.d.ts +12 -0
- package/dist/allend/index.js +18 -0
- package/dist/allend/index.js.map +1 -0
- package/dist/backend/Auth.d.ts +38 -0
- package/dist/backend/Auth.js +286 -0
- package/dist/backend/Auth.js.map +1 -0
- package/dist/baseUrl.d.ts +12 -0
- package/dist/baseUrl.js +16 -0
- package/dist/baseUrl.js.map +1 -0
- package/dist/bundle.js +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/types/access.d.ts +8 -0
- package/dist/types/auth.d.ts +27 -0
- package/dist/types/index.d.ts +281 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/stream.d.ts +20 -0
- package/dist/utils/stream.js +63 -0
- package/dist/utils/stream.js.map +1 -0
- package/package.json +66 -0
- package/src/allend/Access.ts +78 -0
- package/src/allend/DAuth/index.ts +39 -0
- package/src/allend/DClient/Client.ts +76 -0
- package/src/allend/DClient/Event.ts +76 -0
- package/src/allend/DClient/Order.ts +452 -0
- package/src/allend/IoTClient.ts +68 -0
- package/src/allend/MSI/Controls.ts +760 -0
- package/src/allend/MSI/Handles.ts +387 -0
- package/src/allend/MSI/Plugins.ts +52 -0
- package/src/allend/MSI/index.ts +160 -0
- package/src/allend/index.ts +18 -0
- package/src/backend/Auth.ts +201 -0
- package/src/baseUrl.ts +13 -0
- package/src/index.ts +19 -0
- package/src/types/access.d.ts +8 -0
- package/src/types/auth.d.ts +27 -0
- package/src/types/index.d.ts +281 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/stream.ts +68 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AccessOptions } from '../types/access';
|
|
2
|
+
import type { HTTPRequestOptions } from '../types';
|
|
3
|
+
type AccessType = 'API' | 'ASI';
|
|
4
|
+
export default class AccessManager {
|
|
5
|
+
private atype;
|
|
6
|
+
private version;
|
|
7
|
+
private platform;
|
|
8
|
+
private baseURL;
|
|
9
|
+
protected accessToken?: string;
|
|
10
|
+
protected remoteOrigin?: string;
|
|
11
|
+
constructor(options: AccessOptions, atype: AccessType);
|
|
12
|
+
request<Response>({ url, ...options }: HTTPRequestOptions): Promise<Response>;
|
|
13
|
+
setToken(token: string): void;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
47
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
48
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
49
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
50
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
51
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
52
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
56
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
57
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
58
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
59
|
+
function step(op) {
|
|
60
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
61
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
62
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
63
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
64
|
+
switch (op[0]) {
|
|
65
|
+
case 0: case 1: t = op; break;
|
|
66
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
67
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
68
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
69
|
+
default:
|
|
70
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
71
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
72
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
73
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
74
|
+
if (t[2]) _.ops.pop();
|
|
75
|
+
_.trys.pop(); continue;
|
|
76
|
+
}
|
|
77
|
+
op = body.call(thisArg, _);
|
|
78
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
79
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
83
|
+
var t = {};
|
|
84
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
85
|
+
t[p] = s[p];
|
|
86
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
87
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
88
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
89
|
+
t[p[i]] = s[p[i]];
|
|
90
|
+
}
|
|
91
|
+
return t;
|
|
92
|
+
};
|
|
93
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
94
|
+
var baseUrl_1 = require("../baseUrl");
|
|
95
|
+
var USER_ACCOUNT_SERVICE = 'De.API';
|
|
96
|
+
var AccessManager = /** @class */ (function () {
|
|
97
|
+
function AccessManager(options, atype) {
|
|
98
|
+
if (!options)
|
|
99
|
+
throw new Error('Undefined Access Configuration');
|
|
100
|
+
if (!options.context)
|
|
101
|
+
throw new Error('Undefined Context Reference. Check https://doc.dedot.io/sdk/auth');
|
|
102
|
+
if (!options.accessToken)
|
|
103
|
+
throw new Error('Undefined Access Token. Check https://doc.dedot.io/sdk/auth');
|
|
104
|
+
this.atype = atype;
|
|
105
|
+
this.version = options.version || 1;
|
|
106
|
+
this.platform = options.platform || 'proxy';
|
|
107
|
+
this.accessToken = options.accessToken;
|
|
108
|
+
this.remoteOrigin = options.remoteOrigin;
|
|
109
|
+
this.baseURL = this.atype === 'ASI'
|
|
110
|
+
? baseUrl_1.ASI_SERVER_BASEURL[options.env || 'dev']
|
|
111
|
+
: baseUrl_1.API_SERVER_BASEURL[options.env || 'dev'];
|
|
112
|
+
}
|
|
113
|
+
AccessManager.prototype.request = function (_a) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
+
var rawOptions, fetch;
|
|
116
|
+
var url = _a.url, options = __rest(_a, ["url"]);
|
|
117
|
+
return __generator(this, function (_b) {
|
|
118
|
+
switch (_b.label) {
|
|
119
|
+
case 0:
|
|
120
|
+
rawOptions = {
|
|
121
|
+
method: 'GET',
|
|
122
|
+
headers: {
|
|
123
|
+
/**
|
|
124
|
+
* Default User agent for SDK request calls
|
|
125
|
+
*
|
|
126
|
+
* NOTE: Later replace by latest SDK version
|
|
127
|
+
*/
|
|
128
|
+
origin: this.remoteOrigin,
|
|
129
|
+
'de-user-agent': "De.".concat(this.platform, "/").concat(this.version, ".0")
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
if (this.atype === 'ASI')
|
|
133
|
+
rawOptions.headers['de-auth-service'] = USER_ACCOUNT_SERVICE;
|
|
134
|
+
if (this.accessToken)
|
|
135
|
+
rawOptions.headers.authorization = "Bearer ".concat(this.accessToken);
|
|
136
|
+
if (options.body) {
|
|
137
|
+
rawOptions.headers['content-type'] = 'application/json';
|
|
138
|
+
if (typeof options.body === 'object')
|
|
139
|
+
options.body = JSON.stringify(options.body);
|
|
140
|
+
}
|
|
141
|
+
if (typeof options.headers == 'object')
|
|
142
|
+
options.headers = __assign(__assign({}, options.headers), rawOptions.headers);
|
|
143
|
+
options = __assign(__assign({}, rawOptions), options);
|
|
144
|
+
url = "".concat(this.baseURL, "/v").concat(this.version, "/").concat(url.replace(/^\//, ''));
|
|
145
|
+
fetch = (globalThis === null || globalThis === void 0 ? void 0 : globalThis.window) && (globalThis === null || globalThis === void 0 ? void 0 : globalThis.fetch);
|
|
146
|
+
if (!!fetch) return [3 /*break*/, 2];
|
|
147
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('node-fetch')); })];
|
|
148
|
+
case 1:
|
|
149
|
+
fetch = (_b.sent()).default;
|
|
150
|
+
_b.label = 2;
|
|
151
|
+
case 2: return [4 /*yield*/, fetch(url, options)];
|
|
152
|
+
case 3: return [4 /*yield*/, (_b.sent()).json()];
|
|
153
|
+
case 4:
|
|
154
|
+
// console.log( options )
|
|
155
|
+
return [2 /*return*/, _b.sent()];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
AccessManager.prototype.setToken = function (token) { this.accessToken = token; };
|
|
161
|
+
return AccessManager;
|
|
162
|
+
}());
|
|
163
|
+
exports.default = AccessManager;
|
|
164
|
+
//# sourceMappingURL=Access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Access.js","sourceRoot":"","sources":["../../src/allend/Access.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,sCAAmE;AAInE,IAAM,oBAAoB,GAAG,QAAQ,CAAA;AAErC;IAQE,uBAAa,OAAsB,EAAE,KAAiB;QACpD,IAAI,CAAC,OAAO;YAAG,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CA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AAC,IAAI,EAAE,CAAC;4BACjB,UAAU,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAA;4BACvD,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ;gCAClC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAE,OAAO,CAAC,IAAI,CAAE,CAAA;wBACjD,CAAC;wBAED,IAAI,OAAO,OAAO,CAAC,OAAO,IAAI,QAAQ;4BACpC,OAAO,CAAC,OAAO,yBACV,OAAO,CAAC,OAAO,GACf,UAAU,CAAC,OAAO,CACtB,CAAA;wBAEH,OAAO,yBAAQ,UAAU,GAAK,OAAO,CAAE,CAAA;wBAEvC,GAAG,GAAG,UAAG,IAAI,CAAC,OAAO,eAAK,IAAI,CAAC,OAAO,cAAI,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAE,CAAA;wBAG9D,KAAK,GAAG,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,MAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,CAAA,CAAA;6BAC/C,CAAC,KAAK,EAAN,wBAAM;wBACE,sFAAa,YAAY,QAAC;;wBAApC,KAAK,GAAG,CAAE,SAA0B,CAAE,CAAC,OAAc,CAAA;;4BAGxC,qBAAM,KAAK,CAAE,GAAG,EAAE,OAAO,CAAE,EAAA;4BAAnC,qBAAM,CAAE,SAA2B,CAAE,CAAC,IAAI,EAAE,EAAA;;oBADnD,yBAAyB;oBACzB,sBAAO,SAAwD,EAAA;;;;KAChE;IAED,gCAAQ,GAAR,UAAU,KAAa,IAAW,IAAI,CAAC,WAAW,GAAG,KAAK,CAAA,CAAC,CAAC;IAC9D,oBAAC;AAAD,CAAC,AArED,IAqEC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { HTTPResponse } from '../../types';
|
|
2
|
+
import type { AccessOptions } from '../../types/access';
|
|
3
|
+
import AccessManager from '../Access';
|
|
4
|
+
type SigninBody = {
|
|
5
|
+
type?: 'CUSTOMER' | 'VENDOR' | 'ADMIN';
|
|
6
|
+
phone: string;
|
|
7
|
+
device?: string;
|
|
8
|
+
country?: string;
|
|
9
|
+
};
|
|
10
|
+
type SigninResponse = HTTPResponse & {
|
|
11
|
+
token: string;
|
|
12
|
+
};
|
|
13
|
+
export default class DAuth extends AccessManager {
|
|
14
|
+
constructor(access: AccessOptions);
|
|
15
|
+
/**
|
|
16
|
+
* Signin
|
|
17
|
+
*/
|
|
18
|
+
signin(body: SigninBody): Promise<SigninResponse>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
28
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
+
};
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
var Access_1 = __importDefault(require("../Access"));
|
|
58
|
+
var DAuth = /** @class */ (function (_super) {
|
|
59
|
+
__extends(DAuth, _super);
|
|
60
|
+
function DAuth(access) {
|
|
61
|
+
return _super.call(this, access, 'ASI') || this;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Signin
|
|
65
|
+
*/
|
|
66
|
+
DAuth.prototype.signin = function (body) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
+
var options, response;
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
switch (_a.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
if (!body.phone)
|
|
73
|
+
throw new Error('<phone> argument required');
|
|
74
|
+
options = {
|
|
75
|
+
url: '/auth/signin',
|
|
76
|
+
method: 'POST',
|
|
77
|
+
body: body
|
|
78
|
+
};
|
|
79
|
+
return [4 /*yield*/, this.request(options)];
|
|
80
|
+
case 1:
|
|
81
|
+
response = _a.sent();
|
|
82
|
+
if (response.error)
|
|
83
|
+
throw new Error(response.message);
|
|
84
|
+
return [2 /*return*/, response];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
return DAuth;
|
|
90
|
+
}(Access_1.default));
|
|
91
|
+
exports.default = DAuth;
|
|
92
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/allend/DAuth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qDAAqC;AAYrC;IAAmC,yBAAa;IAC9C,eAAa,MAAqB;QAChC,OAAA,MAAK,YAAE,MAAM,EAAE,KAAK,CAAE,SAAA;IACxB,CAAC;IAED;;OAEG;IACG,sBAAM,GAAZ,UAAc,IAAgB;;;;;;wBAC5B,IAAI,CAAC,IAAI,CAAC,KAAK;4BACb,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;wBAG9C,OAAO,GAAuB;4BAC5B,GAAG,EAAE,cAAc;4BACnB,MAAM,EAAE,MAAM;4BACd,IAAI,MAAA;yBACL;wBACU,qBAAM,IAAI,CAAC,OAAO,CAAkB,OAAO,CAAE,EAAA;;wBAAxD,QAAQ,GAAG,SAA6C;wBACxD,IAAI,QAAQ,CAAC,KAAK;4BAAG,MAAM,IAAI,KAAK,CAAE,QAAQ,CAAC,OAAO,CAAE,CAAA;wBAExD,sBAAO,QAAQ,EAAA;;;;KAChB;IAEH,YAAC;AAAD,CAAC,AAxBD,CAAmC,gBAAa,GAwB/C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AccessOptions } from '../../types/access';
|
|
2
|
+
import type { RTLocation, OrderService, Entity } from '../../types';
|
|
3
|
+
import AccessManager from '../Access';
|
|
4
|
+
export default class Client extends AccessManager {
|
|
5
|
+
private clientId;
|
|
6
|
+
constructor(clientId: string, access: AccessOptions);
|
|
7
|
+
fetchActiveOrders(): Promise<OrderService[]>;
|
|
8
|
+
fetchOrderHistory(): Promise<OrderService[]>;
|
|
9
|
+
nearby(location: RTLocation): Promise<Entity[]>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
28
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
+
};
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
var Access_1 = __importDefault(require("../Access"));
|
|
58
|
+
var Client = /** @class */ (function (_super) {
|
|
59
|
+
__extends(Client, _super);
|
|
60
|
+
function Client(clientId, access) {
|
|
61
|
+
var _this = this;
|
|
62
|
+
if (!clientId)
|
|
63
|
+
throw new Error('Undefined <clientId>');
|
|
64
|
+
// Instanciate access
|
|
65
|
+
_this = _super.call(this, access, 'API') || this;
|
|
66
|
+
// ID/reference of the client on this session
|
|
67
|
+
_this.clientId = clientId;
|
|
68
|
+
return _this;
|
|
69
|
+
}
|
|
70
|
+
Client.prototype.fetchActiveOrders = function () {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var options, _a, error, message, orders;
|
|
73
|
+
return __generator(this, function (_b) {
|
|
74
|
+
switch (_b.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
if (!this.accessToken)
|
|
77
|
+
throw new Error('Authentication required');
|
|
78
|
+
options = {
|
|
79
|
+
url: "/client/".concat(this.clientId, "/orders/actives"),
|
|
80
|
+
method: 'GET'
|
|
81
|
+
};
|
|
82
|
+
return [4 /*yield*/, this.request(options)];
|
|
83
|
+
case 1:
|
|
84
|
+
_a = _b.sent(), error = _a.error, message = _a.message, orders = _a.orders;
|
|
85
|
+
if (error)
|
|
86
|
+
throw new Error(message);
|
|
87
|
+
return [2 /*return*/, orders];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
Client.prototype.fetchOrderHistory = function () {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
+
var options, _a, error, message, orders;
|
|
95
|
+
return __generator(this, function (_b) {
|
|
96
|
+
switch (_b.label) {
|
|
97
|
+
case 0:
|
|
98
|
+
if (!this.accessToken)
|
|
99
|
+
throw new Error('Authentication required');
|
|
100
|
+
options = {
|
|
101
|
+
url: "/client/".concat(this.clientId, "/orders/history"),
|
|
102
|
+
method: 'GET'
|
|
103
|
+
};
|
|
104
|
+
return [4 /*yield*/, this.request(options)];
|
|
105
|
+
case 1:
|
|
106
|
+
_a = _b.sent(), error = _a.error, message = _a.message, orders = _a.orders;
|
|
107
|
+
if (error)
|
|
108
|
+
throw new Error(message);
|
|
109
|
+
return [2 /*return*/, orders];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
Client.prototype.nearby = function (location) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
+
var options, _a, error, message, nearby;
|
|
117
|
+
return __generator(this, function (_b) {
|
|
118
|
+
switch (_b.label) {
|
|
119
|
+
case 0:
|
|
120
|
+
if (!this.accessToken)
|
|
121
|
+
throw new Error('Authentication required');
|
|
122
|
+
if (!location)
|
|
123
|
+
throw new Error('Undefined epicenter location');
|
|
124
|
+
if (!location.lng || !location.lat)
|
|
125
|
+
throw new Error('Invalid location coordinates');
|
|
126
|
+
options = {
|
|
127
|
+
url: "/client/".concat(this.clientId, "/nearby"),
|
|
128
|
+
method: 'POST',
|
|
129
|
+
body: location
|
|
130
|
+
};
|
|
131
|
+
return [4 /*yield*/, this.request(options)];
|
|
132
|
+
case 1:
|
|
133
|
+
_a = _b.sent(), error = _a.error, message = _a.message, nearby = _a.nearby;
|
|
134
|
+
if (error)
|
|
135
|
+
throw new Error(message);
|
|
136
|
+
return [2 /*return*/, nearby];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
return Client;
|
|
142
|
+
}(Access_1.default));
|
|
143
|
+
exports.default = Client;
|
|
144
|
+
//# sourceMappingURL=Client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../../src/allend/DClient/Client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qDAAqC;AASrC;IAAoC,0BAAa;IAG/C,gBAAa,QAAgB,EAAE,MAAqB;QAApD,iBAQC;QAPC,IAAI,CAAC,QAAQ;YACX,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;QAEzC,qBAAqB;QACrB,QAAA,MAAK,YAAE,MAAM,EAAE,KAAK,CAAE,SAAA;QACtB,6CAA6C;QAC7C,KAAI,CAA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CAAC,QAAQ,CAAC,GAAG;4BAChC,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;wBAGjD,OAAO,GAAuB;4BAC5B,GAAG,EAAE,kBAAW,IAAI,CAAC,QAAQ,YAAS;4BACtC,MAAM,EAAE,MAAM;4BACd,IAAI,EAAE,QAAQ;yBACf;wBAC4B,qBAAM,IAAI,CAAC,OAAO,CAAkB,OAAO,CAAE,EAAA;;wBAA1E,KAA6B,SAA6C,EAAxE,KAAK,WAAA,EAAE,OAAO,aAAA,EAAE,MAAM,YAAA;wBACxB,IAAI,KAAK;4BAAG,MAAM,IAAI,KAAK,CAAE,OAAO,CAAE,CAAA;wBAEtC,sBAAO,MAAM,EAAA;;;;KACd;IACH,aAAC;AAAD,CAAC,AAhED,CAAoC,gBAAa,GAgEhD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RTLocation, Message, Peer, OrderStage } from '../../types';
|
|
2
|
+
import type { AccessOptions } from '../../types/access';
|
|
3
|
+
import AccessManager from '../Access';
|
|
4
|
+
export default class Event extends AccessManager {
|
|
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: RTLocation) => void): this;
|
|
17
|
+
onMessage(fn: (payload: Message) => void): this;
|
|
18
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
var socket_io_client_1 = __importDefault(require("socket.io-client"));
|
|
22
|
+
var Access_1 = __importDefault(require("../Access"));
|
|
23
|
+
var Event = /** @class */ (function (_super) {
|
|
24
|
+
__extends(Event, _super);
|
|
25
|
+
function Event(access) {
|
|
26
|
+
var _this = _super.call(this, access, 'API') || this;
|
|
27
|
+
// Socket server host
|
|
28
|
+
_this.iosHost = access.env == 'prod' ?
|
|
29
|
+
'https://api.dedot.io' // Production server
|
|
30
|
+
: 'http://api.dedot.io:24800'; // Development & staging server
|
|
31
|
+
return _this;
|
|
32
|
+
}
|
|
33
|
+
Event.prototype.connect = function (clientId) {
|
|
34
|
+
var _this = this;
|
|
35
|
+
return new Promise(function (resolve, reject) {
|
|
36
|
+
// Connect to main clients namespace
|
|
37
|
+
var auth = {
|
|
38
|
+
utype: 'client',
|
|
39
|
+
id: clientId,
|
|
40
|
+
remoteOrigin: (globalThis === null || globalThis === void 0 ? void 0 : globalThis.window) ? globalThis.origin : _this.remoteOrigin,
|
|
41
|
+
accessToken: _this.accessToken
|
|
42
|
+
};
|
|
43
|
+
_this.nsp = (0, socket_io_client_1.default)(_this.iosHost, { auth: auth });
|
|
44
|
+
_this.nsp.on('connect', resolve);
|
|
45
|
+
_this.nsp.on('connect_error', reject);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
Event.prototype.disconnect = function () {
|
|
49
|
+
var _a;
|
|
50
|
+
(_a = this.nsp) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
51
|
+
return true;
|
|
52
|
+
};
|
|
53
|
+
Event.prototype.join = function (jrtoken) {
|
|
54
|
+
var _this = this;
|
|
55
|
+
return new Promise(function (resolve, reject) {
|
|
56
|
+
var _a;
|
|
57
|
+
(_a = _this.nsp) === null || _a === void 0 ? void 0 : _a.emit('JOIN', jrtoken, function (errmess) {
|
|
58
|
+
errmess ? reject(new Error(errmess)) : resolve(true);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
Event.prototype.onLeft = function (fn) {
|
|
63
|
+
var _a;
|
|
64
|
+
(_a = this.nsp) === null || _a === void 0 ? void 0 : _a.on('LEFT', fn);
|
|
65
|
+
return this;
|
|
66
|
+
};
|
|
67
|
+
Event.prototype.onConnected = function (fn) {
|
|
68
|
+
var _a;
|
|
69
|
+
(_a = this.nsp) === null || _a === void 0 ? void 0 : _a.on('CONNECTED', fn);
|
|
70
|
+
return this;
|
|
71
|
+
};
|
|
72
|
+
Event.prototype.onDisconnected = function (fn) {
|
|
73
|
+
var _a;
|
|
74
|
+
(_a = this.nsp) === null || _a === void 0 ? void 0 : _a.on('DISCONNECTED', fn);
|
|
75
|
+
return this;
|
|
76
|
+
};
|
|
77
|
+
Event.prototype.onRoute = function (fn) {
|
|
78
|
+
var _a;
|
|
79
|
+
(_a = this.nsp) === null || _a === void 0 ? void 0 : _a.on('ROUTE-CHANGE', fn);
|
|
80
|
+
return this;
|
|
81
|
+
};
|
|
82
|
+
Event.prototype.onStage = function (fn) {
|
|
83
|
+
var _a;
|
|
84
|
+
(_a = this.nsp) === null || _a === void 0 ? void 0 : _a.on('STAGE-CHANGE', fn);
|
|
85
|
+
return this;
|
|
86
|
+
};
|
|
87
|
+
Event.prototype.onLocation = function (fn) {
|
|
88
|
+
var _a;
|
|
89
|
+
(_a = this.nsp) === null || _a === void 0 ? void 0 : _a.on('LOCATION-CHANGE', fn);
|
|
90
|
+
return this;
|
|
91
|
+
};
|
|
92
|
+
Event.prototype.onMessage = function (fn) {
|
|
93
|
+
var _a;
|
|
94
|
+
(_a = this.nsp) === null || _a === void 0 ? void 0 : _a.on('MESSAGE', fn);
|
|
95
|
+
return this;
|
|
96
|
+
};
|
|
97
|
+
return Event;
|
|
98
|
+
}(Access_1.default));
|
|
99
|
+
exports.default = Event;
|
|
100
|
+
//# sourceMappingURL=Event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Event.js","sourceRoot":"","sources":["../../../src/allend/DClient/Event.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA,sEAA6C;AAC7C,qDAAqC;AAErC;IAAmC,yBAAa;IAI9C,eAAa,MAAqB;QAChC,YAAA,MAAK,YAAE,MAAM,EAAE,KAAK,CAAE,SAAA;QAEtB,qBAAqB;QACrB,KAAI,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC;YACjB,sBAAsB,CAAC,oBAAoB;YAC3C,CAAC,CAAC,2BAA2B,CAAA,CAAC,+BAA+B;;IACnF,CAAC;IAED,uBAAO,GAAP,UAAS,QAAgB;QAAzB,iBAcC;QAbC,OAAO,IAAI,OAAO,CAAE,UAAE,OAAO,EAAE,MAAM;YACnC,oCAAoC;YACpC,IAAM,IAAI,GAA0B;gBAClC,KAAK,EAAE,QAAQ;gBACf,EAAE,EAAE,QAAQ;gBACZ,YAAY,EAAE,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,EAAC,CAAC,CAAC,UAAU,CAAC,MAAM,C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,cAAc,EAAE,EAAE,CAAE,CAAA;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,uBAAO,GAAP,UAAS,EAAyB;;QAChC,MAAA,IAAI,CAAC,GAAG,0CAAE,EAAE,CAAC,cAAc,EAAE,EAAE,CAAE,CAAA;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;IACD,uBAAO,GAAP,UAAS,EAAgC;;QACvC,MAAA,IAAI,CAAC,GAAG,0CAAE,EAAE,CAAC,cAAc,EAAE,EAAE,CAAE,CAAA;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;IACD,0BAAU,GAAV,UAAY,EAAqC;;QAC/C,MAAA,IAAI,CAAC,GAAG,0CAAE,EAAE,CAAC,iBAAiB,EAAE,EAAE,CAAE,CAAA;QACpC,OAAO,IAAI,CAAA;IACb,CAAC;IACD,yBAAS,GAAT,UAAW,EAAgC;;QACzC,MAAA,IAAI,CAAC,GAAG,0CAAE,EAAE,CAAC,SAAS,EAAE,EAAE,CAAE,CAAA;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;IACH,YAAC;AAAD,CAAC,AArED,CAAmC,gBAAa,GAqE/C"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AccessOptions } from '../../types/access';
|
|
2
|
+
import type { Package, PackageOptions, Waypoint, WaypointOptions, OrderService, OrderServiceOptions, OrderOperator, OrderStage } from '../../types';
|
|
3
|
+
import AccessManager from '../Access';
|
|
4
|
+
type OrderOperators = {
|
|
5
|
+
[index: string]: OrderOperator;
|
|
6
|
+
};
|
|
7
|
+
export default class Order extends AccessManager {
|
|
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 {};
|