@azure/notification-hubs 2.0.0-alpha.20240912.1 → 2.0.0-alpha.20240916.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.
Files changed (170) hide show
  1. package/README.md +6 -6
  2. package/dist/api/notification-hubs.d.ts +37 -13
  3. package/dist/browser/api/index.d.ts +2 -0
  4. package/dist/browser/api/index.d.ts.map +1 -1
  5. package/dist/browser/api/index.js +2 -0
  6. package/dist/browser/api/index.js.map +1 -1
  7. package/dist/browser/api/internal/_scheduleNotification.d.ts +15 -0
  8. package/dist/browser/api/internal/_scheduleNotification.d.ts.map +1 -0
  9. package/dist/browser/api/internal/_scheduleNotification.js +31 -0
  10. package/dist/browser/api/internal/_scheduleNotification.js.map +1 -0
  11. package/dist/browser/api/internal/_sendNotification.d.ts +13 -0
  12. package/dist/browser/api/internal/_sendNotification.d.ts.map +1 -0
  13. package/dist/browser/api/internal/_sendNotification.js +62 -0
  14. package/dist/browser/api/internal/_sendNotification.js.map +1 -0
  15. package/dist/browser/api/scheduleBroadcastNotification.d.ts +15 -0
  16. package/dist/browser/api/scheduleBroadcastNotification.d.ts.map +1 -0
  17. package/dist/browser/api/scheduleBroadcastNotification.js +16 -0
  18. package/dist/browser/api/scheduleBroadcastNotification.js.map +1 -0
  19. package/dist/browser/api/scheduleNotification.d.ts +1 -1
  20. package/dist/browser/api/scheduleNotification.d.ts.map +1 -1
  21. package/dist/browser/api/scheduleNotification.js +3 -18
  22. package/dist/browser/api/scheduleNotification.js.map +1 -1
  23. package/dist/browser/api/sendBroadcastNotification.d.ts +13 -0
  24. package/dist/browser/api/sendBroadcastNotification.d.ts.map +1 -0
  25. package/dist/browser/api/sendBroadcastNotification.js +14 -0
  26. package/dist/browser/api/sendBroadcastNotification.js.map +1 -0
  27. package/dist/browser/api/sendNotification.d.ts +1 -1
  28. package/dist/browser/api/sendNotification.d.ts.map +1 -1
  29. package/dist/browser/api/sendNotification.js +3 -52
  30. package/dist/browser/api/sendNotification.js.map +1 -1
  31. package/dist/browser/models/options.d.ts +13 -10
  32. package/dist/browser/models/options.d.ts.map +1 -1
  33. package/dist/browser/models/options.js.map +1 -1
  34. package/dist/browser/notificationHubsClient.d.ts +19 -3
  35. package/dist/browser/notificationHubsClient.d.ts.map +1 -1
  36. package/dist/browser/notificationHubsClient.js +24 -2
  37. package/dist/browser/notificationHubsClient.js.map +1 -1
  38. package/dist/browser/utils/optionUtils.d.ts +7 -1
  39. package/dist/browser/utils/optionUtils.d.ts.map +1 -1
  40. package/dist/browser/utils/optionUtils.js +8 -0
  41. package/dist/browser/utils/optionUtils.js.map +1 -1
  42. package/dist/browser/utils/xmlUtils.js +1 -1
  43. package/dist/browser/utils/xmlUtils.js.map +1 -1
  44. package/dist/commonjs/api/index.d.ts +2 -0
  45. package/dist/commonjs/api/index.d.ts.map +1 -1
  46. package/dist/commonjs/api/index.js +2 -0
  47. package/dist/commonjs/api/index.js.map +1 -1
  48. package/dist/commonjs/api/internal/_scheduleNotification.d.ts +15 -0
  49. package/dist/commonjs/api/internal/_scheduleNotification.d.ts.map +1 -0
  50. package/dist/commonjs/api/internal/_scheduleNotification.js +34 -0
  51. package/dist/commonjs/api/internal/_scheduleNotification.js.map +1 -0
  52. package/dist/commonjs/api/internal/_sendNotification.d.ts +13 -0
  53. package/dist/commonjs/api/internal/_sendNotification.d.ts.map +1 -0
  54. package/dist/commonjs/api/internal/_sendNotification.js +65 -0
  55. package/dist/commonjs/api/internal/_sendNotification.js.map +1 -0
  56. package/dist/commonjs/api/scheduleBroadcastNotification.d.ts +15 -0
  57. package/dist/commonjs/api/scheduleBroadcastNotification.d.ts.map +1 -0
  58. package/dist/commonjs/api/scheduleBroadcastNotification.js +19 -0
  59. package/dist/commonjs/api/scheduleBroadcastNotification.js.map +1 -0
  60. package/dist/commonjs/api/scheduleNotification.d.ts +1 -1
  61. package/dist/commonjs/api/scheduleNotification.d.ts.map +1 -1
  62. package/dist/commonjs/api/scheduleNotification.js +3 -18
  63. package/dist/commonjs/api/scheduleNotification.js.map +1 -1
  64. package/dist/commonjs/api/sendBroadcastNotification.d.ts +13 -0
  65. package/dist/commonjs/api/sendBroadcastNotification.d.ts.map +1 -0
  66. package/dist/commonjs/api/sendBroadcastNotification.js +17 -0
  67. package/dist/commonjs/api/sendBroadcastNotification.js.map +1 -0
  68. package/dist/commonjs/api/sendNotification.d.ts +1 -1
  69. package/dist/commonjs/api/sendNotification.d.ts.map +1 -1
  70. package/dist/commonjs/api/sendNotification.js +3 -52
  71. package/dist/commonjs/api/sendNotification.js.map +1 -1
  72. package/dist/commonjs/models/options.d.ts +13 -10
  73. package/dist/commonjs/models/options.d.ts.map +1 -1
  74. package/dist/commonjs/models/options.js.map +1 -1
  75. package/dist/commonjs/notificationHubsClient.d.ts +19 -3
  76. package/dist/commonjs/notificationHubsClient.d.ts.map +1 -1
  77. package/dist/commonjs/notificationHubsClient.js +24 -2
  78. package/dist/commonjs/notificationHubsClient.js.map +1 -1
  79. package/dist/commonjs/tsdoc-metadata.json +1 -1
  80. package/dist/commonjs/utils/optionUtils.d.ts +7 -1
  81. package/dist/commonjs/utils/optionUtils.d.ts.map +1 -1
  82. package/dist/commonjs/utils/optionUtils.js +9 -0
  83. package/dist/commonjs/utils/optionUtils.js.map +1 -1
  84. package/dist/commonjs/utils/xmlUtils.js +1 -1
  85. package/dist/commonjs/utils/xmlUtils.js.map +1 -1
  86. package/dist/esm/api/index.d.ts +2 -0
  87. package/dist/esm/api/index.d.ts.map +1 -1
  88. package/dist/esm/api/index.js +2 -0
  89. package/dist/esm/api/index.js.map +1 -1
  90. package/dist/esm/api/internal/_scheduleNotification.d.ts +15 -0
  91. package/dist/esm/api/internal/_scheduleNotification.d.ts.map +1 -0
  92. package/dist/esm/api/internal/_scheduleNotification.js +31 -0
  93. package/dist/esm/api/internal/_scheduleNotification.js.map +1 -0
  94. package/dist/esm/api/internal/_sendNotification.d.ts +13 -0
  95. package/dist/esm/api/internal/_sendNotification.d.ts.map +1 -0
  96. package/dist/esm/api/internal/_sendNotification.js +62 -0
  97. package/dist/esm/api/internal/_sendNotification.js.map +1 -0
  98. package/dist/esm/api/scheduleBroadcastNotification.d.ts +15 -0
  99. package/dist/esm/api/scheduleBroadcastNotification.d.ts.map +1 -0
  100. package/dist/esm/api/scheduleBroadcastNotification.js +16 -0
  101. package/dist/esm/api/scheduleBroadcastNotification.js.map +1 -0
  102. package/dist/esm/api/scheduleNotification.d.ts +1 -1
  103. package/dist/esm/api/scheduleNotification.d.ts.map +1 -1
  104. package/dist/esm/api/scheduleNotification.js +3 -18
  105. package/dist/esm/api/scheduleNotification.js.map +1 -1
  106. package/dist/esm/api/sendBroadcastNotification.d.ts +13 -0
  107. package/dist/esm/api/sendBroadcastNotification.d.ts.map +1 -0
  108. package/dist/esm/api/sendBroadcastNotification.js +14 -0
  109. package/dist/esm/api/sendBroadcastNotification.js.map +1 -0
  110. package/dist/esm/api/sendNotification.d.ts +1 -1
  111. package/dist/esm/api/sendNotification.d.ts.map +1 -1
  112. package/dist/esm/api/sendNotification.js +3 -52
  113. package/dist/esm/api/sendNotification.js.map +1 -1
  114. package/dist/esm/models/options.d.ts +13 -10
  115. package/dist/esm/models/options.d.ts.map +1 -1
  116. package/dist/esm/models/options.js.map +1 -1
  117. package/dist/esm/notificationHubsClient.d.ts +19 -3
  118. package/dist/esm/notificationHubsClient.d.ts.map +1 -1
  119. package/dist/esm/notificationHubsClient.js +24 -2
  120. package/dist/esm/notificationHubsClient.js.map +1 -1
  121. package/dist/esm/utils/optionUtils.d.ts +7 -1
  122. package/dist/esm/utils/optionUtils.d.ts.map +1 -1
  123. package/dist/esm/utils/optionUtils.js +8 -0
  124. package/dist/esm/utils/optionUtils.js.map +1 -1
  125. package/dist/esm/utils/xmlUtils.js +1 -1
  126. package/dist/esm/utils/xmlUtils.js.map +1 -1
  127. package/dist/models/notification-hubs.d.ts +15 -11
  128. package/dist/notification-hubs.d.ts +33 -13
  129. package/dist/react-native/api/index.d.ts +2 -0
  130. package/dist/react-native/api/index.d.ts.map +1 -1
  131. package/dist/react-native/api/index.js +2 -0
  132. package/dist/react-native/api/index.js.map +1 -1
  133. package/dist/react-native/api/internal/_scheduleNotification.d.ts +15 -0
  134. package/dist/react-native/api/internal/_scheduleNotification.d.ts.map +1 -0
  135. package/dist/react-native/api/internal/_scheduleNotification.js +31 -0
  136. package/dist/react-native/api/internal/_scheduleNotification.js.map +1 -0
  137. package/dist/react-native/api/internal/_sendNotification.d.ts +13 -0
  138. package/dist/react-native/api/internal/_sendNotification.d.ts.map +1 -0
  139. package/dist/react-native/api/internal/_sendNotification.js +62 -0
  140. package/dist/react-native/api/internal/_sendNotification.js.map +1 -0
  141. package/dist/react-native/api/scheduleBroadcastNotification.d.ts +15 -0
  142. package/dist/react-native/api/scheduleBroadcastNotification.d.ts.map +1 -0
  143. package/dist/react-native/api/scheduleBroadcastNotification.js +16 -0
  144. package/dist/react-native/api/scheduleBroadcastNotification.js.map +1 -0
  145. package/dist/react-native/api/scheduleNotification.d.ts +1 -1
  146. package/dist/react-native/api/scheduleNotification.d.ts.map +1 -1
  147. package/dist/react-native/api/scheduleNotification.js +3 -18
  148. package/dist/react-native/api/scheduleNotification.js.map +1 -1
  149. package/dist/react-native/api/sendBroadcastNotification.d.ts +13 -0
  150. package/dist/react-native/api/sendBroadcastNotification.d.ts.map +1 -0
  151. package/dist/react-native/api/sendBroadcastNotification.js +14 -0
  152. package/dist/react-native/api/sendBroadcastNotification.js.map +1 -0
  153. package/dist/react-native/api/sendNotification.d.ts +1 -1
  154. package/dist/react-native/api/sendNotification.d.ts.map +1 -1
  155. package/dist/react-native/api/sendNotification.js +3 -52
  156. package/dist/react-native/api/sendNotification.js.map +1 -1
  157. package/dist/react-native/models/options.d.ts +13 -10
  158. package/dist/react-native/models/options.d.ts.map +1 -1
  159. package/dist/react-native/models/options.js.map +1 -1
  160. package/dist/react-native/notificationHubsClient.d.ts +19 -3
  161. package/dist/react-native/notificationHubsClient.d.ts.map +1 -1
  162. package/dist/react-native/notificationHubsClient.js +24 -2
  163. package/dist/react-native/notificationHubsClient.js.map +1 -1
  164. package/dist/react-native/utils/optionUtils.d.ts +7 -1
  165. package/dist/react-native/utils/optionUtils.d.ts.map +1 -1
  166. package/dist/react-native/utils/optionUtils.js +8 -0
  167. package/dist/react-native/utils/optionUtils.js.map +1 -1
  168. package/dist/react-native/utils/xmlUtils.js +1 -1
  169. package/dist/react-native/utils/xmlUtils.js.map +1 -1
  170. package/package.json +3 -2
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.sendNotificationInternal = sendNotificationInternal;
6
+ const _client_js_1 = require("./_client.js");
7
+ const optionUtils_js_1 = require("../../utils/optionUtils.js");
8
+ const notificationUtils_js_1 = require("../../utils/notificationUtils.js");
9
+ const core_util_1 = require("@azure/core-util");
10
+ const tracing_js_1 = require("../../utils/tracing.js");
11
+ /**
12
+ * Sends push notifications to devices that match the given tags or tag expression.
13
+ * @param context - The Notification Hubs client.
14
+ * @param notification - The notification to send to the matching devices.
15
+ * @param options - Options for the notification including tags, device handles and whether to enable test send.
16
+ * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
17
+ */
18
+ function sendNotificationInternal(context, notification, options) {
19
+ return tracing_js_1.tracingClient.withSpan(`NotificationHubsClientContext.sendNotification`, options, async (updatedOptions) => {
20
+ const endpoint = context.requestUrl();
21
+ endpoint.pathname += "/messages/";
22
+ // Check if batch direct send
23
+ if ((0, optionUtils_js_1.isDirectSendNotificationOptions)(options) && Array.isArray(options.deviceHandle)) {
24
+ endpoint.pathname += "$batch";
25
+ }
26
+ // Check for test send
27
+ if (((0, optionUtils_js_1.isSendNotificationOptions)(options) || (0, optionUtils_js_1.isBroadcastSendNotificationOptions)(options)) &&
28
+ options.enableTestSend) {
29
+ endpoint.searchParams.append("test", "true");
30
+ }
31
+ const headers = await context.createHeaders("sendNotification", notification.headers);
32
+ headers.set("ServiceBusNotification-Format", notification.platform);
33
+ let body = notification.body;
34
+ let contentType = notification.contentType;
35
+ // Check for direct batch send
36
+ if ((0, optionUtils_js_1.isDirectSendNotificationOptions)(options) && Array.isArray(options.deviceHandle)) {
37
+ endpoint.searchParams.append("direct", "true");
38
+ const boundary = `nh-boundary-${(0, core_util_1.randomUUID)()}`;
39
+ contentType = `multipart/mixed; boundary = "${boundary}"`;
40
+ body = (0, notificationUtils_js_1.createMultipartDirectNotification)(boundary, notification, options.deviceHandle);
41
+ }
42
+ else if ((0, optionUtils_js_1.isDirectSendNotificationOptions)(options)) {
43
+ endpoint.searchParams.append("direct", "true");
44
+ if (notification.platform === "browser") {
45
+ const browserHandle = options.deviceHandle;
46
+ headers.set("ServiceBusNotification-DeviceHandle", browserHandle.endpoint);
47
+ headers.set("Auth", browserHandle.auth);
48
+ headers.set("P256DH", browserHandle.p256dh);
49
+ }
50
+ else {
51
+ headers.set("ServiceBusNotification-DeviceHandle", options.deviceHandle);
52
+ }
53
+ }
54
+ else if ((0, optionUtils_js_1.isSendNotificationOptions)(options)) {
55
+ headers.set("ServiceBusNotification-Tags", options.tagExpression);
56
+ }
57
+ headers.set("Content-Type", contentType);
58
+ headers.set("ServiceBusNotification-Format", notification.platform);
59
+ const request = (0, _client_js_1.createRequest)(endpoint, "POST", headers, updatedOptions);
60
+ request.body = body;
61
+ const response = await (0, _client_js_1.sendRequest)(context, request, 201);
62
+ return (0, _client_js_1.parseNotificationSendResponse)(response);
63
+ });
64
+ }
65
+ //# sourceMappingURL=_sendNotification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_sendNotification.js","sourceRoot":"","sources":["../../../../src/api/internal/_sendNotification.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AA6BlC,4DAqEC;AA3FD,6CAAyF;AACzF,+DAIoC;AAMpC,2EAAqF;AACrF,gDAA8C;AAC9C,uDAAuD;AAEvD;;;;;;GAMG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AAC;QAE1D,OAAO,IAAA,0CAA6B,EAAC,QAAQ,CAAC,CAAC;IACjD,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n BroadcastSendNotificationOptions,\n DirectSendNotificationOptions,\n SendNotificationOptions,\n} from \"../../models/options.js\";\nimport { createRequest, parseNotificationSendResponse, sendRequest } from \"./_client.js\";\nimport {\n isBroadcastSendNotificationOptions,\n isDirectSendNotificationOptions,\n isSendNotificationOptions,\n} from \"../../utils/optionUtils.js\";\nimport { BrowserPushChannel } from \"../../models/installation.js\";\nimport { NonNullableRecord } from \"../../utils/utils.js\";\nimport { Notification } from \"../../models/notification.js\";\nimport { NotificationHubsClientContext } from \"../index.js\";\nimport { NotificationHubsMessageResponse } from \"../../models/notificationDetails.js\";\nimport { createMultipartDirectNotification } from \"../../utils/notificationUtils.js\";\nimport { randomUUID } from \"@azure/core-util\";\nimport { tracingClient } from \"../../utils/tracing.js\";\n\n/**\n * Sends push notifications to devices that match the given tags or tag expression.\n * @param context - The Notification Hubs client.\n * @param notification - The notification to send to the matching devices.\n * @param options - Options for the notification including tags, device handles and whether to enable test send.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\nexport function sendNotificationInternal(\n context: NotificationHubsClientContext,\n notification: Notification,\n options:\n | DirectSendNotificationOptions\n | SendNotificationOptions\n | BroadcastSendNotificationOptions,\n): Promise<NotificationHubsMessageResponse> {\n return tracingClient.withSpan(\n `NotificationHubsClientContext.sendNotification`,\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/messages/\";\n\n // Check if batch direct send\n if (isDirectSendNotificationOptions(options) && Array.isArray(options.deviceHandle)) {\n endpoint.pathname += \"$batch\";\n }\n\n // Check for test send\n if (\n (isSendNotificationOptions(options) || isBroadcastSendNotificationOptions(options)) &&\n options.enableTestSend\n ) {\n endpoint.searchParams.append(\"test\", \"true\");\n }\n\n const headers = await context.createHeaders(\n \"sendNotification\",\n notification.headers as NonNullableRecord,\n );\n headers.set(\"ServiceBusNotification-Format\", notification.platform);\n\n let body = notification.body;\n let contentType: string = notification.contentType;\n\n // Check for direct batch send\n if (isDirectSendNotificationOptions(options) && Array.isArray(options.deviceHandle)) {\n endpoint.searchParams.append(\"direct\", \"true\");\n const boundary = `nh-boundary-${randomUUID()}`;\n contentType = `multipart/mixed; boundary = \"${boundary}\"`;\n body = createMultipartDirectNotification(boundary, notification, options.deviceHandle);\n } else if (isDirectSendNotificationOptions(options)) {\n endpoint.searchParams.append(\"direct\", \"true\");\n\n if (notification.platform === \"browser\") {\n const browserHandle = options.deviceHandle as BrowserPushChannel;\n headers.set(\"ServiceBusNotification-DeviceHandle\", browserHandle.endpoint);\n headers.set(\"Auth\", browserHandle.auth);\n headers.set(\"P256DH\", browserHandle.p256dh);\n } else {\n headers.set(\"ServiceBusNotification-DeviceHandle\", options.deviceHandle as string);\n }\n } else if (isSendNotificationOptions(options)) {\n headers.set(\"ServiceBusNotification-Tags\", options.tagExpression);\n }\n\n headers.set(\"Content-Type\", contentType);\n headers.set(\"ServiceBusNotification-Format\", notification.platform);\n\n const request = createRequest(endpoint, \"POST\", headers, updatedOptions);\n request.body = body;\n\n const response = await sendRequest(context, request, 201);\n\n return parseNotificationSendResponse(response);\n },\n );\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { Notification } from "../models/notification.js";
2
+ import { NotificationHubsClientContext } from "./index.js";
3
+ import { NotificationHubsMessageResponse } from "../models/notificationDetails.js";
4
+ import { OperationOptions } from "@azure-rest/core-client";
5
+ /**
6
+ * Schedules a push notification to all registered devices.
7
+ * NOTE: This is only available in Standard SKU Azure Notification Hubs.
8
+ * @param context - The Notification Hubs client.
9
+ * @param scheduledTime - The Date to send the push notification.
10
+ * @param notification - The notification to send to the matching devices.
11
+ * @param options - Operation options.
12
+ * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
13
+ */
14
+ export declare function scheduleBroadcastNotification(context: NotificationHubsClientContext, scheduledTime: Date, notification: Notification, options?: OperationOptions): Promise<NotificationHubsMessageResponse>;
15
+ //# sourceMappingURL=scheduleBroadcastNotification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduleBroadcastNotification.d.ts","sourceRoot":"","sources":["../../../src/api/scheduleBroadcastNotification.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,6BAA6B,EACtC,aAAa,EAAE,IAAI,EACnB,YAAY,EAAE,YAAY,EAC1B,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,+BAA+B,CAAC,CAQ1C"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.scheduleBroadcastNotification = scheduleBroadcastNotification;
6
+ const _scheduleNotification_js_1 = require("./internal/_scheduleNotification.js");
7
+ /**
8
+ * Schedules a push notification to all registered devices.
9
+ * NOTE: This is only available in Standard SKU Azure Notification Hubs.
10
+ * @param context - The Notification Hubs client.
11
+ * @param scheduledTime - The Date to send the push notification.
12
+ * @param notification - The notification to send to the matching devices.
13
+ * @param options - Operation options.
14
+ * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
15
+ */
16
+ function scheduleBroadcastNotification(context, scheduledTime, notification, options = {}) {
17
+ return (0, _scheduleNotification_js_1.scheduleNotificationInternal)(context, scheduledTime, notification, options, "scheduleBroadcastNotification");
18
+ }
19
+ //# sourceMappingURL=scheduleBroadcastNotification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduleBroadcastNotification.js","sourceRoot":"","sources":["../../../src/api/scheduleBroadcastNotification.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAiBlC,sEAaC;AAxBD,kFAAmF;AAEnF;;;;;;;;GAQG;AACH,SAAgB,6BAA6B,CAC3C,OAAsC,EACtC,aAAmB,EACnB,YAA0B,EAC1B,UAA4B,EAAE;IAE9B,OAAO,IAAA,uDAA4B,EACjC,OAAO,EACP,aAAa,EACb,YAAY,EACZ,OAAO,EACP,+BAA+B,CAChC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/notificationDetails.js\";\nimport { OperationOptions } from \"@azure-rest/core-client\";\nimport { scheduleNotificationInternal } from \"./internal/_scheduleNotification.js\";\n\n/**\n * Schedules a push notification to all registered devices.\n * NOTE: This is only available in Standard SKU Azure Notification Hubs.\n * @param context - The Notification Hubs client.\n * @param scheduledTime - The Date to send the push notification.\n * @param notification - The notification to send to the matching devices.\n * @param options - Operation options.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\nexport function scheduleBroadcastNotification(\n context: NotificationHubsClientContext,\n scheduledTime: Date,\n notification: Notification,\n options: OperationOptions = {},\n): Promise<NotificationHubsMessageResponse> {\n return scheduleNotificationInternal(\n context,\n scheduledTime,\n notification,\n options,\n \"scheduleBroadcastNotification\",\n );\n}\n"]}
@@ -11,5 +11,5 @@ import { ScheduleNotificationOptions } from "../models/options.js";
11
11
  * @param options - Options which include tags used to target the device for push notifications in either an array or tag expression.
12
12
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
13
13
  */
14
- export declare function scheduleNotification(context: NotificationHubsClientContext, scheduledTime: Date, notification: Notification, options?: ScheduleNotificationOptions): Promise<NotificationHubsMessageResponse>;
14
+ export declare function scheduleNotification(context: NotificationHubsClientContext, scheduledTime: Date, notification: Notification, options: ScheduleNotificationOptions): Promise<NotificationHubsMessageResponse>;
15
15
  //# sourceMappingURL=scheduleNotification.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scheduleNotification.d.ts","sourceRoot":"","sources":["../../../src/api/scheduleNotification.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAGnE;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,6BAA6B,EACtC,aAAa,EAAE,IAAI,EACnB,YAAY,EAAE,YAAY,EAC1B,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,+BAA+B,CAAC,CA4B1C"}
1
+ {"version":3,"file":"scheduleNotification.d.ts","sourceRoot":"","sources":["../../../src/api/scheduleNotification.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAGnE;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,6BAA6B,EACtC,aAAa,EAAE,IAAI,EACnB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,+BAA+B,CAAC,CAS1C"}
@@ -3,8 +3,7 @@
3
3
  // Licensed under the MIT License.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.scheduleNotification = scheduleNotification;
6
- const _client_js_1 = require("./internal/_client.js");
7
- const tracing_js_1 = require("../utils/tracing.js");
6
+ const _scheduleNotification_js_1 = require("./internal/_scheduleNotification.js");
8
7
  /**
9
8
  * Schedules a push notification to devices that match the given tags or tag expression at the specified time.
10
9
  * NOTE: This is only available in Standard SKU Azure Notification Hubs.
@@ -14,21 +13,7 @@ const tracing_js_1 = require("../utils/tracing.js");
14
13
  * @param options - Options which include tags used to target the device for push notifications in either an array or tag expression.
15
14
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
16
15
  */
17
- function scheduleNotification(context, scheduledTime, notification, options = {}) {
18
- return tracing_js_1.tracingClient.withSpan(`NotificationHubsClientContext.scheduleNotification`, options, async (updatedOptions) => {
19
- const endpoint = context.requestUrl();
20
- endpoint.pathname += "/schedulednotifications/";
21
- const headers = await context.createHeaders("scheduleNotification", notification.headers);
22
- headers.set("ServiceBusNotification-ScheduleTime", scheduledTime.toISOString());
23
- headers.set("Content-Type", notification.contentType);
24
- headers.set("ServiceBusNotification-Format", notification.platform);
25
- if (options.tagExpression) {
26
- headers.set("ServiceBusNotification-Tags", options.tagExpression);
27
- }
28
- const request = (0, _client_js_1.createRequest)(endpoint, "POST", headers, updatedOptions);
29
- request.body = notification.body;
30
- const response = await (0, _client_js_1.sendRequest)(context, request, 201);
31
- return (0, _client_js_1.parseNotificationSendResponse)(response);
32
- });
16
+ function scheduleNotification(context, scheduledTime, notification, options) {
17
+ return (0, _scheduleNotification_js_1.scheduleNotificationInternal)(context, scheduledTime, notification, options, "scheduleNotification", options.tagExpression);
33
18
  }
34
19
  //# sourceMappingURL=scheduleNotification.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scheduleNotification.js","sourceRoot":"","sources":["../../../src/api/scheduleNotification.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAmBlC,oDAiCC;AAlDD,sDAAkG;AAMlG,oDAAoD;AAEpD;;;;;;;;GAQG;AACH,SAAgB,oBAAoB,CAClC,OAAsC,EACtC,aAAmB,EACnB,YAA0B,EAC1B,UAAuC,EAAE;IAEzC,OAAO,0BAAa,CAAC,QAAQ,CAC3B,oDAAoD,EACpD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,0BAA0B,CAAC;QAEhD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CACzC,sBAAsB,EACtB,YAAY,CAAC,OAA4B,CAC1C,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;QAChF,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;QAEpE,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;YAC1B,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;QACpE,CAAC;QAED,MAAM,OAAO,GAAG,IAAA,0BAAa,EAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACzE,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;QAEjC,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAW,EAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,OAAO,IAAA,0CAA6B,EAAC,QAAQ,CAAC,CAAC;IACjD,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createRequest, parseNotificationSendResponse, sendRequest } from \"./internal/_client.js\";\nimport { NonNullableRecord } from \"../utils/utils.js\";\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/notificationDetails.js\";\nimport { ScheduleNotificationOptions } from \"../models/options.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\n/**\n * Schedules a push notification to devices that match the given tags or tag expression at the specified time.\n * NOTE: This is only available in Standard SKU Azure Notification Hubs.\n * @param context - The Notification Hubs client.\n * @param scheduledTime - The Date to send the push notification.\n * @param notification - The notification to send to the matching devices.\n * @param options - Options which include tags used to target the device for push notifications in either an array or tag expression.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\nexport function scheduleNotification(\n context: NotificationHubsClientContext,\n scheduledTime: Date,\n notification: Notification,\n options: ScheduleNotificationOptions = {},\n): Promise<NotificationHubsMessageResponse> {\n return tracingClient.withSpan(\n `NotificationHubsClientContext.scheduleNotification`,\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/schedulednotifications/\";\n\n const headers = await context.createHeaders(\n \"scheduleNotification\",\n notification.headers as NonNullableRecord,\n );\n headers.set(\"ServiceBusNotification-ScheduleTime\", scheduledTime.toISOString());\n headers.set(\"Content-Type\", notification.contentType);\n headers.set(\"ServiceBusNotification-Format\", notification.platform);\n\n if (options.tagExpression) {\n headers.set(\"ServiceBusNotification-Tags\", options.tagExpression);\n }\n\n const request = createRequest(endpoint, \"POST\", headers, updatedOptions);\n request.body = notification.body;\n\n const response = await sendRequest(context, request, 201);\n\n return parseNotificationSendResponse(response);\n },\n );\n}\n"]}
1
+ {"version":3,"file":"scheduleNotification.js","sourceRoot":"","sources":["../../../src/api/scheduleNotification.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAiBlC,oDAcC;AAzBD,kFAAmF;AAEnF;;;;;;;;GAQG;AACH,SAAgB,oBAAoB,CAClC,OAAsC,EACtC,aAAmB,EACnB,YAA0B,EAC1B,OAAoC;IAEpC,OAAO,IAAA,uDAA4B,EACjC,OAAO,EACP,aAAa,EACb,YAAY,EACZ,OAAO,EACP,sBAAsB,EACtB,OAAO,CAAC,aAAa,CACtB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/notificationDetails.js\";\nimport { ScheduleNotificationOptions } from \"../models/options.js\";\nimport { scheduleNotificationInternal } from \"./internal/_scheduleNotification.js\";\n\n/**\n * Schedules a push notification to devices that match the given tags or tag expression at the specified time.\n * NOTE: This is only available in Standard SKU Azure Notification Hubs.\n * @param context - The Notification Hubs client.\n * @param scheduledTime - The Date to send the push notification.\n * @param notification - The notification to send to the matching devices.\n * @param options - Options which include tags used to target the device for push notifications in either an array or tag expression.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\nexport function scheduleNotification(\n context: NotificationHubsClientContext,\n scheduledTime: Date,\n notification: Notification,\n options: ScheduleNotificationOptions,\n): Promise<NotificationHubsMessageResponse> {\n return scheduleNotificationInternal(\n context,\n scheduledTime,\n notification,\n options,\n \"scheduleNotification\",\n options.tagExpression,\n );\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { BroadcastSendNotificationOptions } from "../models/options.js";
2
+ import { Notification } from "../models/notification.js";
3
+ import { NotificationHubsClientContext } from "./index.js";
4
+ import { NotificationHubsMessageResponse } from "../models/notificationDetails.js";
5
+ /**
6
+ * Sends push notifications to all devices with a broadcast send.
7
+ * @param context - The Notification Hubs client.
8
+ * @param notification - The notification to send to the matching devices.
9
+ * @param options - Options for the notification including whether to enable test send.
10
+ * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
11
+ */
12
+ export declare function sendBroadcastNotification(context: NotificationHubsClientContext, notification: Notification, options?: BroadcastSendNotificationOptions): Promise<NotificationHubsMessageResponse>;
13
+ //# sourceMappingURL=sendBroadcastNotification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendBroadcastNotification.d.ts","sourceRoot":"","sources":["../../../src/api/sendBroadcastNotification.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AAGnF;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,6BAA6B,EACtC,YAAY,EAAE,YAAY,EAC1B,OAAO,GAAE,gCAAqC,GAC7C,OAAO,CAAC,+BAA+B,CAAC,CAE1C"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.sendBroadcastNotification = sendBroadcastNotification;
6
+ const _sendNotification_js_1 = require("./internal/_sendNotification.js");
7
+ /**
8
+ * Sends push notifications to all devices with a broadcast send.
9
+ * @param context - The Notification Hubs client.
10
+ * @param notification - The notification to send to the matching devices.
11
+ * @param options - Options for the notification including whether to enable test send.
12
+ * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
13
+ */
14
+ function sendBroadcastNotification(context, notification, options = {}) {
15
+ return (0, _sendNotification_js_1.sendNotificationInternal)(context, notification, options);
16
+ }
17
+ //# sourceMappingURL=sendBroadcastNotification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendBroadcastNotification.js","sourceRoot":"","sources":["../../../src/api/sendBroadcastNotification.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAelC,8DAMC;AAfD,0EAA2E;AAE3E;;;;;;GAMG;AACH,SAAgB,yBAAyB,CACvC,OAAsC,EACtC,YAA0B,EAC1B,UAA4C,EAAE;IAE9C,OAAO,IAAA,+CAAwB,EAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { BroadcastSendNotificationOptions } from \"../models/options.js\";\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/notificationDetails.js\";\nimport { sendNotificationInternal } from \"./internal/_sendNotification.js\";\n\n/**\n * Sends push notifications to all devices with a broadcast send.\n * @param context - The Notification Hubs client.\n * @param notification - The notification to send to the matching devices.\n * @param options - Options for the notification including whether to enable test send.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\nexport function sendBroadcastNotification(\n context: NotificationHubsClientContext,\n notification: Notification,\n options: BroadcastSendNotificationOptions = {},\n): Promise<NotificationHubsMessageResponse> {\n return sendNotificationInternal(context, notification, options);\n}\n"]}
@@ -9,5 +9,5 @@ import { NotificationHubsMessageResponse } from "../models/notificationDetails.j
9
9
  * @param options - Options for the notification including tags, device handles and whether to enable test send.
10
10
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
11
11
  */
12
- export declare function sendNotification(context: NotificationHubsClientContext, notification: Notification, options?: DirectSendNotificationOptions | SendNotificationOptions): Promise<NotificationHubsMessageResponse>;
12
+ export declare function sendNotification(context: NotificationHubsClientContext, notification: Notification, options: DirectSendNotificationOptions | SendNotificationOptions): Promise<NotificationHubsMessageResponse>;
13
13
  //# sourceMappingURL=sendNotification.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sendNotification.d.ts","sourceRoot":"","sources":["../../../src/api/sendNotification.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAQ9F,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AAKnF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,6BAA6B,EACtC,YAAY,EAAE,YAAY,EAC1B,OAAO,GAAE,6BAA6B,GAAG,uBAAmD,GAC3F,OAAO,CAAC,+BAA+B,CAAC,CA6D1C"}
1
+ {"version":3,"file":"sendNotification.d.ts","sourceRoot":"","sources":["../../../src/api/sendNotification.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AAGnF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,6BAA6B,EACtC,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,6BAA6B,GAAG,uBAAuB,GAC/D,OAAO,CAAC,+BAA+B,CAAC,CAE1C"}
@@ -3,11 +3,7 @@
3
3
  // Licensed under the MIT License.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.sendNotification = sendNotification;
6
- const _client_js_1 = require("./internal/_client.js");
7
- const optionUtils_js_1 = require("../utils/optionUtils.js");
8
- const notificationUtils_js_1 = require("../utils/notificationUtils.js");
9
- const core_util_1 = require("@azure/core-util");
10
- const tracing_js_1 = require("../utils/tracing.js");
6
+ const _sendNotification_js_1 = require("./internal/_sendNotification.js");
11
7
  /**
12
8
  * Sends push notifications to devices that match the given tags or tag expression.
13
9
  * @param context - The Notification Hubs client.
@@ -15,52 +11,7 @@ const tracing_js_1 = require("../utils/tracing.js");
15
11
  * @param options - Options for the notification including tags, device handles and whether to enable test send.
16
12
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
17
13
  */
18
- function sendNotification(context, notification, options = { enableTestSend: false }) {
19
- return tracing_js_1.tracingClient.withSpan(`NotificationHubsClientContext.sendNotification`, options, async (updatedOptions) => {
20
- const endpoint = context.requestUrl();
21
- endpoint.pathname += "/messages/";
22
- // Check if batch direct send
23
- if ((0, optionUtils_js_1.isDirectSendNotificationOptions)(options) && Array.isArray(options.deviceHandle)) {
24
- endpoint.pathname += "$batch";
25
- }
26
- // Check for test send
27
- if ((0, optionUtils_js_1.isSendNotificationOptions)(options) && options.enableTestSend) {
28
- endpoint.searchParams.append("test", "true");
29
- }
30
- const headers = await context.createHeaders("sendNotification", notification.headers);
31
- headers.set("ServiceBusNotification-Format", notification.platform);
32
- let body = notification.body;
33
- let contentType = notification.contentType;
34
- // Check for direct batch send
35
- if ((0, optionUtils_js_1.isDirectSendNotificationOptions)(options) && Array.isArray(options.deviceHandle)) {
36
- endpoint.searchParams.append("direct", "true");
37
- const boundary = `nh-boundary-${(0, core_util_1.randomUUID)()}`;
38
- contentType = `multipart/mixed; boundary = "${boundary}"`;
39
- body = (0, notificationUtils_js_1.createMultipartDirectNotification)(boundary, notification, options.deviceHandle);
40
- }
41
- else if ((0, optionUtils_js_1.isDirectSendNotificationOptions)(options)) {
42
- endpoint.searchParams.append("direct", "true");
43
- if (notification.platform === "browser") {
44
- const browserHandle = options.deviceHandle;
45
- headers.set("ServiceBusNotification-DeviceHandle", browserHandle.endpoint);
46
- headers.set("Auth", browserHandle.auth);
47
- headers.set("P256DH", browserHandle.p256dh);
48
- }
49
- else {
50
- headers.set("ServiceBusNotification-DeviceHandle", options.deviceHandle);
51
- }
52
- }
53
- else if ((0, optionUtils_js_1.isSendNotificationOptions)(options)) {
54
- if (options.tagExpression) {
55
- headers.set("ServiceBusNotification-Tags", options.tagExpression);
56
- }
57
- }
58
- headers.set("Content-Type", contentType);
59
- headers.set("ServiceBusNotification-Format", notification.platform);
60
- const request = (0, _client_js_1.createRequest)(endpoint, "POST", headers, updatedOptions);
61
- request.body = body;
62
- const response = await (0, _client_js_1.sendRequest)(context, request, 201);
63
- return (0, _client_js_1.parseNotificationSendResponse)(response);
64
- });
14
+ function sendNotification(context, notification, options) {
15
+ return (0, _sendNotification_js_1.sendNotificationInternal)(context, notification, options);
65
16
  }
66
17
  //# sourceMappingURL=sendNotification.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sendNotification.js","sourceRoot":"","sources":["../../../src/api/sendNotification.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAwBlC,4CAiEC;AAtFD,sDAAkG;AAClG,4DAGiC;AAMjC,wEAAkF;AAClF,gDAA8C;AAC9C,oDAAoD;AAEpD;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAC9B,OAAsC,EACtC,YAA0B,EAC1B,UAAmE,EAAE,cAAc,EAAE,KAAK,EAAE;IAE5F,OAAO,0BAAa,CAAC,QAAQ,CAC3B,gDAAgD,EAChD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,YAAY,CAAC;QAElC,6BAA6B;QAC7B,IAAI,IAAA,gDAA+B,EAAC,OAAO,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YACpF,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC;QAChC,CAAC;QAED,sBAAsB;QACtB,IAAI,IAAA,0CAAyB,EAAC,OAAO,CAAC,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YACjE,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/C,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CACzC,kBAAkB,EAClB,YAAY,CAAC,OAA4B,CAC1C,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;QAEpE,IAAI,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;QAC7B,IAAI,WAAW,GAAW,YAAY,CAAC,WAAW,CAAC;QAEnD,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AAc,EAAE,WAAW,CAAC,CAAC;QACzC,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;QAEpE,MAAM,OAAO,GAAG,IAAA,0BAAa,EAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACzE,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QAEpB,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAW,EAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,OAAO,IAAA,0CAA6B,EAAC,QAAQ,CAAC,CAAC;IACjD,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { DirectSendNotificationOptions, SendNotificationOptions } from \"../models/options.js\";\nimport { createRequest, parseNotificationSendResponse, sendRequest } from \"./internal/_client.js\";\nimport {\n isDirectSendNotificationOptions,\n isSendNotificationOptions,\n} from \"../utils/optionUtils.js\";\nimport { BrowserPushChannel } from \"../models/installation.js\";\nimport { NonNullableRecord } from \"../utils/utils.js\";\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/notificationDetails.js\";\nimport { createMultipartDirectNotification } from \"../utils/notificationUtils.js\";\nimport { randomUUID } from \"@azure/core-util\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\n/**\n * Sends push notifications to devices that match the given tags or tag expression.\n * @param context - The Notification Hubs client.\n * @param notification - The notification to send to the matching devices.\n * @param options - Options for the notification including tags, device handles and whether to enable test send.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\nexport function sendNotification(\n context: NotificationHubsClientContext,\n notification: Notification,\n options: DirectSendNotificationOptions | SendNotificationOptions = { enableTestSend: false },\n): Promise<NotificationHubsMessageResponse> {\n return tracingClient.withSpan(\n `NotificationHubsClientContext.sendNotification`,\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/messages/\";\n\n // Check if batch direct send\n if (isDirectSendNotificationOptions(options) && Array.isArray(options.deviceHandle)) {\n endpoint.pathname += \"$batch\";\n }\n\n // Check for test send\n if (isSendNotificationOptions(options) && options.enableTestSend) {\n endpoint.searchParams.append(\"test\", \"true\");\n }\n\n const headers = await context.createHeaders(\n \"sendNotification\",\n notification.headers as NonNullableRecord,\n );\n headers.set(\"ServiceBusNotification-Format\", notification.platform);\n\n let body = notification.body;\n let contentType: string = notification.contentType;\n\n // Check for direct batch send\n if (isDirectSendNotificationOptions(options) && Array.isArray(options.deviceHandle)) {\n endpoint.searchParams.append(\"direct\", \"true\");\n const boundary = `nh-boundary-${randomUUID()}`;\n contentType = `multipart/mixed; boundary = \"${boundary}\"`;\n body = createMultipartDirectNotification(boundary, notification, options.deviceHandle);\n } else if (isDirectSendNotificationOptions(options)) {\n endpoint.searchParams.append(\"direct\", \"true\");\n\n if (notification.platform === \"browser\") {\n const browserHandle = options.deviceHandle as BrowserPushChannel;\n headers.set(\"ServiceBusNotification-DeviceHandle\", browserHandle.endpoint);\n headers.set(\"Auth\", browserHandle.auth);\n headers.set(\"P256DH\", browserHandle.p256dh);\n } else {\n headers.set(\"ServiceBusNotification-DeviceHandle\", options.deviceHandle as string);\n }\n } else if (isSendNotificationOptions(options)) {\n if (options.tagExpression) {\n headers.set(\"ServiceBusNotification-Tags\", options.tagExpression);\n }\n }\n\n headers.set(\"Content-Type\", contentType);\n headers.set(\"ServiceBusNotification-Format\", notification.platform);\n\n const request = createRequest(endpoint, \"POST\", headers, updatedOptions);\n request.body = body;\n\n const response = await sendRequest(context, request, 201);\n\n return parseNotificationSendResponse(response);\n },\n );\n}\n"]}
1
+ {"version":3,"file":"sendNotification.js","sourceRoot":"","sources":["../../../src/api/sendNotification.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAelC,4CAMC;AAfD,0EAA2E;AAE3E;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAC9B,OAAsC,EACtC,YAA0B,EAC1B,OAAgE;IAEhE,OAAO,IAAA,+CAAwB,EAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { DirectSendNotificationOptions, SendNotificationOptions } from \"../models/options.js\";\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/notificationDetails.js\";\nimport { sendNotificationInternal } from \"./internal/_sendNotification.js\";\n\n/**\n * Sends push notifications to devices that match the given tags or tag expression.\n * @param context - The Notification Hubs client.\n * @param notification - The notification to send to the matching devices.\n * @param options - Options for the notification including tags, device handles and whether to enable test send.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\nexport function sendNotification(\n context: NotificationHubsClientContext,\n notification: Notification,\n options: DirectSendNotificationOptions | SendNotificationOptions,\n): Promise<NotificationHubsMessageResponse> {\n return sendNotificationInternal(context, notification, options);\n}\n"]}
@@ -15,29 +15,32 @@ export interface PolledOperationOptions extends OperationOptions {
15
15
  updateIntervalInMs?: number;
16
16
  }
17
17
  /**
18
- * Options for sending notifications for both tag based send and broadcast scheduled send.
18
+ * Options for sending notifications for both tag based scheduled send.
19
19
  */
20
20
  export interface ScheduleNotificationOptions extends OperationOptions {
21
21
  /**
22
22
  * A tag expression used to target devices. Use the `createTagExpression` function to create a tag expression from an array of tags.
23
- * If not set, this results in a broadcast notification to be scheduled.
24
23
  */
25
- tagExpression?: string;
24
+ tagExpression: string;
26
25
  }
27
26
  /**
28
- * Options for sending notifications for both tag based send and broadcast send.
27
+ * Options for sending notifications for test send.
29
28
  */
30
- export interface SendNotificationOptions extends OperationOptions {
31
- /**
32
- * A tag expression used to target devices. Use the `createTagExpression` function to create a tag expression from an array of tags.
33
- * If not set, this results in a broadcast notification to be sent.
34
- */
35
- tagExpression?: string;
29
+ export interface BroadcastSendNotificationOptions extends OperationOptions {
36
30
  /**
37
31
  * Set to true to enable test send.
38
32
  */
39
33
  enableTestSend?: boolean;
40
34
  }
35
+ /**
36
+ * Options for sending notifications for tag based send.
37
+ */
38
+ export interface SendNotificationOptions extends BroadcastSendNotificationOptions {
39
+ /**
40
+ * A tag expression used to target devices. Use the `createTagExpression` function to create a tag expression from an array of tags.
41
+ */
42
+ tagExpression: string;
43
+ }
41
44
  /**
42
45
  * Options for sending notifications to individual devices.
43
46
  */
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/models/options.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,6BAA8B,SAAQ,aAAa;CAAG;AAEvE;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,gBAAgB;IACnE;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;IAC/D;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,6BAA8B,SAAQ,gBAAgB;IACrE;;OAEG;IACH,YAAY,EAAE,MAAM,GAAG,kBAAkB,GAAG,MAAM,EAAE,CAAC;CACtD;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,6B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W,wBAAyB,SAAQ,6BAA6B;IAC7E;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/models/options.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { ClientOptions, OperationOptions } from \"@azure-rest/core-client\";\nimport { BrowserPushChannel } from \"./installation.js\";\n\n/**\n * Describes the options that can be provided while creating the NotificationHubsClientContext.\n */\nexport interface NotificationHubsClientOptions extends ClientOptions {}\n\n/**\n * Options for polled operations including the polling interval cycle.\n */\nexport interface PolledOperationOptions extends OperationOptions {\n /**\n * Time delay between poll requests, in milliseconds.\n */\n updateIntervalInMs?: number;\n}\n\n/**\n * Options for sending notifications for both tag based send and broadcast scheduled send.\n */\nexport interface ScheduleNotificationOptions extends OperationOptions {\n /**\n * A tag expression used to target devices. Use the `createTagExpression` function to create a tag expression from an array of tags.\n * If not set, this results in a broadcast notification to be scheduled.\n */\n tagExpression?: string;\n}\n\n/**\n * Options for sending notifications for both tag based send and broadcast send.\n */\nexport interface SendNotificationOptions extends OperationOptions {\n /**\n * A tag expression used to target devices. Use the `createTagExpression` function to create a tag expression from an array of tags.\n * If not set, this results in a broadcast notification to be sent.\n */\n tagExpression?: string;\n /**\n * Set to true to enable test send.\n */\n enableTestSend?: boolean;\n}\n\n/**\n * Options for sending notifications to individual devices.\n */\nexport interface DirectSendNotificationOptions extends OperationOptions {\n /**\n * The device handle to send the notification. If an array is provided, this uses batch direct send which is only available in Standard SKU and above.\n */\n deviceHandle: string | BrowserPushChannel | string[];\n}\n\n/**\n * Represents entity update operation options that can be set.\n */\nexport interface EntityOperationOptions extends OperationOptions {\n /**\n * ETag as returned by creation, update, and retrieval, or ‘*’ (overwrite).\n */\n etag?: string;\n}\n\n/**\n * Represents query options to include $top support.\n */\nexport interface RegistrationQueryLimitOptions extends OperationOptions {\n /**\n * The $top query member to get a number of records.\n */\n top?: number;\n}\n\n/**\n * Represents query options to include both $top and $filter.\n */\nexport interface RegistrationQueryOptions extends RegistrationQueryLimitOptions {\n /**\n * The OData $filter operator query string.\n */\n filter?: string;\n}\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/models/options.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { ClientOptions, OperationOptions } from \"@azure-rest/core-client\";\nimport { BrowserPushChannel } from \"./installation.js\";\n\n/**\n * Describes the options that can be provided while creating the NotificationHubsClientContext.\n */\nexport interface NotificationHubsClientOptions extends ClientOptions {}\n\n/**\n * Options for polled operations including the polling interval cycle.\n */\nexport interface PolledOperationOptions extends OperationOptions {\n /**\n * Time delay between poll requests, in milliseconds.\n */\n updateIntervalInMs?: number;\n}\n\n/**\n * Options for sending notifications for both tag based scheduled send.\n */\nexport interface ScheduleNotificationOptions extends OperationOptions {\n /**\n * A tag expression used to target devices. Use the `createTagExpression` function to create a tag expression from an array of tags.\n */\n tagExpression: string;\n}\n\n/**\n * Options for sending notifications for test send.\n */\nexport interface BroadcastSendNotificationOptions extends OperationOptions {\n /**\n * Set to true to enable test send.\n */\n enableTestSend?: boolean;\n}\n\n/**\n * Options for sending notifications for tag based send.\n */\nexport interface SendNotificationOptions extends BroadcastSendNotificationOptions {\n /**\n * A tag expression used to target devices. Use the `createTagExpression` function to create a tag expression from an array of tags.\n */\n tagExpression: string;\n}\n\n/**\n * Options for sending notifications to individual devices.\n */\nexport interface DirectSendNotificationOptions extends OperationOptions {\n /**\n * The device handle to send the notification. If an array is provided, this uses batch direct send which is only available in Standard SKU and above.\n */\n deviceHandle: string | BrowserPushChannel | string[];\n}\n\n/**\n * Represents entity update operation options that can be set.\n */\nexport interface EntityOperationOptions extends OperationOptions {\n /**\n * ETag as returned by creation, update, and retrieval, or ‘*’ (overwrite).\n */\n etag?: string;\n}\n\n/**\n * Represents query options to include $top support.\n */\nexport interface RegistrationQueryLimitOptions extends OperationOptions {\n /**\n * The $top query member to get a number of records.\n */\n top?: number;\n}\n\n/**\n * Represents query options to include both $top and $filter.\n */\nexport interface RegistrationQueryOptions extends RegistrationQueryLimitOptions {\n /**\n * The OData $filter operator query string.\n */\n filter?: string;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { DirectSendNotificationOptions, EntityOperationOptions, NotificationHubsClientOptions, PolledOperationOptions, RegistrationQueryLimitOptions, ScheduleNotificationOptions, SendNotificationOptions } from "./models/options.js";
1
+ import { BroadcastSendNotificationOptions, DirectSendNotificationOptions, EntityOperationOptions, NotificationHubsClientOptions, PolledOperationOptions, RegistrationQueryLimitOptions, ScheduleNotificationOptions, SendNotificationOptions } from "./models/options.js";
2
2
  import { Installation, JsonPatch } from "./models/installation.js";
3
3
  import { NotificationDetails, NotificationHubsMessageResponse, NotificationHubsResponse } from "./models/notificationDetails.js";
4
4
  import { NotificationHubJob, NotificationHubJobPoller } from "./models/notificationHubJob.js";
@@ -111,13 +111,29 @@ export declare class NotificationHubsClient {
111
111
  * @returns A paged async iterable containing the matching registrations for the notification hub.
112
112
  */
113
113
  listRegistrationsByTag(tag: string, options?: RegistrationQueryLimitOptions): PagedAsyncIterableIterator<RegistrationDescription>;
114
+ /**
115
+ * Sends push notifications to devices all devices.
116
+ * @param notification - The notification to send to all devices.
117
+ * @param options - Options for the notification including whether to enable test send.
118
+ * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
119
+ */
120
+ sendBroadcastNotification(notification: Notification, options?: BroadcastSendNotificationOptions): Promise<NotificationHubsMessageResponse>;
114
121
  /**
115
122
  * Sends push notifications to devices that match the given tags or tag expression.
116
123
  * @param notification - The notification to send to the matching devices.
117
124
  * @param options - Options for the notification including tags, device handles and whether to enable test send.
118
125
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
119
126
  */
120
- sendNotification(notification: Notification, options?: DirectSendNotificationOptions | SendNotificationOptions): Promise<NotificationHubsMessageResponse>;
127
+ sendNotification(notification: Notification, options: DirectSendNotificationOptions | SendNotificationOptions): Promise<NotificationHubsMessageResponse>;
128
+ /**
129
+ * Schedules a push notification to all devices at the specified time.
130
+ * NOTE: This is only available in Standard SKU Azure Notification Hubs.
131
+ * @param scheduledTime - The Date to send the push notification.
132
+ * @param notification - The notification to send to the matching devices.
133
+ * @param options - The operation options.
134
+ * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
135
+ */
136
+ scheduleBroadcastNotification(scheduledTime: Date, notification: Notification, options?: OperationOptions): Promise<NotificationHubsMessageResponse>;
121
137
  /**
122
138
  * Schedules a push notification to devices that match the given tags or tag expression at the specified time.
123
139
  * NOTE: This is only available in Standard SKU Azure Notification Hubs.
@@ -126,7 +142,7 @@ export declare class NotificationHubsClient {
126
142
  * @param options - Options which include tags used to target the device for push notifications in either an array or tag expression.
127
143
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
128
144
  */
129
- scheduleNotification(scheduledTime: Date, notification: Notification, options?: ScheduleNotificationOptions): Promise<NotificationHubsMessageResponse>;
145
+ scheduleNotification(scheduledTime: Date, notification: Notification, options: ScheduleNotificationOptions): Promise<NotificationHubsMessageResponse>;
130
146
  /**
131
147
  * Cancels the scheduled notification with the given notification ID.
132
148
  * @param notificationId - The notification ID from the scheduled notification.
@@ -1 +1 @@
1
- {"version":3,"file":"notificationHubsClient.d.ts","sourceRoot":"","sources":["../../src/notificationHubsClient.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,6BAA6B,EAC7B,sBAAsB,EACtB,6BAA6B,EAC7B,2BAA2B,EAC3B,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EACL,mBAAmB,EACnB,+BAA+B,EAC/B,wBAAwB,EACzB,MAAM,iCAAi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B,CAAC;IAI/B;;;;;OAKG;IACH,qBAAqB,CACnB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,kBAAkB,CAAC;IAI9B;;;;;OAKG;IACH,6BAA6B,CAC3B,kBAAkB,EAAE,kBAAkB,EACtC,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,wBAAwB,CAAC;IAIpC;;;;;OAKG;IACH,wBAAwB,CACtB,GAAG,EAAE,kBAAkB,EACvB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,kBAAkB,CAAC;IAI9B;;;;OAIG;IACH,uBAAuB,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;CAGvF"}
@@ -21,7 +21,9 @@ const listNotificationHubJobs_js_1 = require("./api/listNotificationHubJobs.js")
21
21
  const listRegistrationsByChannel_js_1 = require("./api/listRegistrationsByChannel.js");
22
22
  const listRegistrationsByTag_js_1 = require("./api/listRegistrationsByTag.js");
23
23
  const listRegistrations_js_1 = require("./api/listRegistrations.js");
24
+ const scheduleBroadcastNotification_js_1 = require("./api/scheduleBroadcastNotification.js");
24
25
  const scheduleNotification_js_1 = require("./api/scheduleNotification.js");
26
+ const sendBroadcastNotification_js_1 = require("./api/sendBroadcastNotification.js");
25
27
  const sendNotification_js_1 = require("./api/sendNotification.js");
26
28
  const submitNotificationHubJob_js_1 = require("./api/submitNotificationHubJob.js");
27
29
  const updateInstallation_js_1 = require("./api/updateInstallation.js");
@@ -158,15 +160,35 @@ class NotificationHubsClient {
158
160
  listRegistrationsByTag(tag, options = {}) {
159
161
  return (0, listRegistrationsByTag_js_1.listRegistrationsByTag)(this._client, tag, options);
160
162
  }
163
+ /**
164
+ * Sends push notifications to devices all devices.
165
+ * @param notification - The notification to send to all devices.
166
+ * @param options - Options for the notification including whether to enable test send.
167
+ * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
168
+ */
169
+ sendBroadcastNotification(notification, options = {}) {
170
+ return (0, sendBroadcastNotification_js_1.sendBroadcastNotification)(this._client, notification, options);
171
+ }
161
172
  /**
162
173
  * Sends push notifications to devices that match the given tags or tag expression.
163
174
  * @param notification - The notification to send to the matching devices.
164
175
  * @param options - Options for the notification including tags, device handles and whether to enable test send.
165
176
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
166
177
  */
167
- sendNotification(notification, options = { enableTestSend: false }) {
178
+ sendNotification(notification, options) {
168
179
  return (0, sendNotification_js_1.sendNotification)(this._client, notification, options);
169
180
  }
181
+ /**
182
+ * Schedules a push notification to all devices at the specified time.
183
+ * NOTE: This is only available in Standard SKU Azure Notification Hubs.
184
+ * @param scheduledTime - The Date to send the push notification.
185
+ * @param notification - The notification to send to the matching devices.
186
+ * @param options - The operation options.
187
+ * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
188
+ */
189
+ scheduleBroadcastNotification(scheduledTime, notification, options = {}) {
190
+ return (0, scheduleBroadcastNotification_js_1.scheduleBroadcastNotification)(this._client, scheduledTime, notification, options);
191
+ }
170
192
  /**
171
193
  * Schedules a push notification to devices that match the given tags or tag expression at the specified time.
172
194
  * NOTE: This is only available in Standard SKU Azure Notification Hubs.
@@ -175,7 +197,7 @@ class NotificationHubsClient {
175
197
  * @param options - Options which include tags used to target the device for push notifications in either an array or tag expression.
176
198
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
177
199
  */
178
- scheduleNotification(scheduledTime, notification, options = {}) {
200
+ scheduleNotification(scheduledTime, notification, options) {
179
201
  return (0, scheduleNotification_js_1.scheduleNotification)(this._client, scheduledTime, notification, options);
180
202
  }
181
203
  /**