@azure/eventgrid 5.0.0 → 5.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/index.js +852 -1640
  2. package/dist/index.js.map +1 -1
  3. package/dist-esm/src/cadl-generated/EventGridClient.js +41 -0
  4. package/dist-esm/src/cadl-generated/EventGridClient.js.map +1 -0
  5. package/dist-esm/src/cadl-generated/api/EventGridContext.js +10 -0
  6. package/dist-esm/src/cadl-generated/api/EventGridContext.js.map +1 -0
  7. package/dist-esm/src/cadl-generated/api/index.js +5 -0
  8. package/dist-esm/src/cadl-generated/api/index.js.map +1 -0
  9. package/dist-esm/src/cadl-generated/api/operations.js +198 -0
  10. package/dist-esm/src/cadl-generated/api/operations.js.map +1 -0
  11. package/dist-esm/src/cadl-generated/index.js +4 -0
  12. package/dist-esm/src/cadl-generated/index.js.map +1 -0
  13. package/dist-esm/src/cadl-generated/logger.js +5 -0
  14. package/dist-esm/src/cadl-generated/logger.js.map +1 -0
  15. package/dist-esm/src/cadl-generated/models/index.js +4 -0
  16. package/dist-esm/src/cadl-generated/models/index.js.map +1 -0
  17. package/dist-esm/src/cadl-generated/models/models.js +4 -0
  18. package/dist-esm/src/cadl-generated/models/models.js.map +1 -0
  19. package/dist-esm/src/cadl-generated/models/options.js +4 -0
  20. package/dist-esm/src/cadl-generated/models/options.js.map +1 -0
  21. package/dist-esm/src/cadl-generated/rest/clientDefinitions.js +4 -0
  22. package/dist-esm/src/cadl-generated/rest/clientDefinitions.js.map +1 -0
  23. package/dist-esm/src/cadl-generated/rest/eventGridClient.js +38 -0
  24. package/dist-esm/src/cadl-generated/rest/eventGridClient.js.map +1 -0
  25. package/dist-esm/src/cadl-generated/rest/index.js +12 -0
  26. package/dist-esm/src/cadl-generated/rest/index.js.map +1 -0
  27. package/dist-esm/src/cadl-generated/rest/isUnexpected.js +75 -0
  28. package/dist-esm/src/cadl-generated/rest/isUnexpected.js.map +1 -0
  29. package/dist-esm/src/cadl-generated/rest/models.js +4 -0
  30. package/dist-esm/src/cadl-generated/rest/models.js.map +1 -0
  31. package/dist-esm/src/cadl-generated/rest/outputModels.js +4 -0
  32. package/dist-esm/src/cadl-generated/rest/outputModels.js.map +1 -0
  33. package/dist-esm/src/cadl-generated/rest/parameters.js +4 -0
  34. package/dist-esm/src/cadl-generated/rest/parameters.js.map +1 -0
  35. package/dist-esm/src/cadl-generated/rest/responses.js +4 -0
  36. package/dist-esm/src/cadl-generated/rest/responses.js.map +1 -0
  37. package/dist-esm/src/eventGridClientV2.js +147 -0
  38. package/dist-esm/src/eventGridClientV2.js.map +1 -0
  39. package/dist-esm/src/eventGridV2PublishBinaryMode.js +63 -0
  40. package/dist-esm/src/eventGridV2PublishBinaryMode.js.map +1 -0
  41. package/dist-esm/src/generated/generatedClientContext.js +1 -1
  42. package/dist-esm/src/generated/generatedClientContext.js.map +1 -1
  43. package/dist-esm/src/generated/models/index.js.map +1 -1
  44. package/dist-esm/src/generated/models/mappers.js +372 -1673
  45. package/dist-esm/src/generated/models/mappers.js.map +1 -1
  46. package/dist-esm/src/index.js +1 -0
  47. package/dist-esm/src/index.js.map +1 -1
  48. package/dist-esm/src/models.js.map +1 -1
  49. package/dist-esm/src/predicates.js.map +1 -1
  50. package/dist-esm/src/tracing.js +1 -1
  51. package/dist-esm/src/tracing.js.map +1 -1
  52. package/package.json +10 -8
  53. package/types/eventgrid.d.ts +203 -705
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/cadl-generated/rest/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/** Properties of an event published to an Azure Messaging EventGrid Namespace topic using the CloudEvent 1.0 Schema. */\nexport interface CloudEvent {\n /** An identifier for the event. The combination of id and source must be unique for each distinct event. */\n id: string;\n /** Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event. */\n source: string;\n /** Event data specific to the event type. */\n data?: unknown;\n /** Event data specific to the event type, encoded as a base64 string. */\n data_base64?: string;\n /** Type of event related to the originating occurrence. */\n type: string;\n /** The time (in UTC) the event was generated, in RFC3339 format. */\n time?: Date | string;\n /** The version of the CloudEvents specification which the event uses. */\n specversion: string;\n /** Identifies the schema that data adheres to. */\n dataschema?: string;\n /** Content type of data value. */\n datacontenttype?: string;\n /** This describes the subject of the event in the context of the event producer (identified by source). */\n subject?: string;\n}\n\n/** Array of lock tokens for the corresponding received Cloud Events to be acknowledged. */\nexport interface AcknowledgeOptions {\n /** Array of lock tokens. */\n lockTokens: string[];\n}\n\n/** Array of lock tokens for the corresponding received Cloud Events to be released. */\nexport interface ReleaseOptions {\n /** Array of lock tokens. */\n lockTokens: string[];\n}\n\n/** Array of lock tokens for the corresponding received Cloud Events to be rejected. */\nexport interface RejectOptions {\n /** Array of lock tokens. */\n lockTokens: string[];\n}\n\n/** Array of lock tokens for the corresponding received Cloud Events to be renewed. */\nexport interface RenewLockOptions {\n /** Array of lock tokens. */\n lockTokens: string[];\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=outputModels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputModels.js","sourceRoot":"","sources":["../../../../src/cadl-generated/rest/outputModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ErrorModel } from \"@azure-rest/core-client\";\n\n/** Properties of an event published to an Azure Messaging EventGrid Namespace topic using the CloudEvent 1.0 Schema. */\nexport interface CloudEventOutput {\n /** An identifier for the event. The combination of id and source must be unique for each distinct event. */\n id: string;\n /** Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event. */\n source: string;\n /** Event data specific to the event type. */\n data?: any;\n /** Event data specific to the event type, encoded as a base64 string. */\n data_base64?: string;\n /** Type of event related to the originating occurrence. */\n type: string;\n /** The time (in UTC) the event was generated, in RFC3339 format. */\n time?: string;\n /** The version of the CloudEvents specification which the event uses. */\n specversion: string;\n /** Identifies the schema that data adheres to. */\n dataschema?: string;\n /** Content type of data value. */\n datacontenttype?: string;\n /** This describes the subject of the event in the context of the event producer (identified by source). */\n subject?: string;\n}\n\n/** The result of the Publish operation. */\nexport interface PublishResultOutput {}\n\n/** Details of the Receive operation response. */\nexport interface ReceiveResultOutput {\n /** Array of receive responses, one per cloud event. */\n value: Array<ReceiveDetailsOutput>;\n}\n\n/** Receive operation details per Cloud Event. */\nexport interface ReceiveDetailsOutput {\n /** The Event Broker details. */\n brokerProperties: BrokerPropertiesOutput;\n /** Cloud Event details. */\n event: CloudEventOutput;\n}\n\n/** Properties of the Event Broker operation. */\nexport interface BrokerPropertiesOutput {\n /** The token of the lock on the event. */\n lockToken: string;\n /** The attempt count for delivering the event. */\n deliveryCount: number;\n}\n\n/** The result of the Acknowledge operation. */\nexport interface AcknowledgeResultOutput {\n /** Array of FailedLockToken for failed cloud events. Each FailedLockToken includes the lock token along with the related error information (namely, the error code and description). */\n failedLockTokens: Array<FailedLockTokenOutput>;\n /** Array of lock tokens for the successfully acknowledged cloud events. */\n succeededLockTokens: string[];\n}\n\n/** Failed LockToken information. */\nexport interface FailedLockTokenOutput {\n /** The lock token of an entry in the request. */\n lockToken: string;\n /** Error information of the failed operation result for the lock token in the request. */\n error: ErrorModel;\n}\n\n/** The result of the Release operation. */\nexport interface ReleaseResultOutput {\n /** Array of FailedLockToken for failed cloud events. Each FailedLockToken includes the lock token along with the related error information (namely, the error code and description). */\n failedLockTokens: Array<FailedLockTokenOutput>;\n /** Array of lock tokens for the successfully released cloud events. */\n succeededLockTokens: string[];\n}\n\n/** The result of the Reject operation. */\nexport interface RejectResultOutput {\n /** Array of FailedLockToken for failed cloud events. Each FailedLockToken includes the lock token along with the related error information (namely, the error code and description). */\n failedLockTokens: Array<FailedLockTokenOutput>;\n /** Array of lock tokens for the successfully rejected cloud events. */\n succeededLockTokens: string[];\n}\n\n/** The result of the RenewLock operation. */\nexport interface RenewCloudEventLocksResultOutput {\n /** Array of FailedLockToken for failed cloud events. Each FailedLockToken includes the lock token along with the related error information (namely, the error code and description). */\n failedLockTokens: Array<FailedLockTokenOutput>;\n /** Array of lock tokens for the successfully renewed locks. */\n succeededLockTokens: string[];\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=parameters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../../../src/cadl-generated/rest/parameters.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RequestParameters } from \"@azure-rest/core-client\";\nimport {\n CloudEvent,\n AcknowledgeOptions,\n ReleaseOptions,\n RejectOptions,\n RenewLockOptions,\n} from \"./models\";\n\nexport interface PublishCloudEventBodyParam {\n /** Single Cloud Event being published. */\n body: CloudEvent;\n}\n\nexport interface PublishCloudEventMediaTypesParam {\n /** content type */\n contentType: \"application/cloudevents+json; charset=utf-8\";\n}\n\nexport type PublishCloudEventParameters = PublishCloudEventMediaTypesParam &\n PublishCloudEventBodyParam &\n RequestParameters;\n\nexport interface PublishCloudEventsBodyParam {\n /** Array of Cloud Events being published. */\n body: Array<CloudEvent>;\n}\n\nexport interface PublishCloudEventsMediaTypesParam {\n /** content type */\n contentType: \"application/cloudevents-batch+json; charset=utf-8\";\n}\n\nexport type PublishCloudEventsParameters = PublishCloudEventsMediaTypesParam &\n PublishCloudEventsBodyParam &\n RequestParameters;\n\nexport interface ReceiveCloudEventsQueryParamProperties {\n /** Max Events count to be received. Minimum value is 1, while maximum value is 100 events. If not specified, the default value is 1. */\n maxEvents?: number;\n /** Max wait time value for receive operation in Seconds. It is the time in seconds that the server approximately waits for the availability of an event and responds to the request. If an event is available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120 seconds. If not specified, the default value is 60 seconds. */\n maxWaitTime?: number;\n}\n\nexport interface ReceiveCloudEventsQueryParam {\n queryParameters?: ReceiveCloudEventsQueryParamProperties;\n}\n\nexport type ReceiveCloudEventsParameters = ReceiveCloudEventsQueryParam & RequestParameters;\n\nexport interface AcknowledgeCloudEventsBodyParam {\n /** AcknowledgeOptions. */\n body: AcknowledgeOptions;\n}\n\nexport type AcknowledgeCloudEventsParameters = AcknowledgeCloudEventsBodyParam & RequestParameters;\n\nexport interface ReleaseCloudEventsBodyParam {\n /** ReleaseOptions */\n body: ReleaseOptions;\n}\n\nexport interface ReleaseCloudEventsQueryParamProperties {\n /**\n * Release cloud events with the specified delay in seconds.\n *\n * Possible values: 0, 10, 60, 600, 3600\n */\n releaseDelayInSeconds?: string;\n}\n\nexport interface ReleaseCloudEventsQueryParam {\n queryParameters?: ReleaseCloudEventsQueryParamProperties;\n}\n\nexport type ReleaseCloudEventsParameters = ReleaseCloudEventsQueryParam &\n ReleaseCloudEventsBodyParam &\n RequestParameters;\n\nexport interface RejectCloudEventsBodyParam {\n /** RejectOptions */\n body: RejectOptions;\n}\n\nexport type RejectCloudEventsParameters = RejectCloudEventsBodyParam & RequestParameters;\n\nexport interface RenewCloudEventLocksBodyParam {\n /** RenewLockOptions */\n body: RenewLockOptions;\n}\n\nexport type RenewCloudEventLocksParameters = RenewCloudEventLocksBodyParam & RequestParameters;\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=responses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responses.js","sourceRoot":"","sources":["../../../../src/cadl-generated/rest/responses.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RawHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport { HttpResponse, ErrorResponse } from \"@azure-rest/core-client\";\nimport {\n PublishResultOutput,\n ReceiveResultOutput,\n AcknowledgeResultOutput,\n ReleaseResultOutput,\n RejectResultOutput,\n RenewCloudEventLocksResultOutput,\n} from \"./outputModels\";\n\n/** The request has succeeded. */\nexport interface PublishCloudEvent200Response extends HttpResponse {\n status: \"200\";\n body: PublishResultOutput;\n}\n\nexport interface PublishCloudEventDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface PublishCloudEventDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & PublishCloudEventDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface PublishCloudEvents200Response extends HttpResponse {\n status: \"200\";\n body: PublishResultOutput;\n}\n\nexport interface PublishCloudEventsDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface PublishCloudEventsDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & PublishCloudEventsDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface ReceiveCloudEvents200Response extends HttpResponse {\n status: \"200\";\n body: ReceiveResultOutput;\n}\n\nexport interface ReceiveCloudEventsDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface ReceiveCloudEventsDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & ReceiveCloudEventsDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface AcknowledgeCloudEvents200Response extends HttpResponse {\n status: \"200\";\n body: AcknowledgeResultOutput;\n}\n\nexport interface AcknowledgeCloudEventsDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface AcknowledgeCloudEventsDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & AcknowledgeCloudEventsDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface ReleaseCloudEvents200Response extends HttpResponse {\n status: \"200\";\n body: ReleaseResultOutput;\n}\n\nexport interface ReleaseCloudEventsDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface ReleaseCloudEventsDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & ReleaseCloudEventsDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface RejectCloudEvents200Response extends HttpResponse {\n status: \"200\";\n body: RejectResultOutput;\n}\n\nexport interface RejectCloudEventsDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface RejectCloudEventsDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & RejectCloudEventsDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface RenewCloudEventLocks200Response extends HttpResponse {\n status: \"200\";\n body: RenewCloudEventLocksResultOutput;\n}\n\nexport interface RenewCloudEventLocksDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface RenewCloudEventLocksDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & RenewCloudEventLocksDefaultHeaders;\n}\n"]}
@@ -0,0 +1,147 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import { cloudEventReservedPropertyNames } from "./models";
4
+ import { v4 as uuidv4 } from "uuid";
5
+ import { EventGridClient as EventGridClientGenerated } from "./cadl-generated/EventGridClient";
6
+ import { publishCloudEventBinaryMode } from "./eventGridV2PublishBinaryMode";
7
+ /**
8
+ * Event Grid Client
9
+ */
10
+ export class EventGridClient {
11
+ /** Azure Messaging EventGrid Client */
12
+ constructor(endpoint, credential, options = {}) {
13
+ // credential.update(`SharedAccessKey ${credential.key}`);
14
+ this._client = new EventGridClientGenerated(endpoint, credential, options);
15
+ }
16
+ /**
17
+ * Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200
18
+ * status code with an empty JSON object in response. Otherwise, the server can return various error codes.
19
+ * For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message
20
+ * is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for
21
+ * internal server error.
22
+ *
23
+ * @param event - Event to publish
24
+ * @param topicName - Topic to publish the event
25
+ * @param options - Options to publish
26
+ *
27
+ */
28
+ publishCloudEvent(event, topicName, options = { requestOptions: {} }) {
29
+ const cloudEventWireModel = convertCloudEventToModelType(event);
30
+ if (!options.binaryMode) {
31
+ return this._client.publishCloudEvent(cloudEventWireModel.id, cloudEventWireModel.source, cloudEventWireModel.type, cloudEventWireModel.specversion, topicName, Object.assign({ time: cloudEventWireModel.time, dataschema: cloudEventWireModel.dataschema, datacontenttype: cloudEventWireModel.datacontenttype, subject: cloudEventWireModel.subject, contentType: options.contentType, data: cloudEventWireModel.data, dataBase64: cloudEventWireModel.dataBase64 }, options));
32
+ }
33
+ else {
34
+ return publishCloudEventBinaryMode(this._client.getClient(), cloudEventWireModel.id, cloudEventWireModel.source, cloudEventWireModel.type, cloudEventWireModel.specversion, topicName, Object.assign({ time: cloudEventWireModel.time, dataschema: cloudEventWireModel.dataschema, datacontenttype: cloudEventWireModel.datacontenttype, subject: cloudEventWireModel.subject, contentType: options.contentType, data: cloudEventWireModel.data, dataBase64: cloudEventWireModel.dataBase64 }, options));
35
+ }
36
+ }
37
+ /**
38
+ * Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200
39
+ * status code with an empty JSON object in response. Otherwise, the server can return various error codes.
40
+ * For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message
41
+ * is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for
42
+ * internal server error.
43
+ *
44
+ * @param events - Events to publish
45
+ * @param topicName - Topic to publish the event
46
+ * @param options - Options to publish
47
+ *
48
+ */
49
+ publishCloudEvents(events, topicName, options = { requestOptions: {} }) {
50
+ const eventsWireModel = [];
51
+ for (const individualevent of events) {
52
+ eventsWireModel.push(convertCloudEventToModelType(individualevent));
53
+ }
54
+ return this._client.publishCloudEvents(eventsWireModel, topicName, options);
55
+ }
56
+ /**
57
+ * Receive Batch of Cloud Events from the Event Subscription.
58
+ *
59
+ * @param topicName - Topic to receive
60
+ * @param eventSubscriptionName - Name of the Event Subscription
61
+ * @param options - Options to receive
62
+ *
63
+ */
64
+ receiveCloudEvents(topicName, eventSubscriptionName, options = { requestOptions: {} }) {
65
+ return this._client.receiveCloudEvents(topicName, eventSubscriptionName, options);
66
+ }
67
+ /**
68
+ * Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if at least one
69
+ * event is successfully acknowledged. The response body will include the set of successfully acknowledged
70
+ * lockTokens, along with other failed lockTokens with their corresponding error information. Successfully
71
+ * acknowledged events will no longer be available to any consumer.
72
+ *
73
+ * @param lockTokens - Lock Tokens
74
+ * @param topicName - Topic Name
75
+ * @param eventSubscriptionName - Name of the Event Subscription
76
+ * @param options - Options to Acknowledge
77
+ *
78
+ */
79
+ acknowledgeCloudEvents(lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
80
+ return this._client.acknowledgeCloudEvents(lockTokens, topicName, eventSubscriptionName, options);
81
+ }
82
+ /**
83
+ * Release batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is
84
+ * successfully released. The response body will include the set of successfully released lockTokens, along
85
+ * with other failed lockTokens with their corresponding error information.
86
+ *
87
+ * @param lockTokens - Lock Tokens
88
+ * @param topicName - Topic Name
89
+ * @param eventSubscriptionName - Name of the Event Subscription
90
+ * @param options - Options to release
91
+ *
92
+ */
93
+ releaseCloudEvents(lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
94
+ return this._client.releaseCloudEvents(lockTokens, topicName, eventSubscriptionName, options);
95
+ }
96
+ /**
97
+ * Reject batch of Cloud Events.
98
+ *
99
+ * @param lockTokens - Lock Tokens
100
+ * @param topicName - Topic Name
101
+ * @param eventSubscriptionName - Name of the Event Subscription
102
+ * @param options - Options to reject
103
+ *
104
+ */
105
+ rejectCloudEvents(lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
106
+ return this._client.rejectCloudEvents(lockTokens, topicName, eventSubscriptionName, options);
107
+ }
108
+ /**
109
+ * Renew lock for batch of Cloud Events.
110
+ *
111
+ * @param lockTokens - Lock Tokens
112
+ * @param topicName - Topic Name
113
+ * @param eventSubscriptionName - Name of the Event Subscription
114
+ * @param options - Options to renew
115
+ */
116
+ renewCloudEventLocks(lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
117
+ return this._client.renewCloudEventLocks(lockTokens, topicName, eventSubscriptionName, options);
118
+ }
119
+ }
120
+ export function convertCloudEventToModelType(event) {
121
+ var _a, _b, _c, _d, _e;
122
+ if (event.extensionAttributes) {
123
+ for (const propName in event.extensionAttributes) {
124
+ // Per the cloud events spec: "CloudEvents attribute names MUST consist of lower-case letters ('a' to 'z') or digits ('0' to '9') from the ASCII character set"
125
+ // they also can not match an existing defined property name.
126
+ if (!/^[a-z0-9]*$/.test(propName) ||
127
+ cloudEventReservedPropertyNames.indexOf(propName) !== -1) {
128
+ throw new Error(`invalid extension attribute name: ${propName}`);
129
+ }
130
+ }
131
+ }
132
+ const converted = Object.assign({ specversion: (_a = event.specversion) !== null && _a !== void 0 ? _a : "1.0", type: event.type, source: event.source, id: (_b = event.id) !== null && _b !== void 0 ? _b : uuidv4(), time: (_c = event.time) !== null && _c !== void 0 ? _c : new Date(), subject: event.subject, dataschema: event.dataschema }, ((_d = event.extensionAttributes) !== null && _d !== void 0 ? _d : []));
133
+ if (event.data instanceof Uint8Array) {
134
+ if (!event.datacontenttype) {
135
+ throw new Error("a data content type must be provided when sending an event with binary data");
136
+ }
137
+ converted.datacontenttype = event.datacontenttype;
138
+ converted.dataBase64 = event.data;
139
+ }
140
+ else {
141
+ converted.datacontenttype =
142
+ (_e = event.datacontenttype) !== null && _e !== void 0 ? _e : "application/cloudevents+json; charset=utf-8";
143
+ converted.data = event.data;
144
+ }
145
+ return converted;
146
+ }
147
+ //# sourceMappingURL=eventGridClientV2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventGridClientV2.js","sourceRoot":"","sources":["../../src/eventGridClientV2.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAgBlC,OAAO,EAAc,+BAA+B,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,eAAe,IAAI,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAI/F,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAE7E;;GAEG;AACH,MAAM,OAAO,eAAe;IAG1B,uCAAuC;IACvC,YACE,QAAgB,EAChB,UAA8B,EAC9B,UAAkC,EAAE;QAEpC,0DAA0D;QAC1D,IAAI,CAAC,OAAO,GAAG,IAAI,wBAAwB,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;;;;;;OAWG;IACH,iBAAiB,CACf,KAAoB,EACpB,SAAiB,EACjB,UAAoC,EAAE,cAAc,EAAE,EAAE,EAAE;QAE1D,MAAM,mBAAmB,GAAwB,4BAA4B,CAAC,KAAK,CAAC,CAAC;QAErF,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CACnC,mBAAmB,CAAC,EAAE,EACtB,mBAAmB,CAAC,MAAM,EAC1B,mBAAmB,CAAC,IAAI,EACxB,mBAAmB,CAAC,WAAW,EAC/B,SAAS,kBAEP,IAAI,EAAE,mBAAmB,CAAC,IAAI,EAC9B,UAAU,EAAE,mBAAmB,CAAC,UAAU,EAC1C,eAAe,EAAE,mBAAmB,C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+B,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EACxD;gBACA,MAAM,IAAI,KAAK,CAAC,qCAAqC,QAAQ,EAAE,CAAC,CAAC;aAClE;SACF;KACF;IAED,MAAM,SAAS,mBACb,WAAW,EAAE,MAAA,KAAK,CAAC,WAAW,mCAAI,KAAK,EACvC,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,EAAE,EAAE,MAAA,KAAK,CAAC,EAAE,mCAAI,MAAM,EAAE,EACxB,IAAI,EAAE,MAAA,KAAK,CAAC,IAAI,mCAAI,IAAI,IAAI,EAAE,EAC9B,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,UAAU,EAAE,KAAK,CAAC,UAAU,IACzB,CAAC,MAAA,KAAK,CAAC,mBAAmB,mCAAI,EAAE,CAAC,CACrC,CAAC;IAEF,IAAI,KAAK,CAAC,IAAI,YAAY,UAAU,EAAE;QACpC,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE;YAC1B,MAAM,IAAI,KAAK,CACb,6EAA6E,CAC9E,CAAC;SACH;QAED,SAAS,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;QAClD,SAAS,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC;KACnC;SAAM;QACL,SAAS,CAAC,eAAe;YACvB,MAAA,KAAK,CAAC,eAAe,mCAAI,6CAA6C,CAAC;QACzE,SAAS,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;KAC7B;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AzureKeyCredential } from \"@azure/core-auth\";\nimport {\n ReceiveResult,\n AcknowledgeResult,\n ReleaseResult,\n RejectResult,\n PublishCloudEventsOptions,\n ReceiveCloudEventsOptions,\n AcknowledgeCloudEventsOptions,\n ReleaseCloudEventsOptions,\n RejectCloudEventsOptions,\n RenewCloudEventLocksOptions,\n RenewCloudEventLocksResult,\n} from \"./cadl-generated/models\";\nimport { CloudEvent, cloudEventReservedPropertyNames } from \"./models\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { CloudEvent as CloudEventWireModel } from \"./cadl-generated/models/\";\nimport { EventGridClient as EventGridClientGenerated } from \"./cadl-generated/EventGridClient\";\nimport { EventGridClientOptions } from \"./cadl-generated/api\";\nimport { PublishResultOutput } from \"./cadl-generated/rest\";\nimport { PublishCloudEventOptions } from \"./models\";\nimport { publishCloudEventBinaryMode } from \"./eventGridV2PublishBinaryMode\";\n\n/**\n * Event Grid Client\n */\nexport class EventGridClient {\n private _client: EventGridClientGenerated;\n\n /** Azure Messaging EventGrid Client */\n constructor(\n endpoint: string,\n credential: AzureKeyCredential,\n options: EventGridClientOptions = {}\n ) {\n // credential.update(`SharedAccessKey ${credential.key}`);\n this._client = new EventGridClientGenerated(endpoint, credential, options);\n }\n\n /**\n * Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200\n * status code with an empty JSON object in response. Otherwise, the server can return various error codes.\n * For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message\n * is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for\n * internal server error.\n *\n * @param event - Event to publish\n * @param topicName - Topic to publish the event\n * @param options - Options to publish\n *\n */\n publishCloudEvent<T>(\n event: CloudEvent<T>,\n topicName: string,\n options: PublishCloudEventOptions = { requestOptions: {} }\n ): Promise<PublishResultOutput> {\n const cloudEventWireModel: CloudEventWireModel = convertCloudEventToModelType(event);\n\n if (!options.binaryMode) {\n return this._client.publishCloudEvent(\n cloudEventWireModel.id,\n cloudEventWireModel.source,\n cloudEventWireModel.type,\n cloudEventWireModel.specversion,\n topicName,\n {\n time: cloudEventWireModel.time,\n dataschema: cloudEventWireModel.dataschema,\n datacontenttype: cloudEventWireModel.datacontenttype,\n subject: cloudEventWireModel.subject,\n contentType: options.contentType,\n data: cloudEventWireModel.data,\n dataBase64: cloudEventWireModel.dataBase64,\n ...options,\n }\n );\n } else {\n return publishCloudEventBinaryMode(\n this._client.getClient(),\n cloudEventWireModel.id,\n cloudEventWireModel.source,\n cloudEventWireModel.type,\n cloudEventWireModel.specversion,\n topicName,\n {\n time: cloudEventWireModel.time,\n dataschema: cloudEventWireModel.dataschema,\n datacontenttype: cloudEventWireModel.datacontenttype,\n subject: cloudEventWireModel.subject,\n contentType: options.contentType,\n data: cloudEventWireModel.data,\n dataBase64: cloudEventWireModel.dataBase64,\n ...options,\n }\n );\n }\n }\n\n /**\n * Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200\n * status code with an empty JSON object in response. Otherwise, the server can return various error codes.\n * For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message\n * is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for\n * internal server error.\n *\n * @param events - Events to publish\n * @param topicName - Topic to publish the event\n * @param options - Options to publish\n *\n */\n publishCloudEvents<T>(\n events: CloudEvent<T>[],\n topicName: string,\n options: PublishCloudEventsOptions = { requestOptions: {} }\n ): Promise<PublishResultOutput> {\n const eventsWireModel: Array<CloudEventWireModel> = [];\n for (const individualevent of events) {\n eventsWireModel.push(convertCloudEventToModelType(individualevent));\n }\n return this._client.publishCloudEvents(eventsWireModel, topicName, options);\n }\n\n /**\n * Receive Batch of Cloud Events from the Event Subscription.\n *\n * @param topicName - Topic to receive\n * @param eventSubscriptionName - Name of the Event Subscription\n * @param options - Options to receive\n *\n */\n receiveCloudEvents<T>(\n topicName: string,\n eventSubscriptionName: string,\n options: ReceiveCloudEventsOptions = { requestOptions: {} }\n ): Promise<ReceiveResult<T>> {\n return this._client.receiveCloudEvents(topicName, eventSubscriptionName, options);\n }\n\n /**\n * Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if at least one\n * event is successfully acknowledged. The response body will include the set of successfully acknowledged\n * lockTokens, along with other failed lockTokens with their corresponding error information. Successfully\n * acknowledged events will no longer be available to any consumer.\n *\n * @param lockTokens - Lock Tokens\n * @param topicName - Topic Name\n * @param eventSubscriptionName - Name of the Event Subscription\n * @param options - Options to Acknowledge\n *\n */\n acknowledgeCloudEvents(\n lockTokens: string[],\n topicName: string,\n eventSubscriptionName: string,\n options: AcknowledgeCloudEventsOptions = { requestOptions: {} }\n ): Promise<AcknowledgeResult> {\n return this._client.acknowledgeCloudEvents(\n lockTokens,\n topicName,\n eventSubscriptionName,\n options\n );\n }\n\n /**\n * Release batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is\n * successfully released. The response body will include the set of successfully released lockTokens, along\n * with other failed lockTokens with their corresponding error information.\n *\n * @param lockTokens - Lock Tokens\n * @param topicName - Topic Name\n * @param eventSubscriptionName - Name of the Event Subscription\n * @param options - Options to release\n *\n */\n releaseCloudEvents(\n lockTokens: string[],\n topicName: string,\n eventSubscriptionName: string,\n options: ReleaseCloudEventsOptions = { requestOptions: {} }\n ): Promise<ReleaseResult> {\n return this._client.releaseCloudEvents(lockTokens, topicName, eventSubscriptionName, options);\n }\n\n /**\n * Reject batch of Cloud Events.\n *\n * @param lockTokens - Lock Tokens\n * @param topicName - Topic Name\n * @param eventSubscriptionName - Name of the Event Subscription\n * @param options - Options to reject\n *\n */\n rejectCloudEvents(\n lockTokens: string[],\n topicName: string,\n eventSubscriptionName: string,\n options: RejectCloudEventsOptions = { requestOptions: {} }\n ): Promise<RejectResult> {\n return this._client.rejectCloudEvents(lockTokens, topicName, eventSubscriptionName, options);\n }\n\n /**\n * Renew lock for batch of Cloud Events.\n *\n * @param lockTokens - Lock Tokens\n * @param topicName - Topic Name\n * @param eventSubscriptionName - Name of the Event Subscription\n * @param options - Options to renew\n */\n renewCloudEventLocks(\n lockTokens: string[],\n topicName: string,\n eventSubscriptionName: string,\n options: RenewCloudEventLocksOptions = { requestOptions: {} }\n ): Promise<RenewCloudEventLocksResult> {\n return this._client.renewCloudEventLocks(lockTokens, topicName, eventSubscriptionName, options);\n }\n}\n\nexport function convertCloudEventToModelType<T>(event: CloudEvent<T>): CloudEventWireModel {\n if (event.extensionAttributes) {\n for (const propName in event.extensionAttributes) {\n // Per the cloud events spec: \"CloudEvents attribute names MUST consist of lower-case letters ('a' to 'z') or digits ('0' to '9') from the ASCII character set\"\n // they also can not match an existing defined property name.\n\n if (\n !/^[a-z0-9]*$/.test(propName) ||\n cloudEventReservedPropertyNames.indexOf(propName) !== -1\n ) {\n throw new Error(`invalid extension attribute name: ${propName}`);\n }\n }\n }\n\n const converted: CloudEventWireModel = {\n specversion: event.specversion ?? \"1.0\",\n type: event.type,\n source: event.source,\n id: event.id ?? uuidv4(),\n time: event.time ?? new Date(),\n subject: event.subject,\n dataschema: event.dataschema,\n ...(event.extensionAttributes ?? []),\n };\n\n if (event.data instanceof Uint8Array) {\n if (!event.datacontenttype) {\n throw new Error(\n \"a data content type must be provided when sending an event with binary data\"\n );\n }\n\n converted.datacontenttype = event.datacontenttype;\n converted.dataBase64 = event.data;\n } else {\n converted.datacontenttype =\n event.datacontenttype ?? \"application/cloudevents+json; charset=utf-8\";\n converted.data = event.data;\n }\n\n return converted;\n}\n"]}
@@ -0,0 +1,63 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import { isUnexpected, } from "./cadl-generated/rest/index";
4
+ import { operationOptionsToRequestParameters } from "@azure-rest/core-client";
5
+ import { Buffer } from "buffer";
6
+ export async function publishCloudEventBinaryMode(context, id, source, type, specversion, topicName, options = { requestOptions: {} }) {
7
+ const result = await _publishCloudEventSendBinaryMode(context, id, source, type, specversion, topicName, options);
8
+ return _publishCloudEventDeserialize(result);
9
+ }
10
+ export async function _publishCloudEventDeserialize(result) {
11
+ if (isUnexpected(result)) {
12
+ throw result.body;
13
+ }
14
+ return result.body;
15
+ }
16
+ export function _publishCloudEventSendBinaryMode(context, id, source, type, specversion, topicName, options = { requestOptions: {} }) {
17
+ var _a, _b;
18
+ const headers = {
19
+ "ce-id": id,
20
+ "ce-source": source,
21
+ "ce-type": type,
22
+ "ce-specversion": specversion,
23
+ };
24
+ if (options === null || options === void 0 ? void 0 : options.time) {
25
+ headers["ce-time"] = options.time.toISOString();
26
+ }
27
+ if (options === null || options === void 0 ? void 0 : options.dataschema) {
28
+ headers["ce-dataschema"] = options.dataschema;
29
+ }
30
+ if (options === null || options === void 0 ? void 0 : options.datacontenttype) {
31
+ headers["ce-datacontenttype"] = options.datacontenttype;
32
+ }
33
+ if (options === null || options === void 0 ? void 0 : options.subject) {
34
+ headers["ce-subject"] = options.subject;
35
+ }
36
+ let data;
37
+ if (options === null || options === void 0 ? void 0 : options.data) {
38
+ // If data is already encoded
39
+ if (Buffer.isBuffer(options.data)) {
40
+ data = options.data;
41
+ }
42
+ else {
43
+ throw new Error(`CloudEvent data must be binary when in binary mode.`);
44
+ }
45
+ }
46
+ else {
47
+ if (options === null || options === void 0 ? void 0 : options.dataBase64) {
48
+ data = options.dataBase64;
49
+ }
50
+ }
51
+ return context.path("/topics/{topicName}:publish", topicName).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: (_a = options.contentType) !== null && _a !== void 0 ? _a : "application/cloudevents+json; charset=utf-8", headers, body: {
52
+ id: id,
53
+ source: source,
54
+ data,
55
+ type: type,
56
+ time: (_b = options === null || options === void 0 ? void 0 : options.time) === null || _b === void 0 ? void 0 : _b.toISOString(),
57
+ specversion: specversion,
58
+ dataschema: options === null || options === void 0 ? void 0 : options.dataschema,
59
+ datacontenttype: options === null || options === void 0 ? void 0 : options.datacontenttype,
60
+ subject: options === null || options === void 0 ? void 0 : options.subject,
61
+ } }));
62
+ }
63
+ //# sourceMappingURL=eventGridV2PublishBinaryMode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventGridV2PublishBinaryMode.js","sourceRoot":"","sources":["../../src/eventGridV2PublishBinaryMode.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,YAAY,GAIb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAoB,mCAAmC,EAA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{\n isUnexpected,\n EventGridContext as Client,\n PublishCloudEvent200Response,\n PublishCloudEventDefaultResponse,\n} from \"./cadl-generated/rest/index\";\nimport { StreamableMethod, operationOptionsToRequestParameters } from \"@azure-rest/core-client\";\nimport { PublishCloudEventOptions } from \"./cadl-generated/models/options\";\nimport { RawHttpHeadersInput } from \"@azure/core-rest-pipeline\";\nimport { Buffer } from \"buffer\";\n\nexport async function publishCloudEventBinaryMode(\n context: Client,\n id: string,\n source: string,\n type: string,\n specversion: string,\n topicName: string,\n options: PublishCloudEventOptions = { requestOptions: {} }\n): Promise<Record<string, any>> {\n const result = await _publishCloudEventSendBinaryMode(\n context,\n id,\n source,\n type,\n specversion,\n topicName,\n options\n );\n return _publishCloudEventDeserialize(result);\n}\n\nexport async function _publishCloudEventDeserialize(\n result: PublishCloudEvent200Response | PublishCloudEventDefaultResponse\n): Promise<Record<string, any>> {\n if (isUnexpected(result)) {\n throw result.body;\n }\n\n return result.body;\n}\n\nexport function _publishCloudEventSendBinaryMode(\n context: Client,\n id: string,\n source: string,\n type: string,\n specversion: string,\n topicName: string,\n options: PublishCloudEventOptions = { requestOptions: {} }\n): StreamableMethod<PublishCloudEvent200Response | PublishCloudEventDefaultResponse> {\n const headers: RawHttpHeadersInput = {\n \"ce-id\": id,\n \"ce-source\": source,\n \"ce-type\": type,\n \"ce-specversion\": specversion,\n };\n\n if (options?.time) {\n headers[\"ce-time\"] = options.time.toISOString();\n }\n\n if (options?.dataschema) {\n headers[\"ce-dataschema\"] = options.dataschema;\n }\n\n if (options?.datacontenttype) {\n headers[\"ce-datacontenttype\"] = options.datacontenttype;\n }\n\n if (options?.subject) {\n headers[\"ce-subject\"] = options.subject;\n }\n\n let data: any;\n if (options?.data) {\n // If data is already encoded\n if (Buffer.isBuffer(options.data)) {\n data = options.data;\n } else {\n throw new Error(`CloudEvent data must be binary when in binary mode.`);\n }\n } else {\n if (options?.dataBase64) {\n data = options.dataBase64;\n }\n }\n\n return context.path(\"/topics/{topicName}:publish\", topicName).post({\n ...operationOptionsToRequestParameters(options),\n contentType: (options.contentType as any) ?? \"application/cloudevents+json; charset=utf-8\",\n headers,\n body: {\n id: id,\n source: source,\n data,\n type: type,\n time: options?.time?.toISOString(),\n specversion: specversion,\n dataschema: options?.dataschema,\n datacontenttype: options?.datacontenttype,\n subject: options?.subject,\n },\n });\n}\n"]}
@@ -20,7 +20,7 @@ export class GeneratedClientContext extends coreClient.ServiceClient {
20
20
  const defaults = {
21
21
  requestContentType: "application/json; charset=utf-8"
22
22
  };
23
- const packageDetails = `azsdk-js-eventgrid/5.0.0`;
23
+ const packageDetails = `azsdk-js-eventgrid/5.1.0-beta.1`;
24
24
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
25
25
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
26
26
  : `${packageDetails}`;
@@ -1 +1 @@
1
- {"version":3,"file":"generatedClientContext.js","sourceRoot":"","sources":["../../../src/generated/generatedClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,gBAAgB;AAChB,MAAM,OAAO,sBAAuB,SAAQ,UAAU,CAAC,aAAa;IAGlE;;;OAGG;IACH,YAAY,OAAuC;QACjD,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAAkC;YAC9C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,0BAA0B,CAAC;QAClD,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,iBAAiB,GAC/C,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAE3B,0CAA0C;QAC1C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,YAAY,CAAC;IACvD,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { GeneratedClientOptionalParams } from \"./models\";\n\n/** @internal */\nexport class GeneratedClientContext extends coreClient.ServiceClient {\n apiVersion: string;\n\n /**\n * Initializes a new instance of the GeneratedClientContext class.\n * @param options The parameter options\n */\n constructor(options?: GeneratedClientOptionalParams) {\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-eventgrid/5.0.0`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint || \"{topicHostname}\"\n };\n super(optionsWithDefaults);\n\n // Assigning values to Constant parameters\n this.apiVersion = options.apiVersion || \"2018-01-01\";\n }\n}\n"]}
1
+ {"version":3,"file":"generatedClientContext.js","sourceRoot":"","sources":["../../../src/generated/generatedClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,gBAAgB;AAChB,MAAM,OAAO,sBAAuB,SAAQ,UAAU,CAAC,aAAa;IAGlE;;;OAGG;IACH,YAAY,OAAuC;QACjD,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAAkC;YAC9C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,iCAAiC,CAAC;QACzD,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,iBAAiB,GAC/C,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAE3B,0CAA0C;QAC1C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,YAAY,CAAC;IACvD,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { GeneratedClientOptionalParams } from \"./models\";\n\n/** @internal */\nexport class GeneratedClientContext extends coreClient.ServiceClient {\n apiVersion: string;\n\n /**\n * Initializes a new instance of the GeneratedClientContext class.\n * @param options The parameter options\n */\n constructor(options?: GeneratedClientOptionalParams) {\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-eventgrid/5.1.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint || \"{topicHostname}\"\n };\n super(optionsWithDefaults);\n\n // Assigning values to Constant parameters\n this.apiVersion = options.apiVersion || \"2018-01-01\";\n }\n}\n"]}