@azure/notification-hubs 2.0.1-alpha.20250619.1 → 2.0.1-alpha.20250729.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 (122) hide show
  1. package/dist/browser/api/beginSubmitNotificationHubJob.js +6 -7
  2. package/dist/browser/api/beginSubmitNotificationHubJob.js.map +1 -1
  3. package/dist/browser/api/clientContext.js +12 -5
  4. package/dist/browser/api/clientContext.js.map +1 -1
  5. package/dist/browser/api/internal/_client.js +21 -4
  6. package/dist/browser/api/internal/_client.js.map +1 -1
  7. package/dist/browser/api/internal/_listRegistrations.js +13 -31
  8. package/dist/browser/api/internal/_listRegistrations.js.map +1 -1
  9. package/dist/browser/api/listRegistrationsByChannel.js +4 -1
  10. package/dist/browser/api/listRegistrationsByChannel.js.map +1 -1
  11. package/dist/browser/api/listRegistrationsByTag.js +13 -31
  12. package/dist/browser/api/listRegistrationsByTag.js.map +1 -1
  13. package/dist/browser/auth/sasTokenCredential.js +4 -0
  14. package/dist/browser/auth/sasTokenCredential.js.map +1 -1
  15. package/dist/browser/models/installation.js +32 -8
  16. package/dist/browser/models/installation.js.map +1 -1
  17. package/dist/browser/models/notification.js +69 -13
  18. package/dist/browser/models/notification.js.map +1 -1
  19. package/dist/browser/models/registration.js +64 -16
  20. package/dist/browser/models/registration.js.map +1 -1
  21. package/dist/browser/notificationHubsClient.js +1 -0
  22. package/dist/browser/notificationHubsClient.js.map +1 -1
  23. package/dist/browser/serializers/notificationDetailsSerializer.js +6 -7
  24. package/dist/browser/serializers/notificationDetailsSerializer.js.map +1 -1
  25. package/dist/browser/serializers/notificationHubJobSerializer.js +4 -5
  26. package/dist/browser/serializers/notificationHubJobSerializer.js.map +1 -1
  27. package/dist/browser/serializers/registrationSerializer.js +185 -48
  28. package/dist/browser/serializers/registrationSerializer.js.map +1 -1
  29. package/dist/browser/utils/xmlUtils.js +1 -1
  30. package/dist/browser/utils/xmlUtils.js.map +1 -1
  31. package/dist/commonjs/api/beginSubmitNotificationHubJob.js +6 -7
  32. package/dist/commonjs/api/beginSubmitNotificationHubJob.js.map +1 -1
  33. package/dist/commonjs/api/clientContext.js +12 -5
  34. package/dist/commonjs/api/clientContext.js.map +1 -1
  35. package/dist/commonjs/api/internal/_client.js +21 -4
  36. package/dist/commonjs/api/internal/_client.js.map +1 -1
  37. package/dist/commonjs/api/internal/_listRegistrations.js +13 -31
  38. package/dist/commonjs/api/internal/_listRegistrations.js.map +1 -1
  39. package/dist/commonjs/api/listRegistrationsByChannel.js +4 -1
  40. package/dist/commonjs/api/listRegistrationsByChannel.js.map +1 -1
  41. package/dist/commonjs/api/listRegistrationsByTag.js +13 -31
  42. package/dist/commonjs/api/listRegistrationsByTag.js.map +1 -1
  43. package/dist/commonjs/auth/sasTokenCredential.js +4 -0
  44. package/dist/commonjs/auth/sasTokenCredential.js.map +1 -1
  45. package/dist/commonjs/models/installation.js +32 -8
  46. package/dist/commonjs/models/installation.js.map +1 -1
  47. package/dist/commonjs/models/notification.js +69 -13
  48. package/dist/commonjs/models/notification.js.map +1 -1
  49. package/dist/commonjs/models/registration.js +64 -16
  50. package/dist/commonjs/models/registration.js.map +1 -1
  51. package/dist/commonjs/notificationHubsClient.js +1 -0
  52. package/dist/commonjs/notificationHubsClient.js.map +1 -1
  53. package/dist/commonjs/serializers/notificationDetailsSerializer.js +6 -7
  54. package/dist/commonjs/serializers/notificationDetailsSerializer.js.map +1 -1
  55. package/dist/commonjs/serializers/notificationHubJobSerializer.js +4 -5
  56. package/dist/commonjs/serializers/notificationHubJobSerializer.js.map +1 -1
  57. package/dist/commonjs/serializers/registrationSerializer.js +185 -48
  58. package/dist/commonjs/serializers/registrationSerializer.js.map +1 -1
  59. package/dist/commonjs/tsdoc-metadata.json +11 -11
  60. package/dist/commonjs/utils/xmlUtils.js +1 -1
  61. package/dist/commonjs/utils/xmlUtils.js.map +1 -1
  62. package/dist/esm/api/beginSubmitNotificationHubJob.js +6 -7
  63. package/dist/esm/api/beginSubmitNotificationHubJob.js.map +1 -1
  64. package/dist/esm/api/clientContext.js +12 -5
  65. package/dist/esm/api/clientContext.js.map +1 -1
  66. package/dist/esm/api/internal/_client.js +21 -4
  67. package/dist/esm/api/internal/_client.js.map +1 -1
  68. package/dist/esm/api/internal/_listRegistrations.js +13 -31
  69. package/dist/esm/api/internal/_listRegistrations.js.map +1 -1
  70. package/dist/esm/api/listRegistrationsByChannel.js +4 -1
  71. package/dist/esm/api/listRegistrationsByChannel.js.map +1 -1
  72. package/dist/esm/api/listRegistrationsByTag.js +13 -31
  73. package/dist/esm/api/listRegistrationsByTag.js.map +1 -1
  74. package/dist/esm/auth/sasTokenCredential.js +4 -0
  75. package/dist/esm/auth/sasTokenCredential.js.map +1 -1
  76. package/dist/esm/models/installation.js +32 -8
  77. package/dist/esm/models/installation.js.map +1 -1
  78. package/dist/esm/models/notification.js +69 -13
  79. package/dist/esm/models/notification.js.map +1 -1
  80. package/dist/esm/models/registration.js +64 -16
  81. package/dist/esm/models/registration.js.map +1 -1
  82. package/dist/esm/notificationHubsClient.js +1 -0
  83. package/dist/esm/notificationHubsClient.js.map +1 -1
  84. package/dist/esm/serializers/notificationDetailsSerializer.js +6 -7
  85. package/dist/esm/serializers/notificationDetailsSerializer.js.map +1 -1
  86. package/dist/esm/serializers/notificationHubJobSerializer.js +4 -5
  87. package/dist/esm/serializers/notificationHubJobSerializer.js.map +1 -1
  88. package/dist/esm/serializers/registrationSerializer.js +185 -48
  89. package/dist/esm/serializers/registrationSerializer.js.map +1 -1
  90. package/dist/esm/utils/xmlUtils.js +1 -1
  91. package/dist/esm/utils/xmlUtils.js.map +1 -1
  92. package/dist/react-native/api/beginSubmitNotificationHubJob.js +6 -7
  93. package/dist/react-native/api/beginSubmitNotificationHubJob.js.map +1 -1
  94. package/dist/react-native/api/clientContext.js +12 -5
  95. package/dist/react-native/api/clientContext.js.map +1 -1
  96. package/dist/react-native/api/internal/_client.js +21 -4
  97. package/dist/react-native/api/internal/_client.js.map +1 -1
  98. package/dist/react-native/api/internal/_listRegistrations.js +13 -31
  99. package/dist/react-native/api/internal/_listRegistrations.js.map +1 -1
  100. package/dist/react-native/api/listRegistrationsByChannel.js +4 -1
  101. package/dist/react-native/api/listRegistrationsByChannel.js.map +1 -1
  102. package/dist/react-native/api/listRegistrationsByTag.js +13 -31
  103. package/dist/react-native/api/listRegistrationsByTag.js.map +1 -1
  104. package/dist/react-native/auth/sasTokenCredential.js +4 -0
  105. package/dist/react-native/auth/sasTokenCredential.js.map +1 -1
  106. package/dist/react-native/models/installation.js +32 -8
  107. package/dist/react-native/models/installation.js.map +1 -1
  108. package/dist/react-native/models/notification.js +69 -13
  109. package/dist/react-native/models/notification.js.map +1 -1
  110. package/dist/react-native/models/registration.js +64 -16
  111. package/dist/react-native/models/registration.js.map +1 -1
  112. package/dist/react-native/notificationHubsClient.js +1 -0
  113. package/dist/react-native/notificationHubsClient.js.map +1 -1
  114. package/dist/react-native/serializers/notificationDetailsSerializer.js +6 -7
  115. package/dist/react-native/serializers/notificationDetailsSerializer.js.map +1 -1
  116. package/dist/react-native/serializers/notificationHubJobSerializer.js +4 -5
  117. package/dist/react-native/serializers/notificationHubJobSerializer.js.map +1 -1
  118. package/dist/react-native/serializers/registrationSerializer.js +185 -48
  119. package/dist/react-native/serializers/registrationSerializer.js.map +1 -1
  120. package/dist/react-native/utils/xmlUtils.js +1 -1
  121. package/dist/react-native/utils/xmlUtils.js.map +1 -1
  122. package/package.json +2 -2
@@ -11,7 +11,6 @@ import { submitNotificationHubJob } from "./submitNotificationHubJob.js";
11
11
  * @returns A poller which can be called to poll until completion of the job.
12
12
  */
