@azure/eventgrid 4.10.0-beta.1 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist-esm/src/eventGridClient.js.map +1 -1
- package/dist-esm/src/generated/generatedClientContext.js +1 -1
- package/dist-esm/src/generated/generatedClientContext.js.map +1 -1
- package/dist-esm/src/tracing.js +1 -1
- package/dist-esm/src/tracing.js.map +1 -1
- package/dist-esm/src/util.js +2 -2
- package/dist-esm/src/util.js.map +1 -1
- package/package.json +6 -6
- package/types/eventgrid.d.ts +1 -1
- package/CHANGELOG.md +0 -188
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"eventGridClient.js","sourceRoot":"","sources":["../../src/eventGridClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,iBAAiB,EAAgC,MAAM,kBAAkB,CAAC;AAGnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAGL,+BAA+B,GAChC,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAM9D,OAAO,EAAE,0CAA0C,EAAE,MAAM,6CAA6C,CAAC;AACzG,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AA+D/F;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAqBnC;;;;;;;;;;;;;;;;;;OAkBG;IACH,YACE,WAAmB,EACnB,WAAc,EACd,UAA2D,EAC3D,UAA2C,EAAE;QAE7C,IAAI,CAAC,WAAW,GAAG,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AClB,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,GAAG,MAAA,KAAK,CAAC,eAAe,mCAAI,kBAAkB,CAAC;QACxE,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 { isTokenCredential, KeyCredential, SASCredential } from \"@azure/core-auth\";\nimport { OperationOptions, CommonClientOptions } from \"@azure/core-client\";\n\nimport { eventGridCredentialPolicy } from \"./eventGridAuthenticationPolicy\";\nimport { DEFAULT_EVENTGRID_SCOPE } from \"./constants\";\nimport {\n SendCloudEventInput,\n SendEventGridEventInput,\n cloudEventReservedPropertyNames,\n} from \"./models\";\nimport { GeneratedClient } from \"./generated/generatedClient\";\nimport {\n CloudEvent as CloudEventWireModel,\n EventGridEvent as EventGridEventWireModel,\n GeneratedClientPublishCloudEventEventsOptionalParams,\n} from \"./generated/models\";\nimport { cloudEventDistributedTracingEnricherPolicy } from \"./cloudEventDistrubtedTracingEnricherPolicy\";\nimport { tracingClient } from \"./tracing\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { bearerTokenAuthenticationPolicy, tracingPolicyName } from \"@azure/core-rest-pipeline\";\n\n/**\n * Options for the Event Grid Client.\n */\nexport type EventGridPublisherClientOptions = CommonClientOptions;\n\n/**\n * Options for the send events operation.\n */\nexport type SendOptions = OperationOptions;\n\n/***\n * Options for the send events operation, when the input schema is cloud event.\n */\nexport interface CloudEventSendOptions extends SendOptions {\n /**\n * The name of the channel to send the event to (only valid for Partner Namespaces and Topics).\n */\n channelName?: string;\n}\n\n/**\n * A map of input schema names to shapes of the input for the send method on EventGridPublisherClient.\n */\nexport interface InputSchemaToInputTypeMap {\n /**\n * The shape of the input to `send` when the client is configured to send events using the Event Grid schema.\n */\n EventGrid: SendEventGridEventInput<unknown>;\n /**\n * The shape of the input to `send` when the client is configured to send events using the Cloud Event schema.\n */\n CloudEvent: SendCloudEventInput<unknown>;\n /**\n * The shape of the input to `send` when the client is configured to send events using a custom schema.\n */\n Custom: Record<string, unknown>;\n}\n\n/**\n * A map of input schema names to shapes of the options bag for the send method on EventGridPublisherClient.\n */\nexport interface InputSchemaToOptionsTypeMap {\n /**\n * The shape of the options parameter for `send` when the client is configured to send events using the Event Grid schema.\n */\n EventGrid: SendOptions;\n /**\n * The shape of the options parameter for `send` when the client is configured to send events using the Cloud Event schema.\n */\n CloudEvent: CloudEventSendOptions;\n /**\n * The shape of the options parameter for `send` when the client is configured to send events using a custom schema.\n */\n Custom: SendOptions;\n}\n\n/**\n * Allowed schema types, to be used when constructing the EventGridPublisherClient.\n */\nexport type InputSchema = keyof InputSchemaToInputTypeMap;\n\n/**\n * Client class for publishing events to the Event Grid Service.\n */\nexport class EventGridPublisherClient<T extends InputSchema> {\n /**\n * The URL to the Event Grid endpoint.\n */\n public readonly endpointUrl: string;\n\n /**\n * The version of the Even Grid service.\n */\n public readonly apiVersion: string;\n\n /**\n * The AutoRest generated client for the EventGrid dataplane.\n */\n private readonly client: GeneratedClient;\n\n /**\n * The schema that will be used when sending events.\n */\n private readonly inputSchema: InputSchema;\n\n /**\n * Creates an instance of EventGridPublisherClient which sends events using the Event Grid Schema.\n *\n * Example usage:\n * ```ts\n * import { EventGridPublisherClient, AzureKeyCredential } from \"@azure/eventgrid\";\n *\n * const client = new EventGridPublisherClient(\n * \"<service endpoint>\",\n * \"EventGrid\",\n * new AzureKeyCredential(\"<api key>\")\n * );\n * ```\n *\n * @param endpointUrl - The URL to the Event Grid endpoint, e.g. https://eg-topic.westus2-1.eventgrid.azure.net/api/events.\n * @param inputSchema - The schema that the Event Grid endpoint is configured to accept. One of \"EventGrid\", \"CloudEvent\", or \"Custom\".\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the Event Grid Client.\n */\n constructor(\n endpointUrl: string,\n inputSchema: T,\n credential: KeyCredential | SASCredential | TokenCredential,\n options: EventGridPublisherClientOptions = {}\n ) {\n this.endpointUrl = endpointUrl;\n this.inputSchema = inputSchema;\n\n this.client = new GeneratedClient(options);\n\n const authPolicy = isTokenCredential(credential)\n ? bearerTokenAuthenticationPolicy({ credential, scopes: DEFAULT_EVENTGRID_SCOPE })\n : eventGridCredentialPolicy(credential);\n\n this.client.pipeline.addPolicy(authPolicy);\n this.client.pipeline.addPolicy(cloudEventDistributedTracingEnricherPolicy(), {\n afterPolicies: [tracingPolicyName],\n });\n this.apiVersion = this.client.apiVersion;\n }\n\n /**\n * Sends events to a topic.\n *\n * @param events - The events to send. The events should be in the schema used when constructing the client.\n * @param options - Options to control the underlying operation.\n */\n send(\n events: InputSchemaToInputTypeMap[T][],\n options: InputSchemaToOptionsTypeMap[T] = {}\n ): Promise<void> {\n return tracingClient.withSpan(\"EventGridPublisherClient.send\", options, (updatedOptions) => {\n switch (this.inputSchema) {\n case \"EventGrid\": {\n return this.client.publishEvents(\n this.endpointUrl,\n (events as InputSchemaToInputTypeMap[\"EventGrid\"][]).map(\n convertEventGridEventToModelType\n ),\n updatedOptions\n );\n }\n case \"CloudEvent\": {\n // The underlying REST API expects a header named `aeg-channel-name`, and so the generated client\n // expects that options bag has a property called `aegChannelName`, where as we expose it with the\n // friendlier name \"channelName\". Fix up the impedence mismatch here\n const {\n channelName,\n ...sendOptions\n }: { channelName?: string } & GeneratedClientPublishCloudEventEventsOptionalParams =\n updatedOptions as CloudEventSendOptions;\n\n if (channelName) {\n sendOptions.aegChannelName = channelName;\n }\n\n return this.client.publishCloudEventEvents(\n this.endpointUrl,\n (events as InputSchemaToInputTypeMap[\"CloudEvent\"][]).map(convertCloudEventToModelType),\n sendOptions\n );\n }\n case \"Custom\": {\n return this.client.publishCustomEventEvents(\n this.endpointUrl,\n events as InputSchemaToInputTypeMap[\"Custom\"][],\n updatedOptions\n );\n }\n default: {\n throw new Error(`Unknown input schema type '${this.inputSchema}'`);\n }\n }\n });\n }\n}\n\n/**\n * @internal\n */\nexport function convertEventGridEventToModelType(\n event: SendEventGridEventInput<any>\n): EventGridEventWireModel {\n return {\n eventType: event.eventType,\n eventTime: event.eventTime ?? new Date(),\n id: event.id ?? uuidv4(),\n subject: event.subject,\n topic: event.topic,\n data: event.data,\n dataVersion: event.dataVersion,\n };\n}\n\n/**\n * @internal\n */\nexport function convertCloudEventToModelType(event: SendCloudEventInput<any>): 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: \"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 = event.datacontenttype ?? \"application/json\";\n converted.data = event.data;\n }\n\n return converted;\n}\n"]}
|
1
|
+
{"version":3,"file":"eventGridClient.js","sourceRoot":"","sources":["../../src/eventGridClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,iBAAiB,EAAgC,MAAM,kBAAkB,CAAC;AAGnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAGL,+BAA+B,GAChC,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAM9D,OAAO,EAAE,0CAA0C,EAAE,MAAM,6CAA6C,CAAC;AACzG,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AA+D/F;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAqBnC;;;;;;;;;;;;;;;;;;OAkBG;IACH,YACE,WAAmB,EACnB,WAAc,EACd,UAA2D,EAC3D,UAA2C,EAAE;QAE7C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;QAE3C,MAAM,UAAU,GAAG,iBAAiB,CAAC,UAAU,CAAC;YAC9C,CAAC,CAAC,+BAA+B,CAAC,EA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O,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,GAAG,MAAA,KAAK,CAAC,eAAe,mCAAI,kBAAkB,CAAC;QACxE,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 { isTokenCredential, KeyCredential, SASCredential } from \"@azure/core-auth\";\nimport { OperationOptions, CommonClientOptions } from \"@azure/core-client\";\n\nimport { eventGridCredentialPolicy } from \"./eventGridAuthenticationPolicy\";\nimport { DEFAULT_EVENTGRID_SCOPE } from \"./constants\";\nimport {\n SendCloudEventInput,\n SendEventGridEventInput,\n cloudEventReservedPropertyNames,\n} from \"./models\";\nimport { GeneratedClient } from \"./generated/generatedClient\";\nimport {\n CloudEvent as CloudEventWireModel,\n EventGridEvent as EventGridEventWireModel,\n GeneratedClientPublishCloudEventEventsOptionalParams,\n} from \"./generated/models\";\nimport { cloudEventDistributedTracingEnricherPolicy } from \"./cloudEventDistrubtedTracingEnricherPolicy\";\nimport { tracingClient } from \"./tracing\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { bearerTokenAuthenticationPolicy, tracingPolicyName } from \"@azure/core-rest-pipeline\";\n\n/**\n * Options for the Event Grid Client.\n */\nexport type EventGridPublisherClientOptions = CommonClientOptions;\n\n/**\n * Options for the send events operation.\n */\nexport type SendOptions = OperationOptions;\n\n/**\n * Options for the send events operation, when the input schema is cloud event.\n */\nexport interface CloudEventSendOptions extends SendOptions {\n /**\n * The name of the channel to send the event to (only valid for Partner Namespaces and Topics).\n */\n channelName?: string;\n}\n\n/**\n * A map of input schema names to shapes of the input for the send method on EventGridPublisherClient.\n */\nexport interface InputSchemaToInputTypeMap {\n /**\n * The shape of the input to `send` when the client is configured to send events using the Event Grid schema.\n */\n EventGrid: SendEventGridEventInput<unknown>;\n /**\n * The shape of the input to `send` when the client is configured to send events using the Cloud Event schema.\n */\n CloudEvent: SendCloudEventInput<unknown>;\n /**\n * The shape of the input to `send` when the client is configured to send events using a custom schema.\n */\n Custom: Record<string, unknown>;\n}\n\n/**\n * A map of input schema names to shapes of the options bag for the send method on EventGridPublisherClient.\n */\nexport interface InputSchemaToOptionsTypeMap {\n /**\n * The shape of the options parameter for `send` when the client is configured to send events using the Event Grid schema.\n */\n EventGrid: SendOptions;\n /**\n * The shape of the options parameter for `send` when the client is configured to send events using the Cloud Event schema.\n */\n CloudEvent: CloudEventSendOptions;\n /**\n * The shape of the options parameter for `send` when the client is configured to send events using a custom schema.\n */\n Custom: SendOptions;\n}\n\n/**\n * Allowed schema types, to be used when constructing the EventGridPublisherClient.\n */\nexport type InputSchema = keyof InputSchemaToInputTypeMap;\n\n/**\n * Client class for publishing events to the Event Grid Service.\n */\nexport class EventGridPublisherClient<T extends InputSchema> {\n /**\n * The URL to the Event Grid endpoint.\n */\n public readonly endpointUrl: string;\n\n /**\n * The version of the Even Grid service.\n */\n public readonly apiVersion: string;\n\n /**\n * The AutoRest generated client for the EventGrid dataplane.\n */\n private readonly client: GeneratedClient;\n\n /**\n * The schema that will be used when sending events.\n */\n private readonly inputSchema: InputSchema;\n\n /**\n * Creates an instance of EventGridPublisherClient which sends events using the Event Grid Schema.\n *\n * Example usage:\n * ```ts\n * import { EventGridPublisherClient, AzureKeyCredential } from \"@azure/eventgrid\";\n *\n * const client = new EventGridPublisherClient(\n * \"<service endpoint>\",\n * \"EventGrid\",\n * new AzureKeyCredential(\"<api key>\")\n * );\n * ```\n *\n * @param endpointUrl - The URL to the Event Grid endpoint, e.g. https://eg-topic.westus2-1.eventgrid.azure.net/api/events.\n * @param inputSchema - The schema that the Event Grid endpoint is configured to accept. One of \"EventGrid\", \"CloudEvent\", or \"Custom\".\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the Event Grid Client.\n */\n constructor(\n endpointUrl: string,\n inputSchema: T,\n credential: KeyCredential | SASCredential | TokenCredential,\n options: EventGridPublisherClientOptions = {}\n ) {\n this.endpointUrl = endpointUrl;\n this.inputSchema = inputSchema;\n\n this.client = new GeneratedClient(options);\n\n const authPolicy = isTokenCredential(credential)\n ? bearerTokenAuthenticationPolicy({ credential, scopes: DEFAULT_EVENTGRID_SCOPE })\n : eventGridCredentialPolicy(credential);\n\n this.client.pipeline.addPolicy(authPolicy);\n this.client.pipeline.addPolicy(cloudEventDistributedTracingEnricherPolicy(), {\n afterPolicies: [tracingPolicyName],\n });\n this.apiVersion = this.client.apiVersion;\n }\n\n /**\n * Sends events to a topic.\n *\n * @param events - The events to send. The events should be in the schema used when constructing the client.\n * @param options - Options to control the underlying operation.\n */\n send(\n events: InputSchemaToInputTypeMap[T][],\n options: InputSchemaToOptionsTypeMap[T] = {}\n ): Promise<void> {\n return tracingClient.withSpan(\"EventGridPublisherClient.send\", options, (updatedOptions) => {\n switch (this.inputSchema) {\n case \"EventGrid\": {\n return this.client.publishEvents(\n this.endpointUrl,\n (events as InputSchemaToInputTypeMap[\"EventGrid\"][]).map(\n convertEventGridEventToModelType\n ),\n updatedOptions\n );\n }\n case \"CloudEvent\": {\n // The underlying REST API expects a header named `aeg-channel-name`, and so the generated client\n // expects that options bag has a property called `aegChannelName`, where as we expose it with the\n // friendlier name \"channelName\". Fix up the impedence mismatch here\n const {\n channelName,\n ...sendOptions\n }: { channelName?: string } & GeneratedClientPublishCloudEventEventsOptionalParams =\n updatedOptions as CloudEventSendOptions;\n\n if (channelName) {\n sendOptions.aegChannelName = channelName;\n }\n\n return this.client.publishCloudEventEvents(\n this.endpointUrl,\n (events as InputSchemaToInputTypeMap[\"CloudEvent\"][]).map(convertCloudEventToModelType),\n sendOptions\n );\n }\n case \"Custom\": {\n return this.client.publishCustomEventEvents(\n this.endpointUrl,\n events as InputSchemaToInputTypeMap[\"Custom\"][],\n updatedOptions\n );\n }\n default: {\n throw new Error(`Unknown input schema type '${this.inputSchema}'`);\n }\n }\n });\n }\n}\n\n/**\n * @internal\n */\nexport function convertEventGridEventToModelType(\n event: SendEventGridEventInput<any>\n): EventGridEventWireModel {\n return {\n eventType: event.eventType,\n eventTime: event.eventTime ?? new Date(),\n id: event.id ?? uuidv4(),\n subject: event.subject,\n topic: event.topic,\n data: event.data,\n dataVersion: event.dataVersion,\n };\n}\n\n/**\n * @internal\n */\nexport function convertCloudEventToModelType(event: SendCloudEventInput<any>): 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: \"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 = event.datacontenttype ?? \"application/json\";\n converted.data = event.data;\n }\n\n return converted;\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/4.10.0
|
23
|
+
const packageDetails = `azsdk-js-eventgrid/4.10.0`;
|
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,
|
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,2BAA2B,CAAC;QACnD,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/4.10.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"]}
|
package/dist-esm/src/tracing.js
CHANGED
@@ -8,6 +8,6 @@ import { createTracingClient } from "@azure/core-tracing";
|
|
8
8
|
export const tracingClient = createTracingClient({
|
9
9
|
namespace: "Microsoft.Messaging.EventGrid",
|
10
10
|
packageName: "@azure/event-grid",
|
11
|
-
packageVersion: "4.
|
11
|
+
packageVersion: "4.10.0",
|
12
12
|
});
|
13
13
|
//# sourceMappingURL=tracing.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../src/tracing.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC;IAC/C,SAAS,EAAE,+BAA+B;IAC1C,WAAW,EAAE,mBAAmB;IAChC,cAAc,EAAE,
|
1
|
+
{"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../src/tracing.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC;IAC/C,SAAS,EAAE,+BAA+B;IAC1C,WAAW,EAAE,mBAAmB;IAChC,cAAc,EAAE,QAAQ;CACzB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createTracingClient } from \"@azure/core-tracing\";\n\n/**\n * A tracing client to handle spans.\n * @internal\n */\nexport const tracingClient = createTracingClient({\n namespace: \"Microsoft.Messaging.EventGrid\",\n packageName: \"@azure/event-grid\",\n packageVersion: \"4.10.0\",\n});\n"]}
|
package/dist-esm/src/util.js
CHANGED
@@ -17,10 +17,10 @@ export function dateToServiceTimeString(d) {
|
|
17
17
|
const month = d.getUTCMonth() + 1; // getUTCMonth returns 0-11 not 1-12.
|
18
18
|
const day = d.getUTCDate();
|
19
19
|
const year = d.getUTCFullYear();
|
20
|
-
const hour = d.getUTCHours() === 0 ? 12 : d.getUTCHours() % 12; // getUTCHours returns 0-23, and we want this in 12 hour format.
|
20
|
+
const hour = d.getUTCHours() === 0 || d.getUTCHours() === 12 ? 12 : d.getUTCHours() % 12; // getUTCHours returns 0-23, and we want this in 12 hour format.
|
21
21
|
const minute = d.getUTCMinutes().toString().padStart(2, "0");
|
22
22
|
const second = d.getUTCSeconds().toString().padStart(2, "0");
|
23
|
-
const am = d.getUTCHours() >=
|
23
|
+
const am = d.getUTCHours() >= 12 ? "PM" : "AM";
|
24
24
|
return `${month}/${day}/${year} ${hour}:${minute}:${second} ${am}`;
|
25
25
|
}
|
26
26
|
/**
|
package/dist-esm/src/util.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB,CAAC,CAAO;IAC7C,MAAM,KAAK,GAAG,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,qCAAqC;IACxE,MAAM,GAAG,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,CAAC;IAEhC,MAAM,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,gEAAgE;
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB,CAAC,CAAO;IAC7C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K,CAAC,4CAA4C,CAAC,CAAC;KAC/D;AACH,CAAC;AAED,SAAS,gCAAgC,CAAC,CAAM,EAAE,aAAuB;IACvE,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;QACxC,IAAI,OAAO,CAAC,CAAC,YAAY,CAAC,KAAK,WAAW,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,uCAAuC,YAAY,GAAG,CAAC,CAAC;SACzE;QAED,IAAI,OAAO,CAAC,CAAC,YAAY,CAAC,KAAK,QAAQ,EAAE;YACvC,MAAM,IAAI,SAAS,CACjB,mBAAmB,YAAY,kCAAkC,OAAO,CAAC,CAAC,YAAY,CAAC,GAAG,CAC3F,CAAC;SACH;KACF;AACH,CAAC;AAED,SAAS,6BAA6B,CAAC,CAAM,EAAE,aAAuB;IACpE,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;QACxC,IAAI,OAAO,CAAC,CAAC,YAAY,CAAC,KAAK,WAAW,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,uCAAuC,YAAY,GAAG,CAAC,CAAC;SACzE;KACF;AACH,CAAC;AAED,SAAS,gCAAgC,CAAC,CAAM,EAAE,aAAuB;IACvE,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;QACxC,IAAI,OAAO,CAAC,CAAC,YAAY,CAAC,KAAK,WAAW,IAAI,OAAO,CAAC,CAAC,YAAY,CAAC,KAAK,QAAQ,EAAE;YACjF,MAAM,IAAI,SAAS,CACjB,mBAAmB,YAAY,uCAAuC,OAAO,CAAC,CAC5E,YAAY,CACb,GAAG,CACL,CAAC;SACH;KACF;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { KeyCredential } from \"@azure/core-auth\";\n\n/**\n * Stringifies a Date object in the format expected by the Event Grid service, for use in a Shared Access Signiture.\n *\n * The service expects this time string to be in the same format as what is returned by the .NET DateTime.ToString\n * method, using the \"en-US\" culture.\n *\n * This corresponds to the .NET format string: \"M/d/yyyy h:mm:ss tt\". For example, the date \"June 5th, 2020, 12:09:03 PM\"\n * is represented as the string \"6/5/2020 12:09:03 PM\"\n *\n * The service expects a UTC time, so this method returns a string based on the UTC time of the provided Date.\n *\n * @param d - The Date object to convert to a string.\n */\nexport function dateToServiceTimeString(d: Date): string {\n const month = d.getUTCMonth() + 1; // getUTCMonth returns 0-11 not 1-12.\n const day = d.getUTCDate();\n const year = d.getUTCFullYear();\n\n const hour = d.getUTCHours() === 0 || d.getUTCHours() === 12 ? 12 : d.getUTCHours() % 12; // getUTCHours returns 0-23, and we want this in 12 hour format.\n const minute = d.getUTCMinutes().toString().padStart(2, \"0\");\n const second = d.getUTCSeconds().toString().padStart(2, \"0\");\n const am = d.getUTCHours() >= 12 ? \"PM\" : \"AM\";\n\n return `${month}/${day}/${year} ${hour}:${minute}:${second} ${am}`;\n}\n\n/**\n * Returns `true` if the credential object is like the KeyCredential interface (i.e. it has a\n * key property).\n *\n * @param credential - The object to test\n */\nexport function isKeyCredentialLike(o: unknown): o is KeyCredential {\n const castO = o as {\n key: unknown;\n };\n return castO.key !== undefined;\n}\n\nexport function parseAndWrap(jsonStringOrObject: string | Record<string, unknown>): any[] {\n if (typeof jsonStringOrObject === \"string\") {\n const o = JSON.parse(jsonStringOrObject);\n if (Array.isArray(o)) {\n return o;\n } else {\n return [o];\n }\n }\n\n if (Array.isArray(jsonStringOrObject)) {\n return jsonStringOrObject;\n } else {\n return [jsonStringOrObject];\n }\n}\n\nconst EVENT_GRID_SCHEMA_METADATA_VERSION = \"1\";\n\nexport function validateEventGridEvent(o: unknown): void {\n if (typeof o !== \"object\") {\n throw new TypeError(\"event is not an object\");\n }\n\n const castO = o as {\n metadataVersion: unknown;\n };\n validateRequiredStringProperties(o, [\n \"eventType\",\n \"eventTime\",\n \"id\",\n \"subject\",\n \"topic\",\n \"dataVersion\",\n \"metadataVersion\",\n ]);\n\n validateRequiredAnyProperties(o, [\"data\"]);\n\n if (castO.metadataVersion !== EVENT_GRID_SCHEMA_METADATA_VERSION) {\n throw new TypeError(\"event is not in the Event Grid schema\");\n }\n}\n\nconst CLOUD_EVENT_1_0_SPEC_VERSION = \"1.0\";\n\nexport function validateCloudEventEvent(o: unknown): void {\n validateRequiredStringProperties(o, [\"type\", \"source\", \"id\", \"specversion\"]);\n validateOptionalStringProperties(o, [\"time\", \"dataschema\", \"datacontenttype\", \"subject\"]);\n\n if (typeof o !== \"object\") {\n throw new TypeError(\"event is not an object\");\n }\n\n const castO = o as {\n specversion: unknown;\n };\n\n if (castO.specversion !== CLOUD_EVENT_1_0_SPEC_VERSION) {\n throw new Error(\"event is not in the Cloud Event 1.0 schema\");\n }\n}\n\nfunction validateRequiredStringProperties(o: any, propertyNames: string[]): void {\n for (const propertyName of propertyNames) {\n if (typeof o[propertyName] === \"undefined\") {\n throw new Error(`event is missing required property '${propertyName}'`);\n }\n\n if (typeof o[propertyName] !== \"string\") {\n throw new TypeError(\n `event property '${propertyName} should be a 'string', but is '${typeof o[propertyName]}'`\n );\n }\n }\n}\n\nfunction validateRequiredAnyProperties(o: any, propertyNames: string[]): void {\n for (const propertyName of propertyNames) {\n if (typeof o[propertyName] === \"undefined\") {\n throw new Error(`event is missing required property '${propertyName}'`);\n }\n }\n}\n\nfunction validateOptionalStringProperties(o: any, propertyNames: string[]): void {\n for (const propertyName of propertyNames) {\n if (typeof o[propertyName] !== \"undefined\" && typeof o[propertyName] !== \"string\") {\n throw new TypeError(\n `event property '${propertyName}' should be a 'string' but it is a '${typeof o[\n propertyName\n ]}'`\n );\n }\n }\n}\n"]}
|
package/package.json
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
"sdk-type": "client",
|
4
4
|
"author": "Microsoft Corporation",
|
5
5
|
"description": "An isomorphic client library for the Azure Event Grid service.",
|
6
|
-
"version": "4.10.0
|
6
|
+
"version": "4.10.0",
|
7
7
|
"keywords": [
|
8
8
|
"node",
|
9
9
|
"azure",
|
@@ -78,8 +78,8 @@
|
|
78
78
|
"integration-test:browser": "dev-tool run test:browser",
|
79
79
|
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 \"dist-esm/test/**/*.spec.js\"",
|
80
80
|
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
81
|
-
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
|
82
|
-
"lint": "eslint package.json api-extractor.json src test --ext .ts",
|
81
|
+
"lint:fix": "eslint package.json api-extractor.json README.md src test --ext .ts,.javascript,.js --fix --fix-type [problem,suggestion]",
|
82
|
+
"lint": "eslint package.json api-extractor.json README.md src test --ext .ts,.javascript,.js",
|
83
83
|
"pack": "npm pack 2>&1",
|
84
84
|
"test:browser": "npm run clean && npm run build:test && npm run unit-test:browser",
|
85
85
|
"test:node": "npm run clean && npm run build:test && npm run unit-test:node",
|
@@ -105,7 +105,7 @@
|
|
105
105
|
"@azure/service-bus": "^7.0.0",
|
106
106
|
"@azure/test-utils": "^1.0.0",
|
107
107
|
"@azure-tools/test-recorder": "^2.0.0",
|
108
|
-
"@microsoft/api-extractor": "
|
108
|
+
"@microsoft/api-extractor": "7.18.11",
|
109
109
|
"@types/chai": "^4.1.6",
|
110
110
|
"@types/chai-as-promised": "^7.1.0",
|
111
111
|
"@types/mocha": "^7.0.2",
|
@@ -116,7 +116,7 @@
|
|
116
116
|
"chai-as-promised": "^7.1.1",
|
117
117
|
"cross-env": "^7.0.2",
|
118
118
|
"dotenv": "^8.2.0",
|
119
|
-
"eslint": "^
|
119
|
+
"eslint": "^8.0.0",
|
120
120
|
"karma": "^6.2.0",
|
121
121
|
"karma-chrome-launcher": "^3.0.0",
|
122
122
|
"karma-coverage": "^2.0.0",
|
@@ -136,6 +136,6 @@
|
|
136
136
|
"sinon": "^9.0.2",
|
137
137
|
"source-map-support": "^0.5.9",
|
138
138
|
"ts-node": "^10.0.0",
|
139
|
-
"typescript": "~4.
|
139
|
+
"typescript": "~4.6.0"
|
140
140
|
}
|
141
141
|
}
|
package/types/eventgrid.d.ts
CHANGED
@@ -502,7 +502,7 @@ export declare interface CloudEvent<T> {
|
|
502
502
|
extensionAttributes?: Record<string, unknown>;
|
503
503
|
}
|
504
504
|
|
505
|
-
|
505
|
+
/**
|
506
506
|
* Options for the send events operation, when the input schema is cloud event.
|
507
507
|
*/
|
508
508
|
export declare interface CloudEventSendOptions extends SendOptions {
|
package/CHANGELOG.md
DELETED
@@ -1,188 +0,0 @@
|
|
1
|
-
# Release History
|
2
|
-
|
3
|
-
## 4.10.0-beta.1 (2022-04-14)
|
4
|
-
|
5
|
-
### Features Added
|
6
|
-
|
7
|
-
- Add support for specifiying a channel to send to in a specific Partner Topic via the `channelName` property of `SendOptions`.
|
8
|
-
|
9
|
-
### Other Changes
|
10
|
-
|
11
|
-
- Updated our `@azure/core-tracing` dependency to the latest version (1.0.0).
|
12
|
-
- Notable changes include Removal of `@opentelemetry/api` as a transitive dependency and ensuring that the active context is properly propagated.
|
13
|
-
- Customers who would like to continue using OpenTelemetry driven tracing should visit our [OpenTelemetry Instrumentation](https://www.npmjs.com/package/@azure/opentelemetry-instrumentation-azure-sdk) package for instructions.
|
14
|
-
|
15
|
-
## 4.9.0 (2022-04-07)
|
16
|
-
|
17
|
-
### Features Added
|
18
|
-
|
19
|
-
- Added new System Events:
|
20
|
-
|
21
|
-
- `Microsoft.HealthcareApis.FhirResourceCreated`
|
22
|
-
- `Microsoft.HealthcareApis.FhirUpdatedCreated`
|
23
|
-
- `Microsoft.HealthcareApis.FhirDeletedCreated`
|
24
|
-
|
25
|
-
## 4.8.0 (2022-03-08)
|
26
|
-
|
27
|
-
### Features Added
|
28
|
-
|
29
|
-
- Added new value `IdentityUnsupported` to `MediaJobErrorCode` and `Account` to `MediaJobErrorCategory` for `Microsoft.Media` events.
|
30
|
-
|
31
|
-
## 4.7.0 (2022-02-08)
|
32
|
-
|
33
|
-
### Key Bug Fixes
|
34
|
-
|
35
|
-
- The TypeScript typings for two events have had small changes to accurately reflect the data sent by Azure.
|
36
|
-
- `Microsoft.EventHub.CaptureFileCreated`'s `fileurl` property is now correctly cased as `fileUrl`
|
37
|
-
- `Microsoft.Storage.DirectoryDeleted`'s `recursive` property has been changed from `boolean` to `string`. The service sets this property to the string `"true"` or `"false"`.
|
38
|
-
|
39
|
-
## 4.6.0 (2022-01-11)
|
40
|
-
|
41
|
-
### Features Added
|
42
|
-
|
43
|
-
- Added a new property to `AcsRecordingChunkInfo` (for the `Microsoft.Communication.RecordingFileStatusUpdated` system event):
|
44
|
-
|
45
|
-
- `deleteLocation`
|
46
|
-
|
47
|
-
- Added new properties to `ContainerRegistryArtifactEventData` and `ContainerRegistryEventData` (for the `Microsoft.ContainerRegistry.{ChartDeleted|ChartPushed|ImagePushed|ImageDeleted}` system events):
|
48
|
-
|
49
|
-
- `connectedRegistry`
|
50
|
-
- `location`
|
51
|
-
|
52
|
-
- Added new properties to `AcsRecordingFileStatusUpdatedEventData` (for the `Microsoft.Communication.RecordingFileStatusUpdated` system event):
|
53
|
-
|
54
|
-
- `recordingChannelType`
|
55
|
-
- `recordingContentType`
|
56
|
-
- `recordingFormatType`
|
57
|
-
|
58
|
-
### Key Bug Fixes
|
59
|
-
|
60
|
-
- The TypeScript typings for events from Azure Resource Manager were incorrect. The following properties had their types changed:
|
61
|
-
|
62
|
-
- `authorization`
|
63
|
-
- `claims`
|
64
|
-
- `httpRequest`
|
65
|
-
|
66
|
-
Previously, these properties were typed as `string` but the underlying events from the service actually contained objects. Customers using `isSystemEvent` with TypeScript will
|
67
|
-
now see compliation issues if they try to treat these properties as strings (previously, the code would fail at runtime).
|
68
|
-
|
69
|
-
## 4.5.0 (2021-10-05)
|
70
|
-
|
71
|
-
### Features Added
|
72
|
-
|
73
|
-
- Added new properties for the `Microsoft.Media.LiveEventIngestHeartbeat` System Event:
|
74
|
-
|
75
|
-
- `ingestDriftValue`
|
76
|
-
- `lastFragmentArrivalTime`
|
77
|
-
- `transcriptionLanguage`
|
78
|
-
- `transcriptionState`
|
79
|
-
|
80
|
-
- Added new System Events:
|
81
|
-
- API Management:
|
82
|
-
- `Microsoft.ApiManagement.APICreated`
|
83
|
-
- `Microsoft.ApiManagement.APIDeleted`
|
84
|
-
- `Microsoft.ApiManagement.APIReleaseCreated`
|
85
|
-
- `Microsoft.ApiManagement.APIReleaseDeleted`
|
86
|
-
- `Microsoft.ApiManagement.APIReleaseUpdated`
|
87
|
-
- `Microsoft.ApiManagement.APIUpdated`
|
88
|
-
- `Microsoft.ApiManagement.ProductCreated`
|
89
|
-
- `Microsoft.ApiManagement.ProductDeleted`
|
90
|
-
- `Microsoft.ApiManagement.ProductUpdated`
|
91
|
-
- `Microsoft.ApiManagement.SubscriptionCreated`
|
92
|
-
- `Microsoft.ApiManagement.SubscriptionDeleted`
|
93
|
-
- `Microsoft.ApiManagement.SubscriptionUpdated`
|
94
|
-
- `Microsoft.ApiManagement.UserCreated`
|
95
|
-
- `Microsoft.ApiManagement.UserDeleted`
|
96
|
-
- `Microsoft.ApiManagement.UserUpdated`
|
97
|
-
- Container Service:
|
98
|
-
- `Microsoft.ContainerService.NewKubernetesVersionAvailable`
|
99
|
-
- Communication:
|
100
|
-
- `Microsoft.Communication.UserDisconnected`
|
101
|
-
- Media Streaming:
|
102
|
-
- `Microsoft.Media.LiveEventChannelArchiveHeartbeat`
|
103
|
-
|
104
|
-
## 4.4.0 (2021-07-19)
|
105
|
-
|
106
|
-
### Features Added
|
107
|
-
|
108
|
-
- With the dropping of support for Node.js versions that are no longer in LTS, the dependency on `@types/node` has been updated to version 12. Read our
|
109
|
-
[support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
|
110
|
-
- Updated our internal core package dependencies to their latest versions in order to add support for Opentelemetry 1.0.0 which is compatible with the latest versions of our other client libraries.
|
111
|
-
- Changed TS compilation target to ES2017 in order to produce smaller bundles and use more native platform features
|
112
|
-
- `EventGridPublisherClient` now supports Azure Active Directory (AAD) for authentication. When constructing an `EventGridPublisherClient` you may now pass an instance
|
113
|
-
of a `TokenCredential` as the credential. See the readme for [`@azure/identity`](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity) to learn
|
114
|
-
more about using Azure Active Directory for authentication.
|
115
|
-
|
116
|
-
- Added a "metadata" property for the following system events:
|
117
|
-
|
118
|
-
- `Microsoft.Communication.AcsChatMessageReceived`
|
119
|
-
- `Microsoft.Communication.AcsChatMessageEdited`
|
120
|
-
- `Microsoft.Communication.AcsChatMessageReceivedInThread`
|
121
|
-
- `Microsoft.Communication.AcsChatMessageEditedInThread`
|
122
|
-
|
123
|
-
## 4.3.0 (2021-06-08)
|
124
|
-
|
125
|
-
### New Features
|
126
|
-
|
127
|
-
- Added new System Event: `Microsoft.Storage.BlobInventoryPolicyCompleted`
|
128
|
-
|
129
|
-
### Key Bug Fixes
|
130
|
-
|
131
|
-
- The `Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListeners` event was incorrectly listed with the name of `Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener`.
|
132
|
-
This has been corrected. When using TypeScript, you will need to replace any calls to `isSystemEvent("Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener")` with
|
133
|
-
`isSystemEvent("Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListeners")`.
|
134
|
-
|
135
|
-
## 4.2.0 (2021-05-11)
|
136
|
-
|
137
|
-
### New Features
|
138
|
-
|
139
|
-
- Added new System Events: "Microsoft.PolicyInsights.PolicyStateCreated", "Microsoft.PolicyInsights.PolicyStateChanged", "Microsoft.PolicyInsights.PolicyStateDeleted",
|
140
|
-
"Microsoft.Storage.AsyncOperationInitiated", "Microsoft.Storage.BlobTierChanged".
|
141
|
-
|
142
|
-
## 4.1.0 (2021-03-23)
|
143
|
-
|
144
|
-
- The system event names `Microsoft.Communication.ChatParticipantAddedToThread` and `Microsoft.Communication.ChatParticipantRemovedFromThread` have been removed, and
|
145
|
-
`Microsoft.Communication.ChatThreadParticipantAdded` and `Microsoft.Communication.ChatThreadParticipantRemoved` have been added. The old names did not match the
|
146
|
-
the type names that Azure Communication Services was using for these events. TypeScript users will now see compliation errors if they are calling `isSystemEvent` with
|
147
|
-
either `Microsoft.Communication.ChatParticipantAddedToThread` or `Microsoft.Communication.ChatParticipantRemovedFromThread` as the event name. To fix these issues,
|
148
|
-
replace all uses of `Microsoft.Communication.ChatParticipantAddedToThread` with `Microsoft.Communication.ChatThreadParticipantAdded` and
|
149
|
-
`Microsoft.Communication.ChatParticipantRemovedFromThread` with `Microsoft.Communication.ChatThreadParticipantRemoved`.
|
150
|
-
|
151
|
-
- Add `Microsoft.Communications.RecordingFileStatusUpdated` system event.
|
152
|
-
|
153
|
-
## 4.0.0 (2021-03-17)
|
154
|
-
|
155
|
-
- Update version to 4.0.0 to align with other EventGrid SDKs
|
156
|
-
|
157
|
-
### Breaking Changes
|
158
|
-
|
159
|
-
- `EventGridConsumer` no longer applies any conversions to the `data` property of system events. The interfaces that describe the data payload of each
|
160
|
-
system event has been updated to reflect this. The most visible impact of this change is that some properties of events are no longer converted into JavaScript
|
161
|
-
`Date` objects, and instead are kepts as strings which contain ISO 8601 timestamps.
|
162
|
-
- Related to the above, `EventGridConsumer` no longer accepts a set of custom converters that can be used to further transform the `data` property of a specific
|
163
|
-
event type when deserializing events.
|
164
|
-
- The interfaces which describe the shape of the `data` member of system events have been updated so that properties always included in the event are not typed as optional.
|
165
|
-
|
166
|
-
## 3.0.0-beta.3 (2020-10-06)
|
167
|
-
|
168
|
-
- Added distributed tracing support. `EventGridProducerClient` will now create spans when sending events to Event Grid.
|
169
|
-
- Added support for system events sent by Azure Key Vault.
|
170
|
-
|
171
|
-
### Breaking Changes
|
172
|
-
|
173
|
-
- The type definitions for SMS events sent by Azure Communication Services have been renamed, to use the prefix "AcsSms" instead of "Acssms". If you are
|
174
|
-
using TypeScript and explicitly referencing these interfaces, you will need to update your code to use the new names. The payload of the events is unchanged.
|
175
|
-
- `EventGridSharedAccessCredential` has been removed, in favor of `AzureSASCredential`. Code which is using `EventGridSharedAccessCredential` should
|
176
|
-
now use `AzureSASCredential` instead.
|
177
|
-
- When constructing the client, you must now include the schema type your topic is configured to expect (one of "EventGrid", "CloudEvent" or "Custom").
|
178
|
-
- The `sendEvents` methods have been collapsed into a single method on the client called `send` which uses the input schema that was configured on the client.
|
179
|
-
|
180
|
-
## 3.0.0-beta.2 (2020-09-24)
|
181
|
-
|
182
|
-
- Added support for system events sent by the Azure Communication Services.
|
183
|
-
|
184
|
-
## 3.0.0-beta.1 (2020-09-08)
|
185
|
-
|
186
|
-
- This release is a preview of our efforts to create a client library that is user friendly and
|
187
|
-
idiomatic to the JavaScript ecosystem. The reasons for most of the changes in this update can be found in the
|
188
|
-
[Azure SDK Design Guidelines for TypeScript](https://azuresdkspecs.z5.web.core.windows.net/TypeScriptSpec.html).
|