Exemplo n.º 1
0
 /**
  * @return Schema
  */
 protected static function defineSchema()
 {
     $schema = new Schema('pbj:gdbots:tests.pbj:fixtures:email-message:1-0-0', __CLASS__, [Fb::create('id', T\TimeUuidType::create())->required()->build(), Fb::create('from_name', T\StringType::create())->build(), Fb::create('from_email', T\StringType::create())->required()->format('email')->build(), Fb::create('subject', T\StringType::create())->withDefault(function (EmailMessage $message = null) {
         if (!$message) {
             return null;
         }
         return implode(',', $message->get('labels', [])) . ' test';
     })->build(), Fb::create('body', T\StringType::create())->build(), Fb::create('priority', T\IntEnumType::create())->required()->className('Gdbots\\Tests\\Pbj\\Fixtures\\Enum\\Priority')->withDefault(Priority::NORMAL)->build(), Fb::create('sent', T\BooleanType::create())->build(), Fb::create('date_sent', T\DateTimeType::create())->build(), Fb::create('microtime_sent', T\MicrotimeType::create())->build(), Fb::create('provider', T\StringEnumType::create())->className('Gdbots\\Tests\\Pbj\\Fixtures\\Enum\\Provider')->withDefault(Provider::GMAIL())->build(), Fb::create('labels', T\StringType::create())->format(Format::HASHTAG())->asASet()->build(), Fb::create('nested', T\MessageType::create())->className('Gdbots\\Tests\\Pbj\\Fixtures\\NestedMessage')->build(), Fb::create('enum_in_set', T\StringEnumType::create())->className('Gdbots\\Tests\\Pbj\\Fixtures\\Enum\\Provider')->asASet()->build(), Fb::create('enum_in_list', T\StringEnumType::create())->className('Gdbots\\Tests\\Pbj\\Fixtures\\Enum\\Provider')->asAList()->build(), Fb::create('any_of_message', T\MessageType::create())->className('Gdbots\\Pbj\\Message')->asAList()->build(), Fb::create('dynamic_fields', T\DynamicFieldType::create())->asAList()->build()]);
     MessageResolver::registerSchema($schema);
     return $schema;
 }
Exemplo n.º 2
0
 /**
  * @return Schema
  */
 protected static function defineSchema()
 {
     return new Schema('pbj:eme:solicits:command:import-submission:1-0-0', __CLASS__, [Fb::create('solicit_id', T\IdentifierType::create())->required()->className('Eme\\Schemas\\Solicits\\SolicitId')->build(), Fb::create('first_name', T\StringType::create())->build(), Fb::create('last_name', T\StringType::create())->build(), Fb::create('email', T\StringType::create())->format(Format::EMAIL())->build(), Fb::create('email_domain', T\StringType::create())->format(Format::HOSTNAME())->build(), Fb::create('address', T\MessageType::create())->className('Gdbots\\Schemas\\Geo\\Address')->build(), Fb::create('phone', T\StringType::create())->asAMap()->maxLength(20)->pattern('^\\+?[1-9]\\d{1,14}$')->build(), Fb::create('dob', T\DateType::create())->build(), Fb::create('age', T\TinyIntType::create())->max(120)->build(), Fb::create('gender', T\IntEnumType::create())->className('Gdbots\\Schemas\\Common\\Enum\\Gender')->build(), Fb::create('story', T\TextType::create())->build(), Fb::create('file_ids', T\IdentifierType::create())->asASet()->className('Gdbots\\Schemas\\Files\\FileId')->build(), Fb::create('photo_urls', T\StringType::create())->asAList()->format(Format::URL())->build(), Fb::create('video_urls', T\StringType::create())->asAList()->format(Format::URL())->build(), Fb::create('networks', T\StringType::create())->asAMap()->maxLength(50)->pattern('^[\\w\\.-]+$')->build(), Fb::create('ppid', T\StringType::create())->pattern('^[\\w\\/\\.:-]+$')->build(), Fb::create('cf', T\DynamicFieldType::create())->asAList()->build(), Fb::create('hashtags', T\StringType::create())->asASet()->format(Format::HASHTAG())->build(), Fb::create('tags', T\StringType::create())->asAMap()->pattern('^[\\w\\/\\.:-]+$')->build(), Fb::create('is_blocked', T\BooleanType::create())->build(), Fb::create('is_read', T\BooleanType::create())->build(), Fb::create('last_read_at', T\MicrotimeType::create())->useTypeDefault(false)->build(), Fb::create('last_read_by_ref', T\MessageRefType::create())->build(), Fb::create('is_verified', T\BooleanType::create())->build(), Fb::create('verified_at', T\MicrotimeType::create())->useTypeDefault(false)->build()], [AccountRefV1Mixin::create(), CommandV1Mixin::create(), CollectableV1Mixin::create(), TimePartingV1Mixin::create(), TimeSamplingV1Mixin::create(), UtmV1Mixin::create()]);
 }