13
13
  export async function beginSubmitNotificationHubJob(context, notificationHubJob, polledOperationOptions = {}) {
14
- var _a;
15
14
  let submittedJob = await submitNotificationHubJob(context, notificationHubJob, polledOperationOptions);
16
15
  const state = {
17
16
  status: "notStarted",
@@ -20,7 +19,7 @@ export async function beginSubmitNotificationHubJob(context, notificationHubJob,
20
19
  const processProgressCallbacks = async () => progressCallbacks.forEach((h) => h(state));
21
20
  let resultPromise;
22
21
  const abortController = new AbortController();
23
- const currentPollIntervalInMs = (_a = polledOperationOptions.updateIntervalInMs) !== null && _a !== void 0 ? _a : 2000;
22
+ const currentPollIntervalInMs = polledOperationOptions.updateIntervalInMs ?? 2000;
24
23
  const poller = {
25
24
  async poll(options) {
26
25
  submittedJob = await getNotificationHubJob(context, submittedJob.jobId, options);
@@ -45,18 +44,18 @@ export async function beginSubmitNotificationHubJob(context, notificationHubJob,
45
44
  return state;
46
45
  },
47
46
  pollUntilDone(pollOptions) {
48
- return (resultPromise !== null && resultPromise !== void 0 ? resultPromise : (resultPromise = (async () => {
47
+ return (resultPromise ??= (async () => {
49
48
  const { abortSignal: inputAbortSignal } = pollOptions || {};
50
49
  // In the future we can use AbortSignal.any() instead
51
50
  function abortListener() {
52
51
  abortController.abort();
53
52
  }
54
53
  const abortSignal = abortController.signal;
55
- if (inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.aborted) {
54
+ if (inputAbortSignal?.aborted) {
56
55
  abortController.abort();
57
56
  }
58
57
  else if (!abortSignal.aborted) {
59
- inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.addEventListener("abort", abortListener, { once: true });
58
+ inputAbortSignal?.addEventListener("abort", abortListener, { once: true });
60
59
  }
61
60
  try {
62
61
  if (!poller.isDone) {
@@ -68,7 +67,7 @@ export async function beginSubmitNotificationHubJob(context, notificationHubJob,
68
67
  }
69
68
  }
70
69
  finally {
71
- inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.removeEventListener("abort", abortListener);
70
+ inputAbortSignal?.removeEventListener("abort", abortListener);
72
71
  }
73
72
  switch (state.status) {
74
73
  case "succeeded":
@@ -83,7 +82,7 @@ export async function beginSubmitNotificationHubJob(context, notificationHubJob,
83
82
  }
84
83
  })().finally(() => {
85
84
  resultPromise = undefined;
86
- })));
85
+ }));
87
86
  },
88
87
  onProgress(callback) {
89
88
  const s = Symbol();
@@ -1 +1 @@
1
- {"version":3,"file":"beginSubmitNotificationHubJob.js","sourceRoot":"","sources":["../../../src/api/beginSubmitNotificationHubJob.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,OAAsC,EACtC,kBAAsC,EACtC,yBAAiD,EAAE;;IAEnD,IAAI,YAAY,GAAG,MAAM,wBAAwB,CAC/C,OAAO,EACP,kBAAkB,EAClB,sBAAsB,CACvB,CAAC;IAIF,MAAM,KAAK,GAAuC;QAChD,MAAM,EAAE,YAAY;KACrB,CAAC;IAEF,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAmB,CAAC;IACrD,MAAM,wBAAwB,GAAG,KAAK,IAAmB,EAAE,CACzD,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,IAAI,aAAsD,CAAC;IAC3D,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAC9C,MAAM,uBAAuB,GAAG,MAAA,sBAAsB,CAAC,kBAAkB,mCAAI,IAAI,CAAC;IAElF,MAAM,MAAM,GAAuE;QACjF,KAAK,CAAC,IAAI,CAAC,OAEV;YACC,YAAY,GAAG,MAAM,qBAAqB,CAAC,OAAO,EAAE,YAAY,CAAC,KAAM,EAAE,OAAO,CAAC,CAAC;YAClF,IAAI,YAAY,CAAC,MAAM,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBAC3E,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;YAC3B,CAAC;YAED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MAAM;YACR,OAAO,CAAC,WAAW,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpE,CAAC;QAED,IAAI,cAAc;YAChB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,MAAM;YACR,OAAO,KAAK,CAAC,MAAM,CAAC;QACtB,CAAC;QAED,KAAK,CAAC,SAAS;YACb,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACnC,CAAC;QAED,KAAK,CAAC,SAAS;YACb,QAAQ;YACR,OAAO;QACT,CAAC;QAED,IAAI,CACF,WAGQ,EACR,UAAmF;YAEnF,OAAO,MAAM,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAC9D,CAAC;QACD,KAAK,CACH,UAAmF;YAEnF,OAAO,MAAM,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,CAAC,SAA2C;YACjD,OAAO,MAAM,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC;QACD,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,QAAQ;KAC/B,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { CancelOnProgress, OperationState, PollerLike } from \"@azure/core-lro\";\nimport type { NotificationHubJob, NotificationHubJobPoller } from \"../models/notificationHubJob.js\";\nimport type { NotificationHubsClientContext } from \"./index.js\";\nimport type { PolledOperationOptions } from \"../models/options.js\";\nimport { delay } from \"@azure/core-util\";\nimport { getNotificationHubJob } from \"./getNotificationHubJob.js\";\nimport { submitNotificationHubJob } from \"./submitNotificationHubJob.js\";\n\n/**\n * Submits a Notification Hub job and creates a poller to poll for results.\n * @param context - The Notification Hubs client.\n * @param notificationHubJob - The Notification Hub import/export job to start.\n * @param options - The operation options.\n * @returns A poller which can be called to poll until completion of the job.\n */\nexport async function beginSubmitNotificationHubJob(\n context: NotificationHubsClientContext,\n notificationHubJob: NotificationHubJob,\n polledOperationOptions: PolledOperationOptions = {},\n): Promise<NotificationHubJobPoller> {\n let submittedJob = await submitNotificationHubJob(\n context,\n notificationHubJob,\n polledOperationOptions,\n );\n\n type Handler = (state: OperationState<NotificationHubJob>) => void;\n\n const state: OperationState<NotificationHubJob> = {\n status: \"notStarted\",\n };\n\n const progressCallbacks = new Map<symbol, Handler>();\n const processProgressCallbacks = async (): Promise<void> =>\n progressCallbacks.forEach((h) => h(state));\n let resultPromise: Promise<NotificationHubJob> | undefined;\n const abortController = new AbortController();\n const currentPollIntervalInMs = polledOperationOptions.updateIntervalInMs ?? 2000;\n\n const poller: PollerLike<OperationState<NotificationHubJob>, NotificationHubJob> = {\n async poll(options?: {\n abortSignal?: AbortSignalLike;\n }): Promise<OperationState<NotificationHubJob>> {\n submittedJob = await getNotificationHubJob(context, submittedJob.jobId!, options);\n if (submittedJob.status === \"Running\" || submittedJob.status === \"Started\") {\n state.status = \"running\";\n }\n\n if (submittedJob.status === \"Completed\") {\n state.status = \"succeeded\";\n state.result = submittedJob;\n }\n\n if (submittedJob.status === \"Failed\") {\n state.status = \"failed\";\n state.error = new Error(submittedJob.failure);\n }\n\n await processProgressCallbacks();\n\n if (state.status === \"canceled\") {\n throw new Error(\"Operation was canceled\");\n }\n if (state.status === \"failed\") {\n throw state.error;\n }\n\n return state;\n },\n\n pollUntilDone(pollOptions?: { abortSignal?: AbortSignalLike }): Promise<NotificationHubJob> {\n return (resultPromise ??= (async () => {\n const { abortSignal: inputAbortSignal } = pollOptions || {};\n // In the future we can use AbortSignal.any() instead\n function abortListener(): void {\n abortController.abort();\n }\n const abortSignal = abortController.signal;\n if (inputAbortSignal?.aborted) {\n abortController.abort();\n } else if (!abortSignal.aborted) {\n inputAbortSignal?.addEventListener(\"abort\", abortListener, { once: true });\n }\n\n try {\n if (!poller.isDone) {\n await poller.poll({ abortSignal });\n while (!poller.isDone) {\n await delay(currentPollIntervalInMs, { abortSignal });\n await poller.poll({ abortSignal });\n }\n }\n } finally {\n inputAbortSignal?.removeEventListener(\"abort\", abortListener);\n }\n switch (state.status) {\n case \"succeeded\":\n return poller.result as NotificationHubJob;\n case \"canceled\":\n throw new Error(\"Operation was canceled\");\n case \"failed\":\n throw state.error;\n case \"notStarted\":\n case \"running\":\n throw new Error(`Polling completed without succeeding or failing`);\n }\n })().finally(() => {\n resultPromise = undefined;\n }));\n },\n\n onProgress(callback: (state: OperationState<NotificationHubJob>) => void): CancelOnProgress {\n const s = Symbol();\n progressCallbacks.set(s, callback);\n\n return () => progressCallbacks.delete(s);\n },\n\n get isDone(): boolean {\n return [\"succeeded\", \"failed\", \"canceled\"].includes(state.status);\n },\n\n get operationState(): OperationState<NotificationHubJob> | undefined {\n return state;\n },\n\n get result(): NotificationHubJob | undefined {\n return state.result;\n },\n\n async serialize(): Promise<string> {\n return JSON.stringify({ state });\n },\n\n async submitted() {\n // No-op\n return;\n },\n\n then<TResult1 = NotificationHubJob, TResult2 = never>(\n onfulfilled?:\n | ((value: NotificationHubJob) => TResult1 | PromiseLike<TResult1>)\n | undefined\n | null,\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null,\n ): Promise<TResult1 | TResult2> {\n return poller.pollUntilDone().then(onfulfilled, onrejected);\n },\n catch<TResult2 = never>(\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null,\n ): Promise<NotificationHubJob | TResult2> {\n return poller.pollUntilDone().catch(onrejected);\n },\n finally(onfinally?: (() => void) | undefined | null): Promise<NotificationHubJob> {\n return poller.pollUntilDone().finally(onfinally);\n },\n [Symbol.toStringTag]: \"Poller\",\n };\n\n return poller;\n}\n"]}
1
+ {"version":3,"file":"beginSubmitNotificationHubJob.js","sourceRoot":"","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ACtB,CAAC;QAED,KAAK,CAAC,SAAS;YACb,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACnC,CAAC;QAED,KAAK,CAAC,SAAS;YACb,QAAQ;YACR,OAAO;QACT,CAAC;QAED,IAAI,CACF,WAGQ,EACR,UAAmF;YAEnF,OAAO,MAAM,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAC9D,CAAC;QACD,KAAK,CACH,UAAmF;YAEnF,OAAO,MAAM,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,CAAC,SAA2C;YACjD,OAAO,MAAM,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC;QACD,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,QAAQ;KAC/B,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { CancelOnProgress, OperationState, PollerLike } from \"@azure/core-lro\";\nimport type { NotificationHubJob, NotificationHubJobPoller } from \"../models/notificationHubJob.js\";\nimport type { NotificationHubsClientContext } from \"./index.js\";\nimport type { PolledOperationOptions } from \"../models/options.js\";\nimport { delay } from \"@azure/core-util\";\nimport { getNotificationHubJob } from \"./getNotificationHubJob.js\";\nimport { submitNotificationHubJob } from \"./submitNotificationHubJob.js\";\n\n/**\n * Submits a Notification Hub job and creates a poller to poll for results.\n * @param context - The Notification Hubs client.\n * @param notificationHubJob - The Notification Hub import/export job to start.\n * @param options - The operation options.\n * @returns A poller which can be called to poll until completion of the job.\n */\nexport async function beginSubmitNotificationHubJob(\n context: NotificationHubsClientContext,\n notificationHubJob: NotificationHubJob,\n polledOperationOptions: PolledOperationOptions = {},\n): Promise<NotificationHubJobPoller> {\n let submittedJob = await submitNotificationHubJob(\n context,\n notificationHubJob,\n polledOperationOptions,\n );\n\n type Handler = (state: OperationState<NotificationHubJob>) => void;\n\n const state: OperationState<NotificationHubJob> = {\n status: \"notStarted\",\n };\n\n const progressCallbacks = new Map<symbol, Handler>();\n const processProgressCallbacks = async (): Promise<void> =>\n progressCallbacks.forEach((h) => h(state));\n let resultPromise: Promise<NotificationHubJob> | undefined;\n const abortController = new AbortController();\n const currentPollIntervalInMs = polledOperationOptions.updateIntervalInMs ?? 2000;\n\n const poller: PollerLike<OperationState<NotificationHubJob>, NotificationHubJob> = {\n async poll(options?: {\n abortSignal?: AbortSignalLike;\n }): Promise<OperationState<NotificationHubJob>> {\n submittedJob = await getNotificationHubJob(context, submittedJob.jobId!, options);\n if (submittedJob.status === \"Running\" || submittedJob.status === \"Started\") {\n state.status = \"running\";\n }\n\n if (submittedJob.status === \"Completed\") {\n state.status = \"succeeded\";\n state.result = submittedJob;\n }\n\n if (submittedJob.status === \"Failed\") {\n state.status = \"failed\";\n state.error = new Error(submittedJob.failure);\n }\n\n await processProgressCallbacks();\n\n if (state.status === \"canceled\") {\n throw new Error(\"Operation was canceled\");\n }\n if (state.status === \"failed\") {\n throw state.error;\n }\n\n return state;\n },\n\n pollUntilDone(pollOptions?: { abortSignal?: AbortSignalLike }): Promise<NotificationHubJob> {\n return (resultPromise ??= (async () => {\n const { abortSignal: inputAbortSignal } = pollOptions || {};\n // In the future we can use AbortSignal.any() instead\n function abortListener(): void {\n abortController.abort();\n }\n const abortSignal = abortController.signal;\n if (inputAbortSignal?.aborted) {\n abortController.abort();\n } else if (!abortSignal.aborted) {\n inputAbortSignal?.addEventListener(\"abort\", abortListener, { once: true });\n }\n\n try {\n if (!poller.isDone) {\n await poller.poll({ abortSignal });\n while (!poller.isDone) {\n await delay(currentPollIntervalInMs, { abortSignal });\n await poller.poll({ abortSignal });\n }\n }\n } finally {\n inputAbortSignal?.removeEventListener(\"abort\", abortListener);\n }\n switch (state.status) {\n case \"succeeded\":\n return poller.result as NotificationHubJob;\n case \"canceled\":\n throw new Error(\"Operation was canceled\");\n case \"failed\":\n throw state.error;\n case \"notStarted\":\n case \"running\":\n throw new Error(`Polling completed without succeeding or failing`);\n }\n })().finally(() => {\n resultPromise = undefined;\n }));\n },\n\n onProgress(callback: (state: OperationState<NotificationHubJob>) => void): CancelOnProgress {\n const s = Symbol();\n progressCallbacks.set(s, callback);\n\n return () => progressCallbacks.delete(s);\n },\n\n get isDone(): boolean {\n return [\"succeeded\", \"failed\", \"canceled\"].includes(state.status);\n },\n\n get operationState(): OperationState<NotificationHubJob> | undefined {\n return state;\n },\n\n get result(): NotificationHubJob | undefined {\n return state.result;\n },\n\n async serialize(): Promise<string> {\n return JSON.stringify({ state });\n },\n\n async submitted() {\n // No-op\n return;\n },\n\n then<TResult1 = NotificationHubJob, TResult2 = never>(\n onfulfilled?:\n | ((value: NotificationHubJob) => TResult1 | PromiseLike<TResult1>)\n | undefined\n | null,\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null,\n ): Promise<TResult1 | TResult2> {\n return poller.pollUntilDone().then(onfulfilled, onrejected);\n },\n catch<TResult2 = never>(\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null,\n ): Promise<NotificationHubJob | TResult2> {\n return poller.pollUntilDone().catch(onrejected);\n },\n finally(onfinally?: (() => void) | undefined | null): Promise<NotificationHubJob> {\n return poller.pollUntilDone().finally(onfinally);\n },\n [Symbol.toStringTag]: \"Poller\",\n };\n\n return poller;\n}\n"]}
@@ -15,23 +15,30 @@ export function createClientContext(connectionString, hubName, options = {}) {
15
15
  return new NotificationHubsServiceClient(connectionString, hubName, options);
16
16
  }
17
17
  class NotificationHubsServiceClient {
18
+ sasTokenCredential;
19
+ baseUrl;
20
+ hubName;
21
+ client;
22
+ httpClient;
18
23
  constructor(connectionString, hubName,
19
24
  // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
20
25
  options = {}) {
21
- var _a, _b;
22
26
  this.hubName = hubName;
23
27
  const parsedConnection = parseNotificationHubsConnectionString(connectionString);
24
28
  // Node doesn't allow change in protocol but browsers do, so doing a string replace
25
29
  this.baseUrl = parsedConnection.endpoint.replace("sb://", "https://");
26
30
  this.sasTokenCredential = createTokenCredentialFromConnection(parsedConnection.sharedAccessKey, parsedConnection.sharedAccessKeyName);
27
31
  const packageDetails = `azsdk-js-notificationhubs/${constants.SDK_VERSION}`;
28
- const userAgentPrefix = ((_a = options.userAgentOptions) === null || _a === void 0 ? void 0 : _a.userAgentPrefix)
32
+ const userAgentPrefix = options.userAgentOptions?.userAgentPrefix
29
33
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
30
34
  : `${packageDetails}`;
31
- this.httpClient = (_b = options === null || options === void 0 ? void 0 : options.httpClient) !== null && _b !== void 0 ? _b : createDefaultHttpClient();
32
- this.client = getClient(this.baseUrl, Object.assign({ userAgentOptions: {
35
+ this.httpClient = options?.httpClient ?? createDefaultHttpClient();
36
+ this.client = getClient(this.baseUrl, {
37
+ userAgentOptions: {
33
38
  userAgentPrefix,
34
- } }, options));
39
+ },
40
+ ...options,
41
+ });
35
42
  }
36
43
  async createHeaders(operationName, rawHeaders) {
37
44
  const authorization = await this.sasTokenCredential.getToken(this.baseUrl);
@@ -1 +1 @@
1
- {"version":3,"file":"clientContext.js","sourceRoot":"","sources":["../../../src/api/clientContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AAOnD,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,EACL,mCAAmC,EACnC,qCAAqC,GACtC,MAAM,kCAAkC,CAAC;AAI1C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,WAAW,GAAG,SAAS,CAAC;AAsB9B;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,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YACnB,MAAM,IAAI,SAAS,CAAC,wCAAwC,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;QACrF,CAAC;QAED,MAAM,OAAO,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QACzC,OAAO,CAAC,GAAG,CACT,sBAAsB,EACtB,8CAA8C,aAAa,EAAE,CAC9D,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,WAAW,CAAC,OAAwB;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACpE,CAAC;IAED,UAAU;QACR,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAEjD,OAAO,GAAG,CAAC;IACb,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport * as constants from \"../utils/constants.js\";\nimport type {\n HttpClient,\n HttpHeaders,\n PipelineRequest,\n PipelineResponse,\n} from \"@azure/core-rest-pipeline\";\nimport { RestError, createDefaultHttpClient, createHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport {\n createTokenCredentialFromConnection,\n parseNotificationHubsConnectionString,\n} from \"../auth/connectionStringUtils.js\";\nimport type { NotificationHubsClientOptions } from \"../models/options.js\";\nimport type { SasTokenCredential } from \"../auth/sasTokenCredential.js\";\nimport type { Client } from \"@azure-rest/core-client\";\nimport { getClient } from \"@azure-rest/core-client\";\n\nconst API_VERSION = \"2020-06\";\n\n/**\n * Represents the Notification Hubs SDK client context.\n */\nexport interface NotificationHubsClientContext {\n /**\n * @internal\n */\n sendRequest(request: PipelineRequest): Promise<PipelineResponse>;\n\n /**\n * @internal\n */\n createHeaders(operationName: string, rawHeaders?: Record<string, string>): Promise<HttpHeaders>;\n\n /**\n * @internal\n */\n requestUrl(): URL;\n}\n\n/**\n * Creates a NotificationHubClient from the Access Policy connection string and hub name.\n * @param connectionString - The Access Policy connection string for the notification hub.\n * @param hubName - The notification hub name.\n * @returns A NotificationHubsClientContext initialized from the connection string and hub name.\n */\nexport function createClientContext(\n connectionString: string,\n hubName: string,\n options: NotificationHubsClientOptions = {},\n): NotificationHubsClientContext {\n return new NotificationHubsServiceClient(connectionString, hubName, options);\n}\n\nclass NotificationHubsServiceClient implements NotificationHubsClientContext {\n sasTokenCredential: SasTokenCredential;\n baseUrl: string;\n hubName: string;\n client: Client;\n httpClient: HttpClient;\n\n constructor(\n connectionString: string,\n hubName: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: NotificationHubsClientOptions = {},\n ) {\n this.hubName = hubName;\n\n const parsedConnection = parseNotificationHubsConnectionString(connectionString);\n // Node doesn't allow change in protocol but browsers do, so doing a string replace\n this.baseUrl = parsedConnection.endpoint.replace(\"sb://\", \"https://\");\n this.sasTokenCredential = createTokenCredentialFromConnection(\n parsedConnection.sharedAccessKey,\n parsedConnection.sharedAccessKeyName,\n );\n\n const packageDetails = `azsdk-js-notificationhubs/${constants.SDK_VERSION}`;\n const userAgentPrefix = options.userAgentOptions?.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n this.httpClient = options?.httpClient ?? createDefaultHttpClient();\n this.client = getClient(this.baseUrl, {\n userAgentOptions: {\n userAgentPrefix,\n },\n ...options,\n });\n }\n\n async createHeaders(\n operationName: string,\n rawHeaders?: Record<string, string>,\n ): Promise<HttpHeaders> {\n const authorization = await this.sasTokenCredential.getToken(this.baseUrl);\n if (!authorization) {\n throw new RestError(\"Failed to get the authorization header\", { statusCode: 401 });\n }\n\n const headers = createHttpHeaders(rawHeaders);\n headers.set(\"Authorization\", authorization.token);\n headers.set(\"x-ms-version\", API_VERSION);\n headers.set(\n \"x-ms-azsdk-telemetry\",\n `class=NotificationHubsServiceClient;method=${operationName}`,\n );\n\n return headers;\n }\n\n sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n return this.client.pipeline.sendRequest(this.httpClient, request);\n }\n\n requestUrl(): URL {\n const url = new URL(this.baseUrl);\n url.pathname = this.hubName;\n url.searchParams.set(\"api-version\", API_VERSION);\n\n return url;\n }\n}\n"]}
1
+ {"version":3,"file":"clientContext.js","sourceRoot":"","sources":["../../../src/api/clientContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AAOnD,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,EACL,mCAAmC,EACnC,qCAAqC,GACtC,MAAM,kCAAkC,CAAC;AAI1C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,WAAW,GAAG,SAAS,CAAC;AAsB9B;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,gBAAwB,EACxB,OAAe,EACf,UAAyC,EAAE;IAE3C,OAAO,IAAI,6BAA6B,CAAC,gBAAgB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/E,CAAC;AAED,MAAM,6BAA6B;IACjC,kBAAkB,CAAqB;IACvC,OAAO,CAAS;IAChB,OAAO,CAAS;IAChB,MAAM,CAAS;IACf,UAAU,CAAa;IAEvB,YACE,gBAAwB,EACxB,OAAe;IACf,8DAA8D;IAC9D,UAAyC,EAAE;QAE3C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,MAAM,gBAAgB,GAAG,qCAAqC,CAAC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8C,aAAa,EAAE,CAC9D,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,WAAW,CAAC,OAAwB;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACpE,CAAC;IAED,UAAU;QACR,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAEjD,OAAO,GAAG,CAAC;IACb,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport * as constants from \"../utils/constants.js\";\nimport type {\n HttpClient,\n HttpHeaders,\n PipelineRequest,\n PipelineResponse,\n} from \"@azure/core-rest-pipeline\";\nimport { RestError, createDefaultHttpClient, createHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport {\n createTokenCredentialFromConnection,\n parseNotificationHubsConnectionString,\n} from \"../auth/connectionStringUtils.js\";\nimport type { NotificationHubsClientOptions } from \"../models/options.js\";\nimport type { SasTokenCredential } from \"../auth/sasTokenCredential.js\";\nimport type { Client } from \"@azure-rest/core-client\";\nimport { getClient } from \"@azure-rest/core-client\";\n\nconst API_VERSION = \"2020-06\";\n\n/**\n * Represents the Notification Hubs SDK client context.\n */\nexport interface NotificationHubsClientContext {\n /**\n * @internal\n */\n sendRequest(request: PipelineRequest): Promise<PipelineResponse>;\n\n /**\n * @internal\n */\n createHeaders(operationName: string, rawHeaders?: Record<string, string>): Promise<HttpHeaders>;\n\n /**\n * @internal\n */\n requestUrl(): URL;\n}\n\n/**\n * Creates a NotificationHubClient from the Access Policy connection string and hub name.\n * @param connectionString - The Access Policy connection string for the notification hub.\n * @param hubName - The notification hub name.\n * @returns A NotificationHubsClientContext initialized from the connection string and hub name.\n */\nexport function createClientContext(\n connectionString: string,\n hubName: string,\n options: NotificationHubsClientOptions = {},\n): NotificationHubsClientContext {\n return new NotificationHubsServiceClient(connectionString, hubName, options);\n}\n\nclass NotificationHubsServiceClient implements NotificationHubsClientContext {\n sasTokenCredential: SasTokenCredential;\n baseUrl: string;\n hubName: string;\n client: Client;\n httpClient: HttpClient;\n\n constructor(\n connectionString: string,\n hubName: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: NotificationHubsClientOptions = {},\n ) {\n this.hubName = hubName;\n\n const parsedConnection = parseNotificationHubsConnectionString(connectionString);\n // Node doesn't allow change in protocol but browsers do, so doing a string replace\n this.baseUrl = parsedConnection.endpoint.replace(\"sb://\", \"https://\");\n this.sasTokenCredential = createTokenCredentialFromConnection(\n parsedConnection.sharedAccessKey,\n parsedConnection.sharedAccessKeyName,\n );\n\n const packageDetails = `azsdk-js-notificationhubs/${constants.SDK_VERSION}`;\n const userAgentPrefix = options.userAgentOptions?.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n this.httpClient = options?.httpClient ?? createDefaultHttpClient();\n this.client = getClient(this.baseUrl, {\n userAgentOptions: {\n userAgentPrefix,\n },\n ...options,\n });\n }\n\n async createHeaders(\n operationName: string,\n rawHeaders?: Record<string, string>,\n ): Promise<HttpHeaders> {\n const authorization = await this.sasTokenCredential.getToken(this.baseUrl);\n if (!authorization) {\n throw new RestError(\"Failed to get the authorization header\", { statusCode: 401 });\n }\n\n const headers = createHttpHeaders(rawHeaders);\n headers.set(\"Authorization\", authorization.token);\n headers.set(\"x-ms-version\", API_VERSION);\n headers.set(\n \"x-ms-azsdk-telemetry\",\n `class=NotificationHubsServiceClient;method=${operationName}`,\n );\n\n return headers;\n }\n\n sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n return this.client.pipeline.sendRequest(this.httpClient, request);\n }\n\n requestUrl(): URL {\n const url = new URL(this.baseUrl);\n url.pathname = this.hubName;\n url.searchParams.set(\"api-version\", API_VERSION);\n\n return url;\n }\n}\n"]}
@@ -5,8 +5,14 @@ import { isDefined } from "../../utils/utils.js";
5
5
  import { parseNotificationOutcome } from "../../serializers/notificationOutcomeSerializer.js";
6
6
  import { parseXMLError } from "../../utils/xmlUtils.js";
7
7
  export function createRequest(endpoint, method, headers, options) {
8
- return createPipelineRequest(Object.assign(Object.assign(Object.assign({}, options.tracingOptions), options.requestOptions), { url: endpoint.toString(), abortSignal: options.abortSignal, method,
9
- headers }));
8
+ return createPipelineRequest({
9
+ ...options.tracingOptions,
10
+ ...options.requestOptions,
11
+ url: endpoint.toString(),
12
+ abortSignal: options.abortSignal,
13
+ method,
14
+ headers,
15
+ });
10
16
  }
11
17
  /**
12
18
  * Parses the HTTP response and creates a NotificationHubsResponse with header information from the operation.
@@ -42,14 +48,25 @@ export async function parseNotificationSendResponse(response) {
42
48
  const responseBody = response.bodyAsText;
43
49
  if (isTestSend && !isDirectSend && isDefined(responseBody)) {
44
50
  const outcome = await parseNotificationOutcome(responseBody);
45
- return Object.assign(Object.assign(Object.assign({}, result), outcome), { notificationId });
51
+ return {
52
+ ...result,
53
+ ...outcome,
54
+ notificationId,
55
+ };
46
56
  }
47
57
  else {
48
58
  return createDefaultResponse(result, notificationId);
49
59
  }
50
60
  }
51
61
  function createDefaultResponse(response, notificationId) {
52
- return Object.assign(Object.assign({}, response), { notificationId, successCount: 0, failureCount: 0, results: [], state: "Enqueued" });
62
+ return {
63
+ ...response,
64
+ notificationId,
65
+ successCount: 0,
66
+ failureCount: 0,
67
+ results: [],
68
+ state: "Enqueued",
69
+ };
53
70
  }
54
71
  /**
55
72
  * Sends a request through the client context.
@@ -1 +1 @@
1
- {"version":3,"file":"_client.js","sourceRoot":"","sources":["../../../../src/api/internal/_client.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,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AAI,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5B,OAAO,GAAG,MAAM,aAAa,CAAC,YAAY,CAAC,CAAC;QAC9C,CAAC;QAED,IAAI,YAAgC,CAAC;QACrC,IAAI,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YACvB,YAAY,GAAG,2BAA2B,OAAO,EAAE,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,YAAY,GAAG,gCAAgC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACnE,CAAC;QAED,MAAM,IAAI,SAAS,CAAC,YAAY,EAAE;YAChC,UAAU,EAAE,QAAQ,CAAC,MAAM;YAC3B,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n HttpHeaders,\n HttpMethods,\n PipelineRequest,\n PipelineResponse,\n} from \"@azure/core-rest-pipeline\";\nimport { RestError, createPipelineRequest } from \"@azure/core-rest-pipeline\";\nimport type {\n NotificationHubsMessageResponse,\n NotificationHubsResponse,\n} from \"../../models/notificationDetails.js\";\nimport type { NotificationHubsClientContext } from \"../index.js\";\nimport type { OperationOptions } from \"@azure-rest/core-client\";\nimport { isDefined } from \"../../utils/utils.js\";\nimport { parseNotificationOutcome } from \"../../serializers/notificationOutcomeSerializer.js\";\nimport { parseXMLError } from \"../../utils/xmlUtils.js\";\n\nexport function createRequest(\n endpoint: URL,\n method: HttpMethods,\n headers: HttpHeaders,\n options: OperationOptions,\n): PipelineRequest {\n return createPipelineRequest({\n ...options.tracingOptions,\n ...options.requestOptions,\n url: endpoint.toString(),\n abortSignal: options.abortSignal,\n method,\n headers,\n });\n}\n\n/**\n * Parses the HTTP response and creates a NotificationHubsResponse with header information from the operation.\n * @param response - The HTTP response used to populate the result.\n * @returns A NotificationHubsResponse with header information from the operation.\n */\nexport function parseNotificationResponse(response: PipelineResponse): NotificationHubsResponse {\n const correlationId = response.headers.get(\"x-ms-correlation-request-id\");\n const trackingId = response.headers.get(\"TrackingId\");\n const location = response.headers.get(\"Location\");\n\n return {\n correlationId,\n trackingId,\n location,\n };\n}\n\n/**\n * Parses the HTTP response and creates a NotificationHubsMessageResponse with results from the notification.\n * @param response - The HTTP response used to populate the result.\n * @returns A NotificationHubsMessageResponse with results from the notification.\n */\nexport async function parseNotificationSendResponse(\n response: PipelineResponse,\n): Promise<NotificationHubsMessageResponse> {\n const result = parseNotificationResponse(response);\n let notificationId: string | undefined;\n if (result.location) {\n const locationUrl = new URL(result.location);\n notificationId = locationUrl.pathname.split(\"/\")[3];\n }\n\n const requestUrl = new URL(response.request.url);\n const isTestSend = requestUrl.searchParams.has(\"test\");\n const isDirectSend = requestUrl.searchParams.has(\"direct\");\n\n // Only broadcast/tag based sends are supported for test send\n const responseBody = response.bodyAsText;\n if (isTestSend && !isDirectSend && isDefined(responseBody)) {\n const outcome = await parseNotificationOutcome(responseBody);\n return {\n ...result,\n ...outcome,\n notificationId,\n };\n } else {\n return createDefaultResponse(result, notificationId);\n }\n}\n\nfunction createDefaultResponse(\n response: NotificationHubsResponse,\n notificationId?: string,\n): NotificationHubsMessageResponse {\n return {\n ...response,\n notificationId,\n successCount: 0,\n failureCount: 0,\n results: [],\n state: \"Enqueued\",\n };\n}\n\n/**\n * Sends a request through the client context.\n * @param context - The client context to use.\n * @param request - The HTTP request to send.\n * @param successStatusCode - A status code or list of status codes to check for success.\n * @returns The HTTP Response.\n */\nexport async function sendRequest(\n context: NotificationHubsClientContext,\n request: PipelineRequest,\n successStatusCode: number | number[],\n): Promise<PipelineResponse> {\n const statuses: number[] = Array.isArray(successStatusCode)\n ? successStatusCode\n : [successStatusCode];\n\n const response = await context.sendRequest(request);\n\n if (!statuses.some((statusCode) => statusCode === response.status)) {\n const responseBody = response.bodyAsText;\n let details: string | undefined;\n if (isDefined(responseBody)) {\n details = await parseXMLError(responseBody);\n }\n\n let errorMessage: string | undefined;\n if (isDefined(details)) {\n errorMessage = `operations failed with: ${details}`;\n } else {\n errorMessage = `operation failed with status ${response.status}`;\n }\n\n throw new RestError(errorMessage, {\n statusCode: response.status,\n response,\n });\n }\n\n return response;\n}\n"]}
1
+ {"version":3,"file":"_client.js","sourceRoot":"","sources":["../../../../src/api/internal/_client.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAO7E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,UAAU,aAAa,CAC3B,QAAa,EACb,MAAmB,EACnB,OAAoB,EACpB,OAAyB;IAEzB,OAAO,qBAAqB,CAAC;QAC3B,GAAG,OAAO,CAAC,cAAc;QACzB,GAAG,OAAO,CAAC,cAAc;QACzB,GAAG,EAAE,QAAQ,CAAC,QAAQ,EAAE;QACxB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,MAAM;QACN,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAA0B;IAClE,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAC1E,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAElD,OAAO;QACL,aAAa;QACb,UAAU;QACV,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,QAA0B;IAE1B,MAAM,MAAM,GAAG,yBAAyB,CAAC,QAAQ,CAAC,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AAC;QACzD,CAAC,CAAC,iBAAiB;QACnB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAExB,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAEpD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,KAAK,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACnE,MAAM,YAAY,GAAG,QAAQ,CAAC,UAAU,CAAC;QACzC,IAAI,OAA2B,CAAC;QAChC,IAAI,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5B,OAAO,GAAG,MAAM,aAAa,CAAC,YAAY,CAAC,CAAC;QAC9C,CAAC;QAED,IAAI,YAAgC,CAAC;QACrC,IAAI,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YACvB,YAAY,GAAG,2BAA2B,OAAO,EAAE,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,YAAY,GAAG,gCAAgC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACnE,CAAC;QAED,MAAM,IAAI,SAAS,CAAC,YAAY,EAAE;YAChC,UAAU,EAAE,QAAQ,CAAC,MAAM;YAC3B,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n HttpHeaders,\n HttpMethods,\n PipelineRequest,\n PipelineResponse,\n} from \"@azure/core-rest-pipeline\";\nimport { RestError, createPipelineRequest } from \"@azure/core-rest-pipeline\";\nimport type {\n NotificationHubsMessageResponse,\n NotificationHubsResponse,\n} from \"../../models/notificationDetails.js\";\nimport type { NotificationHubsClientContext } from \"../index.js\";\nimport type { OperationOptions } from \"@azure-rest/core-client\";\nimport { isDefined } from \"../../utils/utils.js\";\nimport { parseNotificationOutcome } from \"../../serializers/notificationOutcomeSerializer.js\";\nimport { parseXMLError } from \"../../utils/xmlUtils.js\";\n\nexport function createRequest(\n endpoint: URL,\n method: HttpMethods,\n headers: HttpHeaders,\n options: OperationOptions,\n): PipelineRequest {\n return createPipelineRequest({\n ...options.tracingOptions,\n ...options.requestOptions,\n url: endpoint.toString(),\n abortSignal: options.abortSignal,\n method,\n headers,\n });\n}\n\n/**\n * Parses the HTTP response and creates a NotificationHubsResponse with header information from the operation.\n * @param response - The HTTP response used to populate the result.\n * @returns A NotificationHubsResponse with header information from the operation.\n */\nexport function parseNotificationResponse(response: PipelineResponse): NotificationHubsResponse {\n const correlationId = response.headers.get(\"x-ms-correlation-request-id\");\n const trackingId = response.headers.get(\"TrackingId\");\n const location = response.headers.get(\"Location\");\n\n return {\n correlationId,\n trackingId,\n location,\n };\n}\n\n/**\n * Parses the HTTP response and creates a NotificationHubsMessageResponse with results from the notification.\n * @param response - The HTTP response used to populate the result.\n * @returns A NotificationHubsMessageResponse with results from the notification.\n */\nexport async function parseNotificationSendResponse(\n response: PipelineResponse,\n): Promise<NotificationHubsMessageResponse> {\n const result = parseNotificationResponse(response);\n let notificationId: string | undefined;\n if (result.location) {\n const locationUrl = new URL(result.location);\n notificationId = locationUrl.pathname.split(\"/\")[3];\n }\n\n const requestUrl = new URL(response.request.url);\n const isTestSend = requestUrl.searchParams.has(\"test\");\n const isDirectSend = requestUrl.searchParams.has(\"direct\");\n\n // Only broadcast/tag based sends are supported for test send\n const responseBody = response.bodyAsText;\n if (isTestSend && !isDirectSend && isDefined(responseBody)) {\n const outcome = await parseNotificationOutcome(responseBody);\n return {\n ...result,\n ...outcome,\n notificationId,\n };\n } else {\n return createDefaultResponse(result, notificationId);\n }\n}\n\nfunction createDefaultResponse(\n response: NotificationHubsResponse,\n notificationId?: string,\n): NotificationHubsMessageResponse {\n return {\n ...response,\n notificationId,\n successCount: 0,\n failureCount: 0,\n results: [],\n state: \"Enqueued\",\n };\n}\n\n/**\n * Sends a request through the client context.\n * @param context - The client context to use.\n * @param request - The HTTP request to send.\n * @param successStatusCode - A status code or list of status codes to check for success.\n * @returns The HTTP Response.\n */\nexport async function sendRequest(\n context: NotificationHubsClientContext,\n request: PipelineRequest,\n successStatusCode: number | number[],\n): Promise<PipelineResponse> {\n const statuses: number[] = Array.isArray(successStatusCode)\n ? successStatusCode\n : [successStatusCode];\n\n const response = await context.sendRequest(request);\n\n if (!statuses.some((statusCode) => statusCode === response.status)) {\n const responseBody = response.bodyAsText;\n let details: string | undefined;\n if (isDefined(responseBody)) {\n details = await parseXMLError(responseBody);\n }\n\n let errorMessage: string | undefined;\n if (isDefined(details)) {\n errorMessage = `operations failed with: ${details}`;\n } else {\n errorMessage = `operation failed with status ${response.status}`;\n }\n\n throw new RestError(errorMessage, {\n statusCode: response.status,\n response,\n });\n }\n\n return response;\n}\n"]}
@@ -1,39 +1,21 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
4
3
  import { createRequest, sendRequest } from "./_client.js";
5
4
  import { registrationDescriptionParser } from "../../serializers/registrationSerializer.js";
6
- export function listRegistrationsAll(context, options) {
7
- return __asyncGenerator(this, arguments, function* listRegistrationsAll_1() {
8
- var _a, e_1, _b, _c;
9
- try {
10
- for (var _d = true, _e = __asyncValues(listRegistrationPagingPage(context, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
11
- _c = _f.value;
12
- _d = false;
13
- const page = _c;
14
- yield __await(yield* __asyncDelegator(__asyncValues(page)));
15
- }
16
- }
17
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
18
- finally {
19
- try {
20
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
21
- }
22
- finally { if (e_1) throw e_1.error; }
23
- }
24
- });
5
+ export async function* listRegistrationsAll(context, options) {
6
+ for await (const page of listRegistrationPagingPage(context, options)) {
7
+ yield* page;
8
+ }
25
9
  }
26
- export function listRegistrationPagingPage(context, options) {
27
- return __asyncGenerator(this, arguments, function* listRegistrationPagingPage_1() {
28
- let result = yield __await(_listRegistrations(context, options));
29
- yield yield __await(result.registrations || []);
30
- let continuationToken = result.continuationToken;
31
- while (continuationToken) {
32
- result = yield __await(_listRegistrations(context, options, continuationToken));
33
- continuationToken = result.continuationToken;
34
- yield yield __await(result.registrations || []);
35
- }
36
- });
10
+ export async function* listRegistrationPagingPage(context, options) {
11
+ let result = await _listRegistrations(context, options);
12
+ yield result.registrations || [];
13
+ let continuationToken = result.continuationToken;
14
+ while (continuationToken) {
15
+ result = await _listRegistrations(context, options, continuationToken);
16
+ continuationToken = result.continuationToken;
17
+ yield result.registrations || [];
18
+ }
37
19
  }
38
20
  async function _listRegistrations(context, options, continuationToken) {
39
21
  const endpoint = context.requestUrl();
@@ -1 +1 @@
1
- {"version":3,"file":"_listRegistrations.js","sourceRoot":"","sources":["../../../../src/api/internal/_listRegistrations.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAK1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAE5F,MAAM,UAAiB,oBAAoB,CACzC,OAAsC,EACtC,OAAiC;;;;YAEjC,KAAyB,eAAA,KAAA,cAAA,0BAA0B,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA,IAAA,+DAAE,CAAC;gBAA/C,cAA4C;gBAA5C,WAA4C;gBAA1D,MAAM,IAAI,KAAA,CAAA;gBACnB,cAAA,KAAK,CAAC,CAAC,iBAAA,cAAA,IAAI,CAAA,CAAA,CAAA,CAAC;YACd,CAAC;;;;;;;;;IACH,CAAC;CAAA;AAED,MAAM,UAAiB,0BAA0B,CAC/C,OAAsC,EACtC,OAAiC;;QAEjC,IAAI,MAAM,GAAG,cAAM,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA,CAAC;QACxD,oBAAM,MAAM,CAAC,aAAa,IAAI,EAAE,CAAA,CAAC;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AC7E,QAAQ,CAAC,UAAW,CACrB,CAAC;IACF,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACjE,OAAO;QACL,aAAa;QACb,iBAAiB,EAAE,SAAS;KAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createRequest, sendRequest } from \"./_client.js\";\nimport type { NotificationHubsClientContext } from \"../index.js\";\nimport type { RegistrationDescription } from \"../../models/registration.js\";\nimport type { RegistrationQueryOptions } from \"../../models/options.js\";\nimport type { RegistrationQueryResponse } from \"../../models/response.js\";\nimport { registrationDescriptionParser } from \"../../serializers/registrationSerializer.js\";\n\nexport async function* listRegistrationsAll(\n context: NotificationHubsClientContext,\n options: RegistrationQueryOptions,\n): AsyncIterableIterator<RegistrationDescription> {\n for await (const page of listRegistrationPagingPage(context, options)) {\n yield* page;\n }\n}\n\nexport async function* listRegistrationPagingPage(\n context: NotificationHubsClientContext,\n options: RegistrationQueryOptions,\n): AsyncIterableIterator<RegistrationDescription[]> {\n let result = await _listRegistrations(context, options);\n yield result.registrations || [];\n let continuationToken = result.continuationToken;\n while (continuationToken) {\n result = await _listRegistrations(context, options, continuationToken);\n continuationToken = result.continuationToken;\n yield result.registrations || [];\n }\n}\n\nasync function _listRegistrations(\n context: NotificationHubsClientContext,\n options: RegistrationQueryOptions,\n continuationToken?: string,\n): Promise<RegistrationQueryResponse> {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/registrations\";\n if (options.top !== undefined) {\n endpoint.searchParams.set(\"$top\", `${options.top}`);\n }\n\n if (options.filter !== undefined) {\n endpoint.searchParams.set(\"$filter\", options.filter);\n }\n\n if (continuationToken !== undefined) {\n endpoint.searchParams.set(\"continuationtoken\", continuationToken);\n }\n\n const headers = await context.createHeaders(\"listRegistrations\");\n const request = createRequest(endpoint, \"GET\", headers, options);\n const response = await sendRequest(context, request, 200);\n\n const registrations = await registrationDescriptionParser.parseRegistrationFeed(\n response.bodyAsText!,\n );\n const nextToken = response.headers.get(\"x-ms-continuationtoken\");\n return {\n registrations,\n continuationToken: nextToken,\n };\n}\n"]}
1
+ {"version":3,"file":"_listRegistrations.js","sourceRoot":"","sources":["../../../../src/api/internal/_listRegistrations.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAK1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAE5F,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,oBAAoB,CACzC,OAAsC,EACtC,OAAiC;IAEjC,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,0BAA0B,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;QACtE,KAAK,CAAC,CAAC,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,0BAA0B,CAC/C,OAAsC,EACtC,OAAiC;IAEjC,IAAI,MAAM,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxD,MAAM,MAAM,CAAC,aAAa,IAAI,EAAE,CAAC;IACjC,IAAI,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;IACjD,OAAO,iBAAiB,EAAE,CAAC;QACzB,MAAM,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;QACvE,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QAC7C,MAAM,MAAM,CAAC,aAAa,IAAI,EAAE,CAAC;IACnC,CAAC;AACH,CAAC;AAED,KAAK,UAAU,kBAAkB,CAC/B,OAAsC,EACtC,OAAiC,EACjC,iBAA0B;IAE1B,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IACtC,QAAQ,CAAC,QAAQ,IAAI,gBAAgB,CAAC;IACtC,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC9B,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACjC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACpC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAE1D,MAAM,aAAa,GAAG,MAAM,6BAA6B,CAAC,qBAAqB,CAC7E,QAAQ,CAAC,UAAW,CACrB,CAAC;IACF,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACjE,OAAO;QACL,aAAa;QACb,iBAAiB,EAAE,SAAS;KAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createRequest, sendRequest } from \"./_client.js\";\nimport type { NotificationHubsClientContext } from \"../index.js\";\nimport type { RegistrationDescription } from \"../../models/registration.js\";\nimport type { RegistrationQueryOptions } from \"../../models/options.js\";\nimport type { RegistrationQueryResponse } from \"../../models/response.js\";\nimport { registrationDescriptionParser } from \"../../serializers/registrationSerializer.js\";\n\nexport async function* listRegistrationsAll(\n context: NotificationHubsClientContext,\n options: RegistrationQueryOptions,\n): AsyncIterableIterator<RegistrationDescription> {\n for await (const page of listRegistrationPagingPage(context, options)) {\n yield* page;\n }\n}\n\nexport async function* listRegistrationPagingPage(\n context: NotificationHubsClientContext,\n options: RegistrationQueryOptions,\n): AsyncIterableIterator<RegistrationDescription[]> {\n let result = await _listRegistrations(context, options);\n yield result.registrations || [];\n let continuationToken = result.continuationToken;\n while (continuationToken) {\n result = await _listRegistrations(context, options, continuationToken);\n continuationToken = result.continuationToken;\n yield result.registrations || [];\n }\n}\n\nasync function _listRegistrations(\n context: NotificationHubsClientContext,\n options: RegistrationQueryOptions,\n continuationToken?: string,\n): Promise<RegistrationQueryResponse> {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/registrations\";\n if (options.top !== undefined) {\n endpoint.searchParams.set(\"$top\", `${options.top}`);\n }\n\n if (options.filter !== undefined) {\n endpoint.searchParams.set(\"$filter\", options.filter);\n }\n\n if (continuationToken !== undefined) {\n endpoint.searchParams.set(\"continuationtoken\", continuationToken);\n }\n\n const headers = await context.createHeaders(\"listRegistrations\");\n const request = createRequest(endpoint, \"GET\", headers, options);\n const response = await sendRequest(context, request, 200);\n\n const registrations = await registrationDescriptionParser.parseRegistrationFeed(\n response.bodyAsText!,\n );\n const nextToken = response.headers.get(\"x-ms-continuationtoken\");\n return {\n registrations,\n continuationToken: nextToken,\n };\n}\n"]}
@@ -11,7 +11,10 @@ import { tracingClient } from "../utils/tracing.js";
11
11
  * @returns A paged async iterable containing all of the registrations for the notification hub.
12
12
  */
13
13
  export function listRegistrationsByChannel(context, channel, options = {}) {
14
- const newOptions = Object.assign(Object.assign({}, options), { filter: getFilterByChannel(channel) });
14
+ const newOptions = {
15
+ ...options,
16
+ filter: getFilterByChannel(channel),
17
+ };
15
18
  const { span, updatedOptions } = tracingClient.startSpan("NotificationHubsClientContext.listRegistrationsByDevice", newOptions);
16
19
  try {
17
20
  const iter = listRegistrationsAll(context, updatedOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"listRegistrationsByChannel.js","sourceRoot":"","sources":["../../../src/api/listRegistrationsByChannel.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAIpG,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAAsC,EACtC,OAA4B,EAC5B,UAAyC,EAAE;IAE3C,MAAM,UAAU,mCACX,OAAO,KACV,MAAM,EAAE,kBAAkB,CAAC,OAAO,CAAC,GACpC,CAAC;IACF,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,SAAS,CACtD,yDAAyD,EACzD,UAAU,CACX,CAAC;IACF,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,oBAAoB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC3D,OAAO;YACL,IAAI;gBACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,EAAE,GAAG,EAAE;gBACX,OAAO,0BAA0B,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YAC7D,CAAC;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QAC9C,MAAM,CAAC,CAAC;IACV,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,GAAG,EAAE,CAAC;IACb,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { RegistrationDescription, RegistrationChannel } from \"../models/registration.js\";\nimport { listRegistrationPagingPage, listRegistrationsAll } from \"./internal/_listRegistrations.js\";\nimport type { NotificationHubsClientContext } from \"./index.js\";\nimport type { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport type { RegistrationQueryLimitOptions } from \"../models/options.js\";\nimport { getFilterByChannel } from \"../utils/registrationUtils.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\n/**\n * Gets all registrations for the notification hub with the given device information and options.\n * @param context - The Notification Hubs client.\n * @param channel - The Registration channel information to query per PNS type.\n * @param options - The options for querying the registrations such as $top.\n * @returns A paged async iterable containing all of the registrations for the notification hub.\n */\nexport function listRegistrationsByChannel(\n context: NotificationHubsClientContext,\n channel: RegistrationChannel,\n options: RegistrationQueryLimitOptions = {},\n): PagedAsyncIterableIterator<RegistrationDescription> {\n const newOptions = {\n ...options,\n filter: getFilterByChannel(channel),\n };\n const { span, updatedOptions } = tracingClient.startSpan(\n \"NotificationHubsClientContext.listRegistrationsByDevice\",\n newOptions,\n );\n try {\n const iter = listRegistrationsAll(context, updatedOptions);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: () => {\n return listRegistrationPagingPage(context, updatedOptions);\n },\n };\n } catch (e: any) {\n span.setStatus({ status: \"error\", error: e });\n throw e;\n } finally {\n span.end();\n }\n}\n"]}
1
+ {"version":3,"file":"listRegistrationsByChannel.js","sourceRoot":"","sources":["../../../src/api/listRegistrationsByChannel.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAIpG,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAAsC,EACtC,OAA4B,EAC5B,UAAyC,EAAE;IAE3C,MAAM,UAAU,GAAG;QACjB,GAAG,OAAO;QACV,MAAM,EAAE,kBAAkB,CAAC,OAAO,CAAC;KACpC,CAAC;IACF,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,SAAS,CACtD,yDAAyD,EACzD,UAAU,CACX,CAAC;IACF,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,oBAAoB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC3D,OAAO;YACL,IAAI;gBACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,EAAE,GAAG,EAAE;gBACX,OAAO,0BAA0B,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YAC7D,CAAC;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QAC9C,MAAM,CAAC,CAAC;IACV,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,GAAG,EAAE,CAAC;IACb,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { RegistrationDescription, RegistrationChannel } from \"../models/registration.js\";\nimport { listRegistrationPagingPage, listRegistrationsAll } from \"./internal/_listRegistrations.js\";\nimport type { NotificationHubsClientContext } from \"./index.js\";\nimport type { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport type { RegistrationQueryLimitOptions } from \"../models/options.js\";\nimport { getFilterByChannel } from \"../utils/registrationUtils.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\n/**\n * Gets all registrations for the notification hub with the given device information and options.\n * @param context - The Notification Hubs client.\n * @param channel - The Registration channel information to query per PNS type.\n * @param options - The options for querying the registrations such as $top.\n * @returns A paged async iterable containing all of the registrations for the notification hub.\n */\nexport function listRegistrationsByChannel(\n context: NotificationHubsClientContext,\n channel: RegistrationChannel,\n options: RegistrationQueryLimitOptions = {},\n): PagedAsyncIterableIterator<RegistrationDescription> {\n const newOptions = {\n ...options,\n filter: getFilterByChannel(channel),\n };\n const { span, updatedOptions } = tracingClient.startSpan(\n \"NotificationHubsClientContext.listRegistrationsByDevice\",\n newOptions,\n );\n try {\n const iter = listRegistrationsAll(context, updatedOptions);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: () => {\n return listRegistrationPagingPage(context, updatedOptions);\n },\n };\n } catch (e: any) {\n span.setStatus({ status: \"error\", error: e });\n throw e;\n } finally {\n span.end();\n }\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
4
3
  import { createRequest, sendRequest } from "./internal/_client.js";
5
4
  import { registrationDescriptionParser } from "../serializers/registrationSerializer.js";
6
5
  import { tracingClient } from "../utils/tracing.js";
@@ -36,37 +35,20 @@ export function listRegistrationsByTag(context, tag, options = {}) {
36
35
  span.end();
37
36
  }
38
37
  }
39
- function listRegistrationsByTagAll(context, tag, options) {
40
- return __asyncGenerator(this, arguments, function* listRegistrationsByTagAll_1() {
41
- var _a, e_1, _b, _c;
42
- try {
43
- for (var _d = true, _e = __asyncValues(listRegistrationsByTagPagingPage(context, tag, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
44
- _c = _f.value;
45
- _d = false;
46
- const page = _c;
47
- yield __await(yield* __asyncDelegator(__asyncValues(page)));
48
- }
49
- }
50
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
51
- finally {
52
- try {
53
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
54
- }
55
- finally { if (e_1) throw e_1.error; }
56
- }
57
- });
38
+ async function* listRegistrationsByTagAll(context, tag, options) {
39
+ for await (const page of listRegistrationsByTagPagingPage(context, tag, options)) {
40
+ yield* page;
41
+ }
58
42
  }
59
- function listRegistrationsByTagPagingPage(context, tag, options) {
60
- return __asyncGenerator(this, arguments, function* listRegistrationsByTagPagingPage_1() {
61
- let result = yield __await(_listRegistrationsByTag(context, tag, options));
62
- yield yield __await(result.registrations || []);
63
- let continuationToken = result.continuationToken;
64
- while (continuationToken) {
65
- result = yield __await(_listRegistrationsByTag(context, tag, options, continuationToken));
66
- continuationToken = result.continuationToken;
67
- yield yield __await(result.registrations || []);
68
- }
69
- });
43
+ async function* listRegistrationsByTagPagingPage(context, tag, options) {
44
+ let result = await _listRegistrationsByTag(context, tag, options);
45
+ yield result.registrations || [];
46
+ let continuationToken = result.continuationToken;
47
+ while (continuationToken) {
48
+ result = await _listRegistrationsByTag(context, tag, options, continuationToken);
49
+ continuationToken = result.continuationToken;
50
+ yield result.registrations || [];
51
+ }
70
52
  }
71
53
  async function _listRegistrationsByTag(context, tag, options, continuationToken) {
72
54
  const endpoint = context.requestUrl();
@@ -1 +1 @@
1
- {"version":3,"file":"listRegistrationsByTag.js","sourceRoot":"","sources":["../../../src/api/listRegistrationsByTag.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAsC,EACtC,GAAW,EACX,UAAyC,EAAE;IAE3C,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,SAAS,CACtD,iCAAiC,cAAc,EAAE,EACjD,OAAO,CACR,CAAC;IACF,IAAI,CAAC;QAC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c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createRequest, sendRequest } from \"./internal/_client.js\";\nimport type { NotificationHubsClientContext } from \"./index.js\";\nimport type { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport type { RegistrationDescription } from \"../models/registration.js\";\nimport type { RegistrationQueryLimitOptions } from \"../models/options.js\";\nimport type { RegistrationQueryResponse } from \"../models/response.js\";\nimport { registrationDescriptionParser } from \"../serializers/registrationSerializer.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\nconst OPERATION_NAME = \"listRegistrationsByTag\";\n\n/**\n * Lists all registrations with the matching tag.\n * @param context - The Notification Hubs client.\n * @param tag - The tag to query for matching registrations.\n * @param options - The query options such as $top.\n * @returns A paged async iterable containing the matching registrations for the notification hub.\n */\nexport function listRegistrationsByTag(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions = {},\n): PagedAsyncIterableIterator<RegistrationDescription> {\n const { span, updatedOptions } = tracingClient.startSpan(\n `NotificationHubsClientContext.${OPERATION_NAME}`,\n options,\n );\n try {\n const iter = listRegistrationsByTagAll(context, tag, updatedOptions);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: () => {\n return listRegistrationsByTagPagingPage(context, tag, options);\n },\n };\n } catch (e: any) {\n span.setStatus({ status: \"error\", error: e });\n throw e;\n } finally {\n span.end();\n }\n}\n\nasync function* listRegistrationsByTagAll(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions,\n): AsyncIterableIterator<RegistrationDescription> {\n for await (const page of listRegistrationsByTagPagingPage(context, tag, options)) {\n yield* page;\n }\n}\n\nasync function* listRegistrationsByTagPagingPage(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions,\n): AsyncIterableIterator<RegistrationDescription[]> {\n let result = await _listRegistrationsByTag(context, tag, options);\n yield result.registrations || [];\n let continuationToken = result.continuationToken;\n while (continuationToken) {\n result = await _listRegistrationsByTag(context, tag, options, continuationToken);\n continuationToken = result.continuationToken;\n yield result.registrations || [];\n }\n}\n\nasync function _listRegistrationsByTag(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions,\n continuationToken?: string,\n): Promise<RegistrationQueryResponse> {\n const endpoint = context.requestUrl();\n endpoint.pathname += `/tags/${tag}/registrations`;\n if (options.top !== undefined) {\n endpoint.searchParams.set(\"$top\", `${options.top}`);\n }\n\n if (continuationToken !== undefined) {\n endpoint.searchParams.set(\"continuationtoken\", continuationToken);\n }\n\n const headers = await context.createHeaders(OPERATION_NAME);\n const request = createRequest(endpoint, \"GET\", headers, options);\n const response = await sendRequest(context, request, 200);\n\n const registrations = await registrationDescriptionParser.parseRegistrationFeed(\n response.bodyAsText!,\n );\n const nextToken = response.headers.get(\"x-ms-continuationtoken\");\n return {\n registrations,\n continuationToken: nextToken,\n };\n}\n"]}
1
+ {"version":3,"file":"listRegistrationsByTag.js","sourceRoot":"","sources":["../../../src/api/listRegistrationsByTag.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAsC,EACtC,GAAW,EACX,UAAyC,EAAE;IAE3C,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,SAAS,CACtD,iCAAiC,cAAc,EAAE,EACjD,OAAO,CACR,CAAC;IACF,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,yBAAyB,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;QACrE,OAAO;YACL,IAAI;gBACF,OAAO,IAAI,CA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U,uBAAuB,CACpC,OAAsC,EACtC,GAAW,EACX,OAAsC,EACtC,iBAA0B;IAE1B,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IACtC,QAAQ,CAAC,QAAQ,IAAI,SAAS,GAAG,gBAAgB,CAAC;IAClD,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC9B,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACpC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAE1D,MAAM,aAAa,GAAG,MAAM,6BAA6B,CAAC,qBAAqB,CAC7E,QAAQ,CAAC,UAAW,CACrB,CAAC;IACF,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACjE,OAAO;QACL,aAAa;QACb,iBAAiB,EAAE,SAAS;KAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createRequest, sendRequest } from \"./internal/_client.js\";\nimport type { NotificationHubsClientContext } from \"./index.js\";\nimport type { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport type { RegistrationDescription } from \"../models/registration.js\";\nimport type { RegistrationQueryLimitOptions } from \"../models/options.js\";\nimport type { RegistrationQueryResponse } from \"../models/response.js\";\nimport { registrationDescriptionParser } from \"../serializers/registrationSerializer.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\nconst OPERATION_NAME = \"listRegistrationsByTag\";\n\n/**\n * Lists all registrations with the matching tag.\n * @param context - The Notification Hubs client.\n * @param tag - The tag to query for matching registrations.\n * @param options - The query options such as $top.\n * @returns A paged async iterable containing the matching registrations for the notification hub.\n */\nexport function listRegistrationsByTag(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions = {},\n): PagedAsyncIterableIterator<RegistrationDescription> {\n const { span, updatedOptions } = tracingClient.startSpan(\n `NotificationHubsClientContext.${OPERATION_NAME}`,\n options,\n );\n try {\n const iter = listRegistrationsByTagAll(context, tag, updatedOptions);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: () => {\n return listRegistrationsByTagPagingPage(context, tag, options);\n },\n };\n } catch (e: any) {\n span.setStatus({ status: \"error\", error: e });\n throw e;\n } finally {\n span.end();\n }\n}\n\nasync function* listRegistrationsByTagAll(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions,\n): AsyncIterableIterator<RegistrationDescription> {\n for await (const page of listRegistrationsByTagPagingPage(context, tag, options)) {\n yield* page;\n }\n}\n\nasync function* listRegistrationsByTagPagingPage(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions,\n): AsyncIterableIterator<RegistrationDescription[]> {\n let result = await _listRegistrationsByTag(context, tag, options);\n yield result.registrations || [];\n let continuationToken = result.continuationToken;\n while (continuationToken) {\n result = await _listRegistrationsByTag(context, tag, options, continuationToken);\n continuationToken = result.continuationToken;\n yield result.registrations || [];\n }\n}\n\nasync function _listRegistrationsByTag(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions,\n continuationToken?: string,\n): Promise<RegistrationQueryResponse> {\n const endpoint = context.requestUrl();\n endpoint.pathname += `/tags/${tag}/registrations`;\n if (options.top !== undefined) {\n endpoint.searchParams.set(\"$top\", `${options.top}`);\n }\n\n if (continuationToken !== undefined) {\n endpoint.searchParams.set(\"continuationtoken\", continuationToken);\n }\n\n const headers = await context.createHeaders(OPERATION_NAME);\n const request = createRequest(endpoint, \"GET\", headers, options);\n const response = await sendRequest(context, request, 200);\n\n const registrations = await registrationDescriptionParser.parseRegistrationFeed(\n response.bodyAsText!,\n );\n const nextToken = response.headers.get(\"x-ms-continuationtoken\");\n return {\n registrations,\n continuationToken: nextToken,\n };\n}\n"]}
@@ -8,6 +8,10 @@ import { signString } from "./hmacSha256.js";
8
8
  * @internal
9
9
  */
10
10
  export class SasTokenCredential {
11
+ /**
12
+ * The SASCredential containing the key name and secret key value.
13
+ */
14
+ _credential;
11
15
  /**
12
16
  * Initializes a new instance of SasTokenProvider
13
17
  * @param credential - The source `NamedKeyCredential` or `SASCredential`.
@@ -1 +1 @@
1
- {"version":3,"file":"sasTokenCredential.js","sourceRoot":"","sources":["../../../src/auth/sasTokenCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAiB7C;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IAM7B;;;OAGG;IACH,YAAY,UAA8B;QACxC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ,CAAC,MAAyB;QACtC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC5D,OAAO,WAAW,CAChB,IAAI,CAAC,WAAW,CAAC,mBAAmB,EACpC,IAAI,CAAC,WAAW,CAAC,eAAe,EAChC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,EACpC,QAAQ,CACT,CAAC;IACJ,CAAC;CACF;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,WAAW,CACxB,OAAe,EACf,GAAW,EACX,MAAc,EACd,QAAgB;IAEhB,QAAQ,GAAG,kBAAkB,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IACtD,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;IAC9C,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAEhD,OAAO;QACL,KAAK,EAAE,4BAA4B,QAAQ,QAAQ,GAAG,OAAO,MAAM,QAAQ,OAAO,EAAE;QACpF,kBAAkB,EAAE,MAAM;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, TokenCredential } from \"@azure/core-auth\";\nimport { signString } from \"./hmacSha256.js\";\n\n/**\n * Represents a named key credential.\n */\nexport interface NamedKeyCredential {\n /**\n * The Shared Access Signature key name.\n */\n sharedAccessKeyName: string;\n\n /**\n * The Shared Access Signature key value.\n */\n sharedAccessKey: string;\n}\n\n/**\n * A TokenProvider that generates a Sas token:\n * `SharedAccessSignature sr=<resource>&sig=<signature>&se=<expiry>&skn=<keyname>`\n *\n * @internal\n */\nexport class SasTokenCredential implements TokenCredential {\n /**\n * The SASCredential containing the key name and secret key value.\n */\n private _credential: NamedKeyCredential;\n\n /**\n * Initializes a new instance of SasTokenProvider\n * @param credential - The source `NamedKeyCredential` or `SASCredential`.\n */\n constructor(credential: NamedKeyCredential) {\n this._credential = credential;\n }\n\n /**\n * Gets the sas token for the specified audience\n * @param scopes - The scope for which the token is desired.\n */\n async getToken(scopes: string | string[]): Promise<AccessToken | null> {\n const audience = Array.isArray(scopes) ? scopes[0] : scopes;\n return createToken(\n this._credential.sharedAccessKeyName,\n this._credential.sharedAccessKey,\n Math.floor(Date.now() / 1000) + 3600,\n audience,\n );\n }\n}\n\n/**\n * Creates the sas token based on the provided information.\n * @param keyName - The shared access key name.\n * @param key - The shared access key.\n * @param expiry - The time period in unix time after which the token will expire.\n * @param audience - The audience for which the token is desired.\n * @internal\n */\nasync function createToken(\n keyName: string,\n key: string,\n expiry: number,\n audience: string,\n): Promise<AccessToken> {\n audience = encodeURIComponent(audience.toLowerCase());\n keyName = encodeURIComponent(keyName);\n const stringToSign = audience + \"\\n\" + expiry;\n const sig = await signString(key, stringToSign);\n\n return {\n token: `SharedAccessSignature sr=${audience}&sig=${sig}&se=${expiry}&skn=${keyName}`,\n expiresOnTimestamp: expiry,\n };\n}\n"]}
1
+ {"version":3,"file":"sasTokenCredential.js","sourceRoot":"","sources":["../../../src/auth/sasTokenCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAiB7C;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IAC7B;;OAEG;IACK,WAAW,CAAqB;IAExC;;;OAGG;IACH,YAAY,UAA8B;QACxC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ,CAAC,MAAyB;QACtC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC5D,OAAO,WAAW,CAChB,IAAI,CAAC,WAAW,CAAC,mBAAmB,EACpC,IAAI,CAAC,WAAW,CAAC,eAAe,EAChC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,EACpC,QAAQ,CACT,CAAC;IACJ,CAAC;CACF;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,WAAW,CACxB,OAAe,EACf,GAAW,EACX,MAAc,EACd,QAAgB;IAEhB,QAAQ,GAAG,kBAAkB,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IACtD,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;IAC9C,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAEhD,OAAO;QACL,KAAK,EAAE,4BAA4B,QAAQ,QAAQ,GAAG,OAAO,MAAM,QAAQ,OAAO,EAAE;QACpF,kBAAkB,EAAE,MAAM;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, TokenCredential } from \"@azure/core-auth\";\nimport { signString } from \"./hmacSha256.js\";\n\n/**\n * Represents a named key credential.\n */\nexport interface NamedKeyCredential {\n /**\n * The Shared Access Signature key name.\n */\n sharedAccessKeyName: string;\n\n /**\n * The Shared Access Signature key value.\n */\n sharedAccessKey: string;\n}\n\n/**\n * A TokenProvider that generates a Sas token:\n * `SharedAccessSignature sr=<resource>&sig=<signature>&se=<expiry>&skn=<keyname>`\n *\n * @internal\n */\nexport class SasTokenCredential implements TokenCredential {\n /**\n * The SASCredential containing the key name and secret key value.\n */\n private _credential: NamedKeyCredential;\n\n /**\n * Initializes a new instance of SasTokenProvider\n * @param credential - The source `NamedKeyCredential` or `SASCredential`.\n */\n constructor(credential: NamedKeyCredential) {\n this._credential = credential;\n }\n\n /**\n * Gets the sas token for the specified audience\n * @param scopes - The scope for which the token is desired.\n */\n async getToken(scopes: string | string[]): Promise<AccessToken | null> {\n const audience = Array.isArray(scopes) ? scopes[0] : scopes;\n return createToken(\n this._credential.sharedAccessKeyName,\n this._credential.sharedAccessKey,\n Math.floor(Date.now() / 1000) + 3600,\n audience,\n );\n }\n}\n\n/**\n * Creates the sas token based on the provided information.\n * @param keyName - The shared access key name.\n * @param key - The shared access key.\n * @param expiry - The time period in unix time after which the token will expire.\n * @param audience - The audience for which the token is desired.\n * @internal\n */\nasync function createToken(\n keyName: string,\n key: string,\n expiry: number,\n audience: string,\n): Promise<AccessToken> {\n audience = encodeURIComponent(audience.toLowerCase());\n keyName = encodeURIComponent(keyName);\n const stringToSign = audience + \"\\n\" + expiry;\n const sig = await signString(key, stringToSign);\n\n return {\n token: `SharedAccessSignature sr=${audience}&sig=${sig}&se=${expiry}&skn=${keyName}`,\n expiresOnTimestamp: expiry,\n };\n}\n"]}
@@ -6,7 +6,10 @@
6
6
  * @returns The newly created Apple installation.
7
7
  */
8
8
  export function createAppleInstallation(installation) {
9
- return Object.assign(Object.assign({}, installation), { platform: "apns" });
9
+ return {
10
+ ...installation,
11
+ platform: "apns",
12
+ };
10
13
  }
11
14
  /**
12
15
  * Creates an Amazon Device Messaging (ADM) based installation.
@@ -14,7 +17,10 @@ export function createAppleInstallation(installation) {
14
17
  * @returns The newly created ADM installation.
15
18
  */
16
19
  export function createAdmInstallation(installation) {
17
- return Object.assign(Object.assign({}, installation), { platform: "adm" });
20
+ return {
21
+ ...installation,
22
+ platform: "adm",
23
+ };
18
24
  }
19
25
  /**
20
26
  * Creates a Baidu based installation.
@@ -22,7 +28,10 @@ export function createAdmInstallation(installation) {
22
28
  * @returns The newly created Baidu installation.
23
29
  */
24
30
  export function createBaiduInstallation(installation) {
25
- return Object.assign(Object.assign({}, installation), { platform: "baidu" });
31
+ return {
32
+ ...installation,
33
+ platform: "baidu",
34
+ };
26
35
  }
27
36
  /**
28
37
  * Creates a Firebase legacy HTTP based installation.
@@ -30,7 +39,10 @@ export function createBaiduInstallation(installation) {
30
39
  * @returns The newly created Baidu installation.
31
40
  */
32
41
  export function createFcmLegacyInstallation(installation) {
33
- return Object.assign(Object.assign({}, installation), { platform: "gcm" });
42
+ return {
43
+ ...installation,
44
+ platform: "gcm",
45
+ };
34
46
  }
35
47
  /**
36
48
  * Creates an Firebase V1 Cloud Messaging based installation.
@@ -38,7 +50,10 @@ export function createFcmLegacyInstallation(installation) {
38
50
  * @returns The newly created Firebase V1 Cloud Messaging installation.
39
51
  */
40
52
  export function createFcmV1Installation(installation) {
41
- return Object.assign(Object.assign({}, installation), { platform: "fcmv1" });
53
+ return {
54
+ ...installation,
55
+ platform: "fcmv1",
56
+ };
42
57
  }
43
58
  /**
44
59
  * Creates a Xiaomi based installation.
@@ -46,7 +61,10 @@ export function createFcmV1Installation(installation) {
46
61
  * @returns The newly created Xiaomi installation.
47
62
  */
48
63
  export function createXiaomiInstallation(installation) {
49
- return Object.assign(Object.assign({}, installation), { platform: "xiaomi" });
64
+ return {
65
+ ...installation,
66
+ platform: "xiaomi",
67
+ };
50
68
  }
51
69
  /**
52
70
  * Creates a Windows Notification Services (WNS) based installation.
@@ -54,7 +72,10 @@ export function createXiaomiInstallation(installation) {
54
72
  * @returns The newly created WNS installation.
55
73
  */
56
74
  export function createWindowsInstallation(installation) {
57
- return Object.assign(Object.assign({}, installation), { platform: "wns" });
75
+ return {
76
+ ...installation,
77
+ platform: "wns",
78
+ };
58
79
  }
59
80
  /**
60
81
  * Creates a Web Push based installation.
@@ -62,6 +83,9 @@ export function createWindowsInstallation(installation) {
62
83
  * @returns The newly created Web Push installation.
63
84
  */
64
85
  export function createBrowserInstallation(installation) {
65
- return Object.assign(Object.assign({}, installation), { platform: "browser" });
86
+ return {
87
+ ...installation,
88
+ platform: "browser",
89
+ };
66
90
  }
67
91
  //# sourceMappingURL=installation.js.map