diff --git a/packages/firebase_data_connect/firebase_data_connect/example/.firebaserc b/packages/firebase_data_connect/firebase_data_connect/example/.firebaserc index cad24fca0101..4f437a595212 100644 --- a/packages/firebase_data_connect/firebase_data_connect/example/.firebaserc +++ b/packages/firebase_data_connect/firebase_data_connect/example/.firebaserc @@ -6,7 +6,7 @@ "etags": {}, "dataconnectEmulatorConfig": { "postgres": { - "localConnectionString": "postgresql://postgres:postgres@localhost:5432/postgres?sslmode=disable" + "localConnectionString": "postgresql://postgres:secretpassword@localhost:5432/postgres?sslmode=disable" } } } \ No newline at end of file diff --git a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/implicit.gql b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/implicit.gql index 6023bf3bb134..edc6e8a5fe33 100755 --- a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/implicit.gql +++ b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/implicit.gql @@ -8,3 +8,6 @@ extend type Movie { extend type Person { id: UUID! @default(expr: "uuidV4()") @fdc_generated(from: "Person", purpose: IMPLICIT_KEY_FIELD) } +extend type TimestampHolder { + id: UUID! @default(expr: "uuidV4()") @fdc_generated(from: "TimestampHolder", purpose: IMPLICIT_KEY_FIELD) +} diff --git a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/input.gql b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/input.gql index 5fa1104b564e..7e88f7d7b3c6 100755 --- a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/input.gql +++ b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/input.gql @@ -1,6 +1,7 @@ scalar DirectedBy_Key scalar Movie_Key scalar Person_Key +scalar TimestampHolder_Key input DirectedBy_Data { movieId: UUID movieId_expr: UUID_Expr @@ -88,3 +89,30 @@ input Person_Order { id: OrderDirection name: OrderDirection } +input TimestampHolder_Data { + id: UUID + id_expr: UUID_Expr + date: Date + date_date: Date_Relative + date_expr: Date_Expr + timestamp: Timestamp + timestamp_expr: Timestamp_Expr + timestamp_time: Timestamp_Relative +} +input TimestampHolder_Filter { + _and: [TimestampHolder_Filter!] + _not: TimestampHolder_Filter + _or: [TimestampHolder_Filter!] + id: UUID_Filter + date: Date_Filter + timestamp: Timestamp_Filter +} +input TimestampHolder_ListFilter { + count: Int_Filter = {gt:0} + exist: TimestampHolder_Filter +} +input TimestampHolder_Order { + id: OrderDirection + date: OrderDirection + timestamp: OrderDirection +} diff --git a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/mutation.gql b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/mutation.gql index 4daa8a6f0c64..c36f32ea1eaa 100755 --- a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/mutation.gql +++ b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/mutation.gql @@ -12,6 +12,10 @@ extend type Mutation { """ person_insert(data: Person_Data!): Person_Key! @fdc_generated(from: "Person", purpose: INSERT_SINGLE) """ + Insert a single TimestampHolder into the table. Columns not specified in `data` will receive defaults (e.g. `null`). + """ + timestampHolder_insert(data: TimestampHolder_Data!): TimestampHolder_Key! @fdc_generated(from: "TimestampHolder", purpose: INSERT_SINGLE) + """ Insert DirectedBy entries into the table. Columns not specified in `data` will receive defaults (e.g. `null`). """ directedBy_insertMany(data: [DirectedBy_Data!]!): [DirectedBy_Key!]! @fdc_generated(from: "DirectedBy", purpose: INSERT_MULTIPLE) @@ -24,6 +28,10 @@ extend type Mutation { """ person_insertMany(data: [Person_Data!]!): [Person_Key!]! @fdc_generated(from: "Person", purpose: INSERT_MULTIPLE) """ + Insert TimestampHolder entries into the table. Columns not specified in `data` will receive defaults (e.g. `null`). + """ + timestampHolder_insertMany(data: [TimestampHolder_Data!]!): [TimestampHolder_Key!]! @fdc_generated(from: "TimestampHolder", purpose: INSERT_MULTIPLE) + """ Insert or update a single DirectedBy into the table, based on the primary key. Returns the key of the newly inserted DirectedBy. """ directedBy_upsert(data: DirectedBy_Data!): DirectedBy_Key! @fdc_generated(from: "DirectedBy", purpose: UPSERT_SINGLE) @@ -36,6 +44,10 @@ extend type Mutation { """ person_upsert(data: Person_Data!): Person_Key! @fdc_generated(from: "Person", purpose: UPSERT_SINGLE) """ + Insert or update a single TimestampHolder into the table, based on the primary key. Returns the key of the newly inserted TimestampHolder. + """ + timestampHolder_upsert(data: TimestampHolder_Data!): TimestampHolder_Key! @fdc_generated(from: "TimestampHolder", purpose: UPSERT_SINGLE) + """ Insert or update DirectedBy entries into the table, based on the primary key. Returns the key of the newly inserted DirectedBy. """ directedBy_upsertMany(data: [DirectedBy_Data!]): [DirectedBy_Key!]! @fdc_generated(from: "DirectedBy", purpose: UPSERT_MULTIPLE) @@ -48,6 +60,10 @@ extend type Mutation { """ person_upsertMany(data: [Person_Data!]): [Person_Key!]! @fdc_generated(from: "Person", purpose: UPSERT_MULTIPLE) """ + Insert or update TimestampHolder entries into the table, based on the primary key. Returns the key of the newly inserted TimestampHolder. + """ + timestampHolder_upsertMany(data: [TimestampHolder_Data!]): [TimestampHolder_Key!]! @fdc_generated(from: "TimestampHolder", purpose: UPSERT_MULTIPLE) + """ Update a single DirectedBy based on `id` or `key`, setting columns specified in `data`. Returns `null` if not found. """ directedBy_update(key: DirectedBy_Key, data: DirectedBy_Data!): DirectedBy_Key @fdc_generated(from: "DirectedBy", purpose: UPDATE_SINGLE) @@ -60,6 +76,10 @@ extend type Mutation { """ person_update(id: UUID, key: Person_Key, data: Person_Data!): Person_Key @fdc_generated(from: "Person", purpose: UPDATE_SINGLE) """ + Update a single TimestampHolder based on `id` or `key`, setting columns specified in `data`. Returns `null` if not found. + """ + timestampHolder_update(id: UUID, key: TimestampHolder_Key, data: TimestampHolder_Data!): TimestampHolder_Key @fdc_generated(from: "TimestampHolder", purpose: UPDATE_SINGLE) + """ Update DirectedBy entries matching `where` conditions (or `all`, if true) according to `data`. Returns the number of rows updated. """ directedBy_updateMany(where: DirectedBy_Filter, all: Boolean = false, data: DirectedBy_Data!): Int! @fdc_generated(from: "DirectedBy", purpose: UPDATE_MULTIPLE) @@ -72,6 +92,10 @@ extend type Mutation { """ person_updateMany(where: Person_Filter, all: Boolean = false, data: Person_Data!): Int! @fdc_generated(from: "Person", purpose: UPDATE_MULTIPLE) """ + Update TimestampHolder entries matching `where` conditions (or `all`, if true) according to `data`. Returns the number of rows updated. + """ + timestampHolder_updateMany(where: TimestampHolder_Filter, all: Boolean = false, data: TimestampHolder_Data!): Int! @fdc_generated(from: "TimestampHolder", purpose: UPDATE_MULTIPLE) + """ Delete a single DirectedBy based on `id` or `key` and return its key (or `null` if not found). """ directedBy_delete(key: DirectedBy_Key): DirectedBy_Key @fdc_generated(from: "DirectedBy", purpose: DELETE_SINGLE) @@ -84,6 +108,10 @@ extend type Mutation { """ person_delete(id: UUID, key: Person_Key): Person_Key @fdc_generated(from: "Person", purpose: DELETE_SINGLE) """ + Delete a single TimestampHolder based on `id` or `key` and return its key (or `null` if not found). + """ + timestampHolder_delete(id: UUID, key: TimestampHolder_Key): TimestampHolder_Key @fdc_generated(from: "TimestampHolder", purpose: DELETE_SINGLE) + """ Delete DirectedBy entries matching `where` conditions (or `all`, if true). Returns the number of rows deleted. """ directedBy_deleteMany(where: DirectedBy_Filter, all: Boolean = false): Int! @fdc_generated(from: "DirectedBy", purpose: DELETE_MULTIPLE) @@ -95,4 +123,8 @@ extend type Mutation { Delete Person entries matching `where` conditions (or `all`, if true). Returns the number of rows deleted. """ person_deleteMany(where: Person_Filter, all: Boolean = false): Int! @fdc_generated(from: "Person", purpose: DELETE_MULTIPLE) + """ + Delete TimestampHolder entries matching `where` conditions (or `all`, if true). Returns the number of rows deleted. + """ + timestampHolder_deleteMany(where: TimestampHolder_Filter, all: Boolean = false): Int! @fdc_generated(from: "TimestampHolder", purpose: DELETE_MULTIPLE) } diff --git a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/query.gql b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/query.gql index db0f2136ff69..3df5abe5d1cc 100755 --- a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/query.gql +++ b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/main/query.gql @@ -12,6 +12,10 @@ extend type Query { """ person(id: UUID, key: Person_Key): Person @fdc_generated(from: "Person", purpose: QUERY_SINGLE) """ + Look up a single TimestampHolder based on `id` or `key` and return selected fields (or `null` if not found). + """ + timestampHolder(id: UUID, key: TimestampHolder_Key): TimestampHolder @fdc_generated(from: "TimestampHolder", purpose: QUERY_SINGLE) + """ List DirectedBy entries in the table, optionally filtered by `where` conditions. """ directedBies(where: DirectedBy_Filter, orderBy: [DirectedBy_Order!], offset: Int, limit: Int = 100): [DirectedBy!]! @fdc_generated(from: "DirectedBy", purpose: QUERY_MULTIPLE) @@ -23,4 +27,8 @@ extend type Query { List Person entries in the table, optionally filtered by `where` conditions. """ people(where: Person_Filter, orderBy: [Person_Order!], offset: Int, limit: Int = 100): [Person!]! @fdc_generated(from: "Person", purpose: QUERY_MULTIPLE) + """ + List TimestampHolder entries in the table, optionally filtered by `where` conditions. + """ + timestampHolders(where: TimestampHolder_Filter, orderBy: [TimestampHolder_Order!], offset: Int, limit: Int = 100): [TimestampHolder!]! @fdc_generated(from: "TimestampHolder", purpose: QUERY_MULTIPLE) } diff --git a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/prelude.gql b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/prelude.gql index c75ac521add7..54eee276ad8a 100755 --- a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/prelude.gql +++ b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/.dataconnect/schema/prelude.gql @@ -46,6 +46,17 @@ directive @auth( """ expr: Boolean_Expr @fdc_oneOf(required: true) ) on QUERY | MUTATION + +""" +Marks an element of a GraphQL operation as no longer supported on the client. +The Firebase Data Connect backend will still support this element, but it will +no longer appear in generated SDKs. +""" +directive @retired( + "Explains why this element was retired." + reason: String +) on QUERY | MUTATION | FIELD | VARIABLE_DEFINITION + "Query filter criteria for `String` scalar fields." input String_Filter { "When true, match if field `IS NULL`. When false, match if field is `NOT NULL`." @@ -304,6 +315,7 @@ input Any_ListFilter { "Match if list field does not contain any of the provided values as members." excludesAll: [Any!] } + """ (Internal) A string that uniquely identifies a type, field, and so on. @@ -358,53 +370,7 @@ directive @fdc_generated( | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION -""" -Defines a database index to optimize query performance. - -Given `type TableName @table @index(fields: [“fieldName”, “secondFieldName”])`, -`table_name_field_name_second_field_name_aa_idx` is the SQL index id. -`table_name_field_name_second_field_name_ad_idx` if `order: [ASC DESC]`. -`table_name_field_name_second_field_name_dd_idx` if `order: [DESC DESC]`. - -Given `type TableName @table { fieldName: Int @index } ` -`table_name_field_name_idx` is the SQL index id. -`order` matters less for single field indexes because they can be scanned in both ways. - -Override with `@index(name)` in case of index name conflicts. -""" -directive @index( - "The SQL database index id. Defaults to __idx." - name: String - """ - Only allowed and required when used on OBJECT. - The fields to create an index on. - """ - fields: [String!] - """ - Only allowed when used on OBJECT and BTREE index. - Index order of each column. Default to all ASC. - """ - order: [IndexFieldOrder!] - """ - For array field, default to `GIN`. - For Vector field, default to `HNSW`. - """ - type: IndexType - """ - Only allowed when used on vector field. - The vector similarity method. Default to `INNER_PRODUCT`. - """ - vector_method: VectorSimilarityMethod -) repeatable on FIELD_DEFINITION | OBJECT -enum IndexFieldOrder { ASC DESC } - -enum IndexType { - BTREE - GIN - HNSW - IVFFLAT -} type Query { _service: _Service! } @@ -415,7 +381,10 @@ type Mutation { } type _Service { + "Full Service Definition Language of the Frebase Data Connect Schema, including normalized schema, predefined and generated types." sdl: String! + "Orignal Schema Sources in the service." + schema: String! } "(Internal) Added to things that may be removed from FDC and will soon be no longer usable in schema or operations." @@ -465,6 +434,7 @@ directive @fdc_oneOf( "If true, exactly one field / argument in the group must be specified." required: Boolean! = false ) repeatable on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION + """ UUID is a string with hex digits representing an RFC4122 value. @@ -490,16 +460,7 @@ scalar True @fdc_forbiddenAsFieldType @fdc_forbiddenAsVariableType @fdc_example(value: true, description: "The only allowed value.") -"Define the intervals used in timestamps and dates (subset)" -enum TimestampInterval @fdc_deprecated { - second - minute - hour - day - week - month - year -} + """ A Common Expression Language (CEL) expression that returns a boolean at runtime. @@ -566,6 +527,7 @@ scalar Any_SQL @fdc_sqlExpression @fdc_forbiddenAsVariableType @fdc_forbiddenAsFieldType + """ Defines a relational database table. @@ -718,24 +680,6 @@ enum OrderDirection { DESC } -enum ColDefault @fdc_deprecated { - """ - Generates a random UUID (v4) as the default column value. - Compatible with String or UUID typed fields. - """ - UUID - """ - Generates an auto-incrementing sequence as the default column value. - Compatible with Int and Int64 typed fields. - """ - SEQUENCE - """ - Populates the default column value with the current date or timestamp. - Compatible with Date and Timestamp typed fields. - """ - NOW -} - """ Specify the default column value. @@ -744,8 +688,6 @@ The supported arguments vary based on the field type. directive @default( "A constant value. Validated against the field GraphQL type at compile-time." value: Any @fdc_oneOf(required: true) - "(Deprecated) Built-in common ways to generate initial value." - generate: ColDefault @fdc_oneOf(required: true) @deprecated "A CEL expression, whose return value must match the field data type." expr: Any_Expr @fdc_oneOf(required: true) """ @@ -757,6 +699,75 @@ directive @default( """ sql: Any_SQL @fdc_oneOf(required: true) ) on FIELD_DEFINITION + +""" +Defines a database index to optimize query performance. + +Given `type TableName @table @index(fields: [“fieldName”, “secondFieldName”])`, +`table_name_field_name_second_field_name_aa_idx` is the SQL index id. +`table_name_field_name_second_field_name_ad_idx` if `order: [ASC DESC]`. +`table_name_field_name_second_field_name_dd_idx` if `order: [DESC DESC]`. + +Given `type TableName @table { fieldName: Int @index } ` +`table_name_field_name_idx` is the SQL index id. +`order` matters less for single field indexes because they can be scanned in both ways. + +Override with `@index(name)` in case of index name conflicts. +""" +directive @index( + "The SQL database index id. Defaults to __idx." + name: String + """ + Only allowed and required when used on OBJECT. + The fields to create an index on. + """ + fields: [String!] + """ + Only allowed when used on OBJECT and BTREE index. + Index order of each column. Default to all ASC. + """ + order: [IndexFieldOrder!] + """ + For array field, default to `GIN`. + For Vector field, default to `HNSW`. + """ + type: IndexType + """ + Only allowed when used on vector field. + The vector similarity method. Default to `INNER_PRODUCT`. + """ + vector_method: VectorSimilarityMethod +) repeatable on FIELD_DEFINITION | OBJECT + +enum IndexFieldOrder { ASC DESC } + +enum IndexType { + BTREE + GIN + HNSW + IVFFLAT +} + +""" +Defines a unique constraint. + +Given `type TableName @table @unique(fields: [“fieldName”, “secondFieldName”])`, +`table_name_field_name_second_field_name_uidx` is the SQL unique index id. +Given `type TableName @table { fieldName: Int @unique } ` +`table_name_field_name_uidx` is the SQL unique index id. + +Override with `@unique(indexName)` in case of index name conflicts. +""" +directive @unique( + "The SQL database unique index name. Defaults to __uidx." + indexName: String + """ + Only allowed and required when used on OBJECT. + The fields to create a unique constraint on. + """ + fields: [String!] +) repeatable on FIELD_DEFINITION | OBJECT + """ Date is a string in the YYYY-MM-DD format representing a local-only date. @@ -980,25 +991,7 @@ enum Date_Interval @fdc_forbiddenAsFieldType { MONTH YEAR } -""" -Defines a unique constraint. - -Given `type TableName @table @unique(fields: [“fieldName”, “secondFieldName”])`, -`table_name_field_name_second_field_name_uidx` is the SQL unique index id. -Given `type TableName @table { fieldName: Int @unique } ` -`table_name_field_name_uidx` is the SQL unique index id. -Override with `@unique(indexName)` in case of index name conflicts. -""" -directive @unique( - "The SQL database unique index name. Defaults to __uidx." - indexName: String - """ - Only allowed and required when used on OBJECT. - The fields to create a unique constraint on. - """ - fields: [String!] -) repeatable on FIELD_DEFINITION | OBJECT "Update input of a String value" input String_Update { set: String @fdc_oneOf(group: "set") @@ -1090,6 +1083,7 @@ input Any_ListUpdate { append: [Any!] prepend: [Any!] } + """ Vector is an array of single-precision floating-point numbers, serialized as a JSON array. All elements must be finite (no NaN, Infinity or -Infinity). @@ -1168,3 +1162,4 @@ scalar Vector_Embed_Model @fdc_forbiddenAsVariableType @fdc_forbiddenAsFieldType @fdc_example(value: "textembedding-gecko@003", description: "A stable version of the textembedding-gecko model") + diff --git a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/connector/mutations.gql b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/connector/mutations.gql index a869f6fea236..e7267ad14c44 100644 --- a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/connector/mutations.gql +++ b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/connector/mutations.gql @@ -6,6 +6,18 @@ mutation addDirectorToMovie($personId: Person_Key, $movieId: UUID) @auth(level: PUBLIC) { directedBy_insert(data: { directedby: $personId, movieId: $movieId }) } +mutation addTimestamp($timestamp: Timestamp!) @auth(level: PUBLIC) { + timestampHolder_insert(data: { + timestamp: $timestamp + }) +} +mutation addDateAndTimestamp($date: Date!, $timestamp: Timestamp!) @auth(level: PUBLIC) { + timestampHolder_insert(data: { + date: $date, + timestamp: $timestamp + }) +} + mutation createMovie( $title: String! $releaseYear: Int! diff --git a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/connector/queries.gql b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/connector/queries.gql index 25787ca9aa33..d6b1df7ab639 100644 --- a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/connector/queries.gql +++ b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/connector/queries.gql @@ -21,11 +21,18 @@ query ListMoviesByPartialTitle($input: String!) @auth(level: PUBLIC) { query ListPersons @auth(level: USER) { people { - id + id name } } +query ListTimestamps @auth(level: USER) { + timestampHolders { + timestamp, + date + } +} + # List subset of fields for users # query ListUsers @auth(level: PUBLIC) { # users { diff --git a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/schema/schema.gql b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/schema/schema.gql index 8fa70b4ec39d..2eac87eba0b4 100644 --- a/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/schema/schema.gql +++ b/packages/firebase_data_connect/firebase_data_connect/example/dataconnect/schema/schema.gql @@ -12,6 +12,10 @@ type Movie @table { releaseYear: Int rating: Float } +type TimestampHolder @table { + timestamp: Timestamp! + date: Date +} # type Movie # # The below parameter values are generated by default with @table, and can be edited manually. # @table(name: "Movies", singular: "movie", plural: "movies", key: ["id"]) { diff --git a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/add_date_and_timestamp.dart b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/add_date_and_timestamp.dart new file mode 100644 index 000000000000..b8c6412c807c --- /dev/null +++ b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/add_date_and_timestamp.dart @@ -0,0 +1,221 @@ +part of movies; + + + + + + + +class AddDateAndTimestamp { + String name = "addDateAndTimestamp"; + AddDateAndTimestamp({required this.dataConnect}); + + Deserializer dataDeserializer = (String json) => AddDateAndTimestampData.fromJson(jsonDecode(json) as Map); + Serializer varsSerializer = (AddDateAndTimestampVariables vars) => jsonEncode(vars.toJson()); + MutationRef ref( + {required DateTime date,required Timestamp timestamp,}) { + AddDateAndTimestampVariables vars=AddDateAndTimestampVariables(date: date,timestamp: timestamp,); + + return dataConnect.mutation(this.name, dataDeserializer, varsSerializer, vars); + } + FirebaseDataConnect dataConnect; +} + + + + + +class AddDateAndTimestampTimestampHolderInsert { + + + + + String id; + + + + + AddDateAndTimestampTimestampHolderInsert.fromJson(Map json): + id = + + nativeFromJson(json['id']) + + + + { + + + + } + + + // TODO(mtewani): Fix up to create a map on the fly + Map toJson() { + Map json = {}; + + + json['id'] = + + nativeToJson(id) + +; + + + return json; + } + + AddDateAndTimestampTimestampHolderInsert({ + + required this.id, + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + + } +} + + + + + + +class AddDateAndTimestampData { + + + + + AddDateAndTimestampTimestampHolderInsert timestampHolder_insert; + + + + + AddDateAndTimestampData.fromJson(Map json): + timestampHolder_insert = + + AddDateAndTimestampTimestampHolderInsert.fromJson(json['timestampHolder_insert']) + + + + { + + + + } + + + // TODO(mtewani): Fix up to create a map on the fly + Map toJson() { + Map json = {}; + + + json['timestampHolder_insert'] = + + timestampHolder_insert.toJson() + +; + + + return json; + } + + AddDateAndTimestampData({ + + required this.timestampHolder_insert, + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + + } +} + + + + + + +class AddDateAndTimestampVariables { + + + + + DateTime date; + + + + + + + Timestamp timestamp; + + + + + AddDateAndTimestampVariables.fromJson(Map json): + date = + + nativeFromJson(json['date']) + + + , + + timestamp = + + Timestamp.fromJson(json['timestamp']) + + + + { + + + + + + } + + + // TODO(mtewani): Fix up to create a map on the fly + Map toJson() { + Map json = {}; + + + json['date'] = + + nativeToJson(date) + +; + + + + json['timestamp'] = + + timestamp.toJson() + +; + + + return json; + } + + AddDateAndTimestampVariables({ + + required this.date, + + required this.timestamp, + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + + + + } +} + + + + + + + diff --git a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/add_director_to_movie.dart b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/add_director_to_movie.dart index 0929d0a602b9..85cda56f2611 100644 --- a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/add_director_to_movie.dart +++ b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/add_director_to_movie.dart @@ -1,132 +1,306 @@ part of movies; + + + + + + class AddDirectorToMovie { String name = "addDirectorToMovie"; AddDirectorToMovie({required this.dataConnect}); - Deserializer dataDeserializer = (String json) => - AddDirectorToMovieResponse.fromJson( - jsonDecode(json) as Map); - Serializer varsSerializer = - (AddDirectorToMovieVariables vars) => jsonEncode(vars.toJson()); - MutationRef ref( - {AddDirectorToMovieVariablesPersonId? personId, - String? movieId, - AddDirectorToMovieVariables? addDirectorToMovieVariables}) { - AddDirectorToMovieVariables vars1 = AddDirectorToMovieVariables( - personId: personId, - movieId: movieId, - ); - AddDirectorToMovieVariables vars = addDirectorToMovieVariables ?? vars1; - return dataConnect.mutation( - this.name, dataDeserializer, varsSerializer, vars); - } + Deserializer dataDeserializer = (String json) => AddDirectorToMovieData.fromJson(jsonDecode(json) as Map); + Serializer varsSerializer = (AddDirectorToMovieVariables vars) => jsonEncode(vars.toJson()); + MutationRef ref( + {AddDirectorToMovieVariablesPersonId? personId,String? movieId,}) { + AddDirectorToMovieVariables vars=AddDirectorToMovieVariables(personId: personId,movieId: movieId,); + return dataConnect.mutation(this.name, dataDeserializer, varsSerializer, vars); + } FirebaseDataConnect dataConnect; } + + + + class AddDirectorToMovieDirectedByInsert { - late String directedbyId; + + + + + String directedbyId; - late String movieId; + + + + + + String movieId; - AddDirectorToMovieDirectedByInsert.fromJson(Map json) - : directedbyId = json['directedbyId'], - movieId = json['movieId'] {} + + + + AddDirectorToMovieDirectedByInsert.fromJson(Map json): + directedbyId = + + nativeFromJson(json['directedbyId']) + - // TODO(mtewani): Fix up to create a map on the fly - Map toJson() { - Map json = {}; + , + + movieId = + + nativeFromJson(json['movieId']) + - json['directedbyId'] = directedbyId; + + { + + + + + + } - json['movieId'] = movieId; + // TODO(mtewani): Fix up to create a map on the fly + Map toJson() { + Map json = {}; + + + json['directedbyId'] = + + nativeToJson(directedbyId) + +; + + + + json['movieId'] = + + nativeToJson(movieId) + +; + + return json; } AddDirectorToMovieDirectedByInsert({ + required this.directedbyId, + required this.movieId, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + + + } } -class AddDirectorToMovieResponse { - late AddDirectorToMovieDirectedByInsert directedBy_insert; - AddDirectorToMovieResponse.fromJson(Map json) - : directedBy_insert = AddDirectorToMovieDirectedByInsert.fromJson( - json['directedBy_insert']) {} + + + + +class AddDirectorToMovieData { + + + + + AddDirectorToMovieDirectedByInsert directedBy_insert; + + + + + AddDirectorToMovieData.fromJson(Map json): + directedBy_insert = + + AddDirectorToMovieDirectedByInsert.fromJson(json['directedBy_insert']) + + + + { + + + + } + // TODO(mtewani): Fix up to create a map on the fly Map toJson() { Map json = {}; - - json['directedBy_insert'] = directedBy_insert.toJson(); - + + + json['directedBy_insert'] = + + directedBy_insert.toJson() + +; + + return json; } - AddDirectorToMovieResponse({ + AddDirectorToMovieData({ + required this.directedBy_insert, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + } } + + + + + class AddDirectorToMovieVariablesPersonId { - late String id; + + + + + String id; + + + + + AddDirectorToMovieVariablesPersonId.fromJson(Map json): + id = + + nativeFromJson(json['id']) + + + + { + + + + } - AddDirectorToMovieVariablesPersonId.fromJson(Map json) - : id = json['id'] {} // TODO(mtewani): Fix up to create a map on the fly Map toJson() { Map json = {}; - - json['id'] = id; - + + + json['id'] = + + nativeToJson(id) + +; + + return json; } AddDirectorToMovieVariablesPersonId({ + required this.id, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + } } -class AddDirectorToMovieVariables { - late AddDirectorToMovieVariablesPersonId? personId; - late String? movieId; - AddDirectorToMovieVariables.fromJson(Map json) - : personId = - AddDirectorToMovieVariablesPersonId.fromJson(json['personId']), - movieId = json['movieId'] {} + - // TODO(mtewani): Fix up to create a map on the fly - Map toJson() { - Map json = {}; - if (personId != null) { - json['personId'] = personId!.toJson(); - } +class AddDirectorToMovieVariables { + + + + + AddDirectorToMovieVariablesPersonId? personId; + + + + + + + String? movieId; - if (movieId != null) { - json['movieId'] = movieId; + + + + AddDirectorToMovieVariables.fromJson(Map json) { + + + personId = json['personId'] == null ? null : + + AddDirectorToMovieVariablesPersonId.fromJson(json['personId']) + +; + + + + movieId = json['movieId'] == null ? null : + + nativeFromJson(json['movieId']) + +; + + } + + // TODO(mtewani): Fix up to create a map on the fly + Map toJson() { + Map json = {}; + + + if (personId != null) { + json['personId'] = + + personId!.toJson() + +; + } + + + + if (movieId != null) { + json['movieId'] = + + nativeToJson(movieId) + +; + } + + return json; } AddDirectorToMovieVariables({ - AddDirectorToMovieVariablesPersonId? this.personId, - String? this.movieId, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + this.personId, + + this.movieId, + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + + + } } + + + + + + + diff --git a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/add_person.dart b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/add_person.dart index 9d418952fcd1..89b6c851d1ae 100644 --- a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/add_person.dart +++ b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/add_person.dart @@ -4,16 +4,17 @@ class AddPerson { String name = "addPerson"; AddPerson({required this.dataConnect}); - Deserializer dataDeserializer = (String json) => - AddPersonResponse.fromJson(jsonDecode(json) as Map); + Deserializer dataDeserializer = (String json) => + AddPersonData.fromJson(jsonDecode(json) as Map); Serializer varsSerializer = (AddPersonVariables vars) => jsonEncode(vars.toJson()); - MutationRef ref( - {String? name, AddPersonVariables? addPersonVariables}) { - AddPersonVariables vars1 = AddPersonVariables( + MutationRef ref({ + String? name, + }) { + AddPersonVariables vars = AddPersonVariables( name: name, ); - AddPersonVariables vars = addPersonVariables ?? vars1; + return dataConnect.mutation( this.name, dataDeserializer, varsSerializer, vars); } @@ -22,15 +23,16 @@ class AddPerson { } class AddPersonPersonInsert { - late String id; + String id; - AddPersonPersonInsert.fromJson(Map json) : id = json['id'] {} + AddPersonPersonInsert.fromJson(Map json) + : id = nativeFromJson(json['id']) {} // TODO(mtewani): Fix up to create a map on the fly Map toJson() { Map json = {}; - json['id'] = id; + json['id'] = nativeToJson(id); return json; } @@ -42,10 +44,10 @@ class AddPersonPersonInsert { } } -class AddPersonResponse { - late AddPersonPersonInsert person_insert; +class AddPersonData { + AddPersonPersonInsert person_insert; - AddPersonResponse.fromJson(Map json) + AddPersonData.fromJson(Map json) : person_insert = AddPersonPersonInsert.fromJson(json['person_insert']) {} // TODO(mtewani): Fix up to create a map on the fly @@ -57,7 +59,7 @@ class AddPersonResponse { return json; } - AddPersonResponse({ + AddPersonData({ required this.person_insert, }) { // TODO(mtewani): Only show this if there are optional fields. @@ -65,24 +67,25 @@ class AddPersonResponse { } class AddPersonVariables { - late String? name; + String? name; - AddPersonVariables.fromJson(Map json) - : name = json['name'] {} + AddPersonVariables.fromJson(Map json) { + name = json['name'] == null ? null : nativeFromJson(json['name']); + } // TODO(mtewani): Fix up to create a map on the fly Map toJson() { Map json = {}; if (name != null) { - json['name'] = name; + json['name'] = nativeToJson(name); } return json; } AddPersonVariables({ - String? this.name, + this.name, }) { // TODO(mtewani): Only show this if there are optional fields. } diff --git a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/add_timestamp.dart b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/add_timestamp.dart new file mode 100644 index 000000000000..bd35b8a52f23 --- /dev/null +++ b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/add_timestamp.dart @@ -0,0 +1,193 @@ +part of movies; + + + + + + + +class AddTimestamp { + String name = "addTimestamp"; + AddTimestamp({required this.dataConnect}); + + Deserializer dataDeserializer = (String json) => AddTimestampData.fromJson(jsonDecode(json) as Map); + Serializer varsSerializer = (AddTimestampVariables vars) => jsonEncode(vars.toJson()); + MutationRef ref( + {required Timestamp timestamp,}) { + AddTimestampVariables vars=AddTimestampVariables(timestamp: timestamp,); + + return dataConnect.mutation(this.name, dataDeserializer, varsSerializer, vars); + } + FirebaseDataConnect dataConnect; +} + + + + + +class AddTimestampTimestampHolderInsert { + + + + + String id; + + + + + AddTimestampTimestampHolderInsert.fromJson(Map json): + id = + + nativeFromJson(json['id']) + + + + { + + + + } + + + // TODO(mtewani): Fix up to create a map on the fly + Map toJson() { + Map json = {}; + + + json['id'] = + + nativeToJson(id) + +; + + + return json; + } + + AddTimestampTimestampHolderInsert({ + + required this.id, + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + + } +} + + + + + + +class AddTimestampData { + + + + + AddTimestampTimestampHolderInsert timestampHolder_insert; + + + + + AddTimestampData.fromJson(Map json): + timestampHolder_insert = + + AddTimestampTimestampHolderInsert.fromJson(json['timestampHolder_insert']) + + + + { + + + + } + + + // TODO(mtewani): Fix up to create a map on the fly + Map toJson() { + Map json = {}; + + + json['timestampHolder_insert'] = + + timestampHolder_insert.toJson() + +; + + + return json; + } + + AddTimestampData({ + + required this.timestampHolder_insert, + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + + } +} + + + + + + +class AddTimestampVariables { + + + + + Timestamp timestamp; + + + + + AddTimestampVariables.fromJson(Map json): + timestamp = + + Timestamp.fromJson(json['timestamp']) + + + + { + + + + } + + + // TODO(mtewani): Fix up to create a map on the fly + Map toJson() { + Map json = {}; + + + json['timestamp'] = + + timestamp.toJson() + +; + + + return json; + } + + AddTimestampVariables({ + + required this.timestamp, + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + + } +} + + + + + + + diff --git a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/create_movie.dart b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/create_movie.dart index 6d1e020cce3b..cfcb50c5d214 100644 --- a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/create_movie.dart +++ b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/create_movie.dart @@ -1,125 +1,307 @@ part of movies; + + + + + + class CreateMovie { String name = "createMovie"; CreateMovie({required this.dataConnect}); - Deserializer dataDeserializer = (String json) => - CreateMovieResponse.fromJson(jsonDecode(json) as Map); - Serializer varsSerializer = - (CreateMovieVariables vars) => jsonEncode(vars.toJson()); - MutationRef ref( - {required String title, - required int releaseYear, - required String genre, - double? rating, - String? description, - CreateMovieVariables? createMovieVariables}) { - CreateMovieVariables vars1 = CreateMovieVariables( - title: title, - releaseYear: releaseYear, - genre: genre, - rating: rating, - description: description, - ); - CreateMovieVariables vars = createMovieVariables ?? vars1; - return dataConnect.mutation( - this.name, dataDeserializer, varsSerializer, vars); - } + Deserializer dataDeserializer = (String json) => CreateMovieData.fromJson(jsonDecode(json) as Map); + Serializer varsSerializer = (CreateMovieVariables vars) => jsonEncode(vars.toJson()); + MutationRef ref( + {required String title,required int releaseYear,required String genre,double? rating,String? description,}) { + CreateMovieVariables vars=CreateMovieVariables(title: title,releaseYear: releaseYear,genre: genre,rating: rating,description: description,); + return dataConnect.mutation(this.name, dataDeserializer, varsSerializer, vars); + } FirebaseDataConnect dataConnect; } + + + + class CreateMovieMovieInsert { - late String id; + + + + + String id; + + + + + CreateMovieMovieInsert.fromJson(Map json): + id = + + nativeFromJson(json['id']) + + + + { + + + + } - CreateMovieMovieInsert.fromJson(Map json) - : id = json['id'] {} // TODO(mtewani): Fix up to create a map on the fly Map toJson() { Map json = {}; - - json['id'] = id; - + + + json['id'] = + + nativeToJson(id) + +; + + return json; } CreateMovieMovieInsert({ + required this.id, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + } } -class CreateMovieResponse { - late CreateMovieMovieInsert movie_insert; - CreateMovieResponse.fromJson(Map json) - : movie_insert = CreateMovieMovieInsert.fromJson(json['movie_insert']) {} + + + + +class CreateMovieData { + + + + + CreateMovieMovieInsert movie_insert; + + + + + CreateMovieData.fromJson(Map json): + movie_insert = + + CreateMovieMovieInsert.fromJson(json['movie_insert']) + + + + { + + + + } + // TODO(mtewani): Fix up to create a map on the fly Map toJson() { Map json = {}; - - json['movie_insert'] = movie_insert.toJson(); - + + + json['movie_insert'] = + + movie_insert.toJson() + +; + + return json; } - CreateMovieResponse({ + CreateMovieData({ + required this.movie_insert, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + } } -class CreateMovieVariables { - late String title; - late int releaseYear; - late String genre; + - late double? rating; - late String? description; +class CreateMovieVariables { + + + + + String title; - CreateMovieVariables.fromJson(Map json) - : title = json['title'], - releaseYear = json['releaseYear'], - genre = json['genre'], - rating = json['rating'], - description = json['description'] {} + + + + + + int releaseYear; - // TODO(mtewani): Fix up to create a map on the fly - Map toJson() { - Map json = {}; + + + + + + String genre; - json['title'] = title; + + + + + + double? rating; - json['releaseYear'] = releaseYear; + + + + + + String? description; - json['genre'] = genre; + + + + CreateMovieVariables.fromJson(Map json): + title = + + nativeFromJson(json['title']) + - if (rating != null) { - json['rating'] = rating; - } + , + + releaseYear = + + nativeFromJson(json['releaseYear']) + - if (description != null) { - json['description'] = description; + , + + genre = + + nativeFromJson(json['genre']) + + + + { + + + + + + + + + rating = json['rating'] == null ? null : + + nativeFromJson(json['rating']) + +; + + + + description = json['description'] == null ? null : + + nativeFromJson(json['description']) + +; + + } + + // TODO(mtewani): Fix up to create a map on the fly + Map toJson() { + Map json = {}; + + + json['title'] = + + nativeToJson(title) + +; + + + + json['releaseYear'] = + + nativeToJson(releaseYear) + +; + + + + json['genre'] = + + nativeToJson(genre) + +; + + + + if (rating != null) { + json['rating'] = + + nativeToJson(rating) + +; + } + + + + if (description != null) { + json['description'] = + + nativeToJson(description) + +; + } + + return json; } CreateMovieVariables({ + required this.title, + required this.releaseYear, + required this.genre, - double? this.rating, - String? this.description, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + this.rating, + + this.description, + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + + + + + + + + + } } + + + + + + + diff --git a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/delete_movie.dart b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/delete_movie.dart index 5aeb6cdd1938..3657ca456fed 100644 --- a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/delete_movie.dart +++ b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/delete_movie.dart @@ -1,89 +1,194 @@ part of movies; + + + + + + class DeleteMovie { String name = "deleteMovie"; DeleteMovie({required this.dataConnect}); - Deserializer dataDeserializer = (String json) => - DeleteMovieResponse.fromJson(jsonDecode(json) as Map); - Serializer varsSerializer = - (DeleteMovieVariables vars) => jsonEncode(vars.toJson()); - MutationRef ref( - {required String id, DeleteMovieVariables? deleteMovieVariables}) { - DeleteMovieVariables vars1 = DeleteMovieVariables( - id: id, - ); - DeleteMovieVariables vars = deleteMovieVariables ?? vars1; - return dataConnect.mutation( - this.name, dataDeserializer, varsSerializer, vars); - } + Deserializer dataDeserializer = (String json) => DeleteMovieData.fromJson(jsonDecode(json) as Map); + Serializer varsSerializer = (DeleteMovieVariables vars) => jsonEncode(vars.toJson()); + MutationRef ref( + {required String id,}) { + DeleteMovieVariables vars=DeleteMovieVariables(id: id,); + return dataConnect.mutation(this.name, dataDeserializer, varsSerializer, vars); + } FirebaseDataConnect dataConnect; } + + + + class DeleteMovieMovieDelete { - late String id; + + + + + String id; + + + + + DeleteMovieMovieDelete.fromJson(Map json): + id = + + nativeFromJson(json['id']) + + + + { + + + + } - DeleteMovieMovieDelete.fromJson(Map json) - : id = json['id'] {} // TODO(mtewani): Fix up to create a map on the fly Map toJson() { Map json = {}; - - json['id'] = id; - + + + json['id'] = + + nativeToJson(id) + +; + + return json; } DeleteMovieMovieDelete({ + required this.id, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + } } -class DeleteMovieResponse { - late DeleteMovieMovieDelete? movie_delete; - DeleteMovieResponse.fromJson(Map json) - : movie_delete = DeleteMovieMovieDelete.fromJson(json['movie_delete']) {} - // TODO(mtewani): Fix up to create a map on the fly - Map toJson() { - Map json = {}; + + + +class DeleteMovieData { + + + + + DeleteMovieMovieDelete? movie_delete; - if (movie_delete != null) { - json['movie_delete'] = movie_delete!.toJson(); + + + + DeleteMovieData.fromJson(Map json) { + + + movie_delete = json['movie_delete'] == null ? null : + + DeleteMovieMovieDelete.fromJson(json['movie_delete']) + +; + + } + + // TODO(mtewani): Fix up to create a map on the fly + Map toJson() { + Map json = {}; + + + if (movie_delete != null) { + json['movie_delete'] = + + movie_delete!.toJson() + +; + } + + return json; } - DeleteMovieResponse({ - DeleteMovieMovieDelete? movie_delete, - }) { - // TODO(mtewani): Only show this if there are optional fields. + DeleteMovieData({ + + this.movie_delete, + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + } } + + + + + class DeleteMovieVariables { - late String id; + + + + + String id; + + + + + DeleteMovieVariables.fromJson(Map json): + id = + + nativeFromJson(json['id']) + + + + { + + + + } - DeleteMovieVariables.fromJson(Map json) : id = json['id'] {} // TODO(mtewani): Fix up to create a map on the fly Map toJson() { Map json = {}; - - json['id'] = id; - + + + json['id'] = + + nativeToJson(id) + +; + + return json; } DeleteMovieVariables({ + required this.id, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + } } + + + + + + + diff --git a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_movies.dart b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_movies.dart index 58e13493a23e..883b183503c5 100644 --- a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_movies.dart +++ b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_movies.dart @@ -1,97 +1,260 @@ part of movies; + + + + + + class ListMovies { String name = "ListMovies"; ListMovies({required this.dataConnect}); - Deserializer dataDeserializer = (String json) => - ListMoviesResponse.fromJson(jsonDecode(json) as Map); - - QueryRef ref() { - return dataConnect.query(this.name, dataDeserializer, null, null); + Deserializer dataDeserializer = (String json) => ListMoviesData.fromJson(jsonDecode(json) as Map); + + QueryRef ref( + ) { + + return dataConnect.query(this.name, dataDeserializer, emptySerializer, null); } - FirebaseDataConnect dataConnect; } + + + + class ListMoviesMovies { - late String id; + + + + + String id; - late String title; + + + + + + String title; - late List directed_by; + + + + + + List directed_by; - ListMoviesMovies.fromJson(Map json) - : id = json['id'], - title = json['title'], - directed_by = (json['directed_by'] as List) - .map((e) => ListMoviesMoviesDirectedBy.fromJson(e)) - .toList() {} + + + + ListMoviesMovies.fromJson(Map json): + id = + + nativeFromJson(json['id']) + - // TODO(mtewani): Fix up to create a map on the fly - Map toJson() { - Map json = {}; + , + + title = + + nativeFromJson(json['title']) + - json['id'] = id; + , + + directed_by = + + + (json['directed_by'] as List) + .map((e) => ListMoviesMoviesDirectedBy.fromJson(e)) + .toList() + + - json['title'] = title; + + { + + + + + + + + } - json['directed_by'] = directed_by.map((e) => e.toJson()).toList(); + // TODO(mtewani): Fix up to create a map on the fly + Map toJson() { + Map json = {}; + + + json['id'] = + + nativeToJson(id) + +; + + + + json['title'] = + + nativeToJson(title) + +; + + + + json['directed_by'] = + + + directed_by.map((e) => e.toJson()).toList() + + +; + + return json; } ListMoviesMovies({ + required this.id, + required this.title, + required this.directed_by, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + + + + + } } + + + + + class ListMoviesMoviesDirectedBy { - late String name; + + + + + String name; + + + + + ListMoviesMoviesDirectedBy.fromJson(Map json): + name = + + nativeFromJson(json['name']) + + + + { + + + + } - ListMoviesMoviesDirectedBy.fromJson(Map json) - : name = json['name'] {} // TODO(mtewani): Fix up to create a map on the fly Map toJson() { Map json = {}; - - json['name'] = name; - + + + json['name'] = + + nativeToJson(name) + +; + + return json; } ListMoviesMoviesDirectedBy({ + required this.name, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + } } -class ListMoviesResponse { - late List movies; - ListMoviesResponse.fromJson(Map json) - : movies = (json['movies'] as List) - .map((e) => ListMoviesMovies.fromJson(e)) - .toList() {} + + + + +class ListMoviesData { + + + + + List movies; + + + + + ListMoviesData.fromJson(Map json): + movies = + + + (json['movies'] as List) + .map((e) => ListMoviesMovies.fromJson(e)) + .toList() + + + + + { + + + + } + // TODO(mtewani): Fix up to create a map on the fly Map toJson() { Map json = {}; - - json['movies'] = movies.map((e) => e.toJson()).toList(); - + + + json['movies'] = + + + movies.map((e) => e.toJson()).toList() + + +; + + return json; } - ListMoviesResponse({ + ListMoviesData({ + required this.movies, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + } } + + + + + + + diff --git a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_movies_by_partial_title.dart b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_movies_by_partial_title.dart index f06a7f68d304..6fa2a3bd37f2 100644 --- a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_movies_by_partial_title.dart +++ b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_movies_by_partial_title.dart @@ -1,114 +1,284 @@ part of movies; + + + + + + class ListMoviesByPartialTitle { String name = "ListMoviesByPartialTitle"; ListMoviesByPartialTitle({required this.dataConnect}); - Deserializer dataDeserializer = - (String json) => ListMoviesByPartialTitleResponse.fromJson( - jsonDecode(json) as Map); - Serializer varsSerializer = - (ListMoviesByPartialTitleVariables vars) => jsonEncode(vars.toJson()); - QueryRef - ref( - {required String input, - ListMoviesByPartialTitleVariables? - listMoviesByPartialTitleVariables}) { - ListMoviesByPartialTitleVariables vars1 = ListMoviesByPartialTitleVariables( - input: input, - ); - ListMoviesByPartialTitleVariables vars = - listMoviesByPartialTitleVariables ?? vars1; + Deserializer dataDeserializer = (String json) => ListMoviesByPartialTitleData.fromJson(jsonDecode(json) as Map); + Serializer varsSerializer = (ListMoviesByPartialTitleVariables vars) => jsonEncode(vars.toJson()); + QueryRef ref( + {required String input,}) { + ListMoviesByPartialTitleVariables vars=ListMoviesByPartialTitleVariables(input: input,); + return dataConnect.query(this.name, dataDeserializer, varsSerializer, vars); } - FirebaseDataConnect dataConnect; } -class ListMoviesByPartialTitleMovies { - late String id; - late String title; + - late String genre; - late double? rating; +class ListMoviesByPartialTitleMovies { + + + + + String id; - ListMoviesByPartialTitleMovies.fromJson(Map json) - : id = json['id'], - title = json['title'], - genre = json['genre'], - rating = json['rating'] {} + + + + + + String title; - // TODO(mtewani): Fix up to create a map on the fly - Map toJson() { - Map json = {}; + + + + + + String genre; + + + + + + + double? rating; - json['id'] = id; + + + + ListMoviesByPartialTitleMovies.fromJson(Map json): + id = + + nativeFromJson(json['id']) + - json['title'] = title; + , + + title = + + nativeFromJson(json['title']) + - json['genre'] = genre; + , + + genre = + + nativeFromJson(json['genre']) + - if (rating != null) { - json['rating'] = rating; + + { + + + + + + + + + rating = json['rating'] == null ? null : + + nativeFromJson(json['rating']) + +; + + } + + // TODO(mtewani): Fix up to create a map on the fly + Map toJson() { + Map json = {}; + + + json['id'] = + + nativeToJson(id) + +; + + + + json['title'] = + + nativeToJson(title) + +; + + + + json['genre'] = + + nativeToJson(genre) + +; + + + + if (rating != null) { + json['rating'] = + + nativeToJson(rating) + +; + } + + return json; } ListMoviesByPartialTitleMovies({ + required this.id, + required this.title, + required this.genre, - double? rating, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + this.rating, + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + + + + + + + } } -class ListMoviesByPartialTitleResponse { - late List movies; - ListMoviesByPartialTitleResponse.fromJson(Map json) - : movies = (json['movies'] as List) - .map((e) => ListMoviesByPartialTitleMovies.fromJson(e)) - .toList() {} + + + + +class ListMoviesByPartialTitleData { + + + + + List movies; + + + + + ListMoviesByPartialTitleData.fromJson(Map json): + movies = + + + (json['movies'] as List) + .map((e) => ListMoviesByPartialTitleMovies.fromJson(e)) + .toList() + + + + + { + + + + } + // TODO(mtewani): Fix up to create a map on the fly Map toJson() { Map json = {}; - - json['movies'] = movies.map((e) => e.toJson()).toList(); - + + + json['movies'] = + + + movies.map((e) => e.toJson()).toList() + + +; + + return json; } - ListMoviesByPartialTitleResponse({ + ListMoviesByPartialTitleData({ + required this.movies, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + } } + + + + + class ListMoviesByPartialTitleVariables { - late String input; + + + + + String input; + + + + + ListMoviesByPartialTitleVariables.fromJson(Map json): + input = + + nativeFromJson(json['input']) + + + + { + + + + } - ListMoviesByPartialTitleVariables.fromJson(Map json) - : input = json['input'] {} // TODO(mtewani): Fix up to create a map on the fly Map toJson() { Map json = {}; - - json['input'] = input; - + + + json['input'] = + + nativeToJson(input) + +; + + return json; } ListMoviesByPartialTitleVariables({ + required this.input, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + } } + + + + + + + diff --git a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_persons.dart b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_persons.dart index 8a4d7e4cb0a6..622e554dcd9f 100644 --- a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_persons.dart +++ b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_persons.dart @@ -1,67 +1,171 @@ part of movies; + + + + + + class ListPersons { String name = "ListPersons"; ListPersons({required this.dataConnect}); - Deserializer dataDeserializer = (String json) => - ListPersonsResponse.fromJson(jsonDecode(json) as Map); - - QueryRef ref() { - return dataConnect.query(this.name, dataDeserializer, null, null); + Deserializer dataDeserializer = (String json) => ListPersonsData.fromJson(jsonDecode(json) as Map); + + QueryRef ref( + ) { + + return dataConnect.query(this.name, dataDeserializer, emptySerializer, null); } - FirebaseDataConnect dataConnect; } -class ListPersonsPeople { - late String id; - late String name; + + + +class ListPersonsPeople { + + + + + String id; + + + + + + + String name; + + + + + ListPersonsPeople.fromJson(Map json): + id = + + nativeFromJson(json['id']) + + + , + + name = + + nativeFromJson(json['name']) + + + + { + + + + + + } - ListPersonsPeople.fromJson(Map json) - : id = json['id'], - name = json['name'] {} // TODO(mtewani): Fix up to create a map on the fly Map toJson() { Map json = {}; - - json['id'] = id; - - json['name'] = name; - + + + json['id'] = + + nativeToJson(id) + +; + + + + json['name'] = + + nativeToJson(name) + +; + + return json; } ListPersonsPeople({ + required this.id, + required this.name, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + + + } } -class ListPersonsResponse { - late List people; - ListPersonsResponse.fromJson(Map json) - : people = (json['people'] as List) - .map((e) => ListPersonsPeople.fromJson(e)) - .toList() {} + + + + +class ListPersonsData { + + + + + List people; + + + + + ListPersonsData.fromJson(Map json): + people = + + + (json['people'] as List) + .map((e) => ListPersonsPeople.fromJson(e)) + .toList() + + + + + { + + + + } + // TODO(mtewani): Fix up to create a map on the fly Map toJson() { Map json = {}; - - json['people'] = people.map((e) => e.toJson()).toList(); - + + + json['people'] = + + + people.map((e) => e.toJson()).toList() + + +; + + return json; } - ListPersonsResponse({ + ListPersonsData({ + required this.people, - }) { - // TODO(mtewani): Only show this if there are optional fields. + + }) { // TODO(mtewani): Only show this if there are optional fields. + + + } } + + + + + + + diff --git a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_timestamps.dart b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_timestamps.dart new file mode 100644 index 000000000000..03827da22a93 --- /dev/null +++ b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/list_timestamps.dart @@ -0,0 +1,71 @@ +part of movies; + +class ListTimestamps { + String name = "ListTimestamps"; + ListTimestamps({required this.dataConnect}); + + Deserializer dataDeserializer = (String json) => + ListTimestampsData.fromJson(jsonDecode(json) as Map); + + QueryRef ref() { + return dataConnect.query( + this.name, dataDeserializer, emptySerializer, null); + } + + FirebaseDataConnect dataConnect; +} + +class ListTimestampsTimestampHolders { + Timestamp timestamp; + + DateTime? date; + + ListTimestampsTimestampHolders.fromJson(Map json) + : timestamp = Timestamp.fromJson(json['timestamp']) { + date = json['date'] == null ? null : nativeFromJson(json['date']); + } + + // TODO(mtewani): Fix up to create a map on the fly + Map toJson() { + Map json = {}; + + json['timestamp'] = timestamp.toJson(); + + if (date != null) { + json['date'] = nativeToJson(date); + } + + return json; + } + + ListTimestampsTimestampHolders({ + required this.timestamp, + this.date, + }) { + // TODO(mtewani): Only show this if there are optional fields. + } +} + +class ListTimestampsData { + List timestampHolders; + + ListTimestampsData.fromJson(Map json) + : timestampHolders = (json['timestampHolders'] as List) + .map((e) => ListTimestampsTimestampHolders.fromJson(e)) + .toList() {} + + // TODO(mtewani): Fix up to create a map on the fly + Map toJson() { + Map json = {}; + + json['timestampHolders'] = timestampHolders.map((e) => e.toJson()).toList(); + + return json; + } + + ListTimestampsData({ + required this.timestampHolders, + }) { + // TODO(mtewani): Only show this if there are optional fields. + } +} diff --git a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/movies.dart b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/movies.dart index 9c0f15b0ac39..067d78201f76 100644 --- a/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/movies.dart +++ b/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/movies.dart @@ -1,5 +1,4 @@ library movies; - import 'package:firebase_data_connect/firebase_data_connect.dart'; import 'dart:convert'; @@ -7,6 +6,10 @@ part 'add_person.dart'; part 'add_director_to_movie.dart'; +part 'add_timestamp.dart'; + +part 'add_date_and_timestamp.dart'; + part 'create_movie.dart'; part 'delete_movie.dart'; @@ -17,34 +20,52 @@ part 'list_movies_by_partial_title.dart'; part 'list_persons.dart'; +part 'list_timestamps.dart'; + + + class MoviesConnector { + AddPerson get addPerson { return AddPerson(dataConnect: dataConnect); } - + AddDirectorToMovie get addDirectorToMovie { return AddDirectorToMovie(dataConnect: dataConnect); } - + + AddTimestamp get addTimestamp { + return AddTimestamp(dataConnect: dataConnect); + } + + AddDateAndTimestamp get addDateAndTimestamp { + return AddDateAndTimestamp(dataConnect: dataConnect); + } + CreateMovie get createMovie { return CreateMovie(dataConnect: dataConnect); } - + DeleteMovie get deleteMovie { return DeleteMovie(dataConnect: dataConnect); } - + ListMovies get listMovies { return ListMovies(dataConnect: dataConnect); } - + ListMoviesByPartialTitle get listMoviesByPartialTitle { return ListMoviesByPartialTitle(dataConnect: dataConnect); } - + ListPersons get listPersons { return ListPersons(dataConnect: dataConnect); } + + ListTimestamps get listTimestamps { + return ListTimestamps(dataConnect: dataConnect); + } + static ConnectorConfig connectorConfig = ConnectorConfig( 'us-west2', @@ -61,3 +82,4 @@ class MoviesConnector { FirebaseDataConnect dataConnect; } + diff --git a/packages/firebase_data_connect/firebase_data_connect/example/lib/main.dart b/packages/firebase_data_connect/firebase_data_connect/example/lib/main.dart index 10da1ce05f60..ef1efe576e08 100644 --- a/packages/firebase_data_connect/firebase_data_connect/example/lib/main.dart +++ b/packages/firebase_data_connect/firebase_data_connect/example/lib/main.dart @@ -109,8 +109,14 @@ class _DataConnectWidgetState extends State { void initState() { super.initState(); - QueryRef ref = + QueryRef ref = MoviesConnector.instance.listMovies.ref(); + // MoviesConnector.instance.addDateAndTimestamp + // .ref(date: DateTime.now(), timestamp: Timestamp(123456789, 864000)) + // .execute(); + MoviesConnector.instance.listTimestamps.ref().execute().then((res) { + print(res.data.timestampHolders.first.toJson()); + }); ref.subscribe().listen((event) { setState(() { diff --git a/packages/firebase_data_connect/firebase_data_connect/lib/firebase_data_connect.dart b/packages/firebase_data_connect/firebase_data_connect/lib/firebase_data_connect.dart index 3befd9588c65..644c9b264867 100644 --- a/packages/firebase_data_connect/firebase_data_connect/lib/firebase_data_connect.dart +++ b/packages/firebase_data_connect/firebase_data_connect/lib/firebase_data_connect.dart @@ -5,6 +5,7 @@ library firebase_data_connect; import 'dart:async'; +import 'package:intl/intl.dart'; import 'package:firebase_app_check/firebase_app_check.dart'; import 'package:firebase_auth/firebase_auth.dart'; diff --git a/packages/firebase_data_connect/firebase_data_connect/lib/src/optional.dart b/packages/firebase_data_connect/firebase_data_connect/lib/src/optional.dart index ee054b97aa0e..de29c6b9c75b 100644 --- a/packages/firebase_data_connect/firebase_data_connect/lib/src/optional.dart +++ b/packages/firebase_data_connect/firebase_data_connect/lib/src/optional.dart @@ -65,11 +65,16 @@ class Optional { } } -String nativeToJson(T type) { - if (type is bool || type is int || type is double || type is num) { - return type.toString(); - } else if (type is String) { +dynamic nativeToJson(T type) { + if (type is bool || + type is int || + type is double || + type is num || + type is String) { return type; + } else if (type is DateTime) { + final DateFormat formatter = DateFormat('yyyy-MM-dd'); + return formatter.format(type); } else { throw UnimplementedError('This type is unimplemented: ${type.runtimeType}'); } @@ -81,6 +86,7 @@ T nativeFromJson(String json) { if (T == double) return double.parse(json) as T; if (T == num) return num.parse(json) as T; if (T == String) return json as T; + if (T == DateTime) return DateTime.parse(json) as T; throw UnimplementedError('This type is unimplemented: ${T.runtimeType}'); } diff --git a/packages/firebase_data_connect/firebase_data_connect/lib/src/timestamp.dart b/packages/firebase_data_connect/firebase_data_connect/lib/src/timestamp.dart index d4d5343f2a67..ea3f2f279931 100644 --- a/packages/firebase_data_connect/firebase_data_connect/lib/src/timestamp.dart +++ b/packages/firebase_data_connect/firebase_data_connect/lib/src/timestamp.dart @@ -13,7 +13,6 @@ class Timestamp { /// Constructor Timestamp(this.nanoseconds, this.seconds); - // TODO(mtewani): Fix this so that it keeps track of positional arguments so you don't have to repeatedly search the string multiple times. Timestamp.fromJson(String date) { if (!regex.hasMatch(date)) { throw Exception('Invalid Date provided!'); diff --git a/packages/firebase_data_connect/firebase_data_connect/pubspec.yaml b/packages/firebase_data_connect/firebase_data_connect/pubspec.yaml index 62a4f9ff61d8..8487ef22c7b4 100644 --- a/packages/firebase_data_connect/firebase_data_connect/pubspec.yaml +++ b/packages/firebase_data_connect/firebase_data_connect/pubspec.yaml @@ -19,6 +19,7 @@ dependencies: sdk: flutter grpc: ^3.2.4 http: ^1.2.1 + intl: ^0.19.0 protobuf: ^3.1.0 dev_dependencies: