diff --git a/crates/configuration/src/to_runtime_configuration.rs b/crates/configuration/src/to_runtime_configuration.rs index c83c655..8230861 100644 --- a/crates/configuration/src/to_runtime_configuration.rs +++ b/crates/configuration/src/to_runtime_configuration.rs @@ -16,7 +16,7 @@ pub fn make_runtime_configuration( parsed_config: ParsedConfiguration, environment: impl Environment, ) -> Result { - let connection_uri = match parsed_config.connection_uri { + let connection_uri = match parsed_config.service_key { ConnectionUri(Secret::Plain(uri)) => Ok(uri), ConnectionUri(Secret::FromEnvironment { variable }) => { environment.read(&variable).map_err(|error| { diff --git a/crates/configuration/src/version1.rs b/crates/configuration/src/version1.rs index f70a7b5..d408fce 100644 --- a/crates/configuration/src/version1.rs +++ b/crates/configuration/src/version1.rs @@ -27,7 +27,7 @@ use query_engine_metadata::metadata::{self, database, CompositeTypes, ScalarType const CURRENT_VERSION: u32 = 1; pub const CONFIGURATION_FILENAME: &str = "configuration.json"; -pub const DEFAULT_CONNECTION_URI_VARIABLE: &str = "CONNECTION_URI"; +pub const DEFAULT_CONNECTION_URI_VARIABLE: &str = "HASURA_BIGQUERY_SERVICE_KEY"; const CONFIGURATION_QUERY: &str = include_str!("config2.sql"); const CONFIGURATION_JSONSCHEMA_FILENAME: &str = "schema.json"; @@ -58,7 +58,7 @@ pub struct ParsedConfiguration { // Which version of the configuration format are we using pub version: u32, // Connection string for a Postgres-compatible database - pub connection_uri: ConnectionUri, + pub service_key: ConnectionUri, #[serde(skip_serializing_if = "PoolSettings::is_default")] #[serde(default)] pub pool_settings: PoolSettings, @@ -166,7 +166,7 @@ impl ParsedConfiguration { pub fn empty() -> Self { Self { version: CURRENT_VERSION, - connection_uri: ConnectionUri(Secret::FromEnvironment { + service_key: ConnectionUri(Secret::FromEnvironment { variable: DEFAULT_CONNECTION_URI_VARIABLE.into(), }), pool_settings: PoolSettings::default(), @@ -355,7 +355,7 @@ pub async fn configure( // configuration_query: &str, ) -> anyhow::Result { // dbg!(args); - let uri = match &args.connection_uri { + let uri = match &args.service_key { ConnectionUri(Secret::Plain(value)) => Cow::Borrowed(value), ConnectionUri(Secret::FromEnvironment { variable }) => { Cow::Owned(environment.read(variable)?) @@ -524,7 +524,7 @@ pub async fn configure( Ok(ParsedConfiguration { version: 1, - connection_uri: args.connection_uri.clone(), + service_key: args.service_key.clone(), pool_settings: args.pool_settings.clone(), metadata: metadata::Metadata { tables: tables_info, diff --git a/crates/connectors/ndc-bigquery/tests/configuration_tests.rs b/crates/connectors/ndc-bigquery/tests/configuration_tests.rs index aa9c4ab..a0727cb 100644 --- a/crates/connectors/ndc-bigquery/tests/configuration_tests.rs +++ b/crates/connectors/ndc-bigquery/tests/configuration_tests.rs @@ -36,7 +36,7 @@ async fn test_configure() { POSTGRESQL_CONNECTION_STRING.into(), )]); - args.connection_uri = + args.service_key = ConnectionUri(Secret::Plain((POSTGRESQL_CONNECTION_STRING.to_string()))); let actual = version1::configure(&args, environment) diff --git a/test1/configuration.json b/test1/configuration.json new file mode 100644 index 0000000..8195d21 --- /dev/null +++ b/test1/configuration.json @@ -0,0 +1,973 @@ +{ + "version": 1, + "service_key": { + "variable": "HASURA_BIGQUERY_SERVICE_KEY" + }, + "metadata": { + "tables": { + "albums": { + "schemaName": "hasura-development.chinook_sample", + "tableName": "albums", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "Title": { + "name": "Title", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, + "artists": { + "schemaName": "hasura-development.chinook_sample", + "tableName": "artists", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "Name": { + "name": "Name", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, + "customers": { + "schemaName": "hasura-development.chinook_sample", + "tableName": "customers", + "columns": { + "Address": { + "name": "Address", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "City": { + "name": "City", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "Company": { + "name": "Company", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "Country": { + "name": "Country", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "CustomerId": { + "name": "CustomerId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "Email": { + "name": "Email", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "Fax": { + "name": "Fax", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "FirstName": { + "name": "FirstName", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "LastName": { + "name": "LastName", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "Phone": { + "name": "Phone", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "PostalCode": { + "name": "PostalCode", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "State": { + "name": "State", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "SupportRepId": { + "name": "SupportRepId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, + "employees": { + "schemaName": "hasura-development.chinook_sample", + "tableName": "employees", + "columns": { + "Address": { + "name": "Address", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "BirthDate": { + "name": "BirthDate", + "type": { + "ScalarType": "DATE" + }, + "nullable": "nullable", + "description": null + }, + "City": { + "name": "City", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "Country": { + "name": "Country", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "Email": { + "name": "Email", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "EmployeeId": { + "name": "EmployeeId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "Fax": { + "name": "Fax", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "FirstName": { + "name": "FirstName", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "HireDate": { + "name": "HireDate", + "type": { + "ScalarType": "DATE" + }, + "nullable": "nullable", + "description": null + }, + "LastName": { + "name": "LastName", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "Phone": { + "name": "Phone", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "PostalCode": { + "name": "PostalCode", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "ReportsTo": { + "name": "ReportsTo", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "State": { + "name": "State", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "Title": { + "name": "Title", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, + "genres": { + "schemaName": "hasura-development.chinook_sample", + "tableName": "genres", + "columns": { + "GenreId": { + "name": "GenreId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "Name": { + "name": "Name", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, + "invoice_items": { + "schemaName": "hasura-development.chinook_sample", + "tableName": "invoice_items", + "columns": { + "InvoiceId": { + "name": "InvoiceId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "InvoiceLineId": { + "name": "InvoiceLineId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "Quantity": { + "name": "Quantity", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "TrackId": { + "name": "TrackId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "UnitPrice": { + "name": "UnitPrice", + "type": { + "ScalarType": "FLOAT64" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, + "invoices": { + "schemaName": "hasura-development.chinook_sample", + "tableName": "invoices", + "columns": { + "BillingAddress": { + "name": "BillingAddress", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "BillingCity": { + "name": "BillingCity", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "BillingCountry": { + "name": "BillingCountry", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "BillingPostalCode": { + "name": "BillingPostalCode", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "BillingState": { + "name": "BillingState", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "CustomerId": { + "name": "CustomerId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "InvoiceDate": { + "name": "InvoiceDate", + "type": { + "ScalarType": "DATE" + }, + "nullable": "nullable", + "description": null + }, + "InvoiceId": { + "name": "InvoiceId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "Total": { + "name": "Total", + "type": { + "ScalarType": "FLOAT64" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, + "media_types": { + "schemaName": "hasura-development.chinook_sample", + "tableName": "media_types", + "columns": { + "MediaTypeId": { + "name": "MediaTypeId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "Name": { + "name": "Name", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, + "playlist_track": { + "schemaName": "hasura-development.chinook_sample", + "tableName": "playlist_track", + "columns": { + "PlaylistId": { + "name": "PlaylistId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "TrackId": { + "name": "TrackId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, + "playlists": { + "schemaName": "hasura-development.chinook_sample", + "tableName": "playlists", + "columns": { + "Name": { + "name": "Name", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "PlaylistId": { + "name": "PlaylistId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, + "test_table": { + "schemaName": "hasura-development.chinook_sample", + "tableName": "test_table", + "columns": { + "album_id": { + "name": "album_id", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "id": { + "name": "id", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": { + "test_table.pk$": [ + "id" + ] + }, + "foreignRelations": { + "test_table.fk$1": { + "foreign_schema": null, + "foreign_table": "test_table_2", + "column_mapping": { + "album_id": "id" + } + }, + "test_table.fk$2": { + "foreign_schema": null, + "foreign_table": "test_table_3", + "column_mapping": { + "album_id": "id" + } + } + }, + "description": null + }, + "test_table_2": { + "schemaName": "hasura-development.chinook_sample", + "tableName": "test_table_2", + "columns": { + "album_id": { + "name": "album_id", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "id": { + "name": "id", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": { + "test_table_2.pk$": [ + "id" + ] + }, + "foreignRelations": {}, + "description": null + }, + "test_table_3": { + "schemaName": "hasura-development.chinook_sample", + "tableName": "test_table_3", + "columns": { + "album_id3": { + "name": "album_id3", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "id": { + "name": "id", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": { + "test_table_3.pk$": [ + "id" + ] + }, + "foreignRelations": {}, + "description": null + }, + "tracks": { + "schemaName": "hasura-development.chinook_sample", + "tableName": "tracks", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "Bytes": { + "name": "Bytes", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "Composer": { + "name": "Composer", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "GenreId": { + "name": "GenreId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "MediaTypeId": { + "name": "MediaTypeId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "Milliseconds": { + "name": "Milliseconds", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "Name": { + "name": "Name", + "type": { + "ScalarType": "STRING" + }, + "nullable": "nullable", + "description": null + }, + "TrackId": { + "name": "TrackId", + "type": { + "ScalarType": "INT64" + }, + "nullable": "nullable", + "description": null + }, + "UnitPrice": { + "name": "UnitPrice", + "type": { + "ScalarType": "FLOAT64" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + } + }, + "native_operations": { + "queries": {}, + "mutations": {} + }, + "scalar_types": { + "DATE": { + "typeName": "DATE", + "schemaName": "hasura-development.chinook_sample", + "description": null, + "aggregateFunctions": { + "APPROX_COUNT_DISTINCT": { + "returnType": "bigint" + }, + "COUNT": { + "returnType": "int" + }, + "COUNT_BIG": { + "returnType": "bigint" + } + }, + "comparisonOperators": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "DATE", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "DATE", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "DATE", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "DATE", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "DATE", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "DATE", + "isInfix": true + }, + "_neq": { + "operatorName": "!=", + "operatorKind": "custom", + "argumentType": "DATE", + "isInfix": true + } + }, + "typeRepresentation": null + }, + "FLOAT64": { + "typeName": "FLOAT64", + "schemaName": "hasura-development.chinook_sample", + "description": null, + "aggregateFunctions": { + "APPROX_COUNT_DISTINCT": { + "returnType": "bigint" + }, + "COUNT": { + "returnType": "int" + }, + "COUNT_BIG": { + "returnType": "bigint" + } + }, + "comparisonOperators": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "FLOAT64", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "FLOAT64", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "FLOAT64", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "FLOAT64", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "FLOAT64", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "FLOAT64", + "isInfix": true + }, + "_neq": { + "operatorName": "!=", + "operatorKind": "custom", + "argumentType": "FLOAT64", + "isInfix": true + } + }, + "typeRepresentation": null + }, + "INT64": { + "typeName": "INT64", + "schemaName": "hasura-development.chinook_sample", + "description": null, + "aggregateFunctions": { + "APPROX_COUNT_DISTINCT": { + "returnType": "bigint" + }, + "COUNT": { + "returnType": "int" + }, + "COUNT_BIG": { + "returnType": "bigint" + } + }, + "comparisonOperators": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "INT64", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "INT64", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "INT64", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "INT64", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "INT64", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "INT64", + "isInfix": true + }, + "_neq": { + "operatorName": "!=", + "operatorKind": "custom", + "argumentType": "INT64", + "isInfix": true + } + }, + "typeRepresentation": null + }, + "STRING": { + "typeName": "STRING", + "schemaName": "hasura-development.chinook_sample", + "description": null, + "aggregateFunctions": { + "APPROX_COUNT_DISTINCT": { + "returnType": "bigint" + }, + "COUNT": { + "returnType": "int" + }, + "COUNT_BIG": { + "returnType": "bigint" + } + }, + "comparisonOperators": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "STRING", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "STRING", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "STRING", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "STRING", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "STRING", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "STRING", + "isInfix": true + }, + "_neq": { + "operatorName": "!=", + "operatorKind": "custom", + "argumentType": "STRING", + "isInfix": true + } + }, + "typeRepresentation": null + } + } + } +} diff --git a/test1/schema.json b/test1/schema.json new file mode 100644 index 0000000..9d647d6 --- /dev/null +++ b/test1/schema.json @@ -0,0 +1,857 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ParsedConfiguration", + "description": "Initial configuration, just enough to connect to a database and elaborate a full 'Configuration'.", + "type": "object", + "required": [ + "service_key", + "version" + ], + "properties": { + "version": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "service_key": { + "$ref": "#/definitions/ConnectionUri" + }, + "pool_settings": { + "$ref": "#/definitions/PoolSettings" + }, + "metadata": { + "default": { + "tables": {}, + "native_operations": { + "queries": {}, + "mutations": {} + }, + "scalar_types": {} + }, + "allOf": [ + { + "$ref": "#/definitions/Metadata" + } + ] + } + }, + "definitions": { + "ConnectionUri": { + "$ref": "#/definitions/Secret" + }, + "Secret": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "required": [ + "variable" + ], + "properties": { + "variable": { + "$ref": "#/definitions/Variable" + } + } + } + ] + }, + "Variable": { + "description": "The name of an an environment variable.", + "type": "string" + }, + "PoolSettings": { + "description": "Settings for the PostgreSQL connection pool", + "type": "object", + "properties": { + "max_connections": { + "description": "maximum number of pool connections", + "default": 50, + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "pool_timeout": { + "description": "timeout for acquiring a connection from the pool (seconds)", + "default": 600, + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "idle_timeout": { + "description": "idle timeout for releasing a connection from the pool (seconds)", + "default": 180, + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + }, + "connection_lifetime": { + "description": "maximum lifetime for an individual connection (seconds)", + "default": 600, + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Metadata": { + "description": "Metadata information.", + "type": "object", + "required": [ + "native_operations", + "scalar_types", + "tables" + ], + "properties": { + "tables": { + "$ref": "#/definitions/TablesInfo" + }, + "native_operations": { + "$ref": "#/definitions/NativeOperations" + }, + "scalar_types": { + "$ref": "#/definitions/ScalarTypes" + } + } + }, + "TablesInfo": { + "description": "Mapping from a \"table\" name to its information.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/TableInfo" + } + }, + "TableInfo": { + "description": "Information about a database table (or any other kind of relation).", + "type": "object", + "required": [ + "columns", + "foreignRelations", + "schemaName", + "tableName", + "uniquenessConstraints" + ], + "properties": { + "schemaName": { + "type": "string" + }, + "tableName": { + "type": "string" + }, + "columns": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/ColumnInfo" + } + }, + "uniquenessConstraints": { + "$ref": "#/definitions/UniquenessConstraints" + }, + "foreignRelations": { + "$ref": "#/definitions/ForeignRelations" + }, + "description": { + "type": [ + "string", + "null" + ] + } + } + }, + "ColumnInfo": { + "description": "Information about a database column.", + "type": "object", + "required": [ + "name", + "type" + ], + "properties": { + "name": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/Type" + }, + "nullable": { + "default": "nullable", + "allOf": [ + { + "$ref": "#/definitions/Nullable" + } + ] + }, + "hasDefault": { + "$ref": "#/definitions/HasDefault" + }, + "isIdentity": { + "$ref": "#/definitions/IsIdentity" + }, + "isGenerated": { + "$ref": "#/definitions/IsGenerated" + }, + "description": { + "default": null, + "type": [ + "string", + "null" + ] + } + } + }, + "Type": { + "description": "The type of values that a column, field, or argument may take.", + "oneOf": [ + { + "type": "object", + "required": [ + "ScalarType" + ], + "properties": { + "ScalarType": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "CompositeType" + ], + "properties": { + "CompositeType": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "ArrayType" + ], + "properties": { + "ArrayType": { + "$ref": "#/definitions/Type" + } + }, + "additionalProperties": false + } + ] + }, + "Nullable": { + "description": "Can this column contain null values", + "type": "string", + "enum": [ + "nullable", + "nonNullable" + ] + }, + "HasDefault": { + "description": "Does this column have a default value.", + "type": "string", + "enum": [ + "noDefault", + "hasDefault" + ] + }, + "IsIdentity": { + "description": "Is this column an identity column.", + "type": "string", + "enum": [ + "notIdentity", + "identityByDefault", + "identityAlways" + ] + }, + "IsGenerated": { + "description": "Is this column a generated column.", + "type": "string", + "enum": [ + "notGenerated", + "stored" + ] + }, + "UniquenessConstraints": { + "description": "A mapping from the name of a unique constraint to its value.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/UniquenessConstraint" + } + }, + "UniquenessConstraint": { + "description": "The set of columns that make up a uniqueness constraint.", + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "ForeignRelations": { + "description": "A mapping from the name of a foreign key constraint to its value.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/ForeignRelation" + } + }, + "ForeignRelation": { + "description": "A foreign key constraint.", + "type": "object", + "required": [ + "column_mapping", + "foreign_table" + ], + "properties": { + "foreign_schema": { + "type": [ + "string", + "null" + ] + }, + "foreign_table": { + "type": "string" + }, + "column_mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "NativeOperations": { + "description": "Metadata information of native queries.", + "type": "object", + "required": [ + "mutations", + "queries" + ], + "properties": { + "queries": { + "$ref": "#/definitions/NativeQueries" + }, + "mutations": { + "$ref": "#/definitions/NativeMutations" + } + } + }, + "NativeQueries": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/NativeQueryInfo" + } + }, + "NativeQueryInfo": { + "description": "Information about a Native Query", + "type": "object", + "required": [ + "arguments", + "columns", + "sql" + ], + "properties": { + "sql": { + "description": "SQL expression to use for the Native Query. We can interpolate values using `{{variable_name}}` syntax, such as `SELECT * FROM authors WHERE name = {{author_name}}`", + "allOf": [ + { + "$ref": "#/definitions/NativeQuerySqlEither" + } + ] + }, + "columns": { + "description": "Columns returned by the Native Query", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/ReadOnlyColumnInfo" + } + }, + "arguments": { + "description": "Names and types of arguments that can be passed to this Native Query", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/ReadOnlyColumnInfo" + } + }, + "description": { + "type": [ + "string", + "null" + ] + } + } + }, + "NativeQuerySqlEither": { + "description": "This type contains information that still needs to be resolved. After deserializing, we expect the value to be \"external\", and after a subsequent step where we read from files, they should all be converted to NativeQuerySql.", + "oneOf": [ + { + "type": "object", + "required": [ + "NativeQuerySql" + ], + "properties": { + "NativeQuerySql": { + "$ref": "#/definitions/NativeQuerySql" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "NativeQuerySqlExternal" + ], + "properties": { + "NativeQuerySqlExternal": { + "$ref": "#/definitions/NativeQuerySqlExternal" + } + }, + "additionalProperties": false + } + ] + }, + "NativeQuerySql": { + "description": "A Native Query SQL after file resolution. This is the underlying type of the `NativeQuerySqlEither` variant with the same name that is expected in the metadata when translating requests. A subsequent phase after de-serializing Should convert NativeQuerySqlExternal values to values of this type.", + "oneOf": [ + { + "type": "object", + "required": [ + "FromFile" + ], + "properties": { + "FromFile": { + "type": "object", + "required": [ + "file", + "sql" + ], + "properties": { + "file": { + "type": "string" + }, + "sql": { + "$ref": "#/definitions/NativeQueryParts" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "Inline" + ], + "properties": { + "Inline": { + "type": "object", + "required": [ + "sql" + ], + "properties": { + "sql": { + "$ref": "#/definitions/NativeQueryParts" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "NativeQueryParts": { + "description": "A Native Query SQL parts after parsing.", + "type": "array", + "items": { + "$ref": "#/definitions/NativeQueryPart" + } + }, + "NativeQueryPart": { + "description": "A part of a Native Query text, either raw text or a parameter.", + "oneOf": [ + { + "description": "A raw text part", + "type": "object", + "required": [ + "Text" + ], + "properties": { + "Text": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "description": "A parameter", + "type": "object", + "required": [ + "Parameter" + ], + "properties": { + "Parameter": { + "type": "string" + } + }, + "additionalProperties": false + } + ] + }, + "NativeQuerySqlExternal": { + "description": "Native Query SQL location.", + "oneOf": [ + { + "description": "Refer to an external Native Query SQL file.", + "type": "object", + "required": [ + "File" + ], + "properties": { + "File": { + "type": "object", + "required": [ + "file" + ], + "properties": { + "file": { + "description": "Relative path to a sql file.", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Inline Native Query SQL string.", + "type": "object", + "required": [ + "Inline" + ], + "properties": { + "Inline": { + "type": "object", + "required": [ + "inline" + ], + "properties": { + "inline": { + "description": "An inline Native Query SQL string.", + "allOf": [ + { + "$ref": "#/definitions/NativeQueryParts" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "InlineUntagged" + ], + "properties": { + "InlineUntagged": { + "$ref": "#/definitions/NativeQueryParts" + } + }, + "additionalProperties": false + } + ] + }, + "ReadOnlyColumnInfo": { + "description": "Information about a native query column.", + "type": "object", + "required": [ + "name", + "nullable", + "type" + ], + "properties": { + "name": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/Type" + }, + "nullable": { + "$ref": "#/definitions/Nullable" + }, + "description": { + "type": [ + "string", + "null" + ] + } + } + }, + "NativeMutations": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/NativeQueryInfo" + } + }, + "ScalarTypes": { + "description": "Map of all known/occurring scalar types.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/ScalarType" + } + }, + "ScalarType": { + "description": "Information about a scalar type. A scalar type is completely characterized by its name and the operations you can do on it.", + "type": "object", + "required": [ + "aggregateFunctions", + "comparisonOperators", + "typeName" + ], + "properties": { + "typeName": { + "type": "string" + }, + "schemaName": { + "type": [ + "string", + "null" + ] + }, + "description": { + "type": [ + "string", + "null" + ] + }, + "aggregateFunctions": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/AggregateFunction" + } + }, + "comparisonOperators": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/ComparisonOperator" + } + }, + "typeRepresentation": { + "anyOf": [ + { + "$ref": "#/definitions/TypeRepresentation" + }, + { + "type": "null" + } + ] + } + } + }, + "AggregateFunction": { + "type": "object", + "required": [ + "returnType" + ], + "properties": { + "returnType": { + "type": "string" + } + } + }, + "ComparisonOperator": { + "description": "Represents a postgres binary comparison operator", + "type": "object", + "required": [ + "argumentType", + "isInfix", + "operatorKind", + "operatorName" + ], + "properties": { + "operatorName": { + "type": "string" + }, + "operatorKind": { + "$ref": "#/definitions/OperatorKind" + }, + "argumentType": { + "type": "string" + }, + "isInfix": { + "type": "boolean" + } + } + }, + "OperatorKind": { + "description": "Is it a built-in operator, or a custom operator.", + "type": "string", + "enum": [ + "equal", + "in", + "custom" + ] + }, + "TypeRepresentation": { + "description": "Type representation of a scalar type.", + "oneOf": [ + { + "description": "JSON booleans", + "type": "string", + "enum": [ + "boolean" + ] + }, + { + "description": "Any JSON string", + "type": "string", + "enum": [ + "string" + ] + }, + { + "description": "float4", + "type": "string", + "enum": [ + "float32" + ] + }, + { + "description": "float8", + "type": "string", + "enum": [ + "float64" + ] + }, + { + "description": "int2", + "type": "string", + "enum": [ + "int16" + ] + }, + { + "description": "int4", + "type": "string", + "enum": [ + "int32" + ] + }, + { + "description": "int8 as integer", + "type": "string", + "enum": [ + "int64" + ] + }, + { + "description": "int8 as string", + "type": "string", + "enum": [ + "int64AsString" + ] + }, + { + "description": "numeric", + "type": "string", + "enum": [ + "bigDecimal" + ] + }, + { + "description": "numeric as string", + "type": "string", + "enum": [ + "bigDecimalAsString" + ] + }, + { + "description": "timestamp", + "type": "string", + "enum": [ + "timestamp" + ] + }, + { + "description": "timestamp with timezone", + "type": "string", + "enum": [ + "timestamptz" + ] + }, + { + "description": "time", + "type": "string", + "enum": [ + "time" + ] + }, + { + "description": "time with timezone", + "type": "string", + "enum": [ + "timetz" + ] + }, + { + "description": "date", + "type": "string", + "enum": [ + "date" + ] + }, + { + "description": "uuid", + "type": "string", + "enum": [ + "uUID" + ] + }, + { + "description": "geography", + "type": "string", + "enum": [ + "geography" + ] + }, + { + "description": "geometry", + "type": "string", + "enum": [ + "geometry" + ] + }, + { + "description": "An arbitrary json.", + "type": "string", + "enum": [ + "json" + ] + }, + { + "description": "One of the specified string values", + "type": "object", + "required": [ + "enum" + ], + "properties": { + "enum": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false + } + ] + } + } +}