@azure/notification-hubs 1.0.0-beta.1
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 +749 -0
- package/dist/index.js +2235 -0
- package/dist/index.js.map +1 -0
- package/dist-esm/src/client/cancelScheduledNotification.js +23 -0
- package/dist-esm/src/client/cancelScheduledNotification.js.map +1 -0
- package/dist-esm/src/client/createOrUpdateInstallation.js +24 -0
- package/dist-esm/src/client/createOrUpdateInstallation.js.map +1 -0
- package/dist-esm/src/client/createOrUpdateRegistration.js +17 -0
- package/dist-esm/src/client/createOrUpdateRegistration.js.map +1 -0
- package/dist-esm/src/client/createRegistration.js +24 -0
- package/dist-esm/src/client/createRegistration.js.map +1 -0
- package/dist-esm/src/client/createRegistrationId.js +26 -0
- package/dist-esm/src/client/createRegistrationId.js.map +1 -0
- package/dist-esm/src/client/deleteInstallation.js +22 -0
- package/dist-esm/src/client/deleteInstallation.js.map +1 -0
- package/dist-esm/src/client/deleteRegistration.js +25 -0
- package/dist-esm/src/client/deleteRegistration.js.map +1 -0
- package/dist-esm/src/client/getFeedbackContainerUrl.js +23 -0
- package/dist-esm/src/client/getFeedbackContainerUrl.js.map +1 -0
- package/dist-esm/src/client/getInstallation.js +23 -0
- package/dist-esm/src/client/getInstallation.js.map +1 -0
- package/dist-esm/src/client/getNotificationHubJob.js +24 -0
- package/dist-esm/src/client/getNotificationHubJob.js.map +1 -0
- package/dist-esm/src/client/getNotificationOutcomeDetails.js +24 -0
- package/dist-esm/src/client/getNotificationOutcomeDetails.js.map +1 -0
- package/dist-esm/src/client/getRegistration.js +24 -0
- package/dist-esm/src/client/getRegistration.js.map +1 -0
- package/dist-esm/src/client/index.js +44 -0
- package/dist-esm/src/client/index.js.map +1 -0
- package/dist-esm/src/client/internal/_client.js +75 -0
- package/dist-esm/src/client/internal/_client.js.map +1 -0
- package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js +31 -0
- package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js.map +1 -0
- package/dist-esm/src/client/internal/_scheduleNotificationPayload.js +37 -0
- package/dist-esm/src/client/internal/_scheduleNotificationPayload.js.map +1 -0
- package/dist-esm/src/client/internal/_sendNotificationPayload.js +51 -0
- package/dist-esm/src/client/internal/_sendNotificationPayload.js.map +1 -0
- package/dist-esm/src/client/listNotificationHubJobs.js +23 -0
- package/dist-esm/src/client/listNotificationHubJobs.js.map +1 -0
- package/dist-esm/src/client/listRegistrations.js +89 -0
- package/dist-esm/src/client/listRegistrations.js.map +1 -0
- package/dist-esm/src/client/listRegistrationsByTag.js +87 -0
- package/dist-esm/src/client/listRegistrationsByTag.js.map +1 -0
- package/dist-esm/src/client/scheduleBroadcastNotification.js +17 -0
- package/dist-esm/src/client/scheduleBroadcastNotification.js.map +1 -0
- package/dist-esm/src/client/scheduleNotification.js +18 -0
- package/dist-esm/src/client/scheduleNotification.js.map +1 -0
- package/dist-esm/src/client/sendBroadcastNotification.js +15 -0
- package/dist-esm/src/client/sendBroadcastNotification.js.map +1 -0
- package/dist-esm/src/client/sendDirectNotification.js +16 -0
- package/dist-esm/src/client/sendDirectNotification.js.map +1 -0
- package/dist-esm/src/client/sendNotification.js +16 -0
- package/dist-esm/src/client/sendNotification.js.map +1 -0
- package/dist-esm/src/client/submitNotificationHubJob.js +26 -0
- package/dist-esm/src/client/submitNotificationHubJob.js.map +1 -0
- package/dist-esm/src/client/updateInstallation.js +25 -0
- package/dist-esm/src/client/updateInstallation.js.map +1 -0
- package/dist-esm/src/client/updateRegistration.js +21 -0
- package/dist-esm/src/client/updateRegistration.js.map +1 -0
- package/dist-esm/src/index.js +12 -0
- package/dist-esm/src/index.js.map +1 -0
- package/dist-esm/src/models/installation.js +51 -0
- package/dist-esm/src/models/installation.js.map +1 -0
- package/dist-esm/src/models/notification.js +104 -0
- package/dist-esm/src/models/notification.js.map +1 -0
- package/dist-esm/src/models/notificationBuilder.js +169 -0
- package/dist-esm/src/models/notificationBuilder.js.map +1 -0
- package/dist-esm/src/models/notificationDetails.js +4 -0
- package/dist-esm/src/models/notificationDetails.js.map +1 -0
- package/dist-esm/src/models/notificationHubJob.js +4 -0
- package/dist-esm/src/models/notificationHubJob.js.map +1 -0
- package/dist-esm/src/models/options.js +4 -0
- package/dist-esm/src/models/options.js.map +1 -0
- package/dist-esm/src/models/registration.js +135 -0
- package/dist-esm/src/models/registration.js.map +1 -0
- package/dist-esm/src/models/response.js +4 -0
- package/dist-esm/src/models/response.js.map +1 -0
- package/dist-esm/src/notificationHubsClient.js +251 -0
- package/dist-esm/src/notificationHubsClient.js.map +1 -0
- package/dist-esm/src/serializers/notificationDetailsSerializer.js +58 -0
- package/dist-esm/src/serializers/notificationDetailsSerializer.js.map +1 -0
- package/dist-esm/src/serializers/notificationHubJobSerializer.js +74 -0
- package/dist-esm/src/serializers/notificationHubJobSerializer.js.map +1 -0
- package/dist-esm/src/serializers/registrationSerializer.js +375 -0
- package/dist-esm/src/serializers/registrationSerializer.js.map +1 -0
- package/dist-esm/src/utils/connectionStringUtils.js +37 -0
- package/dist-esm/src/utils/connectionStringUtils.js.map +1 -0
- package/dist-esm/src/utils/constants.js +11 -0
- package/dist-esm/src/utils/constants.js.map +1 -0
- package/dist-esm/src/utils/retryPolicy.js +144 -0
- package/dist-esm/src/utils/retryPolicy.js.map +1 -0
- package/dist-esm/src/utils/tracing.js +13 -0
- package/dist-esm/src/utils/tracing.js.map +1 -0
- package/dist-esm/src/utils/utils.js +130 -0
- package/dist-esm/src/utils/utils.js.map +1 -0
- package/dist-esm/src/utils/xmlUtils.js +101 -0
- package/dist-esm/src/utils/xmlUtils.js.map +1 -0
- package/package.json +144 -0
- package/types/3.1/notification-hubs.d.ts +1728 -0
- package/types/latest/notification-hubs.d.ts +1840 -0
- package/types/latest/tsdoc-metadata.json +11 -0
- package/types/src/client/cancelScheduledNotification.d.ts +13 -0
- package/types/src/client/cancelScheduledNotification.d.ts.map +1 -0
- package/types/src/client/createOrUpdateInstallation.d.ts +13 -0
- package/types/src/client/createOrUpdateInstallation.d.ts.map +1 -0
- package/types/src/client/createOrUpdateRegistration.d.ts +12 -0
- package/types/src/client/createOrUpdateRegistration.d.ts.map +1 -0
- package/types/src/client/createRegistration.d.ts +13 -0
- package/types/src/client/createRegistration.d.ts.map +1 -0
- package/types/src/client/createRegistrationId.d.ts +10 -0
- package/types/src/client/createRegistrationId.d.ts.map +1 -0
- package/types/src/client/deleteInstallation.d.ts +12 -0
- package/types/src/client/deleteInstallation.d.ts.map +1 -0
- package/types/src/client/deleteRegistration.d.ts +12 -0
- package/types/src/client/deleteRegistration.d.ts.map +1 -0
- package/types/src/client/getFeedbackContainerUrl.d.ts +11 -0
- package/types/src/client/getFeedbackContainerUrl.d.ts.map +1 -0
- package/types/src/client/getInstallation.d.ts +12 -0
- package/types/src/client/getInstallation.d.ts.map +1 -0
- package/types/src/client/getNotificationHubJob.d.ts +12 -0
- package/types/src/client/getNotificationHubJob.d.ts.map +1 -0
- package/types/src/client/getNotificationOutcomeDetails.d.ts +13 -0
- package/types/src/client/getNotificationOutcomeDetails.d.ts.map +1 -0
- package/types/src/client/getRegistration.d.ts +12 -0
- package/types/src/client/getRegistration.d.ts.map +1 -0
- package/types/src/client/index.d.ts +41 -0
- package/types/src/client/index.d.ts.map +1 -0
- package/types/src/client/internal/_client.d.ts +26 -0
- package/types/src/client/internal/_client.d.ts.map +1 -0
- package/types/src/client/internal/_createOrUpdateRegistrationDescription.d.ts +8 -0
- package/types/src/client/internal/_createOrUpdateRegistrationDescription.d.ts.map +1 -0
- package/types/src/client/internal/_scheduleNotificationPayload.d.ts +9 -0
- package/types/src/client/internal/_scheduleNotificationPayload.d.ts.map +1 -0
- package/types/src/client/internal/_sendNotificationPayload.d.ts +10 -0
- package/types/src/client/internal/_sendNotificationPayload.d.ts.map +1 -0
- package/types/src/client/listNotificationHubJobs.d.ts +11 -0
- package/types/src/client/listNotificationHubJobs.d.ts.map +1 -0
- package/types/src/client/listRegistrations.d.ts +12 -0
- package/types/src/client/listRegistrations.d.ts.map +1 -0
- package/types/src/client/listRegistrationsByTag.d.ts +13 -0
- package/types/src/client/listRegistrationsByTag.d.ts.map +1 -0
- package/types/src/client/scheduleBroadcastNotification.d.ts +16 -0
- package/types/src/client/scheduleBroadcastNotification.d.ts.map +1 -0
- package/types/src/client/scheduleNotification.d.ts +17 -0
- package/types/src/client/scheduleNotification.d.ts.map +1 -0
- package/types/src/client/sendBroadcastNotification.d.ts +14 -0
- package/types/src/client/sendBroadcastNotification.d.ts.map +1 -0
- package/types/src/client/sendDirectNotification.d.ts +16 -0
- package/types/src/client/sendDirectNotification.d.ts.map +1 -0
- package/types/src/client/sendNotification.d.ts +15 -0
- package/types/src/client/sendNotification.d.ts.map +1 -0
- package/types/src/client/submitNotificationHubJob.d.ts +13 -0
- package/types/src/client/submitNotificationHubJob.d.ts.map +1 -0
- package/types/src/client/updateInstallation.d.ts +14 -0
- package/types/src/client/updateInstallation.d.ts.map +1 -0
- package/types/src/client/updateRegistration.d.ts +12 -0
- package/types/src/client/updateRegistration.d.ts.map +1 -0
- package/types/src/index.d.ts +10 -0
- package/types/src/index.d.ts.map +1 -0
- package/types/src/models/installation.d.ts +200 -0
- package/types/src/models/installation.d.ts.map +1 -0
- package/types/src/models/notification.d.ts +166 -0
- package/types/src/models/notification.d.ts.map +1 -0
- package/types/src/models/notificationBuilder.d.ts +546 -0
- package/types/src/models/notificationBuilder.d.ts.map +1 -0
- package/types/src/models/notificationDetails.d.ts +87 -0
- package/types/src/models/notificationDetails.d.ts.map +1 -0
- package/types/src/models/notificationHubJob.d.ts +104 -0
- package/types/src/models/notificationHubJob.d.ts.map +1 -0
- package/types/src/models/options.d.ts +43 -0
- package/types/src/models/options.d.ts.map +1 -0
- package/types/src/models/registration.d.ts +368 -0
- package/types/src/models/registration.d.ts.map +1 -0
- package/types/src/models/response.d.ts +41 -0
- package/types/src/models/response.d.ts.map +1 -0
- package/types/src/notificationHubsClient.d.ts +190 -0
- package/types/src/notificationHubsClient.d.ts.map +1 -0
- package/types/src/serializers/notificationDetailsSerializer.d.ts +7 -0
- package/types/src/serializers/notificationDetailsSerializer.d.ts.map +1 -0
- package/types/src/serializers/notificationHubJobSerializer.d.ts +21 -0
- package/types/src/serializers/notificationHubJobSerializer.d.ts.map +1 -0
- package/types/src/serializers/registrationSerializer.d.ts +193 -0
- package/types/src/serializers/registrationSerializer.d.ts.map +1 -0
- package/types/src/utils/connectionStringUtils.d.ts +37 -0
- package/types/src/utils/connectionStringUtils.d.ts.map +1 -0
- package/types/src/utils/constants.d.ts +9 -0
- package/types/src/utils/constants.d.ts.map +1 -0
- package/types/src/utils/retryPolicy.d.ts +72 -0
- package/types/src/utils/retryPolicy.d.ts.map +1 -0
- package/types/src/utils/tracing.d.ts +6 -0
- package/types/src/utils/tracing.d.ts.map +1 -0
- package/types/src/utils/utils.d.ts +65 -0
- package/types/src/utils/utils.d.ts.map +1 -0
- package/types/src/utils/xmlUtils.d.ts +46 -0
- package/types/src/utils/xmlUtils.d.ts.map +1 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { AbortError } from "@azure/abort-controller";
|
|
4
|
+
import { delay } from "@azure/core-amqp";
|
|
5
|
+
import { isDefined } from "./utils.js";
|
|
6
|
+
import { isError } from "@azure/core-util";
|
|
7
|
+
import { isRestError } from "@azure/core-rest-pipeline";
|
|
8
|
+
const JITTER_FACTOR = 0.08;
|
|
9
|
+
function isAbortError(e) {
|
|
10
|
+
if (e instanceof AbortError) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return isError(e) && e.name === "AbortError";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Represents the retry delay calculation either fixed or exponential.
|
|
17
|
+
*/
|
|
18
|
+
export var RetryMode;
|
|
19
|
+
(function (RetryMode) {
|
|
20
|
+
/**
|
|
21
|
+
* Fixed interval between retries.
|
|
22
|
+
*/
|
|
23
|
+
RetryMode[RetryMode["Fixed"] = 0] = "Fixed";
|
|
24
|
+
/**
|
|
25
|
+
* Exporation interval between retries.
|
|
26
|
+
*/
|
|
27
|
+
RetryMode[RetryMode["Exponential"] = 1] = "Exponential";
|
|
28
|
+
})(RetryMode = RetryMode || (RetryMode = {}));
|
|
29
|
+
/**
|
|
30
|
+
* Creates a set of retry options with defaults.
|
|
31
|
+
* @param options - The options for the retry behavior.
|
|
32
|
+
* @returns The retry options.
|
|
33
|
+
*/
|
|
34
|
+
export function createRetryOptions(options) {
|
|
35
|
+
return Object.assign({ mode: RetryMode.Fixed, maxRetries: 3, delay: 1000, maxDelay: 1000 * 60 }, options);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates a base retry policy with the incoming calculateRetryDelay method.
|
|
39
|
+
* @param calculateRetryDelay - The retry calculation behavior based upon attempt number and error.
|
|
40
|
+
* @returns A retry policy with the given calculateRetryDelay method.
|
|
41
|
+
*/
|
|
42
|
+
export function createBaseRetryPolicy(calculateRetryDelay) {
|
|
43
|
+
async function runOperation(operation, signal) {
|
|
44
|
+
let failedAttemptCount = 0;
|
|
45
|
+
while (!(signal === null || signal === void 0 ? void 0 : signal.aborted)) {
|
|
46
|
+
try {
|
|
47
|
+
return await operation(signal);
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
++failedAttemptCount;
|
|
51
|
+
const retryDelay = calculateRetryDelay(err, failedAttemptCount);
|
|
52
|
+
if (isDefined(retryDelay)) {
|
|
53
|
+
await delay(retryDelay, signal);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
throw new AbortError("The operation has been aborted");
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
calculateRetryDelay,
|
|
64
|
+
runOperation,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates a retry policy configured with the given retry options.
|
|
69
|
+
* @param options - The retry options including delay, max attempts and backoff behavior.
|
|
70
|
+
* @returns A retry policy configured with the given options.
|
|
71
|
+
*/
|
|
72
|
+
export function createDefaultRetryPolicy(options) {
|
|
73
|
+
function calculateRetryDelay(error, attempt) {
|
|
74
|
+
var _a;
|
|
75
|
+
if (options.maxRetries <= 0 ||
|
|
76
|
+
options.delay === 0 ||
|
|
77
|
+
options.maxDelay === 0 ||
|
|
78
|
+
attempt > options.maxRetries ||
|
|
79
|
+
!shouldRetryError(error)) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const baseJitterSeconds = (options.delay / 1000) * JITTER_FACTOR;
|
|
83
|
+
let retryDelay;
|
|
84
|
+
if (isRestError(error)) {
|
|
85
|
+
retryDelay = parseRetryAfter((_a = error.response) === null || _a === void 0 ? void 0 : _a.headers.get("retry-after"));
|
|
86
|
+
}
|
|
87
|
+
if (!isDefined(retryDelay)) {
|
|
88
|
+
if (options.mode === RetryMode.Exponential) {
|
|
89
|
+
retryDelay = calculateExponentialDelay(attempt, options.delay / 1000, baseJitterSeconds);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
retryDelay = calculateFixedDelay(options.delay / 1000, baseJitterSeconds);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (options.maxDelay < retryDelay) {
|
|
96
|
+
return options.maxDelay;
|
|
97
|
+
}
|
|
98
|
+
return retryDelay;
|
|
99
|
+
}
|
|
100
|
+
return createBaseRetryPolicy(calculateRetryDelay);
|
|
101
|
+
}
|
|
102
|
+
function parseRetryAfter(headerValue) {
|
|
103
|
+
if (!isDefined(headerValue)) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
// Retry-After is defined in seconds
|
|
107
|
+
const number = new Number(headerValue);
|
|
108
|
+
if (Number.isFinite(number) && number >= 0) {
|
|
109
|
+
return number.valueOf() * 1000;
|
|
110
|
+
}
|
|
111
|
+
// Retry-After is defined as a Date
|
|
112
|
+
const retryDate = Date.parse(headerValue);
|
|
113
|
+
if (Number.isNaN(retryDate)) {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
const diff = retryDate - Date.now();
|
|
117
|
+
return diff <= 0 ? undefined : diff;
|
|
118
|
+
}
|
|
119
|
+
function shouldRetryError(e) {
|
|
120
|
+
if (isAbortError(e)) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
if (isRestError(e)) {
|
|
124
|
+
// Throttle and legacy throttle
|
|
125
|
+
if ((e === null || e === void 0 ? void 0 : e.statusCode) === 429 || (e === null || e === void 0 ? void 0 : e.statusCode) === 403) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
// Network hiccups
|
|
129
|
+
if ((e === null || e === void 0 ? void 0 : e.statusCode) === 500 ||
|
|
130
|
+
(e === null || e === void 0 ? void 0 : e.statusCode) === 503 ||
|
|
131
|
+
(e === null || e === void 0 ? void 0 : e.statusCode) === 504 ||
|
|
132
|
+
(e === null || e === void 0 ? void 0 : e.statusCode) === 408) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
function calculateFixedDelay(baseDelaySeconds, baseJitterSeconds) {
|
|
139
|
+
return (baseDelaySeconds + Math.random() * baseJitterSeconds) * 1000;
|
|
140
|
+
}
|
|
141
|
+
function calculateExponentialDelay(attemptCount, baseDelaySeconds, baseJitterSeconds) {
|
|
142
|
+
return (Math.pow(2, attemptCount) * baseDelaySeconds + Math.random() * baseJitterSeconds) * 1000;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=retryPolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retryPolicy.js","sourceRoot":"","sources":["../../../src/utils/retryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,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,MAAK,GAAG;YACrB,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG;YACrB,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG;YACrB,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG,EACrB;YACA,OAAO,IAAI,CAAC;SACb;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,mBAAmB,CAAC,gBAAwB,EAAE,iBAAyB;IAC9E,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC,GAAG,IAAI,CAAC;AACvE,CAAC;AAED,SAAS,yBAAyB,CAChC,YAAoB,EACpB,gBAAwB,EACxB,iBAAyB;IAEzB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,gBAAgB,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC,GAAG,IAAI,CAAC;AACnG,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortError, AbortSignal } from \"@azure/abort-controller\";\nimport { delay } from \"@azure/core-amqp\";\nimport { isDefined } from \"./utils.js\";\nimport { isError } from \"@azure/core-util\";\nimport { isRestError } from \"@azure/core-rest-pipeline\";\n\nconst JITTER_FACTOR = 0.08;\n\nfunction isAbortError(e: unknown): e is AbortError {\n if (e instanceof AbortError) {\n return true;\n }\n\n return isError(e) && e.name === \"AbortError\";\n}\n\n/**\n * Represents the retry delay calculation either fixed or exponential.\n */\nexport enum RetryMode {\n /**\n * Fixed interval between retries.\n */\n Fixed,\n /**\n * Exporation interval between retries.\n */\n Exponential,\n}\n\n/**\n * Represents the retry options for an operation.\n */\nexport interface RetryOptions {\n /**\n * The retry mode.\n */\n mode: RetryMode;\n\n /**\n * The number of maximum retries.\n */\n maxRetries: number;\n\n /**\n * The delay in milliseconds between retries.\n */\n delay: number;\n\n /**\n * The maximum delay in milliseconds between retries.\n */\n maxDelay: number;\n}\n\n/**\n * Creates a set of retry options with defaults.\n * @param options - The options for the retry behavior.\n * @returns The retry options.\n */\nexport function createRetryOptions(options?: Partial<RetryOptions>): RetryOptions {\n return {\n mode: RetryMode.Fixed,\n maxRetries: 3,\n delay: 1000,\n maxDelay: 1000 * 60,\n ...options,\n };\n}\n\n/**\n * Represents a retry policy with a run operation and define a retry time calculation.\n */\nexport interface RetryPolicy {\n /**\n * Calculates the retry delay based upon the error and retry attempt.\n * @param error - The error from the operation.\n * @param attempt - The retry attempt number.\n */\n calculateRetryDelay: (error: unknown, attempt: number) => number | undefined;\n\n /**\n * Runs an operation and retries based upon the retry policy.\n * @param operation - The operation to run and retry if necessary.\n * @param signal - An AbortSignal to check for cancellation.\n * @returns The result of the operation.\n */\n runOperation<TResult>(\n operation: (signal?: AbortSignal) => Promise<TResult>,\n signal?: AbortSignal\n ): Promise<TResult>;\n}\n\n/**\n * Creates a base retry policy with the incoming calculateRetryDelay method.\n * @param calculateRetryDelay - The retry calculation behavior based upon attempt number and error.\n * @returns A retry policy with the given calculateRetryDelay method.\n */\nexport function createBaseRetryPolicy(\n calculateRetryDelay: (error: unknown, attempt: number) => number | undefined\n): RetryPolicy {\n async function runOperation<TResult>(\n operation: (signal?: AbortSignal) => Promise<TResult>,\n signal?: AbortSignal\n ): Promise<TResult> {\n let failedAttemptCount = 0;\n\n while (!signal?.aborted) {\n try {\n return await operation(signal);\n } catch (err) {\n ++failedAttemptCount;\n const retryDelay = calculateRetryDelay(err, failedAttemptCount);\n if (isDefined(retryDelay)) {\n await delay(retryDelay, signal);\n } else {\n throw err;\n }\n }\n }\n\n throw new AbortError(\"The operation has been aborted\");\n }\n\n return {\n calculateRetryDelay,\n runOperation,\n };\n}\n\n/**\n * Creates a retry policy configured with the given retry options.\n * @param options - The retry options including delay, max attempts and backoff behavior.\n * @returns A retry policy configured with the given options.\n */\nexport function createDefaultRetryPolicy(options: RetryOptions): RetryPolicy {\n function calculateRetryDelay(error: unknown, attempt: number): number | undefined {\n if (\n options.maxRetries <= 0 ||\n options.delay === 0 ||\n options.maxDelay === 0 ||\n attempt > options.maxRetries ||\n !shouldRetryError(error)\n ) {\n return undefined;\n }\n\n const baseJitterSeconds = (options.delay / 1000) * JITTER_FACTOR;\n\n let retryDelay: number | undefined;\n if (isRestError(error)) {\n retryDelay = parseRetryAfter(error.response?.headers.get(\"retry-after\"));\n }\n\n if (!isDefined(retryDelay)) {\n if (options.mode === RetryMode.Exponential) {\n retryDelay = calculateExponentialDelay(attempt, options.delay / 1000, baseJitterSeconds);\n } else {\n retryDelay = calculateFixedDelay(options.delay / 1000, baseJitterSeconds);\n }\n }\n\n if (options.maxDelay < retryDelay) {\n return options.maxDelay;\n }\n\n return retryDelay;\n }\n\n return createBaseRetryPolicy(calculateRetryDelay);\n}\n\nfunction parseRetryAfter(headerValue: string | undefined): number | undefined {\n if (!isDefined(headerValue)) {\n return undefined;\n }\n\n // Retry-After is defined in seconds\n const number = new Number(headerValue);\n if (Number.isFinite(number) && number >= 0) {\n return number.valueOf() * 1000;\n }\n\n // Retry-After is defined as a Date\n const retryDate = Date.parse(headerValue);\n if (Number.isNaN(retryDate)) {\n return undefined;\n }\n\n const diff = retryDate - Date.now();\n return diff <= 0 ? undefined : diff;\n}\n\nfunction shouldRetryError(e: unknown): boolean {\n if (isAbortError(e)) {\n return false;\n }\n\n if (isRestError(e)) {\n // Throttle and legacy throttle\n if (e?.statusCode === 429 || e?.statusCode === 403) {\n return true;\n }\n // Network hiccups\n if (\n e?.statusCode === 500 ||\n e?.statusCode === 503 ||\n e?.statusCode === 504 ||\n e?.statusCode === 408\n ) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction calculateFixedDelay(baseDelaySeconds: number, baseJitterSeconds: number): number {\n return (baseDelaySeconds + Math.random() * baseJitterSeconds) * 1000;\n}\n\nfunction calculateExponentialDelay(\n attemptCount: number,\n baseDelaySeconds: number,\n baseJitterSeconds: number\n): number {\n return (Math.pow(2, attemptCount) * baseDelaySeconds + Math.random() * baseJitterSeconds) * 1000;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { createTracingClient } from "@azure/core-tracing";
|
|
4
|
+
/**
|
|
5
|
+
* A tracing client to handle spans.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export const tracingClient = createTracingClient({
|
|
9
|
+
namespace: "Microsoft.NotificationHubs",
|
|
10
|
+
packageName: "@azure/notification-hubs",
|
|
11
|
+
packageVersion: "1.0.0",
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=tracing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../../src/utils/tracing.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC;IAC/C,SAAS,EAAE,4BAA4B;IACvC,WAAW,EAAE,0BAA0B;IACvC,cAAc,EAAE,OAAO;CACxB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createTracingClient } from \"@azure/core-tracing\";\n\n/**\n * A tracing client to handle spans.\n * @internal\n */\nexport const tracingClient = createTracingClient({\n namespace: \"Microsoft.NotificationHubs\",\n packageName: \"@azure/notification-hubs\",\n packageVersion: \"1.0.0\",\n});\n"]}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
/**
|
|
4
|
+
* Helper TypeGuard that checks if something is defined or not.
|
|
5
|
+
* @param thing - Anything
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export function isDefined(thing) {
|
|
9
|
+
return typeof thing !== "undefined" && thing !== null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Helper TypeGuard that checks if something is a string or not.
|
|
13
|
+
* @param thing - Anything
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export function isString(thing) {
|
|
17
|
+
return typeof thing === "string" || thing instanceof String;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
* Helper utility to retrieve `string` value from given string,
|
|
22
|
+
* or throws error if undefined.
|
|
23
|
+
*/
|
|
24
|
+
export function getString(value, nameOfProperty) {
|
|
25
|
+
const result = getStringOrUndefined(value);
|
|
26
|
+
if (result === undefined) {
|
|
27
|
+
throw new Error(`"${nameOfProperty}" received from service expected to be a string value and not undefined.`);
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
* Helper utility to retrieve `string` value from given input,
|
|
34
|
+
* or undefined if not passed in.
|
|
35
|
+
*/
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
37
|
+
export function getStringOrUndefined(value) {
|
|
38
|
+
if (!isDefined(value)) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return value.toString();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @internal
|
|
45
|
+
* Helper utility to retrieve `integer` value from given string,
|
|
46
|
+
* or throws error if undefined.
|
|
47
|
+
*/
|
|
48
|
+
export function getInteger(value, nameOfProperty) {
|
|
49
|
+
const result = getIntegerOrUndefined(value);
|
|
50
|
+
if (result === undefined) {
|
|
51
|
+
throw new Error(`"${nameOfProperty}" received from service expected to be a number value and not undefined.`);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
* Helper utility to retrieve `integer` value from given string,
|
|
58
|
+
* or undefined if not passed in.
|
|
59
|
+
*/
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
61
|
+
export function getIntegerOrUndefined(value) {
|
|
62
|
+
if (!isDefined(value)) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
const result = parseInt(value.toString());
|
|
66
|
+
return isNaN(result) ? undefined : result;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @internal
|
|
70
|
+
* Helper utility to retrieve `float` value from given string,
|
|
71
|
+
* or throws error if undefined.
|
|
72
|
+
*/
|
|
73
|
+
export function getFloat(value, nameOfProperty) {
|
|
74
|
+
const result = getFloatOrUndefined(value);
|
|
75
|
+
if (result === undefined) {
|
|
76
|
+
throw new Error(`"${nameOfProperty}" received from service expected to be a number value and not undefined.`);
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
* Helper utility to retrieve `float` value from given string,
|
|
83
|
+
* or undefined if not passed in.
|
|
84
|
+
*/
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
86
|
+
export function getFloatOrUndefined(value) {
|
|
87
|
+
if (!isDefined(value)) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
const result = parseFloat(value.toString());
|
|
91
|
+
return Number.isNaN(result) ? undefined : result;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @internal
|
|
95
|
+
* Helper utility to convert ISO-8601 time into Date type.
|
|
96
|
+
*/
|
|
97
|
+
export function getDate(value, nameOfProperty) {
|
|
98
|
+
const result = getDateOrUndefined(value);
|
|
99
|
+
if (result === undefined) {
|
|
100
|
+
throw new Error(`"${nameOfProperty}" received from service expected to be a Date value and not undefined.`);
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* @internal
|
|
106
|
+
* Helper utility to convert ISO-8601 time into Date type,
|
|
107
|
+
* or undefined if not passed in.
|
|
108
|
+
*/
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
110
|
+
export function getDateOrUndefined(value) {
|
|
111
|
+
const stringValue = getStringOrUndefined(value);
|
|
112
|
+
if (stringValue === undefined) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
const result = new Date(stringValue.toString());
|
|
116
|
+
return Number.isNaN(+result) ? undefined : result;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @internal
|
|
120
|
+
* Helper utility to parse tags from a comma separated string.
|
|
121
|
+
*/
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
123
|
+
export function getTagsOrUndefined(value) {
|
|
124
|
+
const result = getStringOrUndefined(value);
|
|
125
|
+
if (result === undefined) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
return result.split(",");
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAI,KAA2B;IACtD,OAAO,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,CAAC;AAC9D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc,EAAE,cAAsB;IAC9D,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAI,MAAM,KAAK,SAAS,EAAE;QACx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,SAAS,CAAC,KAAK,CAAC,EAAE;QACrB,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC5C,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,cAAsB;IAC3D,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACzC,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,MAAM,IAAI,KAAK,CACb,IAAI,cAAc,wEAAwE,CAC3F,CAAC;KACH;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,6EAA6E;AAC7E,MAAM,UAAU,kBAAkB,CAAC,KAAU;IAC3C,MAAM,WAAW,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAChD,IAAI,WAAW,KAAK,SAAS,EAAE;QAC7B,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,6EAA6E;AAC7E,MAAM,UAAU,kBAAkB,CAAC,KAAW;IAC5C,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Helper TypeGuard that checks if something is defined or not.\n * @param thing - Anything\n * @internal\n */\nexport function isDefined<T>(thing: T | undefined | null): thing is T {\n return typeof thing !== \"undefined\" && thing !== null;\n}\n\n/**\n * Helper TypeGuard that checks if something is a string or not.\n * @param thing - Anything\n * @internal\n */\nexport function isString(thing: unknown): thing is string {\n return typeof thing === \"string\" || thing instanceof String;\n}\n\n/**\n * @internal\n * Helper utility to retrieve `string` value from given string,\n * or throws error if undefined.\n */\nexport function getString(value: unknown, nameOfProperty: string): string {\n const result = getStringOrUndefined(value);\n if (result === undefined) {\n throw new Error(\n `\"${nameOfProperty}\" received from service expected to be a string value and not undefined.`\n );\n }\n return result;\n}\n\n/**\n * @internal\n * Helper utility to retrieve `string` value from given input,\n * or undefined if not passed in.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function getStringOrUndefined(value: any): string | undefined {\n if (!isDefined(value)) {\n return undefined;\n }\n return value.toString();\n}\n\n/**\n * @internal\n * Helper utility to retrieve `integer` value from given string,\n * or throws error if undefined.\n */\nexport function getInteger(value: unknown, nameOfProperty: string): number {\n const result = getIntegerOrUndefined(value);\n if (result === undefined) {\n throw new Error(\n `\"${nameOfProperty}\" received from service expected to be a number value and not undefined.`\n );\n }\n return result;\n}\n\n/**\n * @internal\n * Helper utility to retrieve `integer` value from given string,\n * or undefined if not passed in.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function getIntegerOrUndefined(value: any): number | undefined {\n if (!isDefined(value)) {\n return undefined;\n }\n const result = parseInt(value.toString());\n return isNaN(result) ? undefined : result;\n}\n\n/**\n * @internal\n * Helper utility to retrieve `float` value from given string,\n * or throws error if undefined.\n */\nexport function getFloat(value: unknown, nameOfProperty: string): number {\n const result = getFloatOrUndefined(value);\n if (result === undefined) {\n throw new Error(\n `\"${nameOfProperty}\" received from service expected to be a number value and not undefined.`\n );\n }\n return result;\n}\n\n/**\n * @internal\n * Helper utility to retrieve `float` value from given string,\n * or undefined if not passed in.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function getFloatOrUndefined(value: any): number | undefined {\n if (!isDefined(value)) {\n return undefined;\n }\n const result = parseFloat(value.toString());\n return Number.isNaN(result) ? undefined : result;\n}\n\n/**\n * @internal\n * Helper utility to convert ISO-8601 time into Date type.\n */\nexport function getDate(value: string, nameOfProperty: string): Date {\n const result = getDateOrUndefined(value);\n if (result === undefined) {\n throw new Error(\n `\"${nameOfProperty}\" received from service expected to be a Date value and not undefined.`\n );\n }\n return result;\n}\n\n/**\n * @internal\n * Helper utility to convert ISO-8601 time into Date type,\n * or undefined if not passed in.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function getDateOrUndefined(value: any): Date | undefined {\n const stringValue = getStringOrUndefined(value);\n if (stringValue === undefined) {\n return undefined;\n }\n const result = new Date(stringValue.toString());\n return Number.isNaN(+result) ? undefined : result;\n}\n\n/**\n * @internal\n * Helper utility to parse tags from a comma separated string.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function getTagsOrUndefined(value?: any): string[] | undefined {\n const result = getStringOrUndefined(value);\n if (result === undefined) {\n return undefined;\n }\n return result.split(\",\");\n}\n"]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { isDefined } from "./utils.js";
|
|
4
|
+
import { parseXML } from "@azure/core-xml";
|
|
5
|
+
/**
|
|
6
|
+
* Marker for atom metadata.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export const XML_METADATA_MARKER = "$";
|
|
11
|
+
/**
|
|
12
|
+
* Marker for atom value.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export const XML_VALUE_MARKER = "_";
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
* Helps in differentiating JSON like objects from other kinds of objects.
|
|
20
|
+
*/
|
|
21
|
+
const EMPTY_JSON_OBJECT_CONSTRUCTOR = {}.constructor;
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
* Returns `true` if given input is a JSON like object.
|
|
25
|
+
*/
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
27
|
+
export function isJSONLikeObject(value) {
|
|
28
|
+
// `value.constructor === {}.constructor` differentiates among the "object"s,
|
|
29
|
+
// would filter the JSON objects and won't match any array or other kinds of objects
|
|
30
|
+
// -------------------------------------------------------------------------------
|
|
31
|
+
// Few examples | typeof obj ==="object" | obj.constructor==={}.constructor
|
|
32
|
+
// -------------------------------------------------------------------------------
|
|
33
|
+
// {abc:1} | true | true
|
|
34
|
+
// ["a","b"] | true | false
|
|
35
|
+
// [{"a":1},{"b":2}] | true | false
|
|
36
|
+
// new Date() | true | false
|
|
37
|
+
// 123 | false | false
|
|
38
|
+
// -------------------------------------------------------------------------------
|
|
39
|
+
return typeof value === "object" && value.constructor === EMPTY_JSON_OBJECT_CONSTRUCTOR;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @internal
|
|
43
|
+
* The key-value pairs having undefined/null as the values would lead to the empty tags in the serialized XML request.
|
|
44
|
+
* Empty tags in the request body is problematic because of the following reasons.
|
|
45
|
+
* - ATOM based management operations throw a "Bad Request" error if empty tags are included in the XML request body at top level.
|
|
46
|
+
* - At the inner levels, Service assigns the empty strings as values to the empty tags instead of throwing an error.
|
|
47
|
+
*
|
|
48
|
+
* This method recursively removes the key-value pairs with undefined/null as the values from the request object that is to be serialized.
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
export function sanitizeSerializableObject(resource) {
|
|
52
|
+
Object.keys(resource).forEach(function (property) {
|
|
53
|
+
if (!isDefined(resource[property])) {
|
|
54
|
+
delete resource[property];
|
|
55
|
+
}
|
|
56
|
+
else if (isJSONLikeObject(resource[property])) {
|
|
57
|
+
sanitizeSerializableObject(resource[property]);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @internal
|
|
63
|
+
* Serializes input information to construct the Atom XML request
|
|
64
|
+
* @param resourceName - Name of the resource to be serialized like `QueueDescription`
|
|
65
|
+
* @param resource - The entity details
|
|
66
|
+
* @returns An object to be serialized into a string.
|
|
67
|
+
*/
|
|
68
|
+
export function serializeToAtomXmlRequest(resourceName, resource) {
|
|
69
|
+
const content = {};
|
|
70
|
+
content[resourceName] = Object.assign({}, resource);
|
|
71
|
+
sanitizeSerializableObject(content[resourceName]);
|
|
72
|
+
content[resourceName][XML_METADATA_MARKER] = {
|
|
73
|
+
xmlns: "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
|
|
74
|
+
"xmlns:i": "http://www.w3.org/2001/XMLSchema-instance",
|
|
75
|
+
};
|
|
76
|
+
content[XML_METADATA_MARKER] = { type: "application/xml" };
|
|
77
|
+
const requestDetails = {
|
|
78
|
+
updated: new Date().toISOString(),
|
|
79
|
+
content: content,
|
|
80
|
+
};
|
|
81
|
+
requestDetails[XML_METADATA_MARKER] = {
|
|
82
|
+
xmlns: "http://www.w3.org/2005/Atom",
|
|
83
|
+
};
|
|
84
|
+
return requestDetails;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* @internal
|
|
88
|
+
* Parses the XML message from a Notification Hubs response
|
|
89
|
+
* @param bodyText - The HTTP response body.
|
|
90
|
+
* @returns The notification details if any from the XML.
|
|
91
|
+
*/
|
|
92
|
+
export async function parseXMLError(bodyText) {
|
|
93
|
+
let result;
|
|
94
|
+
const xmlError = await parseXML(bodyText, { includeRoot: true });
|
|
95
|
+
const detail = xmlError["Detail"];
|
|
96
|
+
if (isDefined(detail)) {
|
|
97
|
+
return detail;
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=xmlUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xm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AC;IAExB,OAAO,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IACpD,0BAA0B,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;IAElD,OAAO,CAAC,YAAY,CAAC,CAAC,mBAAmB,CAAC,GAAG;QAC3C,KAAK,EAAE,qEAAqE;QAC5E,SAAS,EAAE,2CAA2C;KACvD,CAAC;IAEF,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;IAC3D,MAAM,cAAc,GAA4B;QAC9C,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACjC,OAAO,EAAE,OAAO;KACjB,CAAC;IACF,cAAc,CAAC,mBAAmB,CAAC,GAAG;QACpC,KAAK,EAAE,6BAA6B;KACrC,CAAC;IACF,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,QAAgB;IAClD,IAAI,MAA0B,CAAC;IAC/B,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAClC,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE;QACrB,OAAO,MAAM,CAAC;KACf;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isDefined } from \"./utils.js\";\nimport { parseXML } from \"@azure/core-xml\";\n\n/**\n * Marker for atom metadata.\n *\n * @internal\n */\nexport const XML_METADATA_MARKER = \"$\";\n\n/**\n * Marker for atom value.\n *\n * @internal\n */\nexport const XML_VALUE_MARKER = \"_\";\n\n/**\n * @internal\n * Helps in differentiating JSON like objects from other kinds of objects.\n */\nconst EMPTY_JSON_OBJECT_CONSTRUCTOR = {}.constructor;\n\n/**\n * @internal\n * Returns `true` if given input is a JSON like object.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function isJSONLikeObject(value: any): boolean {\n // `value.constructor === {}.constructor` differentiates among the \"object\"s,\n // would filter the JSON objects and won't match any array or other kinds of objects\n\n // -------------------------------------------------------------------------------\n // Few examples | typeof obj ===\"object\" | obj.constructor==={}.constructor\n // -------------------------------------------------------------------------------\n // {abc:1} | true | true\n // [\"a\",\"b\"] | true | false\n // [{\"a\":1},{\"b\":2}] | true | false\n // new Date() | true | false\n // 123 | false | false\n // -------------------------------------------------------------------------------\n return typeof value === \"object\" && value.constructor === EMPTY_JSON_OBJECT_CONSTRUCTOR;\n}\n\n/**\n * @internal\n * The key-value pairs having undefined/null as the values would lead to the empty tags in the serialized XML request.\n * Empty tags in the request body is problematic because of the following reasons.\n * - ATOM based management operations throw a \"Bad Request\" error if empty tags are included in the XML request body at top level.\n * - At the inner levels, Service assigns the empty strings as values to the empty tags instead of throwing an error.\n *\n * This method recursively removes the key-value pairs with undefined/null as the values from the request object that is to be serialized.\n *\n */\nexport function sanitizeSerializableObject(resource: { [key: string]: any }): void {\n Object.keys(resource).forEach(function (property) {\n if (!isDefined(resource[property])) {\n delete resource[property];\n } else if (isJSONLikeObject(resource[property])) {\n sanitizeSerializableObject(resource[property]);\n }\n });\n}\n\n/**\n * @internal\n * Serializes input information to construct the Atom XML request\n * @param resourceName - Name of the resource to be serialized like `QueueDescription`\n * @param resource - The entity details\n * @returns An object to be serialized into a string.\n */\nexport function serializeToAtomXmlRequest(\n resourceName: string,\n resource: unknown\n): Record<string, unknown> {\n const content: any = {};\n\n content[resourceName] = Object.assign({}, resource);\n sanitizeSerializableObject(content[resourceName]);\n\n content[resourceName][XML_METADATA_MARKER] = {\n xmlns: \"http://schemas.microsoft.com/netservices/2010/10/servicebus/connect\",\n \"xmlns:i\": \"http://www.w3.org/2001/XMLSchema-instance\",\n };\n\n content[XML_METADATA_MARKER] = { type: \"application/xml\" };\n const requestDetails: Record<string, unknown> = {\n updated: new Date().toISOString(),\n content: content,\n };\n requestDetails[XML_METADATA_MARKER] = {\n xmlns: \"http://www.w3.org/2005/Atom\",\n };\n return requestDetails;\n}\n\n/**\n * @internal\n * Parses the XML message from a Notification Hubs response\n * @param bodyText - The HTTP response body.\n * @returns The notification details if any from the XML.\n */\nexport async function parseXMLError(bodyText: string): Promise<string | undefined> {\n let result: string | undefined;\n const xmlError = await parseXML(bodyText, { includeRoot: true });\n const detail = xmlError[\"Detail\"];\n if (isDefined(detail)) {\n return detail;\n }\n\n return result;\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@azure/notification-hubs",
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
|
+
"description": "Azure Notification Hubs SDK for JavaScript",
|
|
5
|
+
"sdk-type": "client",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist-esm/src/index.js",
|
|
8
|
+
"browser": {},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./types/src/index.js",
|
|
13
|
+
"require": "./dist/index.js",
|
|
14
|
+
"import": "./dist-esm/src/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./client": {
|
|
17
|
+
"types": "./types/src/client/index.js",
|
|
18
|
+
"import": "./dist-esm/src/client/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./client/*": {
|
|
21
|
+
"types": "./types/src/client/*.js",
|
|
22
|
+
"import": "./dist-esm/src/client/*.js"
|
|
23
|
+
},
|
|
24
|
+
"./models/*": {
|
|
25
|
+
"types": "./types/src/models/*.js",
|
|
26
|
+
"import": "./dist-esm/src/models/*.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"//metadata": {
|
|
30
|
+
"constantPaths": [
|
|
31
|
+
{
|
|
32
|
+
"path": "src/constants.ts",
|
|
33
|
+
"prefix": "SDK_VERSION"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"types": "types/latest/notification-hubs.d.ts",
|
|
38
|
+
"typesVersions": {
|
|
39
|
+
"<3.6": {
|
|
40
|
+
"*": [
|
|
41
|
+
"types/3.1/notification-hubs.d.ts"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
|
|
47
|
+
"build:samples": "echo Obsolete",
|
|
48
|
+
"build:test": "npm run clean && tsc -p . && dev-tool run bundle",
|
|
49
|
+
"build:types": "downlevel-dts types/latest/ types/3.1/",
|
|
50
|
+
"build": "npm run build:test && api-extractor run --local && npm run build:types",
|
|
51
|
+
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|
|
52
|
+
"clean": "rimraf dist dist-* temp types *.tgz *.log",
|
|
53
|
+
"execute:samples": "dev-tool samples run samples-dev",
|
|
54
|
+
"extract-api": "tsc -p . && api-extractor run --local",
|
|
55
|
+
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
|
56
|
+
"integration-test:browser": "echo skipped",
|
|
57
|
+
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 600000 --full-trace \"dist-esm/test/internal/**/*.spec.js\" \"dist-esm/test/public/**/*.spec.js\"",
|
|
58
|
+
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
|
59
|
+
"lint:fix": "eslint README.md package.json api-extractor.json src test --ext .ts,.javascript,.js --fix --fix-type [problem,suggestion]",
|
|
60
|
+
"lint": "eslint README.md package.json api-extractor.json src test --ext .ts,.javascript,.js",
|
|
61
|
+
"pack": "npm pack 2>&1",
|
|
62
|
+
"test:browser": "npm run clean && npm run build:test && npm run integration-test:browser",
|
|
63
|
+
"test:node": "npm run clean && tsc -p . && npm run integration-test:node",
|
|
64
|
+
"test": "npm run clean && tsc -p . && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test",
|
|
65
|
+
"unit-test:browser": "echo skipped",
|
|
66
|
+
"unit-test:node": "mocha -r ts-node/register --timeout 1200000 --full-trace --exclude \"dist-esm/test/**/browser/*.spec.js\" \"dist-esm/test/internal/unit/{,!(browser)/**/}*.spec.js\" \"dist-esm/test/public/unit/{,!(browser)/**/}*.spec.js\"",
|
|
67
|
+
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
|
|
68
|
+
},
|
|
69
|
+
"files": [
|
|
70
|
+
"dist/",
|
|
71
|
+
"dist-esm/src/",
|
|
72
|
+
"types/src",
|
|
73
|
+
"types/latest/",
|
|
74
|
+
"types/3.1/",
|
|
75
|
+
"README.md",
|
|
76
|
+
"LICENSE"
|
|
77
|
+
],
|
|
78
|
+
"repository": "github:Azure/azure-sdk-for-js",
|
|
79
|
+
"engines": {
|
|
80
|
+
"node": ">=12.0.0"
|
|
81
|
+
},
|
|
82
|
+
"keywords": [
|
|
83
|
+
"azure",
|
|
84
|
+
"cloud",
|
|
85
|
+
"typescript"
|
|
86
|
+
],
|
|
87
|
+
"author": "Microsoft Corporation",
|
|
88
|
+
"license": "MIT",
|
|
89
|
+
"bugs": {
|
|
90
|
+
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
|
|
91
|
+
},
|
|
92
|
+
"homepage": "https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/notificationhubs/notification-hubs/README.md",
|
|
93
|
+
"sideEffects": false,
|
|
94
|
+
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
|
|
95
|
+
"devDependencies": {
|
|
96
|
+
"@azure/dev-tool": "^1.0.0",
|
|
97
|
+
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
|
|
98
|
+
"@azure/test-utils": "^1.0.0",
|
|
99
|
+
"@microsoft/api-extractor": "^7.24.2",
|
|
100
|
+
"@types/chai": "^4.3.1",
|
|
101
|
+
"@types/mocha": "^9.1.1",
|
|
102
|
+
"@types/node": "^12.0.0",
|
|
103
|
+
"@types/uuid": "^8.3.4",
|
|
104
|
+
"chai": "^4.3.6",
|
|
105
|
+
"cross-env": "^7.0.3",
|
|
106
|
+
"dotenv": "^16.0.1",
|
|
107
|
+
"downlevel-dts": "^0.10.0",
|
|
108
|
+
"eslint": "^8.16.0",
|
|
109
|
+
"esm": "^3.2.25",
|
|
110
|
+
"karma": "^6.4.0",
|
|
111
|
+
"karma-chrome-launcher": "^3.1.1",
|
|
112
|
+
"karma-coverage": "^2.2.0",
|
|
113
|
+
"karma-edge-launcher": "^0.4.2",
|
|
114
|
+
"karma-env-preprocessor": "^0.1.1",
|
|
115
|
+
"karma-firefox-launcher": "^2.1.2",
|
|
116
|
+
"karma-json-preprocessor": "^0.3.3",
|
|
117
|
+
"karma-json-to-file-reporter": "^1.0.1",
|
|
118
|
+
"karma-junit-reporter": "^2.0.1",
|
|
119
|
+
"karma-mocha": "^2.0.1",
|
|
120
|
+
"karma-mocha-reporter": "^2.2.5",
|
|
121
|
+
"mocha": "^10.0.0",
|
|
122
|
+
"mocha-junit-reporter": "^2.0.2",
|
|
123
|
+
"nyc": "^15.1.0",
|
|
124
|
+
"prettier": "^2.6.2",
|
|
125
|
+
"rimraf": "^3.0.2",
|
|
126
|
+
"ts-node": "^10.8.1",
|
|
127
|
+
"typescript": "^4.7.2",
|
|
128
|
+
"util": "^0.12.4",
|
|
129
|
+
"uuid": "^8.3.2"
|
|
130
|
+
},
|
|
131
|
+
"dependencies": {
|
|
132
|
+
"@azure/abort-controller": "^1.1.0",
|
|
133
|
+
"@azure/core-amqp": "^3.1.0",
|
|
134
|
+
"@azure/core-auth": "^1.4.0",
|
|
135
|
+
"@azure/core-client": "^1.6.1",
|
|
136
|
+
"@azure/core-paging": "^1.3.0",
|
|
137
|
+
"@azure/core-rest-pipeline": "^1.8.1",
|
|
138
|
+
"@azure/core-tracing": "^1.0.1",
|
|
139
|
+
"@azure/core-util": "^1.0.0",
|
|
140
|
+
"@azure/core-xml": "^1.3.0",
|
|
141
|
+
"@azure/logger": "^1.0.3",
|
|
142
|
+
"tslib": "^2.4.0"
|
|
143
|
+
}
|
|
144
|
+
}
|