Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add converter for uint8array map to string and serialization for models #1934

Merged
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"tslib": "^2.2.0",
"@azure/core-paging": "^1.5.0",
"@azure/core-lro": "^2.5.4",
"@azure/abort-controller": "^1.0.0"
"@azure/abort-controller": "^1.0.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0",
"@azure/core-lro": "^2.5.4",
"@azure/abort-controller": "^1.0.0"
"@azure/abort-controller": "^1.0.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"tslib": "^2.2.0",
"@azure/core-paging": "^1.5.0",
"@azure/core-lro": "^2.5.4",
"@azure/abort-controller": "^1.0.0"
"@azure/abort-controller": "^1.0.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"tslib": "^2.2.0",
"@azure/core-paging": "^1.5.0",
"@azure/core-lro": "^2.5.4",
"@azure/abort-controller": "^1.0.0"
"@azure/abort-controller": "^1.0.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0",
"@azure/core-paging": "^1.5.0"
"@azure/core-paging": "^1.5.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"tslib": "^2.2.0",
"@azure/core-paging": "^1.5.0",
"@azure/core-lro": "^2.5.4",
"@azure/abort-controller": "^1.0.0"
"@azure/abort-controller": "^1.0.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0",
"@azure/core-paging": "^1.5.0"
"@azure/core-paging": "^1.5.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/rlc-common/src/metadata/buildPackageFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ function restLevelPackage(model: RLCModel, hasSamplesGenerated: boolean) {
...(hasLRO && {
"@azure/core-lro": "^2.5.4",
"@azure/abort-controller": "^1.0.0"
})
}),
"@azure/core-util": "^1.4.0"
},
devDependencies: {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0",
"@azure/core-paging": "^1.5.0"
"@azure/core-paging": "^1.5.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"tslib": "^2.2.0",
"@azure/core-paging": "^1.5.0",
"@azure/core-lro": "^2.5.4",
"@azure/abort-controller": "^1.0.0"
"@azure/abort-controller": "^1.0.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0",
"@azure/core-paging": "^1.5.0"
"@azure/core-paging": "^1.5.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"tslib": "^2.2.0",
"@azure/core-paging": "^1.5.0",
"@azure/core-lro": "^2.5.4",
"@azure/abort-controller": "^1.0.0"
"@azure/abort-controller": "^1.0.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"@azure-rest/core-client": "^1.1.4",
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
StreamableMethod,
operationOptionsToRequestParameters,
} from "@azure-rest/core-client";
import { stringToUint8Array, uint8ArrayToString } from "@azure/core-util";
import {
PublishCloudEventOptions,
PublishCloudEventsOptions,
Expand All @@ -52,7 +53,23 @@ export function _publishCloudEventSend(
contentType:
(options.contentType as any) ??
"application/cloudevents+json; charset=utf-8",
body: { event: event },
body: {
event: {
id: event["id"],
source: event["source"],
data: event["data"],
data_base64: uint8ArrayToString(
qiaozha marked this conversation as resolved.
Show resolved Hide resolved
event["dataBase64"] ?? new Uint8Array(),
"base64"
),
type: event["type"],
time: new Date(event["time"] ?? ""),
qiaozha marked this conversation as resolved.
Show resolved Hide resolved
specversion: event["specversion"],
dataschema: event["dataschema"],
datacontenttype: event["datacontenttype"],
subject: event["subject"],
},
},
});
}

Expand Down Expand Up @@ -90,15 +107,29 @@ export function _publishCloudEventsSend(
): StreamableMethod<
PublishCloudEvents200Response | PublishCloudEventsDefaultResponse
> {
return context
.path("/topics/{topicName}:publish", topicName)
.post({
...operationOptionsToRequestParameters(options),
contentType:
(options.contentType as any) ??
"application/cloudevents-batch+json; charset=utf-8",
body: events,
});
return context.path("/topics/{topicName}:publish", topicName).post({
...operationOptionsToRequestParameters(options),
contentType:
(options.contentType as any) ??
"application/cloudevents-batch+json; charset=utf-8",
body: (events ?? []).map((p) => {
return {
id: p["id"],
source: p["source"],
data: p["data"],
data_base64: uint8ArrayToString(
p["dataBase64"] ?? new Uint8Array(),
"base64"
),
type: p["type"],
time: new Date(p["time"] ?? ""),
specversion: p["specversion"],
dataschema: p["dataschema"],
datacontenttype: p["datacontenttype"],
subject: p["subject"],
};
}),
});
}

export async function _publishCloudEventsDeserialize(
Expand Down Expand Up @@ -167,7 +198,13 @@ export async function _receiveCloudEventsDeserialize(
id: p.event["id"],
source: p.event["source"],
data: p.event["data"],
dataBase64: Buffer.from(p.event["data_base64"] ?? ""),
dataBase64:
typeof p.event["data_base64"] === "string"
? stringToUint8Array(
p.event["data_base64"] ?? new Uint8Array(),
"base64"
)
: p.event["data_base64"],
qiaozha marked this conversation as resolved.
Show resolved Hide resolved
type: p.event["type"],
time: new Date(p.event["time"] ?? ""),
specversion: p.event["specversion"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"@azure/logger": "^1.0.0",
"tslib": "^2.2.0",
"@azure/core-lro": "^2.5.4",
"@azure/abort-controller": "^1.0.0"
"@azure/abort-controller": "^1.0.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"tslib": "^2.2.0",
"@azure/core-paging": "^1.5.0",
"@azure/core-lro": "^2.5.4",
"@azure/abort-controller": "^1.0.0"
"@azure/abort-controller": "^1.0.0",
"@azure/core-util": "^1.4.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"tslib": "^2.2.0",
"@azure/core-paging": "^1.5.0",
"@azure/core-lro": "^2.5.4",
"@azure/abort-controller": "^1.0.0"
"@azure/abort-controller": "^1.0.0",
"@azure/core-util": "^1.4.0"
qiaozha marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"@microsoft/api-extractor": "^7.31.1",
Expand Down
Loading
Loading