Exemplo n.º 3
0
 /**
  * @return Schema
  */
 protected static function defineSchema()
 {
     return new Schema('pbj:eme:solicits:node:solicit:1-0-0', __CLASS__, [Fb::create('_id', T\IdentifierType::create())->required()->withDefault(function () {
         return SolicitId::generate();
     })->className('Eme\\Schemas\\Solicits\\SolicitId')->build(), Fb::create('description', T\TextType::create())->build(), Fb::create('hashtags', T\StringType::create())->asASet()->format(Format::HASHTAG())->build(), Fb::create('story_enabled', T\BooleanType::create())->withDefault(true)->build(), Fb::create('story_required', T\BooleanType::create())->build(), Fb::create('story_label', T\StringType::create())->build(), Fb::create('utm_campaign', T\StringType::create())->maxLength(50)->pattern('^[\\w\\/\\.:-]+$')->build()], [AccountRefV1Mixin::create(), NodeV1Mixin::create(), ExpirableV1Mixin::create(), IndexedV1Mixin::create(), PublishableV1Mixin::create()]);
 }
Exemplo n.º 4
0
 /**
  * @return Schema
  */
 protected static function defineSchema()
 {
     return new Schema('pbj:gdbots:pbjx::envelope:1-0-0', __CLASS__, [Fb::create('envelope_id', T\UuidType::create())->required()->build(), Fb::create('ok', T\BooleanType::create())->withDefault(true)->build(), Fb::create('code', T\SmallIntType::create())->withDefault(Code::OK)->build(), Fb::create('http_code', T\IntEnumType::create())->withDefault(HttpCode::HTTP_OK())->className('Gdbots\\Schemas\\Pbjx\\Enum\\HttpCode')->build(), Fb::create('etag', T\StringType::create())->maxLength(100)->pattern('^[\\w\\.:-]+$')->build(), Fb::create('error_name', T\StringType::create())->pattern('^[\\w\\/\\.:-]+$')->build(), Fb::create('error_message', T\TextType::create())->build(), Fb::create('message_ref', T\MessageRefType::create())->build(), Fb::create('message', T\MessageType::create())->className('Gdbots\\Pbj\\Message')->build()]);
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function getFields()
 {
     return [Fb::create('month_of_year', T\IntEnumType::create())->withDefault(Month::UNKNOWN())->className('Gdbots\\Schemas\\Common\\Enum\\Month')->build(), Fb::create('day_of_month', T\TinyIntType::create())->max(31)->build(), Fb::create('day_of_week', T\IntEnumType::create())->withDefault(DayOfWeek::UNKNOWN())->className('Gdbots\\Schemas\\Common\\Enum\\DayOfWeek')->build(), Fb::create('is_weekend', T\BooleanType::create())->build(), Fb::create('hour_of_day', T\TinyIntType::create())->max(23)->build()];
 }
Exemplo n.º 6
0
 /**
  * @param string $kind
  *
  * @return Field
  */
 private static function createField($kind)
 {
     if (!isset(self::$fields[$kind])) {
         switch ($kind) {
             case DynamicFieldKind::STRING_VAL:
                 $type = StringType::create();
                 break;
             case DynamicFieldKind::TEXT_VAL:
                 $type = TextType::create();
                 break;
             case DynamicFieldKind::INT_VAL:
                 $type = IntType::create();
                 break;
             case DynamicFieldKind::BOOL_VAL:
                 $type = BooleanType::create();
                 break;
             case DynamicFieldKind::FLOAT_VAL:
                 $type = FloatType::create();
                 break;
             case DynamicFieldKind::DATE_VAL:
                 $type = DateType::create();
                 break;
             default:
                 throw new InvalidArgumentException(sprintf('DynamicField "%s" is not a valid type.', $kind));
         }
         self::$fields[$kind] = new Field($kind, $type, FieldRule::A_SINGLE_VALUE(), true);
     }
     return self::$fields[$kind];
 }
Exemplo n.º 7
0
 /**
  * @return Schema
  */
 protected static function defineSchema()
 {
     return new Schema('pbj:eme:users:node:user:1-0-0', __CLASS__, [Fb::create('_id', T\IdentifierType::create())->required()->withDefault(function () {
         return UserId::generate();
     })->className('Eme\\Schemas\\Users\\UserId')->build(), Fb::create('first_name', T\StringType::create())->build(), Fb::create('last_name', T\StringType::create())->build(), Fb::create('email', T\StringType::create())->format(Format::EMAIL())->build(), Fb::create('email_domain', T\StringType::create())->format(Format::HOSTNAME())->build(), Fb::create('address', T\MessageType::create())->className('Gdbots\\Schemas\\Geo\\Address')->build(), Fb::create('phone', T\StringType::create())->asAMap()->pattern('^\\+?[1-9]\\d{1,14}$')->build(), Fb::create('dob', T\DateType::create())->build(), Fb::create('gender', T\IntEnumType::create())->withDefault(Gender::UNKNOWN())->className('Gdbots\\Schemas\\Common\\Enum\\Gender')->build(), Fb::create('networks', T\StringType::create())->asAMap()->maxLength(50)->pattern('^[\\w\\.-]+$')->build(), Fb::create('hashtags', T\StringType::create())->asASet()->format(Format::HASHTAG())->build(), Fb::create('tags', T\StringType::create())->asAMap()->pattern('^[\\w\\/\\.:-]+$')->build(), Fb::create('is_blocked', T\BooleanType::create())->build()], [AccountRefV1Mixin::create(), NodeV1Mixin::create(), IndexedV1Mixin::create()]);
 }
Exemplo n.º 8
0
 /**
  * @return Schema
  */
 protected static function defineSchema()
 {
     return new Schema('pbj:gdbots:geo::address:1-0-0', __CLASS__, [Fb::create('geo_hash', T\StringType::create())->maxLength(20)->pattern('^\\w+$')->build(), Fb::create('geo_point', T\GeoPointType::create())->build(), Fb::create('is_verified', T\BooleanType::create())->build(), Fb::create('street1', T\StringType::create())->build(), Fb::create('street2', T\StringType::create())->maxLength(20)->build(), Fb::create('po_box', T\StringType::create())->maxLength(20)->build(), Fb::create('city', T\StringType::create())->maxLength(100)->build(), Fb::create('region', T\StringType::create())->pattern('^[A-Z0-9]{2}$')->build(), Fb::create('region_name', T\StringType::create())->maxLength(150)->build(), Fb::create('postal_code', T\StringType::create())->maxLength(30)->pattern('^[\\w\\s-]+$')->build(), Fb::create('country', T\StringType::create())->pattern('^[A-Z]{2}$')->build(), Fb::create('continent', T\StringType::create())->build()]);
 }