@onesignal/node-onesignal 5.7.0 → 5.8.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/dist/apis/DefaultApi.js +2282 -4372
- package/dist/apis/baseapi.js +11 -30
- package/dist/apis/exception.js +9 -26
- package/dist/auth/auth.js +17 -83
- package/dist/configuration.js +9 -9
- package/dist/http/http.js +53 -132
- package/dist/http/isomorphic-fetch.js +15 -18
- package/dist/middleware.js +8 -9
- package/dist/models/ApiKeyToken.js +45 -46
- package/dist/models/ApiKeyTokensListResponse.js +15 -16
- package/dist/models/App.js +213 -214
- package/dist/models/BasicNotification.js +711 -712
- package/dist/models/BasicNotificationAllOf.js +627 -628
- package/dist/models/BasicNotificationAllOfAndroidBackgroundLayout.js +27 -28
- package/dist/models/Button.js +27 -28
- package/dist/models/CopyTemplateRequest.js +15 -16
- package/dist/models/CreateApiKeyRequest.js +27 -28
- package/dist/models/CreateApiKeyResponse.js +21 -22
- package/dist/models/CreateNotificationSuccessResponse.js +27 -28
- package/dist/models/CreateSegmentConflictResponse.js +21 -22
- package/dist/models/CreateSegmentSuccessResponse.js +21 -22
- package/dist/models/CreateTemplateRequest.js +75 -76
- package/dist/models/CreateUserConflictResponse.js +15 -16
- package/dist/models/CreateUserConflictResponseErrorsInner.js +27 -28
- package/dist/models/CreateUserConflictResponseErrorsItemsMeta.js +15 -16
- package/dist/models/CustomEvent.js +39 -40
- package/dist/models/CustomEventsRequest.js +15 -16
- package/dist/models/DeliveryData.js +39 -40
- package/dist/models/ExportEventsSuccessResponse.js +15 -16
- package/dist/models/ExportSubscriptionsRequestBody.js +27 -28
- package/dist/models/ExportSubscriptionsSuccessResponse.js +15 -16
- package/dist/models/Filter.js +57 -58
- package/dist/models/FilterExpression.js +63 -64
- package/dist/models/GenericError.js +27 -28
- package/dist/models/GenericSuccessBoolResponse.js +15 -16
- package/dist/models/GetNotificationHistoryRequestBody.js +27 -28
- package/dist/models/GetSegmentsSuccessResponse.js +33 -34
- package/dist/models/LanguageStringMap.js +267 -268
- package/dist/models/Notification.js +717 -718
- package/dist/models/NotificationAllOf.js +15 -16
- package/dist/models/NotificationHistorySuccessResponse.js +21 -22
- package/dist/models/NotificationSlice.js +33 -34
- package/dist/models/NotificationTarget.js +93 -94
- package/dist/models/NotificationWithMeta.js +789 -790
- package/dist/models/NotificationWithMetaAllOf.js +93 -94
- package/dist/models/ObjectSerializer.js +111 -115
- package/dist/models/Operator.js +15 -16
- package/dist/models/OutcomeData.js +27 -28
- package/dist/models/OutcomesData.js +15 -16
- package/dist/models/PlatformDeliveryData.js +57 -58
- package/dist/models/PlatformDeliveryDataEmailAllOf.js +51 -52
- package/dist/models/PlatformDeliveryDataSmsAllOf.js +27 -28
- package/dist/models/PropertiesBody.js +15 -16
- package/dist/models/PropertiesDeltas.js +27 -28
- package/dist/models/PropertiesObject.js +75 -76
- package/dist/models/Purchase.js +33 -34
- package/dist/models/RateLimitError.js +21 -22
- package/dist/models/Segment.js +27 -28
- package/dist/models/SegmentData.js +51 -52
- package/dist/models/SegmentNotificationTarget.js +21 -22
- package/dist/models/StartLiveActivityRequest.js +105 -106
- package/dist/models/StartLiveActivitySuccessResponse.js +15 -16
- package/dist/models/Subscription.js +111 -112
- package/dist/models/SubscriptionBody.js +15 -16
- package/dist/models/SubscriptionNotificationTarget.js +81 -82
- package/dist/models/TemplateResource.js +45 -46
- package/dist/models/TemplatesListResponse.js +15 -16
- package/dist/models/TransferSubscriptionRequestBody.js +15 -16
- package/dist/models/UpdateApiKeyRequest.js +27 -28
- package/dist/models/UpdateLiveActivityRequest.js +63 -64
- package/dist/models/UpdateLiveActivitySuccessResponse.js +15 -16
- package/dist/models/UpdateTemplateRequest.js +69 -70
- package/dist/models/UpdateUserRequest.js +27 -28
- package/dist/models/User.js +27 -28
- package/dist/models/UserIdentityBody.js +15 -16
- package/dist/models/WebButton.js +33 -34
- package/dist/rxjsStub.js +8 -9
- package/dist/servers.js +14 -15
- package/dist/types/ObjectParamAPI.js +92 -94
- package/dist/types/ObservableAPI.js +534 -931
- package/dist/types/PromiseAPI.js +136 -137
- package/dist/util.js +2 -2
- package/package.json +4 -2
package/dist/apis/baseapi.js
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.RequiredError = exports.BaseAPIRequestFactory = exports.COLLECTION_FORMATS = void 0;
|
|
19
4
|
exports.COLLECTION_FORMATS = {
|
|
@@ -22,25 +7,21 @@ exports.COLLECTION_FORMATS = {
|
|
|
22
7
|
tsv: "\t",
|
|
23
8
|
pipes: "|",
|
|
24
9
|
};
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
class BaseAPIRequestFactory {
|
|
11
|
+
constructor(configuration) {
|
|
27
12
|
this.configuration = configuration;
|
|
28
13
|
}
|
|
29
|
-
|
|
30
|
-
}());
|
|
14
|
+
}
|
|
31
15
|
exports.BaseAPIRequestFactory = BaseAPIRequestFactory;
|
|
32
16
|
;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
_this.name = "RequiredError";
|
|
41
|
-
return _this;
|
|
17
|
+
class RequiredError extends Error {
|
|
18
|
+
constructor(api, method, field) {
|
|
19
|
+
super("Required parameter " + field + " was null or undefined when calling " + api + "." + method + ".");
|
|
20
|
+
this.api = api;
|
|
21
|
+
this.method = method;
|
|
22
|
+
this.field = field;
|
|
23
|
+
this.name = "RequiredError";
|
|
42
24
|
}
|
|
43
|
-
|
|
44
|
-
}(Error));
|
|
25
|
+
}
|
|
45
26
|
exports.RequiredError = RequiredError;
|
|
46
27
|
//# sourceMappingURL=baseapi.js.map
|
package/dist/apis/exception.js
CHANGED
|
@@ -1,32 +1,15 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.ApiException = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return _this;
|
|
4
|
+
class ApiException extends Error {
|
|
5
|
+
constructor(code, message, body, headers) {
|
|
6
|
+
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body) + "\nHeaders: " +
|
|
7
|
+
JSON.stringify(headers));
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.body = body;
|
|
10
|
+
this.headers = headers;
|
|
11
|
+
Object.setPrototypeOf(this, ApiException.prototype);
|
|
28
12
|
}
|
|
29
|
-
|
|
30
|
-
}(Error));
|
|
13
|
+
}
|
|
31
14
|
exports.ApiException = ApiException;
|
|
32
15
|
//# sourceMappingURL=exception.js.map
|
package/dist/auth/auth.js
CHANGED
|
@@ -1,98 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.configureAuthMethods = exports.RestApiKeyAuthentication = exports.OrganizationApiKeyAuthentication = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
4
|
+
class OrganizationApiKeyAuthentication {
|
|
5
|
+
constructor(tokenProvider) {
|
|
42
6
|
this.tokenProvider = tokenProvider;
|
|
43
7
|
}
|
|
44
|
-
|
|
8
|
+
getName() {
|
|
45
9
|
return "organization_api_key";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
switch (_e.label) {
|
|
52
|
-
case 0:
|
|
53
|
-
_b = (_a = context).setHeaderParam;
|
|
54
|
-
_c = ["Authorization"];
|
|
55
|
-
_d = "Key ";
|
|
56
|
-
return [4, this.tokenProvider.getToken()];
|
|
57
|
-
case 1:
|
|
58
|
-
_b.apply(_a, _c.concat([_d + (_e.sent())]));
|
|
59
|
-
return [2];
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
return OrganizationApiKeyAuthentication;
|
|
65
|
-
}());
|
|
10
|
+
}
|
|
11
|
+
async applySecurityAuthentication(context) {
|
|
12
|
+
context.setHeaderParam("Authorization", "Key " + await this.tokenProvider.getToken());
|
|
13
|
+
}
|
|
14
|
+
}
|
|
66
15
|
exports.OrganizationApiKeyAuthentication = OrganizationApiKeyAuthentication;
|
|
67
|
-
|
|
68
|
-
|
|
16
|
+
class RestApiKeyAuthentication {
|
|
17
|
+
constructor(tokenProvider) {
|
|
69
18
|
this.tokenProvider = tokenProvider;
|
|
70
19
|
}
|
|
71
|
-
|
|
20
|
+
getName() {
|
|
72
21
|
return "rest_api_key";
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
switch (_e.label) {
|
|
79
|
-
case 0:
|
|
80
|
-
_b = (_a = context).setHeaderParam;
|
|
81
|
-
_c = ["Authorization"];
|
|
82
|
-
_d = "Key ";
|
|
83
|
-
return [4, this.tokenProvider.getToken()];
|
|
84
|
-
case 1:
|
|
85
|
-
_b.apply(_a, _c.concat([_d + (_e.sent())]));
|
|
86
|
-
return [2];
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
return RestApiKeyAuthentication;
|
|
92
|
-
}());
|
|
22
|
+
}
|
|
23
|
+
async applySecurityAuthentication(context) {
|
|
24
|
+
context.setHeaderParam("Authorization", "Key " + await this.tokenProvider.getToken());
|
|
25
|
+
}
|
|
26
|
+
}
|
|
93
27
|
exports.RestApiKeyAuthentication = RestApiKeyAuthentication;
|
|
94
28
|
function configureAuthMethods(config) {
|
|
95
|
-
|
|
29
|
+
let authMethods = {};
|
|
96
30
|
if (!config) {
|
|
97
31
|
return authMethods;
|
|
98
32
|
}
|
package/dist/configuration.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createConfiguration = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const middleware_1 = require("./middleware");
|
|
5
|
+
const isomorphic_fetch_1 = require("./http/isomorphic-fetch");
|
|
6
|
+
const servers_1 = require("./servers");
|
|
7
|
+
const auth_1 = require("./auth/auth");
|
|
8
8
|
function createConfiguration(conf) {
|
|
9
|
-
|
|
9
|
+
const authMethods = {
|
|
10
10
|
'organization_api_key': {
|
|
11
11
|
tokenProvider: {
|
|
12
|
-
getToken:
|
|
12
|
+
getToken: () => conf.organizationApiKey || ''
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
'rest_api_key': {
|
|
16
16
|
tokenProvider: {
|
|
17
|
-
getToken:
|
|
17
|
+
getToken: () => conf.restApiKey || ''
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
const configuration = {
|
|
22
22
|
baseServer: conf.baseServer !== undefined ? conf.baseServer : servers_1.server1,
|
|
23
23
|
httpApi: conf.httpApi || new isomorphic_fetch_1.IsomorphicFetchHttpLibrary(),
|
|
24
24
|
middleware: conf.middleware || [],
|
|
25
25
|
authMethods: (0, auth_1.configureAuthMethods)(Object.assign(authMethods, conf.authMethods || {}))
|
|
26
26
|
};
|
|
27
27
|
if (conf.promiseMiddleware) {
|
|
28
|
-
conf.promiseMiddleware.forEach(
|
|
28
|
+
conf.promiseMiddleware.forEach(m => configuration.middleware.push(new middleware_1.PromiseMiddlewareWrapper(m)));
|
|
29
29
|
}
|
|
30
30
|
return configuration;
|
|
31
31
|
}
|
package/dist/http/http.js
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
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
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
3
|
if (k2 === undefined) k2 = k;
|
|
19
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -28,45 +13,9 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
28
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
29
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
15
|
};
|
|
31
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
32
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
33
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
34
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
35
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
36
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
37
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
41
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
42
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
43
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
44
|
-
function step(op) {
|
|
45
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
46
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
47
|
-
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;
|
|
48
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
49
|
-
switch (op[0]) {
|
|
50
|
-
case 0: case 1: t = op; break;
|
|
51
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
52
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
53
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
54
|
-
default:
|
|
55
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
56
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
57
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
58
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
59
|
-
if (t[2]) _.ops.pop();
|
|
60
|
-
_.trys.pop(); continue;
|
|
61
|
-
}
|
|
62
|
-
op = body.call(thisArg, _);
|
|
63
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
64
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
68
17
|
exports.wrapHttpLibrary = exports.ResponseContext = exports.SelfDecodingBody = exports.RequestContext = exports.HttpException = exports.HttpMethod = void 0;
|
|
69
|
-
|
|
18
|
+
const rxjsStub_1 = require("../rxjsStub");
|
|
70
19
|
__exportStar(require("./isomorphic-fetch"), exports);
|
|
71
20
|
var HttpMethod;
|
|
72
21
|
(function (HttpMethod) {
|
|
@@ -80,92 +29,78 @@ var HttpMethod;
|
|
|
80
29
|
HttpMethod["TRACE"] = "TRACE";
|
|
81
30
|
HttpMethod["PATCH"] = "PATCH";
|
|
82
31
|
})(HttpMethod = exports.HttpMethod || (exports.HttpMethod = {}));
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return _super.call(this, msg) || this;
|
|
32
|
+
class HttpException extends Error {
|
|
33
|
+
constructor(msg) {
|
|
34
|
+
super(msg);
|
|
87
35
|
}
|
|
88
|
-
|
|
89
|
-
}(Error));
|
|
36
|
+
}
|
|
90
37
|
exports.HttpException = HttpException;
|
|
91
|
-
|
|
92
|
-
|
|
38
|
+
class RequestContext {
|
|
39
|
+
constructor(url, httpMethod) {
|
|
93
40
|
this.httpMethod = httpMethod;
|
|
94
41
|
this.headers = {};
|
|
95
42
|
this.body = undefined;
|
|
96
43
|
this.url = new URL(url);
|
|
97
44
|
}
|
|
98
|
-
|
|
45
|
+
getUrl() {
|
|
99
46
|
return this.url.toString();
|
|
100
|
-
}
|
|
101
|
-
|
|
47
|
+
}
|
|
48
|
+
setUrl(url) {
|
|
102
49
|
this.url = new URL(url);
|
|
103
|
-
}
|
|
104
|
-
|
|
50
|
+
}
|
|
51
|
+
setBody(body) {
|
|
105
52
|
this.body = body;
|
|
106
|
-
}
|
|
107
|
-
|
|
53
|
+
}
|
|
54
|
+
getHttpMethod() {
|
|
108
55
|
return this.httpMethod;
|
|
109
|
-
}
|
|
110
|
-
|
|
56
|
+
}
|
|
57
|
+
getHeaders() {
|
|
111
58
|
return this.headers;
|
|
112
|
-
}
|
|
113
|
-
|
|
59
|
+
}
|
|
60
|
+
getBody() {
|
|
114
61
|
return this.body;
|
|
115
|
-
}
|
|
116
|
-
|
|
62
|
+
}
|
|
63
|
+
setQueryParam(name, value) {
|
|
117
64
|
this.url.searchParams.set(name, value);
|
|
118
|
-
}
|
|
119
|
-
|
|
65
|
+
}
|
|
66
|
+
addCookie(name, value) {
|
|
120
67
|
if (!this.headers["Cookie"]) {
|
|
121
68
|
this.headers["Cookie"] = "";
|
|
122
69
|
}
|
|
123
70
|
this.headers["Cookie"] += name + "=" + value + "; ";
|
|
124
|
-
}
|
|
125
|
-
|
|
71
|
+
}
|
|
72
|
+
setHeaderParam(key, value) {
|
|
126
73
|
this.headers[key] = value;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
}());
|
|
74
|
+
}
|
|
75
|
+
}
|
|
130
76
|
exports.RequestContext = RequestContext;
|
|
131
|
-
|
|
132
|
-
|
|
77
|
+
class SelfDecodingBody {
|
|
78
|
+
constructor(dataSource) {
|
|
133
79
|
this.dataSource = dataSource;
|
|
134
80
|
}
|
|
135
|
-
|
|
81
|
+
binary() {
|
|
136
82
|
return this.dataSource;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
case 0: return [4, this.dataSource];
|
|
144
|
-
case 1:
|
|
145
|
-
data = _a.sent();
|
|
146
|
-
return [2, data.toString()];
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
};
|
|
151
|
-
return SelfDecodingBody;
|
|
152
|
-
}());
|
|
83
|
+
}
|
|
84
|
+
async text() {
|
|
85
|
+
const data = await this.dataSource;
|
|
86
|
+
return data.toString();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
153
89
|
exports.SelfDecodingBody = SelfDecodingBody;
|
|
154
|
-
|
|
155
|
-
|
|
90
|
+
class ResponseContext {
|
|
91
|
+
constructor(httpStatusCode, headers, body) {
|
|
156
92
|
this.httpStatusCode = httpStatusCode;
|
|
157
93
|
this.headers = headers;
|
|
158
94
|
this.body = body;
|
|
159
95
|
}
|
|
160
|
-
|
|
161
|
-
|
|
96
|
+
getParsedHeader(headerName) {
|
|
97
|
+
const result = {};
|
|
162
98
|
if (!this.headers[headerName]) {
|
|
163
99
|
return result;
|
|
164
100
|
}
|
|
165
|
-
|
|
166
|
-
for (
|
|
167
|
-
|
|
168
|
-
var _a = parameter.split("=", 2), key = _a[0], value = _a[1];
|
|
101
|
+
const parameters = this.headers[headerName].split(";");
|
|
102
|
+
for (const parameter of parameters) {
|
|
103
|
+
let [key, value] = parameter.split("=", 2);
|
|
169
104
|
key = key.toLowerCase().trim();
|
|
170
105
|
if (value === undefined) {
|
|
171
106
|
result[""] = key;
|
|
@@ -179,34 +114,20 @@ var ResponseContext = (function () {
|
|
|
179
114
|
}
|
|
180
115
|
}
|
|
181
116
|
return result;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return [2, { data: data, name: fileName }];
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
};
|
|
197
|
-
ResponseContext.prototype.getBodyAsAny = function () {
|
|
198
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
-
return __generator(this, function (_a) {
|
|
200
|
-
return [2, this.body];
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
|
-
return ResponseContext;
|
|
205
|
-
}());
|
|
117
|
+
}
|
|
118
|
+
async getBodyAsFile() {
|
|
119
|
+
const data = await this.body.binary();
|
|
120
|
+
const fileName = this.getParsedHeader("content-disposition")["filename"] || "";
|
|
121
|
+
return { data, name: fileName };
|
|
122
|
+
}
|
|
123
|
+
async getBodyAsAny() {
|
|
124
|
+
return this.body;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
206
127
|
exports.ResponseContext = ResponseContext;
|
|
207
128
|
function wrapHttpLibrary(promiseHttpLibrary) {
|
|
208
129
|
return {
|
|
209
|
-
send
|
|
130
|
+
send(request) {
|
|
210
131
|
return (0, rxjsStub_1.from)(promiseHttpLibrary.send(request));
|
|
211
132
|
}
|
|
212
133
|
};
|
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IsomorphicFetchHttpLibrary = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var body = request.getBody();
|
|
12
|
-
var resultPromise = fetch(request.getUrl(), {
|
|
4
|
+
const http_1 = require("./http");
|
|
5
|
+
const rxjsStub_1 = require("../rxjsStub");
|
|
6
|
+
class IsomorphicFetchHttpLibrary {
|
|
7
|
+
send(request) {
|
|
8
|
+
let method = request.getHttpMethod().toString();
|
|
9
|
+
let body = request.getBody();
|
|
10
|
+
const resultPromise = fetch(request.getUrl(), {
|
|
13
11
|
method: method,
|
|
14
12
|
body: body,
|
|
15
13
|
headers: request.getHeaders(),
|
|
16
|
-
}).then(
|
|
17
|
-
|
|
18
|
-
resp.headers.forEach(
|
|
14
|
+
}).then((resp) => {
|
|
15
|
+
const headers = {};
|
|
16
|
+
resp.headers.forEach((value, name) => {
|
|
19
17
|
headers[name] = value;
|
|
20
18
|
});
|
|
21
|
-
|
|
22
|
-
text:
|
|
23
|
-
binary:
|
|
19
|
+
const body = {
|
|
20
|
+
text: () => resp.text(),
|
|
21
|
+
binary: () => resp.buffer()
|
|
24
22
|
};
|
|
25
23
|
return new http_1.ResponseContext(resp.status, headers, body);
|
|
26
24
|
});
|
|
27
25
|
return (0, rxjsStub_1.from)(resultPromise);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
}());
|
|
26
|
+
}
|
|
27
|
+
}
|
|
31
28
|
exports.IsomorphicFetchHttpLibrary = IsomorphicFetchHttpLibrary;
|
|
32
29
|
//# sourceMappingURL=isomorphic-fetch.js.map
|
package/dist/middleware.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PromiseMiddlewareWrapper = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const rxjsStub_1 = require("./rxjsStub");
|
|
5
|
+
class PromiseMiddlewareWrapper {
|
|
6
|
+
constructor(middleware) {
|
|
7
7
|
this.middleware = middleware;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
pre(context) {
|
|
10
10
|
return (0, rxjsStub_1.from)(this.middleware.pre(context));
|
|
11
|
-
}
|
|
12
|
-
|
|
11
|
+
}
|
|
12
|
+
post(context) {
|
|
13
13
|
return (0, rxjsStub_1.from)(this.middleware.post(context));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
}());
|
|
14
|
+
}
|
|
15
|
+
}
|
|
17
16
|
exports.PromiseMiddlewareWrapper = PromiseMiddlewareWrapper;
|
|
18
17
|
//# sourceMappingURL=middleware.js.map
|