Skip to content

Commit

Permalink
Fixed plugin timestamp getter.
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Nov 3, 2023
1 parent 2bd802f commit 0b2ae6a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
8 changes: 4 additions & 4 deletions packages/ast/src/encoding/__snapshots__/object.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,7 @@ exports[`google/api/expr/v1alpha1/syntax Constant 1`] = `
stringValue: object?.string_value,
bytesValue: object?.bytes_value,
durationValue: object?.duration_value ? Duration.fromAmino(object.duration_value) : undefined,
timestampValue: object?.timestamp_value ? Timestamp.fromAmino(object.timestamp_value) : undefined
timestampValue: object?.timestamp_value ? fromTimestamp(Timestamp.fromAmino(object.timestamp_value)) : undefined
};
},
toAmino(message: Constant): ConstantAmino {
Expand All @@ -2038,7 +2038,7 @@ exports[`google/api/expr/v1alpha1/syntax Constant 1`] = `
obj.string_value = message.stringValue;
obj.bytes_value = message.bytesValue;
obj.duration_value = message.durationValue ? Duration.toAmino(message.durationValue) : undefined;
obj.timestamp_value = message.timestampValue ? Timestamp.toAmino(message.timestampValue) : undefined;
obj.timestamp_value = message.timestampValue ? Timestamp.toAmino(toTimestamp(message.timestampValue)) : undefined;
return obj;
},
fromAminoMsg(object: ConstantAminoMsg): Constant {
Expand Down Expand Up @@ -2760,7 +2760,7 @@ exports[`google/api/servicecontrol/v1/log_entry LogEntry 1`] = `
fromAmino(object: LogEntryAmino): LogEntry {
return {
name: object.name,
timestamp: object?.timestamp ? Timestamp.fromAmino(object.timestamp) : undefined,
timestamp: object?.timestamp ? fromTimestamp(Timestamp.fromAmino(object.timestamp)) : undefined,
severity: isSet(object.severity) ? logSeverityFromJSON(object.severity) : -1,
httpRequest: object?.http_request ? HttpRequest.fromAmino(object.http_request) : undefined,
trace: object.trace,
Expand All @@ -2781,7 +2781,7 @@ exports[`google/api/servicecontrol/v1/log_entry LogEntry 1`] = `
toAmino(message: LogEntry): LogEntryAmino {
const obj: any = {};
obj.name = message.name;
obj.timestamp = message.timestamp ? Timestamp.toAmino(message.timestamp) : undefined;
obj.timestamp = message.timestamp ? Timestamp.toAmino(toTimestamp(message.timestamp)) : undefined;
obj.severity = message.severity;
obj.http_request = message.httpRequest ? HttpRequest.toAmino(message.httpRequest) : undefined;
obj.trace = message.trace;
Expand Down
8 changes: 1 addition & 7 deletions packages/ast/src/encoding/proto/from-amino/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,9 @@ export const fromAminoJSON = {
},

timestamp(args: FromAminoJSONMethod) {
let timestampFormat = args.context.pluginValue(
const timestampFormat = args.context.pluginValue(
'prototypes.typingsFormat.timestamp'
);
const env = args.context.pluginValue(
'env'
);
if (!env || env == 'default') {
timestampFormat = 'timestamp';
}
switch (timestampFormat) {
case 'timestamp':
return fromAminoJSON.type(args);
Expand Down
8 changes: 1 addition & 7 deletions packages/ast/src/encoding/proto/to-amino/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,9 @@ export const toAminoJSON = {
},

timestamp(args: ToAminoJSONMethod) {
let timestampFormat = args.context.pluginValue(
const timestampFormat = args.context.pluginValue(
'prototypes.typingsFormat.timestamp'
);
const env = args.context.pluginValue(
'env'
);
if (!env || env == 'default') {
timestampFormat = 'timestamp';
}
switch (timestampFormat) {
case 'timestamp':
return toAminoJSON.type(args);
Expand Down

0 comments on commit 0b2ae6a

Please sign in to comment.