-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding WellKnown types and using codec for serializers
1 parent
37bcaee
commit beac75a
Showing
60 changed files
with
1,532 additions
and
187 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
'use strict'; | ||
|
||
import DynamicField from 'gdbots/pbj/well-known/dynamic-field'; | ||
import GeoPoint from 'gdbots/pbj/well-known/geo-point'; | ||
import Message from 'gdbots/pbj/message'; | ||
import MessageRef from 'gdbots/pbj/message-ref'; | ||
|
||
export default class Codec | ||
{ | ||
/** | ||
* @param Message message | ||
* @param Field field | ||
* | ||
* @return mixed | ||
*/ | ||
encodeMessage(message, field) { | ||
throw message.toArray(); | ||
} | ||
|
||
/** | ||
* @param mixed value | ||
* @param Field field | ||
* | ||
* @return Message | ||
*/ | ||
decodeMessage(value, field) { | ||
return Message.fromArray(value); | ||
} | ||
|
||
/** | ||
* @param MessageRef messageRef | ||
* @param Field field | ||
* | ||
* @return mixed | ||
*/ | ||
encodeMessageRef(messageRef, field) { | ||
return messageRef.toArray(); | ||
} | ||
|
||
/** | ||
* @param mixed value | ||
* @param Field field | ||
* | ||
* @return MessageRef | ||
*/ | ||
decodeMessageRef(value, field) { | ||
return MessageRef.fromArray(value); | ||
} | ||
|
||
/** | ||
* @param GeoPoint geoPoint | ||
* @param Field field | ||
* | ||
* @return mixed | ||
*/ | ||
encodeGeoPoint(geoPoint, field) { | ||
return [geoPoint.getLongitude(), geoPoint.getLatitude()]; | ||
} | ||
|
||
/** | ||
* @param mixed value | ||
* @param Field field | ||
* | ||
* @return GeoPoint | ||
*/ | ||
decodeGeoPoint(value, field) { | ||
return new GeoPoint(value[1], value[0]); | ||
} | ||
|
||
/** | ||
* @param DynamicField dynamicField | ||
* @param Field field | ||
* | ||
* @return mixed | ||
*/ | ||
encodeDynamicField(dynamicField, field) { | ||
dynamicField.toArray(); | ||
} | ||
|
||
/** | ||
* @param mixed value | ||
* @param Field field | ||
* | ||
* @return DynamicField | ||
*/ | ||
decodeDynamicField(value, field) { | ||
DynamicField.fromArray(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
import Enum from 'gdbots/common/enum'; | ||
import SystemUtils from 'gdbots/common/util/system-utils'; | ||
|
||
/** | ||
* @method static DynamicFieldKind BOOL_VAL() | ||
* @method static DynamicFieldKind DATE_VAL() | ||
* @method static DynamicFieldKind FLOAT_VAL() | ||
* @method static DynamicFieldKind INT_VAL() | ||
* @method static DynamicFieldKind STRING_VAL() | ||
* @method static DynamicFieldKind TEXT_VAL() | ||
*/ | ||
export default class DynamicFieldKind extends SystemUtils.mixinClass(Enum) {} | ||
|
||
DynamicFieldKind.initEnum({ | ||
BOOL_VAL: 'bool_val', | ||
DATE_VAL: 'date_val', | ||
FLOAT_VAL: 'float_val', | ||
INT_VAL: 'int_val', | ||
STRING_VAL: 'string_val', | ||
TEXT_VAL: 'text_val' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
|
||
import SystemUtils from 'gdbots/common/util/system-utils'; | ||
import GdbotsPbjException from 'gdbots/pbj/exception/gdbots-pbj-exception'; | ||
|
||
export default class InvalidArgumentException extends SystemUtils.mixinClass(GdbotsPbjException) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
'use strict'; | ||
|
||
import SystemUtils from 'gdbots/common/util/system-utils'; | ||
import GdbotsPbjException from 'gdbots/pbj/exception/gdbots-pbj-exception'; | ||
import InvalidArgumentException from 'gdbots/pbj/exception/invalid-argument-exception'; | ||
|
||
export default class InvalidSchemaCurie extends SystemUtils.mixinClass(GdbotsPbjException) {} | ||
export default class InvalidSchemaCurie extends SystemUtils.mixinClass(InvalidArgumentException) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
'use strict'; | ||
|
||
import SystemUtils from 'gdbots/common/util/system-utils'; | ||
import GdbotsPbjException from 'gdbots/pbj/exception/gdbots-pbj-exception'; | ||
import InvalidArgumentException from 'gdbots/pbj/exception/invalid-argument-exception'; | ||
|
||
export default class InvalidSchemaId extends SystemUtils.mixinClass(GdbotsPbjException) {} | ||
export default class InvalidSchemaId extends SystemUtils.mixinClass(InvalidArgumentException) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
|
||
import SystemUtils from 'gdbots/common/util/system-utils'; | ||
import InvalidArgumentException from 'gdbots/pbj/exception/invalid-argument-exception'; | ||
|
||
export default class InvalidSchemaQName extends SystemUtils.mixinClass(InvalidArgumentException) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
'use strict'; | ||
|
||
import SystemUtils from 'gdbots/common/util/system-utils'; | ||
import GdbotsPbjException from 'gdbots/pbj/exception/gdbots-pbj-exception'; | ||
import InvalidArgumentException from 'gdbots/pbj/exception/invalid-argument-exception'; | ||
|
||
export default class InvalidSchemaVersion extends SystemUtils.mixinClass(GdbotsPbjException) {} | ||
export default class InvalidSchemaVersion extends SystemUtils.mixinClass(InvalidArgumentException) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.