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

support encode for modular #2006

Merged
merged 19 commits into from
Sep 11, 2023
Merged
3 changes: 2 additions & 1 deletion packages/rlc-common/src/buildIndexFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ function generateRLCIndex(file: SourceFile, model: RLCModel) {
hasMultiCollection(model) ||
hasSsvCollection(model) ||
hasPipeCollection(model) ||
hasTsvCollection(model)
hasTsvCollection(model) ||
hasCsvCollection(model)
) {
file.addExportDeclarations([
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,12 @@ export function _addOrUpdateBlockItemsSend(
)
.post({
...operationOptionsToRequestParameters(options),
body: { blockItems: blockItems },
body: {
blockItems: (blockItems ?? []).map((p) => ({
description: p["description"],
text: p["text"],
})),
},
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ export function _publishCloudEventSend(
? uint8ArrayToString(event["dataBase64"], "base64")
: undefined,
type: event["type"],
time:
event["time"] !== undefined ? new Date(event["time"]) : undefined,
time: event["time"]?.toISOString(),
Copy link
Contributor

@MaryGao MaryGao Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice the typespec type here is utcDateTime but we generate to toISOString

https://github.com/Azure/autorest.typescript/blob/1235e0ba4762ac1171f5777b50eafb1b7e43a8d0/packages/typespec-test/test/eventgrid_modular/spec/main.tsp#L64-L65C24

Not sure it is possible to add some UTs to cover typespec type to modular type:

/**
 * A date on a calendar without a time zone, e.g. "April 10th"
 */
scalar plainDate;

/**
 * A time on a clock without a time zone, e.g. "3:00 am"
 */
scalar plainTime;

/**
 * An instant in coordinated universal time (UTC)"
 */
scalar utcDateTime;

/**
 * A date and time in a particular time zone, e.g. "April 10th at 3:00am in PST"
 */
scalar offsetDateTime;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect typespec compiler does not provide any format info to these types, but let me check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typescript date.toUTCString() is "Fri, 08 Sep 2023 08:50:03 GMT" and date.toISOString() is "2023-09-08T08:42:49.439Z"
therefore use toISOString for utcDateTime makes more sense. and toUTCString for offsetDateTime makes more sense to me.

Copy link
Contributor

@MaryGao MaryGao Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it makes sense to me also. Just checking with Tim here microsoft/typespec#1899 (comment)

Copy link
Contributor

@MaryGao MaryGao Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not the same
image

specversion: event["specversion"],
dataschema: event["dataschema"],
datacontenttype: event["datacontenttype"],
Expand Down Expand Up @@ -123,7 +122,7 @@ export function _publishCloudEventsSend(
? uint8ArrayToString(p["dataBase64"], "base64")
: undefined,
type: p["type"],
time: p["time"] !== undefined ? new Date(p["time"]) : undefined,
time: p["time"]?.toISOString(),
specversion: p["specversion"],
dataschema: p["dataschema"],
datacontenttype: p["datacontenttype"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export interface CreateOrUpdateAppComponentsOptions extends OperationOptions {
// (undocumented)
contentType?: string;
createdBy?: string;
createdDateTime?: any;
createdDateTime?: Date;
lastModifiedBy?: string;
lastModifiedDateTime?: any;
lastModifiedDateTime?: Date;
testId?: string;
}

Expand All @@ -48,9 +48,9 @@ export interface CreateOrUpdateServerMetricsConfigOptions extends OperationOptio
// (undocumented)
contentType?: string;
createdBy?: string;
createdDateTime?: any;
createdDateTime?: Date;
lastModifiedBy?: string;
lastModifiedDateTime?: any;
lastModifiedDateTime?: Date;
metrics?: Record<string, ResourceMetric>;
testId?: string;
}
Expand All @@ -61,15 +61,15 @@ export interface CreateOrUpdateTestOptions extends OperationOptions {
// (undocumented)
contentType?: string;
createdBy?: string;
createdDateTime?: any;
createdDateTime?: Date;
description?: string;
displayName?: string;
environmentVariables?: Record<string, string>;
inputArtifacts?: TestInputArtifacts;
keyvaultReferenceIdentityId?: string;
keyvaultReferenceIdentityType?: string;
lastModifiedBy?: string;
lastModifiedDateTime?: any;
lastModifiedDateTime?: Date;
loadTestConfiguration?: LoadTestConfiguration;
passFailCriteria?: PassFailCriteria;
secrets?: Record<string, Secret>;
Expand Down Expand Up @@ -114,7 +114,7 @@ export interface ErrorDetails {

// @public
export interface FileInfo {
expireDateTime?: any;
expireDateTime?: Date;
fileName?: string;
fileType?: FileType;
url?: string;
Expand Down Expand Up @@ -187,8 +187,8 @@ export interface ListTestFilesOptions extends OperationOptions {

// @public (undocumented)
export interface ListTestRunsOptions extends OperationOptions {
executionFrom?: any;
executionTo?: any;
executionFrom?: Date;
executionTo?: Date;
maxpagesize?: number;
orderby?: string;
search?: string;
Expand All @@ -198,8 +198,8 @@ export interface ListTestRunsOptions extends OperationOptions {

// @public (undocumented)
export interface ListTestsOptions extends OperationOptions {
lastModifiedEndTime?: any;
lastModifiedStartTime?: any;
lastModifiedEndTime?: Date;
lastModifiedStartTime?: Date;
maxpagesize?: number;
orderby?: string;
search?: string;
Expand Down Expand Up @@ -289,9 +289,9 @@ export interface LoadTestRunClientCreateOrUpdateAppComponentsOptions extends Ope
// (undocumented)
contentType?: string;
createdBy?: string;
createdDateTime?: any;
createdDateTime?: Date;
lastModifiedBy?: string;
lastModifiedDateTime?: any;
lastModifiedDateTime?: Date;
testRunId?: string;
}

Expand All @@ -300,9 +300,9 @@ export interface LoadTestRunClientCreateOrUpdateServerMetricsConfigOptions exten
// (undocumented)
contentType?: string;
createdBy?: string;
createdDateTime?: any;
createdDateTime?: Date;
lastModifiedBy?: string;
lastModifiedDateTime?: any;
lastModifiedDateTime?: Date;
metrics?: Record<string, LoadTestRunClientResourceMetric>;
testRunId?: string;
}
Expand Down Expand Up @@ -332,7 +332,7 @@ export interface LoadTestRunClientErrorDetails {

// @public
export interface LoadTestRunClientFileInfo {
expireDateTime?: any;
expireDateTime?: Date;
fileName?: string;
fileType?: LoadTestRunClientFileType;
url?: string;
Expand Down Expand Up @@ -475,15 +475,15 @@ export type LoadTestRunClientStatus = string;
export interface LoadTestRunClientTest {
certificate?: LoadTestRunClientCertificateMetadata;
readonly createdBy?: string;
readonly createdDateTime?: any;
readonly createdDateTime?: Date;
description?: string;
displayName?: string;
environmentVariables?: Record<string, string>;
readonly inputArtifacts?: LoadTestRunClientTestInputArtifacts;
keyvaultReferenceIdentityId?: string;
keyvaultReferenceIdentityType?: string;
readonly lastModifiedBy?: string;
readonly lastModifiedDateTime?: any;
readonly lastModifiedDateTime?: Date;
loadTestConfiguration?: LoadTestRunClientLoadTestConfiguration;
passFailCriteria?: LoadTestRunClientPassFailCriteria;
secrets?: Record<string, LoadTestRunClientSecret>;
Expand All @@ -504,21 +504,21 @@ export interface LoadTestRunClientTestInputArtifacts {
export interface LoadTestRunClientTestRun {
certificate?: LoadTestRunClientCertificateMetadata;
readonly createdBy?: string;
readonly createdDateTime?: any;
readonly createdDateTime?: Date;
description?: string;
displayName?: string;
readonly duration?: number;
readonly endDateTime?: any;
readonly endDateTime?: Date;
environmentVariables?: Record<string, string>;
readonly errorDetails?: LoadTestRunClientErrorDetails[];
readonly executedDateTime?: any;
readonly executedDateTime?: Date;
readonly lastModifiedBy?: string;
readonly lastModifiedDateTime?: any;
readonly lastModifiedDateTime?: Date;
loadTestConfiguration?: LoadTestRunClientLoadTestConfiguration;
passFailCriteria?: LoadTestRunClientPassFailCriteria;
readonly portalUrl?: string;
secrets?: Record<string, LoadTestRunClientSecret>;
readonly startDateTime?: any;
readonly startDateTime?: Date;
readonly status?: LoadTestRunClientStatus;
readonly subnetId?: string;
readonly testArtifacts?: LoadTestRunClientTestRunArtifacts;
Expand Down Expand Up @@ -699,15 +699,15 @@ export interface StopTestRunOptions extends OperationOptions {
export interface Test {
certificate?: CertificateMetadata;
readonly createdBy?: string;
readonly createdDateTime?: any;
readonly createdDateTime?: Date;
description?: string;
displayName?: string;
environmentVariables?: Record<string, string>;
readonly inputArtifacts?: TestInputArtifacts;
keyvaultReferenceIdentityId?: string;
keyvaultReferenceIdentityType?: string;
readonly lastModifiedBy?: string;
readonly lastModifiedDateTime?: any;
readonly lastModifiedDateTime?: Date;
loadTestConfiguration?: LoadTestConfiguration;
passFailCriteria?: PassFailCriteria;
secrets?: Record<string, Secret>;
Expand All @@ -719,9 +719,9 @@ export interface Test {
export interface TestAppComponents {
components: Record<string, AppComponent>;
readonly createdBy?: string;
readonly createdDateTime?: any;
readonly createdDateTime?: Date;
readonly lastModifiedBy?: string;
readonly lastModifiedDateTime?: any;
readonly lastModifiedDateTime?: Date;
readonly testId?: string;
}

Expand All @@ -738,21 +738,21 @@ export interface TestInputArtifacts {
export interface TestRun {
certificate?: CertificateMetadata;
readonly createdBy?: string;
readonly createdDateTime?: any;
readonly createdDateTime?: Date;
description?: string;
displayName?: string;
readonly duration?: number;
readonly endDateTime?: any;
readonly endDateTime?: Date;
environmentVariables?: Record<string, string>;
readonly errorDetails?: ErrorDetails[];
readonly executedDateTime?: any;
readonly executedDateTime?: Date;
readonly lastModifiedBy?: string;
readonly lastModifiedDateTime?: any;
readonly lastModifiedDateTime?: Date;
loadTestConfiguration?: LoadTestConfiguration;
passFailCriteria?: PassFailCriteria;
readonly portalUrl?: string;
secrets?: Record<string, Secret>;
readonly startDateTime?: any;
readonly startDateTime?: Date;
readonly status?: Status;
readonly subnetId?: string;
readonly testArtifacts?: TestRunArtifacts;
Expand Down Expand Up @@ -783,22 +783,22 @@ export interface TestRunOptions extends OperationOptions {
certificate?: LoadTestRunClientCertificateMetadata;
contentType?: string;
createdBy?: string;
createdDateTime?: any;
createdDateTime?: Date;
description?: string;
displayName?: string;
duration?: number;
endDateTime?: any;
endDateTime?: Date;
environmentVariables?: Record<string, string>;
errorDetails?: LoadTestRunClientErrorDetails[];
executedDateTime?: any;
executedDateTime?: Date;
lastModifiedBy?: string;
lastModifiedDateTime?: any;
lastModifiedDateTime?: Date;
loadTestConfiguration?: LoadTestRunClientLoadTestConfiguration;
oldTestRunId?: string;
passFailCriteria?: LoadTestRunClientPassFailCriteria;
portalUrl?: string;
secrets?: Record<string, LoadTestRunClientSecret>;
startDateTime?: any;
startDateTime?: Date;
status?: LoadTestRunClientStatus;
subnetId?: string;
testArtifacts?: LoadTestRunClientTestRunArtifacts;
Expand Down Expand Up @@ -835,9 +835,9 @@ export interface TestRunStatistics {
// @public
export interface TestServerMetricConfig {
readonly createdBy?: string;
readonly createdDateTime?: any;
readonly createdDateTime?: Date;
readonly lastModifiedBy?: string;
readonly lastModifiedDateTime?: any;
readonly lastModifiedDateTime?: Date;
metrics?: Record<string, ResourceMetric>;
readonly testId?: string;
}
Expand Down
Loading
Loading